DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lijun Ou <oulijun@huawei.com>
To: <ferruh.yigit@intel.com>
Cc: <dev@dpdk.org>, <linuxarm@huawei.com>
Subject: [dpdk-dev] [PATCH v3 3/8] net/hns3: fix packect type report in Rx
Date: Thu, 29 Oct 2020 20:51:52 +0800
Message-ID: <1603975917-28576-4-git-send-email-oulijun@huawei.com> (raw)
In-Reply-To: <1603975917-28576-1-git-send-email-oulijun@huawei.com>

From: Chengchang Tang <tangchengchang@huawei.com>

Currently, hns3 support recognizing a lot of ptypes, but most
tunnel packet types are not reported to the API
rte_eth_dev_get_supported_ptypes.

And there are some error in L2 and L3 packet recognization. The
ARP and LLDP are classified to L3 field in RX descriptor. So,
the ptype of LLDP and ARP packets will be set twice. And ptypes
are assigned by bitwise OR, which will eventually cause the ptype
result to be incorrect.

Besides, when a packet with only L2 header, its ptype will not
report by hns3 PMD. This is because the L2L3 ptype table is not
initialized properly. In this case, the table query result is 0
by default.

As a result, it fixes missing supported ptypes and the mistake in
L2L3 packet recognization and the unreported L2 packect ptype by
reporting its L2 type when the L3 type unrecognized..

Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
Cc: stable@dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.h |  5 ++-
 drivers/net/hns3/hns3_rxtx.c   | 99 ++++++++++++++++++++++++++++++------------
 drivers/net/hns3/hns3_rxtx.h   | 13 +++---
 3 files changed, 82 insertions(+), 35 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index da8aead..d195c19 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -647,16 +647,17 @@ struct hns3_mp_param {
 #define HNS3_L2TBL_NUM	4
 #define HNS3_L3TBL_NUM	16
 #define HNS3_L4TBL_NUM	16
+#define HNS3_OL2TBL_NUM	4
 #define HNS3_OL3TBL_NUM	16
 #define HNS3_OL4TBL_NUM	16
 
 struct hns3_ptype_table {
-	uint32_t l2table[HNS3_L2TBL_NUM];
-	uint32_t l3table[HNS3_L3TBL_NUM];
+	uint32_t l2l3table[HNS3_L2TBL_NUM][HNS3_L3TBL_NUM];
 	uint32_t l4table[HNS3_L4TBL_NUM];
 	uint32_t inner_l2table[HNS3_L2TBL_NUM];
 	uint32_t inner_l3table[HNS3_L3TBL_NUM];
 	uint32_t inner_l4table[HNS3_L4TBL_NUM];
+	uint32_t ol2table[HNS3_OL2TBL_NUM];
 	uint32_t ol3table[HNS3_OL3TBL_NUM];
 	uint32_t ol4table[HNS3_OL4TBL_NUM];
 };
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 55bee17..3d5e465 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -1839,6 +1839,19 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 		RTE_PTYPE_L4_TCP,
 		RTE_PTYPE_L4_UDP,
 		RTE_PTYPE_TUNNEL_GRE,
+		RTE_PTYPE_INNER_L2_ETHER,
+		RTE_PTYPE_INNER_L2_ETHER_VLAN,
+		RTE_PTYPE_INNER_L2_ETHER_QINQ,
+		RTE_PTYPE_INNER_L3_IPV4,
+		RTE_PTYPE_INNER_L3_IPV6,
+		RTE_PTYPE_INNER_L3_IPV4_EXT,
+		RTE_PTYPE_INNER_L3_IPV6_EXT,
+		RTE_PTYPE_INNER_L4_UDP,
+		RTE_PTYPE_INNER_L4_TCP,
+		RTE_PTYPE_INNER_L4_SCTP,
+		RTE_PTYPE_INNER_L4_ICMP,
+		RTE_PTYPE_TUNNEL_VXLAN,
+		RTE_PTYPE_TUNNEL_NVGRE,
 		RTE_PTYPE_UNKNOWN
 	};
 
