[PATCH 1/1] net/mana: add vlan tagging support
Wei Hu
weh at microsoft.com
Fri Feb 9 09:52:11 CET 2024
For tx path, use LONG_PACKET_FORMAT if vlan tag is present. For rx,
extract vlan id from oob, put into mbuf and set the vlan flags in
mbuf.
Also add myself to the maintainers list for vmbus, mana and netvsc.
Signed-off-by: Wei Hu <weh at microsoft.com>
---
MAINTAINERS | 3 +++
drivers/net/mana/mana.h | 2 ++
drivers/net/mana/rx.c | 6 ++++++
drivers/net/mana/tx.c | 30 +++++++++++++++++++++++++++---
4 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 5fb3a73f84..9983d013a6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -608,6 +608,7 @@ F: app/test/test_vdev.c
VMBUS bus driver
M: Long Li <longli at microsoft.com>
+M: Wei Hu <weh at microsoft.com>
F: drivers/bus/vmbus/
@@ -867,6 +868,7 @@ F: doc/guides/nics/features/mlx5.ini
Microsoft mana
M: Long Li <longli at microsoft.com>
+M: Wei Hu <weh at microsoft.com>
F: drivers/net/mana/
F: doc/guides/nics/mana.rst
F: doc/guides/nics/features/mana.ini
@@ -878,6 +880,7 @@ F: doc/guides/nics/vdev_netvsc.rst
Microsoft Hyper-V netvsc
M: Long Li <longli at microsoft.com>
+M: Wei Hu <weh at microsoft.com>
F: drivers/net/netvsc/
F: doc/guides/nics/netvsc.rst
F: doc/guides/nics/features/netvsc.ini
diff --git a/drivers/net/mana/mana.h b/drivers/net/mana/mana.h
index 4c56e6f746..2b65a19878 100644
--- a/drivers/net/mana/mana.h
+++ b/drivers/net/mana/mana.h
@@ -21,10 +21,12 @@ struct mana_shared_data {
#define MANA_MAX_MAC_ADDR 1
#define MANA_DEV_RX_OFFLOAD_SUPPORT ( \
+ RTE_ETH_RX_OFFLOAD_VLAN_STRIP | \
RTE_ETH_RX_OFFLOAD_CHECKSUM | \
RTE_ETH_RX_OFFLOAD_RSS_HASH)
#define MANA_DEV_TX_OFFLOAD_SUPPORT ( \
+ RTE_ETH_TX_OFFLOAD_VLAN_INSERT | \
RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \
RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \
diff --git a/drivers/net/mana/rx.c b/drivers/net/mana/rx.c
index acad5e26cd..506f073708 100644
--- a/drivers/net/mana/rx.c
+++ b/drivers/net/mana/rx.c
@@ -517,6 +517,12 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
mbuf->hash.rss = oob->packet_info[pkt_idx].packet_hash;
}
+ if (oob->rx_vlan_tag_present) {
+ mbuf->ol_flags |=
+ RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+ mbuf->vlan_tci = oob->rx_vlan_id;
+ }
+
pkts[pkt_received++] = mbuf;
rxq->stats.packets++;
rxq->stats.bytes += mbuf->data_len;
diff --git a/drivers/net/mana/tx.c b/drivers/net/mana/tx.c
index 58c4a1d976..f075fcb0f5 100644
--- a/drivers/net/mana/tx.c
+++ b/drivers/net/mana/tx.c
@@ -180,6 +180,15 @@ get_vsq_frame_num(uint32_t vsq)
return v.vsq_frame;
}
+#define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */
+#define VLAN_PRIO_SHIFT 13
+#define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator / Drop Eligible Indicator */
+#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */
+
+#define mana_mbuf_vlan_tag_get_id(m) ((m)->vlan_tci & VLAN_VID_MASK)
+#define mana_mbuf_vlan_tag_get_cfi(m) (!!((m)->vlan_tci & VLAN_CFI_MASK))
+#define mana_mbuf_vlan_tag_get_prio(m) (((m)->vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT)
+
uint16_t
mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
{
@@ -254,7 +263,18 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
}
/* Fill in the oob */
- tx_oob.short_oob.packet_format = SHORT_PACKET_FORMAT;
+ if (m_pkt->ol_flags & RTE_MBUF_F_TX_VLAN) {
+ tx_oob.short_oob.packet_format = LONG_PACKET_FORMAT;
+ tx_oob.long_oob.inject_vlan_prior_tag = 1;
+ tx_oob.long_oob.priority_code_point =
+ mana_mbuf_vlan_tag_get_prio(m_pkt);
+ tx_oob.long_oob.drop_eligible_indicator =
+ mana_mbuf_vlan_tag_get_cfi(m_pkt);
+ tx_oob.long_oob.vlan_identifier =
+ mana_mbuf_vlan_tag_get_id(m_pkt);
+ } else {
+ tx_oob.short_oob.packet_format = SHORT_PACKET_FORMAT;
+ }
tx_oob.short_oob.tx_is_outer_ipv4 =
m_pkt->ol_flags & RTE_MBUF_F_TX_IPV4 ? 1 : 0;
tx_oob.short_oob.tx_is_outer_ipv6 =
@@ -409,8 +429,12 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
work_req.sgl = sgl.gdma_sgl;
work_req.num_sgl_elements = m_pkt->nb_segs;
- work_req.inline_oob_size_in_bytes =
- sizeof(struct transmit_short_oob_v2);
+ if (tx_oob.short_oob.packet_format == SHORT_PACKET_FORMAT)
+ work_req.inline_oob_size_in_bytes =
+ sizeof(struct transmit_short_oob_v2);
+ else
+ work_req.inline_oob_size_in_bytes =
+ sizeof(struct transmit_oob_v2);
work_req.inline_oob_data = &tx_oob;
work_req.flags = 0;
work_req.client_data_unit = NOT_USING_CLIENT_DATA_UNIT;
--
2.34.1
More information about the dev
mailing list