[dpdk-dev] [PATCH v3] i40: fix the VXLAN TSO issue

2016-07-18 Thread Zhe Tao
Problem:
When using the TSO + VXLAN feature in i40e, the outer UDP length fields in
the multiple UDP segments which are TSOed by the i40e will have a
wrong value.

Fix this problem by adding the tunnel type field in the i40e descriptor
which was missed before.

Fixes: 77b8301733c3 ("i40e: VXLAN Tx checksum offload")

Signed-off-by: Zhe Tao 
---
v2: edited the comments
v3: added external IP offload flag when TSO is enabled for tunnelling packets

 app/test-pmd/csumonly.c  | 29 +
 drivers/net/i40e/i40e_rxtx.c | 12 +---
 lib/librte_mbuf/rte_mbuf.h   | 16 +++-
 3 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index ac4bd8f..aaa006f 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -204,7 +204,8 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct 
testpmd_offload_info *info)
 static void
 parse_vxlan(struct udp_hdr *udp_hdr,
struct testpmd_offload_info *info,
-   uint32_t pkt_type)
+   uint32_t pkt_type,
+   uint64_t *ol_flags)
 {
struct ether_hdr *eth_hdr;

@@ -215,6 +216,7 @@ parse_vxlan(struct udp_hdr *udp_hdr,
RTE_ETH_IS_TUNNEL_PKT(pkt_type) == 0)
return;

+   *ol_flags |= PKT_TX_TUNNEL_VXLAN;
info->is_tunnel = 1;
info->outer_ethertype = info->ethertype;
info->outer_l2_len = info->l2_len;
@@ -231,7 +233,9 @@ parse_vxlan(struct udp_hdr *udp_hdr,

 /* Parse a gre header */
 static void
-parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
+parse_gre(struct simple_gre_hdr *gre_hdr,
+ struct testpmd_offload_info *info,
+ uint64_t *ol_flags)
 {
struct ether_hdr *eth_hdr;
struct ipv4_hdr *ipv4_hdr;
@@ -242,6 +246,8 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct 
testpmd_offload_info *info)
if ((gre_hdr->flags & _htons(~GRE_SUPPORTED_FIELDS)) != 0)
return;

+   *ol_flags |= PKT_TX_TUNNEL_GRE;
+
gre_len += sizeof(struct simple_gre_hdr);

if (gre_hdr->flags & _htons(GRE_KEY_PRESENT))
@@ -417,7 +423,7 @@ process_inner_cksums(void *l3_hdr, const struct 
testpmd_offload_info *info,
  * packet */
 static uint64_t
 process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info,
-   uint16_t testpmd_ol_flags)
+   uint16_t testpmd_ol_flags, uint64_t orig_ol_flags)
 {
struct ipv4_hdr *ipv4_hdr = outer_l3_hdr;
struct ipv6_hdr *ipv6_hdr = outer_l3_hdr;
@@ -428,7 +434,8 @@ process_outer_cksums(void *outer_l3_hdr, struct 
testpmd_offload_info *info,
ipv4_hdr->hdr_checksum = 0;
ol_flags |= PKT_TX_OUTER_IPV4;

-   if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)
+   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ||
+   (info->tso_segsz != 0))
ol_flags |= PKT_TX_OUTER_IP_CKSUM;
else
ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr);
@@ -442,6 +449,9 @@ process_outer_cksums(void *outer_l3_hdr, struct 
testpmd_offload_info *info,
 * hardware supporting it today, and no API for it. */

udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len);
+   if ((orig_ol_flags & PKT_TX_TCP_SEG) &&
+   ((orig_ol_flags & PKT_TX_TUNNEL_MASK) == PKT_TX_TUNNEL_VXLAN))
+   udp_hdr->dgram_cksum = 0;
/* do not recalculate udp cksum if it was 0 */
if (udp_hdr->dgram_cksum != 0) {
udp_hdr->dgram_cksum = 0;
@@ -705,15 +715,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
if (info.l4_proto == IPPROTO_UDP) {
struct udp_hdr *udp_hdr;
udp_hdr = (struct udp_hdr *)((char *)l3_hdr +
-   info.l3_len);
-   parse_vxlan(udp_hdr, , m->packet_type);
+  info.l3_len);
+   parse_vxlan(udp_hdr, , m->packet_type,
+   _flags);
} else if (info.l4_proto == IPPROTO_GRE) {
struct simple_gre_hdr *gre_hdr;
gre_hdr = (struct simple_gre_hdr *)
((char *)l3_hdr + info.l3_len);
-   parse_gre(gre_hdr, );
+   parse_gre(gre_hdr, , _flags);
} else if (info.l4_proto == IPPROTO_IPIP) {
void *encap_ip_hdr;
+
+   ol_flags |= PKT_TX_TUNNEL_IPIP;
encap_ip_hdr = (char *)l3_hdr + info.l3_len;

[dpdk-dev] [PATCH v2] i40: fix the VXLAN TSO issue

2016-07-18 Thread Zhe Tao
On Thu, Jul 07, 2016 at 08:24:43PM +0800, Ananyev, Konstantin wrote:
> 
> 
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ananyev, Konstantin
> > Sent: Thursday, July 07, 2016 11:51 AM
> > To: Tao, Zhe; dev at dpdk.org
> > Cc: Tao, Zhe; Wu, Jingjing
> > Subject: Re: [dpdk-dev] [PATCH v2] i40: fix the VXLAN TSO issue
> > 
> > 
> > > > @@ -215,6 +216,7 @@ parse_vxlan(struct udp_hdr *udp_hdr,
> > > > RTE_ETH_IS_TUNNEL_PKT(pkt_type) == 0)
> > > > return;
> > > >
> > > > +   *ol_flags |= PKT_TX_TUNNEL_VXLAN;
> 
> Do we always have to setup tunnelling flags here?
> Obviously it would mean an extra CTD per packet and might slowdown things.
this flag is for tunnelling type, and CTD is based on whether we need to do the
external ip offload and TSO.so this flag will not cause one extra CTD.
> In fact, I think current patch wouldn't work correctly if
> TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM is not set.
> So, can we do it only when TSO is enabled or outer IP checksum is enabled?
good comments and I aggree with you to let the APP to make sure all the flags 
driver needed
is set.
> 
> > > > info->is_tunnel = 1;
> > > > info->outer_ethertype = info->ethertype;
> > > > info->outer_l2_len = info->l2_len;
> > > > @@ -231,7 +233,9 @@ parse_vxlan(struct udp_hdr *udp_hdr,
> > > >
> > > > +   testpmd_ol_flags, ol_flags);
> > > > }
> > > >
> > > > /* step 4: fill the mbuf meta data (flags and header 
> > > > lengths) */
> > > > diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
> > > > index 049a813..4c987f2 100644
> > > > --- a/drivers/net/i40e/i40e_rxtx.c
> > > > +++ b/drivers/net/i40e/i40e_rxtx.c
> > > > @@ -801,6 +801,12 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
> > > > union i40e_tx_offload tx_offload,
> > > > uint32_t *cd_tunneling)
> > > >  {
> > > > +   /* Tx pkts tunnel type*/
> > > > +   if ((ol_flags & PKT_TX_TUNNEL_MASK) == PKT_TX_TUNNEL_VXLAN)
> > > > +   *cd_tunneling |= I40E_TXD_CTX_UDP_TUNNELING;
> > > > +   else if ((ol_flags & PKT_TX_TUNNEL_MASK) == PKT_TX_TUNNEL_GRE)
> > > > +   *cd_tunneling |= I40E_TXD_CTX_GRE_TUNNELING;
> > > > +
> > 
> > As I understand that fix is needed to enable TSO for tunnelling packets, 
> > correct?
> > For that case, should we setup EIPLEN also, no matter is 
> > PKT_TX_OUTER_IP_CKSUM
> > is on/off?
> 
> In fact, it seems we have always to setup all 3: EIPLEN, MACLEN and L4TUNLEN,
> when L4TUNT != 0.
L4TUNT only means the tunnel type, but if we don't want to do the checksum,
these fields will not be set
> 
> > 
> > > > /* UDP tunneling packet TX checksum offload */
> > > > if (ol_flags & PKT_TX_OUTER_IP_CKSUM) {
> > > >
> > > > @@ -1510,7 +1516,8 @@ i40e_calc_context_desc(uint64_t flags)
thanks again for the commets,
I will resend the patch
Zhe 


[dpdk-dev] [PATCH v2] i40: fix the VXLAN TSO issue

2016-07-07 Thread Zhe Tao
Problem:
When using the TSO + VXLAN feature in i40e, the outer UDP length fields in
the multiple UDP segments which are TSOed by the i40e will have the
wrong value.

Fix this problem by adding the tunnel type field in the i40e descriptor
which was missed before.

Fixes: 77b8301733c3 ("i40e: VXLAN Tx checksum offload")

Signed-off-by: Zhe Tao 
---
V2: Edited some comments for mbuf structure and i40e driver.

 app/test-pmd/csumonly.c  | 26 +++---
 drivers/net/i40e/i40e_rxtx.c | 12 +---
 lib/librte_mbuf/rte_mbuf.h   | 16 +++-
 3 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index ac4bd8f..d423c20 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -204,7 +204,8 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct 
testpmd_offload_info *info)
 static void
 parse_vxlan(struct udp_hdr *udp_hdr,
struct testpmd_offload_info *info,
-   uint32_t pkt_type)
+   uint32_t pkt_type,
+   uint64_t *ol_flags)
 {
struct ether_hdr *eth_hdr;

@@ -215,6 +216,7 @@ parse_vxlan(struct udp_hdr *udp_hdr,
RTE_ETH_IS_TUNNEL_PKT(pkt_type) == 0)
return;

+   *ol_flags |= PKT_TX_TUNNEL_VXLAN;
info->is_tunnel = 1;
info->outer_ethertype = info->ethertype;
info->outer_l2_len = info->l2_len;
@@ -231,7 +233,9 @@ parse_vxlan(struct udp_hdr *udp_hdr,

 /* Parse a gre header */
 static void
-parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
+parse_gre(struct simple_gre_hdr *gre_hdr,
+ struct testpmd_offload_info *info,
+ uint64_t *ol_flags)
 {
struct ether_hdr *eth_hdr;
struct ipv4_hdr *ipv4_hdr;
@@ -242,6 +246,8 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct 
testpmd_offload_info *info)
if ((gre_hdr->flags & _htons(~GRE_SUPPORTED_FIELDS)) != 0)
return;

+   *ol_flags |= PKT_TX_TUNNEL_GRE;
+
gre_len += sizeof(struct simple_gre_hdr);

if (gre_hdr->flags & _htons(GRE_KEY_PRESENT))
@@ -417,7 +423,7 @@ process_inner_cksums(void *l3_hdr, const struct 
testpmd_offload_info *info,
  * packet */
 static uint64_t
 process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info,
-   uint16_t testpmd_ol_flags)
+   uint16_t testpmd_ol_flags, uint64_t orig_ol_flags)
 {
struct ipv4_hdr *ipv4_hdr = outer_l3_hdr;
struct ipv6_hdr *ipv6_hdr = outer_l3_hdr;
@@ -442,6 +448,9 @@ process_outer_cksums(void *outer_l3_hdr, struct 
testpmd_offload_info *info,
 * hardware supporting it today, and no API for it. */

udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len);
+   if ((orig_ol_flags & PKT_TX_TCP_SEG) &&
+   ((orig_ol_flags & PKT_TX_TUNNEL_MASK) == PKT_TX_TUNNEL_VXLAN))
+   udp_hdr->dgram_cksum = 0;
/* do not recalculate udp cksum if it was 0 */
if (udp_hdr->dgram_cksum != 0) {
udp_hdr->dgram_cksum = 0;
@@ -705,15 +714,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
if (info.l4_proto == IPPROTO_UDP) {
struct udp_hdr *udp_hdr;
udp_hdr = (struct udp_hdr *)((char *)l3_hdr +
-   info.l3_len);
-   parse_vxlan(udp_hdr, , m->packet_type);
+  info.l3_len);
+   parse_vxlan(udp_hdr, , m->packet_type,
+   _flags);
} else if (info.l4_proto == IPPROTO_GRE) {
struct simple_gre_hdr *gre_hdr;
gre_hdr = (struct simple_gre_hdr *)
((char *)l3_hdr + info.l3_len);
-   parse_gre(gre_hdr, );
+   parse_gre(gre_hdr, , _flags);
} else if (info.l4_proto == IPPROTO_IPIP) {
void *encap_ip_hdr;
+
+   ol_flags |= PKT_TX_TUNNEL_IPIP;
encap_ip_hdr = (char *)l3_hdr + info.l3_len;
parse_encap_ip(encap_ip_hdr, );
}
@@ -745,7 +757,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 * processed in hardware. */
if (info.is_tunnel == 1) {
ol_flags |= process_outer_cksums(outer_l3_hdr, ,
-   testpmd_ol_flags);
+   testpmd_ol_flags, ol_flags);
}

/* step 4: fill the mbuf meta data (flags and header lengths) */
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 049a813..4c987f2 100644
--- a/

[dpdk-dev] [PATCH v15 2/2] i40e: add device args to enable a floating VEB

2016-06-29 Thread Zhe Tao
The standard Virtual Ethernet Bridge(VEB) definition in 1Qbg is a bridge
which has an uplink port to the outside world (maybe another bridge), but
a "floating" VEB is a special VEB without an uplink port to the outside.
Instead, traffic can be sent from one VF to another using the floating
VEB - even when the physical link on the NIC port is down.

This patch adds floating VEB options in the devargs for i40e driver.
Using these parameters, applications can decide whether to use legacy
VEB/VEPA or a floating VEB.
To enable this feature, the user should pass a devargs parameter to the
EAL, for example "-w 84:00.0,enable_floating_veb=1", to control whether
the PMD will to use the floating VEB feature or not.

Once the floating VEB feature is enabled, all the VFs created by
this PF device are connected to the floating VEB.

NOTE: The floating VEB functionality requires a NIC firmware version
of 5.0 or greater.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  45 ++
 doc/guides/rel_notes/release_16_07.rst |   8 ++
 drivers/net/i40e/i40e_ethdev.c | 160 +
 drivers/net/i40e/i40e_ethdev.h |   5 ++
 4 files changed, 218 insertions(+)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 934eb02..da695af 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,48 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+
+The Intel? Ethernet Controller X710 and XL710 Family support a feature called
+"Floating VEB".
+
+A Virtual Ethernet Bridge (VEB) is an IEEE Edge Virtual Bridging (EVB) term
+for functionality that allows local switching between virtual endpoints within
+a physical endpoint and also with an external bridge/network.
+
+A "Floating" VEB doesn't have an uplink connection to the outside world so all
+switching is done internally and remains within the host. As such, this
+feature provides security benefits.
+
+In addition, a Floating VEB overcomes a limitation of normal VEBs where they
+cannot forward packets when the physical link is down. Floating VEBs don't need
+to connect to the NIC port so they can still forward traffic from VF to VF
+even when the physical link is down.
+
+Therefore, with this feature enabled VFs can be limited to communicating with
+each other but not an outside network, and they can do so even when there is
+no physical uplink on the associated NIC port.
+
+To enable this feature, the user should pass a ``devargs`` parameter to the
+EAL, for example::
+
+-w 84:00.0,enable_floating_veb=1
+
+In this configuration the PMD will use the floating VEB feature for all the
+VFs created by this PF device.
+
+Alternatively, the user can specify which VFs need to connect to this floating
+VEB using the ``floating_veb_list`` argument::
+
+-w 84:00.0,enable_floating_veb=1,floating_veb_list=1;3-4
+
+In this example ``VF1``, ``VF3`` and ``VF4`` connect to the floating VEB,
+while other VFs connect to the normal VEB.
+
+The current implementation only supports one floating VEB and one regular
+VEB. VFs can connect to a floating VEB or a regular VEB according to the
+configuration passed on the EAL command line.
+
+The floating VEB functionality requires a NIC firmware version of 5.0
+or greater.
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 54ebdc7..fc574af 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -132,6 +132,14 @@ New Features
   * A new library ``librte_pdump`` is added to provide packet capture API.
   * A new ``app/pdump`` tool is added to capture packets in DPDK.

+* **Added floating VEB support for i40e PF driver.**
+
+  A "floating VEB" is a special Virtual Ethernet Bridge (VEB) which does not
+  have an upload port, but instead is used for switching traffic between
+  virtual functions (VFs) on a port.
+
+  For information on this feature,  please see the "I40E Poll Mode Driver"
+  section of the "Network Interface Controller Drivers" document.

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 5efcbc2..9ef0727 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -63,6 +63,9 @@
 #include "i40e_pf.h"
 #include "i40e_regs.h"

+#define ETH_I40E_FLOATING_VEB_ARG  "enable_floating_veb"
+#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list"
+
 #define I40E_CLEAR_PXE_WAIT_MS 200

 /* Maximun number of capability elements */
@@ -755,6 +758,161 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
 }

 static int
+floating_veb_list_handler(__rte_unused const char *key,
+ const char *floating_veb_value,
+ void *opaque)
+{

[dpdk-dev] [PATCH v15 1/2] i40e: add floating VEB support

2016-06-29 Thread Zhe Tao
The standard Virtual Ethernet Bridge(VEB) definition in 1Qbg is a bridge
which has an uplink port to the outside world (maybe another bridge),
but a "floating" VEB is a special VEB without an uplink port to the
outside. Instead, traffic can be sent from one VF to another using the
floating VEB - even when the physical link on the NIC port is down.

VFs VSIs connect either to the standard VEB/VEPA or to the floating VEB,
they cannot connect to both of them. The PF, VMDQ and FD VSIs still
connect to the normal VEB/VEPA.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 113 +
 drivers/net/i40e/i40e_ethdev.h |   7 +++
 drivers/net/i40e/i40e_pf.c |  12 -
 3 files changed, 108 insertions(+), 24 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f94ad87..5efcbc2 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3768,21 +3768,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3794,9 +3800,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
-   PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   if (pf == NULL) {
+   PMD_DRV_LOG(ERR,
+   "veb setup failed, associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3808,11 +3814,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
+ I40E_DEFAULT_TCMAP, false,
+ >seid, false, NULL);
+   } else {
+   ret = i40e_aq_add_veb(hw, 0, 0, I40E_DEFAULT_TCMAP,
+ true, >seid, false, NULL);
+   }

if (ret != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Add veb failed, aq_err: %d",
@@ -3828,10 +3842,10 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
hw->aq.asq_last_status);
goto fail;
}
-
/* Get VEB bandwidth, to be implemented */
/* Now associated vsi binding to the VEB, set uplink to this VEB */
-   vsi->uplink_seid = veb->seid;
+   if (vsi)
+   vsi->uplink_seid = veb->seid;

return veb;
 fail:
@@ -3847,6 +3861,7 @@ i40e_vsi_release(struct i40e_vsi *vsi)
struct i40e_vsi_list *vsi_list;
int ret;
struct i40e_mac_filter *f;
+   uint16_t user_param = vsi->user_param;

if (!vsi)
return I40E_SUCCESS;
@@ -3864,12 +3879,22 @@ i40e_vsi_release(struct i40e_vsi *vsi)
i40e_veb_release(vsi->veb);
}

+   if (vsi->floating_veb) {
+   TAILQ_FOREACH(vsi_list, >floating_veb->head, list) {
+   if (i40e_vsi_release(vsi_list->vsi) != I40E_SUCCESS)
+   return -1;
+   TAILQ_REMOVE(>floating_veb->head, vsi_list, list);
+   }
+   }
+
/* Remove all macvlan filters of the VSI */
i40e_vsi_remove_all_macvlan_filter(vsi);
TAILQ_FOREACH(f, >mac_list, next)
rte_free(f);

-   if (vsi->type != I40E_VSI_MAIN)

[dpdk-dev] [PATCH v15 0/2] i40e: add floating VEB support for i40e

2016-06-29 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W which newer
than 5.0.

Zhe Tao (2):
 i40e: add floating VEB support
 i40e: add device args to enable a floating VEB

 doc/guides/nics/i40e.rst   |  45 ++
 doc/guides/rel_notes/release_16_07.rst |   8 +
 drivers/net/i40e/i40e_ethdev.c | 273 ++---
 drivers/net/i40e/i40e_ethdev.h |  12 ++
 drivers/net/i40e/i40e_pf.c |  12 +-
 5 files changed, 326 insertions(+), 24 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
V8: removed global reset and added floating VEB extension support 
V9: Added floating VEB related explanation into commit log 
V10: Changed third patch commit log 
V11: Fixed the issues reported by check-git-log.sh 
V12: Changed the floating VEB VF bitmask to VF list 
V13: Changed some internal functions'names to make it more clear 
V14: Changed some internal variable names 
V15: Changed the sequence of patches and add more explanation
 for floating VEB 
-- 
2.1.4



[dpdk-dev] [PATCH v14 2/2] i40e: add floating VEB support in i40e

2016-06-27 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in
the 802.1Qbg spec.

The floating VEB feature is only available for the FW version which
newer than 5.0 (FW major version number > 5).

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  27 
 doc/guides/rel_notes/release_16_07.rst |   4 ++
 drivers/net/i40e/i40e_ethdev.c | 112 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  12 +++-
 5 files changed, 134 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 934eb02..1ce60ab 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,30 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+
+The floating VEB means the VEB doesn't has some uplink connection to the 
outside
+world, so all the switching belong to this VEB cannot go to outside, the
+security can be assured. Because the floating VEB doesn't need to connect to
+the MAC port, so when the physical port link is down, all the switching within
+this VEB still works fine, but for legacy VEB when the physical port is down
+the VEB cannot forward packets anymore.
+
+With this feature, VFs can communicate with each other, but cannot access
+outside network. When PF is down, and VFs can still forward pkts between each
+other.
+
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floating_veb=1", and then the PMD will use the floating
+VEB feature for all the VFs created by this PF device.
+Also you can specify which VF need to connect to this floating veb using
+"floating_veb_list".
+Like "-w 84:00.0,enable_floating_veb=1,floating_veb_list=1/3-4", means VF1, 
VF3,
+VF4 connect to the floating VEB, other VFs connect to the legacy VEB.The "/"
+is used for delimiter of the floating VEB list.
+
+The current implementation only support one floating VEB and one legacy
+VEB. VF can connect to floating VEB or legacy VEB according to the
+configuration.
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..1752c40 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -47,6 +47,10 @@ New Features
   * Dropped specific Xen Dom0 code.
   * Dropped specific anonymous mempool code in testpmd.

+* **Added floating VEB support for i40e PF driver.**
+
+  More details please see floating VEB part in the document
+  doc/guides/nics/i40e.rst.

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 553ef56..b6abd1c 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3878,21 +3878,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3904,9 +3910,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3918,11 +3924,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

[dpdk-dev] [PATCH v14 1/2] i40e: support floating VEB config

2016-06-27 Thread Zhe Tao
Add the new floating related argument option in the devarg.
Using this parameter, all the applications can decide whether to use legacy
VEB/VEPA or floating VEB.
To enable this feature, the user should pass a devargs parameter to the
EAL like "-w 84:00.0,enable_floating_veb=1", and the application will
tell PMD whether to use the floating VEB feature or not.
Once the floating VEB feature is enabled, all the VFs created by
this PF device are connected to the floating VEB.

All the VEB/VEPA concepts are not specific for FVL, they are defined in
the 802.1Qbg spec. But the floating VEB concept is from i40e data sheet.

The standard VEB definition in 1Qbg is a bridge which has a uplink port
to the outside world (maybe another bridge), but floating means this
special VEB has no uplink port to the outside.

For floating VEB, it has two major difference comparing to
the standard VEB:
1. doesn't has a up link connection which means
the traffic cannot go to outside world.
2. doesn't need to connect to the physical port which means
when the physical link is down the floating VEB can still works
fine.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 160 +
 drivers/net/i40e/i40e_ethdev.h |  10 +++
 2 files changed, 170 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..553ef56 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -63,6 +63,9 @@
 #include "i40e_pf.h"
 #include "i40e_regs.h"

+#define ETH_I40E_FLOATING_VEB_ARG  "enable_floating_veb"
+#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list"
+
 #define I40E_CLEAR_PXE_WAIT_MS 200

 /* Maximun number of capability elements */
@@ -751,6 +754,161 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
 }

 static int
