[dpdk-dev] [PATCH] net/fm10k: fix SGLORT of VF Tx queues

2016-10-19 Thread Xiao Wang
The SGLORT (Source Global Resource Tag) of the VF queues should be
assigned by PF driver, VF driver should not set these registers.

Fixes: 3b845bf6bcd9 ("fm10k: fix switch manager high CPU usage")

Signed-off-by: Xiao Wang 
Reported-by: Sarathx Somasekharan 
---
 drivers/net/fm10k/fm10k_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index c804436..923690c 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -695,8 +695,9 @@ fm10k_dev_tx_init(struct rte_eth_dev *dev)
base_addr >> (CHAR_BIT * sizeof(uint32_t)));
FM10K_WRITE_REG(hw, FM10K_TDLEN(i), size);

-   /* assign default SGLORT for each TX queue */
-   FM10K_WRITE_REG(hw, FM10K_TX_SGLORT(i), hw->mac.dglort_map);
+   /* assign default SGLORT for each TX queue by PF */
+   if (hw->mac.type == fm10k_mac_pf)
+   FM10K_WRITE_REG(hw, FM10K_TX_SGLORT(i), 
hw->mac.dglort_map);
}

/* set up vector or scalar TX function as appropriate */
-- 
1.9.3



[dpdk-dev] [PATCH v2 5/5] net/i40e: implement new Rx checksum flag

2016-09-06 Thread Xiao Wang
Add CKSUM_GOOD flag to distinguish a good checksum from an unknown one.

Signed-off-by: Xiao Wang 
---
 drivers/net/i40e/i40e_rxtx.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 554d167..b49d9dc 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -142,8 +142,14 @@ i40e_rxd_error_to_pkt_flags(uint64_t qword)
return flags;
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_IPE_SHIFT)))
flags |= PKT_RX_IP_CKSUM_BAD;
+   else
+   flags |= PKT_RX_IP_CKSUM_GOOD;
+
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_L4E_SHIFT)))
flags |= PKT_RX_L4_CKSUM_BAD;
+   else
+   flags |= PKT_RX_L4_CKSUM_GOOD;
+
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_EIPE_SHIFT)))
flags |= PKT_RX_EIP_CKSUM_BAD;

-- 
1.9.3



[dpdk-dev] [PATCH v2 4/5] net/ixgbe: implement new Rx checksum flag

2016-09-06 Thread Xiao Wang
Add CKSUM_GOOD flag to distinguish a good checksum from an unknown one.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/ixgbe_rxtx.c |  4 +++-
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 30 --
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 8a306b0..d2dc82a 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -1345,7 +1345,9 @@ rx_desc_error_to_pkt_flags(uint32_t rx_status)
 * Bit 30: L4I, L4I integrity error
 */
static uint64_t error_to_pkt_flags_map[4] = {
-   0,  PKT_RX_L4_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD,
+   PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD,
+   PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD,
+   PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_GOOD,
PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD
};
pkt_flags = error_to_pkt_flags_map[(rx_status >>
diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c 
b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
index dc5657e..7929593 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c
@@ -156,6 +156,11 @@ desc_to_olflags_v(__m128i descs[4], uint8_t vlan_flags,
0x, 0x, 0x, 0x,
0x000F, 0x000F, 0x000F, 0x000F);

+   /* mask the lower byte of ol_flags */
+   const __m128i ol_flags_msk = _mm_set_epi16(
+   0x, 0x, 0x, 0x,
+   0x00FF, 0x00FF, 0x00FF, 0x00FF);
+
/* map rss type to rss hash flag */
const __m128i rss_flags = _mm_set_epi8(PKT_RX_FDIR, 0, 0, 0,
0, 0, 0, PKT_RX_RSS_HASH,
@@ -171,17 +176,25 @@ desc_to_olflags_v(__m128i descs[4], uint8_t vlan_flags,
IXGBE_RXD_STAT_VP, IXGBE_RXD_STAT_VP,
IXGBE_RXD_STAT_VP, IXGBE_RXD_STAT_VP);
/* map vlan present (0x8), IPE (0x2), L4E (0x1) to ol_flags */
-   const __m128i vlan_csum_map = _mm_set_epi8(
+   const __m128i vlan_csum_map_lo = _mm_set_epi8(
0, 0, 0, 0,
vlan_flags | PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD,
vlan_flags | PKT_RX_IP_CKSUM_BAD,
-   vlan_flags | PKT_RX_L4_CKSUM_BAD,
-   vlan_flags,
+   vlan_flags | PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD,
+   vlan_flags | PKT_RX_IP_CKSUM_GOOD,
0, 0, 0, 0,
PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD,
PKT_RX_IP_CKSUM_BAD,
-   PKT_RX_L4_CKSUM_BAD,
-   0);
+   PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD,
+   PKT_RX_IP_CKSUM_GOOD);
+
+   const __m128i vlan_csum_map_hi = _mm_set_epi8(
+   0, 0, 0, 0,
+   0, PKT_RX_L4_CKSUM_GOOD >> sizeof(uint8_t), 0,
+   PKT_RX_L4_CKSUM_GOOD >> sizeof(uint8_t),
+   0, 0, 0, 0,
+   0, PKT_RX_L4_CKSUM_GOOD >> sizeof(uint8_t), 0,
+   PKT_RX_L4_CKSUM_GOOD >> sizeof(uint8_t));

ptype0 = _mm_unpacklo_epi16(descs[0], descs[1]);
ptype1 = _mm_unpacklo_epi16(descs[2], descs[3]);
@@ -207,7 +220,12 @@ desc_to_olflags_v(__m128i descs[4], uint8_t vlan_flags,
vtag1 = _mm_or_si128(csum, vtag1);

/* convert VP, IPE, L4E to ol_flags */
-   vtag1 = _mm_shuffle_epi8(vlan_csum_map, vtag1);
+   vtag0 = _mm_shuffle_epi8(vlan_csum_map_hi, vtag1);
+   vtag0 = _mm_slli_epi16(vtag0, sizeof(uint8_t));
+
+   vtag1 = _mm_shuffle_epi8(vlan_csum_map_lo, vtag1);
+   vtag1 = _mm_and_si128(vtag1, ol_flags_msk);
+   vtag1 = _mm_or_si128(vtag0, vtag1);

vtag1 = _mm_or_si128(ptype0, vtag1);
vol.dword = _mm_cvtsi128_si64(vtag1);
-- 
1.9.3



[dpdk-dev] [PATCH v2 3/5] net/e1000: implement new Rx checksum flag

2016-09-06 Thread Xiao Wang
Add CKSUM_GOOD flag to distinguish a good checksum from an unknown one.

Signed-off-by: Xiao Wang 
---
 drivers/net/e1000/igb_rxtx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 9d80a0b..bc33aed 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -748,7 +748,9 @@ rx_desc_error_to_pkt_flags(uint32_t rx_status)
 */

static uint64_t error_to_pkt_flags_map[4] = {
-   0,  PKT_RX_L4_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD,
+   PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD,
+   PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD,
+   PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_GOOD,
PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD
};
return error_to_pkt_flags_map[(rx_status >>
-- 
1.9.3



[dpdk-dev] [PATCH v2 2/5] net/fm10k: implement new Rx checksum flag

2016-09-06 Thread Xiao Wang
Add CKSUM_GOOD flag to distinguish a good checksum from an unknown one.
Since vector Rx supports checksum offload, this patch removes the
hw_ip_checksum check in fm10k_rx_vec_condition_check().

Signed-off-by: Xiao Wang 
---
 drivers/net/fm10k/fm10k_rxtx.c |  4 
 drivers/net/fm10k/fm10k_rxtx_vec.c | 24 +---
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_rxtx.c b/drivers/net/fm10k/fm10k_rxtx.c
index bf5888b..32cc7ff 100644
--- a/drivers/net/fm10k/fm10k_rxtx.c
+++ b/drivers/net/fm10k/fm10k_rxtx.c
@@ -101,11 +101,15 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const union 
fm10k_rx_desc *d)
(FM10K_RXD_STATUS_IPCS | FM10K_RXD_STATUS_IPE)) ==
(FM10K_RXD_STATUS_IPCS | FM10K_RXD_STATUS_IPE)))
m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+   else
+   m->ol_flags |= PKT_RX_IP_CKSUM_GOOD;

if (unlikely((d->d.staterr &
(FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)) ==
(FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)))
m->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+   else
+   m->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
 }

 uint16_t
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 9ea747e..5513f86 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -67,6 +67,8 @@ fm10k_reset_tx_queue(struct fm10k_tx_queue *txq);
 #define RXEFLAG_SHIFT (13)
 /* IPE/L4E flag shift */
 #define L3L4EFLAG_SHIFT (14)
+/* shift PKT_RX_L4_CKSUM_GOOD into one byte by 1 bit */
+#define CKSUM_SHIFT (1)

 static inline void
 fm10k_desc_to_olflags_v(__m128i descs[4], struct rte_mbuf **rx_pkts)
@@ -92,11 +94,18 @@ fm10k_desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
0x, 0x, 0x, 0x,
0x0001, 0x0001, 0x0001, 0x0001);

+   /* mask the lower byte of ol_flags */
+   const __m128i ol_flags_msk = _mm_set_epi16(
+   0x, 0x, 0x, 0x,
+   0x00FF, 0x00FF, 0x00FF, 0x00FF);
+
const __m128i l3l4cksum_flag = _mm_set_epi8(0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
-   PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD,
-   PKT_RX_IP_CKSUM_BAD, PKT_RX_L4_CKSUM_BAD, 0);
+   (PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD) >> 
CKSUM_SHIFT,
+   (PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_GOOD) >> 
CKSUM_SHIFT,
+   (PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD) >> 
CKSUM_SHIFT,
+   (PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD) >> 
CKSUM_SHIFT);

const __m128i rxe_flag = _mm_set_epi8(0, 0, 0, 0,
0, 0, 0, 0,
@@ -139,6 +148,10 @@ fm10k_desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
/* Process L4/L3 checksum error flags */
cksumflag = _mm_srli_epi16(cksumflag, L3L4EFLAG_SHIFT);
cksumflag = _mm_shuffle_epi8(l3l4cksum_flag, cksumflag);
+
+   /* clean the higher byte and shift back the flag bits */
+   cksumflag = _mm_and_si128(cksumflag, ol_flags_msk);
+   cksumflag = _mm_slli_epi16(cksumflag, CKSUM_SHIFT);
vtag1 = _mm_or_si128(cksumflag, vtag1);

vol.dword = _mm_cvtsi128_si64(vtag1);
@@ -234,11 +247,8 @@ fm10k_rx_vec_condition_check(struct rte_eth_dev *dev)
if (fconf->mode != RTE_FDIR_MODE_NONE)
return -1;

-   /* - no csum error report support
-* - no header split support
-*/
-   if (rxmode->hw_ip_checksum == 1 ||
-   rxmode->header_split == 1)
+   /* no header split support */
+   if (rxmode->header_split == 1)
return -1;

return 0;
-- 
1.9.3



[dpdk-dev] [PATCH v2 1/5] net/fm10k: fix Rx checksum flags

2016-09-06 Thread Xiao Wang
A previous patch removed some necessary lines about Rx checksum offload
by mistake, this patch adds them back.

Fixes: 6046898f5097 ("net/mbuf: remove unused Rx error flags")

Signed-off-by: Xiao Wang 
---
 drivers/net/fm10k/fm10k_rxtx.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/fm10k/fm10k_rxtx.c b/drivers/net/fm10k/fm10k_rxtx.c
index 5b2d04b..bf5888b 100644
--- a/drivers/net/fm10k/fm10k_rxtx.c
+++ b/drivers/net/fm10k/fm10k_rxtx.c
@@ -96,6 +96,16 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const union 
fm10k_rx_desc *d)

if (d->w.pkt_info & FM10K_RXD_RSSTYPE_MASK)
m->ol_flags |= PKT_RX_RSS_HASH;
+
+   if (unlikely((d->d.staterr &
+   (FM10K_RXD_STATUS_IPCS | FM10K_RXD_STATUS_IPE)) ==
+   (FM10K_RXD_STATUS_IPCS | FM10K_RXD_STATUS_IPE)))
+   m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+
+   if (unlikely((d->d.staterr &
+   (FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)) ==
+   (FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)))
+   m->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 }

 uint16_t
-- 
1.9.3



[dpdk-dev] [PATCH v2 0/5] implement new Rx checksum flag

2016-09-06 Thread Xiao Wang
v2:
* Removed hw_ip_checksum check in fm10k_rx_vec_condition_check().

* Defined CKSUM_SHIFT for SSE bits shift.

* Changed commit title from "add back Rx checksum offload" to
  "fix Rx checksum flags".

