History log of /openbsd-current/sys/dev/pci/if_oce.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.109 24-May-2024 jsg

remove unneeded includes; ok miod@


Revision tags: OPENBSD_7_5_BASE
# 1.108 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither
uses WRITE_ONCE() nor a mutex and is called before the ifq mutex
is initialized. The new name expresses that it should be used only
during interface attach when there is no concurrency.

Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with
READ_ONCE(). They can be used without lock as they only read a
single integer.

OK dlg@


Revision tags: OPENBSD_7_4_BASE
# 1.107 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.106 11-Mar-2022 mpi

Constify struct cfattach.


# 1.105 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.104 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


Revision tags: OPENBSD_6_8_BASE
# 1.103 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.102 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


# 1.101 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.100 27-Nov-2017 sthen

lenght->length, mostly in comments


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.99 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


# 1.98 15-Sep-2016 dlg

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);


# 1.97 14-Sep-2016 mikeb

Declare the type instead of a on-stack variable for sizeof purposes

(Un?)surprisingly the compiler is smart enough to produce the same
code in both cases, but this conveys the intention better.


# 1.96 24-Aug-2016 dlg

pool_setipl for oce(4)

ok mikeb@


Revision tags: OPENBSD_6_0_BASE
# 1.95 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.94 14-Mar-2016 mikeb

Allocate statistics command from the heap, pointed out by deraadt@


# 1.93 04-Mar-2016 deraadt

extra ) not needed, spotted by tiago silva


Revision tags: OPENBSD_5_9_BASE
# 1.92 06-Jan-2016 mikeb

revert 1.87, more work is needed here


# 1.91 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.90 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.89 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.88 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.87 29-Sep-2015 chris

Unlock interrupt handler rx path with intr_barrier

ok mikeb@


# 1.86 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.85 29-Jun-2015 mikeb

Hide ETHER_ALIGN mbuf adjustment under "#ifdef __STRICT_ALIGNMENT"
for now to get jumbo frames working. oce(4) will need the same
treatment as ix(4) when sparc64 support will be implemented.

Tested by Pedro Caetano <pedrocaetano at binaryflows ! com>, thanks!


# 1.84 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.83 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


# 1.82 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.81 22-Dec-2014 tedu

unifdef INET


# 1.80 13-Dec-2014 doug

yet more mallocarray() changes.

ok tedu@ deraadt@


# 1.79 30-Aug-2014 dlg

let the mru always be what the chip can do, not what the mtu implies.

tested by and ok mikeb@


# 1.78 14-Aug-2014 mikeb

Implement rxrinfo ioctl for cluster usage statistics


Revision tags: OPENBSD_5_6_BASE
# 1.77 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.76 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.75 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


Revision tags: OPENBSD_5_5_BASE
# 1.74 20-Jan-2014 chris

bcopy to memcpy

ok mikeb@


# 1.73 20-Jan-2014 chris

bcmp to memcmp

ok mikeb@


# 1.72 20-Jan-2014 chris

bzero to memset

ok mikeb@


# 1.71 23-Aug-2013 mikeb

don't call if_link_state_change if link state is not changed


# 1.70 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.69 17-Jan-2013 henning

first or second coming, commie or not commie, one m in coming is sufficient
ok claudio


# 1.68 10-Dec-2012 mikeb

adjust mbuf chain data pointer so that ip header would appear
word aligned; remove pool constraints insanity while here


# 1.67 27-Nov-2012 gsoares

fix format string; OK mikeb@


# 1.66 26-Nov-2012 mikeb

shorten MBX_RX_IFACE_* defines


# 1.65 26-Nov-2012 mikeb

get rid of some useless bitfields in oce_mbx and mbx_hdr


# 1.64 23-Nov-2012 mikeb

better way to set baudrate to 0; pointed out by gsoares@


# 1.63 21-Nov-2012 mikeb

Don't forget to delete an rx refill timeout when bringing
an interface down (noticed by dlg@ in the other diff).
While here, do some minor cleanup in the interrupt handler.


# 1.62 20-Nov-2012 mikeb

fix typo


# 1.61 14-Nov-2012 mikeb

allocate a mailbox payload dma memory upfront instead of per request


# 1.60 13-Nov-2012 mikeb

do an OACTIVE/if_start dance only once per tx interrupt


# 1.59 13-Nov-2012 mikeb

enable hardware tx checksum offloading as oce doesn't
seem to require an initialized pseudo-header checksum


# 1.58 13-Nov-2012 mikeb

more cleanup missed in the previous commit


# 1.57 13-Nov-2012 mikeb

major cleanup; get rid of the oce_destroy_queue


# 1.56 12-Nov-2012 mikeb

move some stuff around, do minor cleanup


# 1.55 09-Nov-2012 mikeb

don't sync dma memory for the whole ring when updating a single
entry but rather sync the whole ring once done with individual
entries; use proper dma sync flags as well


# 1.54 09-Nov-2012 mikeb

merge if_ocevar.h and if_oce.c; do some minor cleanup while here


# 1.53 09-Nov-2012 mikeb

cleanup oce_encap


# 1.52 09-Nov-2012 mikeb

stop passing if_id around


# 1.51 09-Nov-2012 mikeb

improve flow control code


# 1.50 09-Nov-2012 mikeb

To be able to receive ethernet packets with VLAN tags oce_set_promisc
should not disable VLAN promiscuous mode set up by oce_config_vlan.
Move VLAN and Flow Control configuration to oce_init so that it would
be rerun every time we plumb the interface.


# 1.49 08-Nov-2012 mikeb

make link state update code more comprehensible by using some ideas from myx(4)


# 1.48 08-Nov-2012 mikeb

hardware supports mtu values from 256 up to 9000;
figured out the hard way, linux driver agrees


# 1.47 08-Nov-2012 mikeb

When halting the rx engine wait 1ms after destroying the queue in
firmware then drain the completion queue and only afterwards deal
with posted buffers so that the firmware wouldn't decide to DMA
something into the freed cluster. Logic from the Linux driver.


# 1.46 08-Nov-2012 mikeb

minor style cleanup, improve the mailbox timeout printf


# 1.45 08-Nov-2012 mikeb

Hide stats calculation ugliness inside oce_update_stats and
don't schedule another update if the one at hand fails.
s/oce_local_timer/oce_tick/ while here (:


# 1.44 07-Nov-2012 mikeb

minor tweaks to the ioctl code


# 1.43 07-Nov-2012 mikeb

do not depend on IFCAP_CSUM flags set when reading rx checksumming
results from the hardware


# 1.42 07-Nov-2012 mikeb

we still need to query the firmware for a couple of values after all


# 1.41 05-Nov-2012 mikeb

Steal SIMPLEQ-based packet descriptor managing code from myx(4)
to simplify a whole bunch of things. And despite this being the
main purpose of the commit I'm also sneaking in loads of minor
and unrelated cleanup since separating it out would be just too
much work. Enjoy!


# 1.40 03-Nov-2012 mikeb

s/OCE_DMAPTR/OCE_MEM_KVA/ and don't require a type


# 1.39 03-Nov-2012 brynet

Obligatory second oce commit for tonight. No binary change.

ok mikeb@


# 1.38 02-Nov-2012 mikeb

Introduce better and simpler producer/consumer queue iterator
implementation that is usable for both producer (rq, wq, mq)
and consumer (eq, cq) rings.


# 1.37 31-Oct-2012 mikeb

minor style cleanup


# 1.36 30-Oct-2012 mikeb

introduce specialized register read and write functions
oce_{read,write}_{cfg,csr,db} for different pci bars


# 1.35 29-Oct-2012 mikeb

prefer to return oce_cmd and save on the error variable


# 1.34 29-Oct-2012 mikeb

shorten fwcmd to cmd


# 1.33 29-Oct-2012 mikeb

merge oce.c into if_oce.c and rename oce{reg,var}.h to if_oce{reg,var}.h


# 1.32 29-Oct-2012 mikeb

rearrange the function layout a bit


# 1.31 29-Oct-2012 mikeb

oce_get_fw_config is useless; ditch it


# 1.30 26-Oct-2012 mikeb

oce_first_mcc_cmd doesn't return anything of value so make it void;
shorten it to oce_first_mcc while here


# 1.29 26-Oct-2012 mikeb

cleanup oce_init_fw; use less bitfields


# 1.28 26-Oct-2012 mikeb

rename oce_config_nic_rss to oce_config_rss and merge oce_rss_itbl_init in;
cleanup oce_set_promisc and oce_config_vlan function arguments, a bunch of
defines and prototypes while at it.


# 1.27 25-Oct-2012 mikeb

simplify/unify writes to the rx and tx doorbell registers


# 1.26 25-Oct-2012 mikeb

don't use bitfields in oce_pci_alloc; kill some unused structures


# 1.25 25-Oct-2012 mikeb

cleanup interrupt register defines


# 1.24 25-Oct-2012 mikeb

simplify oce_arm_eq and oce_arm_cq


# 1.23 22-Oct-2012 brad

Fix the multicast filter full size check.

ok mikeb@


# 1.22 18-Oct-2012 mikeb

make oce_arm_{eq,cq} functions look like the other queue
manupulation functions in this file; do some minor style
cleanup while here.


# 1.21 15-Oct-2012 mikeb

eliminate a couple of gotos


# 1.20 15-Oct-2012 mikeb

major cleanup of the queue allocation code; we need only half of
those functions. fixup some dma syncs, not tested yet though.


# 1.19 12-Oct-2012 mikeb

no need to fetch and print the fw revision


# 1.18 12-Oct-2012 mikeb

major cleanup


# 1.17 12-Oct-2012 mikeb

a bit of janitoring


# 1.16 11-Oct-2012 mikeb

rework the firmware interface and incorporate all the guts into
one single function instead of spreading them across 10 others.


# 1.15 11-Oct-2012 mikeb

better integer log2 implementation, checked with what linux is doing


# 1.14 09-Aug-2012 mikeb

don't compile rss functions in unless OCE_RSS is specified


# 1.13 09-Aug-2012 mikeb

oops. missed these conflicts in the previous commit


# 1.12 09-Aug-2012 mikeb

schedule a rx refill if the ring is empty, sprinkle some dma syncs


# 1.11 09-Aug-2012 mikeb

remove internal queue stats, use if_* counters wherever possible


# 1.10 09-Aug-2012 mikeb

respect the mtu value that ifconfig sets


# 1.9 09-Aug-2012 mikeb

set a timeout in case the chip goes out to lunch


# 1.8 09-Aug-2012 mikeb

remove oce_dmamap_sync wrapper


# 1.7 08-Aug-2012 mikeb

call m_cluncount to account correctly for cluster chains the driver
builds upon receiving a jumbo frame.


# 1.6 08-Aug-2012 mikeb

remove rx debugging code


# 1.5 07-Aug-2012 mikeb

a bit of cleanup and a tx delay tweak


# 1.4 07-Aug-2012 mikeb

don't forget to set IFF_ALLMULTI; from brad


# 1.3 06-Aug-2012 mikeb

kill sc->promisc


# 1.2 02-Aug-2012 mikeb

get rid of some "capabilities" leftovers


# 1.1 02-Aug-2012 mikeb

Add a driver for Emulex OneConnect 10Gb Ethernet obtained from FreeBSD
but heavily massaged to look like other BSD network drivers. Support is
provided for cards based on the following controllers:

o ServerEngines BladeEngine 2
o ServerEngines BladeEngine 3
o Emulex Lancer


# 1.108 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither
uses WRITE_ONCE() nor a mutex and is called before the ifq mutex
is initialized. The new name expresses that it should be used only
during interface attach when there is no concurrency.

Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with
READ_ONCE(). They can be used without lock as they only read a
single integer.

OK dlg@


Revision tags: OPENBSD_7_4_BASE
# 1.107 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.106 11-Mar-2022 mpi

Constify struct cfattach.


# 1.105 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.104 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


Revision tags: OPENBSD_6_8_BASE
# 1.103 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.102 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


# 1.101 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.100 27-Nov-2017 sthen

lenght->length, mostly in comments


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.99 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


# 1.98 15-Sep-2016 dlg

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);


# 1.97 14-Sep-2016 mikeb

Declare the type instead of a on-stack variable for sizeof purposes

(Un?)surprisingly the compiler is smart enough to produce the same
code in both cases, but this conveys the intention better.


# 1.96 24-Aug-2016 dlg

