Commit graph

485 commits

Author SHA1 Message Date
Mark Johnston 50505c853c bge: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Gordon Bergling d646dca3bc bge(4): Fix some typos in source code comments
- s/firwmare/firmware/
- s/recue/reduce/
- s/throughpout/throughput/
- s/hardwares/hardware/

Obtainted from:	NetBSD
MFC after:	3 days
2024-02-22 20:40:10 +01:00
Justin Hibbits 2a3716432d IfAPI: Retire if_etherbpfmtap() and if_bpfmtap()
Summary:
These came in the original DrvAPI commits in 2014, and are obsoleted by
bpf_mtap_if() and ether_bpf_mtap_if().  The `_if` suffix, rather than
prefix, conveys that it's operating on the bpf of the interface, instead
than the interface itself.

Reviewed by:	glebius
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D41146
2023-08-25 12:50:14 -04: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
Justin Hibbits 087f0d352a Mechanically convert bge(4) to DrvAPI
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37842
2023-01-31 15:02:18 -05:00
Gordon Bergling de47bf0d52 bge(4): Fix a typo in a source code comment
- s/overriden/overridden/

MFC after:	3 days
2022-09-03 15:38:26 +02:00
Eric van Gyzen 3ca4a33903 bge: tell debugnet there are 2 rx rings, not 1,024
debugnet provides the network stack for netgdb and netdump.  Since it
must operate under panic/debugger conditions and can't rely on dynamic
memory allocation, it preallocates mbufs during boot or network
configuration.  At that time, it does not yet know which interface
will be used for debugging, so it does not know the required size and
quantity of mbufs to allocate.  It takes the worst-case approach by
calculating its requirements from the largest MTU and largest number
of receive queues across all interfaces that support debugnet.

Unfortunately, the bge NIC driver told debugnet that it supports 1,024
receive queues.  It actually supports only 2 queues (with 1,024 slots,
thus the error).  This greatly exaggerated debugnet's preallocation,
so with an MTU of 9000 on any interface, it allocated 600 MB of memory.
A tiny fraction of this memory would be used if netgdb or netdump were
invoked; the rest is completely wasted.

Reviewed by:	markj, rlibby
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D35845
2022-07-18 16:05:18 -05:00
John Baldwin d628b8c9e7 bge: Remove unused devclass argument to DRIVER_MODULE. 2022-05-06 15:39:29 -07:00
John Baldwin 3e38757d4c Remove unused miibus_devclass and miibus_fdt_devclass. 2022-05-06 15:39:28 -07:00
Scott Long 1c64538f58 Fix "set but not used" for bge
Sponsored by: Rubicon Communications, LLC ("Netgate")
2021-12-03 23:29:51 -07:00
Marius Strobl 6535f188f1 bge(4): remove obsolete support for on-board Fujitsu and Sun MACs
It's no longer used since 58aa35d429
and r357455 respectively.
2020-12-25 20:04:19 +01:00
Mateusz Guzik b410de8ad2 bge: clean up empty lines in .c and .h files 2020-09-01 21:42:49 +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 6c3e93cb5a Use NET_TASK_INIT() and NET_GROUPTASK_INIT() for drivers that process
incoming packets in taskqueue context.

Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D23518
2020-02-11 18:57:07 +00:00
Warner Losh 58aa35d429 Remove sparc64 kernel support
Remove all sparc64 specific files
Remove all sparc64 ifdefs
Removee indireeect sparc64 ifdefs
2020-02-03 17:35:11 +00:00
Gleb Smirnoff 976d7cecd5 With MSI interrupts bge(4) just schedules taskqueue. Enter the network
epoch in the taskqueue handler.

Reported by:	kib
2020-01-23 16:36:58 +00:00
Gleb Smirnoff 0322ca23bc Convert to if_foreach_llmaddr() KPI. 2019-10-21 18:06:26 +00:00
Conrad Meyer 7790c8c199 Split out a more generic debugnet(4) from netdump(4)
Debugnet is a simplistic and specialized panic- or debug-time reliable
datagram transport.  It can drive a single connection at a time and is
currently unidirectional (debug/panic machine transmit to remote server
only).

It is mostly a verbatim code lift from netdump(4).  Netdump(4) remains
the only consumer (until the rest of this patch series lands).

