Skip to contentSkip to conversation

ethdev: get rxq interrupt fd

PATCH Superseded Xiaoyun Li 3 participants 9 messages Sep 28, 2018 – Oct 4, 2018

lore
Share & tools
lore

Xiaoyun Li

author
#0 lore raw

PATCH 1/1 ethdev: get rxq interrupt fd

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.

---
 lib/librte_ethdev/rte_ethdev.c | 37 ++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h |  3 +++
 2 files changed, 40 insertions(+)
lib/librte_ethdev/rte_ethdev.c +37 -0
index ef99f7068..c21124e32 100644
@@ -3433,6 +3433,43 @@ rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data)
 	return 0;
 }
 
+int
+rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id,
+				 int *fd)
+{
+	struct rte_intr_handle *intr_handle;
+	struct rte_eth_dev *dev;
+	unsigned int efd_idx;
+	uint32_t vec;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+	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 -EINVAL;
+	}
+
+	if (!dev->intr_handle) {
+		RTE_ETHDEV_LOG(ERR, "RX Intr handle unset\n");
+		return -ENOTSUP;
+	}
+
+	intr_handle = dev->intr_handle;
+	if (!intr_handle->intr_vec) {
+		RTE_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
+		return -EPERM;
+	}
+
+	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 0;
+}
+
 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,
lib/librte_ethdev/rte_ethdev.h +3 -0
index 012577b0a..3670d7249 100644
@@ -2719,6 +2719,9 @@ 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);
 