pool_setipl for oce(4)

ok mikeb@


Revision tags: OPENBSD_6_0_BASE
# 1.95 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.94 14-Mar-2016 mikeb

Allocate statistics command from the heap, pointed out by deraadt@


# 1.93 04-Mar-2016 deraadt

extra ) not needed, spotted by tiago silva


Revision tags: OPENBSD_5_9_BASE
# 1.92 06-Jan-2016 mikeb

revert 1.87, more work is needed here


# 1.91 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.90 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.89 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.88 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.87 29-Sep-2015 chris

Unlock interrupt handler rx path with intr_barrier

ok mikeb@


# 1.86 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.85 29-Jun-2015 mikeb

Hide ETHER_ALIGN mbuf adjustment under "#ifdef __STRICT_ALIGNMENT"
for now to get jumbo frames working. oce(4) will need the same
treatment as ix(4) when sparc64 support will be implemented.

Tested by Pedro Caetano <pedrocaetano at binaryflows ! com>, thanks!


# 1.84 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.83 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


# 1.82 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.81 22-Dec-2014 tedu

unifdef INET


# 1.80 13-Dec-2014 doug

yet more mallocarray() changes.

ok tedu@ deraadt@


# 1.79 30-Aug-2014 dlg

let the mru always be what the chip can do, not what the mtu implies.

tested by and ok mikeb@


# 1.78 14-Aug-2014 mikeb

Implement rxrinfo ioctl for cluster usage statistics


Revision tags: OPENBSD_5_6_BASE
# 1.77 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.76 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.75 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


Revision tags: OPENBSD_5_5_BASE
# 1.74 20-Jan-2014 chris

bcopy to memcpy

ok mikeb@


# 1.73 20-Jan-2014 chris

bcmp to memcmp

ok mikeb@


# 1.72 20-Jan-2014 chris

bzero to memset

ok mikeb@


# 1.71 23-Aug-2013 mikeb

don't call if_link_state_change if link state is not changed


# 1.70 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.69 17-Jan-2013 henning

first or second coming, commie or not commie, one m in coming is sufficient
ok claudio


# 1.68 10-Dec-2012 mikeb

adjust mbuf chain data pointer so that ip header would appear
word aligned; remove pool constraints insanity while here


# 1.67 27-Nov-2012 gsoares

fix format string; OK mikeb@


# 1.66 26-Nov-2012 mikeb

shorten MBX_RX_IFACE_* defines


# 1.65 26-Nov-2012 mikeb

get rid of some useless bitfields in oce_mbx and mbx_hdr


# 1.64 23-Nov-2012 mikeb

better way to set baudrate to 0; pointed out by gsoares@


# 1.63 21-Nov-2012 mikeb

Don't forget to delete an rx refill timeout when bringing
an interface down (noticed by dlg@ in the other diff).
While here, do some minor cleanup in the interrupt handler.


# 1.62 20-Nov-2012 mikeb

fix typo


# 1.61 14-Nov-2012 mikeb

allocate a mailbox payload dma memory upfront instead of per request


# 1.60 13-Nov-2012 mikeb

do an OACTIVE/if_start dance only once per tx interrupt


# 1.59 13-Nov-2012 mikeb

enable hardware tx checksum offloading as oce doesn't
seem to require an initialized pseudo-header checksum


# 1.58 13-Nov-2012 mikeb

more cleanup missed in the previous commit


# 1.57 13-Nov-2012 mikeb

major cleanup; get rid of the oce_destroy_queue


# 1.56 12-Nov-2012 mikeb

move some stuff around, do minor cleanup


# 1.55 09-Nov-2012 mikeb

don't sync dma memory for the whole ring when updating a single
entry but rather sync the whole ring once done with individual
entries; use proper dma sync flags as well


# 1.54 09-Nov-2012 mikeb

merge if_ocevar.h and if_oce.c; do some minor cleanup while here


# 1.53 09-Nov-2012 mikeb

cleanup oce_encap


# 1.52 09-Nov-2012 mikeb

stop passing if_id around


# 1.51 09-Nov-2012 mikeb

improve flow control code


# 1.50 09-Nov-2012 mikeb

To be able to receive ethernet packets with VLAN tags oce_set_promisc
should not disable VLAN promiscuous mode set up by oce_config_vlan.
Move VLAN and Flow Control configuration to oce_init so that it would
be rerun every time we plumb the interface.


# 1.49 08-Nov-2012 mikeb

make link state update code more comprehensible by using some ideas from myx(4)


# 1.48 08-Nov-2012 mikeb

hardware supports mtu values from 256 up to 9000;
figured out the hard way, linux driver agrees


# 1.47 08-Nov-2012 mikeb

When halting the rx engine wait 1ms after destroying the queue in
firmware then drain the completion queue and only afterwards deal
with posted buffers so that the firmware wouldn't decide to DMA
something into the freed cluster. Logic from the Linux driver.


# 1.46 08-Nov-2012 mikeb

minor style cleanup, improve the mailbox timeout printf


# 1.45 08-Nov-2012 mikeb

Hide stats calculation ugliness inside oce_update_stats and
don't schedule another update if the one at hand fails.
s/oce_local_timer/oce_tick/ while here (:


# 1.44 07-Nov-2012 mikeb

minor tweaks to the ioctl code


# 1.43 07-Nov-2012 mikeb

do not depend on IFCAP_CSUM flags set when reading rx checksumming
results from the hardware


# 1.42 07-Nov-2012 mikeb

we still need to query the firmware for a couple of values after all


# 1.41 05-Nov-2012 mikeb

Steal SIMPLEQ-based packet descriptor managing code from myx(4)
to simplify a whole bunch of things. And despite this being the
main purpose of the commit I'm also sneaking in loads of minor
and unrelated cleanup since separating it out would be just too
much work. Enjoy!


# 1.40 03-Nov-2012 mikeb

s/OCE_DMAPTR/OCE_MEM_KVA/ and don't require a type


# 1.39 03-Nov-2012 brynet

Obligatory second oce commit for tonight. No binary change.

ok mikeb@


# 1.38 02-Nov-2012 mikeb

Introduce better and simpler producer/consumer queue iterator
implementation that is usable for both producer (rq, wq, mq)
and consumer (eq, cq) rings.


# 1.37 31-Oct-2012 mikeb

minor style cleanup


# 1.36 30-Oct-2012 mikeb

introduce specialized register read and write functions
oce_{read,write}_{cfg,csr,db} for different pci bars


# 1.35 29-Oct-2012 mikeb

prefer to return oce_cmd and save on the error variable


# 1.34 29-Oct-2012 mikeb

shorten fwcmd to cmd


# 1.33 29-Oct-2012 mikeb

merge oce.c into if_oce.c and rename oce{reg,var}.h to if_oce{reg,var}.h


# 1.32 29-Oct-2012 mikeb

rearrange the function layout a bit


# 1.31 29-Oct-2012 mikeb

oce_get_fw_config is useless; ditch it


# 1.30 26-Oct-2012 mikeb

oce_first_mcc_cmd doesn't return anything of value so make it void;
shorten it to oce_first_mcc while here


# 1.29 26-Oct-2012 mikeb

cleanup oce_init_fw; use less bitfields


# 1.28 26-Oct-2012 mikeb

rename oce_config_nic_rss to oce_config_rss and merge oce_rss_itbl_init in;
cleanup oce_set_promisc and oce_config_vlan function arguments, a bunch of
defines and prototypes while at it.


# 1.27 25-Oct-2012 mikeb

simplify/unify writes to the rx and tx doorbell registers


# 1.26 25-Oct-2012 mikeb

don't use bitfields in oce_pci_alloc; kill some unused structures


# 1.25 25-Oct-2012 mikeb

cleanup interrupt register defines


# 1.24 25-Oct-2012 mikeb

simplify oce_arm_eq and oce_arm_cq


# 1.23 22-Oct-2012 brad

Fix the multicast filter full size check.

ok mikeb@


# 1.22 18-Oct-2012 mikeb

make oce_arm_{eq,cq} functions look like the other queue
manupulation functions in this file; do some minor style
cleanup while here.


# 1.21 15-Oct-2012 mikeb

eliminate a couple of gotos


# 1.20 15-Oct-2012 mikeb

major cleanup of the queue allocation code; we need only half of
those functions. fixup some dma syncs, not tested yet though.


# 1.19 12-Oct-2012 mikeb

no need to fetch and print the fw revision


# 1.18 12-Oct-2012 mikeb

major cleanup


# 1.17 12-Oct-2012 mikeb

a bit of janitoring


# 1.16 11-Oct-2012 mikeb

rework the firmware interface and incorporate all the guts into
one single function instead of spreading them across 10 others.


# 1.15 11-Oct-2012 mikeb

better integer log2 implementation, checked with what linux is doing


# 1.14 09-Aug-2012 mikeb

don't compile rss functions in unless OCE_RSS is specified


# 1.13 09-Aug-2012 mikeb

oops. missed these conflicts in the previous commit


# 1.12 09-Aug-2012 mikeb

schedule a rx refill if the ring is empty, sprinkle some dma syncs


# 1.11 09-Aug-2012 mikeb

remove internal queue stats, use if_* counters wherever possible


# 1.10 09-Aug-2012 mikeb

respect the mtu value that ifconfig sets


# 1.9 09-Aug-2012 mikeb

set a timeout in case the chip goes out to lunch


# 1.8 09-Aug-2012 mikeb

remove oce_dmamap_sync wrapper


# 1.7 08-Aug-2012 mikeb

call m_cluncount to account correctly for cluster chains the driver
builds upon receiving a jumbo frame.


# 1.6 08-Aug-2012 mikeb

remove rx debugging code


# 1.5 07-Aug-2012 mikeb

a bit of cleanup and a tx delay tweak


# 1.4 07-Aug-2012 mikeb

don't forget to set IFF_ALLMULTI; from brad


# 1.3 06-Aug-2012 mikeb

kill sc->promisc


# 1.2 02-Aug-2012 mikeb

get rid of some "capabilities" leftovers


# 1.1 02-Aug-2012 mikeb

Add a driver for Emulex OneConnect 10Gb Ethernet obtained from FreeBSD
but heavily massaged to look like other BSD network drivers. Support is
provided for cards based on the following controllers:

o ServerEngines BladeEngine 2
o ServerEngines BladeEngine 3
o Emulex Lancer


# 1.107 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.106 11-Mar-2022 mpi

Constify struct cfattach.


# 1.105 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.104 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


Revision tags: OPENBSD_6_8_BASE
# 1.103 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.102 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


# 1.101 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.100 27-Nov-2017 sthen

lenght->length, mostly in comments


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.99 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


# 1.98 15-Sep-2016 dlg

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);


# 1.97 14-Sep-2016 mikeb

Declare the type instead of a on-stack variable for sizeof purposes

(Un?)surprisingly the compiler is smart enough to produce the same
code in both cases, but this conveys the intention better.


# 1.96 24-Aug-2016 dlg

pool_setipl for oce(4)

ok mikeb@


Revision tags: OPENBSD_6_0_BASE
# 1.95 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.94 14-Mar-2016 mikeb

Allocate statistics command from the heap, pointed out by deraadt@


# 1.93 04-Mar-2016 deraadt

extra ) not needed, spotted by tiago silva


Revision tags: OPENBSD_5_9_BASE
# 1.92 06-Jan-2016 mikeb

revert 1.87, more work is needed here


# 1.91 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.90 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.89 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.88 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.87 29-Sep-2015 chris

Unlock interrupt handler rx path with intr_barrier

ok mikeb@


# 1.86 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.85 29-Jun-2015 mikeb

Hide ETHER_ALIGN mbuf adjustment under "#ifdef __STRICT_ALIGNMENT"
for now to get jumbo frames working. oce(4) will need the same
treatment as ix(4) when sparc64 support will be implemented.

Tested by Pedro Caetano <pedrocaetano at binaryflows ! com>, thanks!


# 1.84 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.83 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


# 1.82 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.81 22-Dec-2014 tedu

unifdef INET


# 1.80 13-Dec-2014 doug

yet more mallocarray() changes.

ok tedu@ deraadt@


# 1.79 30-Aug-2014 dlg

let the mru always be what the chip can do, not what the mtu implies.

tested by and ok mikeb@


# 1.78 14-Aug-2014 mikeb

Implement rxrinfo ioctl for cluster usage statistics


