Commit graph

56 commits

Author SHA1 Message Date
Warner Losh fdafd315ad sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Warner Losh 685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh 95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Justin Hibbits d8b78838c5 tsec(4): Fix the build from IfAPI conversion
Fixes:		47842ecfe
Sponsored by:	Juniper Networks, Inc.
2023-02-06 15:23:52 -05:00
Justin Hibbits 47842ecfe0 Mechanically convert if_tsec(4) to IfAPI
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37805
2023-02-06 12:32:05 -05:00
John Baldwin 67eeba2682 tsec: Remove unused devclass argument to DRIVER_MODULE. 2022-05-10 10:21:39 -07:00
John Baldwin 3e38757d4c Remove unused miibus_devclass and miibus_fdt_devclass. 2022-05-06 15:39:28 -07:00
Gordon Bergling 5c0b62dcfc tsec: Fix a typo in a source code comment
- s/immediatly/immediately/

MFC after:	3 days
2022-04-02 10:48:37 +02:00
Mateusz Guzik 93a6b43939 tsec: clean up empty lines in .c and .h files 2020-09-01 21:50:21 +00:00
Pawel Biernacki 7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Gleb Smirnoff 5c973840f1 Convert to if_foreach_llmaddr() KPI. 2019-10-21 18:12:36 +00:00
Matt Macy d7c5a620e2 ifnet: Replace if_addr_lock rwlock with epoch + mutex
Run on LLNW canaries and tested by pho@

gallatin:
Using a 14-core, 28-HTT single socket E5-2697 v3 with a 40GbE MLX5
based ConnectX 4-LX NIC, I see an almost 12% improvement in received
packet rate, and a larger improvement in bytes delivered all the way
to userspace.

When the host receiving 64 streams of netperf -H $DUT -t UDP_STREAM -- -m 1,
I see, using nstat -I mce0 1 before the patch:

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
4.98   0.00   4.42   0.00 4235592     33   83.80 4720653 2149771   1235 247.32
4.73   0.00   4.20   0.00 4025260     33   82.99 4724900 2139833   1204 247.32
4.72   0.00   4.20   0.00 4035252     33   82.14 4719162 2132023   1264 247.32
4.71   0.00   4.21   0.00 4073206     33   83.68 4744973 2123317   1347 247.32
4.72   0.00   4.21   0.00 4061118     33   80.82 4713615 2188091   1490 247.32
4.72   0.00   4.21   0.00 4051675     33   85.29 4727399 2109011   1205 247.32
4.73   0.00   4.21   0.00 4039056     33   84.65 4724735 2102603   1053 247.32

After the patch

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
5.43   0.00   4.20   0.00 3313143     33   84.96 5434214 1900162   2656 245.51
5.43   0.00   4.20   0.00 3308527     33   85.24 5439695 1809382   2521 245.51
5.42   0.00   4.19   0.00 3316778     33   87.54 5416028 1805835   2256 245.51
5.42   0.00   4.19   0.00 3317673     33   90.44 5426044 1763056   2332 245.51
5.42   0.00   4.19   0.00 3314839     33   88.11 5435732 1792218   2499 245.52
5.44   0.00   4.19   0.00 3293228     33   91.84 5426301 1668597   2121 245.52

Similarly, netperf reports 230Mb/s before the patch, and 270Mb/s after the patch

Reviewed by:	gallatin
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D15366
2018-05-18 20:13:34 +00:00
Pedro F. Giffuni 718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Jason A. Harmening eb36b1d0bc Clean up MD pollution of bus_dma.h:
--Remove special-case handling of sparc64 bus_dmamap* functions.
  Replace with a more generic mechanism that allows MD busdma
  implementations to generate inline mapping functions by
  defining WANT_INLINE_DMAMAP in <machine/bus_dma.h>.  This
  is currently useful for sparc64, x86, and arm64, which all
  implement non-load dmamap operations as simple wrappers
  around map objects which may be bus- or device-specific.

