From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id B9E312931 for ; Wed, 6 Apr 2016 12:51:44 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 06 Apr 2016 03:51:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,447,1455004800"; d="scan'208";a="80062372" Received: from dpdk06.sh.intel.com ([10.239.128.225]) by fmsmga004.fm.intel.com with ESMTP; 06 Apr 2016 03:51:42 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, bruce.richardson@intel.com, thomas.monjalon@6wind.com, Jianfeng Tan Date: Wed, 6 Apr 2016 11:51:13 +0800 Message-Id: <1459914673-27716-1-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458875736-56444-1-git-send-email-jianfeng.tan@intel.com> References: <1458875736-56444-1-git-send-email-jianfeng.tan@intel.com> Subject: [dpdk-dev] [PATCH v2] ethdev: refine new API to query supported ptypes 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: Wed, 06 Apr 2016 10:51:45 -0000 This change is to make user code simpler. For PMDs which do not fill any packet types, return 0 instead of -ENOTSUP as suggested by Bruce. Usually, users only care if the required (by ptype_mask) ptypes can be filled by the specified PMD. If the PMD implements dev_supported_ptypes_get func is not important. And the introduce of another return value (-ENOTSUP) would increase the complexity of user programs to check it. Besides, there are ways to know if a PMD implements the func: a. see doc/guides/nics/overview.rst. b. use (~1) as parameter ptype_mask, then check if return 0. Suggested-by: Bruce Richardson Signed-off-by: Jianfeng Tan Acked-by: Konstantin Ananyev --- v2: exclude the commit of updating doc/guides/nics/overview.rst. lib/librte_ether/rte_ethdev.c | 3 +-- lib/librte_ether/rte_ethdev.h | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index fd49b26..5a16d5e 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1670,8 +1670,7 @@ rte_eth_dev_get_supported_ptypes(uint8_t port_id, uint32_t ptype_mask, 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); + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_supported_ptypes_get, 0); all_ptypes = (*dev->dev_ops->dev_supported_ptypes_get)(dev); if (!all_ptypes) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 37ddd51..022733e 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -2379,6 +2379,9 @@ void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info); * @note * Better to invoke this API after the device is already started or rx burst * function is decided, to obtain correct supported ptypes. + * @note + * if a given PMD does not report what ptypes it supports, then the supported + * ptype count is reported as 0. * @param port_id * The port identifier of the Ethernet device. * @param ptype_mask @@ -2388,9 +2391,9 @@ void rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info); * @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. + * - (>=0) Number of supported ptypes. If the number of types exceeds num, + * only num entries will be filled into the ptypes array, but the full + * count of supported ptypes will be returned. * - (-ENODEV) if *port_id* invalid. */ int rte_eth_dev_get_supported_ptypes(uint8_t port_id, uint32_t ptype_mask, -- 2.1.4