DPDK patches and discussions
 help / color / mirror / Atom feed
From: Junfeng Guo <junfeng.guo@intel.com>
To: qi.z.zhang@intel.com, jingjing.wu@intel.com, beilei.xing@intel.com
Cc: dev@dpdk.org, junfeng.guo@intel.com
Subject: [RFC v2 6/9] net/idpf: support packet type getting
Date: Mon,  9 May 2022 17:11:30 +0800	[thread overview]
Message-ID: <20220509091133.3752306-7-junfeng.guo@intel.com> (raw)
In-Reply-To: <20220509091133.3752306-1-junfeng.guo@intel.com>

Add ops dev_supported_ptypes_get.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
---
 drivers/net/idpf/idpf_ethdev.c |  3 ++
 drivers/net/idpf/idpf_rxtx.c   | 51 ++++++++++++++++++++++++++++++++++
 drivers/net/idpf/idpf_rxtx.h   |  3 ++
 3 files changed, 57 insertions(+)

diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index c58a40e7ab..01fd023bfc 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -32,6 +32,7 @@ static int idpf_dev_info_get(struct rte_eth_dev *dev,
 			     struct rte_eth_dev_info *dev_info);
 
 static const struct eth_dev_ops idpf_eth_dev_ops = {
+	.dev_supported_ptypes_get	= idpf_dev_supported_ptypes_get,
 	.dev_configure			= idpf_dev_configure,
 	.dev_start			= idpf_dev_start,
 	.dev_stop			= idpf_dev_stop,
@@ -501,6 +502,8 @@ idpf_adapter_init(struct rte_eth_dev *dev)
 	if (adapter->initialized)
 		return 0;
 
+	idpf_set_default_ptype_table(dev);
+
 	hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
 	hw->hw_addr_len = pci_dev->mem_resource[0].len;
 	hw->back = adapter;
diff --git a/drivers/net/idpf/idpf_rxtx.c b/drivers/net/idpf/idpf_rxtx.c
index 770ed52281..6b436141c8 100644
--- a/drivers/net/idpf/idpf_rxtx.c
+++ b/drivers/net/idpf/idpf_rxtx.c
@@ -8,6 +8,57 @@
 #include "idpf_ethdev.h"
 #include "idpf_rxtx.h"
 
+const uint32_t *
+idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_NONFRAG,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_SCTP,
+		RTE_PTYPE_L4_ICMP,
+		RTE_PTYPE_UNKNOWN
+	};
+
+	return ptypes;
+}
+
+static inline uint32_t
+idpf_get_default_pkt_type(uint16_t ptype)
+{
+	static const uint32_t type_table[IDPF_MAX_PKT_TYPE]
+		__rte_cache_aligned = {
+		[1] = RTE_PTYPE_L2_ETHER,
+		[22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_FRAG,
+		[23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4,
+		[24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+		[26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
+		[27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_SCTP,
+		[28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_ICMP,
+		[88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_FRAG,
+		[89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6,
+		[90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+		[92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
+		[93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_SCTP,
+		[94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_ICMP,
+	};
+
+	return type_table[ptype];
+}
+
+void __rte_cold
+idpf_set_default_ptype_table(struct rte_eth_dev *dev __rte_unused)
+{
+	int i;
+
+	for (i = 0; i < IDPF_MAX_PKT_TYPE; i++)
+		adapter->ptype_tbl[i] = idpf_get_default_pkt_type(i);
+}
+
 static inline int
 check_rx_thresh(uint16_t nb_desc, uint16_t thresh)
 {
diff --git a/drivers/net/idpf/idpf_rxtx.h b/drivers/net/idpf/idpf_rxtx.h
index 705f706890..21b6d8cb84 100644
--- a/drivers/net/idpf/idpf_rxtx.h
+++ b/drivers/net/idpf/idpf_rxtx.h
@@ -164,4 +164,7 @@ void idpf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
 
 void idpf_stop_queues(struct rte_eth_dev *dev);
 
+void idpf_set_default_ptype_table(struct rte_eth_dev *dev);
+const uint32_t *idpf_dev_supported_ptypes_get(struct rte_eth_dev *dev);
+
 #endif /* _IDPF_RXTX_H_ */
-- 
2.25.1


  parent reply	other threads:[~2022-05-09  9:11 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-07  7:07 [RFC 0/9] add support for idpf PMD in DPDK Junfeng Guo
2022-05-07  7:07 ` [RFC 1/9] net/idpf/base: introduce base code Junfeng Guo
2022-05-09  9:11   ` [RFC v2 0/9] add support for idpf PMD in DPDK Junfeng Guo
2022-05-09  9:11     ` [RFC v2 1/9] net/idpf/base: introduce base code Junfeng Guo
2022-05-09  9:11     ` [RFC v2 2/9] net/idpf/base: add OS specific implementation Junfeng Guo
2022-05-09  9:11     ` [RFC v2 3/9] net/idpf: support device initialization Junfeng Guo
2022-05-09  9:11     ` [RFC v2 4/9] net/idpf: support queue ops Junfeng Guo
2022-05-09  9:11     ` [RFC v2 5/9] net/idpf: support getting device information Junfeng Guo
2022-05-09  9:11     ` Junfeng Guo [this message]
2022-05-09  9:11     ` [RFC v2 7/9] net/idpf: support link update Junfeng Guo
2022-05-09  9:11     ` [RFC v2 8/9] net/idpf: support basic Rx/Tx Junfeng Guo
2022-05-09  9:11     ` [RFC v2 9/9] net/idpf: support RSS Junfeng Guo
2022-05-18  8:25       ` [RFC v3 00/11] add support for idpf PMD in DPDK Junfeng Guo
2022-05-18  8:25         ` [RFC v3 01/11] net/idpf/base: introduce base code Junfeng Guo
2022-05-18 15:26           ` Stephen Hemminger
2022-05-18  8:25         ` [RFC v3 02/11] net/idpf/base: add OS specific implementation Junfeng Guo
2022-05-18  8:25         ` [RFC v3 03/11] net/idpf: support device initialization Junfeng Guo
2022-05-18  8:25         ` [RFC v3 04/11] net/idpf: support queue ops Junfeng Guo
2022-05-18  8:25         ` [RFC v3 05/11] net/idpf: support getting device information Junfeng Guo
2022-05-18  8:25         ` [RFC v3 06/11] net/idpf: support packet type getting Junfeng Guo
2022-05-18  8:25         ` [RFC v3 07/11] net/idpf: support link update Junfeng Guo
2022-05-18  8:25         ` [RFC v3 08/11] net/idpf: support basic Rx/Tx Junfeng Guo
2022-05-18  8:25         ` [RFC v3 09/11] net/idpf: support RSS Junfeng Guo
2022-05-18  8:25         ` [RFC v3 10/11] net/idpf: support MTU configuration Junfeng Guo
2022-05-18  8:25         ` [RFC v3 11/11] net/idpf: add CPF device ID for idpf map table Junfeng Guo
2022-05-07  7:07 ` [RFC 2/9] net/idpf/base: add OS specific implementation Junfeng Guo
2022-05-07  7:07 ` [RFC 3/9] net/idpf: support device initialization Junfeng Guo
2022-05-07  7:07 ` [RFC 4/9] net/idpf: support queue ops Junfeng Guo
2022-05-07  7:07 ` [RFC 5/9] net/idpf: support getting device information Junfeng Guo
2022-05-07  7:07 ` [RFC 6/9] net/idpf: support packet type getting Junfeng Guo
2022-05-07  7:07 ` [RFC 7/9] net/idpf: support link update Junfeng Guo
2022-05-07  7:07 ` [RFC 8/9] net/idpf: support basic Rx/Tx Junfeng Guo
2022-05-07  7:07 ` [RFC 9/9] net/idpf: support RSS Junfeng Guo

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=20220509091133.3752306-7-junfeng.guo@intel.com \
    --to=junfeng.guo@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=qi.z.zhang@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).