Skip to contentSkip to conversation

mbuf: add Tx offloads for packet marking

PATCH In review Nithin Dabilpuram 7 participants 36 messages Apr 17, 2020 – Aug 14, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mbuf: add Tx offloads for packet marking

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
 	case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
 	case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+	case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+	case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+	case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
 	default: return NULL;
 	}
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		{ PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
 		{ PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
 		{ PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+		{ PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+		{ PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+		{ PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
 	};
 	const char *name;
 	unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +34 -2
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI		(1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP		(1ULL << 39)
+#define PKT_TX_MARK_IP_ECN		(1ULL << 40)
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
 		PKT_TX_MACSEC |		 \
 		PKT_TX_SEC_OFFLOAD |	 \
 		PKT_TX_UDP_SEG |	 \
-		PKT_TX_OUTER_UDP_CKSUM)
+		PKT_TX_OUTER_UDP_CKSUM | \
+		PKT_TX_MARK_VLAN_DEI |	 \
+		PKT_TX_MARK_IP_DSCP |	 \
+		PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
Signature · 1 line
2.8.4
#1 lore raw

PATCH 2/3 net/octeontx2: add tm packet marking cb

From: Krzysztof Kanas <[email protected]>

Add tm packet marking enable/disable callbacks for VLAN DEI, IP DSCP and IP ECN marking to support marking in VLAN, IPv4 and IPv6 packets.

---

Depends-on:series-9450

 drivers/net/octeontx2/otx2_ethdev.c |  12 +-
 drivers/net/octeontx2/otx2_ethdev.h |   5 +
 drivers/net/octeontx2/otx2_tm.c     | 472 +++++++++++++++++++++++++++++++++++-
 drivers/net/octeontx2/otx2_tm.h     |  31 +++
 drivers/net/octeontx2/otx2_tx.h     |   9 +-
 5 files changed, 514 insertions(+), 15 deletions(-)
drivers/net/octeontx2/otx2_ethdev.c +8 -4
index 3116e5c..1c7c465 100644
@@ -655,8 +655,8 @@ nix_rx_offload_flags(struct rte_eth_dev *eth_dev)
 	return flags;
 }
 
-static uint16_t
-nix_tx_offload_flags(struct rte_eth_dev *eth_dev)
+uint16_t
+otx2_nix_tx_offload_flags(struct rte_eth_dev *eth_dev)
 {
 	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
 	uint64_t conf = dev->tx_offloads;
@@ -974,6 +974,10 @@ otx2_nix_form_default_desc(struct otx2_eth_txq *txq)
 			send_mem->alg = NIX_SENDMEMALG_SETTSTMP;
 			send_mem->addr = txq->dev->tstamp.tx_tstamp_iova;
 		}
+
+		/* Update mark format */
+		txq->markfmt_en = txq->dev->tm_markfmt_en;
+
 		sg = (union nix_send_sg_s *)&txq->cmd[4];
 	} else {
 		send_hdr = (struct nix_send_hdr_s *)&txq->cmd[0];
@@ -1663,7 +1667,7 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev)
 	dev->rx_offloads = rxmode->offloads;
 	dev->tx_offloads = txmode->offloads;
 	dev->rx_offload_flags |= nix_rx_offload_flags(eth_dev);
-	dev->tx_offload_flags |= nix_tx_offload_flags(eth_dev);
+	dev->tx_offload_flags |= otx2_nix_tx_offload_flags(eth_dev);
 	dev->rss_info.rss_grps = NIX_RSS_GRPS;
 
 	nb_rxq = RTE_MAX(data->nb_rx_queues, 1);
@@ -1829,7 +1833,7 @@ otx2_nix_configure(struct rte_eth_dev *eth_dev)
 	nix_lf_free(dev);
 fail_offloads:
 	dev->rx_offload_flags &= ~nix_rx_offload_flags(eth_dev);
-	dev->tx_offload_flags &= ~nix_tx_offload_flags(eth_dev);
+	dev->tx_offload_flags &= ~otx2_nix_tx_offload_flags(eth_dev);
 fail_configure:
 	dev->configured = 0;
 	return rc;
drivers/net/octeontx2/otx2_ethdev.h +5 -0
index 0fbf68b..b34842a 100644
@@ -304,6 +304,9 @@ struct otx2_eth_dev {
 	uint16_t txschq_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
 	/* Contiguous queues */
 	uint16_t txschq_contig_list[NIX_TXSCH_LVL_CNT][MAX_TXSCHQ_PER_FUNC];
+	uint64_t tm_markfmt_en;
+	uint8_t tm_markfmt_null;
+	uint8_t tm_markfmt[NIX_TM_MARK_MAX][NIX_TM_MARK_COLOR_MAX];
 	uint16_t otx2_tm_root_lvl;
 	uint16_t link_cfg_lvl;
 	uint16_t tm_flags;
@@ -347,6 +350,7 @@ struct otx2_eth_txq {
 	rte_iova_t fc_iova;
 	uint16_t sqes_per_sqb_log2;
 	int16_t nb_sqb_bufs_adj;
+	uint64_t markfmt_en;
 	RTE_MARKER slow_path_start;
 	uint16_t nb_sqb_bufs;
 	uint16_t sq;
@@ -570,6 +574,7 @@ int otx2_ethdev_parse_devargs(struct rte_devargs *devargs,
 void otx2_eth_set_rx_function(struct rte_eth_dev *eth_dev);
 void otx2_eth_set_tx_function(struct rte_eth_dev *eth_dev);
 void otx2_nix_form_default_desc(struct otx2_eth_txq *txq);
+uint16_t otx2_nix_tx_offload_flags(struct rte_eth_dev *eth_dev);
 
 /* Timesync - PTP routines */
 int otx2_nix_timesync_enable(struct rte_eth_dev *eth_dev);
drivers/net/octeontx2/otx2_tm.c +464 -8

532 lines not on this page · raw message

drivers/net/octeontx2/otx2_tm.h +31 -0
index db44d48..afc796a 100644
@@ -13,6 +13,37 @@
 #define NIX_TM_COMMITTED	BIT_ULL(1)
 #define NIX_TM_RATE_LIMIT_TREE	BIT_ULL(2)
 #define NIX_TM_TL1_NO_SP	BIT_ULL(3)
+#define NIX_TM_MARK_IP_DSCP_EN	BIT_ULL(4)
+#define NIX_TM_MARK_IP_ECN_EN	BIT_ULL(5)
+#define NIX_TM_MARK_VLAN_DEI_EN	BIT_ULL(6)
+
+
+#define NIX_TM_MARK_EN_MASK	(NIX_TM_MARK_IP_DSCP_EN | \
+				 NIX_TM_MARK_IP_ECN_EN |  \
+				 NIX_TM_MARK_VLAN_DEI_EN)
+
+/* Shift positions for struct otx2_eth_dev::tm_markfmt_en field */
+#define NIX_TM_MARK_VLAN_DEI_SHIFT	0 /* Leave 16b for VLAN for FP logic */
+#define NIX_TM_MARK_IPV4_DSCP_SHIFT	16
+#define NIX_TM_MARK_IPV6_DSCP_SHIFT	24
+#define NIX_TM_MARK_IPV4_ECN_SHIFT	32
+#define NIX_TM_MARK_IPV6_ECN_SHIFT	40
+
+enum otx2_nix_tm_mark {
+	NIX_TM_MARK_VLAN_DEI,
+	NIX_TM_MARK_IPV4_DSCP,
+	NIX_TM_MARK_IPV4_ECN,
+	NIX_TM_MARK_IPV6_DSCP,
+	NIX_TM_MARK_IPV6_ECN,
+	NIX_TM_MARK_MAX
+};
+
+enum otx2_nix_tm_mark_color {
+	NIX_TM_MARK_COLOR_Y,
+	NIX_TM_MARK_COLOR_R,
+	NIX_TM_MARK_COLOR_Y_R,
+	NIX_TM_MARK_COLOR_MAX
+};
 
 struct otx2_eth_dev;
 
drivers/net/octeontx2/otx2_tx.h +6 -3
index 3c43170..928e4ea 100644
@@ -13,6 +13,7 @@
 #define NIX_TX_OFFLOAD_TSTAMP_F		BIT(4)
 #define NIX_TX_OFFLOAD_TSO_F		BIT(5)
 #define NIX_TX_OFFLOAD_SECURITY_F	BIT(6)
+#define NIX_TX_OFFLOAD_MARK_F		BIT(7)
 
 /* Flags to control xmit_prepare function.
  * Defining it from backwards to denote its been
@@ -22,11 +23,12 @@
 
 #define NIX_TX_NEED_SEND_HDR_W1	\
 	(NIX_TX_OFFLOAD_L3_L4_CSUM_F | NIX_TX_OFFLOAD_OL3_OL4_CSUM_F |	\
-	 NIX_TX_OFFLOAD_VLAN_QINQ_F | NIX_TX_OFFLOAD_TSO_F)
+	 NIX_TX_OFFLOAD_VLAN_QINQ_F | NIX_TX_OFFLOAD_TSO_F | \
+	 NIX_TX_OFFLOAD_MARK_F)
 
 #define NIX_TX_NEED_EXT_HDR \
 	(NIX_TX_OFFLOAD_VLAN_QINQ_F | NIX_TX_OFFLOAD_TSTAMP_F | \
-	 NIX_TX_OFFLOAD_TSO_F)
+	 NIX_TX_OFFLOAD_TSO_F | NIX_TX_OFFLOAD_MARK_F)
 
 #define NIX_UDP_TUN_BITMASK \
 	((1ull << (PKT_TX_TUNNEL_VXLAN >> 45)) | \
@@ -42,7 +44,8 @@ static __rte_always_inline int
 otx2_nix_tx_ext_subs(const uint16_t flags)
 {
 	return (flags & NIX_TX_OFFLOAD_TSTAMP_F) ? 2 :
-		((flags & (NIX_TX_OFFLOAD_VLAN_QINQ_F | NIX_TX_OFFLOAD_TSO_F)) ?
+		((flags & (NIX_TX_OFFLOAD_VLAN_QINQ_F | NIX_TX_OFFLOAD_TSO_F |
+			   NIX_TX_OFFLOAD_MARK_F)) ?
 		 1 : 0);
 }
 
Signature · 1 line
2.8.4
#2 lore raw

PATCH 3/3 net/octeontx2: add Tx packet marking offload support

In reply to Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

This patch adds Tx packet marking offload support for VLAN DEI, IP ECN, and IP DSCP.

---

Depends-on:series-9450

 drivers/event/octeontx2/otx2_evdev.c       |  28 +-
 drivers/event/octeontx2/otx2_evdev.h       |   2 +-
 drivers/event/octeontx2/otx2_worker.c      |   4 +-
 drivers/event/octeontx2/otx2_worker.h      |   4 +-
 drivers/event/octeontx2/otx2_worker_dual.c |   4 +-
 drivers/net/octeontx2/otx2_tx.c            |  48 ++-
 drivers/net/octeontx2/otx2_tx.h            | 580 ++++++++++++++++++++++-------
 7 files changed, 503 insertions(+), 167 deletions(-)
drivers/event/octeontx2/otx2_evdev.c +16 -12
index d20213d..33cba09 100644
@@ -178,36 +178,36 @@ SSO_RX_ADPTR_ENQ_FASTPATH_FUNC
 
 	/* Tx modes */
 	const event_tx_adapter_enqueue
-		ssogws_tx_adptr_enq[2][2][2][2][2][2][2] = {
-#define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
-		[f6][f5][f4][f3][f2][f1][f0] =				\
+		ssogws_tx_adptr_enq[2][2][2][2][2][2][2][2] = {
+#define T(name, f7, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
+		[f7][f6][f5][f4][f3][f2][f1][f0] =				\
 			otx2_ssogws_tx_adptr_enq_ ## name,
 SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 #undef T
 	};
 
 	const event_tx_adapter_enqueue
-		ssogws_tx_adptr_enq_seg[2][2][2][2][2][2][2] = {
-#define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
-		[f6][f5][f4][f3][f2][f1][f0] =				\
+		ssogws_tx_adptr_enq_seg[2][2][2][2][2][2][2][2] = {
+#define T(name, f7, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
+		[f7][f6][f5][f4][f3][f2][f1][f0] =				\
 			otx2_ssogws_tx_adptr_enq_seg_ ## name,
 SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 #undef T
 	};
 
 	const event_tx_adapter_enqueue
-		ssogws_dual_tx_adptr_enq[2][2][2][2][2][2][2] = {
-#define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
-		[f6][f5][f4][f3][f2][f1][f0] =				\
+		ssogws_dual_tx_adptr_enq[2][2][2][2][2][2][2][2] = {
+#define T(name, f7, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
+		[f7][f6][f5][f4][f3][f2][f1][f0] =				\
 			otx2_ssogws_dual_tx_adptr_enq_ ## name,
 SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 #undef T
 	};
 
 	const event_tx_adapter_enqueue
-		ssogws_dual_tx_adptr_enq_seg[2][2][2][2][2][2][2] = {
-#define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
-		[f6][f5][f4][f3][f2][f1][f0] =				\
+		ssogws_dual_tx_adptr_enq_seg[2][2][2][2][2][2][2][2] = {
+#define T(name, f7, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
+		[f7][f6][f5][f4][f3][f2][f1][f0] =				\
 			otx2_ssogws_dual_tx_adptr_enq_seg_ ## name,
 SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 #undef T
@@ -294,6 +294,7 @@ SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 	if (dev->tx_offloads & NIX_TX_MULTI_SEG_F) {
 		/* [SEC] [TSMP] [MBUF_NOFF] [VLAN] [OL3_L4_CSUM] [L3_L4_CSUM] */
 		event_dev->txa_enqueue = ssogws_tx_adptr_enq_seg
+			[!!(dev->tx_offloads & NIX_TX_OFFLOAD_MARK_F)]
 			[!!(dev->tx_offloads & NIX_TX_OFFLOAD_SECURITY_F)]
 			[!!(dev->tx_offloads & NIX_TX_OFFLOAD_TSO_F)]
 			[!!(dev->tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F)]
@@ -303,6 +304,7 @@ SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 			[!!(dev->tx_offloads & NIX_TX_OFFLOAD_L3_L4_CSUM_F)];
 	} else {
 		event_dev->txa_enqueue = ssogws_tx_adptr_enq
+			[!!(dev->tx_offloads & NIX_TX_OFFLOAD_MARK_F)]
 			[!!(dev->tx_offloads & NIX_TX_OFFLOAD_SECURITY_F)]
 			[!!(dev->tx_offloads & NIX_TX_OFFLOAD_TSO_F)]
 			[!!(dev->tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F)]
@@ -446,6 +448,7 @@ SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 		if (dev->tx_offloads & NIX_TX_MULTI_SEG_F) {
 		/* [SEC] [TSMP] [MBUF_NOFF] [VLAN] [OL3_L4_CSUM] [L3_L4_CSUM] */
 			event_dev->txa_enqueue = ssogws_dual_tx_adptr_enq_seg
+				[!!(dev->tx_offloads & NIX_TX_OFFLOAD_MARK_F)]
 				[!!(dev->tx_offloads &
 						NIX_TX_OFFLOAD_SECURITY_F)]
 				[!!(dev->tx_offloads & NIX_TX_OFFLOAD_TSO_F)]
@@ -460,6 +463,7 @@ SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 						NIX_TX_OFFLOAD_L3_L4_CSUM_F)];
 		} else {
 			event_dev->txa_enqueue = ssogws_dual_tx_adptr_enq
+				[!!(dev->tx_offloads & NIX_TX_OFFLOAD_MARK_F)]
 				[!!(dev->tx_offloads &
 						NIX_TX_OFFLOAD_SECURITY_F)]
 				[!!(dev->tx_offloads & NIX_TX_OFFLOAD_TSO_F)]
drivers/event/octeontx2/otx2_evdev.h +1 -1
index 3b47782..73eee8f 100644
@@ -335,7 +335,7 @@ uint16_t otx2_ssogws_dual_deq_seg_timeout_burst_ ##name(void *port,	       \
 SSO_RX_ADPTR_ENQ_FASTPATH_FUNC
 #undef R
 
-#define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)			     \
+#define T(name, f7, f6, f5, f4, f3, f2, f1, f0, sz, flags)		     \
 uint16_t otx2_ssogws_tx_adptr_enq_ ## name(void *port, struct rte_event ev[],\
 					   uint16_t nb_events);		     \
 uint16_t otx2_ssogws_tx_adptr_enq_seg_ ## name(void *port,		     \
drivers/event/octeontx2/otx2_worker.c +2 -2
index 8bec59e..cf73fd0 100644
@@ -267,7 +267,7 @@ otx2_ssogws_enq_fwd_burst(void *port, const struct rte_event ev[],
 	return 1;
 }
 
-#define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
+#define T(name, f7, f6, f5, f4, f3, f2, f1, f0, sz, flags)		\
 uint16_t __hot								\
 otx2_ssogws_tx_adptr_enq_ ## name(void *port, struct rte_event ev[],	\
 				  uint16_t nb_events)			\
@@ -281,7 +281,7 @@ otx2_ssogws_tx_adptr_enq_ ## name(void *port, struct rte_event ev[],	\
 SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 #undef T
 
-#define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
+#define T(name, f7, f6, f5, f4, f3, f2, f1, f0, sz, flags)		\
 uint16_t __hot								\
 otx2_ssogws_tx_adptr_enq_seg_ ## name(void *port, struct rte_event ev[],\
 				      uint16_t nb_events)		\
drivers/event/octeontx2/otx2_worker.h +3 -1
index 5f5aa87..5a59493 100644
@@ -270,8 +270,10 @@ static __rte_always_inline void
 otx2_ssogws_prepare_pkt(const struct otx2_eth_txq *txq, struct rte_mbuf *m,
 			uint64_t *cmd, const uint32_t flags)
 {
+	const uint64_t markfmt_en = txq->markfmt_en;
+
 	otx2_lmt_mov(cmd, txq->cmd, otx2_nix_tx_ext_subs(flags));
-	otx2_nix_xmit_prepare(m, cmd, flags);
+	otx2_nix_xmit_prepare(m, cmd, flags, markfmt_en);
 }
 
 static __rte_always_inline uint16_t
drivers/event/octeontx2/otx2_worker_dual.c +2 -2
index 3cba09c..5f3acc3 100644
@@ -307,7 +307,7 @@ otx2_ssogws_dual_deq_seg_timeout_burst_ ##name(void *port,		\
 SSO_RX_ADPTR_ENQ_FASTPATH_FUNC
 #undef R
 
-#define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
+#define T(name, f7, f6, f5, f4, f3, f2, f1, f0, sz, flags)		\
 uint16_t __hot								\
 otx2_ssogws_dual_tx_adptr_enq_ ## name(void *port,			\
 				       struct rte_event ev[],		\
@@ -324,7 +324,7 @@ otx2_ssogws_dual_tx_adptr_enq_ ## name(void *port,			\
 SSO_TX_ADPTR_ENQ_FASTPATH_FUNC
 #undef T
 
-#define T(name, f6, f5, f4, f3, f2, f1, f0, sz, flags)			\
+#define T(name, f7, f6, f5, f4, f3, f2, f1, f0, sz, flags)		\
 uint16_t __hot								\
 otx2_ssogws_dual_tx_adptr_enq_seg_ ## name(void *port,			\
 					   struct rte_event ev[],	\
drivers/net/octeontx2/otx2_tx.c +29 -19

138 lines not on this page · raw message

drivers/net/octeontx2/otx2_tx.h +450 -130

736 lines not on this page · raw message

Signature · 1 line
2.8.4
#3 lore raw
In reply to Nithin Dabilpuram
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 116 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +34 -3
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#4 lore raw

Hi,

Quoted 17 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 6 lines
Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Regards,
Olivier

Quoted 118 lines
Quoted 118 lines

---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +34 -3
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#5 lore raw

Hi Olivier,

Quoted 26 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 20 lines · Jerin Jacob
Quoted 17 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 7 lines
Quoted 3 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

Quoted 4 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Thanks
Nithin

Quoted 124 lines

Regards,
Olivier

Quoted 118 lines
Quoted 118 lines

---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +34 -3
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#6 lore raw
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

The problem is for packets that cannot be recognized by the hardware, correct?

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Quoted 14 lines
Quoted 3 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 2 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
lib/librte_mbuf/rte_mbuf_core.h +11 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 8 lines
lib/librte_mbuf/rte_mbuf_core.h +8 -0
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#7 lore raw
Quoted 61 lines · Olivier Matz
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

Quoted 2 lines

The problem is for packets that cannot be recognized by the hardware, correct?

Yes. Octeontx2 HW always depends on application knowledge instead of walking through all the layers of packet data in Tx to identify what packet it is and where the l2, l3, l4 headers start for performance reasons.

I believe there are other hardware too that have the same expectation and hence we have a need for PKT_TX_IPv4, PKT_TX_IPv6 kind of flags.

Hence we want to make use of mbuf:tx_offload field and PKT_TX_* flags for identifying the packet and knowing what are its l2,l3,l4 offsets.

Quoted 5 lines

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Packet is coloured based on Single Rate[1] or Dual Rate[2] Shaping result and packet color determines traffic class. The exact behavior of packet color to traffic class mapping is mentioned in TM spec based on few other RFC's.

[1] https://tools.ietf.org/html/rfc2697
[2] https://tools.ietf.org/html/rfc2698

Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Quoted 8 lines
Quoted 4 lines

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Yes, I thought PMD's need to support both.
I'm fine adding specific feature flag for the offload flags alone if you insist or if there are other PMD's which don't need the offload flags for packet marking. I was not able to find out about other PMD's as none of the existing PMD's support packet marking.

Quoted 71 lines

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

I meant by setting the flag, a packet has VLAN header adhering to IEEE 802.1Q spec.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

L2 header when VLAN header is preset will be
{custom header 'X' Bytes}:{Ethernet SRC+DST (12B)}:{VLAN Header (4B)}:{Ether Type (2B)} l2_len = X + 12 + 4 + 2
So, VLAN header starts at (l2_len - 6) bytes.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_mbuf/rte_mbuf_core.h +13 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Ack, will fix in V2.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#8 lore raw
Quoted 69 lines · Nithin Dabilpuram
Quoted 61 lines · Olivier Matz
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

Quoted 2 lines

The problem is for packets that cannot be recognized by the hardware, correct?

Yes. Octeontx2 HW always depends on application knowledge instead of walking through all the layers of packet data in Tx to identify what packet it is and where the l2, l3, l4 headers start for performance reasons.

Quoted 5 lines

I believe there are other hardware too that have the same expectation and hence we have a need for PKT_TX_IPv4, PKT_TX_IPv6 kind of flags.

Hence we want to make use of mbuf:tx_offload field and PKT_TX_* flags for identifying the packet and knowing what are its l2,l3,l4 offsets.

The objective is to give an indication to the hardware that the packet has:
- an 802.1q header at offset X for PKT_TX_MARK_VLAN_DEI
- an IP/IPv6 header at offset X for PKT_TX_MARK_IP_DSCP
- an IP/IPv6 header at offset X and a TCP/SCTP header at offset Y for PKT_TX_MARK_IP_ECN

Just to be sure I'm getting the point, would it also work if with flags like this:

- an 802.1q header at offset X for PKT_TX_HAS_VLAN
- an IP/IPv6 header at offset X for PKT_TX_IPv4 or PKT_TX_IPv6
- a TCP/SCTP header at offset Y for PKT_TX_TCP/PKT_TX_SCTP (implies PKT_TX_IPv4 or PKT_TX_IPv6)

The underlying question is: do we need the flags to only describe the content of the packet or do the flag also indicate that an action has to be done?

Quoted 5 lines
Quoted 4 lines

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Quoted 7 lines

Packet is coloured based on Single Rate[1] or Dual Rate[2] Shaping result and packet color determines traffic class. The exact behavior of packet color to traffic class mapping is mentioned in TM spec based on few other RFC's.

[1] https://tools.ietf.org/html/rfc2697
[2] https://tools.ietf.org/html/rfc2698

OK, so the traffic class does not depend on the packet type?

Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 3 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Quoted 8 lines
Quoted 4 lines

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Quoted 5 lines

Yes, I thought PMD's need to support both.
I'm fine adding specific feature flag for the offload flags alone if you insist or if there are other PMD's which don't need the offload flags for packet marking. I was not able to find out about other PMD's as none of the existing PMD's support packet marking.

Do you suggest that the behavior of the traffic manager marking should be:

a- the hardware tries to recognize tx packets, and mark them
accordingly. What packets are recognized depend on hardware.
b- if the mbuf has a specific flag, it helps the PMD and hardware to
recognize packets, so it can mark packets.

For an application, a- is difficult to apprehend as it will be dependent on hardware.

Or do you suggest that packets should only be marked if there is a mbuf flag? (only b-)

Do you confirm that there is no support at all for this feature today? I mean, what was the usage of rte_tm_mark_vlan_dei() these last 3 years?

Thanks,
Olivier

Quoted 140 lines
Quoted 72 lines

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

I meant by setting the flag, a packet has VLAN header adhering to IEEE 802.1Q spec.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

L2 header when VLAN header is preset will be
{custom header 'X' Bytes}:{Ethernet SRC+DST (12B)}:{VLAN Header (4B)}:{Ether Type (2B)} l2_len = X + 12 + 4 + 2
So, VLAN header starts at (l2_len - 6) bytes.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_mbuf/rte_mbuf_core.h +13 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Ack, will fix in V2.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#9 lore raw
Quoted 85 lines · Olivier Matz
Quoted 69 lines · Nithin Dabilpuram
Quoted 61 lines · Olivier Matz
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

Quoted 2 lines

The problem is for packets that cannot be recognized by the hardware, correct?

Yes. Octeontx2 HW always depends on application knowledge instead of walking through all the layers of packet data in Tx to identify what packet it is and where the l2, l3, l4 headers start for performance reasons.

Quoted 5 lines

I believe there are other hardware too that have the same expectation and hence we have a need for PKT_TX_IPv4, PKT_TX_IPv6 kind of flags.

Hence we want to make use of mbuf:tx_offload field and PKT_TX_* flags for identifying the packet and knowing what are its l2,l3,l4 offsets.

The objective is to give an indication to the hardware that the packet has:
- an 802.1q header at offset X for PKT_TX_MARK_VLAN_DEI
- an IP/IPv6 header at offset X for PKT_TX_MARK_IP_DSCP
- an IP/IPv6 header at offset X and a TCP/SCTP header at offset Y for PKT_TX_MARK_IP_ECN

Just to be sure I'm getting the point, would it also work if with flags like this:

Quoted 8 lines

- an 802.1q header at offset X for PKT_TX_HAS_VLAN
- an IP/IPv6 header at offset X for PKT_TX_IPv4 or PKT_TX_IPv6
- a TCP/SCTP header at offset Y for PKT_TX_TCP/PKT_TX_SCTP (implies PKT_TX_IPv4 or PKT_TX_IPv6)

The underlying question is: do we need the flags to only describe the content of the packet or do the flag also indicate that an action has to be done?

If we don't have a specific action based flag, then in future it might collide with other functionality and we will not be able to choose that specific offload. All the existing features are having specific flags, like TSO, CSUM.

RFC wise, even when marking in enabled and packet is coloured, not all packets can be marked.
For example when IP DSCP marking(RFC 2597) is enabled, marking is defined only with below 12 code points out of 64 code points (6 bits of DSCP).

Class 1 Class 2 Class 3 Class 4
+----------+----------+----------+----------+

Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |
Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |
High Drop Prec   |  001110  |  010110  |  011110  |  100110  |
                 +----------+----------+----------+----------+

All other combinations of DSCP value can be used for some other purposes and hence packets with those values shouldn't be marked. Similar is the case with IP ECN marking for TCP/SCTP(RFC 3168).

Having PMD or HW to check if the packet falls in the said class and then do marking will impact performance. Since application actually fills those values in packet, it will be more easy for them to say.

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Packet is coloured based on Single Rate[1] or Dual Rate[2] Shaping result and packet color determines traffic class. The exact behavior of packet color to traffic class mapping is mentioned in TM spec based on few other RFC's.

Quoted 4 lines
Quoted 2 lines

[1] https://urldefense.proofpoint.com/v2/url?u=https-3A__tools.ietf.org_html_rfc2697&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=05emGNkz3Qat3dtZIbEsmQDC5y9-tU9yItHX0x1aaJU&e=
[2] https://urldefense.proofpoint.com/v2/url?u=https-3A__tools.ietf.org_html_rfc2698&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=3VN2dIGSDt4vWM-FpPOOf-8SeVShl_t7QpXRU6Zw460&e=

OK, so the traffic class does not depend on the packet type?

Yes it doesn't. But where to update the traffic class is specific to packet type like DEI bit in VLAN or ECN field in IPv4/IPv6 or DSCP field in IPv4/IPv6. Also ECN marking is only valid for TCP/SCTP packets.

Quoted 43 lines
Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Quoted 8 lines
Quoted 4 lines

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Quoted 5 lines

Yes, I thought PMD's need to support both.
I'm fine adding specific feature flag for the offload flags alone if you insist or if there are other PMD's which don't need the offload flags for packet marking. I was not able to find out about other PMD's as none of the existing PMD's support packet marking.

Do you suggest that the behavior of the traffic manager marking should be:

a- the hardware tries to recognize tx packets, and mark them
accordingly. What packets are recognized depend on hardware.
b- if the mbuf has a specific flag, it helps the PMD and hardware to
recognize packets, so it can mark packets.

Quoted 5 lines

For an application, a- is difficult to apprehend as it will be dependent on hardware.

Or do you suggest that packets should only be marked if there is a mbuf flag? (only b-)

Yes, I believe b- is the right thing.

Quoted 3 lines

Do you confirm that there is no support at all for this feature today? I mean, what was the usage of rte_tm_mark_vlan_dei() these last 3 years?

Yes, it was not implemented/used. Because of such reasons, rte_tm.h is supposed to be experimental but was mistakenly marked stable. You can see related discussion in below threads about marking rte_tm.h experimental again in v20.11.
https://mails.dpdk.org/archives/dev/2020-April/164970.html
https://mails.dpdk.org/archives/dev/2020-May/166221.html

Thanks
Nithin

Quoted 145 lines

Thanks,
Olivier

Quoted 140 lines
Quoted 72 lines

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

I meant by setting the flag, a packet has VLAN header adhering to IEEE 802.1Q spec.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

L2 header when VLAN header is preset will be
{custom header 'X' Bytes}:{Ethernet SRC+DST (12B)}:{VLAN Header (4B)}:{Ether Type (2B)} l2_len = X + 12 + 4 + 2
So, VLAN header starts at (l2_len - 6) bytes.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_mbuf/rte_mbuf_core.h +13 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Ack, will fix in V2.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#10 lore raw

Hi Olivier,

Any thoughts on this ?

Quoted 348 lines · Nithin Dabilpuram
Quoted 85 lines · Olivier Matz
Quoted 69 lines · Nithin Dabilpuram
Quoted 61 lines · Olivier Matz
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

Quoted 2 lines

The problem is for packets that cannot be recognized by the hardware, correct?

Yes. Octeontx2 HW always depends on application knowledge instead of walking through all the layers of packet data in Tx to identify what packet it is and where the l2, l3, l4 headers start for performance reasons.

Quoted 5 lines

I believe there are other hardware too that have the same expectation and hence we have a need for PKT_TX_IPv4, PKT_TX_IPv6 kind of flags.

Hence we want to make use of mbuf:tx_offload field and PKT_TX_* flags for identifying the packet and knowing what are its l2,l3,l4 offsets.

The objective is to give an indication to the hardware that the packet has:
- an 802.1q header at offset X for PKT_TX_MARK_VLAN_DEI
- an IP/IPv6 header at offset X for PKT_TX_MARK_IP_DSCP
- an IP/IPv6 header at offset X and a TCP/SCTP header at offset Y for PKT_TX_MARK_IP_ECN

Just to be sure I'm getting the point, would it also work if with flags like this:

Quoted 8 lines

- an 802.1q header at offset X for PKT_TX_HAS_VLAN
- an IP/IPv6 header at offset X for PKT_TX_IPv4 or PKT_TX_IPv6
- a TCP/SCTP header at offset Y for PKT_TX_TCP/PKT_TX_SCTP (implies PKT_TX_IPv4 or PKT_TX_IPv6)

The underlying question is: do we need the flags to only describe the content of the packet or do the flag also indicate that an action has to be done?

If we don't have a specific action based flag, then in future it might collide with other functionality and we will not be able to choose that specific offload. All the existing features are having specific flags, like TSO, CSUM.

RFC wise, even when marking in enabled and packet is coloured, not all packets can be marked.
For example when IP DSCP marking(RFC 2597) is enabled, marking is defined only with below 12 code points out of 64 code points (6 bits of DSCP).

Class 1 Class 2 Class 3 Class 4
+----------+----------+----------+----------+

Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |
Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |
High Drop Prec   |  001110  |  010110  |  011110  |  100110  |
                 +----------+----------+----------+----------+

All other combinations of DSCP value can be used for some other purposes and hence packets with those values shouldn't be marked. Similar is the case with IP ECN marking for TCP/SCTP(RFC 3168).

Having PMD or HW to check if the packet falls in the said class and then do marking will impact performance. Since application actually fills those values in packet, it will be more easy for them to say.

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Packet is coloured based on Single Rate[1] or Dual Rate[2] Shaping result and packet color determines traffic class. The exact behavior of packet color to traffic class mapping is mentioned in TM spec based on few other RFC's.

Quoted 4 lines
Quoted 2 lines

[1] https://urldefense.proofpoint.com/v2/url?u=https-3A__tools.ietf.org_html_rfc2697&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=05emGNkz3Qat3dtZIbEsmQDC5y9-tU9yItHX0x1aaJU&e=
[2] https://urldefense.proofpoint.com/v2/url?u=https-3A__tools.ietf.org_html_rfc2698&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=3VN2dIGSDt4vWM-FpPOOf-8SeVShl_t7QpXRU6Zw460&e=

OK, so the traffic class does not depend on the packet type?

Yes it doesn't. But where to update the traffic class is specific to packet type like DEI bit in VLAN or ECN field in IPv4/IPv6 or DSCP field in IPv4/IPv6. Also ECN marking is only valid for TCP/SCTP packets.

Quoted 43 lines
Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Quoted 8 lines
Quoted 4 lines

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Quoted 5 lines

Yes, I thought PMD's need to support both.
I'm fine adding specific feature flag for the offload flags alone if you insist or if there are other PMD's which don't need the offload flags for packet marking. I was not able to find out about other PMD's as none of the existing PMD's support packet marking.

Do you suggest that the behavior of the traffic manager marking should be:

a- the hardware tries to recognize tx packets, and mark them
accordingly. What packets are recognized depend on hardware.
b- if the mbuf has a specific flag, it helps the PMD and hardware to
recognize packets, so it can mark packets.

Quoted 5 lines

For an application, a- is difficult to apprehend as it will be dependent on hardware.

Or do you suggest that packets should only be marked if there is a mbuf flag? (only b-)

Yes, I believe b- is the right thing.

Quoted 3 lines

Do you confirm that there is no support at all for this feature today? I mean, what was the usage of rte_tm_mark_vlan_dei() these last 3 years?

Yes, it was not implemented/used. Because of such reasons, rte_tm.h is supposed to be experimental but was mistakenly marked stable. You can see related discussion in below threads about marking rte_tm.h experimental again in v20.11.
https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-2DApril_164970.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=JWDwlSkCAEkWR-4kKuuIGFmhMtr8W10Ns9kEPidDFbQ&s=XESl2bNVKTkGiVmm3qww3zDb0vYu9_XcaqT2CkCViTs&e=
https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-2DMay_166221.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=JWDwlSkCAEkWR-4kKuuIGFmhMtr8W10Ns9kEPidDFbQ&s=ZGxLxUL_76HZo9YmWhyvDZeYg28uEh3q6od48a3KlbI&e=

Thanks
Nithin

Quoted 145 lines

Thanks,
Olivier

Quoted 140 lines
Quoted 72 lines

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

I meant by setting the flag, a packet has VLAN header adhering to IEEE 802.1Q spec.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

L2 header when VLAN header is preset will be
{custom header 'X' Bytes}:{Ethernet SRC+DST (12B)}:{VLAN Header (4B)}:{Ether Type (2B)} l2_len = X + 12 + 4 + 2
So, VLAN header starts at (l2_len - 6) bytes.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_mbuf/rte_mbuf_core.h +13 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Ack, will fix in V2.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#11 lore raw
In reply to Nithin Dabilpuram

Hi Nithin,

Quoted 193 lines · Nithin Dabilpuram
Quoted 85 lines · Olivier Matz
Quoted 69 lines · Nithin Dabilpuram
Quoted 61 lines · Olivier Matz
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

Quoted 2 lines

The problem is for packets that cannot be recognized by the hardware, correct?

Yes. Octeontx2 HW always depends on application knowledge instead of walking through all the layers of packet data in Tx to identify what packet it is and where the l2, l3, l4 headers start for performance reasons.

Quoted 5 lines

I believe there are other hardware too that have the same expectation and hence we have a need for PKT_TX_IPv4, PKT_TX_IPv6 kind of flags.

Hence we want to make use of mbuf:tx_offload field and PKT_TX_* flags for identifying the packet and knowing what are its l2,l3,l4 offsets.

The objective is to give an indication to the hardware that the packet has:
- an 802.1q header at offset X for PKT_TX_MARK_VLAN_DEI
- an IP/IPv6 header at offset X for PKT_TX_MARK_IP_DSCP
- an IP/IPv6 header at offset X and a TCP/SCTP header at offset Y for PKT_TX_MARK_IP_ECN

Just to be sure I'm getting the point, would it also work if with flags like this:

Quoted 8 lines

- an 802.1q header at offset X for PKT_TX_HAS_VLAN
- an IP/IPv6 header at offset X for PKT_TX_IPv4 or PKT_TX_IPv6
- a TCP/SCTP header at offset Y for PKT_TX_TCP/PKT_TX_SCTP (implies PKT_TX_IPv4 or PKT_TX_IPv6)

The underlying question is: do we need the flags to only describe the content of the packet or do the flag also indicate that an action has to be done?

If we don't have a specific action based flag, then in future it might collide with other functionality and we will not be able to choose that specific offload. All the existing features are having specific flags, like TSO, CSUM.

RFC wise, even when marking in enabled and packet is coloured, not all packets can be marked.
For example when IP DSCP marking(RFC 2597) is enabled, marking is defined only with below 12 code points out of 64 code points (6 bits of DSCP).

Class 1 Class 2 Class 3 Class 4
+----------+----------+----------+----------+

Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |
Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |
High Drop Prec   |  001110  |  010110  |  011110  |  100110  |
                 +----------+----------+----------+----------+

All other combinations of DSCP value can be used for some other purposes and hence packets with those values shouldn't be marked. Similar is the case with IP ECN marking for TCP/SCTP(RFC 3168).

Having PMD or HW to check if the packet falls in the said class and then do marking will impact performance. Since application actually fills those values in packet, it will be more easy for them to say.

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Packet is coloured based on Single Rate[1] or Dual Rate[2] Shaping result and packet color determines traffic class. The exact behavior of packet color to traffic class mapping is mentioned in TM spec based on few other RFC's.

Quoted 4 lines
Quoted 2 lines

[1] https://urldefense.proofpoint.com/v2/url?u=https-3A__tools.ietf.org_html_rfc2697&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=05emGNkz3Qat3dtZIbEsmQDC5y9-tU9yItHX0x1aaJU&e=
[2] https://urldefense.proofpoint.com/v2/url?u=https-3A__tools.ietf.org_html_rfc2698&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=3VN2dIGSDt4vWM-FpPOOf-8SeVShl_t7QpXRU6Zw460&e=

OK, so the traffic class does not depend on the packet type?

Yes it doesn't. But where to update the traffic class is specific to packet type like DEI bit in VLAN or ECN field in IPv4/IPv6 or DSCP field in IPv4/IPv6. Also ECN marking is only valid for TCP/SCTP packets.

Quoted 43 lines
Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Quoted 8 lines
Quoted 4 lines

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Quoted 5 lines

Yes, I thought PMD's need to support both.
I'm fine adding specific feature flag for the offload flags alone if you insist or if there are other PMD's which don't need the offload flags for packet marking. I was not able to find out about other PMD's as none of the existing PMD's support packet marking.

Do you suggest that the behavior of the traffic manager marking should be:

a- the hardware tries to recognize tx packets, and mark them
accordingly. What packets are recognized depend on hardware.
b- if the mbuf has a specific flag, it helps the PMD and hardware to
recognize packets, so it can mark packets.

Quoted 5 lines

For an application, a- is difficult to apprehend as it will be dependent on hardware.

Or do you suggest that packets should only be marked if there is a mbuf flag? (only b-)

Yes, I believe b- is the right thing.

Quoted 3 lines

Do you confirm that there is no support at all for this feature today? I mean, what was the usage of rte_tm_mark_vlan_dei() these last 3 years?

Quoted 6 lines

Yes, it was not implemented/used. Because of such reasons, rte_tm.h is supposed to be experimental but was mistakenly marked stable. You can see related discussion in below threads about marking rte_tm.h experimental again in v20.11.
https://mails.dpdk.org/archives/dev/2020-April/164970.html
https://mails.dpdk.org/archives/dev/2020-May/166221.html

Thank you for the explanations. I also think b- is a better choice.

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Would it be a problem to use a dynamic flag in this case?

Thanks,
Olivier

Quoted 149 lines

Thanks
Nithin

Quoted 145 lines

Thanks,
Olivier

Quoted 140 lines
Quoted 72 lines

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

I meant by setting the flag, a packet has VLAN header adhering to IEEE 802.1Q spec.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

L2 header when VLAN header is preset will be
{custom header 'X' Bytes}:{Ethernet SRC+DST (12B)}:{VLAN Header (4B)}:{Ether Type (2B)} l2_len = X + 12 + 4 + 2
So, VLAN header starts at (l2_len - 6) bytes.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_mbuf/rte_mbuf_core.h +13 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Ack, will fix in V2.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#12 lore raw
Quoted 205 lines · Olivier Matz

Hi Nithin,

Quoted 193 lines · Nithin Dabilpuram
Quoted 85 lines · Olivier Matz
Quoted 69 lines · Nithin Dabilpuram
Quoted 61 lines · Olivier Matz
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

Quoted 2 lines

The problem is for packets that cannot be recognized by the hardware, correct?

Yes. Octeontx2 HW always depends on application knowledge instead of walking through all the layers of packet data in Tx to identify what packet it is and where the l2, l3, l4 headers start for performance reasons.

Quoted 5 lines

I believe there are other hardware too that have the same expectation and hence we have a need for PKT_TX_IPv4, PKT_TX_IPv6 kind of flags.

Hence we want to make use of mbuf:tx_offload field and PKT_TX_* flags for identifying the packet and knowing what are its l2,l3,l4 offsets.

The objective is to give an indication to the hardware that the packet has:
- an 802.1q header at offset X for PKT_TX_MARK_VLAN_DEI
- an IP/IPv6 header at offset X for PKT_TX_MARK_IP_DSCP
- an IP/IPv6 header at offset X and a TCP/SCTP header at offset Y for PKT_TX_MARK_IP_ECN

Just to be sure I'm getting the point, would it also work if with flags like this:

Quoted 8 lines

- an 802.1q header at offset X for PKT_TX_HAS_VLAN
- an IP/IPv6 header at offset X for PKT_TX_IPv4 or PKT_TX_IPv6
- a TCP/SCTP header at offset Y for PKT_TX_TCP/PKT_TX_SCTP (implies PKT_TX_IPv4 or PKT_TX_IPv6)

The underlying question is: do we need the flags to only describe the content of the packet or do the flag also indicate that an action has to be done?

If we don't have a specific action based flag, then in future it might collide with other functionality and we will not be able to choose that specific offload. All the existing features are having specific flags, like TSO, CSUM.

RFC wise, even when marking in enabled and packet is coloured, not all packets can be marked.
For example when IP DSCP marking(RFC 2597) is enabled, marking is defined only with below 12 code points out of 64 code points (6 bits of DSCP).

Class 1 Class 2 Class 3 Class 4
+----------+----------+----------+----------+

Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |
Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |
High Drop Prec   |  001110  |  010110  |  011110  |  100110  |
                 +----------+----------+----------+----------+

All other combinations of DSCP value can be used for some other purposes and hence packets with those values shouldn't be marked. Similar is the case with IP ECN marking for TCP/SCTP(RFC 3168).

Having PMD or HW to check if the packet falls in the said class and then do marking will impact performance. Since application actually fills those values in packet, it will be more easy for them to say.

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Packet is coloured based on Single Rate[1] or Dual Rate[2] Shaping result and packet color determines traffic class. The exact behavior of packet color to traffic class mapping is mentioned in TM spec based on few other RFC's.

Quoted 4 lines
Quoted 2 lines

[1] https://urldefense.proofpoint.com/v2/url?u=https-3A__tools.ietf.org_html_rfc2697&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=05emGNkz3Qat3dtZIbEsmQDC5y9-tU9yItHX0x1aaJU&e=
[2] https://urldefense.proofpoint.com/v2/url?u=https-3A__tools.ietf.org_html_rfc2698&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=3VN2dIGSDt4vWM-FpPOOf-8SeVShl_t7QpXRU6Zw460&e=

OK, so the traffic class does not depend on the packet type?

Yes it doesn't. But where to update the traffic class is specific to packet type like DEI bit in VLAN or ECN field in IPv4/IPv6 or DSCP field in IPv4/IPv6. Also ECN marking is only valid for TCP/SCTP packets.

Quoted 43 lines
Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Quoted 8 lines
Quoted 4 lines

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Quoted 5 lines

Yes, I thought PMD's need to support both.
I'm fine adding specific feature flag for the offload flags alone if you insist or if there are other PMD's which don't need the offload flags for packet marking. I was not able to find out about other PMD's as none of the existing PMD's support packet marking.

Do you suggest that the behavior of the traffic manager marking should be:

a- the hardware tries to recognize tx packets, and mark them
accordingly. What packets are recognized depend on hardware.
b- if the mbuf has a specific flag, it helps the PMD and hardware to
recognize packets, so it can mark packets.

Quoted 5 lines

For an application, a- is difficult to apprehend as it will be dependent on hardware.

Or do you suggest that packets should only be marked if there is a mbuf flag? (only b-)

Yes, I believe b- is the right thing.

Quoted 3 lines

Do you confirm that there is no support at all for this feature today? I mean, what was the usage of rte_tm_mark_vlan_dei() these last 3 years?

Quoted 6 lines

Yes, it was not implemented/used. Because of such reasons, rte_tm.h is supposed to be experimental but was mistakenly marked stable. You can see related discussion in below threads about marking rte_tm.h experimental again in v20.11.
https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-2DApril_164970.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=myqGwnIHNjN9IP7urxcVAB384qKoxlmm00p1gS7ttbw&s=-o2E-F9aHy3mrQw6xgO__RPXY9t8s3yjJn81X6Ius3k&e=
https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-2DMay_166221.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=myqGwnIHNjN9IP7urxcVAB384qKoxlmm00p1gS7ttbw&s=gTKSzMmlhE75x4TP8IJB7NP5MVO-zxjmNRQ9bZ6MxwI&e=

Thank you for the explanations. I also think b- is a better choice.

Quoted 7 lines

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 154 lines

Thanks,
Olivier

Quoted 149 lines

Thanks
Nithin

Quoted 145 lines

Thanks,
Olivier

Quoted 140 lines
Quoted 72 lines

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

I meant by setting the flag, a packet has VLAN header adhering to IEEE 802.1Q spec.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

L2 header when VLAN header is preset will be
{custom header 'X' Bytes}:{Ethernet SRC+DST (12B)}:{VLAN Header (4B)}:{Ether Type (2B)} l2_len = X + 12 + 4 + 2
So, VLAN header starts at (l2_len - 6) bytes.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_mbuf/rte_mbuf_core.h +13 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Ack, will fix in V2.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#13 lore raw
Quoted 207 lines · Olivier Matz
Quoted 135 lines

Hi Nithin,

Quoted 132 lines · Nithin Dabilpuram
Quoted 85 lines · Olivier Matz
Quoted 69 lines · Nithin Dabilpuram
Quoted 61 lines · Olivier Matz
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

Quoted 2 lines

The problem is for packets that cannot be recognized by the hardware, correct?

Yes. Octeontx2 HW always depends on application knowledge instead of walking through all the layers of packet data in Tx to identify what packet it is and where the l2, l3, l4 headers start for performance reasons.

Quoted 5 lines

I believe there are other hardware too that have the same expectation and hence we have a need for PKT_TX_IPv4, PKT_TX_IPv6 kind of flags.

Hence we want to make use of mbuf:tx_offload field and PKT_TX_* flags for identifying the packet and knowing what are its l2,l3,l4 offsets.

The objective is to give an indication to the hardware that the packet has:
- an 802.1q header at offset X for PKT_TX_MARK_VLAN_DEI
- an IP/IPv6 header at offset X for PKT_TX_MARK_IP_DSCP
- an IP/IPv6 header at offset X and a TCP/SCTP header at offset Y for PKT_TX_MARK_IP_ECN

Just to be sure I'm getting the point, would it also work if with flags like this:

Quoted 8 lines

- an 802.1q header at offset X for PKT_TX_HAS_VLAN
- an IP/IPv6 header at offset X for PKT_TX_IPv4 or PKT_TX_IPv6
- a TCP/SCTP header at offset Y for PKT_TX_TCP/PKT_TX_SCTP (implies PKT_TX_IPv4 or PKT_TX_IPv6)

The underlying question is: do we need the flags to only describe the content of the packet or do the flag also indicate that an action has to be done?

If we don't have a specific action based flag, then in future it might collide with other functionality and we will not be able to choose that specific offload. All the existing features are having specific flags, like TSO, CSUM.

RFC wise, even when marking in enabled and packet is coloured, not all packets can be marked.
For example when IP DSCP marking(RFC 2597) is enabled, marking is defined only with below 12 code points out of 64 code points (6 bits of DSCP).

Class 1 Class 2 Class 3 Class 4
+----------+----------+----------+----------+

Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |
Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |
High Drop Prec   |  001110  |  010110  |  011110  |  100110  |
                 +----------+----------+----------+----------+

All other combinations of DSCP value can be used for some other purposes and hence packets with those values shouldn't be marked. Similar is the case with IP ECN marking for TCP/SCTP(RFC 3168).

Having PMD or HW to check if the packet falls in the said class and then do marking will impact performance. Since application actually fills those values in packet, it will be more easy for them to say.

Quoted 12 lines
Quoted 12 lines
Quoted 5 lines

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Packet is coloured based on Single Rate[1] or Dual Rate[2] Shaping result and packet color determines traffic class. The exact behavior of packet color to traffic class mapping is mentioned in TM spec based on few other RFC's.

[1] https://urldefense.proofpoint.com/v2/url?u=https-

3A__tools.ietf.org_html_rfc2697&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m= pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=05emGNkz3Qat3dtZIbEsmQDC5y9-tU9yItHX0x1aaJU&e=

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

[2] https://urldefense.proofpoint.com/v2/url?u=https-

3A__tools.ietf.org_html_rfc2698&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m= pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=3VN2dIGSDt4vWM-FpPOOf-8SeVShl_t7QpXRU6Zw460&e=

Quoted 57 lines
Quoted 57 lines
Quoted 2 lines

OK, so the traffic class does not depend on the packet type?

Yes it doesn't. But where to update the traffic class is specific to packet type like DEI bit in VLAN or ECN field in IPv4/IPv6 or DSCP field in IPv4/IPv6. Also ECN marking is only valid for TCP/SCTP packets.

Quoted 43 lines
Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Quoted 8 lines
Quoted 4 lines

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Quoted 5 lines

Yes, I thought PMD's need to support both.
I'm fine adding specific feature flag for the offload flags alone if you insist or if there are other PMD's which don't need the offload flags for packet marking. I was not able to find out about other PMD's as none of the existing PMD's support packet marking.

Do you suggest that the behavior of the traffic manager marking should be:

a- the hardware tries to recognize tx packets, and mark them
accordingly. What packets are recognized depend on hardware.
b- if the mbuf has a specific flag, it helps the PMD and hardware to
recognize packets, so it can mark packets.

Quoted 5 lines

For an application, a- is difficult to apprehend as it will be dependent on hardware.

Or do you suggest that packets should only be marked if there is a mbuf flag? (only b-)

Yes, I believe b- is the right thing.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Do you confirm that there is no support at all for this feature today? I mean, what was the usage of rte_tm_mark_vlan_dei() these last 3 years?

Yes, it was not implemented/used. Because of such reasons, rte_tm.h is supposed to be experimental but was mistakenly marked stable. You can see related discussion in below threads about marking rte_tm.h experimental again in v20.11.
https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-

Quoted 13 lines

2DApril_164970.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=myqGwnIHN jN9IP7urxcVAB384qKoxlmm00p1gS7ttbw&s=-o2E-F9aHy3mrQw6xgO__RPXY9t8s3yjJn81X6Ius3k&e=

Quoted 1 line
Quoted 1 line

https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-

2DMay_166221.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=myqGwnIHNj N9IP7urxcVAB384qKoxlmm00p1gS7ttbw&s=gTKSzMmlhE75x4TP8IJB7NP5MVO-zxjmNRQ9bZ6MxwI&e=

Quoted 8 lines

Thank you for the explanations. I also think b- is a better choice.

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

Quoted 162 lines
Quoted 2 lines

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 154 lines

Thanks,
Olivier

Quoted 149 lines

Thanks
Nithin

Quoted 145 lines

Thanks,
Olivier

Quoted 140 lines
Quoted 72 lines

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

I meant by setting the flag, a packet has VLAN header adhering to IEEE 802.1Q spec.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

L2 header when VLAN header is preset will be
{custom header 'X' Bytes}:{Ethernet SRC+DST (12B)}:{VLAN Header (4B)}:{Ether Type (2B)} l2_len = X + 12 + 4 + 2
So, VLAN header starts at (l2_len - 6) bytes.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_mbuf/rte_mbuf_core.h +13 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Ack, will fix in V2.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#14 lore raw
Quoted 221 lines · Konstantin
Quoted 207 lines · Olivier Matz
Quoted 135 lines

Hi Nithin,

Quoted 132 lines · Nithin Dabilpuram
Quoted 85 lines · Olivier Matz
Quoted 69 lines · Nithin Dabilpuram
Quoted 61 lines · Olivier Matz
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

Quoted 2 lines

The problem is for packets that cannot be recognized by the hardware, correct?

Yes. Octeontx2 HW always depends on application knowledge instead of walking through all the layers of packet data in Tx to identify what packet it is and where the l2, l3, l4 headers start for performance reasons.

Quoted 5 lines

I believe there are other hardware too that have the same expectation and hence we have a need for PKT_TX_IPv4, PKT_TX_IPv6 kind of flags.

Hence we want to make use of mbuf:tx_offload field and PKT_TX_* flags for identifying the packet and knowing what are its l2,l3,l4 offsets.

The objective is to give an indication to the hardware that the packet has:
- an 802.1q header at offset X for PKT_TX_MARK_VLAN_DEI
- an IP/IPv6 header at offset X for PKT_TX_MARK_IP_DSCP
- an IP/IPv6 header at offset X and a TCP/SCTP header at offset Y for PKT_TX_MARK_IP_ECN

Just to be sure I'm getting the point, would it also work if with flags like this:

Quoted 8 lines

- an 802.1q header at offset X for PKT_TX_HAS_VLAN
- an IP/IPv6 header at offset X for PKT_TX_IPv4 or PKT_TX_IPv6
- a TCP/SCTP header at offset Y for PKT_TX_TCP/PKT_TX_SCTP (implies PKT_TX_IPv4 or PKT_TX_IPv6)

The underlying question is: do we need the flags to only describe the content of the packet or do the flag also indicate that an action has to be done?

If we don't have a specific action based flag, then in future it might collide with other functionality and we will not be able to choose that specific offload. All the existing features are having specific flags, like TSO, CSUM.

RFC wise, even when marking in enabled and packet is coloured, not all packets can be marked.
For example when IP DSCP marking(RFC 2597) is enabled, marking is defined only with below 12 code points out of 64 code points (6 bits of DSCP).

Class 1 Class 2 Class 3 Class 4
+----------+----------+----------+----------+

Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |
Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |
High Drop Prec   |  001110  |  010110  |  011110  |  100110  |
                 +----------+----------+----------+----------+

All other combinations of DSCP value can be used for some other purposes and hence packets with those values shouldn't be marked. Similar is the case with IP ECN marking for TCP/SCTP(RFC 3168).

Having PMD or HW to check if the packet falls in the said class and then do marking will impact performance. Since application actually fills those values in packet, it will be more easy for them to say.

Quoted 12 lines
Quoted 12 lines
Quoted 5 lines

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Packet is coloured based on Single Rate[1] or Dual Rate[2] Shaping result and packet color determines traffic class. The exact behavior of packet color to traffic class mapping is mentioned in TM spec based on few other RFC's.

[1] https://urldefense.proofpoint.com/v2/url?u=https-

3A__tools.ietf.org_html_rfc2697&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m= pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=05emGNkz3Qat3dtZIbEsmQDC5y9-tU9yItHX0x1aaJU&e=

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

[2] https://urldefense.proofpoint.com/v2/url?u=https-

3A__tools.ietf.org_html_rfc2698&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m= pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=3VN2dIGSDt4vWM-FpPOOf-8SeVShl_t7QpXRU6Zw460&e=

Quoted 57 lines
Quoted 57 lines
Quoted 2 lines

OK, so the traffic class does not depend on the packet type?

Yes it doesn't. But where to update the traffic class is specific to packet type like DEI bit in VLAN or ECN field in IPv4/IPv6 or DSCP field in IPv4/IPv6. Also ECN marking is only valid for TCP/SCTP packets.

Quoted 43 lines
Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Quoted 8 lines
Quoted 4 lines

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Quoted 5 lines

Yes, I thought PMD's need to support both.
I'm fine adding specific feature flag for the offload flags alone if you insist or if there are other PMD's which don't need the offload flags for packet marking. I was not able to find out about other PMD's as none of the existing PMD's support packet marking.

Do you suggest that the behavior of the traffic manager marking should be:

a- the hardware tries to recognize tx packets, and mark them
accordingly. What packets are recognized depend on hardware.
b- if the mbuf has a specific flag, it helps the PMD and hardware to
recognize packets, so it can mark packets.

Quoted 5 lines

For an application, a- is difficult to apprehend as it will be dependent on hardware.

Or do you suggest that packets should only be marked if there is a mbuf flag? (only b-)

Yes, I believe b- is the right thing.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Do you confirm that there is no support at all for this feature today? I mean, what was the usage of rte_tm_mark_vlan_dei() these last 3 years?

Yes, it was not implemented/used. Because of such reasons, rte_tm.h is supposed to be experimental but was mistakenly marked stable. You can see related discussion in below threads about marking rte_tm.h experimental again in v20.11.
https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-

Quoted 13 lines

2DApril_164970.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=myqGwnIHN jN9IP7urxcVAB384qKoxlmm00p1gS7ttbw&s=-o2E-F9aHy3mrQw6xgO__RPXY9t8s3yjJn81X6Ius3k&e=

Quoted 1 line
Quoted 1 line

https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-

2DMay_166221.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=myqGwnIHNj N9IP7urxcVAB384qKoxlmm00p1gS7ttbw&s=gTKSzMmlhE75x4TP8IJB7NP5MVO-zxjmNRQ9bZ6MxwI&e=

Quoted 8 lines

Thank you for the explanations. I also think b- is a better choice.

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

@@ -186,10 +186,16 @@ extern "C" {

/* add new RX flags here, don't forget to update PKT_FIRST_FREE */

+/* Reused Rx offload bits for Tx offloads */

+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)

+
#define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)

/* add new TX flags here, don't forget to update PKT_LAST_FREE */
+#define PKT_TX_MARK_EN (1ULL << 40)

Is this fine ?

Quoted 163 lines
Quoted 163 lines
Quoted 3 lines

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 154 lines

Thanks,
Olivier

Quoted 149 lines

Thanks
Nithin

Quoted 145 lines

Thanks,
Olivier

Quoted 140 lines
Quoted 72 lines

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

I meant by setting the flag, a packet has VLAN header adhering to IEEE 802.1Q spec.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

L2 header when VLAN header is preset will be
{custom header 'X' Bytes}:{Ethernet SRC+DST (12B)}:{VLAN Header (4B)}:{Ether Type (2B)} l2_len = X + 12 + 4 + 2
So, VLAN header starts at (l2_len - 6) bytes.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_mbuf/rte_mbuf_core.h +13 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Ack, will fix in V2.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#15 lore raw

Hi Olivier,

Quoted 249 lines · Nithin Dabilpuram
Quoted 221 lines · Konstantin
Quoted 207 lines · Olivier Matz
Quoted 135 lines

Hi Nithin,

Quoted 132 lines · Nithin Dabilpuram
Quoted 85 lines · Olivier Matz
Quoted 69 lines · Nithin Dabilpuram
Quoted 61 lines · Olivier Matz
Quoted 33 lines · Nithin Dabilpuram

Hi Olivier,

Quoted 30 lines · Olivier Matz

External Email

----------------------------------------------------------------------
Hi,

Quoted 23 lines · Jerin Jacob
Quoted 15 lines · Nithin Dabilpuram

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

Quoted 2 lines

None of the ethdev TM driver implementations has supported packet marking support.
rte_tm and rte_mbuf maintainers(Christian, Oliver), Could you review this patch?

Quoted 7 lines
Quoted 3 lines

As you know, the number of mbuf flags is limited (only 18 bits are remaining), so I think we should use them with care, i.e. for features that are generic enough.

I agree, but I believe this is one of the basic flags needed like other Tx checksum offload flags (like PKT_TX_IP_CKSUM, PKT_TX_IPV4, etc) which are needed to identify on which packets HW should/can apply packet marking.

PKT_TX_IP_CKSUM tells the hardware to offload the checksum calculation. This is pretty straightforward and there is no other dependency than the offload feature advertised by the PMD.

I'm sorry, I have not a lot of experience with rte_tm.h, so it's difficult for me to have a global view of what is done for instance when PKT_TX_MARK_VLAN_DEI is set, and what happens when it is not set.

Can you confirm that my understanding below is correct? (or correct me where I'm wrong)

Before your patch:
- the application enables the port and traffic manager on it
- the application calls rte_tm_mark_vlan_dei() to select which traffic class must be marked
- when a packet is transmitted, the traffic class is determined by the hardware, and if the hardware recognizes a VLAN packet, the VLAN DEI bit is set depending on traffic class

Quoted 2 lines

The problem is for packets that cannot be recognized by the hardware, correct?

Yes. Octeontx2 HW always depends on application knowledge instead of walking through all the layers of packet data in Tx to identify what packet it is and where the l2, l3, l4 headers start for performance reasons.

Quoted 5 lines

I believe there are other hardware too that have the same expectation and hence we have a need for PKT_TX_IPv4, PKT_TX_IPv6 kind of flags.

Hence we want to make use of mbuf:tx_offload field and PKT_TX_* flags for identifying the packet and knowing what are its l2,l3,l4 offsets.

The objective is to give an indication to the hardware that the packet has:
- an 802.1q header at offset X for PKT_TX_MARK_VLAN_DEI
- an IP/IPv6 header at offset X for PKT_TX_MARK_IP_DSCP
- an IP/IPv6 header at offset X and a TCP/SCTP header at offset Y for PKT_TX_MARK_IP_ECN

Just to be sure I'm getting the point, would it also work if with flags like this:

Quoted 8 lines

- an 802.1q header at offset X for PKT_TX_HAS_VLAN
- an IP/IPv6 header at offset X for PKT_TX_IPv4 or PKT_TX_IPv6
- a TCP/SCTP header at offset Y for PKT_TX_TCP/PKT_TX_SCTP (implies PKT_TX_IPv4 or PKT_TX_IPv6)

The underlying question is: do we need the flags to only describe the content of the packet or do the flag also indicate that an action has to be done?

If we don't have a specific action based flag, then in future it might collide with other functionality and we will not be able to choose that specific offload. All the existing features are having specific flags, like TSO, CSUM.

RFC wise, even when marking in enabled and packet is coloured, not all packets can be marked.
For example when IP DSCP marking(RFC 2597) is enabled, marking is defined only with below 12 code points out of 64 code points (6 bits of DSCP).

Class 1 Class 2 Class 3 Class 4
+----------+----------+----------+----------+

Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |
Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |
High Drop Prec   |  001110  |  010110  |  011110  |  100110  |
                 +----------+----------+----------+----------+

All other combinations of DSCP value can be used for some other purposes and hence packets with those values shouldn't be marked. Similar is the case with IP ECN marking for TCP/SCTP(RFC 3168).

Having PMD or HW to check if the packet falls in the said class and then do marking will impact performance. Since application actually fills those values in packet, it will be more easy for them to say.

Quoted 12 lines
Quoted 12 lines
Quoted 5 lines

So your patch is a way to force the hardware to recognize mark set the VLAN DEI on packets that are not recognized as VLAN packets?

How the is traffic class of the packet determined?

Packet is coloured based on Single Rate[1] or Dual Rate[2] Shaping result and packet color determines traffic class. The exact behavior of packet color to traffic class mapping is mentioned in TM spec based on few other RFC's.

[1] https://urldefense.proofpoint.com/v2/url?u=https-

3A__tools.ietf.org_html_rfc2697&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m= pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=05emGNkz3Qat3dtZIbEsmQDC5y9-tU9yItHX0x1aaJU&e=

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

[2] https://urldefense.proofpoint.com/v2/url?u=https-

3A__tools.ietf.org_html_rfc2698&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m= pJDciSXpMy6TawycjvpYj_Jq5M5j_ywqhU8-keRI_ac&s=3VN2dIGSDt4vWM-FpPOOf-8SeVShl_t7QpXRU6Zw460&e=

Quoted 57 lines
Quoted 57 lines
Quoted 2 lines

OK, so the traffic class does not depend on the packet type?

Yes it doesn't. But where to update the traffic class is specific to packet type like DEI bit in VLAN or ECN field in IPv4/IPv6 or DSCP field in IPv4/IPv6. Also ECN marking is only valid for TCP/SCTP packets.

Quoted 43 lines
Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
Quoted 5 lines

From what I understand, this feature is bound to octeontx2, so using a mbuf dynamic flag would make more sense here. There are some examples in dpdk repository, just grep for "dynflag".

This is not octeontx2 specific flag but any "packet marking feature" enabled PMD would need these flags to identify on which packets marking needs to be done. This is the first PMD that supports packet marking feature and hence it was not exposed earlier.

For example to mark VLAN DEI, PMD cannot always assume that there is preexisting VLAN header from Byte 12 as there is no gaurantee that ethernet header always starts at Byte 0 (Custom headers before ethernet hdr).

Quoted 4 lines

Also, I think that the feature availability should be advertised through an ethdev offload, so an application can know at initialization time that these flags can be used.

Quoted 8 lines
Quoted 4 lines

Feature availablity is already part of TM spec in rte_tm.h struct rte_tm_capabilities:mark_vlan_dei_supported struct rte_tm_capabilities:mark_ip_ecn_[sctp|tcp]_supported struct rte_tm_capabilities:mark_ip_dscp_supported

Does this mean that any driver advertising this existing feature flag has to support the new mbuf flags too? Shouldn't we have a specific feature for it?

Quoted 5 lines

Yes, I thought PMD's need to support both.
I'm fine adding specific feature flag for the offload flags alone if you insist or if there are other PMD's which don't need the offload flags for packet marking. I was not able to find out about other PMD's as none of the existing PMD's support packet marking.

Do you suggest that the behavior of the traffic manager marking should be:

a- the hardware tries to recognize tx packets, and mark them
accordingly. What packets are recognized depend on hardware.
b- if the mbuf has a specific flag, it helps the PMD and hardware to
recognize packets, so it can mark packets.

Quoted 5 lines

For an application, a- is difficult to apprehend as it will be dependent on hardware.

Or do you suggest that packets should only be marked if there is a mbuf flag? (only b-)

Yes, I believe b- is the right thing.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Do you confirm that there is no support at all for this feature today? I mean, what was the usage of rte_tm_mark_vlan_dei() these last 3 years?

Yes, it was not implemented/used. Because of such reasons, rte_tm.h is supposed to be experimental but was mistakenly marked stable. You can see related discussion in below threads about marking rte_tm.h experimental again in v20.11.
https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-

Quoted 13 lines

2DApril_164970.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=myqGwnIHN jN9IP7urxcVAB384qKoxlmm00p1gS7ttbw&s=-o2E-F9aHy3mrQw6xgO__RPXY9t8s3yjJn81X6Ius3k&e=

Quoted 1 line
Quoted 1 line

https://urldefense.proofpoint.com/v2/url?u=https-3A__mails.dpdk.org_archives_dev_2020-

2DMay_166221.html&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=myqGwnIHNj N9IP7urxcVAB384qKoxlmm00p1gS7ttbw&s=gTKSzMmlhE75x4TP8IJB7NP5MVO-zxjmNRQ9bZ6MxwI&e=

Quoted 8 lines

Thank you for the explanations. I also think b- is a better choice.

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

(quoted diff) +7 -1
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN         (1ULL << 40)
 
Quoted 1 line

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

Quoted 165 lines
Quoted 165 lines
Quoted 165 lines
Quoted 5 lines

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 154 lines

Thanks,
Olivier

Quoted 149 lines

Thanks
Nithin

Quoted 145 lines

Thanks,
Olivier

Quoted 140 lines
Quoted 72 lines

Please also see few comments below.

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
---
 doc/guides/nics/features.rst    | 14 ++++++++++++++
 lib/librte_mbuf/rte_mbuf.c      |  6 ++++++
 lib/librte_mbuf/rte_mbuf_core.h | 36 ++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/nics/features.rst +14 -0
index edd21c4..bc978fb 100644
@@ -913,6 +913,20 @@ Supports to get Rx/Tx packet burst mode information.
 * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``.
 * **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``.
 
+.. _nic_features_traffic_manager_packet_marking_offload:
+
+Traffic Manager Packet marking offload
+--------------------------------------
+
+Supports enabling a packet marking offload specific mbuf.
+
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_MARK_IP_DSCP``,
+  ``mbuf.ol_flags:PKT_TX_MARK_IP_ECN``, ``mbuf.ol_flags:PKT_TX_MARK_VLAN_DEI``,
+  ``mbuf.ol_flags:PKT_TX_IPV4``, ``mbuf.ol_flags:PKT_TX_IPV6``.
+* **[uses]     mbuf**: ``mbuf.l2_len``.
+* **[related] API**: ``rte_tm_mark_ip_dscp()``, ``rte_tm_mark_ip_ecn()``,
+  ``rte_tm_mark_vlan_dei()``.
+
 .. _nic_features_other:
 
 Other dev ops not represented by a Feature
lib/librte_mbuf/rte_mbuf.c +6 -0
index cd5794d..5c6896d 100644
@@ -880,6 +880,9 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
        case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
        case PKT_TX_UDP_SEG: return "PKT_TX_UDP_SEG";
        case PKT_TX_OUTER_UDP_CKSUM: return "PKT_TX_OUTER_UDP_CKSUM";
+       case PKT_TX_MARK_VLAN_DEI: return "PKT_TX_MARK_VLAN_DEI";
+       case PKT_TX_MARK_IP_DSCP: return "PKT_TX_MARK_IP_DSCP";
+       case PKT_TX_MARK_IP_ECN: return "PKT_TX_MARK_IP_ECN";
        default: return NULL;
        }
 }
@@ -916,6 +919,9 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
                { PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
                { PKT_TX_UDP_SEG, PKT_TX_UDP_SEG, NULL },
                { PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
+               { PKT_TX_MARK_VLAN_DEI, PKT_TX_MARK_VLAN_DEI, NULL },
+               { PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_DSCP, NULL },
+               { PKT_TX_MARK_IP_ECN, PKT_TX_MARK_IP_ECN, NULL },
        };
        const char *name;
        unsigned int i;
lib/librte_mbuf/rte_mbuf_core.h +1 -1
index b9a59c8..d9f1290 100644
@@ -187,11 +187,40 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 37)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
 
Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 200

Quoted 7 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
 /**
+ * Packet marking offload flags. These flags indicated what kind
+ * of packet marking needs to be applied on a given mbuf when
+ * appropriate Traffic Manager configuration is in place.
+ * When user set's these flags on a mbuf, below assumptions are made
+ * 1) When PKT_TX_MARK_VLAN_DEI is set,
+ * a) PMD assumes pkt to be a 802.1q packet.

What does that imply?

I meant by setting the flag, a packet has VLAN header adhering to IEEE 802.1Q spec.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 202

Quoted 3 lines
lib/librte_mbuf/rte_mbuf_core.h +2 -0
+ * b) Application should also set mbuf.l2_len where 802.1Q header is
+ *    at (mbuf.l2_len - 6) offset.

Why mbuf.l2_len - 6 ?

L2 header when VLAN header is preset will be
{custom header 'X' Bytes}:{Ethernet SRC+DST (12B)}:{VLAN Header (4B)}:{Ether Type (2B)} l2_len = X + 12 + 4 + 2
So, VLAN header starts at (l2_len - 6) bytes.

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
lib/librte_mbuf/rte_mbuf_core.h +13 -0
+ * 2) When PKT_TX_MARK_IP_DSCP is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6
+ *    to indicate whether if it is IPv4 packet or IPv6 packet
+ *    for DSCP marking. It should also set PKT_TX_IP_CKSUM if it is
+ *    IPv4 pkt.
+ * b) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ * 3) When PKT_TX_MARK_IP_ECN is set,
+ * a) Application should also set either PKT_TX_IPV4 or PKT_TX_IPV6.
+ *    It should also set PKT_TX_IP_CKSUM if it is IPv4 pkt.
+ * b) PMD will assume pkt L4 protocol is either TCP or SCTP and
+ *    ECN is set to 2'b01 or 2'b10 as per RFC 3168 and hence HW
+ *    can mark the packet for a configured color.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_mbuf/rte_mbuf_core.h extern "C" { · line 221

Quoted 6 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -0
+ * c) Application should also set mbuf.l2_len that indicates
+ *    start offset of L3 header.
+ */
+#define PKT_TX_MARK_VLAN_DEI           (1ULL << 38)
+#define PKT_TX_MARK_IP_DSCP            (1ULL << 39)
+#define PKT_TX_MARK_IP_ECN             (1ULL << 40)

We should have one comment per define.

Ack, will fix in V2.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
lib/librte_mbuf/rte_mbuf_core.h +6 -2
+
+/**
  * Outer UDP checksum offload flag. This flag is used for enabling
  * outer UDP checksum in PMD. To use outer UDP checksum, the user needs to
  * 1) Enable the following in mbuf,
@@ -384,7 +413,10 @@ extern "C" {
                PKT_TX_MACSEC |          \
                PKT_TX_SEC_OFFLOAD |     \
                PKT_TX_UDP_SEG |         \
-               PKT_TX_OUTER_UDP_CKSUM)
+               PKT_TX_OUTER_UDP_CKSUM | \
+               PKT_TX_MARK_VLAN_DEI |   \
+               PKT_TX_MARK_IP_DSCP |    \
+               PKT_TX_MARK_IP_ECN)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.
--

2.8.4

#16 lore raw
Quoted 24 lines
Quoted 24 lines
Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

(quoted diff) +6 -1
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
Quoted 7 lines
Quoted 4 lines
(quoted diff) +1 -0
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN         (1ULL << 40)
 

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

+ Techboard

There is a related thread going on
http://mails.dpdk.org/archives/dev/2020-May/168810.html

If there is no consensus on email, then I would like to add this item to the next TB meeting.

#17 lore raw

Hi Jerin,

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

(quoted diff) +6 -1
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
(quoted diff) +1 -0
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN         (1ULL << 40)
 

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

My thought was not about re-defining the flags (I think it is better to keep them intact), but adding a union for one of rx-only fields (packet_type/rss/timestamp).

Quoted 8 lines

+ Techboard

There is a related thread going on
http://mails.dpdk.org/archives/dev/2020-May/168810.html

If there is no consensus on email, then I would like to add this item to the next TB meeting.

Ok, I'll add that to tomorrow meeting agenda.
Konstantin

#18 lore raw
Quoted 29 lines · Konstantin

Hi Jerin,

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

(quoted diff) +7 -1
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN         (1ULL << 40)
 
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

My thought was not about re-defining the flags (I think it is better to keep them intact), but adding a union for one of rx-only fields (packet_type/rss/timestamp).

Ok. Adding a union field at packet_type field is also fine like below.

@@ -187,9 +187,10 @@ extern "C" {
/* add new RX flags here, don't forget to update PKT_FIRST_FREE */

#define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)

/* add new TX flags here, don't forget to update PKT_LAST_FREE */
+#define PKT_TX_MARK_EN (1ULL << 40)

/**
* Outer UDP checksum offload flag. This flag is used for enabling
@@ -461,6 +462,14 @@ enum {
#endif
};

+/* Tx packet marking flags in rte_mbuf::tx_mark.
+ * Valid only when PKT_TX_MARK_EN is set in
+ * rte_mbuf::ol_flags.
+ */
+#define TX_MARK_VLAN_DEI (1ULL << 0)
+#define TX_MARK_IP_DSCP (1ULL << 1)
+#define TX_MARK_IP_ECN (1ULL << 2)
+
/**
* The generic rte_mbuf, containing a packet mbuf.
*/
@@ -543,6 +552,10 @@ struct rte_mbuf {
};
uint32_t inner_l4_type:4; /**< Inner L4 type. */
};
+ struct {
+ uint32_t reserved:29;
+ uint32_t tx_mark:3;
+ };
};

Please correct me if this is not what you mean.

Quoted 13 lines
Quoted 9 lines

+ Techboard

There is a related thread going on
https://urldefense.proofpoint.com/v2/url?u=http-3A__mails.dpdk.org_archives_dev_2020-2DMay_168810.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=nyV4Rud03HW6DbWMpyvOCulQNkagmfo0wKtrwQ7zmmg&s=VuktoUb_xoLsHKdB9mV87x67cP9tXk3DqVXptt9nF_s&e=

If there is no consensus on email, then I would like to add this item to the next TB meeting.

Ok, I'll add that to tomorrow meeting agenda.
Konstantin

#19 lore raw

Hi,

Quoted 79 lines · Nithin Dabilpuram
Quoted 29 lines · Konstantin

Hi Jerin,

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

(quoted diff) +7 -1
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN         (1ULL << 40)
 
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

My thought was not about re-defining the flags (I think it is better to keep them intact), but adding a union for one of rx-only fields (packet_type/rss/timestamp).

Ok. Adding a union field at packet_type field is also fine like below.

(quoted diff) +14 -1
@@ -187,9 +187,10 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN		(1ULL << 40)
 
 /**
  * Outer UDP checksum offload flag. This flag is used for enabling
@@ -461,6 +462,14 @@ enum {
 #endif
 };
 
+/* Tx packet marking flags in rte_mbuf::tx_mark.
+ * Valid only when PKT_TX_MARK_EN is set in
+ * rte_mbuf::ol_flags.
+ */
+#define TX_MARK_VLAN_DEI	(1ULL << 0)
+#define TX_MARK_IP_DSCP	(1ULL << 1)
+#define TX_MARK_IP_ECN		(1ULL << 2)
+
 /**
  * The generic rte_mbuf, containing a packet mbuf.
  */
@@ -543,6 +552,10 @@ struct rte_mbuf {
 			};
 			uint32_t inner_l4_type:4; /**< Inner L4 type. */
 		};
+		struct {
+			uint32_t reserved:29;
+			uint32_t tx_mark:3;
+		};
 	};
 
 
Quoted 1 line

Please correct me if this is not what you mean.

I'm not a big fan of reusing Rx fields or flags for Tx.
It's not obvious for an application than adding a tx_mark will overwrite the packet_type. I understand that the risk is limited because packet_type is Rx and the marks are Tx, but there is still one.

To summarize the different proposed approaches (please correct me if I'm wrong):

a- add 3 Tx mbuf flags
(-) consumes limited resource

b- add 3 dynamic flags
(-) slower

c- add 1 Tx flag and union with Rx field
(-) exclusive with Rx field
(-) still consumes one flag

My preference is still b-, for these reasons:

- There are many different DPDK use cases, and resources in mbuf is tight. Recent contributions (rte_flow and ice driver) already made use of dynamic fields/flags.

- When I implemented the dynamic fields/flags feature, I did a test which showed that the cost of having a dynamic offset was few cycles (on my test platform, it was~3 cycles for reading a field and ~2 cycles for writing a field).

Regards,
Olivier

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

+ Techboard

There is a related thread going on
https://urldefense.proofpoint.com/v2/url?u=http-3A__mails.dpdk.org_archives_dev_2020-2DMay_168810.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=nyV4Rud03HW6DbWMpyvOCulQNkagmfo0wKtrwQ7zmmg&s=VuktoUb_xoLsHKdB9mV87x67cP9tXk3DqVXptt9nF_s&e=

If there is no consensus on email, then I would like to add this item to the next TB meeting.

Ok, I'll add that to tomorrow meeting agenda.
Konstantin

#20 lore raw
Quoted 82 lines · Olivier Matz

Hi,

Quoted 79 lines · Nithin Dabilpuram
Quoted 29 lines · Konstantin

Hi Jerin,

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

(quoted diff) +7 -1
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN         (1ULL << 40)
 
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

My thought was not about re-defining the flags (I think it is better to keep them intact), but adding a union for one of rx-only fields (packet_type/rss/timestamp).

Ok. Adding a union field at packet_type field is also fine like below.

(quoted diff) +14 -1
@@ -187,9 +187,10 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN		(1ULL << 40)
 
 /**
  * Outer UDP checksum offload flag. This flag is used for enabling
@@ -461,6 +462,14 @@ enum {
 #endif
 };
 
+/* Tx packet marking flags in rte_mbuf::tx_mark.
+ * Valid only when PKT_TX_MARK_EN is set in
+ * rte_mbuf::ol_flags.
+ */
+#define TX_MARK_VLAN_DEI	(1ULL << 0)
+#define TX_MARK_IP_DSCP	(1ULL << 1)
+#define TX_MARK_IP_ECN		(1ULL << 2)
+
 /**
  * The generic rte_mbuf, containing a packet mbuf.
  */
@@ -543,6 +552,10 @@ struct rte_mbuf {
 			};
 			uint32_t inner_l4_type:4; /**< Inner L4 type. */
 		};
+		struct {
+			uint32_t reserved:29;
+			uint32_t tx_mark:3;
+		};
 	};
 
 
Quoted 6 lines
Quoted 1 line

Please correct me if this is not what you mean.

I'm not a big fan of reusing Rx fields or flags for Tx.
It's not obvious for an application than adding a tx_mark will overwrite the packet_type. I understand that the risk is limited because packet_type is Rx and the marks are Tx, but there is still one.

I'm also not a big fan but just wanted to take this approach so that, it can both conserve space and also help fast path. Reusing Rx area is however not a new thing as is already followed for mbuf->txadapter field.

Apart from documentation issue, Is there any other issue or future ramification with using Rx field's for Tx ?
If it is only about documentation, then we can add more documentation to make things clear.

Quoted 8 lines

To summarize the different proposed approaches (please correct me if I'm wrong):

a- add 3 Tx mbuf flags
(-) consumes limited resource

b- add 3 dynamic flags
(-) slower

- Tx burst Vector implementation can't be done for this tx offload as offset keeps changing.

Quoted 10 lines

c- add 1 Tx flag and union with Rx field
(-) exclusive with Rx field
(-) still consumes one flag

My preference is still b-, for these reasons:

- There are many different DPDK use cases, and resources in mbuf is tight. Recent contributions (rte_flow and ice driver) already made use of dynamic fields/flags.

- Since RTE_FLOW metadata is 32-bit field, it is a clear candidate for dynamic flags.
- ICE PMD's dynamic field is however a vendor specific field and only for ICE PMD users.

In this case, it is just 1 bit out of 18 free bits available in ol_flags.

Quoted 5 lines

- When I implemented the dynamic fields/flags feature, I did a test which showed that the cost of having a dynamic offset was few cycles (on my test platform, it was~3 cycles for reading a field and ~2 cycles for writing a field).

I think this cost is of the case where the address where the dyn_offset is stored is already in cache as it needs to be read first.

Quoted 20 lines

Regards,
Olivier

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

+ Techboard

There is a related thread going on
https://urldefense.proofpoint.com/v2/url?u=http-3A__mails.dpdk.org_archives_dev_2020-2DMay_168810.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=nyV4Rud03HW6DbWMpyvOCulQNkagmfo0wKtrwQ7zmmg&s=VuktoUb_xoLsHKdB9mV87x67cP9tXk3DqVXptt9nF_s&e=

If there is no consensus on email, then I would like to add this item to the next TB meeting.

Ok, I'll add that to tomorrow meeting agenda.
Konstantin

#21 lore raw

Hi Nithin,

Quoted 90 lines · Nithin Dabilpuram
Quoted 82 lines · Olivier Matz

Hi,

Quoted 79 lines · Nithin Dabilpuram
Quoted 29 lines · Konstantin

Hi Jerin,

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

(quoted diff) +7 -1
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN         (1ULL << 40)
 
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

My thought was not about re-defining the flags (I think it is better to keep them intact), but adding a union for one of rx-only fields (packet_type/rss/timestamp).

Ok. Adding a union field at packet_type field is also fine like below.

(quoted diff) +14 -1
@@ -187,9 +187,10 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN		(1ULL << 40)
 
 /**
  * Outer UDP checksum offload flag. This flag is used for enabling
@@ -461,6 +462,14 @@ enum {
 #endif
 };
 
+/* Tx packet marking flags in rte_mbuf::tx_mark.
+ * Valid only when PKT_TX_MARK_EN is set in
+ * rte_mbuf::ol_flags.
+ */
+#define TX_MARK_VLAN_DEI	(1ULL << 0)
+#define TX_MARK_IP_DSCP	(1ULL << 1)
+#define TX_MARK_IP_ECN		(1ULL << 2)
+
 /**
  * The generic rte_mbuf, containing a packet mbuf.
  */
@@ -543,6 +552,10 @@ struct rte_mbuf {
 			};
 			uint32_t inner_l4_type:4; /**< Inner L4 type. */
 		};
+		struct {
+			uint32_t reserved:29;
+			uint32_t tx_mark:3;
+		};
 	};
 
 