* Added new cksum flag support for ixgbe vector Rx, based on patch
  (http://dpdk.org/dev/patchwork/patch/14630/) which came earlier.

v1:
Following http://dpdk.org/dev/patchwork/patch/14941/, this patch set
implements newly defined Rx checksum flag for igb, ixgbe, i40e and fm10k.

Currently, ixgbe and fm10k support Rx checksum offload in both scalar
and vector datapath, while the other two don't, this patch set keeps
this situation.

Note: This patch set has dependency on the following patches:

"mbuf: add new Rx checksum mbuf flags"
(http://dpdk.org/dev/patchwork/patch/14941/)

"ixgbe: support checksum flags in sse vector Rx function"
(http://dpdk.org/dev/patchwork/patch/14630/)

Xiao Wang (5):
  net/fm10k: fix Rx checksum flags
  net/fm10k: implement new Rx checksum flag
  net/e1000: implement new Rx checksum flag
  net/ixgbe: implement new Rx checksum flag
  net/i40e: implement new Rx checksum flag

 drivers/net/e1000/igb_rxtx.c   |  4 +++-
 drivers/net/fm10k/fm10k_rxtx.c | 14 ++
 drivers/net/fm10k/fm10k_rxtx_vec.c | 24 +---
 drivers/net/i40e/i40e_rxtx.c   |  6 ++
 drivers/net/ixgbe/ixgbe_rxtx.c |  4 +++-
 drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 30 --
 6 files changed, 67 insertions(+), 15 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH 39/39] net/ixgbe/base: add base driver update brief

2016-08-28 Thread Xiao Wang
The ixgbe base driver was updated to version
cid-10g-shared-code.2016.04.12.

Signed-off-by: Xiao Wang 
---
 doc/guides/rel_notes/release_16_11.rst | 8 
 drivers/net/ixgbe/base/README  | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_11.rst 
b/doc/guides/rel_notes/release_16_11.rst
index 0b9022d..9bbe65a 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -36,6 +36,14 @@ New Features

  This section is a comment. Make sure to start the actual text at the 
margin.

+   * **Updated the ixgbe base driver.**
+
+ Updated the ixgbe base driver, including the following changes:
+
+ * add X550em_a 10G PHY support
+ * add VF multicast promiscuous mode support
+ * support flow control auto negotiation for X550em_a 1G PHY
+ * add X550em_a FW ALEF support

 Resolved Issues
 ---
diff --git a/drivers/net/ixgbe/base/README b/drivers/net/ixgbe/base/README
index 76e7805..6b54c31 100644
--- a/drivers/net/ixgbe/base/README
+++ b/drivers/net/ixgbe/base/README
@@ -34,7 +34,7 @@ Intel? IXGBE driver
 ===

 This directory contains source code of FreeBSD ixgbe driver of version
-cid-10g-shared-code.2016.04.12 released by ND. The sub-directory of base/
+cid-10g-shared-code.2016.08.15 released by ND. The sub-directory of base/
 contains the original source package.
 This driver is valid for the product(s) listed below

-- 
1.9.3



[dpdk-dev] [PATCH 38/39] net/ixgbe/base: do not skip PHY configuration

2016-08-28 Thread Xiao Wang
By exiting early we could skip the PHY configuration and as such
the driver may not configure the PHY correctly for SFP+.

This patch removes the logic which would previously skip the PHY
configuration in the case where we are already at the requested
speed in ixgbe_setup_mac_link_multispeed_fiber().

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 3d42a8f..cca19ef 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -5063,14 +5063,6 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct 
ixgbe_hw *hw,
speedcnt++;
highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL;

-   /* If we already have link at this speed, just jump out */
-   status = ixgbe_check_link(hw, _speed, _up, false);
-   if (status != IXGBE_SUCCESS)
-   return status;
-
-   if ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
-   goto out;
-
/* Set the module link speed */
switch (hw->phy.media_type) {
case ixgbe_media_type_fiber:
@@ -5121,14 +5113,6 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct 
ixgbe_hw *hw,
if (highest_link_speed == IXGBE_LINK_SPEED_UNKNOWN)
highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL;

-   /* If we already have link at this speed, just jump out */
-   status = ixgbe_check_link(hw, _speed, _up, false);
-   if (status != IXGBE_SUCCESS)
-   return status;
-
-   if ((link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
-   goto out;
-
/* Set the module link speed */
switch (hw->phy.media_type) {
case ixgbe_media_type_fiber:
-- 
1.9.3



[dpdk-dev] [PATCH 37/39] net/ixgbe/base: clean code of flow control autoneg

2016-08-28 Thread Xiao Wang
Support for flow control auto negotiation is defeatured from X550em_a
fiber when connected to speeds lower than 10Gbps. This patch cleans up
the code path which is mostly dead to begin with.

- add device IDs check in ixgbe_device_supports_autoneg_fc().
- ixgbe_fc_autoneg_fiber_x550em_a() is now used only to pass the user
  settings to ixgbe_fc_enable_generic().
- make sure that start_hw does not fail when setup_fc is not implemented.
- small fix in the debug message when ixgbe_device_supports_autoneg_fc()
  returns false.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_common.c |  37 ++--
 drivers/net/ixgbe/base/ixgbe_x550.c   | 307 +++---
 drivers/net/ixgbe/base/ixgbe_x550.h   |   8 +-
 3 files changed, 93 insertions(+), 259 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index d31fb81..3d42a8f 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -168,13 +168,24 @@ bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
switch (hw->phy.media_type) {
case ixgbe_media_type_fiber_qsfp:
case ixgbe_media_type_fiber:
-   hw->mac.ops.check_link(hw, , _up, false);
-   /* if link is down, assume supported */
-   if (link_up)
-   supported = speed == IXGBE_LINK_SPEED_1GB_FULL ?
+   /* flow control autoneg black list */
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_A_SFP:
+   case IXGBE_DEV_ID_X550EM_A_SFP_N:
+   case IXGBE_DEV_ID_X550EM_A_QSFP:
+   case IXGBE_DEV_ID_X550EM_A_QSFP_N:
+   supported = false;
+   break;
+   default:
+   hw->mac.ops.check_link(hw, , _up, false);
+   /* if link is down, assume supported */
+   if (link_up)
+   supported = speed == IXGBE_LINK_SPEED_1GB_FULL ?
true : false;
-   else
-   supported = true;
+   else
+   supported = true;
+   }
+
break;
case ixgbe_media_type_backplane:
supported = true;
@@ -200,9 +211,10 @@ bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
break;
}

-   ERROR_REPORT2(IXGBE_ERROR_UNSUPPORTED,
- "Device %x does not support flow control autoneg",
- hw->device_id);
+   if (!supported)
+   ERROR_REPORT2(IXGBE_ERROR_UNSUPPORTED,
+ "Device %x does not support flow control autoneg",
+ hw->device_id);
return supported;
 }

@@ -397,8 +409,8 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)

/* Setup flow control */
ret_val = ixgbe_setup_fc(hw);
-   if (ret_val != IXGBE_SUCCESS)
-   goto out;
+   if (ret_val != IXGBE_SUCCESS && ret_val != IXGBE_NOT_IMPLEMENTED)
+   return ret_val;

/* Cache bit indicating need for crosstalk fix */
switch (hw->mac.type) {
@@ -419,8 +431,7 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
/* Clear adapter stopped flag */
hw->adapter_stopped = false;

-out:
-   return ret_val;
+   return IXGBE_SUCCESS;
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 8c2479b..87d4302 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -660,7 +660,7 @@ s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)

switch (mac->ops.get_media_type(hw)) {
case ixgbe_media_type_fiber:
-   mac->ops.setup_fc = ixgbe_setup_fc_fiber_x550em_a;
+   mac->ops.setup_fc = NULL;
mac->ops.fc_autoneg = ixgbe_fc_autoneg_fiber_x550em_a;
break;
case ixgbe_media_type_backplane:
@@ -906,20 +906,20 @@ STATIC s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_KR:
case IXGBE_DEV_ID_X550EM_A_KR_L:
status = hw->mac.ops.read_iosf_sb_reg(hw,
-IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
+   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+   IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
if (status != IXGBE_SUCCESS)
return status;

link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
-   IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
+   IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;

/* Don

[dpdk-dev] [PATCH 33/39] net/ixgbe/base: add X550em_a FW ALEF support

2016-08-28 Thread Xiao Wang
This patch adds X550em_a FW ALEF support for B0 per DCR 64. ALEF is
the new unified FW. The driver uses the KRM_PMD_RX_FLEX_PORT/
FLX_MASK_ST20 registers to configure the lane mode.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_type.h |  16 +++
 drivers/net/ixgbe/base/ixgbe_x550.c | 223 ++--
 2 files changed, 180 insertions(+), 59 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index a3cc5e2..92c3e24 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4162,9 +4162,25 @@ struct ixgbe_hw {
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
 #define IXGBE_KRM_RX_TRN_LINKUP_CTRL(P)((P) ? 0x8B00 : 0x4B00)
 #define IXGBE_KRM_PMD_DFX_BURNIN(P)((P) ? 0x8E00 : 0x4E00)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20(P) ((P) ? 0x9054 : 0x5054)
 #define IXGBE_KRM_TX_COEFF_CTRL_1(P)   ((P) ? 0x9520 : 0x5520)
 #define IXGBE_KRM_RX_ANA_CTL(P)((P) ? 0x9A00 : 0x5A00)

+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_DA ~(0x3 << 20)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_SR (1u << 20)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_LR (0x2 << 20)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN   (1u << 25)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN(1u << 26)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN  (1u << 27)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_10M  ~(0x7 << 28)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_100M (1u << 28)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G   (0x2 << 28)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_10G  (0x3 << 28)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN   (0x4 << 28)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_2_5G (0x7 << 28)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK (0x7 << 28)
+#define IXGBE_KRM_PMD_FLX_MASK_ST20_FW_AN_RESTART  (1u << 31)
+
 #define IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B   (1 << 9)
 #define IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS (1 << 11)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 19a554d..0cc7a3f 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1607,6 +1607,53 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
 }

 /**
+*  ixgbe_restart_an_internal_phy_x550em - restart autonegotiation for the
+*  internal PHY
+*  @hw: pointer to hardware structure
+**/
+STATIC s32 ixgbe_restart_an_internal_phy_x550em(struct ixgbe_hw *hw)
+{
+   s32 status;
+   u32 link_ctrl;
+
+   /* Restart auto-negotiation. */
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
+  IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, _ctrl);
+
+   if (status) {
+   DEBUGOUT("Auto-negotiation did not complete\n");
+   return status;
+   }
+
+   link_ctrl |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
+   status = hw->mac.ops.write_iosf_sb_reg(hw,
+   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+   IXGBE_SB_IOSF_TARGET_KR_PHY, link_ctrl);
+
+   if (hw->mac.type == ixgbe_mac_X550EM_a) {
+   u32 flx_mask_st20;
+
+   /* Indicate to FW that AN restart has been asserted */
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
+   IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
+   IXGBE_SB_IOSF_TARGET_KR_PHY, _mask_st20);
+
+   if (status) {
+   DEBUGOUT("Auto-negotiation did not complete\n");
+   return status;
+   }
+
+   flx_mask_st20 |= IXGBE_KRM_PMD_FLX_MASK_ST20_FW_AN_RESTART;
+   status = hw->mac.ops.write_iosf_sb_reg(hw,
+   IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
+   IXGBE_SB_IOSF_TARGET_KR_PHY, flx_mask_st20);
+   }
+
+   return status;
+}
+
+/**
  * ixgbe_setup_sgmii - Set up link for sgmii
  * @hw: pointer to hardware structure
  */
@@ -1614,7 +1661,7 @@ STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, 
ixgbe_link_speed speed,
 bool autoneg_wait)
 {
struct ixgbe_mac_info *mac = >mac;
-   u32 lval, sval;
+   u32 lval, sval, flx_val;
s32 rc;

rc = mac->ops.read_iosf_sb_reg(hw,
@@ -1648,10 +1695,25 @@ STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, 
ixgbe_link_speed speed,
if (rc)
return rc;

-   lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
+   rc = mac->ops.read_iosf_sb_reg(hw,
+  

[dpdk-dev] [PATCH 32/39] net/ixgbe/base: separate ops init from PHY init

2016-08-28 Thread Xiao Wang
This patch moves PHY ops pointers initialization to
ixgbe_init_phy_ops_X550em and PHY identifying/initializing
to ixgbe_identify_phy_x550em.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 39 -
 1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index f2e885c..19a554d 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed 
*speed);
 STATIC s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
 STATIC void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
+STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw);

 /**
  *  ixgbe_init_ops_X550 - Inits func ptrs and MAC type
@@ -428,18 +429,15 @@ STATIC s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw 
*hw, u32 reg_addr,
  */
 STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
 {
+   hw->mac.ops.set_lan_id(hw);
+
+   ixgbe_read_mng_if_sel_x550em(hw);
+
switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_A_SFP:
-   hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
-   hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
-   if (hw->bus.lan_id)
-   hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
-   else
-   hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
return ixgbe_identify_module_generic(hw);
case IXGBE_DEV_ID_X550EM_X_SFP:
/* set up for CS4227 usage */
-   hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
ixgbe_setup_mux_ctl(hw);
ixgbe_check_cs4227(hw);
/* Fallthrough */
@@ -456,9 +454,6 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
hw->phy.type = ixgbe_phy_x550em_kr;
break;
case IXGBE_DEV_ID_X550EM_A_10G_T:
-   hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
-   hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
-   /* Fallthrough to ixgbe_identify_phy_generic */
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_X_1G_T:
@@ -2339,10 +2334,6 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)

DEBUGFUNC("ixgbe_init_phy_ops_X550em");

-   hw->mac.ops.set_lan_id(hw);
-
-   ixgbe_read_mng_if_sel_x550em(hw);
-
if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
ixgbe_setup_mux_ctl(hw);
@@ -2354,6 +2345,26 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi_22;
phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi_22;
+   hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
+   hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
+   if (hw->bus.lan_id)
+   hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
+   else
+   hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
+
+   break;
+   case IXGBE_DEV_ID_X550EM_A_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_SFP:
+   hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
+   hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
+   if (hw->bus.lan_id)
+   hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
+   else
+   hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
+   break;
+   case IXGBE_DEV_ID_X550EM_X_SFP:
+   /* set up for CS4227 usage */
+   hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
break;
default:
break;
-- 
1.9.3



[dpdk-dev] [PATCH 31/39] net/ixgbe/base: unify link speed value

2016-08-28 Thread Xiao Wang
This patch changes the value of IXGBE_LINK_SPEED_10_FULL from 4 to 2,
as 4 is reserved to 100Mbit Half Duplex in E1000 shared code.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index f1e4274..a3cc5e2 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3319,7 +3319,7 @@ typedef u32 ixgbe_autoneg_advertised;
 /* Link speed */
 typedef u32 ixgbe_link_speed;
 #define IXGBE_LINK_SPEED_UNKNOWN   0
-#define IXGBE_LINK_SPEED_10_FULL   0x0004
+#define IXGBE_LINK_SPEED_10_FULL   0x0002
 #define IXGBE_LINK_SPEED_100_FULL  0x0008
 #define IXGBE_LINK_SPEED_1GB_FULL  0x0020
 #define IXGBE_LINK_SPEED_2_5GB_FULL0x0400
-- 
1.9.3



[dpdk-dev] [PATCH 29/39] net/ixgbe/base: report autoneg supported for X550

2016-08-28 Thread Xiao Wang
Make sure ixgbe_device_supports_autoneg_fc() returns true for the device
IDs of Seabrook and Shady Acres.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index bc12bc1..9776ab9 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -189,6 +189,8 @@ bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550T1:
case IXGBE_DEV_ID_X550EM_X_10G_T:
case IXGBE_DEV_ID_X550EM_A_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_1G_T:
+   case IXGBE_DEV_ID_X550EM_A_1G_T_L:
supported = true;
break;
default:
-- 
1.9.3



[dpdk-dev] [PATCH 28/39] net/ixgbe/base: reduce delay for SWFW semaphore

2016-08-28 Thread Xiao Wang
This patch reduces the SWFW semaphore/PHY Token retry delay.

ixgbe_release_swfw_sync_X540: Reduce 5 ms delay after releasing
semaphore to 2 ms. HW team indicated 1 ms delay would be sufficient
for FW access.

ixgbe_acquire_swfw_sync_X540: Remove 5 ms delay after acquiring
semaphore.

ixgbe_acquire_swfw_sync_X550a: Remove 5 ms delay since there are
two 2 ms delays in the semaphore release flow.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_x540.c | 4 ++--
 drivers/net/ixgbe/base/ixgbe_x550.c | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c 
b/drivers/net/ixgbe/base/ixgbe_x540.c
index 24e9c93..6e778bc 100644
--- a/drivers/net/ixgbe/base/ixgbe_x540.c
+++ b/drivers/net/ixgbe/base/ixgbe_x540.c
@@ -271,6 +271,7 @@ mac_reset_top:
if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
/* Save the SAN MAC RAR index */
hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;
+
hw->mac.ops.set_rar(hw, hw->mac.san_mac_rar_index,
hw->mac.san_addr, 0, IXGBE_RAH_AV);

@@ -783,7 +784,6 @@ s32 ixgbe_acquire_swfw_sync_X540(struct ixgbe_hw *hw, u32 
mask)
IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw),
swfw_sync);
ixgbe_release_swfw_sync_semaphore(hw);
-   msec_delay(5);
return IXGBE_SUCCESS;
}
/* Firmware currently using resource (fwmask), hardware
@@ -860,7 +860,7 @@ void ixgbe_release_swfw_sync_X540(struct ixgbe_hw *hw, u32 
mask)
IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw), swfw_sync);

ixgbe_release_swfw_sync_semaphore(hw);
-   msec_delay(5);
+   msec_delay(2);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 32759cc..f2e885c 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -4523,7 +4523,6 @@ STATIC s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw 
*hw, u32 mask)
ixgbe_release_swfw_sync_X540(hw, hmask);
if (status != IXGBE_ERR_TOKEN_RETRY)
return status;
-   msec_delay(FW_PHY_TOKEN_DELAY);
}

return status;
-- 
1.9.3



[dpdk-dev] [PATCH 27/39] net/ixgbe/base: commonize mailbox write and read

2016-08-28 Thread Xiao Wang
ixgbevf_write_msg_read_ack() is now performing mailbox write and read,
so this patch use this function to commonize mailbox write and read.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_vf.c | 31 +++
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_vf.c 
b/drivers/net/ixgbe/base/ixgbe_vf.c
index f60ff7d..919b975 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.c
+++ b/drivers/net/ixgbe/base/ixgbe_vf.c
@@ -346,7 +346,6 @@ STATIC s32 ixgbevf_write_msg_read_ack(struct ixgbe_hw *hw, 
u32 *msg,
 s32 ixgbe_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 u32 enable_addr)
 {
-   struct ixgbe_mbx_info *mbx = >mbx;
u32 msgbuf[3];
u8 *msg_addr = (u8 *)([1]);
s32 ret_val;
@@ -355,10 +354,7 @@ s32 ixgbe_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 
*addr, u32 vmdq,
memset(msgbuf, 0, 12);
msgbuf[0] = IXGBE_VF_SET_MAC_ADDR;
memcpy(msg_addr, addr, 6);
-   ret_val = mbx->ops.write_posted(hw, msgbuf, 3, 0);
-
-   if (!ret_val)
-   ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
+   ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 3);

msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;

@@ -429,7 +425,6 @@ s32 ixgbe_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 
*mc_addr_list,
  **/
 s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
 {
-   struct ixgbe_mbx_info *mbx = >mbx;
u32 msgbuf[2];
s32 err;

@@ -444,11 +439,7 @@ s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int 
xcast_mode)
msgbuf[0] = IXGBE_VF_UPDATE_XCAST_MODE;
msgbuf[1] = xcast_mode;

