From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 25923A050A; Sat, 7 May 2022 09:08:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 622CC42832; Sat, 7 May 2022 09:08:31 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id D054A42832 for ; Sat, 7 May 2022 09:08:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651907310; x=1683443310; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k4K9cnAKQ9sJa1VKMTWFkZKI+SLwogNyQnsJ7qkw8w0=; b=A5Yi5MbecElJbNZbHCeAmqH1daRjlNwraFlFKrn8/MmEqv/8qQnmju13 FwyHfCt8ulYoWB85gNdev00+ItjtLpHNtrnSe1JQ4tgBiu6TtNN46zBri 40gnl3wPSmlJzvMj+zaz3hUxyr3RECyjqzFwzIIzEYJ9sSO6EPmb7GK7t i4zECwFey5QqRFPTrAFY0bfG6tHML/mmXumMpQofj7zGaIn7I4Nzq7PiO cFDLzwZvl9Bssm3Z+tBaC69xxxmM66YWs1GEVbGiabusBQD1XsjnLr6kn CbPqmWRLaE2ATJq/eIDoaep5HAo+PpHBK3mTro06pfDFJuYTASEhxzn9d A==; X-IronPort-AV: E=McAfee;i="6400,9594,10339"; a="256157755" X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="256157755" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2022 00:08:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="564217024" Received: from dpdk-jf-ntb-v2.sh.intel.com ([10.67.119.111]) by orsmga007.jf.intel.com with ESMTP; 07 May 2022 00:08:27 -0700 From: Junfeng Guo To: qi.z.zhang@intel.com, jingjing.wu@intel.com, beilei.xing@intel.com Cc: dev@dpdk.org, junfeng.guo@intel.com Subject: [RFC 6/9] net/idpf: support packet type getting Date: Sat, 7 May 2022 15:07:23 +0800 Message-Id: <20220507070726.3263649-7-junfeng.guo@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507070726.3263649-1-junfeng.guo@intel.com> References: <20220507070726.3263649-1-junfeng.guo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add ops dev_supported_ptypes_get. Signed-off-by: Beilei Xing Signed-off-by: Junfeng Guo --- 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