DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ting Xu <ting.xu@intel.com>
To: dev@dpdk.org
Cc: qi.z.zhang@intel.com, jingjing.wu@intel.com,
	beilei.xing@intel.com, qiming.yang@intel.com,
	Ting Xu <ting.xu@intel.com>
Subject: [dpdk-dev] [PATCH v4 6/7] net/iavf: check Tx packet with correct UP and queue
Date: Wed, 30 Jun 2021 14:53:43 +0800	[thread overview]
Message-ID: <20210630065344.50352-7-ting.xu@intel.com> (raw)
In-Reply-To: <20210630065344.50352-1-ting.xu@intel.com>

Add check in the Tx packet preparation function, to guarantee that the
packet with specific user priority is distributed to the correct Tx
queue according to the configured Tx queue TC mapping.

Signed-off-by: Ting Xu <ting.xu@intel.com>
---
 drivers/net/iavf/iavf.h      | 10 +++++++++
 drivers/net/iavf/iavf_rxtx.c | 43 ++++++++++++++++++++++++++++++++++++
 drivers/net/iavf/iavf_tm.c   | 13 +++++++++++
 3 files changed, 66 insertions(+)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index feb8337b55..b3bd078111 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -86,6 +86,8 @@
 
 #define IAVF_BITS_PER_BYTE 8
 
+#define IAVF_VLAN_TAG_PCP_OFFSET 13
+
 struct iavf_adapter;
 struct iavf_rx_queue;
 struct iavf_tx_queue;
@@ -165,6 +167,13 @@ struct iavf_tm_conf {
 	bool committed;
 };
 
+/* Struct to store queue TC mapping. Queue is continuous in one TC */
+struct iavf_qtc_map {
+	uint8_t	tc;
+	uint16_t start_queue_id;
+	uint16_t queue_count;
+};
+
 /* Structure to store private data specific for VF instance. */
 struct iavf_info {
 	uint16_t num_queue_pairs;
@@ -213,6 +222,7 @@ struct iavf_info {
 	bool lv_enabled;
 
 	struct virtchnl_qos_cap_list *qos_cap;
+	struct iavf_qtc_map *qtc_map;
 	struct iavf_tm_conf tm_conf;
 };
 
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 0361af0d85..eb6d83a165 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -2342,14 +2342,49 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	return nb_tx;
 }
 
+/* Check if the packet with vlan user priority is transmitted in the
+ * correct queue.
+ */
+static int
+iavf_check_vlan_up2tc(struct iavf_tx_queue *txq, uint8_t tc, struct rte_mbuf *m)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	uint16_t up;
+
+	up = m->vlan_tci >> IAVF_VLAN_TAG_PCP_OFFSET;
+
+	if (!(vf->qos_cap->cap[tc].tc_prio & BIT(up))) {
+		PMD_TX_LOG(ERR, "packet with vlan pcp %u cannot transmit in queue %u\n",
+			up, txq->queue_id);
+		return -1;
+	} else {
+		return 0;
+	}
+}
+
 /* TX prep functions */
 uint16_t
 iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	      uint16_t nb_pkts)
 {
 	int i, ret;
+	uint8_t tc = 0;
 	uint64_t ol_flags;
 	struct rte_mbuf *m;
+	struct iavf_tx_queue *txq = tx_queue;
+	struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+
+	if (vf->tm_conf.committed) {
+		for (i = 0; i < vf->qos_cap->num_elem; i++) {
+			if (txq->queue_id >= vf->qtc_map[i].start_queue_id &&
+				txq->queue_id < (vf->qtc_map[i].start_queue_id +
+				vf->qtc_map[i].queue_count))
+				break;
+		}
+		tc = i;
+	}
 
 	for (i = 0; i < nb_pkts; i++) {
 		m = tx_pkts[i];
@@ -2385,6 +2420,14 @@ iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 			rte_errno = -ret;
 			return i;
 		}
+
+		if (ol_flags & (PKT_RX_VLAN_STRIPPED | PKT_RX_VLAN)) {
+			ret = iavf_check_vlan_up2tc(txq, tc, m);
+			if (ret != 0) {
+				rte_errno = -ret;
+				return i;
+			}
+		}
 	}
 
 	return i;