Revision tags: OPENBSD_5_6_BASE
# 1.77 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.76 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.75 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


Revision tags: OPENBSD_5_5_BASE
# 1.74 20-Jan-2014 chris

bcopy to memcpy

ok mikeb@


# 1.73 20-Jan-2014 chris

bcmp to memcmp

ok mikeb@


# 1.72 20-Jan-2014 chris

bzero to memset

ok mikeb@


# 1.71 23-Aug-2013 mikeb

don't call if_link_state_change if link state is not changed


# 1.70 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.69 17-Jan-2013 henning

first or second coming, commie or not commie, one m in coming is sufficient
ok claudio


# 1.68 10-Dec-2012 mikeb

adjust mbuf chain data pointer so that ip header would appear
word aligned; remove pool constraints insanity while here


# 1.67 27-Nov-2012 gsoares

fix format string; OK mikeb@


# 1.66 26-Nov-2012 mikeb

shorten MBX_RX_IFACE_* defines


# 1.65 26-Nov-2012 mikeb

get rid of some useless bitfields in oce_mbx and mbx_hdr


# 1.64 23-Nov-2012 mikeb

better way to set baudrate to 0; pointed out by gsoares@


# 1.63 21-Nov-2012 mikeb

Don't forget to delete an rx refill timeout when bringing
an interface down (noticed by dlg@ in the other diff).
While here, do some minor cleanup in the interrupt handler.


# 1.62 20-Nov-2012 mikeb

fix typo


# 1.61 14-Nov-2012 mikeb

allocate a mailbox payload dma memory upfront instead of per request


# 1.60 13-Nov-2012 mikeb

do an OACTIVE/if_start dance only once per tx interrupt


# 1.59 13-Nov-2012 mikeb

enable hardware tx checksum offloading as oce doesn't
seem to require an initialized pseudo-header checksum


# 1.58 13-Nov-2012 mikeb

more cleanup missed in the previous commit


# 1.57 13-Nov-2012 mikeb

major cleanup; get rid of the oce_destroy_queue


# 1.56 12-Nov-2012 mikeb

move some stuff around, do minor cleanup


# 1.55 09-Nov-2012 mikeb

don't sync dma memory for the whole ring when updating a single
entry but rather sync the whole ring once done with individual
entries; use proper dma sync flags as well


# 1.54 09-Nov-2012 mikeb

merge if_ocevar.h and if_oce.c; do some minor cleanup while here


# 1.53 09-Nov-2012 mikeb

cleanup oce_encap


# 1.52 09-Nov-2012 mikeb

stop passing if_id around


# 1.51 09-Nov-2012 mikeb

improve flow control code


# 1.50 09-Nov-2012 mikeb

To be able to receive ethernet packets with VLAN tags oce_set_promisc
should not disable VLAN promiscuous mode set up by oce_config_vlan.
Move VLAN and Flow Control configuration to oce_init so that it would
be rerun every time we plumb the interface.


# 1.49 08-Nov-2012 mikeb

make link state update code more comprehensible by using some ideas from myx(4)


# 1.48 08-Nov-2012 mikeb

hardware supports mtu values from 256 up to 9000;
figured out the hard way, linux driver agrees


# 1.47 08-Nov-2012 mikeb

When halting the rx engine wait 1ms after destroying the queue in
firmware then drain the completion queue and only afterwards deal
with posted buffers so that the firmware wouldn't decide to DMA
something into the freed cluster. Logic from the Linux driver.


# 1.46 08-Nov-2012 mikeb

minor style cleanup, improve the mailbox timeout printf


# 1.45 08-Nov-2012 mikeb

Hide stats calculation ugliness inside oce_update_stats and
don't schedule another update if the one at hand fails.
s/oce_local_timer/oce_tick/ while here (:


# 1.44 07-Nov-2012 mikeb

minor tweaks to the ioctl code


# 1.43 07-Nov-2012 mikeb

do not depend on IFCAP_CSUM flags set when reading rx checksumming
results from the hardware


# 1.42 07-Nov-2012 mikeb

we still need to query the firmware for a couple of values after all


# 1.41 05-Nov-2012 mikeb

Steal SIMPLEQ-based packet descriptor managing code from myx(4)
to simplify a whole bunch of things. And despite this being the
main purpose of the commit I'm also sneaking in loads of minor
and unrelated cleanup since separating it out would be just too
much work. Enjoy!


# 1.40 03-Nov-2012 mikeb

s/OCE_DMAPTR/OCE_MEM_KVA/ and don't require a type


# 1.39 03-Nov-2012 brynet

Obligatory second oce commit for tonight. No binary change.

ok mikeb@


# 1.38 02-Nov-2012 mikeb

Introduce better and simpler producer/consumer queue iterator
implementation that is usable for both producer (rq, wq, mq)
and consumer (eq, cq) rings.


# 1.37 31-Oct-2012 mikeb

minor style cleanup


# 1.36 30-Oct-2012 mikeb

introduce specialized register read and write functions
oce_{read,write}_{cfg,csr,db} for different pci bars


# 1.35 29-Oct-2012 mikeb

prefer to return oce_cmd and save on the error variable


# 1.34 29-Oct-2012 mikeb

shorten fwcmd to cmd


# 1.33 29-Oct-2012 mikeb

merge oce.c into if_oce.c and rename oce{reg,var}.h to if_oce{reg,var}.h


# 1.32 29-Oct-2012 mikeb

rearrange the function layout a bit


# 1.31 29-Oct-2012 mikeb

oce_get_fw_config is useless; ditch it


# 1.30 26-Oct-2012 mikeb

oce_first_mcc_cmd doesn't return anything of value so make it void;
shorten it to oce_first_mcc while here


# 1.29 26-Oct-2012 mikeb

cleanup oce_init_fw; use less bitfields


# 1.28 26-Oct-2012 mikeb

rename oce_config_nic_rss to oce_config_rss and merge oce_rss_itbl_init in;
cleanup oce_set_promisc and oce_config_vlan function arguments, a bunch of
defines and prototypes while at it.


# 1.27 25-Oct-2012 mikeb

simplify/unify writes to the rx and tx doorbell registers


# 1.26 25-Oct-2012 mikeb

don't use bitfields in oce_pci_alloc; kill some unused structures


# 1.25 25-Oct-2012 mikeb

cleanup interrupt register defines


# 1.24 25-Oct-2012 mikeb

simplify oce_arm_eq and oce_arm_cq


# 1.23 22-Oct-2012 brad

Fix the multicast filter full size check.

ok mikeb@


# 1.22 18-Oct-2012 mikeb

make oce_arm_{eq,cq} functions look like the other queue
manupulation functions in this file; do some minor style
cleanup while here.


# 1.21 15-Oct-2012 mikeb

eliminate a couple of gotos


# 1.20 15-Oct-2012 mikeb

major cleanup of the queue allocation code; we need only half of
those functions. fixup some dma syncs, not tested yet though.


# 1.19 12-Oct-2012 mikeb

no need to fetch and print the fw revision


# 1.18 12-Oct-2012 mikeb

major cleanup


# 1.17 12-Oct-2012 mikeb

a bit of janitoring


# 1.16 11-Oct-2012 mikeb

rework the firmware interface and incorporate all the guts into
one single function instead of spreading them across 10 others.


# 1.15 11-Oct-2012 mikeb

better integer log2 implementation, checked with what linux is doing


# 1.14 09-Aug-2012 mikeb

don't compile rss functions in unless OCE_RSS is specified


# 1.13 09-Aug-2012 mikeb

oops. missed these conflicts in the previous commit


# 1.12 09-Aug-2012 mikeb

schedule a rx refill if the ring is empty, sprinkle some dma syncs


# 1.11 09-Aug-2012 mikeb

remove internal queue stats, use if_* counters wherever possible


# 1.10 09-Aug-2012 mikeb

respect the mtu value that ifconfig sets


# 1.9 09-Aug-2012 mikeb

set a timeout in case the chip goes out to lunch


# 1.8 09-Aug-2012 mikeb

remove oce_dmamap_sync wrapper


# 1.7 08-Aug-2012 mikeb

call m_cluncount to account correctly for cluster chains the driver
builds upon receiving a jumbo frame.


# 1.6 08-Aug-2012 mikeb

remove rx debugging code


# 1.5 07-Aug-2012 mikeb

a bit of cleanup and a tx delay tweak


# 1.4 07-Aug-2012 mikeb

don't forget to set IFF_ALLMULTI; from brad


# 1.3 06-Aug-2012 mikeb

kill sc->promisc


# 1.2 02-Aug-2012 mikeb

get rid of some "capabilities" leftovers


# 1.1 02-Aug-2012 mikeb

Add a driver for Emulex OneConnect 10Gb Ethernet obtained from FreeBSD
but heavily massaged to look like other BSD network drivers. Support is
provided for cards based on the following controllers:

o ServerEngines BladeEngine 2
o ServerEngines BladeEngine 3
o Emulex Lancer


# 1.106 11-Mar-2022 mpi

Constify struct cfattach.


# 1.105 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.104 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


Revision tags: OPENBSD_6_8_BASE
# 1.103 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.102 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


# 1.101 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.100 27-Nov-2017 sthen

lenght->length, mostly in comments


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.99 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


# 1.98 15-Sep-2016 dlg

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);


# 1.97 14-Sep-2016 mikeb

Declare the type instead of a on-stack variable for sizeof purposes

(Un?)surprisingly the compiler is smart enough to produce the same
code in both cases, but this conveys the intention better.


# 1.96 24-Aug-2016 dlg

pool_setipl for oce(4)

ok mikeb@


Revision tags: OPENBSD_6_0_BASE
# 1.95 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.94 14-Mar-2016 mikeb

Allocate statistics command from the heap, pointed out by deraadt@


# 1.93 04-Mar-2016 deraadt

extra ) not needed, spotted by tiago silva


Revision tags: OPENBSD_5_9_BASE
# 1.92 06-Jan-2016 mikeb

revert 1.87, more work is needed here


# 1.91 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.90 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.89 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.88 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.87 29-Sep-2015 chris

Unlock interrupt handler rx path with intr_barrier

ok mikeb@


# 1.86 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.85 29-Jun-2015 mikeb

Hide ETHER_ALIGN mbuf adjustment under "#ifdef __STRICT_ALIGNMENT"
for now to get jumbo frames working. oce(4) will need the same
treatment as ix(4) when sparc64 support will be implemented.

Tested by Pedro Caetano <pedrocaetano at binaryflows ! com>, thanks!


# 1.84 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.83 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


# 1.82 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.81 22-Dec-2014 tedu

unifdef INET


# 1.80 13-Dec-2014 doug

yet more mallocarray() changes.

ok tedu@ deraadt@


# 1.79 30-Aug-2014 dlg

let the mru always be what the chip can do, not what the mtu implies.

tested by and ok mikeb@


# 1.78 14-Aug-2014 mikeb

Implement rxrinfo ioctl for cluster usage statistics


Revision tags: OPENBSD_5_6_BASE
# 1.77 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.76 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.75 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


Revision tags: OPENBSD_5_5_BASE
# 1.74 20-Jan-2014 chris

bcopy to memcpy

ok mikeb@


# 1.73 20-Jan-2014 chris

bcmp to memcmp

ok mikeb@


# 1.72 20-Jan-2014 chris

bzero to memset

ok mikeb@


# 1.71 23-Aug-2013 mikeb

don't call if_link_state_change if link state is not changed


# 1.70 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.69 17-Jan-2013 henning

first or second coming, commie or not commie, one m in coming is sufficient
ok claudio


# 1.68 10-Dec-2012 mikeb

adjust mbuf chain data pointer so that ip header would appear
word aligned; remove pool constraints insanity while here


# 1.67 27-Nov-2012 gsoares

fix format string; OK mikeb@


# 1.66 26-Nov-2012 mikeb

shorten MBX_RX_IFACE_* defines


# 1.65 26-Nov-2012 mikeb

get rid of some useless bitfields in oce_mbx and mbx_hdr


# 1.64 23-Nov-2012 mikeb

better way to set baudrate to 0; pointed out by gsoares@


# 1.63 21-Nov-2012 mikeb

Don't forget to delete an rx refill timeout when bringing
an interface down (noticed by dlg@ in the other diff).
While here, do some minor cleanup in the interrupt handler.


# 1.62 20-Nov-2012 mikeb

fix typo