--Remove NULL-checked bus_dmamap macros.  Implement the
  equivalent NULL checks in the inlined x86 implementation.
  For non-x86 platforms, these checks are a minor pessimization
  as those platforms do not currently allow NULL maps.  NULL
  maps were originally allowed on arm64, which appears to have
  been the motivation behind adding arm[64]-specific barriers
  to bus_dma.h, but that support was removed in r299463.

--Simplify the internal interface used by the bus_dmamap_load*
  variants and move it to bus_dma_internal.h

--Fix some drivers that directly include sys/bus_dma.h
  despite the recommendations of bus_dma(9)

Reviewed by:	kib (previous revision), marius
Differential Revision:	https://reviews.freebsd.org/D10729
2017-07-01 05:35:29 +00:00
Justin Hibbits 2fad65cfa0 Don't calltsec_receive_intr_locked() from the error interrupt handler.
The tsec_error_intr_locked() is called with the global lock owned (e.g.
the transmit and the receive lock are both owned).  We must not call
tsec_receive_intr_locked() while owning the transmit lock.  The normal
receive interrupt takes care that frames are received, this is none of
the business of the error interrupt.

Submitted by:	Sebastian Huber <sebastian.huber_AT_embedded-brains.de>
2017-04-04 02:55:55 +00:00
Justin Hibbits 2c0dbbcb8a Defragment the transmit mbuf chain only if necessary.
Use a method similar to the if_dwc driver.  Use a wmb() before the flags of the
first transmit buffer of a frame are written.

Group transmit/receive structure members for better cache efficiency.

Tested on P1020RDB.  TCP transmit throughput increases from 60MiB/s to
90MiB/s.

Submitted by:	Sebastian Huber <sebastian.huber_AT_embedded-brains.de>
2017-04-04 02:48:27 +00:00
Justin Hibbits 72b58db80f Fix mis-manual merge.
Timeout is now effectively a boolean rather than a time-remaining.  This was
missed in r316478, but included in the original patch (mis-merged with a manual
merge).
2017-04-04 02:37:41 +00:00
Justin Hibbits b11512cc9c Fix set-but-not-used warnings
Submitted by:	Sebastian Huber <sebastian_DOT_huber_AT_embedded-brains_DOT_de>
2017-04-04 00:46:48 +00:00
Justin Hibbits 88011b597f Use a common tsec_mii_wait() function to busy wait for status changes.
The status indicators are not set immediatly after a command.  Discard
the first value.

Unlock the PHY mutex after a timeout in tsec_init_locked().

Tested on the P1020RDB.

Submitted by:	Sebastian Huber <sebastian_DOT_huber_AT_embedded-brains_DOT_de>
2017-04-04 00:43:09 +00:00
Justin Hibbits e150821a8c Add support for NXP/Freescale etsec2 ethernet controller
Adding the compatible property check isn't enough.  Device trees for eTSEC2
devices are missing a 'reg' property on the eTSEC node itself, relegating it to
the queue group child nodes.

Still left to do: add Multigroup mode support (see QorIQ reference manuals s for
SoCs with eTSEC2).

MFC after:	2 weeks
Relnotes:	Yes
2016-08-30 01:58:49 +00:00
Justin Hibbits af20e818eb Add an alternate compatible string for eTSEC devices.
Newer device trees now use fsl,etsec2 to denote eTSEC nodes.  Same device, new
name.
2016-05-19 00:04:58 +00:00
Pedro F. Giffuni 453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Andrew Turner 45fd186285 Allow callers of OF_decode_addr to get the size of the found mapping. This
will allow for code that uses the old fdt_get_range and fdt_regsize
functions to find a range, map it, access, then unmap to replace this, up
to and including the map, with a call to OF_decode_addr.

As this function should only be used in the early boot code the unmap is
mostly do document we no longer need the mapping as it's a no-op, at least
on arm.

Reviewed by:	jhibbits
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5258
2016-02-16 15:18:12 +00:00
Justin Hibbits 38f004fbb0 Fix a couple printf formats.
This was found when working on 64-bit PowerPC book-e support.
2016-01-01 15:17:24 +00:00
Gleb Smirnoff c8dfaf382f Mechanically convert to if_inc_counter(). 2014-09-19 03:51:26 +00:00
Ian Lepore 752ba93078 Rename OF_xref_phandle() to OF_node_from_xref() and add a new function
that provides the inverse translation, OF_xref_from_node().

