Home | History | Annotate | Download | only in broadcom
History log of /src/sys/arch/arm/broadcom/bcm53xx_eth.c
RevisionDateAuthorComments
 1.46  04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.45  04-Dec-2024  andvar s/transmite/transmitte/ in comments.
 1.44  16-Feb-2024  skrll branches: 1.44.2;
Test sc->sc_soft_ih (not sc->sc_ih) to see if the soft interrupt got
established correctly.

From Mori Hiroki.

Fix some error recovery while I'm here.
 1.43  16-Feb-2024  skrll Fix non-DIAGNOSTIC build
 1.42  17-Sep-2022  thorpej branches: 1.42.4;
Eliminate use of IFF_OACTIVE.
 1.41  16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.40  03-Feb-2020  skrll branches: 1.40.10;
Adopt <net/if_stats.h>
 1.39  30-Oct-2019  msaitoh branches: 1.39.2;
ether_input() automatically add input bytes to if_ibytes, so it's not
required to do in the driver who use ether_input().
 1.38  29-May-2019  msaitoh branches: 1.38.2;
Remove unused variable.
 1.37  29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.36  29-May-2019  msaitoh KNF. No functional change.
 1.35  26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.34  08-Mar-2019  msaitoh s/ the the / the /
 1.33  22-Dec-2018  maxv Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.
 1.32  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.31  26-Jun-2018  msaitoh branches: 1.31.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.30  23-Oct-2017  msaitoh branches: 1.30.2;
If error occured in bcmeth_ccb_attach(), free resources and return.
 1.29  15-Dec-2016  ozaki-r branches: 1.29.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.28  10-Jun-2016  ozaki-r branches: 1.28.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.27  09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.26  23-Feb-2014  matt branches: 1.26.6;
#include <arm/locore.h>
 1.25  28-Oct-2013  matt branches: 1.25.2;
Add support for the BCM56340 iProc based switch
 1.24  19-Feb-2013  matt branches: 1.24.2;
As with pax, use cf_flags 2 to indicate to use the bounce dma tag.
 1.23  19-Jan-2013  matt Remove a KASSERT that is no longer valid (no restricted to only coherent
memory).
Fix c&p error for a !RCVMAGIC bus_dmamap_sync PREREAD.
 1.22  10-Jan-2013  matt Don't hard code the frequency used for INTRCVLAZY but grab the correct
frequency from the cpu_softc.
 1.21  09-Jan-2013  matt Don't rely on PKTTYPE in the rxsts since it becomes unreliable.
 1.20  25-Dec-2012  matt Change the way rx are consumed. Only consume a 1/4 of the receive buffers
before refilling with new buffers. Don't stop until there are no packets
left to receive.
 1.19  19-Dec-2012  matt Use max_linkhdr to determine what rcvoffset to program.
 1.18  07-Dec-2012  matt Make evcnt'ers optional.
 1.17  08-Nov-2012  matt branches: 1.17.2;
Reduce burstlen for RCV/XMT from 128bits to 96bits.
 1.16  08-Nov-2012  matt Make sure to 0 sc_work_flags in ifstop.
return immediately in ifstart if IFF_RUNNING is not set.
Make RCVMAGIC checks conditional
Release softc lock when calling if_input.
 1.15  01-Nov-2012  matt If IFF_LINK2 is set, copy all transmitted packets into a single mbuf to
avoid DMA corruption problems with chained buffers.
Fix various conditions with setting INTMASK.
 1.14  26-Oct-2012  matt branches: 1.14.2;
When writing intmask from a softint/workqueue thread, make sure to do so
only with the hwlock locked.
 1.13  26-Oct-2012  matt Use atomic_ops to manipulate sc_intmask
 1.12  18-Oct-2012  matt Make an ASSERT more "flexible".
 1.11  17-Oct-2012  matt Add a coherent bus dma tag which marks the first 256MB as having coherent
dma (but only for PCIe and ethernet). Make the ethernet and PCIe attachments
use this tag instead of the default non-coherent one.
 1.10  12-Oct-2012  matt Add some defensive code to deal with "issues" of this interface.
