From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 215CD5582 for ; Tue, 15 Mar 2016 04:51:27 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 14 Mar 2016 20:51:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,337,1455004800"; d="scan'208";a="933922148" Received: from dpdk06.sh.intel.com ([10.239.128.225]) by orsmga002.jf.intel.com with ESMTP; 14 Mar 2016 20:51:25 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: helin.zhang@intel.com, konstantin.ananyev@intel.com, adrien.mazarguil@6wind.com, ferruh.yigit@intel.com, Jianfeng Tan Date: Tue, 15 Mar 2016 04:50:50 +0800 Message-Id: <1457988650-52797-1-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <56E6F176.80304@intel.com> References: <56E6F176.80304@intel.com> Subject: [dpdk-dev] [PATCH v9 01/11] ethdev: add API to query supported packet types X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2016 03:51:29 -0000 Add a new API rte_eth_dev_get_supported_ptypes to query what packet types can be filled by given already started device (or its pmd rx burst function has already been decided). Signed-off-by: Jianfeng Tan Acked-by: Konstantin Ananyev Acked-by: Adrien Mazarguil --- v9: - Fix rte_ether_version.map as Ferruh Yigit sugguests. lib/librte_ether/rte_ethdev.c | 27 +++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 27 +++++++++++++++++++++++++++ lib/librte_ether/rte_ether_version.map | 7 +++++++ 3 files changed, 61 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index a6e83c1..52fb62c 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1616,6 +1616,33 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info) dev_info->driver_name = dev->data->drv_name; } +int +rte_eth_dev_get_supported_ptypes(uint8_t port_id, uint32_t ptype_mask, + uint32_t *ptypes, int num) +{ + int i, j; + struct rte_eth_dev *dev; + const uint32_t *all_ptypes; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_supported_ptypes_get, + -ENOTSUP); + all_ptypes = (*dev->dev_ops->dev_supported_ptypes_get)(dev); + + if (!all_ptypes) + return 0; + + for (i = 0, j = 0; all_ptypes[i] != RTE_PTYPE_UNKNOWN; ++i) + if (all_ptypes[i] & ptype_mask) { + if (j < num) + ptypes[j] = all_ptypes[i]; + j++; + } + + return j; +} + void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index e2893ba..7770f24 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1021,6 +1021,9 @@ typedef void (*eth_dev_infos_get_t)(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); /**< @internal Get specific informations of an Ethernet device. */ +typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev); +/**< @internal Get supported ptypes of an Ethernet device. */ + typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev, uint16_t queue_id); /**< @internal Start rx and tx of a queue of an Ethernet device. */ @@ -1347,6 +1350,7 @@ struct eth_dev_ops { eth_queue_stats_mapping_set_t queue_stats_mapping_set; /**< Configure per queue stat counter mapping. */ eth_dev_infos_get_t dev_infos_get; /**< Get device info. */ + eth_dev_supported_ptypes_get_t dev_supported_ptypes_get; /** Get supported ptypes */ mtu_set_t mtu_set; /**< Set MTU. */ vlan_filter_set_t vlan_filter_set; /**< Filter VLAN Setup. */ vlan_tpid_set_t vlan_tpid_set; /**< Outer VLAN TPID Setup. */ @@ -2270,6 +2274,29 @@ void rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr); void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info); /** + * Retrieve the supported packet types of an Ethernet device. + * + * @note + * Better to invoke this API after the device is already started or rx burst + * function is decided, to obtain correct supported ptypes. + * @param port_id + * The port identifier of the Ethernet device. + * @param ptype_mask + * A hint of what kind of packet type which the caller is interested in. + * @param ptypes + * An array pointer to store adequent packet types, allocated by caller. + * @param num + * Size of the array pointed by param ptypes. + * @return + * - (>0) Number of supported ptypes. If it exceeds param num, exceeding + * packet types will not be filled in the given array. + * - (0 or -ENOTSUP) if PMD does not fill the specified ptype. + * - (-ENODEV) if *port_id* invalid. + */ +int rte_eth_dev_get_supported_ptypes(uint8_t port_id, uint32_t ptype_mask, + uint32_t *ptypes, int num); + +/** * Retrieve the MTU of an Ethernet device. * * @param port_id diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index d8db24d..c242e71 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -117,3 +117,10 @@ DPDK_2.2 { local: *; }; + +DPDK_16.04 { + global: + + rte_eth_dev_get_supported_ptypes; + +} DPDK_2.2; -- 2.1.4