@@ -1851,26 +1864,35 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 	return NULL;
 }
 
-void
-hns3_init_rx_ptype_tble(struct rte_eth_dev *dev)
-{
-	struct hns3_adapter *hns = dev->data->dev_private;
-	struct hns3_ptype_table *tbl = &hns->ptype_tbl;
-
-	memset(tbl, 0, sizeof(*tbl));
-
-	tbl->l2table[0] = RTE_PTYPE_L2_ETHER;
-	tbl->l2table[1] = RTE_PTYPE_L2_ETHER_QINQ;
-	tbl->l2table[2] = RTE_PTYPE_L2_ETHER_VLAN;
-	tbl->l2table[3] = RTE_PTYPE_L2_ETHER_VLAN;
-
-	tbl->l3table[0] = RTE_PTYPE_L3_IPV4;
-	tbl->l3table[1] = RTE_PTYPE_L3_IPV6;
-	tbl->l3table[2] = RTE_PTYPE_L2_ETHER_ARP;
-	tbl->l3table[3] = RTE_PTYPE_L2_ETHER;
-	tbl->l3table[4] = RTE_PTYPE_L3_IPV4_EXT;
-	tbl->l3table[5] = RTE_PTYPE_L3_IPV6_EXT;
-	tbl->l3table[6] = RTE_PTYPE_L2_ETHER_LLDP;
+static void
+hns3_init_non_tunnel_ptype_tbl(struct hns3_ptype_table *tbl)
+{
+	tbl->l2l3table[0][0] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4;
+	tbl->l2l3table[0][1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6;
+	tbl->l2l3table[0][2] = RTE_PTYPE_L2_ETHER_ARP;
+	tbl->l2l3table[0][3] = RTE_PTYPE_L2_ETHER;
+	tbl->l2l3table[0][4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT;
+	tbl->l2l3table[0][5] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT;
+	tbl->l2l3table[0][6] = RTE_PTYPE_L2_ETHER_LLDP;
+	tbl->l2l3table[0][15] = RTE_PTYPE_L2_ETHER;
+
+	tbl->l2l3table[1][0] = RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4;
+	tbl->l2l3table[1][1] = RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV6;
+	tbl->l2l3table[1][2] = RTE_PTYPE_L2_ETHER_ARP;
+	tbl->l2l3table[1][3] = RTE_PTYPE_L2_ETHER_VLAN;
+	tbl->l2l3table[1][4] = RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4_EXT;
+	tbl->l2l3table[1][5] = RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV6_EXT;
+	tbl->l2l3table[1][6] = RTE_PTYPE_L2_ETHER_LLDP;
+	tbl->l2l3table[1][15] = RTE_PTYPE_L2_ETHER_VLAN;
+
+	tbl->l2l3table[2][0] = RTE_PTYPE_L2_ETHER_QINQ | RTE_PTYPE_L3_IPV4;
+	tbl->l2l3table[2][1] = RTE_PTYPE_L2_ETHER_QINQ | RTE_PTYPE_L3_IPV6;
+	tbl->l2l3table[2][2] = RTE_PTYPE_L2_ETHER_ARP;
+	tbl->l2l3table[2][3] = RTE_PTYPE_L2_ETHER_QINQ;
+	tbl->l2l3table[2][4] = RTE_PTYPE_L2_ETHER_QINQ | RTE_PTYPE_L3_IPV4_EXT;
+	tbl->l2l3table[2][5] = RTE_PTYPE_L2_ETHER_QINQ | RTE_PTYPE_L3_IPV6_EXT;
+	tbl->l2l3table[2][6] = RTE_PTYPE_L2_ETHER_LLDP;
+	tbl->l2l3table[2][15] = RTE_PTYPE_L2_ETHER_QINQ;
 
 	tbl->l4table[0] = RTE_PTYPE_L4_UDP;
 	tbl->l4table[1] = RTE_PTYPE_L4_TCP;
@@ -1878,37 +1900,60 @@ hns3_init_rx_ptype_tble(struct rte_eth_dev *dev)
 	tbl->l4table[3] = RTE_PTYPE_L4_SCTP;
 	tbl->l4table[4] = RTE_PTYPE_L4_IGMP;
 	tbl->l4table[5] = RTE_PTYPE_L4_ICMP;
+}
 
+static void
+hns3_init_tunnel_ptype_tbl(struct hns3_ptype_table *tbl)
+{
 	tbl->inner_l2table[0] = RTE_PTYPE_INNER_L2_ETHER;
 	tbl->inner_l2table[1] = RTE_PTYPE_INNER_L2_ETHER_VLAN;
 	tbl->inner_l2table[2] = RTE_PTYPE_INNER_L2_ETHER_QINQ;
 
 	tbl->inner_l3table[0] = RTE_PTYPE_INNER_L3_IPV4;
 	tbl->inner_l3table[1] = RTE_PTYPE_INNER_L3_IPV6;
-	tbl->inner_l3table[2] = 0;
-	tbl->inner_l3table[3] = RTE_PTYPE_INNER_L2_ETHER;
+	/* There is not a ptype for inner ARP/RARP */
+	tbl->inner_l3table[2] = RTE_PTYPE_UNKNOWN;
+	tbl->inner_l3table[3] = RTE_PTYPE_UNKNOWN;
 	tbl->inner_l3table[4] = RTE_PTYPE_INNER_L3_IPV4_EXT;
 	tbl->inner_l3table[5] = RTE_PTYPE_INNER_L3_IPV6_EXT;
 
 	tbl->inner_l4table[0] = RTE_PTYPE_INNER_L4_UDP;
 	tbl->inner_l4table[1] = RTE_PTYPE_INNER_L4_TCP;
-	tbl->inner_l4table[2] = RTE_PTYPE_TUNNEL_GRE;
+	/* There is not a ptype for inner GRE */
+	tbl->inner_l4table[2] = RTE_PTYPE_UNKNOWN;
 	tbl->inner_l4table[3] = RTE_PTYPE_INNER_L4_SCTP;
-	tbl->inner_l4table[4] = RTE_PTYPE_L4_IGMP;
+	/* There is not a ptype for inner IGMP */
+	tbl->inner_l4table[4] = RTE_PTYPE_UNKNOWN;
 	tbl->inner_l4table[5] = RTE_PTYPE_INNER_L4_ICMP;
 
+	tbl->ol2table[0] = RTE_PTYPE_L2_ETHER;
+	tbl->ol2table[1] = RTE_PTYPE_L2_ETHER_VLAN;
+	tbl->ol2table[2] = RTE_PTYPE_L2_ETHER_QINQ;
+
 	tbl->ol3table[0] = RTE_PTYPE_L3_IPV4;
 	tbl->ol3table[1] = RTE_PTYPE_L3_IPV6;
-	tbl->ol3table[2] = 0;
-	tbl->ol3table[3] = 0;
+	tbl->ol3table[2] = RTE_PTYPE_UNKNOWN;
+	tbl->ol3table[3] = RTE_PTYPE_UNKNOWN;
 	tbl->ol3table[4] = RTE_PTYPE_L3_IPV4_EXT;
 	tbl->ol3table[5] = RTE_PTYPE_L3_IPV6_EXT;
 
-	tbl->ol4table[0] = 0;
+	tbl->ol4table[0] = RTE_PTYPE_UNKNOWN;
 	tbl->ol4table[1] = RTE_PTYPE_TUNNEL_VXLAN;
 	tbl->ol4table[2] = RTE_PTYPE_TUNNEL_NVGRE;
 }
 
+void
+hns3_init_rx_ptype_tble(struct rte_eth_dev *dev)
+{
+	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_ptype_table *tbl = &hns->ptype_tbl;
+
+	memset(tbl, 0, sizeof(*tbl));
+
+	hns3_init_non_tunnel_ptype_tbl(tbl);
+	hns3_init_tunnel_ptype_tbl(tbl);
+}
+
 static inline void
 hns3_rxd_to_vlan_tci(struct hns3_rx_queue *rxq, struct rte_mbuf *mb,
 		     uint32_t l234_info, const struct hns3_desc *rxd)
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index ae09e94..68497a0 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -580,14 +580,14 @@ static inline uint32_t
 hns3_rx_calc_ptype(struct hns3_rx_queue *rxq, const uint32_t l234_info,
 		   const uint32_t ol_info)
 {
-	const struct hns3_ptype_table *const ptype_tbl = rxq->ptype_tbl;
+	const struct hns3_ptype_table * const ptype_tbl = rxq->ptype_tbl;
 	uint32_t l2id, l3id, l4id;
-	uint32_t ol3id, ol4id;
+	uint32_t ol3id, ol4id, ol2id;
 
 	ol4id = hns3_get_field(ol_info, HNS3_RXD_OL4ID_M, HNS3_RXD_OL4ID_S);
 	ol3id = hns3_get_field(ol_info, HNS3_RXD_OL3ID_M, HNS3_RXD_OL3ID_S);
-	l2id = hns3_get_field(l234_info, HNS3_RXD_STRP_TAGP_M,
-			      HNS3_RXD_STRP_TAGP_S);
+	ol2id = hns3_get_field(ol_info, HNS3_RXD_OVLAN_M, HNS3_RXD_OVLAN_S);
+	l2id = hns3_get_field(l234_info, HNS3_RXD_VLAN_M, HNS3_RXD_VLAN_S);
 	l3id = hns3_get_field(l234_info, HNS3_RXD_L3ID_M, HNS3_RXD_L3ID_S);
 	l4id = hns3_get_field(l234_info, HNS3_RXD_L4ID_M, HNS3_RXD_L4ID_S);
 
@@ -595,9 +595,10 @@ hns3_rx_calc_ptype(struct hns3_rx_queue *rxq, const uint32_t l234_info,
 		return ptype_tbl->inner_l2table[l2id] |
 			ptype_tbl->inner_l3table[l3id] |
 			ptype_tbl->inner_l4table[l4id] |
-			ptype_tbl->ol3table[ol3id] | ptype_tbl->ol4table[ol4id];
+			ptype_tbl->ol3table[ol3id] |
+			ptype_tbl->ol4table[ol4id] | ptype_tbl->ol2table[ol2id];
 	else
-		return ptype_tbl->l2table[l2id] | ptype_tbl->l3table[l3id] |
+		return ptype_tbl->l2l3table[l2id][l3id] |
 			ptype_tbl->l4table[l4id];
 }
 
-- 
2.7.4


  parent reply	other threads:[~2020-10-29 12:54 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 11:14 [dpdk-dev] [PATCH 0/8] hns3 misc updates Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 1/8] net/hns3: add queue count of Rx API support Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 2/8] net/hns3: fix RSS max queue id allowed in multi-TC case Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 3/8] net/hns3: fix packect type report in Rx Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 4/8] net/hns3: fix uncheck return value warning Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 5/8] net/hns3: fix data type to release fake queue > 255 Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 6/8] net/hns3: fix HW ring not clear after queue stop Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 7/8] net/hns3: fix return value check of setting VF bus master Lijun Ou
