Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jul 2024 08:06:22 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: df85c75a80f2 - stable/13 - cxgbev(4): Pay attention to the VLAN configuration for the VF.
Message-ID:  <202407020806.46286MwD083244@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=df85c75a80f28bf2a1f70669ad9ee8a4647acfb7

commit df85c75a80f28bf2a1f70669ad9ee8a4647acfb7
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2024-06-17 17:11:16 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-07-02 07:45:55 +0000

    cxgbev(4): Pay attention to the VLAN configuration for the VF.
    
    Make sure that the transmit traffic is tagged correctly or else the
    firmware will refuse to transmit and will report an ACL violation.
    
    On receive the hardware will make sure that tagged traffic is delivered
    to the appropriate VM.  The driver only asserts that the VLAN id that
    was extracted from the wire traffic matches the VF's configuration.
    
    All this works when associating a specific VLAN id with a VF.  The
    'trunk' setting likely needs more work.
    
    MFC after:      1 week
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 2d0a01271223ce623c78f5c8236f8f3f4b6ef104)
---
 sys/dev/cxgbe/adapter.h |  1 +
 sys/dev/cxgbe/t4_sge.c  | 20 +++++++++++++++-----
 sys/dev/cxgbe/t4_vf.c   |  2 ++
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index 706bdf1b9f8b..648182fe31c4 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -928,6 +928,7 @@ struct adapter {
 	u_int vxlan_refcount;
 	int rawf_base;
 	int nrawf;
+	u_int vlan_id;
 
 	struct taskqueue *tq[MAX_NCHAN];	/* General purpose taskqueues */
 	struct port_info *port[MAX_NPORTS];
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index a6f77a2b7430..93f914c3e2c5 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -2098,9 +2098,17 @@ have_mbuf:
 	}
 
 	if (cpl->vlan_ex) {
-		m0->m_pkthdr.ether_vtag = be16toh(cpl->vlan);
-		m0->m_flags |= M_VLANTAG;
-		rxq->vlan_extraction++;
+		if (sc->flags & IS_VF && sc->vlan_id) {
+			/*
+			 * HW is not setup correctly if extracted vlan_id does
+			 * not match the VF's setting.
+			 */
+			MPASS(be16toh(cpl->vlan) == sc->vlan_id);
+		} else {
+			m0->m_pkthdr.ether_vtag = be16toh(cpl->vlan);
+			m0->m_flags |= M_VLANTAG;
+			rxq->vlan_extraction++;
+		}
 	}
 
 	if (rxq->iq.flags & IQ_RX_TIMESTAMP) {
@@ -5530,7 +5538,8 @@ write_txpkt_vm_wr(struct adapter *sc, struct sge_txq *txq, struct mbuf *m0)
 		ctrl1 |= F_TXPKT_VLAN_VLD |
 		    V_TXPKT_VLAN(m0->m_pkthdr.ether_vtag);
 		txq->vlan_insertion++;
-	}
+	} else if (sc->vlan_id)
+		ctrl1 |= F_TXPKT_VLAN_VLD | V_TXPKT_VLAN(sc->vlan_id);
 
 	/* CPL header */
 	cpl->ctrl0 = txq->cpl_ctrl0;
@@ -6031,7 +6040,8 @@ write_txpkts_vm_wr(struct adapter *sc, struct sge_txq *txq)
 			ctrl1 |= F_TXPKT_VLAN_VLD |
 			    V_TXPKT_VLAN(m->m_pkthdr.ether_vtag);
 			txq->vlan_insertion++;
-		}
+		} else if (sc->vlan_id)
+			ctrl1 |= F_TXPKT_VLAN_VLD | V_TXPKT_VLAN(sc->vlan_id);
 
 		/* CPL header */
 		cpl->ctrl0 = txq->cpl_ctrl0;
diff --git a/sys/dev/cxgbe/t4_vf.c b/sys/dev/cxgbe/t4_vf.c
index d22937ef2bbd..ac28f5b02aff 100644
--- a/sys/dev/cxgbe/t4_vf.c
+++ b/sys/dev/cxgbe/t4_vf.c
@@ -660,6 +660,8 @@ t4vf_attach(device_t dev)
 			t4_os_set_hw_addr(pi, mac);
 		pmask &= ~(1 << p);
 
+		sc->vlan_id = t4vf_get_vf_vlan(sc);
+
 		/* No t4_link_start. */
 
 		snprintf(pi->lockname, sizeof(pi->lockname), "%sp%d",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407020806.46286MwD083244>