From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-3.cisco.com (alln-iport-3.cisco.com [173.37.142.90]) by dpdk.org (Postfix) with ESMTP id 28778C312 for ; Fri, 12 Jun 2015 19:32:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3955; q=dns/txt; s=iport; t=1434130372; x=1435339972; h=message-id:date:from:mime-version:to:cc:subject: references:in-reply-to:content-transfer-encoding; bh=T3OUPxKS4C41CY15kcGEqSgrz65WGYqFCb76H7B7wU8=; b=LJZpqKbXQAYnPlLzCd1uhWfr4/OoYoZ+3n+MUjLsu0XSd1AVVF/Vo1Xv YCD6DVZRahikd1e2VnQm4o66mc70UNO5xJ4Z0tcD/S8kZXp2/zNl9xlzC tQtIcopcs0U2a3awMwxTLe+EIvBMD4cGFiWxC6I2Kh1rA19vIqXSI+azf 4=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A5BAAiF3tV/5xdJa1ZA4MQVF+DHrpRCYFhhXoCgUE4FAEBAQEBAQGBCoQiAQEBAQIBIwQRHSMBBQsLGAICBRYLAgIJAwIBAgFFBg0BBQIBAYgjCA2ySaQ8AQEBAQEBAQEBAQEBAQEBAQEBARmBIYoihCMRASsWEAcRgleBRQEEk1aLPIEyhAGCY4U4ijomY4FZgVkiMQGBC4E7AQEB X-IronPort-AV: E=Sophos;i="5.13,602,1427760000"; d="scan'208";a="158766312" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by alln-iport-3.cisco.com with ESMTP; 12 Jun 2015 17:32:50 +0000 Received: from [10.82.237.197] (rtp-vpn5-1472.cisco.com [10.82.237.197]) by rcdn-core-5.cisco.com (8.14.5/8.14.5) with ESMTP id t5CHWonO015770; Fri, 12 Jun 2015 17:32:50 GMT Message-ID: <557B17C8.3090300@cisco.com> Date: Fri, 12 Jun 2015 13:32:56 -0400 From: "Roger B. Melton" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Bruce Richardson References: <1434108496-1993-1-git-send-email-bruce.richardson@intel.com> <1434108496-1993-5-git-send-email-bruce.richardson@intel.com> In-Reply-To: <1434108496-1993-5-git-send-email-bruce.richardson@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns 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: Fri, 12 Jun 2015 17:32:52 -0000 Hi Bruce, Comment in-line. Regards, Roger On 6/12/15 7:28 AM, Bruce Richardson wrote: > The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are > supported by very few PMDs. Therefore, it is best to check for support > for the functions in the ethdev library, so as to avoid crashes > at run-time if the application goes to use those APIs. The performance > impact of this change should be very small as this is a predictable > branch in the function. > > Signed-off-by: Bruce Richardson > --- > lib/librte_ether/rte_ethdev.h | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h > index 827ca3e..9ad1b6a 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -2496,6 +2496,8 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id, > * The queue id on the specific port. > * @return > * The number of used descriptors in the specific queue. > + * NOTE: if function is not supported by device this call > + * returns (uint32_t)-ENOTSUP > */ > static inline uint32_t Why not change the return type to int32_t? In this way, the caller isn't required to make the assumption that a large queue count indicates an error. < 0 means error, other wise it's a valid queue count. This approach would be consistent with other APIs. > rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) > @@ -2507,8 +2509,9 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) > RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); > return 0; > } > - RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0); > #endif > + RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, (uint32_t)-ENOTSUP); > + > return (*dev->dev_ops->rx_queue_count)(dev, queue_id); > } > > @@ -2525,6 +2528,7 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) > * - (1) if the specific DD bit is set. > * - (0) if the specific DD bit is not set. > * - (-ENODEV) if *port_id* invalid. > + * - (-ENOTSUP) if the device does not support this function > */ > static inline int > rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset) > @@ -2536,8 +2540,8 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset) > RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); > return -ENODEV; > } > - RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP); > #endif > + RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP); > > return (*dev->dev_ops->rx_descriptor_done)( \ > dev->data->rx_queues[queue_id], offset); -- ____________________________________________________________________ |Roger B. Melton | | Cisco Systems | |CPP Software :|: :|: 7100 Kit Creek Rd | |+1.919.476.2332 phone :|||: :|||: RTP, NC 27709-4987 | |+1.919.392.1094 fax .:|||||||:..:|||||||:. rmelton@cisco.com | | | | This email may contain confidential and privileged material for the| | sole use of the intended recipient. Any review, use, distribution | | or disclosure by others is strictly prohibited. If you are not the | | intended recipient (or authorized to receive for the recipient), | | please contact the sender by reply email and delete all copies of | | this message. | | | | For corporate legal information go to: | | http://www.cisco.com/web/about/doing_business/legal/cri/index.html | |__________________________ http://www.cisco.com ____________________|