2016-05-18 04:35:58 +00:00
|
|
|
/*-
|
2017-12-19 17:59:00 +00:00
|
|
|
* Copyright (c) 2014-2017, Matthew Macy (mmacy@mattmacy.io)
|
2016-05-18 04:35:58 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Neither the name of Matthew Macy nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
#ifndef __IFLIB_H_
|
|
|
|
#define __IFLIB_H_
|
|
|
|
|
|
|
|
#include <sys/kobj.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/cpuset.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/nv.h>
|
2016-08-12 21:29:44 +00:00
|
|
|
#include <sys/gtaskqueue.h>
|
2016-05-18 04:35:58 +00:00
|
|
|
|
2018-05-11 20:08:28 +00:00
|
|
|
struct if_clone;
|
|
|
|
|
2017-03-13 22:53:06 +00:00
|
|
|
/*
|
|
|
|
* The value type for indexing, limits max descriptors
|
|
|
|
* to 65535 can be conditionally redefined to uint32_t
|
|
|
|
* in the future if the need arises.
|
|
|
|
*/
|
|
|
|
typedef uint16_t qidx_t;
|
|
|
|
#define QIDX_INVALID 0xFFFF
|
2016-05-18 04:35:58 +00:00
|
|
|
|
|
|
|
struct iflib_ctx;
|
|
|
|
typedef struct iflib_ctx *if_ctx_t;
|
|
|
|
struct if_shared_ctx;
|
|
|
|
typedef struct if_shared_ctx *if_shared_ctx_t;
|
|
|
|
struct if_int_delay_info;
|
|
|
|
typedef struct if_int_delay_info *if_int_delay_info_t;
|
2018-05-11 20:08:28 +00:00
|
|
|
struct if_pseudo;
|
|
|
|
typedef struct if_pseudo *if_pseudo_t;
|
2016-05-18 04:35:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* File organization:
|
|
|
|
* - public structures
|
|
|
|
* - iflib accessors
|
|
|
|
* - iflib utility functions
|
|
|
|
* - iflib core functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct if_rxd_frag {
|
|
|
|
uint8_t irf_flid;
|
2017-03-13 22:53:06 +00:00
|
|
|
qidx_t irf_idx;
|
2016-08-12 21:29:44 +00:00
|
|
|
uint16_t irf_len;
|
2016-05-18 04:35:58 +00:00
|
|
|
} *if_rxd_frag_t;
|
|
|
|
|
2019-01-22 01:11:17 +00:00
|
|
|
/* bnxt supports 64 with hardware LRO enabled */
|
|
|
|
#define IFLIB_MAX_RX_SEGS 64
|
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
typedef struct if_rxd_info {
|
|
|
|
/* set by iflib */
|
|
|
|
uint16_t iri_qsidx; /* qset index */
|
|
|
|
uint16_t iri_vtag; /* vlan tag - if flag set */
|
2016-08-12 21:29:44 +00:00
|
|
|
/* XXX redundant with the new irf_len field */
|
2016-05-18 04:35:58 +00:00
|
|
|
uint16_t iri_len; /* packet length */
|
2017-03-13 22:53:06 +00:00
|
|
|
qidx_t iri_cidx; /* consumer index of cq */
|
2019-05-06 20:56:41 +00:00
|
|
|
if_t iri_ifp; /* driver may have >1 iface per softc */
|
2016-05-18 04:35:58 +00:00
|
|
|
|
|
|
|
/* updated by driver */
|
2017-03-13 22:53:06 +00:00
|
|
|
if_rxd_frag_t iri_frags;
|
2016-05-18 04:35:58 +00:00
|
|
|
uint32_t iri_flowid; /* RSS hash for packet */
|
|
|
|
uint32_t iri_csum_flags; /* m_pkthdr csum flags */
|
2017-03-13 22:53:06 +00:00
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
uint32_t iri_csum_data; /* m_pkthdr csum data */
|
2017-03-13 22:53:06 +00:00
|
|
|
uint8_t iri_flags; /* mbuf flags for packet */
|
2016-05-18 04:35:58 +00:00
|
|
|
uint8_t iri_nfrags; /* number of fragments in packet */
|
|
|
|
uint8_t iri_rsstype; /* RSS hash type */
|
|
|
|
uint8_t iri_pad; /* any padding in the received data */
|
|
|
|
} *if_rxd_info_t;
|
|
|
|
|
2017-03-13 22:53:06 +00:00
|
|
|
typedef struct if_rxd_update {
|
|
|
|
uint64_t *iru_paddrs;
|
|
|
|
qidx_t *iru_idxs;
|
|
|
|
qidx_t iru_pidx;
|
|
|
|
uint16_t iru_qsidx;
|
|
|
|
uint16_t iru_count;
|
|
|
|
uint16_t iru_buf_size;
|
|
|
|
uint8_t iru_flidx;
|
|
|
|
} *if_rxd_update_t;
|
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
#define IPI_TX_INTR 0x1 /* send an interrupt when this packet is sent */
|
|
|
|
#define IPI_TX_IPV4 0x2 /* ethertype IPv4 */
|
|
|
|
#define IPI_TX_IPV6 0x4 /* ethertype IPv6 */
|
|
|
|
|
|
|
|
typedef struct if_pkt_info {
|
2017-03-13 22:53:06 +00:00
|
|
|
bus_dma_segment_t *ipi_segs; /* physical addresses */
|
|
|
|
uint32_t ipi_len; /* packet length */
|
|
|
|
uint16_t ipi_qsidx; /* queue set index */
|
|
|
|
qidx_t ipi_nsegs; /* number of segments */
|
|
|
|
|
|
|
|
qidx_t ipi_ndescs; /* number of descriptors used by encap */
|
|
|
|
uint16_t ipi_flags; /* iflib per-packet flags */
|
|
|
|
qidx_t ipi_pidx; /* start pidx for encap */
|
|
|
|
qidx_t ipi_new_pidx; /* next available pidx post-encap */
|
2016-05-18 04:35:58 +00:00
|
|
|
/* offload handling */
|
2017-03-13 22:53:06 +00:00
|
|
|
uint8_t ipi_ehdrlen; /* ether header length */
|
|
|
|
uint8_t ipi_ip_hlen; /* ip header length */
|
|
|
|
uint8_t ipi_tcp_hlen; /* tcp header length */
|
|
|
|
uint8_t ipi_ipproto; /* ip protocol */
|
|
|
|
|
|
|
|
uint32_t ipi_csum_flags; /* packet checksum flags */
|
|
|
|
uint16_t ipi_tso_segsz; /* tso segment size */
|
|
|
|
uint16_t ipi_vtag; /* VLAN tag */
|
|
|
|
uint16_t ipi_etype; /* ether header type */
|
|
|
|
uint8_t ipi_tcp_hflags; /* tcp header flags */
|
|
|
|
uint8_t ipi_mflags; /* packet mbuf flags */
|
|
|
|
|
|
|
|
uint32_t ipi_tcp_seq; /* tcp seqno */
|
2019-06-15 11:07:41 +00:00
|
|
|
uint32_t __spare0__;
|
2016-05-18 04:35:58 +00:00
|
|
|
} *if_pkt_info_t;
|
|
|
|
|
|
|
|
typedef struct if_irq {
|
|
|
|
struct resource *ii_res;
|
2019-06-15 11:07:41 +00:00
|
|
|
int __spare0__;
|
2016-05-18 04:35:58 +00:00
|
|
|
void *ii_tag;
|
|
|
|
} *if_irq_t;
|
|
|
|
|
|
|
|
struct if_int_delay_info {
|
|
|
|
if_ctx_t iidi_ctx; /* Back-pointer to the iflib ctx (softc) */
|
|
|
|
int iidi_offset; /* Register offset to read/write */
|
|
|
|
int iidi_value; /* Current value in usecs */
|
|
|
|
struct sysctl_oid *iidi_oidp;
|
|
|
|
struct sysctl_req *iidi_req;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
IFLIB_INTR_LEGACY,
|
|
|
|
IFLIB_INTR_MSI,
|
|
|
|
IFLIB_INTR_MSIX
|
|
|
|
} iflib_intr_mode_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This really belongs in pciio.h or some place more general
|
|
|
|
* but this is the only consumer for now.
|
|
|
|
*/
|
|
|
|
typedef struct pci_vendor_info {
|
|
|
|
uint32_t pvi_vendor_id;
|
|
|
|
uint32_t pvi_device_id;
|
|
|
|
uint32_t pvi_subvendor_id;
|
|
|
|
uint32_t pvi_subdevice_id;
|
|
|
|
uint32_t pvi_rev_id;
|
|
|
|
uint32_t pvi_class_mask;
|
2019-06-15 11:07:41 +00:00
|
|
|
const char *pvi_name;
|
2016-05-18 04:35:58 +00:00
|
|
|
} pci_vendor_info_t;
|
|
|
|
#define PVID(vendor, devid, name) {vendor, devid, 0, 0, 0, 0, name}
|
|
|
|
#define PVID_OEM(vendor, devid, svid, sdevid, revid, name) {vendor, devid, svid, sdevid, revid, 0, name}
|
|
|
|
#define PVID_END {0, 0, 0, 0, 0, 0, NULL}
|
|
|
|
|
2020-03-24 19:20:10 +00:00
|
|
|
/* No drivers in tree currently match on anything except vendor:device. */
|
|
|
|
#define IFLIB_PNP_DESCR "U32:vendor;U32:device;U32:#;U32:#;" \
|
|
|
|
"U32:#;U32:#;D:#"
|
2017-09-26 23:23:58 +00:00
|
|
|
#define IFLIB_PNP_INFO(b, u, t) \
|
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
|
|
|
MODULE_PNP_INFO(IFLIB_PNP_DESCR, b, u, t, nitems(t) - 1)
|
2017-09-26 23:23:58 +00:00
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
typedef struct if_txrx {
|
|
|
|
int (*ift_txd_encap) (void *, if_pkt_info_t);
|
2017-03-13 22:53:06 +00:00
|
|
|
void (*ift_txd_flush) (void *, uint16_t, qidx_t pidx);
|
|
|
|
int (*ift_txd_credits_update) (void *, uint16_t qsidx, bool clear);
|
2016-05-18 04:35:58 +00:00
|
|
|
|
2017-03-13 22:53:06 +00:00
|
|
|
int (*ift_rxd_available) (void *, uint16_t qsidx, qidx_t pidx, qidx_t budget);
|
2016-05-18 04:35:58 +00:00
|
|
|
int (*ift_rxd_pkt_get) (void *, if_rxd_info_t ri);
|
2017-03-13 22:53:06 +00:00
|
|
|
void (*ift_rxd_refill) (void * , if_rxd_update_t iru);
|
|
|
|
void (*ift_rxd_flush) (void *, uint16_t qsidx, uint8_t flidx, qidx_t pidx);
|
2016-05-18 04:35:58 +00:00
|
|
|
int (*ift_legacy_intr) (void *);
|
|
|
|
} *if_txrx_t;
|
|
|
|
|
|
|
|
typedef struct if_softc_ctx {
|
|
|
|
int isc_vectors;
|
|
|
|
int isc_nrxqsets;
|
|
|
|
int isc_ntxqsets;
|
2019-06-15 11:07:41 +00:00
|
|
|
uint16_t __spare0__;
|
|
|
|
uint32_t __spare1__;
|
2016-05-18 04:35:58 +00:00
|
|
|
int isc_msix_bar; /* can be model specific - initialize in attach_pre */
|
|
|
|
int isc_tx_nsegments; /* can be model specific - initialize in attach_pre */
|
2016-08-12 21:29:44 +00:00
|
|
|
int isc_ntxd[8];
|
|
|
|
int isc_nrxd[8];
|
|
|
|
|
|
|
|
uint32_t isc_txqsizes[8];
|
|
|
|
uint32_t isc_rxqsizes[8];
|
2017-03-13 22:53:06 +00:00
|
|
|
/* is there such thing as a descriptor that is more than 248 bytes ? */
|
|
|
|
uint8_t isc_txd_size[8];
|
|
|
|
uint8_t isc_rxd_size[8];
|
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
int isc_tx_tso_segments_max;
|
|
|
|
int isc_tx_tso_size_max;
|
|
|
|
int isc_tx_tso_segsize_max;
|
2017-01-02 00:56:33 +00:00
|
|
|
int isc_tx_csum_flags;
|
Assorted TSO fixes for em(4)/iflib(9) and dead code removal:
- Ever since the workaround for the silicon bug of TSO4 causing MAC hangs
was committed in r295133, CSUM_TSO always got disabled unconditionally
by em(4) on the first invocation of em_init_locked(). However, even with
that problem fixed, it turned out that for at least e. g. 82579 not all
necessary TSO workarounds are in place, still causing MAC hangs even at
Gigabit speed. Thus, for stable/11, TSO usage was deliberately disabled
in r323292 (r323293 for stable/10) for the EM-class by default, allowing
users to turn it on if it happens to work with their particular EM MAC
in a Gigabit-only environment.
In head, the TSO workaround for speeds other than Gigabit was lost with
the conversion to iflib(9) in r311849 (possibly along with another one
or two TSO workarounds). Yet at the same time, for EM-class MACs TSO4
got enabled by default again, causing device hangs. Therefore, change the
default for this hardware class back to have TSO4 off, allowing users
to turn it on manually if it happens to work in their environment as
we do in stable/{10,11}. An alternative would be to add a whitelist of
EM-class devices where TSO4 actually is reliable with the workarounds in
place, but given that the advantage of TSO at Gigabit speed is rather
limited - especially with the overhead of these workarounds -, that's
really not worth it. [1]
This change includes the addition of an isc_capabilities to struct
if_softc_ctx so iflib(9) can also handle interface capabilities that
shouldn't be enabled by default which is used to handle the default-off
capabilities of e1000 as suggested by shurd@ and moving their handling
from em_setup_interface() to em_if_attach_pre() accordingly.
- Although 82543 support TSO4 in theory, the former lem(4) didn't have
support for TSO4, presumably because TSO4 is even more broken in the
LEM-class of MACs than the later EM ones. Still, TSO4 for LEM-class
devices was enabled as part of the conversion to iflib(9) in r311849,
causing device hangs. So revert back to the pre-r311849 behavior of
not supporting TSO4 for LEM-class at all, which includes not creating
a TSO DMA tag in iflib(9) for devices not having IFCAP_TSO4 set. [2]
- In fact, the FreeBSD TCP stack can handle a TSO size of IP_MAXPACKET
(65535) rather than FREEBSD_TSO_SIZE_MAX (65518). However, the TSO
DMA must have a maxsize of the maximum TSO size plus the size of a
VLAN header for software VLAN tagging. The iflib(9) converted em(4),
thus, first correctly sets scctx->isc_tx_tso_size_max to EM_TSO_SIZE
in em_if_attach_pre(), but later on overrides it with IP_MAXPACKET
in em_setup_interface() (apparently, left-over from pre-iflib(9)
times). So remove the later and correct iflib(9) to correctly cap
the maximum TSO size reported to the stack at IP_MAXPACKET. While at
it, let iflib(9) use if_sethwtsomax*().
This change includes the addition of isc_tso_max{seg,}size DMA engine
constraints for the TSO DMA tag to struct if_shared_ctx and letting
iflib_txsd_alloc() automatically adjust the maxsize of that tag in case
IFCAP_VLAN_MTU is supported as requested by shurd@.
- Move the if_setifheaderlen(9) call for adjusting the maximum Ethernet
header length from {ixgbe,ixl,ixlv,ixv,em}_setup_interface() to iflib(9)
so adjustment is automatically done in case IFCAP_VLAN_MTU is supported.
As a consequence, this adjustment now is also done in case of bnxt(4)
which missed it previously.
- Move the reduction of the maximum TSO segment count reported to the
stack by the number of m_pullup(9) calls (which in the worst case,
can add another mbuf and, thus, the requirement for another DMA
segment each) in the transmit path for performance reasons from
em_setup_interface() to iflib_txsd_alloc() as these pull-ups are now
done in iflib_parse_header() rather than in the no longer existing
em_xmit(). Moreover, this optimization applies to all drivers using
iflib(9) and not just em(4); all in-tree iflib(9) consumers still
have enough room to handle full size TSO packets. Also, reduce the
adjustment to the maximum number of m_pullup(9)'s now performed in
iflib_parse_header().
- Prior to the conversion of em(4)/igb(4)/lem(4) and ixl(4) to iflib(9)
in r311849 and r335338 respectively, these drivers didn't enable
IFCAP_VLAN_HWFILTER by default due to VLAN events not being passed
through by lagg(4). With iflib(9), IFCAP_VLAN_HWFILTER was turned on
by default but also lagg(4) was fixed in that regard in r203548. So
just remove the now redundant and defunct IFCAP_VLAN_HWFILTER handling
in {em,ixl,ixlv}_setup_interface().
- Nuke other redundant IFCAP_* setting in {em,ixl,ixlv}_setup_interface()
which is (more completely) already done in {em,ixl,ixlv}_if_attach_pre()
now.
- Remove some redundant/dead setting of scctx->isc_tx_csum_flags in
em_if_attach_pre().
- Remove some IFCAP_* duplicated either directly or indirectly (e. g.
via IFCAP_HWCSUM) in {EM,IGB,IXL}_CAPS.
- Don't bother to fiddle with IFCAP_HWSTATS in ixgbe(4)/ixgbev(4) as
iflib(9) adds that capability unconditionally.
- Remove some unused macros from em(4).
- Bump __FreeBSD_version as some of the above changes require the modules
of drivers using iflib(9) to be recompiled.
Okayed by: sbruno@ at 201806 DevSummit Transport Working Group [1]
Reviewed by: sbruno (earlier version), erj
PR: 219428 (part of; comment #10) [1], 220997 (part of; comment #3) [2]
Differential Revision: https://reviews.freebsd.org/D15720
2018-07-15 19:04:23 +00:00
|
|
|
int isc_capabilities;
|
2017-01-02 00:56:33 +00:00
|
|
|
int isc_capenable;
|
2016-05-18 04:35:58 +00:00
|
|
|
int isc_rss_table_size;
|
|
|
|
int isc_rss_table_mask;
|
2016-08-12 21:29:44 +00:00
|
|
|
int isc_nrxqsets_max;
|
|
|
|
int isc_ntxqsets_max;
|
2019-06-15 11:07:41 +00:00
|
|
|
uint32_t __spare2__;
|
2016-05-18 04:35:58 +00:00
|
|
|
|
|
|
|
iflib_intr_mode_t isc_intr;
|
2020-03-14 19:56:46 +00:00
|
|
|
uint16_t isc_rxd_buf_size[8]; /* set at init time by driver, 0
|
|
|
|
means use iflib-calculated size
|
|
|
|
based on isc_max_frame_size */
|
2016-05-18 04:35:58 +00:00
|
|
|
uint16_t isc_max_frame_size; /* set at init time by driver */
|
2017-12-05 21:00:31 +00:00
|
|
|
uint16_t isc_min_frame_size; /* set at init time by driver, only used if
|
|
|
|
IFLIB_NEED_ETHER_PAD is set. */
|
2017-04-07 00:33:03 +00:00
|
|
|
uint32_t isc_pause_frames; /* set by driver for iflib_timer to detect */
|
2019-06-15 11:07:41 +00:00
|
|
|
uint32_t __spare3__;
|
|
|
|
uint32_t __spare4__;
|
|
|
|
uint32_t __spare5__;
|
|
|
|
uint32_t __spare6__;
|
|
|
|
uint32_t __spare7__;
|
|
|
|
uint32_t __spare8__;
|
|
|
|
caddr_t __spare9__;
|
2017-04-04 21:03:34 +00:00
|
|
|
int isc_disable_msix;
|
2017-01-02 00:56:33 +00:00
|
|
|
if_txrx_t isc_txrx;
|
2019-05-03 20:05:31 +00:00
|
|
|
struct ifmedia *isc_media;
|
2021-02-24 22:56:45 +00:00
|
|
|
bus_size_t isc_dma_width; /* device dma width in bits, 0 means
|
|
|
|
use BUS_SPACE_MAXADDR instead */
|
2016-05-18 04:35:58 +00:00
|
|
|
} *if_softc_ctx_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialization values for device
|
|
|
|
*/
|
|
|
|
struct if_shared_ctx {
|
2018-02-21 18:57:00 +00:00
|
|
|
unsigned isc_magic;
|
2016-05-18 04:35:58 +00:00
|
|
|
driver_t *isc_driver;
|
|
|
|
bus_size_t isc_q_align;
|
|
|
|
bus_size_t isc_tx_maxsize;
|
|
|
|
bus_size_t isc_tx_maxsegsize;
|
Assorted TSO fixes for em(4)/iflib(9) and dead code removal:
- Ever since the workaround for the silicon bug of TSO4 causing MAC hangs
was committed in r295133, CSUM_TSO always got disabled unconditionally
by em(4) on the first invocation of em_init_locked(). However, even with
that problem fixed, it turned out that for at least e. g. 82579 not all
necessary TSO workarounds are in place, still causing MAC hangs even at
Gigabit speed. Thus, for stable/11, TSO usage was deliberately disabled
in r323292 (r323293 for stable/10) for the EM-class by default, allowing
users to turn it on if it happens to work with their particular EM MAC
in a Gigabit-only environment.
In head, the TSO workaround for speeds other than Gigabit was lost with
the conversion to iflib(9) in r311849 (possibly along with another one
or two TSO workarounds). Yet at the same time, for EM-class MACs TSO4
got enabled by default again, causing device hangs. Therefore, change the
default for this hardware class back to have TSO4 off, allowing users
to turn it on manually if it happens to work in their environment as
we do in stable/{10,11}. An alternative would be to add a whitelist of
EM-class devices where TSO4 actually is reliable with the workarounds in
place, but given that the advantage of TSO at Gigabit speed is rather
limited - especially with the overhead of these workarounds -, that's
really not worth it. [1]
This change includes the addition of an isc_capabilities to struct
if_softc_ctx so iflib(9) can also handle interface capabilities that
shouldn't be enabled by default which is used to handle the default-off
capabilities of e1000 as suggested by shurd@ and moving their handling
from em_setup_interface() to em_if_attach_pre() accordingly.
- Although 82543 support TSO4 in theory, the former lem(4) didn't have
support for TSO4, presumably because TSO4 is even more broken in the
LEM-class of MACs than the later EM ones. Still, TSO4 for LEM-class
devices was enabled as part of the conversion to iflib(9) in r311849,
causing device hangs. So revert back to the pre-r311849 behavior of
not supporting TSO4 for LEM-class at all, which includes not creating
a TSO DMA tag in iflib(9) for devices not having IFCAP_TSO4 set. [2]
- In fact, the FreeBSD TCP stack can handle a TSO size of IP_MAXPACKET
(65535) rather than FREEBSD_TSO_SIZE_MAX (65518). However, the TSO
DMA must have a maxsize of the maximum TSO size plus the size of a
VLAN header for software VLAN tagging. The iflib(9) converted em(4),
thus, first correctly sets scctx->isc_tx_tso_size_max to EM_TSO_SIZE
in em_if_attach_pre(), but later on overrides it with IP_MAXPACKET
in em_setup_interface() (apparently, left-over from pre-iflib(9)
times). So remove the later and correct iflib(9) to correctly cap
the maximum TSO size reported to the stack at IP_MAXPACKET. While at
it, let iflib(9) use if_sethwtsomax*().
This change includes the addition of isc_tso_max{seg,}size DMA engine
constraints for the TSO DMA tag to struct if_shared_ctx and letting
iflib_txsd_alloc() automatically adjust the maxsize of that tag in case
IFCAP_VLAN_MTU is supported as requested by shurd@.
- Move the if_setifheaderlen(9) call for adjusting the maximum Ethernet
header length from {ixgbe,ixl,ixlv,ixv,em}_setup_interface() to iflib(9)
so adjustment is automatically done in case IFCAP_VLAN_MTU is supported.
As a consequence, this adjustment now is also done in case of bnxt(4)
which missed it previously.
- Move the reduction of the maximum TSO segment count reported to the
stack by the number of m_pullup(9) calls (which in the worst case,
can add another mbuf and, thus, the requirement for another DMA
segment each) in the transmit path for performance reasons from
em_setup_interface() to iflib_txsd_alloc() as these pull-ups are now
done in iflib_parse_header() rather than in the no longer existing
em_xmit(). Moreover, this optimization applies to all drivers using
iflib(9) and not just em(4); all in-tree iflib(9) consumers still
have enough room to handle full size TSO packets. Also, reduce the
adjustment to the maximum number of m_pullup(9)'s now performed in
iflib_parse_header().
- Prior to the conversion of em(4)/igb(4)/lem(4) and ixl(4) to iflib(9)
in r311849 and r335338 respectively, these drivers didn't enable
IFCAP_VLAN_HWFILTER by default due to VLAN events not being passed
through by lagg(4). With iflib(9), IFCAP_VLAN_HWFILTER was turned on
by default but also lagg(4) was fixed in that regard in r203548. So
just remove the now redundant and defunct IFCAP_VLAN_HWFILTER handling
in {em,ixl,ixlv}_setup_interface().
- Nuke other redundant IFCAP_* setting in {em,ixl,ixlv}_setup_interface()
which is (more completely) already done in {em,ixl,ixlv}_if_attach_pre()
now.
- Remove some redundant/dead setting of scctx->isc_tx_csum_flags in
em_if_attach_pre().
- Remove some IFCAP_* duplicated either directly or indirectly (e. g.
via IFCAP_HWCSUM) in {EM,IGB,IXL}_CAPS.
- Don't bother to fiddle with IFCAP_HWSTATS in ixgbe(4)/ixgbev(4) as
iflib(9) adds that capability unconditionally.
- Remove some unused macros from em(4).
- Bump __FreeBSD_version as some of the above changes require the modules
of drivers using iflib(9) to be recompiled.
Okayed by: sbruno@ at 201806 DevSummit Transport Working Group [1]
Reviewed by: sbruno (earlier version), erj
PR: 219428 (part of; comment #10) [1], 220997 (part of; comment #3) [2]
Differential Revision: https://reviews.freebsd.org/D15720
2018-07-15 19:04:23 +00:00
|
|
|
bus_size_t isc_tso_maxsize;
|
|
|
|
bus_size_t isc_tso_maxsegsize;
|
2016-05-18 04:35:58 +00:00
|
|
|
bus_size_t isc_rx_maxsize;
|
|
|
|
bus_size_t isc_rx_maxsegsize;
|
|
|
|
int isc_rx_nsegments;
|
|
|
|
int isc_admin_intrcnt; /* # of admin/link interrupts */
|
|
|
|
|
|
|
|
/* fields necessary for probe */
|
2019-06-15 11:07:41 +00:00
|
|
|
const pci_vendor_info_t *isc_vendor_info;
|
2019-03-19 23:44:26 +00:00
|
|
|
const char *isc_driver_version;
|
2018-10-12 22:40:54 +00:00
|
|
|
/* optional function to transform the read values to match the table*/
|
2016-05-18 04:35:58 +00:00
|
|
|
void (*isc_parse_devinfo) (uint16_t *device_id, uint16_t *subvendor_id,
|
|
|
|
uint16_t *subdevice_id, uint16_t *rev_id);
|
2016-08-12 21:29:44 +00:00
|
|
|
int isc_nrxd_min[8];
|
|
|
|
int isc_nrxd_default[8];
|
|
|
|
int isc_nrxd_max[8];
|
|
|
|
int isc_ntxd_min[8];
|
|
|
|
int isc_ntxd_default[8];
|
|
|
|
int isc_ntxd_max[8];
|
2017-03-13 22:53:06 +00:00
|
|
|
|
|
|
|
/* actively used during operation */
|
|
|
|
int isc_nfl __aligned(CACHE_LINE_SIZE);
|
|
|
|
int isc_ntxqs; /* # of tx queues per tx qset - usually 1 */
|
|
|
|
int isc_nrxqs; /* # of rx queues per rx qset - intel 1, chelsio 2, broadcom 3 */
|
2019-06-15 11:07:41 +00:00
|
|
|
int __spare0__;
|
2017-03-13 22:53:06 +00:00
|
|
|
int isc_tx_reclaim_thresh;
|
|
|
|
int isc_flags;
|
2018-05-11 20:08:28 +00:00
|
|
|
const char *isc_name;
|
2016-05-18 04:35:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct iflib_dma_info {
|
|
|
|
bus_addr_t idi_paddr;
|
|
|
|
caddr_t idi_vaddr;
|
|
|
|
bus_dma_tag_t idi_tag;
|
|
|
|
bus_dmamap_t idi_map;
|
|
|
|
uint32_t idi_size;
|
|
|
|
} *iflib_dma_info_t;
|
|
|
|
|
|
|
|
#define IFLIB_MAGIC 0xCAFEF00D
|
|
|
|
|
|
|
|
typedef enum {
|
2020-12-19 01:08:33 +00:00
|
|
|
/* Interrupt or softirq handles only receive */
|
2016-05-18 04:35:58 +00:00
|
|
|
IFLIB_INTR_RX,
|
2020-12-19 01:08:33 +00:00
|
|
|
|
|
|
|
/* Interrupt or softirq handles only transmit */
|
2017-03-13 22:53:06 +00:00
|
|
|
IFLIB_INTR_TX,
|
2020-12-19 01:08:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupt will check for both pending receive
|
|
|
|
* and available tx credits and dispatch a task
|
|
|
|
* for one or both depending on the disposition
|
|
|
|
* of the respective queues.
|
|
|
|
*/
|
2017-03-13 22:53:06 +00:00
|
|
|
IFLIB_INTR_RXTX,
|
2020-12-19 01:08:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Other interrupt - typically link status and
|
|
|
|
* or error conditions.
|
|
|
|
*/
|
2016-05-18 04:35:58 +00:00
|
|
|
IFLIB_INTR_ADMIN,
|
2020-12-19 01:08:33 +00:00
|
|
|
|
|
|
|
/* Softirq (task) for iov handling */
|
2016-05-18 04:35:58 +00:00
|
|
|
IFLIB_INTR_IOV,
|
|
|
|
} iflib_intr_type_t;
|
|
|
|
|
|
|
|
/*
|
2020-08-12 14:45:31 +00:00
|
|
|
* Interface has a separate completion queue for RX
|
2016-05-18 04:35:58 +00:00
|
|
|
*/
|
2017-01-02 00:56:33 +00:00
|
|
|
#define IFLIB_HAS_RXCQ 0x01
|
2016-05-18 04:35:58 +00:00
|
|
|
/*
|
|
|
|
* Driver has already allocated vectors
|
|
|
|
*/
|
2017-01-02 00:56:33 +00:00
|
|
|
#define IFLIB_SKIP_MSIX 0x02
|
2016-05-18 04:35:58 +00:00
|
|
|
/*
|
|
|
|
* Interface is a virtual function
|
|
|
|
*/
|
2017-01-02 00:56:33 +00:00
|
|
|
#define IFLIB_IS_VF 0x04
|
2016-08-12 21:29:44 +00:00
|
|
|
/*
|
2020-08-12 14:45:31 +00:00
|
|
|
* Interface has a separate completion queue for TX
|
2016-08-12 21:29:44 +00:00
|
|
|
*/
|
2017-01-02 00:56:33 +00:00
|
|
|
#define IFLIB_HAS_TXCQ 0x08
|
|
|
|
/*
|
2017-09-16 02:41:38 +00:00
|
|
|
* Interface does checksum in place
|
2017-01-02 00:56:33 +00:00
|
|
|
*/
|
2017-09-16 02:41:38 +00:00
|
|
|
#define IFLIB_NEED_SCRATCH 0x10
|
2017-01-02 00:56:33 +00:00
|
|
|
/*
|
|
|
|
* Interface doesn't expect in_pseudo for th_sum
|
|
|
|
*/
|
|
|
|
#define IFLIB_TSO_INIT_IP 0x20
|
2017-03-13 22:53:06 +00:00
|
|
|
/*
|
|
|
|
* Interface doesn't align IP header
|
|
|
|
*/
|
|
|
|
#define IFLIB_DO_RX_FIXUP 0x40
|
2017-09-23 01:33:20 +00:00
|
|
|
/*
|
|
|
|
* Driver needs csum zeroed for offloading
|
|
|
|
*/
|
|
|
|
#define IFLIB_NEED_ZERO_CSUM 0x80
|
2017-12-05 21:00:31 +00:00
|
|
|
/*
|
|
|
|
* Driver needs frames padded to some minimum length
|
|
|
|
*/
|
|
|
|
#define IFLIB_NEED_ETHER_PAD 0x100
|
2018-05-11 20:08:28 +00:00
|
|
|
/*
|
|
|
|
* Packets can be freed immediately after encap
|
|
|
|
*/
|
|
|
|
#define IFLIB_TXD_ENCAP_PIO 0x00200
|
|
|
|
/*
|
|
|
|
* Use RX completion handler
|
|
|
|
*/
|
|
|
|
#define IFLIB_RX_COMPLETION 0x00400
|
|
|
|
/*
|
|
|
|
* Skip refilling cluster free lists
|
|
|
|
*/
|
|
|
|
#define IFLIB_SKIP_CLREFILL 0x00800
|
|
|
|
/*
|
|
|
|
* Don't reset on hang
|
|
|
|
*/
|
|
|
|
#define IFLIB_NO_HANG_RESET 0x01000
|
|
|
|
/*
|
|
|
|
* Don't need/want most of the niceties of
|
|
|
|
* queue management
|
|
|
|
*/
|
|
|
|
#define IFLIB_PSEUDO 0x02000
|
|
|
|
/*
|
|
|
|
* No DMA support needed / wanted
|
|
|
|
*/
|
|
|
|
#define IFLIB_VIRTUAL 0x04000
|
|
|
|
/*
|
|
|
|
* autogenerate a MAC address
|
|
|
|
*/
|
|
|
|
#define IFLIB_GEN_MAC 0x08000
|
2018-05-26 00:46:08 +00:00
|
|
|
/*
|
|
|
|
* Interface needs admin task to ignore interface up/down status
|
|
|
|
*/
|
|
|
|
#define IFLIB_ADMIN_ALWAYS_RUN 0x10000
|
2019-05-03 20:05:31 +00:00
|
|
|
/*
|
|
|
|
* Driver will pass the media
|
|
|
|
*/
|
|
|
|
#define IFLIB_DRIVER_MEDIA 0x20000
|
2019-09-30 15:59:07 +00:00
|
|
|
/*
|
|
|
|
* When using a single hardware interrupt for the interface, only process RX
|
|
|
|
* interrupts instead of doing combined RX/TX processing.
|
|
|
|
*/
|
|
|
|
#define IFLIB_SINGLE_IRQ_RX_ONLY 0x40000
|
2020-06-21 22:02:49 +00:00
|
|
|
/*
|
|
|
|
* Don't need/want most of the niceties of
|
|
|
|
* emulating ethernet
|
|
|
|
*/
|
|
|
|
#define IFLIB_PSEUDO_ETHER 0x80000
|
|
|
|
|
iflib: Stop interface before (un)registering VLAN
This patch is intended to solve a specific problem that iavf(4)
encounters, but what it does can be extended to solve other issues.
To summarize the iavf(4) issue, if the PF driver configures VLAN
anti-spoof, then the VF driver needs to make sure no untagged traffic is
sent if a VLAN is configured, and vice-versa. This can be an issue when
a VLAN is being registered or unregistered, e.g. when a packet may be on
the ring with a VLAN in it, but the VLANs are being unregistered. This
can cause that tagged packet to go out and cause an MDD event.
To fix this, include a new interface-dependent function that drivers can
implement named IFDI_NEEDS_RESTART(). Right now, this function is called
in iflib_vlan_unregister/register() to determine whether the interface
needs to be stopped and started when a VLAN is registered or
unregistered. The default return value of IFDI_NEEDS_RESTART() is true,
so this fixes the MDD problem that iavf(4) encounters, since the
interface rings are flushed during a stop/init.
A future change to iavf(4) will implement that function just in case the
default value changes, and to make it explicit that this interface reset
is required when a VLAN is added or removed.
Reviewed by: gallatin@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D22086
2020-04-27 22:02:44 +00:00
|
|
|
/*
|
|
|
|
* These enum values are used in iflib_needs_restart to indicate to iflib
|
|
|
|
* functions whether or not the interface needs restarting when certain events
|
|
|
|
* happen.
|
|
|
|
*/
|
|
|
|
enum iflib_restart_event {
|
|
|
|
IFLIB_RESTART_VLAN_CONFIG,
|
|
|
|
};
|
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
/*
|
|
|
|
* field accessors
|
|
|
|
*/
|
|
|
|
void *iflib_get_softc(if_ctx_t ctx);
|
|
|
|
|
|
|
|
device_t iflib_get_dev(if_ctx_t ctx);
|
|
|
|
|
|
|
|
if_t iflib_get_ifp(if_ctx_t ctx);
|
|
|
|
|
|
|
|
struct ifmedia *iflib_get_media(if_ctx_t ctx);
|
|
|
|
|
|
|
|
if_softc_ctx_t iflib_get_softc_ctx(if_ctx_t ctx);
|
|
|
|
if_shared_ctx_t iflib_get_sctx(if_ctx_t ctx);
|
|
|
|
|
|
|
|
void iflib_set_mac(if_ctx_t ctx, uint8_t mac[ETHER_ADDR_LEN]);
|
2018-10-12 22:40:54 +00:00
|
|
|
void iflib_request_reset(if_ctx_t ctx);
|
|
|
|
uint8_t iflib_in_detach(if_ctx_t ctx);
|
2016-05-18 04:35:58 +00:00
|
|
|
|
2019-03-19 17:59:56 +00:00
|
|
|
uint32_t iflib_get_rx_mbuf_sz(if_ctx_t ctx);
|
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
/*
|
|
|
|
* If the driver can plug cleanly in to newbus use these
|
|
|
|
*/
|
|
|
|
int iflib_device_probe(device_t);
|
|
|
|
int iflib_device_attach(device_t);
|
|
|
|
int iflib_device_detach(device_t);
|
|
|
|
int iflib_device_suspend(device_t);
|
|
|
|
int iflib_device_resume(device_t);
|
|
|
|
int iflib_device_shutdown(device_t);
|
|
|
|
|
2019-05-29 22:24:10 +00:00
|
|
|
/*
|
|
|
|
* Use this instead of iflib_device_probe if the driver should report
|
|
|
|
* BUS_PROBE_VENDOR instead of BUS_PROBE_DEFAULT. (For example, an out-of-tree
|
|
|
|
* driver based on iflib).
|
|
|
|
*/
|
|
|
|
int iflib_device_probe_vendor(device_t);
|
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
int iflib_device_iov_init(device_t, uint16_t, const nvlist_t *);
|
|
|
|
void iflib_device_iov_uninit(device_t);
|
|
|
|
int iflib_device_iov_add_vf(device_t, uint16_t, const nvlist_t *);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the driver can't plug cleanly in to newbus
|
|
|
|
* use these
|
|
|
|
*/
|
|
|
|
int iflib_device_register(device_t dev, void *softc, if_shared_ctx_t sctx, if_ctx_t *ctxp);
|
|
|
|
int iflib_device_deregister(if_ctx_t);
|
|
|
|
|
2018-05-29 21:56:39 +00:00
|
|
|
int iflib_irq_alloc(if_ctx_t, if_irq_t, int, driver_filter_t, void *filter_arg, driver_intr_t, void *arg, const char *name);
|
2016-05-18 04:35:58 +00:00
|
|
|
int iflib_irq_alloc_generic(if_ctx_t ctx, if_irq_t irq, int rid,
|
2018-05-29 21:56:39 +00:00
|
|
|
iflib_intr_type_t type, driver_filter_t *filter,
|
|
|
|
void *filter_arg, int qid, const char *name);
|
|
|
|
void iflib_softirq_alloc_generic(if_ctx_t ctx, if_irq_t irq, iflib_intr_type_t type, void *arg, int qid, const char *name);
|
2016-05-18 04:35:58 +00:00
|
|
|
|
|
|
|
void iflib_irq_free(if_ctx_t ctx, if_irq_t irq);
|
|
|
|
|
2019-06-15 11:07:41 +00:00
|
|
|
void iflib_io_tqg_attach(struct grouptask *gt, void *uniq, int cpu,
|
|
|
|
const char *name);
|
2016-05-18 04:35:58 +00:00
|
|
|
|
2018-05-03 17:02:31 +00:00
|
|
|
void iflib_config_gtask_init(void *ctx, struct grouptask *gtask,
|
|
|
|
gtask_fn_t *fn, const char *name);
|
2016-08-12 21:29:44 +00:00
|
|
|
void iflib_config_gtask_deinit(struct grouptask *gtask);
|
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
void iflib_tx_intr_deferred(if_ctx_t ctx, int txqid);
|
|
|
|
void iflib_rx_intr_deferred(if_ctx_t ctx, int rxqid);
|
|
|
|
void iflib_admin_intr_deferred(if_ctx_t ctx);
|
|
|
|
void iflib_iov_intr_deferred(if_ctx_t ctx);
|
|
|
|
|
2016-08-12 21:29:44 +00:00
|
|
|
void iflib_link_state_change(if_ctx_t ctx, int linkstate, uint64_t baudrate);
|
2016-05-18 04:35:58 +00:00
|
|
|
|
|
|
|
int iflib_dma_alloc(if_ctx_t ctx, int size, iflib_dma_info_t dma, int mapflags);
|
2019-01-22 01:11:17 +00:00
|
|
|
int iflib_dma_alloc_align(if_ctx_t ctx, int size, int align, iflib_dma_info_t dma, int mapflags);
|
2016-05-18 04:35:58 +00:00
|
|
|
void iflib_dma_free(iflib_dma_info_t dma);
|
|
|
|
int iflib_dma_alloc_multi(if_ctx_t ctx, int *sizes, iflib_dma_info_t *dmalist, int mapflags, int count);
|
|
|
|
|
|
|
|
void iflib_dma_free_multi(iflib_dma_info_t *dmalist, int count);
|
|
|
|
|
2018-05-03 17:02:31 +00:00
|
|
|
struct sx *iflib_ctx_lock_get(if_ctx_t);
|
2016-05-18 04:35:58 +00:00
|
|
|
|
|
|
|
void iflib_led_create(if_ctx_t ctx);
|
|
|
|
|
|
|
|
void iflib_add_int_delay_sysctl(if_ctx_t, const char *, const char *,
|
|
|
|
if_int_delay_info_t, int, int);
|
|
|
|
|
2018-05-11 20:08:28 +00:00
|
|
|
/*
|
|
|
|
* Pseudo device support
|
|
|
|
*/
|
|
|
|
if_pseudo_t iflib_clone_register(if_shared_ctx_t);
|
|
|
|
void iflib_clone_deregister(if_pseudo_t);
|
2019-06-15 11:07:41 +00:00
|
|
|
|
2016-05-18 04:35:58 +00:00
|
|
|
#endif /* __IFLIB_H_ */
|