Commit Graph

67 Commits

Author SHA1 Message Date
andvar 96c646f762 fix tripple/quadruple "r" letter typos in comments and log messages. 2024-02-04 18:52:35 +00:00
rin 4318e600c0 Correct byte-order for bufsize field of RX descriptor.
XXX
This bug affected only armeb. Unfortunately, the systems including
armel still lock up eventually with NFS root on mvgbe(4)...
2022-05-21 10:33:05 +00:00
rin 225d4a6d39 m_freem() *after* bus_dmamap_sync() and bus_dmamap_load() for
that mbuf. This is mandatory for some archs.
2022-05-21 10:27:30 +00:00
rin 98c5320acd Add DPRINTF() to catch failure of m_defrag() in mvgbe_encap(). 2022-05-21 10:24:50 +00:00
rin 29c35fffae Raise threshold of debug level to 3 for DPRINTF() in non-error path of
mvgbe_encap(). Without this change, debug level 2 is almost unusable...
2022-05-21 10:22:27 +00:00
rin f63a3328af Add ARMEB support to mvgbe(4).
For ARMEB, peripheral is configured to little-endian mode, even if
CPU itself is in big-endian mode. Therefore, we need to configure
the device to little-endian mode, and byte-swap descriptor fields
(unlike the case of powerpc).
2021-08-30 00:08:28 +00:00
thorpej c7fb772b85 Merge thorpej-cfargs2. 2021-08-07 16:18:40 +00:00
thorpej 2685996b0e Merge thorpej-cfargs branch:
Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
  actually needed.