+floating_veb_list_handler(__rte_unused const char *key,
+ const char *floating_veb_value,
+ void *opaque)
+{
+   int idx = 0;
+   unsigned count = 0;
+   char *end = NULL;
+   int min, max;
+   bool *vf_floating_veb = opaque;
+
+   while (isblank(*floating_veb_value))
+   floating_veb_value++;
+
+   /* Reset floating VEB configuration for VFs */
+   for (idx = 0; idx < I40E_MAX_VF; idx++)
+   vf_floating_veb[idx] = false;
+
+   min = I40E_MAX_VF;
+   do {
+   while (isblank(*floating_veb_value))
+   floating_veb_value++;
+   if (*floating_veb_value == '\0')
+   return -1;
+   errno = 0;
+   idx = strtoul(floating_veb_value, , 10);
+   if (errno || end == NULL)
+   return -1;
+   while (isblank(*end))
+   end++;
+   if (*end == '-') {
+   min = idx;
+   } else if ((*end == '/') || (*end == '\0')) {
+   max = idx;
+   if (min == I40E_MAX_VF)
+   min = idx;
+   if (max >= I40E_MAX_VF)
+   max = I40E_MAX_VF - 1;
+   for (idx = min; idx <= max; idx++) {
+   vf_floating_veb[idx] = true;
+   count++;
+   }
+   min = I40E_MAX_VF;
+   } else {
+   return -1;
+   }
+   floating_veb_value = end + 1;
+   } while (*end != '\0');
+
+   if (count == 0)
+   return -1;
+
+   return 0;
+}
+
+static void
+config_vf_floating_veb(struct rte_devargs *devargs,
+  uint16_t floating_veb,
+  bool *vf_floating_veb)
+{
+   struct rte_kvargs *kvlist;
+   int i;
+   const char *floating_veb_list = ETH_I40E_FLOATING_VEB_LIST_ARG;
+
+   if (floating_veb == false)
+   return;
+   /* All the VFs attach to the floating VEB by default
+* when the floating VEB is enabled.
+*/
+   for (i = 0; i < I40E_MAX_VF; i++)
+   vf_floating_veb[i] = true;
+
+   if (devargs == NULL)
+   return;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return;
+
+   if (!rte_kvargs_count(kvlist, floating_veb_list)) {
+   rte_kvargs_free(kvlist);
+   return;
+   }
+   /* When the floating_veb_list parameter exists, all the VFs
+* will attach to the legacy VEB firstly, then configure VFs
+* to the floating VEB according to the floating_veb_list.
+*/
+   if (rte_kvargs_process(kvlist, floating_veb_list,
+  floating_veb_list_handler,
+  vf_floating_veb) < 0) {
+   rte_kvargs_fre

[dpdk-dev] [PATCH v14 0/2] i40e: add floating VEB support for i40e

2016-06-27 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W which newer
than 5.0.

Zhe Tao (2):
  i40e: support floating VEB config
  i40e: add floating VEB support in i40e

 doc/guides/nics/i40e.rst   |  27 
 doc/guides/rel_notes/release_16_07.rst |   4 +
 drivers/net/i40e/i40e_ethdev.c | 272 ++---
 drivers/net/i40e/i40e_ethdev.h |  12 ++
 drivers/net/i40e/i40e_pf.c |  12 +-
 5 files changed, 304 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
V8: removed global reset and added floating VEB extension support 
V9: Added floating VEB related explanation into commit log 
V10: Changed third patch commit log 
V11: Fixed the issues reported by check-git-log.sh 
V12: Changed the floating VEB VF bitmask to VF list 
V13: Changed some internal functions'names to make it more clear 
V14: Changed some internal variable names 

-- 
2.1.4



[dpdk-dev] [PATCH v13 2/2] i40e: add floating VEB support in i40e

2016-06-27 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in
the 802.1Qbg spec.

The floating VEB feature is only available for the FW version which
newer than 5.0 (FW major version number > 5).

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  27 
 doc/guides/rel_notes/release_16_07.rst |   4 ++
 drivers/net/i40e/i40e_ethdev.c | 112 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  12 +++-
 5 files changed, 134 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 934eb02..1ce60ab 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,30 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+
+The floating VEB means the VEB doesn't has some uplink connection to the 
outside
+world, so all the switching belong to this VEB cannot go to outside, the
+security can be assured. Because the floating VEB doesn't need to connect to
+the MAC port, so when the physical port link is down, all the switching within
+this VEB still works fine, but for legacy VEB when the physical port is down
+the VEB cannot forward packets anymore.
+
+With this feature, VFs can communicate with each other, but cannot access
+outside network. When PF is down, and VFs can still forward pkts between each
+other.
+
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floating_veb=1", and then the PMD will use the floating
+VEB feature for all the VFs created by this PF device.
+Also you can specify which VF need to connect to this floating veb using
+"floating_veb_list".
+Like "-w 84:00.0,enable_floating_veb=1,floating_veb_list=1/3-4", means VF1, 
VF3,
+VF4 connect to the floating VEB, other VFs connect to the legacy VEB.The "/"
+is used for delimiter of the floating VEB list.
+
+The current implementation only support one floating VEB and one legacy
+VEB. VF can connect to floating VEB or legacy VEB according to the
+configuration.
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..1752c40 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -47,6 +47,10 @@ New Features
   * Dropped specific Xen Dom0 code.
   * Dropped specific anonymous mempool code in testpmd.

+* **Added floating VEB support for i40e PF driver.**
+
+  More details please see floating VEB part in the document
+  doc/guides/nics/i40e.rst.

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 553ef56..52c6b9f 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3878,21 +3878,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3904,9 +3910,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3918,11 +3924,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

[dpdk-dev] [PATCH v13 1/2] i40e: support floating VEB config

2016-06-27 Thread Zhe Tao
Add the new floating related argument option in the devarg.
Using this parameter, all the applications can decide whether to use legacy
VEB/VEPA or floating VEB.
To enable this feature, the user should pass a devargs parameter to the
EAL like "-w 84:00.0,enable_floating_veb=1", and the application will
tell PMD whether to use the floating VEB feature or not.
Once the floating VEB feature is enabled, all the VFs created by
this PF device are connected to the floating VEB.

All the VEB/VEPA concepts are not specific for FVL, they are defined in
the 802.1Qbg spec. But the floating VEB concept is from i40e data sheet.

The standard VEB definition in 1Qbg is a bridge which has a uplink port
to the outside world (maybe another bridge), but floating means this
special VEB has no uplink port to the outside.

For floating VEB, it has two major difference comparing to
the standard VEB:
1. doesn't has a up link connection which means
the traffic cannot go to outside world.
2. doesn't need to connect to the physical port which means
when the physical link is down the floating VEB can still works
fine.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 160 +
 drivers/net/i40e/i40e_ethdev.h |  10 +++
 2 files changed, 170 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..553ef56 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -63,6 +63,9 @@
 #include "i40e_pf.h"
 #include "i40e_regs.h"

+#define ETH_I40E_FLOATING_VEB_ARG  "enable_floating_veb"
+#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list"
+
 #define I40E_CLEAR_PXE_WAIT_MS 200

 /* Maximun number of capability elements */
@@ -751,6 +754,161 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
 }

 static int
+floating_veb_list_handler(__rte_unused const char *key,
+ const char *floating_veb_value,
+ void *opaque)
+{
+   int idx = 0;
+   unsigned count = 0;
+   char *end = NULL;
+   int min, max;
+   bool *vf_floating_veb = opaque;
+
+   while (isblank(*floating_veb_value))
+   floating_veb_value++;
+
+   /* Reset floating VEB configuration for VFs */
+   for (idx = 0; idx < I40E_MAX_VF; idx++)
+   vf_floating_veb[idx] = false;
+
+   min = I40E_MAX_VF;
+   do {
+   while (isblank(*floating_veb_value))
+   floating_veb_value++;
+   if (*floating_veb_value == '\0')
+   return -1;
+   errno = 0;
+   idx = strtoul(floating_veb_value, , 10);
+   if (errno || end == NULL)
+   return -1;
+   while (isblank(*end))
+   end++;
+   if (*end == '-') {
+   min = idx;
+   } else if ((*end == '/') || (*end == '\0')) {
+   max = idx;
+   if (min == I40E_MAX_VF)
+   min = idx;
+   if (max >= I40E_MAX_VF)
+   max = I40E_MAX_VF - 1;
+   for (idx = min; idx <= max; idx++) {
+   vf_floating_veb[idx] = true;
+   count++;
+   }
+   min = I40E_MAX_VF;
+   } else {
+   return -1;
+   }
+   floating_veb_value = end + 1;
+   } while (*end != '\0');
+
+   if (count == 0)
+   return -1;
+
+   return 0;
+}
+
+static void
+config_vf_floating_veb(struct rte_devargs *devargs,
+  uint16_t floating_veb,
+  bool *vf_floating_veb)
+{
+   struct rte_kvargs *kvlist;
+   int i;
+   const char *floating_veb_list = ETH_I40E_FLOATING_VEB_LIST_ARG;
+
+   if (floating_veb == false)
+   return;
+   /* All the VFs attach to the floating VEB by default
+* when the floating VEB is enabled.
+*/
+   for (i = 0; i < I40E_MAX_VF; i++)
+   vf_floating_veb[i] = true;
+
+   if (devargs == NULL)
+   return;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return;
+
+   if (!rte_kvargs_count(kvlist, floating_veb_list)) {
+   rte_kvargs_free(kvlist);
+   return;
+   }
+   /* When the floating_veb_list parameter exists, all the VFs
+* will attach to the legacy VEB firstly, then configure VFs
+* to the floating VEB according to the floating_veb_list.
+*/
+   if (rte_kvargs_process(kvlist, floating_veb_list,
+  floating_veb_list_handler,
+  vf_floating_veb) < 0) {
+   rte_kvargs_fre

[dpdk-dev] [PATCH v13 0/2] i40e: add floating VEB support for i40e

2016-06-27 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W which newer
than 5.0.

Zhe Tao (2):
  i40e: support floating VEB config
  i40e: add floating VEB support in i40e

 doc/guides/nics/i40e.rst   |  27 
 doc/guides/rel_notes/release_16_07.rst |   4 +
 drivers/net/i40e/i40e_ethdev.c | 272 ++---
 drivers/net/i40e/i40e_ethdev.h |  12 ++
 drivers/net/i40e/i40e_pf.c |  12 +-
 5 files changed, 304 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
V8: removed global reset and added floating VEB extension support 
V9: Added floating VEB related explanation into commit log 
V10: Changed third patch commit log 
V11: Fixed the issues reported by check-git-log.sh 
V12: Changed the floating VEB VF bitmask to VF list 
V13: Changed some internal functions'names to make it more clear 

-- 
2.1.4



[dpdk-dev] [PATCH v12 1/2] i40e: support floating VEB config

2016-06-27 Thread Zhe Tao
On Fri, Jun 24, 2016 at 12:14:14PM +0100, Ferruh Yigit wrote:
> Hi Zhe,
> 
> On 6/24/2016 9:29 AM, Zhe Tao wrote:
> > Add the new floating VEB related arguments option in the devarg.
> > Using this parameter, all the applications can decide whether to use legacy
> > VEB/VEPA or floating VEB.
> > To enable this feature, the user should pass a devargs parameter to the
> > EAL like "-w 84:00.0,enable_floating_veb=1", and the application will
> > tell PMD whether to use the floating VEB feature or not.
> Is providing the enable_floating_veb=1 devarg enough, or should
> application call an driver API to enable this feature, if so documenting
> what application needs to do helps app developers.
yes only provide the devarg is enough, the APP don't need to modify.
> 
> > Once the floating VEB feature is enabled, all the VFs created by
> > this PF device are connected to the floating VEB.
> Technically there can be multiple floating VEBs, right? And with this
> param only one floating VEB created and all VFs connected to it. Is
> there any use case to create multiple VEBs with selective VFs connected
> to them?
discuss this feature internally with Walter and FAE team, have an agreement
for this release we only implement one floating VEB.
> 
> > 
> > Also user can specify which VF need to connect to this floating veb using
> > "floating_veb_list".
> > Like "-w 84:00.0,enable_floating_veb=1,floating_veb_list=1/3-4", means VF1, 
> > VF3,
> > VF4 connect to the floating VEB, other VFs connect to the legacy VEB.The "/"
> > is used for delimiter of the floating VEB list.
> Is there a use case to change VF VEB connection on runtime?
maybe there is a case, but from the customer requirement, we only support the 
static
configuration for floating VEB.

> 
> > 
> > All the VEB/VEPA concepts are not specific for FVL, they are defined in
> > the 802.1Qbg spec.
> > 
> > But for floating VEB, it has two major difference.
> > 1. doesn't has a up link connection which means
> > the traffic cannot go to outside world.
> > 2. doesn't need to connect to the physical port which means
> > when the physical link is down the floating VEB can still works
> > fine.
> > 
> > Signed-off-by: Zhe Tao 
> > ---
> 
> ...
> 
> >  
> > +static int vf_floating_veb_handler(__rte_unused const char *key,
> What about floating_veb_list_handler, to be consistent with argument name?
> 
> > +  const char *floating_veb_value,
> > +  void *opaque)
> > +{
> > +   int idx = 0;
> > +   bool floating_veb; /* The flag to use the floating VEB */
> > +   /* The floating enable flag for the specific VF */
> > +   bool vf_floating_veb[I40E_MAX_VF];
> what about floating_veb_list, to be consistent with argument name?
> 
> >  };
> >  
> >  enum pending_msg {
> > 
All the comments in the code is great, I changed the code according to your
comments,
thanks again
Zhe 


[dpdk-dev] [PATCH v12 2/2] i40e: add floating VEB support in i40e

2016-06-24 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in
the 802.1Qbg spec.

The floating VEB feature is only available for the FW version which
newer than 5.0 (FW major version number > 5).

To enable this feature, the user should pass a devargs parameter to the
EAL like "-w 84:00.0,enable_floating_veb=1", and the application use
this method to tell PMD to connect all the VFs created by
this PF device to the floating VEB.

Also you can specify which VF need to connect to this floating veb using
"floating_veb_list".
Like "-w 84:00.0,enable_floating_veb=1,floating_veb_list=1/3-4", means VF1, VF3,
VF4 connect to the floating VEB, other VFs connect to the legacy VEB.The "/"
is used for delimiter of the floating VEB list.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  27 
 doc/guides/rel_notes/release_16_07.rst |   4 ++
 drivers/net/i40e/i40e_ethdev.c | 112 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  12 +++-
 5 files changed, 134 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 934eb02..1ce60ab 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,30 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+
+The floating VEB means the VEB doesn't has some uplink connection to the 
outside
+world, so all the switching belong to this VEB cannot go to outside, the
+security can be assured. Because the floating VEB doesn't need to connect to
+the MAC port, so when the physical port link is down, all the switching within
+this VEB still works fine, but for legacy VEB when the physical port is down
+the VEB cannot forward packets anymore.
+
+With this feature, VFs can communicate with each other, but cannot access
+outside network. When PF is down, and VFs can still forward pkts between each
+other.
+
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floating_veb=1", and then the PMD will use the floating
+VEB feature for all the VFs created by this PF device.
+Also you can specify which VF need to connect to this floating veb using
+"floating_veb_list".
+Like "-w 84:00.0,enable_floating_veb=1,floating_veb_list=1/3-4", means VF1, 
VF3,
+VF4 connect to the floating VEB, other VFs connect to the legacy VEB.The "/"
+is used for delimiter of the floating VEB list.
+
+The current implementation only support one floating VEB and one legacy
+VEB. VF can connect to floating VEB or legacy VEB according to the
+configuration.
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..1752c40 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -47,6 +47,10 @@ New Features
   * Dropped specific Xen Dom0 code.
   * Dropped specific anonymous mempool code in testpmd.

+* **Added floating VEB support for i40e PF driver.**
+
+  More details please see floating VEB part in the document
+  doc/guides/nics/i40e.rst.

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index b304fc3..4673619 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3860,21 +3860,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS

[dpdk-dev] [PATCH v12 1/2] i40e: support floating VEB config

2016-06-24 Thread Zhe Tao
Add the new floating VEB related arguments option in the devarg.
Using this parameter, all the applications can decide whether to use legacy
VEB/VEPA or floating VEB.
To enable this feature, the user should pass a devargs parameter to the
EAL like "-w 84:00.0,enable_floating_veb=1", and the application will
tell PMD whether to use the floating VEB feature or not.
Once the floating VEB feature is enabled, all the VFs created by
this PF device are connected to the floating VEB.

Also user can specify which VF need to connect to this floating veb using
"floating_veb_list".
Like "-w 84:00.0,enable_floating_veb=1,floating_veb_list=1/3-4", means VF1, VF3,
VF4 connect to the floating VEB, other VFs connect to the legacy VEB.The "/"
is used for delimiter of the floating VEB list.

All the VEB/VEPA concepts are not specific for FVL, they are defined in
the 802.1Qbg spec.

But for floating VEB, it has two major difference.
1. doesn't has a up link connection which means
the traffic cannot go to outside world.
2. doesn't need to connect to the physical port which means
when the physical link is down the floating VEB can still works
fine.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 142 +
 drivers/net/i40e/i40e_ethdev.h |  10 +++
 2 files changed, 152 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..b304fc3 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -63,6 +63,9 @@
 #include "i40e_pf.h"
 #include "i40e_regs.h"

+#define ETH_I40E_FLOATING_VEB_ARG  "enable_floating_veb"
+#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list"
+
 #define I40E_CLEAR_PXE_WAIT_MS 200

 /* Maximun number of capability elements */
@@ -750,6 +753,136 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int vf_floating_veb_handler(__rte_unused const char *key,
+  const char *floating_veb_value,
+  void *opaque)
+{
+   int idx = 0;
+   unsigned count = 0;
+   char *end = NULL;
+   int min, max;
+   bool *vf_floating_veb = opaque;
+
+   while (isblank(*floating_veb_value))
+   floating_veb_value++;
+
+   /* Reset floating VEB configuration for VFs */
+   for (idx = 0; idx < I40E_MAX_VF; idx++)
+   vf_floating_veb[idx] = false;
+
+   min = I40E_MAX_VF;
+   do {
+   while (isblank(*floating_veb_value))
+   floating_veb_value++;
+   if (*floating_veb_value == '\0')
+   return -1;
+   errno = 0;
+   idx = strtoul(floating_veb_value, , 10);
+   if (errno || end == NULL)
+   return -1;
+   while (isblank(*end))
+   end++;
+   if (*end == '-') {
+   min = idx;
+   } else if ((*end == '/') || (*end == '\0')) {
+   max = idx;
+   if (min == I40E_MAX_VF)
+   min = idx;
+   if (max >= I40E_MAX_VF)
+   max = I40E_MAX_VF - 1;
+   for (idx = min; idx <= max; idx++) {
+   vf_floating_veb[idx] = true;
+   count++;
+   }
+   min = I40E_MAX_VF;
+   } else {
+   return -1;
+   }
+   floating_veb_value = end + 1;
+   } while (*end != '\0');
+
+   if (count == 0)
+   return -1;
+
+   return 0;
+}
+
+static void config_vf_floating_veb(struct rte_devargs *devargs,
+  uint16_t floating,
+  bool *vf_floating_veb)
+{
+   struct rte_kvargs *kvlist;
+   int i;
+   const char *floating_veb_list = ETH_I40E_FLOATING_VEB_LIST_ARG;
+
+   if (floating == false)
+   return;
+   for (i = 0; i < I40E_MAX_VF; i++)
+   vf_floating_veb[i] = true;
+
+   if (devargs == NULL)
+   return;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return;
+
+   if (!rte_kvargs_count(kvlist, floating_veb_list)) {
+   rte_kvargs_free(kvlist);
+   return;
+   }
+
+   if (rte_kvargs_process(kvlist, floating_veb_list,
+  vf_floating_veb_handler,
+  vf_floating_veb) < 0) {
+   rte_kvargs_free(kvlist);
+   return;
+   }
+   rte_kvargs_free(kvlist);
+
+   return;
+}
+
+static int i40e_check_floating_handler(__rte_unused const char *key,
+

[dpdk-dev] [PATCH v12 0/2] i40e: add floating VEB support for i40e

2016-06-24 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W which newer
than 5.0.

Zhe Tao (2):
  i40e: support floating VEB config
  i40e: add floating VEB support in i40e

 doc/guides/nics/i40e.rst   |  27 
 doc/guides/rel_notes/release_16_07.rst |   4 +
 drivers/net/i40e/i40e_ethdev.c | 254 ++---
 drivers/net/i40e/i40e_ethdev.h |  12 ++
 drivers/net/i40e/i40e_pf.c |  12 +-
 5 files changed, 286 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
V8: removed global reset and added floating VEB extension support 
V9: Added floating VEB related explanation into commit log 
V10: Changed third patch commit log 
V11: Fixed the issues reported by check-git-log.sh 
V12: Changed the floating VEB VF bitmask to VF list 

-- 
2.1.4



[dpdk-dev] [PATCH v11 3/3] i40e: add floating VEB extension support

2016-06-14 Thread Zhe Tao
To enable this feature, the user should pass a devargs parameter to the
EAL like "-w 84:00.0,enable_floatingVEB=1", and the application will make
sure the PMD will use the floating VEB feature for all the VFs created by
this PF device.

Also you can specifiy which VF need to connect to this floating veb using
"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
Like "-w 84:00.0,enable_floatingVEB=1,floating_bitmap=1", means only the
VF0 connect to the floating VEB, VF1 connect to the legacy VEB.

The current implementation only support one floating VEB and one legacy
VEB. VF can connect to floating VEB or legacy VEB according to the
configuration.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  8 ++
 drivers/net/i40e/i40e_ethdev.c | 56 --
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_pf.c |  3 ++-
 4 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index aae78ca..a34d91a 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -372,6 +372,14 @@ FVL can support floating VEB feature.
 To enable this feature, the user should pass a devargs parameter to the EAL
 like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the
 PMD will use the floating VEB feature for all the VFs created by this PF 
device.
+Also you can specify which VF need to connect to this floating veb using
+"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
+Like "-w 84:00.0,enable_floatingVEB=1,floating_bitmap=1", means only the VF0
+connect to the floating VEB, VF1 connect to the legacy VEB.
+
+The current implementation only support one floating VEB and one legacy
+VEB. VF can connect to floating VEB or legacy VEB according to the
+configuration.

 The floating VEB means the VEB doesn't has some uplink connection to the 
outside
 world, so all the switching belong to this VEB cannot go to outside, the
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 025d498..17aaa08 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,52 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_fbitmap_handler(__rte_unused const char *key,
+ const char *value,
+ void *opaque)
+{
+   errno = 0;
+   *(uint16_t *)opaque = strtoul(value, NULL, 0);
+   if (errno)
+   return -1;
+   return 0;
+}
+
+static uint16_t i40e_check_fbitmap(struct rte_devargs *devargs,
+  uint16_t floating)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_bitmap = "floating_bitmap";
+   /* default value for vf floating bitmap is -1 */
+   uint16_t vf_fbitmap = (uint16_t)-1;
+   uint16_t new_vf_fbitmap;
+
+   if (floating == false)
+   return 0;
+
+   if (devargs == NULL)
+   return vf_fbitmap;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return vf_fbitmap;
+
+   if (!rte_kvargs_count(kvlist, floating_bitmap)) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   /* Floating is enabled when there's key-value: enable_floatingVEB=1 */
+   if (rte_kvargs_process(kvlist, floating_bitmap,
+  i40e_check_fbitmap_handler,
+  _vf_fbitmap) < 0) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   rte_kvargs_free(kvlist);
+
+   return new_vf_fbitmap;
+}
+
 static int i40e_check_floating_handler(__rte_unused const char *key,
   const char *value,
   __rte_unused void *opaque)
@@ -884,8 +930,11 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
/* Need the special FW version support floating VEB */
if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
pf->floating = i40e_check_floating(pci_dev->devargs);
+   pf->vf_fbitmap = i40e_check_fbitmap(pci_dev->devargs,
+   pf->floating);
} else {
pf->floating = false;
+   pf->vf_fbitmap = 0;
}
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);
@@ -3855,6 +3904,7 @@ i40e_vsi_release(struct i40e_vsi *vsi)
struct i40e_vsi_list *vsi_list;
int ret;
struct i40e_mac_filter *f;
+   uint16_t user_param = vsi->user_param;

if (!vsi)
return I40E_SUCCESS;
@@ -3886,7 +3936,8 @@ i40e_vsi_release(struct i40e_vsi *vsi)
 

[dpdk-dev] [PATCH v11 2/3] i40e: add floating VEB support in i40e

2016-06-14 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in
the 802.1Qbg spec.

Now the floating VEB feature is only avaiable for the FW version which
newer than 5.0 (FW major version number > 5).

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  17 +
 doc/guides/rel_notes/release_16_07.rst |   4 ++
 drivers/net/i40e/i40e_ethdev.c | 109 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 120 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 934eb02..aae78ca 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,20 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the
+PMD will use the floating VEB feature for all the VFs created by this PF 
device.
+
+The floating VEB means the VEB doesn't has some uplink connection to the 
outside
+world, so all the switching belong to this VEB cannot go to outside, the
+security can be assured. Because the floating VEB doesn't need to connect to
+the MAC port, so when the physical port link is down, all the switching within
+this VEB still works fine, but for legacy VEB when the physical port is down
+the VEB cannot forward packets anymore.
+
+With this feature, VFs can communicate with each other, but cannot access
+outside network. When PF is down, and VFs can still forward pkts between each
+other.
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..1752c40 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -47,6 +47,10 @@ New Features
   * Dropped specific Xen Dom0 code.
   * Dropped specific anonymous mempool code in testpmd.

+* **Added floating VEB support for i40e PF driver.**
+
+  More details please see floating VEB part in the document
+  doc/guides/nics/i40e.rst.

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 8c4ae1c..025d498 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3762,21 +3762,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3788,9 +3794,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3802,11 +3808,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->

[dpdk-dev] [PATCH v11 1/3] i40e: support floating VEB config

2016-06-14 Thread Zhe Tao
Add the new floating related argument option in the devarg.
Using this parameter, all the samples can decide whether to use legacy
VEB/VEPA or floating VEB.
To enable this feature, the user should pass a devargs parameter to the
EAL like "-w 84:00.0,enable_floatingVEB=1", and the application will make
sure the PMD will use the floating VEB feature for all the VFs created by
this PF device.

All the VEB/VEPA concepts are not specific for FVL, they are defined in
the 802.1Qbg spec.

But for floating VEB, it has two major difference.
1. doesn't has a up link connection which means
the traffic cannot go to ouside world.
2. doesn't need to connect to the phsical port which means
when the physical link is down the floating VEB can still works
fine.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 44 ++
 drivers/net/i40e/i40e_ethdev.h |  6 ++
 2 files changed, 50 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..8c4ae1c 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,44 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_floating_handler(__rte_unused const char *key,
+  const char *value,
+  __rte_unused void *opaque)
+{
+   if (strcmp(value, "1"))
+   return -1;
+
+   return 0;
+}
+
+static int
+i40e_check_floating(struct rte_devargs *devargs)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_key = "enable_floatingVEB";
+
+   if (devargs == NULL)
+   return 0;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return 0;
+
+   if (!rte_kvargs_count(kvlist, floating_key)) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   /* Floating is enabled when there's key-value: enable_floatingVEB=1 */
+   if (rte_kvargs_process(kvlist, floating_key,
+  i40e_check_floating_handler, NULL) < 0) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   rte_kvargs_free(kvlist);
+
+   return 1;
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -843,6 +881,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

+   /* Need the special FW version support floating VEB */
+   if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
+   pf->floating = i40e_check_floating(pci_dev->devargs);
+   } else {
+   pf->floating = false;
+   }
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..8297c5f 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -36,6 +36,7 @@

 #include 
 #include 
+#include 

 #define I40E_VLAN_TAG_SIZE4

@@ -171,6 +172,10 @@ enum i40e_flxpld_layer_idx {
 #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
 #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */

+/* Special FW support this floating VEB feature */
+#define FLOATING_FW_MAJ 5
+#define FLOATING_FW_MIN 0
+
 struct i40e_adapter;

 /**
@@ -450,6 +455,7 @@ struct i40e_pf {
struct i40e_fc_conf fc_conf; /* Flow control conf */
struct i40e_mirror_rule_list mirror_list;
uint16_t nb_mirror_rule;   /* The number of mirror rules */
+   uint16_t floating; /* The flag to use the floating VEB */
 };

 enum pending_msg {
-- 
2.1.4



[dpdk-dev] [PATCH v11 0/3] i40e: add floating VEB support for i40e

2016-06-14 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W which newer
than 5.0.

Zhe Tao (3):
  i40e: support floating VEB config
  i40e: add floating VEB support in i40e
  i40e: add floating VEB extension support

 doc/guides/nics/i40e.rst   |  25 
 doc/guides/rel_notes/release_16_07.rst |   4 +
 drivers/net/i40e/i40e_ethdev.c | 205 +
 drivers/net/i40e/i40e_ethdev.h |   9 ++
 drivers/net/i40e/i40e_pf.c |  12 +-
 5 files changed, 232 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
V8: removed global reset and added floating VEB extension support 
V9: Added floating VEB related explanation into commit log 
V10: Changed third patch commit log 
V11: Fixed the issues reported by check-git-log.sh 

-- 
2.1.4



[dpdk-dev] [PATCH v3] i40e: fix olflags for vector Rx

2016-06-14 Thread Zhe Tao
Problem:
The flag for RSS and flow director is not set correctly in the
vector Rx function, so the upper layer APP which base on the related
flags will not work correctly.

Fix this problem by change the shuffle table. the original shuffle
table is not correct.

Fixes: 9ed94e5bb04e ("i40e: add vector Rx")

Signed-off-by: Zhe Tao 
---
v2: Changed the comments according to the code change.
v3: Fixed the issues reported by check-git-log.sh.

 drivers/net/i40e/i40e_rxtx_vec.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx_vec.c b/drivers/net/i40e/i40e_rxtx_vec.c
index eef80d9..704924f 100644
--- a/drivers/net/i40e/i40e_rxtx_vec.c
+++ b/drivers/net/i40e/i40e_rxtx_vec.c
@@ -144,12 +144,13 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
uint64_t dword;
} vol;

-   /* mask everything except rss and vlan flags
-   *bit2 is for vlan tag, bits 13:12 for rss
-   */
+   /* mask everything except RSS, flow director and VLAN flags
+* bit2 is for VLAN tag, bit11 for flow director indication
+* bit13:12 for RSS indication.
+*/
const __m128i rss_vlan_msk = _mm_set_epi16(
0x, 0x, 0x, 0x,
-   0x3004, 0x3004, 0x3004, 0x3004);
+   0x3804, 0x3804, 0x3804, 0x3804);

/* map rss and vlan type to rss hash and vlan flag */
const __m128i vlan_flags = _mm_set_epi8(0, 0, 0, 0,
@@ -159,8 +160,8 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)

const __m128i rss_flags = _mm_set_epi8(0, 0, 0, 0,
0, 0, 0, 0,
-   0, 0, 0, 0,
-   PKT_RX_FDIR, 0, PKT_RX_RSS_HASH, 0);
+   PKT_RX_RSS_HASH | PKT_RX_FDIR, PKT_RX_RSS_HASH, 0, 0,
+   0, 0, PKT_RX_FDIR, 0);

vlan0 = _mm_unpackhi_epi16(descs[0], descs[1]);
vlan1 = _mm_unpackhi_epi16(descs[2], descs[3]);
@@ -169,7 +170,7 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
vlan1 = _mm_and_si128(vlan0, rss_vlan_msk);
vlan0 = _mm_shuffle_epi8(vlan_flags, vlan1);

-   rss = _mm_srli_epi16(vlan1, 12);
+   rss = _mm_srli_epi16(vlan1, 11);
rss = _mm_shuffle_epi8(rss_flags, rss);

vlan0 = _mm_or_si128(vlan0, rss);
-- 
2.1.4



[dpdk-dev] [PATCH v11 0/3] i40e: add floating VEB support for i40e

2016-06-14 Thread Zhe Tao
On Tue, Jun 14, 2016 at 01:57:11PM +0800, Zhe Tao wrote:
> This patch-set add the support for floating VEB in i40e.
> All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
> the floating VEB. When connect to the floating VEB a new floating VEB is
> created. Now all the VFs need to connect to floating VEB or legacy VEB,
> cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
> the old legacy VEB/VEPA.
> 
> All the VEB/VEPA concepts are not specific for FVL, they are defined in the
> 802.1Qbg spec.
> 
> This floating VEB only take effects on the specific version F/W which newer
> than 5.0.
> 
> Zhe Tao (3):
>   i40e: support floating VEB config
>   i40e: add floating VEB support in i40e
>   i40e: add floating VEB extension support
> 
>  doc/guides/nics/i40e.rst   |  25 
>  doc/guides/rel_notes/release_16_07.rst |   4 +
>  drivers/net/i40e/i40e_ethdev.c | 205 
> +
>  drivers/net/i40e/i40e_ethdev.h |   9 ++
>  drivers/net/i40e/i40e_pf.c |  12 +-
>  5 files changed, 232 insertions(+), 23 deletions(-)
> 
> V2: Added the release notes and changed commit log. 
> V3: Changed the VSI release operation. 
> V4: Added the FW version check otherwise it will cause the segment fault.
> V5: Edited the code for new share code APIs
> V6: Changed the floating VEB configuration method 
> V7: Added global reset for i40e 
> V8: removed global reset and added floating VEB extension support 
> V9: Added floating VEB related explanation into commit log 
> V10: Changed third patch commit log 
> V11: Fixed the issues reported by check-git-log.sh 
> 
> -- 
> 2.1.4
Acked-by: Jingjing Wu 


[dpdk-dev] [PATCH v10 3/3] i40e: add floating VEB extension support

2016-06-13 Thread Zhe Tao
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the 
PMD
will use the floating VEB feature for all the VFs created by this PF device.

Also you can specifiy which VF need to connect to this floating veb using
"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
Like "-w 84:00.0,enable_floatingVEB=1,floating_bitmap=1", means only the VF0 
connect
to the floating VEB, VF1 connect to the legacy VEB.

The current implementation only support one floating VEB and one legacy
VEB. VF can connect to floating VEB or legacy VEB according to the
configuration.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  8 ++
 drivers/net/i40e/i40e_ethdev.c | 56 --
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_pf.c |  3 ++-
 4 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index aae78ca..d3196ad 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -372,6 +372,14 @@ FVL can support floating VEB feature.
 To enable this feature, the user should pass a devargs parameter to the EAL
 like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the
 PMD will use the floating VEB feature for all the VFs created by this PF 
device.
+Also you can specify which VF need to connect to this floating veb using
+"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
+Like "-w 84:00.0,enable_floatingVEB=1,floating_bitmap=1", means only the VF0
+connect to the floating VEB, VF1 connect to the legacy VEB.
+
+The current implementation only support one floating VEB and one legacy
+VEB. VF can connect to floating VEB or legacy VEB according to the
+configuration. 

 The floating VEB means the VEB doesn't has some uplink connection to the 
outside
 world, so all the switching belong to this VEB cannot go to outside, the
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 025d498..17aaa08 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,52 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_fbitmap_handler(__rte_unused const char *key,
+ const char *value,
+ void *opaque)
+{
+   errno = 0;
+   *(uint16_t *)opaque = strtoul(value, NULL, 0);
+   if (errno)
+   return -1;
+   return 0;
+}
+
+static uint16_t i40e_check_fbitmap(struct rte_devargs *devargs,
+  uint16_t floating)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_bitmap = "floating_bitmap";
+   /* default value for vf floating bitmap is -1 */
+   uint16_t vf_fbitmap = (uint16_t)-1;
+   uint16_t new_vf_fbitmap;
+
+   if (floating == false)
+   return 0;
+
+   if (devargs == NULL)
+   return vf_fbitmap;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return vf_fbitmap;
+
+   if (!rte_kvargs_count(kvlist, floating_bitmap)) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   /* Floating is enabled when there's key-value: enable_floatingVEB=1 */
+   if (rte_kvargs_process(kvlist, floating_bitmap,
+  i40e_check_fbitmap_handler,
+  _vf_fbitmap) < 0) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   rte_kvargs_free(kvlist);
+
+   return new_vf_fbitmap;
+}
+
 static int i40e_check_floating_handler(__rte_unused const char *key,
   const char *value,
   __rte_unused void *opaque)
@@ -884,8 +930,11 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
/* Need the special FW version support floating VEB */
if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
pf->floating = i40e_check_floating(pci_dev->devargs);
+   pf->vf_fbitmap = i40e_check_fbitmap(pci_dev->devargs,
+   pf->floating);
} else {
pf->floating = false;
+   pf->vf_fbitmap = 0;
}
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);
@@ -3855,6 +3904,7 @@ i40e_vsi_release(struct i40e_vsi *vsi)
struct i40e_vsi_list *vsi_list;
int ret;
struct i40e_mac_filter *f;
+   uint16_t user_param = vsi->user_param;

if (!vsi)
return I40E_SUCCESS;
@@ -3886,7 +3936,8 @@ i40e_vsi_release(struct i40e_vsi *vsi)
 

[dpdk-dev] [PATCH v10 2/3] i40e: add floating VEB support in i40e

2016-06-13 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

Now the floating VEB feature is only avaiable for the FW version which
newer than 5.0 (FW major version number > 5).

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  17 +
 doc/guides/rel_notes/release_16_07.rst |   4 ++
 drivers/net/i40e/i40e_ethdev.c | 109 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 120 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 934eb02..aae78ca 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,20 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the
+PMD will use the floating VEB feature for all the VFs created by this PF 
device.
+
+The floating VEB means the VEB doesn't has some uplink connection to the 
outside
+world, so all the switching belong to this VEB cannot go to outside, the
+security can be assured. Because the floating VEB doesn't need to connect to
+the MAC port, so when the physical port link is down, all the switching within
+this VEB still works fine, but for legacy VEB when the physical port is down
+the VEB cannot forward packets anymore.
+
+With this feature, VFs can communicate with each other, but cannot access
+outside network. When PF is down, and VFs can still forward pkts between each
+other.
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..686b683 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -47,6 +47,10 @@ New Features
   * Dropped specific Xen Dom0 code.
   * Dropped specific anonymous mempool code in testpmd.

+* **Added floating VEB support for i40e PF driver.**
+
+  More details please see floating VEB part in the document
+  doc/guides/nics/i40e.rst. 

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 8c4ae1c..025d498 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3762,21 +3762,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3788,9 +3794,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3802,11 +3808,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->

[dpdk-dev] [PATCH v10 1/3] i40e: support floating VEB config

2016-06-13 Thread Zhe Tao
Add the new floating related argument option in the devarg.
Using this parameter, all the samples can decide whether to use legacy VEB/VEPA
or floating VEB.
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the 
PMD
will use the floating VEB feature for all the VFs created by this PF device.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

But for floating VEB, it has two major difference.
1. doesn't has a up link connection which means
the traffic cannot go to ouside world.
2. doesn't need to connect to the phsical port which means
when the physical link is down the floating VEB can still works
fine.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 44 ++
 drivers/net/i40e/i40e_ethdev.h |  6 ++
 2 files changed, 50 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..8c4ae1c 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,44 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_floating_handler(__rte_unused const char *key,
+  const char *value,
+  __rte_unused void *opaque)
+{
+   if (strcmp(value, "1"))
+   return -1;
+
+   return 0;
+}
+
+static int
+i40e_check_floating(struct rte_devargs *devargs)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_key = "enable_floatingVEB";
+
+   if (devargs == NULL)
+   return 0;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return 0;
+
+   if (!rte_kvargs_count(kvlist, floating_key)) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   /* Floating is enabled when there's key-value: enable_floatingVEB=1 */
+   if (rte_kvargs_process(kvlist, floating_key,
+  i40e_check_floating_handler, NULL) < 0) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   rte_kvargs_free(kvlist);
+
+   return 1;
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -843,6 +881,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

+   /* Need the special FW version support floating VEB */
+   if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
+   pf->floating = i40e_check_floating(pci_dev->devargs);
+   } else {
+   pf->floating = false;
+   }
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..8297c5f 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -36,6 +36,7 @@

 #include 
 #include 
+#include 

 #define I40E_VLAN_TAG_SIZE4