Quoted 6 lines
Quoted 1 line

Please correct me if this is not what you mean.

I'm not a big fan of reusing Rx fields or flags for Tx.
It's not obvious for an application than adding a tx_mark will overwrite the packet_type. I understand that the risk is limited because packet_type is Rx and the marks are Tx, but there is still one.

Quoted 4 lines

I'm also not a big fan but just wanted to take this approach so that, it can both conserve space and also help fast path. Reusing Rx area is however not a new thing as is already followed for mbuf->txadapter field.

Yes, and in my opinion this is something we should avoid when possible, because it makes some features exclusive (ex: the big union with sched/rss/adapter/usr/...).

Quoted 2 lines

Apart from documentation issue, Is there any other issue or future ramification with using Rx field's for Tx ?

No, I don't see any other issue except the ones we already mentioned (doc, code clarity, ).

Quoted 4 lines

If it is only about documentation, then we can add more documentation to make things clear.

Quoted 3 lines

To summarize the different proposed approaches (please correct me if I'm wrong):

Quoted 8 lines
Quoted 5 lines

a- add 3 Tx mbuf flags
(-) consumes limited resource

b- add 3 dynamic flags
(-) slower

- Tx burst Vector implementation can't be done for this tx offload as offset keeps changing.

A vector implementation can be done. But yes, it would be slower than with a static flag.

Quoted 5 lines
Quoted 5 lines

c- add 1 Tx flag and union with Rx field
(-) exclusive with Rx field
(-) still consumes one flag

Quoted 7 lines
Quoted 5 lines

My preference is still b-, for these reasons:

- There are many different DPDK use cases, and resources in mbuf is tight. Recent contributions (rte_flow and ice driver) already made use of dynamic fields/flags.

- Since RTE_FLOW metadata is 32-bit field, it is a clear candidate for dynamic flags.

I'm not sure to get why it is a better candidate than packet marking. You mean because it requires more room in mbuf?

Quoted 2 lines

- ICE PMD's dynamic field is however a vendor specific field and only for ICE PMD users.

Yes, but ICE PMD users may be as important as packet marking users.

Quoted 10 lines

In this case, it is just 1 bit out of 18 free bits available in ol_flags.

Quoted 5 lines

- When I implemented the dynamic fields/flags feature, I did a test which showed that the cost of having a dynamic offset was few cycles (on my test platform, it was~3 cycles for reading a field and ~2 cycles for writing a field).

I think this cost is of the case where the address where the dyn_offset is stored is already in cache as it needs to be read first.

This fetch of the value (in case it is not in cache) can be done once per bulk, so I'm not sure the impact would be high.

Regards,
Olivier

Quoted 22 lines
Quoted 22 lines

Regards,
Olivier

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

+ Techboard

There is a related thread going on
https://urldefense.proofpoint.com/v2/url?u=http-3A__mails.dpdk.org_archives_dev_2020-2DMay_168810.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=nyV4Rud03HW6DbWMpyvOCulQNkagmfo0wKtrwQ7zmmg&s=VuktoUb_xoLsHKdB9mV87x67cP9tXk3DqVXptt9nF_s&e=

If there is no consensus on email, then I would like to add this item to the next TB meeting.

Ok, I'll add that to tomorrow meeting agenda.
Konstantin

#22 lore raw
Quoted 114 lines · Olivier Matz

Hi Nithin,

Quoted 90 lines · Nithin Dabilpuram
Quoted 82 lines · Olivier Matz

Hi,

Quoted 79 lines · Nithin Dabilpuram
Quoted 29 lines · Konstantin

Hi Jerin,

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

(quoted diff) +7 -1
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN         (1ULL << 40)
 
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

My thought was not about re-defining the flags (I think it is better to keep them intact), but adding a union for one of rx-only fields (packet_type/rss/timestamp).

Ok. Adding a union field at packet_type field is also fine like below.

(quoted diff) +14 -1
@@ -187,9 +187,10 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN		(1ULL << 40)
 
 /**
  * Outer UDP checksum offload flag. This flag is used for enabling
@@ -461,6 +462,14 @@ enum {
 #endif
 };
 
+/* Tx packet marking flags in rte_mbuf::tx_mark.
+ * Valid only when PKT_TX_MARK_EN is set in
+ * rte_mbuf::ol_flags.
+ */
+#define TX_MARK_VLAN_DEI	(1ULL << 0)
+#define TX_MARK_IP_DSCP	(1ULL << 1)
+#define TX_MARK_IP_ECN		(1ULL << 2)
+
 /**
  * The generic rte_mbuf, containing a packet mbuf.
  */
@@ -543,6 +552,10 @@ struct rte_mbuf {
 			};
 			uint32_t inner_l4_type:4; /**< Inner L4 type. */
 		};
