[dpdk-dev,v7,01/27] net/i40e: support link status notification
diff mbox

Message ID 1483426488-117332-2-git-send-email-wenzhuo.lu@intel.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show

Checks

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

Commit Message

Lu, Wenzhuo Jan. 3, 2017, 6:54 a.m. UTC
Add an API to expose the ability, that PF can notify VF
when link status changes, to APP.
So if PF APP doesn't want to enable interruption but check
link status by itself, PF APP can let VF know link status
changed.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 drivers/net/i40e/Makefile                 |  4 ++-
 drivers/net/i40e/i40e_ethdev.c            | 28 +++++++++++++++
 drivers/net/i40e/i40e_pf.c                |  4 +--
 drivers/net/i40e/i40e_pf.h                |  4 ++-
 drivers/net/i40e/rte_pmd_i40e.h           | 58 +++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  7 ++++
 6 files changed, 101 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/i40e/rte_pmd_i40e.h

Comments

Wu, Jingjing Jan. 5, 2017, 5:58 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wenzhuo Lu
> Sent: Tuesday, January 3, 2017 2:54 PM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: [dpdk-dev] [PATCH v7 01/27] net/i40e: support link status notification
> 
> Add an API to expose the ability, that PF can notify VF when link status changes,
> to APP.
> So if PF APP doesn't want to enable interruption but check link status by itself, PF
> APP can let VF know link status changed.
> 
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> ---
>  drivers/net/i40e/Makefile                 |  4 ++-
>  drivers/net/i40e/i40e_ethdev.c            | 28 +++++++++++++++
>  drivers/net/i40e/i40e_pf.c                |  4 +--
>  drivers/net/i40e/i40e_pf.h                |  4 ++-
>  drivers/net/i40e/rte_pmd_i40e.h           | 58
> +++++++++++++++++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e_version.map |  7 ++++
>  6 files changed, 101 insertions(+), 4 deletions(-)  create mode 100644
> drivers/net/i40e/rte_pmd_i40e.h
> 
> diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile index
> 66997b6..a2ef53c 100644
> --- a/drivers/net/i40e/Makefile
> +++ b/drivers/net/i40e/Makefile
> @@ -1,6 +1,6 @@
>  #   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
> @@ -111,6 +111,8 @@ ifeq ($(findstring
> RTE_MACHINE_CPUFLAG_SSE4_1,$(CFLAGS)),)
>  CFLAGS_i40e_rxtx_vec_sse.o += -msse4.1
>  endif
> 
> +# install this header file
> +SYMLINK-$(CONFIG_RTE_LIBRTE_I40E_PMD)-include := rte_pmd_i40e.h
> 
>  # this lib depends upon:
>  DEPDIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += lib/librte_eal lib/librte_ether
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index f42f4ba..fc7e987 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -62,6 +62,7 @@
>  #include "i40e_rxtx.h"
>  #include "i40e_pf.h"
>  #include "i40e_regs.h"
> +#include "rte_pmd_i40e.h"
> 
>  #define ETH_I40E_FLOATING_VEB_ARG	"enable_floating_veb"
>  #define ETH_I40E_FLOATING_VEB_LIST_ARG	"floating_veb_list"
> @@ -9695,3 +9696,30 @@ static void i40e_set_default_mac_addr(struct
> rte_eth_dev *dev,
> 
>  	return ret;
>  }
> +
> +int
> +rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf) {
> +	struct rte_eth_dev *dev;
> +	struct rte_eth_dev_info dev_info;
> +	struct i40e_pf *pf;
> +
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
> +
> +	dev = &rte_eth_devices[port];
> +	rte_eth_dev_info_get(port, &dev_info);
> +
> +	if (vf >= dev_info.max_vfs)
> +		return -EINVAL;
> +
> +	pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
> +
> +	if (vf > pf->vf_num - 1 || !pf->vfs) {
How about
if (!pf->vfs || vf > pf->vf_num - 1) {
because if vf_num is 0, the pf->vfs will be NULL.

Thanks
Jingjing
Lu, Wenzhuo Jan. 5, 2017, 6:23 a.m. UTC | #2
Hi Jingjing,


> -----Original Message-----
> From: Wu, Jingjing
> Sent: Thursday, January 5, 2017 1:58 PM
> To: Lu, Wenzhuo; dev@dpdk.org
> Cc: Lu, Wenzhuo
> Subject: RE: [dpdk-dev] [PATCH v7 01/27] net/i40e: support link status
> notification
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wenzhuo Lu
> > Sent: Tuesday, January 3, 2017 2:54 PM
> > To: dev@dpdk.org
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> > Subject: [dpdk-dev] [PATCH v7 01/27] net/i40e: support link status
> > notification
> >
> > Add an API to expose the ability, that PF can notify VF when link
> > status changes, to APP.
> > So if PF APP doesn't want to enable interruption but check link status
> > by itself, PF APP can let VF know link status changed.
> >
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > ---
> >  drivers/net/i40e/Makefile                 |  4 ++-
> >  drivers/net/i40e/i40e_ethdev.c            | 28 +++++++++++++++
> >  drivers/net/i40e/i40e_pf.c                |  4 +--
> >  drivers/net/i40e/i40e_pf.h                |  4 ++-
> >  drivers/net/i40e/rte_pmd_i40e.h           | 58
> > +++++++++++++++++++++++++++++++
> >  drivers/net/i40e/rte_pmd_i40e_version.map |  7 ++++
> >  6 files changed, 101 insertions(+), 4 deletions(-)  create mode
> > 100644 drivers/net/i40e/rte_pmd_i40e.h
> >
> > diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
> > index 66997b6..a2ef53c 100644
> > --- a/drivers/net/i40e/Makefile
> > +++ b/drivers/net/i40e/Makefile
> > @@ -1,6 +1,6 @@
> >  #   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
> > @@ -111,6 +111,8 @@ ifeq ($(findstring
> > RTE_MACHINE_CPUFLAG_SSE4_1,$(CFLAGS)),)
> >  CFLAGS_i40e_rxtx_vec_sse.o += -msse4.1  endif
> >
> > +# install this header file
> > +SYMLINK-$(CONFIG_RTE_LIBRTE_I40E_PMD)-include := rte_pmd_i40e.h
> >
> >  # this lib depends upon:
> >  DEPDIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += lib/librte_eal
> > lib/librte_ether diff --git a/drivers/net/i40e/i40e_ethdev.c
> > b/drivers/net/i40e/i40e_ethdev.c index f42f4ba..fc7e987 100644
> > --- a/drivers/net/i40e/i40e_ethdev.c
> > +++ b/drivers/net/i40e/i40e_ethdev.c
> > @@ -62,6 +62,7 @@
> >  #include "i40e_rxtx.h"
> >  #include "i40e_pf.h"
> >  #include "i40e_regs.h"
> > +#include "rte_pmd_i40e.h"
> >
> >  #define ETH_I40E_FLOATING_VEB_ARG	"enable_floating_veb"
> >  #define ETH_I40E_FLOATING_VEB_LIST_ARG	"floating_veb_list"
> > @@ -9695,3 +9696,30 @@ static void i40e_set_default_mac_addr(struct
> > rte_eth_dev *dev,
> >
> >  	return ret;
> >  }
> > +
> > +int
> > +rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf) {
> > +	struct rte_eth_dev *dev;
> > +	struct rte_eth_dev_info dev_info;
> > +	struct i40e_pf *pf;
> > +
> > +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
> > +
> > +	dev = &rte_eth_devices[port];
> > +	rte_eth_dev_info_get(port, &dev_info);
> > +
> > +	if (vf >= dev_info.max_vfs)
> > +		return -EINVAL;
> > +
> > +	pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
> > +
> > +	if (vf > pf->vf_num - 1 || !pf->vfs) {
> How about
> if (!pf->vfs || vf > pf->vf_num - 1) {
> because if vf_num is 0, the pf->vfs will be NULL.
Thanks for the comments. 
As the number can be 0, how about change the code to?
if (vf >= pf->vf_num || !pf->vfs) {

> 
> Thanks
> Jingjing

Patch
diff mbox

diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 66997b6..a2ef53c 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -1,6 +1,6 @@ 
 #   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
@@ -111,6 +111,8 @@  ifeq ($(findstring RTE_MACHINE_CPUFLAG_SSE4_1,$(CFLAGS)),)
 CFLAGS_i40e_rxtx_vec_sse.o += -msse4.1
 endif
 
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_I40E_PMD)-include := rte_pmd_i40e.h
 
 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += lib/librte_eal lib/librte_ether
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f42f4ba..fc7e987 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -62,6 +62,7 @@ 
 #include "i40e_rxtx.h"
 #include "i40e_pf.h"
 #include "i40e_regs.h"
+#include "rte_pmd_i40e.h"
 
 #define ETH_I40E_FLOATING_VEB_ARG	"enable_floating_veb"
 #define ETH_I40E_FLOATING_VEB_LIST_ARG	"floating_veb_list"
@@ -9695,3 +9696,30 @@  static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
 
 	return ret;
 }
+
+int
+rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf)
+{
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+	struct i40e_pf *pf;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+	rte_eth_dev_info_get(port, &dev_info);
+
+	if (vf >= dev_info.max_vfs)
+		return -EINVAL;
+
+	pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+
+	if (vf > pf->vf_num - 1 || !pf->vfs) {
+		PMD_DRV_LOG(ERR, "Invalid argument.");
+		return -EINVAL;
+	}
+
+	i40e_notify_vf_link_status(dev, &pf->vfs[vf]);
+
+	return 0;
+}
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index ddfc140..f70712b 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_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
@@ -897,7 +897,7 @@ 
 	return ret;
 }
 
-static void
+void
 i40e_notify_vf_link_status(struct rte_eth_dev *dev, struct i40e_pf_vf *vf)
 {
 	struct i40e_virtchnl_pf_event event;
diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h
index cddc45c..59bf2ee 100644
--- a/drivers/net/i40e/i40e_pf.h
+++ b/drivers/net/i40e/i40e_pf.h
@@ -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
@@ -123,5 +123,7 @@  void i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 				uint8_t *msg, uint16_t msglen);
 int i40e_pf_host_init(struct rte_eth_dev *dev);
 int i40e_pf_host_uninit(struct rte_eth_dev *dev);
+void i40e_notify_vf_link_status(struct rte_eth_dev *dev,
+				struct i40e_pf_vf *vf);
 
 #endif /* _I40E_PF_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
new file mode 100644
index 0000000..14852f2
--- /dev/null
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -0,0 +1,58 @@ 
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright (c) 2016 Intel Corporation. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file rte_pmd_i40e.h
+ * i40e PMD specific functions.
+ *
+ **/
+
+#ifndef _PMD_I40E_H_
+#define _PMD_I40E_H_
+
+#include <rte_ethdev.h>
+
+/**
+ * Notify VF when PF link status changes.
+ *
+ * @param port
+ *   The port identifier of the Ethernet device.
+ * @param vf
+ *   VF id.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if *vf* invalid.
+ */
+int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
+
+#endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ef35398..3c6a192 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -2,3 +2,10 @@  DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_17.02 {
+	global:
+
+	rte_pmd_i40e_ping_vfs;
+
+} DPDK_2.0;