-   err = mbx->ops.write_posted(hw, msgbuf, 2, 0);
-   if (err)
-   return err;
-
-   err = mbx->ops.read_posted(hw, msgbuf, 2, 0);
+   err = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
if (err)
return err;

@@ -465,11 +456,12 @@ s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int 
xcast_mode)
  *  @vind: unused by VF drivers
  *  @vlan_on: if true then set bit, else clear bit
  *  @vlvf_bypass: boolean flag indicating updating default pool is okay
+ *
+ *  Turn on/off specified VLAN in the VLAN filter table.
  **/
 s32 ixgbe_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
  bool vlan_on, bool vlvf_bypass)
 {
-   struct ixgbe_mbx_info *mbx = >mbx;
u32 msgbuf[2];
s32 ret_val;
UNREFERENCED_2PARAMETER(vind, vlvf_bypass);
@@ -479,10 +471,7 @@ s32 ixgbe_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 
vind,
/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
msgbuf[0] |= vlan_on << IXGBE_VT_MSGINFO_SHIFT;

-   ret_val = mbx->ops.write_posted(hw, msgbuf, 2, 0);
-   if (!ret_val)
-   ret_val = mbx->ops.read_posted(hw, msgbuf, 1, 0);
-
+   ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
if (!ret_val && (msgbuf[0] & IXGBE_VT_MSGTYPE_ACK))
return IXGBE_SUCCESS;

@@ -697,11 +686,8 @@ int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int 
api)
msg[0] = IXGBE_VF_API_NEGOTIATE;
msg[1] = api;
msg[2] = 0;
-   err = hw->mbx.ops.write_posted(hw, msg, 3, 0);
-
-   if (!err)
-   err = hw->mbx.ops.read_posted(hw, msg, 3, 0);

+   err = ixgbevf_write_msg_read_ack(hw, msg, msg, 3);
if (!err) {
msg[0] &= ~IXGBE_VT_MSGTYPE_CTS;

@@ -736,11 +722,8 @@ int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int 
*num_tcs,
/* Fetch queue configuration from the PF */
msg[0] = IXGBE_VF_GET_QUEUES;
msg[1] = msg[2] = msg[3] = msg[4] = 0;
-   err = hw->mbx.ops.write_posted(hw, msg, 5, 0);
-
-   if (!err)
-   err = hw->mbx.ops.read_posted(hw, msg, 5, 0);

+   err = ixgbevf_write_msg_read_ack(hw, msg, msg, 5);
if (!err) {
msg[0] &= ~IXGBE_VT_MSGTYPE_CTS;

-- 
1.9.3



[dpdk-dev] [PATCH 26/39] net/ixgbe/base: add missing FDIRSCTPM mask setting

2016-08-28 Thread Xiao Wang
This patch adds missing FDIRSCTPM mask setting for tunneled packets.
It should be set the same way as FDIRTCPM and FDIRUDPM so that SCTP
packets can be filtered correctly.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_82599.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_82599.c 
b/drivers/net/ixgbe/base/ixgbe_82599.c
index 5bc7c2b..832242e 100644
--- a/drivers/net/ixgbe/base/ixgbe_82599.c
+++ b/drivers/net/ixgbe/base/ixgbe_82599.c
@@ -1178,6 +1178,7 @@ mac_reset_top:
if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
/* Save the SAN MAC RAR index */
hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;
+
hw->mac.ops.set_rar(hw, hw->mac.san_mac_rar_index,
hw->mac.san_addr, 0, IXGBE_RAH_AV);

@@ -1809,14 +1810,23 @@ s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
}
IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIP6M, fdirip6m);

-   /* Set all bits in FDIRTCPM, FDIRUDPM, FDIRSIP4M and
-* FDIRDIP4M in cloud mode to allow L3/L3 packets to
-* tunnel.
+   /* Set all bits in FDIRTCPM, FDIRUDPM, FDIRSCTPM,
+* FDIRSIP4M and FDIRDIP4M in cloud mode to allow
+* L3/L3 packets to tunnel.
 */
IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM, 0x);
IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM, 0x);
IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRDIP4M, 0x);
IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIP4M, 0x);
+   switch (hw->mac.type) {
+   case ixgbe_mac_X550:
+   case ixgbe_mac_X550EM_x:
+   case ixgbe_mac_X550EM_a:
+   IXGBE_WRITE_REG(hw, IXGBE_FDIRSCTPM, 0x);
+   break;
+   default:
+   break;
+   }
}

/* Now mask VM pool and destination IPv6 - bits 5 and 2 */
-- 
1.9.3



[dpdk-dev] [PATCH 25/39] net/ixgbe/base: set default autoneg speed at reset

2016-08-28 Thread Xiao Wang
This patch avoids the situation where we initialize adapter and not
yet set up phy.autoneg_advertised speeds. In that case we could end
up in having no autoneg speeds enabled and get no link until we
reset link and set autoneg speeds correctly.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 3c19326..32759cc 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -2283,6 +2283,12 @@ STATIC s32 ixgbe_reset_phy_m88(struct ixgbe_hw *hw)

hw->mac.ops.release_swfw_sync(hw, mask);

+   /* In case of first reset set advertised speeds to default value */
+   if (!hw->phy.autoneg_advertised)
+   hw->phy.autoneg_advertised = IXGBE_LINK_SPEED_1GB_FULL |
+IXGBE_LINK_SPEED_100_FULL |
+IXGBE_LINK_SPEED_10_FULL;
+
return ixgbe_setup_m88(hw);

 out:
-- 
1.9.3



[dpdk-dev] [PATCH 24/39] net/ixgbe/base: use default check link function

2016-08-28 Thread Xiao Wang
This patch removes X550em_a specific check link function and use default
ixgbe_check_mac_link_generic for it. It is not necessary to check both the
MAC link register and external PHY registers when checking link.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_common.c |  7 
 drivers/net/ixgbe/base/ixgbe_type.h   |  1 +
 drivers/net/ixgbe/base/ixgbe_x550.c   | 78 ---
 3 files changed, 16 insertions(+), 70 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 3c3272e..bc12bc1 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4173,6 +4173,13 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, 
