Skip to contentSkip to conversation

ethdev: add notifications for probing and removal

PATCH In review Thomas Monjalon 4 participants 25 messages Nov 28, 2017 – Jan 10, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethdev: add notifications for probing and removal

When a PMD finishes probing, it creates the new port by calling the function rte_eth_dev_allocate().
A notification of the new port is sent there to the upper layer.

When a PMD finishes removal of a port, it calls the function rte_eth_dev_release_port().
A notification of the destroyed port is sent there to the upper layer.

---

This patch depends on:
- ethdev: remove useless parameter in callback process
- ethdev: free a port by a dedicated API

---
 lib/librte_ether/rte_ethdev.c | 5 +++++
 lib/librte_ether/rte_ethdev.h | 2 ++
 2 files changed, 7 insertions(+)
lib/librte_ether/rte_ethdev.c +5 -0
index c196c3692..517e6546f 100644
@@ -238,6 +238,8 @@ rte_eth_dev_allocate(const char *name)
 	eth_dev->data->port_id = port_id;
 	eth_dev->data->mtu = ETHER_MTU;
 
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_NEW, NULL);
+
 	return eth_dev;
 }
 
@@ -279,6 +281,9 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 		return -EINVAL;
 
 	eth_dev->state = RTE_ETH_DEV_UNUSED;
+
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
+
 	return 0;
 }
 
lib/librte_ether/rte_ethdev.h +2 -0
index 15309aa7c..6986ee2a0 100644
@@ -3526,6 +3526,8 @@ enum rte_eth_event_type {
 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
+	RTE_ETH_EVENT_NEW,      /**< port is probed */
+	RTE_ETH_EVENT_DESTROY,  /**< port is released */
 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
 };
 
Signature · 1 line
2.15.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Thomas Monjalon

When a PMD finishes probing, it creates the new port by calling the function rte_eth_dev_allocate().
A notification of the new port is sent there to the upper layer.

When a PMD finishes removal of a port, it calls the function rte_eth_dev_release_port().
A notification of the destroyed port is sent there to the upper layer.

Quoted 5 lines

---

This patch depends on:
- ethdev: remove useless parameter in callback process
- ethdev: free a port by a dedicated API

What do you think pulling that patch from port ownership patchset, which is still under discussion, to this one? Is it required for port ownership one?

#2 lore raw

22/12/2017 04:17, Ferruh Yigit:

Quoted 13 lines · Thomas Monjalon
Quoted 9 lines

When a PMD finishes probing, it creates the new port by calling the function rte_eth_dev_allocate().
A notification of the new port is sent there to the upper layer.

When a PMD finishes removal of a port, it calls the function rte_eth_dev_release_port().
A notification of the destroyed port is sent there to the upper layer.

Quoted 8 lines
Quoted 5 lines

---

This patch depends on:
- ethdev: remove useless parameter in callback process
- ethdev: free a port by a dedicated API

What do you think pulling that patch from port ownership patchset, which is still under discussion, to this one? Is it required for port ownership one?

It can be used with port ownership, but they are two separate things.

#3 lore raw

v2 cover ethdev port notifications

In reply to Thomas Monjalon

This patchset aims to add notifications for ethdev ports added or removed.
It will be especially useful for hotplug.

The first patches were sent individually by Matan, and now grouped in a consistent patchset v2.

Note: this patchset depends on
"ethdev: remove useless parameter in callback process"

Matan Azrad (2):
ethdev: allow event registration for all ports
ethdev: free detached port by the dedicated function

Thomas Monjalon (1):
ethdev: add notifications for probing and removal

 lib/librte_ether/rte_ethdev.c | 128 +++++++++++++++++++++++++++++-------------
 lib/librte_ether/rte_ethdev.h |  10 +++-
 2 files changed, 96 insertions(+), 42 deletions(-)
Signature · 1 line
2.15.1
#4 lore raw

PATCH v2 1/3 ethdev: allow event registration for all ports

From: Matan Azrad <[email protected]>

Add option to register event callback for all ports by one call to rte_eth_dev_callback_register using port_id=RTE_ETH_ALL.

In this case the callback is also registered to invalid ports.

---
v2:
- moved callback lists constructor
- changed ports variables from 32 to 16 bits
- changed doxygen comment

---
 lib/librte_ether/rte_ethdev.c | 121 ++++++++++++++++++++++++++++--------------
 lib/librte_ether/rte_ethdev.h |   8 ++-
 2 files changed, 88 insertions(+), 41 deletions(-)
lib/librte_ether/rte_ethdev.c +82 -39
index c196c3692..5323d445d 100644
@@ -204,7 +204,6 @@ eth_dev_get(uint16_t port_id)
 
 	eth_dev->data = &rte_eth_dev_data[port_id];
 	eth_dev->state = RTE_ETH_DEV_ATTACHED;
-	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
 	eth_dev_last_created_port = port_id;
 
@@ -2820,6 +2819,14 @@ rte_eth_mirror_rule_reset(uint16_t port_id, uint8_t rule_id)
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
 
+RTE_INIT(eth_dev_init_cb_lists)
+{
+	int i;
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		TAILQ_INIT(&rte_eth_devices[i].link_intr_cbs);
+}
+
 int
 rte_eth_dev_callback_register(uint16_t port_id,
 			enum rte_eth_event_type event,
@@ -2827,37 +2834,59 @@ rte_eth_dev_callback_register(uint16_t port_id,
 {
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_callback *user_cb;
+	uint16_t next_port;
+	uint16_t last_port;
 
 	if (!cb_fn)
 		return -EINVAL;
 
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
+		RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+		return -EINVAL;
+	}
+
+	if (port_id == RTE_ETH_ALL) {
+		next_port = 0;
+		last_port = RTE_MAX_ETHPORTS - 1;
+	} else {
+		next_port = last_port = port_id;
+	}
 
-	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
 
-	TAILQ_FOREACH(user_cb, &(dev->link_intr_cbs), next) {
-		if (user_cb->cb_fn == cb_fn &&
-			user_cb->cb_arg == cb_arg &&
-			user_cb->event == event) {
-			break;
+	do {
+		dev = &rte_eth_devices[next_port];
+
+		TAILQ_FOREACH(user_cb, &(dev->link_intr_cbs), next) {
+			if (user_cb->cb_fn == cb_fn &&
+				user_cb->cb_arg == cb_arg &&
+				user_cb->event == event) {
+				break;
+			}
 		}
-	}
 
-	/* create a new callback. */
-	if (user_cb == NULL) {
-		user_cb = rte_zmalloc("INTR_USER_CALLBACK",
-					sizeof(struct rte_eth_dev_callback), 0);
-		if (user_cb != NULL) {
-			user_cb->cb_fn = cb_fn;
-			user_cb->cb_arg = cb_arg;
-			user_cb->event = event;
-			TAILQ_INSERT_TAIL(&(dev->link_intr_cbs), user_cb, next);
+		/* create a new callback. */
+		if (user_cb == NULL) {
+			user_cb = rte_zmalloc("INTR_USER_CALLBACK",
+				sizeof(struct rte_eth_dev_callback), 0);
+			if (user_cb != NULL) {
+				user_cb->cb_fn = cb_fn;
+				user_cb->cb_arg = cb_arg;
+				user_cb->event = event;
+				TAILQ_INSERT_TAIL(&(dev->link_intr_cbs),
+						  user_cb, next);
+			} else {
+				rte_spinlock_unlock(&rte_eth_dev_cb_lock);
+				rte_eth_dev_callback_unregister(port_id, event,
+								cb_fn, cb_arg);
+				return -ENOMEM;
+			}
+
 		}
-	}
+	} while (++next_port <= last_port);
 
 	rte_spinlock_unlock(&rte_eth_dev_cb_lock);
-	return (user_cb == NULL) ? -ENOMEM : 0;
+	return 0;
 }
 
 int
@@ -2868,36 +2897,50 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
 	int ret;
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_callback *cb, *next;
+	uint16_t next_port;
+	uint16_t last_port;
 
 	if (!cb_fn)
 		return -EINVAL;
 
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
+		RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+		return -EINVAL;
+	}
+
+	if (port_id == RTE_ETH_ALL) {
+		next_port = 0;
+		last_port = RTE_MAX_ETHPORTS - 1;
+	} else {
+		next_port = last_port = port_id;
+	}
 
-	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
 
-	ret = 0;
-	for (cb = TAILQ_FIRST(&dev->link_intr_cbs); cb != NULL; cb = next) {
+	do {
+		dev = &rte_eth_devices[next_port];
+		ret = 0;
+		for (cb = TAILQ_FIRST(&dev->link_intr_cbs); cb != NULL;
+		     cb = next) {
 
-		next = TAILQ_NEXT(cb, next);
+			next = TAILQ_NEXT(cb, next);
 
-		if (cb->cb_fn != cb_fn || cb->event != event ||
-				(cb->cb_arg != (void *)-1 &&
-				cb->cb_arg != cb_arg))
-			continue;
+			if (cb->cb_fn != cb_fn || cb->event != event ||
+			    (cb->cb_arg != (void *)-1 && cb->cb_arg != cb_arg))
+				continue;
 
-		/*
-		 * if this callback is not executing right now,
-		 * then remove it.
-		 */
-		if (cb->active == 0) {
-			TAILQ_REMOVE(&(dev->link_intr_cbs), cb, next);
-			rte_free(cb);
-		} else {
-			ret = -EAGAIN;
+			/*
+			 * if this callback is not executing right now,
+			 * then remove it.
+			 */
+			if (cb->active == 0) {
+				TAILQ_REMOVE(&(dev->link_intr_cbs), cb, next);
+				rte_free(cb);
+			} else {
+				ret = -EAGAIN;
+			}
 		}
-	}
+	} while (++next_port <= last_port);
 
 	rte_spinlock_unlock(&rte_eth_dev_cb_lock);
 	return ret;
lib/librte_ether/rte_ethdev.h +6 -2
index 15309aa7c..c92508cfd 100644
@@ -1137,6 +1137,8 @@ struct rte_eth_dcb_info {
 
 struct rte_eth_dev;
 
+#define RTE_ETH_ALL RTE_MAX_ETHPORTS
+
 struct rte_eth_dev_callback;
 /** @internal Structure to keep track of registered callbacks */
 TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
@@ -3536,10 +3538,11 @@ typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
 
 
 /**
- * Register a callback function for specific port id.
+ * Register a callback function for port event.
  *
  * @param port_id
  *  Port id.
+ *  RTE_ETH_ALL means register the event for all port ids.
  * @param event
  *  Event interested.
  * @param cb_fn
@@ -3556,10 +3559,11 @@ int rte_eth_dev_callback_register(uint16_t port_id,
 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
 
 /**
- * Unregister a callback function for specific port id.
+ * Unregister a callback function for port event.
  *
  * @param port_id
  *  Port id.
+ *  RTE_ETH_ALL means unregister the event for all port ids.
  * @param event
  *  Event interested.
  * @param cb_fn
Signature · 1 line
2.15.1
#5 lore raw

PATCH v2 2/3 ethdev: free detached port by the dedicated function

In reply to Thomas Monjalon

From: Matan Azrad <[email protected]>

In the port detach function, use the function to free an ethdev port instead of changing its state directly.

---
v2: no change, just grouped in a patchset

---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 5323d445d..f40627fa3 100644
@@ -436,7 +436,7 @@ rte_eth_dev_detach(uint16_t port_id, char *name)
 	if (ret < 0)
 		goto err;
 
-	rte_eth_devices[port_id].state = RTE_ETH_DEV_UNUSED;
+	rte_eth_dev_release_port(&rte_eth_devices[port_id]);
 	return 0;
 
 err:
Signature · 1 line
2.15.1
#6 lore raw

PATCH v2 3/3 ethdev: add notifications for probing and removal

In reply to Thomas Monjalon

When a PMD finishes probing, it creates the new port by calling the function rte_eth_dev_allocate().
A notification of the new port is sent there to the upper layer.

When a PMD finishes removal of a port, it calls the function rte_eth_dev_release_port().
A notification of the destroyed port is sent there to the upper layer.

---
v2: no change

---
 lib/librte_ether/rte_ethdev.c | 5 +++++
 lib/librte_ether/rte_ethdev.h | 2 ++
 2 files changed, 7 insertions(+)
lib/librte_ether/rte_ethdev.c +5 -0
index f40627fa3..436066889 100644
@@ -237,6 +237,8 @@ rte_eth_dev_allocate(const char *name)
 	eth_dev->data->port_id = port_id;
 	eth_dev->data->mtu = ETHER_MTU;
 
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_NEW, NULL);
+
 	return eth_dev;
 }
 
@@ -278,6 +280,9 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 		return -EINVAL;
 
 	eth_dev->state = RTE_ETH_DEV_UNUSED;
+
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
+
 	return 0;
 }
 
lib/librte_ether/rte_ethdev.h +2 -0
index c92508cfd..11f97e709 100644
@@ -3528,6 +3528,8 @@ enum rte_eth_event_type {
 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
+	RTE_ETH_EVENT_NEW,      /**< port is probed */
+	RTE_ETH_EVENT_DESTROY,  /**< port is released */
 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
 };
 
Signature · 1 line
2.15.1
#7 lore raw

v3 cover ethdev port notifications

In reply to Thomas Monjalon

This patchset aims to add notifications for ethdev ports added or removed.
It will be especially useful for hotplug.

This v3 is gathering more related patches which were sent individually (callback process cleanup and testpmd additions).

Matan Azrad (3):
ethdev: allow event registration for all ports
ethdev: free detached port by the dedicated function app/testpmd: extend event printing

Thomas Monjalon (2):
ethdev: remove useless parameter in callback process
ethdev: add notifications for probing and removal

 app/test-pmd/parameters.c               |   4 +
 app/test-pmd/testpmd.c                  |  30 ++++----
 doc/guides/prog_guide/poll_mode_drv.rst |   4 +-
 doc/guides/testpmd_app_ug/run_app.rst   |   4 +-
 drivers/net/bnxt/rte_pmd_bnxt.c         |   2 +-
 drivers/net/bonding/rte_eth_bond_pmd.c  |   6 +-
 drivers/net/dpaa2/dpaa2_ethdev.c        |   2 +-
 drivers/net/e1000/em_ethdev.c           |   2 +-
 drivers/net/e1000/igb_ethdev.c          |   4 +-
 drivers/net/enic/enic_main.c            |   2 +-
 drivers/net/failsafe/failsafe_ether.c   |   2 +-
 drivers/net/fm10k/fm10k_ethdev.c        |   8 +-
 drivers/net/i40e/i40e_ethdev.c          |   2 +-
 drivers/net/i40e/i40e_ethdev_vf.c       |   2 +-
 drivers/net/i40e/i40e_pf.c              |   3 +-
 drivers/net/ixgbe/ixgbe_ethdev.c        |   6 +-
 drivers/net/ixgbe/ixgbe_pf.c            |   4 +-
 drivers/net/mlx4/mlx4_intr.c            |   4 +-
 drivers/net/mlx5/mlx5_ethdev.c          |   9 +--
 drivers/net/nfp/nfp_net.c               |   2 +-
 drivers/net/sfc/sfc_intr.c              |   4 +-
 drivers/net/thunderx/nicvf_ethdev.c     |   2 +-
 drivers/net/vhost/rte_eth_vhost.c       |   9 +--
 drivers/net/virtio/virtio_ethdev.c      |   2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |   2 +-
 lib/librte_ether/rte_ethdev.c           | 132 +++++++++++++++++++++-----------
 lib/librte_ether/rte_ethdev.h           |  14 ++--
 test/test/virtual_pmd.c                 |   2 +-
 28 files changed, 159 insertions(+), 110 deletions(-)
Signature · 1 line
2.15.1
#8 lore raw

PATCH v3 1/5 ethdev: remove useless parameter in callback process

The pointer to the user parameter of the callback registration is automatically pass to the callback function.
There is no point to allow changing this user parameter by a caller. That's why this parameter is always set to NULL by PMDs and set only in ethdev layer before calling the callback function.

The history is that the user parameter was initially used
by the callback implementation to pass some information
between the application and the driver:
c1ceaf3ad056 ("ethdev: add an argument to internal callback function")
Then a new parameter has been added to leave the user parameter to its standard usage of context given at registration:
d6af1a13d7a1 ("ethdev: add return values to callback process API")

The NULL parameter in the internal callback processing function is now removed. It makes clear that the callback parameter is user managed and opaque from a DPDK point of view.

---
v2: add history
v3: no change

---
 doc/guides/prog_guide/poll_mode_drv.rst | 4 ++--
 drivers/net/bnxt/rte_pmd_bnxt.c         | 2 +-
 drivers/net/bonding/rte_eth_bond_pmd.c  | 6 +++---
 drivers/net/dpaa2/dpaa2_ethdev.c        | 2 +-
 drivers/net/e1000/em_ethdev.c           | 2 +-
 drivers/net/e1000/igb_ethdev.c          | 4 ++--
 drivers/net/enic/enic_main.c            | 2 +-
 drivers/net/failsafe/failsafe_ether.c   | 2 +-
 drivers/net/fm10k/fm10k_ethdev.c        | 8 ++++----
 drivers/net/i40e/i40e_ethdev.c          | 2 +-
 drivers/net/i40e/i40e_ethdev_vf.c       | 2 +-
 drivers/net/i40e/i40e_pf.c              | 3 +--
 drivers/net/ixgbe/ixgbe_ethdev.c        | 6 +++---
 drivers/net/ixgbe/ixgbe_pf.c            | 4 ++--
 drivers/net/mlx4/mlx4_intr.c            | 4 ++--
 drivers/net/mlx5/mlx5_ethdev.c          | 9 +++------
 drivers/net/nfp/nfp_net.c               | 2 +-
 drivers/net/sfc/sfc_intr.c              | 4 ++--
 drivers/net/thunderx/nicvf_ethdev.c     | 2 +-
 drivers/net/vhost/rte_eth_vhost.c       | 9 +++------
 drivers/net/virtio/virtio_ethdev.c      | 2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    | 2 +-
 lib/librte_ether/rte_ethdev.c           | 4 +---
 lib/librte_ether/rte_ethdev.h           | 4 +---
 test/test/virtual_pmd.c                 | 2 +-
 25 files changed, 41 insertions(+), 52 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +2 -2
index 6a0c9f992..d1d4b1cb7 100644
@@ -581,8 +581,8 @@ thread safety all these operations should be called from the same thread.
 For example when PF is reset, the PF sends a message to notify VFs of
 this event and also trigger an interrupt to VFs. Then in the interrupt
 service routine the VFs detects this notification message and calls
-_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL,
-NULL). This means that a PF reset triggers an RTE_ETH_EVENT_INTR_RESET
+_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL).
+This means that a PF reset triggers an RTE_ETH_EVENT_INTR_RESET
 event within VFs. The function _rte_eth_dev_callback_process() will
 call the registered callback function. The callback function can trigger
 the application to handle all operations the VF reset requires including
drivers/net/bnxt/rte_pmd_bnxt.c +1 -1
index a31340742..e86e670dc 100644
@@ -57,7 +57,7 @@ int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg)
 	ret_param.msg = msg;
 
 	_rte_eth_dev_callback_process(bp->eth_dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+				      &ret_param);
 
 	/* Default to approve */
 	if (ret_param.retval == RTE_PMD_BNXT_MB_EVENT_PROCEED)
