diff mbox

[dpdk-dev,v6,2/2] net/ixgbe: add callback to user app on VF to PF mbox msg

Message ID 1475772490-10491-3-git-send-email-bernard.iremonger@intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Iremonger, Bernard Oct. 6, 2016, 4:48 p.m. UTC
call _rte_eth_dev_callback_process from ixgbe_rcv_msg_from_vf function.

The callback asks the user application if it is allowed to perform
the function.
If the cb_param.retval is RTE_PMD_IXGBE_MB_EVENT_PROCEED then continue,
if 0, do nothing and send ACK to VF
if > 1, do nothing and send NAK to VF.

Signed-off-by: Alex Zelezniak <az5157@att.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c  |  4 ++--
 drivers/net/ixgbe/ixgbe_pf.c      | 42 +++++++++++++++++++++++++++++++++------
 drivers/net/ixgbe/rte_pmd_ixgbe.h | 17 ++++++++++++++++
 3 files changed, 55 insertions(+), 8 deletions(-)

Comments

Thomas Monjalon Oct. 7, 2016, 12:14 p.m. UTC | #1
2016-10-06 17:48, Bernard Iremonger:
> call _rte_eth_dev_callback_process from ixgbe_rcv_msg_from_vf function.
> 
> The callback asks the user application if it is allowed to perform
> the function.
> If the cb_param.retval is RTE_PMD_IXGBE_MB_EVENT_PROCEED then continue,
> if 0, do nothing and send ACK to VF
> if > 1, do nothing and send NAK to VF.
[...]
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -3559,7 +3559,7 @@ ixgbe_dev_interrupt_delayed_handler(void *param)
>  		ixgbe_dev_link_update(dev, 0);
>  		intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
>  		ixgbe_dev_link_status_print(dev);
> -		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
> +		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
>  	}
>  
>  	PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
> @@ -7525,7 +7525,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);
> +		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL);
>  }

This piece should go into the patch 1.
Iremonger, Bernard Oct. 7, 2016, 12:19 p.m. UTC | #2
Hi Thomas,

<snip>

> Subject: Re: [dpdk-dev] [PATCH v6 2/2] net/ixgbe: add callback to user app
> on VF to PF mbox msg
> 
> 2016-10-06 17:48, Bernard Iremonger:
> > call _rte_eth_dev_callback_process from ixgbe_rcv_msg_from_vf
> function.
> >
> > The callback asks the user application if it is allowed to perform the
> > function.
> > If the cb_param.retval is RTE_PMD_IXGBE_MB_EVENT_PROCEED then
> > continue, if 0, do nothing and send ACK to VF if > 1, do nothing and
> > send NAK to VF.
> [...]
> > --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> > @@ -3559,7 +3559,7 @@ ixgbe_dev_interrupt_delayed_handler(void
> *param)
> >  		ixgbe_dev_link_update(dev, 0);
> >  		intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
> >  		ixgbe_dev_link_status_print(dev);
> > -		_rte_eth_dev_callback_process(dev,
> RTE_ETH_EVENT_INTR_LSC);
> > +		_rte_eth_dev_callback_process(dev,
> RTE_ETH_EVENT_INTR_LSC, NULL);
> >  	}
> >
> >  	PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]",
> eicr);
> > @@ -7525,7 +7525,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);
> > +		_rte_eth_dev_callback_process(dev,
> RTE_ETH_EVENT_INTR_RESET, NULL);
> >  }
> 
> This piece should go into the patch 1.

Ok, I will send a v7.

Regards,

Bernard.
diff mbox

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 55a82d3..91db2c3 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -3559,7 +3559,7 @@  ixgbe_dev_interrupt_delayed_handler(void *param)
 		ixgbe_dev_link_update(dev, 0);
 		intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
 		ixgbe_dev_link_status_print(dev);
-		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
+		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 	}
 
 	PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
@@ -7525,7 +7525,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);
+		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL);
 }
 
 static int
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index 56393ff..2a177b8 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -1,7 +1,7 @@ 
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,7 @@ 
 
 #include "base/ixgbe_common.h"
 #include "ixgbe_ethdev.h"
+#include "rte_pmd_ixgbe.h"
 
 #define IXGBE_MAX_VFTA     (128)
 #define IXGBE_VF_MSG_SIZE_DEFAULT 1
@@ -660,6 +661,7 @@  ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ixgbe_vf_info *vfinfo =
 		*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