ixgbe_link_speed *speed,
*speed = IXGBE_LINK_SPEED_5GB_FULL;
}
break;
+   case IXGBE_LINKS_SPEED_10_X550EM_A:
+   *speed = IXGBE_LINK_SPEED_UNKNOWN;
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T ||
+   hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) {
+   *speed = IXGBE_LINK_SPEED_10_FULL;
+   }
+   break;
default:
*speed = IXGBE_LINK_SPEED_UNKNOWN;
}
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 70f684c..f1e4274 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -2213,6 +2213,7 @@ enum {
 #define IXGBE_LINKS_SPEED_10G_825990x3000
 #define IXGBE_LINKS_SPEED_1G_82599 0x2000
 #define IXGBE_LINKS_SPEED_100_825990x1000
+#define IXGBE_LINKS_SPEED_10_X550EM_A  0x
 #define IXGBE_LINK_UP_TIME 90 /* 9.0 Seconds */
 #define IXGBE_AUTO_NEG_TIME45 /* 4.5 Seconds */

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index a9f4d2a..3c19326 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1716,72 +1716,6 @@ STATIC s32 ixgbe_setup_sgmii_m88(struct ixgbe_hw *hw, 
ixgbe_link_speed speed,
 }

 /**
- * ixgbe_check_link_m88 - Poll PHY for link
- * @hw: pointer to hardware structure
- * @speed: pointer to link speed
- * @link_up: true when link is up
- * @link_up_wait: bool indicating whether to wait for link
- *
- * Check that both the MAC and PHY have link.
- */
-static s32
-ixgbe_check_link_m88(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
-bool *link_up, bool link_up_wait)
-{
-   u16 reg;
-   s32 rc;
-   u32 i;
-
-   rc = ixgbe_check_mac_link_generic(hw, speed, link_up, link_up_wait);
-   if (rc || !*link_up)
-   return rc;
-
-   rc = hw->phy.ops.read_reg(hw, IXGBE_M88E1500_PHY_SPEC_STATUS, 0, );
-
-   /* MAC link is up, so check external PHY link */
-   *link_up = !!(reg & IXGBE_M88E1500_PHY_SPEC_STATUS_LINK);
-
-   if (link_up_wait) {
-   for (i = 0; i < IXGBE_AUTO_NEG_TIME; i++) {
-   if (!rc &&
-   (reg & IXGBE_M88E1500_PHY_SPEC_STATUS_LINK)) {
-   *link_up = true;
-   break;
-   }
-   *link_up = false;
-   msec_delay(100);
-   rc = hw->phy.ops.read_reg(hw,
-IXGBE_M88E1500_PHY_SPEC_STATUS,
-0, );
-   }
-   }
-
-#define M88_SPEED(x) (IXGBE_M88E1500_PHY_SPEC_STATUS_RESOLVED  | \
- IXGBE_M88E1500_PHY_SPEC_STATUS_DUPLEX | \
- ((IXGBE_M88E1500_PHY_SPEC_STATUS_SPEED_##x) <<\
-   IXGBE_M88E1500_PHY_SPEC_STATUS_SPEED_SHIFT))
-
-   reg &= M88_SPEED(MASK);
-   switch (reg) {
-   case M88_SPEED(10):
-   *speed = IXGBE_LINK_SPEED_10_FULL;
-   break;
-   case M88_SPEED(100):
-   *speed = IXGBE_LINK_SPEED_100_FULL;
-   break;
-   case M88_SPEED(1000):
-   *speed = IXGBE_LINK_SPEED_1GB_FULL;
-   break;
-   default:
-   *speed = IXGBE_LINK_SPEED_UNKNOWN;
-   break;
-   }
-#undef M88_SPEED
-
-   return rc;
-}
-
-/**
  *  ixgbe_init_mac_link_ops_X550em - init mac link function pointers
  *  @hw: pointer to hardware structure
  */
@@ -1811,10 +1745,14 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
ixgbe_setup_mac_link_sfp_x550em;
break;
case ixgbe_media_type_copper:
-   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T ||
-   hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) {
-   mac->ops.setup_link = ixgbe_setup_sgmii_m88;
-   mac->ops.chec

[dpdk-dev] [PATCH 23/39] net/ixgbe/base: add bound check in LED functions

2016-08-28 Thread Xiao Wang
Do parameter check to prevent exceptional value being written into
register.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 15 ++-
 drivers/net/ixgbe/base/ixgbe_x540.c   |  6 ++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 1c7263d..3c3272e 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -1133,6 +1133,9 @@ s32 ixgbe_led_on_generic(struct ixgbe_hw *hw, u32 index)

DEBUGFUNC("ixgbe_led_on_generic");

+   if (index > 3)
+   return IXGBE_ERR_PARAM;
+
/* To turn on the LED, set mode to ON. */
led_reg &= ~IXGBE_LED_MODE_MASK(index);
led_reg |= IXGBE_LED_ON << IXGBE_LED_MODE_SHIFT(index);
@@ -1153,6 +1156,9 @@ s32 ixgbe_led_off_generic(struct ixgbe_hw *hw, u32 index)

DEBUGFUNC("ixgbe_led_off_generic");

+   if (index > 3)
+   return IXGBE_ERR_PARAM;
+
/* To turn off the LED, set mode to OFF. */
led_reg &= ~IXGBE_LED_MODE_MASK(index);
led_reg |= IXGBE_LED_OFF << IXGBE_LED_MODE_SHIFT(index);
@@ -3341,7 +3347,7 @@ s32 prot_autoc_write_generic(struct ixgbe_hw *hw, u32 
reg_val, bool locked)
  **/
 s32 ixgbe_enable_sec_rx_path_generic(struct ixgbe_hw *hw)
 {
-   int secrxreg;
+   u32 secrxreg;

DEBUGFUNC("ixgbe_enable_sec_rx_path_generic");

@@ -3388,6 +3394,9 @@ s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, 
u32 index)

DEBUGFUNC("ixgbe_blink_led_start_generic");

+   if (index > 3)
+   return IXGBE_ERR_PARAM;
+
/*
 * Link must be up to auto-blink the LEDs;
 * Force it if link is down.
@@ -3433,6 +3442,10 @@ s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, 
u32 index)

DEBUGFUNC("ixgbe_blink_led_stop_generic");

+   if (index > 3)
+   return IXGBE_ERR_PARAM;
+
+
ret_val = hw->mac.ops.prot_autoc_read(hw, , _reg);
if (ret_val != IXGBE_SUCCESS)
goto out;
diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c 
b/drivers/net/ixgbe/base/ixgbe_x540.c
index 31dead0..24e9c93 100644
--- a/drivers/net/ixgbe/base/ixgbe_x540.c
+++ b/drivers/net/ixgbe/base/ixgbe_x540.c
@@ -982,6 +982,9 @@ s32 ixgbe_blink_led_start_X540(struct ixgbe_hw *hw, u32 
index)

DEBUGFUNC("ixgbe_blink_led_start_X540");

+   if (index > 3)
+   return IXGBE_ERR_PARAM;
+
/*
 * Link should be up in order for the blink bit in the LED control
 * register to work. Force link and speed in the MAC if link is down.
@@ -1016,6 +1019,9 @@ s32 ixgbe_blink_led_stop_X540(struct ixgbe_hw *hw, u32 
index)
u32 macc_reg;
u32 ledctl_reg;

+   if (index > 3)
+   return IXGBE_ERR_PARAM;
+
DEBUGFUNC("ixgbe_blink_led_stop_X540");

/* Restore the LED to its default value. */
-- 
1.9.3



[dpdk-dev] [PATCH 22/39] net/ixgbe/base: add macros for GENEVE UDP port

2016-08-28 Thread Xiao Wang
X550em_a adds GENEVE support by using the upper 16 bits of VXLANCTRL
to store the UDP port (VXLANCTRL.GENEVE_UDP_PORT).

This patch adds definitions that can be used to manipulate the ports
depending on which protocol is being configured.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 262f656..70f684c 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -565,6 +565,13 @@ struct ixgbe_thermal_sensor_data {
 #define IXGBE_PROXYFC  0x05F64 /* Proxying Filter Control Register */
 #define IXGBE_VXLANCTRL0x507C /* Rx filter VXLAN UDPPORT Register 
*/

+/* masks for accessing VXLAN and GENEVE UDP ports */
+#define IXGBE_VXLANCTRL_VXLAN_UDPPORT_MASK 0x /* VXLAN port */
+#define IXGBE_VXLANCTRL_GENEVE_UDPPORT_MASK0x /* GENEVE port */
+#define IXGBE_VXLANCTRL_ALL_UDPPORT_MASK   0x /* GENEVE/VXLAN */
+
+#define IXGBE_VXLANCTRL_GENEVE_UDPPORT_SHIFT   16
+
 #define IXGBE_FHFT(_n) (0x09000 + ((_n) * 0x100)) /* Flex host filter table */
 /* Ext Flexible Host Filter Table */
 #define IXGBE_FHFT_EXT(_n) (0x09800 + ((_n) * 0x100))
@@ -2785,6 +2792,7 @@ enum {
 #define IXGBE_RXDADV_PKTTYPE_UDP   0x0200 /* UDP hdr present */
 #define IXGBE_RXDADV_PKTTYPE_SCTP  0x0400 /* SCTP hdr present */
 #define IXGBE_RXDADV_PKTTYPE_NFS   0x0800 /* NFS hdr present */
+#define IXGBE_RXDADV_PKTTYPE_GENEVE0x0800 /* GENEVE hdr present */
 #define IXGBE_RXDADV_PKTTYPE_VXLAN 0x0800 /* VXLAN hdr present */
 #define IXGBE_RXDADV_PKTTYPE_TUNNEL0x0001 /* Tunnel type */
 #define IXGBE_RXDADV_PKTTYPE_IPSEC_ESP 0x1000 /* IPSec ESP */
-- 
1.9.3



[dpdk-dev] [PATCH 21/39] net/ixgbe/base: support X550em_a SGMII FC autoneg

2016-08-28 Thread Xiao Wang
Create FC (flow control) setup and enable FC function with code to
configure the PHY registers to advertize FC settings according to the
user requested settings and to negotiate the same with the link partner
and arrive at a negotiated setting (RX and TX enabled, TX only enabled,
FC disabled and RX enabled (which also enables TX) ). Remove the part of
code that performs FC auto-negotiation (AN) in ixgbe_setup_m88 and put it
in a new function to maintain consistency with other FC AN implementations
so far.  Add function pointers to the setup-fc and enable-fc functions so
that they get called during init to perform FC AN.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 172 
 drivers/net/ixgbe/base/ixgbe_x550.h |   2 +
 2 files changed, 158 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index c8873ee..a9f4d2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -676,6 +676,12 @@ s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
break;
}

+   if ((hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T) ||
+   (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L)) {
+   mac->ops.fc_autoneg = ixgbe_fc_autoneg_sgmii_x550em_a;
+   mac->ops.setup_fc = ixgbe_setup_fc_sgmii_x550em_a;
+   }
+
return ret_val;
 }

@@ -2182,27 +2188,15 @@ STATIC s32 ixgbe_setup_m88(struct ixgbe_hw *hw)
rc = hw->phy.ops.read_reg_mdi(hw, IXGBE_M88E1500_COPPER_AN, 0, );
if (rc)
goto out;
-   reg &= ~IXGBE_M88E1500_COPPER_AN_AS_PAUSE;
-   reg &= ~IXGBE_M88E1500_COPPER_AN_PAUSE;
reg &= ~IXGBE_M88E1500_COPPER_AN_T4;
reg &= ~IXGBE_M88E1500_COPPER_AN_100TX_FD;
reg &= ~IXGBE_M88E1500_COPPER_AN_100TX_HD;
reg &= ~IXGBE_M88E1500_COPPER_AN_10TX_FD;
reg &= ~IXGBE_M88E1500_COPPER_AN_10TX_HD;
-   switch (hw->fc.current_mode) {
-   case ixgbe_fc_full:
-   reg |= IXGBE_M88E1500_COPPER_AN_PAUSE;
-   break;
-   case ixgbe_fc_rx_pause:
-   reg |= IXGBE_M88E1500_COPPER_AN_PAUSE;
-   reg |= IXGBE_M88E1500_COPPER_AN_AS_PAUSE;
-   break;
-   case ixgbe_fc_tx_pause:
-   reg |= IXGBE_M88E1500_COPPER_AN_AS_PAUSE;
-   break;
-   default:
-   break;
-   }
+
+   /* Flow control auto negotiation configuration was moved from here to
+* the function ixgbe_setup_fc_sgmii_x550em_a()
+*/

if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
reg |= IXGBE_M88E1500_COPPER_AN_100TX_FD;
@@ -4122,6 +4116,152 @@ out:
 }

 /**
+ *  ixgbe_fc_autoneg_sgmii_x550em_a - Enable flow control IEEE clause 37
+ *  @hw: pointer to hardware structure
+ *
+ *  Enable flow control according to IEEE clause 37.
+ **/
+void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
+{
+   s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
+   u16 reg, pcs_an_lp, pcs_an;
+   ixgbe_link_speed speed;
+   bool link_up;
+
+   /* AN should have completed when the cable was plugged in.
+* Look for reasons to bail out.  Bail out if:
+* - FC autoneg is disabled, or if
+* - link is not up.
+*/
+   if (hw->fc.disable_fc_autoneg) {
+   ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
+"Flow control autoneg is disabled");
+   goto out;
+   }
+
+   hw->mac.ops.check_link(hw, , _up, false);
+   if (!link_up) {
+   ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
+   goto out;
+   }
+
+   /* Check if auto-negotiation has completed */
+   status = hw->phy.ops.read_reg(hw, IXGBE_M88E1500_COPPER_STATUS,
+   IXGBE_MDIO_ZERO_DEV_TYPE, );
+   if (status != IXGBE_SUCCESS ||
+   (reg & IXGBE_M88E1500_COPPER_STATUS_AN_DONE) == 0) {
+   DEBUGOUT("Auto-Negotiation did not complete\n");
+   status = IXGBE_ERR_FC_NOT_NEGOTIATED;
+   goto out;
+   }
+
+   /* Get the advertized flow control */
+   status = hw->phy.ops.read_reg(hw, IXGBE_M88E1500_COPPER_AN,
+   IXGBE_MDIO_ZERO_DEV_TYPE, _an);
+   if (status != IXGBE_SUCCESS)
+   goto out;
+
+   /* Get link partner's flow control */
+   status = hw->phy.ops.read_reg(hw,
+   IXGBE_M88E1500_COPPER_AN_LP_ABILITY,
+   IXGBE_MDIO_ZERO_DEV_TYPE, _an_lp);
+   if (status != IXGBE_SUCCESS)
+   goto out;
+
+   /* Negotiate the flow control */
+   status = ixgbe_negotiate_fc(hw, (u32)pcs_an, (u32)pcs_an_lp,
+  

[dpdk-dev] [PATCH 20/39] net/ixgbe/base: bypass checking link for crosstalk

2016-08-28 Thread Xiao Wang
When HW starts, first read the NVM to see if the crosstalk fix should
be used on the given HW and cache that information in the HW structure.

When we check_link we first see if 1) NVM requests this fix 2) if
we are an SFP+ device 3) see if a module is not in the SFP+ cage.
If all the above are true then don't bother checking the link, just
say it is down.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 72 +++
 drivers/net/ixgbe/base/ixgbe_type.h   |  1 +
 2 files changed, 73 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index e46af23..1c7263d 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -372,6 +372,7 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
 {
s32 ret_val;
u32 ctrl_ext;
+   u16 device_caps;

DEBUGFUNC("ixgbe_start_hw_generic");

@@ -397,6 +398,22 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
if (ret_val != IXGBE_SUCCESS)
goto out;

+   /* Cache bit indicating need for crosstalk fix */
+   switch (hw->mac.type) {
+   case ixgbe_mac_82599EB:
+   case ixgbe_mac_X550EM_x:
+   case ixgbe_mac_X550EM_a:
+   hw->mac.ops.get_device_caps(hw, _caps);
+   if (device_caps & IXGBE_DEVICE_CAPS_NO_CROSSTALK_WR)
+   hw->need_crosstalk_fix = false;
+   else
+   hw->need_crosstalk_fix = true;
+   break;
+   default:
+   hw->need_crosstalk_fix = false;
+   break;
+   }
+
/* Clear adapter stopped flag */
hw->adapter_stopped = false;

@@ -4026,6 +4043,32 @@ s32 ixgbe_clear_vfta_generic(struct ixgbe_hw *hw)
 }

 /**
+ *  ixgbe_need_crosstalk_fix - Determine if we need to do cross talk fix
+ *  @hw: pointer to hardware structure
+ *
+ *  Contains the logic to identify if we need to verify link for the
+ *  crosstalk fix
+ **/
+static bool ixgbe_need_crosstalk_fix(struct ixgbe_hw *hw)
+{
+
+   /* Does FW say we need the fix */
+   if (!hw->need_crosstalk_fix)
+   return false;
+
+   /* Only consider SFP+ PHYs i.e. media type fiber */
+   switch (hw->mac.ops.get_media_type(hw)) {
+   case ixgbe_media_type_fiber:
+   case ixgbe_media_type_fiber_qsfp:
+   break;
+   default:
+   return false;
+   }
+
+   return true;
+}
+
+/**
  *  ixgbe_check_mac_link_generic - Determine link and speed status
  *  @hw: pointer to hardware structure
  *  @speed: pointer to link speed
@@ -4042,6 +4085,35 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, 
ixgbe_link_speed *speed,

DEBUGFUNC("ixgbe_check_mac_link_generic");

+   /* If Crosstalk fix enabled do the sanity check of making sure
+* the SFP+ cage is full.
+*/
+   if (ixgbe_need_crosstalk_fix(hw)) {
+   u32 sfp_cage_full;
+
+   switch (hw->mac.type) {
+   case ixgbe_mac_82599EB:
+   sfp_cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) &
+   IXGBE_ESDP_SDP2;
+   break;
+   case ixgbe_mac_X550EM_x:
+   case ixgbe_mac_X550EM_a:
+   sfp_cage_full = IXGBE_READ_REG(hw, IXGBE_ESDP) &
+   IXGBE_ESDP_SDP0;
+   break;
+   default:
+   /* sanity check - No SFP+ devices here */
+   sfp_cage_full = false;
+   break;
+   }
+
+   if (!sfp_cage_full) {
+   *link_up = false;
+   *speed = IXGBE_LINK_SPEED_UNKNOWN;
+   return IXGBE_SUCCESS;
+   }
+   }
+
/* clear the old state */
links_orig = IXGBE_READ_REG(hw, IXGBE_LINKS);

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 1fc7c02..262f656 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4084,6 +4084,7 @@ struct ixgbe_hw {
bool force_full_reset;
bool allow_unsupported_sfp;
bool wol_enabled;
+   bool need_crosstalk_fix;
 };

 #define ixgbe_call_func(hw, func, params, error) \
-- 
1.9.3



[dpdk-dev] [PATCH 19/39] net/ixgbe/base: define X550 PCIe serial MAC addr

2016-08-28 Thread Xiao Wang
Add SERIAL_NUMBER_MAC_ADDR definition for X550.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index f42ebaf..1fc7c02 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -2338,7 +2338,9 @@ enum {

 #define IXGBE_SAN_MAC_ADDR_PTR 0x28
 #define IXGBE_DEVICE_CAPS  0x2C
-#define IXGBE_SERIAL_NUMBER_MAC_ADDR   0x11
+#define IXGBE_82599_SERIAL_NUMBER_MAC_ADDR 0x11
+#define IXGBE_X550_SERIAL_NUMBER_MAC_ADDR  0x04
+
 #define IXGBE_PCIE_MSIX_82599_CAPS 0x72
 #define IXGBE_MAX_MSIX_VECTORS_82599   0x40
 #define IXGBE_PCIE_MSIX_82598_CAPS 0x62
-- 
1.9.3



[dpdk-dev] [PATCH 18/39] net/ixgbe/base: fix check on NACK

2016-08-28 Thread Xiao Wang
Previously we checked only msgbuf[0] for
(IXGBE_VF_SET_MACVLAN |  IXGBE_VT_MSGTYPE_NACK), but this would not
work if index != 0 and as a result NACK will not be detected.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_vf.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_vf.c 
b/drivers/net/ixgbe/base/ixgbe_vf.c
index c0fedea..f60ff7d 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.c
+++ b/drivers/net/ixgbe/base/ixgbe_vf.c
@@ -529,8 +529,7 @@ s32 ixgbe_get_mac_addr_vf(struct ixgbe_hw *hw, u8 *mac_addr)

 s32 ixgbevf_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr)
 {
-   struct ixgbe_mbx_info *mbx = >mbx;
-   u32 msgbuf[3];
+   u32 msgbuf[3], msgbuf_chk;
u8 *msg_addr = (u8 *)([1]);
s32 ret_val;

@@ -543,18 +542,17 @@ s32 ixgbevf_set_uc_addr_vf(struct ixgbe_hw *hw, u32 
index, u8 *addr)
 */
msgbuf[0] |= index << IXGBE_VT_MSGINFO_SHIFT;
msgbuf[0] |= IXGBE_VF_SET_MACVLAN;
+   msgbuf_chk = msgbuf[0];
if (addr)
memcpy(msg_addr, addr, 6);
-   ret_val = mbx->ops.write_posted(hw, msgbuf, 3, 0);

-   if (!ret_val)
-   ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
+   ret_val = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 3);
+   if (!ret_val) {
+   msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;

-   msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;
-
-   if (!ret_val)
-   if (msgbuf[0] == (IXGBE_VF_SET_MACVLAN | IXGBE_VT_MSGTYPE_NACK))
-   ret_val = IXGBE_ERR_OUT_OF_MEM;
+   if (msgbuf[0] == (msgbuf_chk | IXGBE_VT_MSGTYPE_NACK))
+   return IXGBE_ERR_OUT_OF_MEM;
+   }