drivers/net/bonding/rte_eth_bond_pmd.c +3 -3
index fe2328954..68952c4c0 100644
@@ -2476,7 +2476,7 @@ bond_ethdev_delayed_lsc_propagation(void *arg)
 		return;
 
 	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
-			RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+			RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 int
@@ -2584,7 +2584,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 			else
 				_rte_eth_dev_callback_process(bonded_eth_dev,
 						RTE_ETH_EVENT_INTR_LSC,
-						NULL, NULL);
+						NULL);
 
 		} else {
 			if (internals->link_down_delay_ms > 0)
@@ -2594,7 +2594,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 			else
 				_rte_eth_dev_callback_process(bonded_eth_dev,
 						RTE_ETH_EVENT_INTR_LSC,
-						NULL, NULL);
+						NULL);
 		}
 	}
 	return 0;
drivers/net/dpaa2/dpaa2_ethdev.c +1 -1
index 202f84f0a..b302bbb7b 100644
@@ -655,7 +655,7 @@ dpaa2_interrupt_handler(void *param)
 		dpaa2_dev_link_update(dev, 0);
 		/* calling all the apps registered for link status event */
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 out:
 	ret = dpni_clear_irq_status(dpni, CMD_PRI_LOW, priv->token,
drivers/net/e1000/em_ethdev.c +1 -1
index a0c3b4dc5..d9fafca8c 100644
@@ -1678,7 +1678,7 @@ eth_em_interrupt_handler(void *param)
 
 	eth_em_interrupt_get_status(dev);
 	eth_em_interrupt_action(dev, dev->intr_handle);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 static int
drivers/net/e1000/igb_ethdev.c +2 -2
index fdc139f35..ad4c0865a 100644
@@ -2916,7 +2916,7 @@ eth_igb_interrupt_action(struct rte_eth_dev *dev,
 		E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 		E1000_WRITE_FLUSH(hw);
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
 	return 0;
@@ -2976,7 +2976,7 @@ void igbvf_mbx_process(struct rte_eth_dev *dev)
 	/* PF reset VF event */
 	if (in_msg == E1000_PF_CONTROL_MSG)
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 }
 
 static int
drivers/net/enic/enic_main.c +1 -1
index 8af0ccd3c..a9509f068 100644
@@ -434,7 +434,7 @@ enic_intr_handler(void *arg)
 	vnic_intr_return_all_credits(&enic->intr);
 
 	enic_link_update(enic);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 	enic_log_q_error(enic);
 }
 
drivers/net/failsafe/failsafe_ether.c +1 -1
index 21392e5a7..8a4cacf4a 100644
@@ -480,7 +480,7 @@ failsafe_eth_lsc_event_callback(uint16_t port_id __rte_unused,
 	if (ret)
 		return _rte_eth_dev_callback_process(dev,
 						     RTE_ETH_EVENT_INTR_LSC,
-						     NULL, NULL);
+						     NULL);
 	else
 		return 0;
 }
drivers/net/fm10k/fm10k_ethdev.c +4 -4
index 2d05a4669..3cd30b854 100644
@@ -2625,7 +2625,7 @@ fm10k_dev_interrupt_handler_pf(void *param)
 			dev_info->sm_down = 0;
 			_rte_eth_dev_callback_process(dev,
 					RTE_ETH_EVENT_INTR_LSC,
-					NULL, NULL);
+					NULL);
 		}
 	}
 
@@ -2638,7 +2638,7 @@ fm10k_dev_interrupt_handler_pf(void *param)
 		PMD_INIT_LOG(INFO, "INT: Switch is down");
 		dev_info->sm_down = 1;
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
 	/* Handle SRAM error */
@@ -2706,7 +2706,7 @@ fm10k_dev_interrupt_handler_vf(void *param)
 		/* Setting reset flag */
 		dev_info->sm_down = 1;
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
 	if (dev_info->sm_down == 1 &&
@@ -2735,7 +2735,7 @@ fm10k_dev_interrupt_handler_vf(void *param)
 
 		dev_info->sm_down = 0;
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
 	/* Re-enable interrupt from device side */
drivers/net/i40e/i40e_ethdev.c +1 -1
index 811cc9ffe..0fe6eeacc 100644
@@ -5996,7 +5996,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
 			ret = i40e_dev_link_update(dev, 0);
 			if (!ret)
 				_rte_eth_dev_callback_process(dev,
-					RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+					RTE_ETH_EVENT_INTR_LSC, NULL);
 			break;
 		default:
 			PMD_DRV_LOG(DEBUG, "Request %u is not supported yet",
drivers/net/i40e/i40e_ethdev_vf.c +1 -1
index 91b5bb033..74473d267 100644
@@ -1308,7 +1308,7 @@ i40evf_handle_pf_event(struct rte_eth_dev *dev, uint8_t *msg,
 	case VIRTCHNL_EVENT_RESET_IMPENDING:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 		break;
 	case VIRTCHNL_EVENT_LINK_CHANGE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
drivers/net/i40e/i40e_pf.c +1 -2
index 94bb0cfd1..322396368 100644
@@ -1185,8 +1185,7 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 	 * do nothing and send not_supported to VF. As PF must send a response
 	 * to VF and ACK/NACK is not defined.
 	 */
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX, &ret_param);
 	if (ret_param.retval != RTE_PMD_I40E_MB_EVENT_PROCEED) {
 		PMD_DRV_LOG(WARNING, "VF to PF message(%d) is not permitted!",
 			    opcode);
drivers/net/ixgbe/ixgbe_ethdev.c +3 -3
index ff19a564a..6dbda9c7d 100644
@@ -4383,12 +4383,12 @@ ixgbe_dev_interrupt_delayed_handler(void *param)
 		intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
 		ixgbe_dev_link_status_print(dev);
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
 	if (intr->flags & IXGBE_FLAG_MACSEC) {
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
-					      NULL, NULL);
+					      NULL);
 		intr->flags &= ~IXGBE_FLAG_MACSEC;
 	}
 
@@ -8171,7 +8171,7 @@ static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
 	/* PF reset VF event */
 	if (in_msg == IXGBE_PF_CONTROL_MSG)
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 }
 
 static int
drivers/net/ixgbe/ixgbe_pf.c +2 -2
index 676e92c7b..e18ec8660 100644
@@ -768,7 +768,7 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
 
 		/* notify application about VF reset */
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-					      NULL, &ret_param);
+					      &ret_param);
 		return ret;
 	}
 
@@ -780,7 +780,7 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
 	 * if ret_param.retval > 1, do nothing and send NAK to VF
 	 */
 	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+				      &ret_param);
 
 	retval = ret_param.retval;
 
drivers/net/mlx4/mlx4_intr.c +2 -2
index 50d197698..9becee4a8 100644
@@ -154,7 +154,7 @@ mlx4_link_status_alarm(struct priv *priv)
 	if (intr_conf->lsc && !mlx4_link_status_check(priv))
 		_rte_eth_dev_callback_process(priv->dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 }
 
 /**
@@ -236,7 +236,7 @@ mlx4_interrupt_handler(struct priv *priv)
 	for (i = 0; i != RTE_DIM(caught); ++i)
 		if (caught[i])
 			_rte_eth_dev_callback_process(priv->dev, type[i],
-						      NULL, NULL);
+						      NULL);
 }
 
 /**
drivers/net/mlx5/mlx5_ethdev.c +3 -6
index a3cef6891..62474ab1c 100644
@@ -1230,8 +1230,7 @@ mlx5_dev_link_status_handler(void *arg)
 	ret = priv_link_status_update(priv);
 	priv_unlock(priv);
 	if (!ret)
-		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 /**
@@ -1253,11 +1252,9 @@ mlx5_dev_interrupt_handler(void *cb_arg)
 	events = priv_dev_status_handler(priv);
 	priv_unlock(priv);
 	if (events & (1 << RTE_ETH_EVENT_INTR_LSC))
-		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 	if (events & (1 << RTE_ETH_EVENT_INTR_RMV))
-		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RMV, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RMV, NULL);
 }
 
 /**
drivers/net/nfp/nfp_net.c +1 -1
index 0501156ba..99b6aa65e 100644
@@ -1450,7 +1450,7 @@ nfp_net_dev_interrupt_delayed_handler(void *param)
 	struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
 
 	nfp_net_link_update(dev, 0);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 
 	nfp_net_dev_link_status_print(dev);
 
drivers/net/sfc/sfc_intr.c +2 -2
index ee59cb1c0..aa324c4b6 100644
@@ -112,7 +112,7 @@ sfc_intr_line_handler(void *cb_arg)
 			 "UP" : "DOWN");
 		_rte_eth_dev_callback_process(sa->eth_dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 }
 
@@ -154,7 +154,7 @@ sfc_intr_message_handler(void *cb_arg)
 		sfc_info(sa, "link status change event");
 		_rte_eth_dev_callback_process(sa->eth_dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 }
 
drivers/net/thunderx/nicvf_ethdev.c +1 -1
index d65d3cee7..5cead831b 100644
@@ -113,7 +113,7 @@ nicvf_interrupt(void *arg)
 		if (dev->data->dev_conf.intr_conf.lsc)
 			nicvf_set_eth_link_status(nic, &dev->data->dev_link);
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
 	rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
drivers/net/vhost/rte_eth_vhost.c +3 -6
index 2536ee4a2..014428580 100644
@@ -609,8 +609,7 @@ new_device(int vid)
 
 	RTE_LOG(INFO, PMD, "New connection established\n");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 
 	return 0;
 }
@@ -664,8 +663,7 @@ destroy_device(int vid)
 
 	RTE_LOG(INFO, PMD, "Connection closed\n");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 static int
@@ -694,8 +692,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
 	RTE_LOG(INFO, PMD, "vring%u is %s\n",
 			vring, enable ? "enabled" : "disabled");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE, NULL);
 
 	return 0;
 }
drivers/net/virtio/virtio_ethdev.c +1 -1
index e0328f61d..4290d59a5 100644
@@ -1266,7 +1266,7 @@ virtio_interrupt_handler(void *param)
 		if (virtio_dev_link_update(dev, 0) == 0)
 			_rte_eth_dev_callback_process(dev,
 						      RTE_ETH_EVENT_INTR_LSC,
-						      NULL, NULL);
+						      NULL);
 	}
 
 }
drivers/net/vmxnet3/vmxnet3_ethdev.c +1 -1
index 82d59ca8c..54b688f2f 100644
@@ -1332,7 +1332,7 @@ vmxnet3_process_events(struct rte_eth_dev *dev)
 		if (vmxnet3_dev_link_update(dev, 0) == 0)
 			_rte_eth_dev_callback_process(dev,
 						      RTE_ETH_EVENT_INTR_LSC,
-						      NULL, NULL);
+						      NULL);
 	}
 
 	/* Check if there is an error on xmit/recv queues */
lib/librte_ether/rte_ethdev.c +1 -3
index 318af2869..c196c3692 100644
@@ -2905,7 +2905,7 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
 
 int
 _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