# 1.61 14-Nov-2012 mikeb

allocate a mailbox payload dma memory upfront instead of per request


# 1.60 13-Nov-2012 mikeb

do an OACTIVE/if_start dance only once per tx interrupt


# 1.59 13-Nov-2012 mikeb

enable hardware tx checksum offloading as oce doesn't
seem to require an initialized pseudo-header checksum


# 1.58 13-Nov-2012 mikeb

more cleanup missed in the previous commit


# 1.57 13-Nov-2012 mikeb

major cleanup; get rid of the oce_destroy_queue


# 1.56 12-Nov-2012 mikeb

move some stuff around, do minor cleanup


# 1.55 09-Nov-2012 mikeb

don't sync dma memory for the whole ring when updating a single
entry but rather sync the whole ring once done with individual
entries; use proper dma sync flags as well


# 1.54 09-Nov-2012 mikeb

merge if_ocevar.h and if_oce.c; do some minor cleanup while here


# 1.53 09-Nov-2012 mikeb

cleanup oce_encap


# 1.52 09-Nov-2012 mikeb

stop passing if_id around


# 1.51 09-Nov-2012 mikeb

improve flow control code


# 1.50 09-Nov-2012 mikeb

To be able to receive ethernet packets with VLAN tags oce_set_promisc
should not disable VLAN promiscuous mode set up by oce_config_vlan.
Move VLAN and Flow Control configuration to oce_init so that it would
be rerun every time we plumb the interface.


# 1.49 08-Nov-2012 mikeb

make link state update code more comprehensible by using some ideas from myx(4)


# 1.48 08-Nov-2012 mikeb

hardware supports mtu values from 256 up to 9000;
figured out the hard way, linux driver agrees


# 1.47 08-Nov-2012 mikeb

When halting the rx engine wait 1ms after destroying the queue in
firmware then drain the completion queue and only afterwards deal
with posted buffers so that the firmware wouldn't decide to DMA
something into the freed cluster. Logic from the Linux driver.


# 1.46 08-Nov-2012 mikeb

minor style cleanup, improve the mailbox timeout printf


# 1.45 08-Nov-2012 mikeb

Hide stats calculation ugliness inside oce_update_stats and
don't schedule another update if the one at hand fails.
s/oce_local_timer/oce_tick/ while here (:


# 1.44 07-Nov-2012 mikeb

minor tweaks to the ioctl code


# 1.43 07-Nov-2012 mikeb

do not depend on IFCAP_CSUM flags set when reading rx checksumming
results from the hardware


# 1.42 07-Nov-2012 mikeb

we still need to query the firmware for a couple of values after all


# 1.41 05-Nov-2012 mikeb

Steal SIMPLEQ-based packet descriptor managing code from myx(4)
to simplify a whole bunch of things. And despite this being the
main purpose of the commit I'm also sneaking in loads of minor
and unrelated cleanup since separating it out would be just too
much work. Enjoy!


# 1.40 03-Nov-2012 mikeb

s/OCE_DMAPTR/OCE_MEM_KVA/ and don't require a type


# 1.39 03-Nov-2012 brynet

Obligatory second oce commit for tonight. No binary change.

ok mikeb@


# 1.38 02-Nov-2012 mikeb

Introduce better and simpler producer/consumer queue iterator
implementation that is usable for both producer (rq, wq, mq)
and consumer (eq, cq) rings.


# 1.37 31-Oct-2012 mikeb

minor style cleanup


# 1.36 30-Oct-2012 mikeb

introduce specialized register read and write functions
oce_{read,write}_{cfg,csr,db} for different pci bars


# 1.35 29-Oct-2012 mikeb

prefer to return oce_cmd and save on the error variable


# 1.34 29-Oct-2012 mikeb

shorten fwcmd to cmd


# 1.33 29-Oct-2012 mikeb

merge oce.c into if_oce.c and rename oce{reg,var}.h to if_oce{reg,var}.h


# 1.32 29-Oct-2012 mikeb

rearrange the function layout a bit


# 1.31 29-Oct-2012 mikeb

oce_get_fw_config is useless; ditch it


# 1.30 26-Oct-2012 mikeb

oce_first_mcc_cmd doesn't return anything of value so make it void;
shorten it to oce_first_mcc while here


# 1.29 26-Oct-2012 mikeb

cleanup oce_init_fw; use less bitfields


# 1.28 26-Oct-2012 mikeb

rename oce_config_nic_rss to oce_config_rss and merge oce_rss_itbl_init in;
cleanup oce_set_promisc and oce_config_vlan function arguments, a bunch of
defines and prototypes while at it.


# 1.27 25-Oct-2012 mikeb

simplify/unify writes to the rx and tx doorbell registers


# 1.26 25-Oct-2012 mikeb

don't use bitfields in oce_pci_alloc; kill some unused structures


# 1.25 25-Oct-2012 mikeb

cleanup interrupt register defines


# 1.24 25-Oct-2012 mikeb

simplify oce_arm_eq and oce_arm_cq


# 1.23 22-Oct-2012 brad

Fix the multicast filter full size check.

ok mikeb@


# 1.22 18-Oct-2012 mikeb

make oce_arm_{eq,cq} functions look like the other queue
manupulation functions in this file; do some minor style
cleanup while here.


# 1.21 15-Oct-2012 mikeb

eliminate a couple of gotos


# 1.20 15-Oct-2012 mikeb

major cleanup of the queue allocation code; we need only half of
those functions. fixup some dma syncs, not tested yet though.


# 1.19 12-Oct-2012 mikeb

no need to fetch and print the fw revision


# 1.18 12-Oct-2012 mikeb

major cleanup


# 1.17 12-Oct-2012 mikeb

a bit of janitoring


# 1.16 11-Oct-2012 mikeb

rework the firmware interface and incorporate all the guts into
one single function instead of spreading them across 10 others.


# 1.15 11-Oct-2012 mikeb

better integer log2 implementation, checked with what linux is doing


# 1.14 09-Aug-2012 mikeb

don't compile rss functions in unless OCE_RSS is specified


# 1.13 09-Aug-2012 mikeb

oops. missed these conflicts in the previous commit


# 1.12 09-Aug-2012 mikeb

schedule a rx refill if the ring is empty, sprinkle some dma syncs


# 1.11 09-Aug-2012 mikeb

remove internal queue stats, use if_* counters wherever possible


# 1.10 09-Aug-2012 mikeb

respect the mtu value that ifconfig sets


# 1.9 09-Aug-2012 mikeb

set a timeout in case the chip goes out to lunch


# 1.8 09-Aug-2012 mikeb

remove oce_dmamap_sync wrapper


# 1.7 08-Aug-2012 mikeb

call m_cluncount to account correctly for cluster chains the driver
builds upon receiving a jumbo frame.


# 1.6 08-Aug-2012 mikeb

remove rx debugging code


# 1.5 07-Aug-2012 mikeb

a bit of cleanup and a tx delay tweak


# 1.4 07-Aug-2012 mikeb

don't forget to set IFF_ALLMULTI; from brad


# 1.3 06-Aug-2012 mikeb

kill sc->promisc


# 1.2 02-Aug-2012 mikeb

get rid of some "capabilities" leftovers


# 1.1 02-Aug-2012 mikeb

Add a driver for Emulex OneConnect 10Gb Ethernet obtained from FreeBSD
but heavily massaged to look like other BSD network drivers. Support is
provided for cards based on the following controllers:

o ServerEngines BladeEngine 2
o ServerEngines BladeEngine 3
o Emulex Lancer


# 1.105 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.104 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


Revision tags: OPENBSD_6_8_BASE
# 1.103 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.102 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


# 1.101 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.100 27-Nov-2017 sthen

lenght->length, mostly in comments


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.99 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


# 1.98 15-Sep-2016 dlg

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);


# 1.97 14-Sep-2016 mikeb

Declare the type instead of a on-stack variable for sizeof purposes

(Un?)surprisingly the compiler is smart enough to produce the same
code in both cases, but this conveys the intention better.


# 1.96 24-Aug-2016 dlg

pool_setipl for oce(4)

ok mikeb@


Revision tags: OPENBSD_6_0_BASE
# 1.95 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.94 14-Mar-2016 mikeb

Allocate statistics command from the heap, pointed out by deraadt@


# 1.93 04-Mar-2016 deraadt

extra ) not needed, spotted by tiago silva


Revision tags: OPENBSD_5_9_BASE
# 1.92 06-Jan-2016 mikeb

revert 1.87, more work is needed here


# 1.91 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.90 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.89 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.88 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.87 29-Sep-2015 chris

Unlock interrupt handler rx path with intr_barrier

ok mikeb@


# 1.86 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.85 29-Jun-2015 mikeb

Hide ETHER_ALIGN mbuf adjustment under "#ifdef __STRICT_ALIGNMENT"
for now to get jumbo frames working. oce(4) will need the same
treatment as ix(4) when sparc64 support will be implemented.

Tested by Pedro Caetano <pedrocaetano at binaryflows ! com>, thanks!


# 1.84 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.83 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


# 1.82 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.81 22-Dec-2014 tedu

unifdef INET


# 1.80 13-Dec-2014 doug

yet more mallocarray() changes.

ok tedu@ deraadt@


# 1.79 30-Aug-2014 dlg

let the mru always be what the chip can do, not what the mtu implies.

tested by and ok mikeb@


# 1.78 14-Aug-2014 mikeb

Implement rxrinfo ioctl for cluster usage statistics


Revision tags: OPENBSD_5_6_BASE
# 1.77 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.76 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.75 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


Revision tags: OPENBSD_5_5_BASE
# 1.74 20-Jan-2014 chris

bcopy to memcpy

ok mikeb@


# 1.73 20-Jan-2014 chris

bcmp to memcmp

ok mikeb@


# 1.72 20-Jan-2014 chris

bzero to memset

ok mikeb@


# 1.71 23-Aug-2013 mikeb

don't call if_link_state_change if link state is not changed


# 1.70 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.69 17-Jan-2013 henning

first or second coming, commie or not commie, one m in coming is sufficient
ok claudio


# 1.68 10-Dec-2012 mikeb

adjust mbuf chain data pointer so that ip header would appear
word aligned; remove pool constraints insanity while here


# 1.67 27-Nov-2012 gsoares

fix format string; OK mikeb@


# 1.66 26-Nov-2012 mikeb

shorten MBX_RX_IFACE_* defines


# 1.65 26-Nov-2012 mikeb

get rid of some useless bitfields in oce_mbx and mbx_hdr


# 1.64 23-Nov-2012 mikeb

better way to set baudrate to 0; pointed out by gsoares@


# 1.63 21-Nov-2012 mikeb

Don't forget to delete an rx refill timeout when bringing
an interface down (noticed by dlg@ in the other diff).
While here, do some minor cleanup in the interrupt handler.


# 1.62 20-Nov-2012 mikeb

fix typo


# 1.61 14-Nov-2012 mikeb

allocate a mailbox payload dma memory upfront instead of per request


# 1.60 13-Nov-2012 mikeb

do an OACTIVE/if_start dance only once per tx interrupt


# 1.59 13-Nov-2012 mikeb

enable hardware tx checksum offloading as oce doesn't
seem to require an initialized pseudo-header checksum


# 1.58 13-Nov-2012 mikeb

more cleanup missed in the previous commit


# 1.57 13-Nov-2012 mikeb

major cleanup; get rid of the oce_destroy_queue


# 1.56 12-Nov-2012 mikeb

move some stuff around, do minor cleanup


# 1.55 09-Nov-2012 mikeb

don't sync dma memory for the whole ring when updating a single
entry but rather sync the whole ring once done with individual
entries; use proper dma sync flags as well


# 1.54 09-Nov-2012 mikeb

merge if_ocevar.h and if_oce.c; do some minor cleanup while here


# 1.53 09-Nov-2012 mikeb

cleanup oce_encap


# 1.52 09-Nov-2012 mikeb

stop passing if_id around


# 1.51 09-Nov-2012 mikeb

improve flow control code


# 1.50 09-Nov-2012 mikeb

To be able to receive ethernet packets with VLAN tags oce_set_promisc
should not disable VLAN promiscuous mode set up by oce_config_vlan.
Move VLAN and Flow Control configuration to oce_init so that it would
be rerun every time we plumb the interface.


# 1.49 08-Nov-2012 mikeb