+	struct rte_pmd_ixgbe_mb_event_param cb_param;
 
 	retval = ixgbe_read_mbx(hw, msgbuf, mbx_size, vf);
 	if (retval) {
@@ -674,27 +676,54 @@  ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
 	/* flush the ack before we write any messages back */
 	IXGBE_WRITE_FLUSH(hw);
 
+	/**
+	 * initialise structure to send to user application
+	 * will return response from user in retval field
+	 */
+	cb_param.retval = RTE_PMD_IXGBE_MB_EVENT_PROCEED;
+	cb_param.vfid = vf;
+	cb_param.msg_type = msgbuf[0] & 0xFFFF;
+	cb_param.userdata = (void *)msgbuf;
+
 	/* perform VF reset */
 	if (msgbuf[0] == IXGBE_VF_RESET) {
 		int ret = ixgbe_vf_reset(dev, vf, msgbuf);
 
 		vfinfo[vf].clear_to_send = true;
+
+		/* notify application about VF reset */
+		_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX, &cb_param);
 		return ret;
 	}
 
+	/**
+	 * ask user application if we allowed to perform those functions
+	 * if we get cb_param.retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED
+	 * then business as usual,
+	 * if 0, do nothing and send ACK to VF
+	 * if cb_param.retval > 1, do nothing and send NAK to VF
+	 */
+	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX, &cb_param);
+
+	retval = cb_param.retval;
+
 	/* check & process VF to PF mailbox message */
 	switch ((msgbuf[0] & 0xFFFF)) {
 	case IXGBE_VF_SET_MAC_ADDR:
-		retval = ixgbe_vf_set_mac_addr(dev, vf, msgbuf);
+		if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
+			retval = ixgbe_vf_set_mac_addr(dev, vf, msgbuf);
 		break;
 	case IXGBE_VF_SET_MULTICAST:
-		retval = ixgbe_vf_set_multicast(dev, vf, msgbuf);
+		if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
+			retval = ixgbe_vf_set_multicast(dev, vf, msgbuf);
 		break;
 	case IXGBE_VF_SET_LPE:
-		retval = ixgbe_set_vf_lpe(dev, vf, msgbuf);
+		if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
+			retval = ixgbe_set_vf_lpe(dev, vf, msgbuf);
 		break;
 	case IXGBE_VF_SET_VLAN:
-		retval = ixgbe_vf_set_vlan(dev, vf, msgbuf);
+		if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
+			retval = ixgbe_vf_set_vlan(dev, vf, msgbuf);
 		break;
 	case IXGBE_VF_API_NEGOTIATE:
 		retval = ixgbe_negotiate_vf_api(dev, vf, msgbuf);
@@ -704,7 +733,8 @@  ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
 		msg_size = IXGBE_VF_GET_QUEUE_MSG_SIZE;
 		break;
 	case IXGBE_VF_UPDATE_XCAST_MODE:
-		retval = ixgbe_set_vf_mc_promisc(dev, vf, msgbuf);
+		if (retval == RTE_PMD_IXGBE_MB_EVENT_PROCEED)
+			retval = ixgbe_set_vf_mc_promisc(dev, vf, msgbuf);
 		break;
 	default:
 		PMD_DRV_LOG(DEBUG, "Unhandled Msg %8.8x", (unsigned)msgbuf[0]);
diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.h b/drivers/net/ixgbe/rte_pmd_ixgbe.h
index 33b5b2d..2f6cf46 100644
--- a/drivers/net/ixgbe/rte_pmd_ixgbe.h
+++ b/drivers/net/ixgbe/rte_pmd_ixgbe.h
@@ -181,4 +181,21 @@  int rte_pmd_ixgbe_set_vf_split_drop_en(uint8_t port, uint16_t vf, uint8_t on);
  */
 int
 rte_pmd_ixgbe_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
+
+/**
+ * Response sent back to ixgbe driver from user app after callback
+ */
+enum rte_pmd_ixgbe_mb_event_rsp {
+	RTE_PMD_IXGBE_MB_EVENT_NOOP_ACK,  /**< skip mbox request and ACK */
+	RTE_PMD_IXGBE_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
+	RTE_PMD_IXGBE_MB_EVENT_PROCEED,  /**< proceed with mbox request  */
+	RTE_PMD_IXGBE_MB_EVENT_MAX       /**< max value of this enum */
+};
+
+struct rte_pmd_ixgbe_mb_event_param {
+	uint16_t vfid;
+	uint16_t msg_type;
+	uint16_t retval;
+	void *userdata;
+};
 #endif /* _PMD_IXGBE_H_ */