return ret_val;
 }
-- 
1.9.3



[dpdk-dev] [PATCH 17/39] net/ixgbe/base: access IOSF by host interface

2016-08-28 Thread Xiao Wang
This patch makes sure that we access IOSF registers through the HIC
(host interface command) for the majority of X550em devices. All devices
with NVM are capable of using the HIC.

For consistency all instances where the ixgbe_read/write_iosf_sb_reg_x550
is called directly are converted to function pointer calls.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_phy.c  |  2 +-
 drivers/net/ixgbe/base/ixgbe_x550.c | 38 ++---
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c 
b/drivers/net/ixgbe/base/ixgbe_phy.c
index d33d0f8..ee8618f 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.c
+++ b/drivers/net/ixgbe/base/ixgbe_phy.c
@@ -741,7 +741,7 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 
reg_addr,
DEBUGFUNC("ixgbe_write_phy_reg_generic");

if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
-   status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type,
+   status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
 phy_data);
hw->mac.ops.release_swfw_sync(hw, gssr);
} else {
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index ddd1195..c8873ee 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -652,8 +652,14 @@ s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
/* Start with generic X550EM init */
ret_val = ixgbe_init_ops_X550EM(hw);

-   mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
-   mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
+   hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L) {
+   mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
+   mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
+   } else {
+   mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a;
+   mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a;
+   }
mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;

@@ -2807,24 +2813,25 @@ s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
  **/
 STATIC s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
 {
+   struct ixgbe_mac_info *mac = >mac;
s32 status;
u32 reg_val;

/* Disable training protocol FSM. */
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
+   status = mac->ops.read_iosf_sb_reg(hw,
IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (status != IXGBE_SUCCESS)
return status;
reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
-   status = ixgbe_write_iosf_sb_reg_x550(hw,
+   status = mac->ops.write_iosf_sb_reg(hw,
IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
if (status != IXGBE_SUCCESS)
return status;

/* Disable Flex from training TXFFE. */
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
+   status = mac->ops.read_iosf_sb_reg(hw,
IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (status != IXGBE_SUCCESS)
@@ -2832,12 +2839,12 @@ STATIC s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw 
*hw)
reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
-   status = ixgbe_write_iosf_sb_reg_x550(hw,
+   status = mac->ops.write_iosf_sb_reg(hw,
IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
if (status != IXGBE_SUCCESS)
return status;
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
+   status = mac->ops.read_iosf_sb_reg(hw,
IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (status != IXGBE_SUCCESS)
@@ -2845,14 +2852,14 @@ STATIC s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw 
*hw)
reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
-   status = ixgbe_write_iosf_sb_reg_x550(hw,
+   status = mac->ops.write_iosf_sb_reg(hw,
IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan

[dpdk-dev] [PATCH 15/39] net/ixgbe/base: report setting LPE register error

2016-08-28 Thread Xiao Wang
Propagate return value when trying to set the maximum packet length. A
PF driver could return a NACK for this request, and the VF driver will
need to know this.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_vf.c | 24 +---
 drivers/net/ixgbe/base/ixgbe_vf.h |  2 +-
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_vf.c 
b/drivers/net/ixgbe/base/ixgbe_vf.c
index 20a739c..69805f7 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.c
+++ b/drivers/net/ixgbe/base/ixgbe_vf.c
@@ -323,15 +323,16 @@ STATIC s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 
*mc_addr)
return vector;
 }

-STATIC void ixgbevf_write_msg_read_ack(struct ixgbe_hw *hw,
-   u32 *msg, u16 size)
+STATIC s32 ixgbevf_write_msg_read_ack(struct ixgbe_hw *hw, u32 *msg,
+ u32 *retmsg, u16 size)
 {
struct ixgbe_mbx_info *mbx = >mbx;
-   u32 retmsg[IXGBE_VFMAILBOX_SIZE];
s32 retval = mbx->ops.write_posted(hw, msg, size, 0);

-   if (!retval)
-   mbx->ops.read_posted(hw, retmsg, size, 0);
+   if (retval)
+   return retval;
+
+   return mbx->ops.read_posted(hw, retmsg, size, 0);
 }

 /**
@@ -665,13 +666,22 @@ out:
  *  @hw: pointer to the HW structure
  *  @max_size: value to assign to max frame size
  **/
-void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size)
+s32 ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size)
 {
u32 msgbuf[2];
+   s32 retval;

msgbuf[0] = IXGBE_VF_SET_LPE;
msgbuf[1] = max_size;
-   ixgbevf_write_msg_read_ack(hw, msgbuf, 2);
+
+   retval = ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+   if (retval)
+   return retval;
+   if ((msgbuf[0] & IXGBE_VF_SET_LPE) &&
+   (msgbuf[0] & IXGBE_VT_MSGTYPE_NACK))
+   return IXGBE_ERR_MBX;
+
+   return 0;
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_vf.h 
b/drivers/net/ixgbe/base/ixgbe_vf.h
index 624a97d..d288f31 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.h
+++ b/drivers/net/ixgbe/base/ixgbe_vf.h
@@ -134,7 +134,7 @@ s32 ixgbe_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 
*mc_addr_list,
 s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode);
 s32 ixgbe_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
  bool vlan_on, bool vlvf_bypass);
-void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
+s32 ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
 int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api);
 int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
   unsigned int *default_tc);
-- 
1.9.3



[dpdk-dev] [PATCH 14/39] net/ixgbe/base: fix function comments about X550

2016-08-28 Thread Xiao Wang
Some function commets are obviously wrong, this patch rewords them.

Fixes: d2e72774e58c ("ixgbe/base: support X550")
Fixes: 0790adeb5675 ("ixgbe/base: support X550em_a device")

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 08886a7..ddd1195 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1106,8 +1106,8 @@ STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
 }

 /**
- *  ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the 
IOSF
- *  device
+ *  ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register
+ *  of the IOSF device
  *  @hw: pointer to hardware structure
  *  @reg_addr: 32 bit PHY register to write
  *  @device_type: 3 bit device type
@@ -1153,12 +1153,11 @@ out:
 }

 /**
- *  ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the 
IOSF
- *  device
+ *  ixgbe_read_iosf_sb_reg_x550 - Reads specified register of the IOSF device
  *  @hw: pointer to hardware structure
  *  @reg_addr: 32 bit PHY register to write
  *  @device_type: 3 bit device type
- *  @phy_data: Pointer to read data from the register
+ *  @data: Pointer to read data from the register
  **/
 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
   u32 device_type, u32 *data)
@@ -1292,8 +1291,7 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
 }

 /**
- *  ixgbe_read_iosf_sb_reg_x550a - Writes a value to specified register
- *  of the IOSF device.
+ *  ixgbe_read_iosf_sb_reg_x550a - Reads specified register of the IOSF device
  *  @hw: pointer to hardware structure
  *  @reg_addr: 32 bit PHY register to write
  *  @device_type: 3 bit device type
-- 
1.9.3



[dpdk-dev] [PATCH 13/39] net/ixgbe/base: configure DMAC for 10Mb operation

2016-08-28 Thread Xiao Wang
Provide a DMA coalescing configuration for 10Mb link speed.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 2cd5730..08886a7 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -768,6 +768,7 @@ s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)

/* Configure DMA coalescing enabled */
switch (hw->mac.dmac_config.link_speed) {
+   case IXGBE_LINK_SPEED_10_FULL:
case IXGBE_LINK_SPEED_100_FULL:
pb_headroom = IXGBE_DMACRXT_100M;
break;
-- 
1.9.3



[dpdk-dev] [PATCH 12/39] net/ixgbe/base: clear page register in error path

2016-08-28 Thread Xiao Wang
The error exit should at least try to set the page register to 0
since other code will assume that state.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index bf3da10..2cd5730 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -2349,6 +2349,7 @@ STATIC s32 ixgbe_reset_phy_m88(struct ixgbe_hw *hw)
return ixgbe_setup_m88(hw);

 out:
+   hw->phy.ops.write_reg_mdi(hw, IXGBE_M88E1500_PAGE_ADDR, 0, 0);
hw->mac.ops.release_swfw_sync(hw, mask);
return rc;
 }
-- 
1.9.3



[dpdk-dev] [PATCH 11/39] net/ixgbe/base: add FC autoneg for X550em_a fiber

2016-08-28 Thread Xiao Wang
This patch adds a separate function for enabling FC (flow control)
auto-negotiation on X550em_a:

- rename ixgbe_fc_autoneg_x550a() to ixgbe_fc_autoneg_backplane_x550em_a().
- create ixgbe_fc_autoneg_fiber_x550em_a() specifically for fiber.
- add definitions for KRM_PCS_KX_AN_LP register and related bits.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_type.h |  3 ++
 drivers/net/ixgbe/base/ixgbe_x550.c | 85 +++--
 drivers/net/ixgbe/base/ixgbe_x550.h |  3 +-
 3 files changed, 87 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 1d38195..f42ebaf 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4143,6 +4143,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_AN_CNTL_4(P) ((P) ? 0x8238 : 0x4238)
 #define IXGBE_KRM_AN_CNTL_8(P) ((P) ? 0x8248 : 0x4248)
 #define IXGBE_KRM_PCS_KX_AN(P) ((P) ? 0x9918 : 0x5918)
+#define IXGBE_KRM_PCS_KX_AN_LP(P)  ((P) ? 0x991C : 0x591C)
 #define IXGBE_KRM_SGMII_CTRL(P)((P) ? 0x82A0 : 0x42A0)
 #define IXGBE_KRM_LP_BASE_PAGE_HIGH(P) ((P) ? 0x836C : 0x436C)
 #define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
@@ -4174,6 +4175,8 @@ struct ixgbe_hw {
 #define IXGBE_KRM_AN_CNTL_1_ASM_PAUSE  (1 << 29)
 #define IXGBE_KRM_PCS_KX_AN_SYM_PAUSE  (1 << 1)
 #define IXGBE_KRM_PCS_KX_AN_ASM_PAUSE  (1 << 2)
+#define IXGBE_KRM_PCS_KX_AN_LP_SYM_PAUSE   (1 << 2)
+#define IXGBE_KRM_PCS_KX_AN_LP_ASM_PAUSE   (1 << 3)
 #define IXGBE_KRM_AN_CNTL_4_ECSR_AN37_OVER_73  (1 << 29)
 #define IXGBE_KRM_AN_CNTL_8_LINEAR (1 << 0)
 #define IXGBE_KRM_AN_CNTL_8_LIMITING   (1 << 1)
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index b0697aa..bf3da10 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -656,13 +656,14 @@ s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
-   mac->ops.fc_autoneg = ixgbe_fc_autoneg_x550a;

switch (mac->ops.get_media_type(hw)) {
case ixgbe_media_type_fiber:
mac->ops.setup_fc = ixgbe_setup_fc_fiber_x550em_a;
+   mac->ops.fc_autoneg = ixgbe_fc_autoneg_fiber_x550em_a;
break;
case ixgbe_media_type_backplane:
+   mac->ops.fc_autoneg = ixgbe_fc_autoneg_backplane_x550em_a;
mac->ops.setup_fc = ixgbe_setup_fc_backplane_x550em_a;
break;
default:
@@ -3958,12 +3959,12 @@ out:
 }

 /**
- *  ixgbe_fc_autoneg_x550a - Enable flow control IEEE clause 37
+ *  ixgbe_fc_autoneg_backplane_x550em_a - Enable flow control IEEE clause 37
  *  @hw: pointer to hardware structure
  *
  *  Enable flow control according to IEEE clause 37.
  **/
-void ixgbe_fc_autoneg_x550a(struct ixgbe_hw *hw)
+void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *hw)
 {
u32 link_s1, lp_an_page_low, an_cntl_1;
s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
@@ -3995,6 +3996,7 @@ void ixgbe_fc_autoneg_x550a(struct ixgbe_hw *hw)
if (status != IXGBE_SUCCESS ||
(link_s1 & IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE) == 0) {
DEBUGOUT("Auto-Negotiation did not complete\n");
+   status = IXGBE_ERR_FC_NOT_NEGOTIATED;
goto out;
}

@@ -4035,6 +4037,83 @@ out:
 }

 /**
+ *  ixgbe_fc_autoneg_fiber_x550em_a - Enable flow control IEEE clause 37
+ *  @hw: pointer to hardware structure
+ *
+ *  Enable flow control according to IEEE clause 37.
+ **/
+void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *hw)
+{
+   u32 link_s1, pcs_an_lp, pcs_an;
+   s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
+   ixgbe_link_speed speed;
+   bool link_up;
+
+   /* AN should have completed when the cable was plugged in.
+* Look for reasons to bail out.  Bail out if:
+* - FC autoneg is disabled, or if
+* - link is not up.
+*/
+   if (hw->fc.disable_fc_autoneg) {
+   ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
+"Flow control autoneg is disabled");
+   goto out;
+   }
+
+   hw->mac.ops.check_link(hw, , _up, false);
+   if (!link_up) {
+   ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
+   goto out;
+   }
+
+   /* Check if auto-negotiation has completed */
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
+IXGBE_KRM_LINK_S1(hw->bus.lan_id),
+   

[dpdk-dev] [PATCH 10/39] net/ixgbe/base: add FC setup for X550em_a fiber

2016-08-28 Thread Xiao Wang
This patch adds a separate function for setting up FC (flow control)
on X550em_a fiber:

