Commit Graph

73 Commits

Author SHA1 Message Date
Warner Losh
031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06: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
Gordon Bergling
b73763fc10 vnic: Fix a typo in a source code comment
- s/Enabele/Enable/

MFC after:	3 days
2023-08-02 09:33:35 +02:00
Ed Maste
5e95f5f531 thunderx: fix potential sign extension issue
Coverity reported a sign extension issue on rq->caching << 26 in the
Linux ThunderX driver.  (It appears Coverity Scan doesn't build arm64
objects in FreeBSD.)

As done in Linux, add a cast.

Fixes: 3c0086b813 ("Raw import of ThunderX VNIC networking driver...")
Sponsored by: The FreeBSD Foundation
2023-03-01 09:48:17 -05:00
Justin Hibbits
b9545c5794 Mechanically convert vnic to IfAPI
Reviewed by:	zlei
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37827
2023-02-07 14:16:17 -05:00
Warner Losh
a67c0fae0c vnic: work_done here only used for debug
Sponsored by:		Netflix
2022-10-25 10:57:29 -06:00
John Baldwin
94412ad7d9 vnic: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-09 14:26:46 -07:00
John Baldwin
3e38757d4c Remove unused miibus_devclass and miibus_fdt_devclass. 2022-05-06 15:39:28 -07:00
John Baldwin
216536350a vnic: Use __diagused for variables only used in KASSERT(). 2022-04-13 16:08:23 -07:00
Gordon Bergling
fafb1c574d vnic: Fix a typo in a comment
- s/setings/settings/

MFC after:	3 days
2021-10-02 10:47:21 +02:00
Ed Maste
9feff969a0 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder (in the associated license block).

Sponsored by:	The FreeBSD Foundation
2021-08-08 10:42:24 -04:00
Ed Maste
29e9b487c1 vnic: add TODO list item for multicast filter support
PR:		223573
2021-07-28 14:09:32 -04:00
Andrew Turner
c007408c24 Fix the spelling of '*/' in the vnic driver
Sponsored by:	The FreeBSD Foundation
2021-07-27 19:45:03 +00:00
Ed Maste
941650aae9 vnic: add TODO list item for non-promisc mode
Also drop ARM64TODO comments; this is an issue with this specific
driver, not a general arm64 issue.

PR:		223575
2021-07-27 20:09:01 -04:00
Mateusz Guzik
78ee240673 vnic: clean up empty lines in .c and .h files 2020-09-01 21:48:21 +00:00
Ed Maste
aeb665b538 remove extraneous double ;s in sys/ 2020-03-30 16:04:25 +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
Mark Johnston
6074a3c0f4 vnic: Relax PHY node matching after r336281.
The phy name may apparently be followed by a number in some systems.
Allow that.

PR:		242654
Reported and tested by:	Marcel <marcel@brickporch.com>
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2019-12-18 21:41:53 +00:00
Ed Maste
73f4b4ebac vnic: correct and simplify SIOCSIFFLAGS
PR:		223573, 223575
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13028
2019-09-01 16:53:17 +00:00
Ed Maste
3485f4574e vnic: avoid NULL deref in error case
Reported by:	Dr Silvio Cesare of InfoSect
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2019-08-29 12:05:06 +00:00
Mark Johnston
f6982511f8 Fix vnic fallback PHY name matching after r334880.
In some cases it seems that the PHY mode can only be identified by
matching against the corresponding device node name in the FDT.  r334880
broke this for the case where the node name contains a unit address.
Fix the problem by allowing a match in that case.

Reviewed by:	andrew, sbruno
Tested by:	sbruno
Differential Revision:	https://reviews.freebsd.org/D16259
2018-07-14 16:06:53 +00:00
Andrew Turner
c11862c030 In the ThunderX BGX network driver we were skipping the NULL terminator
when parsing the phy type, however this is included in the length returned
by OF_getprop. To fix this stop ignoring the terminator.

PR:		228828
Reported by:	sbruno
Sponsored by:	DARPA, AFRL
2018-06-09 14:47:49 +00:00
Oleksandr Tymoshenko
f7604b1b27 Align OF_getencprop_alloc API with OF_getencprop and OF_getprop_alloc
Change OF_getencprop_alloc semantics to be combination of malloc and
OF_getencprop and return size of the property, not number of elements
allocated.