@@ -171,6 +172,10 @@ enum i40e_flxpld_layer_idx {
 #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
 #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */

+/* Special FW support this floating VEB feature */
+#define FLOATING_FW_MAJ 5
+#define FLOATING_FW_MIN 0
+
 struct i40e_adapter;

 /**
@@ -450,6 +455,7 @@ struct i40e_pf {
struct i40e_fc_conf fc_conf; /* Flow control conf */
struct i40e_mirror_rule_list mirror_list;
uint16_t nb_mirror_rule;   /* The number of mirror rules */
+   uint16_t floating; /* The flag to use the floating VEB */
 };

 enum pending_msg {
-- 
2.1.4



[dpdk-dev] [PATCH v10 0/3] i40e: add floating VEB support for i40e

2016-06-13 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W which newer
than 5.0.

Zhe Tao (3):
  Support floating VEB config
  Add floating VEB support in i40e
  Add floating VEB extention support for i40e

 doc/guides/nics/i40e.rst   |  25 
 doc/guides/rel_notes/release_16_07.rst |   4 +
 drivers/net/i40e/i40e_ethdev.c | 205 +
 drivers/net/i40e/i40e_ethdev.h |   9 ++
 drivers/net/i40e/i40e_pf.c |  12 +-
 5 files changed, 232 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
V8: removed global reset and added floating VEB extension support 
V9: Added floating VEB related explanation into commit log 
V10: Changed third patch commit log 

-- 
2.1.4



[dpdk-dev] [PATCH v9 3/3] i40e: add floating VEB extension support

2016-06-13 Thread Zhe Tao
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floating=1", and the application will make sure the PMD
will use the floating VEB feature for all the VFs created by this PF device.

Also you can specifiy which VF need to connect to this floating veb using
"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
Like "-w 84:00.0,enable_floating=1,floating_bitmap=1", means only the VF0 
connect
to the floating VEB, VF1 connect to the legacy VEB.

The current implementation only support one floating VEB and one legacy
VEB. VF can connect to floating VEB or legacy VEB according to the
configuration.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  8 ++
 drivers/net/i40e/i40e_ethdev.c | 56 --
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_pf.c |  3 ++-
 4 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index aae78ca..d3196ad 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -372,6 +372,14 @@ FVL can support floating VEB feature.
 To enable this feature, the user should pass a devargs parameter to the EAL
 like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the
 PMD will use the floating VEB feature for all the VFs created by this PF 
device.
+Also you can specify which VF need to connect to this floating veb using
+"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
+Like "-w 84:00.0,enable_floatingVEB=1,floating_bitmap=1", means only the VF0
+connect to the floating VEB, VF1 connect to the legacy VEB.
+
+The current implementation only support one floating VEB and one legacy
+VEB. VF can connect to floating VEB or legacy VEB according to the
+configuration. 

 The floating VEB means the VEB doesn't has some uplink connection to the 
outside
 world, so all the switching belong to this VEB cannot go to outside, the
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 025d498..17aaa08 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,52 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_fbitmap_handler(__rte_unused const char *key,
+ const char *value,
+ void *opaque)
+{
+   errno = 0;
+   *(uint16_t *)opaque = strtoul(value, NULL, 0);
+   if (errno)
+   return -1;
+   return 0;
+}
+
+static uint16_t i40e_check_fbitmap(struct rte_devargs *devargs,
+  uint16_t floating)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_bitmap = "floating_bitmap";
+   /* default value for vf floating bitmap is -1 */
+   uint16_t vf_fbitmap = (uint16_t)-1;
+   uint16_t new_vf_fbitmap;
+
+   if (floating == false)
+   return 0;
+
+   if (devargs == NULL)
+   return vf_fbitmap;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return vf_fbitmap;
+
+   if (!rte_kvargs_count(kvlist, floating_bitmap)) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   /* Floating is enabled when there's key-value: enable_floatingVEB=1 */
+   if (rte_kvargs_process(kvlist, floating_bitmap,
+  i40e_check_fbitmap_handler,
+  _vf_fbitmap) < 0) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   rte_kvargs_free(kvlist);
+
+   return new_vf_fbitmap;
+}
+
 static int i40e_check_floating_handler(__rte_unused const char *key,
   const char *value,
   __rte_unused void *opaque)
@@ -884,8 +930,11 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
/* Need the special FW version support floating VEB */
if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
pf->floating = i40e_check_floating(pci_dev->devargs);
+   pf->vf_fbitmap = i40e_check_fbitmap(pci_dev->devargs,
+   pf->floating);
} else {
pf->floating = false;
+   pf->vf_fbitmap = 0;
}
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);
@@ -3855,6 +3904,7 @@ i40e_vsi_release(struct i40e_vsi *vsi)
struct i40e_vsi_list *vsi_list;
int ret;
struct i40e_mac_filter *f;
+   uint16_t user_param = vsi->user_param;

if (!vsi)
return I40E_SUCCESS;
@@ -3886,7 +3936,8 @@ i40e_vsi_release(struct i40e_vsi *vsi)
   

[dpdk-dev] [PATCH v9 2/3] i40e: add floating VEB support in i40e

2016-06-13 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

Now the floating VEB feature is only avaiable for the FW version which
newer than 5.0 (FW major version number > 5).

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  17 +
 doc/guides/rel_notes/release_16_07.rst |   4 ++
 drivers/net/i40e/i40e_ethdev.c | 109 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 120 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 934eb02..aae78ca 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,20 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the
+PMD will use the floating VEB feature for all the VFs created by this PF 
device.
+
+The floating VEB means the VEB doesn't has some uplink connection to the 
outside
+world, so all the switching belong to this VEB cannot go to outside, the
+security can be assured. Because the floating VEB doesn't need to connect to
+the MAC port, so when the physical port link is down, all the switching within
+this VEB still works fine, but for legacy VEB when the physical port is down
+the VEB cannot forward packets anymore.
+
+With this feature, VFs can communicate with each other, but cannot access
+outside network. When PF is down, and VFs can still forward pkts between each
+other.
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..686b683 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -47,6 +47,10 @@ New Features
   * Dropped specific Xen Dom0 code.
   * Dropped specific anonymous mempool code in testpmd.

+* **Added floating VEB support for i40e PF driver.**
+
+  More details please see floating VEB part in the document
+  doc/guides/nics/i40e.rst. 

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 8c4ae1c..025d498 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3762,21 +3762,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3788,9 +3794,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3802,11 +3808,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->

[dpdk-dev] [PATCH v9 1/3] i40e: support floating VEB config

2016-06-13 Thread Zhe Tao
Add the new floating related argument option in the devarg.
Using this parameter, all the samples can decide whether to use legacy VEB/VEPA
or floating VEB.
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floatingVEB=1", and the application will make sure the 
PMD
will use the floating VEB feature for all the VFs created by this PF device.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

But for floating VEB, it has two major difference.
1. doesn't has a up link connection which means
the traffic cannot go to ouside world.
2. doesn't need to connect to the phsical port which means
when the physical link is down the floating VEB can still works
fine.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 44 ++
 drivers/net/i40e/i40e_ethdev.h |  6 ++
 2 files changed, 50 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..8c4ae1c 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,44 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_floating_handler(__rte_unused const char *key,
+  const char *value,
+  __rte_unused void *opaque)
+{
+   if (strcmp(value, "1"))
+   return -1;
+
+   return 0;
+}
+
+static int
+i40e_check_floating(struct rte_devargs *devargs)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_key = "enable_floatingVEB";
+
+   if (devargs == NULL)
+   return 0;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return 0;
+
+   if (!rte_kvargs_count(kvlist, floating_key)) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   /* Floating is enabled when there's key-value: enable_floatingVEB=1 */
+   if (rte_kvargs_process(kvlist, floating_key,
+  i40e_check_floating_handler, NULL) < 0) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   rte_kvargs_free(kvlist);
+
+   return 1;
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -843,6 +881,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

+   /* Need the special FW version support floating VEB */
+   if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
+   pf->floating = i40e_check_floating(pci_dev->devargs);
+   } else {
+   pf->floating = false;
+   }
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..8297c5f 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -36,6 +36,7 @@

 #include 
 #include 
+#include 

 #define I40E_VLAN_TAG_SIZE4

@@ -171,6 +172,10 @@ enum i40e_flxpld_layer_idx {
 #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
 #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */

+/* Special FW support this floating VEB feature */
+#define FLOATING_FW_MAJ 5
+#define FLOATING_FW_MIN 0
+
 struct i40e_adapter;

 /**
@@ -450,6 +455,7 @@ struct i40e_pf {
struct i40e_fc_conf fc_conf; /* Flow control conf */
struct i40e_mirror_rule_list mirror_list;
uint16_t nb_mirror_rule;   /* The number of mirror rules */
+   uint16_t floating; /* The flag to use the floating VEB */
 };

 enum pending_msg {
-- 
2.1.4



[dpdk-dev] [PATCH v9 0/3] i40e: add floating VEB support for i40e

2016-06-13 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W which newer
than 5.0.

Zhe Tao (3):
  Support floating VEB config
  Add floating VEB support in i40e
  Add floating VEB extention support for i40e

 doc/guides/nics/i40e.rst   |  25 
 doc/guides/rel_notes/release_16_07.rst |   4 +
 drivers/net/i40e/i40e_ethdev.c | 205 +
 drivers/net/i40e/i40e_ethdev.h |   9 ++
 drivers/net/i40e/i40e_pf.c |  12 +-
 5 files changed, 232 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
V8: removed global reset and added floating VEB extension support 
V9: Added floating VEB related explanation into commit log 

-- 
2.1.4



[dpdk-dev] [PATCH v2] i40e: fix olflags for vector RX

2016-06-13 Thread Zhe Tao
Problem:
The flag for RSS and flow director is not set correctly in the
vector RX function, so the upper layer APP which base on the related
flags will not work correctly.

Fix this problem by change the shuffle table. the original shuffle
table is not correct.

Fixes: 9ed94 (i40e: add vector Rx)

Signed-off-by: Zhe Tao 
---
v2: Changed the comments according to the code change.

 drivers/net/i40e/i40e_rxtx_vec.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx_vec.c b/drivers/net/i40e/i40e_rxtx_vec.c
index eef80d9..dd113f3 100644
--- a/drivers/net/i40e/i40e_rxtx_vec.c
+++ b/drivers/net/i40e/i40e_rxtx_vec.c
@@ -144,12 +144,13 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
uint64_t dword;
} vol;

-   /* mask everything except rss and vlan flags
-   *bit2 is for vlan tag, bits 13:12 for rss
-   */
+   /* mask everything except RSS, flow director and VLAN flags
+* bit2 is for VLAN tag, bit11 for flow director indication
+* bit13:12 for RSS indication. 
+*/
const __m128i rss_vlan_msk = _mm_set_epi16(
0x, 0x, 0x, 0x,
-   0x3004, 0x3004, 0x3004, 0x3004);
+   0x3804, 0x3804, 0x3804, 0x3804);

/* map rss and vlan type to rss hash and vlan flag */
const __m128i vlan_flags = _mm_set_epi8(0, 0, 0, 0,
@@ -159,8 +160,8 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)

const __m128i rss_flags = _mm_set_epi8(0, 0, 0, 0,
0, 0, 0, 0,
-   0, 0, 0, 0,
-   PKT_RX_FDIR, 0, PKT_RX_RSS_HASH, 0);
+   PKT_RX_RSS_HASH | PKT_RX_FDIR, PKT_RX_RSS_HASH, 0, 0,
+   0, 0, PKT_RX_FDIR, 0);

vlan0 = _mm_unpackhi_epi16(descs[0], descs[1]);
vlan1 = _mm_unpackhi_epi16(descs[2], descs[3]);
@@ -169,7 +170,7 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
vlan1 = _mm_and_si128(vlan0, rss_vlan_msk);
vlan0 = _mm_shuffle_epi8(vlan_flags, vlan1);

-   rss = _mm_srli_epi16(vlan1, 12);
+   rss = _mm_srli_epi16(vlan1, 11);
rss = _mm_shuffle_epi8(rss_flags, rss);

vlan0 = _mm_or_si128(vlan0, rss);
-- 
2.1.4



[dpdk-dev] [PATCH v4 8/8] i40e: implement device reset on VF

2016-06-07 Thread Zhe Tao
Implement the device reset function.
1, Add the fake RX/TX functions.
2, The reset function tries to stop RX/TX by replacing
   the RX/TX functions with the fake ones and getting the
   locks to make sure the regular RX/TX finished.
3, After the RX/TX stopped, reset the VF port, and then
   release the locks.

Signed-off-by: Zhe Tao 
---
 doc/guides/rel_notes/release_16_07.rst |   5 ++
 drivers/net/i40e/i40e_ethdev.h |   7 +-
 drivers/net/i40e/i40e_ethdev_vf.c  | 152 -
 drivers/net/i40e/i40e_rxtx.c   |  10 +++
 drivers/net/i40e/i40e_rxtx.h   |   4 +
 5 files changed, 172 insertions(+), 6 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index a4c0cc3..f43b867 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -62,6 +62,11 @@ New Features
   callback in the message handler to notice the APP. APP need call the device
   reset API to reset the VF port.

+* **Added VF reset support for i40e VF driver.**
+
+  Added a new implementaion to allow i40e VF driver to
+  reset the functionality and state of itself.
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 672d920..dcd6e0f 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -541,9 +541,8 @@ struct i40e_adapter {
struct rte_timecounter rx_tstamp_tc;
struct rte_timecounter tx_tstamp_tc;

-   /* For VF reset backup */
-   eth_rx_burst_t rx_backup;
-   eth_tx_burst_t tx_backup;
+   /* For VF reset */
+   uint8_t reset_number;
 };

 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
@@ -597,6 +596,8 @@ void i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t 
queue_id,
 void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
struct rte_eth_txq_info *qinfo);

+void i40evf_emulate_vf_reset(uint8_t port_id);
+
 /* I40E_DEV_PRIVATE_TO */
 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
(&((struct i40e_adapter *)adapter)->pf)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 46d8a7c..d873d2d 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -157,6 +157,12 @@ i40evf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, 
uint16_t queue_id);
 static void i40evf_handle_pf_event(__rte_unused struct rte_eth_dev *dev,
   uint8_t *msg,
   uint16_t msglen);
+static int i40evf_dev_uninit(struct rte_eth_dev *eth_dev);
+static int i40evf_dev_init(struct rte_eth_dev *eth_dev);
+static void i40evf_dev_close(struct rte_eth_dev *dev);
+static int i40evf_dev_start(struct rte_eth_dev *dev);
+static int i40evf_dev_configure(struct rte_eth_dev *dev);
+static int i40evf_handle_vf_reset(struct rte_eth_dev *dev);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
@@ -223,6 +229,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
.reta_query   = i40evf_dev_rss_reta_query,
.rss_hash_update  = i40evf_dev_rss_hash_update,
.rss_hash_conf_get= i40evf_dev_rss_hash_conf_get,
+   .dev_reset= i40evf_handle_vf_reset
 };

 /*
@@ -1309,6 +1316,140 @@ i40evf_uninit_vf(struct rte_eth_dev *dev)
 }

 static void
+i40e_vf_queue_reset(struct rte_eth_dev *dev)
+{
+   uint16_t i;
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
+
+   if (rxq->q_set) {
+   i40e_dev_rx_queue_setup(dev,
+   rxq->queue_id,
+   rxq->nb_rx_desc,
+   rxq->socket_id,
+   >rxconf,
+   rxq->mp);
+   }
+
+   rxq = dev->data->rx_queues[i];
+   rte_spinlock_trylock(>rx_lock);
+   }
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   struct i40e_tx_queue *txq = dev->data->tx_queues[i];
+
+   if (txq->q_set) {
+   i40e_dev_tx_queue_setup(dev,
+   txq->queue_id,
+   txq->nb_tx_desc,
+   txq->socket_id,
+   >txconf);
+   }
+
+   txq = dev->data->tx_queues[i];
+   rte_spinlock_trylock(>tx_lock);
+   }
+}
+
+static void
+i40e_vf_reset_dev(struct rte_eth_dev *dev)
+{
+   struct i40e_adapter *adapter =
+   I40E_DEV_PRIVATE_TO_ADAPTER(dev-

[dpdk-dev] [PATCH v4 7/8] i40e: RX/TX with lock on VF

2016-06-07 Thread Zhe Tao
Add RX/TX paths with lock for VF. It's used when
the function of link reset on VF is needed.
When the lock for RX/TX is added, the RX/TX can be
stopped. Then we have a chance to reset the VF link.

Please be aware there's performence drop if the lock
path is chosen.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c|  4 ++--
 drivers/net/i40e/i40e_ethdev.h|  4 
 drivers/net/i40e/i40e_ethdev_vf.c |  4 ++--
 drivers/net/i40e/i40e_rxtx.c  | 45 +--
 drivers/net/i40e/i40e_rxtx.h  | 30 ++
 5 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..1380330 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -764,8 +764,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
PMD_INIT_FUNC_TRACE();

dev->dev_ops = _eth_dev_ops;
-   dev->rx_pkt_burst = i40e_recv_pkts;
-   dev->tx_pkt_burst = i40e_xmit_pkts;
+   dev->rx_pkt_burst = RX_LOCK_FUNCTION(dev, i40e_recv_pkts);
+   dev->tx_pkt_burst = TX_LOCK_FUNCTION(dev, i40e_xmit_pkts);

/* for secondary processes, we don't initialise any further as primary
 * has already done this work. Only check we don't need a different
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..672d920 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -540,6 +540,10 @@ struct i40e_adapter {
struct rte_timecounter systime_tc;
struct rte_timecounter rx_tstamp_tc;
struct rte_timecounter tx_tstamp_tc;
+
+   /* For VF reset backup */
+   eth_rx_burst_t rx_backup;
+   eth_tx_burst_t tx_backup;
 };

 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 90682ac..46d8a7c 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1451,8 +1451,8 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)

/* assign ops func pointer */
eth_dev->dev_ops = _eth_dev_ops;
-   eth_dev->rx_pkt_burst = _recv_pkts;
-   eth_dev->tx_pkt_burst = _xmit_pkts;
+   eth_dev->rx_pkt_burst = RX_LOCK_FUNCTION(eth_dev, i40e_recv_pkts);
+   eth_dev->tx_pkt_burst = TX_LOCK_FUNCTION(eth_dev, i40e_xmit_pkts);

/*
 * For secondary processes, we don't initialise any further as primary
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index c833aa3..0a6dcfb 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -79,10 +79,6 @@
PKT_TX_TCP_SEG | \
PKT_TX_OUTER_IP_CKSUM)

-static uint16_t i40e_xmit_pkts_simple(void *tx_queue,
- struct rte_mbuf **tx_pkts,
- uint16_t nb_pkts);
-
 static inline void
 i40e_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union i40e_rx_desc *rxdp)
 {
@@ -1144,7 +1140,7 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
return 0;
 }

-static uint16_t
+uint16_t
 i40e_recv_pkts_bulk_alloc(void *rx_queue,
  struct rte_mbuf **rx_pkts,
  uint16_t nb_pkts)
@@ -1169,7 +1165,7 @@ i40e_recv_pkts_bulk_alloc(void *rx_queue,
return nb_rx;
 }
 #else
-static uint16_t
+uint16_t
 i40e_recv_pkts_bulk_alloc(void __rte_unused *rx_queue,
  struct rte_mbuf __rte_unused **rx_pkts,
  uint16_t __rte_unused nb_pkts)
@@ -1892,7 +1888,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq,
return nb_pkts;
 }

-static uint16_t
+uint16_t
 i40e_xmit_pkts_simple(void *tx_queue,
  struct rte_mbuf **tx_pkts,
  uint16_t nb_pkts)
@@ -2121,10 +2117,13 @@ i40e_dev_supported_ptypes_get(struct rte_eth_dev *dev)
};

if (dev->rx_pkt_burst == i40e_recv_pkts ||
+   dev->rx_pkt_burst == i40e_recv_pkts_lock ||
 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
dev->rx_pkt_burst == i40e_recv_pkts_bulk_alloc ||
+   dev->rx_pkt_burst == i40e_recv_pkts_bulk_alloc_lock ||
 #endif
-   dev->rx_pkt_burst == i40e_recv_scattered_pkts)
+   dev->rx_pkt_burst == i40e_recv_scattered_pkts ||
+   dev->rx_pkt_burst == i40e_recv_scattered_pkts_lock)
return ptypes;
return NULL;
 }
@@ -2648,6 +2647,7 @@ i40e_reset_rx_queue(struct i40e_rx_queue *rxq)

rxq->rxrearm_start = 0;
rxq->rxrearm_nb = 0;
+   rte_spinlock_init(>rx_lock);
 }

 void
@@ -2704,6 +2704,7 @@ i40e_reset_tx_queue(struct i40e_tx_queue *txq)

txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
+   rte_spinl

[dpdk-dev] [PATCH v4 6/8] igb: implement device reset on VF

2016-06-07 Thread Zhe Tao
Implement the device reset function.
1, Add the fake RX/TX functions.
2, The reset function tries to stop RX/TX by replacing
   the RX/TX functions with the fake ones and getting the
   locks to make sure the regular RX/TX finished.
3, After the RX/TX stopped, reset the VF port, and then
   release the locks and restore the RX/TX functions.

BTW: The definition of some structures are moved from .c
file to .h file.

Signed-off-by: Wenzhuo Lu 
---
 doc/guides/rel_notes/release_16_07.rst |   2 +-
 drivers/net/e1000/e1000_ethdev.h   | 116 ++
 drivers/net/e1000/igb_ethdev.c | 104 +++
 drivers/net/e1000/igb_rxtx.c   | 128 ++---
 4 files changed, 243 insertions(+), 107 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index d36c4b1..a4c0cc3 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -53,7 +53,7 @@ New Features
   VF. To handle this link up/down event, add the mailbox interruption
   support to receive the message.

-* **Added device reset support for ixgbe VF.**
+* **Added device reset support for ixgbe/igb VF.**

   Added the device reset API. APP can call this API to reset the VF port
   when it's not working.
diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 6a42994..4ae03ce 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include 
+#include 

 /* need update link, bit flag */
 #define E1000_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
@@ -261,6 +262,113 @@ struct e1000_adapter {
struct rte_timecounter  systime_tc;
struct rte_timecounter  rx_tstamp_tc;
struct rte_timecounter  tx_tstamp_tc;
+   eth_rx_burst_t rx_backup;
+   eth_tx_burst_t tx_backup;
+};
+
+/**
+ * Structure associated with each descriptor of the RX ring of a RX queue.
+ */
+struct igb_rx_entry {
+   struct rte_mbuf *mbuf; /**< mbuf associated with RX descriptor. */
+};
+
+/**
+ * Structure associated with each descriptor of the TX ring of a TX queue.
+ */
+struct igb_tx_entry {
+   struct rte_mbuf *mbuf; /**< mbuf associated with TX desc, if any. */
+   uint16_t next_id; /**< Index of next descriptor in ring. */
+   uint16_t last_id; /**< Index of last scattered descriptor. */
+};
+
+/**
+ * Hardware context number
+ */
+enum igb_advctx_num {
+   IGB_CTX_0= 0, /**< CTX0*/
+   IGB_CTX_1= 1, /**< CTX1*/
+   IGB_CTX_NUM  = 2, /**< CTX_NUM */
+};
+
+/** Offload features */
+union igb_tx_offload {
+   uint64_t data;
+   struct {
+   uint64_t l3_len:9; /**< L3 (IP) Header Length. */
+   uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
+   uint64_t vlan_tci:16;  /**< VLAN Tag Control Identifier(CPU 
order). */
+   uint64_t l4_len:8; /**< L4 (TCP/UDP) Header Length. */
+   uint64_t tso_segsz:16; /**< TCP TSO segment size. */
+
+   /* uint64_t unused:8; */
+   };
+};
+
+/**
+ * Strucutre to check if new context need be built
+ */
+struct igb_advctx_info {
+   uint64_t flags;   /**< ol_flags related to context build. */
+   /** tx offload: vlan, tso, l2-l3-l4 lengths. */
+   union igb_tx_offload tx_offload;
+   /** compare mask for tx offload. */
+   union igb_tx_offload tx_offload_mask;
+};
+
+/**
+ * Structure associated with each RX queue.
+ */
+struct igb_rx_queue {
+   struct rte_mempool  *mb_pool;   /**< mbuf pool to populate RX ring. */
+   volatile union e1000_adv_rx_desc *rx_ring; /**< RX ring virtual 
address. */
+   uint64_trx_ring_phys_addr; /**< RX ring DMA address. */
+   volatile uint32_t   *rdt_reg_addr; /**< RDT register address. */
+   volatile uint32_t   *rdh_reg_addr; /**< RDH register address. */
+   struct igb_rx_entry *sw_ring;   /**< address of RX software ring. */
+   struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
+   struct rte_mbuf *pkt_last_seg;  /**< Last segment of current packet. */
+   rte_spinlock_t  rx_lock; /**< Lock for packet receiption. */
+   uint16_tnb_rx_desc; /**< number of RX descriptors. */
+   uint16_trx_tail;/**< current value of RDT register. */
+   uint16_tnb_rx_hold; /**< number of held free RX desc. */
+   uint16_trx_free_thresh; /**< max free RX desc to hold. */
+   uint16_tqueue_id;   /**< RX queue index. */
+   uint16_treg_idx;/**< RX queue register index. */
+   uint8_t port_id;/**< Device port identifier. */
+   uint8_t pthresh;/**< Prefetch threshold register. */
+   uint8_t hthresh;/**< Host threshold register. */
+   

[dpdk-dev] [PATCH v4 5/8] igb: RX/TX with lock on VF

2016-06-07 Thread Zhe Tao
Add RX/TX paths with lock for VF. It's used when
the function of link reset on VF is needed.
When the lock for RX/TX is added, the RX/TX can be
stopped. Then we have a chance to reset the VF link.

Please be aware there's performence drop if the lock
path is chosen.

Signed-off-by: Wenzhuo Lu 
---
 drivers/net/e1000/e1000_ethdev.h | 10 ++
 drivers/net/e1000/igb_ethdev.c   | 14 +++---
 drivers/net/e1000/igb_rxtx.c | 26 +-
 3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index e8bf8da..6a42994 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -319,6 +319,16 @@ uint16_t eth_igb_recv_pkts(void *rxq, struct rte_mbuf 
**rx_pkts,
 uint16_t eth_igb_recv_scattered_pkts(void *rxq,
struct rte_mbuf **rx_pkts, uint16_t nb_pkts);

+uint16_t eth_igb_xmit_pkts_lock(void *txq,
+   struct rte_mbuf **tx_pkts,
+   uint16_t nb_pkts);
+uint16_t eth_igb_recv_pkts_lock(void *rxq,
+   struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts);
+uint16_t eth_igb_recv_scattered_pkts_lock(void *rxq,
+ struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts);
+
 int eth_igb_rss_hash_update(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf);

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index b0e5e6a..8aad741 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -909,15 +909,17 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
PMD_INIT_FUNC_TRACE();

eth_dev->dev_ops = _eth_dev_ops;
-   eth_dev->rx_pkt_burst = _igb_recv_pkts;
-   eth_dev->tx_pkt_burst = _igb_xmit_pkts;
+   eth_dev->rx_pkt_burst = RX_LOCK_FUNCTION(eth_dev, eth_igb_recv_pkts);
+   eth_dev->tx_pkt_burst = TX_LOCK_FUNCTION(eth_dev, eth_igb_xmit_pkts);

/* for secondary processes, we don't initialise any further as primary
 * has already done this work. Only check we don't need a different
 * RX function */
if (rte_eal_process_type() != RTE_PROC_PRIMARY){
if (eth_dev->data->scattered_rx)
-   eth_dev->rx_pkt_burst = _igb_recv_scattered_pkts;
+   eth_dev->rx_pkt_burst =
+   RX_LOCK_FUNCTION(eth_dev,
+eth_igb_recv_scattered_pkts);
return 0;
}

@@ -1999,7 +2001,13 @@ eth_igb_supported_ptypes_get(struct rte_eth_dev *dev)
};

if (dev->rx_pkt_burst == eth_igb_recv_pkts ||
+#ifndef RTE_NEXT_ABI
dev->rx_pkt_burst == eth_igb_recv_scattered_pkts)
+#else
+   dev->rx_pkt_burst == eth_igb_recv_scattered_pkts ||
+   dev->rx_pkt_burst == eth_igb_recv_pkts_lock ||
+   dev->rx_pkt_burst == eth_igb_recv_scattered_pkts_lock)
+#endif
return ptypes;
return NULL;
 }
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 18aeead..7e97330 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "e1000_logs.h"
 #include "base/e1000_api.h"
@@ -107,6 +108,7 @@ struct igb_rx_queue {
struct igb_rx_entry *sw_ring;   /**< address of RX software ring. */
struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
struct rte_mbuf *pkt_last_seg;  /**< Last segment of current packet. */
+   rte_spinlock_t  rx_lock; /**< Lock for packet receiption. */
uint16_tnb_rx_desc; /**< number of RX descriptors. */
uint16_trx_tail;/**< current value of RDT register. */
uint16_tnb_rx_hold; /**< number of held free RX desc. */
@@ -174,6 +176,7 @@ struct igb_tx_queue {
volatile union e1000_adv_tx_desc *tx_ring; /**< TX ring address */
uint64_t   tx_ring_phys_addr; /**< TX ring DMA address. */
struct igb_tx_entry*sw_ring; /**< virtual address of SW ring. */
+   rte_spinlock_t tx_lock; /**< Lock for packet transmission. */
volatile uint32_t  *tdt_reg_addr; /**< Address of TDT register. */
uint32_t   txd_type;  /**< Device-specific TXD type */
uint16_t   nb_tx_desc;/**< number of TX descriptors. */
@@ -615,6 +618,8 @@ eth_igb_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
return nb_tx;
 }

+GENERATE_TX_LOCK(eth_igb_xmit_pkts, igb)
+
 /*
  *
  *  RX functions
@@ -931,6 +936,8 @@ eth_igb_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
return nb_rx;
 }


[dpdk-dev] [PATCH v4 4/8] ixgbe: implement device reset on VF

2016-06-07 Thread Zhe Tao
Implement the device reset function.
1, Add the fake RX/TX functions.
2, The reset function tries to stop RX/TX by replacing
   the RX/TX functions with the fake ones and getting the
   locks to make sure the regular RX/TX finished.
3, After the RX/TX stopped, reset the VF port, and then
   release the locks and restore the RX/TX functions.

Signed-off-by: Wenzhuo Lu 
---
 doc/guides/rel_notes/release_16_07.rst |   9 +++
 drivers/net/ixgbe/ixgbe_ethdev.c   | 108 -
 drivers/net/ixgbe/ixgbe_ethdev.h   |  12 +++-
 drivers/net/ixgbe/ixgbe_rxtx.c |  42 -
 4 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index a761e3c..d36c4b1 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -53,6 +53,15 @@ New Features
   VF. To handle this link up/down event, add the mailbox interruption
   support to receive the message.

+* **Added device reset support for ixgbe VF.**
+
+  Added the device reset API. APP can call this API to reset the VF port
+  when it's not working.
+  Based on the mailbox interruption support, when VF reseives the control
+  message from PF, it means the PF link state changes, VF uses the reset
+  callback in the message handler to notice the APP. APP need call the device
+  reset API to reset the VF port.
+

 Resolved Issues
 ---
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index fd2682f..1e3520b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -381,6 +381,8 @@ static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev 
*dev,
 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
 struct rte_eth_udp_tunnel *udp_tunnel);

+static int ixgbevf_dev_reset(struct rte_eth_dev *dev);
+
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */
@@ -586,6 +588,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
.reta_query   = ixgbe_dev_rss_reta_query,
.rss_hash_update  = ixgbe_dev_rss_hash_update,
.rss_hash_conf_get= ixgbe_dev_rss_hash_conf_get,
+   .dev_reset= ixgbevf_dev_reset,
 };

 /* store statistics names and its offset in stats structure */
@@ -4060,7 +4063,8 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)
ETH_VLAN_EXTEND_MASK;
ixgbevf_vlan_offload_set(dev, mask);

-   ixgbevf_dev_rxtx_start(dev);
+   if (ixgbevf_dev_rxtx_start(dev))
+   return -1;

/* check and configure queue intr-vector mapping */
if (dev->data->dev_conf.intr_conf.rxq != 0) {
@@ -7193,6 +7197,108 @@ static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
 }

 static int