- rename ixgbe_setup_fc_x550a() to ixgbe_setup_fc_backplane_x550em_a().
- create ixgbe_setup_fc_fiber_x550em_a() to configure FC for fiber.
- add definitions for KRM_AN_CNTL_4 and KRM_PCS_KX_AN along with related
  definitions.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_type.h |   6 +-
 drivers/net/ixgbe/base/ixgbe_x550.c | 144 +++-
 drivers/net/ixgbe/base/ixgbe_x550.h |   3 +-
 3 files changed, 147 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index c65d3a3..1d38195 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4140,7 +4140,9 @@ struct ixgbe_hw {
 #define IXGBE_KRM_LINK_S1(P)   ((P) ? 0x8200 : 0x4200)
 #define IXGBE_KRM_LINK_CTRL_1(P)   ((P) ? 0x820C : 0x420C)
 #define IXGBE_KRM_AN_CNTL_1(P) ((P) ? 0x822C : 0x422C)
+#define IXGBE_KRM_AN_CNTL_4(P) ((P) ? 0x8238 : 0x4238)
 #define IXGBE_KRM_AN_CNTL_8(P) ((P) ? 0x8248 : 0x4248)
+#define IXGBE_KRM_PCS_KX_AN(P) ((P) ? 0x9918 : 0x5918)
 #define IXGBE_KRM_SGMII_CTRL(P)((P) ? 0x82A0 : 0x42A0)
 #define IXGBE_KRM_LP_BASE_PAGE_HIGH(P) ((P) ? 0x836C : 0x436C)
 #define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
@@ -4170,7 +4172,9 @@ struct ixgbe_hw {

 #define IXGBE_KRM_AN_CNTL_1_SYM_PAUSE  (1 << 28)
 #define IXGBE_KRM_AN_CNTL_1_ASM_PAUSE  (1 << 29)
-
+#define IXGBE_KRM_PCS_KX_AN_SYM_PAUSE  (1 << 1)
+#define IXGBE_KRM_PCS_KX_AN_ASM_PAUSE  (1 << 2)
+#define IXGBE_KRM_AN_CNTL_4_ECSR_AN37_OVER_73  (1 << 29)
 #define IXGBE_KRM_AN_CNTL_8_LINEAR (1 << 0)
 #define IXGBE_KRM_AN_CNTL_8_LIMITING   (1 << 1)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 0de9238..b0697aa 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -656,9 +656,19 @@ s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
-   mac->ops.setup_fc = ixgbe_setup_fc_x550a;
mac->ops.fc_autoneg = ixgbe_fc_autoneg_x550a;

+   switch (mac->ops.get_media_type(hw)) {
+   case ixgbe_media_type_fiber:
+   mac->ops.setup_fc = ixgbe_setup_fc_fiber_x550em_a;
+   break;
+   case ixgbe_media_type_backplane:
+   mac->ops.setup_fc = ixgbe_setup_fc_backplane_x550em_a;
+   break;
+   default:
+   break;
+   }
+
return ret_val;
 }

@@ -4025,17 +4035,17 @@ out:
 }

 /**
- *  ixgbe_setup_fc_x550em - Set up flow control
+ *  ixgbe_setup_fc_backplane_x550em_a - Set up flow control
  *  @hw: pointer to hardware structure
  *
  *  Called at init time to set up flow control.
  **/
-s32 ixgbe_setup_fc_x550a(struct ixgbe_hw *hw)
+s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *hw)
 {
s32 status = IXGBE_SUCCESS;
u32 an_cntl, link_ctrl = 0;

-   DEBUGFUNC("ixgbe_setup_fc_x550em");
+   DEBUGFUNC("ixgbe_setup_fc_backplane_x550em_a");

/* Validate the requested mode */
if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
@@ -4125,6 +4135,132 @@ s32 ixgbe_setup_fc_x550a(struct ixgbe_hw *hw)
 }

 /**
+ *  ixgbe_setup_fc_fiber_x550em_a - Set up flow control
+ *  @hw: pointer to hardware structure
+ *
+ *  Called at init time to set up flow control.
+ **/
+s32 ixgbe_setup_fc_fiber_x550em_a(struct ixgbe_hw *hw)
+{
+   struct ixgbe_mac_info *mac = >mac;
+   s32 rc = IXGBE_SUCCESS;
+   u32 an_cntl4, lctrl, pcs_an;
+
+   DEBUGFUNC("ixgbe_setup_fc_fiber_x550em_a");
+
+   /* Validate the requested mode */
+   if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
+   ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
+ "ixgbe_fc_rx_pause not valid in strict IEEE 
mode\n");
+   return IXGBE_ERR_INVALID_LINK_SETTINGS;
+   }
+
+   /* Enable clause 37 auto-negotiation in KRM_LINK_CTRL_1 */
+   if (hw->fc.requested_mode == ixgbe_fc_default)
+   hw->fc.requested_mode = ixgbe_fc_full;
+
+   rc = mac->ops.read_iosf_sb_reg(hw,
+  IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, );
+   if (rc)
+   return rc;
+
+   lctrl |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
+   lctrl |= IXGBE_KRM_LINK_CT

[dpdk-dev] [PATCH 09/39] net/ixgbe/base: add macros for VF promiscuous mode

2016-08-28 Thread Xiao Wang
Add new definitions to support VF unicast promiscuous mode which
will be implemented in a later patch.

Besides, rename definitions of subdevice IDs on SFP LOM to make it
easier to distinguish.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 39099d6..c65d3a3 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -105,11 +105,11 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_SUBDEV_ID_82599_560FLR   0x17D0
 #define IXGBE_SUBDEV_ID_82599_ECNA_DP  0x0470
 #define IXGBE_SUBDEV_ID_82599_SP_560FLR0x211B
-#define IXGBE_SUBDEV_ID_82599_LOM_SFP  0x8976
 #define IXGBE_SUBDEV_ID_82599_LOM_SNAP60x2159
 #define IXGBE_SUBDEV_ID_82599_SFP_1OCP 0x000D
 #define IXGBE_SUBDEV_ID_82599_SFP_2OCP 0x0008
-#define IXGBE_SUBDEV_ID_82599_SFP_LOM  0x06EE
+#define IXGBE_SUBDEV_ID_82599_SFP_LOM_OEM1 0x8976
+#define IXGBE_SUBDEV_ID_82599_SFP_LOM_OEM2 0x06EE
 #define IXGBE_DEV_ID_82599_BACKPLANE_FCOE  0x152A
 #define IXGBE_DEV_ID_82599_SFP_FCOE0x1529
 #define IXGBE_DEV_ID_82599_SFP_EM  0x1507
@@ -1766,6 +1766,8 @@ enum {
 #define IXGBE_VT_CTL_POOL_MASK (0x3F << IXGBE_VT_CTL_POOL_SHIFT)

 /* VMOLR bitmasks */
+#define IXGBE_VMOLR_UPE0x0040 /* unicast promiscuous */
+#define IXGBE_VMOLR_VPE0x0080 /* VLAN promiscuous */
 #define IXGBE_VMOLR_AUPE   0x0100 /* accept untagged packets */
 #define IXGBE_VMOLR_ROMPE  0x0200 /* accept packets in MTA tbl */
 #define IXGBE_VMOLR_ROPE   0x0400 /* accept packets in UC tbl */
-- 
1.9.3



[dpdk-dev] [PATCH 08/39] net/ixgbe/base: fully initialize X550em_a 1G PHYs

2016-08-28 Thread Xiao Wang
Fully initialize X550em_a 1G PHYs; move the PHY definitions from
ixgbe_x550.h to ixgbe_phy.h, where they really belong; define
register numbers in decimal because that is how they are in the spec.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_phy.c  |  43 +--
 drivers/net/ixgbe/base/ixgbe_phy.h  |  71 -
 drivers/net/ixgbe/base/ixgbe_type.h |  14 +-
 drivers/net/ixgbe/base/ixgbe_x550.c | 514 
 drivers/net/ixgbe/base/ixgbe_x550.h |  43 ---
 5 files changed, 454 insertions(+), 231 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c 
b/drivers/net/ixgbe/base/ixgbe_phy.c
index 297a335..d33d0f8 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.c
+++ b/drivers/net/ixgbe/base/ixgbe_phy.c
@@ -335,25 +335,33 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
}

-   if (hw->phy.type == ixgbe_phy_unknown) {
-   for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
-   if (ixgbe_probe_phy(hw, phy_addr)) {
-   status = IXGBE_SUCCESS;
-   break;
-   }
-   }
+   if (hw->phy.type != ixgbe_phy_unknown)
+   return IXGBE_SUCCESS;

-   /* Certain media types do not have a phy so an address will not
-* be found and the code will take this path.  Caller has to
-* decide if it is an error or not.
-*/
-   if (status != IXGBE_SUCCESS) {
-   hw->phy.addr = 0;
+   if (hw->phy.nw_mng_if_sel) {
+   phy_addr = (hw->phy.nw_mng_if_sel &
+   IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
+  IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
+   if (ixgbe_probe_phy(hw, phy_addr))
+   return IXGBE_SUCCESS;
+   else
+   return IXGBE_ERR_PHY_ADDR_INVALID;
+   }
+
+   for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
+   if (ixgbe_probe_phy(hw, phy_addr)) {
+   status = IXGBE_SUCCESS;
+   break;
}
-   } else {
-   status = IXGBE_SUCCESS;
}

+   /* Certain media types do not have a phy so an address will not
+* be found and the code will take this path.  Caller has to
+* decide if it is an error or not.
+*/
+   if (status != IXGBE_SUCCESS)
+   hw->phy.addr = 0;
+
return status;
 }

@@ -464,9 +472,11 @@ enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
phy_type = ixgbe_phy_nl;
break;
case X557_PHY_ID:
+   case X557_PHY_ID2:
phy_type = ixgbe_phy_x550em_ext_t;
break;
case IXGBE_M88E1500_E_PHY_ID:
+   case IXGBE_M88E1543_E_PHY_ID:
phy_type = ixgbe_phy_m88;
break;
default:
@@ -894,6 +904,9 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
if (speed & IXGBE_LINK_SPEED_100_FULL)
hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;

+   if (speed & IXGBE_LINK_SPEED_10_FULL)
+   hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10_FULL;
+
/* Setup link based on the new speed settings */
ixgbe_setup_phy_link(hw);

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.h 
b/drivers/net/ixgbe/base/ixgbe_phy.h
index 281f9fa..da14abc 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.h
+++ b/drivers/net/ixgbe/base/ixgbe_phy.h
@@ -92,8 +92,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_CS4227_GLOBAL_ID_MSB 1
 #define IXGBE_CS4227_SCRATCH   2
 #define IXGBE_CS4227_GLOBAL_ID_VALUE   0x03E5
-#define IXGBE_CS4223_PHY_ID0x7003/* Quad port */
-#define IXGBE_CS4227_PHY_ID0x3003/* Dual port */
+#define IXGBE_CS4223_PHY_ID0x7003  /* Quad port */
+#define IXGBE_CS4227_PHY_ID0x3003  /* Dual port */
 #define IXGBE_CS4227_RESET_PENDING 0x1357
 #define IXGBE_CS4227_RESET_COMPLETE0x5AA5
 #define IXGBE_CS4227_RETRIES   15
@@ -154,6 +154,73 @@ POSSIBILITY OF SUCH DAMAGE.
 /* SFP+ SFF-8472 Compliance */
 #define IXGBE_SFF_SFF_8472_UNSUP   0x00

+/* More phy definitions */
+#define IXGBE_M88E1500_COPPER_CTRL 0   /* Page 0 reg */
+#define IXGBE_M88E1500_COPPER_CTRL_RESET   (1u << 15)
+#define IXGBE_M88E1500_COPPER_CTRL_AN_EN   (1u << 12)
+#define IXGBE_M88E1500_COPPER_CTRL_POWER_DOWN  (1u << 11)
+#define IXGBE_M88E1500_COPPER_CTRL_RESTART_AN  (1u << 9)
+#define IXGBE_M88E1500_COPPER_CTRL_FULL_DUPLEX (1u << 8)
+#define IXGBE_M88E1500_COPPER_CTRL_SPEED_MSB   (1u << 6)
+#define IXGBE_M88E1500_COPPER_STATUS   1   /* Page 0 reg */
+#define IXGBE_M88E1

[dpdk-dev] [PATCH 07/39] net/ixgbe/base: separate PHY probe code

2016-08-28 Thread Xiao Wang
Move the PHY probe code into a separate function so that it can be
reused. A subsequent patch will use it for configurations that
provide the PHY address explicitly.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_phy.c | 58 +++---
 1 file changed, 35 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c 