For the use cases where number of elements is preferred introduce
OF_getencprop_alloc_multi helper function that copies semantics
of OF_getencprop_alloc prior to this change.

This is to make OF_getencprop_alloc and OF_getencprop_alloc_multi
function signatures consistent with OF_getencprop_alloc and
OF_getencprop_alloc_multi.

Functionality-wise this patch is mostly rename of OF_getencprop_alloc
to OF_getencprop_alloc_multi except two calls in ofw_bus_setup_iinfo
where 1 was used as a block size.
2018-04-09 22:06:16 +00:00
Oleksandr Tymoshenko
217d17bcd3 Clean up OF_getprop_alloc API
OF_getprop_alloc takes element size argument and returns number of
elements in the property. There are valid use cases for such behavior
but mostly API consumers pass 1 as element size to get string
properties. What API users would expect from OF_getprop_alloc is to be
a combination of malloc + OF_getprop with the same semantic of return
value. This patch modifies API signature to match these expectations.

For the valid use cases with element size != 1 and to reduce
modification scope new OF_getprop_alloc_multi function has been
introduced that behaves the same way OF_getprop_alloc behaved prior to
this patch.

Reviewed by:	ian, manu
Differential Revision:	https://reviews.freebsd.org/D14850
2018-04-08 22:59:34 +00:00
Oleksandr Tymoshenko
108117cc22 [ofw] fix errneous checks for OF_finddevice(9) return value
OF_finddevices returns ((phandle_t)-1) in case of failure. Some code
in existing drivers checked return value to be equal to 0 or
less/equal to 0 which is also wrong because phandle_t is unsigned
type. Most of these checks were for negative cases that were never
triggered so trhere was no impact on functionality.

Reviewed by:	nwhitehorn
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D14645
2018-03-20 00:03:49 +00:00
Pedro F. Giffuni
ac2fffa4b7 Revert r327828, r327949, r327953, r328016-r328026, r328041:
Uses of mallocarray(9).

The use of mallocarray(9) has rocketed the required swap to build FreeBSD.
This is likely caused by the allocation size attributes which put extra pressure
on the compiler.

Given that most of these checks are superfluous we have to choose better
where to use mallocarray(9). We still have more uses of mallocarray(9) but
hopefully this is enough to bring swap usage to a reasonable level.

Reported by:	wosch
PR:		225197
2018-01-21 15:42:36 +00:00
Pedro F. Giffuni
26c1d774b5 dev: make some use of mallocarray(9).
Focus on code where we are doing multiplications within malloc(9). None of
these is likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.
2018-01-13 22:30:30 +00:00
Alexander Kabaev
151ba7933a Do pass removing some write-only variables from the kernel.
This reduces noise when kernel is compiled by newer GCC versions,
such as one used by external toolchain ports.

