[dpdk-dev] [PATCH 7/7] ethdev: use opaque user callback object

Ferruh Yigit ferruh.yigit at intel.com
Fri Dec 1 03:29:57 CET 2017


"struct rte_eth_rxtx_callback" is defined as internal data structure but
used in public APIs.

Checking the API documentation shows that intention was using this
object as opaque object. Data structure only used in delete APIs which
doesn't require to know the internals of the data structure.

Converting callback parameter in API to void pointer should not require
any modification in user application because this data structure was
already marked as internal and only should be used as pointer in
application.

Signed-off-by: Ferruh Yigit <ferruh.yigit at intel.com>
---
 lib/librte_ether/rte_ethdev.c | 10 ++++++----
 lib/librte_ether/rte_ethdev.h | 10 ++++------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 5558db7c4..fca4895a5 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3206,12 +3206,13 @@ rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
 }
 
 int
-rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
-		struct rte_eth_rxtx_callback *user_cb)
+rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id, void *_user_cb)
 {
 #ifndef RTE_ETHDEV_RXTX_CALLBACKS
 	return -ENOTSUP;
 #endif
+	struct rte_eth_rxtx_callback *user_cb = _user_cb;
+
 	/* Check input parameters. */
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 	if (user_cb == NULL ||
@@ -3240,12 +3241,13 @@ rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
 }
 
 int
-rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
-		struct rte_eth_rxtx_callback *user_cb)
+rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id, void *_user_cb)
 {
 #ifndef RTE_ETHDEV_RXTX_CALLBACKS
 	return -ENOTSUP;
 #endif
+	struct rte_eth_rxtx_callback *user_cb = _user_cb;
+
 	/* Check input parameters. */
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 	if (user_cb == NULL ||
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 12b85a263..b94abef5f 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1215,8 +1215,6 @@ typedef uint16_t (*rte_rx_callback_fn)(uint16_t port_id, uint16_t queue,
 typedef uint16_t (*rte_tx_callback_fn)(uint16_t port_id, uint16_t queue,
 	struct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);
 
-struct rte_eth_rxtx_callback;
-
 /**
  * A set of values to describe the possible states of an eth device.
  */
@@ -2960,8 +2958,8 @@ void *rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id,
  *   - -EINVAL:  The port_id or the queue_id is out of range, or the callback
  *               is NULL or not found for the port/queue.
  */
-int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
-		struct rte_eth_rxtx_callback *user_cb);
+int
+rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id, void *user_cb);
 
 /**
  * Remove a TX packet callback from a given port and queue.
@@ -2993,8 +2991,8 @@ int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id,
  *   - -EINVAL:  The port_id or the queue_id is out of range, or the callback
  *               is NULL or not found for the port/queue.
  */
-int rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id,
-		struct rte_eth_rxtx_callback *user_cb);
+int
+rte_eth_remove_tx_callback(uint16_t port_id, uint16_t queue_id, void *user_cb);
 
 /**
  * Retrieve information about given port's RX queue.
-- 
2.14.3



More information about the dev mailing list