b/drivers/net/ixgbe/base/ixgbe_phy.c
index ed1b14f..297a335 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.c
+++ b/drivers/net/ixgbe/base/ixgbe_phy.c
@@ -283,6 +283,39 @@ s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_probe_phy - Probe a single address for a PHY
+ * @hw: pointer to hardware structure
+ * @phy_addr: PHY address to probe
+ *
+ * Returns true if PHY found
+ */
+static bool ixgbe_probe_phy(struct ixgbe_hw *hw, u16 phy_addr)
+{
+   u16 ext_ability = 0;
+
+   if (!ixgbe_validate_phy_addr(hw, phy_addr))
+   return false;
+
+   if (ixgbe_get_phy_id(hw))
+   return false;
+
+   hw->phy.type = ixgbe_get_phy_type_from_id(hw->phy.id);
+
+   if (hw->phy.type == ixgbe_phy_unknown) {
+   hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
+IXGBE_MDIO_PMA_PMD_DEV_TYPE, _ability);
+   if (ext_ability &
+   (IXGBE_MDIO_PHY_10GBASET_ABILITY |
+IXGBE_MDIO_PHY_1000BASET_ABILITY))
+   hw->phy.type = ixgbe_phy_cu_unknown;
+   else
+   hw->phy.type = ixgbe_phy_generic;
+   }
+
+   return true;
+}
+
+/**
  *  ixgbe_identify_phy_generic - Get physical layer module
  *  @hw: pointer to hardware structure
  *
@@ -291,8 +324,7 @@ s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
 s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
 {
s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
-   u32 phy_addr;
-   u16 ext_ability = 0;
+   u16 phy_addr;

DEBUGFUNC("ixgbe_identify_phy_generic");

@@ -305,27 +337,7 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)

if (hw->phy.type == ixgbe_phy_unknown) {
for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
-   if (ixgbe_validate_phy_addr(hw, phy_addr)) {
-   hw->phy.addr = phy_addr;
-   ixgbe_get_phy_id(hw);
-   hw->phy.type =
-   ixgbe_get_phy_type_from_id(hw->phy.id);
-
-   if (hw->phy.type == ixgbe_phy_unknown) {
-   hw->phy.ops.read_reg(hw,
- IXGBE_MDIO_PHY_EXT_ABILITY,
- IXGBE_MDIO_PMA_PMD_DEV_TYPE,
- _ability);
-   if (ext_ability &
-   (IXGBE_MDIO_PHY_10GBASET_ABILITY |
-IXGBE_MDIO_PHY_1000BASET_ABILITY))
-   hw->phy.type =
-ixgbe_phy_cu_unknown;
-   else
-   hw->phy.type =
-ixgbe_phy_generic;
-   }
-
+   if (ixgbe_probe_phy(hw, phy_addr)) {
status = IXGBE_SUCCESS;
break;
}
-- 
1.9.3



[dpdk-dev] [PATCH 06/39] net/ixgbe/base: introduce new ops init functions

2016-08-28 Thread Xiao Wang
This patch introduces new init_ops functions for X550EM_a and X550EM_x.
This makes it easier to assign function pointers with specific
dependencies (like media type) for each MAC.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_api.c  |  4 +-
 drivers/net/ixgbe/base/ixgbe_api.h  |  2 +
 drivers/net/ixgbe/base/ixgbe_x550.c | 83 ++---
 3 files changed, 64 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 5b721af..094ee52 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -106,8 +106,10 @@ s32 ixgbe_init_shared_code(struct ixgbe_hw *hw)
status = ixgbe_init_ops_X550(hw);
break;
case ixgbe_mac_X550EM_x:
+   status = ixgbe_init_ops_X550EM_x(hw);
+   break;
case ixgbe_mac_X550EM_a:
-   status = ixgbe_init_ops_X550EM(hw);
+   status = ixgbe_init_ops_X550EM_a(hw);
break;
case ixgbe_mac_82599_vf:
case ixgbe_mac_X540_vf:
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index 3aad1da..24c4ae8 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -45,6 +45,8 @@ extern s32 ixgbe_init_ops_82599(struct ixgbe_hw *hw);
 extern s32 ixgbe_init_ops_X540(struct ixgbe_hw *hw);
 extern s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw);
 extern s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw);
+extern s32 ixgbe_init_ops_X550EM_x(struct ixgbe_hw *hw);
+extern s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw);
 extern s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw);

 s32 ixgbe_set_mac_type(struct ixgbe_hw *hw);
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 5c09bfe..db12339 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -604,7 +604,6 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
struct ixgbe_mac_info *mac = >mac;
struct ixgbe_eeprom_info *eeprom = >eeprom;
struct ixgbe_phy_info *phy = >phy;
-   struct ixgbe_link_info *link = >link;
s32 ret_val;

DEBUGFUNC("ixgbe_init_ops_X550EM");
@@ -640,25 +639,6 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
hw->bus.type = ixgbe_bus_type_internal;
mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;

-   if (hw->mac.type == ixgbe_mac_X550EM_x) {
-   mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
-   mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
-   mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
-   mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
-   link->ops.read_link = ixgbe_read_i2c_combined_generic;
-   link->ops.read_link_unlocked =
-   ixgbe_read_i2c_combined_generic_unlocked;
-   link->ops.write_link = ixgbe_write_i2c_combined_generic;
-   link->ops.write_link_unlocked =
-   ixgbe_write_i2c_combined_generic_unlocked;
-   link->addr = IXGBE_CS4227;
-   }
-   if (hw->mac.type == ixgbe_mac_X550EM_a) {
-   mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
-   mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
-   mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
-   mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
-   }

mac->ops.get_media_type = ixgbe_get_media_type_X550em;
mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
@@ -669,10 +649,6 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)

if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
mac->ops.setup_fc = ixgbe_setup_fc_generic;
-   else if (hw->mac.type == ixgbe_mac_X550EM_a) {
-   mac->ops.setup_fc = ixgbe_setup_fc_x550a;
-   mac->ops.fc_autoneg = ixgbe_fc_autoneg_x550a;
-   }
else
mac->ops.setup_fc = ixgbe_setup_fc_X550em;

@@ -706,6 +682,65 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
 }

 /**
+*  ixgbe_init_ops_X550EM_a - Inits func ptrs and MAC type
+*  @hw: pointer to hardware structure
+*
+*  Initialize the function pointers and for MAC type X550EM_a.
+*  Does not touch the hardware.
+**/
+s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
+{
+   struct ixgbe_mac_info *mac = >mac;
+   s32 ret_val;
+
+   DEBUGFUNC("ixgbe_init_ops_X550EM_a");
+
+   /* Start with generic X550EM init */
+   ret_val = ixgbe_init_ops_X550EM(hw);
+
+   mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
+   mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
+   mac->op

[dpdk-dev] [PATCH 05/39] net/ixgbe/base: support VF multicast promiscuous

2016-08-28 Thread Xiao Wang
Currently, VF is limited to 30 multicast addresses. In order to
accommodate more addresses, this patch adds support for VF multicast
promiscuous.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_mbx.h  |  2 +-
 drivers/net/ixgbe/base/ixgbe_type.h |  1 +
 drivers/net/ixgbe/base/ixgbe_vf.c   | 38 
 drivers/net/ixgbe/base/ixgbe_vf.h   |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.c| 43 ++---
 5 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_mbx.h 
b/drivers/net/ixgbe/base/ixgbe_mbx.h
index d775142..c3e301f 100644
--- a/drivers/net/ixgbe/base/ixgbe_mbx.h
+++ b/drivers/net/ixgbe/base/ixgbe_mbx.h
@@ -111,7 +111,7 @@ enum ixgbe_pfvf_api_rev {
 /* mailbox API, version 1.2 VF requests */
 #define IXGBE_VF_GET_RETA  0x0a /* VF request for RETA */
 #define IXGBE_VF_GET_RSS_KEY   0x0b /* get RSS key */
-#define IXGBE_VF_UPDATE_XCAST_MODE 0x0C
+#define IXGBE_VF_UPDATE_XCAST_MODE 0x0c

 /* GET_QUEUES return data indices within the mailbox */
 #define IXGBE_VF_TX_QUEUES 1   /* number of Tx queues supported */
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index b2fdfcd..96b5cbd 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3883,6 +3883,7 @@ struct ixgbe_mac_operations {
s32 (*init_uta_tables)(struct ixgbe_hw *);
void (*set_mac_anti_spoofing)(struct ixgbe_hw *, bool, int);
void (*set_vlan_anti_spoofing)(struct ixgbe_hw *, bool, int);
+   s32 (*update_xcast_mode)(struct ixgbe_hw *, int);

/* Flow Control */
s32 (*fc_enable)(struct ixgbe_hw *);
diff --git a/drivers/net/ixgbe/base/ixgbe_vf.c 
b/drivers/net/ixgbe/base/ixgbe_vf.c
index a75074a..20a739c 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.c
+++ b/drivers/net/ixgbe/base/ixgbe_vf.c
@@ -75,6 +75,7 @@ s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw)
hw->mac.ops.set_uc_addr = ixgbevf_set_uc_addr_vf;
hw->mac.ops.init_rx_addrs = NULL;
hw->mac.ops.update_mc_addr_list = ixgbe_update_mc_addr_list_vf;
+   hw->mac.ops.update_xcast_mode = ixgbevf_update_xcast_mode;
hw->mac.ops.enable_mc = NULL;
hw->mac.ops.disable_mc = NULL;
hw->mac.ops.clear_vfta = NULL;
@@ -419,6 +420,43 @@ s32 ixgbe_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 
*mc_addr_list,
 }

 /**
+ *  ixgbevf_update_xcast_mode - Update Multicast mode
+ *  @hw: pointer to the HW structure
+ *  @xcast_mode: new multicast mode
+ *
+ *  Updates the Multicast Mode of VF.
+ **/
+s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
+{
+   struct ixgbe_mbx_info *mbx = >mbx;
+   u32 msgbuf[2];
+   s32 err;
+
+   switch (hw->api_version) {
+   case ixgbe_mbox_api_12:
+   break;
+   default:
+   return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
+   }
+
+   msgbuf[0] = IXGBE_VF_UPDATE_XCAST_MODE;
+   msgbuf[1] = xcast_mode;
+
+   err = mbx->ops.write_posted(hw, msgbuf, 2, 0);
+   if (err)
+   return err;
+
+   err = mbx->ops.read_posted(hw, msgbuf, 2, 0);
+   if (err)
+   return err;
+
+   msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;
+   if (msgbuf[0] == (IXGBE_VF_UPDATE_XCAST_MODE | IXGBE_VT_MSGTYPE_NACK))
+   return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
+   return IXGBE_SUCCESS;
+}
+
+/**
  *  ixgbe_set_vfta_vf - Set/Unset vlan filter table address
  *  @hw: pointer to the HW structure
  *  @vlan: 12 bit VLAN ID
diff --git a/drivers/net/ixgbe/base/ixgbe_vf.h 
b/drivers/net/ixgbe/base/ixgbe_vf.h
index 8851cb8..624a97d 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.h
+++ b/drivers/net/ixgbe/base/ixgbe_vf.h
@@ -131,6 +131,7 @@ s32 ixgbevf_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, 
u8 *addr);
 s32 ixgbe_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list,
 u32 mc_addr_count, ixgbe_mc_addr_itr,
 bool clear);
+s32 ixgbevf_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode);
 s32 ixgbe_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
  bool vlan_on, bool vlvf_bypass);
 void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index d478a15..7794960 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -7236,51 +7236,12 @@ ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
return ret;
 }

-/* ixgbevf_update_xcast_mode - Update Multicast mode
- * @hw: pointer to the HW structure
- * @netdev: pointer to net device structure
- * @xcast_mode: new multicast mode
- *
- * Updates the Multicast Mode of VF.
- */
-static int ixgbevf_update_xcast_mode(struct ixgbe_hw *hw,
-int xcast_mode)
-{
-   struct ix

[dpdk-dev] [PATCH 04/39] net/ixgbe/base: add X550em_a 10G PHY support

2016-08-28 Thread Xiao Wang
This patch use the shared MDIO functions ixgbe_read_phy_reg_x550a
and ixgbe_write_phy_reg_x550a for X550em_a 10G PHY which supports
flow control auto-negotiation.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 1 +
 drivers/net/ixgbe/base/ixgbe_x550.c   | 5 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 161bf32..e46af23 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -188,6 +188,7 @@ bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550T:
case IXGBE_DEV_ID_X550T1:
case IXGBE_DEV_ID_X550EM_X_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_10G_T:
supported = true;
break;
default:
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 2c80a9b..5c09bfe 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -494,9 +494,12 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_KR_L:
hw->phy.type = ixgbe_phy_x550em_kr;
break;
+   case IXGBE_DEV_ID_X550EM_A_10G_T:
+   hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
+   hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
+   /* Fallthrough to ixgbe_identify_phy_generic */
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_10G_T:
-   case IXGBE_DEV_ID_X550EM_A_10G_T:
return ixgbe_identify_phy_generic(hw);
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
-- 
1.9.3



[dpdk-dev] [PATCH 01/39] net/ixgbe/base: fix delta check for setting VFTA

2016-08-28 Thread Xiao Wang
The delta value rather than vfta_delta pointer should be checked.

Fixes: b978f7b38c14 ("net/ixgbe/base: simplify VLAN management")

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/base/ixgbe_82598.c  | 6 +++---
 drivers/net/ixgbe/base/ixgbe_api.c| 7 ---
 drivers/net/ixgbe/base/ixgbe_common.c | 2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_82598.c 
b/drivers/net/ixgbe/base/ixgbe_82598.c
index db80880..724dcbb 100644
--- a/drivers/net/ixgbe/base/ixgbe_82598.c
+++ b/drivers/net/ixgbe/base/ixgbe_82598.c
@@ -995,19 +995,19 @@ STATIC s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, 
u32 rar, u32 vmdq)
  *  @vlan: VLAN id to write to VLAN filter
  *  @vind: VMDq output index that maps queue to VLAN id in VFTA
  *  @vlan_on: boolean flag to turn on/off VLAN in VFTA
- *  @bypass_vlvf: boolean flag - unused
+ *  @vlvf_bypass: boolean flag - unused
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
 s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,
-bool vlan_on, bool bypass_vlvf)
+bool vlan_on, bool vlvf_bypass)
 {
u32 regindex;
u32 bitindex;
u32 bits;
u32 vftabyte;

-   UNREFERENCED_1PARAMETER(bypass_vlvf);
+   UNREFERENCED_1PARAMETER(vlvf_bypass);

DEBUGFUNC("ixgbe_set_vfta_82598");

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 1786867..5b721af 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1090,7 +1090,7 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on,
   bool vlvf_bypass)
 {
return ixgbe_call_func(hw, hw->mac.ops.set_vfta, (hw, vlan, vind,
- vlan_on, vlvf_bypass), IXGBE_NOT_IMPLEMENTED);
+  vlan_on, vlvf_bypass), IXGBE_NOT_IMPLEMENTED);
 }

 /**
@@ -1100,7 +1100,7 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on,
  *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
  *  @vlan_on: boolean flag to turn on/off VLAN in VLVF
  *  @vfta_delta: pointer to the difference between the current value of VFTA
- *   and the desired value
+ *  and the desired value
  *  @vfta: the desired value of the VFTA
  *  @vlvf_bypass: boolean flag indicating updating the default pool is okay
  *
@@ -1110,7 +1110,7 @@ s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on,
   u32 *vfta_delta, u32 vfta, bool vlvf_bypass)
 {
return ixgbe_call_func(hw, hw->mac.ops.set_vlvf, (hw, vlan, vind,
-   vlan_on, vfta_delta, vfta, vlvf_bypass),
+  vlan_on, vfta_delta, vfta, vlvf_bypass),
   IXGBE_NOT_IMPLEMENTED);
 }

@@ -1659,6 +1659,7 @@ void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw)
hw->mac.ops.init_swfw_sync(hw);
 }

+
 void ixgbe_disable_rx(struct ixgbe_hw *hw)
 {
if (hw->mac.ops.disable_rx)
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 811875a..161bf32 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -3967,7 +3967,7 @@ s32 ixgbe_set_vlvf_generic(struct ixgbe_hw *hw, u32 vlan, 
u32 vind,
 * we run the risk of stray packets leaking into
 * the PF via the default pool
 */
-   if (vfta_delta)
+   if (*vfta_delta)
IXGBE_WRITE_REG(hw, IXGBE_VFTA(vlan / 32), vfta);

/* disable VLVF and clear remaining bit from pool */
-- 
1.9.3



[dpdk-dev] [PATCH 00/39] net/ixgbe: base code update

2016-08-28 Thread Xiao Wang
 Update ixgbe base driver, including the following changes:

 * add X550em_a 10G PHY support
 * add VF multicast promiscuous mode support
 * support flow control auto negotiation for X550em_a 1G PHY
 * add X550em_a FW ALEF support
 * some functional fixes