The INET-specific logic has been extracted somewhat more thoroughly than
previously in netdump(4), into debugnet_inet.c.  UDP-layer logic and up, as
much as possible as is protocol-independent, remains in debugnet.c.  The
separation is not perfect and future improvement is welcome.  Supporting
INET6 is a long-term goal.

Much of the diff is "gratuitous" renaming from 'netdump_' or 'nd_' to
'debugnet_' or 'dn_' -- sorry.  I thought keeping the netdump name on the
generic module would be more confusing than the refactoring.

The only functional change here is the mbuf allocation / tracking.  Instead
of initiating solely on netdump-configured interface(s) at dumpon(8)
configuration time, we watch for any debugnet-enabled NIC for link
activation and query it for mbuf parameters at that time.  If they exceed
the existing high-water mark allocation, we re-allocate and track the new
high-water mark.  Otherwise, we leave the pre-panic mbuf allocation alone.
In a future patch in this series, this will allow initiating netdump from
panic ddb(4) without pre-panic configuration.

No other functional change intended.

Reviewed by:	markj (earlier version)
Some discussion with:	emaste, jhb
Objection from:	marius
Differential Revision:	https://reviews.freebsd.org/D21421
2019-10-17 16:23:03 +00:00
Andriy Gapon a70e114dc6 bge: check that the bus is a pci bus before using it as such
This fixes the following panic on powerpc:
  pci_get_vendor failed for pcib1 on bus ofwbus0, error = 2

PR:		238730
Reported by:	Dennis Clarke <dclarke@blastwave.org>
Tested by:	Dennis Clarke <dclarke@blastwave.org>
MFC after:	2 weeks
2019-07-16 08:36:49 +00:00
Tycho Nightingale 2acae6bf7f Remove unused define.
Sponsored by:	Dell EMC Isilon
2019-05-17 13:08:12 +00:00
Tycho Nightingale 344f8c0062 Fix integer overflow in r346386.
Sponsored by:	Dell EMC Isilon
2019-05-16 22:27:38 +00:00
Tycho Nightingale e86fa024ac reinstate 4GB DMA boundary workarounds for bge and aac
Reviewed by:	kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D20277
2019-05-16 20:41:28 +00:00
Tycho Nightingale 96ca24dc32 remove the 4GB boundary requirement on PCI DMA segments
Reviewed by:	kib
Discussed with:	jhb
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D19867
2019-04-19 13:43:33 +00:00
Warner Losh 329e817fcc Reapply, with minor tweaks, r338025, from the original commit:
Remove unused and easy to misuse PNP macro parameter

Inspired by r338025, just remove the element size parameter to the
MODULE_PNP_INFO macro entirely.  The 'table' parameter is now required to
have correct pointer (or array) type.  Since all invocations of the macro
already had this property and the emitted PNP data continues to include the
element size, there is no functional change.

Mostly done with the coccinelle 'spatch' tool:

  $ cat modpnpsize0.cocci
    @normaltables@
    identifier b,c;
    expression a,d,e;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,d,
    -sizeof(d[0]),
     e);

    @singletons@
    identifier b,c,d;
    expression a;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,&d,
    -sizeof(d),
     1);

  $ rg -l MODULE_PNP_INFO -- sys | \
    xargs spatch --in-place --sp-file modpnpsize0.cocci

(Note that coccinelle invokes diff(1) via a PATH search and expects diff to
tolerate the -B flag, which BSD diff does not.  So I had to link gdiff into
PATH as diff to use spatch.)

Tinderbox'd (-DMAKE_JUST_KERNELS).
Approved by: re (glen)
2018-09-26 17:12:14 +00:00
Conrad Meyer b8e771e97a Back out r338035 until Warner is finished churning GSoC PNP patches
I was not aware Warner was making or planning to make forward progress in
this area and have since been informed of that.

It's easy to apply/reapply when churn dies down.
2018-08-19 00:46:22 +00:00
Conrad Meyer faa319436f Remove unused and easy to misuse PNP macro parameter
Inspired by r338025, just remove the element size parameter to the
MODULE_PNP_INFO macro entirely.  The 'table' parameter is now required to
have correct pointer (or array) type.  Since all invocations of the macro
already had this property and the emitted PNP data continues to include the
element size, there is no functional change.