make link state update code more comprehensible by using some ideas from myx(4)


# 1.48 08-Nov-2012 mikeb

hardware supports mtu values from 256 up to 9000;
figured out the hard way, linux driver agrees


# 1.47 08-Nov-2012 mikeb

When halting the rx engine wait 1ms after destroying the queue in
firmware then drain the completion queue and only afterwards deal
with posted buffers so that the firmware wouldn't decide to DMA
something into the freed cluster. Logic from the Linux driver.


# 1.46 08-Nov-2012 mikeb

minor style cleanup, improve the mailbox timeout printf


# 1.45 08-Nov-2012 mikeb

Hide stats calculation ugliness inside oce_update_stats and
don't schedule another update if the one at hand fails.
s/oce_local_timer/oce_tick/ while here (:


# 1.44 07-Nov-2012 mikeb

minor tweaks to the ioctl code


# 1.43 07-Nov-2012 mikeb

do not depend on IFCAP_CSUM flags set when reading rx checksumming
results from the hardware


# 1.42 07-Nov-2012 mikeb

we still need to query the firmware for a couple of values after all


# 1.41 05-Nov-2012 mikeb

Steal SIMPLEQ-based packet descriptor managing code from myx(4)
to simplify a whole bunch of things. And despite this being the
main purpose of the commit I'm also sneaking in loads of minor
and unrelated cleanup since separating it out would be just too
much work. Enjoy!


# 1.40 03-Nov-2012 mikeb

s/OCE_DMAPTR/OCE_MEM_KVA/ and don't require a type


# 1.39 03-Nov-2012 brynet

Obligatory second oce commit for tonight. No binary change.

ok mikeb@


# 1.38 02-Nov-2012 mikeb

Introduce better and simpler producer/consumer queue iterator
implementation that is usable for both producer (rq, wq, mq)
and consumer (eq, cq) rings.


# 1.37 31-Oct-2012 mikeb

minor style cleanup


# 1.36 30-Oct-2012 mikeb

introduce specialized register read and write functions
oce_{read,write}_{cfg,csr,db} for different pci bars


# 1.35 29-Oct-2012 mikeb

prefer to return oce_cmd and save on the error variable


# 1.34 29-Oct-2012 mikeb

shorten fwcmd to cmd


# 1.33 29-Oct-2012 mikeb

merge oce.c into if_oce.c and rename oce{reg,var}.h to if_oce{reg,var}.h


# 1.32 29-Oct-2012 mikeb

rearrange the function layout a bit


# 1.31 29-Oct-2012 mikeb

oce_get_fw_config is useless; ditch it


# 1.30 26-Oct-2012 mikeb

oce_first_mcc_cmd doesn't return anything of value so make it void;
shorten it to oce_first_mcc while here


# 1.29 26-Oct-2012 mikeb

cleanup oce_init_fw; use less bitfields


# 1.28 26-Oct-2012 mikeb

rename oce_config_nic_rss to oce_config_rss and merge oce_rss_itbl_init in;
cleanup oce_set_promisc and oce_config_vlan function arguments, a bunch of
defines and prototypes while at it.


# 1.27 25-Oct-2012 mikeb

simplify/unify writes to the rx and tx doorbell registers


# 1.26 25-Oct-2012 mikeb

don't use bitfields in oce_pci_alloc; kill some unused structures


# 1.25 25-Oct-2012 mikeb

cleanup interrupt register defines


# 1.24 25-Oct-2012 mikeb

simplify oce_arm_eq and oce_arm_cq


# 1.23 22-Oct-2012 brad

Fix the multicast filter full size check.

ok mikeb@


# 1.22 18-Oct-2012 mikeb

make oce_arm_{eq,cq} functions look like the other queue
manupulation functions in this file; do some minor style
cleanup while here.


# 1.21 15-Oct-2012 mikeb

eliminate a couple of gotos


# 1.20 15-Oct-2012 mikeb

major cleanup of the queue allocation code; we need only half of
those functions. fixup some dma syncs, not tested yet though.


# 1.19 12-Oct-2012 mikeb

no need to fetch and print the fw revision


# 1.18 12-Oct-2012 mikeb

major cleanup


# 1.17 12-Oct-2012 mikeb

a bit of janitoring


# 1.16 11-Oct-2012 mikeb

rework the firmware interface and incorporate all the guts into
one single function instead of spreading them across 10 others.


# 1.15 11-Oct-2012 mikeb

better integer log2 implementation, checked with what linux is doing


# 1.14 09-Aug-2012 mikeb

don't compile rss functions in unless OCE_RSS is specified


# 1.13 09-Aug-2012 mikeb

oops. missed these conflicts in the previous commit


# 1.12 09-Aug-2012 mikeb

schedule a rx refill if the ring is empty, sprinkle some dma syncs


# 1.11 09-Aug-2012 mikeb

remove internal queue stats, use if_* counters wherever possible


# 1.10 09-Aug-2012 mikeb

respect the mtu value that ifconfig sets


# 1.9 09-Aug-2012 mikeb

set a timeout in case the chip goes out to lunch


# 1.8 09-Aug-2012 mikeb

remove oce_dmamap_sync wrapper


# 1.7 08-Aug-2012 mikeb

call m_cluncount to account correctly for cluster chains the driver
builds upon receiving a jumbo frame.


# 1.6 08-Aug-2012 mikeb

remove rx debugging code


# 1.5 07-Aug-2012 mikeb

a bit of cleanup and a tx delay tweak


# 1.4 07-Aug-2012 mikeb

don't forget to set IFF_ALLMULTI; from brad


# 1.3 06-Aug-2012 mikeb

kill sc->promisc


# 1.2 02-Aug-2012 mikeb

get rid of some "capabilities" leftovers


# 1.1 02-Aug-2012 mikeb

Add a driver for Emulex OneConnect 10Gb Ethernet obtained from FreeBSD
but heavily massaged to look like other BSD network drivers. Support is
provided for cards based on the following controllers:

o ServerEngines BladeEngine 2
o ServerEngines BladeEngine 3
o Emulex Lancer


# 1.104 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


Revision tags: OPENBSD_6_8_BASE
# 1.103 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.102 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


# 1.101 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.100 27-Nov-2017 sthen

lenght->length, mostly in comments


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.99 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


# 1.98 15-Sep-2016 dlg

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);


# 1.97 14-Sep-2016 mikeb

Declare the type instead of a on-stack variable for sizeof purposes

(Un?)surprisingly the compiler is smart enough to produce the same
code in both cases, but this conveys the intention better.


# 1.96 24-Aug-2016 dlg

pool_setipl for oce(4)

ok mikeb@


Revision tags: OPENBSD_6_0_BASE
# 1.95 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.94 14-Mar-2016 mikeb

Allocate statistics command from the heap, pointed out by deraadt@


# 1.93 04-Mar-2016 deraadt

extra ) not needed, spotted by tiago silva


Revision tags: OPENBSD_5_9_BASE
# 1.92 06-Jan-2016 mikeb

revert 1.87, more work is needed here


# 1.91 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.90 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.89 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.88 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.87 29-Sep-2015 chris

Unlock interrupt handler rx path with intr_barrier

ok mikeb@


# 1.86 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.85 29-Jun-2015 mikeb

Hide ETHER_ALIGN mbuf adjustment under "#ifdef __STRICT_ALIGNMENT"
for now to get jumbo frames working. oce(4) will need the same
treatment as ix(4) when sparc64 support will be implemented.

Tested by Pedro Caetano <pedrocaetano at binaryflows ! com>, thanks!


# 1.84 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.83 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


# 1.82 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.81 22-Dec-2014 tedu

unifdef INET


# 1.80 13-Dec-2014 doug

yet more mallocarray() changes.

ok tedu@ deraadt@


# 1.79 30-Aug-2014 dlg

let the mru always be what the chip can do, not what the mtu implies.

tested by and ok mikeb@


# 1.78 14-Aug-2014 mikeb

Implement rxrinfo ioctl for cluster usage statistics


Revision tags: OPENBSD_5_6_BASE
# 1.77 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.76 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.75 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


Revision tags: OPENBSD_5_5_BASE
# 1.74 20-Jan-2014 chris

bcopy to memcpy

ok mikeb@


# 1.73 20-Jan-2014 chris

bcmp to memcmp

ok mikeb@


# 1.72 20-Jan-2014 chris

bzero to memset

ok mikeb@


# 1.71 23-Aug-2013 mikeb

don't call if_link_state_change if link state is not changed


# 1.70 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.69 17-Jan-2013 henning

first or second coming, commie or not commie, one m in coming is sufficient
ok claudio


# 1.68 10-Dec-2012 mikeb

adjust mbuf chain data pointer so that ip header would appear
word aligned; remove pool constraints insanity while here


# 1.67 27-Nov-2012 gsoares

fix format string; OK mikeb@


# 1.66 26-Nov-2012 mikeb

shorten MBX_RX_IFACE_* defines


# 1.65 26-Nov-2012 mikeb

get rid of some useless bitfields in oce_mbx and mbx_hdr


# 1.64 23-Nov-2012 mikeb

better way to set baudrate to 0; pointed out by gsoares@


# 1.63 21-Nov-2012 mikeb

Don't forget to delete an rx refill timeout when bringing
an interface down (noticed by dlg@ in the other diff).
While here, do some minor cleanup in the interrupt handler.


# 1.62 20-Nov-2012 mikeb

fix typo


# 1.61 14-Nov-2012 mikeb

allocate a mailbox payload dma memory upfront instead of per request


# 1.60 13-Nov-2012 mikeb

do an OACTIVE/if_start dance only once per tx interrupt


# 1.59 13-Nov-2012 mikeb

enable hardware tx checksum offloading as oce doesn't
seem to require an initialized pseudo-header checksum


# 1.58 13-Nov-2012 mikeb

more cleanup missed in the previous commit


# 1.57 13-Nov-2012 mikeb

major cleanup; get rid of the oce_destroy_queue


# 1.56 12-Nov-2012 mikeb

move some stuff around, do minor cleanup


# 1.55 09-Nov-2012 mikeb

don't sync dma memory for the whole ring when updating a single
entry but rather sync the whole ring once done with individual
entries; use proper dma sync flags as well


# 1.54 09-Nov-2012 mikeb

merge if_ocevar.h and if_oce.c; do some minor cleanup while here


# 1.53 09-Nov-2012 mikeb

cleanup oce_encap


# 1.52 09-Nov-2012 mikeb

stop passing if_id around


# 1.51 09-Nov-2012 mikeb

improve flow control code


# 1.50 09-Nov-2012 mikeb

To be able to receive ethernet packets with VLAN tags oce_set_promisc
should not disable VLAN promiscuous mode set up by oce_config_vlan.
Move VLAN and Flow Control configuration to oce_init so that it would
be rerun every time we plumb the interface.


# 1.49 08-Nov-2012 mikeb

make link state update code more comprehensible by using some ideas from myx(4)


# 1.48 08-Nov-2012 mikeb

hardware supports mtu values from 256 up to 9000;
figured out the hard way, linux driver agrees


# 1.47 08-Nov-2012 mikeb

When halting the rx engine wait 1ms after destroying the queue in
firmware then drain the completion queue and only afterwards deal
with posted buffers so that the firmware wouldn't decide to DMA
something into the freed cluster. Logic from the Linux driver.


# 1.46 08-Nov-2012 mikeb

minor style cleanup, improve the mailbox timeout printf


# 1.45 08-Nov-2012 mikeb