-	enum rte_eth_event_type event, void *cb_arg, void *ret_param)
+	enum rte_eth_event_type event, void *ret_param)
 {
 	struct rte_eth_dev_callback *cb_lst;
 	struct rte_eth_dev_callback dev_cb;
@@ -2917,8 +2917,6 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
 			continue;
 		dev_cb = *cb_lst;
 		cb_lst->active = 1;
-		if (cb_arg != NULL)
-			dev_cb.cb_arg = cb_arg;
 		if (ret_param != NULL)
 			dev_cb.ret_param = ret_param;
 
lib/librte_ether/rte_ethdev.h +1 -3
index 341c2d624..15309aa7c 100644
@@ -3585,8 +3585,6 @@ int rte_eth_dev_callback_unregister(uint16_t port_id,
  *  Pointer to struct rte_eth_dev.
  * @param event
  *  Eth device interrupt event type.
- * @param cb_arg
- *  callback parameter.
  * @param ret_param
  *  To pass data back to user application.
  *  This allows the user application to decide if a particular function
@@ -3596,7 +3594,7 @@ int rte_eth_dev_callback_unregister(uint16_t port_id,
  *  int
  */
 int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
-		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
+		enum rte_eth_event_type event, void *ret_param);
 
 /**
  * When there is no rx packet coming in Rx Queue for a long time, we can
test/test/virtual_pmd.c +1 -1
index b57a9493b..f55288537 100644
@@ -489,7 +489,7 @@ virtual_ethdev_simulate_link_status_interrupt(uint16_t port_id,
 	vrtl_eth_dev->data->dev_link.link_status = link_status;
 
 	_rte_eth_dev_callback_process(vrtl_eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+				      NULL);
 }
 
 int
Signature · 1 line
2.15.1
#12 lore raw

PATCH v3 2/5 ethdev: allow event registration for all ports

In reply to Thomas Monjalon

From: Matan Azrad <[email protected]>

Add option to register event callback for all ports by one call to rte_eth_dev_callback_register using port_id=RTE_ETH_ALL.

In this case the callback is also registered to invalid ports.

---
v2:
- moved callback lists constructor
- changed ports variables from 32 to 16 bits
- changed doxygen comment
v3: no change

---
 lib/librte_ether/rte_ethdev.c | 121 ++++++++++++++++++++++++++++--------------
 lib/librte_ether/rte_ethdev.h |   8 ++-
 2 files changed, 88 insertions(+), 41 deletions(-)
lib/librte_ether/rte_ethdev.c +82 -39
index c196c3692..5323d445d 100644
@@ -204,7 +204,6 @@ eth_dev_get(uint16_t port_id)
 
 	eth_dev->data = &rte_eth_dev_data[port_id];
 	eth_dev->state = RTE_ETH_DEV_ATTACHED;
-	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
 	eth_dev_last_created_port = port_id;
 
@@ -2820,6 +2819,14 @@ rte_eth_mirror_rule_reset(uint16_t port_id, uint8_t rule_id)
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
 
+RTE_INIT(eth_dev_init_cb_lists)
+{
+	int i;
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		TAILQ_INIT(&rte_eth_devices[i].link_intr_cbs);
+}
+
 int
 rte_eth_dev_callback_register(uint16_t port_id,
 			enum rte_eth_event_type event,
@@ -2827,37 +2834,59 @@ rte_eth_dev_callback_register(uint16_t port_id,
 {
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_callback *user_cb;
+	uint16_t next_port;
+	uint16_t last_port;
 
 	if (!cb_fn)
 		return -EINVAL;
 
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
+		RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+		return -EINVAL;
+	}
+
+	if (port_id == RTE_ETH_ALL) {
+		next_port = 0;
+		last_port = RTE_MAX_ETHPORTS - 1;
+	} else {
+		next_port = last_port = port_id;
+	}
 
-	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
 
-	TAILQ_FOREACH(user_cb, &(dev->link_intr_cbs), next) {
-		if (user_cb->cb_fn == cb_fn &&
-			user_cb->cb_arg == cb_arg &&
-			user_cb->event == event) {
-			break;
+	do {
+		dev = &rte_eth_devices[next_port];
+
+		TAILQ_FOREACH(user_cb, &(dev->link_intr_cbs), next) {
+			if (user_cb->cb_fn == cb_fn &&
+				user_cb->cb_arg == cb_arg &&
+				user_cb->event == event) {
+				break;
+			}
 		}
-	}
 
-	/* create a new callback. */
-	if (user_cb == NULL) {
-		user_cb = rte_zmalloc("INTR_USER_CALLBACK",
-					sizeof(struct rte_eth_dev_callback), 0);
-		if (user_cb != NULL) {
-			user_cb->cb_fn = cb_fn;
-			user_cb->cb_arg = cb_arg;
-			user_cb->event = event;
-			TAILQ_INSERT_TAIL(&(dev->link_intr_cbs), user_cb, next);
+		/* create a new callback. */
+		if (user_cb == NULL) {
+			user_cb = rte_zmalloc("INTR_USER_CALLBACK",
+				sizeof(struct rte_eth_dev_callback), 0);
+			if (user_cb != NULL) {
+				user_cb->cb_fn = cb_fn;
+				user_cb->cb_arg = cb_arg;
+				user_cb->event = event;
+				TAILQ_INSERT_TAIL(&(dev->link_intr_cbs),
+						  user_cb, next);
+			} else {
+				rte_spinlock_unlock(&rte_eth_dev_cb_lock);
+				rte_eth_dev_callback_unregister(port_id, event,
+								cb_fn, cb_arg);
+				return -ENOMEM;
+			}
+
 		}
-	}
+	} while (++next_port <= last_port);
 
 	rte_spinlock_unlock(&rte_eth_dev_cb_lock);
-	return (user_cb == NULL) ? -ENOMEM : 0;
+	return 0;
 }
 
 int
@@ -2868,36 +2897,50 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
 	int ret;
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_callback *cb, *next;
+	uint16_t next_port;
+	uint16_t last_port;
 
 	if (!cb_fn)
 		return -EINVAL;
 
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
+		RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+		return -EINVAL;
+	}
+
+	if (port_id == RTE_ETH_ALL) {
+		next_port = 0;
+		last_port = RTE_MAX_ETHPORTS - 1;
+	} else {
+		next_port = last_port = port_id;
+	}
 
-	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
 
-	ret = 0;
-	for (cb = TAILQ_FIRST(&dev->link_intr_cbs); cb != NULL; cb = next) {
+	do {
+		dev = &rte_eth_devices[next_port];
+		ret = 0;
+		for (cb = TAILQ_FIRST(&dev->link_intr_cbs); cb != NULL;
+		     cb = next) {
 
-		next = TAILQ_NEXT(cb, next);
+			next = TAILQ_NEXT(cb, next);
 
-		if (cb->cb_fn != cb_fn || cb->event != event ||
-				(cb->cb_arg != (void *)-1 &&
-				cb->cb_arg != cb_arg))
-			continue;
+			if (cb->cb_fn != cb_fn || cb->event != event ||
+			    (cb->cb_arg != (void *)-1 && cb->cb_arg != cb_arg))
+				continue;
 
-		/*
-		 * if this callback is not executing right now,
-		 * then remove it.
-		 */
-		if (cb->active == 0) {
-			TAILQ_REMOVE(&(dev->link_intr_cbs), cb, next);
-			rte_free(cb);
-		} else {
-			ret = -EAGAIN;
+			/*
+			 * if this callback is not executing right now,
+			 * then remove it.
+			 */
+			if (cb->active == 0) {
+				TAILQ_REMOVE(&(dev->link_intr_cbs), cb, next);
+				rte_free(cb);
+			} else {
+				ret = -EAGAIN;
+			}
 		}
-	}
+	} while (++next_port <= last_port);
 
 	rte_spinlock_unlock(&rte_eth_dev_cb_lock);
 	return ret;
lib/librte_ether/rte_ethdev.h +6 -2
index 15309aa7c..c92508cfd 100644
@@ -1137,6 +1137,8 @@ struct rte_eth_dcb_info {
 
 struct rte_eth_dev;
 
+#define RTE_ETH_ALL RTE_MAX_ETHPORTS
+
 struct rte_eth_dev_callback;
 /** @internal Structure to keep track of registered callbacks */
 TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
@@ -3536,10 +3538,11 @@ typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
 
 
 /**
- * Register a callback function for specific port id.
+ * Register a callback function for port event.
  *
  * @param port_id
  *  Port id.
+ *  RTE_ETH_ALL means register the event for all port ids.
  * @param event
  *  Event interested.
  * @param cb_fn
@@ -3556,10 +3559,11 @@ int rte_eth_dev_callback_register(uint16_t port_id,
 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
 
 /**
- * Unregister a callback function for specific port id.
+ * Unregister a callback function for port event.
  *
  * @param port_id
  *  Port id.
+ *  RTE_ETH_ALL means unregister the event for all port ids.
  * @param event
  *  Event interested.
  * @param cb_fn
Signature · 1 line
2.15.1
#13 lore raw

PATCH v3 3/5 ethdev: free detached port by the dedicated function

In reply to Thomas Monjalon

From: Matan Azrad <[email protected]>

In the port detach function, use the function to free an ethdev port instead of changing its state directly.

---
v2: no change
v3: no change

---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 5323d445d..f40627fa3 100644
@@ -436,7 +436,7 @@ rte_eth_dev_detach(uint16_t port_id, char *name)
 	if (ret < 0)
 		goto err;
 
-	rte_eth_devices[port_id].state = RTE_ETH_DEV_UNUSED;
+	rte_eth_dev_release_port(&rte_eth_devices[port_id]);
 	return 0;
 
 err:
Signature · 1 line
2.15.1
#14 lore raw

PATCH v3 4/5 ethdev: add notifications for probing and removal

In reply to Thomas Monjalon

When a PMD finishes probing, it creates the new port by calling the function rte_eth_dev_allocate().
A notification of the new port is sent there to the upper layer.

When a PMD finishes removal of a port, it calls the function rte_eth_dev_release_port().
A notification of the destroyed port is sent there to the upper layer.

---
v2: no change
v3: no change

---
 lib/librte_ether/rte_ethdev.c | 5 +++++
 lib/librte_ether/rte_ethdev.h | 2 ++
 2 files changed, 7 insertions(+)
lib/librte_ether/rte_ethdev.c +5 -0
index f40627fa3..436066889 100644
@@ -237,6 +237,8 @@ rte_eth_dev_allocate(const char *name)
 	eth_dev->data->port_id = port_id;
 	eth_dev->data->mtu = ETHER_MTU;
 
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_NEW, NULL);
+
 	return eth_dev;
 }
 
@@ -278,6 +280,9 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 		return -EINVAL;
 
 	eth_dev->state = RTE_ETH_DEV_UNUSED;
+
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
+
 	return 0;
 }
 
lib/librte_ether/rte_ethdev.h +2 -0
index c92508cfd..11f97e709 100644
@@ -3528,6 +3528,8 @@ enum rte_eth_event_type {
 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
+	RTE_ETH_EVENT_NEW,      /**< port is probed */
+	RTE_ETH_EVENT_DESTROY,  /**< port is released */
 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
 };
 
Signature · 1 line
2.15.1
#15 lore raw

PATCH v3 5/5 app/testpmd: extend event printing

In reply to Thomas Monjalon

From: Matan Azrad <[email protected]>

There are new Ethernet device events - NEW and DESTROY, and new option to register all ports by one call.

Adjust application to aforementioned changes.

---
v3: no change

---
 app/test-pmd/parameters.c             |  4 ++++
 app/test-pmd/testpmd.c                | 30 ++++++++++++++++--------------
 doc/guides/testpmd_app_ug/run_app.rst |  4 ++--
 3 files changed, 22 insertions(+), 16 deletions(-)
app/test-pmd/parameters.c +4 -0
index 84e7a63ef..796d1a5b6 100644
@@ -546,6 +546,10 @@ parse_event_printing_config(const char *optarg, int enable)
 		mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
 	else if (!strcmp(optarg, "intr_rmv"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
+	else if (!strcmp(optarg, "dev_probed"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_NEW;
+	else if (!strcmp(optarg, "dev_released"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_DESTROY;
 	else if (!strcmp(optarg, "all"))
 		mask = ~UINT32_C(0);
 	else {
app/test-pmd/testpmd.c +16 -14
index c3ab44849..26576eb76 100644
@@ -1568,20 +1568,6 @@ start_port(portid_t pid)
 			}
 		}
 
-		for (event_type = RTE_ETH_EVENT_UNKNOWN;
-		     event_type < RTE_ETH_EVENT_MAX;
-		     event_type++) {
-			diag = rte_eth_dev_callback_register(pi,
-							event_type,
-							eth_event_callback,
-							NULL);
-			if (diag) {
-				printf("Failed to setup even callback for event %d\n",
-					event_type);
-				return -1;
-			}
-		}
-
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
@@ -1608,6 +1594,20 @@ start_port(portid_t pid)
 		need_check_link_status = 1;
 	}
 
+	for (event_type = RTE_ETH_EVENT_UNKNOWN;
+	     event_type < RTE_ETH_EVENT_MAX;
+	     event_type++) {
+		diag = rte_eth_dev_callback_register(RTE_ETH_ALL,
+						event_type,
+						eth_event_callback,
+						NULL);
+		if (diag) {
+			printf("Failed to setup even callback for event %d\n",
+				event_type);
+			return -1;
+		}
+	}
+
 	if (need_check_link_status == 1 && !no_link_check)
 		check_all_ports_link_status(RTE_PORT_ALL);
 	else if (need_check_link_status == 0)
@@ -1930,6 +1930,8 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,
 		[RTE_ETH_EVENT_VF_MBOX] = "VF Mbox",
 		[RTE_ETH_EVENT_MACSEC] = "MACsec",
 		[RTE_ETH_EVENT_INTR_RMV] = "device removal",
+		[RTE_ETH_EVENT_NEW] = "device probed",
+		[RTE_ETH_EVENT_DESTROY] = "device released",
 		[RTE_ETH_EVENT_MAX] = NULL,
 	};
 
doc/guides/testpmd_app_ug/run_app.rst +2 -2
index 4c0d2cede..377b07651 100644
@@ -492,12 +492,12 @@ The commandline options are:
 
     Set the logical core N to perform bitrate calculation.
 
-*   ``--print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>``
+*   ``--print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|dev_probed|dev_released|all>``
 
     Enable printing the occurrence of the designated event. Using all will
     enable all of them.
 
-*   ``--mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>``
+*   ``--mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|dev_probed|dev_released|all>``
 
     Disable printing the occurrence of the designated event. Using all will
     disable all of them.
Signature · 1 line
2.15.1
#9 lore raw

Re: [PATCH v3 1/5] ethdev: remove useless parameter in callback process

In reply to Thomas Monjalon

Hi Thomas,

Quoted 581 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Friday, December 29, 2017 1:37 PM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>
Subject: [dpdk-dev] [PATCH v3 1/5] ethdev: remove useless parameter in callback process

The pointer to the user parameter of the callback registration is automatically pass to the callback function.
There is no point to allow changing this user parameter by a caller. That's why this parameter is always set to NULL by PMDs and set only in ethdev layer before calling the callback function.

The history is that the user parameter was initially used by the callback implementation to pass some information between the application and the driver:
c1ceaf3ad056 ("ethdev: add an argument to internal callback function")
Then a new parameter has been added to leave the user parameter to its standard usage of context given at registration:
d6af1a13d7a1 ("ethdev: add return values to callback process API")

The NULL parameter in the internal callback processing function is now removed. It makes clear that the callback parameter is user managed and opaque from a DPDK point of view.

---
v2: add history
v3: no change

---
 doc/guides/prog_guide/poll_mode_drv.rst | 4 ++--
 drivers/net/bnxt/rte_pmd_bnxt.c         | 2 +-
 drivers/net/bonding/rte_eth_bond_pmd.c  | 6 +++---
 drivers/net/dpaa2/dpaa2_ethdev.c        | 2 +-
 drivers/net/e1000/em_ethdev.c           | 2 +-
 drivers/net/e1000/igb_ethdev.c          | 4 ++--
 drivers/net/enic/enic_main.c            | 2 +-
 drivers/net/failsafe/failsafe_ether.c   | 2 +-
 drivers/net/fm10k/fm10k_ethdev.c        | 8 ++++----
 drivers/net/i40e/i40e_ethdev.c          | 2 +-
 drivers/net/i40e/i40e_ethdev_vf.c       | 2 +-
 drivers/net/i40e/i40e_pf.c              | 3 +--
 drivers/net/ixgbe/ixgbe_ethdev.c        | 6 +++---
 drivers/net/ixgbe/ixgbe_pf.c            | 4 ++--
 drivers/net/mlx4/mlx4_intr.c            | 4 ++--
 drivers/net/mlx5/mlx5_ethdev.c          | 9 +++------
 drivers/net/nfp/nfp_net.c               | 2 +-
 drivers/net/sfc/sfc_intr.c              | 4 ++--
 drivers/net/thunderx/nicvf_ethdev.c     | 2 +-
 drivers/net/vhost/rte_eth_vhost.c       | 9 +++------
 drivers/net/virtio/virtio_ethdev.c      | 2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    | 2 +-
 lib/librte_ether/rte_ethdev.c           | 4 +---
 lib/librte_ether/rte_ethdev.h           | 4 +---
 test/test/virtual_pmd.c                 | 2 +-
 25 files changed, 41 insertions(+), 52 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +0 -0
index 6a0c9f992..d1d4b1cb7 100644
@@ -581,8 +581,8 @@ thread safety all these operations should be called from

the same thread.
For example when PF is reset, the PF sends a message to notify VFs of this
event and also trigger an interrupt to VFs. Then in the interrupt service routine the VFs detects this notification message and calls - _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL, - NULL). This means that a PF reset triggers an RTE_ETH_EVENT_INTR_RESET

doc/guides/prog_guide/poll_mode_drv.rst +2 -0
+_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL).
+This means that a PF reset triggers an RTE_ETH_EVENT_INTR_RESET
 event within VFs. The function _rte_eth_dev_callback_process() will  call the

registered callback function. The callback function can trigger the application to handle all operations the VF reset requires including diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c index a31340742..e86e670dc 100644

drivers/net/bnxt/rte_pmd_bnxt.c +1 -1
@@ -57,7 +57,7 @@ int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id,
 void *msg)
 	ret_param.msg = msg;
 
 	_rte_eth_dev_callback_process(bp->eth_dev,
 RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+				      &ret_param);
 
drivers/net/bnxt/rte_pmd_bnxt.c +0 -0
 	/* Default to approve */
 	if (ret_param.retval == RTE_PMD_BNXT_MB_EVENT_PROCEED) diff --

git a/drivers/net/bonding/rte_eth_bond_pmd.c
b/drivers/net/bonding/rte_eth_bond_pmd.c
index fe2328954..68952c4c0 100644

drivers/net/bonding/rte_eth_bond_pmd.c +2 -2
@@ -2476,7 +2476,7 @@ bond_ethdev_delayed_lsc_propagation(void *arg)
 		return;
 
 	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
-			RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+			RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 int
@@ -2584,7 +2584,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id,
 enum rte_eth_event_type type,
 			else
 
 	_rte_eth_dev_callback_process(bonded_eth_dev,
 						RTE_ETH_EVENT_INTR_LSC,
-						NULL, NULL);
+						NULL);
 