+		struct {
+			uint32_t reserved:29;
+			uint32_t tx_mark:3;
+		};
 	};
 
 
Quoted 6 lines
Quoted 1 line

Please correct me if this is not what you mean.

I'm not a big fan of reusing Rx fields or flags for Tx.
It's not obvious for an application than adding a tx_mark will overwrite the packet_type. I understand that the risk is limited because packet_type is Rx and the marks are Tx, but there is still one.

Quoted 4 lines

I'm also not a big fan but just wanted to take this approach so that, it can both conserve space and also help fast path. Reusing Rx area is however not a new thing as is already followed for mbuf->txadapter field.

Yes, and in my opinion this is something we should avoid when possible, because it makes some features exclusive (ex: the big union with sched/rss/adapter/usr/...).

Quoted 2 lines

Apart from documentation issue, Is there any other issue or future ramification with using Rx field's for Tx ?

No, I don't see any other issue except the ones we already mentioned (doc, code clarity, ).

Quoted 7 lines

If it is only about documentation, then we can add more documentation to make things clear.

Quoted 6 lines

To summarize the different proposed approaches (please correct me if I'm wrong):

a- add 3 Tx mbuf flags
(-) consumes limited resource

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

b- add 3 dynamic flags
(-) slower

- Tx burst Vector implementation can't be done for this tx offload as offset keeps changing.

A vector implementation can be done. But yes, it would be slower than with a static flag.

Very slow atleast in our HW as, we try to translate ol_flags to HW descriptor flags in addition to extra operations to be done like offset calculations etc.

So if we have fixed offsets, then it is easy to have static constant 128/256 bit words with offsets and use things like shuffle/table lookup to reorganize multiple mbuf flags to descriptor fields in a single instruction.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

c- add 1 Tx flag and union with Rx field
(-) exclusive with Rx field
(-) still consumes one flag

My preference is still b-, for these reasons:

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

- There are many different DPDK use cases, and resources in mbuf is tight. Recent contributions (rte_flow and ice driver) already made use of dynamic fields/flags.

- Since RTE_FLOW metadata is 32-bit field, it is a clear candidate for dynamic flags.

I'm not sure to get why it is a better candidate than packet marking. You mean because it requires more room in mbuf?

Yes, I feel space consumption is one way to decide whether it should be a dynfield or static field.

IMO, other parameter to judge could be whether the field definition/usage itself is well know standard and is a part of RTE spec or its definition is vendor specific.

Quoted 5 lines
Quoted 3 lines

- ICE PMD's dynamic field is however a vendor specific field and only for ICE PMD users.

Yes, but ICE PMD users may be as important as packet marking users.

Agree, I only meant that the flag ICE PMD registered cannot be used for other PMD's so by using dynamic field, we are avoiding wastage of a static field that is needed only by one specific PMD irrespective of whether that PMD is probed or not.

Quoted 9 lines
Quoted 9 lines

In this case, it is just 1 bit out of 18 free bits available in ol_flags.

Quoted 5 lines

- When I implemented the dynamic fields/flags feature, I did a test which showed that the cost of having a dynamic offset was few cycles (on my test platform, it was~3 cycles for reading a field and ~2 cycles for writing a field).

Quoted 5 lines
Quoted 2 lines

I think this cost is of the case where the address where the dyn_offset is stored is already in cache as it needs to be read first.

This fetch of the value (in case it is not in cache) can be done once per bulk, so I'm not sure the impact would be high.

Agreed, for bulk case offset loading should have less impact.

Quoted 28 lines

Regards,
Olivier

Quoted 22 lines
Quoted 22 lines

Regards,
Olivier

Quoted 14 lines
Quoted 14 lines
Quoted 10 lines

+ Techboard

There is a related thread going on
https://urldefense.proofpoint.com/v2/url?u=http-3A__mails.dpdk.org_archives_dev_2020-2DMay_168810.html&d=DwIGaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=nyV4Rud03HW6DbWMpyvOCulQNkagmfo0wKtrwQ7zmmg&s=VuktoUb_xoLsHKdB9mV87x67cP9tXk3DqVXptt9nF_s&e=

If there is no consensus on email, then I would like to add this item to the next TB meeting.

Ok, I'll add that to tomorrow meeting agenda.
Konstantin

#23 lore raw
Quoted 147 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Nithin Dabilpuram
Sent: Wednesday, June 3, 2020 15:52
To: Olivier Matz <[email protected]>
Cc: Ananyev, Konstantin <[email protected]>; Jerin Jacob <[email protected]>; Dumitrescu, Cristian <[email protected]>; Nithin Dabilpuram <[email protected]>; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; Ori Kam <[email protected]>; Burakov, Anatoly <[email protected]>; Mcnamara, John <[email protected]>; Kovacevic, Marko <[email protected]>; dpdk-dev <[email protected]>; Jerin Jacob <[email protected]>; Krzysztof Kanas <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH 1/3] mbuf: add Tx offloads for packet marking

Quoted 8 lines · Olivier Matz

Hi Nithin,

Quoted 5 lines · Nithin Dabilpuram
Quoted 4 lines · Olivier Matz

Hi,

Quoted 1 line · Nithin Dabilpuram

On Tue, Jun 02, 2020 at 10:53:08AM +0000, Ananyev, Konstantin

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Hi Jerin,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

I also share Olivier's concern about consuming 3 bits in

ol_flags for that feature.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store

additional information (packet_type, or so).

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx

offload flags area.

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

For example:

(quoted diff) +0 -0
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update

PKT_FIRST_FREE */

(quoted diff) +5 -0
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23) -#define

PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)

/* add new TX flags here, don't forget to update
PKT_LAST_FREE */
+#define PKT_TX_MARK_EN (1ULL << 40)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

My thought was not about re-defining the flags (I think it is better to keep them intact), but adding a union for one of rx-only

fields (packet_type/rss/timestamp).

Quoted 55 lines
Quoted 49 lines
Quoted 42 lines
Quoted 42 lines

Ok. Adding a union field at packet_type field is also fine like below.

(quoted diff) +2 -0
@@ -187,9 +187,10 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE
 */
 
 #define PKT_FIRST_FREE (1ULL << 23) -#define PKT_LAST_FREE
 (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE
 */
+#define PKT_TX_MARK_EN		(1ULL << 40)
 
 /**
  * Outer UDP checksum offload flag. This flag is used for

enabling @@ -461,6 +462,14 @@ enum { #endif };

(quoted diff) +12 -0
+/* Tx packet marking flags in rte_mbuf::tx_mark.
+ * Valid only when PKT_TX_MARK_EN is set in
+ * rte_mbuf::ol_flags.
+ */
+#define TX_MARK_VLAN_DEI	(1ULL << 0)
+#define TX_MARK_IP_DSCP	(1ULL << 1)
+#define TX_MARK_IP_ECN		(1ULL << 2)
+
 /**
  * The generic rte_mbuf, containing a packet mbuf.
  */
@@ -543,6 +552,10 @@ struct rte_mbuf {
 			};
 			uint32_t inner_l4_type:4; /**< Inner L4 type. */
 		};