Hide stats calculation ugliness inside oce_update_stats and
don't schedule another update if the one at hand fails.
s/oce_local_timer/oce_tick/ while here (:


# 1.44 07-Nov-2012 mikeb

minor tweaks to the ioctl code


# 1.43 07-Nov-2012 mikeb

do not depend on IFCAP_CSUM flags set when reading rx checksumming
results from the hardware


# 1.42 07-Nov-2012 mikeb

we still need to query the firmware for a couple of values after all


# 1.41 05-Nov-2012 mikeb

Steal SIMPLEQ-based packet descriptor managing code from myx(4)
to simplify a whole bunch of things. And despite this being the
main purpose of the commit I'm also sneaking in loads of minor
and unrelated cleanup since separating it out would be just too
much work. Enjoy!


# 1.40 03-Nov-2012 mikeb

s/OCE_DMAPTR/OCE_MEM_KVA/ and don't require a type


# 1.39 03-Nov-2012 brynet

Obligatory second oce commit for tonight. No binary change.

ok mikeb@


# 1.38 02-Nov-2012 mikeb

Introduce better and simpler producer/consumer queue iterator
implementation that is usable for both producer (rq, wq, mq)
and consumer (eq, cq) rings.


# 1.37 31-Oct-2012 mikeb

minor style cleanup


# 1.36 30-Oct-2012 mikeb

introduce specialized register read and write functions
oce_{read,write}_{cfg,csr,db} for different pci bars


# 1.35 29-Oct-2012 mikeb

prefer to return oce_cmd and save on the error variable


# 1.34 29-Oct-2012 mikeb

shorten fwcmd to cmd


# 1.33 29-Oct-2012 mikeb

merge oce.c into if_oce.c and rename oce{reg,var}.h to if_oce{reg,var}.h


# 1.32 29-Oct-2012 mikeb

rearrange the function layout a bit


# 1.31 29-Oct-2012 mikeb

oce_get_fw_config is useless; ditch it


# 1.30 26-Oct-2012 mikeb

oce_first_mcc_cmd doesn't return anything of value so make it void;
shorten it to oce_first_mcc while here


# 1.29 26-Oct-2012 mikeb

cleanup oce_init_fw; use less bitfields


# 1.28 26-Oct-2012 mikeb

rename oce_config_nic_rss to oce_config_rss and merge oce_rss_itbl_init in;
cleanup oce_set_promisc and oce_config_vlan function arguments, a bunch of
defines and prototypes while at it.


# 1.27 25-Oct-2012 mikeb

simplify/unify writes to the rx and tx doorbell registers


# 1.26 25-Oct-2012 mikeb

don't use bitfields in oce_pci_alloc; kill some unused structures


# 1.25 25-Oct-2012 mikeb

cleanup interrupt register defines


# 1.24 25-Oct-2012 mikeb

simplify oce_arm_eq and oce_arm_cq


# 1.23 22-Oct-2012 brad

Fix the multicast filter full size check.

ok mikeb@


# 1.22 18-Oct-2012 mikeb

make oce_arm_{eq,cq} functions look like the other queue
manupulation functions in this file; do some minor style
cleanup while here.


# 1.21 15-Oct-2012 mikeb

eliminate a couple of gotos


# 1.20 15-Oct-2012 mikeb

major cleanup of the queue allocation code; we need only half of
those functions. fixup some dma syncs, not tested yet though.


# 1.19 12-Oct-2012 mikeb

no need to fetch and print the fw revision


# 1.18 12-Oct-2012 mikeb

major cleanup


# 1.17 12-Oct-2012 mikeb

a bit of janitoring


# 1.16 11-Oct-2012 mikeb

rework the firmware interface and incorporate all the guts into
one single function instead of spreading them across 10 others.


# 1.15 11-Oct-2012 mikeb

better integer log2 implementation, checked with what linux is doing


# 1.14 09-Aug-2012 mikeb

don't compile rss functions in unless OCE_RSS is specified


# 1.13 09-Aug-2012 mikeb

oops. missed these conflicts in the previous commit


# 1.12 09-Aug-2012 mikeb

schedule a rx refill if the ring is empty, sprinkle some dma syncs


# 1.11 09-Aug-2012 mikeb

remove internal queue stats, use if_* counters wherever possible


# 1.10 09-Aug-2012 mikeb

respect the mtu value that ifconfig sets


# 1.9 09-Aug-2012 mikeb

set a timeout in case the chip goes out to lunch


# 1.8 09-Aug-2012 mikeb

remove oce_dmamap_sync wrapper


# 1.7 08-Aug-2012 mikeb

call m_cluncount to account correctly for cluster chains the driver
builds upon receiving a jumbo frame.


# 1.6 08-Aug-2012 mikeb

remove rx debugging code


# 1.5 07-Aug-2012 mikeb

a bit of cleanup and a tx delay tweak


# 1.4 07-Aug-2012 mikeb

don't forget to set IFF_ALLMULTI; from brad


# 1.3 06-Aug-2012 mikeb

kill sc->promisc


# 1.2 02-Aug-2012 mikeb

get rid of some "capabilities" leftovers


# 1.1 02-Aug-2012 mikeb

Add a driver for Emulex OneConnect 10Gb Ethernet obtained from FreeBSD
but heavily massaged to look like other BSD network drivers. Support is
provided for cards based on the following controllers:

o ServerEngines BladeEngine 2
o ServerEngines BladeEngine 3
o Emulex Lancer


# 1.103 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.102 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


# 1.101 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.100 27-Nov-2017 sthen

lenght->length, mostly in comments


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.99 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


# 1.98 15-Sep-2016 dlg

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);


# 1.97 14-Sep-2016 mikeb

Declare the type instead of a on-stack variable for sizeof purposes

(Un?)surprisingly the compiler is smart enough to produce the same
code in both cases, but this conveys the intention better.


# 1.96 24-Aug-2016 dlg

pool_setipl for oce(4)

ok mikeb@


Revision tags: OPENBSD_6_0_BASE
# 1.95 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.94 14-Mar-2016 mikeb

Allocate statistics command from the heap, pointed out by deraadt@


# 1.93 04-Mar-2016 deraadt

extra ) not needed, spotted by tiago silva


Revision tags: OPENBSD_5_9_BASE
# 1.92 06-Jan-2016 mikeb

revert 1.87, more work is needed here


# 1.91 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.90 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.89 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.88 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.87 29-Sep-2015 chris

Unlock interrupt handler rx path with intr_barrier

ok mikeb@


# 1.86 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.85 29-Jun-2015 mikeb

Hide ETHER_ALIGN mbuf adjustment under "#ifdef __STRICT_ALIGNMENT"
for now to get jumbo frames working. oce(4) will need the same
treatment as ix(4) when sparc64 support will be implemented.

Tested by Pedro Caetano <pedrocaetano at binaryflows ! com>, thanks!


# 1.84 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.83 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


# 1.82 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.81 22-Dec-2014 tedu

unifdef INET


# 1.80 13-Dec-2014 doug

yet more mallocarray() changes.

ok tedu@ deraadt@


# 1.79 30-Aug-2014 dlg

let the mru always be what the chip can do, not what the mtu implies.

tested by and ok mikeb@


# 1.78 14-Aug-2014 mikeb

Implement rxrinfo ioctl for cluster usage statistics


Revision tags: OPENBSD_5_6_BASE
# 1.77 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.76 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.75 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


Revision tags: OPENBSD_5_5_BASE
# 1.74 20-Jan-2014 chris

bcopy to memcpy

ok mikeb@


# 1.73 20-Jan-2014 chris

bcmp to memcmp

ok mikeb@


# 1.72 20-Jan-2014 chris

bzero to memset

ok mikeb@


# 1.71 23-Aug-2013 mikeb

don't call if_link_state_change if link state is not changed


# 1.70 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.69 17-Jan-2013 henning

first or second coming, commie or not commie, one m in coming is sufficient
ok claudio


# 1.68 10-Dec-2012 mikeb

adjust mbuf chain data pointer so that ip header would appear
word aligned; remove pool constraints insanity while here


# 1.67 27-Nov-2012 gsoares

fix format string; OK mikeb@


# 1.66 26-Nov-2012 mikeb

shorten MBX_RX_IFACE_* defines


# 1.65 26-Nov-2012 mikeb

get rid of some useless bitfields in oce_mbx and mbx_hdr


# 1.64 23-Nov-2012 mikeb

better way to set baudrate to 0; pointed out by gsoares@


# 1.63 21-Nov-2012 mikeb

Don't forget to delete an rx refill timeout when bringing
an interface down (noticed by dlg@ in the other diff).
While here, do some minor cleanup in the interrupt handler.


# 1.62 20-Nov-2012 mikeb

fix typo


# 1.61 14-Nov-2012 mikeb

allocate a mailbox payload dma memory upfront instead of per request


# 1.60 13-Nov-2012 mikeb

do an OACTIVE/if_start dance only once per tx interrupt


# 1.59 13-Nov-2012 mikeb

enable hardware tx checksum offloading as oce doesn't
seem to require an initialized pseudo-header checksum


# 1.58 13-Nov-2012 mikeb

more cleanup missed in the previous commit


# 1.57 13-Nov-2012 mikeb

major cleanup; get rid of the oce_destroy_queue


# 1.56 12-Nov-2012 mikeb

move some stuff around, do minor cleanup


# 1.55 09-Nov-2012 mikeb

don't sync dma memory for the whole ring when updating a single
entry but rather sync the whole ring once done with individual
entries; use proper dma sync flags as well


# 1.54 09-Nov-2012 mikeb

merge if_ocevar.h and if_oce.c; do some minor cleanup while here


# 1.53 09-Nov-2012 mikeb

cleanup oce_encap


# 1.52 09-Nov-2012 mikeb

stop passing if_id around


# 1.51 09-Nov-2012 mikeb

improve flow control code


# 1.50 09-Nov-2012 mikeb

To be able to receive ethernet packets with VLAN tags oce_set_promisc
should not disable VLAN promiscuous mode set up by oce_config_vlan.
Move VLAN and Flow Control configuration to oce_init so that it would
be rerun every time we plumb the interface.


# 1.49 08-Nov-2012 mikeb

make link state update code more comprehensible by using some ideas from myx(4)


# 1.48 08-Nov-2012 mikeb

hardware supports mtu values from 256 up to 9000;
figured out the hard way, linux driver agrees


# 1.47 08-Nov-2012 mikeb

When halting the rx engine wait 1ms after destroying the queue in
firmware then drain the completion queue and only afterwards deal
with posted buffers so that the firmware wouldn't decide to DMA
something into the freed cluster. Logic from the Linux driver.


# 1.46 08-Nov-2012 mikeb

minor style cleanup, improve the mailbox timeout printf


# 1.45 08-Nov-2012 mikeb