drivers/net/bonding/rte_eth_bond_pmd.c +1 -0
 		} else {
 			if (internals->link_down_delay_ms > 0) @@ -2594,7
+2594,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum

rte_eth_event_type type,
else

_rte_eth_dev_callback_process(bonded_eth_dev,

drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
 						RTE_ETH_EVENT_INTR_LSC,
-						NULL, NULL);
+						NULL);
 		}
 	}
 	return 0;
drivers/net/dpaa2/dpaa2_ethdev.c +1 -1
index 202f84f0a..b302bbb7b 100644
@@ -655,7 +655,7 @@ dpaa2_interrupt_handler(void *param)
 		dpaa2_dev_link_update(dev, 0);
 		/* calling all the apps registered for link status event */
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 out:

ret = dpni_clear_irq_status(dpni, CMD_PRI_LOW, priv->token, diff --git
a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index a0c3b4dc5..d9fafca8c 100644

drivers/net/e1000/em_ethdev.c +1 -1
@@ -1678,7 +1678,7 @@ eth_em_interrupt_handler(void *param)
 
 	eth_em_interrupt_get_status(dev);
 	eth_em_interrupt_action(dev, dev->intr_handle);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
 }

static int

drivers/net/e1000/igb_ethdev.c +1 -1
index fdc139f35..ad4c0865a 100644
@@ -2916,7 +2916,7 @@ eth_igb_interrupt_action(struct rte_eth_dev *dev,
 		E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 		E1000_WRITE_FLUSH(hw);
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
drivers/net/e1000/igb_ethdev.c +1 -1
 	return 0;
@@ -2976,7 +2976,7 @@ void igbvf_mbx_process(struct rte_eth_dev *dev)
 	/* PF reset VF event */
 	if (in_msg == E1000_PF_CONTROL_MSG)
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 }
 

static int

drivers/net/enic/enic_main.c index renamed from drivers/net/enic/enic_main.c +0 -0

8af0ccd3c..a9509f068 100644

drivers/net/enic/enic_main.c +1 -1
@@ -434,7 +434,7 @@ enic_intr_handler(void *arg)
 	vnic_intr_return_all_credits(&enic->intr);
 
 	enic_link_update(enic);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
 	enic_log_q_error(enic);

}

drivers/net/failsafe/failsafe_ether.c +1 -1
index 21392e5a7..8a4cacf4a 100644
@@ -480,7 +480,7 @@ failsafe_eth_lsc_event_callback(uint16_t port_id
 __rte_unused,
 	if (ret)
 		return _rte_eth_dev_callback_process(dev,
 
 RTE_ETH_EVENT_INTR_LSC,
-						     NULL, NULL);
+						     NULL);
 	else
drivers/net/failsafe/failsafe_ether.c +0 -0
 		return 0;
 }
drivers/net/fm10k/fm10k_ethdev.c +2 -2
index 2d05a4669..3cd30b854 100644
@@ -2625,7 +2625,7 @@ fm10k_dev_interrupt_handler_pf(void *param)
 			dev_info->sm_down = 0;
 			_rte_eth_dev_callback_process(dev,
 					RTE_ETH_EVENT_INTR_LSC,
-					NULL, NULL);
+					NULL);
 		}
 	}
 
@@ -2638,7 +2638,7 @@ fm10k_dev_interrupt_handler_pf(void *param)
 		PMD_INIT_LOG(INFO, "INT: Switch is down");
 		dev_info->sm_down = 1;
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
drivers/net/fm10k/fm10k_ethdev.c +1 -1
 	/* Handle SRAM error */
@@ -2706,7 +2706,7 @@ fm10k_dev_interrupt_handler_vf(void *param)
 		/* Setting reset flag */
 		dev_info->sm_down = 1;
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
drivers/net/fm10k/fm10k_ethdev.c +1 -1
 	if (dev_info->sm_down == 1 &&
@@ -2735,7 +2735,7 @@ fm10k_dev_interrupt_handler_vf(void *param)
 
 		dev_info->sm_down = 0;
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 

/* Re-enable interrupt from device side */ diff --git
a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 811cc9ffe..0fe6eeacc 100644

drivers/net/i40e/i40e_ethdev.c +1 -1
@@ -5996,7 +5996,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
 			ret = i40e_dev_link_update(dev, 0);
 			if (!ret)
 				_rte_eth_dev_callback_process(dev,
-					RTE_ETH_EVENT_INTR_LSC, NULL,
 NULL);
+					RTE_ETH_EVENT_INTR_LSC, NULL);
 			break;
 		default:

PMD_DRV_LOG(DEBUG, "Request %u is not supported
yet", diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 91b5bb033..74473d267 100644

drivers/net/i40e/i40e_ethdev_vf.c +1 -1
@@ -1308,7 +1308,7 @@ i40evf_handle_pf_event(struct rte_eth_dev *dev,
 uint8_t *msg,
 	case VIRTCHNL_EVENT_RESET_IMPENDING:
 		PMD_DRV_LOG(DEBUG,
 "VIRTCHNL_EVENT_RESET_IMPENDING event");
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
drivers/net/i40e/i40e_ethdev_vf.c +0 -0
 		break;
 	case VIRTCHNL_EVENT_LINK_CHANGE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE

event"); diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index 94bb0cfd1..322396368 100644

drivers/net/i40e/i40e_pf.c +1 -2
@@ -1185,8 +1185,7 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev
 *dev,
 	 * do nothing and send not_supported to VF. As PF must send a response
 	 * to VF and ACK/NACK is not defined.
 	 */
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
 &ret_param);
 	if (ret_param.retval != RTE_PMD_I40E_MB_EVENT_PROCEED) {

PMD_DRV_LOG(WARNING, "VF to PF message(%d) is not
permitted!",

drivers/net/i40e/i40e_pf.c +0 -0
 			    opcode);
drivers/net/ixgbe/ixgbe_ethdev.c +2 -2
index ff19a564a..6dbda9c7d 100644
@@ -4383,12 +4383,12 @@ ixgbe_dev_interrupt_delayed_handler(void
 *param)
 		intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
 		ixgbe_dev_link_status_print(dev);
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
 	if (intr->flags & IXGBE_FLAG_MACSEC) {
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_MACSEC,
-					      NULL, NULL);
+					      NULL);
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
 		intr->flags &= ~IXGBE_FLAG_MACSEC;
 	}
@@ -8171,7 +8171,7 @@ static void ixgbevf_mbx_process(struct rte_eth_dev
 *dev)
 	/* PF reset VF event */
 	if (in_msg == IXGBE_PF_CONTROL_MSG)
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 }

static int

drivers/net/ixgbe/ixgbe_pf.c index renamed from drivers/net/ixgbe/ixgbe_pf.c +0 -0

676e92c7b..e18ec8660 100644

drivers/net/ixgbe/ixgbe_pf.c +1 -1
@@ -768,7 +768,7 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev,
 uint16_t vf)
 
 		/* notify application about VF reset */
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_VF_MBOX,
-					      NULL, &ret_param);
+					      &ret_param);
 		return ret;
drivers/net/ixgbe/ixgbe_pf.c +1 -1
 	}
@@ -780,7 +780,7 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev,
 uint16_t vf)
 	 * if ret_param.retval > 1, do nothing and send NAK to VF
 	 */
 	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+				      &ret_param);
 
 	retval = ret_param.retval;
drivers/net/mlx4/mlx4_intr.c index renamed from drivers/net/mlx4/mlx4_intr.c +0 -0

50d197698..9becee4a8 100644

drivers/net/mlx4/mlx4_intr.c +2 -2
@@ -154,7 +154,7 @@ mlx4_link_status_alarm(struct priv *priv)
 	if (intr_conf->lsc && !mlx4_link_status_check(priv))
 		_rte_eth_dev_callback_process(priv->dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 }
 
 /**
@@ -236,7 +236,7 @@ mlx4_interrupt_handler(struct priv *priv)
 	for (i = 0; i != RTE_DIM(caught); ++i)
 		if (caught[i])
 			_rte_eth_dev_callback_process(priv->dev, type[i],
-						      NULL, NULL);
+						      NULL);
 }
 
 /**
drivers/net/mlx5/mlx5_ethdev.c +1 -2
index a3cef6891..62474ab1c 100644
@@ -1230,8 +1230,7 @@ mlx5_dev_link_status_handler(void *arg)
 	ret = priv_link_status_update(priv);
 	priv_unlock(priv);
 	if (!ret)
-		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC, NULL);
 }

/**

drivers/net/mlx5/mlx5_ethdev.c +2 -4
@@ -1253,11 +1252,9 @@ mlx5_dev_interrupt_handler(void *cb_arg)
 	events = priv_dev_status_handler(priv);
 	priv_unlock(priv);
 	if (events & (1 << RTE_ETH_EVENT_INTR_LSC))
-		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC, NULL);
 	if (events & (1 << RTE_ETH_EVENT_INTR_RMV))
-		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_RMV, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev,

RTE_ETH_EVENT_INTR_RMV, NULL);
}

/**

drivers/net/nfp/nfp_net.c index renamed from drivers/net/nfp/nfp_net.c +0 -0

0501156ba..99b6aa65e 100644

drivers/net/nfp/nfp_net.c +1 -1
@@ -1450,7 +1450,7 @@ nfp_net_dev_interrupt_delayed_handler(void
 *param)
 	struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
 
 	nfp_net_link_update(dev, 0);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
drivers/net/nfp/nfp_net.c +0 -0
 	nfp_net_dev_link_status_print(dev);
drivers/net/sfc/sfc_intr.c index renamed from drivers/net/sfc/sfc_intr.c +0 -0

ee59cb1c0..aa324c4b6 100644

drivers/net/sfc/sfc_intr.c +2 -2
@@ -112,7 +112,7 @@ sfc_intr_line_handler(void *cb_arg)
 			 "UP" : "DOWN");
 		_rte_eth_dev_callback_process(sa->eth_dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 }
 
@@ -154,7 +154,7 @@ sfc_intr_message_handler(void *cb_arg)
 		sfc_info(sa, "link status change event");
 		_rte_eth_dev_callback_process(sa->eth_dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 }
 
drivers/net/thunderx/nicvf_ethdev.c +1 -1
index d65d3cee7..5cead831b 100644
@@ -113,7 +113,7 @@ nicvf_interrupt(void *arg)
 		if (dev->data->dev_conf.intr_conf.lsc)
 			nicvf_set_eth_link_status(nic, &dev->data->dev_link);
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 

rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000, diff --git
a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 2536ee4a2..014428580 100644

drivers/net/vhost/rte_eth_vhost.c +1 -2
@@ -609,8 +609,7 @@ new_device(int vid)
 
 	RTE_LOG(INFO, PMD, "New connection established\n");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
 
 	return 0;

}

drivers/net/vhost/rte_eth_vhost.c +1 -2
@@ -664,8 +663,7 @@ destroy_device(int vid)
 
 	RTE_LOG(INFO, PMD, "Connection closed\n");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
 }
 

static int

drivers/net/vhost/rte_eth_vhost.c +2 -2
@@ -694,8 +692,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
 	RTE_LOG(INFO, PMD, "vring%u is %s\n",
 			vring, enable ? "enabled" : "disabled");
 
-	_rte_eth_dev_callback_process(eth_dev,
 RTE_ETH_EVENT_QUEUE_STATE,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev,
 RTE_ETH_EVENT_QUEUE_STATE,
+NULL);
 
 	return 0;
 }
drivers/net/virtio/virtio_ethdev.c +1 -1
index e0328f61d..4290d59a5 100644
@@ -1266,7 +1266,7 @@ virtio_interrupt_handler(void *param)
 		if (virtio_dev_link_update(dev, 0) == 0)
 			_rte_eth_dev_callback_process(dev,
 
 RTE_ETH_EVENT_INTR_LSC,
-						      NULL, NULL);
+						      NULL);
 	}
 

}

drivers/net/vmxnet3/vmxnet3_ethdev.c +1 -1
index 82d59ca8c..54b688f2f 100644
@@ -1332,7 +1332,7 @@ vmxnet3_process_events(struct rte_eth_dev *dev)
 		if (vmxnet3_dev_link_update(dev, 0) == 0)
 			_rte_eth_dev_callback_process(dev,
 
 RTE_ETH_EVENT_INTR_LSC,
-						      NULL, NULL);
+						      NULL);
 	}
 

/* Check if there is an error on xmit/recv queues */ diff --git
a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 318af2869..c196c3692 100644