Discussed with:	nwhitehorn
2014-09-01 18:51:01 +00:00
Marcel Moolenaar aa5fed07eb Remove bogus module dependencies. 2014-07-26 17:57:13 +00:00
Ian Lepore add35ed5b8 Follow r261352 by updating all drivers which are children of simplebus
to check the status property in their probe routines.

Simplebus used to only instantiate its children whose status="okay"
but that was improper behavior, fixed in r261352.  Now that it doesn't
check anymore and probes all its children; the children all have to
do the check because really only the children know how to properly
interpret their status property strings.

Right now all existing drivers only understand "okay" versus something-
that's-not-okay, so they all use the new ofw_bus_status_okay() helper.
2014-02-02 19:17:28 +00:00
Nathan Whitehorn 629aa519d6 Make tsec work with the device tree present on the RB800. The previous code
assumed that the MDIO bus was a direct child of the Ethernet interface. It
may not be and indeed on many device trees is not. While here, add proper
locking for MII transactions, which may be on a bus shared by several MACs.

Hardware donated by:	Benjamin Perrault
2013-11-11 15:43:21 +00:00
Gleb Smirnoff 66e01d73cd - Provide necessary includes.
- Remove unnecessary includes.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2013-10-29 11:17:49 +00:00
Gleb Smirnoff 76039bc84f The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare
to this event, adding if_var.h to files that do need it. Also, include
all includes that now are included due to implicit pollution via if_var.h

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2013-10-26 17:58:36 +00:00
Gleb Smirnoff c6499eccad Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags in sys/dev.
2012-12-04 09:32:43 +00:00
Andrew Thompson afceeed703 Do not reinitialise the interface if it is already running, this prevents the
bootp+nfs code from working as it calls init on each dhcp send and rx fails to
start in time.
2012-05-09 00:56:11 +00:00
Andrew Thompson 335181759e The DEVICE_POLLING dereference of sc->tsec_ifp needs to be checked for null
first or this will panic. Condense three blocks that check sc->tsec_ifp into
one while I am here.
2012-05-08 21:09:03 +00:00
Rafal Jaworowski aa15e881bb Respect phy-handle property in Ethernet nodes of the device tree.
This lets specify whereabouts of the parent PHY for a given MAC node
(and get rid of ugly kludges in mge(4) and tsec(4)).

Obtained from:	Semihalf
MFC after:	1 week
2012-03-04 19:22:52 +00:00
Kevin Lo 5bbe0c5357 ether_ifattach() sets if_mtu to ETHERMTU, don't bother set it again
Reviewed by:	yongari
2012-01-07 09:41:57 +00:00
Marius Strobl 4b7ec27007 - There's no need to overwrite the default device method with the default
one. Interestingly, these are actually the default for quite some time
  (bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9)
  since r52045) but even recently added device drivers do this unnecessarily.
  Discussed with: jhb, marcel
- While at it, use DEVMETHOD_END.
  Discussed with: jhb
- Also while at it, use __FBSDID.
2011-11-22 21:28:20 +00:00
Marcel Moolenaar df0437ca6f Don't use the MAC address in the device tree if it's all zeroes
(i.e. 00-00-00-00-00-00). Use the currently programmed address
instead.

While here, simplify the function.
2011-01-28 23:40:13 +00:00
Marius Strobl 8e5d93dbb4 Convert the PHY drivers to honor the mii_flags passed down and convert
the NIC drivers as well as the PHY drivers to take advantage of the
mii_attach() introduced in r213878 to get rid of certain hacks. For
the most part these were:
- Artificially limiting miibus_{read,write}reg methods to certain PHY
  addresses; we now let mii_attach() only probe the PHY at the desired
  address(es) instead.
- PHY drivers setting MIIF_* flags based on the NIC driver they hang
  off from, partly even based on grabbing and using the softc of the
  parent; we now pass these flags down from the NIC to the PHY drivers
  via mii_attach(). This got us rid of all such hacks except those of
  brgphy() in combination with bce(4) and bge(4), which is way beyond
  what can be expressed with simple flags.