Hide stats calculation ugliness inside oce_update_stats and
don't schedule another update if the one at hand fails.
s/oce_local_timer/oce_tick/ while here (:


# 1.44 07-Nov-2012 mikeb

minor tweaks to the ioctl code


# 1.43 07-Nov-2012 mikeb

do not depend on IFCAP_CSUM flags set when reading rx checksumming
results from the hardware


# 1.42 07-Nov-2012 mikeb

we still need to query the firmware for a couple of values after all


# 1.41 05-Nov-2012 mikeb

Steal SIMPLEQ-based packet descriptor managing code from myx(4)
to simplify a whole bunch of things. And despite this being the
main purpose of the commit I'm also sneaking in loads of minor
and unrelated cleanup since separating it out would be just too
much work. Enjoy!


# 1.40 03-Nov-2012 mikeb

s/OCE_DMAPTR/OCE_MEM_KVA/ and don't require a type


# 1.39 03-Nov-2012 brynet

Obligatory second oce commit for tonight. No binary change.

ok mikeb@


# 1.38 02-Nov-2012 mikeb

Introduce better and simpler producer/consumer queue iterator
implementation that is usable for both producer (rq, wq, mq)
and consumer (eq, cq) rings.


# 1.37 31-Oct-2012 mikeb

minor style cleanup


# 1.36 30-Oct-2012 mikeb

introduce specialized register read and write functions
oce_{read,write}_{cfg,csr,db} for different pci bars


# 1.35 29-Oct-2012 mikeb

prefer to return oce_cmd and save on the error variable


# 1.34 29-Oct-2012 mikeb

shorten fwcmd to cmd


# 1.33 29-Oct-2012 mikeb

merge oce.c into if_oce.c and rename oce{reg,var}.h to if_oce{reg,var}.h


# 1.32 29-Oct-2012 mikeb

rearrange the function layout a bit


# 1.31 29-Oct-2012 mikeb

oce_get_fw_config is useless; ditch it


# 1.30 26-Oct-2012 mikeb

oce_first_mcc_cmd doesn't return anything of value so make it void;
shorten it to oce_first_mcc while here


# 1.29 26-Oct-2012 mikeb

cleanup oce_init_fw; use less bitfields


# 1.28 26-Oct-2012 mikeb

rename oce_config_nic_rss to oce_config_rss and merge oce_rss_itbl_init in;
cleanup oce_set_promisc and oce_config_vlan function arguments, a bunch of
defines and prototypes while at it.


# 1.27 25-Oct-2012 mikeb

simplify/unify writes to the rx and tx doorbell registers


# 1.26 25-Oct-2012 mikeb

don't use bitfields in oce_pci_alloc; kill some unused structures


# 1.25 25-Oct-2012 mikeb

cleanup interrupt register defines


# 1.24 25-Oct-2012 mikeb

simplify oce_arm_eq and oce_arm_cq


# 1.23 22-Oct-2012 brad

Fix the multicast filter full size check.

ok mikeb@


# 1.22 18-Oct-2012 mikeb

make oce_arm_{eq,cq} functions look like the other queue
manupulation functions in this file; do some minor style
cleanup while here.


# 1.21 15-Oct-2012 mikeb

eliminate a couple of gotos


# 1.20 15-Oct-2012 mikeb

major cleanup of the queue allocation code; we need only half of
those functions. fixup some dma syncs, not tested yet though.


# 1.19 12-Oct-2012 mikeb

no need to fetch and print the fw revision


# 1.18 12-Oct-2012 mikeb

major cleanup


# 1.17 12-Oct-2012 mikeb

a bit of janitoring


# 1.16 11-Oct-2012 mikeb

rework the firmware interface and incorporate all the guts into
one single function instead of spreading them across 10 others.


# 1.15 11-Oct-2012 mikeb

better integer log2 implementation, checked with what linux is doing


# 1.14 09-Aug-2012 mikeb

don't compile rss functions in unless OCE_RSS is specified


# 1.13 09-Aug-2012 mikeb

oops. missed these conflicts in the previous commit


# 1.12 09-Aug-2012 mikeb

schedule a rx refill if the ring is empty, sprinkle some dma syncs


# 1.11 09-Aug-2012 mikeb

remove internal queue stats, use if_* counters wherever possible


# 1.10 09-Aug-2012 mikeb

respect the mtu value that ifconfig sets


# 1.9 09-Aug-2012 mikeb

set a timeout in case the chip goes out to lunch


# 1.8 09-Aug-2012 mikeb

remove oce_dmamap_sync wrapper


# 1.7 08-Aug-2012 mikeb

call m_cluncount to account correctly for cluster chains the driver
builds upon receiving a jumbo frame.


# 1.6 08-Aug-2012 mikeb

remove rx debugging code


# 1.5 07-Aug-2012 mikeb

a bit of cleanup and a tx delay tweak


# 1.4 07-Aug-2012 mikeb

don't forget to set IFF_ALLMULTI; from brad


# 1.3 06-Aug-2012 mikeb

kill sc->promisc


# 1.2 02-Aug-2012 mikeb

get rid of some "capabilities" leftovers


# 1.1 02-Aug-2012 mikeb

Add a driver for Emulex OneConnect 10Gb Ethernet obtained from FreeBSD
but heavily massaged to look like other BSD network drivers. Support is
provided for cards based on the following controllers:

o ServerEngines BladeEngine 2
o ServerEngines BladeEngine 3
o Emulex Lancer


# 1.101 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.100 27-Nov-2017 sthen

lenght->length, mostly in comments


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.99 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


# 1.98 15-Sep-2016 dlg

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);


# 1.97 14-Sep-2016 mikeb

Declare the type instead of a on-stack variable for sizeof purposes

(Un?)surprisingly the compiler is smart enough to produce the same
code in both cases, but this conveys the intention better.


# 1.96 24-Aug-2016 dlg

pool_setipl for oce(4)

ok mikeb@


Revision tags: OPENBSD_6_0_BASE
# 1.95 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.94 14-Mar-2016 mikeb

Allocate statistics command from the heap, pointed out by deraadt@


# 1.93 04-Mar-2016 deraadt

extra ) not needed, spotted by tiago silva


Revision tags: OPENBSD_5_9_BASE
# 1.92 06-Jan-2016 mikeb

revert 1.87, more work is needed here


# 1.91 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.90 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.89 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.88 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.87 29-Sep-2015 chris

Unlock interrupt handler rx path with intr_barrier

ok mikeb@


# 1.86 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.85 29-Jun-2015 mikeb

Hide ETHER_ALIGN mbuf adjustment under "#ifdef __STRICT_ALIGNMENT"
for now to get jumbo frames working. oce(4) will need the same
treatment as ix(4) when sparc64 support will be implemented.

Tested by Pedro Caetano <pedrocaetano at binaryflows ! com>, thanks!


# 1.84 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.83 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


# 1.82 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.81 22-Dec-2014 tedu

unifdef INET


# 1.80 13-Dec-2014 doug

yet more mallocarray() changes.

ok tedu@ deraadt@


# 1.79 30-Aug-2014 dlg

let the mru always be what the chip can do, not what the mtu implies.

tested by and ok mikeb@


# 1.78 14-Aug-2014 mikeb

Implement rxrinfo ioctl for cluster usage statistics


Revision tags: OPENBSD_5_6_BASE
# 1.77 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.76 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.75 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


Revision tags: OPENBSD_5_5_BASE
# 1.74 20-Jan-2014 chris

bcopy to memcpy

ok mikeb@


# 1.73 20-Jan-2014 chris

bcmp to memcmp

ok mikeb@


# 1.72 20-Jan-2014 chris

bzero to memset

ok mikeb@


# 1.71 23-Aug-2013 mikeb

don't call if_link_state_change if link state is not changed


# 1.70 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.69 17-Jan-2013 henning

first or second coming, commie or not commie, one m in coming is sufficient
ok claudio


# 1.68 10-Dec-2012 mikeb

adjust mbuf chain data pointer so that ip header would appear
word aligned; remove pool constraints insanity while here


# 1.67 27-Nov-2012 gsoares

fix format string; OK mikeb@


# 1.66 26-Nov-2012 mikeb

shorten MBX_RX_IFACE_* defines


# 1.65 26-Nov-2012 mikeb

get rid of some useless bitfields in oce_mbx and mbx_hdr


# 1.64 23-Nov-2012 mikeb

better way to set baudrate to 0; pointed out by gsoares@


# 1.63 21-Nov-2012 mikeb

Don't forget to delete an rx refill timeout when bringing
an interface down (noticed by dlg@ in the other diff).
While here, do some minor cleanup in the interrupt handler.


# 1.62 20-Nov-2012 mikeb

fix typo


# 1.61 14-Nov-2012 mikeb

allocate a mailbox payload dma memory upfront instead of per request


# 1.60 13-Nov-2012 mikeb

do an OACTIVE/if_start dance only once per tx interrupt


# 1.59 13-Nov-2012 mikeb

enable hardware tx checksum offloading as oce doesn't
seem to require an initialized pseudo-header checksum


# 1.58 13-Nov-2012 mikeb

more cleanup missed in the previous commit


# 1.57 13-Nov-2012 mikeb

major cleanup; get rid of the oce_destroy_queue


# 1.56 12-Nov-2012 mikeb

move some stuff around, do minor cleanup


# 1.55 09-Nov-2012 mikeb

don't sync dma memory for the whole ring when updating a single
entry but rather sync the whole ring once done with individual
entries; use proper dma sync flags as well


# 1.54 09-Nov-2012 mikeb

merge if_ocevar.h and if_oce.c; do some minor cleanup while here


# 1.53 09-Nov-2012 mikeb

cleanup oce_encap


# 1.52 09-Nov-2012 mikeb

stop passing if_id around


# 1.51 09-Nov-2012 mikeb

improve flow control code


# 1.50 09-Nov-2012 mikeb

To be able to receive ethernet packets with VLAN tags oce_set_promisc
should not disable VLAN promiscuous mode set up by oce_config_vlan.
Move VLAN and Flow Control configuration to oce_init so that it would
be rerun every time we plumb the interface.


# 1.49 08-Nov-2012 mikeb

make link state update code more comprehensible by using some ideas from myx(4)


# 1.48 08-Nov-2012 mikeb

hardware supports mtu values from 256 up to 9000;
figured out the hard way, linux driver agrees


# 1.47 08-Nov-2012 mikeb

When halting the rx engine wait 1ms after destroying the queue in
firmware then drain the completion queue and only afterwards deal
with posted buffers so that the firmware wouldn't decide to DMA
something into the freed cluster. Logic from the Linux driver.


# 1.46 08-Nov-2012 mikeb

minor style cleanup, improve the mailbox timeout printf


# 1.45 08-Nov-2012 mikeb

Hide stats calculation ugliness inside oce_update_stats and
don't schedule another update if the one at hand fails.
s/oce_local_timer/oce_tick/ while here (:


# 1.44 07-Nov-2012 mikeb

minor tweaks to the ioctl code


# 1.43 07-Nov-2012 mikeb

do not depend on IFCAP_CSUM flags set when reading rx checksumming
results from the hardware


# 1.42 07-Nov-2012 mikeb

we still need to query the firmware for a couple of values after all


# 1.41 05-Nov-2012 mikeb

Steal SIMPLEQ-based packet descriptor managing code from myx(4)
to simplify a whole bunch of things. And despite this being the
main purpose of the commit I'm also sneaking in loads of minor
and unrelated cleanup since separating it out would be just too
much work. Enjoy!


# 1.40 03-Nov-2012 mikeb

s/OCE_DMAPTR/OCE_MEM_KVA/ and don't require a type


# 1.39 03-Nov-2012 brynet

Obligatory second oce commit for tonight. No binary change.

ok mikeb@


# 1.38 02-Nov-2012 mikeb

Introduce better and simpler producer/consumer queue iterator
implementation that is usable for both producer (rq, wq, mq)
and consumer (eq, cq) rings.


# 1.37 31-Oct-2012 mikeb

minor style cleanup


# 1.36 30-Oct-2012 mikeb

introduce specialized register read and write functions
oce_{read,write}_{cfg,csr,db} for different pci bars


# 1.35 29-Oct-2012 mikeb

prefer to return oce_cmd and save on the error variable


# 1.34 29-Oct-2012 mikeb

shorten fwcmd to cmd


# 1.33 29-Oct-2012 mikeb

merge oce.c into if_oce.c and rename oce{reg,var}.h to if_oce{reg,var}.h


# 1.32 29-Oct-2012 mikeb

rearrange the function layout a bit


# 1.31 29-Oct-2012 mikeb

oce_get_fw_config is useless; ditch it


# 1.30 26-Oct-2012 mikeb

oce_first_mcc_cmd doesn't return anything of value so make it void;
shorten it to oce_first_mcc while here


# 1.29 26-Oct-2012 mikeb

cleanup oce_init_fw; use less bitfields


# 1.28 26-Oct-2012 mikeb

rename oce_config_nic_rss to oce_config_rss and merge oce_rss_itbl_init in;
cleanup oce_set_promisc and oce_config_vlan function arguments, a bunch of
defines and prototypes while at it.


# 1.27 25-Oct-2012 mikeb

simplify/unify writes to the rx and tx doorbell registers


# 1.26 25-Oct-2012 mikeb

don't use bitfields in oce_pci_alloc; kill some unused structures


# 1.25 25-Oct-2012 mikeb

cleanup interrupt register defines


# 1.24 25-Oct-2012 mikeb

simplify oce_arm_eq and oce_arm_cq


# 1.23 22-Oct-2012 brad

Fix the multicast filter full size check.

ok mikeb@


# 1.22 18-Oct-2012 mikeb

make oce_arm_{eq,cq} functions look like the other queue
manupulation functions in this file; do some minor style
cleanup while here.


# 1.21 15-Oct-2012 mikeb

eliminate a couple of gotos


# 1.20 15-Oct-2012 mikeb

major cleanup of the queue allocation code; we need only half of
those functions. fixup some dma syncs, not tested yet though.


# 1.19 12-Oct-2012 mikeb

no need to fetch and print the fw revision


# 1.18 12-Oct-2012 mikeb

major cleanup


# 1.17 12-Oct-2012 mikeb

a bit of janitoring


# 1.16 11-Oct-2012 mikeb

rework the firmware interface and incorporate all the guts into
one single function instead of spreading them across 10 others.


# 1.15 11-Oct-2012 mikeb

better integer log2 implementation, checked with what linux is doing


# 1.14 09-Aug-2012 mikeb

don't compile rss functions in unless OCE_RSS is specified


# 1.13 09-Aug-2012 mikeb

oops. missed these conflicts in the previous commit


# 1.12 09-Aug-2012 mikeb

schedule a rx refill if the ring is empty, sprinkle some dma syncs


# 1.11 09-Aug-2012 mikeb

remove internal queue stats, use if_* counters wherever possible


# 1.10 09-Aug-2012 mikeb

respect the mtu value that ifconfig sets


# 1.9 09-Aug-2012 mikeb

set a timeout in case the chip goes out to lunch


# 1.8 09-Aug-2012 mikeb

remove oce_dmamap_sync wrapper


# 1.7 08-Aug-2012 mikeb

call m_cluncount to account correctly for cluster chains the driver
builds upon receiving a jumbo frame.


# 1.6 08-Aug-2012 mikeb

remove rx debugging code


# 1.5 07-Aug-2012 mikeb

a bit of cleanup and a tx delay tweak


# 1.4 07-Aug-2012 mikeb

don't forget to set IFF_ALLMULTI; from brad


# 1.3 06-Aug-2012 mikeb

kill sc->promisc


# 1.2 02-Aug-2012 mikeb

get rid of some "capabilities" leftovers


# 1.1 02-Aug-2012 mikeb

Add a driver for Emulex OneConnect 10Gb Ethernet obtained from FreeBSD
but heavily massaged to look like other BSD network drivers. Support is
provided for cards based on the following controllers:

o ServerEngines BladeEngine 2
o ServerEngines BladeEngine 3
o Emulex Lancer


# 1.100 27-Nov-2017 sthen

lenght->length, mostly in comments


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.99 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


# 1.98 15-Sep-2016 dlg

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);