lib/librte_ether/rte_ethdev.c +1 -3
@@ -2905,7 +2905,7 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
 
 int
 _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
-	enum rte_eth_event_type event, void *cb_arg, void *ret_param)
+	enum rte_eth_event_type event, void *ret_param)
 {
 	struct rte_eth_dev_callback *cb_lst;
 	struct rte_eth_dev_callback dev_cb;
@@ -2917,8 +2917,6 @@ _rte_eth_dev_callback_process(struct rte_eth_dev
 *dev,
 			continue;
 		dev_cb = *cb_lst;
 		cb_lst->active = 1;
-		if (cb_arg != NULL)
-			dev_cb.cb_arg = cb_arg;
 		if (ret_param != NULL)
 			dev_cb.ret_param = ret_param;
lib/librte_ether/rte_ethdev.h index renamed from lib/librte_ether/rte_ethdev.h +0 -0

341c2d624..15309aa7c 100644

lib/librte_ether/rte_ethdev.h +1 -3
@@ -3585,8 +3585,6 @@ int rte_eth_dev_callback_unregister(uint16_t port_id,
  *  Pointer to struct rte_eth_dev.
  * @param event
  *  Eth device interrupt event type.
- * @param cb_arg
- *  callback parameter.
  * @param ret_param
  *  To pass data back to user application.
  *  This allows the user application to decide if a particular function @@ -3596,7
+3594,7 @@ int rte_eth_dev_callback_unregister(uint16_t port_id,
  *  int
  */
 int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
-		enum rte_eth_event_type event, void *cb_arg, void

*ret_param);

lib/librte_ether/rte_ethdev.h int rte_eth_dev_callback_unregister(uint16_t port_id, · line 3597

Quoted 1 line
lib/librte_ether/rte_ethdev.h +1 -0
+		enum rte_eth_event_type event, void *ret_param);

As this is a change to the public API of librte_ether is a deprecation notice needed ? This API is currently used by the test/test/virtual_pmd.c APP and may be used by other APP's in the field.

Quoted 16 lines

/**
* When there is no rx packet coming in Rx Queue for a long time, we can diff --
git a/test/test/virtual_pmd.c b/test/test/virtual_pmd.c index b57a9493b..f55288537 100644

test/test/virtual_pmd.c +1 -1
@@ -489,7 +489,7 @@ virtual_ethdev_simulate_link_status_interrupt(uint16_t
 port_id,
 	vrtl_eth_dev->data->dev_link.link_status = link_status;
 
 	_rte_eth_dev_callback_process(vrtl_eth_dev,
 RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+				      NULL);
 }
Quoted 3 lines

int
--
2.15.1

Regards,

Bernard

#10 lore raw

Re: [PATCH v3 1/5] ethdev: remove useless parameter in callback process

Quoted 579 lines · Bernard

Hi Thomas,

Quoted 577 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Friday, December 29, 2017 1:37 PM
To: [email protected]
Cc: Yigit, Ferruh <[email protected]>
Subject: [dpdk-dev] [PATCH v3 1/5] ethdev: remove useless parameter in callback process

The pointer to the user parameter of the callback registration is automatically pass to the callback function.
There is no point to allow changing this user parameter by a caller. That's why this parameter is always set to NULL by PMDs and set only in ethdev layer before calling the callback function.

The history is that the user parameter was initially used by the callback implementation to pass some information between the application and the driver:
c1ceaf3ad056 ("ethdev: add an argument to internal callback function")
Then a new parameter has been added to leave the user parameter to its standard usage of context given at registration:
d6af1a13d7a1 ("ethdev: add return values to callback process API")

The NULL parameter in the internal callback processing function is now removed. It makes clear that the callback parameter is user managed and opaque from a DPDK point of view.

---
v2: add history
v3: no change

---
 doc/guides/prog_guide/poll_mode_drv.rst | 4 ++--
 drivers/net/bnxt/rte_pmd_bnxt.c         | 2 +-
 drivers/net/bonding/rte_eth_bond_pmd.c  | 6 +++---
 drivers/net/dpaa2/dpaa2_ethdev.c        | 2 +-
 drivers/net/e1000/em_ethdev.c           | 2 +-
 drivers/net/e1000/igb_ethdev.c          | 4 ++--
 drivers/net/enic/enic_main.c            | 2 +-
 drivers/net/failsafe/failsafe_ether.c   | 2 +-
 drivers/net/fm10k/fm10k_ethdev.c        | 8 ++++----
 drivers/net/i40e/i40e_ethdev.c          | 2 +-
 drivers/net/i40e/i40e_ethdev_vf.c       | 2 +-
 drivers/net/i40e/i40e_pf.c              | 3 +--
 drivers/net/ixgbe/ixgbe_ethdev.c        | 6 +++---
 drivers/net/ixgbe/ixgbe_pf.c            | 4 ++--
 drivers/net/mlx4/mlx4_intr.c            | 4 ++--
 drivers/net/mlx5/mlx5_ethdev.c          | 9 +++------
 drivers/net/nfp/nfp_net.c               | 2 +-
 drivers/net/sfc/sfc_intr.c              | 4 ++--
 drivers/net/thunderx/nicvf_ethdev.c     | 2 +-
 drivers/net/vhost/rte_eth_vhost.c       | 9 +++------
 drivers/net/virtio/virtio_ethdev.c      | 2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    | 2 +-
 lib/librte_ether/rte_ethdev.c           | 4 +---
 lib/librte_ether/rte_ethdev.h           | 4 +---
 test/test/virtual_pmd.c                 | 2 +-
 25 files changed, 41 insertions(+), 52 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +0 -0
index 6a0c9f992..d1d4b1cb7 100644
@@ -581,8 +581,8 @@ thread safety all these operations should be called from

the same thread.
For example when PF is reset, the PF sends a message to notify VFs of this
event and also trigger an interrupt to VFs. Then in the interrupt service routine the VFs detects this notification message and calls - _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL, - NULL). This means that a PF reset triggers an RTE_ETH_EVENT_INTR_RESET

doc/guides/prog_guide/poll_mode_drv.rst +2 -0
+_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL).
+This means that a PF reset triggers an RTE_ETH_EVENT_INTR_RESET
 event within VFs. The function _rte_eth_dev_callback_process() will  call the

registered callback function. The callback function can trigger the application to handle all operations the VF reset requires including diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c index a31340742..e86e670dc 100644

drivers/net/bnxt/rte_pmd_bnxt.c +1 -1
@@ -57,7 +57,7 @@ int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id,
 void *msg)
 	ret_param.msg = msg;
 
 	_rte_eth_dev_callback_process(bp->eth_dev,
 RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+				      &ret_param);
 
drivers/net/bnxt/rte_pmd_bnxt.c +0 -0
 	/* Default to approve */
 	if (ret_param.retval == RTE_PMD_BNXT_MB_EVENT_PROCEED) diff --

git a/drivers/net/bonding/rte_eth_bond_pmd.c
b/drivers/net/bonding/rte_eth_bond_pmd.c
index fe2328954..68952c4c0 100644

drivers/net/bonding/rte_eth_bond_pmd.c +2 -2
@@ -2476,7 +2476,7 @@ bond_ethdev_delayed_lsc_propagation(void *arg)
 		return;
 
 	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
-			RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+			RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 int
@@ -2584,7 +2584,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id,
 enum rte_eth_event_type type,
 			else
 
 	_rte_eth_dev_callback_process(bonded_eth_dev,
 						RTE_ETH_EVENT_INTR_LSC,
-						NULL, NULL);
+						NULL);
 
drivers/net/bonding/rte_eth_bond_pmd.c +1 -0
 		} else {
 			if (internals->link_down_delay_ms > 0) @@ -2594,7
+2594,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum

rte_eth_event_type type,
else

_rte_eth_dev_callback_process(bonded_eth_dev,

drivers/net/bonding/rte_eth_bond_pmd.c +1 -1
 						RTE_ETH_EVENT_INTR_LSC,
-						NULL, NULL);
+						NULL);
 		}
 	}
 	return 0;
drivers/net/dpaa2/dpaa2_ethdev.c +1 -1
index 202f84f0a..b302bbb7b 100644
@@ -655,7 +655,7 @@ dpaa2_interrupt_handler(void *param)
 		dpaa2_dev_link_update(dev, 0);
 		/* calling all the apps registered for link status event */
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 out:

ret = dpni_clear_irq_status(dpni, CMD_PRI_LOW, priv->token, diff --git
a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index a0c3b4dc5..d9fafca8c 100644

drivers/net/e1000/em_ethdev.c +1 -1
@@ -1678,7 +1678,7 @@ eth_em_interrupt_handler(void *param)
 
 	eth_em_interrupt_get_status(dev);
 	eth_em_interrupt_action(dev, dev->intr_handle);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
 }

static int

drivers/net/e1000/igb_ethdev.c +1 -1
index fdc139f35..ad4c0865a 100644
@@ -2916,7 +2916,7 @@ eth_igb_interrupt_action(struct rte_eth_dev *dev,
 		E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 		E1000_WRITE_FLUSH(hw);
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
drivers/net/e1000/igb_ethdev.c +1 -1
 	return 0;
@@ -2976,7 +2976,7 @@ void igbvf_mbx_process(struct rte_eth_dev *dev)
 	/* PF reset VF event */
 	if (in_msg == E1000_PF_CONTROL_MSG)
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 }
 

static int

drivers/net/enic/enic_main.c index renamed from drivers/net/enic/enic_main.c +0 -0

8af0ccd3c..a9509f068 100644

drivers/net/enic/enic_main.c +1 -1
@@ -434,7 +434,7 @@ enic_intr_handler(void *arg)
 	vnic_intr_return_all_credits(&enic->intr);
 
 	enic_link_update(enic);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
 	enic_log_q_error(enic);

}

drivers/net/failsafe/failsafe_ether.c +1 -1
index 21392e5a7..8a4cacf4a 100644
@@ -480,7 +480,7 @@ failsafe_eth_lsc_event_callback(uint16_t port_id
 __rte_unused,
 	if (ret)
 		return _rte_eth_dev_callback_process(dev,
 
 RTE_ETH_EVENT_INTR_LSC,
-						     NULL, NULL);
+						     NULL);
 	else
drivers/net/failsafe/failsafe_ether.c +0 -0
 		return 0;
 }
drivers/net/fm10k/fm10k_ethdev.c +2 -2
index 2d05a4669..3cd30b854 100644
@@ -2625,7 +2625,7 @@ fm10k_dev_interrupt_handler_pf(void *param)
 			dev_info->sm_down = 0;
 			_rte_eth_dev_callback_process(dev,
 					RTE_ETH_EVENT_INTR_LSC,
-					NULL, NULL);
+					NULL);
 		}
 	}
 
@@ -2638,7 +2638,7 @@ fm10k_dev_interrupt_handler_pf(void *param)
 		PMD_INIT_LOG(INFO, "INT: Switch is down");
 		dev_info->sm_down = 1;
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
drivers/net/fm10k/fm10k_ethdev.c +1 -1
 	/* Handle SRAM error */
@@ -2706,7 +2706,7 @@ fm10k_dev_interrupt_handler_vf(void *param)
 		/* Setting reset flag */
 		dev_info->sm_down = 1;
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
drivers/net/fm10k/fm10k_ethdev.c +1 -1
 	if (dev_info->sm_down == 1 &&
@@ -2735,7 +2735,7 @@ fm10k_dev_interrupt_handler_vf(void *param)
 
 		dev_info->sm_down = 0;
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 

/* Re-enable interrupt from device side */ diff --git
a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 811cc9ffe..0fe6eeacc 100644

drivers/net/i40e/i40e_ethdev.c +1 -1
@@ -5996,7 +5996,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
 			ret = i40e_dev_link_update(dev, 0);
 			if (!ret)
 				_rte_eth_dev_callback_process(dev,
-					RTE_ETH_EVENT_INTR_LSC, NULL,
 NULL);
+					RTE_ETH_EVENT_INTR_LSC, NULL);
 			break;
 		default:

PMD_DRV_LOG(DEBUG, "Request %u is not supported
yet", diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 91b5bb033..74473d267 100644

drivers/net/i40e/i40e_ethdev_vf.c +1 -1
@@ -1308,7 +1308,7 @@ i40evf_handle_pf_event(struct rte_eth_dev *dev,
 uint8_t *msg,
 	case VIRTCHNL_EVENT_RESET_IMPENDING:
 		PMD_DRV_LOG(DEBUG,
 "VIRTCHNL_EVENT_RESET_IMPENDING event");
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
drivers/net/i40e/i40e_ethdev_vf.c +0 -0
 		break;
 	case VIRTCHNL_EVENT_LINK_CHANGE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE

event"); diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index 94bb0cfd1..322396368 100644

drivers/net/i40e/i40e_pf.c +1 -2
@@ -1185,8 +1185,7 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev
 *dev,
 	 * do nothing and send not_supported to VF. As PF must send a response
 	 * to VF and ACK/NACK is not defined.
 	 */
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
 &ret_param);
 	if (ret_param.retval != RTE_PMD_I40E_MB_EVENT_PROCEED) {

PMD_DRV_LOG(WARNING, "VF to PF message(%d) is not
permitted!",

drivers/net/i40e/i40e_pf.c +0 -0
 			    opcode);
drivers/net/ixgbe/ixgbe_ethdev.c +2 -2
index ff19a564a..6dbda9c7d 100644
@@ -4383,12 +4383,12 @@ ixgbe_dev_interrupt_delayed_handler(void
 *param)
 		intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
 		ixgbe_dev_link_status_print(dev);
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
 	if (intr->flags & IXGBE_FLAG_MACSEC) {
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_MACSEC,
-					      NULL, NULL);
+					      NULL);
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
 		intr->flags &= ~IXGBE_FLAG_MACSEC;
 	}
@@ -8171,7 +8171,7 @@ static void ixgbevf_mbx_process(struct rte_eth_dev
 *dev)
 	/* PF reset VF event */
 	if (in_msg == IXGBE_PF_CONTROL_MSG)
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 }

static int

drivers/net/ixgbe/ixgbe_pf.c index renamed from drivers/net/ixgbe/ixgbe_pf.c +0 -0

676e92c7b..e18ec8660 100644

