diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 9ab672ba644..36529601dff 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -929,6 +929,7 @@ struct adapter { u_int vxlan_refcount; int rawf_base; int nrawf; + u_int vlan_id; struct taskqueue *tq[MAX_NPORTS]; /* 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 505f2d1bf67..350d385ac49 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -2086,9 +2086,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) { @@ -5476,7 +5484,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; @@ -5977,7 +5986,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 24c80aaa7b2..8ca6dd98a66 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",