[dpdk-dev,v3,1/4] eventdev: Add caps API and PMD callbacks for rte_event_eth_rx_adapter

Message ID 1505219369-2493-2-git-send-email-nikhil.rao@intel.com
State New
Headers show

Checks

Context Check Description
checkpatch success coding style OK
Intel-compilation success Compilation OK

Commit Message

Nikhil Rao Sept. 12, 2017, 12:29 p.m.
The caps API allows application to get information
needed to configure the ethernet receive adapter for the eventdev and
ethdev pair.

The PMD callbacks are used by the rte_event_eth_rx_xxx() APIs to
configure and control the ethernet receive adapter if packet transfers
from the ethdev to eventdev is implemented in hardware.

For e.g., the ethdev, eventdev pairing maybe such that all of the
Eth Rx queues can only be connected to a single event queue, in
which case the application is required to pass in -1 as the queue id
when adding a receive queue to the adapter.

Signed-off-by: Nikhil Rao <nikhil.rao@intel.com>
---
 lib/librte_eventdev/rte_eventdev.h           |  33 ++++++
 lib/librte_eventdev/rte_eventdev_pmd.h       | 170 +++++++++++++++++++++++++++
 lib/librte_eventdev/rte_eventdev.c           |  19 +++
 lib/librte_eventdev/rte_eventdev_version.map |   8 ++
 4 files changed, 230 insertions(+)

Patch hide | download patch | download mbox

diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h
index 128bc52..a8bebac 100644
--- a/lib/librte_eventdev/rte_eventdev.h
+++ b/lib/librte_eventdev/rte_eventdev.h
@@ -990,6 +990,39 @@  struct rte_event {
 	};
 };
 
+/* Ethdev Rx adapter capability bitmap flags */
+#define RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT	0x1
+/**< Eventdev can send packets to ethdev using internal event port */
+#define RTE_EVENT_ETH_RX_ADAPTER_CAP_SINGLE_EVENTQ	0x2
+/**< Ethdev Rx queues can be connected to single event queue */
+#define RTE_EVENT_ETH_RX_ADAPTER_CAP_FLOW_ID		0x4
+/**< Ethdev Rx adapter can set flow ID for event queue, if this flag
+ * is unset, the application needs to provide a flow id when adding
+ * the Rx queue to the adapter.
+ */
+
+/**
+ * Retrieve the event device's ethdev Rx adapter capabilities for the
+ * specified ethernet port
+ *
+ * @param dev_id
+ *   The identifier of the device.
+ *
+ * @param eth_port_id
+ *   The identifier of the ethernet device.
+ *
+ * @param[out] caps
+ *   A pointer to memory filled with Rx event adapter capabilities.
+ *
+ * @return
+ *   - 0: Success, driver provides Rx event adapter capabilities for the
+ *	ethernet device.
+ *   - <0: Error code returned by the driver function.
+ *
+ */
+int
+rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint8_t eth_port_id,
+				uint32_t *caps);
 
 struct rte_eventdev_driver;
 struct rte_eventdev_ops;
diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h
index 3d72acf..4cc9671 100644
--- a/lib/librte_eventdev/rte_eventdev_pmd.h
+++ b/lib/librte_eventdev/rte_eventdev_pmd.h
@@ -429,6 +429,161 @@  typedef int (*eventdev_xstats_get_names_t)(const struct rte_eventdev *dev,
 typedef uint64_t (*eventdev_xstats_get_by_name)(const struct rte_eventdev *dev,
 		const char *name, unsigned int *id);
 
+/**
+ * Retrieve the event device's ethdev Rx adapter capabilities for the
+ * specified ethernet port
+ *
+ * @param dev
+ *   Event device pointer
+ *
+ * @param eth_port_id
+ *   The identifier of the ethernet device.
+ *
+ * @param[out] caps
+ *   A pointer to memory filled with Rx event adapter capabilities.
+ *
+ * @return
+ *   - 0: Success, driver provides Rx event adapter capabilities for the
+ *	ethernet device.
+ *   - <0: Error code returned by the driver function.
+ *
+ */
+typedef int (*eventdev_eth_rx_adapter_caps_get_t)
+						(const struct rte_eventdev *dev,
+						uint8_t eth_port_id,
+						uint32_t *caps);
+
+struct rte_event_eth_rx_adapter_queue_conf *queue_conf;
+
+/**
+ * Add ethernet Rx queues to event device. This callback is invoked if
+ * the caps returned from rte_eventdev_eth_rx_adapter_caps_get(, eth_port_id)
+ * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set.
+ *
+ * @param dev
+ *   Event device pointer
+ *
+ * @param eth_port_id
+ *   The identifier of the ethernet device
+ *
+ * @param rx_queue_id
+ *   Ethernet device receive queue index
+ *
+ * @param queue_conf
+ *  Additonal configuration structure
+
+ * @return
+ *   - 0: Success, ethernet receive queue added successfully.
+ *   - <0: Error code returned by the driver function.
+ *
+ */
+typedef int (*eventdev_eth_rx_adapter_queue_add_t)(
+		const struct rte_eventdev *dev,
+		uint8_t eth_port_id,
+		int32_t rx_queue_id,
+		const struct rte_event_eth_rx_adapter_queue_conf *queue_conf);
+
+/**
+ * Delete ethernet Rx queues from event device. This callback is invoked if
+ * the caps returned from eventdev_eth_rx_adapter_caps_get(, eth_port_id)
+ * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set.
+ *
+ * @param dev
+ *   Event device pointer
+ *
+ * @param eth_port_id
+ *   The identifier of the ethernet device
+ *
+ * @param rx_queue_id
+ *   Ethernet device receive queue index
+ *
+ * @return
+ *   - 0: Success, ethernet receive queue deleted successfully.
+ *   - <0: Error code returned by the driver function.
+ *
+ */
+typedef int (*eventdev_eth_rx_adapter_queue_del_t)
+					(const struct rte_eventdev *dev,
+					uint8_t eth_port_id,
+					int32_t rx_queue_id);
+
+/**
+ * Start ethernet Rx adapter. This callback is invoked if
+ * the caps returned from eventdev_eth_rx_adapter_caps_get(.., eth_port_id)
+ * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
+ * from eth_port_id have been added to the event device.
+ *
+ * @param dev
+ *   Event device pointer
+ *
+ * @param eth_port_id
+ *   The identifier of the ethernet device
+ *
+ * @return
+ *   - 0: Success, ethernet Rx adapter started successfully.
+ *   - <0: Error code returned by the driver function.
+ */
+typedef int (*eventdev_eth_rx_adapter_start_t)
+					(const struct rte_eventdev *dev,
+					uint8_t eth_port_id);
+
+/**
+ * Stop ethernet Rx adapter. This callback is invoked if
+ * the caps returned from eventdev_eth_rx_adapter_caps_get(..,eth_port_id)
+ * has RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT set and Rx queues
+ * from eth_port_id have been added to the event device.
+ *
+ * @param dev
+ *   Event device pointer
+ *
+ * @param eth_port_id
+ *   The identifier of the ethernet device
+ *
+ * @return
+ *   - 0: Success, ethernet Rx adapter stopped successfully.
+ *   - <0: Error code returned by the driver function.
+ */
+typedef int (*eventdev_eth_rx_adapter_stop_t)
+					(const struct rte_eventdev *dev,
+					uint8_t eth_port_id);
+
+struct rte_event_eth_rx_adapter_stats *stats;
+
+/**
+ * Retrieve ethernet Rx adapter statistics.
+ *
+ * @param dev
+ *   Event device pointer
+ *
+ * @param eth_port_id
+ *   The identifier of the ethernet device
+ *
+ * @param[out] stats
+ *   Pointer to stats structure
+ * @return
+ *   Return 0 on success.
+ */
+
+typedef int (*eventdev_eth_rx_adapter_stats_get)
+			(const struct rte_eventdev *dev,
+			uint8_t eth_port_id,
+			struct rte_event_eth_rx_adapter_stats *stats);
+/**
+ * Reset ethernet Rx adapter statistics.
+ *
+ * @param dev
+ *   Event device pointer
+ *
+ * @param eth_port_id
+ *   The identifier of the ethernet device
+ *
+ * @return
+ *   Return 0 on success.
+ */
+typedef int (*eventdev_eth_rx_adapter_stats_reset)
+			(const struct rte_eventdev *dev,
+			uint8_t eth_port_id);
+
 /** Event device operations function pointer table */
 struct rte_eventdev_ops {
 	eventdev_info_get_t dev_infos_get;	/**< Get device info. */
@@ -468,6 +623,21 @@  struct rte_eventdev_ops {
 	/**< Get one value by name. */
 	eventdev_xstats_reset_t xstats_reset;
 	/**< Reset the statistics values in xstats. */
+
+	eventdev_eth_rx_adapter_caps_get_t eth_rx_adapter_caps_get;
+	/**< Get ethernet Rx adapter capabilities */
+	eventdev_eth_rx_adapter_queue_add_t eth_rx_adapter_queue_add;
+	/**< Add Rx queues to ethernet Rx adapter */
+	eventdev_eth_rx_adapter_queue_del_t eth_rx_adapter_queue_del;
+	/**< Delete Rx queues from ethernet Rx adapter */
+	eventdev_eth_rx_adapter_start_t eth_rx_adapter_start;
+	/**< Start ethernet Rx adapter */
+	eventdev_eth_rx_adapter_stop_t eth_rx_adapter_stop;
+	/**< Stop ethernet Rx adapter */
+	eventdev_eth_rx_adapter_stats_get eth_rx_adapter_stats_get;
+	/**< Get ethernet Rx stats */
+	eventdev_eth_rx_adapter_stats_reset eth_rx_adapter_stats_reset;
+	/**< Reset ethernet Rx stats */
 };
 
 /**
diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c
index bbb3805..d3eb608 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -128,6 +128,25 @@  rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
 	return 0;
 }
 
+int
+rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint8_t eth_port_id,
+				uint32_t *caps)
+{
+	struct rte_eventdev *dev;
+
+	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+	dev = &rte_eventdevs[dev_id];
+
+	if (caps == NULL)
+		return -EINVAL;
+	*caps = 0;
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_rx_adapter_caps_get,
+				-ENOTSUP);
+	return (*dev->dev_ops->eth_rx_adapter_caps_get)
+						(dev, eth_port_id, caps);
+}
+
 static inline int
 rte_event_dev_queue_config(struct rte_eventdev *dev, uint8_t nb_queues)
 {
diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map
index 4c48e5f..996b361 100644
--- a/lib/librte_eventdev/rte_eventdev_version.map
+++ b/lib/librte_eventdev/rte_eventdev_version.map
@@ -51,3 +51,11 @@  DPDK_17.08 {
 	rte_event_ring_init;
 	rte_event_ring_lookup;
 } DPDK_17.05;
+
+
+DPDK_17.11 {
+	global:
+
+	rte_event_eth_rx_adapter_caps_get;
+
+} DPDK_17.08;