drivers/net/ixgbe/ixgbe_pf.c +1 -1
@@ -768,7 +768,7 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev,
 uint16_t vf)
 
 		/* notify application about VF reset */
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_VF_MBOX,
-					      NULL, &ret_param);
+					      &ret_param);
 		return ret;
drivers/net/ixgbe/ixgbe_pf.c +1 -1
 	}
@@ -780,7 +780,7 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev,
 uint16_t vf)
 	 * if ret_param.retval > 1, do nothing and send NAK to VF
 	 */
 	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+				      &ret_param);
 
 	retval = ret_param.retval;
drivers/net/mlx4/mlx4_intr.c index renamed from drivers/net/mlx4/mlx4_intr.c +0 -0

50d197698..9becee4a8 100644

drivers/net/mlx4/mlx4_intr.c +2 -2
@@ -154,7 +154,7 @@ mlx4_link_status_alarm(struct priv *priv)
 	if (intr_conf->lsc && !mlx4_link_status_check(priv))
 		_rte_eth_dev_callback_process(priv->dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 }
 
 /**
@@ -236,7 +236,7 @@ mlx4_interrupt_handler(struct priv *priv)
 	for (i = 0; i != RTE_DIM(caught); ++i)
 		if (caught[i])
 			_rte_eth_dev_callback_process(priv->dev, type[i],
-						      NULL, NULL);
+						      NULL);
 }
 
 /**
drivers/net/mlx5/mlx5_ethdev.c +1 -2
index a3cef6891..62474ab1c 100644
@@ -1230,8 +1230,7 @@ mlx5_dev_link_status_handler(void *arg)
 	ret = priv_link_status_update(priv);
 	priv_unlock(priv);
 	if (!ret)
-		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC, NULL);
 }

/**

drivers/net/mlx5/mlx5_ethdev.c +2 -4
@@ -1253,11 +1252,9 @@ mlx5_dev_interrupt_handler(void *cb_arg)
 	events = priv_dev_status_handler(priv);
 	priv_unlock(priv);
 	if (events & (1 << RTE_ETH_EVENT_INTR_LSC))
-		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC, NULL);
 	if (events & (1 << RTE_ETH_EVENT_INTR_RMV))
-		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_RMV, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev,

RTE_ETH_EVENT_INTR_RMV, NULL);
}

/**

drivers/net/nfp/nfp_net.c index renamed from drivers/net/nfp/nfp_net.c +0 -0

0501156ba..99b6aa65e 100644

drivers/net/nfp/nfp_net.c +1 -1
@@ -1450,7 +1450,7 @@ nfp_net_dev_interrupt_delayed_handler(void
 *param)
 	struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
 
 	nfp_net_link_update(dev, 0);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
drivers/net/nfp/nfp_net.c +0 -0
 	nfp_net_dev_link_status_print(dev);
drivers/net/sfc/sfc_intr.c index renamed from drivers/net/sfc/sfc_intr.c +0 -0

ee59cb1c0..aa324c4b6 100644

drivers/net/sfc/sfc_intr.c +2 -2
@@ -112,7 +112,7 @@ sfc_intr_line_handler(void *cb_arg)
 			 "UP" : "DOWN");
 		_rte_eth_dev_callback_process(sa->eth_dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 }
 
@@ -154,7 +154,7 @@ sfc_intr_message_handler(void *cb_arg)
 		sfc_info(sa, "link status change event");
 		_rte_eth_dev_callback_process(sa->eth_dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 }
 
drivers/net/thunderx/nicvf_ethdev.c +1 -1
index d65d3cee7..5cead831b 100644
@@ -113,7 +113,7 @@ nicvf_interrupt(void *arg)
 		if (dev->data->dev_conf.intr_conf.lsc)
 			nicvf_set_eth_link_status(nic, &dev->data->dev_link);
 		_rte_eth_dev_callback_process(dev,
 RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 

rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000, diff --git
a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 2536ee4a2..014428580 100644

drivers/net/vhost/rte_eth_vhost.c +1 -2
@@ -609,8 +609,7 @@ new_device(int vid)
 
 	RTE_LOG(INFO, PMD, "New connection established\n");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
 
 	return 0;

}

drivers/net/vhost/rte_eth_vhost.c +1 -2
@@ -664,8 +663,7 @@ destroy_device(int vid)
 
 	RTE_LOG(INFO, PMD, "Connection closed\n");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
 NULL);
 }
 

static int

drivers/net/vhost/rte_eth_vhost.c +2 -2
@@ -694,8 +692,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
 	RTE_LOG(INFO, PMD, "vring%u is %s\n",
 			vring, enable ? "enabled" : "disabled");
 
-	_rte_eth_dev_callback_process(eth_dev,
 RTE_ETH_EVENT_QUEUE_STATE,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev,
 RTE_ETH_EVENT_QUEUE_STATE,
+NULL);
 
 	return 0;
 }
drivers/net/virtio/virtio_ethdev.c +1 -1
index e0328f61d..4290d59a5 100644
@@ -1266,7 +1266,7 @@ virtio_interrupt_handler(void *param)
 		if (virtio_dev_link_update(dev, 0) == 0)
 			_rte_eth_dev_callback_process(dev,
 
 RTE_ETH_EVENT_INTR_LSC,
-						      NULL, NULL);
+						      NULL);
 	}
 

}

drivers/net/vmxnet3/vmxnet3_ethdev.c +1 -1
index 82d59ca8c..54b688f2f 100644
@@ -1332,7 +1332,7 @@ vmxnet3_process_events(struct rte_eth_dev *dev)
 		if (vmxnet3_dev_link_update(dev, 0) == 0)
 			_rte_eth_dev_callback_process(dev,
 
 RTE_ETH_EVENT_INTR_LSC,
-						      NULL, NULL);
+						      NULL);
 	}
 

/* Check if there is an error on xmit/recv queues */ diff --git
a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 318af2869..c196c3692 100644

lib/librte_ether/rte_ethdev.c +1 -3
@@ -2905,7 +2905,7 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
 
 int
 _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
-	enum rte_eth_event_type event, void *cb_arg, void *ret_param)
+	enum rte_eth_event_type event, void *ret_param)
 {
 	struct rte_eth_dev_callback *cb_lst;
 	struct rte_eth_dev_callback dev_cb;
@@ -2917,8 +2917,6 @@ _rte_eth_dev_callback_process(struct rte_eth_dev
 *dev,
 			continue;
 		dev_cb = *cb_lst;
 		cb_lst->active = 1;
-		if (cb_arg != NULL)
-			dev_cb.cb_arg = cb_arg;
 		if (ret_param != NULL)
 			dev_cb.ret_param = ret_param;
lib/librte_ether/rte_ethdev.h index renamed from lib/librte_ether/rte_ethdev.h +0 -0

341c2d624..15309aa7c 100644

lib/librte_ether/rte_ethdev.h +1 -2
@@ -3585,8 +3585,6 @@ int rte_eth_dev_callback_unregister(uint16_t port_id,
  *  Pointer to struct rte_eth_dev.
  * @param event
  *  Eth device interrupt event type.
- * @param cb_arg
- *  callback parameter.
  * @param ret_param
  *  To pass data back to user application.
  *  This allows the user application to decide if a particular function @@ -3596,7
+3594,7 @@ int rte_eth_dev_callback_unregister(uint16_t port_id,
  *  int
Quoted 9 lines

lib/librte_ether/rte_ethdev.h int rte_eth_dev_callback_unregister(uint16_t port_id, · line 3597

Quoted 5 lines

*/
int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,

lib/librte_ether/rte_ethdev.h +0 -1
-		enum rte_eth_event_type event, void *cb_arg, void

*ret_param);

lib/librte_ether/rte_ethdev.h +1 -0
+		enum rte_eth_event_type event, void *ret_param);

As this is a change to the public API of librte_ether is a deprecation notice needed ? This API is currently used by the test/test/virtual_pmd.c APP and may be used by other APP's in the field.

Agreed, it definately should go through the deprecation process

Neil

#11 lore raw

Re: [PATCH v3 1/5] ethdev: remove useless parameter in callback process

02/01/2018 13:21, Neil Horman:

Quoted 9 lines · Bernard
Quoted 7 lines

lib/librte_ether/rte_ethdev.h int rte_eth_dev_callback_unregister(uint16_t port_id, · line 3597

Quoted 3 lines

int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,

lib/librte_ether/rte_ethdev.h +1 -1
-		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
+		enum rte_eth_event_type event, void *ret_param);

As this is a change to the public API of librte_ether is a deprecation notice needed ? This API is currently used by the test/test/virtual_pmd.c APP and may be used by other APP's in the field.

Agreed, it definately should go through the deprecation process

This function is used by drivers only, that's why there is an underscore at the beginning of its name.
So it is not part of the regular ABI and does not need any deprecation notice, in my opinion.

#17 lore raw

PATCH v4 1/5 ethdev: remove useless parameter in callback process

In reply to Thomas Monjalon

The pointer to the user parameter of the callback registration is automatically pass to the callback function.
There is no point to allow changing this user parameter by a caller. That's why this parameter is always set to NULL by PMDs and set only in ethdev layer before calling the callback function.

The history is that the user parameter was initially used
by the callback implementation to pass some information
between the application and the driver:
c1ceaf3ad056 ("ethdev: add an argument to internal callback function")
Then a new parameter has been added to leave the user parameter to its standard usage of context given at registration:
d6af1a13d7a1 ("ethdev: add return values to callback process API")

The NULL parameter in the internal callback processing function is now removed. It makes clear that the callback parameter is user managed and opaque from a DPDK point of view.

---
v2: add history
v3: no change
v4: no change

---
 doc/guides/prog_guide/poll_mode_drv.rst | 4 ++--
 drivers/net/bnxt/rte_pmd_bnxt.c         | 2 +-
 drivers/net/bonding/rte_eth_bond_pmd.c  | 6 +++---
 drivers/net/dpaa2/dpaa2_ethdev.c        | 2 +-
 drivers/net/e1000/em_ethdev.c           | 2 +-
 drivers/net/e1000/igb_ethdev.c          | 4 ++--
 drivers/net/enic/enic_main.c            | 2 +-
 drivers/net/failsafe/failsafe_ether.c   | 2 +-
 drivers/net/fm10k/fm10k_ethdev.c        | 8 ++++----
 drivers/net/i40e/i40e_ethdev.c          | 2 +-
 drivers/net/i40e/i40e_ethdev_vf.c       | 2 +-
 drivers/net/i40e/i40e_pf.c              | 3 +--
 drivers/net/ixgbe/ixgbe_ethdev.c        | 6 +++---
 drivers/net/ixgbe/ixgbe_pf.c            | 4 ++--
 drivers/net/mlx4/mlx4_intr.c            | 4 ++--
 drivers/net/mlx5/mlx5_ethdev.c          | 9 +++------
 drivers/net/nfp/nfp_net.c               | 2 +-
 drivers/net/sfc/sfc_intr.c              | 4 ++--
 drivers/net/thunderx/nicvf_ethdev.c     | 2 +-
 drivers/net/vhost/rte_eth_vhost.c       | 9 +++------
 drivers/net/virtio/virtio_ethdev.c      | 2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    | 2 +-
 lib/librte_ether/rte_ethdev.c           | 4 +---
 lib/librte_ether/rte_ethdev.h           | 4 +---
 test/test/virtual_pmd.c                 | 2 +-
 25 files changed, 41 insertions(+), 52 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +2 -2
index 6a0c9f992..d1d4b1cb7 100644
@@ -581,8 +581,8 @@ thread safety all these operations should be called from the same thread.
 For example when PF is reset, the PF sends a message to notify VFs of
 this event and also trigger an interrupt to VFs. Then in the interrupt
 service routine the VFs detects this notification message and calls
-_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL,
-NULL). This means that a PF reset triggers an RTE_ETH_EVENT_INTR_RESET
+_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL).
+This means that a PF reset triggers an RTE_ETH_EVENT_INTR_RESET
 event within VFs. The function _rte_eth_dev_callback_process() will
 call the registered callback function. The callback function can trigger
 the application to handle all operations the VF reset requires including
drivers/net/bnxt/rte_pmd_bnxt.c +1 -1
index a31340742..e86e670dc 100644
@@ -57,7 +57,7 @@ int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg)
 	ret_param.msg = msg;
 
 	_rte_eth_dev_callback_process(bp->eth_dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+				      &ret_param);
 
 	/* Default to approve */
 	if (ret_param.retval == RTE_PMD_BNXT_MB_EVENT_PROCEED)
drivers/net/bonding/rte_eth_bond_pmd.c +3 -3
index fe2328954..68952c4c0 100644
@@ -2476,7 +2476,7 @@ bond_ethdev_delayed_lsc_propagation(void *arg)
 		return;
 
 	_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
-			RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+			RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 int
@@ -2584,7 +2584,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 			else
 				_rte_eth_dev_callback_process(bonded_eth_dev,
 						RTE_ETH_EVENT_INTR_LSC,
-						NULL, NULL);
+						NULL);
 
 		} else {
 			if (internals->link_down_delay_ms > 0)
@@ -2594,7 +2594,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 			else
 				_rte_eth_dev_callback_process(bonded_eth_dev,
 						RTE_ETH_EVENT_INTR_LSC,
-						NULL, NULL);
+						NULL);
 		}
 	}
 	return 0;
drivers/net/dpaa2/dpaa2_ethdev.c +1 -1
index 202f84f0a..b302bbb7b 100644
@@ -655,7 +655,7 @@ dpaa2_interrupt_handler(void *param)
 		dpaa2_dev_link_update(dev, 0);
 		/* calling all the apps registered for link status event */
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 out:
 	ret = dpni_clear_irq_status(dpni, CMD_PRI_LOW, priv->token,
drivers/net/e1000/em_ethdev.c +1 -1
index a0c3b4dc5..d9fafca8c 100644
@@ -1678,7 +1678,7 @@ eth_em_interrupt_handler(void *param)
 
 	eth_em_interrupt_get_status(dev);
 	eth_em_interrupt_action(dev, dev->intr_handle);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 static int
drivers/net/e1000/igb_ethdev.c +2 -2
index fdc139f35..ad4c0865a 100644
@@ -2916,7 +2916,7 @@ eth_igb_interrupt_action(struct rte_eth_dev *dev,
 		E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 		E1000_WRITE_FLUSH(hw);
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
 	return 0;
@@ -2976,7 +2976,7 @@ void igbvf_mbx_process(struct rte_eth_dev *dev)
 	/* PF reset VF event */
 	if (in_msg == E1000_PF_CONTROL_MSG)
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 }
 
 static int
drivers/net/enic/enic_main.c +1 -1
index 8af0ccd3c..a9509f068 100644
@@ -434,7 +434,7 @@ enic_intr_handler(void *arg)
 	vnic_intr_return_all_credits(&enic->intr);
 
 	enic_link_update(enic);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 	enic_log_q_error(enic);
 }
 
drivers/net/failsafe/failsafe_ether.c +1 -1
index 21392e5a7..8a4cacf4a 100644
@@ -480,7 +480,7 @@ failsafe_eth_lsc_event_callback(uint16_t port_id __rte_unused,
 	if (ret)
 		return _rte_eth_dev_callback_process(dev,
 						     RTE_ETH_EVENT_INTR_LSC,
-						     NULL, NULL);
+						     NULL);
 	else
 		return 0;
 }