Mostly done with the coccinelle 'spatch' tool:

  $ cat modpnpsize0.cocci
    @normaltables@
    identifier b,c;
    expression a,d,e;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,d,
    -sizeof(d[0]),
     e);

    @singletons@
    identifier b,c,d;
    expression a;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,&d,
    -sizeof(d),
     1);

  $ rg -l MODULE_PNP_INFO -- sys | \
    xargs spatch --in-place --sp-file modpnpsize0.cocci

(Note that coccinelle invokes diff(1) via a PATH search and expects diff to
tolerate the -B flag, which BSD diff does not.  So I had to link gdiff into
PATH as diff to use spatch.)

Tinderbox'd (-DMAKE_JUST_KERNELS).
2018-08-19 00:22:21 +00:00
Dimitry Andric a06da7bafe Use the size of one bge_devs element for the MODULE_PNP_INFO macro,
instead of the size of the whole bge_devs array.

This should stop kldxref searching beyond the end of .rodata when it
processes relocations, and emitting "unhandled relocation type" errors,
at least on i386.
2018-08-18 20:41:43 +00:00
Cy Schubert 4732295d5c As non-sparc64 undconditionally returns 1, simplify #ifdefs.
MFC after:	1 week
2018-08-01 02:59:56 +00:00
Eugene Grosbein 91c69b972e bge(4): disable MSI for BGE_ASICREV_BCM5784/BGE_CHIPREV_5784_AX
found in some MacBook Pro.

PR:		229727
Reported by:	Stephan Neuhaus <sten@artdecode.de> and others
Tested by:	Stephan Neuhaus <sten@artdecode.de>
Approved by:	mav (mentor)
MFC after:	1 month
2018-07-18 18:28:17 +00:00
Warner Losh ea72f463b2 Add PNP info to PCI attachments of bge driver
Reviewed by: imp, chuck
Submitted by: Lakhan Shiva Kamireddy <lakhanshiva@gmail.com>
Sponsored by: Google, Inc. (GSoC 2018)
Differential Revision: https://reviews.freebsd.org/D15995
2018-07-08 20:40:01 +00:00
Mark Johnston ded669627a Add netdump hooks to bge(4).
Tested with a NetXtreme BCM5727 adapter.

Reviewed by:	julian
MFC after:	1 month
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D15256
2018-05-06 00:45:41 +00:00
Pedro F. Giffuni df57947f08 spdx: initial adoption of licensing ID tags.
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.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133
2017-11-18 14:26:50 +00:00
Sepherosa Ziehau 1ca32af8f2 bge: Force chipid to 5720 A0 for 5717 C0 in an early place
Discussed with:	yongari
MFC after:	1 week
Sponsored by:	Microsoft OSTC
2016-06-01 05:15:11 +00:00
Sepherosa Ziehau cb2404b4ad bge: Support 5717 C0, which is almost same as 5720 A0
PR:		209758
Obtained from:	DragonFlyBSD d79f5d8f5fe94cd6769207b2901422977d502bc0
MFC after:	1 week
2016-05-30 06:49:01 +00:00
Pedro F. Giffuni 049855d88f bge(4): Small memory leak
CID:		1229985
Reviewed by:	marcel
Differential Review:	https://reviews.freebsd.org/D2024
2015-03-08 19:55:46 +00:00
Robert Watson 2a8c860fe3 In order to reduce use of M_EXT outside of the mbuf allocator and
socket-buffer implementations, introduce a return value for MCLGET()
(and m_cljget() that underlies it) to allow the caller to avoid testing
M_EXT itself.  Update all callers to use the return value.

With this change, very few network device drivers remain aware of
M_EXT; the primary exceptions lie in mbuf-chain pretty printers for
debugging, and in a few cases, custom mbuf and cluster allocation
implementations.

NB: This is a difficult-to-test change as it touches many drivers for
which I don't have physical devices.  Instead we've gone for intensive
review, but further post-commit review would definitely be appreciated
to spot errors where changes could not easily be made mechanically,
but were largely mechanical in nature.

