[dpdk-dev,v3,2/6] ethdev: return named opaque type instead of void pointer

Message ID 20180117215802.90809-2-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Ferruh Yigit Jan. 17, 2018, 9:57 p.m. UTC
  "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.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2:
* keep using struct * in parameters, instead add callback functions
return struct rte_eth_rxtx_callback pointer.
---
 lib/librte_ether/rte_ethdev.c | 6 +++---
 lib/librte_ether/rte_ethdev.h | 9 ++++++---
 2 files changed, 9 insertions(+), 6 deletions(-)
  

Comments

Thomas Monjalon Jan. 17, 2018, 10:11 p.m. UTC | #1
17/01/2018 22:57, Ferruh Yigit:
> "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.

It is an API change.
Let's plan it for 18.05.
  
Ferruh Yigit Jan. 18, 2018, 10:09 a.m. UTC | #2
On 1/17/2018 10:11 PM, Thomas Monjalon wrote:
> 17/01/2018 22:57, Ferruh Yigit:
>> "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.
> 
> It is an API change.
> Let's plan it for 18.05.

No issue for pushing this to next release, but not sure if this API change
effects end user.

"struct rte_eth_rxtx_callback" is private data structure, previously how user
should be using it can be:

a)
void *cb;
cb = rte_eth_add_rx_callback(..);
rte_eth_remove_rx_callback(.., cb);

b)
struct rte_eth_rxtx_callback *cb;
cb = rte_eth_add_rx_callback(..);
rte_eth_remove_rx_callback(.., cb);


And same a) or b) can be used without any side effect with updated API.
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 779853d02..b3d01dcb4 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3160,7 +3160,7 @@  rte_eth_dev_filter_ctrl(uint16_t port_id, enum rte_filter_type filter_type,
 	return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);
 }
 
-void *
+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)
 {
@@ -3202,7 +3202,7 @@  rte_eth_add_rx_callback(uint16_t port_id, uint16_t queue_id,
 	return cb;
 }
 
-void *
+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)
 {
@@ -3237,7 +3237,7 @@  rte_eth_add_first_rx_callback(uint16_t port_id, uint16_t queue_id,
 	return cb;
 }
 
-void *
+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)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index e4927029d..e45806933 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -4080,7 +4080,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,
+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);
 
 /**
@@ -4108,7 +4109,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,
+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);
 
 /**
@@ -4135,7 +4137,8 @@  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,
+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);
 
 /**