drivers/net/fm10k/fm10k_ethdev.c +4 -4
index 2d05a4669..3cd30b854 100644
@@ -2625,7 +2625,7 @@ fm10k_dev_interrupt_handler_pf(void *param)
 			dev_info->sm_down = 0;
 			_rte_eth_dev_callback_process(dev,
 					RTE_ETH_EVENT_INTR_LSC,
-					NULL, NULL);
+					NULL);
 		}
 	}
 
@@ -2638,7 +2638,7 @@ fm10k_dev_interrupt_handler_pf(void *param)
 		PMD_INIT_LOG(INFO, "INT: Switch is down");
 		dev_info->sm_down = 1;
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
 	/* Handle SRAM error */
@@ -2706,7 +2706,7 @@ fm10k_dev_interrupt_handler_vf(void *param)
 		/* Setting reset flag */
 		dev_info->sm_down = 1;
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
 	if (dev_info->sm_down == 1 &&
@@ -2735,7 +2735,7 @@ fm10k_dev_interrupt_handler_vf(void *param)
 
 		dev_info->sm_down = 0;
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-				NULL, NULL);
+				NULL);
 	}
 
 	/* Re-enable interrupt from device side */
drivers/net/i40e/i40e_ethdev.c +1 -1
index 811cc9ffe..0fe6eeacc 100644
@@ -5996,7 +5996,7 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
 			ret = i40e_dev_link_update(dev, 0);
 			if (!ret)
 				_rte_eth_dev_callback_process(dev,
-					RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+					RTE_ETH_EVENT_INTR_LSC, NULL);
 			break;
 		default:
 			PMD_DRV_LOG(DEBUG, "Request %u is not supported yet",
drivers/net/i40e/i40e_ethdev_vf.c +1 -1
index 91b5bb033..74473d267 100644
@@ -1308,7 +1308,7 @@ i40evf_handle_pf_event(struct rte_eth_dev *dev, uint8_t *msg,
 	case VIRTCHNL_EVENT_RESET_IMPENDING:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 		break;
 	case VIRTCHNL_EVENT_LINK_CHANGE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
drivers/net/i40e/i40e_pf.c +1 -2
index 94bb0cfd1..322396368 100644
@@ -1185,8 +1185,7 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 	 * do nothing and send not_supported to VF. As PF must send a response
 	 * to VF and ACK/NACK is not defined.
 	 */
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX, &ret_param);
 	if (ret_param.retval != RTE_PMD_I40E_MB_EVENT_PROCEED) {
 		PMD_DRV_LOG(WARNING, "VF to PF message(%d) is not permitted!",
 			    opcode);
drivers/net/ixgbe/ixgbe_ethdev.c +3 -3
index ff19a564a..6dbda9c7d 100644
@@ -4383,12 +4383,12 @@ ixgbe_dev_interrupt_delayed_handler(void *param)
 		intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
 		ixgbe_dev_link_status_print(dev);
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
 	if (intr->flags & IXGBE_FLAG_MACSEC) {
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
-					      NULL, NULL);
+					      NULL);
 		intr->flags &= ~IXGBE_FLAG_MACSEC;
 	}
 
@@ -8171,7 +8171,7 @@ static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
 	/* PF reset VF event */
 	if (in_msg == IXGBE_PF_CONTROL_MSG)
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
-					      NULL, NULL);
+					      NULL);
 }
 
 static int
drivers/net/ixgbe/ixgbe_pf.c +2 -2
index 676e92c7b..e18ec8660 100644
@@ -768,7 +768,7 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
 
 		/* notify application about VF reset */
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-					      NULL, &ret_param);
+					      &ret_param);
 		return ret;
 	}
 
@@ -780,7 +780,7 @@ ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
 	 * if ret_param.retval > 1, do nothing and send NAK to VF
 	 */
 	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX,
-				      NULL, &ret_param);
+				      &ret_param);
 
 	retval = ret_param.retval;
 
drivers/net/mlx4/mlx4_intr.c +2 -2
index 50d197698..9becee4a8 100644
@@ -154,7 +154,7 @@ mlx4_link_status_alarm(struct priv *priv)
 	if (intr_conf->lsc && !mlx4_link_status_check(priv))
 		_rte_eth_dev_callback_process(priv->dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 }
 
 /**
@@ -236,7 +236,7 @@ mlx4_interrupt_handler(struct priv *priv)
 	for (i = 0; i != RTE_DIM(caught); ++i)
 		if (caught[i])
 			_rte_eth_dev_callback_process(priv->dev, type[i],
-						      NULL, NULL);
+						      NULL);
 }
 
 /**
drivers/net/mlx5/mlx5_ethdev.c +3 -6
index a3cef6891..62474ab1c 100644
@@ -1230,8 +1230,7 @@ mlx5_dev_link_status_handler(void *arg)
 	ret = priv_link_status_update(priv);
 	priv_unlock(priv);
 	if (!ret)
-		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 /**
@@ -1253,11 +1252,9 @@ mlx5_dev_interrupt_handler(void *cb_arg)
 	events = priv_dev_status_handler(priv);
 	priv_unlock(priv);
 	if (events & (1 << RTE_ETH_EVENT_INTR_LSC))
-		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 	if (events & (1 << RTE_ETH_EVENT_INTR_RMV))
-		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RMV, NULL,
-					      NULL);
+		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RMV, NULL);
 }
 
 /**
drivers/net/nfp/nfp_net.c +1 -1
index 0501156ba..99b6aa65e 100644
@@ -1450,7 +1450,7 @@ nfp_net_dev_interrupt_delayed_handler(void *param)
 	struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
 
 	nfp_net_link_update(dev, 0);
-	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, NULL);
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 
 	nfp_net_dev_link_status_print(dev);
 
drivers/net/sfc/sfc_intr.c +2 -2
index ee59cb1c0..aa324c4b6 100644
@@ -112,7 +112,7 @@ sfc_intr_line_handler(void *cb_arg)
 			 "UP" : "DOWN");
 		_rte_eth_dev_callback_process(sa->eth_dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 }
 
@@ -154,7 +154,7 @@ sfc_intr_message_handler(void *cb_arg)
 		sfc_info(sa, "link status change event");
 		_rte_eth_dev_callback_process(sa->eth_dev,
 					      RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 }
 
drivers/net/thunderx/nicvf_ethdev.c +1 -1
index d65d3cee7..5cead831b 100644
@@ -113,7 +113,7 @@ nicvf_interrupt(void *arg)
 		if (dev->data->dev_conf.intr_conf.lsc)
 			nicvf_set_eth_link_status(nic, &dev->data->dev_link);
 		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
-					      NULL, NULL);
+					      NULL);
 	}
 
 	rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
drivers/net/vhost/rte_eth_vhost.c +3 -6
index 2536ee4a2..014428580 100644
@@ -609,8 +609,7 @@ new_device(int vid)
 
 	RTE_LOG(INFO, PMD, "New connection established\n");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 
 	return 0;
 }
@@ -664,8 +663,7 @@ destroy_device(int vid)
 
 	RTE_LOG(INFO, PMD, "Connection closed\n");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 static int
@@ -694,8 +692,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
 	RTE_LOG(INFO, PMD, "vring%u is %s\n",
 			vring, enable ? "enabled" : "disabled");
 
-	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE,
-				      NULL, NULL);
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE, NULL);
 
 	return 0;
 }
drivers/net/virtio/virtio_ethdev.c +1 -1
index e0328f61d..4290d59a5 100644
@@ -1266,7 +1266,7 @@ virtio_interrupt_handler(void *param)
 		if (virtio_dev_link_update(dev, 0) == 0)
 			_rte_eth_dev_callback_process(dev,
 						      RTE_ETH_EVENT_INTR_LSC,
-						      NULL, NULL);
+						      NULL);
 	}
 
 }
drivers/net/vmxnet3/vmxnet3_ethdev.c +1 -1
index 82d59ca8c..54b688f2f 100644
@@ -1332,7 +1332,7 @@ vmxnet3_process_events(struct rte_eth_dev *dev)
 		if (vmxnet3_dev_link_update(dev, 0) == 0)
 			_rte_eth_dev_callback_process(dev,
 						      RTE_ETH_EVENT_INTR_LSC,
-						      NULL, NULL);
+						      NULL);
 	}
 
 	/* Check if there is an error on xmit/recv queues */
lib/librte_ether/rte_ethdev.c +1 -3
index 318af2869..c196c3692 100644
@@ -2905,7 +2905,7 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
 
 int
 _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
-	enum rte_eth_event_type event, void *cb_arg, void *ret_param)
+	enum rte_eth_event_type event, void *ret_param)
 {
 	struct rte_eth_dev_callback *cb_lst;
 	struct rte_eth_dev_callback dev_cb;
@@ -2917,8 +2917,6 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
 			continue;
 		dev_cb = *cb_lst;
 		cb_lst->active = 1;
-		if (cb_arg != NULL)
-			dev_cb.cb_arg = cb_arg;
 		if (ret_param != NULL)
 			dev_cb.ret_param = ret_param;
 
lib/librte_ether/rte_ethdev.h +1 -3
index 341c2d624..15309aa7c 100644
@@ -3585,8 +3585,6 @@ int rte_eth_dev_callback_unregister(uint16_t port_id,
  *  Pointer to struct rte_eth_dev.
  * @param event
  *  Eth device interrupt event type.
- * @param cb_arg
- *  callback parameter.
  * @param ret_param
  *  To pass data back to user application.
  *  This allows the user application to decide if a particular function
@@ -3596,7 +3594,7 @@ int rte_eth_dev_callback_unregister(uint16_t port_id,
  *  int
  */
 int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
-		enum rte_eth_event_type event, void *cb_arg, void *ret_param);
+		enum rte_eth_event_type event, void *ret_param);
 
 /**
  * When there is no rx packet coming in Rx Queue for a long time, we can
test/test/virtual_pmd.c +1 -1
index b57a9493b..f55288537 100644
@@ -489,7 +489,7 @@ virtual_ethdev_simulate_link_status_interrupt(uint16_t port_id,
 	vrtl_eth_dev->data->dev_link.link_status = link_status;
 
 	_rte_eth_dev_callback_process(vrtl_eth_dev, RTE_ETH_EVENT_INTR_LSC,
-				      NULL, NULL);
+				      NULL);
 }
 
 int
Signature · 1 line
2.15.1
#18 lore raw

PATCH v4 2/5 ethdev: allow event registration for all ports

In reply to Thomas Monjalon

From: Matan Azrad <[email protected]>

Add option to register event callback for all ports by one call to rte_eth_dev_callback_register using port_id=RTE_ETH_ALL.

In this case the callback is also registered to invalid ports.

---
v2:
- moved callback lists constructor
- changed ports variables from 32 to 16 bits
- changed doxygen comment
v3: no change
v4: revert next_port to uint32_t to avoid wrap-around

---
 lib/librte_ether/rte_ethdev.c | 121 ++++++++++++++++++++++++++++--------------
 lib/librte_ether/rte_ethdev.h |   8 ++-
 2 files changed, 88 insertions(+), 41 deletions(-)
lib/librte_ether/rte_ethdev.c +82 -39
index c196c3692..7b440fc6b 100644
@@ -204,7 +204,6 @@ eth_dev_get(uint16_t port_id)
 
 	eth_dev->data = &rte_eth_dev_data[port_id];
 	eth_dev->state = RTE_ETH_DEV_ATTACHED;
-	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
 	eth_dev_last_created_port = port_id;
 
@@ -2820,6 +2819,14 @@ rte_eth_mirror_rule_reset(uint16_t port_id, uint8_t rule_id)
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
 
+RTE_INIT(eth_dev_init_cb_lists)
+{
+	int i;
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		TAILQ_INIT(&rte_eth_devices[i].link_intr_cbs);
+}
+
 int
 rte_eth_dev_callback_register(uint16_t port_id,
 			enum rte_eth_event_type event,
@@ -2827,37 +2834,59 @@ rte_eth_dev_callback_register(uint16_t port_id,
 {
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_callback *user_cb;
+	uint32_t next_port; /* size is 32-bit to prevent loop wrap-around */
+	uint16_t last_port;
 
 	if (!cb_fn)
 		return -EINVAL;
 
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
+		RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+		return -EINVAL;
+	}
+
+	if (port_id == RTE_ETH_ALL) {
+		next_port = 0;
+		last_port = RTE_MAX_ETHPORTS - 1;
+	} else {
+		next_port = last_port = port_id;
+	}
 
-	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
 
