summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_myx.c
AgeCommit message (Collapse)Author
2021-02-08Simplify sleep_setup API to two operations in preparation for splittingMartin Pieuchot
the SCHED_LOCK(). Putting a thread on a sleep queue is reduce to the following: sleep_setup(); /* check condition or release lock */ sleep_finish(); Previous version ok cheloha@, jmatthew@, ok claudio@
2021-01-17this hardware is fine with BUS_DMA_64BIT mappings.David Gwynne
this raises performance of tcpbench on an m3000 from ~3kpps and ~8MB/s to ~70kpps and ~191MB/s when transmitting, and ~10kpps and ~15MB/s to ~120kpps and 174MB/s when receiving. i also tested this on a v245 and an m4000 a while back.
2020-12-12Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.jan
OK dlg@, bluhm@ No Opinion mpi@ Not against it claudio@
2020-11-27Add initialization of sc_sff_lock rwlock.Kevin Lo
ok semarie@
2020-07-17name the rx rings so systat mb shows them.David Gwynne
2020-07-17add kstats to myx.David Gwynne
myx is unusually minimal, so there's not a lot of information that the chip provides. the most interesting is the number of packets the chip drops cos of a lack of space on the rx rings.
2020-07-10Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.Patrick Wildt
ok dlg@ tobhe@
2019-07-03use ifiq_input return values to apply backpressure to rings.David Gwynne
2019-04-16i2c reads are more reliable a byte at a time.David Gwynne
reading all 256 at a time was a nice idea, but meant page 0xa2 wasnt appearing like it should. this follows what freebsd does more closely too.
2019-04-16make sff page reads work on little endian archs too. like amd64.David Gwynne
some modules seem to need more time when waiting for bytes while here. hrvoje popovski hit the endian issue
2019-04-15implement SIOCGIFSFFPAGE so ifconfig can get transceiver info.David Gwynne
myx doesn't allow i2c writes, so you can only read whatever page the firmware is already pointing at on device 0xa0. if you try to read another page it will return ENXIO. tested on a 10G-PCIE-8A-R with an xfp module.
2019-04-15trim some debug code that printed out the name of a commandDavid Gwynne
the list of commands is going to grow, but the thought of keeping the list in debug code up to date with it just makes me feel tired. this prints the command id number instead in the same format we represent it in the header.
2017-08-01defer init of the myxmcl pool to mountroot, and enable pool cpu caches.David Gwynne
pool_cache_init cannot be called during autoconf because we cant be confident about the number of cpus in the machine until the first run of attaches. mountroot is after autoconf, and myx already has code that runs there for the firmware loading. discussed with deraadt@
2017-02-07move the mbuf pools to m_pool_init and a single global memory limitDavid Gwynne
this replaces individual calls to pool_init, pool_set_constraints, and pool_sethardlimit with calls to m_pool_init. m_pool_init inits the mbuf pools with the mbuf pool allocator, and because of that doesnt set per pool limits. ok bluhm@ as part of a larger diff
2017-01-24add support for multiple transmit ifqueues per network interface.David Gwynne
an ifq to transmit a packet is picked by the current traffic conditioner (ie, priq or hfsc) by providing an index into an array of ifqs. by default interfaces get a single ifq but can ask for more using if_attach_queues(). the vast majority of our drivers still think there's a 1:1 mapping between interfaces and transmit queues, so their if_start routines take an ifnet pointer instead of a pointer to the ifqueue struct. instead of changing all the drivers in the tree, drivers can opt into using an if_qstart routine and setting the IFXF_MPSAFE flag. the stack provides a compatability wrapper from the new if_qstart handler to the previous if_start handlers if IFXF_MPSAFE isnt set. enabling hfsc on an interface configures it to transmit everything through the first ifq. any other ifqs are left configured as priq, but unused, when hfsc is enabled. getting this in now so everyone can kick the tyres. ok mpi@ visa@ (who provided some tweaks for cnmac).
2017-01-22move counting if_opackets next to counting if_obytes in if_enqueue.David Gwynne
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@
2016-10-31turns out these chips can handle buffers up to 9400 bytes in length.David Gwynne
raise the mtu to 9380 bytes so we can take advantage of the extra space. i need to revisit the macro names at some point.
2016-10-31revert 1.97 where i moved myx to using the system poolsDavid Gwynne
my early revision board doesnt like it at all
2016-10-28get rid of the custom pool in myx for jumbo frames.David Gwynne
now it asks the mbuf layer for the 9k from its pools. a question from chris@ made me go look at the chip doco again and i realised that the chip only requires 4 byte alignment for rx buffers, no 4k alignment for jumbo buffers. i also found that the chip is supposed to be able to rx up to 9400 bytes instead of 9000. ill fix that later though.
2016-09-15all pools have their ipl set via pool_setipl, so fold it into pool_init.David Gwynne
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);
2016-05-23remove the function pointer from mbufs. this memory is shared with dataTed Unangst
via unions, and we don't want to make it easy to control the target. instead an integer index into an array of acceptable functions is used. drivers using custom functions must register them to receive an index. ok deraadt
2016-04-13G/C IFQ_SET_READY().Martin Pieuchot
2016-04-13G/C IFQ_SET_READY().Martin Pieuchot
2015-12-11Replace mountroothook_establish(9) by config_mountroot(9) a narrower APIMartin Pieuchot
similar to config_defer(9). ok mikeb@, deraadt@
2015-12-09rework the if_start mpsafe serialisation so it can serialise arbitrary workDavid Gwynne
work is represented by struct task. the start routine is now wrapped by a task which is serialised by the infrastructure. if_start_barrier has been renamed to ifq_barrier and is now implemented as a task that gets serialised with the start routine. this also adds an ifq_restart() function. it serialises a call to ifq_clr_oactive and calls the start routine again. it exists to avoid a race that kettenis@ identified in between when a start routine discovers theres no space left on a ring, and when it calls ifq_set_oactive. if the txeof side of the driver empties the ring and calls ifq_clr_oactive in between the above calls in start, the queue will be marked oactive and the stack will never call the start routine again. by serialising the ifq_set_oactive call in the start routine and ifq_clr_oactive calls we avoid that race. tested on various nics ok mpi@
2015-12-03tell the stack myx_start is mpsafe.David Gwynne
as per the stack commit, the driver changes are: 1. setting ifp->if_xflags = IFXF_MPSAFE 2. only calling if_start() instead of its own start routine 3. clearing IFF_RUNNING before calling if_start_barrier() on its way down 4. only using IFQ_DEQUEUE (not ifq_deq_begin/commit/rollback)
2015-12-01myx doesnt use atomic.h anymore.David Gwynne
2015-11-25replace IFF_OACTIVE manipulation with mpsafe operations.David Gwynne
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@
2015-11-24fix tx ring accounting in myx_start.David Gwynne
turns out i was calculating the number of packets (not descriptors) on the tx ring, and then using that as the free space for descriptors.
2015-11-19get rid of sc_tx_free and the atomic ops on it in myx_start and myx_txeof.David Gwynne
myx_start calculates the free space by reading the consumer index and doing some maths, which lets us avoid the interlocked cpu ops.
2015-10-25arp_ifinit() is no longer needed.Martin Pieuchot
2015-09-29get rid of the mutex between access to the status block and myx_downDavid Gwynne
myx is unusual in that it has an explicit command to shut down the chip that gets an interrupt when it's done. so myx_down sends the command and has to sleep until it gets that interrupt. this moves to using a single int to represent that state (so loads and stores are atomic), and sleep_setup/sleep_finish in myx_down to wait for it to change. this has been running in production at work for a few months now tested by chris@
2015-09-01free() firmware with right len; ok dlgTheo de Raadt
2015-08-15do the global tx free accounting in myx_start with a single atomic opDavid Gwynne
instead of one per packet. seems to let me send packets a little faster.
2015-08-15rework the tx path to use a ring to keep track of dmamaps/mbufs.David Gwynne
this removes the myx_buf structure and uses myx_slot instead. theyre the same expcet slots dont have list entry structures, so theyre smaller. this cuts out four mutex ops per packet out of the tx handling. just have to get rid of the atomic op per packet in myx_start now.
2015-08-14move to a per rx ring timeout for refilling empty rings.David Gwynne
this lets me get rid of the locking around the refilling of the rx ring. the timeout only runs refill if the rx ring is empty. we know rxeof wont try and refill it in that situation because there's no packets on the ring so we wont get interrupts for it. therefore we dont need to lock between the timeout and rxeof cos they cant run at the same time.
2015-08-14rework how we track the packets on the rx rings.David Gwynne
originally there were two mutex protected lists for rx packets, a list of free packets, and a list of packets that were on the ring. filling the ring popped packets off the free list, attached an mbuf and dmamapped it, and pushed it onto the list of active packets. the hw fills packets in order, so on rx completion we'd pop packets the active list, unmap the mbuf and shove it up the stack before putting the packet on the free list. the problem with the lists is that every rx ring operation resulted in two mutex ops. so 4 mutex ops per packet after you do both fill and rxeof. this replaces the mutexed lists with rings that shadow the hardware rings. filling the rx ring pushes a producer index along, while rxeof chases it with a consumer. because we know only one thing can do either of those tasks at a time, we can get away with not using atomic ops for them. there's more to be done, but this is a good first step.
2015-06-24Increment if_ipackets in if_input().Martin Pieuchot
Note that pseudo-drivers not using if_input() are not affected by this conversion. ok mikeb@, kettenis@, claudio@, dlg@
2015-05-17We don't need KERNEL_LOCK() around if_input() anymore, as if_input() hasChris Cappuccio
appropriate locking around bpf now. ok dlg@
2015-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
2015-02-20Now that if_input() is a thing, use itChris Cappuccio
ok dlg@
2015-02-18myri employees and their drivers for linux and solaris have repeatedlyDavid Gwynne
told me that if you're going to rx into buffers greater than 4k in size, they have to be aligned to a 4k boundary. the mru of this chip is 9k, but ive been using the 12k mcl pool to provide the alignment. however, if we move to putting 8 items on a pool page there'll be enough slack space in the mcl12k pool pages to allow item colouring, which in turn will break the chip requirement above. in practice the chips i have seem to work fine with unaligned buffers, but i dont want to risk breaking early revision chips. this moves myx to using a private pool for allocating clusters for the big rx ring. the item size is 9k, but we specify a 4k alignment so every item we get out of it will be correct for the chip.
2015-02-18enable pcie relaxed transaction ordering and bump the max payloadDavid Gwynne
size up to 4k. found while reading someone elses driver.
2014-12-22unifdef INETTed Unangst
2014-10-28the if_rxring accounting would get screwed up if the first mbuf toDavid Gwynne
be put on the ring couldnt be allocated. this pulls the code that puts the mbufs on the ring out of myx_rx_fill so it can return early if firstmb cant be allocated, which puts it in the right place to return unused slots to the if_rxring. this means myx rx wont lock up if you're DoSsed to the point where you exhaust your mbuf pools and cant allocate mbufs for the ring. ok jmatthew@
2014-10-04replace mutexes to serialise the operations on the flag that restrictsDavid Gwynne
the number of contexts that are refilling the rx rings with atomic ops. this is borrowed from code i wrote for the scsi midlayer but cant put in yet because i havent got atomic.h up to scrach on all archs yet. the archs myx runs on do have enough atomic.h to be fine though.
2014-10-03refill the rx ring in myx_rxeof, not much later at the end of myx_intr.David Gwynne
2014-10-03in rxeof, instead of taking the biglock on every packet to call bpfDavid Gwynne
and ether_input, queue all the mbufs onto an mbuf_list on the stack and then take the biglock once outside the loop.
2014-10-03we dont need the kernel lock to call bus_dmamap_load and unload thanksDavid Gwynne
to ketenis. move the if_ipacket and if_opacket increments out of biglock too. theyre only updated from the interrupt handler, which is only run on a single cpu so there's no chance of the update racing. everywhere else only reads them.
2014-10-03dont need to hold the kernel lock to call MCLGETI and m_freem now.David Gwynne