Module Name: src
Committed By: martin
Date: Sun Oct 8 14:57:54 UTC 2023
Modified Files:
src/sys/dev/pci/ixgbe [netbsd-10]: ix_txrx.c ixgbe.c ixgbe.h
ixgbe_82599.c ixgbe_mbx.h ixgbe_type.h ixgbe_vf.c ixgbe_vf.h ixv.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #395):
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.30
sys/dev/pci/ixgbe/ixv.c: revision 1.184
sys/dev/pci/ixgbe/ixv.c: revision 1.185
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.32
sys/dev/pci/ixgbe/ixgbe_vf.c: revision 1.33
sys/dev/pci/ixgbe/ixgbe.h: revision 1.87
sys/dev/pci/ixgbe/ixgbe.h: revision 1.88
sys/dev/pci/ixgbe/ixgbe.c: revision 1.330
sys/dev/pci/ixgbe/ixgbe.c: revision 1.331
sys/dev/pci/ixgbe/ixgbe.c: revision 1.332
sys/dev/pci/ixgbe/ixgbe_vf.h: revision 1.18
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.101
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.57
sys/dev/pci/ixgbe/ixgbe_mbx.h: revision 1.20
sys/dev/pci/ixgbe/ixgbe.c: revision 1.327
sys/dev/pci/ixgbe/ixgbe.c: revision 1.328
sys/dev/pci/ixgbe/ixgbe.c: revision 1.329
ixgbe: Reorder some event counters for readability.
ixg(4): Rename some descriptions of event counters.
- Rename some descriptions from register name to the meaning.
- For the same meaning's counters, add "(soft)" or "(reg)".
The former is for a software level counter and the latter is for a
statistics counter register based.
ixg(4): Count Queue Bytes {Transmit, Receive} counter.
ixg(4): Reorder some flow control related event counters for readability.
ixg(4): Rename some descriptions of flow control related event conters.
Remove obsolete comment.
ixgbe: Fix typo in comment. No functional change.
ixv(4): Improve error check.
ixgbe_vf.c rev. 1.31 changed the behavior of the ixgbe_check_mac_link_vf()
function. It was from FreeBSD's ixv-1.5.25 to resolve mailbox collision
problem. The change had a problem that error checks have not done at all if
the API version >= 1.5. Fix it. From FreeBSD ixv-1.5.27.
ixv(4): Add new IXGBE_VF_GET_LINK_STATE message support.
PF can control vf's link state by this change. Note that Linux's PF driver
can't control the link to force up (i.e. ip link set XXX vf Y state enable).
>From FreeBSD ixv-1.5.30.
ixg(4): Update FCTRL after writing multicast filter. Same as other OSes.
From FreeBSD 395cc55d896654b8f75071e71e856b22aed87da5.
To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.100.4.1 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.324.2.1 -r1.324.2.2 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.86 -r1.86.4.1 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.29 -r1.29.4.1 src/sys/dev/pci/ixgbe/ixgbe_82599.c
cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/dev/pci/ixgbe/ixgbe_mbx.h
cvs rdiff -u -r1.55.4.1 -r1.55.4.2 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.31 -r1.31.4.1 src/sys/dev/pci/ixgbe/ixgbe_vf.c
cvs rdiff -u -r1.17 -r1.17.4.1 src/sys/dev/pci/ixgbe/ixgbe_vf.h
cvs rdiff -u -r1.183 -r1.183.4.1 src/sys/dev/pci/ixgbe/ixv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.100 src/sys/dev/pci/ixgbe/ix_txrx.c:1.100.4.1
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.100 Fri Sep 16 03:05:51 2022
+++ src/sys/dev/pci/ixgbe/ix_txrx.c Sun Oct 8 14:57:53 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.100 2022/09/16 03:05:51 knakahara Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.100.4.1 2023/10/08 14:57:53 martin Exp $ */
/******************************************************************************
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.100 2022/09/16 03:05:51 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ix_txrx.c,v 1.100.4.1 2023/10/08 14:57:53 martin Exp $");
#include "opt_inet.h"
#include "opt_inet6.h"
@@ -1334,11 +1334,6 @@ ixgbe_setup_hw_rsc(struct rx_ring *rxr)
* exhaustion are unnecessary, if an mbuf cannot be obtained
* it just returns, keeping its placeholder, thus it can simply
* be recalled to try again.
- *
- * XXX NetBSD TODO:
- * - The ixgbe_rxeof() function always preallocates mbuf cluster,
- * so the ixgbe_refresh_mbufs() function can be simplified.
- *
************************************************************************/
static void
ixgbe_refresh_mbufs(struct rx_ring *rxr, int limit)
Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.324.2.1 src/sys/dev/pci/ixgbe/ixgbe.c:1.324.2.2
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.324.2.1 Wed Jun 21 19:16:12 2023
+++ src/sys/dev/pci/ixgbe/ixgbe.c Sun Oct 8 14:57:53 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.324.2.1 2023/06/21 19:16:12 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.324.2.2 2023/10/08 14:57:53 martin Exp $ */
/******************************************************************************
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.324.2.1 2023/06/21 19:16:12 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.324.2.2 2023/10/08 14:57:53 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1638,8 +1638,19 @@ ixgbe_update_stats_counters(struct adapt
for (i = 0; i < queue_counters; i++) {
IXGBE_EVC_REGADD(hw, stats, IXGBE_QPRC(i), qprc[i]);
IXGBE_EVC_REGADD(hw, stats, IXGBE_QPTC(i), qptc[i]);
- if (hw->mac.type >= ixgbe_mac_82599EB)
+ if (hw->mac.type >= ixgbe_mac_82599EB) {
+ IXGBE_EVC_ADD(&stats->qbrc[i],
+ IXGBE_READ_REG(hw, IXGBE_QBRC_L(i)) +
+ ((u64)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32));
+ IXGBE_EVC_ADD(&stats->qbtc[i],
+ IXGBE_READ_REG(hw, IXGBE_QBTC_L(i)) +
+ ((u64)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32));
IXGBE_EVC_REGADD(hw, stats, IXGBE_QPRDC(i), qprdc[i]);
+ } else {
+ /* 82598 */
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_QBRC(i), qbrc[i]);
+ IXGBE_EVC_REGADD(hw, stats, IXGBE_QBTC(i), qbtc[i]);
+ }
}
/* 8 registers exist */
@@ -1849,28 +1860,28 @@ ixgbe_add_hw_stats(struct adapter *adapt
if (i < __arraycount(stats->pxontxc)) {
evcnt_attach_dynamic(&stats->pxontxc[i],
EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
- "pxontxc");
- evcnt_attach_dynamic(&stats->pxonrxc[i],
- EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
- "pxonrxc");
+ "Priority XON Transmitted");
evcnt_attach_dynamic(&stats->pxofftxc[i],
EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
- "pxofftxc");
- evcnt_attach_dynamic(&stats->pxoffrxc[i],
- EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
- "pxoffrxc");
+ "Priority XOFF Transmitted");
if (hw->mac.type >= ixgbe_mac_82599EB)
evcnt_attach_dynamic(&stats->pxon2offc[i],
EVCNT_TYPE_MISC, NULL,
adapter->tcs[i].evnamebuf,
- "pxon2offc");
+ "Priority XON to XOFF");
+ evcnt_attach_dynamic(&stats->pxonrxc[i],
+ EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
+ "Priority XON Received");
+ evcnt_attach_dynamic(&stats->pxoffrxc[i],
+ EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
+ "Priority XOFF Received");
}
}
for (i = 0; i < adapter->num_queues; i++, rxr++, txr++) {
#ifdef LRO
struct lro_ctrl *lro = &rxr->lro;
-#endif /* LRO */
+#endif
snprintf(adapter->queues[i].evnamebuf,
sizeof(adapter->queues[i].evnamebuf), "%s q%d", xname, i);
@@ -1910,27 +1921,6 @@ ixgbe_add_hw_stats(struct adapter *adapt
0, CTL_CREATE, CTL_EOL) != 0)
break;
- evcnt_attach_dynamic(&adapter->queues[i].irqs, EVCNT_TYPE_INTR,
- NULL, adapter->queues[i].evnamebuf, "IRQs on queue");
- evcnt_attach_dynamic(&adapter->queues[i].handleq,
- EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
- "Handled queue in softint");
- evcnt_attach_dynamic(&adapter->queues[i].req, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "Requeued in softint");
- evcnt_attach_dynamic(&txr->tso_tx, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "TSO");
- evcnt_attach_dynamic(&txr->no_desc_avail, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf,
- "TX Queue No Descriptor Available");
- evcnt_attach_dynamic(&txr->total_packets, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf,
- "Queue Packets Transmitted");
-#ifndef IXGBE_LEGACY_TX
- evcnt_attach_dynamic(&txr->pcq_drops, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf,
- "Packets dropped in pcq");
-#endif
-
if (sysctl_createv(log, 0, &rnode, &cnode,
CTLFLAG_READONLY, CTLTYPE_INT, "rxd_nxck",
SYSCTL_DESCR("Receive Descriptor next to check"),
@@ -1959,33 +1949,62 @@ ixgbe_add_hw_stats(struct adapter *adapt
CTL_CREATE, CTL_EOL) != 0)
break;
- if (i < __arraycount(stats->qprc)) {
- evcnt_attach_dynamic(&stats->qprc[i], EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "qprc");
+ evcnt_attach_dynamic(&adapter->queues[i].irqs, EVCNT_TYPE_INTR,
+ NULL, adapter->queues[i].evnamebuf, "IRQs on queue");
+ evcnt_attach_dynamic(&adapter->queues[i].handleq,
+ EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
+ "Handled queue in softint");
+ evcnt_attach_dynamic(&adapter->queues[i].req, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf, "Requeued in softint");
+ if (i < __arraycount(stats->qbtc))
+ evcnt_attach_dynamic(&stats->qbtc[i], EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "Queue Bytes Transmitted (reg)");
+ evcnt_attach_dynamic(&txr->total_packets, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "Queue Packets Transmitted (soft)");
+ if (i < __arraycount(stats->qptc))
evcnt_attach_dynamic(&stats->qptc[i], EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "qptc");
+ NULL, adapter->queues[i].evnamebuf,
+ "Queue Packets Transmitted (reg)");
+#ifndef IXGBE_LEGACY_TX
+ evcnt_attach_dynamic(&txr->pcq_drops, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "Packets dropped in pcq");
+#endif
+ evcnt_attach_dynamic(&txr->no_desc_avail, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "TX Queue No Descriptor Available");
+ evcnt_attach_dynamic(&txr->tso_tx, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf, "TSO");
+
+ evcnt_attach_dynamic(&rxr->rx_bytes, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "Queue Bytes Received (soft)");
+ if (i < __arraycount(stats->qbrc))
evcnt_attach_dynamic(&stats->qbrc[i], EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "qbrc");
- evcnt_attach_dynamic(&stats->qbtc[i], EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "qbtc");
- if (hw->mac.type >= ixgbe_mac_82599EB)
+ NULL, adapter->queues[i].evnamebuf,
+ "Queue Bytes Received (reg)");
+ evcnt_attach_dynamic(&rxr->rx_packets, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "Queue Packets Received (soft)");
+ if (i < __arraycount(stats->qprc))
+ evcnt_attach_dynamic(&stats->qprc[i], EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "Queue Packets Received (reg)");
+ if ((i < __arraycount(stats->qprdc)) &&
+ (hw->mac.type >= ixgbe_mac_82599EB))
evcnt_attach_dynamic(&stats->qprdc[i],
EVCNT_TYPE_MISC, NULL,
- adapter->queues[i].evnamebuf, "qprdc");
- }
+ adapter->queues[i].evnamebuf,
+ "Queue Packets Received Drop");
- evcnt_attach_dynamic(&rxr->rx_packets, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf,
- "Queue Packets Received");
- evcnt_attach_dynamic(&rxr->rx_bytes, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf,
- "Queue Bytes Received");
- evcnt_attach_dynamic(&rxr->rx_copies, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "Copied RX Frames");
evcnt_attach_dynamic(&rxr->no_mbuf, EVCNT_TYPE_MISC,
NULL, adapter->queues[i].evnamebuf, "Rx no mbuf");
evcnt_attach_dynamic(&rxr->rx_discarded, EVCNT_TYPE_MISC,
NULL, adapter->queues[i].evnamebuf, "Rx discarded");
+ evcnt_attach_dynamic(&rxr->rx_copies, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf, "Copied RX Frames");
#ifdef LRO
SYSCTL_ADD_INT(ctx, queue_list, OID_AUTO, "lro_queued",
CTLFLAG_RD, &lro->lro_queued, 0,
@@ -2038,10 +2057,10 @@ ixgbe_add_hw_stats(struct adapter *adapt
stats->namebuf, "Receive Length Errors");
evcnt_attach_dynamic(&stats->lxontxc, EVCNT_TYPE_MISC, NULL,
stats->namebuf, "Link XON Transmitted");
- evcnt_attach_dynamic(&stats->lxonrxc, EVCNT_TYPE_MISC, NULL,
- stats->namebuf, "Link XON Received");
evcnt_attach_dynamic(&stats->lxofftxc, EVCNT_TYPE_MISC, NULL,
stats->namebuf, "Link XOFF Transmitted");
+ evcnt_attach_dynamic(&stats->lxonrxc, EVCNT_TYPE_MISC, NULL,
+ stats->namebuf, "Link XON Received");
evcnt_attach_dynamic(&stats->lxoffrxc, EVCNT_TYPE_MISC, NULL,
stats->namebuf, "Link XOFF Received");
@@ -2157,12 +2176,12 @@ ixgbe_clear_evcnt(struct adapter *adapte
IXGBE_EVC_STORE(&adapter->queues[i].irqs, 0);
IXGBE_EVC_STORE(&adapter->queues[i].handleq, 0);
IXGBE_EVC_STORE(&adapter->queues[i].req, 0);
- IXGBE_EVC_STORE(&txr->no_desc_avail, 0);
IXGBE_EVC_STORE(&txr->total_packets, 0);
- IXGBE_EVC_STORE(&txr->tso_tx, 0);
#ifndef IXGBE_LEGACY_TX
IXGBE_EVC_STORE(&txr->pcq_drops, 0);
#endif
+ IXGBE_EVC_STORE(&txr->no_desc_avail, 0);
+ IXGBE_EVC_STORE(&txr->tso_tx, 0);
txr->q_efbig_tx_dma_setup = 0;
txr->q_mbuf_defrag_failed = 0;
txr->q_efbig2_tx_dma_setup = 0;
@@ -3772,12 +3791,12 @@ ixgbe_detach(device_t dev, int flags)
evcnt_detach(&adapter->queues[i].irqs);
evcnt_detach(&adapter->queues[i].handleq);
evcnt_detach(&adapter->queues[i].req);
- evcnt_detach(&txr->no_desc_avail);
evcnt_detach(&txr->total_packets);
- evcnt_detach(&txr->tso_tx);
#ifndef IXGBE_LEGACY_TX
evcnt_detach(&txr->pcq_drops);
#endif
+ evcnt_detach(&txr->no_desc_avail);
+ evcnt_detach(&txr->tso_tx);
if (i < __arraycount(stats->qprc)) {
evcnt_detach(&stats->qprc[i]);
@@ -4532,8 +4551,6 @@ ixgbe_set_rxfilter(struct adapter *adapt
} else
fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
- IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCTRL, fctrl);
-
/* Update multicast filter entries only when it's not ALLMULTI */
if ((ec->ec_flags & ETHER_F_ALLMULTI) == 0) {
ETHER_UNLOCK(ec);
@@ -4542,6 +4559,8 @@ ixgbe_set_rxfilter(struct adapter *adapt
ixgbe_mc_array_itr, TRUE);
} else
ETHER_UNLOCK(ec);
+
+ IXGBE_WRITE_REG(&adapter->hw, IXGBE_FCTRL, fctrl);
} /* ixgbe_set_rxfilter */
/************************************************************************
Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.86 src/sys/dev/pci/ixgbe/ixgbe.h:1.86.4.1
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.86 Mon May 30 05:08:17 2022
+++ src/sys/dev/pci/ixgbe/ixgbe.h Sun Oct 8 14:57:53 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.86 2022/05/30 05:08:17 msaitoh Exp $ */
+/* $NetBSD: ixgbe.h,v 1.86.4.1 2023/10/08 14:57:53 martin Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@@ -390,10 +390,10 @@ struct tx_ring {
u64 bytes; /* Used for AIM */
u64 packets;
/* Soft Stats */
- struct evcnt tso_tx;
- struct evcnt no_desc_avail;
struct evcnt total_packets;
struct evcnt pcq_drops;
+ struct evcnt no_desc_avail;
+ struct evcnt tso_tx;
/* Per queue conters. The adapter total is in struct adapter */
u64 q_efbig_tx_dma_setup;
u64 q_mbuf_defrag_failed;
@@ -511,6 +511,7 @@ struct adapter {
u16 num_segs;
u32 link_speed;
bool link_up;
+ bool link_enabled;
u32 vector;
u16 dmac;
u32 phy_layer;
Index: src/sys/dev/pci/ixgbe/ixgbe_82599.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_82599.c:1.29 src/sys/dev/pci/ixgbe/ixgbe_82599.c:1.29.4.1
--- src/sys/dev/pci/ixgbe/ixgbe_82599.c:1.29 Fri Dec 24 05:11:04 2021
+++ src/sys/dev/pci/ixgbe/ixgbe_82599.c Sun Oct 8 14:57:53 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_82599.c,v 1.29 2021/12/24 05:11:04 msaitoh Exp $ */
+/* $NetBSD: ixgbe_82599.c,v 1.29.4.1 2023/10/08 14:57:53 martin Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@@ -36,7 +36,7 @@
/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_82599.c 331224 2018-03-19 20:55:05Z erj $*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixgbe_82599.c,v 1.29 2021/12/24 05:11:04 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_82599.c,v 1.29.4.1 2023/10/08 14:57:53 martin Exp $");
#include "ixgbe_type.h"
#include "ixgbe_82599.h"
@@ -1829,7 +1829,7 @@ s32 ixgbe_fdir_set_input_mask_82599(stru
switch (input_mask->formatted.tunnel_type & 0xFFFF) {
case 0x0:
- /* Mask turnnel type, fall through */
+ /* Mask tunnel type, fall through */
fdirip6m |= IXGBE_FDIRIP6M_TUNNEL_TYPE;
case 0xFFFF:
break;
Index: src/sys/dev/pci/ixgbe/ixgbe_mbx.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_mbx.h:1.19 src/sys/dev/pci/ixgbe/ixgbe_mbx.h:1.19.4.1
--- src/sys/dev/pci/ixgbe/ixgbe_mbx.h:1.19 Fri Dec 24 05:11:04 2021
+++ src/sys/dev/pci/ixgbe/ixgbe_mbx.h Sun Oct 8 14:57:54 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_mbx.h,v 1.19 2021/12/24 05:11:04 msaitoh Exp $ */
+/* $NetBSD: ixgbe_mbx.h,v 1.19.4.1 2023/10/08 14:57:54 martin Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@@ -156,6 +156,7 @@ enum ixgbe_pfvf_api_rev {
#define IXGBE_VF_GET_RETA 0x0a /* VF request for RETA */
#define IXGBE_VF_GET_RSS_KEY 0x0b /* get RSS key */
#define IXGBE_VF_UPDATE_XCAST_MODE 0x0c
+#define IXGBE_VF_GET_LINK_STATE 0x10 /* get vf link state */
/* mode choices for IXGBE_VF_UPDATE_XCAST_MODE */
enum ixgbevf_xcast_modes {
Index: src/sys/dev/pci/ixgbe/ixgbe_type.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_type.h:1.55.4.1 src/sys/dev/pci/ixgbe/ixgbe_type.h:1.55.4.2
--- src/sys/dev/pci/ixgbe/ixgbe_type.h:1.55.4.1 Wed Jun 21 19:16:12 2023
+++ src/sys/dev/pci/ixgbe/ixgbe_type.h Sun Oct 8 14:57:54 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_type.h,v 1.55.4.1 2023/06/21 19:16:12 martin Exp $ */
+/* $NetBSD: ixgbe_type.h,v 1.55.4.2 2023/10/08 14:57:54 martin Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@@ -4076,6 +4076,7 @@ struct ixgbe_mac_operations {
s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32,
ixgbe_mc_addr_itr, bool clear);
s32 (*update_xcast_mode)(struct ixgbe_hw *, int);
+ s32 (*get_link_state)(struct ixgbe_hw *hw, bool *link_state);
s32 (*enable_mc)(struct ixgbe_hw *);
s32 (*disable_mc)(struct ixgbe_hw *);
s32 (*clear_vfta)(struct ixgbe_hw *);
Index: src/sys/dev/pci/ixgbe/ixgbe_vf.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.31 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.31.4.1
--- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.31 Fri Dec 24 05:11:04 2021
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.c Sun Oct 8 14:57:53 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.c,v 1.31 2021/12/24 05:11:04 msaitoh Exp $ */
+/* $NetBSD: ixgbe_vf.c,v 1.31.4.1 2023/10/08 14:57:53 martin Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@@ -36,7 +36,7 @@
/*$FreeBSD: head/sys/dev/ixgbe/ixgbe_vf.c 331224 2018-03-19 20:55:05Z erj $*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixgbe_vf.c,v 1.31 2021/12/24 05:11:04 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe_vf.c,v 1.31.4.1 2023/10/08 14:57:53 martin Exp $");
#include "ixgbe_api.h"
#include "ixgbe_type.h"
@@ -85,6 +85,7 @@ s32 ixgbe_init_ops_vf(struct ixgbe_hw *h
hw->mac.ops.init_rx_addrs = NULL;
hw->mac.ops.update_mc_addr_list = ixgbe_update_mc_addr_list_vf;
hw->mac.ops.update_xcast_mode = ixgbevf_update_xcast_mode;
+ hw->mac.ops.get_link_state = ixgbe_get_link_state_vf;
hw->mac.ops.enable_mc = NULL;
hw->mac.ops.disable_mc = NULL;
hw->mac.ops.clear_vfta = NULL;
@@ -497,6 +498,34 @@ s32 ixgbevf_update_xcast_mode(struct ixg
}
/**
+ * ixgbe_get_link_state_vf - Get VF link state from PF
+ * @hw: pointer to the HW structure
+ * @link_state: link state storage
+ *
+ * Returns state of the operation error or success.
+ **/
+s32 ixgbe_get_link_state_vf(struct ixgbe_hw *hw, bool *link_state)
+{
+ u32 msgbuf[2];
+ s32 err;
+ s32 ret_val;
+
+ msgbuf[0] = IXGBE_VF_GET_LINK_STATE;
+ msgbuf[1] = 0x0;
+
+ err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+
+ if (err || (msgbuf[0] & IXGBE_VT_MSGTYPE_FAILURE)) {
+ ret_val = IXGBE_ERR_MBX;
+ } else {
+ ret_val = IXGBE_SUCCESS;
+ *link_state = msgbuf[1];
+ }
+
+ return ret_val;
+}
+
+/**
* ixgbe_set_vfta_vf - Set/Unset vlan filter table address
* @hw: pointer to the HW structure
* @vlan: 12 bit VLAN ID
@@ -624,7 +653,9 @@ s32 ixgbe_check_mac_link_vf(struct ixgbe
struct ixgbe_mbx_info *mbx = &hw->mbx;
struct ixgbe_mac_info *mac = &hw->mac;
s32 ret_val = IXGBE_SUCCESS;
+ u32 in_msg = 0;
u32 links_reg;
+
UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
/* If we were hit with a reset drop the link */
@@ -682,27 +713,26 @@ s32 ixgbe_check_mac_link_vf(struct ixgbe
*speed = IXGBE_LINK_SPEED_UNKNOWN;
}
- if (hw->api_version < ixgbe_mbox_api_15) {
- u32 in_msg = 0;
-
- /* if the read failed it could just be a mailbox collision, best wait
- * until we are called again and don't report an error
- */
- if (ixgbe_read_mbx(hw, &in_msg, 1, 0))
- goto out;
+ /* if the read failed it could just be a mailbox collision, best wait
+ * until we are called again and don't report an error
+ */
+ if (ixgbe_read_mbx(hw, &in_msg, 1, 0)) {
+ if (hw->api_version >= ixgbe_mbox_api_15)
+ mac->get_link_status = FALSE;
+ goto out;
+ }
- if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) {
- /* msg is not CTS and is NACK we must have lost CTS status */
- if (in_msg & IXGBE_VT_MSGTYPE_FAILURE)
- ret_val = IXGBE_ERR_MBX;
- goto out;
- }
+ if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) {
+ /* msg is not CTS and is NACK we must have lost CTS status */
+ if (in_msg & IXGBE_VT_MSGTYPE_FAILURE)
+ ret_val = IXGBE_ERR_MBX;
+ goto out;
+ }
- /* the pf is talking, if we timed out in the past we reinit */
- if (!mbx->timeout) {
- ret_val = IXGBE_ERR_TIMEOUT;
- goto out;
- }
+ /* the pf is talking, if we timed out in the past we reinit */
+ if (!mbx->timeout) {
+ ret_val = IXGBE_ERR_TIMEOUT;
+ goto out;
}
/* if we passed all the tests above then the link is up and we no
Index: src/sys/dev/pci/ixgbe/ixgbe_vf.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.17 src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.17.4.1
--- src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.17 Mon Jan 24 01:50:19 2022
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.h Sun Oct 8 14:57:53 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.h,v 1.17 2022/01/24 01:50:19 msaitoh Exp $ */
+/* $NetBSD: ixgbe_vf.h,v 1.17.4.1 2023/10/08 14:57:53 martin Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@@ -133,6 +133,7 @@ s32 ixgbe_update_mc_addr_list_vf(struct
u32 mc_addr_count, ixgbe_mc_addr_itr,
bool clear);
s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode);
+s32 ixgbe_get_link_state_vf(struct ixgbe_hw *hw, bool *link_state);
s32 ixgbe_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
bool vlan_on, bool vlvf_bypass);
s32 ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.183 src/sys/dev/pci/ixgbe/ixv.c:1.183.4.1
--- src/sys/dev/pci/ixgbe/ixv.c:1.183 Wed Jul 6 06:31:47 2022
+++ src/sys/dev/pci/ixgbe/ixv.c Sun Oct 8 14:57:53 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ixv.c,v 1.183 2022/07/06 06:31:47 msaitoh Exp $ */
+/* $NetBSD: ixv.c,v 1.183.4.1 2023/10/08 14:57:53 martin Exp $ */
/******************************************************************************
@@ -35,7 +35,7 @@
/*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 331224 2018-03-19 20:55:05Z erj $*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.183 2022/07/06 06:31:47 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.183.4.1 2023/10/08 14:57:53 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -558,6 +558,13 @@ ixv_attach(device_t parent, device_t dev
adapter->mta = malloc(sizeof(*adapter->mta) *
IXGBE_MAX_VF_MC, M_DEVBUF, M_WAITOK);
+ /* Check if VF was disabled by PF */
+ error = hw->mac.ops.get_link_state(hw, &adapter->link_enabled);
+ if (error) {
+ /* PF is not capable of controlling VF state. Enable the link. */
+ adapter->link_enabled = TRUE;
+ }
+
/* Do the stats setup */
ixv_init_stats(adapter);
ixv_add_stats_sysctls(adapter);
@@ -648,12 +655,12 @@ ixv_detach(device_t dev, int flags)
evcnt_detach(&adapter->queues[i].irqs);
evcnt_detach(&adapter->queues[i].handleq);
evcnt_detach(&adapter->queues[i].req);
- evcnt_detach(&txr->no_desc_avail);
evcnt_detach(&txr->total_packets);
- evcnt_detach(&txr->tso_tx);
#ifndef IXGBE_LEGACY_TX
evcnt_detach(&txr->pcq_drops);
#endif
+ evcnt_detach(&txr->no_desc_avail);
+ evcnt_detach(&txr->tso_tx);
evcnt_detach(&rxr->rx_packets);
evcnt_detach(&rxr->rx_bytes);
@@ -786,6 +793,13 @@ ixv_init_locked(struct adapter *adapter)
ixv_init_stats(adapter);
/* Config/Enable Link */
+ error = hw->mac.ops.get_link_state(hw, &adapter->link_enabled);
+ if (error) {
+ /* PF is not capable of controlling VF state. Enable the link. */
+ adapter->link_enabled = TRUE;
+ } else if (adapter->link_enabled == FALSE)
+ device_printf(dev, "VF is disabled by PF\n");
+
hw->mac.get_link_status = TRUE;
hw->mac.ops.check_link(hw, &adapter->link_speed, &adapter->link_up,
FALSE);
@@ -1382,7 +1396,7 @@ ixv_update_link_status(struct adapter *a
KASSERT(mutex_owned(&adapter->core_mtx));
- if (adapter->link_up) {
+ if (adapter->link_up && adapter->link_enabled) {
if (adapter->link_active != LINK_STATE_UP) {
if (bootverbose) {
const char *bpsmsg;
@@ -2644,6 +2658,10 @@ ixv_add_stats_sysctls(struct adapter *ad
NULL, xname, "Admin event");
for (int i = 0; i < adapter->num_queues; i++, rxr++, txr++) {
+#ifdef LRO
+ struct lro_ctrl *lro = &rxr->lro;
+#endif
+
snprintf(adapter->queues[i].evnamebuf,
sizeof(adapter->queues[i].evnamebuf), "%s q%d", xname, i);
snprintf(adapter->queues[i].namebuf,
@@ -2682,31 +2700,6 @@ ixv_add_stats_sysctls(struct adapter *ad
0, CTL_CREATE, CTL_EOL) != 0)
break;
- evcnt_attach_dynamic(&adapter->queues[i].irqs, EVCNT_TYPE_INTR,
- NULL, adapter->queues[i].evnamebuf, "IRQs on queue");
- evcnt_attach_dynamic(&adapter->queues[i].handleq,
- EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
- "Handled queue in softint");
- evcnt_attach_dynamic(&adapter->queues[i].req, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "Requeued in softint");
- evcnt_attach_dynamic(&txr->tso_tx, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "TSO");
- evcnt_attach_dynamic(&txr->no_desc_avail, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf,
- "TX Queue No Descriptor Available");
- evcnt_attach_dynamic(&txr->total_packets, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf,
- "Queue Packets Transmitted");
-#ifndef IXGBE_LEGACY_TX
- evcnt_attach_dynamic(&txr->pcq_drops, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf,
- "Packets dropped in pcq");
-#endif
-
-#ifdef LRO
- struct lro_ctrl *lro = &rxr->lro;
-#endif /* LRO */
-
if (sysctl_createv(log, 0, &rnode, &cnode,
CTLFLAG_READONLY, CTLTYPE_INT, "rxd_nxck",
SYSCTL_DESCR("Receive Descriptor next to check"),
@@ -2735,18 +2728,39 @@ ixv_add_stats_sysctls(struct adapter *ad
CTL_CREATE, CTL_EOL) != 0)
break;
- evcnt_attach_dynamic(&rxr->rx_packets, EVCNT_TYPE_MISC,
+ evcnt_attach_dynamic(&adapter->queues[i].irqs, EVCNT_TYPE_INTR,
+ NULL, adapter->queues[i].evnamebuf, "IRQs on queue");
+ evcnt_attach_dynamic(&adapter->queues[i].handleq,
+ EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
+ "Handled queue in softint");
+ evcnt_attach_dynamic(&adapter->queues[i].req, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf, "Requeued in softint");
+ evcnt_attach_dynamic(&txr->total_packets, EVCNT_TYPE_MISC,
NULL, adapter->queues[i].evnamebuf,
- "Queue Packets Received");
+ "Queue Packets Transmitted");
+#ifndef IXGBE_LEGACY_TX
+ evcnt_attach_dynamic(&txr->pcq_drops, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "Packets dropped in pcq");
+#endif
+ evcnt_attach_dynamic(&txr->no_desc_avail, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "TX Queue No Descriptor Available");
+ evcnt_attach_dynamic(&txr->tso_tx, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf, "TSO");
+
evcnt_attach_dynamic(&rxr->rx_bytes, EVCNT_TYPE_MISC,
NULL, adapter->queues[i].evnamebuf,
"Queue Bytes Received");
- evcnt_attach_dynamic(&rxr->rx_copies, EVCNT_TYPE_MISC,
- NULL, adapter->queues[i].evnamebuf, "Copied RX Frames");
+ evcnt_attach_dynamic(&rxr->rx_packets, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf,
+ "Queue Packets Received");
evcnt_attach_dynamic(&rxr->no_mbuf, EVCNT_TYPE_MISC,
NULL, adapter->queues[i].evnamebuf, "Rx no mbuf");
evcnt_attach_dynamic(&rxr->rx_discarded, EVCNT_TYPE_MISC,
NULL, adapter->queues[i].evnamebuf, "Rx discarded");
+ evcnt_attach_dynamic(&rxr->rx_copies, EVCNT_TYPE_MISC,
+ NULL, adapter->queues[i].evnamebuf, "Copied RX Frames");
#ifdef LRO
SYSCTL_ADD_INT(ctx, queue_list, OID_AUTO, "lro_queued",
CTLFLAG_RD, &lro->lro_queued, 0,
@@ -2823,12 +2837,12 @@ ixv_clear_evcnt(struct adapter *adapter)
IXGBE_EVC_STORE(&adapter->queues[i].irqs, 0);
IXGBE_EVC_STORE(&adapter->queues[i].handleq, 0);
IXGBE_EVC_STORE(&adapter->queues[i].req, 0);
- IXGBE_EVC_STORE(&txr->tso_tx, 0);
- IXGBE_EVC_STORE(&txr->no_desc_avail, 0);
IXGBE_EVC_STORE(&txr->total_packets, 0);
#ifndef IXGBE_LEGACY_TX
IXGBE_EVC_STORE(&txr->pcq_drops, 0);
#endif
+ IXGBE_EVC_STORE(&txr->no_desc_avail, 0);
+ IXGBE_EVC_STORE(&txr->tso_tx, 0);
txr->q_efbig_tx_dma_setup = 0;
txr->q_mbuf_defrag_failed = 0;
txr->q_efbig2_tx_dma_setup = 0;