+		struct {
+			uint32_t reserved:29;
+			uint32_t tx_mark:3;
+		};
 	};
 
 
Quoted 6 lines
Quoted 1 line

Please correct me if this is not what you mean.

I'm not a big fan of reusing Rx fields or flags for Tx.
It's not obvious for an application than adding a tx_mark will overwrite the packet_type. I understand that the risk is limited because packet_type is Rx and the marks are Tx, but there is still one.

Quoted 5 lines

I'm also not a big fan but just wanted to take this approach so that, it can both conserve space and also help fast path. Reusing Rx area is however not a new thing as is already followed for
mbuf->txadapter field.

Quoted 8 lines

Yes, and in my opinion this is something we should avoid when possible, because it makes some features exclusive (ex: the big union with sched/rss/adapter/usr/...).

Quoted 2 lines

Apart from documentation issue, Is there any other issue or future ramification with using Rx field's for Tx ?

No, I don't see any other issue except the ones we already mentioned (doc,

code clarity, ).

Quoted 2 lines
Quoted 2 lines

If it is only about documentation, then we can add more documentation

to make things clear.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

To summarize the different proposed approaches (please correct me if

I'm wrong):

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

a- add 3 Tx mbuf flags
(-) consumes limited resource

b- add 3 dynamic flags
(-) slower

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

- Tx burst Vector implementation can't be done for this tx offload as offset keeps changing.

A vector implementation can be done. But yes, it would be slower than with a static flag.

Very slow atleast in our HW as, we try to translate ol_flags to HW descriptor flags in addition to extra operations to be done like offset calculations etc.

The dynamic flag offset is not subject to be changed after registration.
So, flag offset can be converted once into appropriate mask and stored locally by PMD for further using in vector instructions. The only difference - loaded variable mask instead of constant one, should not affect performance too much. With the cmpeq/shifts the and results can be converted to any desired predefined mask (like static one).

Quoted 2 lines

So if we have fixed offsets, then it is easy to have static constant

BTW, how this constant is loaded?
I suppose on x86 it would be rather mm_load?_si128(*constant array) - no difference between dynamic and static masks at all. BTW, there is the hint - to make local copy of the mask/offset in order to avoid cache-line concurrency in global variable storage.

Quoted 2 lines

128/256 bit words with offsets and use things like shuffle/table lookup to reorganize multiple mbuf flags to descriptor fields in a single instruction.

Offsets in the HW descriptor remain the fixed ones, so shuffle would still work OK. Do you already have some vectorized implementation? It would be curious to have a look at.

I strongly share the concern about defining the static mbuf flags, we should consider all ways to avoid doing this.

WBR, Slava

Quoted 104 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

c- add 1 Tx flag and union with Rx field
(-) exclusive with Rx field
(-) still consumes one flag

My preference is still b-, for these reasons:

- There are many different DPDK use cases, and resources in mbuf is

tight.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Recent contributions (rte_flow and ice driver) already made use of

dynamic

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

fields/flags.

- Since RTE_FLOW metadata is 32-bit field, it is a clear candidate for dynamic flags.

I'm not sure to get why it is a better candidate than packet marking. You mean because it requires more room in mbuf?

Yes, I feel space consumption is one way to decide whether it should be a dynfield or static field.

IMO, other parameter to judge could be whether the field definition/usage itself is well know standard and is a part of RTE spec or its definition is vendor specific.

Quoted 5 lines
Quoted 3 lines

- ICE PMD's dynamic field is however a vendor specific field and only for ICE PMD users.

Yes, but ICE PMD users may be as important as packet marking users.

Agree, I only meant that the flag ICE PMD registered cannot be used for other PMD's so by using dynamic field, we are avoiding wastage of a static field that is needed only by one specific PMD irrespective of whether that PMD is probed or not.

Quoted 5 lines
Quoted 5 lines

In this case, it is just 1 bit out of 18 free bits available in ol_flags.

Quoted 2 lines

- When I implemented the dynamic fields/flags feature, I did a test

which

Quoted 1 line
Quoted 1 line
Quoted 1 line

showed that the cost of having a dynamic offset was few cycles (on

my test

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

platform, it was~3 cycles for reading a field and ~2 cycles for writing a field).

I think this cost is of the case where the address where the dyn_offset is stored is already in cache as it needs to be read first.

This fetch of the value (in case it is not in cache) can be done once per bulk, so I'm not sure the impact would be high.

Agreed, for bulk case offset loading should have less impact.

Quoted 20 lines

Regards,
Olivier

Quoted 14 lines
Quoted 14 lines

Regards,
Olivier

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+ Techboard

There is a related thread going on
https://eur03.safelinks.protection.outlook.com/?url=https%3A
%2F%2Furldefense.proofpoint.com%2Fv2%2Furl%3Fu%3Dhttp-

3A__ma

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ils.dpdk.org_archives_dev_2020-

2DMay_168810.html%26d%3DDwIGa

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Q%26c%3DnKjWec2b6R0mOyPaz7xtfQ%26r%3DFZ_tPCbgFOh18zwRPO9H0y D

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

x8VW38vuapifdDfc8SFQ%26m%3DnyV4Rud03HW6DbWMpyvOCulQNkagmf o0w

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

KtrwQ7zmmg%26s%3DVuktoUb_xoLsHKdB9mV87x67cP9tXk3DqVXptt9nF_s

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

%26e%3D&amp;data=02%7C01%7Cviacheslavo%40mellanox.com%7C5e7a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

9c93fd684e09267108d807bd0160%7Ca652971c7d2e4d9ba6a4d149256f4

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

61b%7C0%7C0%7C637267855650797843&amp;sdata=r%2B0JIDapZocl6DD

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

A8wbNd4LV0CX6zEdDoQJhBpMoELw%3D&amp;reserved=0

If there is no consensus on email, then I would like to add this item to the next TB meeting.

Ok, I'll add that to tomorrow meeting agenda.
Konstantin

#24 lore raw
Quoted 169 lines · Slava Ovsiienko
Quoted 147 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Nithin Dabilpuram
Sent: Wednesday, June 3, 2020 15:52
To: Olivier Matz <[email protected]>
Cc: Ananyev, Konstantin <[email protected]>; Jerin Jacob <[email protected]>; Dumitrescu, Cristian <[email protected]>; Nithin Dabilpuram <[email protected]>; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; Ori Kam <[email protected]>; Burakov, Anatoly <[email protected]>; Mcnamara, John <[email protected]>; Kovacevic, Marko <[email protected]>; dpdk-dev <[email protected]>; Jerin Jacob <[email protected]>; Krzysztof Kanas <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH 1/3] mbuf: add Tx offloads for packet marking