# 1.97 14-Sep-2016 mikeb

Declare the type instead of a on-stack variable for sizeof purposes

(Un?)surprisingly the compiler is smart enough to produce the same
code in both cases, but this conveys the intention better.


# 1.96 24-Aug-2016 dlg

pool_setipl for oce(4)

ok mikeb@


Revision tags: OPENBSD_6_0_BASE
# 1.95 13-Apr-2016 mpi

G/C IFQ_SET_READY().


# 1.94 14-Mar-2016 mikeb

Allocate statistics command from the heap, pointed out by deraadt@


# 1.93 04-Mar-2016 deraadt

extra ) not needed, spotted by tiago silva


Revision tags: OPENBSD_5_9_BASE
# 1.92 06-Jan-2016 mikeb

revert 1.87, more work is needed here


# 1.91 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.90 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.89 14-Nov-2015 mpi

Do not include <net/if_vlan_var.h> when it's not necessary.

Because of the VLAN hacks in mpw(4) this file still contains the definition
of "struct ifvlan" which depends on <sys/refcnt.h> which in turns pull
<sys/atomic.h>...


# 1.88 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.87 29-Sep-2015 chris

Unlock interrupt handler rx path with intr_barrier

ok mikeb@


# 1.86 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.85 29-Jun-2015 mikeb

Hide ETHER_ALIGN mbuf adjustment under "#ifdef __STRICT_ALIGNMENT"
for now to get jumbo frames working. oce(4) will need the same
treatment as ix(4) when sparc64 support will be implemented.

Tested by Pedro Caetano <pedrocaetano at binaryflows ! com>, thanks!


# 1.84 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.83 30-Apr-2015 mpi

Convert moar drivers to if_input().

ok dlg@


# 1.82 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.81 22-Dec-2014 tedu

unifdef INET


# 1.80 13-Dec-2014 doug

yet more mallocarray() changes.

ok tedu@ deraadt@


# 1.79 30-Aug-2014 dlg

let the mru always be what the chip can do, not what the mtu implies.

tested by and ok mikeb@


# 1.78 14-Aug-2014 mikeb

Implement rxrinfo ioctl for cluster usage statistics


Revision tags: OPENBSD_5_6_BASE
# 1.77 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


# 1.76 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.75 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


Revision tags: OPENBSD_5_5_BASE
# 1.74 20-Jan-2014 chris

bcopy to memcpy

ok mikeb@


# 1.73 20-Jan-2014 chris

bcmp to memcmp

ok mikeb@


# 1.72 20-Jan-2014 chris

bzero to memset

ok mikeb@


# 1.71 23-Aug-2013 mikeb

don't call if_link_state_change if link state is not changed


# 1.70 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.69 17-Jan-2013 henning

first or second coming, commie or not commie, one m in coming is sufficient
ok claudio


# 1.68 10-Dec-2012 mikeb

adjust mbuf chain data pointer so that ip header would appear
word aligned; remove pool constraints insanity while here


# 1.67 27-Nov-2012 gsoares

fix format string; OK mikeb@


# 1.66 26-Nov-2012 mikeb

shorten MBX_RX_IFACE_* defines


# 1.65 26-Nov-2012 mikeb

get rid of some useless bitfields in oce_mbx and mbx_hdr


# 1.64 23-Nov-2012 mikeb

better way to set baudrate to 0; pointed out by gsoares@


# 1.63 21-Nov-2012 mikeb

Don't forget to delete an rx refill timeout when bringing
an interface down (noticed by dlg@ in the other diff).
While here, do some minor cleanup in the interrupt handler.


# 1.62 20-Nov-2012 mikeb

fix typo


# 1.61 14-Nov-2012 mikeb

allocate a mailbox payload dma memory upfront instead of per request


# 1.60 13-Nov-2012 mikeb

do an OACTIVE/if_start dance only once per tx interrupt


# 1.59 13-Nov-2012 mikeb

enable hardware tx checksum offloading as oce doesn't
seem to require an initialized pseudo-header checksum


# 1.58 13-Nov-2012 mikeb

more cleanup missed in the previous commit


# 1.57 13-Nov-2012 mikeb

major cleanup; get rid of the oce_destroy_queue


# 1.56 12-Nov-2012 mikeb

move some stuff around, do minor cleanup


# 1.55 09-Nov-2012 mikeb

don't sync dma memory for the whole ring when updating a single
entry but rather sync the whole ring once done with individual
entries; use proper dma sync flags as well


# 1.54 09-Nov-2012 mikeb

merge if_ocevar.h and if_oce.c; do some minor cleanup while here


# 1.53 09-Nov-2012 mikeb

cleanup oce_encap


# 1.52 09-Nov-2012 mikeb

stop passing if_id around


# 1.51 09-Nov-2012 mikeb

improve flow control code


# 1.50 09-Nov-2012 mikeb

To be able to receive ethernet packets with VLAN tags oce_set_promisc
should not disable VLAN promiscuous mode set up by oce_config_vlan.
Move VLAN and Flow Control configuration to oce_init so that it would
be rerun every time we plumb the interface.


# 1.49 08-Nov-2012 mikeb

make link state update code more comprehensible by using some ideas from myx(4)


# 1.48 08-Nov-2012 mikeb

hardware supports mtu values from 256 up to 9000;
figured out the hard way, linux driver agrees


# 1.47 08-Nov-2012 mikeb

When halting the rx engine wait 1ms after destroying the queue in
firmware then drain the completion queue and only afterwards deal
with posted buffers so that the firmware wouldn't decide to DMA
something into the freed cluster. Logic from the Linux driver.


# 1.46 08-Nov-2012 mikeb

minor style cleanup, improve the mailbox timeout printf


# 1.45 08-Nov-2012 mikeb

Hide stats calculation ugliness inside oce_update_stats and
don't schedule another update if the one at hand fails.
s/oce_local_timer/oce_tick/ while here (:


# 1.44 07-Nov-2012 mikeb

minor tweaks to the ioctl code


# 1.43 07-Nov-2012 mikeb

do not depend on IFCAP_CSUM flags set when reading rx checksumming
results from the hardware


# 1.42 07-Nov-2012 mikeb

we still need to query the firmware for a couple of values after all


# 1.41 05-Nov-2012 mikeb

Steal SIMPLEQ-based packet descriptor managing code from myx(4)
to simplify a whole bunch of things. And despite this being the
main purpose of the commit I'm also sneaking in loads of minor
and unrelated cleanup since separating it out would be just too
much work. Enjoy!


# 1.40 03-Nov-2012 mikeb

s/OCE_DMAPTR/OCE_MEM_KVA/ and don't require a type


# 1.39 03-Nov-2012 brynet

Obligatory second oce commit for tonight. No binary change.

ok mikeb@


# 1.38 02-Nov-2012 mikeb

Introduce better and simpler producer/consumer queue iterator
implementation that is usable for both producer (rq, wq, mq)
and consumer (eq, cq) rings.


# 1.37 31-Oct-2012 mikeb

minor style cleanup


# 1.36 30-Oct-2012 mikeb

introduce specialized register read and write functions
oce_{read,write}_{cfg,csr,db} for different pci bars


# 1.35 29-Oct-2012 mikeb

prefer to return oce_cmd and save on the error variable


# 1.34 29-Oct-2012 mikeb

shorten fwcmd to cmd


# 1.33 29-Oct-2012 mikeb

merge oce.c into if_oce.c and rename oce{reg,var}.h to if_oce{reg,var}.h


# 1.32 29-Oct-2012 mikeb

rearrange the function layout a bit


# 1.31 29-Oct-2012 mikeb

oce_get_fw_config is useless; ditch it


# 1.30 26-Oct-2012 mikeb

oce_first_mcc_cmd doesn't return anything of value so make it void;
shorten it to oce_first_mcc while here


# 1.29 26-Oct-2012 mikeb

cleanup oce_init_fw; use less bitfields


# 1.28 26-Oct-2012 mikeb

rename oce_config_nic_rss to oce_config_rss and merge oce_rss_itbl_init in;
cleanup oce_set_promisc and oce_config_vlan function arguments, a bunch of
defines and prototypes while at it.


# 1.27 25-Oct-2012 mikeb

simplify/unify writes to the rx and tx doorbell registers


# 1.26 25-Oct-2012 mikeb

don't use bitfields in oce_pci_alloc; kill some unused structures


# 1.25 25-Oct-2012 mikeb

cleanup interrupt register defines


# 1.24 25-Oct-2012 mikeb

simplify oce_arm_eq and oce_arm_cq


# 1.23 22-Oct-2012 brad

Fix the multicast filter full size check.

ok mikeb@


# 1.22 18-Oct-2012 mikeb

make oce_arm_{eq,cq} functions look like the other queue
manupulation functions in this file; do some minor style
cleanup while here.


# 1.21 15-Oct-2012 mikeb

eliminate a couple of gotos


# 1.20 15-Oct-2012 mikeb

major cleanup of the queue allocation code; we need only half of
those functions. fixup some dma syncs, not tested yet though.


# 1.19 12-Oct-2012 mikeb

no need to fetch and print the fw revision


# 1.18 12-Oct-2012 mikeb

major cleanup


# 1.17 12-Oct-2012 mikeb

a bit of janitoring


# 1.16 11-Oct-2012 mikeb

rework the firmware interface and incorporate all the guts into
one single function instead of spreading them across 10 others.


# 1.15 11-Oct-2012 mikeb

better integer log2 implementation, checked with what linux is doing


# 1.14 09-Aug-2012 mikeb

don't compile rss functions in unless OCE_RSS is specified


# 1.13 09-Aug-2012 mikeb

oops. missed these conflicts in the previous commit


# 1.12 09-Aug-2012 mikeb

schedule a rx refill if the ring is empty, sprinkle some dma syncs


# 1.11 09-Aug-2012 mikeb

remove internal queue stats, use if_* counters wherever possible


# 1.10 09-Aug-2012 mikeb

respect the mtu value that ifconfig sets


# 1.9 09-Aug-2012 mikeb

set a timeout in case the chip goes out to lunch


# 1.8 09-Aug-2012 mikeb

remove oce_dmamap_sync wrapper


# 1.7 08-Aug-2012 mikeb

call m_cluncount to account correctly for cluster chains the driver
builds upon receiving a jumbo frame.


# 1.6 08-Aug-2012 mikeb

remove rx debugging code


# 1.5 07-Aug-2012 mikeb

a bit of cleanup and a tx delay tweak


# 1.4 07-Aug-2012 mikeb

don't forget to set IFF_ALLMULTI; from brad


# 1.3 06-Aug-2012 mikeb

kill sc->promisc


# 1.2 02-Aug-2012 mikeb

get rid of some "capabilities" leftovers


# 1.1 02-Aug-2012 mikeb

Add a driver for Emulex OneConnect 10Gb Ethernet obtained from FreeBSD
but heavily massaged to look like other BSD network drivers. Support is
provided for cards based on the following controllers:

o ServerEngines BladeEngine 2
o ServerEngines BladeEngine 3
o Emulex Lancer