Reviewed by: kib, andrew(sys/arm and sys/arm64), emaste(partial), erj(partial)
Reviewed by: jhb (sys/dev/pci/* sys/kern/vfs_aio.c and sys/kern/kern_synch.c)
Differential Revision: https://reviews.freebsd.org/D10385
2017-12-25 04:48:39 +00:00
Ed Maste
7fe94db265 vnic: apply hardware L3 checksum only for IPv4
Previously we set the csum_l3 flag for IPv4 and IPv6, but only IPv4
should have header checksumming applied.

Prompted by Linux commit fa6d7cb5d76cf0467c61420fc9238045aedfd379.

Reviewed by:	bz
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13366
2017-12-05 22:02:46 +00:00
Bjoern A. Zeeb
c04716b1ad Unbreak IPv6.
No longer return ENXIO when trying to send an IPv6 packet in
nicvf_sq_add_hdr_subdesc().
Restructure the code so that the upper layer protocol parts are
agnostic of the L3 protocol (and no longer specific to IPv4).
With this basic IPv6 packets go through.  We are still seeing
weird behaviour which needs further diagnosis.

PR:			223669
In collaboration with:	emaste
MFC after:		3 days
2017-11-14 16:47:05 +00:00
Ed Maste
3bfef74a1f vnic: report that the driver supports multicast
The driver is currently hardcoded to force promiscuous mode, so all of
the MAC filtering code is presently unused and multicast should "just
work."  Report to the higher layers that multicast is supported.

PR:		223573
Reported by:	bz
Sponsored by:	The FreeBSD Foundation, Packet.net (hardware)
2017-11-14 16:31:11 +00:00
Ed Maste
2dc620ac83 vnic: apply BPF tap before passing packet to hardware
Previously we passed tx packets to hardware via nicvf_tx_mbuf_locked
and then to the BPF tap, with a possibly invalid mbuf which would result
in a panic.

PR:		223600
Discussed with:	bz
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation, Packet.net (hardware)
2017-11-10 22:17:30 +00:00
Zbigniew Bodek
19fbe8bdbc Rework BGX detection to support both new and old firmware
Improve existing BGX detection and adjust it to support both
new and older ThunderX firmwares. Match BGX FDT nodes by name
and reg. Match PHY instances by qlm-mode and name.
Tested on Firmware Version: 2016-09-30 09:12:11

Obtained from:	Semihalf
Differential Revision:	https://reviews.freebsd.org/D9863
2017-03-31 18:04:34 +00:00
Stephen J. Kiernan
d0b2cad1ca Add the folowing set accessor functions for recently-added members of ifnet
structure:

if_gethwtsomax(), if_sethwtsomax()                 - if_hw_tsomax
if_gethwtsomaxsegcount(), if_sethwtsomaxsegcount() - if_hw_tsomaxsegcount
if_gethwtsomaxsegsize(), if_sethwtsomaxsegsize()   - if_hw_tsomaxsegsize

Update em and vnic drivers which had already been coverted to use accessor
functions for the other ifnet structure members.

Reviewed by:	erj
Approved by:	sjg (mentor)
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D8544
2017-01-31 16:12:31 +00:00
Michal Meloun
895c8b1c39 INTRNG: Rework handling with resources. Partially revert r301453.
- Read interrupt properties at bus enumeration time and store
   it into global mapping table.
 - At bus_activate_resource() time, given mapping entry is resolved and
   connected to real interrupt source. A copy of mapping entry is attached
   to given resource.
 - At bus_setup_intr() time, mapping entry stored in resource is used
   for delivery of requested interrupt configuration.
 - For MSI/MSIX interrupts, mapping entry is created within
   pci_alloc_msi()/pci_alloc_msix() call.
 - For legacy PCI interrupts, mapping entry must be created within
   pcib_route_interrupt() by pcib driver itself.

Reviewed by: nwhitehorn, andrew
Differential Revision: https://reviews.freebsd.org/D7493
2016-08-19 10:52:39 +00:00
Svatopluk Kraus
ad5244ece1 INTRNG - change the way how an interrupt mapping data are provided
to the framework in OFW (FDT) case.

This is a follow-up to r301451.

Differential Revision:	https://reviews.freebsd.org/D6634
2016-06-05 16:20:12 +00:00
Wojciech Macek
7056927eb8 Fix VNIC module unloading
Fix panics which were present when BGX and PF module were unloaded.

Reviewed by:	zbb
Obtained from:	Semihalf
Sponsored by:	Cavium
Differential Revision:	https://reviews.freebsd.org/D6346
2016-05-20 11:02:04 +00:00
Wojciech Macek
f4aafb9ea6 Allow building VNIC as a module
Add directory structure and fix dependencies to be able to
build and use Cavium VNIC driver as a module.

Reviewed by:	zbb
Obtained from:	Semihalf
Sponsored by:	Cavium
Differential Revision:	https://reviews.freebsd.org/D6345
2016-05-20 11:00:06 +00:00
Zbigniew Bodek
0ef477ea8c Add support for MTU chaning and Jumbo frames to VNIC
Enable previously added code for MTU handling (based on
Cavium 1.0 driver released on BSD license).
This commit enables possibility to change MTU on VNIC driver.

Obtained from: Semihalf
Sponsored by:  Cavium
2016-05-11 13:42:20 +00:00
Zbigniew Bodek
f6cdb4ceb3 Fix deadlock in VNIC when using single CPU only
Number of free Tx descriptors does not need to be locked since
it can be modified atomically between SND and CQ tasks.
It will also block Tx routine from sending packets while CQ will not
be able to free descriptors.

Obtained from:	Semihalf
Sponsored by:	Cavium
Differential Revision: https://reviews.freebsd.org/D6266
2016-05-11 13:38:29 +00:00
Zbigniew Bodek
8191a87959 Add HW RSS support to VNIC driver
Based on v1.0 driver provided by Cavium under BSD license.
Support in-hardware RSS to distribute IP, UDP and TCP traffic
among available RX Queues and hence multiple CPUs.

Reviewed by:	wma
Obtained from:	Semihalf
Sponsored by:	Cavium
Differential Revision: https://reviews.freebsd.org/D6230
2016-05-11 13:22:13 +00:00
Zbigniew Bodek
ec6f8f42db Bind CQ interrupts and tasks to separate CPUs in VNIC
Delegate interrupts and completion tasks on separate CPUs
for each VNIC.

Reviewed by:	wma
Obtained from:	Semihalf
Sponsored by:	Cavium
Differential Revision: https://reviews.freebsd.org/D6229
2016-05-11 13:20:29 +00:00
Zbigniew Bodek
db6eff694c Fix sending TSO packets larger than single DMA segment on VNIC
Due to the bug in the number of 'GATHER' subdescriptors for TSO
packets, VNIC was not able to transmit more than one DMA segment
with TSO enabled.

Obtained from: Semihalf
Sponsored by:  Cavium
2016-04-08 16:14:18 +00:00
Wojciech Macek
d416a65514 Speedup BGX link polling on ARM64
The previous values caused the callout thread stall for 100ms each 2s
if no link is present. Dtrace analysis showed that it has significant
impact on overall interrupt performance.
Decrease these values by a factor of 100.

Obtained from:         Semihalf
Sponsored by:          Cavium
Reviewed by:           zbb
Differential Revision: https://reviews.freebsd.org/D5854
2016-04-08 11:20:56 +00:00
Sepherosa Ziehau
6dd38b8716 tcp/lro: Use tcp_lro_flush_all in device drivers to avoid code duplication
And factor out tcp_lro_rx_done, which deduplicates the same logic with
netinet/tcp_lro.c

Reviewed by:	gallatin (1st version), hps, zbb, np, Dexuan Cui <decui microsoft com>
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5725
2016-04-01 06:28:33 +00:00
Zbigniew Bodek
4764669155 Fix number of the enabled VFs in VNIC
nic->num_vf_en is set based on the number of the enabled LMACs.
This number should not be overwritten later by any routine.
Instead it should fail PCI_IOV_ADD_VF() so that available VFs
with the corresponding LMACs will attach whereas other, disabled
VFs will fail with the proper error code.
Error signaling (due to improper number of VFs requested) is also moved
from PCI_IOV_INIT() to PCI_IOV_ADD_VF().

This will be reworked when multiple queue sets are enabled but for
now this is the correct behavior of the driver.

Obtained from: Semihalf
Sponsored by:  Cavium
2016-03-31 16:44:32 +00:00
Zbigniew Bodek
36a947e91e Don't omit m_dup() for non-writeable mbufs that need checksum calculation
If the driver is not active or link is down the packet could remain
non-writeable. This commit makes all mbufs enqueued to the driver's
ring buffer to have correct attributes.

Pointed out by: wma
Reviewed by:    wma
Obtained from:  Semihalf
Sponsored by:   Cavium
Differential Revision: https://reviews.freebsd.org/D5800
2016-03-31 13:23:43 +00:00
Zbigniew Bodek
316e15b4cc Fix MAC address configuration for VNIC
The FDT description is as follows:
- phy-handle, reg, qlm-mode, mac-address are under nodes in bgx0/1 node
- phy nodes (pointed by phy-handle) are under MDIO even though they may
  not be connected through to MDIO. In those nodes they do not contain
  MAC address or etc.

This commit changes parsing of the FDT nodes for BGX so that it can
obtain correct MAC address for a given PHY.

Reviewed by:   wma
Obtained from: Semihalf
Sponsored by:  Cavium
Differential Revision: https://reviews.freebsd.org/D5781
2016-03-31 13:13:38 +00:00
Zbigniew Bodek
7c617ace70 Improve TX path of the VNIC driver
- Avoid memory leak when nicvf_tx_mbuf_locked() fails
- Introduce nicvf_xmit_locked() routine that uses drbr_peek(),
  drbr_advance() or drbr_putback() for a specific ifnet.
  This gives more clear and efficient design as well as
  prevents from dropping mbufs that where not sent due to temporary
  lack of descriptors.
- Add missing ETHER_BPF_MTAP() hook

Pointed out by: yongari
Reviewed by:    wma
Obtained from:  Semihalf
Sponsored by:   Cavium
Differential Revision: https://reviews.freebsd.org/D5534
2016-03-31 13:10:29 +00:00