+ixgbevf_dev_reset(struct rte_eth_dev *dev)
+{
+   struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct ixgbe_adapter *adapter =
+   (struct ixgbe_adapter *)dev->data->dev_private;
+   int diag = 0;
+   uint32_t vteiam;
+   uint16_t i;
+   struct ixgbe_rx_queue *rxq;
+   struct ixgbe_tx_queue *txq;
+
+   /* Nothing needs to be done if the device is not started. */
+   if (!dev->data->dev_started)
+   return 0;
+
+   PMD_DRV_LOG(DEBUG, "Link up/down event detected.");
+
+   /**
+* Stop RX/TX by fake functions and locks.
+* Fake functions are used to make RX/TX lock easier.
+*/
+   adapter->rx_backup = dev->rx_pkt_burst;
+   adapter->tx_backup = dev->tx_pkt_burst;
+   dev->rx_pkt_burst = ixgbevf_recv_pkts_fake;
+   dev->tx_pkt_burst = ixgbevf_xmit_pkts_fake;
+
+   if (dev->data->rx_queues)
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   rxq = dev->data->rx_queues[i];
+   rte_spinlock_lock(>rx_lock);
+   }
+
+   if (dev->data->tx_queues)
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   rte_spinlock_lock(>tx_lock);
+   }
+
+   /* Performance VF reset. */
+   do {
+   dev->data->dev_started = 0;
+   ixgbevf_dev_stop(dev);
+   if (dev->data->dev_conf.intr_conf.lsc == 0)
+   diag = ixgbe_dev_link_update(dev, 0);
+   if (diag) {
+   PMD_INIT_LOG(INFO, "Ixgbe VF reset: "
+"Failed to update link.");
+   }
+   rte_delay_ms(1000);
+
+   diag = ixgbevf_dev_start(dev);
+   /*If fail to start the device, need to stop/start it again. */
+   if (diag) {
+   PMD_INIT_LOG(ERR, "Ixgbe VF reset: "
+"Failed to start device.");
+   

[dpdk-dev] [PATCH v4 3/8] ixgbe: RX/TX with lock on VF

2016-06-07 Thread Zhe Tao
Add RX/TX paths with lock for VF. It's used when
the function of link reset on VF is needed.
When the lock for RX/TX is added, the RX/TX can be
stopped. Then we have a chance to reset the VF link.

Please be aware there's performence drop if the lock
path is chosen.

Signed-off-by: Wenzhuo Lu 
---
 drivers/net/ixgbe/ixgbe_ethdev.c   | 12 +--
 drivers/net/ixgbe/ixgbe_ethdev.h   | 20 +++
 drivers/net/ixgbe/ixgbe_rxtx.c | 74 --
 drivers/net/ixgbe/ixgbe_rxtx.h | 13 +++
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |  6 
 5 files changed, 112 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 05f4f29..fd2682f 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1325,8 +1325,8 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
PMD_INIT_FUNC_TRACE();

eth_dev->dev_ops = _eth_dev_ops;
-   eth_dev->rx_pkt_burst = _recv_pkts;
-   eth_dev->tx_pkt_burst = _xmit_pkts;
+   eth_dev->rx_pkt_burst = RX_LOCK_FUNCTION(eth_dev, ixgbe_recv_pkts);
+   eth_dev->tx_pkt_burst = TX_LOCK_FUNCTION(eth_dev, ixgbe_xmit_pkts);

/* for secondary processes, we don't initialise any further as primary
 * has already done this work. Only check we don't need a different
@@ -3012,7 +3012,15 @@ ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
+#ifndef RTE_NEXT_ABI
dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
+#else
+   dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_lock ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc_lock ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc_lock ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc_lock)
+#endif
return ptypes;
return NULL;
 }
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 4ff6338..701107b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -390,12 +390,32 @@ uint16_t ixgbe_recv_pkts_lro_single_alloc(void *rx_queue,
 uint16_t ixgbe_recv_pkts_lro_bulk_alloc(void *rx_queue,
struct rte_mbuf **rx_pkts, uint16_t nb_pkts);

+uint16_t ixgbe_recv_pkts_lock(void *rx_queue,
+ struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts);
+uint16_t ixgbe_recv_pkts_bulk_alloc_lock(void *rx_queue,
+struct rte_mbuf **rx_pkts,
+uint16_t nb_pkts);
+uint16_t ixgbe_recv_pkts_lro_single_alloc_lock(void *rx_queue,
+  struct rte_mbuf **rx_pkts,
+  uint16_t nb_pkts);
+uint16_t ixgbe_recv_pkts_lro_bulk_alloc_lock(void *rx_queue,
+struct rte_mbuf **rx_pkts,
+uint16_t nb_pkts);
+
 uint16_t ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);

 uint16_t ixgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);

+uint16_t ixgbe_xmit_pkts_lock(void *tx_queue,
+ struct rte_mbuf **tx_pkts,
+ uint16_t nb_pkts);
+uint16_t ixgbe_xmit_pkts_simple_lock(void *tx_queue,
+struct rte_mbuf **tx_pkts,
+uint16_t nb_pkts);
+
 int ixgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
  struct rte_eth_rss_conf *rss_conf);

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 9c6eaf2..a45d115 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -353,6 +353,8 @@ ixgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf 
**tx_pkts,
return nb_tx;
 }

+GENERATE_TX_LOCK(ixgbe_xmit_pkts_simple, ixgbe)
+
 static inline void
 ixgbe_set_xmit_ctx(struct ixgbe_tx_queue *txq,
volatile struct ixgbe_adv_tx_context_desc *ctx_txd,
@@ -904,6 +906,8 @@ end_of_tx:
return nb_tx;
 }

+GENERATE_TX_LOCK(ixgbe_xmit_pkts, ixgbe)
+
 /*
  *
  *  RX functions
@@ -1524,6 +1528,8 @@ ixgbe_recv_pkts_bulk_alloc(void *rx_queue, struct 
rte_mbuf **rx_pkts,
return nb_rx;
 }

+GENERATE_RX_LOCK(ixgbe_recv_pkts_bulk_alloc, ixgbe)
+
 uint16_t
 ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts)
@@ -1712,6 +1718,8 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
return nb_rx;
 }


[dpdk-dev] [PATCH v4 2/8] lib/librte_ether: defind RX/TX lock mode

2016-06-07 Thread Zhe Tao
Define lock mode for RX/TX queue. Because when resetting
the device we want the resetting thread to get the lock
of the RX/TX queue to make sure the RX/TX is stopped.

Using next ABI macro for this ABI change as it has too
much impact. 7 APIs and 1 global variable are impacted.

Signed-off-by: Wenzhuo Lu 
Signed-off-by: Zhe Tao 
---
 lib/librte_ether/rte_ethdev.h | 62 +++
 1 file changed, 62 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 74e895f..4efb5e9 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -354,7 +354,12 @@ struct rte_eth_rxmode {
jumbo_frame  : 1, /**< Jumbo Frame Receipt enable. */
hw_strip_crc : 1, /**< Enable CRC stripping by hardware. */
enable_scatter   : 1, /**< Enable scatter packets rx handler */
+#ifndef RTE_NEXT_ABI
enable_lro   : 1; /**< Enable LRO */
+#else
+   enable_lro   : 1, /**< Enable LRO */
+   lock_mode: 1; /**< Using lock path */
+#endif
 };

 /**
@@ -634,11 +639,68 @@ struct rte_eth_txmode {
/**< If set, reject sending out tagged pkts */
hw_vlan_reject_untagged : 1,
/**< If set, reject sending out untagged pkts */
+#ifndef RTE_NEXT_ABI
hw_vlan_insert_pvid : 1;
/**< If set, enable port based VLAN insertion */
+#else
+   hw_vlan_insert_pvid : 1,
+   /**< If set, enable port based VLAN insertion */
+   lock_mode : 1;
+   /**< If set, using lock path */
+#endif
 };

 /**
+ * The macros for the RX/TX lock mode functions
+ */
+#ifdef RTE_NEXT_ABI
+#define RX_LOCK_FUNCTION(dev, func) \
+   (dev->data->dev_conf.rxmode.lock_mode ? \
+   func ## _lock : func)
+
+#define TX_LOCK_FUNCTION(dev, func) \
+   (dev->data->dev_conf.txmode.lock_mode ? \
+   func ## _lock : func)
+#else
+#define RX_LOCK_FUNCTION(dev, func) func
+
+#define TX_LOCK_FUNCTION(dev, func) func
+#endif
+
+/* Add the lock RX/TX function for VF reset */
+#define GENERATE_RX_LOCK(func, nic) \
+uint16_t func ## _lock(void *rx_queue, \
+ struct rte_mbuf **rx_pkts, \
+ uint16_t nb_pkts) \
+{  \
+   struct nic ## _rx_queue *rxq = rx_queue; \
+   uint16_t nb_rx = 0; \
+   \
+   if (rte_spinlock_trylock(>rx_lock)) { \
+   nb_rx = func(rx_queue, rx_pkts, nb_pkts); \
+   rte_spinlock_unlock(>rx_lock); \
+   } \
+   \
+   return nb_rx; \
+}
+
+#define GENERATE_TX_LOCK(func, nic) \
+uint16_t func ## _lock(void *tx_queue, \
+ struct rte_mbuf **tx_pkts, \
+ uint16_t nb_pkts) \
+{  \
+   struct nic ## _tx_queue *txq = tx_queue; \
+   uint16_t nb_tx = 0; \
+   \
+   if (rte_spinlock_trylock(>tx_lock)) { \
+   nb_tx = func(tx_queue, tx_pkts, nb_pkts); \
+   rte_spinlock_unlock(>tx_lock); \
+   } \
+   \
+   return nb_tx; \
+}
+
+/**
  * A structure used to configure an RX ring of an Ethernet port.
  */
 struct rte_eth_rxconf {
-- 
2.1.4



[dpdk-dev] [PATCH v4 1/8] lib/librte_ether: support device reset

2016-06-07 Thread Zhe Tao
Add an API to reset the device.
It's for VF device in this scenario, kernel PF + DPDK VF.
When the PF port down/up, APP should call this API to
reset VF port. Most likely, APP should call it in its
management thread and guarantee the thread safe.

Signed-off-by: Wenzhuo Lu 
---
 lib/librte_ether/rte_ethdev.c  | 17 +
 lib/librte_ether/rte_ethdev.h  | 14 ++
 lib/librte_ether/rte_ether_version.map |  7 +++
 3 files changed, 38 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e148028..e43dca9 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3346,3 +3346,20 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id,
-ENOTSUP);
return (*dev->dev_ops->l2_tunnel_offload_set)(dev, l2_tunnel, mask, en);
 }
+
+int
+rte_eth_dev_reset(uint8_t port_id)
+{
+   struct rte_eth_dev *dev;
+   int diag;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+   dev = _eth_devices[port_id];
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_reset, -ENOTSUP);
+
+   diag = (*dev->dev_ops->dev_reset)(dev);
+
+   return diag;
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2757510..74e895f 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1318,6 +1318,9 @@ typedef int (*eth_l2_tunnel_offload_set_t)
 uint8_t en);
 /**< @internal enable/disable the l2 tunnel offload functions */

+typedef int  (*eth_dev_reset_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to reset a configured Ethernet device. */
+
 #ifdef RTE_NIC_BYPASS

 enum {
@@ -1508,6 +1511,8 @@ struct eth_dev_ops {
eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
/** Enable/disable l2 tunnel offload functions */
eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
+   /** Reset device. */
+   eth_dev_reset_t dev_reset;
 };

 /**
@@ -4253,6 +4258,15 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id,
  uint32_t mask,
  uint8_t en);

+/**
+ * Reset an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ */
+int
+rte_eth_dev_reset(uint8_t port_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index 214ecc7..c34207e 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -132,3 +132,10 @@ DPDK_16.04 {
rte_eth_tx_buffer_set_err_callback;

 } DPDK_2.2;
+
+DPDK_16.07 {
+   global:
+
+   rte_eth_dev_reset;
+
+} DPDK_16.04;
-- 
2.1.4



[dpdk-dev] [PATCH v4 0/8] support reset of VF link

2016-06-07 Thread Zhe Tao
If the PF link is down and up, VF link will not work
accordingly.
This patch set addes the support of VF link reset. So, when VF
receices the messges of physical link down/up. APP can reset the
VF link and let it recover.

PS: This patch set is splitted from a previous patch set, *automatic
link recovery on ixgbe/igb VF*, and it's base on the patch set
*support mailbox interruption on ixgbe/igb VF*.

Wenzhuo Lu (6):
  lib/librte_ether: support device reset
  lib/librte_ether: defind RX/TX lock mode
  ixgbe: RX/TX with lock on VF
  ixgbe: implement device reset on VF
  igb: RX/TX with lock on VF
  igb: implement device reset on VF

Zhe Tao (2):
  i40e: RX/TX with lock on VF
  i40e: implement device reset on VF

v1:
  Added the implementation for the VF reset functionality.  
v2:
  Changed the i40e related operations during VF reset.  
v3:
  Resent the patches because of the mail sent issue.  
v4:
  Removed some VF reset emulation code.  

 doc/guides/rel_notes/release_16_07.rst |  14 +++
 drivers/net/e1000/e1000_ethdev.h   | 126 +++
 drivers/net/e1000/igb_ethdev.c | 118 -
 drivers/net/e1000/igb_rxtx.c   | 148 +---
 drivers/net/i40e/i40e_ethdev.c |   4 +-
 drivers/net/i40e/i40e_ethdev.h |   5 ++
 drivers/net/i40e/i40e_ethdev_vf.c  | 152 -
 drivers/net/i40e/i40e_rxtx.c   |  55 
 drivers/net/i40e/i40e_rxtx.h   |  34 
 drivers/net/ixgbe/ixgbe_ethdev.c   | 120 +-
 drivers/net/ixgbe/ixgbe_ethdev.h   |  32 ++-
 drivers/net/ixgbe/ixgbe_rxtx.c | 116 ++---
 drivers/net/ixgbe/ixgbe_rxtx.h |  13 +++
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |   6 ++
 lib/librte_ether/rte_ethdev.c  |  17 
 lib/librte_ether/rte_ethdev.h  |  76 +
 lib/librte_ether/rte_ether_version.map |   7 ++
 17 files changed, 895 insertions(+), 148 deletions(-)

-- 
2.1.4



[dpdk-dev] [PATCH v3 8/8] i40e: implement device reset on VF

2016-06-07 Thread Zhe Tao
Implement the device reset function.
1, Add the fake RX/TX functions.
2, The reset function tries to stop RX/TX by replacing
   the RX/TX functions with the fake ones and getting the
   locks to make sure the regular RX/TX finished.
3, After the RX/TX stopped, reset the VF port, and then
   release the locks.

Signed-off-by: Zhe Tao 
---
 app/test-pmd/config.c  |   3 +
 doc/guides/rel_notes/release_16_07.rst |   5 ++
 drivers/net/i40e/i40e_ethdev.h |   7 +-
 drivers/net/i40e/i40e_ethdev_vf.c  | 152 -
 drivers/net/i40e/i40e_rxtx.c   |  10 +++
 drivers/net/i40e/i40e_rxtx.h   |   4 +
 6 files changed, 175 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1c552e4..a120261 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -378,6 +378,7 @@ tx_queue_infos_display(portid_t port_id, uint16_t queue_id)
printf("\nNumber of TXDs: %hu", qinfo.nb_desc);
printf("\n");
 }
+void i40evf_emulate_vf_reset(uint8_t port_id);

 void
 port_infos_display(portid_t port_id)
@@ -398,6 +399,8 @@ port_infos_display(portid_t port_id)
printf("]\n");
return;
}
+   printf("emulate vf reset\n");
+   i40evf_emulate_vf_reset(port_id);
port = [port_id];
rte_eth_link_get_nowait(port_id, );
printf("\n%s Infos for port %-2d %s\n",
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index a4c0cc3..f43b867 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -62,6 +62,11 @@ New Features
   callback in the message handler to notice the APP. APP need call the device
   reset API to reset the VF port.

+* **Added VF reset support for i40e VF driver.**
+
+  Added a new implementaion to allow i40e VF driver to
+  reset the functionality and state of itself.
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 672d920..dcd6e0f 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -541,9 +541,8 @@ struct i40e_adapter {
struct rte_timecounter rx_tstamp_tc;
struct rte_timecounter tx_tstamp_tc;

-   /* For VF reset backup */
-   eth_rx_burst_t rx_backup;
-   eth_tx_burst_t tx_backup;
+   /* For VF reset */
+   uint8_t reset_number;
 };

 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
@@ -597,6 +596,8 @@ void i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t 
queue_id,
 void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
struct rte_eth_txq_info *qinfo);

+void i40evf_emulate_vf_reset(uint8_t port_id);
+
 /* I40E_DEV_PRIVATE_TO */
 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
(&((struct i40e_adapter *)adapter)->pf)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 46d8a7c..d873d2d 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -157,6 +157,12 @@ i40evf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, 
uint16_t queue_id);
 static void i40evf_handle_pf_event(__rte_unused struct rte_eth_dev *dev,
   uint8_t *msg,
   uint16_t msglen);
+static int i40evf_dev_uninit(struct rte_eth_dev *eth_dev);
+static int i40evf_dev_init(struct rte_eth_dev *eth_dev);
+static void i40evf_dev_close(struct rte_eth_dev *dev);
+static int i40evf_dev_start(struct rte_eth_dev *dev);
+static int i40evf_dev_configure(struct rte_eth_dev *dev);
+static int i40evf_handle_vf_reset(struct rte_eth_dev *dev);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
@@ -223,6 +229,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
.reta_query   = i40evf_dev_rss_reta_query,
.rss_hash_update  = i40evf_dev_rss_hash_update,
.rss_hash_conf_get= i40evf_dev_rss_hash_conf_get,
+   .dev_reset= i40evf_handle_vf_reset
 };

 /*
@@ -1309,6 +1316,140 @@ i40evf_uninit_vf(struct rte_eth_dev *dev)
 }

 static void
+i40e_vf_queue_reset(struct rte_eth_dev *dev)
+{
+   uint16_t i;
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
+
+   if (rxq->q_set) {
+   i40e_dev_rx_queue_setup(dev,
+   rxq->queue_id,
+   rxq->nb_rx_desc,
+   rxq->socket_id,
+   >rxconf,
+   rxq->mp);
+   }
+
+   rxq = dev->data->rx_queues[i];
+   

[dpdk-dev] [PATCH v3 7/8] i40e: RX/TX with lock on VF

2016-06-07 Thread Zhe Tao
Add RX/TX paths with lock for VF. It's used when
the function of link reset on VF is needed.
When the lock for RX/TX is added, the RX/TX can be
stopped. Then we have a chance to reset the VF link.

Please be aware there's performence drop if the lock
path is chosen.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c|  4 ++--
 drivers/net/i40e/i40e_ethdev.h|  4 
 drivers/net/i40e/i40e_ethdev_vf.c |  4 ++--
 drivers/net/i40e/i40e_rxtx.c  | 45 +--
 drivers/net/i40e/i40e_rxtx.h  | 30 ++
 5 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..1380330 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -764,8 +764,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
PMD_INIT_FUNC_TRACE();

dev->dev_ops = _eth_dev_ops;
-   dev->rx_pkt_burst = i40e_recv_pkts;
-   dev->tx_pkt_burst = i40e_xmit_pkts;
+   dev->rx_pkt_burst = RX_LOCK_FUNCTION(dev, i40e_recv_pkts);
+   dev->tx_pkt_burst = TX_LOCK_FUNCTION(dev, i40e_xmit_pkts);

/* for secondary processes, we don't initialise any further as primary
 * has already done this work. Only check we don't need a different
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..672d920 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -540,6 +540,10 @@ struct i40e_adapter {
struct rte_timecounter systime_tc;
struct rte_timecounter rx_tstamp_tc;
struct rte_timecounter tx_tstamp_tc;
+
+   /* For VF reset backup */
+   eth_rx_burst_t rx_backup;
+   eth_tx_burst_t tx_backup;
 };

 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 90682ac..46d8a7c 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1451,8 +1451,8 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)

/* assign ops func pointer */
eth_dev->dev_ops = _eth_dev_ops;
-   eth_dev->rx_pkt_burst = _recv_pkts;
-   eth_dev->tx_pkt_burst = _xmit_pkts;
+   eth_dev->rx_pkt_burst = RX_LOCK_FUNCTION(eth_dev, i40e_recv_pkts);
+   eth_dev->tx_pkt_burst = TX_LOCK_FUNCTION(eth_dev, i40e_xmit_pkts);

/*
 * For secondary processes, we don't initialise any further as primary
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index c833aa3..0a6dcfb 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -79,10 +79,6 @@
PKT_TX_TCP_SEG | \
PKT_TX_OUTER_IP_CKSUM)

-static uint16_t i40e_xmit_pkts_simple(void *tx_queue,
- struct rte_mbuf **tx_pkts,
- uint16_t nb_pkts);
-
 static inline void
 i40e_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union i40e_rx_desc *rxdp)
 {
@@ -1144,7 +1140,7 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
return 0;
 }

-static uint16_t
+uint16_t
 i40e_recv_pkts_bulk_alloc(void *rx_queue,
  struct rte_mbuf **rx_pkts,
  uint16_t nb_pkts)
@@ -1169,7 +1165,7 @@ i40e_recv_pkts_bulk_alloc(void *rx_queue,
return nb_rx;
 }
 #else
-static uint16_t
+uint16_t
 i40e_recv_pkts_bulk_alloc(void __rte_unused *rx_queue,
  struct rte_mbuf __rte_unused **rx_pkts,
  uint16_t __rte_unused nb_pkts)
@@ -1892,7 +1888,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq,
return nb_pkts;
 }

-static uint16_t
+uint16_t
 i40e_xmit_pkts_simple(void *tx_queue,
  struct rte_mbuf **tx_pkts,
  uint16_t nb_pkts)
@@ -2121,10 +2117,13 @@ i40e_dev_supported_ptypes_get(struct rte_eth_dev *dev)
};

if (dev->rx_pkt_burst == i40e_recv_pkts ||
+   dev->rx_pkt_burst == i40e_recv_pkts_lock ||
 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
dev->rx_pkt_burst == i40e_recv_pkts_bulk_alloc ||
+   dev->rx_pkt_burst == i40e_recv_pkts_bulk_alloc_lock ||
 #endif
-   dev->rx_pkt_burst == i40e_recv_scattered_pkts)
+   dev->rx_pkt_burst == i40e_recv_scattered_pkts ||
+   dev->rx_pkt_burst == i40e_recv_scattered_pkts_lock)
return ptypes;
return NULL;
 }
@@ -2648,6 +2647,7 @@ i40e_reset_rx_queue(struct i40e_rx_queue *rxq)

rxq->rxrearm_start = 0;
rxq->rxrearm_nb = 0;
+   rte_spinlock_init(>rx_lock);
 }

 void
@@ -2704,6 +2704,7 @@ i40e_reset_tx_queue(struct i40e_tx_queue *txq)

txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
+   rte_spinl

[dpdk-dev] [PATCH v3 6/8] igb: implement device reset on VF

2016-06-07 Thread Zhe Tao
Implement the device reset function.
1, Add the fake RX/TX functions.
2, The reset function tries to stop RX/TX by replacing
   the RX/TX functions with the fake ones and getting the
   locks to make sure the regular RX/TX finished.
3, After the RX/TX stopped, reset the VF port, and then
   release the locks and restore the RX/TX functions.

BTW: The definition of some structures are moved from .c
file to .h file.

Signed-off-by: Wenzhuo Lu 
---
 doc/guides/rel_notes/release_16_07.rst |   2 +-
 drivers/net/e1000/e1000_ethdev.h   | 116 ++
 drivers/net/e1000/igb_ethdev.c | 104 +++
 drivers/net/e1000/igb_rxtx.c   | 128 ++---
 4 files changed, 243 insertions(+), 107 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index d36c4b1..a4c0cc3 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -53,7 +53,7 @@ New Features
   VF. To handle this link up/down event, add the mailbox interruption
   support to receive the message.

-* **Added device reset support for ixgbe VF.**
+* **Added device reset support for ixgbe/igb VF.**

   Added the device reset API. APP can call this API to reset the VF port
   when it's not working.
diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 6a42994..4ae03ce 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include 
+#include 

 /* need update link, bit flag */
 #define E1000_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
@@ -261,6 +262,113 @@ struct e1000_adapter {
struct rte_timecounter  systime_tc;
struct rte_timecounter  rx_tstamp_tc;
struct rte_timecounter  tx_tstamp_tc;
+   eth_rx_burst_t rx_backup;
+   eth_tx_burst_t tx_backup;
+};
+
+/**
+ * Structure associated with each descriptor of the RX ring of a RX queue.
+ */
+struct igb_rx_entry {
+   struct rte_mbuf *mbuf; /**< mbuf associated with RX descriptor. */
+};
+
+/**
+ * Structure associated with each descriptor of the TX ring of a TX queue.
+ */
+struct igb_tx_entry {
+   struct rte_mbuf *mbuf; /**< mbuf associated with TX desc, if any. */
+   uint16_t next_id; /**< Index of next descriptor in ring. */
+   uint16_t last_id; /**< Index of last scattered descriptor. */
+};
+
+/**
+ * Hardware context number
+ */
+enum igb_advctx_num {
+   IGB_CTX_0= 0, /**< CTX0*/
+   IGB_CTX_1= 1, /**< CTX1*/
+   IGB_CTX_NUM  = 2, /**< CTX_NUM */
+};
+
+/** Offload features */
+union igb_tx_offload {
+   uint64_t data;
+   struct {
+   uint64_t l3_len:9; /**< L3 (IP) Header Length. */
+   uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
+   uint64_t vlan_tci:16;  /**< VLAN Tag Control Identifier(CPU 
order). */
+   uint64_t l4_len:8; /**< L4 (TCP/UDP) Header Length. */
+   uint64_t tso_segsz:16; /**< TCP TSO segment size. */
+
+   /* uint64_t unused:8; */
+   };
+};
+
+/**
+ * Strucutre to check if new context need be built
+ */
+struct igb_advctx_info {
+   uint64_t flags;   /**< ol_flags related to context build. */
+   /** tx offload: vlan, tso, l2-l3-l4 lengths. */
+   union igb_tx_offload tx_offload;
+   /** compare mask for tx offload. */
+   union igb_tx_offload tx_offload_mask;
+};
+
+/**
+ * Structure associated with each RX queue.
+ */
+struct igb_rx_queue {
+   struct rte_mempool  *mb_pool;   /**< mbuf pool to populate RX ring. */
+   volatile union e1000_adv_rx_desc *rx_ring; /**< RX ring virtual 
address. */
+   uint64_trx_ring_phys_addr; /**< RX ring DMA address. */
+   volatile uint32_t   *rdt_reg_addr; /**< RDT register address. */
+   volatile uint32_t   *rdh_reg_addr; /**< RDH register address. */
+   struct igb_rx_entry *sw_ring;   /**< address of RX software ring. */
+   struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
+   struct rte_mbuf *pkt_last_seg;  /**< Last segment of current packet. */
+   rte_spinlock_t  rx_lock; /**< Lock for packet receiption. */
+   uint16_tnb_rx_desc; /**< number of RX descriptors. */
+   uint16_trx_tail;/**< current value of RDT register. */
+   uint16_tnb_rx_hold; /**< number of held free RX desc. */
+   uint16_trx_free_thresh; /**< max free RX desc to hold. */
+   uint16_tqueue_id;   /**< RX queue index. */
+   uint16_treg_idx;/**< RX queue register index. */
+   uint8_t port_id;/**< Device port identifier. */
+   uint8_t pthresh;/**< Prefetch threshold register. */
+   uint8_t hthresh;/**< Host threshold register. */
+   

[dpdk-dev] [PATCH v3 5/8] igb: RX/TX with lock on VF

2016-06-07 Thread Zhe Tao
Add RX/TX paths with lock for VF. It's used when
the function of link reset on VF is needed.
When the lock for RX/TX is added, the RX/TX can be
stopped. Then we have a chance to reset the VF link.

Please be aware there's performence drop if the lock
path is chosen.

Signed-off-by: Wenzhuo Lu 
---
 drivers/net/e1000/e1000_ethdev.h | 10 ++
 drivers/net/e1000/igb_ethdev.c   | 14 +++---
 drivers/net/e1000/igb_rxtx.c | 26 +-
 3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index e8bf8da..6a42994 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -319,6 +319,16 @@ uint16_t eth_igb_recv_pkts(void *rxq, struct rte_mbuf 
**rx_pkts,
 uint16_t eth_igb_recv_scattered_pkts(void *rxq,
struct rte_mbuf **rx_pkts, uint16_t nb_pkts);

+uint16_t eth_igb_xmit_pkts_lock(void *txq,
+   struct rte_mbuf **tx_pkts,
+   uint16_t nb_pkts);
+uint16_t eth_igb_recv_pkts_lock(void *rxq,
+   struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts);
+uint16_t eth_igb_recv_scattered_pkts_lock(void *rxq,
+ struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts);
+
 int eth_igb_rss_hash_update(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf);

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index b0e5e6a..8aad741 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -909,15 +909,17 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
PMD_INIT_FUNC_TRACE();

eth_dev->dev_ops = _eth_dev_ops;
-   eth_dev->rx_pkt_burst = _igb_recv_pkts;
-   eth_dev->tx_pkt_burst = _igb_xmit_pkts;
+   eth_dev->rx_pkt_burst = RX_LOCK_FUNCTION(eth_dev, eth_igb_recv_pkts);
+   eth_dev->tx_pkt_burst = TX_LOCK_FUNCTION(eth_dev, eth_igb_xmit_pkts);

/* for secondary processes, we don't initialise any further as primary
 * has already done this work. Only check we don't need a different
 * RX function */
if (rte_eal_process_type() != RTE_PROC_PRIMARY){
if (eth_dev->data->scattered_rx)
-   eth_dev->rx_pkt_burst = _igb_recv_scattered_pkts;
+   eth_dev->rx_pkt_burst =
+   RX_LOCK_FUNCTION(eth_dev,
+eth_igb_recv_scattered_pkts);
return 0;
}

@@ -1999,7 +2001,13 @@ eth_igb_supported_ptypes_get(struct rte_eth_dev *dev)
};

if (dev->rx_pkt_burst == eth_igb_recv_pkts ||
+#ifndef RTE_NEXT_ABI
dev->rx_pkt_burst == eth_igb_recv_scattered_pkts)
+#else
+   dev->rx_pkt_burst == eth_igb_recv_scattered_pkts ||
+   dev->rx_pkt_burst == eth_igb_recv_pkts_lock ||
+   dev->rx_pkt_burst == eth_igb_recv_scattered_pkts_lock)
+#endif
return ptypes;
return NULL;
 }
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 18aeead..7e97330 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "e1000_logs.h"
 #include "base/e1000_api.h"
@@ -107,6 +108,7 @@ struct igb_rx_queue {
struct igb_rx_entry *sw_ring;   /**< address of RX software ring. */
struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
struct rte_mbuf *pkt_last_seg;  /**< Last segment of current packet. */
+   rte_spinlock_t  rx_lock; /**< Lock for packet receiption. */
uint16_tnb_rx_desc; /**< number of RX descriptors. */
uint16_trx_tail;/**< current value of RDT register. */
uint16_tnb_rx_hold; /**< number of held free RX desc. */
@@ -174,6 +176,7 @@ struct igb_tx_queue {
volatile union e1000_adv_tx_desc *tx_ring; /**< TX ring address */
uint64_t   tx_ring_phys_addr; /**< TX ring DMA address. */
struct igb_tx_entry*sw_ring; /**< virtual address of SW ring. */
+   rte_spinlock_t tx_lock; /**< Lock for packet transmission. */
volatile uint32_t  *tdt_reg_addr; /**< Address of TDT register. */
uint32_t   txd_type;  /**< Device-specific TXD type */
uint16_t   nb_tx_desc;/**< number of TX descriptors. */
@@ -615,6 +618,8 @@ eth_igb_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
return nb_tx;
 }

+GENERATE_TX_LOCK(eth_igb_xmit_pkts, igb)
+
 /*
  *
  *  RX functions
@@ -931,6 +936,8 @@ eth_igb_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
return nb_rx;
 }


[dpdk-dev] [PATCH v3 4/8] ixgbe: implement device reset on VF

2016-06-07 Thread Zhe Tao
Implement the device reset function.
1, Add the fake RX/TX functions.
2, The reset function tries to stop RX/TX by replacing
   the RX/TX functions with the fake ones and getting the
   locks to make sure the regular RX/TX finished.
3, After the RX/TX stopped, reset the VF port, and then
   release the locks and restore the RX/TX functions.

Signed-off-by: Wenzhuo Lu 
---
 doc/guides/rel_notes/release_16_07.rst |   9 +++
 drivers/net/ixgbe/ixgbe_ethdev.c   | 108 -
 drivers/net/ixgbe/ixgbe_ethdev.h   |  12 +++-
 drivers/net/ixgbe/ixgbe_rxtx.c |  42 -
 4 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index a761e3c..d36c4b1 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -53,6 +53,15 @@ New Features
   VF. To handle this link up/down event, add the mailbox interruption
   support to receive the message.

+* **Added device reset support for ixgbe VF.**
+
+  Added the device reset API. APP can call this API to reset the VF port
+  when it's not working.
+  Based on the mailbox interruption support, when VF reseives the control
+  message from PF, it means the PF link state changes, VF uses the reset
+  callback in the message handler to notice the APP. APP need call the device
+  reset API to reset the VF port.
+

 Resolved Issues
 ---
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index fd2682f..1e3520b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -381,6 +381,8 @@ static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev 
*dev,
 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
 struct rte_eth_udp_tunnel *udp_tunnel);

+static int ixgbevf_dev_reset(struct rte_eth_dev *dev);
+
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */
@@ -586,6 +588,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
.reta_query   = ixgbe_dev_rss_reta_query,
.rss_hash_update  = ixgbe_dev_rss_hash_update,
.rss_hash_conf_get= ixgbe_dev_rss_hash_conf_get,
+   .dev_reset= ixgbevf_dev_reset,
 };

 /* store statistics names and its offset in stats structure */
@@ -4060,7 +4063,8 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)
ETH_VLAN_EXTEND_MASK;
ixgbevf_vlan_offload_set(dev, mask);

-   ixgbevf_dev_rxtx_start(dev);
+   if (ixgbevf_dev_rxtx_start(dev))
+   return -1;

/* check and configure queue intr-vector mapping */
if (dev->data->dev_conf.intr_conf.rxq != 0) {
@@ -7193,6 +7197,108 @@ static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
 }

 static int