- Don't be explicit about what interface attribute is attaching if
  the device only has one.  (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
  situations, making is visibly easier to see when indirect config is
  in play, and allowing for future change in semantics.  (As of now,
  this is just a wrapper around config_match(), but that is an
  implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance.  This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
2021-04-24 23:36:23 +00:00
skrll ed7083cb05 Adopt <net/if_stats.h> 2020-02-03 07:47:53 +00:00
msaitoh 70b25bc928 if_flags is neither int nor short. It's unsigned short. 2019-09-13 07:55:05 +00:00
msaitoh 8375928380 Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*. 2019-05-28 07:41:46 +00:00
msaitoh 5542e458a9 Whitespace fix (mainly tabify). 2019-05-23 13:10:50 +00:00
msaitoh 811add33d1 No functional change:
- Simplify MII structure initialization and reference.
 - u_int*_t -> uint*_t.
 - KNF
2019-05-23 10:51:38 +00:00
msaitoh 7de944bcbf On drivers which use MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.
2019-04-22 08:05:00 +00:00
msaitoh a5cdd4b441 Change MII PHY read/write API from:
int (*mii_readreg_t)(device_t, int, int);
	void (*mii_writereg_t)(device_t, int, int, int);
to:

	int (*mii_readreg_t)(device_t, int, int, uint16_t *);
	int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

 In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

 Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

	arm/at91/at91emac.c
	arm/ep93xx/epe.c
	arm/omap/omapl1x_emac.c
	mips/ralink/ralink_eth.c
	arch/powerpc/booke/dev/pq3etsec.c(read)
	dev/cadence/if_cemac.c <- hkenken
	dev/ic/lan9118.c


Tested with the following device:

	axe+ukphy
	axe+rgephy
	axen+rgephy	(tested by Andrius V)
	wm+atphy
	wm+ukphy
	wm+igphy
	wm+ihphy
	wm+makphy
	sk+makphy
	sk+brgphy
	sk+gentbi
	msk+makphy
	sip+icsphy
	sip+ukphy
	re+rgephy
	bge+brgphy
	bnx+brgphy
	gsip+gphyter
	rtk+rlphy
	fxp+inphy	(tested by Andrius V)
	tlp+acphy
	ex+exphy
	epic+qsphy
	vge+ciphy	(tested by Andrius V)
	vr+ukphy	(tested by Andrius V)
	vte+ukphy	(tested by Andrius V)

Not tested (MAC):
	arm:at91emac
	arm:cemac
	arm:epe
	arm:geminigmac
	arm:enet
	arm:cpsw
	arm:emac(omac)
	arm:emac(sunxi)
	arm:npe
	evbppc:temac
	macppc:bm
	macppc:gm
	mips:aumac
	mips:ae
	mips:cnmac
	mips:reth
	mips:sbmac
	playstation2:smap
	powerpc:tsec
	powerpc:emac(ibm4xx)
	sgimips:mec
	sparc:be
	sf
	ne(ax88190, dl10019)
	awge
	ep
	gem
	hme
	smsh
	mtd
	sm
	age
	alc
	ale
	bce
	cas
	et
	jme
	lii
	nfe
	pcn
	ste
	stge
	tl
	xi
	aue
	mue
	smsc
	udav
	url

Not tested (PHY):
	amhphy
	bmtphy
	dmphy
	etphy
	glxtphy
	ikphy
	iophy
	lxtphy
	nsphyter
	pnaphy
	rdcphy
	sqphy
	tlphy
	tqphy
	urlphy
2019-01-22 03:42:24 +00:00
jmcneill cce19cc266 Add intr_establish_xname support to arm and expose it to intrctl 2018-11-16 15:06:21 +00:00
riastradh d1579b2d70 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!)
2018-09-03 16:29:22 +00:00
msaitoh 3cd62456f9 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.
2018-06-26 06:47:57 +00:00
chs fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00
kiyohara ba749f27a4 Support Marvell Dove. 2017-01-07 14:24:27 +00:00
ozaki-r dd8638eea5 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
2016-12-15 09:28:02 +00:00
ozaki-r c0e7885f20 Apply deferred if_start framework
if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
2016-12-08 01:12:00 +00:00
ozaki-r d938d837b3 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.
2016-06-10 13:27:10 +00:00
hikaru 03068386e3 Pass all unicast addresses if it is promisc mode. 2016-02-13 08:44:22 +00:00
kiyohara 5e7343a705 Add more #warning message 'Please use mvxpe instead of this'. 2016-02-09 12:53:17 +00:00
ozaki-r 9c4cd06355 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!
2016-02-09 08:32:07 +00:00
hsuenaga c3635de7de add u-boot argument parser for Marvell ARMADA XP/370.
use 'ethaddr' and 'eth1addr' in u-boot argument to setup MAC address of mvgbe.
2015-04-15 10:15:40 +00:00
riastradh 233f556c2e Convert sys/dev to use <sys/rndsource.h>. 2015-04-13 16:33:23 +00:00
tls ea6af427bd Merge tls-earlyentropy branch into HEAD. 2014-08-10 16:44:32 +00:00
kiyohara c51a6569f3 Support Armada 370 and DDR3 tags. 2014-03-15 13:33:48 +00:00
pooka 4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
msaitoh 3443d04260 Carefully set IFF_OACTIVE in mvgbe_start(). Even if mvgbe_encap()
returns other than 0, the TX ring might not full. Check whether
the TX ring has one or more packets. If the ring is empty,
dont' set IFF_OACTIVE because an TX complete interrupt never
occur and IFF_OACTIVE flags is left. The interface's timer
isn't reset, so a device timeout desn't occur.

 Fixes a bug that IFF_OACTIVE flag is left on heavy load.
Part of PR#48568.
2014-02-03 05:56:23 +00:00
kiyohara 9745ea1238 Support Basic Mode for Armada XP. 2013-12-23 02:23:25 +00:00
msaitoh c73456fec2 Fix a bug that a multicast filter entry is incorrectly overrode
on some cases.
2012-12-28 08:16:53 +00:00
msaitoh a23ec4c8a4 Check wheter an MII PHY is really connected or not.
This change privents panic if MII PHY port is not used.
2012-12-20 10:01:28 +00:00
msaitoh af1c5c02a9 Add MVGBE_EVENT_COUNTERS for debugging. Count rxoverrrun and wdogsoft. 2012-11-09 09:04:19 +00:00
msaitoh 04c8bb64f2 Fix a bug that MVGBE_JLEN is miscalculated. 2012-11-08 15:39:29 +00:00
msaitoh c9fb3a9800 When an interrput is link change, notify link change to mii layer using
mii_pollstat().
2012-11-08 14:37:47 +00:00
msaitoh 4d1a9736e4 Don't use M_HASFCS flag. 2012-11-08 14:32:01 +00:00
msaitoh 5c86b9383c No functional change.
- Change style a bit.
- use "csc" for the variable name of struct mvgbec_softc in mvgbec_attach()
  for consistency.
2012-11-01 02:46:41 +00:00
msaitoh 68c182ec5d Add missing mii_tick() call. 2012-10-26 21:03:26 +00:00
msaitoh e8d66652c1 Fix a bug that kernel panics when the system get a packet while calling
mvgbe_stop (via ifconfig down).
2012-10-17 18:12:59 +00:00
msaitoh 1bf68f95d9 Add code to modify interrupt coalescing with sysctl.
- both TX side an RX side.
 - different setting for each port
 - TX side is hw.mvgbe.mvgbe*.ipginttx
 - RX side is hw.mvgbe.mvgbe*.ipgintrx
 - The default value is 768.
 - The lowest value is 0
 - For highest value, 0x3777 is used for V1, and 0xffff is used for V2.
2012-10-16 19:49:41 +00:00
msaitoh 3f974a9659 Add Interrupt Coalescing setting by Robert Swindells. 2012-10-14 19:17:08 +00:00
msaitoh cfbd580d96 - The MVGBE_RX_MAX_FRAME_LEN_ERROR bit is used to check whether a packet
is fragmented or not, so define new MVGBE_RX_IP_FRAGMENT with the same
  value and use it.
- Remove the checking whether a packet length is lower than 72 octet.
  This check is not used in Linux and FreeBSD. Tested with me (for Kirkwood)
  and Kiyohara (for DiscoveryII).
2012-10-12 10:38:06 +00:00
msaitoh 05a67a38f2 Fix udpcsum-rx bug on fragmented case this time.
- Fix the usage of a local variable for csum_flags.
  - It seemd that sometimes MVGBE_RX_L4_CHECKSUM_OK bit were set to 0
    even if the checksum is correct and the packet was not fragmented.
    So we don't set M_CSUM_TCP_UDP_BAD even if csum bit is 0.
2012-10-04 14:21:00 +00:00
msaitoh ca34255e60 - Fix a bug that a fragmented packet is marked as bad checksum. It causes
a real bug when HW checksum offload function is used. It was easy to
  reproduce with NFS UDP mount.
- Fix a potential bug that a packet other than TCP and UDP is marked as bad
  checksum.
2012-10-02 15:22:46 +00:00
msaitoh ba5d11d6ea Fix device timeout problem.
- Change the synching order of descriptors. First, sync descriptors except
  first and then sync the first descriptor.
- To recover from an race condition, reduce the if_timer from 5 to 1 and
  when timeout occur write MVGBE_TQC_ENQ bit again.
2012-09-21 00:26:15 +00:00
msaitoh 8d4dcb44cb Add missing bus_dmamap_sync() for the RX buffer. 2012-09-06 03:45:02 +00:00
matt 0bc3200029 Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
2012-07-22 14:32:49 +00:00