Xiao Wang (39):
  net/ixgbe/base: fix delta check for setting VFTA
  net/ixgbe/base: remove X550em SFP iXFI setup
  net/ixgbe/base: change endianness of PHY data
  net/ixgbe/base: add X550em_a 10G PHY support
  net/ixgbe/base: support VF multicast promiscuous
  net/ixgbe/base: introduce new ops init functions
  net/ixgbe/base: separate PHY probe code
  net/ixgbe/base: fully initialize X550em_a 1G PHYs
  net/ixgbe/base: add macros for VF promiscuous mode
  net/ixgbe/base: add FC setup for X550em_a fiber
  net/ixgbe/base: add FC autoneg for X550em_a fiber
  net/ixgbe/base: clear page register in error path
  net/ixgbe/base: configure DMAC for 10Mb operation
  net/ixgbe/base: fix function comments about X550
  net/ixgbe/base: report setting LPE register error
  net/ixgbe/base: bump mailbox version
  net/ixgbe/base: access IOSF by host interface
  net/ixgbe/base: fix check on NACK
  net/ixgbe/base: define X550 PCIe serial MAC addr
  net/ixgbe/base: bypass checking link for crosstalk
  net/ixgbe/base: support X550em_a SGMII FC autoneg
  net/ixgbe/base: add macros for GENEVE UDP port
  net/ixgbe/base: add bound check in LED functions
  net/ixgbe/base: use default check link function
  net/ixgbe/base: set default autoneg speed at reset
  net/ixgbe/base: add missing FDIRSCTPM mask setting
  net/ixgbe/base: commonize mailbox write and read
  net/ixgbe/base: reduce delay for SWFW semaphore
  net/ixgbe/base: report autoneg supported for X550
  net/ixgbe/base: remove X550em_a 100Mbps support
  net/ixgbe/base: unify link speed value
  net/ixgbe/base: separate ops init from PHY init
  net/ixgbe/base: add X550em_a FW ALEF support
  net/ixgbe/base: add two MAC ops for Hyper-V
  net/ixgbe/base: hold semaphore for shadow RAM access
  net/ixgbe/base: update X550em_a backplane speed
  net/ixgbe/base: clean code of flow control autoneg
  net/ixgbe/base: do not skip PHY configuration
  net/ixgbe/base: add base driver update brief

 doc/guides/rel_notes/release_16_11.rst |8 +
 drivers/net/ixgbe/base/README  |2 +-
 drivers/net/ixgbe/base/ixgbe_82598.c   |6 +-
 drivers/net/ixgbe/base/ixgbe_82599.c   |   16 +-
 drivers/net/ixgbe/base/ixgbe_api.c |   11 +-
 drivers/net/ixgbe/base/ixgbe_api.h |2 +
 drivers/net/ixgbe/base/ixgbe_common.c  |  258 +--
 drivers/net/ixgbe/base/ixgbe_common.h  |3 +-
 drivers/net/ixgbe/base/ixgbe_mbx.h |7 +-
 drivers/net/ixgbe/base/ixgbe_osdep.h   |1 +
 drivers/net/ixgbe/base/ixgbe_phy.c |  100 ++-
 drivers/net/ixgbe/base/ixgbe_phy.h |   71 +-
 drivers/net/ixgbe/base/ixgbe_type.h|   73 +-
 drivers/net/ixgbe/base/ixgbe_vf.c  |  103 ++-
 drivers/net/ixgbe/base/ixgbe_vf.h  |3 +-
 drivers/net/ixgbe/base/ixgbe_x540.c|   10 +-
 drivers/net/ixgbe/base/ixgbe_x550.c| 1262 +---
 drivers/net/ixgbe/base/ixgbe_x550.h|   61 +-
 drivers/net/ixgbe/ixgbe_ethdev.c   |   43 +-
 19 files changed, 1359 insertions(+), 681 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH 5/5] net/i40e: implement new Rx checksum flag

2016-08-26 Thread Xiao Wang
Add CKSUM_GOOD flag to distinguish a good checksum from an unknown one.

Signed-off-by: Xiao Wang 
---
 drivers/net/i40e/i40e_rxtx.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 554d167..b49d9dc 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -142,8 +142,14 @@ i40e_rxd_error_to_pkt_flags(uint64_t qword)
return flags;
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_IPE_SHIFT)))
flags |= PKT_RX_IP_CKSUM_BAD;
+   else
+   flags |= PKT_RX_IP_CKSUM_GOOD;
+
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_L4E_SHIFT)))
flags |= PKT_RX_L4_CKSUM_BAD;
+   else
+   flags |= PKT_RX_L4_CKSUM_GOOD;
+
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_EIPE_SHIFT)))
flags |= PKT_RX_EIP_CKSUM_BAD;

-- 
1.9.3



[dpdk-dev] [PATCH 4/5] net/ixgbe: implement new Rx checksum flag

2016-08-26 Thread Xiao Wang
Add CKSUM_GOOD flag to distinguish a good checksum from an unknown one.

Signed-off-by: Xiao Wang 
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 8a306b0..d2dc82a 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -1345,7 +1345,9 @@ rx_desc_error_to_pkt_flags(uint32_t rx_status)
 * Bit 30: L4I, L4I integrity error
 */
static uint64_t error_to_pkt_flags_map[4] = {
-   0,  PKT_RX_L4_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD,
+   PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD,
+   PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD,
+   PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_GOOD,
PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD
};
pkt_flags = error_to_pkt_flags_map[(rx_status >>
-- 
1.9.3



[dpdk-dev] [PATCH 3/5] net/e1000: implement new Rx checksum flag

2016-08-26 Thread Xiao Wang
Add CKSUM_GOOD flag to distinguish a good checksum from an unknown one.

Signed-off-by: Xiao Wang 
---
 drivers/net/e1000/igb_rxtx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 9d80a0b..bc33aed 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -748,7 +748,9 @@ rx_desc_error_to_pkt_flags(uint32_t rx_status)
 */

static uint64_t error_to_pkt_flags_map[4] = {
-   0,  PKT_RX_L4_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD,
+   PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD,
+   PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD,
+   PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_GOOD,
PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD
};
return error_to_pkt_flags_map[(rx_status >>
-- 
1.9.3



[dpdk-dev] [PATCH 2/5] net/fm10k: implement new Rx checksum flag

2016-08-26 Thread Xiao Wang
Add CKSUM_GOOD flag to distinguish a good checksum from an unknown one.

Signed-off-by: Xiao Wang 
---
 drivers/net/fm10k/fm10k_rxtx.c | 4 
 drivers/net/fm10k/fm10k_rxtx_vec.c | 7 +--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_rxtx.c b/drivers/net/fm10k/fm10k_rxtx.c
index bf5888b..32cc7ff 100644
--- a/drivers/net/fm10k/fm10k_rxtx.c
+++ b/drivers/net/fm10k/fm10k_rxtx.c
@@ -101,11 +101,15 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const union 
fm10k_rx_desc *d)
(FM10K_RXD_STATUS_IPCS | FM10K_RXD_STATUS_IPE)) ==
(FM10K_RXD_STATUS_IPCS | FM10K_RXD_STATUS_IPE)))
m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+   else
+   m->ol_flags |= PKT_RX_IP_CKSUM_GOOD;

if (unlikely((d->d.staterr &
(FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)) ==
(FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)))
m->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+   else
+   m->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
 }

 uint16_t
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 9ea747e..8c08b44 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -95,8 +95,10 @@ fm10k_desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
const __m128i l3l4cksum_flag = _mm_set_epi8(0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
-   PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD,
-   PKT_RX_IP_CKSUM_BAD, PKT_RX_L4_CKSUM_BAD, 0);
+   (PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD) >> 1,
+   (PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_GOOD) >> 1,
+   (PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_BAD) >> 1,
+   (PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD) >> 1);

const __m128i rxe_flag = _mm_set_epi8(0, 0, 0, 0,
0, 0, 0, 0,
@@ -139,6 +141,7 @@ fm10k_desc_to_olflags_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
/* Process L4/L3 checksum error flags */
cksumflag = _mm_srli_epi16(cksumflag, L3L4EFLAG_SHIFT);
cksumflag = _mm_shuffle_epi8(l3l4cksum_flag, cksumflag);
+   cksumflag = _mm_slli_epi16(cksumflag, 1);
vtag1 = _mm_or_si128(cksumflag, vtag1);

vol.dword = _mm_cvtsi128_si64(vtag1);
-- 
1.9.3



[dpdk-dev] [PATCH 1/5] net/fm10k: add back Rx checksum offload

2016-08-26 Thread Xiao Wang
A previous patch (http://dpdk.org/dev/patchwork/patch/12937/) removed
some necessary lines about Rx checksum by mistake, this patch adds
them back.

Fixes: 6046898f5097 ("net/mbuf: remove unused Rx error flags")

Signed-off-by: Xiao Wang 
---
 drivers/net/fm10k/fm10k_rxtx.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/fm10k/fm10k_rxtx.c b/drivers/net/fm10k/fm10k_rxtx.c
index 5b2d04b..bf5888b 100644
--- a/drivers/net/fm10k/fm10k_rxtx.c
+++ b/drivers/net/fm10k/fm10k_rxtx.c
@@ -96,6 +96,16 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const union 
fm10k_rx_desc *d)

if (d->w.pkt_info & FM10K_RXD_RSSTYPE_MASK)
m->ol_flags |= PKT_RX_RSS_HASH;
+
+   if (unlikely((d->d.staterr &
+   (FM10K_RXD_STATUS_IPCS | FM10K_RXD_STATUS_IPE)) ==
+   (FM10K_RXD_STATUS_IPCS | FM10K_RXD_STATUS_IPE)))
+   m->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+
+   if (unlikely((d->d.staterr &
+   (FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)) ==
+   (FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)))
+   m->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 }

 uint16_t
-- 
1.9.3



[dpdk-dev] [PATCH 0/5] implement new Rx checksum flag

2016-08-26 Thread Xiao Wang
Following http://dpdk.org/dev/patchwork/patch/14941/, this patch set
implements newly defined Rx checksum flag for igb, ixgbe, i40e and fm10k.

Currently, fm10k supports Rx checksum offload in both scalar and vector
pmd, while the other three don't, this patch set keeps the situation.

This patch set has dependency on the following patch:
"mbuf: add new Rx checksum mbuf flags"
(http://dpdk.org/dev/patchwork/patch/14941/)

Xiao Wang (5):
  net/fm10k: add back Rx checksum offload
  net/fm10k: implement new Rx checksum flag
  net/e1000: implement new Rx checksum flag
  net/ixgbe: implement new Rx checksum flag
  net/i40e: implement new Rx checksum flag

 drivers/net/e1000/igb_rxtx.c   |  4 +++-
 drivers/net/fm10k/fm10k_rxtx.c | 14 ++
 drivers/net/fm10k/fm10k_rxtx_vec.c |  7 +--
 drivers/net/i40e/i40e_rxtx.c   |  6 ++
 drivers/net/ixgbe/ixgbe_rxtx.c |  4 +++-
 5 files changed, 31 insertions(+), 4 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH] net/fm10k: fix MAC address remnant in switch

2016-08-05 Thread Xiao Wang
When testpmd quits with two ports, the second port's MAC address
remains in the MAC table of switch manager.

There should be some time for HW to quiesce when closing a port,
otherwise the subsequent port close won't be handled correctly.

This patch adds some delay after turning off a logic port, just as
what the kernel driver does.

Fixes: 8b5c9ec20b7b ("support VMDQ in MAC/VLAN filter")

Reported-by: Xueqin Lin 
Signed-off-by: Xiao Wang 
---
 drivers/net/fm10k/fm10k_ethdev.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 01f4a72..89d99d4 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -52,6 +52,8 @@
 #define MAX_QUERY_SWITCH_STATE_TIMES 10
 /* Wait interval to get switch status */
 #define WAIT_SWITCH_MSG_US10
+/* A period of quiescence for switch */
+#define FM10K_SWITCH_QUIESCE_US 1
 /* Number of chars per uint32 type */
 #define CHARS_PER_UINT32 (sizeof(uint32_t))
 #define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)
@@ -1233,6 +1235,9 @@ fm10k_dev_close(struct rte_eth_dev *dev)
MAX_LPORT_NUM, false);
fm10k_mbx_unlock(hw);

+   /* allow 10ms for device to quiesce */
+   rte_delay_us(FM10K_SWITCH_QUIESCE_US);
+
/* Stop mailbox service first */
fm10k_close_mbx_service(hw);
fm10k_dev_stop(dev);
-- 
1.9.3



[dpdk-dev] [PATCH] net/fm10k: fix RSS hash config

2016-07-21 Thread Xiao Wang
Sometimes app just wants to update the RSS hash function and no RSS key
update is needed, but fm10k pmd will return EINVAL for this case.

If the rss_key is NULL, we don't need to check the rss_key_len.

Fixes: 57033cdf8fdc ("fm10k: add PF RSS")

Reported-by: Xueqin Lin 
Signed-off-by: Xiao Wang 
---
 drivers/net/fm10k/fm10k_ethdev.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 144b2de..01f4a72 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2159,8 +2159,8 @@ fm10k_rss_hash_update(struct rte_eth_dev *dev,

PMD_INIT_FUNC_TRACE();

-   if (rss_conf->rss_key_len < FM10K_RSSRK_SIZE *
-   FM10K_RSSRK_ENTRIES_PER_REG)
+   if (key && (rss_conf->rss_key_len < FM10K_RSSRK_SIZE *
+   FM10K_RSSRK_ENTRIES_PER_REG))
return -EINVAL;

if (hf == 0)
@@ -2202,8 +2202,8 @@ fm10k_rss_hash_conf_get(struct rte_eth_dev *dev,

PMD_INIT_FUNC_TRACE();

-   if (rss_conf->rss_key_len < FM10K_RSSRK_SIZE *
-   FM10K_RSSRK_ENTRIES_PER_REG)
+   if (key && (rss_conf->rss_key_len < FM10K_RSSRK_SIZE *
+   FM10K_RSSRK_ENTRIES_PER_REG))
return -EINVAL;

if (key != NULL)
-- 
1.9.3



[dpdk-dev] [PATCH] net/fm10k: fix FTAG mode on multi-queue

2016-07-15 Thread Xiao Wang
In multi-queue + FTAG use case, we need to turn tx_ftag_en on for all
the Tx queues.

Fixes: 7958b1310d5e ("fm10k: enable FTAG based forwarding")

Reported-by: Ricky Li 
Signed-off-by: Xiao Wang 
---
 drivers/net/fm10k/fm10k_ethdev.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 217853f..144b2de 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2738,10 +2738,8 @@ fm10k_set_tx_function(struct rte_eth_dev *dev)
txq = dev->data->tx_queues[i];
txq->tx_ftag_en = tx_ftag_en;
/* Check if Vector Tx is satisfied */
-   if (fm10k_tx_vec_condition_check(txq)) {
+   if (fm10k_tx_vec_condition_check(txq))
use_sse = 0;
-   break;
-   }
}

if (use_sse) {
-- 
1.9.3