+ixgbevf_dev_reset(struct rte_eth_dev *dev)
+{
+   struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct ixgbe_adapter *adapter =
+   (struct ixgbe_adapter *)dev->data->dev_private;
+   int diag = 0;
+   uint32_t vteiam;
+   uint16_t i;
+   struct ixgbe_rx_queue *rxq;
+   struct ixgbe_tx_queue *txq;
+
+   /* Nothing needs to be done if the device is not started. */
+   if (!dev->data->dev_started)
+   return 0;
+
+   PMD_DRV_LOG(DEBUG, "Link up/down event detected.");
+
+   /**
+* Stop RX/TX by fake functions and locks.
+* Fake functions are used to make RX/TX lock easier.
+*/
+   adapter->rx_backup = dev->rx_pkt_burst;
+   adapter->tx_backup = dev->tx_pkt_burst;
+   dev->rx_pkt_burst = ixgbevf_recv_pkts_fake;
+   dev->tx_pkt_burst = ixgbevf_xmit_pkts_fake;
+
+   if (dev->data->rx_queues)
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   rxq = dev->data->rx_queues[i];
+   rte_spinlock_lock(>rx_lock);
+   }
+
+   if (dev->data->tx_queues)
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   rte_spinlock_lock(>tx_lock);
+   }
+
+   /* Performance VF reset. */
+   do {
+   dev->data->dev_started = 0;
+   ixgbevf_dev_stop(dev);
+   if (dev->data->dev_conf.intr_conf.lsc == 0)
+   diag = ixgbe_dev_link_update(dev, 0);
+   if (diag) {
+   PMD_INIT_LOG(INFO, "Ixgbe VF reset: "
+"Failed to update link.");
+   }
+   rte_delay_ms(1000);
+
+   diag = ixgbevf_dev_start(dev);
+   /*If fail to start the device, need to stop/start it again. */
+   if (diag) {
+   PMD_INIT_LOG(ERR, "Ixgbe VF reset: "
+"Failed to start device.");
+   

[dpdk-dev] [PATCH v3 3/8] ixgbe: RX/TX with lock on VF

2016-06-07 Thread Zhe Tao
Add RX/TX paths with lock for VF. It's used when
the function of link reset on VF is needed.
When the lock for RX/TX is added, the RX/TX can be
stopped. Then we have a chance to reset the VF link.

Please be aware there's performence drop if the lock
path is chosen.

Signed-off-by: Wenzhuo Lu 
---
 drivers/net/ixgbe/ixgbe_ethdev.c   | 12 +--
 drivers/net/ixgbe/ixgbe_ethdev.h   | 20 +++
 drivers/net/ixgbe/ixgbe_rxtx.c | 74 --
 drivers/net/ixgbe/ixgbe_rxtx.h | 13 +++
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |  6 
 5 files changed, 112 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 05f4f29..fd2682f 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1325,8 +1325,8 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
PMD_INIT_FUNC_TRACE();

eth_dev->dev_ops = _eth_dev_ops;
-   eth_dev->rx_pkt_burst = _recv_pkts;
-   eth_dev->tx_pkt_burst = _xmit_pkts;
+   eth_dev->rx_pkt_burst = RX_LOCK_FUNCTION(eth_dev, ixgbe_recv_pkts);
+   eth_dev->tx_pkt_burst = TX_LOCK_FUNCTION(eth_dev, ixgbe_xmit_pkts);

/* for secondary processes, we don't initialise any further as primary
 * has already done this work. Only check we don't need a different
@@ -3012,7 +3012,15 @@ ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
+#ifndef RTE_NEXT_ABI
dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
+#else
+   dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_lock ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc_lock ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc_lock ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc_lock)
+#endif
return ptypes;
return NULL;
 }
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 4ff6338..701107b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -390,12 +390,32 @@ uint16_t ixgbe_recv_pkts_lro_single_alloc(void *rx_queue,
 uint16_t ixgbe_recv_pkts_lro_bulk_alloc(void *rx_queue,
struct rte_mbuf **rx_pkts, uint16_t nb_pkts);

+uint16_t ixgbe_recv_pkts_lock(void *rx_queue,
+ struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts);
+uint16_t ixgbe_recv_pkts_bulk_alloc_lock(void *rx_queue,
+struct rte_mbuf **rx_pkts,
+uint16_t nb_pkts);
+uint16_t ixgbe_recv_pkts_lro_single_alloc_lock(void *rx_queue,
+  struct rte_mbuf **rx_pkts,
+  uint16_t nb_pkts);
+uint16_t ixgbe_recv_pkts_lro_bulk_alloc_lock(void *rx_queue,
+struct rte_mbuf **rx_pkts,
+uint16_t nb_pkts);
+
 uint16_t ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);

 uint16_t ixgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);

+uint16_t ixgbe_xmit_pkts_lock(void *tx_queue,
+ struct rte_mbuf **tx_pkts,
+ uint16_t nb_pkts);
+uint16_t ixgbe_xmit_pkts_simple_lock(void *tx_queue,
+struct rte_mbuf **tx_pkts,
+uint16_t nb_pkts);
+
 int ixgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
  struct rte_eth_rss_conf *rss_conf);

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 9c6eaf2..a45d115 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -353,6 +353,8 @@ ixgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf 
**tx_pkts,
return nb_tx;
 }

+GENERATE_TX_LOCK(ixgbe_xmit_pkts_simple, ixgbe)
+
 static inline void
 ixgbe_set_xmit_ctx(struct ixgbe_tx_queue *txq,
volatile struct ixgbe_adv_tx_context_desc *ctx_txd,
@@ -904,6 +906,8 @@ end_of_tx:
return nb_tx;
 }

+GENERATE_TX_LOCK(ixgbe_xmit_pkts, ixgbe)
+
 /*
  *
  *  RX functions
@@ -1524,6 +1528,8 @@ ixgbe_recv_pkts_bulk_alloc(void *rx_queue, struct 
rte_mbuf **rx_pkts,
return nb_rx;
 }

+GENERATE_RX_LOCK(ixgbe_recv_pkts_bulk_alloc, ixgbe)
+
 uint16_t
 ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts)
@@ -1712,6 +1718,8 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
return nb_rx;
 }


[dpdk-dev] [PATCH v3 2/8] lib/librte_ether: defind RX/TX lock mode

2016-06-07 Thread Zhe Tao
Define lock mode for RX/TX queue. Because when resetting
the device we want the resetting thread to get the lock
of the RX/TX queue to make sure the RX/TX is stopped.

Using next ABI macro for this ABI change as it has too
much impact. 7 APIs and 1 global variable are impacted.

Signed-off-by: Wenzhuo Lu 
Signed-off-by: Zhe Tao 
---
 lib/librte_ether/rte_ethdev.h | 62 +++
 1 file changed, 62 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 74e895f..4efb5e9 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -354,7 +354,12 @@ struct rte_eth_rxmode {
jumbo_frame  : 1, /**< Jumbo Frame Receipt enable. */
hw_strip_crc : 1, /**< Enable CRC stripping by hardware. */
enable_scatter   : 1, /**< Enable scatter packets rx handler */
+#ifndef RTE_NEXT_ABI
enable_lro   : 1; /**< Enable LRO */
+#else
+   enable_lro   : 1, /**< Enable LRO */
+   lock_mode: 1; /**< Using lock path */
+#endif
 };

 /**
@@ -634,11 +639,68 @@ struct rte_eth_txmode {
/**< If set, reject sending out tagged pkts */
hw_vlan_reject_untagged : 1,
/**< If set, reject sending out untagged pkts */
+#ifndef RTE_NEXT_ABI
hw_vlan_insert_pvid : 1;
/**< If set, enable port based VLAN insertion */
+#else
+   hw_vlan_insert_pvid : 1,
+   /**< If set, enable port based VLAN insertion */
+   lock_mode : 1;
+   /**< If set, using lock path */
+#endif
 };

 /**
+ * The macros for the RX/TX lock mode functions
+ */
+#ifdef RTE_NEXT_ABI
+#define RX_LOCK_FUNCTION(dev, func) \
+   (dev->data->dev_conf.rxmode.lock_mode ? \
+   func ## _lock : func)
+
+#define TX_LOCK_FUNCTION(dev, func) \
+   (dev->data->dev_conf.txmode.lock_mode ? \
+   func ## _lock : func)
+#else
+#define RX_LOCK_FUNCTION(dev, func) func
+
+#define TX_LOCK_FUNCTION(dev, func) func
+#endif
+
+/* Add the lock RX/TX function for VF reset */
+#define GENERATE_RX_LOCK(func, nic) \
+uint16_t func ## _lock(void *rx_queue, \
+ struct rte_mbuf **rx_pkts, \
+ uint16_t nb_pkts) \
+{  \
+   struct nic ## _rx_queue *rxq = rx_queue; \
+   uint16_t nb_rx = 0; \
+   \
+   if (rte_spinlock_trylock(>rx_lock)) { \
+   nb_rx = func(rx_queue, rx_pkts, nb_pkts); \
+   rte_spinlock_unlock(>rx_lock); \
+   } \
+   \
+   return nb_rx; \
+}
+
+#define GENERATE_TX_LOCK(func, nic) \
+uint16_t func ## _lock(void *tx_queue, \
+ struct rte_mbuf **tx_pkts, \
+ uint16_t nb_pkts) \
+{  \
+   struct nic ## _tx_queue *txq = tx_queue; \
+   uint16_t nb_tx = 0; \
+   \
+   if (rte_spinlock_trylock(>tx_lock)) { \
+   nb_tx = func(tx_queue, tx_pkts, nb_pkts); \
+   rte_spinlock_unlock(>tx_lock); \
+   } \
+   \
+   return nb_tx; \
+}
+
+/**
  * A structure used to configure an RX ring of an Ethernet port.
  */
 struct rte_eth_rxconf {
-- 
2.1.4



[dpdk-dev] [PATCH v3 1/8] lib/librte_ether: support device reset

2016-06-07 Thread Zhe Tao
Add an API to reset the device.
It's for VF device in this scenario, kernel PF + DPDK VF.
When the PF port down/up, APP should call this API to
reset VF port. Most likely, APP should call it in its
management thread and guarantee the thread safe.

Signed-off-by: Wenzhuo Lu 
---
 lib/librte_ether/rte_ethdev.c  | 17 +
 lib/librte_ether/rte_ethdev.h  | 14 ++
 lib/librte_ether/rte_ether_version.map |  7 +++
 3 files changed, 38 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e148028..e43dca9 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3346,3 +3346,20 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id,
-ENOTSUP);
return (*dev->dev_ops->l2_tunnel_offload_set)(dev, l2_tunnel, mask, en);
 }
+
+int
+rte_eth_dev_reset(uint8_t port_id)
+{
+   struct rte_eth_dev *dev;
+   int diag;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+   dev = _eth_devices[port_id];
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_reset, -ENOTSUP);
+
+   diag = (*dev->dev_ops->dev_reset)(dev);
+
+   return diag;
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2757510..74e895f 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1318,6 +1318,9 @@ typedef int (*eth_l2_tunnel_offload_set_t)
 uint8_t en);
 /**< @internal enable/disable the l2 tunnel offload functions */

+typedef int  (*eth_dev_reset_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to reset a configured Ethernet device. */
+
 #ifdef RTE_NIC_BYPASS

 enum {
@@ -1508,6 +1511,8 @@ struct eth_dev_ops {
eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
/** Enable/disable l2 tunnel offload functions */
eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
+   /** Reset device. */
+   eth_dev_reset_t dev_reset;
 };

 /**
@@ -4253,6 +4258,15 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id,
  uint32_t mask,
  uint8_t en);

+/**
+ * Reset an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ */
+int
+rte_eth_dev_reset(uint8_t port_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index 214ecc7..c34207e 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -132,3 +132,10 @@ DPDK_16.04 {
rte_eth_tx_buffer_set_err_callback;

 } DPDK_2.2;
+
+DPDK_16.07 {
+   global:
+
+   rte_eth_dev_reset;
+
+} DPDK_16.04;
-- 
2.1.4



[dpdk-dev] [PATCH v3 0/8] support reset of VF link

2016-06-07 Thread Zhe Tao
If the PF link is down and up, VF link will not work
accordingly.
This patch set addes the support of VF link reset. So, when VF
receices the messges of physical link down/up. APP can reset the
VF link and let it recover.

PS: This patch set is splitted from a previous patch set, *automatic
link recovery on ixgbe/igb VF*, and it's base on the patch set
*support mailbox interruption on ixgbe/igb VF*.

Wenzhuo Lu (6):
  lib/librte_ether: support device reset
  lib/librte_ether: defind RX/TX lock mode
  ixgbe: RX/TX with lock on VF
  ixgbe: implement device reset on VF
  igb: RX/TX with lock on VF
  igb: implement device reset on VF

Zhe Tao (2):
  i40e: RX/TX with lock on VF
  i40e: implement device reset on VF

v1:
  Added the implementation for the VF reset functionality.  
v2:
  Changed the i40e related operations during VF reset.  
v3:
  Resent the patches because of the mail sent issue.  

 app/test-pmd/config.c  |   3 +
 doc/guides/rel_notes/release_16_07.rst |  14 +++
 drivers/net/e1000/e1000_ethdev.h   | 126 +++
 drivers/net/e1000/igb_ethdev.c | 118 -
 drivers/net/e1000/igb_rxtx.c   | 148 +---
 drivers/net/i40e/i40e_ethdev.c |   4 +-
 drivers/net/i40e/i40e_ethdev.h |   5 ++
 drivers/net/i40e/i40e_ethdev_vf.c  | 152 -
 drivers/net/i40e/i40e_rxtx.c   |  55 
 drivers/net/i40e/i40e_rxtx.h   |  34 
 drivers/net/ixgbe/ixgbe_ethdev.c   | 120 +-
 drivers/net/ixgbe/ixgbe_ethdev.h   |  32 ++-
 drivers/net/ixgbe/ixgbe_rxtx.c | 116 ++---
 drivers/net/ixgbe/ixgbe_rxtx.h |  13 +++
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |   6 ++
 lib/librte_ether/rte_ethdev.c  |  17 
 lib/librte_ether/rte_ethdev.h  |  76 +
 lib/librte_ether/rte_ether_version.map |   7 ++
 18 files changed, 898 insertions(+), 148 deletions(-)

-- 
2.1.4



[dpdk-dev] [PATCH v2 8/8] i40e: implement device reset on VF

2016-06-07 Thread Zhe Tao
From: "zhe.tao" 

Implement the device reset function.
1, Add the fake RX/TX functions.
2, The reset function tries to stop RX/TX by replacing
   the RX/TX functions with the fake ones and getting the
   locks to make sure the regular RX/TX finished.
3, After the RX/TX stopped, reset the VF port, and then
   release the locks.

Signed-off-by: zhe.tao 
---
 app/test-pmd/config.c  |   3 +
 doc/guides/rel_notes/release_16_07.rst |   5 ++
 drivers/net/i40e/i40e_ethdev.h |   7 +-
 drivers/net/i40e/i40e_ethdev_vf.c  | 152 -
 drivers/net/i40e/i40e_rxtx.c   |  10 +++
 drivers/net/i40e/i40e_rxtx.h   |   4 +
 6 files changed, 175 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1c552e4..a120261 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -378,6 +378,7 @@ tx_queue_infos_display(portid_t port_id, uint16_t queue_id)
printf("\nNumber of TXDs: %hu", qinfo.nb_desc);
printf("\n");
 }
+void i40evf_emulate_vf_reset(uint8_t port_id);

 void
 port_infos_display(portid_t port_id)
@@ -398,6 +399,8 @@ port_infos_display(portid_t port_id)
printf("]\n");
return;
}
+   printf("emulate vf reset\n");
+   i40evf_emulate_vf_reset(port_id);
port = [port_id];
rte_eth_link_get_nowait(port_id, );
printf("\n%s Infos for port %-2d %s\n",
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index a4c0cc3..f43b867 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -62,6 +62,11 @@ New Features
   callback in the message handler to notice the APP. APP need call the device
   reset API to reset the VF port.

+* **Added VF reset support for i40e VF driver.**
+
+  Added a new implementaion to allow i40e VF driver to
+  reset the functionality and state of itself.
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 672d920..dcd6e0f 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -541,9 +541,8 @@ struct i40e_adapter {
struct rte_timecounter rx_tstamp_tc;
struct rte_timecounter tx_tstamp_tc;

-   /* For VF reset backup */
-   eth_rx_burst_t rx_backup;
-   eth_tx_burst_t tx_backup;
+   /* For VF reset */
+   uint8_t reset_number;
 };

 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
@@ -597,6 +596,8 @@ void i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t 
queue_id,
 void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
struct rte_eth_txq_info *qinfo);

+void i40evf_emulate_vf_reset(uint8_t port_id);
+
 /* I40E_DEV_PRIVATE_TO */
 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
(&((struct i40e_adapter *)adapter)->pf)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 46d8a7c..d873d2d 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -157,6 +157,12 @@ i40evf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, 
uint16_t queue_id);
 static void i40evf_handle_pf_event(__rte_unused struct rte_eth_dev *dev,
   uint8_t *msg,
   uint16_t msglen);
+static int i40evf_dev_uninit(struct rte_eth_dev *eth_dev);
+static int i40evf_dev_init(struct rte_eth_dev *eth_dev);
+static void i40evf_dev_close(struct rte_eth_dev *dev);
+static int i40evf_dev_start(struct rte_eth_dev *dev);
+static int i40evf_dev_configure(struct rte_eth_dev *dev);
+static int i40evf_handle_vf_reset(struct rte_eth_dev *dev);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
@@ -223,6 +229,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
.reta_query   = i40evf_dev_rss_reta_query,
.rss_hash_update  = i40evf_dev_rss_hash_update,
.rss_hash_conf_get= i40evf_dev_rss_hash_conf_get,
+   .dev_reset= i40evf_handle_vf_reset
 };

 /*
@@ -1309,6 +1316,140 @@ i40evf_uninit_vf(struct rte_eth_dev *dev)
 }

 static void
+i40e_vf_queue_reset(struct rte_eth_dev *dev)
+{
+   uint16_t i;
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
+
+   if (rxq->q_set) {
+   i40e_dev_rx_queue_setup(dev,
+   rxq->queue_id,
+   rxq->nb_rx_desc,
+   rxq->socket_id,
+   >rxconf,
+   rxq->mp);
+   }
+
+   rxq = dev->data->rx_queues[i];
+   rte_spinlock_trylock(>rx_lock);
+   }
+   for (i = 0; i < 

[dpdk-dev] [PATCH v2 7/8] i40e: RX/TX with lock on VF

2016-06-07 Thread Zhe Tao
From: "zhe.tao" 

Add RX/TX paths with lock for VF. It's used when
the function of link reset on VF is needed.
When the lock for RX/TX is added, the RX/TX can be
stopped. Then we have a chance to reset the VF link.

Please be aware there's performence drop if the lock
path is chosen.

Signed-off-by: zhe.tao 
---
 drivers/net/i40e/i40e_ethdev.c|  4 ++--
 drivers/net/i40e/i40e_ethdev.h|  4 
 drivers/net/i40e/i40e_ethdev_vf.c |  4 ++--
 drivers/net/i40e/i40e_rxtx.c  | 45 +--
 drivers/net/i40e/i40e_rxtx.h  | 30 ++
 5 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..1380330 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -764,8 +764,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
PMD_INIT_FUNC_TRACE();

dev->dev_ops = _eth_dev_ops;
-   dev->rx_pkt_burst = i40e_recv_pkts;
-   dev->tx_pkt_burst = i40e_xmit_pkts;
+   dev->rx_pkt_burst = RX_LOCK_FUNCTION(dev, i40e_recv_pkts);
+   dev->tx_pkt_burst = TX_LOCK_FUNCTION(dev, i40e_xmit_pkts);

/* for secondary processes, we don't initialise any further as primary
 * has already done this work. Only check we don't need a different
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..672d920 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -540,6 +540,10 @@ struct i40e_adapter {
struct rte_timecounter systime_tc;
struct rte_timecounter rx_tstamp_tc;
struct rte_timecounter tx_tstamp_tc;
+
+   /* For VF reset backup */
+   eth_rx_burst_t rx_backup;
+   eth_tx_burst_t tx_backup;
 };

 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 90682ac..46d8a7c 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1451,8 +1451,8 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)

/* assign ops func pointer */
eth_dev->dev_ops = _eth_dev_ops;
-   eth_dev->rx_pkt_burst = _recv_pkts;
-   eth_dev->tx_pkt_burst = _xmit_pkts;
+   eth_dev->rx_pkt_burst = RX_LOCK_FUNCTION(eth_dev, i40e_recv_pkts);
+   eth_dev->tx_pkt_burst = TX_LOCK_FUNCTION(eth_dev, i40e_xmit_pkts);

/*
 * For secondary processes, we don't initialise any further as primary
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index c833aa3..0a6dcfb 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -79,10 +79,6 @@
PKT_TX_TCP_SEG | \
PKT_TX_OUTER_IP_CKSUM)

-static uint16_t i40e_xmit_pkts_simple(void *tx_queue,
- struct rte_mbuf **tx_pkts,
- uint16_t nb_pkts);
-
 static inline void
 i40e_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union i40e_rx_desc *rxdp)
 {
@@ -1144,7 +1140,7 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
return 0;
 }

-static uint16_t
+uint16_t
 i40e_recv_pkts_bulk_alloc(void *rx_queue,
  struct rte_mbuf **rx_pkts,
  uint16_t nb_pkts)
@@ -1169,7 +1165,7 @@ i40e_recv_pkts_bulk_alloc(void *rx_queue,
return nb_rx;
 }
 #else
-static uint16_t
+uint16_t
 i40e_recv_pkts_bulk_alloc(void __rte_unused *rx_queue,
  struct rte_mbuf __rte_unused **rx_pkts,
  uint16_t __rte_unused nb_pkts)
@@ -1892,7 +1888,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq,
return nb_pkts;
 }

-static uint16_t
+uint16_t
 i40e_xmit_pkts_simple(void *tx_queue,
  struct rte_mbuf **tx_pkts,
  uint16_t nb_pkts)
@@ -2121,10 +2117,13 @@ i40e_dev_supported_ptypes_get(struct rte_eth_dev *dev)
};

if (dev->rx_pkt_burst == i40e_recv_pkts ||
+   dev->rx_pkt_burst == i40e_recv_pkts_lock ||
 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
dev->rx_pkt_burst == i40e_recv_pkts_bulk_alloc ||
+   dev->rx_pkt_burst == i40e_recv_pkts_bulk_alloc_lock ||
 #endif
-   dev->rx_pkt_burst == i40e_recv_scattered_pkts)
+   dev->rx_pkt_burst == i40e_recv_scattered_pkts ||
+   dev->rx_pkt_burst == i40e_recv_scattered_pkts_lock)
return ptypes;
return NULL;
 }
@@ -2648,6 +2647,7 @@ i40e_reset_rx_queue(struct i40e_rx_queue *rxq)

rxq->rxrearm_start = 0;
rxq->rxrearm_nb = 0;
+   rte_spinlock_init(>rx_lock);
 }

 void
@@ -2704,6 +2704,7 @@ i40e_reset_tx_queue(struct i40e_tx_queue *txq)

txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
+   rte_spinlock_init(>tx_lock);
 }

 /* Init the TX 

[dpdk-dev] [PATCH v2 6/8] igb: implement device reset on VF

2016-06-07 Thread Zhe Tao
From: Wenzhuo Lu 

Implement the device reset function.
1, Add the fake RX/TX functions.
2, The reset function tries to stop RX/TX by replacing
   the RX/TX functions with the fake ones and getting the
   locks to make sure the regular RX/TX finished.
3, After the RX/TX stopped, reset the VF port, and then
   release the locks and restore the RX/TX functions.

BTW: The definition of some structures are moved from .c
file to .h file.

Signed-off-by: Wenzhuo Lu 
Signed-off-by: zhe.tao 
---
 doc/guides/rel_notes/release_16_07.rst |   2 +-
 drivers/net/e1000/e1000_ethdev.h   | 116 ++
 drivers/net/e1000/igb_ethdev.c | 104 +++
 drivers/net/e1000/igb_rxtx.c   | 128 ++---
 4 files changed, 243 insertions(+), 107 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index d36c4b1..a4c0cc3 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -53,7 +53,7 @@ New Features
   VF. To handle this link up/down event, add the mailbox interruption
   support to receive the message.

-* **Added device reset support for ixgbe VF.**
+* **Added device reset support for ixgbe/igb VF.**

   Added the device reset API. APP can call this API to reset the VF port
   when it's not working.
diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 6a42994..4ae03ce 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include 
+#include 

 /* need update link, bit flag */
 #define E1000_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
@@ -261,6 +262,113 @@ struct e1000_adapter {
struct rte_timecounter  systime_tc;
struct rte_timecounter  rx_tstamp_tc;
struct rte_timecounter  tx_tstamp_tc;
+   eth_rx_burst_t rx_backup;
+   eth_tx_burst_t tx_backup;
+};
+
+/**
+ * Structure associated with each descriptor of the RX ring of a RX queue.
+ */
+struct igb_rx_entry {
+   struct rte_mbuf *mbuf; /**< mbuf associated with RX descriptor. */
+};
+
+/**
+ * Structure associated with each descriptor of the TX ring of a TX queue.
+ */
+struct igb_tx_entry {
+   struct rte_mbuf *mbuf; /**< mbuf associated with TX desc, if any. */
+   uint16_t next_id; /**< Index of next descriptor in ring. */
+   uint16_t last_id; /**< Index of last scattered descriptor. */
+};
+
+/**
+ * Hardware context number
+ */
+enum igb_advctx_num {
+   IGB_CTX_0= 0, /**< CTX0*/
+   IGB_CTX_1= 1, /**< CTX1*/
+   IGB_CTX_NUM  = 2, /**< CTX_NUM */
+};
+
+/** Offload features */
+union igb_tx_offload {
+   uint64_t data;
+   struct {
+   uint64_t l3_len:9; /**< L3 (IP) Header Length. */
+   uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
+   uint64_t vlan_tci:16;  /**< VLAN Tag Control Identifier(CPU 
order). */
+   uint64_t l4_len:8; /**< L4 (TCP/UDP) Header Length. */
+   uint64_t tso_segsz:16; /**< TCP TSO segment size. */
+
+   /* uint64_t unused:8; */
+   };
+};
+
+/**
+ * Strucutre to check if new context need be built
+ */
+struct igb_advctx_info {
+   uint64_t flags;   /**< ol_flags related to context build. */
+   /** tx offload: vlan, tso, l2-l3-l4 lengths. */
+   union igb_tx_offload tx_offload;
+   /** compare mask for tx offload. */
+   union igb_tx_offload tx_offload_mask;
+};
+
+/**
+ * Structure associated with each RX queue.
+ */
+struct igb_rx_queue {
+   struct rte_mempool  *mb_pool;   /**< mbuf pool to populate RX ring. */
+   volatile union e1000_adv_rx_desc *rx_ring; /**< RX ring virtual 
address. */
+   uint64_trx_ring_phys_addr; /**< RX ring DMA address. */
+   volatile uint32_t   *rdt_reg_addr; /**< RDT register address. */
+   volatile uint32_t   *rdh_reg_addr; /**< RDH register address. */
+   struct igb_rx_entry *sw_ring;   /**< address of RX software ring. */
+   struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
+   struct rte_mbuf *pkt_last_seg;  /**< Last segment of current packet. */
+   rte_spinlock_t  rx_lock; /**< Lock for packet receiption. */
+   uint16_tnb_rx_desc; /**< number of RX descriptors. */
+   uint16_trx_tail;/**< current value of RDT register. */
+   uint16_tnb_rx_hold; /**< number of held free RX desc. */
+   uint16_trx_free_thresh; /**< max free RX desc to hold. */
+   uint16_tqueue_id;   /**< RX queue index. */
+   uint16_treg_idx;/**< RX queue register index. */
+   uint8_t port_id;/**< Device port identifier. */
+   uint8_t pthresh;/**< Prefetch threshold register. */
+   uint8_t

[dpdk-dev] [PATCH v2 5/8] igb: RX/TX with lock on VF

2016-06-07 Thread Zhe Tao
From: Wenzhuo Lu 

Add RX/TX paths with lock for VF. It's used when
the function of link reset on VF is needed.
When the lock for RX/TX is added, the RX/TX can be
stopped. Then we have a chance to reset the VF link.

Please be aware there's performence drop if the lock
path is chosen.

Signed-off-by: Wenzhuo Lu 
Signed-off-by: zhe.tao 
---
 drivers/net/e1000/e1000_ethdev.h | 10 ++
 drivers/net/e1000/igb_ethdev.c   | 14 +++---
 drivers/net/e1000/igb_rxtx.c | 26 +-
 3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index e8bf8da..6a42994 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -319,6 +319,16 @@ uint16_t eth_igb_recv_pkts(void *rxq, struct rte_mbuf 
**rx_pkts,
 uint16_t eth_igb_recv_scattered_pkts(void *rxq,
struct rte_mbuf **rx_pkts, uint16_t nb_pkts);

+uint16_t eth_igb_xmit_pkts_lock(void *txq,
+   struct rte_mbuf **tx_pkts,
+   uint16_t nb_pkts);
+uint16_t eth_igb_recv_pkts_lock(void *rxq,
+   struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts);
+uint16_t eth_igb_recv_scattered_pkts_lock(void *rxq,
+ struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts);
+
 int eth_igb_rss_hash_update(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf);

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index b0e5e6a..8aad741 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -909,15 +909,17 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
PMD_INIT_FUNC_TRACE();

eth_dev->dev_ops = _eth_dev_ops;
-   eth_dev->rx_pkt_burst = _igb_recv_pkts;
-   eth_dev->tx_pkt_burst = _igb_xmit_pkts;
+   eth_dev->rx_pkt_burst = RX_LOCK_FUNCTION(eth_dev, eth_igb_recv_pkts);
+   eth_dev->tx_pkt_burst = TX_LOCK_FUNCTION(eth_dev, eth_igb_xmit_pkts);

/* for secondary processes, we don't initialise any further as primary
 * has already done this work. Only check we don't need a different
 * RX function */
if (rte_eal_process_type() != RTE_PROC_PRIMARY){
if (eth_dev->data->scattered_rx)
-   eth_dev->rx_pkt_burst = _igb_recv_scattered_pkts;
+   eth_dev->rx_pkt_burst =
+   RX_LOCK_FUNCTION(eth_dev,
+eth_igb_recv_scattered_pkts);
return 0;
}

@@ -1999,7 +2001,13 @@ eth_igb_supported_ptypes_get(struct rte_eth_dev *dev)
};

if (dev->rx_pkt_burst == eth_igb_recv_pkts ||
+#ifndef RTE_NEXT_ABI
dev->rx_pkt_burst == eth_igb_recv_scattered_pkts)
+#else
+   dev->rx_pkt_burst == eth_igb_recv_scattered_pkts ||
+   dev->rx_pkt_burst == eth_igb_recv_pkts_lock ||
+   dev->rx_pkt_burst == eth_igb_recv_scattered_pkts_lock)
+#endif
return ptypes;
return NULL;
 }
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 18aeead..7e97330 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "e1000_logs.h"
 #include "base/e1000_api.h"
@@ -107,6 +108,7 @@ struct igb_rx_queue {
struct igb_rx_entry *sw_ring;   /**< address of RX software ring. */
struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
struct rte_mbuf *pkt_last_seg;  /**< Last segment of current packet. */
+   rte_spinlock_t  rx_lock; /**< Lock for packet receiption. */
uint16_tnb_rx_desc; /**< number of RX descriptors. */
uint16_trx_tail;/**< current value of RDT register. */
uint16_tnb_rx_hold; /**< number of held free RX desc. */
@@ -174,6 +176,7 @@ struct igb_tx_queue {
volatile union e1000_adv_tx_desc *tx_ring; /**< TX ring address */
uint64_t   tx_ring_phys_addr; /**< TX ring DMA address. */
struct igb_tx_entry*sw_ring; /**< virtual address of SW ring. */
+   rte_spinlock_t tx_lock; /**< Lock for packet transmission. */
volatile uint32_t  *tdt_reg_addr; /**< Address of TDT register. */
uint32_t   txd_type;  /**< Device-specific TXD type */
uint16_t   nb_tx_desc;/**< number of TX descriptors. */
@@ -615,6 +618,8 @@ eth_igb_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
return nb_tx;
 }

+GENERATE_TX_LOCK(eth_igb_xmit_pkts, igb)
+
 /*
  *
  *  RX functions
@@ -931,6 +936,8 @@ eth_igb_recv_pkts(void *rx_queue, 

[dpdk-dev] [PATCH v2 4/8] ixgbe: implement device reset on VF

2016-06-07 Thread Zhe Tao
From: Wenzhuo Lu 

Implement the device reset function.
1, Add the fake RX/TX functions.
2, The reset function tries to stop RX/TX by replacing
   the RX/TX functions with the fake ones and getting the
   locks to make sure the regular RX/TX finished.
3, After the RX/TX stopped, reset the VF port, and then
   release the locks and restore the RX/TX functions.

Signed-off-by: Wenzhuo Lu 
Signed-off-by: zhe.tao 
---
 doc/guides/rel_notes/release_16_07.rst |   9 +++
 drivers/net/ixgbe/ixgbe_ethdev.c   | 108 -
 drivers/net/ixgbe/ixgbe_ethdev.h   |  12 +++-
 drivers/net/ixgbe/ixgbe_rxtx.c |  42 -
 4 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index a761e3c..d36c4b1 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -53,6 +53,15 @@ New Features
   VF. To handle this link up/down event, add the mailbox interruption
   support to receive the message.

+* **Added device reset support for ixgbe VF.**
+
+  Added the device reset API. APP can call this API to reset the VF port
+  when it's not working.
+  Based on the mailbox interruption support, when VF reseives the control
+  message from PF, it means the PF link state changes, VF uses the reset
+  callback in the message handler to notice the APP. APP need call the device
+  reset API to reset the VF port.
+

 Resolved Issues
 ---
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index fd2682f..1e3520b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -381,6 +381,8 @@ static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev 
*dev,
 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
 struct rte_eth_udp_tunnel *udp_tunnel);

+static int ixgbevf_dev_reset(struct rte_eth_dev *dev);
+
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */
@@ -586,6 +588,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
.reta_query   = ixgbe_dev_rss_reta_query,
.rss_hash_update  = ixgbe_dev_rss_hash_update,
.rss_hash_conf_get= ixgbe_dev_rss_hash_conf_get,
+   .dev_reset= ixgbevf_dev_reset,
 };

 /* store statistics names and its offset in stats structure */
