From patchwork Sat Sep 29 02:12:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xiaoyun" X-Patchwork-Id: 45639 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D6E31B20D; Sat, 29 Sep 2018 04:20:35 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 7E2591B20D for ; Sat, 29 Sep 2018 04:20:33 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2018 19:20:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,317,1534834800"; d="scan'208";a="90568387" Received: from dpdk-xiaoyun3.sh.intel.com ([10.67.119.56]) by fmsmga002.fm.intel.com with ESMTP; 28 Sep 2018 19:20:19 -0700 From: Xiaoyun Li To: ferruh.yigit@intel.com, thomas@monjalon.net, damarion@cisco.com, stephen@networkplumber.org Cc: helin.zhang@intel.com, ray.kinsella@intel.com, dev@dpdk.org, Xiaoyun Li Date: Sat, 29 Sep 2018 10:12:04 +0800 Message-Id: <20180929021204.52432-1-xiaoyun.li@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180928034331.25147-1-xiaoyun.li@intel.com> References: <20180928034331.25147-1-xiaoyun.li@intel.com> Subject: [dpdk-dev] [PATCH v3] ethdev: get rxq interrupt fd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Some users want to use their own epoll instances to control both DPDK rxq interrupt fds and their own other fds. So added a function to get rxq interrupt fd based on port id and queue id. Signed-off-by: Xiaoyun Li Reviewed-by: Ferruh Yigit --- v3: * Since the API only wants to return fd, return fd or -1. v2: * Added missing API doxygen comments. * Set the new API to be experimental and added it in .map file. --- lib/librte_ethdev/rte_ethdev.c | 37 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 20 +++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 3 files changed, 58 insertions(+) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index ef99f7068..4930eb6ff 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3433,6 +3433,43 @@ rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data) return 0; } +int __rte_experimental +rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id) +{ + struct rte_intr_handle *intr_handle; + struct rte_eth_dev *dev; + unsigned int efd_idx; + uint32_t vec; + int fd; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1); + + dev = &rte_eth_devices[port_id]; + + if (queue_id >= dev->data->nb_rx_queues) { + RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id); + return -1; + } + + if (!dev->intr_handle) { + RTE_ETHDEV_LOG(ERR, "RX Intr handle unset\n"); + return -1; + } + + intr_handle = dev->intr_handle; + if (!intr_handle->intr_vec) { + RTE_ETHDEV_LOG(ERR, "RX Intr vector unset\n"); + return -1; + } + + vec = intr_handle->intr_vec[queue_id]; + efd_idx = (vec >= RTE_INTR_VEC_RXTX_OFFSET) ? + (vec - RTE_INTR_VEC_RXTX_OFFSET) : vec; + fd = intr_handle->efds[efd_idx]; + + return fd; +} + const struct rte_memzone * rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, size_t size, unsigned align, diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 012577b0a..f9366f3f0 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2719,6 +2719,26 @@ int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data); int rte_eth_dev_rx_intr_ctl_q(uint16_t port_id, uint16_t queue_id, int epfd, int op, void *data); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Get interrupt fd per Rx queue. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The index of the receive queue from which to retrieve input packets. + * The value must be in the range [0, nb_rx_queue - 1] previously supplied + * to rte_eth_dev_configure(). + * @return + * - (>=0) the interrupt fd associated to the requested Rx queue if + * successful. + * - (-1) on error. + */ +int __rte_experimental +rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id); + /** * Turn on the LED on the Ethernet device. * This function turns on the LED on the Ethernet device. diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 38f117f01..c98f9fa4a 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -235,6 +235,7 @@ EXPERIMENTAL { rte_eth_dev_owner_new; rte_eth_dev_owner_set; rte_eth_dev_owner_unset; + rte_eth_dev_rx_intr_ctl_q_get_fd; rte_eth_dev_rx_offload_name; rte_eth_dev_tx_offload_name; rte_eth_switch_domain_alloc;