While at it, I took the opportunity to change the NIC drivers to pass
up the error returned by mii_attach() (previously by mii_phy_probe())
and unify the error message used in this case where and as appropriate
as mii_attach() actually can fail for a number of reasons, not just
because of no PHY(s) being present at the expected address(es).

Reviewed by:	jhb, yongari
2010-10-15 14:52:11 +00:00
Rafal Jaworowski d1d3233ebd Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:

  - MPC8555CDS
  - MPC8572DS

This overhaul covers the following major changes:

  - All integrated peripherals drivers for Freescale MPC85XX SoC, which are
    currently in the FreeBSD source tree are reworked and adjusted so they
    derive config data out of the device tree blob (instead of hard coded /
    tabelarized values).

  - This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
    QUICC, UART, CFI.

  - Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
    ocpbus(4) driver, which was based on hard-coded config data.

Note that world for these platforms has to be built WITH_FDT.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
Rafal Jaworowski 04311706d0 tsec: Use IFQ_DRV macros for managing interface packet queue.
This lets tsec(4) work with ALTQ.

Submitted by:	Marcin Ligenza
MFC after:	1 week
2009-11-20 13:28:06 +00:00
Robert Watson eb956cd041 Use if_maddr_rlock()/if_maddr_runlock() rather than IF_ADDR_LOCK()/
IF_ADDR_UNLOCK() across network device drivers when accessing the
per-interface multicast address list, if_multiaddrs.  This will
allow us to change the locking strategy without affecting our driver
programming interface or binary interface.

For two wireless drivers, remove unnecessary locking, since they
don't actually access the multicast address list.

Approved by:	re (kib)
MFC after:	6 weeks
2009-06-26 11:45:06 +00:00
Rafal Jaworowski 661ee6eea5 Fix Book-E/MPC85XX build. Some prototypes were wrong and got revealed with
the recent kobj signature checking.
2009-06-13 08:57:04 +00:00
Attilio Rao 1abcdbd127 When user_frac in the polling subsystem is low it is going to busy the
CPU for too long period than necessary.  Additively, interfaces are kept
polled (in the tick) even if no more packets are available.
In order to avoid such situations a new generic mechanism can be
implemented in proactive way, keeping track of the time spent on any
packet and fragmenting the time for any tick, stopping the processing
as soon as possible.

In order to implement such mechanism, the polling handler needs to
change, returning the number of packets processed.
While the intended logic is not part of this patch, the polling KPI is
broken by this commit, adding an int return value and the new flag
IFCAP_POLLING_NOCOUNT (which will signal that the return value is
meaningless for the installed handler and checking should be skipped).

Bump __FreeBSD_version in order to signal such situation.

Reviewed by:	emaste
Sponsored by:	Sandvine Incorporated
2009-05-30 15:14:44 +00:00
Rafal Jaworowski fb20e2aeac tsec(4) cosmetics. 2009-02-17 16:02:45 +00:00
Rafal Jaworowski 371bf7cc81 tsec(4): Always try to resume the receiver.
This helps recover from RX stall under heavy loads.

Submitted by:	Piotr Ziecik kosmo ! semihalf dot com
2009-02-17 15:59:27 +00:00
Rafal Jaworowski 0390701af8 tsec(4): do not clear interrupt events register before use.
Prior to this fix, IEVENT register was always cleared before calling
tsec_error_intr_locked(), which prevented error recovery actions from
happening with polling enabled (and could lead to serious problems, including
controller hang).

Submitted by:	Marcin Ligenza marcinl ! pacomp dot com dot pl
2009-02-17 15:47:13 +00:00
Rafal Jaworowski ab160495d3 Handle mbuf exhaustion scenario in tsec(4).
Without this fix the system would hang under heavy networking load.

Submitted by:	Leon Theunissen leon ! parsec dot co dot za
2009-02-17 15:39:16 +00:00
Rafal Jaworowski 64f90c9dff tsec(4) style improvements and clean-up. 2009-02-17 14:59:47 +00:00