200 lines
6.3 KiB
Diff
200 lines
6.3 KiB
Diff
|
|
From 226962a2920959977ecc1cf7ab17f250dea60b29 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Ferruh Yigit <ferruh.yigit@intel.com>
|
||
|
|
Date: Fri, 11 Feb 2022 19:11:43 +0000
|
||
|
|
Subject: [PATCH] ethdev: move driver interface functions to its own file
|
||
|
|
|
||
|
|
[ upstream commit 4b4f810e47647f9deeacf04aa1e332b548f61461 ]
|
||
|
|
|
||
|
|
ethdev has two interfaces, one interface between applications and
|
||
|
|
library, these APIs are declared in the rte_ethdev.h public header.
|
||
|
|
Other interface is between drivers and library, these functions are
|
||
|
|
declared in ethdev_driver.h and marked as internal.
|
||
|
|
|
||
|
|
But all functions are defined in rte_ethdev.c file. This patch moves
|
||
|
|
functions for drivers to its own file, ethdev_driver.c for cleanup, no
|
||
|
|
functional change in functions.
|
||
|
|
|
||
|
|
Some public APIs and driver helpers call common internal functions,
|
||
|
|
which were mostly static since both were in same file. To be able to
|
||
|
|
move driver helpers, common functions are moved to ethdev_private.c.
|
||
|
|
(ethdev_private.c is used for functions that are internal to the library
|
||
|
|
and shared by multiple .c files in the ethdev library.)
|
||
|
|
|
||
|
|
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
|
||
|
|
Acked-by: Thomas Monjalon <thomas@monjalon.net>
|
||
|
|
---
|
||
|
|
lib/ethdev/ethdev_driver.c | 11 +++++++++++
|
||
|
|
lib/ethdev/ethdev_driver.h | 18 ++++++++++++++++++
|
||
|
|
lib/ethdev/version.map | 1 +
|
||
|
|
lib/mempool/rte_mempool.c | 34 ++++++++++++++++++++++++++++++++++
|
||
|
|
lib/mempool/rte_mempool.h | 33 +++++++++++++++++++++++++++++++++
|
||
|
|
lib/mempool/version.map | 2 ++
|
||
|
|
6 files changed, 99 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c
|
||
|
|
index fb7323f..b2fa68d 100644
|
||
|
|
--- a/lib/ethdev/ethdev_driver.c
|
||
|
|
+++ b/lib/ethdev/ethdev_driver.c
|
||
|
|
@@ -11,3 +11,14 @@ rte_eth_pkt_burst_dummy(void *queue __rte_unused,
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
+
|
||
|
|
+struct rte_eth_dev *
|
||
|
|
+rte_eth_dev_get_by_name(const char *name)
|
||
|
|
+{
|
||
|
|
+ uint16_t pid;
|
||
|
|
+
|
||
|
|
+ if (rte_eth_dev_get_port_by_name(name, &pid))
|
||
|
|
+ return NULL;
|
||
|
|
+
|
||
|
|
+ return &rte_eth_devices[pid];
|
||
|
|
+}
|
||
|
|
\ No newline at end of file
|
||
|
|
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
|
||
|
|
index 6f539d4..e057348 100644
|
||
|
|
--- a/lib/ethdev/ethdev_driver.h
|
||
|
|
+++ b/lib/ethdev/ethdev_driver.h
|
||
|
|
@@ -1726,6 +1726,24 @@ rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t cur_queue,
|
||
|
|
struct rte_hairpin_peer_info *peer_info,
|
||
|
|
uint32_t direction);
|
||
|
|
|
||
|
|
+/**
|
||
|
|
+ * @internal
|
||
|
|
+ * Get rte_eth_dev from device name. The device name should be specified
|
||
|
|
+ * as below:
|
||
|
|
+ * - PCIe address (Domain:Bus:Device.Function), for example 0000:2:00.0
|
||
|
|
+ * - SoC device name, for example fsl-gmac0
|
||
|
|
+ * - vdev dpdk name, for example net_[pcap0|null0|tap0]
|
||
|
|
+ *
|
||
|
|
+ * @param name
|
||
|
|
+ * PCI address or name of the device
|
||
|
|
+ * @return
|
||
|
|
+ * - rte_eth_dev if successful
|
||
|
|
+ * - NULL on failure
|
||
|
|
+ */
|
||
|
|
+__rte_internal
|
||
|
|
+struct rte_eth_dev*
|
||
|
|
+rte_eth_dev_get_by_name(const char *name);
|
||
|
|
+
|
||
|
|
/**
|
||
|
|
* @internal
|
||
|
|
* Reset the current queue state and configuration to disconnect (unbind) it
|
||
|
|
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
|
||
|
|
index 44cbe04..40dca3d 100644
|
||
|
|
--- a/lib/ethdev/version.map
|
||
|
|
+++ b/lib/ethdev/version.map
|
||
|
|
@@ -282,6 +282,7 @@ INTERNAL {
|
||
|
|
rte_eth_dev_callback_process;
|
||
|
|
rte_eth_dev_create;
|
||
|
|
rte_eth_dev_destroy;
|
||
|
|
+ rte_eth_dev_get_by_name;
|
||
|
|
rte_eth_dev_is_rx_hairpin_queue;
|
||
|
|
rte_eth_dev_is_tx_hairpin_queue;
|
||
|
|
rte_eth_dev_probing_finish;
|
||
|
|
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
|
||
|
|
index 871f4d1..14c4e34 100644
|
||
|
|
--- a/lib/mempool/rte_mempool.c
|
||
|
|
+++ b/lib/mempool/rte_mempool.c
|
||
|
|
@@ -1383,6 +1383,40 @@ struct mempool_callback_data {
|
||
|
|
void *user_data;
|
||
|
|
};
|
||
|
|
|
||
|
|
+int rte_mempool_get_mem_range(const struct rte_mempool *mp,
|
||
|
|
+ struct rte_mempool_mem_range_info *mem_range)
|
||
|
|
+{
|
||
|
|
+ void *address_low = (void *)UINTPTR_MAX;
|
||
|
|
+ void *address_high = 0;
|
||
|
|
+ size_t address_diff = 0;
|
||
|
|
+ size_t total_size = 0;
|
||
|
|
+ struct rte_mempool_memhdr *hdr;
|
||
|
|
+
|
||
|
|
+ if (mp == NULL || mem_range == NULL)
|
||
|
|
+ return -EINVAL;
|
||
|
|
+
|
||
|
|
+ /* go through memory chunks and find the lowest and highest addresses */
|
||
|
|
+ STAILQ_FOREACH(hdr, &mp->mem_list, next) {
|
||
|
|
+ if (address_low > hdr->addr)
|
||
|
|
+ address_low = hdr->addr;
|
||
|
|
+ if (address_high < RTE_PTR_ADD(hdr->addr, hdr->len))
|
||
|
|
+ address_high = RTE_PTR_ADD(hdr->addr, hdr->len);
|
||
|
|
+ total_size += hdr->len;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ /* check if mempool was not populated yet (no memory chunks) */
|
||
|
|
+ if (address_low == (void *)UINTPTR_MAX)
|
||
|
|
+ return -EINVAL;
|
||
|
|
+
|
||
|
|
+ address_diff = (size_t)RTE_PTR_DIFF(address_high, address_low);
|
||
|
|
+
|
||
|
|
+ mem_range->start = address_low;
|
||
|
|
+ mem_range->length = address_diff;
|
||
|
|
+ mem_range->is_contiguous = (total_size == address_diff) ? true : false;
|
||
|
|
+
|
||
|
|
+ return 0;
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
static void
|
||
|
|
mempool_event_callback_invoke(enum rte_mempool_event event,
|
||
|
|
struct rte_mempool *mp)
|
||
|
|
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
|
||
|
|
index 1e7a3c1..9933498 100644
|
||
|
|
--- a/lib/mempool/rte_mempool.h
|
||
|
|
+++ b/lib/mempool/rte_mempool.h
|
||
|
|
@@ -1864,6 +1864,39 @@ int
|
||
|
|
rte_mempool_event_callback_register(rte_mempool_event_callback *func,
|
||
|
|
void *user_data);
|
||
|
|
|
||
|
|
+/**
|
||
|
|
+ * A structure used to retrieve information about the memory range
|
||
|
|
+ * of the mempool.
|
||
|
|
+ */
|
||
|
|
+struct rte_mempool_mem_range_info {
|
||
|
|
+ /** Start of the memory range used by mempool objects */
|
||
|
|
+ void *start;
|
||
|
|
+ /** Length of the memory range used by mempool objects */
|
||
|
|
+ size_t length;
|
||
|
|
+ /** Are all memory addresses used by mempool objects contiguous */
|
||
|
|
+ bool is_contiguous;
|
||
|
|
+};
|
||
|
|
+
|
||
|
|
+/**
|
||
|
|
+ * @warning
|
||
|
|
+ * @b EXPERIMENTAL: this API may change without prior notice.
|
||
|
|
+ *
|
||
|
|
+ * Get information about the memory range used to store objects in the mempool.
|
||
|
|
+ *
|
||
|
|
+ * @param[in] mp
|
||
|
|
+ * Pointer to an initialized mempool.
|
||
|
|
+ * @param[out] mem_range
|
||
|
|
+ * Pointer to struct which is used to return lowest address,
|
||
|
|
+ * length of the memory range containing all the addresses,
|
||
|
|
+ * and whether these addresses are contiguous.
|
||
|
|
+ * @return
|
||
|
|
+ * 0 on success, -EINVAL if mempool is not valid or mem_range is NULL.
|
||
|
|
+ **/
|
||
|
|
+__rte_experimental
|
||
|
|
+int
|
||
|
|
+rte_mempool_get_mem_range(const struct rte_mempool *mp,
|
||
|
|
+ struct rte_mempool_mem_range_info *mem_range);
|
||
|
|
+
|
||
|
|
/**
|
||
|
|
* @internal
|
||
|
|
* Unregister a callback added with rte_mempool_event_callback_register().
|
||
|
|
diff --git a/lib/mempool/version.map b/lib/mempool/version.map
|
||
|
|
index 1b7d7c5..b1240da 100644
|
||
|
|
--- a/lib/mempool/version.map
|
||
|
|
+++ b/lib/mempool/version.map
|
||
|
|
@@ -63,6 +63,8 @@ EXPERIMENTAL {
|
||
|
|
__rte_mempool_trace_ops_alloc;
|
||
|
|
__rte_mempool_trace_ops_free;
|
||
|
|
__rte_mempool_trace_set_ops_byname;
|
||
|
|
+ # added in 24.07
|
||
|
|
+ rte_mempool_get_mem_range;
|
||
|
|
};
|
||
|
|
|
||
|
|
INTERNAL {
|
||
|
|
--
|
||
|
|
2.33.0
|
||
|
|
|