Quoted 8 lines · Olivier Matz

Hi Nithin,

Quoted 5 lines · Nithin Dabilpuram
Quoted 4 lines · Olivier Matz

Hi,

Quoted 1 line · Nithin Dabilpuram

On Tue, Jun 02, 2020 at 10:53:08AM +0000, Ananyev, Konstantin

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Hi Jerin,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

I also share Olivier's concern about consuming 3 bits in

ol_flags for that feature.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store

additional information (packet_type, or so).

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx

offload flags area.

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

For example:

(quoted diff) +0 -0
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update

PKT_FIRST_FREE */

(quoted diff) +5 -0
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23) -#define

PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)

/* add new TX flags here, don't forget to update
PKT_LAST_FREE */
+#define PKT_TX_MARK_EN (1ULL << 40)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

My thought was not about re-defining the flags (I think it is better to keep them intact), but adding a union for one of rx-only

fields (packet_type/rss/timestamp).

Quoted 55 lines
Quoted 49 lines
Quoted 42 lines
Quoted 42 lines

Ok. Adding a union field at packet_type field is also fine like below.

(quoted diff) +2 -0
@@ -187,9 +187,10 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE
 */
 
 #define PKT_FIRST_FREE (1ULL << 23) -#define PKT_LAST_FREE
 (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE
 */
+#define PKT_TX_MARK_EN		(1ULL << 40)
 
 /**
  * Outer UDP checksum offload flag. This flag is used for

enabling @@ -461,6 +462,14 @@ enum { #endif };

(quoted diff) +12 -0
+/* Tx packet marking flags in rte_mbuf::tx_mark.
+ * Valid only when PKT_TX_MARK_EN is set in
+ * rte_mbuf::ol_flags.
+ */
+#define TX_MARK_VLAN_DEI	(1ULL << 0)
+#define TX_MARK_IP_DSCP	(1ULL << 1)
+#define TX_MARK_IP_ECN		(1ULL << 2)
+
 /**
  * The generic rte_mbuf, containing a packet mbuf.
  */
@@ -543,6 +552,10 @@ struct rte_mbuf {
 			};
 			uint32_t inner_l4_type:4; /**< Inner L4 type. */
 		};