-	TAILQ_FOREACH(user_cb, &(dev->link_intr_cbs), next) {
-		if (user_cb->cb_fn == cb_fn &&
-			user_cb->cb_arg == cb_arg &&
-			user_cb->event == event) {
-			break;
+	do {
+		dev = &rte_eth_devices[next_port];
+
+		TAILQ_FOREACH(user_cb, &(dev->link_intr_cbs), next) {
+			if (user_cb->cb_fn == cb_fn &&
+				user_cb->cb_arg == cb_arg &&
+				user_cb->event == event) {
+				break;
+			}
 		}
-	}
 
-	/* create a new callback. */
-	if (user_cb == NULL) {
-		user_cb = rte_zmalloc("INTR_USER_CALLBACK",
-					sizeof(struct rte_eth_dev_callback), 0);
-		if (user_cb != NULL) {
-			user_cb->cb_fn = cb_fn;
-			user_cb->cb_arg = cb_arg;
-			user_cb->event = event;
-			TAILQ_INSERT_TAIL(&(dev->link_intr_cbs), user_cb, next);
+		/* create a new callback. */
+		if (user_cb == NULL) {
+			user_cb = rte_zmalloc("INTR_USER_CALLBACK",
+				sizeof(struct rte_eth_dev_callback), 0);
+			if (user_cb != NULL) {
+				user_cb->cb_fn = cb_fn;
+				user_cb->cb_arg = cb_arg;
+				user_cb->event = event;
+				TAILQ_INSERT_TAIL(&(dev->link_intr_cbs),
+						  user_cb, next);
+			} else {
+				rte_spinlock_unlock(&rte_eth_dev_cb_lock);
+				rte_eth_dev_callback_unregister(port_id, event,
+								cb_fn, cb_arg);
+				return -ENOMEM;
+			}
+
 		}
-	}
+	} while (++next_port <= last_port);
 
 	rte_spinlock_unlock(&rte_eth_dev_cb_lock);
-	return (user_cb == NULL) ? -ENOMEM : 0;
+	return 0;
 }
 
 int
@@ -2868,36 +2897,50 @@ rte_eth_dev_callback_unregister(uint16_t port_id,
 	int ret;
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_callback *cb, *next;
+	uint32_t next_port; /* size is 32-bit to prevent loop wrap-around */
+	uint16_t last_port;
 
 	if (!cb_fn)
 		return -EINVAL;
 
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
+		RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+		return -EINVAL;
+	}
+
+	if (port_id == RTE_ETH_ALL) {
+		next_port = 0;
+		last_port = RTE_MAX_ETHPORTS - 1;
+	} else {
+		next_port = last_port = port_id;
+	}
 
-	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
 
-	ret = 0;
-	for (cb = TAILQ_FIRST(&dev->link_intr_cbs); cb != NULL; cb = next) {
+	do {
+		dev = &rte_eth_devices[next_port];
+		ret = 0;
+		for (cb = TAILQ_FIRST(&dev->link_intr_cbs); cb != NULL;
+		     cb = next) {
 
-		next = TAILQ_NEXT(cb, next);
+			next = TAILQ_NEXT(cb, next);
 
-		if (cb->cb_fn != cb_fn || cb->event != event ||
-				(cb->cb_arg != (void *)-1 &&
-				cb->cb_arg != cb_arg))
-			continue;
+			if (cb->cb_fn != cb_fn || cb->event != event ||
+			    (cb->cb_arg != (void *)-1 && cb->cb_arg != cb_arg))
+				continue;
 
-		/*
-		 * if this callback is not executing right now,
-		 * then remove it.
-		 */
-		if (cb->active == 0) {
-			TAILQ_REMOVE(&(dev->link_intr_cbs), cb, next);
-			rte_free(cb);
-		} else {
-			ret = -EAGAIN;
+			/*
+			 * if this callback is not executing right now,
+			 * then remove it.
+			 */
+			if (cb->active == 0) {
+				TAILQ_REMOVE(&(dev->link_intr_cbs), cb, next);
+				rte_free(cb);
+			} else {
+				ret = -EAGAIN;
+			}
 		}
-	}
+	} while (++next_port <= last_port);
 
 	rte_spinlock_unlock(&rte_eth_dev_cb_lock);
 	return ret;
lib/librte_ether/rte_ethdev.h +6 -2
index 15309aa7c..c92508cfd 100644
@@ -1137,6 +1137,8 @@ struct rte_eth_dcb_info {
 
 struct rte_eth_dev;
 
+#define RTE_ETH_ALL RTE_MAX_ETHPORTS
+
 struct rte_eth_dev_callback;
 /** @internal Structure to keep track of registered callbacks */
 TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
@@ -3536,10 +3538,11 @@ typedef int (*rte_eth_dev_cb_fn)(uint16_t port_id,
 
 
 /**
- * Register a callback function for specific port id.
+ * Register a callback function for port event.
  *
  * @param port_id
  *  Port id.
+ *  RTE_ETH_ALL means register the event for all port ids.
  * @param event
  *  Event interested.
  * @param cb_fn
@@ -3556,10 +3559,11 @@ int rte_eth_dev_callback_register(uint16_t port_id,
 		rte_eth_dev_cb_fn cb_fn, void *cb_arg);
 
 /**
- * Unregister a callback function for specific port id.
+ * Unregister a callback function for port event.
  *
  * @param port_id
  *  Port id.
+ *  RTE_ETH_ALL means unregister the event for all port ids.
  * @param event
  *  Event interested.
  * @param cb_fn
Signature · 1 line
2.15.1
#16 lore raw

v4 cover ethdev port notifications

In reply to Thomas Monjalon

This patchset aims to add notifications for ethdev ports added or removed.
It will be especially useful for hotplug.

v2 & v3 changes: gather more patches in the series v4 change: fix a variable wraparound as in Matan's v1

Matan Azrad (3):
ethdev: allow event registration for all ports
ethdev: free detached port by the dedicated function app/testpmd: extend event printing

Thomas Monjalon (2):
ethdev: remove useless parameter in callback process
ethdev: add notifications for probing and removal

 app/test-pmd/parameters.c               |   4 +
 app/test-pmd/testpmd.c                  |  30 ++++----
 doc/guides/prog_guide/poll_mode_drv.rst |   4 +-
 doc/guides/testpmd_app_ug/run_app.rst   |   4 +-
 drivers/net/bnxt/rte_pmd_bnxt.c         |   2 +-
 drivers/net/bonding/rte_eth_bond_pmd.c  |   6 +-
 drivers/net/dpaa2/dpaa2_ethdev.c        |   2 +-
 drivers/net/e1000/em_ethdev.c           |   2 +-
 drivers/net/e1000/igb_ethdev.c          |   4 +-
 drivers/net/enic/enic_main.c            |   2 +-
 drivers/net/failsafe/failsafe_ether.c   |   2 +-
 drivers/net/fm10k/fm10k_ethdev.c        |   8 +-
 drivers/net/i40e/i40e_ethdev.c          |   2 +-
 drivers/net/i40e/i40e_ethdev_vf.c       |   2 +-
 drivers/net/i40e/i40e_pf.c              |   3 +-
 drivers/net/ixgbe/ixgbe_ethdev.c        |   6 +-
 drivers/net/ixgbe/ixgbe_pf.c            |   4 +-
 drivers/net/mlx4/mlx4_intr.c            |   4 +-
 drivers/net/mlx5/mlx5_ethdev.c          |   9 +--
 drivers/net/nfp/nfp_net.c               |   2 +-
 drivers/net/sfc/sfc_intr.c              |   4 +-
 drivers/net/thunderx/nicvf_ethdev.c     |   2 +-
 drivers/net/vhost/rte_eth_vhost.c       |   9 +--
 drivers/net/virtio/virtio_ethdev.c      |   2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |   2 +-
 lib/librte_ether/rte_ethdev.c           | 132 +++++++++++++++++++++-----------
 lib/librte_ether/rte_ethdev.h           |  14 ++--
 test/test/virtual_pmd.c                 |   2 +-
 28 files changed, 159 insertions(+), 110 deletions(-)
Signature · 1 line
2.15.1
#19 lore raw

PATCH v4 3/5 ethdev: free detached port by the dedicated function

From: Matan Azrad <[email protected]>

In the port detach function, use the function to free an ethdev port instead of changing its state directly.

---
v2: no change
v3: no change
v4: no change

---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_ether/rte_ethdev.c +1 -1
index 7b440fc6b..8700f6f43 100644
@@ -436,7 +436,7 @@ rte_eth_dev_detach(uint16_t port_id, char *name)
 	if (ret < 0)
 		goto err;
 
-	rte_eth_devices[port_id].state = RTE_ETH_DEV_UNUSED;
+	rte_eth_dev_release_port(&rte_eth_devices[port_id]);
 	return 0;
 
 err:
Signature · 1 line
2.15.1
#20 lore raw

PATCH v4 4/5 ethdev: add notifications for probing and removal

In reply to Thomas Monjalon

When a PMD finishes probing, it creates the new port by calling the function rte_eth_dev_allocate().
A notification of the new port is sent there to the upper layer.

When a PMD finishes removal of a port, it calls the function rte_eth_dev_release_port().
A notification of the destroyed port is sent there to the upper layer.

---
v2: no change
v3: no change
v4: no change

---
 lib/librte_ether/rte_ethdev.c | 5 +++++
 lib/librte_ether/rte_ethdev.h | 2 ++
 2 files changed, 7 insertions(+)
lib/librte_ether/rte_ethdev.c +5 -0
index 8700f6f43..7c1f7eef9 100644
@@ -237,6 +237,8 @@ rte_eth_dev_allocate(const char *name)
 	eth_dev->data->port_id = port_id;
 	eth_dev->data->mtu = ETHER_MTU;
 
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_NEW, NULL);
+
 	return eth_dev;
 }
 
@@ -278,6 +280,9 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 		return -EINVAL;
 
 	eth_dev->state = RTE_ETH_DEV_UNUSED;
+
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
+
 	return 0;
 }
 
lib/librte_ether/rte_ethdev.h +2 -0
index c92508cfd..11f97e709 100644
@@ -3528,6 +3528,8 @@ enum rte_eth_event_type {
 	RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
 	RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
 	RTE_ETH_EVENT_INTR_RMV, /**< device removal event */
+	RTE_ETH_EVENT_NEW,      /**< port is probed */
+	RTE_ETH_EVENT_DESTROY,  /**< port is released */
 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
 };
 
Signature · 1 line
2.15.1
#21 lore raw

PATCH v4 5/5 app/testpmd: extend event printing

In reply to Thomas Monjalon

From: Matan Azrad <[email protected]>

There are new Ethernet device events - NEW and DESTROY, and new option to register all ports by one call.

Adjust application to aforementioned changes.

---
v3: no change
v4: no change

---
 app/test-pmd/parameters.c             |  4 ++++
 app/test-pmd/testpmd.c                | 30 ++++++++++++++++--------------
 doc/guides/testpmd_app_ug/run_app.rst |  4 ++--
 3 files changed, 22 insertions(+), 16 deletions(-)
app/test-pmd/parameters.c +4 -0
index 84e7a63ef..796d1a5b6 100644
@@ -546,6 +546,10 @@ parse_event_printing_config(const char *optarg, int enable)
 		mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
 	else if (!strcmp(optarg, "intr_rmv"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
+	else if (!strcmp(optarg, "dev_probed"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_NEW;
+	else if (!strcmp(optarg, "dev_released"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_DESTROY;
 	else if (!strcmp(optarg, "all"))
 		mask = ~UINT32_C(0);
 	else {
app/test-pmd/testpmd.c +16 -14
index c3ab44849..26576eb76 100644
@@ -1568,20 +1568,6 @@ start_port(portid_t pid)
 			}
 		}
 
-		for (event_type = RTE_ETH_EVENT_UNKNOWN;
-		     event_type < RTE_ETH_EVENT_MAX;
-		     event_type++) {
-			diag = rte_eth_dev_callback_register(pi,
-							event_type,
-							eth_event_callback,
-							NULL);
-			if (diag) {
-				printf("Failed to setup even callback for event %d\n",
-					event_type);
-				return -1;
-			}
-		}
-
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
@@ -1608,6 +1594,20 @@ start_port(portid_t pid)
 		need_check_link_status = 1;
 	}
 
+	for (event_type = RTE_ETH_EVENT_UNKNOWN;
+	     event_type < RTE_ETH_EVENT_MAX;
+	     event_type++) {
+		diag = rte_eth_dev_callback_register(RTE_ETH_ALL,
+						event_type,
+						eth_event_callback,
+						NULL);
+		if (diag) {
+			printf("Failed to setup even callback for event %d\n",
+				event_type);
+			return -1;
+		}
+	}
+
 	if (need_check_link_status == 1 && !no_link_check)
 		check_all_ports_link_status(RTE_PORT_ALL);
 	else if (need_check_link_status == 0)
@@ -1930,6 +1930,8 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,
 		[RTE_ETH_EVENT_VF_MBOX] = "VF Mbox",
 		[RTE_ETH_EVENT_MACSEC] = "MACsec",
 		[RTE_ETH_EVENT_INTR_RMV] = "device removal",
+		[RTE_ETH_EVENT_NEW] = "device probed",
+		[RTE_ETH_EVENT_DESTROY] = "device released",
 		[RTE_ETH_EVENT_MAX] = NULL,
 	};
 
doc/guides/testpmd_app_ug/run_app.rst +2 -2
index 4c0d2cede..377b07651 100644
@@ -492,12 +492,12 @@ The commandline options are:
 
     Set the logical core N to perform bitrate calculation.
 
-*   ``--print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>``
+*   ``--print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|dev_probed|dev_released|all>``
 
     Enable printing the occurrence of the designated event. Using all will
     enable all of them.
 
-*   ``--mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>``
+*   ``--mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|dev_probed|dev_released|all>``
 
     Disable printing the occurrence of the designated event. Using all will
     disable all of them.
Signature · 1 line
2.15.1
#22 lore raw

Re: [PATCH v4 5/5] app/testpmd: extend event printing

+Cc Wenzhuo and Jingjing for review, thanks

04/01/2018 17:01, Thomas Monjalon:

Quoted 107 lines

From: Matan Azrad <[email protected]>

There are new Ethernet device events - NEW and DESTROY, and new option to register all ports by one call.

Adjust application to aforementioned changes.

---
v3: no change
v4: no change

---
 app/test-pmd/parameters.c             |  4 ++++
 app/test-pmd/testpmd.c                | 30 ++++++++++++++++--------------
 doc/guides/testpmd_app_ug/run_app.rst |  4 ++--
 3 files changed, 22 insertions(+), 16 deletions(-)
app/test-pmd/parameters.c +4 -0
index 84e7a63ef..796d1a5b6 100644
@@ -546,6 +546,10 @@ parse_event_printing_config(const char *optarg, int enable)
 		mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
 	else if (!strcmp(optarg, "intr_rmv"))
 		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
+	else if (!strcmp(optarg, "dev_probed"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_NEW;
+	else if (!strcmp(optarg, "dev_released"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_DESTROY;
 	else if (!strcmp(optarg, "all"))
 		mask = ~UINT32_C(0);
 	else {
app/test-pmd/testpmd.c +16 -14
index c3ab44849..26576eb76 100644
@@ -1568,20 +1568,6 @@ start_port(portid_t pid)
 			}
 		}
 
-		for (event_type = RTE_ETH_EVENT_UNKNOWN;
-		     event_type < RTE_ETH_EVENT_MAX;
-		     event_type++) {
-			diag = rte_eth_dev_callback_register(pi,
-							event_type,
-							eth_event_callback,
-							NULL);
-			if (diag) {
-				printf("Failed to setup even callback for event %d\n",
-					event_type);
-				return -1;
-			}
-		}
-
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
@@ -1608,6 +1594,20 @@ start_port(portid_t pid)
 		need_check_link_status = 1;
 	}
 
+	for (event_type = RTE_ETH_EVENT_UNKNOWN;
+	     event_type < RTE_ETH_EVENT_MAX;
+	     event_type++) {
+		diag = rte_eth_dev_callback_register(RTE_ETH_ALL,
+						event_type,
+						eth_event_callback,
+						NULL);
+		if (diag) {
+			printf("Failed to setup even callback for event %d\n",
+				event_type);
+			return -1;
+		}
+	}
+
 	if (need_check_link_status == 1 && !no_link_check)
 		check_all_ports_link_status(RTE_PORT_ALL);
 	else if (need_check_link_status == 0)
@@ -1930,6 +1930,8 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param,
 		[RTE_ETH_EVENT_VF_MBOX] = "VF Mbox",
 		[RTE_ETH_EVENT_MACSEC] = "MACsec",
 		[RTE_ETH_EVENT_INTR_RMV] = "device removal",
+		[RTE_ETH_EVENT_NEW] = "device probed",
+		[RTE_ETH_EVENT_DESTROY] = "device released",
 		[RTE_ETH_EVENT_MAX] = NULL,
 	};
 
doc/guides/testpmd_app_ug/run_app.rst +2 -2
index 4c0d2cede..377b07651 100644
@@ -492,12 +492,12 @@ The commandline options are:
 
     Set the logical core N to perform bitrate calculation.
 
-*   ``--print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>``
+*   ``--print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|dev_probed|dev_released|all>``
 
     Enable printing the occurrence of the designated event. Using all will
     enable all of them.
 
-*   ``--mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|all>``
+*   ``--mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv|dev_probed|dev_released|all>``
 
     Disable printing the occurrence of the designated event. Using all will
     disable all of them.
#24 lore raw

Re: [PATCH v4 0/5] ethdev port notifications

In reply to Thomas Monjalon
Quoted 7 lines · Thomas Monjalon

This patchset aims to add notifications for ethdev ports added or removed.
It will be especially useful for hotplug.

v2 & v3 changes: gather more patches in the series v4 change: fix a variable wraparound as in Matan's v1

Quoted 8 lines

Matan Azrad (3):
ethdev: allow event registration for all ports
ethdev: free detached port by the dedicated function app/testpmd: extend event printing

Thomas Monjalon (2):
ethdev: remove useless parameter in callback process
ethdev: add notifications for probing and removal

Series applied to dpdk-next-net/master, thanks.