@@ -4060,7 +4063,8 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)
ETH_VLAN_EXTEND_MASK;
ixgbevf_vlan_offload_set(dev, mask);

-   ixgbevf_dev_rxtx_start(dev);
+   if (ixgbevf_dev_rxtx_start(dev))
+   return -1;

/* check and configure queue intr-vector mapping */
if (dev->data->dev_conf.intr_conf.rxq != 0) {
@@ -7193,6 +7197,108 @@ static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
 }

 static int
+ixgbevf_dev_reset(struct rte_eth_dev *dev)
+{
+   struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct ixgbe_adapter *adapter =
+   (struct ixgbe_adapter *)dev->data->dev_private;
+   int diag = 0;
+   uint32_t vteiam;
+   uint16_t i;
+   struct ixgbe_rx_queue *rxq;
+   struct ixgbe_tx_queue *txq;
+
+   /* Nothing needs to be done if the device is not started. */
+   if (!dev->data->dev_started)
+   return 0;
+
+   PMD_DRV_LOG(DEBUG, "Link up/down event detected.");
+
+   /**
+* Stop RX/TX by fake functions and locks.
+* Fake functions are used to make RX/TX lock easier.
+*/
+   adapter->rx_backup = dev->rx_pkt_burst;
+   adapter->tx_backup = dev->tx_pkt_burst;
+   dev->rx_pkt_burst = ixgbevf_recv_pkts_fake;
+   dev->tx_pkt_burst = ixgbevf_xmit_pkts_fake;
+
+   if (dev->data->rx_queues)
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   rxq = dev->data->rx_queues[i];
+   rte_spinlock_lock(>rx_lock);
+   }
+
+   if (dev->data->tx_queues)
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   rte_spinlock_lock(>tx_lock);
+   }
+
+   /* Performance VF reset. */
+   do {
+   dev->data->dev_started = 0;
+   ixgbevf_dev_stop(dev);
+   if (dev->data->dev_conf.intr_conf.lsc == 0)
+   diag = ixgbe_dev_link_update(dev, 0);
+   if (diag) {
+   PMD_INIT_LOG(INFO, "Ixgbe VF reset: "
+"Failed to update link.");
+   }
+   rte_delay_ms(1000);
+
+   diag = ixgbevf_dev_start(dev);
+   /*If fail to start the device, need to stop/start it again. */
+   if (diag) {
+   PMD_INIT_LOG(ERR, "Ixgbe VF reset: "
+   

[dpdk-dev] [PATCH v2 3/8] ixgbe: RX/TX with lock on VF

2016-06-07 Thread Zhe Tao
From: Wenzhuo Lu 

Add RX/TX paths with lock for VF. It's used when
the function of link reset on VF is needed.
When the lock for RX/TX is added, the RX/TX can be
stopped. Then we have a chance to reset the VF link.

Please be aware there's performence drop if the lock
path is chosen.

Signed-off-by: Wenzhuo Lu 
Signed-off-by: zhe.tao 
---
 drivers/net/ixgbe/ixgbe_ethdev.c   | 12 +--
 drivers/net/ixgbe/ixgbe_ethdev.h   | 20 +++
 drivers/net/ixgbe/ixgbe_rxtx.c | 74 --
 drivers/net/ixgbe/ixgbe_rxtx.h | 13 +++
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |  6 
 5 files changed, 112 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 05f4f29..fd2682f 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1325,8 +1325,8 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
PMD_INIT_FUNC_TRACE();

eth_dev->dev_ops = _eth_dev_ops;
-   eth_dev->rx_pkt_burst = _recv_pkts;
-   eth_dev->tx_pkt_burst = _xmit_pkts;
+   eth_dev->rx_pkt_burst = RX_LOCK_FUNCTION(eth_dev, ixgbe_recv_pkts);
+   eth_dev->tx_pkt_burst = TX_LOCK_FUNCTION(eth_dev, ixgbe_xmit_pkts);

/* for secondary processes, we don't initialise any further as primary
 * has already done this work. Only check we don't need a different
@@ -3012,7 +3012,15 @@ ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
+#ifndef RTE_NEXT_ABI
dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
+#else
+   dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_lock ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc_lock ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc_lock ||
+   dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc_lock)
+#endif
return ptypes;
return NULL;
 }
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 4ff6338..701107b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -390,12 +390,32 @@ uint16_t ixgbe_recv_pkts_lro_single_alloc(void *rx_queue,
 uint16_t ixgbe_recv_pkts_lro_bulk_alloc(void *rx_queue,
struct rte_mbuf **rx_pkts, uint16_t nb_pkts);

+uint16_t ixgbe_recv_pkts_lock(void *rx_queue,
+ struct rte_mbuf **rx_pkts,
+ uint16_t nb_pkts);
+uint16_t ixgbe_recv_pkts_bulk_alloc_lock(void *rx_queue,
+struct rte_mbuf **rx_pkts,
+uint16_t nb_pkts);
+uint16_t ixgbe_recv_pkts_lro_single_alloc_lock(void *rx_queue,
+  struct rte_mbuf **rx_pkts,
+  uint16_t nb_pkts);
+uint16_t ixgbe_recv_pkts_lro_bulk_alloc_lock(void *rx_queue,
+struct rte_mbuf **rx_pkts,
+uint16_t nb_pkts);
+
 uint16_t ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);

 uint16_t ixgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);

+uint16_t ixgbe_xmit_pkts_lock(void *tx_queue,
+ struct rte_mbuf **tx_pkts,
+ uint16_t nb_pkts);
+uint16_t ixgbe_xmit_pkts_simple_lock(void *tx_queue,
+struct rte_mbuf **tx_pkts,
+uint16_t nb_pkts);
+
 int ixgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
  struct rte_eth_rss_conf *rss_conf);

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 9c6eaf2..a45d115 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -353,6 +353,8 @@ ixgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf 
**tx_pkts,
return nb_tx;
 }

+GENERATE_TX_LOCK(ixgbe_xmit_pkts_simple, ixgbe)
+
 static inline void
 ixgbe_set_xmit_ctx(struct ixgbe_tx_queue *txq,
volatile struct ixgbe_adv_tx_context_desc *ctx_txd,
@@ -904,6 +906,8 @@ end_of_tx:
return nb_tx;
 }

+GENERATE_TX_LOCK(ixgbe_xmit_pkts, ixgbe)
+
 /*
  *
  *  RX functions
@@ -1524,6 +1528,8 @@ ixgbe_recv_pkts_bulk_alloc(void *rx_queue, struct 
rte_mbuf **rx_pkts,
return nb_rx;
 }

+GENERATE_RX_LOCK(ixgbe_recv_pkts_bulk_alloc, ixgbe)
+
 uint16_t
 ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts)
@@ -1712,6 +1718,8 @@ ixgbe_recv_pkts(void *rx_queue, struct 

[dpdk-dev] [PATCH v2 2/8] lib/librte_ether: defind RX/TX lock mode

2016-06-07 Thread Zhe Tao
From: Wenzhuo Lu <wenzhuo...@intel.com>

Define lock mode for RX/TX queue. Because when resetting
the device we want the resetting thread to get the lock
of the RX/TX queue to make sure the RX/TX is stopped.

Using next ABI macro for this ABI change as it has too
much impact. 7 APIs and 1 global variable are impacted.

Signed-off-by: Wenzhuo Lu 
Signed-off-by: Zhe Tao 
Signed-off-by: zhe.tao 
---
 lib/librte_ether/rte_ethdev.h | 62 +++
 1 file changed, 62 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 74e895f..4efb5e9 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -354,7 +354,12 @@ struct rte_eth_rxmode {
jumbo_frame  : 1, /**< Jumbo Frame Receipt enable. */
hw_strip_crc : 1, /**< Enable CRC stripping by hardware. */
enable_scatter   : 1, /**< Enable scatter packets rx handler */
+#ifndef RTE_NEXT_ABI
enable_lro   : 1; /**< Enable LRO */
+#else
+   enable_lro   : 1, /**< Enable LRO */
+   lock_mode: 1; /**< Using lock path */
+#endif
 };

 /**
@@ -634,11 +639,68 @@ struct rte_eth_txmode {
/**< If set, reject sending out tagged pkts */
hw_vlan_reject_untagged : 1,
/**< If set, reject sending out untagged pkts */
+#ifndef RTE_NEXT_ABI
hw_vlan_insert_pvid : 1;
/**< If set, enable port based VLAN insertion */
+#else
+   hw_vlan_insert_pvid : 1,
+   /**< If set, enable port based VLAN insertion */
+   lock_mode : 1;
+   /**< If set, using lock path */
+#endif
 };

 /**
+ * The macros for the RX/TX lock mode functions
+ */
+#ifdef RTE_NEXT_ABI
+#define RX_LOCK_FUNCTION(dev, func) \
+   (dev->data->dev_conf.rxmode.lock_mode ? \
+   func ## _lock : func)
+
+#define TX_LOCK_FUNCTION(dev, func) \
+   (dev->data->dev_conf.txmode.lock_mode ? \
+   func ## _lock : func)
+#else
+#define RX_LOCK_FUNCTION(dev, func) func
+
+#define TX_LOCK_FUNCTION(dev, func) func
+#endif
+
+/* Add the lock RX/TX function for VF reset */
+#define GENERATE_RX_LOCK(func, nic) \
+uint16_t func ## _lock(void *rx_queue, \
+ struct rte_mbuf **rx_pkts, \
+ uint16_t nb_pkts) \
+{  \
+   struct nic ## _rx_queue *rxq = rx_queue; \
+   uint16_t nb_rx = 0; \
+   \
+   if (rte_spinlock_trylock(>rx_lock)) { \
+   nb_rx = func(rx_queue, rx_pkts, nb_pkts); \
+   rte_spinlock_unlock(>rx_lock); \
+   } \
+   \
+   return nb_rx; \
+}
+
+#define GENERATE_TX_LOCK(func, nic) \
+uint16_t func ## _lock(void *tx_queue, \
+ struct rte_mbuf **tx_pkts, \
+ uint16_t nb_pkts) \
+{  \
+   struct nic ## _tx_queue *txq = tx_queue; \
+   uint16_t nb_tx = 0; \
+   \
+   if (rte_spinlock_trylock(>tx_lock)) { \
+   nb_tx = func(tx_queue, tx_pkts, nb_pkts); \
+   rte_spinlock_unlock(>tx_lock); \
+   } \
+   \
+   return nb_tx; \
+}
+
+/**
  * A structure used to configure an RX ring of an Ethernet port.
  */
 struct rte_eth_rxconf {
-- 
2.1.4



[dpdk-dev] [PATCH v2 1/8] lib/librte_ether: support device reset

2016-06-07 Thread Zhe Tao
From: Wenzhuo Lu 

Add an API to reset the device.
It's for VF device in this scenario, kernel PF + DPDK VF.
When the PF port down/up, APP should call this API to
reset VF port. Most likely, APP should call it in its
management thread and guarantee the thread safe.

Signed-off-by: Wenzhuo Lu 
Signed-off-by: zhe.tao 
---
 lib/librte_ether/rte_ethdev.c  | 17 +
 lib/librte_ether/rte_ethdev.h  | 14 ++
 lib/librte_ether/rte_ether_version.map |  7 +++
 3 files changed, 38 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e148028..e43dca9 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3346,3 +3346,20 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id,
-ENOTSUP);
return (*dev->dev_ops->l2_tunnel_offload_set)(dev, l2_tunnel, mask, en);
 }
+
+int
+rte_eth_dev_reset(uint8_t port_id)
+{
+   struct rte_eth_dev *dev;
+   int diag;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+   dev = _eth_devices[port_id];
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_reset, -ENOTSUP);
+
+   diag = (*dev->dev_ops->dev_reset)(dev);
+
+   return diag;
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2757510..74e895f 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1318,6 +1318,9 @@ typedef int (*eth_l2_tunnel_offload_set_t)
 uint8_t en);
 /**< @internal enable/disable the l2 tunnel offload functions */

+typedef int  (*eth_dev_reset_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to reset a configured Ethernet device. */
+
 #ifdef RTE_NIC_BYPASS

 enum {
@@ -1508,6 +1511,8 @@ struct eth_dev_ops {
eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
/** Enable/disable l2 tunnel offload functions */
eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
+   /** Reset device. */
+   eth_dev_reset_t dev_reset;
 };

 /**
@@ -4253,6 +4258,15 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id,
  uint32_t mask,
  uint8_t en);

+/**
+ * Reset an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ */
+int
+rte_eth_dev_reset(uint8_t port_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index 214ecc7..c34207e 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -132,3 +132,10 @@ DPDK_16.04 {
rte_eth_tx_buffer_set_err_callback;

 } DPDK_2.2;
+
+DPDK_16.07 {
+   global:
+
+   rte_eth_dev_reset;
+
+} DPDK_16.04;
-- 
2.1.4



[dpdk-dev] [PATCH v2 0/8] support reset of VF link

2016-06-07 Thread Zhe Tao
From: "zhe.tao" 

If the PF link is down and up, VF link will not work
accordingly.
This patch set addes the support of VF link reset. So, when VF
receices the messges of physical link down/up. APP can reset the
VF link and let it recover.

PS: This patch set is splitted from a previous patch set, *automatic
link recovery on ixgbe/igb VF*, and it's base on the patch set
*support mailbox interruption on ixgbe/igb VF*.

Wenzhuo Lu (6):
  lib/librte_ether: support device reset
  lib/librte_ether: defind RX/TX lock mode
  ixgbe: RX/TX with lock on VF
  ixgbe: implement device reset on VF
  igb: RX/TX with lock on VF
  igb: implement device reset on VF

zhe.tao (2):
  i40e: RX/TX with lock on VF
  i40e: implement device reset on VF

v1:
  Added the implementation for the VF reset functionality.  
v2:
  Changed the i40e related operations during VF reset.  

 app/test-pmd/config.c  |   3 +
 doc/guides/rel_notes/release_16_07.rst |  14 +++
 drivers/net/e1000/e1000_ethdev.h   | 126 +++
 drivers/net/e1000/igb_ethdev.c | 118 -
 drivers/net/e1000/igb_rxtx.c   | 148 +---
 drivers/net/i40e/i40e_ethdev.c |   4 +-
 drivers/net/i40e/i40e_ethdev.h |   5 ++
 drivers/net/i40e/i40e_ethdev_vf.c  | 152 -
 drivers/net/i40e/i40e_rxtx.c   |  55 
 drivers/net/i40e/i40e_rxtx.h   |  34 
 drivers/net/ixgbe/ixgbe_ethdev.c   | 120 +-
 drivers/net/ixgbe/ixgbe_ethdev.h   |  32 ++-
 drivers/net/ixgbe/ixgbe_rxtx.c | 116 ++---
 drivers/net/ixgbe/ixgbe_rxtx.h |  13 +++
 drivers/net/ixgbe/ixgbe_rxtx_vec.c |   6 ++
 lib/librte_ether/rte_ethdev.c  |  17 
 lib/librte_ether/rte_ethdev.h  |  76 +
 lib/librte_ether/rte_ether_version.map |   7 ++
 18 files changed, 898 insertions(+), 148 deletions(-)

-- 
2.1.4



[dpdk-dev] [PATCH] i40e: fix flexible payload selection

2016-06-02 Thread Zhe Tao
On Thu, May 12, 2016 at 04:11:40PM +0800, Jingjing Wu wrote:
> When setting up flexible payload selection rules, it is allowed
> that setting value to 63 to disable the rule (NONUSE_FLX_PIT_DEST_OFF).
> However, MK_FLX_PIT macro is always adding an offset value 50
> (I40E_FLX_OFFSET_IN_FIELD_VECTOR), it will be set to "63 + 50" and
> when setting NONUSE_FLX_PIT_DEST_OFF to disable it. It breaks
> the functionality.
> This patch fixes this issue.
> 
> Fixes: d8b90c4eabe9 ("i40e: take flow director flexible payload
>   configuration")
> 
> Reported-by: Michael Habibi 
> Signed-off-by: Jingjing Wu 
> ---
>  drivers/net/i40e/i40e_fdir.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
> index 8aa41e5..efbcd18 100644
> --- a/drivers/net/i40e/i40e_fdir.c
> +++ b/drivers/net/i40e/i40e_fdir.c
> @@ -94,7 +94,9 @@
>   I40E_PRTQF_FLX_PIT_SOURCE_OFF_MASK) | \
>   (((fsize) << I40E_PRTQF_FLX_PIT_FSIZE_SHIFT) & \
>   I40E_PRTQF_FLX_PIT_FSIZE_MASK) | \
> - dst_offset) + I40E_FLX_OFFSET_IN_FIELD_VECTOR) << \
> + dst_offset) == NONUSE_FLX_PIT_DEST_OFF ? \
> + NONUSE_FLX_PIT_DEST_OFF : \
> + ((dst_offset) + I40E_FLX_OFFSET_IN_FIELD_VECTOR)) << \
>       I40E_PRTQF_FLX_PIT_DEST_OFF_SHIFT) & \
>   I40E_PRTQF_FLX_PIT_DEST_OFF_MASK))
>  
> -- 
> 2.4.0
Acked-by: Zhe Tao 


[dpdk-dev] [PATCH 0/2] NSH packet type support in i40e

2016-06-02 Thread Zhe Tao
On Tue, May 03, 2016 at 01:51:10PM +0800, Jingjing Wu wrote:
> NSH packet can be recognized by Intel X710/XL710 series. This
> patch set enables it.
> 
> Jingjing Wu (2):
>   mbuf: new NSH packet type
>   i40e: NSH packet type support
> 
>  app/test-pmd/rxonly.c  |  3 +++
>  doc/guides/rel_notes/release_16_07.rst |  2 ++
>  drivers/net/i40e/i40e_rxtx.c   | 27 +++
>  lib/librte_mbuf/rte_mbuf.h |  7 +++
>  4 files changed, 39 insertions(+)
> 
> -- 
> 2.4.0
Acked-by: Zhe Tao 



[dpdk-dev] [PATCH v8 3/3] i40e: add floating VEB extension support

2016-05-25 Thread Zhe Tao
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floating=1", and the application will make sure the PMD
will use the floating VEB feature for all the VFs created by this PF device.

Also you can specifiy which VF need to connect to this floating veb using
"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
Like "-w 84:00.0,enable_floating=1,floating_bitmap=1", means only the VF0 
connect
to the floating VEB, VF1 connect to the legacy VEB.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |  5 +++-
 drivers/net/i40e/i40e_ethdev.c | 56 --
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_pf.c |  3 ++-
 4 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 49a0598..0919a96 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -372,4 +372,7 @@ FVL can support floating VEB feature.
 To enable this feature, the user should pass a devargs parameter to the EAL
 like "-w 84:00.0,enable_floating=1", and the application will make sure the PMD
 will use the floating VEB feature for all the VFs created by this PF device.
-
+Also you can specify which VF need to connect to this floating veb using
+"floating_bitmap", every bit corresponding to one VF (e.g. bitn for VFn).
+Like "-w 84:00.0,enable_floating=1,floating_bitmap=1", means only the VF0 
connect
+to the floating VEB, VF1 connect to the legacy VEB.
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 8859936..39da1e0 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,52 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_fbitmap_handler(__rte_unused const char *key,
+ const char *value,
+ void *opaque)
+{
+   errno = 0;
+   *(uint16_t *)opaque = strtoul(value, NULL, 0);
+   if (errno)
+   return -1;
+   return 0;
+}
+
+static uint16_t i40e_check_fbitmap(struct rte_devargs *devargs,
+  uint16_t floating)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_bitmap = "floating_bitmap";
+   /* default value for vf floating bitmap is -1 */
+   uint16_t vf_fbitmap = (uint16_t)-1;
+   uint16_t new_vf_fbitmap;
+
+   if (floating == false)
+   return 0;
+
+   if (devargs == NULL)
+   return vf_fbitmap;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return vf_fbitmap;
+
+   if (!rte_kvargs_count(kvlist, floating_bitmap)) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   /* Floating is enabled when there's key-value pair: enable_floating=1 */
+   if (rte_kvargs_process(kvlist, floating_bitmap,
+  i40e_check_fbitmap_handler,
+  _vf_fbitmap) < 0) {
+   rte_kvargs_free(kvlist);
+   return vf_fbitmap;
+   }
+   rte_kvargs_free(kvlist);
+
+   return new_vf_fbitmap;
+}
+
 static int i40e_check_floating_handler(__rte_unused const char *key,
   const char *value,
   __rte_unused void *opaque)
@@ -884,8 +930,11 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
/* Need the special FW version support floating VEB */
if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
pf->floating = i40e_check_floating(pci_dev->devargs);
+   pf->vf_fbitmap = i40e_check_fbitmap(pci_dev->devargs,
+   pf->floating);
} else {
pf->floating = false;
+   pf->vf_fbitmap = 0;
}
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);
@@ -3855,6 +3904,7 @@ i40e_vsi_release(struct i40e_vsi *vsi)
struct i40e_vsi_list *vsi_list;
int ret;
struct i40e_mac_filter *f;
+   uint16_t user_param = vsi->user_param;

if (!vsi)
return I40E_SUCCESS;
@@ -3886,7 +3936,8 @@ i40e_vsi_release(struct i40e_vsi *vsi)
rte_free(f);

if (vsi->type != I40E_VSI_MAIN &&
-   ((vsi->type != I40E_VSI_SRIOV) || !pf->floating)) {
+   ((vsi->type != I40E_VSI_SRIOV) ||
+   !(pf->vf_fbitmap && 1 << user_param))) {
/* Remove vsi from parent's sibling list */
if (vsi->parent_vsi == NULL || vsi->parent_vsi->veb == NULL) {
PMD_DRV_LOG(ERR, "VSI's parent VSI is NULL&

[dpdk-dev] [PATCH v8 2/3] i40e: Add floating VEB support in i40e

2016-05-25 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

Now the floating VEB feature is only avaiable in the specific version of FW.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |   7 +++
 doc/guides/rel_notes/release_16_07.rst |   6 ++
 drivers/net/i40e/i40e_ethdev.c | 109 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 112 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 934eb02..49a0598 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,10 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floating=1", and the application will make sure the PMD
+will use the floating VEB feature for all the VFs created by this PF device.
+
diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 30e78d4..8485b08 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 floating VEB support for i40e PF driver.**
+
+  Now VFs for i40e can connect to the floating VEB.
+  With this feature, VFs can communicate with each other, but cannot access
+  outside network. When PF is down, and VFs can still forward pkts between each
+  other.

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index e558c63..8859936 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3762,21 +3762,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3788,9 +3794,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3802,11 +3808,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
+ I40E_DEFAULT_TCMAP, false,
+ >seid, false, NULL);
+   } else {
+   ret = i40e_aq_add_veb(hw, 0, 0, I40E_DEFAULT_TCMAP,
+ true, >seid, false, NULL);
+   }

if (ret != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Add veb failed, aq_err: %d",
@@ -3822,10 +3836,10 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)

[dpdk-dev] [PATCH v8 1/3] i40e: support floating VEB config

2016-05-25 Thread Zhe Tao
Add the new floating related argument option in the devarg.
Using this parameter, all the samples can decide whether to use legacy VEB/VEPA
or floating VEB.
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floating=1", and the application will make sure the PMD
will use the floating VEB feature for all the VFs created by this PF device.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 44 ++
 drivers/net/i40e/i40e_ethdev.h |  6 ++
 2 files changed, 50 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..e558c63 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -750,6 +750,44 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_floating_handler(__rte_unused const char *key,
+  const char *value,
+  __rte_unused void *opaque)
+{
+   if (strcmp(value, "1"))
+   return -1;
+
+   return 0;
+}
+
+static int
+i40e_check_floating(struct rte_devargs *devargs)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_key = "enable_floating";
+
+   if (devargs == NULL)
+   return 0;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return 0;
+
+   if (!rte_kvargs_count(kvlist, floating_key)) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   /* Floating is enabled when there's key-value pair: enable_floating=1 */
+   if (rte_kvargs_process(kvlist, floating_key,
+  i40e_check_floating_handler, NULL) < 0) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   rte_kvargs_free(kvlist);
+
+   return 1;
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -843,6 +881,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

+   /* Need the special FW version support floating VEB */
+   if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
+   pf->floating = i40e_check_floating(pci_dev->devargs);
+   } else {
+   pf->floating = false;
+   }
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..8297c5f 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -36,6 +36,7 @@

 #include 
 #include 
+#include 

 #define I40E_VLAN_TAG_SIZE4

@@ -171,6 +172,10 @@ enum i40e_flxpld_layer_idx {
 #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
 #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */

+/* Special FW support this floating VEB feature */
+#define FLOATING_FW_MAJ 5
+#define FLOATING_FW_MIN 0
+
 struct i40e_adapter;

 /**
@@ -450,6 +455,7 @@ struct i40e_pf {
struct i40e_fc_conf fc_conf; /* Flow control conf */
struct i40e_mirror_rule_list mirror_list;
uint16_t nb_mirror_rule;   /* The number of mirror rules */
+   uint16_t floating; /* The flag to use the floating VEB */
 };

 enum pending_msg {
-- 
2.1.4



[dpdk-dev] [PATCH v8 0/3] i40e: Add floating VEB support for i40e

2016-05-25 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W.

Zhe Tao (3):
  Support floating VEB config
  Add floating VEB support in i40e
  Add floating VEB extention support for i40e

 doc/guides/nics/i40e.rst   |  10 ++
 doc/guides/rel_notes/release_16_07.rst |   6 +
 drivers/net/i40e/i40e_ethdev.c | 205 +
 drivers/net/i40e/i40e_ethdev.h |   9 ++
 drivers/net/i40e/i40e_pf.c |  12 +-
 5 files changed, 219 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
V7: removed global reset and added floating VEB extension support 

-- 
2.1.4



[dpdk-dev] [PATCH v1] i40e: fix olflags for vector RX

2016-05-24 Thread Zhe Tao
Problem:
The flag for RSS and flow director is not set correctly in the
vector RX function, so the upper layer APP which base on the related
flags will not work correctly.

Fix this problem by change the shuffle table. the original shuffle
table is not correct.

Fixes: 9ed94 (i40e: add vector Rx)

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_rxtx_vec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx_vec.c b/drivers/net/i40e/i40e_rxtx_vec.c
index eef80d9..9f674bf 100644
--- a/drivers/net/i40e/i40e_rxtx_vec.c
+++ b/drivers/net/i40e/i40e_rxtx_vec.c
@@ -149,7 +149,7 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
*/
const __m128i rss_vlan_msk = _mm_set_epi16(
0x, 0x, 0x, 0x,
-   0x3004, 0x3004, 0x3004, 0x3004);
+   0x3804, 0x3804, 0x3804, 0x3804);

/* map rss and vlan type to rss hash and vlan flag */
const __m128i vlan_flags = _mm_set_epi8(0, 0, 0, 0,
@@ -159,8 +159,8 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)

const __m128i rss_flags = _mm_set_epi8(0, 0, 0, 0,
0, 0, 0, 0,
-   0, 0, 0, 0,
-   PKT_RX_FDIR, 0, PKT_RX_RSS_HASH, 0);
+   PKT_RX_RSS_HASH | PKT_RX_FDIR, PKT_RX_RSS_HASH, 0, 0,
+   0, 0, PKT_RX_FDIR, 0);

vlan0 = _mm_unpackhi_epi16(descs[0], descs[1]);
vlan1 = _mm_unpackhi_epi16(descs[2], descs[3]);
@@ -169,7 +169,7 @@ desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
vlan1 = _mm_and_si128(vlan0, rss_vlan_msk);
vlan0 = _mm_shuffle_epi8(vlan_flags, vlan1);

-   rss = _mm_srli_epi16(vlan1, 12);
+   rss = _mm_srli_epi16(vlan1, 11);
rss = _mm_shuffle_epi8(rss_flags, rss);

vlan0 = _mm_or_si128(vlan0, rss);
-- 
2.1.4



[dpdk-dev] [PATCH v1] igu_uio: fix IOMMU domain issue

2016-05-10 Thread Zhe Tao
Problem:
The following  operations will cause the igb_uio based DPDK
operation failed.
--Any device assignment through the kvm_assign_device interface,
this can be the pci-assign method in QEMU
--VFIO group attachment operation(attach to the container)
this can happens in  vfio-pci assignment in QEMU

Root cause:
For the two operation above finally will call the intel_iommu_attach_device
(e.g. for vfio/ vfio_group_set_container->
vfio_iommu_type1_attach_group->intel_iommu_attach_device)
If we use iommu=pt in the grub which means intel iommu driver will create a
static identity domain for all the PCI device,
Which will set the translation type into passthrough for all the context
entry for all the PCI devices,
But once we close QEMU process, e.g. the VFIO framework will invoke the
detach group operation and finally will call the intel_iommu_detach_device
which will clean the context entry.
(now the IOMMU entry for this device is not availablei)

For AMD iommu driver it handle this detach action right which will restore the
pt_domain (the same as static identity domain for intel) to the
corresponding entry.

Solution:
Add a work around in igb_uio driver which map one single page.
Because all the DMA related alloc and map
actions will cause the intel IOMMU driver to reload the SI domain to the context
entry, that's why the kernel driver never meets such problem.


Signed-off-by: Zhe Tao 
---
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c 
b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
index 45a5720..3fa88b0 100644
--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
@@ -327,6 +327,18 @@ igbuio_pci_probe(struct pci_dev *dev, const struct 
pci_device_id *id)
struct rte_uio_pci_dev *udev;
struct msix_entry msix_entry;
int err;
+   struct page *page;
+   /*
+* work around for Intel IOMMU implemation for SI doamin
+*/
+
+   page = alloc_page(GFP_ATOMIC);
+   if (!page) {
+   dev_err(>dev, "Cannot alloc page\n");
+   } else {
+   dma_map_page(>dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE);
+   __free_page(page);
+   }

udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL);
if (!udev)
-- 
2.1.4



[dpdk-dev] [PATCH] i40e: support user unaware VF reset

2016-05-06 Thread Zhe Tao
Problem:
Now the i40e VF PMD driver does not support reset event from PF.
Customer want the user unaware VF reset feature in VF PMD driver,
with this feature, the application doesn't need to concern about
the VF reset procedure and all the application can work correctly
when VF is doing the reset.

Solution:
The following step need to be done
--capture the VF reset event
--reconfigure the VF device
--restore all the configuration parameters.
With this patch, the first two steps can be meet,
part of the configuration parameters can be restored.
This patch mainly focus on the reconfiguration of the VF device when
receive the VF reset event from PF.

Known issues:
This feature cannot work on the primary secondary mixed scenario.

Signed-off-by: zhe.tao 
---
 doc/guides/rel_notes/release_16_07.rst |   5 ++
 drivers/net/i40e/i40e_ethdev.h |   7 ++
 drivers/net/i40e/i40e_ethdev_vf.c  | 148 -
 drivers/net/i40e/i40e_rxtx.c   |  10 +++
 drivers/net/i40e/i40e_rxtx.h   |   4 +
 5 files changed, 171 insertions(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 83c841b..6c7e051 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -34,6 +34,11 @@ This section should contain new features added in this 
release. Sample format:

   Refer to the previous release notes for examples.

+* **Added user unaware VF reset in i40e VF driver.**
+
+  A new feature has been added to allow i40e VF driver to handle the VF reset
+  event from PF, and all the operation for VF reset should not be noticed by 
the
+  application.

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..fa52996 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -540,6 +540,11 @@ struct i40e_adapter {
struct rte_timecounter systime_tc;
struct rte_timecounter rx_tstamp_tc;
struct rte_timecounter tx_tstamp_tc;
+
+   /* VF reset variable must put at the end of the structure */
+   rte_spinlock_t vf_reset_lock;
+   rte_spinlock_t reset_trigger_lock;
+   uint8_t reset_number;
 };

 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
@@ -593,6 +598,8 @@ void i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t 
queue_id,
 void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
struct rte_eth_txq_info *qinfo);

+void i40evf_emulate_vf_reset(uint8_t port_id);
+
 /* I40E_DEV_PRIVATE_TO */
 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