+		struct {
+			uint32_t reserved:29;
+			uint32_t tx_mark:3;
+		};
 	};
 
 
Quoted 6 lines
Quoted 1 line

Please correct me if this is not what you mean.

I'm not a big fan of reusing Rx fields or flags for Tx.
It's not obvious for an application than adding a tx_mark will overwrite the packet_type. I understand that the risk is limited because packet_type is Rx and the marks are Tx, but there is still one.

Quoted 5 lines

I'm also not a big fan but just wanted to take this approach so that, it can both conserve space and also help fast path. Reusing Rx area is however not a new thing as is already followed for
mbuf->txadapter field.

Quoted 8 lines

Yes, and in my opinion this is something we should avoid when possible, because it makes some features exclusive (ex: the big union with sched/rss/adapter/usr/...).

Quoted 2 lines

Apart from documentation issue, Is there any other issue or future ramification with using Rx field's for Tx ?

No, I don't see any other issue except the ones we already mentioned (doc,

code clarity, ).

Quoted 2 lines
Quoted 2 lines

If it is only about documentation, then we can add more documentation

to make things clear.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

To summarize the different proposed approaches (please correct me if

I'm wrong):

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

a- add 3 Tx mbuf flags
(-) consumes limited resource

b- add 3 dynamic flags
(-) slower

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

- Tx burst Vector implementation can't be done for this tx offload as offset keeps changing.

A vector implementation can be done. But yes, it would be slower than with a static flag.

Very slow atleast in our HW as, we try to translate ol_flags to HW descriptor flags in addition to extra operations to be done like offset calculations etc.

The dynamic flag offset is not subject to be changed after registration.
So, flag offset can be converted once into appropriate mask and stored locally by PMD for further using in vector instructions. The only difference - loaded variable mask instead of constant one, should not affect performance too much. With the cmpeq/shifts the and results can be converted to any desired predefined mask (like static one).

Quoted 2 lines

So if we have fixed offsets, then it is easy to have static constant

BTW, how this constant is loaded?
I suppose on x86 it would be rather mm_load?_si128(*constant array) - no difference between dynamic and static masks at all. BTW, there is the hint - to make local copy of the mask/offset in order to avoid cache-line concurrency in global variable storage.

Quoted 5 lines
Quoted 2 lines

128/256 bit words with offsets and use things like shuffle/table lookup to reorganize multiple mbuf flags to descriptor fields in a single instruction.

Offsets in the HW descriptor remain the fixed ones, so shuffle would still work OK. Do you already have some vectorized implementation? It would be curious to have a look at.

Agree that the constants need to be loaded from memory, but there is also a logic created onto transforming that data to descriptor which is not always straight forward.

For example, see otx2_tx.c,

// mbuf has tx offload field L2_LEN of 7 bits, L3_LEN of 9 bits which are not on byte boundary. // Below are the transformations done to get them to byte boundary.

/* Get tx_offload for ol2, ol3, l2, l3 lengths from mbuf*/ /*
* Operation result:
* E(8):OL2_LEN(7):OL3_LEN(9):E(24):L3_LEN(9):L2_LEN(7)
* E(8):OL2_LEN(7):OL3_LEN(9):E(24):L3_LEN(9):L2_LEN(7) */

asm volatile ("LD1 {%[a].D}[0],[%[in]]\n\t" :

                [a]"+w"(senddesc01_w1) :
                [in]"r"(mbuf0 + 2) : "memory");

/*
* Operation Result:
* E(47):L3_LEN(9):L2_LEN(7+z)
* E(47):L3_LEN(9):L2_LEN(7+z)
*/
senddesc01_w1 = vshlq_n_u64(senddesc01_w1, 1);
senddesc23_w1 = vshlq_n_u64(senddesc23_w1, 1);

/*
* Result:
* E(48):L3_LEN(8):L2_LEN(z+7)
* E(48):L3_LEN(8):L2_LEN(z+7)
*/

const int8x16_t tshft3 = {
        -1, 0, 8, 8, 8, 8, 8, 8,
        -1, 0, 8, 8, 8, 8, 8, 8,
};

senddesc01_w1 = vshlq_u8(senddesc01_w1, tshft3);
senddesc23_w1 = vshlq_u8(senddesc23_w1, tshft3);

We cannot get all the above logic done runtime for every position of mbuf->l2_len if the field position keeps changing for every application run.

Quoted 109 lines

I strongly share the concern about defining the static mbuf flags, we should consider all ways to avoid doing this.

WBR, Slava

Quoted 104 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

c- add 1 Tx flag and union with Rx field
(-) exclusive with Rx field
(-) still consumes one flag

My preference is still b-, for these reasons:

- There are many different DPDK use cases, and resources in mbuf is

tight.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Recent contributions (rte_flow and ice driver) already made use of

dynamic

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

fields/flags.

- Since RTE_FLOW metadata is 32-bit field, it is a clear candidate for dynamic flags.

I'm not sure to get why it is a better candidate than packet marking. You mean because it requires more room in mbuf?

Yes, I feel space consumption is one way to decide whether it should be a dynfield or static field.

IMO, other parameter to judge could be whether the field definition/usage itself is well know standard and is a part of RTE spec or its definition is vendor specific.

Quoted 5 lines
Quoted 3 lines

- ICE PMD's dynamic field is however a vendor specific field and only for ICE PMD users.

Yes, but ICE PMD users may be as important as packet marking users.

Agree, I only meant that the flag ICE PMD registered cannot be used for other PMD's so by using dynamic field, we are avoiding wastage of a static field that is needed only by one specific PMD irrespective of whether that PMD is probed or not.

Quoted 5 lines
Quoted 5 lines

In this case, it is just 1 bit out of 18 free bits available in ol_flags.

Quoted 2 lines

- When I implemented the dynamic fields/flags feature, I did a test

which

Quoted 1 line
Quoted 1 line
Quoted 1 line

showed that the cost of having a dynamic offset was few cycles (on

my test

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

platform, it was~3 cycles for reading a field and ~2 cycles for writing a field).

I think this cost is of the case where the address where the dyn_offset is stored is already in cache as it needs to be read first.

This fetch of the value (in case it is not in cache) can be done once per bulk, so I'm not sure the impact would be high.

Agreed, for bulk case offset loading should have less impact.

Quoted 20 lines

Regards,
Olivier

Quoted 14 lines
Quoted 14 lines

Regards,
Olivier

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+ Techboard

There is a related thread going on
https://urldefense.proofpoint.com/v2/url?u=https-3A__eur03.safelinks.protection.outlook.com_-3Furl-3Dhttps-253A&d=DwIFAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=5IzeBXssneRLE7EeAyOUnytITHfcmhQu-eRLr18e5U0&s=aCn4On5jrJAfrGkQm_ftPodlBQo3QiozQM76MU9S8j8&e=
%2F%2Furldefense.proofpoint.com%2Fv2%2Furl%3Fu%3Dhttp-

3A__ma

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ils.dpdk.org_archives_dev_2020-

2DMay_168810.html%26d%3DDwIGa

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Q%26c%3DnKjWec2b6R0mOyPaz7xtfQ%26r%3DFZ_tPCbgFOh18zwRPO9H0y D

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

x8VW38vuapifdDfc8SFQ%26m%3DnyV4Rud03HW6DbWMpyvOCulQNkagmf o0w

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

KtrwQ7zmmg%26s%3DVuktoUb_xoLsHKdB9mV87x67cP9tXk3DqVXptt9nF_s

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

%26e%3D&amp;data=02%7C01%7Cviacheslavo%40mellanox.com%7C5e7a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

9c93fd684e09267108d807bd0160%7Ca652971c7d2e4d9ba6a4d149256f4

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

61b%7C0%7C0%7C637267855650797843&amp;sdata=r%2B0JIDapZocl6DD

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

A8wbNd4LV0CX6zEdDoQJhBpMoELw%3D&amp;reserved=0

If there is no consensus on email, then I would like to add this item to the next TB meeting.

Ok, I'll add that to tomorrow meeting agenda.
Konstantin

#25 lore raw
In reply to Olivier Matz

03/06/2020 13:38, Olivier Matz:

Quoted 12 lines · Nithin Dabilpuram
Quoted 11 lines · Olivier Matz
Quoted 10 lines · Nithin Dabilpuram
Quoted 9 lines · Konstantin
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

[...]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

I'm not a big fan of reusing Rx fields or flags for Tx.
It's not obvious for an application than adding a tx_mark will overwrite the packet_type. I understand that the risk is limited because packet_type is Rx and the marks are Tx, but there is still one.

Mixing Rx and Tx info in the same field is a bad design pattern which will create a lot of difficult bugs.

Quoted 4 lines
Quoted 4 lines

I'm also not a big fan but just wanted to take this approach so that, it can both conserve space and also help fast path. Reusing Rx area is however not a new thing as is already followed for mbuf->txadapter field.

Yes there is a txadapter field union'ed with flow director and QoS. This is a bad pattern that I highlighted in this presentation (slide 8):
https://www.dpdk.org/wp-content/uploads/sites/35/2019/10/DynamicMbuf.pdf

Quoted 3 lines

Yes, and in my opinion this is something we should avoid when possible, because it makes some features exclusive (ex: the big union with sched/rss/adapter/usr/...).

Yes, the "RSS union" must be cleaned-up, as some other mbuf parts.

Quoted 5 lines
Quoted 2 lines

Apart from documentation issue, Is there any other issue or future ramification with using Rx field's for Tx ?

No, I don't see any other issue except the ones we already mentioned (doc, code clarity, ).

"doc clarity" should be understood as the opposite of "design leading inevitably to bugs".

Quoted 1 line
Quoted 1 line

If it is only about documentation, then we can add more documentation to make things clear.

More documentation won't make a bad design better, unfortunately.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

To summarize the different proposed approaches (please correct me if I'm wrong):

a- add 3 Tx mbuf flags
(-) consumes limited resource

Quoted 14 lines
Quoted 5 lines
Quoted 2 lines

b- add 3 dynamic flags
(-) slower

- Tx burst Vector implementation can't be done for this tx offload as offset keeps changing.

A vector implementation can be done. But yes, it would be slower than with a static flag.

Quoted 5 lines
Quoted 5 lines

c- add 1 Tx flag and union with Rx field
(-) exclusive with Rx field
(-) still consumes one flag

My preference is still b-, for these reasons:

Me too, my preference is (b).

#26 lore raw
In reply to Nithin Dabilpuram
Quoted 76 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 5 lines

I also share Olivier's concern about consuming 3 bits in ol_flags for that feature. Can it probably be squeezed somehow?
Let say we reserve one flag that this information is present or not, and re-use one of rx-only fields for store additional information (packet_type, or so). Or might be some other approach.

We are fine with this approach where we define one bit in Tx offloads for pkt marking and and 3 bits reused from Rx offload flags area.

For example:

(quoted diff) +7 -1
@@ -186,10 +186,16 @@ extern "C" {
 
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
+/* Reused Rx offload bits for Tx offloads */
+#define PKT_X_TX_MARK_VLAN_DEI         (1ULL << 0)
+#define PKT_X_TX_MARK_IP_DSCP          (1ULL << 1)
+#define PKT_X_TX_MARK_IP_ECN           (1ULL << 2)
+
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN         (1ULL << 40)
 
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Is this fine ?

Any thoughts on this approach which uses only 1 bit in Tx flags out of 18 and reuse unused Rx flag bits ?

My thought was not about re-defining the flags (I think it is better to keep them intact), but adding a union for one of rx-only fields (packet_type/rss/timestamp).

Ok. Adding a union field at packet_type field is also fine like below.

(quoted diff) +14 -1
@@ -187,9 +187,10 @@ extern "C" {
 /* add new RX flags here, don't forget to update PKT_FIRST_FREE */
 
 #define PKT_FIRST_FREE (1ULL << 23)
-#define PKT_LAST_FREE (1ULL << 40)
+#define PKT_LAST_FREE (1ULL << 39)
 
 /* add new TX flags here, don't forget to update PKT_LAST_FREE  */
+#define PKT_TX_MARK_EN		(1ULL << 40)
 
 /**
  * Outer UDP checksum offload flag. This flag is used for enabling
@@ -461,6 +462,14 @@ enum {
 #endif
 };
 
+/* Tx packet marking flags in rte_mbuf::tx_mark.
+ * Valid only when PKT_TX_MARK_EN is set in
+ * rte_mbuf::ol_flags.
+ */
+#define TX_MARK_VLAN_DEI	(1ULL << 0)
+#define TX_MARK_IP_DSCP	(1ULL << 1)
+#define TX_MARK_IP_ECN		(1ULL << 2)
+
 /**
  * The generic rte_mbuf, containing a packet mbuf.
  */
@@ -543,6 +552,10 @@ struct rte_mbuf {
 			};
 			uint32_t inner_l4_type:4; /**< Inner L4 type. */
 		};
+		struct {
+			uint32_t reserved:29;
+			uint32_t tx_mark:3;
+		};
 	};
 
 
Quoted 2 lines

Please correct me if this is not what you mean.

Yes, I thought about something like that.

#27 lore raw
In reply to Nithin Dabilpuram

15/05/2020 12:08, Nithin Dabilpuram:

Quoted 7 lines · Olivier Matz
Quoted 6 lines

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Quoted 7 lines
Quoted 1 line

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

A dynamic flag is not necessarily PMD-specific.
It is just avoiding consuming bits if the feature is not used by the application. We must move more existing flags and fields to be dynamic.

In general, all new flags and fields in mbuf should be dynamic. And a work must be done to move existing stuff to free more space for more dynamic features.

#28 lore raw
Quoted 16 lines · Thomas Monjalon

15/05/2020 12:08, Nithin Dabilpuram:

Quoted 7 lines · Olivier Matz
Quoted 6 lines

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Quoted 7 lines
Quoted 1 line

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 7 lines

A dynamic flag is not necessarily PMD-specific.
It is just avoiding consuming bits if the feature is not used by the application. We must move more existing flags and fields to be dynamic.

In general, all new flags and fields in mbuf should be dynamic. And a work must be done to move existing stuff to free more space for more dynamic features.

My bad, I thought dynamic flags can only be used for PMD specific thing.

There is however a cost of using dynamic flag which I think should be avoided for DPDK spec defined offloads, though it's fine for PMD specific things.

Dynamic offload flags causes application and PMD to use non constant offset or shift which are looked up at init, instead of having a constant shift or offset. This indirection costs some cycles due to extra loads in fast path.

Quoted 2 lines
#29 lore raw

15/05/2020 15:44, Nithin Dabilpuram:

Quoted 25 lines · Thomas Monjalon
Quoted 16 lines

15/05/2020 12:08, Nithin Dabilpuram:

Quoted 7 lines · Olivier Matz
Quoted 6 lines

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Quoted 7 lines
Quoted 1 line

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 7 lines

A dynamic flag is not necessarily PMD-specific.
It is just avoiding consuming bits if the feature is not used by the application. We must move more existing flags and fields to be dynamic.

In general, all new flags and fields in mbuf should be dynamic. And a work must be done to move existing stuff to free more space for more dynamic features.

Quoted 8 lines

My bad, I thought dynamic flags can only be used for PMD specific thing.

There is however a cost of using dynamic flag which I think should be avoided for DPDK spec defined offloads, though it's fine for PMD specific things.

Dynamic offload flags causes application and PMD to use non constant offset or shift which are looked up at init, instead of having a constant shift or offset. This indirection costs some cycles due to extra loads in fast path.

Yes there is a cost. We described it quite clearly last year. The default rule is now to add new flags and fields as dynamic. In case the rule was not clear, I will send a patch to insert some notes in the code and the doc.

If you disagree with this new rule, you will have to give very good arguments.

#30 lore raw
Quoted 32 lines · Thomas Monjalon

15/05/2020 15:44, Nithin Dabilpuram:

Quoted 30 lines · Thomas Monjalon
Quoted 16 lines

15/05/2020 12:08, Nithin Dabilpuram:

Quoted 7 lines · Olivier Matz
Quoted 6 lines

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Quoted 7 lines
Quoted 1 line

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 7 lines

A dynamic flag is not necessarily PMD-specific.
It is just avoiding consuming bits if the feature is not used by the application. We must move more existing flags and fields to be dynamic.

In general, all new flags and fields in mbuf should be dynamic. And a work must be done to move existing stuff to free more space for more dynamic features.

My bad, I thought dynamic flags can only be used for PMD specific thing.

There is however a cost of using dynamic flag which I think should be avoided for DPDK spec defined offloads, though it's fine for PMD specific things.

Quoted 8 lines
Quoted 3 lines

Dynamic offload flags causes application and PMD to use non constant offset or shift which are looked up at init, instead of having a constant shift or offset. This indirection costs some cycles due to extra loads in fast path.

Yes there is a cost. We described it quite clearly last year. The default rule is now to add new flags and fields as dynamic. In case the rule was not clear, I will send a patch to insert some notes in the code and the doc.

Yes. Please send a patch to document the rule. That makes life easy for everyone to make a boolean decision.

Here is the comment from mbuf: support dynamic fields and flags commit when accepted this patch.

" The typical use case is a PMD that registers space for an offload
feature, when the application requests to enable this feature. As the space in mbuf is limited, the space should only be reserved if it is going to be used (i.e when the application explicitly asks for it).
"
If you are pushing this feature to dynamic mbuf filed then rte_tm subsystem needs to register dynamic field
not the PMD as the feature is part of rte_tm spec.

Quoted 2 lines

If you disagree with this new rule, you will have to give very good arguments.

What would the definition of a good argument? as the same logic can be implemented with dynamic vs
static at the cost of dynamic indirection.

Quoted 4 lines
#31 lore raw

15/05/2020 18:26, Jerin Jacob:

Quoted 36 lines · Thomas Monjalon
Quoted 35 lines

15/05/2020 15:44, Nithin Dabilpuram:

Quoted 33 lines · Thomas Monjalon
Quoted 16 lines

15/05/2020 12:08, Nithin Dabilpuram:

Quoted 7 lines · Olivier Matz
Quoted 6 lines

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Quoted 7 lines
Quoted 1 line

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 7 lines

A dynamic flag is not necessarily PMD-specific.
It is just avoiding consuming bits if the feature is not used by the application. We must move more existing flags and fields to be dynamic.

In general, all new flags and fields in mbuf should be dynamic. And a work must be done to move existing stuff to free more space for more dynamic features.

My bad, I thought dynamic flags can only be used for PMD specific thing.

There is however a cost of using dynamic flag which I think should be avoided for DPDK spec defined offloads, though it's fine for PMD specific things.

Dynamic offload flags causes application and PMD to use non constant offset or shift which are looked up at init, instead of having a constant shift or offset. This indirection costs some cycles due to extra loads in fast path.

Quoted 7 lines
Quoted 4 lines

Yes there is a cost. We described it quite clearly last year. The default rule is now to add new flags and fields as dynamic. In case the rule was not clear, I will send a patch to insert some notes in the code and the doc.

Yes. Please send a patch to document the rule. That makes life easy for everyone to make a boolean decision.

Yes, I will work on it.

Quoted 8 lines

Here is the comment from mbuf: support dynamic fields and flags commit when accepted this patch.

" The typical use case is a PMD that registers space for an offload
feature, when the application requests to enable this feature. As the space in mbuf is limited, the space should only be reserved if it is going to be used (i.e when the application explicitly asks for it).
"

OK, there is probably a documentation gap.

Quoted 3 lines

If you are pushing this feature to dynamic mbuf filed then rte_tm subsystem needs to register dynamic field
not the PMD as the feature is part of rte_tm spec.

Is there a function in rte_tm which initializes or configure the feature?

Quoted 5 lines
Quoted 1 line

If you disagree with this new rule, you will have to give very good arguments.

What would the definition of a good argument? as the same logic can be implemented with dynamic vs
static at the cost of dynamic indirection.

I think the only exception to add a static flag or field is to demonstrate how basic is the feature.
But I think all basic features are already integrated for years.

#32 lore raw
Quoted 43 lines · Thomas Monjalon

15/05/2020 18:26, Jerin Jacob:

Quoted 41 lines · Thomas Monjalon
Quoted 39 lines

15/05/2020 15:44, Nithin Dabilpuram:

Quoted 25 lines · Thomas Monjalon
Quoted 16 lines

15/05/2020 12:08, Nithin Dabilpuram:

Quoted 7 lines · Olivier Matz
Quoted 6 lines

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Quoted 7 lines
Quoted 1 line

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 7 lines

A dynamic flag is not necessarily PMD-specific.
It is just avoiding consuming bits if the feature is not used by the application. We must move more existing flags and fields to be dynamic.

In general, all new flags and fields in mbuf should be dynamic. And a work must be done to move existing stuff to free more space for more dynamic features.

Quoted 8 lines

My bad, I thought dynamic flags can only be used for PMD specific thing.

There is however a cost of using dynamic flag which I think should be avoided for DPDK spec defined offloads, though it's fine for PMD specific things.

Dynamic offload flags causes application and PMD to use non constant offset or shift which are looked up at init, instead of having a constant shift or offset. This indirection costs some cycles due to extra loads in fast path.

Yes there is a cost. We described it quite clearly last year. The default rule is now to add new flags and fields as dynamic. In case the rule was not clear, I will send a patch to insert some notes in the code and the doc.

Quoted 4 lines
Quoted 2 lines

Yes. Please send a patch to document the rule. That makes life easy for everyone to make a boolean decision.

Yes, I will work on it.

Thanks.

Quoted 11 lines
Quoted 9 lines

Here is the comment from mbuf: support dynamic fields and flags commit when accepted this patch.

" The typical use case is a PMD that registers space for an offload
feature, when the application requests to enable this feature. As the space in mbuf is limited, the space should only be reserved if it is going to be used (i.e when the application explicitly asks for it).
"

OK, there is probably a documentation gap.

Obviously :-)

Quoted 6 lines
Quoted 4 lines

If you are pushing this feature to dynamic mbuf filed then rte_tm subsystem needs to register dynamic field
not the PMD as the feature is part of rte_tm spec.

Is there a function in rte_tm which initializes or configure the feature?

See rte_tm_mark_*

Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

If you disagree with this new rule, you will have to give very good arguments.

What would the definition of a good argument? as the same logic can be implemented with dynamic vs
static at the cost of dynamic indirection.

I think the only exception to add a static flag or field is to demonstrate how basic is the feature.
But I think all basic features are already integrated for years.

Yes. That's the path then let have a rule to not add any "new fields" and "flags" to mbuf
and everything should be through dynamic.

Quoted 2 lines
#33 lore raw
In reply to Thomas Monjalon
Quoted 67 lines · Thomas Monjalon

15/05/2020 18:26, Jerin Jacob:

Quoted 36 lines · Thomas Monjalon
Quoted 35 lines

15/05/2020 15:44, Nithin Dabilpuram:

Quoted 33 lines · Thomas Monjalon
Quoted 16 lines

15/05/2020 12:08, Nithin Dabilpuram:

Quoted 7 lines · Olivier Matz
Quoted 6 lines

I don't see any better approach than having a mbuf flag. However, I'm still not fully convinced that a dynamic flag won't do the job. Taking 3 additional flags (among 18 remaing) for this feature also means that we have 3 flags less for dynamic flags for all applications, even for applications that will not use this feature.

Quoted 7 lines
Quoted 1 line

Would it be a problem to use a dynamic flag in this case?

Since packet marking feature itself is already part of spec,
if we move the flags to PMD specific dynamic flag, then it creates a confusion.

It is not the case of a custom feature supported by a specific PMD. I believe when other PMD's implement packet marking, the same flags will suffice.

Quoted 7 lines

A dynamic flag is not necessarily PMD-specific.
It is just avoiding consuming bits if the feature is not used by the application. We must move more existing flags and fields to be dynamic.

In general, all new flags and fields in mbuf should be dynamic. And a work must be done to move existing stuff to free more space for more dynamic features.

My bad, I thought dynamic flags can only be used for PMD specific thing.

There is however a cost of using dynamic flag which I think should be avoided for DPDK spec defined offloads, though it's fine for PMD specific things.

Dynamic offload flags causes application and PMD to use non constant offset or shift which are looked up at init, instead of having a constant shift or offset. This indirection costs some cycles due to extra loads in fast path.

Quoted 7 lines
Quoted 4 lines

Yes there is a cost. We described it quite clearly last year. The default rule is now to add new flags and fields as dynamic. In case the rule was not clear, I will send a patch to insert some notes in the code and the doc.

Yes. Please send a patch to document the rule. That makes life easy for everyone to make a boolean decision.

Yes, I will work on it.

Quoted 8 lines

Here is the comment from mbuf: support dynamic fields and flags commit when accepted this patch.

" The typical use case is a PMD that registers space for an offload
feature, when the application requests to enable this feature. As the space in mbuf is limited, the space should only be reserved if it is going to be used (i.e when the application explicitly asks for it).
"

OK, there is probably a documentation gap.

Quoted 3 lines

If you are pushing this feature to dynamic mbuf filed then rte_tm subsystem needs to register dynamic field
not the PMD as the feature is part of rte_tm spec.

Is there a function in rte_tm which initializes or configure the feature?

Quoted 2 lines
Quoted 1 line

If you disagree with this new rule, you will have to give very good arguments.

Quoted 8 lines
Quoted 3 lines

What would the definition of a good argument? as the same logic can be implemented with dynamic vs
static at the cost of dynamic indirection.

I think the only exception to add a static flag or field is to demonstrate how basic is the feature.
But I think all basic features are already integrated for years.

Vector implementations will always have huge cost due to dynamic offload flags. Ofcourse, I don't have a vector implementation for packet marking but, in future if there is such an offload flag with vector implementation then hard enforcement will not work.

Quoted 1 line
#34 lore raw
In reply to Nithin Dabilpuram

Please can you remind what was decided for this feature? I think I should remove it from the roadmap.

17/04/2020 09:22, Nithin Dabilpuram:

Quoted 16 lines

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.

#35 lore raw

At last it was suggested to use dynamic ol_flags in mbuf for this feature. We decided to postpone this since it effects our fast path performance.
You can remove it from the roadmap.

Thanks
Nithin

Quoted 27 lines · Thomas Monjalon

Please can you remind what was decided for this feature? I think I should remove it from the roadmap.

17/04/2020 09:22, Nithin Dabilpuram:

Quoted 16 lines

From: Nithin Dabilpuram <[email protected]>

Introduce PKT_TX_MARK_IP_DSCP, PKT_TX_MARK_IP_ECN and PKT_TX_MARK_VLAN_DEI Tx offload flags to support packet marking.

When packet marking feature in Traffic manager is enabled, application has to the use the three new flags to indicate to PMD on whether packet marking needs to be enabled on the specific mbuf or not. By setting the three flags, it is assumed by PMD that application has already verified the applicability of marking on that specific packet and PMD need not perform further checks as per RFC.