[dpdk-dev] [PATCH v2 1/2] ixgbe: VF supports mailbox interruption for PF link up/down

2016-06-14 Thread Bruce Richardson
On Wed, Jun 01, 2016 at 09:53:08AM +0800, Wenzhuo Lu wrote:
> In this scenario, kernel PF + DPDK VF, when PF finds the link
> state changes, up -> down or down -> up, it will send a
> message to VF by mailbox. This link state change may be
> triggered by PHY disconnection/reconnection, configuration
> like *ifconfig down/up* or interface parameter, like MTU,
> change.
> This patch enables the support of the mailbox interruption,
> so VF can receive the message of link up/down.
> After VF receives this message, VF port need to be reset to
> recover. So the handler of this message registers a reset
> callback to let APP reset the VF port.
> 
Hi Wenzhuo,

I'm a little unclear as to the last paragraph of this message. Does the
app configure the callback to handle the reset, or does the driver set
up a callback automatically and handle the event itself? [In other words,
who/what is the "handler" in the final sentence, the driver or the app?]

Thanks,
/Bruce



[dpdk-dev] [PATCH v2 1/2] ixgbe: VF supports mailbox interruption for PF link up/down

2016-06-02 Thread Wu, Jingjing


> -Original Message-
> From: Lu, Wenzhuo
> Sent: Wednesday, June 01, 2016 9:53 AM
> To: dev at dpdk.org
> Cc: Wu, Jingjing; Lu, Wenzhuo
> Subject: [PATCH v2 1/2] ixgbe: VF supports mailbox interruption for PF link
> up/down
> 
> In this scenario, kernel PF + DPDK VF, when PF finds the link state changes,
> up -> down or down -> up, it will send a message to VF by mailbox. This link
> state change may be triggered by PHY disconnection/reconnection,
> configuration like *ifconfig down/up* or interface parameter, like MTU,
> change.
> This patch enables the support of the mailbox interruption, so VF can receive
> the message of link up/down.
> After VF receives this message, VF port need to be reset to recover. So the
> handler of this message registers a reset callback to let APP reset the VF 
> port.
> 
> Signed-off-by: Wenzhuo Lu 

Acked-by: Jingjing Wu 




[dpdk-dev] [PATCH v2 1/2] ixgbe: VF supports mailbox interruption for PF link up/down

2016-06-01 Thread Wenzhuo Lu
In this scenario, kernel PF + DPDK VF, when PF finds the link
state changes, up -> down or down -> up, it will send a
message to VF by mailbox. This link state change may be
triggered by PHY disconnection/reconnection, configuration
like *ifconfig down/up* or interface parameter, like MTU,
change.
This patch enables the support of the mailbox interruption,
so VF can receive the message of link up/down.
After VF receives this message, VF port need to be reset to
recover. So the handler of this message registers a reset
callback to let APP reset the VF port.

Signed-off-by: Wenzhuo Lu 
---
 doc/guides/rel_notes/release_16_07.rst |  6 +++
 drivers/net/ixgbe/ixgbe_ethdev.c   | 84 --
 2 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..990bd46 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -47,6 +47,12 @@ New Features
   * Dropped specific Xen Dom0 code.
   * Dropped specific anonymous mempool code in testpmd.

+* **Added mailbox interruption support for ixgbe VF.**
+
+  When the link becomes down or up, PF will use mailbox message to notice
+  VF. To handle this link up/down event, add the mailbox interruption
+  support to receive the message.
+

 Resolved Issues
 ---
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index a2b170b..05f4f29 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -150,6 +150,7 @@
 #define IXGBE_VMVIR_TAGA_ETAG_INSERT   0x0800
 #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
 #define IXGBE_QDE_STRIP_TAG0x0004
+#define IXGBE_VTEICR_MASK  0x07

 enum ixgbevf_xcast_modes {
IXGBEVF_XCAST_MODE_NONE = 0,
@@ -361,6 +362,8 @@ static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
   struct timespec *timestamp);
 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
   const struct timespec *timestamp);
+static void ixgbevf_dev_interrupt_handler(struct rte_intr_handle *handle,
+ void *param);

 static int ixgbe_dev_l2_tunnel_eth_type_conf
(struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
@@ -1442,6 +1445,12 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
return -EIO;
}

+   rte_intr_callback_register(_dev->intr_handle,
+  ixgbevf_dev_interrupt_handler,
+  (void *)eth_dev);
+   rte_intr_enable(_dev->intr_handle);
+   ixgbevf_intr_enable(hw);
+
PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
 eth_dev->data->port_id, pci_dev->id.vendor_id,
 pci_dev->id.device_id, "ixgbe_mac_82599_vf");
@@ -1455,6 +1464,7 @@ static int
 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
 {
struct ixgbe_hw *hw;
+   struct rte_pci_device *pci_dev = eth_dev->pci_dev;

PMD_INIT_FUNC_TRACE();

@@ -1476,6 +1486,11 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
rte_free(eth_dev->data->mac_addrs);
eth_dev->data->mac_addrs = NULL;

+   rte_intr_disable(_dev->intr_handle);
+   rte_intr_callback_unregister(_dev->intr_handle,
+ixgbevf_dev_interrupt_handler,
+(void *)eth_dev);
+
return 0;
 }

@@ -4074,6 +4089,8 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev)

PMD_INIT_FUNC_TRACE();

+   ixgbevf_intr_disable(hw);
+
hw->adapter_stopped = 1;
ixgbe_stop_adapter(hw);

@@ -4818,6 +4835,9 @@ ixgbevf_configure_msix(struct rte_eth_dev *dev)
uint32_t q_idx;
uint32_t vector_idx = IXGBE_MISC_VEC_ID;

+   /* Configure VF other cause ivar */
+   ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
+
/* won't configure msix register if no mapping is done
 * between intr vector and event fd.
 */
@@ -4832,9 +4852,6 @@ ixgbevf_configure_msix(struct rte_eth_dev *dev)
ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
intr_handle->intr_vec[q_idx] = vector_idx;
}
-
-   /* Configure VF other cause ivar */
-   ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
 }

 /**
@@ -7154,6 +7171,67 @@ ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
ixgbevf_update_xcast_mode(hw, IXGBEVF_XCAST_MODE_NONE);
 }

+static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
+{
+   struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   u32 in_msg = 0;
+
+   if (ixgbe_read_mbx(hw, _msg, 1, 0))
+   return;
+
+   /* PF reset VF event */
+   if (in_msg == IXGBE_PF_CONTROL_MSG)
+