2020-10-29 11:14 ` [dpdk-dev] [PATCH 8/8] net/hns3: fix meson build for enabling SVE Rx/Tx Lijun Ou
2020-10-29 12:17 ` [dpdk-dev] [PATCH v2 0/8] hns3 misc updates Lijun Ou
2020-10-29 12:17   ` [dpdk-dev] [PATCH v2 1/8] net/hns3: enable RSS for ipv6-sctp dst/src port fields Lijun Ou
2020-10-29 12:17   ` [dpdk-dev] [PATCH v2 2/8] net/hns3: add queue count of Rx API support Lijun Ou
2020-10-29 12:17   ` [dpdk-dev] [PATCH v2 3/8] net/hns3: fix RSS max queue id allowed in multi-TC case Lijun Ou
2020-10-29 12:17   ` [dpdk-dev] [PATCH v2 4/8] net/hns3: fix packect type report in Rx Lijun Ou
2020-10-29 12:17   ` [dpdk-dev] [PATCH v2 5/8] net/hns3: fix uncheck return value warning Lijun Ou
2020-10-29 12:17   ` [dpdk-dev] [PATCH v2 6/8] net/hns3: fix data type to release fake queue > 255 Lijun Ou
2020-10-29 12:17   ` [dpdk-dev] [PATCH v2 7/8] net/hns3: fix HW ring not clear after queue stop Lijun Ou
2020-10-29 12:17   ` [dpdk-dev] [PATCH v2 8/8] net/hns3: fix return value check of setting VF bus Lijun Ou
2020-10-29 12:49   ` [dpdk-dev] [PATCH v2 0/8] hns3 misc updates Lijun Ou
2020-10-29 12:49     ` [dpdk-dev] [PATCH v2 1/8] net/hns3: enable RSS for ipv6-sctp dst/src port fields Lijun Ou
2020-10-29 12:49     ` [dpdk-dev] [PATCH v2 2/8] net/hns3: add queue count of Rx API support Lijun Ou
2020-10-29 12:49     ` [dpdk-dev] [PATCH v2 3/8] net/hns3: fix RSS max queue id allowed in multi-TC case Lijun Ou
2020-10-29 12:49     ` [dpdk-dev] [PATCH v2 4/8] net/hns3: fix packect type report in Rx Lijun Ou
2020-10-29 12:49     ` [dpdk-dev] [PATCH v2 5/8] net/hns3: fix uncheck return value warning Lijun Ou
2020-10-29 12:49     ` [dpdk-dev] [PATCH v2 6/8] net/hns3: fix data type to release fake queue > 255 Lijun Ou
2020-10-29 12:49     ` [dpdk-dev] [PATCH v2 7/8] net/hns3: fix HW ring not clear after queue stop Lijun Ou
2020-10-29 12:49     ` [dpdk-dev] [PATCH v2 8/8] net/hns3: fix return value check of setting VF bus Lijun Ou
2020-10-29 12:51     ` [dpdk-dev] [PATCH v3 0/8] hns3 misc updates Lijun Ou
2020-10-29 12:51       ` [dpdk-dev] [PATCH v3 1/8] net/hns3: add queue count of Rx API support Lijun Ou
2020-10-29 12:51       ` [dpdk-dev] [PATCH v3 2/8] net/hns3: fix RSS max queue id allowed in multi-TC case Lijun Ou
2020-10-29 12:51       ` Lijun Ou [this message]
2020-10-29 12:51       ` [dpdk-dev] [PATCH v3 4/8] net/hns3: fix uncheck return value warning Lijun Ou
2020-10-29 12:51       ` [dpdk-dev] [PATCH v3 5/8] net/hns3: fix data type to release fake queue > 255 Lijun Ou
2020-10-29 12:51       ` [dpdk-dev] [PATCH v3 6/8] net/hns3: fix HW ring not clear after queue stop Lijun Ou
2020-10-29 12:51       ` [dpdk-dev] [PATCH v3 7/8] net/hns3: fix value check of setting VF PCI bus function Lijun Ou
2020-10-29 12:51       ` [dpdk-dev] [PATCH v3 8/8] net/hns3: fix meson build for enabling SVE Rx/Tx Lijun Ou
2020-10-30 17:00       ` [dpdk-dev] [PATCH v3 0/8] hns3 misc updates Ferruh Yigit

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=1603975917-28576-4-git-send-email-oulijun@huawei.com \
    --to=oulijun@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=linuxarm@huawei.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git