diff --git a/drivers/net/iavf/iavf_tm.c b/drivers/net/iavf/iavf_tm.c
index a8fc142c89..185b37b970 100644
--- a/drivers/net/iavf/iavf_tm.c
+++ b/drivers/net/iavf/iavf_tm.c
@@ -653,6 +653,7 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
 	struct virtchnl_queue_tc_mapping *q_tc_mapping;
 	struct iavf_tm_node_list *queue_list = &vf->tm_conf.queue_list;
 	struct iavf_tm_node *tm_node;
+	struct iavf_qtc_map *qtc_map;
 	uint16_t size;
 	int index = 0, node_committed = 0;
 	int i, ret_val = IAVF_SUCCESS;
@@ -675,6 +676,7 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
 	q_tc_mapping->vsi_id = vf->vsi.vsi_id;
 	q_tc_mapping->num_tc = vf->qos_cap->num_elem;
 	q_tc_mapping->num_queue_pairs = vf->num_queue_pairs;
+
 	TAILQ_FOREACH(tm_node, queue_list, node) {
 		if (tm_node->tc >= q_tc_mapping->num_tc) {
 			PMD_DRV_LOG(ERR, "TC%d is not enabled", tm_node->tc);
@@ -692,15 +694,26 @@ static int iavf_hierarchy_commit(struct rte_eth_dev *dev,
 		goto fail_clear;
 	}
 
+	/* store the queue TC mapping info */
+	qtc_map = rte_zmalloc("qtc_map",
+		sizeof(struct iavf_qtc_map) * q_tc_mapping->num_tc, 0);
+	if (!qtc_map)
+		return IAVF_ERR_NO_MEMORY;
+
 	for (i = 0; i < q_tc_mapping->num_tc; i++) {
 		q_tc_mapping->tc[i].req.start_queue_id = index;
 		index += q_tc_mapping->tc[i].req.queue_count;
+		qtc_map[i].tc = i;
+		qtc_map[i].start_queue_id =
+			q_tc_mapping->tc[i].req.start_queue_id;
+		qtc_map[i].queue_count = q_tc_mapping->tc[i].req.queue_count;
 	}
 
 	ret_val = iavf_set_q_tc_map(dev, q_tc_mapping, size);
 	if (ret_val)
 		goto fail_clear;
 
+	vf->qtc_map = qtc_map;
 	vf->tm_conf.committed = true;
 	return ret_val;
 
-- 
2.17.1


  parent reply	other threads:[~2021-06-30  6:51 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01  1:40 [dpdk-dev] [PATCH v1 0/5] Enable ETS-based Tx QoS for VF in DCF Ting Xu
2021-06-01  1:40 ` [dpdk-dev] [PATCH v1 1/5] common/iavf: add support for ETS-based Tx QoS Ting Xu
2021-06-01  1:40 ` [dpdk-dev] [PATCH v1 2/5] net/ice/base: support DCF query port ETS adminq Ting Xu
2021-06-01  1:40 ` [dpdk-dev] [PATCH v1 3/5] net/ice: support DCF link status event handling Ting Xu
2021-06-01  1:40 ` [dpdk-dev] [PATCH v1 4/5] net/ice: support QoS config VF bandwidth in DCF Ting Xu
2021-06-01  1:40 ` [dpdk-dev] [PATCH v1 5/5] net/iavf: query QoS cap and set queue TC mapping Ting Xu
2021-06-17 10:17 ` [dpdk-dev] [PATCH v2 0/5] Enable ETS-based Tx QoS for VF in DCF Ting Xu
2021-06-17 10:17   ` [dpdk-dev] [PATCH v2 1/5] common/iavf: support ETS-based QoS offload configuration Ting Xu
2021-06-17 10:17   ` [dpdk-dev] [PATCH v2 2/5] net/ice/base: support DCF query port ETS adminq Ting Xu
2021-06-17 10:17   ` [dpdk-dev] [PATCH v2 3/5] net/ice: support DCF link status event handling Ting Xu
2021-06-17 10:17   ` [dpdk-dev] [PATCH v2 4/5] net/ice: support QoS config VF bandwidth in DCF Ting Xu
2021-06-17 10:17   ` [dpdk-dev] [PATCH v2 5/5] net/iavf: query QoS cap and set queue TC mapping Ting Xu
2021-06-25  9:31 ` [dpdk-dev] [PATCH v3 0/5] Enable ETS-based Tx QoS for VF in DCF Ting Xu
2021-06-25  9:31   ` [dpdk-dev] [PATCH v3 1/5] common/iavf: support ETS-based QoS offload configuration Ting Xu
2021-06-25  9:31   ` [dpdk-dev] [PATCH v3 2/5] net/ice/base: support DCF query port ETS adminq Ting Xu
2021-06-25  9:31   ` [dpdk-dev] [PATCH v3 3/5] net/ice: support DCF link status event handling Ting Xu
2021-06-25  9:31   ` [dpdk-dev] [PATCH v3 4/5] net/ice: support QoS config VF bandwidth in DCF Ting Xu
2021-06-25  9:31   ` [dpdk-dev] [PATCH v3 5/5] net/iavf: query QoS cap and set queue TC mapping Ting Xu
2021-06-30  6:53 ` [dpdk-dev] [PATCH v4 0/7] Enable ETS-based Tx QoS for VF in DCF Ting Xu
2021-06-30  6:53   ` [dpdk-dev] [PATCH v4 1/7] common/iavf: support ETS-based QoS offload configuration Ting Xu
2021-06-30  6:53   ` [dpdk-dev] [PATCH v4 2/7] net/ice/base: support DCF query port ETS adminq Ting Xu
2021-06-30  6:53   ` [dpdk-dev] [PATCH v4 3/7] net/ice: support DCF link status event handling Ting Xu
2021-06-30  6:53   ` [dpdk-dev] [PATCH v4 4/7] net/ice: support QoS config VF bandwidth in DCF Ting Xu
2021-06-30  6:53   ` [dpdk-dev] [PATCH v4 5/7] net/iavf: query QoS cap and set queue TC mapping Ting Xu
2021-06-30  6:53   ` Ting Xu [this message]
2021-06-30  6:53   ` [dpdk-dev] [PATCH v4 7/7] doc: release note for ETS-based Tx QoS Ting Xu
2021-07-01 10:20 ` [dpdk-dev] [PATCH v5 0/7] Enable ETS-based Tx QoS for VF in DCF Ting Xu
2021-07-01 10:20   ` [dpdk-dev] [PATCH v5 1/7] common/iavf: support ETS-based QoS offload configuration Ting Xu
2021-07-01 10:20   ` [dpdk-dev] [PATCH v5 2/7] net/ice/base: support DCF query port ETS adminq Ting Xu
2021-07-01 10:20   ` [dpdk-dev] [PATCH v5 3/7] net/ice: support DCF link status event handling Ting Xu
2021-07-01 10:20   ` [dpdk-dev] [PATCH v5 4/7] net/ice: support QoS config VF bandwidth in DCF Ting Xu
2021-07-07  9:23     ` Thomas Monjalon
2021-07-01 10:20   ` [dpdk-dev] [PATCH v5 5/7] net/iavf: query QoS cap and set queue TC mapping Ting Xu
2021-07-01 10:20   ` [dpdk-dev] [PATCH v5 6/7] net/iavf: check Tx packet with correct UP and queue Ting Xu
2021-07-01 10:20   ` [dpdk-dev] [PATCH v5 7/7] doc: release note for ETS-based Tx QoS Ting Xu
2021-07-02  3:00   ` [dpdk-dev] [PATCH v5 0/7] Enable ETS-based Tx QoS for VF in DCF Zhang, Qi Z
2021-07-01 11:41 ` Ting Xu
2021-07-01 11:41   ` [dpdk-dev] [PATCH v5 1/7] common/iavf: support ETS-based QoS offload configuration Ting Xu
2021-07-01 11:41   ` [dpdk-dev] [PATCH v5 2/7] net/ice/base: support DCF query port ETS adminq Ting Xu
2021-07-01 11:41   ` [dpdk-dev] [PATCH v5 3/7] net/ice: support DCF link status event handling Ting Xu
2021-07-01 11:41   ` [dpdk-dev] [PATCH v5 4/7] net/ice: support QoS config VF bandwidth in DCF Ting Xu
2021-07-01 11:41   ` [dpdk-dev] [PATCH v5 5/7] net/iavf: query QoS cap and set queue TC mapping Ting Xu
2021-07-01 11:41   ` [dpdk-dev] [PATCH v5 6/7] net/iavf: check Tx packet with correct UP and queue Ting Xu
2021-07-01 11:41   ` [dpdk-dev] [PATCH v5 7/7] doc: release note for ETS-based Tx QoS Ting Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210630065344.50352-7-ting.xu@intel.com \
    --to=ting.xu@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).