Differential Revision:	https://reviews.freebsd.org/D1440
Reviewed by:	adrian, bz, gnn
Sponsored by:	EMC / Isilon Storage Division
2015-01-06 12:59:37 +00:00
Marius Strobl 40438c4761 - Make PCI_QUIRK_MSI_INTX_BUG work by using the ID of the actual PCI device
for the lookup.
- For devices affected by PCI_QUIRK_MSI_INTX_BUG, ensure PCIM_CMD_INTxDIS
  is cleared when using MSI/MSI-X.
- Employ PCI_QUIRK_MSI_INTX_BUG for BCM5714(S)/BCM5715(S)/BCM5780(S) rather
  than clearing PCIM_CMD_INTxDIS unconditionally for all devices in bge(4).

MFC after:	3 days
2014-12-27 14:26:18 +00:00
Gleb Smirnoff bd071d4d19 - Remove empty wrappers ether_poll_[de]register_drv(). [1]
- Move polling(9) declarations out of ifq.h back to if_var.h
  they are absolutely unrelated to queues.

Submitted by:	Mikhail <mp lenta.ru> [1]
2014-09-28 14:05:18 +00:00
Gleb Smirnoff df3601781d - Use if_inc_counter() to increment various counters.
- Do not ever set a counter to a value. For those counters
  that we don't increment, but return directly from hardware
  create cases in if_get_counter() method.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2014-09-18 15:56:14 +00:00
Gleb Smirnoff 09a8241fc9 It is actually possible to have if_t a typedef to non-void type,
and keep both converted to drvapi and non-converted drivers
compilable.

o Make if_t typedef to struct ifnet *.
o Remove shim functions.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2014-08-31 12:48:13 +00:00
Peter Wemm a127e581c5 Fix an apparent conversion error in bge to the new driver api.
if_multiaddr_array() does the LLADDR work, don't do it twice.

This broke IPv6 in "interesting" ways in the FreeBSD.org cluster.
2014-07-18 07:41:38 +00:00
Sergey Kandaurov 59578ee028 Fixed build with DEVICE_POLLING. 2014-07-02 21:08:25 +00:00
Marcel Moolenaar 4a81240ca7 Fix off-by-one introduced by the conversion to the driver API.
Submitted by:   Sreekanth Rupavatharam <rupavath@juniper.net>
Obtained from:  Juniper Networks, Inc.
2014-07-02 16:17:48 +00:00
Marcel Moolenaar fba8b10966 Convert bge(4) to use the driver API.
Submitted by:   Sreekanth Rupavatharam <rupavath@juniper.net>
Obtained from:  Juniper Networks, Inc.
2014-07-01 19:50:47 +00:00
Hans Petter Selasky af3b2549c4 Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
Glen Barber 37a107a407 Revert r267961, r267973:
These changes prevent sysctl(8) from returning proper output,
such as:

 1) no output from sysctl(8)
 2) erroneously returning ENOMEM with tools like truss(1)
    or uname(1)
 truss: can not get etype: Cannot allocate memory
2014-06-27 22:05:21 +00:00
Hans Petter Selasky 3da1cf1e88 Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after:	2 weeks
Sponsored by:	Mellanox Technologies
2014-06-27 16:33:43 +00:00
John Baldwin 068d8643ad Fix various NIC drivers to properly cleanup static DMA resources.
In particular, don't check the value of the bus_dma map against NULL
to determine if either bus_dmamem_alloc() or bus_dmamap_load() succeeded.
Instead, assume that bus_dmamap_load() succeeeded (and thus that
bus_dmamap_unload() should be called) if the bus address for a resource
is non-zero, and assume that bus_dmamem_alloc() succeeded (and thus
that bus_dmamem_free() should be called) if the virtual address for a
resource is not NULL.

In many cases these bugs could result in leaks when a driver was detached.

Reviewed by:	yongari
MFC after:	2 weeks
2014-06-11 14:53:58 +00:00
Pyun YongHyeon 52ee8ac027 Increase the number of TX DMA segments from 32 to 35. It turned
out 32 is not enough to support a full sized TSO packet.
While I'm here fix a long standing bug introduced in r169632 in
bce(4) where it didn't include L2 header length of TSO packet in
the maximum DMA segment size calculation.

In collaboration with:	rmacklem
MFC after:		2 weeks
2014-03-31 01:54:59 +00:00