+int rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id,
+				     int *fd);
+
 /**
  * Turn on the LED on the Ethernet device.
  * This function turns on the LED on the Ethernet device.
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · Xiaoyun Li

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.

<...>

lib/librte_ethdev/rte_ethdev.h int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data); · line 2723

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +2 -0
@@ -2719,6 +2719,9 @@ 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);
 
+int rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id,
+				     int *fd);

Hi Xiaoyun,

API is missing documentation, please add doxygen comments.

New APIs need to be experimental, at least for one release.
Also can you please add it to .map file otherwise shared lib build will fail

#2 lore raw

OK. Thanks.

Quoted 33 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, September 28, 2018 16:33
To: Li, Xiaoyun <[email protected]>; [email protected]; Zhang, Helin <[email protected]>; [email protected]; Kinsella, Ray <[email protected]>; [email protected]
Subject: Re: [PATCH] ethdev: get rxq interrupt fd

Quoted 5 lines · Xiaoyun Li

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.

<...>

Quoted 2 lines
(quoted diff) +0 -0
@@ -2719,6 +2719,9 @@ 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,

lib/librte_ethdev/rte_ethdev.h int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data);

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +1 -0
 			      int epfd, int op, void *data);
 
+int rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t

queue_id,

lib/librte_ethdev/rte_ethdev.h int rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data); · line 2723

Quoted 1 line
lib/librte_ethdev/rte_ethdev.h +1 -0
+				     int *fd);

Hi Xiaoyun,

API is missing documentation, please add doxygen comments.

New APIs need to be experimental, at least for one release.
Also can you please add it to .map file otherwise shared lib build will fail

author
#3 lore raw

PATCH v2 1/1 ethdev: get rxq interrupt fd

In reply to Xiaoyun Li

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.

---
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           | 22 ++++++++++++++
 lib/librte_ethdev/rte_ethdev_version.map |  1 +
 3 files changed, 60 insertions(+)
lib/librte_ethdev/rte_ethdev.c +37 -0
index ef99f7068..7c580ec68 100644
@@ -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,
+				 int *fd)
+{
+	struct rte_intr_handle *intr_handle;
+	struct rte_eth_dev *dev;
+	unsigned int efd_idx;
+	uint32_t vec;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+	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 -EINVAL;
+	}
+
+	if (!dev->intr_handle) {
+		RTE_ETHDEV_LOG(ERR, "RX Intr handle unset\n");
+		return -ENOTSUP;
+	}
+
+	intr_handle = dev->intr_handle;
+	if (!intr_handle->intr_vec) {
+		RTE_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
+		return -EPERM;
+	}
+
+	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 0;
+}
+
 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,
lib/librte_ethdev/rte_ethdev.h +22 -0
index 012577b0a..8f6a5d08b 100644
@@ -2719,6 +2719,28 @@ 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().
+ * @param fd
+ *   The interrupt fd which the requested Rx queue associated to.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+int __rte_experimental
+rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id,
+				 int *fd);
+
 /**
  * Turn on the LED on the Ethernet device.
  * This function turns on the LED on the Ethernet device.
lib/librte_ethdev/rte_ethdev_version.map +1 -0
index 38f117f01..c98f9fa4a 100644
@@ -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;
Signature · 1 line
2.17.1
#4 lore raw
In reply to Xiaoyun Li

In general, an API is less error prone if it only does return by value. What about just returning fd or -1?

Quoted 81 lines · Xiaoyun Li

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.

---
 lib/librte_ethdev/rte_ethdev.c | 37 ++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h |  3 +++
 2 files changed, 40 insertions(+)
lib/librte_ethdev/rte_ethdev.c +37 -0
index ef99f7068..c21124e32 100644
@@ -3433,6 +3433,43 @@ rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd,
 int op, void *data)
        return 0;
 }
 
+int
+rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id,
+                                int *fd)
+{
+       struct rte_intr_handle *intr_handle;
+       struct rte_eth_dev *dev;
+       unsigned int efd_idx;
+       uint32_t vec;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+       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 -EINVAL;
+       }
+
+       if (!dev->intr_handle) {
+               RTE_ETHDEV_LOG(ERR, "RX Intr handle unset\n");
+               return -ENOTSUP;
+       }
+
+       intr_handle = dev->intr_handle;
+       if (!intr_handle->intr_vec) {
+               RTE_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
+               return -EPERM;
+       }
+
+       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 0;
+}
+
 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,

lib/librte_ethdev/rte_ethdev.h +3 -0
index 012577b0a..3670d7249 100644
@@ -2719,6 +2719,9 @@ 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);
 
+int rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id,
+                                    int *fd);
+
 /**
  * Turn on the LED on the Ethernet device.

* This function turns on the LED on the Ethernet device.
--
2.17.1

#5 lore raw

Sure. Anyway there is an error log to indicate the error. I will send v3 later. Thanks.

From: Stephen Hemminger [mailto:[email protected]]
Sent: Friday, September 28, 2018 20:47
To: Li, Xiaoyun <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Thomas Monjalon <[email protected]>; Zhang, Helin <[email protected]>; [email protected]; Kinsella, Ray <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] ethdev: get rxq interrupt fd

In general, an API is less error prone if it only does return by value. What about just returning fd or -1?

On Fri, Sep 28, 2018, 5:55 AM Xiaoyun Li <[email protected]<mailto:[email protected]>> wrote:
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.

---
 lib/librte_ethdev/rte_ethdev.c | 37 ++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h |  3 +++
 2 files changed, 40 insertions(+)
lib/librte_ethdev/rte_ethdev.c +37 -0
index ef99f7068..c21124e32 100644
@@ -3433,6 +3433,43 @@ rte_eth_dev_rx_intr_ctl(uint16_t port_id, int epfd, int op, void *data)
        return 0;
 }
 
+int
+rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id,
+                                int *fd)
+{
+       struct rte_intr_handle *intr_handle;
+       struct rte_eth_dev *dev;
+       unsigned int efd_idx;
+       uint32_t vec;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+       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 -EINVAL;
+       }
+
+       if (!dev->intr_handle) {
+               RTE_ETHDEV_LOG(ERR, "RX Intr handle unset\n");
+               return -ENOTSUP;
+       }
+
+       intr_handle = dev->intr_handle;
+       if (!intr_handle->intr_vec) {
+               RTE_ETHDEV_LOG(ERR, "RX Intr vector unset\n");
+               return -EPERM;
+       }
+
+       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 0;
+}
+
 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,
lib/librte_ethdev/rte_ethdev.h +3 -0
index 012577b0a..3670d7249 100644
@@ -2719,6 +2719,9 @@ 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);
 
+int rte_eth_dev_rx_intr_ctl_q_get_fd(uint16_t port_id, uint16_t queue_id,
+                                    int *fd);
+
 /**
  * Turn on the LED on the Ethernet device.
  * This function turns on the LED on the Ethernet device.

--
2.17.1

author
#6 lore raw

PATCH v3 1/1 ethdev: get rxq interrupt fd

In reply to Xiaoyun Li

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.

---
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(+)
lib/librte_ethdev/rte_ethdev.c +37 -0
index ef99f7068..4930eb6ff 100644
@@ -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,
lib/librte_ethdev/rte_ethdev.h +20 -0
index 012577b0a..f9366f3f0 100644
@@ -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.
lib/librte_ethdev/rte_ethdev_version.map +1 -0
index 38f117f01..c98f9fa4a 100644
@@ -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;
Signature · 1 line
2.17.1
Applied
#8 lore raw
Quoted 8 lines · Ferruh Yigit
Quoted 5 lines · Xiaoyun Li

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.

Applied to dpdk-next-net/master, thanks.