Seems it can't do DMA updates of the rxsts for mbufs with addresses
>= 256MB. It can't also seem to properly read from the descriptor rings
if they are < 256MB. And I have no idea why either should matter.
 1.9  08-Oct-2012  matt Initialize the workqueue to use IPL_NET for its mutex.
Prefer softints if the current lwp is the idle lwp.
 1.8  07-Oct-2012  matt Don't just rely on softints for handling rx traffic since that can starve
the system and eventually cause a watchdog timer to reset. Instead use
softints for "small" number of packets and use a workqueue thread for large
numbers. This allows receive processing to be handling at normal priorities
and won't starve out other parts of the system.
 1.7  06-Oct-2012  matt Always set IC for each receive descriptor.
Make sure to produce rx descriptors even if you stop at the end of the ring.
 1.6  05-Oct-2012  matt Modify setting of PROMISC flag.
 1.5  05-Oct-2012  matt Fix setting of ethernet address.
Don't set HASFCS
 1.4  05-Oct-2012  matt Set IC after clearing flags.
Insert RCVOFFSET correctly.
 1.3  05-Oct-2012  matt Make sure to set IC in receive descritors. Initial ET at end of ring.
Set INTRCVLAZY to collesce 10 packets or 1ms delay.
 1.2  04-Oct-2012  matt Ethernet driver for BCM53XXX (not quite working).
 1.1  01-Sep-2012  matt branches: 1.1.2;
Add initial device support for the Broadcom BCM5301x family.
 1.1.2.4  03-Dec-2017  jdolecek update from HEAD
 1.1.2.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.2  25-Feb-2013  tls resync with head
 1.1.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.14.2.5  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.2.4  23-Jan-2013  yamt sync with head
 1.14.2.3  16-Jan-2013  yamt sync with (a bit old) head
 1.14.2.2  30-Oct-2012  yamt sync with head
 1.14.2.1  26-Oct-2012  yamt file bcm53xx_eth.c was added on branch yamt-pagecache on 2012-10-30 17:18:59 +0000
 1.17.2.5  19-Feb-2013  matt Sync with HEAD.
 1.17.2.4  07-Feb-2013  matt Sync bcm53xx support to HEAD.
 1.17.2.3  07-Dec-2012  matt Sync with HEAD.
 1.17.2.2  28-Nov-2012  matt Merge improved arm support (especially Cortex) from HEAD
including OMAP and BCM53xx support.
 1.17.2.1  08-Nov-2012  matt file bcm53xx_eth.c was added on branch matt-nb6-plus on 2012-11-28 22:40:22 +0000
 1.24.2.1  18-May-2014  rmind sync with head
 1.25.2.2  15-Feb-2014  matt Merge armv7 support from HEAD, specifically support for the BCM5301X
and BCM56340 evbarm kernels.
 1.25.2.1  28-Oct-2013  matt file bcm53xx_eth.c was added on branch matt-nb5-mips64 on 2014-02-15 16:18:36 +0000
 1.26.6.3  05-Feb-2017  skrll Sync with HEAD
 1.26.6.2  09-Jul-2016  skrll Sync with HEAD
 1.26.6.1  19-Mar-2016  skrll Sync with HEAD
 1.28.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.29.8.2  06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.29.8.1  10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.30.2.3  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.30.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.30.2.1  28-Jul-2018  pgoyette Sync with HEAD
 1.31.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.31.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.31.2.1  10-Jun-2019  christos Sync with HEAD
 1.38.2.1  06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.39.2.1  29-Feb-2020  ad Sync with head.
 1.40.10.1  17-Jun-2021  thorpej Sync w/ HEAD.
 1.42.4.2  18-Feb-2024  martin Pull up following revision(s) (requested by skrll in ticket #599):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.44

Test sc->sc_soft_ih (not sc->sc_ih) to see if the soft interrupt got
established correctly.

From Mori Hiroki.

Fix some error recovery while I'm here.
 1.42.4.1  18-Feb-2024  martin Pull up following revision(s) (requested by skrll in ticket #597):

sys/arch/evbarm/conf/std.bcm53xx: revision 1.21
sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.43
sys/arch/arm/broadcom/bcm53xx_pax.c: revision 1.23

Define KERNEL_VOFFSET_RUNTIME=1 to fix build of BCM5301X and BCM56340

Fix non-DIAGNOSTIC build
 1.44.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed