From: Ferruh Yigit Date: Tue, 20 Mar 2018 16:34:04 +0000 (+0000) Subject: ethdev: return named opaque type instead of void pointer X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=03d8f4710030645c138d8b0f74f5168db6954df9;p=dpdk.git ethdev: return named opaque type instead of void pointer "struct rte_eth_rxtx_callback" is defined as internal data structure and used as named opaque type. So the functions that are adding callbacks can return objects in this type instead of void pointer. Also const qualifier added to "struct rte_eth_rxtx_callback *" to protect it better from application modification. Signed-off-by: Ferruh Yigit Acked-by: Neil Horman --- diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index ad54de721b..0c696f7439 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -142,13 +142,6 @@ Deprecation Notices successful. This modification will only impact the PMDs, not the applications. -* ethdev: functions add rx/tx callback will return named opaque type - ``rte_eth_add_rx_callback()``, ``rte_eth_add_first_rx_callback()`` and - ``rte_eth_add_tx_callback()`` functions currently return callback object as - ``void \*`` but APIs to delete callbacks get ``struct rte_eth_rxtx_callback \*`` - as parameter. For consistency functions adding callback will return - ``struct rte_eth_rxtx_callback \*`` instead of ``void \*``. - * i40e: The default flexible payload configuration which extracts the first 16 bytes of the payload for RSS will be deprecated starting from 18.02. If required the previous behavior can be configured using existing flow diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 2f458cd8f3..aa7b4d51fb 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3493,7 +3493,7 @@ rte_eth_dev_filter_ctrl(uint16_t port_id, enum rte_filter_type filter_type, filter_op, arg)); } -void * +const struct rte_eth_rxtx_callback * rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id, rte_rx_callback_fn fn, void *user_param) { @@ -3535,7 +3535,7 @@ rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id, return cb; } -void * +const struct rte_eth_rxtx_callback * rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id, rte_rx_callback_fn fn, void *user_param) { @@ -3570,7 +3570,7 @@ rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id, return cb; } -void * +const struct rte_eth_rxtx_callback * rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id, rte_tx_callback_fn fn, void *user_param) { @@ -3615,7 +3615,7 @@ 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) + const struct rte_eth_rxtx_callback *user_cb) { #ifndef RTE_ETHDEV_RXTX_CALLBACKS return -ENOTSUP; @@ -3649,7 +3649,7 @@ 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) + const struct rte_eth_rxtx_callback *user_cb) { #ifndef RTE_ETHDEV_RXTX_CALLBACKS return -ENOTSUP; diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 1b127da1a2..5e13dca6ab 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -3002,6 +3002,8 @@ int rte_eth_dev_filter_ctrl(uint16_t port_id, enum rte_filter_type filter_type, int rte_eth_dev_get_dcb_info(uint16_t port_id, struct rte_eth_dcb_info *dcb_info); +struct rte_eth_rxtx_callback; + /** * Add a callback to be called on packet RX on a given port and queue. * @@ -3026,7 +3028,8 @@ int rte_eth_dev_get_dcb_info(uint16_t port_id, * NULL on error. * On success, a pointer value which can later be used to remove the callback. */ -void *rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id, +const struct rte_eth_rxtx_callback * +rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id, rte_rx_callback_fn fn, void *user_param); /** @@ -3054,7 +3057,8 @@ void *rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id, * NULL on error. * On success, a pointer value which can later be used to remove the callback. */ -void *rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id, +const struct rte_eth_rxtx_callback * +rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id, rte_rx_callback_fn fn, void *user_param); /** @@ -3081,11 +3085,10 @@ void *rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id, * NULL on error. * On success, a pointer value which can later be used to remove the callback. */ -void *rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id, +const struct rte_eth_rxtx_callback * +rte_eth_add_tx_callback(uint16_t port_id, uint16_t queue_id, rte_tx_callback_fn fn, void *user_param); -struct rte_eth_rxtx_callback; - /** * Remove an RX packet callback from a given port and queue. * @@ -3117,7 +3120,7 @@ struct rte_eth_rxtx_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); + const struct rte_eth_rxtx_callback *user_cb); /** * Remove a TX packet callback from a given port and queue. @@ -3150,7 +3153,7 @@ int rte_eth_remove_rx_callback(uint16_t port_id, uint16_t queue_id, * 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); + const struct rte_eth_rxtx_callback *user_cb); /** * Retrieve information about given port's RX queue. diff --git a/lib/librte_latencystats/rte_latencystats.c b/lib/librte_latencystats/rte_latencystats.c index 66330203c7..fc94976591 100644 --- a/lib/librte_latencystats/rte_latencystats.c +++ b/lib/librte_latencystats/rte_latencystats.c @@ -46,7 +46,7 @@ struct rte_latency_stats { static struct rte_latency_stats *glob_stats; struct rxtx_cbs { - struct rte_eth_rxtx_callback *cb; + const struct rte_eth_rxtx_callback *cb; }; static struct rxtx_cbs rx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT]; diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c index ec8a5d84cf..4fb0b42046 100644 --- a/lib/librte_pdump/rte_pdump.c +++ b/lib/librte_pdump/rte_pdump.c @@ -75,7 +75,7 @@ struct pdump_response { static struct pdump_rxtx_cbs { struct rte_ring *ring; struct rte_mempool *mp; - struct rte_eth_rxtx_callback *cb; + const struct rte_eth_rxtx_callback *cb; void *filter; } rx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT], tx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT];