diff mbox

[dpdk-dev,v3,1/2] librte_ether: add internal callback functions

Message ID 1475250308-5498-2-git-send-email-bernard.iremonger@intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Iremonger, Bernard Sept. 30, 2016, 3:45 p.m. UTC
add _rte_eth_dev_callback_process_vf function.
add _rte_eth_dev_callback_process_generic function

Adding a callback to the user application on VF to PF mailbox message,
allows passing information to the application controlling the PF
when a VF mailbox event message is received, such as VF reset.

Signed-off-by: Alex Zelezniak <az5157@att.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c          | 17 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 51 ++++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  7 +++++
 3 files changed, 75 insertions(+)

Comments

Stephen Hemminger Oct. 2, 2016, 9:12 a.m. UTC | #1
I know callbacks are needed, in fact even more are necessary. That is why
I  don't like this design. It expands the API for each event. I think
something like the Linux kernel netlink callback mechanism that passes an
event and device handle.
Iremonger, Bernard Oct. 3, 2016, 3:29 p.m. UTC | #2
Hi Stephen,

From: Stephen Hemminger [mailto:stephen@networkplumber.org]

Sent: Sunday, October 2, 2016 10:13 AM
To: Iremonger, Bernard <bernard.iremonger@intel.com>
Cc: dev@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>; jerin.jacob@caviumnetworks.com; az5157@att.com; Shah, Rahul R <rahul.r.shah@intel.com>
Subject: Re: [dpdk-dev] [PATCH v3 1/2] librte_ether: add internal callback functions


I know callbacks are needed, in fact even more are necessary. That is why I  don't like this design. It expands the API for each event. I think something like the Linux kernel netlink callback mechanism that passes an event and device handle.

The current  rte_eth_dev_callback_register()  function takes a parameter void *cb_arg. This allows the passing of a parameter to the callback. For the events RTE_ETH_EVENT_QUEUE_STATE,  RTE_ETH_EVENT_INTR_RESET the callback parameter is not used. In some cases for the RTE_ETH_EVENT_INTR_LSC the call back parameter is used.

This patch adds a new event RTE_ETH_VF_MBOX and a parameter for this event struct rte_eth_mb_event_param{}. This parameter is only used with the RTE_ETH_VF_MBOX event and does not affect the other events.

The struct rte_eth_mb_event_param{} should probably not be in rte_eth_dev.h, I will send a v4.

Regards,

Bernard.
diff mbox

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 382c959..6d93fcf 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2689,6 +2689,20 @@  void
 _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
 	enum rte_eth_event_type event)
 {
+	return _rte_eth_dev_callback_process_generic(dev, event, NULL);
+}
+
+void
+_rte_eth_dev_callback_process_vf(struct rte_eth_dev *dev,
+	enum rte_eth_event_type event, void *param)
+{
+	return _rte_eth_dev_callback_process_generic(dev, event, param);
+}
+
+void
+_rte_eth_dev_callback_process_generic(struct rte_eth_dev *dev,
+	enum rte_eth_event_type event, void *param)
+{
 	struct rte_eth_dev_callback *cb_lst;
 	struct rte_eth_dev_callback dev_cb;
 
@@ -2698,6 +2712,9 @@  _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
 			continue;
 		dev_cb = *cb_lst;
 		cb_lst->active = 1;
+		if (param != NULL)
+			dev_cb.cb_arg = (void *) param;
+
 		rte_spinlock_unlock(&rte_eth_dev_cb_lock);
 		dev_cb.cb_fn(dev->data->port_id, dev_cb.event,
 						dev_cb.cb_arg);
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 96575e8..a61905c 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3051,9 +3051,17 @@  enum rte_eth_event_type {
 				/**< queue state event (enabled/disabled) */
 	RTE_ETH_EVENT_INTR_RESET,
 			/**< reset interrupt event, sent to VF on PF reset */
+	RTE_ETH_EVENT_VF_MBOX,  /**< PF mailbox processing callback */
 	RTE_ETH_EVENT_MAX       /**< max value of this enum */
 };
 
+struct rte_eth_mb_event_param {
+	uint16_t vfid;
+	uint16_t msg_type;
+	uint16_t retval;
+	void *userdata;
+};
+
 typedef void (*rte_eth_dev_cb_fn)(uint8_t port_id, \
 		enum rte_eth_event_type event, void *cb_arg);
 /**< user application callback to be registered for interrupts */
@@ -3118,6 +3126,49 @@  void _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
 				enum rte_eth_event_type event);
 
 /**
+ * @internal Executes all the user application registered callbacks for
+ * the specific device where parameter have to be passed to user application.
+ * It is for DPDK internal user only. User application should not call it
+ * directly.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ * @param event
+ *  Eth device interrupt event type.
+ *
+ * @param param
+ *  parameters to pass back to user application.
+ *
+ * @return
+ *  void
+ */
+
+void
+_rte_eth_dev_callback_process_vf(struct rte_eth_dev *dev,
+				enum rte_eth_event_type event, void *param);
+
+/**
+ * @internal Executes all the user application registered callbacks. Used by:
+ * _rte_eth_dev_callback_process and _rte_eth_dev_callback_process_vf
+ * It is for DPDK internal user only. User application should not call it
+ * directly.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ * @param event
+ *  Eth device interrupt event type.
+ *
+ * @param param
+ *  parameters to pass back to user application.
+ *
+ * @return
+ *  void
+ */
+void
+_rte_eth_dev_callback_process_generic(struct rte_eth_dev *dev,
+				enum rte_eth_event_type event, void *param);
+
+/**
  * When there is no rx packet coming in Rx Queue for a long time, we can
  * sleep lcore related to RX Queue for power saving, and enable rx interrupt
  * to be triggered when rx packect arrives.
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 45ddf44..cb7ef15 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -139,3 +139,10 @@  DPDK_16.07 {
 	rte_eth_dev_get_port_by_name;
 	rte_eth_xstats_get_names;
 } DPDK_16.04;
+
+DPDK_16.11 {
+	global:
+
+	_rte_eth_dev_callback_process_generic;
+	_rte_eth_dev_callback_process_vf;
+} DPDK_16.07;