summaryrefslogtreecommitdiff
path: root/sys/dev/ic/re.c
AgeCommit message (Collapse)Author
2024-01-19consolidate pci and cardbus detach code, and have it detach kstats.David Gwynne
this solves one probably with an re(4) going away.
2023-11-10Make ifq and ifiq interface MP safe.Alexander Bluhm
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@
2022-11-17whitespace fixes. no functional change.David Gwynne
2022-06-21Revert part of r1.212, which caused a regression in a previously workingBjorn Ketelaars
setup OK dlg@
2022-06-05use the write lemtohXX functions for bits of the stats structure.David Gwynne
unbreaks the build on bigendian archs. found by deraadt@
2022-06-03expose hardware counters as kstats.David Gwynne
some of them are 16 bit, so check frequently. now i can see what packets my apu1 is dropping in hardware. ok claudio@
2021-05-17Fix mbuf leaks after reception error in re_rxeof().Visa Hankala
Also, increment the error counter when an unexpected fragment is seen. OK claudio@
2021-05-07RealTek -> RealtekJonathan Gray
ok jmc@ kevlo@
2021-05-07add support for RTL8168FP/RTL8111FP/RTL8117 to re(4)Jonathan Gray
from Stephen Taylor who tested on a ThinkCenter M75n Nano IoT with RTL8111FP-CG
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-08-26Declare hw_{prod,serial,uuid,vendor,ver} in <sys/systm.h>.Visa Hankala
OK deraadt@, mpi@
2020-07-10Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.Patrick Wildt
ok dlg@ tobhe@
2020-06-22use ifiq_input and use it's return value to apply backpressure to rxrs.David Gwynne
this is a step toward deprecating softclock based livelock detection.
2019-11-19Set isr to the correct value (sc->rl_intrs).Kevin Lo
ok deraadt@
2019-11-19Don't assign ifp twice in the re_txeof().Kevin Lo
ok deraadt@
2017-06-19Do not call txeof nor rxeof in the watchdog routine.Martin Pieuchot
They cannot be serialized with the interrupt routine and are useless because the driver is reinitialized right after. Pointed by and ok mikeb@
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@
2017-01-04better handle empty or full rx rings.David Gwynne
currently re appears to end up spinning on landisk. the most obvious cause of this would be an inability to add entries on the rx ring when we run out of mbufs. cope with this by calling rxeof from the isr when the FIFO_OVERFLOW status bit is set. rxeof in turn unconditionally tries to fill the rx ring, even if it doesnt dequeue any packets off the ring. while here limit the number of entries that can go on the rx ring to 1 less than the size of the ring. a full ring looks the same as an empty ring (cos the producer and consumer are the same in both cases), so avoid letting this happen. ok deraadt@ who hit problems on his landisk and tested this diff
2016-11-16rework re_start and re_txeof to be more like other drivers.David Gwynne
the important change is to no longer account for packets and descriptors separately, instead we just deal with available descriptors on the ring. this allows us to guarantee that oactive will only be set after re_start has queued at least one packet, which in turn guarantees that the chip will interrupt in the future and run re_txeof to clear oactive. without this change it was possible for a call of re_start to almost fill the descriptor ring, followed by a second call that could fail to post a packet because it had run out of descriptors and would then set oactive. if re_txeof ran concurrently it could complete all the previously posted packets without noticing that oactive had been set and therefore needed to be cleared. in that situation oactive would be set, but nothing would be set up to clear it in the immediate future. this fixes a lockup reported by haesbaert.
2016-11-16allocate dmamaps for every descriptor in the tx ring.David Gwynne
previously there was a limit of 64 packets on the tx ring. soon we will use as many descriptors as we want to fill the ring.
2016-11-16dont restrict the number of tx descriptors to what can fit on a cpu page.David Gwynne
2016-11-16move toward having the a tx packet descriptor per tx ring entry.David Gwynne
previously you could have 64 packets on a ring with up to 1024 descriptors. this mismatch makes the accounting for free space complicated and allows for a data race with OACTIVE being set. it will also let us push more packets.
2016-11-16serialise posts to the txstart register.David Gwynne
without this it is possible for re_txeof to let the chip look at and complete tx descriptors that re_start has written to the ring but not accounted for in the software producer index. in this situation no future interrupts may be generated for packets on the ring, and tx will stall. the serialisation is implemented by only doing the writes from tasks via ifq_serialize. this is part of a bigger diff that fixes lockups reported by haesbaert.
2016-08-10armish handled some early-gen arm machines, which required tons ofTheo de Raadt
workarounds. Some of them will soon stand in the way of armv7. Off to the attic you go.
2016-04-20If RTL8111E on PC Engines APU is detected, configure NIC LEDs to display link.Stuart Henderson
Normally this would be setup in the vendor-programmed eeprom, but in this case it hasn't been done and the rather unfortunate default results in *only* a normally-off light for network activity, nothing for ethernet link, so it's too easy to mistake the machine for being powered down. hw.vendor/hw.machine idea from naddy@, testing jasper@, ok deraadt@
2016-04-13G/C IFQ_SET_READY().Martin Pieuchot
2016-03-19Reduces the noise around the global ``ticks'' variable by renamingMartin Pieuchot
all the local ones to ``nticks''. ok stefan@, deraadt@
2016-01-04mark the driver MPSAFE. most of this is cleaning up the oactive handling.David Gwynne
if there's lingering bugs we'll deal with them in tree. ok jmatthew@
2015-12-28Rework re_start and re_txeof to only check the producer/consumer ringJonathan Matthew
positions when deciding how much work to do, and to adjust rl_tx_free with atomic operations; split the flag that indicates whether we're using timer based interrupts or not out into a separate field so it can be changed from interrupt context without needing a lock; take the kernel lock when calling re_init and re_start from interrupt context; add an interrupt barrier in re_stop; and finally mark the interrupt handler as mpsafe. started by Jim Smith a while ago, mostly finished up at n2k15 tested by dlg@, chris@ and Dimitris Papastamos on various hardware ok dlg@
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-24You only need <net/if_dl.h> if you're using LLADDR() or a sockaddr_dl.Martin Pieuchot
2015-11-24You need <netinet/ip.h> if you use "struct ip" for hw checksum.Martin Pieuchot
You never need <netinet/ip_var.h> nor <netinet/in_systm.h>.
2015-11-20shuffle struct ifqueue so in flight mbufs are protected by a mutex.David Gwynne
the code is refactored so the IFQ macros call newly implemented ifq functions. the ifq code is split so each discipline (priq and hfsc in our case) is an opaque set of operations that the common ifq code can call. the common code does the locking, accounting (ifq_len manipulation), and freeing of the mbuf if the disciplines enqueue function rejects it. theyre kind of like bufqs in the block layer with their fifo and nscan disciplines. the new api also supports atomic switching of disciplines at runtime. the hfsc setup in pf_ioctl.c has been tweaked to build a complete hfsc_if structure which it attaches to the send queue in a single operation, rather than attaching to the interface up front and building up a list of queues. the send queue is now mutexed, which raises the expectation that packets can be enqueued or purged on one cpu while another cpu is dequeueing them in a driver for transmission. a lot of drivers use IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before committing to it with a later IFQ_DEQUEUE operation. if the mbuf gets freed in between the POLL and DEQUEUE operations, fireworks will ensue. to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback, and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq mutex and get a reference to the mbuf they wish to try and tx. if there's space, they can ifq_deq_commit it to remove the mbuf and release the mutex. if there's no space, ifq_deq_rollback simply releases the mutex. this api was developed to make updating the drivers using IFQ_POLL easy, instead of having to do significant semantic changes to avoid POLL that we cannot test on all the hardware. the common code has been tested pretty hard, and all the driver modifications are straightforward except for de(4). if that breaks it can be dealt with later. ok mpi@ jmatthew@
2015-11-14Do not include <net/if_vlan_var.h> when it's not necessary.Martin Pieuchot
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>...
2015-11-02later variants of these chips can support bigger rx and tx rings. thisDavid Gwynne
diff expands them so devices that need more packets per interrupt can use them. this is all from brad@ tested by jim smith and benjamin perrault on APUs tested by me on 8139s (which dont support bit rings) on landisk, and 8169s
2015-10-25arp_ifinit() is no longer needed.Martin Pieuchot
2015-09-04add support for RTL8168HJonathan Gray
tedu tested an almost identical diff from brad that set the same flags.
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-04-13Initialize RX/TX on re(4) slightly later; it appears that newer chipsStuart Henderson
don't setup DMA correctly until more configuration has been done - enabling RX too soon causes DMA to bad places. KVM corruption problems reported by Adam Wolk on Lenovo G50-70 (RTL8111GU). Diff derived by Brad from FreeBSD commit; see bz# 197535 and 193743, inspired by https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=d6e572911a4cb2b9fcd1c26a38d5317a3971f2fd Tested on the following by Brad, Adam Wolk, box963 at gmail, Jim Smith re0 at pci4 dev 0 function 0 "Realtek 8168" rev 0x03: RTL8168D/8111D (0x2800), apic 2 int 16, address 00:0a:cd:1a:86:04 re0 at pci2 dev 0 function 0 "Realtek 8168" rev 0x0c: RTL8168G/8111G (0x4c00), msi, address 80:ee:73:76:8e:8a re0 at pci0 dev 3 function 0 "Realtek 8169" rev 0x10: RTL8110S (0x0400), ivec 0x78c, address 00:22:3f:ee:fa:25 re0 at pci1 dev 0 function 0 "Realtek 8168" rev 0x06: RTL8168E/8111E (0x2c00), msi, address 00:0d:b9:31:2e:88 re0 at pci1 dev 0 function 0 "Realtek 8168" rev 0x10: RTL8168GU/8111GU (0x5080), msi, address 68:f7:28:18:35:8e ok mpi@ dlg@
2015-03-20add support for jumbos on re(4).David Gwynne
this uses hints from the freebsd driver, but the implementation differs. freebsd manages two lists of rx descriptors. one for "normal" packets and the other for jumbos. this continues to use a single list and uses a per softc variable and MCLGETI to always allocate what the chip is capable and uses it unconditionally. other than that, we just need to enable some bits in some registers to be able to do jumbos. this relies on the previous commit to properly deal with checksum offload for packets of different sizes. from jim smith ok sthen@
2015-03-20some re(4) chips can do jumbos, but none of them can checksum jumboDavid Gwynne
packets. rather than disable cksum offload for all packets, this sets things up so we still advertise offload to the stack, but if the driver gets a large packet it does the checksum itself in software. small (normal sized) packets still get offloaded like now. if you're doing a jumbo you'll be doing the cksum in software, but will hopefully win overall cos you'll be doing a 6th of the work cos you're doing more data in every packet. diff from jim smith ok sthen@
2015-02-09tweak the new if_input function so it takes an mbuf_list insteadDavid Gwynne
of a single mbuf. this forces us to batch work between the hardware rx handlers and the stack. this includes a converstion of bge from ether_input to if_input. ok claudio@ pelikan@ mpi@
2015-02-08Convert to if_input().Martin Pieuchot
2015-01-21Add a comment above the autopad checking.Brad Smith
2015-01-21Use the RL_FLAG_AUTOPAD flag when trying to determine whenBrad Smith
to pad short frames.
2015-01-20Fix size of the bcopy when extracting the MAC address.Brad Smith
From FreeBSD
2015-01-20Remove use of the link change interrupt handling, not all controllersBrad Smith
support this interrupt. Link state changes are noticed via the PHY status change callback or via the timeout for re_tick(). From FreeBSD
2015-01-20Some fixes for handling link state changes.Brad Smith
2015-01-15Remove a variable no longer used in re_tick().Brad Smith
From Fabian Raetz <fabian dot raetz at gmail dot com>