(&((struct i40e_adapter *)adapter)->pf)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 2bce69b..e71a34f 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -157,6 +157,11 @@ i40evf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, 
uint16_t queue_id);
 static void i40evf_handle_pf_event(__rte_unused struct rte_eth_dev *dev,
   uint8_t *msg,
   uint16_t msglen);
+static int i40evf_dev_uninit(struct rte_eth_dev *eth_dev);
+static int i40evf_dev_init(struct rte_eth_dev *eth_dev);
+static void i40evf_dev_close(struct rte_eth_dev *dev);
+static int i40evf_dev_start(struct rte_eth_dev *dev);
+static int i40evf_dev_configure(struct rte_eth_dev *dev);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
@@ -1306,18 +1311,155 @@ i40evf_uninit_vf(struct rte_eth_dev *dev)
 }

 static void
-i40evf_handle_pf_event(__rte_unused struct rte_eth_dev *dev,
-  uint8_t *msg,
-  __rte_unused uint16_t msglen)
+i40e_vf_queue_reset(struct rte_eth_dev *dev)
+{
+   uint16_t i;
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
+
+   if (rxq->q_set) {
+   i40e_dev_rx_queue_setup(dev,
+   rxq->queue_id,
+   rxq->nb_rx_desc,
+   rxq->socket_id,
+   >rxconf,
+   rxq->mp);
+   }
+   }
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   struct i40e_tx_queue *txq = dev->data->tx_queues[i];
+
+   if (txq->q_set) {
+   i40e_dev_tx_queue_setup(dev,
+   txq->queue_id,
+   txq->nb_tx_desc,
+   txq->socket_id,
+   >txconf);
+   }
+   }
+}
+
+static void
+i40e_vf_reset_dev(struct rte_eth_dev *dev)
+{
+   struct 

[dpdk-dev] [PATCH v2 0/3] improve i40e vpmd

2016-04-17 Thread Zhe Tao
On Thu, Apr 14, 2016 at 05:02:34PM +0100, Bruce Richardson wrote:
> This patchset improves the performance of the i40e SSE pmd by removing
> operations that triggered CPU stalls. It also shortens the code and
> cleans it up a little.
> 
> The base requirement for using the SSE code path has been pushed up to
> SSE4.1 from SSE3, due to the use of the blend instruction. The instruction
> set level is now checked at runtime as part of the driver selection process
> 
> Bruce Richardson (3):
>   i40e: require SSE4.1 support for vector driver
>   i40e: improve performance of vector PMD
>   i40e: simplify SSE packet length extraction code
> 
>  drivers/net/i40e/Makefile|  6 
>  drivers/net/i40e/i40e_rxtx_vec.c | 59 
> ++--
>  2 files changed, 27 insertions(+), 38 deletions(-)
> 
> -- 
> 2.5.5
Acked-by: Zhe Tao  


[dpdk-dev] [PATCH] vhost: fix mem share between VM and host

2016-04-11 Thread Zhe Tao
The reason cause this problem is that in QEMU, when assign the
memory-backend-file without share option, will cause QEMU mmap the mem file
without using the MAP_SHARED flag, so the page cache for that file will not
shared between other processes, all the upated to the mapping area in the VM
will not carry through to the vhost-user process.

According to kernel implementation, data for the new hugetlbfs file will be
all zero, so check the first RX virtqueue descriptor next field to see
whether the mem is shared or not, if the mem is shared, the next field should
not equal to zero, otherwise this mem is not shared between VM and host.

Signed-off-by: Zhe Tao 
---
 lib/librte_vhost/vhost-net.h  |  1 +
 lib/librte_vhost/vhost_user/virtio-net-user.c |  7 ---
 lib/librte_vhost/virtio-net.c | 29 ++-
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h
index f193a1f..588008f 100644
--- a/lib/librte_vhost/vhost-net.h
+++ b/lib/librte_vhost/vhost-net.h
@@ -105,6 +105,7 @@ int vhost_set_backend(struct vhost_device_ctx, struct 
vhost_vring_file *);

 int vhost_set_owner(struct vhost_device_ctx);
 int vhost_reset_owner(struct vhost_device_ctx);
+int vhost_check_mem_shared(struct vhost_device_ctx);

 /*
  * Backend-specific cleanup. Defined by vhost-cuse and vhost-user.
diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c 
b/lib/librte_vhost/vhost_user/virtio-net-user.c
index f5248bc..08dd2dd 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -286,9 +286,10 @@ user_set_vring_kick(struct vhost_device_ctx ctx, struct 
VhostUserMsg *pmsg)
"vring kick idx:%d file:%d\n", file.index, file.fd);
vhost_set_vring_kick(ctx, );

-   if (virtio_is_ready(dev) &&
-   !(dev->flags & VIRTIO_DEV_RUNNING))
-   notify_ops->new_device(dev);
+   if (!vhost_check_mem_shared(ctx) &&
+   virtio_is_ready(dev) &&
+   !(dev->flags & VIRTIO_DEV_RUNNING))
+   notify_ops->new_device(dev);
 }

 /*
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index 90da9ba..6b1a59d 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -712,7 +712,8 @@ vhost_set_backend(struct vhost_device_ctx ctx, struct 
vhost_vring_file *file)
 * If the device isn't already running and both backend fds are set,
 * we add the device.
 */
-   if (!(dev->flags & VIRTIO_DEV_RUNNING)) {
+   if (!vhost_check_mem_shared(ctx) &&
+   !(dev->flags & VIRTIO_DEV_RUNNING)) {
if (((int)dev->virtqueue[VIRTIO_TXQ]->backend != 
VIRTIO_DEV_STOPPED) &&
((int)dev->virtqueue[VIRTIO_RXQ]->backend != 
VIRTIO_DEV_STOPPED)) {
return notify_ops->new_device(dev);
@@ -724,6 +725,32 @@ vhost_set_backend(struct vhost_device_ctx ctx, struct 
vhost_vring_file *file)
return 0;
 }

+/* Check the share memory in case the QEMU doesn't set the share option
+ * as on for the memory-backend-file object in the QEMU command line.
+ */
+
+int
+vhost_check_mem_shared(struct vhost_device_ctx ctx)
+{
+   struct virtio_net *dev;
+   struct vhost_virtqueue *vq;
+   int ret = 0;
+
+   dev = get_device(ctx);
+   if ((dev == NULL) || (dev->mem == NULL))
+   return -1;
+
+   /* check first virtqueue 0 rxq. */
+   vq = dev->virtqueue[VIRTIO_RXQ];
+   ret = vq->desc[0].next == 0 ? -1 : 0;
+
+   if (ret)
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "The mem is not shared between VM and host\n");
+
+   return ret;
+}
+
 int rte_vhost_enable_guest_notification(struct virtio_net *dev,
uint16_t queue_id, int enable)
 {
-- 
2.1.4



[dpdk-dev] [PATCH v4] i40e: fix TSO issue for tx function

2016-04-06 Thread Zhe Tao
Issue:

when using the following CLI in testpmd to enable ipv6 TSO feature
(set --txqflags=0 in the testpmd command)
set verbose 1
csum set ip hw 0
csum set udp hw 0
csum set tcp hw 0
csum set sctp hw 0
csum set outer-ip hw 0
csum parse_tunnel on 0
tso set 800 0
set fwd csum
start

We will not get what we want, the ipv6 packets sent out from IXIA can be 
received by i40e, but cannot forward to another port.
The root cause is when HW doing the TSO offload for packets, it does not only
depends on the context descriptor to define the MSS and TSO payload size, it
also need to know whether this packets is ipv4 or ipv6, we use 
i40e_txd_enable_checksum to generate the related fields for data descriptor.
But PMD will not call i40e_txd_enable_checksum if only the TSO offload flag is
set. The reason why ipv4 works fine for TSO in testpmd csum mode is csum engine
will set the ip csum flag when the packet is ipv4 and TSO is enabled but 
will not set the flag for ipv6 and this flag will cause the
i40e_txd_enable_checksum to be invoked. For both the cases the TSO flag will be
set, so we need to use TSO flag to trigger the i40e_txd_enable_checksum.
The right logic here is we enable csum offload for both ipv4 and ipv6 when TSO
flag is set.

Fixes: e3f0151f (i40e: enable Tx checksum only for offloaded packets)

Signed-off-by: Zhe Tao 

---
v2: changed condition check for ipv6 TSO checksum offload
use a more clear check method which include both ipv4 & ipv6 TSO
v3: edited the commit log and title because this problem exists for both
ipv4 and ipv6
v4: moved the history under the commit log 
---
 drivers/net/i40e/i40e_rxtx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 59909f3..4d35d83 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -76,6 +76,7 @@
 #define I40E_TX_CKSUM_OFFLOAD_MASK (\
PKT_TX_IP_CKSUM |\
PKT_TX_L4_MASK | \
+   PKT_TX_TCP_SEG | \
PKT_TX_OUTER_IP_CKSUM)

 static uint16_t i40e_xmit_pkts_simple(void *tx_queue,
-- 
2.1.4



[dpdk-dev] [PATCH v3] i40e: fix TSO issue for tx function

2016-03-31 Thread Zhe Tao
Issue:

when using the following CLI in testpmd to enable ipv6 TSO feature
(set --txqflags=0 in the testpmd command)
set verbose 1
csum set ip hw 0
csum set udp hw 0
csum set tcp hw 0
csum set sctp hw 0
csum set outer-ip hw 0
csum parse_tunnel on 0
tso set 800 0
set fwd csum
start

We will not get what we want, the ipv6 packets sent out from IXIA can be 
received by i40e, but cannot forward to another port.
The root cause is when HW doing the TSO offload for packets, it does not only
depends on the context descriptor to define the MSS and TSO payload size, it
also need to know whether this packets is ipv4 or ipv6, we use 
i40e_txd_enable_checksum to generate the related fields for data descriptor.
But PMD will not call i40e_txd_enable_checksum if only the TSO offload flag is
set. The reason why ipv4 works fine for TSO in testpmd csum mode is csum engine
will set the ip csum flag when the packet is ipv4 and TSO is enabled but 
will not set the flag for ipv6 and this flag will cause the
i40e_txd_enable_checksum to be invoked. For both the cases the TSO flag will be
set, so we need to use TSO flag to trigger the i40e_txd_enable_checksum.
The right logic here is we enable csum offload for both ipv4 and ipv6 when TSO
flag is set.

Fixes: e3f0151f (i40e: enable Tx checksum only for offloaded packets)
---
 drivers/net/i40e/i40e_rxtx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 81cde6c..6e3fd25 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -76,6 +76,7 @@
 #define I40E_TX_CKSUM_OFFLOAD_MASK (\
PKT_TX_IP_CKSUM |\
PKT_TX_L4_MASK | \
+   PKT_TX_TCP_SEG | \
PKT_TX_OUTER_IP_CKSUM)

 static uint16_t i40e_xmit_pkts_simple(void *tx_queue,
-- 
v2: changed condition check for ipv6 TSO checksum offload
use a more clear check method which include both ipv4 & ipv6 TSO
v3: edited the commit log and title because this problem exists for both
ipv4 and ipv6
2.1.4



[dpdk-dev] [PATCH v2] i40e: fix ipv6 TSO issue for tx function

2016-03-31 Thread Zhe Tao
On Thu, Mar 24, 2016 at 03:00:14PM +, Bruce Richardson wrote:
> On Wed, Mar 23, 2016 at 11:27:50AM +0800, Zhe Tao wrote:
> > Issue:
> > when using the following CLI in testpmd to enable ipv6 TSO feature
> > =
> > set verbose 1
> > csum set ip hw 0
> > csum set udp hw 0
> > csum set tcp hw 0
> > csum set sctp hw 0
> > csum set outer-ip hw 0
> > csum parse_tunnel on 0
> > tso set 800 0
> > set fwd csum
> > 
> > start
> > =
> 
> The "===" lines in the message are confusing patchwork. For a new version of
> this patch can you indent the commands rather than putting the "===" above 
> and 
> below. E.g.
> 
>  Issue:
>  when using the following CLI in testpmd to enable ipv6 TSO feature
> 
>   set verbose 1
>   csum set ip hw 0
>   csum set udp hw 0
>   
> 
> Thanks,
> /Bruce
very good advise, will send the new patch, thanks!
Zhe Tao


[dpdk-dev] [PATCH 3/3 v7] i40e: Add global reset support for i40e

2016-03-25 Thread Zhe Tao
Add global reset support in i40e.
Sometimes the PF reset will fail, and the PF software reset cannot ensure
all the status and components are reset. So added the global reset to fix
this issue.
The essential difference for the new global reset and PF reset is that the
PF Reset doesn't clear the packet buffers, doesn't reset the PE
firmware, and doesn't bother the other PFs on the chip.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 35 ++-
 drivers/net/i40e/i40e_ethdev.h | 30 ++
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 87801d3..8336321 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -437,6 +437,8 @@ static int i40e_get_eeprom(struct rte_eth_dev *dev,
 static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
  struct ether_addr *mac_addr);

+static void i40e_do_reset(struct i40e_hw *hw, u32 reset_flags);
+
 static const struct rte_pci_id pci_id_i40e_map[] = {
 #define RTE_PCI_DEV_ID_DECL_I40E(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
 #include "rte_pci_dev_ids.h"
@@ -836,7 +838,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
ret = i40e_pf_reset(hw);
if (ret) {
PMD_INIT_LOG(ERR, "Failed to reset pf: %d", ret);
-   return ret;
+   i40e_do_reset(hw, BIT(__I40E_GLOBAL_RESET_REQUESTED));
}

/* Initialize the shared code (base driver) */
@@ -9117,3 +9119,34 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev 
*dev,
/* Flags: 0x3 updates port address */
i40e_aq_mac_address_write(hw, 0x3, mac_addr->addr_bytes, NULL);
 }
+
+/**
+ * i40e_do_reset - Start a PF or Core Reset sequence
+ * @pf: board private structure
+ * @reset_flags: which reset is requested
+ *
+ * The essential difference in resets is that the PF Reset
+ * doesn't clear the packet buffers, doesn't reset the PE
+ * firmware, and doesn't bother the other PFs on the chip.
+ **/
+static void i40e_do_reset(struct i40e_hw *hw, u32 reset_flags)
+{
+   u32 val;
+
+   /* do the biggest reset indicated */
+   if (reset_flags & BIT_ULL(__I40E_GLOBAL_RESET_REQUESTED)) {
+   /* Request a Global Reset
+*
+* This will start the chip's countdown to the actual full
+* chip reset event, and a warning interrupt to be sent
+* to all PFs, including the requestor.  Our handler
+* for the warning interrupt will deal with the shutdown
+* and recovery of the switch setup.
+*/
+   PMD_INIT_LOG(NOTICE, "GlobalR requested\n");
+   val = rd32(hw, I40E_GLGEN_RTRIG);
+   val |= I40E_GLGEN_RTRIG_GLOBR_MASK;
+   wr32(hw, I40E_GLGEN_RTRIG, val);
+   }
+   /* other reset operations are not supported now */
+}
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 09fb6e2..f2a2fcc 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -108,6 +108,36 @@ enum i40e_flxpld_layer_idx {
I40E_FLXPLD_L4_IDX= 2,
I40E_MAX_FLXPLD_LAYER = 3,
 };
+
+/* driver state flags */
+enum i40e_state_t {
+   __I40E_TESTING,
+   __I40E_CONFIG_BUSY,
+   __I40E_CONFIG_DONE,
+   __I40E_DOWN,
+   __I40E_NEEDS_RESTART,
+   __I40E_SERVICE_SCHED,
+   __I40E_ADMINQ_EVENT_PENDING,
+   __I40E_MDD_EVENT_PENDING,
+   __I40E_VFLR_EVENT_PENDING,
+   __I40E_RESET_RECOVERY_PENDING,
+   __I40E_RESET_INTR_RECEIVED,
+   __I40E_REINIT_REQUESTED,
+   __I40E_PF_RESET_REQUESTED,
+   __I40E_CORE_RESET_REQUESTED,
+   __I40E_GLOBAL_RESET_REQUESTED,
+   __I40E_EMP_RESET_REQUESTED,
+   __I40E_EMP_RESET_INTR_RECEIVED,
+   __I40E_FILTER_OVERFLOW_PROMISC,
+   __I40E_SUSPENDED,
+   __I40E_BAD_EEPROM,
+   __I40E_DEBUG_MODE,
+   __I40E_DOWN_REQUESTED,
+   __I40E_FD_FLUSH_REQUESTED,
+   __I40E_RESET_FAILED,
+   __I40E_PORT_TX_SUSPENDED,
+   __I40E_VF_DISABLE,
+};
 #define I40E_MAX_FLXPLD_FIED3  /* max number of flex payload fields */
 #define I40E_FDIR_BITMASK_NUM_WORD  2  /* max number of bitmask words */
 #define I40E_FDIR_MAX_FLEXWORD_NUM  8  /* max number of flexpayload words */
-- 
2.1.4



[dpdk-dev] [PATCH 2/3 v7] i40e: Add floating VEB support in i40e

2016-03-25 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

Now the floating VEB feature is only avaiable in the specific version of FW.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |   7 +++
 doc/guides/rel_notes/release_16_04.rst |   2 +
 drivers/net/i40e/i40e_ethdev.c | 110 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 109 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 4019b41..520ea09 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,10 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floating=1", and the application will make sure the PMD
+will use the floating VEB feature for all the VFs created by this PF device.
+
diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 9922bcb..1545872 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -248,6 +248,8 @@ This section should contain new features added in this 
release. Sample format:

   New application implementing an IPsec Security Gateway.

+* **Added floating VEB support for FVL.**
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 01f1d3d..87801d3 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3734,21 +3734,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3760,9 +3766,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3774,11 +3780,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
+ I40E_DEFAULT_TCMAP, false,
+ >seid, false, NULL);
+   } else {
+   ret = i40e_aq_add_veb(hw, 0, 0, I40E_DEFAULT_TCMAP,
+ true, >seid, false, NULL);
+   }

if (ret != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Add veb failed, aq_err: %d",
@@ -3794,10 +3808,10 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
hw->aq.asq_last_status);
goto fail;
}
-
/* Get VEB bandwidth, to be implemented */
/* Now associated vsi binding to the VEB, set upl

[dpdk-dev] [PATCH 1/3 v7] i40e: support floating VEB config

2016-03-25 Thread Zhe Tao
Add the new floating related argument option in the devarg.
Using this parameter, all the samples can decide whether to use legacy VEB/VEPA
or floating VEB.
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floating=1", and the application will make sure the PMD
will use the floating VEB feature for all the VFs created by this PF device.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 44 ++
 drivers/net/i40e/i40e_ethdev.h |  6 ++
 2 files changed, 50 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 6fdae57..01f1d3d 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -739,6 +739,44 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_floating_handler(__rte_unused const char *key,
+  const char *value,
+  __rte_unused void *opaque)
+{
+   if (strcmp(value, "1"))
+   return -1;
+
+   return 0;
+}
+
+static int
+i40e_check_floating(struct rte_devargs *devargs)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_key = "enable_floating";
+
+   if (devargs == NULL)
+   return 0;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return 0;
+
+   if (!rte_kvargs_count(kvlist, floating_key)) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   /* Floating is enabled when there's key-value pair: enable_floating=1 */
+   if (rte_kvargs_process(kvlist, floating_key,
+  i40e_check_floating_handler, NULL) < 0) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   rte_kvargs_free(kvlist);
+
+   return 1;
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -829,6 +867,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

+   /* Need the special FW version support floating VEB */
+   if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
+   pf->floating = i40e_check_floating(pci_dev->devargs);
+   } else {
+   pf->floating = false;
+   }
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 1c75672..7dc6936 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -36,6 +36,7 @@

 #include 
 #include 
+#include 

 #define I40E_VLAN_TAG_SIZE4

@@ -171,6 +172,10 @@ enum i40e_flxpld_layer_idx {
 #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
 #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */

+/* Special FW support this floating VEB feature */
+#define FLOATING_FW_MAJ 5
+#define FLOATING_FW_MIN 0
+
 struct i40e_adapter;

 /**
@@ -446,6 +451,7 @@ struct i40e_pf {
struct i40e_fc_conf fc_conf; /* Flow control conf */
struct i40e_mirror_rule_list mirror_list;
uint16_t nb_mirror_rule;   /* The number of mirror rules */
+   uint16_t floating; /* The flag to use the floating VEB */
 };

 enum pending_msg {
-- 
2.1.4



[dpdk-dev] [PATCH 0/3 v7] i40e: Add floating VEB support for i40e

2016-03-25 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W.

Zhe Tao (2):
  Support floating VEB config
  Add floating VEB support in i40e
  Add global reset support for i40e

 doc/guides/nics/i40e.rst   |   7 ++
 doc/guides/rel_notes/release_16_04.rst |   2 +
 drivers/net/i40e/i40e_ethdev.c | 189 +
 drivers/net/i40e/i40e_ethdev.h |  38 +++
 drivers/net/i40e/i40e_pf.c |  11 +-
 5 files changed, 223 insertions(+), 24 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 
V7: Added global reset for i40e 
-- 
2.1.4



[dpdk-dev] [PATCH 2/2 v6] i40e: Add floating VEB support in i40e

2016-03-24 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

Now the floating VEB feature is only avaiable in the specific version of FW.

Signed-off-by: Zhe Tao 
---
 doc/guides/nics/i40e.rst   |   7 +++
 doc/guides/rel_notes/release_16_04.rst |   2 +
 drivers/net/i40e/i40e_ethdev.c | 110 ++---
 drivers/net/i40e/i40e_ethdev.h |   2 +
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 109 insertions(+), 23 deletions(-)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 4019b41..520ea09 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -366,3 +366,10 @@ Delete all flow director rules on a port:

testpmd> flush_flow_director 0

+Floating VEB
+~
+FVL can support floating VEB feature.
+To enable this feature, the user should pass a devargs parameter to the EAL
+like "-w 84:00.0,enable_floating=1", and the application will make sure the PMD
+will use the floating VEB feature for all the VFs created by this PF device.
+
diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 9922bcb..1545872 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -248,6 +248,8 @@ This section should contain new features added in this 
release. Sample format:

   New application implementing an IPsec Security Gateway.

+* **Added floating VEB support for FVL.**
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 01f1d3d..87801d3 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3734,21 +3734,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3760,9 +3766,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3774,11 +3780,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
+ I40E_DEFAULT_TCMAP, false,
+ >seid, false, NULL);
+   } else {
+   ret = i40e_aq_add_veb(hw, 0, 0, I40E_DEFAULT_TCMAP,
+ true, >seid, false, NULL);
+   }

if (ret != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Add veb failed, aq_err: %d",
@@ -3794,10 +3808,10 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
hw->aq.asq_last_status);
goto fail;
}
-
/* Get VEB bandwidth, to be implemented */
/* Now associated vsi binding to the VEB, set upl

[dpdk-dev] [PATCH 1/2 v6] i40e: support floating VEB config

2016-03-24 Thread Zhe Tao
Add the new floating related argument option in the devarg.
Using this parameter, all the samples can decide whether to use legacy VEB/VEPA
or floating VEB.
To enable this feature, the user should pass a devargs parameter to the EAL
like "-w 84:00.0,enable_floating=1", and the application will make sure the PMD
will use the floating VEB feature for all the VFs created by this PF device.

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_ethdev.c | 44 ++
 drivers/net/i40e/i40e_ethdev.h |  6 ++
 2 files changed, 50 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 6fdae57..01f1d3d 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -739,6 +739,44 @@ i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
  " frames from VSIs.");
 }

+static int i40e_check_floating_handler(__rte_unused const char *key,
+  const char *value,
+  __rte_unused void *opaque)
+{
+   if (strcmp(value, "1"))
+   return -1;
+
+   return 0;
+}
+
+static int
+i40e_check_floating(struct rte_devargs *devargs)
+{
+   struct rte_kvargs *kvlist;
+   const char *floating_key = "enable_floating";
+
+   if (devargs == NULL)
+   return 0;
+
+   kvlist = rte_kvargs_parse(devargs->args, NULL);
+   if (kvlist == NULL)
+   return 0;
+
+   if (!rte_kvargs_count(kvlist, floating_key)) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   /* Floating is enabled when there's key-value pair: enable_floating=1 */
+   if (rte_kvargs_process(kvlist, floating_key,
+  i40e_check_floating_handler, NULL) < 0) {
+   rte_kvargs_free(kvlist);
+   return 0;
+   }
+   rte_kvargs_free(kvlist);
+
+   return 1;
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -829,6 +867,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

+   /* Need the special FW version support floating VEB */
+   if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
+   pf->floating = i40e_check_floating(pci_dev->devargs);
+   } else {
+   pf->floating = false;
+   }
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 1c75672..7dc6936 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -36,6 +36,7 @@

 #include 
 #include 
+#include 

 #define I40E_VLAN_TAG_SIZE4

@@ -171,6 +172,10 @@ enum i40e_flxpld_layer_idx {
 #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
 #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */

+/* Special FW support this floating VEB feature */
+#define FLOATING_FW_MAJ 5
+#define FLOATING_FW_MIN 0
+
 struct i40e_adapter;

 /**
@@ -446,6 +451,7 @@ struct i40e_pf {
struct i40e_fc_conf fc_conf; /* Flow control conf */
struct i40e_mirror_rule_list mirror_list;
uint16_t nb_mirror_rule;   /* The number of mirror rules */
+   uint16_t floating; /* The flag to use the floating VEB */
 };

 enum pending_msg {
-- 
2.1.4



[dpdk-dev] [PATCH 0/2 v6] i40e: Add floating VEB support for i40e

2016-03-24 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W.

Zhe Tao (2):
  support floating VEB config
  Add floating VEB support in i40e

 doc/guides/nics/i40e.rst   |   7 ++
 doc/guides/rel_notes/release_16_04.rst |   2 +
 drivers/net/i40e/i40e_ethdev.c | 154 -
 drivers/net/i40e/i40e_ethdev.h |   8 ++
 drivers/net/i40e/i40e_pf.c |  11 ++-
 5 files changed, 159 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
V6: Changed the floating VEB configuration method 

-- 
2.1.4



[dpdk-dev] [PATCH 1/2 v5] i40e: support floating VEB config

2016-03-24 Thread Zhe Tao
On Wed, Mar 23, 2016 at 01:51:09PM +0100, Thomas Monjalon wrote:
> 2016-03-23 20:27, Zhe Tao:
> > Add the new floating related argument option in the EAL.
> > Using this parameter, all the samples can decide whether to use legacy 
> > VEB/VEPA
> > or floating VEB.
> > Even the floating argument is provided in the EAL, but this floating
> > feature are only support for FVL so far.
> > 
> > Signed-off-by: Zhe Tao 
> > ---
> >  doc/guides/testpmd_app_ug/run_app.rst  | 4 
> >  lib/librte_eal/common/eal_common_options.c | 4 
> >  lib/librte_eal/common/eal_internal_cfg.h   | 1 +
> >  lib/librte_eal/common/eal_options.h| 2 ++
> >  4 files changed, 11 insertions(+)
> 
> The label of this patch is "i40e" but it doesn't touch i40e.
> Actually it is an EAL change but there should not be related to EAL.
> It seems to be a config option of the device.
> Please check how ftag has been enabled in fm10k:
>   dpdk.org/browse/dpdk/commit/?id=7958b1310d5e
very good suggestion, thanks for the advice


[dpdk-dev] [PATCH 2/2 v5] i40e: Add floating VEB support in i40e

2016-03-23 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

Now the floating VEB feature is only avaiable in the specific version of FW.

Signed-off-by: Zhe Tao 
---
 doc/guides/rel_notes/release_16_04.rst |   2 +
 drivers/net/i40e/Makefile  |   2 +-
 drivers/net/i40e/i40e_ethdev.c | 116 +++--
 drivers/net/i40e/i40e_ethdev.h |   8 +++
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 115 insertions(+), 24 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 9922bcb..1545872 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -248,6 +248,8 @@ This section should contain new features added in this 
release. Sample format:

   New application implementing an IPsec Security Gateway.

+* **Added floating VEB support for FVL.**
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 6dd6eaa..8f7146f 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -39,7 +39,7 @@ LIB = librte_pmd_i40e.a
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS) -DPF_DRIVER -DVF_DRIVER -DINTEGRATED_VF
 CFLAGS += -DX722_SUPPORT -DX722_A0_SUPPORT
-
+CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common
 EXPORT_MAP := rte_pmd_i40e_version.map

 LIBABIVER := 1
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 6fdae57..00f2da8 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -829,6 +829,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

+   /* Need the special FW version support floating VEB */
+   if (hw->aq.fw_maj_ver >= FLOATING_FW_MAJ) {
+   pf->floating = internal_config.floating;
+   } else {
+   pf->floating = false;
+   }
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

@@ -3690,21 +3696,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3716,9 +3728,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3730,11 +3742,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
+ I40E_DEFAULT_TCMAP, false,
+ >seid, false, NULL);
+   } else {
+   ret = i40e_aq_add_veb(hw, 0, 0, I40E_DEFAULT_TCMAP,
+ true, >seid, false, NULL);
+   }

i

[dpdk-dev] [PATCH 1/2 v5] i40e: support floating VEB config

2016-03-23 Thread Zhe Tao
Add the new floating related argument option in the EAL.
Using this parameter, all the samples can decide whether to use legacy VEB/VEPA
or floating VEB.
Even the floating argument is provided in the EAL, but this floating
feature are only support for FVL so far.

Signed-off-by: Zhe Tao 
---
 doc/guides/testpmd_app_ug/run_app.rst  | 4 
 lib/librte_eal/common/eal_common_options.c | 4 
 lib/librte_eal/common/eal_internal_cfg.h   | 1 +
 lib/librte_eal/common/eal_options.h| 2 ++
 4 files changed, 11 insertions(+)

diff --git a/doc/guides/testpmd_app_ug/run_app.rst 
b/doc/guides/testpmd_app_ug/run_app.rst
index f605564..2f02f63 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -156,6 +156,10 @@ See the DPDK Getting Started Guides for more information 
on these options.

 Use malloc instead of hugetlbfs.

+*   ``--floating``
+
+Enable floating feature for virtual ethernet switch in the NIC.
+Now only Intel i40e NIC supports this feature.

 Testpmd Command-line Options
 
diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 29942ea..29ed7bf 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -95,6 +95,7 @@ eal_long_options[] = {
{OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
{OPT_VMWARE_TSC_MAP,0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
{OPT_XEN_DOM0,  0, NULL, OPT_XEN_DOM0_NUM },
+   {OPT_FLOATING,  0, NULL, OPT_FLOATING_NUM },
{0, 0, NULL, 0}
 };

@@ -896,6 +897,9 @@ eal_parse_common_option(int opt, const char *optarg,
return -1;
}
break;
+   case OPT_FLOATING_NUM:
+   conf->floating = 1;
+   break;

/* don't know what to do, leave this to caller */
default:
diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
b/lib/librte_eal/common/eal_internal_cfg.h
index 5f1367e..19b321a 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -68,6 +68,7 @@ struct internal_config {
volatile unsigned xen_dom0_support; /**< support app running on Xen 
Dom0*/
volatile unsigned no_pci; /**< true to disable PCI */
volatile unsigned no_hpet;/**< true to disable HPET */
+   volatile unsigned floating;   /**< true to enable floating VEB */
volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping

* instead of native TSC */
volatile unsigned no_shconf;  /**< true if there is no shared 
config */
diff --git a/lib/librte_eal/common/eal_options.h 
b/lib/librte_eal/common/eal_options.h
index a881c62..413c9e6 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -83,6 +83,8 @@ enum {
OPT_VMWARE_TSC_MAP_NUM,
 #define OPT_XEN_DOM0  "xen-dom0"
OPT_XEN_DOM0_NUM,
+#define OPT_FLOATING  "floating"
+   OPT_FLOATING_NUM,
OPT_LONG_MAX_NUM
 };

-- 
2.1.4



[dpdk-dev] [PATCH 0/2 v5] i40e: Add floating VEB support for i40e

2016-03-23 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W.

Zhe Tao (2):
  support floating VEB config
  Add floating VEB support in i40e

 doc/guides/rel_notes/release_16_04.rst |   2 +
 doc/guides/testpmd_app_ug/run_app.rst  |   4 +
 drivers/net/i40e/Makefile  |   2 +-
 drivers/net/i40e/i40e_ethdev.c | 116 +++--
 drivers/net/i40e/i40e_ethdev.h |   8 ++
 drivers/net/i40e/i40e_pf.c |  11 ++-
 lib/librte_eal/common/eal_common_options.c |   4 +
 lib/librte_eal/common/eal_internal_cfg.h   |   1 +
 lib/librte_eal/common/eal_options.h|   2 +
 9 files changed, 126 insertions(+), 24 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Added the FW version check otherwise it will cause the segment fault.
V5: Edited the code for new share code APIs
-- 
2.1.4



[dpdk-dev] [PATCH v2] i40e: fix ipv6 TSO issue for tx function

2016-03-23 Thread Zhe Tao
Issue:
when using the following CLI in testpmd to enable ipv6 TSO feature
=
set verbose 1
csum set ip hw 0
csum set udp hw 0
csum set tcp hw 0
csum set sctp hw 0
csum set outer-ip hw 0
csum parse_tunnel on 0
tso set 800 0
set fwd csum

start
=

We will not get we want, the ipv6 packets sent out from IXIA can be received by
i40e, but cannot forward to another port.
The root cause is when HW doing the TSO offload for packets, it not only depends
on the context descriptor to define the MSS and TSO payload size, it also
need to know whether this packets is ipv4 or ipv6, ipv4 need the header csum,
but ipv6 doesn't need the csum. We need to use the i40e_txd_enable_checksum to
set the ipv6 type flag into the data descriptor when the packets are for
ipv6 TSO.  

Fixes: e3f0151f (i40e: enable Tx checksum only for offloaded packets)

Signed-off-by: Zhe Tao 
---
v2: change condition check for ipv6 TSO checksum offload
use a more clear check method which include both ipv4 & ipv6 TSO


 drivers/net/i40e/i40e_rxtx.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 1488f2f..3422ec2 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -73,9 +73,16 @@

 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)

+/* need to add the TSO flag to the checksum offload mask
+ * even the packets like ipv6 doesn't need the checksum for ip header
+ * but the FW need to know whether this TCP packets is ipv4 or ipv6,
+ * so add this kind of information in the checksum offload field in the
+ * normal data descriptor.
+ */
 #define I40E_TX_CKSUM_OFFLOAD_MASK (\
PKT_TX_IP_CKSUM |\
PKT_TX_L4_MASK | \
+   PKT_TX_TCP_SEG | \
PKT_TX_OUTER_IP_CKSUM)

 static uint16_t i40e_xmit_pkts_simple(void *tx_queue,
-- 
2.1.4



[dpdk-dev] [PATCH] i40e: fix ipv6 TSO issue for tx function

2016-03-23 Thread Zhe Tao
On Tue, Mar 22, 2016 at 09:38:55PM +0800, Ananyev, Konstantin wrote:
> Hi, 
> 
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Zhe Tao
> > Sent: Tuesday, March 22, 2016 1:14 PM
> > To: dev at dpdk.org
> > Cc: Tao, Zhe
> > Subject: [dpdk-dev] [PATCH] i40e: fix ipv6 TSO issue for tx function
> > 
> > Issue:
> > when using the following CLI in testpmd to enable ipv6 TSO feature
> > =
> > set verbose 1
> > csum set ip hw 0
> > csum set udp hw 0
> > csum set tcp hw 0
> > csum set sctp hw 0
> > csum set outer-ip hw 0
> > csum parse_tunnel on 0
> > tso set 800 0
> > set fwd csum
> > 
> > start
> > =
> > 
> > We will not get we want, the ipv6 packets sent out from IXIA can be 
> > received by
> > i40e, but cannot forward to another port.
> > The root cause is when HW doing the TSO offload for packets, it not only 
> > depends
> > on the context descriptor to define the MSS and TSO payload size, it also
> > need to know whether this packets is ipv4 or ipv6, ipv4 need the header 
> > csum,
> > but ipv6 doesn't need the csum. We need to use the i40e_txd_enable_checksum 
> > to
> > set the ipv6 type flag into the data descriptor when the packets are for
> > ipv6 TSO.
> > 
> > Fixes: e3f0151f (i40e: enable Tx checksum only for offloaded packets)
> > 
> > Signed-off-by: Zhe Tao 
> > ---
> >  drivers/net/i40e/i40e_rxtx.c | 9 -
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
> > index 1488f2f..ffd6dba 100644
> > --- a/drivers/net/i40e/i40e_rxtx.c
> > +++ b/drivers/net/i40e/i40e_rxtx.c
> > @@ -1545,6 +1545,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
> > **tx_pkts, uint16_t nb_pkts)
> > uint16_t slen;
> > uint64_t buf_dma_addr;
> > union i40e_tx_offload tx_offload = {0};
> > +   bool enable_checksum = 0;
> > 
> > txq = tx_queue;
> > sw_ring = txq->sw_ring;
> > @@ -1620,7 +1621,13 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
> > **tx_pkts, uint16_t nb_pkts)
> > 
> > /* Enable checksum offloading */
> > cd_tunneling_params = 0;
> > -   if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) {
> > +   /* Check whether need to do checksum or not */
> > +   if ((ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) ||
> > +   ((ol_flags & PKT_TX_IPV6) && (ol_flags & PKT_TX_TCP_SEG))) {
> > +   enable_checksum = 1;
> > +   }
> > +
> > +   if (enable_checksum) {
> > i40e_txd_enable_checksum(ol_flags, _cmd, _offset,
> > tx_offload, _tunneling_params);
> > }
> 
> 
> Wonder can't we just include PKT_TX_TCP_SEG into I40E_TX_CKSUM_OFFLOAD_MASK,
> and keep i40e_xmit_pkts() unchanged?
> Konstantin
agreed with you, checked the code again, the logic for ipv4 TSO also has some 
problem,
so should add PKT_TX_TCP_SEG flag for both ipv4 TSO to the offload mask.

> 


[dpdk-dev] [PATCH] i40e: fix ipv6 TSO issue for tx function

2016-03-22 Thread Zhe Tao
Issue:
when using the following CLI in testpmd to enable ipv6 TSO feature
=
set verbose 1
csum set ip hw 0
csum set udp hw 0
csum set tcp hw 0
csum set sctp hw 0
csum set outer-ip hw 0
csum parse_tunnel on 0
tso set 800 0
set fwd csum

start
=

We will not get we want, the ipv6 packets sent out from IXIA can be received by
i40e, but cannot forward to another port.
The root cause is when HW doing the TSO offload for packets, it not only depends
on the context descriptor to define the MSS and TSO payload size, it also
need to know whether this packets is ipv4 or ipv6, ipv4 need the header csum,
but ipv6 doesn't need the csum. We need to use the i40e_txd_enable_checksum to
set the ipv6 type flag into the data descriptor when the packets are for
ipv6 TSO.  

Fixes: e3f0151f (i40e: enable Tx checksum only for offloaded packets)

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_rxtx.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 1488f2f..ffd6dba 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -1545,6 +1545,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
uint16_t slen;
uint64_t buf_dma_addr;
union i40e_tx_offload tx_offload = {0};
+   bool enable_checksum = 0;

txq = tx_queue;
sw_ring = txq->sw_ring;
@@ -1620,7 +1621,13 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)

/* Enable checksum offloading */
cd_tunneling_params = 0;
-   if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) {
+   /* Check whether need to do checksum or not */
+   if ((ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) ||
+   ((ol_flags & PKT_TX_IPV6) && (ol_flags & PKT_TX_TCP_SEG))) {
+   enable_checksum = 1;
+   }
+
+   if (enable_checksum) {
i40e_txd_enable_checksum(ol_flags, _cmd, _offset,
tx_offload, _tunneling_params);
}
-- 
2.1.4



[dpdk-dev] [PATCH v2] i40e: fix build issue for RX set function

2016-03-16 Thread Zhe Tao
Issue:
When define CONFIG_RTE_LIBTRE_I40E_RX_ALLOW_BULK_ALLOC as n in config file,
there will be a build error:
'i40e_recv_pkts_bulk_alloc' undeclared 

Now DPDK i40e PMD use the Macro variable to choose whether to define the
related bulk recv functions, but for selection of the RX function,PMD only
depends on a C variable, which will cause the inconsistency and lead to the
build error which will tell us the bulk recv function is not defined.

Fixes: 8e109464 (i40e: allow vector Rx and Tx usage)

Signed-off-by: Zhe Tao 
---

V2: fix some characters issues in commit log

 drivers/net/i40e/i40e_rxtx.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 8931b8e..1488f2f 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -1175,6 +1175,14 @@ i40e_recv_pkts_bulk_alloc(void *rx_queue,

return nb_rx;
 }
+#else
+static uint16_t
+i40e_recv_pkts_bulk_alloc(void __rte_unused *rx_queue,
+ struct rte_mbuf __rte_unused **rx_pkts,
+ uint16_t __rte_unused nb_pkts)
+{
+   return 0;
+}
 #endif /* RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC */

 uint16_t
-- 
2.1.4



[dpdk-dev] [PATCH] i40e: fix build issue for RX set function

2016-03-16 Thread Zhe Tao
Issue:
When define CONFIG_RTE_LIBTRE_I40E_RX_ALLOW_BULK_ALLOC as n in config file,
there will be a build error:
?40e_recv_pkts_bulk_alloc' undeclared 

Now DPDK i40e PMD use the Macro variable to choose whether to define the
related bulk recv functions, but for selection of the RX function,PMD only
depends on a C variable, which will cause the inconsistency and lead to the
build error which will tell us the bulk recv function is not defined.

Fixes: 8e109464 (i40e: allow vector Rx and Tx usage)

Signed-off-by: Zhe Tao 
---
 drivers/net/i40e/i40e_rxtx.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 8931b8e..1488f2f 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -1175,6 +1175,14 @@ i40e_recv_pkts_bulk_alloc(void *rx_queue,

return nb_rx;
 }
+#else
+static uint16_t
+i40e_recv_pkts_bulk_alloc(void __rte_unused *rx_queue,
+ struct rte_mbuf __rte_unused **rx_pkts,
+ uint16_t __rte_unused nb_pkts)
+{
+   return 0;
+}
 #endif /* RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC */

 uint16_t
-- 
2.1.4



[dpdk-dev] [PATCH v3] ixgbe: fix ixgbevf RX/TX function assignment

2016-03-14 Thread Zhe Tao
For the secondary process of DPDK to initialize ixgbevf, it will always
use the simple RX function or LRO RX function, and this behavior is not
the same RX/TX function selection logic as it is for the primary process,
so use the ixgbe_set_tx_function and ixgbe_set_rx_function to select the
RX/TX function when secondary process call the init function for eth dev.  

Fixes: 46bc9d75 (ixgbe: fix multi-process support)

Signed-off-by: Zhe Tao 
---
V2:added fixes line
V3:changed fixes line

 drivers/net/ixgbe/ixgbe_ethdev.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 3e6fe86..0f9d048 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1278,8 +1278,21 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
 * has already done this work. Only check we don't need a different
 * RX function */
if (rte_eal_process_type() != RTE_PROC_PRIMARY){
-   if (eth_dev->data->scattered_rx)
-   eth_dev->rx_pkt_burst = 
ixgbe_recv_pkts_lro_single_alloc;
+   struct ixgbe_tx_queue *txq;
+   /* TX queue function in primary, set by last queue initialized
+* Tx queue may not initialized by primary process
+*/
+   if (eth_dev->data->tx_queues) {
+   txq = 
eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
+   ixgbe_set_tx_function(eth_dev, txq);
+   } else {
+   /* Use default TX function if we get here */
+   PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
+"Using default TX function.");
+   }
+
+   ixgbe_set_rx_function(eth_dev);
+
return 0;
}

-- 
2.1.4



[dpdk-dev] [PATCH v3] i40e: add VEB switching support for i40e

2016-03-09 Thread Zhe Tao
VEB switching feature for i40e is used to enable the switching between the
VSIs connect to the virtual bridge. The old implementation is setting the
virtual bridge mode as VEPA which is port aggregation. Enable the switching 
ability by setting the loop back mode for the specific VSIs which connect to PF
or VFs. 

VEB/VSI/VEPA are concepts not specific to the i40e HW, the concepts are from
802.1qbg spec
IEEE EVB tutorial:
http://www.ieee802.org/802_tutorials/2009-11/evb-tutorial-draft-20091116_v09.pdf

VEB: a virtual switch can forward the packet based on the specific match field.
VSI: a virtual interface connect between the VEB/VEPA and virtual machine.
VEPA: a virtual Ethernet port aggregator will upstream the packets from VSI to
the LAN port. 

Signed-off-by: Zhe Tao 
---
v1: Add the VEB switching support.
v2: Add the check for the FW version, which should larger than 5.0.
Add release note.
v3: Add the VEB concepts description in the commit log.

 doc/guides/rel_notes/release_16_04.rst |  1 +
 drivers/net/i40e/i40e_ethdev.c | 57 +-
 2 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 5786f74..eb7effc 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -46,6 +46,7 @@ This section should contain new features added in this 
release. Sample format:

 * **Added vhost-user live migration support.**

+* **Added VEB switching support for FVL.**

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index ef24122..5527cb1 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3822,6 +3822,45 @@ i40e_vsi_get_bw_config(struct i40e_vsi *vsi)
return I40E_SUCCESS;
 }

+/* i40e_enable_pf_lb
+ * @pf: pointer to the pf structure
+ *
+ * allow loopback on pf
+ */
+static inline void
+i40e_enable_pf_lb(struct i40e_pf *pf)
+{
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+   struct i40e_vsi_context ctxt;
+   int ret;
+
+   /* Use the FW API if FW >= v5.0 */
+   if (hw->aq.fw_maj_ver < 5) {
+   PMD_INIT_LOG(ERR, "FW < v5.0, cannot enable loopback");
+   return;
+   }
+
+   memset(, 0, sizeof(ctxt));
+   ctxt.seid = pf->main_vsi_seid;
+   ctxt.pf_num = hw->pf_id;
+   ret = i40e_aq_get_vsi_params(hw, , NULL);
+   if (ret) {
+   PMD_DRV_LOG(ERR, "cannot get pf vsi config, err %d, aq_err %d",
+   ret, hw->aq.asq_last_status);
+   return;
+   }
+   ctxt.flags = I40E_AQ_VSI_TYPE_PF;
+   ctxt.info.valid_sections =
+   rte_cpu_to_le_16(I40E_AQ_VSI_PROP_SWITCH_VALID);
+   ctxt.info.switch_id |=
+   rte_cpu_to_le_16(I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB);
+
+   ret = i40e_aq_update_vsi_params(hw, , NULL);
+   if (ret)
+   PMD_DRV_LOG(ERR, "update vsi switch failed, aq_err=%d\n",
+   hw->aq.asq_last_status);
+}
+
 /* Setup a VSI */
 struct i40e_vsi *
 i40e_vsi_setup(struct i40e_pf *pf,
@@ -3857,6 +3896,8 @@ i40e_vsi_setup(struct i40e_pf *pf,
PMD_DRV_LOG(ERR, "VEB setup failed");
return NULL;
}
+   /* set ALLOWLOOPBACk on pf, when veb is created */
+   i40e_enable_pf_lb(pf);
}

vsi = rte_zmalloc("i40e_vsi", sizeof(struct i40e_vsi), 0);
@@ -4029,14 +4070,14 @@ i40e_vsi_setup(struct i40e_pf *pf,
ctxt.connection_type = 0x1;
ctxt.flags = I40E_AQ_VSI_TYPE_VF;

-   /**
-* Do not configure switch ID to enable VEB switch by
-* I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB. Because in Fortville,
-* if the source mac address of packet sent from VF is not
-* listed in the VEB's mac table, the VEB will switch the
-* packet back to the VF. Need to enable it when HW issue
-* is fixed.
-*/
+   /* Use the VEB configuration if FW >= v5.0 */
+   if (hw->aq.fw_maj_ver >= 5) {
+   /* Configure switch ID */
+   ctxt.info.valid_sections |=
+   rte_cpu_to_le_16(I40E_AQ_VSI_PROP_SWITCH_VALID);
+   ctxt.info.switch_id =
+   rte_cpu_to_le_16(I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB);
+   }

/* Configure port/vlan */
ctxt.info.valid_sections |=
-- 
2.1.4



[dpdk-dev] [PATCH v3 0/2] i40evf: pf reset event report

2016-03-09 Thread Zhe Tao
On Fri, Feb 26, 2016 at 02:51:52PM +0800, Jingjing Wu wrote:
> v3 changes:
>  - commit log doc rewording.
>  - rebase on latest dpdk-next-net/rel_16_04 branch.
>  - remove few useless line
>  - adjust interval and increase times for waiting pf msg
> 
> v2 changes:
>  - remove the change on vf reset status checking
>  - add pf event report support in release note
> 
> When Linux PF and DPDK VF are used for i40e PMD, In case of PF reset,
> interrupt request will go via adminq event, VF need be informed, a callback
> mechanism is introduced by VF. This will allow VF to invoke callback when
> reset happens.
> Users can register a callback for this interrupt event like:
> rte_eth_dev_callback_register(portid,
> RTE_ETH_EVENT_INTR_RESET,
> reset_event_callback,
> arg);
> 
> Jingjing Wu (2):
>   i40evf: allocate virtchnl cmd buffer for each vf
>   i40evf: support to report pf reset event
> 
>  doc/guides/rel_notes/release_16_04.rst |   1 +
>  drivers/net/i40e/i40e_ethdev.h |   2 +
>  drivers/net/i40e/i40e_ethdev_vf.c  | 420 
> +++--
>  lib/librte_ether/rte_ethdev.h  |   1 +
>  4 files changed, 301 insertions(+), 123 deletions(-)
> 
> -- 
> 2.4.0
Acked-by: Zhe Tao 



[dpdk-dev] [PATCH v2] ixgbe: fix ixgbevf RX/TX function assignment

2016-03-08 Thread Zhe Tao
For the secondary process of DPDK to initialize ixgbevf, it will always
use the simple RX function or LRO RX function, and this behavior is not
the same RX/TX function selection logic as it is for the primary process,
so use the ixgbe_set_tx_function and ixgbe_set_rx_function to select the
RX/TX function when secondary process call the init function for eth dev.  

Fixes: abf7275bbaa2918 (ixgbe: move to drivers/net/)

V2:add fixes line

Signed-off-by: Zhe Tao 

---
 drivers/net/ixgbe/ixgbe_ethdev.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 3e6fe86..0f9d048 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1278,8 +1278,21 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
 * has already done this work. Only check we don't need a different
 * RX function */
if (rte_eal_process_type() != RTE_PROC_PRIMARY){
-   if (eth_dev->data->scattered_rx)
-   eth_dev->rx_pkt_burst = 
ixgbe_recv_pkts_lro_single_alloc;
+   struct ixgbe_tx_queue *txq;
+   /* TX queue function in primary, set by last queue initialized
+* Tx queue may not initialized by primary process
+*/
+   if (eth_dev->data->tx_queues) {
+   txq = 
eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
+   ixgbe_set_tx_function(eth_dev, txq);
+   } else {
+   /* Use default TX function if we get here */
+   PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
+"Using default TX function.");
+   }
+
+   ixgbe_set_rx_function(eth_dev);
+
return 0;
}

-- 
2.1.4



[dpdk-dev] [PATCH v2 0/2] add VF MAC address generation

2016-03-08 Thread Zhe Tao
On Tue, Mar 08, 2016 at 02:42:07PM +0800, Helin Zhang wrote:
> It adds generating a MAC address for each VFs during PF
> host initialization.
> 
> The patch set branches off below commit on branch rel_16_04
> of dpdk-next-net repo.
> 
> commit 4ac366ba647909c3b71818f9be9db86ba5e871da
> Author: Thomas Monjalon 
> Date:   Sat Feb 6 22:51:16 2016 +0100
> nfp: fix non-x86 build
> 
> v2:
>  - It just adds generating a MAC address for each VFs
>during PF host initialization, and removes configuring
>from users.
>  - Reworded the release notes.
>  - Removed the app changes.
> 
> Helin Zhang (2):
>   i40e: generate MAC address for VF
>   i40evf: use ether API to validate MAC address
> 
>  doc/guides/rel_notes/release_16_04.rst |  5 +
>  drivers/net/i40e/i40e_ethdev.h |  1 +
>  drivers/net/i40e/i40e_ethdev_vf.c  | 14 +++---
>  drivers/net/i40e/i40e_pf.c |  3 +++
>  4 files changed, 16 insertions(+), 7 deletions(-)
> 
> -- 
> 2.5.0
Acked-by: Zhe Tao 



[dpdk-dev] i40e & ixgbe xmit issue: txe->next_id

2016-03-04 Thread Zhe Tao
Hi all,
I have a question about why we need the txe->next_id field in the i40e Tx
function?
>From the current implementation, all the txe is initialized and free 
>sequentially,
so we don't need this "next_id" field in our TX function, and when we decide the
"last_id" for txe, we assume the txe is sequential. So I suggest deprecate using
this next_id field.
Any comments will be welcome!





[dpdk-dev] [PATCH 2/2 v4] i40e: Add floating VEB support in i40e

2016-03-02 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

Now the floating VEB feature is only avaiable in the specific version of FW.

Signed-off-by: Zhe Tao 
---
 doc/guides/rel_notes/release_16_04.rst |   2 +
 drivers/net/i40e/Makefile  |   2 +-
 drivers/net/i40e/i40e_ethdev.c | 115 +++--
 drivers/net/i40e/i40e_ethdev.h |   8 +++
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 115 insertions(+), 23 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 5786f74..446112c 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -46,6 +46,8 @@ This section should contain new features added in this 
release. Sample format:

 * **Added vhost-user live migration support.**

+* **Added floating VEB support for FVL.**
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 033ee4a..2e01d45 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -39,7 +39,7 @@ LIB = librte_pmd_i40e.a
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS) -DPF_DRIVER -DVF_DRIVER -DINTEGRATED_VF
 CFLAGS += -DX722_SUPPORT -DX722_A0_SUPPORT
-
+CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common
 EXPORT_MAP := rte_pmd_i40e_version.map

 LIBABIVER := 1
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index ef24122..cf3c346 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -802,6 +802,13 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

+   /* Need the special FW version support floating VEB */
+   if ((hw->aq.fw_maj_ver == FLOATING_FW_MAJ) &&
+   (hw->aq.fw_min_ver == FLOATING_FW_MIN)) {
+   pf->floating = internal_config.floating;
+   } else {
+   pf->floating = false;
+   }
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

@@ -3592,21 +3599,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3618,9 +3631,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3632,11 +3645,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, false, >seid, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
+ I40E_DEFAULT_TCMAP, false, false,
+ >seid, NULL);
+   } else {
+   ret = i40e_aq_add_veb(hw, 0, 0, I40E_DEFAULT_TCMAP,
+ true, fa

[dpdk-dev] [PATCH 1/2 v4] i40e: support floating VEB config

2016-03-02 Thread Zhe Tao
Add the new floating related argument option in the EAL.
Using this parameter, all the samples can decide whether to use legacy VEB/VEPA
or floating VEB.
Even the floating argument is provided in the EAL, but this floating
feature are only support for FVL so far.

Signed-off-by: Zhe Tao 
---
 doc/guides/testpmd_app_ug/run_app.rst  | 4 
 lib/librte_eal/common/eal_common_options.c | 4 
 lib/librte_eal/common/eal_internal_cfg.h   | 1 +
 lib/librte_eal/common/eal_options.h| 2 ++
 4 files changed, 11 insertions(+)

diff --git a/doc/guides/testpmd_app_ug/run_app.rst 
b/doc/guides/testpmd_app_ug/run_app.rst
index f605564..2f02f63 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -156,6 +156,10 @@ See the DPDK Getting Started Guides for more information 
on these options.

 Use malloc instead of hugetlbfs.

+*   ``--floating``
+
+Enable floating feature for virtual ethernet switch in the NIC.
+Now only Intel i40e NIC supports this feature.

 Testpmd Command-line Options
 
diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 29942ea..29ed7bf 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -95,6 +95,7 @@ eal_long_options[] = {
{OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
{OPT_VMWARE_TSC_MAP,0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
{OPT_XEN_DOM0,  0, NULL, OPT_XEN_DOM0_NUM },
+   {OPT_FLOATING,  0, NULL, OPT_FLOATING_NUM },
{0, 0, NULL, 0}
 };

@@ -896,6 +897,9 @@ eal_parse_common_option(int opt, const char *optarg,
return -1;
}
break;
+   case OPT_FLOATING_NUM:
+   conf->floating = 1;
+   break;

/* don't know what to do, leave this to caller */
default:
diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
b/lib/librte_eal/common/eal_internal_cfg.h
index 5f1367e..19b321a 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -68,6 +68,7 @@ struct internal_config {
volatile unsigned xen_dom0_support; /**< support app running on Xen 
Dom0*/
volatile unsigned no_pci; /**< true to disable PCI */
volatile unsigned no_hpet;/**< true to disable HPET */
+   volatile unsigned floating;   /**< true to enable floating VEB */
volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping

* instead of native TSC */
volatile unsigned no_shconf;  /**< true if there is no shared 
config */
diff --git a/lib/librte_eal/common/eal_options.h 
b/lib/librte_eal/common/eal_options.h
index a881c62..413c9e6 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -83,6 +83,8 @@ enum {
OPT_VMWARE_TSC_MAP_NUM,
 #define OPT_XEN_DOM0  "xen-dom0"
OPT_XEN_DOM0_NUM,
+#define OPT_FLOATING  "floating"
+   OPT_FLOATING_NUM,
OPT_LONG_MAX_NUM
 };

-- 
2.1.4



[dpdk-dev] [PATCH 0/2 v4] i40e: Add floating VEB support for i40e

2016-03-02 Thread Zhe Tao
This patch-set add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
the floating VEB. When connect to the floating VEB a new floating VEB is
created. Now all the VFs need to connect to floating VEB or legacy VEB,
cannot connect to both of them. The PF and VMDQ,FD VSIs connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

This floating VEB only take effects on the specific version F/W.

Zhe Tao (2):
  support floating VEB config
  Add floating VEB support in i40e

 doc/guides/rel_notes/release_16_04.rst |   2 +
 doc/guides/testpmd_app_ug/run_app.rst  |   4 +
 drivers/net/i40e/Makefile  |   2 +-
 drivers/net/i40e/i40e_ethdev.c | 115 -
 drivers/net/i40e/i40e_ethdev.h |   8 ++
 drivers/net/i40e/i40e_pf.c |  11 ++-
 lib/librte_eal/common/eal_common_options.c |   4 +
 lib/librte_eal/common/eal_internal_cfg.h   |   1 +
 lib/librte_eal/common/eal_options.h|   2 +
 9 files changed, 126 insertions(+), 23 deletions(-)

V2: Added the release notes and changed commit log. 
V3: Changed the VSI release operation. 
V4: Add the FW version check otherwise it will cause the segment fault.
-- 
2.1.4



[dpdk-dev] [PATCH v2] ethdev: fix byte order inconsistence between fdir flow and mask

2016-03-02 Thread Zhe Tao
On Mon, Feb 01, 2016 at 10:48:21AM +0800, Jingjing Wu wrote:
> Fixed issue of byte order in ethdev library that the structure
> for setting fdir's mask and flow entry is inconsist and made
> inputs of mask be in big endian.
> 
> Fixes: 76c6f89e80d4 ("ixgbe: support new flow director masks")
> Fixes: 2d4c1a9ea2ac ("ethdev: add new flow director masks")
> 
> Reported-by: Yaacov Hazan 
> Signed-off-by: Jingjing Wu 
> ---
> v2 changes:
>   fix typo and reword API doc.
> 
>  app/test-pmd/cmdline.c   |  6 ++---
>  doc/guides/rel_notes/release_2_3.rst |  6 +
>  drivers/net/ixgbe/ixgbe_fdir.c   | 47 
> ++--
>  lib/librte_ether/rte_eth_ctrl.h  | 17 ++---
>  4 files changed, 51 insertions(+), 25 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 73298c9..13194c9 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -8687,13 +8687,13 @@ cmd_flow_director_mask_parsed(void *parsed_result,
>   return;
>   }
Acked-by: Zhe Tao 



[dpdk-dev] [PATCH] ixgbe: fix ixgbevf RX/TX function assignment

2016-02-28 Thread Zhe Tao
For the secondary process of DPDK to initialize ixgbevf, it will always
use the simple RX function or LRO RX function, and this behavior is not
the same RX/TX function selection logic as it is for the primary process,
so use the ixgbe_set_tx_function and ixgbe_set_rx_function to select the
RX/TX function when secondary process call the init function for eth dev.  
Signed-off-by: Zhe Tao 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 3e6fe86..0f9d048 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1278,8 +1278,21 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
 * has already done this work. Only check we don't need a different
 * RX function */
if (rte_eal_process_type() != RTE_PROC_PRIMARY){
-   if (eth_dev->data->scattered_rx)
-   eth_dev->rx_pkt_burst = 
ixgbe_recv_pkts_lro_single_alloc;
+   struct ixgbe_tx_queue *txq;
+   /* TX queue function in primary, set by last queue initialized
+* Tx queue may not initialized by primary process
+*/
+   if (eth_dev->data->tx_queues) {
+   txq = 
eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
+   ixgbe_set_tx_function(eth_dev, txq);
+   } else {
+   /* Use default TX function if we get here */
+   PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
+"Using default TX function.");
+   }
+
+   ixgbe_set_rx_function(eth_dev);
+
return 0;
}

-- 
2.1.4



[dpdk-dev] [PATCH 2/2 v3] i40e: Add floating VEB support in i40e

2016-02-25 Thread Zhe Tao
This patch add the support for floating VEB in i40e.
All the VFs VSIs can decide whether to connect to the legacy VEB/VEPA or
 the floating VEB. When connect to the floating VEB a new floating VEB is
 created. Now all the VFs need to connect to floating VEB or legacy VEB,
 cannot connect to both of them. The PF and VMDQ,FD VSIs still connect to
the old legacy VEB/VEPA.

All the VEB/VEPA concepts are not specific for FVL, they are defined in the
802.1Qbg spec.

Signed-off-by: Zhe Tao 
---
 doc/guides/rel_notes/release_16_04.rst |   2 +
 drivers/net/i40e/Makefile  |   2 +-
 drivers/net/i40e/i40e_ethdev.c | 105 +++--
 drivers/net/i40e/i40e_ethdev.h |   4 ++
 drivers/net/i40e/i40e_pf.c |  11 +++-
 5 files changed, 103 insertions(+), 21 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 5786f74..446112c 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -46,6 +46,8 @@ This section should contain new features added in this 
release. Sample format:

 * **Added vhost-user live migration support.**

+* **Added floating VEB support for FVL.**
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 033ee4a..2e01d45 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -39,7 +39,7 @@ LIB = librte_pmd_i40e.a
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS) -DPF_DRIVER -DVF_DRIVER -DINTEGRATED_VF
 CFLAGS += -DX722_SUPPORT -DX722_A0_SUPPORT
-
+CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common
 EXPORT_MAP := rte_pmd_i40e_version.map

 LIBABIVER := 1
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index ef24122..f8554c9 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -744,6 +744,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
pf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
pf->adapter->eth_dev = dev;
pf->dev_data = dev->data;
+   pf->floating = internal_config.floating;

hw->back = I40E_PF_TO_ADAPTER(pf);
hw->hw_addr = (uint8_t *)(pci_dev->mem_resource[0].addr);
@@ -3592,21 +3593,27 @@ i40e_veb_release(struct i40e_veb *veb)
struct i40e_vsi *vsi;
struct i40e_hw *hw;

-   if (veb == NULL || veb->associate_vsi == NULL)
+   if (veb == NULL)
return -EINVAL;

if (!TAILQ_EMPTY(>head)) {
PMD_DRV_LOG(ERR, "VEB still has VSI attached, can't remove");
return -EACCES;
}
+   /* associate_vsi field is NULL for floating VEB */
+   if (veb->associate_vsi != NULL) {
+   vsi = veb->associate_vsi;
+   hw = I40E_VSI_TO_HW(vsi);

-   vsi = veb->associate_vsi;
-   hw = I40E_VSI_TO_HW(vsi);
+   vsi->uplink_seid = veb->uplink_seid;
+   vsi->veb = NULL;
+   } else {
+   veb->associate_pf->main_vsi->floating_veb = NULL;
+   hw = I40E_VSI_TO_HW(veb->associate_pf->main_vsi);
+   }

-   vsi->uplink_seid = veb->uplink_seid;
i40e_aq_delete_element(hw, veb->seid, NULL);
rte_free(veb);
-   vsi->veb = NULL;
return I40E_SUCCESS;
 }

@@ -3618,9 +3625,9 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
int ret;
struct i40e_hw *hw;

-   if (NULL == pf || vsi == NULL) {
+   if (NULL == pf) {
PMD_DRV_LOG(ERR, "veb setup failed, "
-   "associated VSI shouldn't null");
+   "associated PF shouldn't null");
return NULL;
}
hw = I40E_PF_TO_HW(pf);
@@ -3632,11 +3639,19 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
}

veb->associate_vsi = vsi;
+   veb->associate_pf = pf;
TAILQ_INIT(>head);
-   veb->uplink_seid = vsi->uplink_seid;
+   veb->uplink_seid = vsi ? vsi->uplink_seid : 0;

-   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, false, >seid, NULL);
+   /* create floating veb if vsi is NULL */
+   if (vsi != NULL) {
+   ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
+ I40E_DEFAULT_TCMAP, false, false,
+ >seid, NULL);
+   } else {
+   ret = i40e_aq_add_veb(hw, 0, 0, I40E_DEFAULT_TCMAP,
+ false, false, >seid, NULL);
+   }

if (ret != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Add veb failed, aq_err: %d",
@@ -3688,12 +3703,22 @@ i40e_vsi_release(struct i40e_vsi *vsi)
i40e_veb_release(vsi->veb);
}

  1   2   >