[dpdk-dev] [PATCH 24/24] net/i40e: flush tunnel filters

2016-12-01 Thread Beilei Xing
This patch is to flush all tunnel filters.

Signed-off-by: Beilei Xing <beilei.x...@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 26a8c5a..71d1f37 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -529,6 +529,7 @@ static int i40e_flow_destroy(struct rte_eth_dev *dev,
 struct rte_flow_error *error);
 static int i40e_ethertype_filter_flush(struct i40e_pf *pf);
 static int i40e_macvlan_filter_flush(struct i40e_pf *pf);
+static int i40e_tunnel_filter_flush(struct i40e_pf *pf);
 static int i40e_flow_flush(struct rte_eth_dev *dev,
 struct rte_flow_error *error);
 
@@ -11849,6 +11850,21 @@ i40e_macvlan_filter_flush(struct i40e_pf *pf)
return ret;
 }
 
+/* Flush all tunnel filters */
+static int
+i40e_tunnel_filter_flush(struct i40e_pf *pf)
+{
+   struct i40e_tunnel_filter_list
+   *tunnel_list = >tunnel.tunnel_list;
+   struct i40e_tunnel_filter *f;
+   int ret = 0;
+
+   while ((f = TAILQ_FIRST(tunnel_list)))
+   ret = i40e_dev_destroy_tunnel_filter(pf, f);
+
+   return ret;
+}
+
 static int
 i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 {
@@ -11873,5 +11889,11 @@ i40e_flow_flush(struct rte_eth_dev *dev, struct 
rte_flow_error *error)
return ret;
}
 
+   ret = i40e_tunnel_filter_flush(pf);
+   if (ret) {
+   error->type = RTE_FLOW_ERROR_TYPE_HANDLE;
+   return ret;
+   }
+
return ret;
 }
-- 
2.5.5



[dpdk-dev] [PATCH 17/24] net/i40e: destroy ethertype filter

2016-12-01 Thread Beilei Xing
This patch adds a function to destroy the ethertype filter.
And this patch also adds flow destroy function.

Signed-off-by: Beilei Xing <beilei.x...@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 69 ++
 1 file changed, 69 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index ac93489..a3ed1f0 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -517,6 +517,11 @@ static struct i40e_flow *i40e_flow_create(struct 
rte_eth_dev *dev,
   const struct rte_flow_item *pattern,
   const struct rte_flow_action *actions,
   struct rte_flow_error *error);
+static int i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
+struct i40e_ethertype_filter *filter);
+static int i40e_flow_destroy(struct rte_eth_dev *dev,
+struct rte_flow *flow,
+struct rte_flow_error *error);
 
 struct i40e_flow {
enum rte_filter_type filter_type;
@@ -621,6 +626,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 static const struct rte_flow_ops i40e_flow_ops = {
.validate = i40e_flow_validate,
.create = (void *)i40e_flow_create,
+   .destroy = i40e_flow_destroy,
 };
 
 /* store statistics names and its offset in stats structure */
@@ -11665,3 +11671,66 @@ i40e_flow_create(struct rte_eth_dev *dev,
rte_free(flow);
return NULL;
 }
+
+static int
+i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
+ struct i40e_ethertype_filter *filter)
+{
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+   struct i40e_ethertype_info *ethertype_info = >ethertype;
+   struct i40e_ethertype_filter *node;
+   struct i40e_control_filter_stats stats;
+   uint16_t flags = 0;
+   int ret = 0;
+
+   if (!(filter->flags & RTE_ETHTYPE_FLAGS_MAC))
+   flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC;
+   if (filter->flags & RTE_ETHTYPE_FLAGS_DROP)
+   flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;
+   flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;
+
+   memset(, 0, sizeof(stats));
+   ret = i40e_aq_add_rem_control_packet_filter(hw,
+   filter->input.mac_addr.addr_bytes,
+   filter->input.ether_type,
+   flags, pf->main_vsi->seid,
+   filter->queue, 0, , NULL);
+   if (ret < 0)
+   return ret;
+
+   node = i40e_sw_ethertype_filter_lookup(ethertype_info, >input);
+   if (node)
+   ret = i40e_sw_ethertype_filter_del(pf, node);
+   else
+   return -EINVAL;
+
+   return ret;
+}
+
+static int
+i40e_flow_destroy(struct rte_eth_dev *dev,
+ struct rte_flow *flow,
+ struct rte_flow_error *error)
+{
+   struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+   struct i40e_flow *pmd_flow = (struct i40e_flow *)flow;
+   enum rte_filter_type filter_type = pmd_flow->filter_type;
+   int ret;
+
+   switch (filter_type) {
+   case RTE_ETH_FILTER_ETHERTYPE:
+   ret = i40e_dev_destroy_ethertype_filter(pf,
+   (struct i40e_ethertype_filter *)pmd_flow->rule);
+   break;
+   default:
+   PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
+   filter_type);
+   ret = -EINVAL;
+   break;
+   }
+
+   if (ret)
+   error->type = RTE_FLOW_ERROR_TYPE_HANDLE;
+
+   return ret;
+}
-- 
2.5.5



[dpdk-dev] [PATCH 18/24] net/i40e: destroy macvlan filter

2016-12-01 Thread Beilei Xing
This patch adds a function to destroy the macvlan filter.

Signed-off-by: Beilei Xing <beilei.x...@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index a3ed1f0..fddd46d 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -519,6 +519,9 @@ static struct i40e_flow *i40e_flow_create(struct 
rte_eth_dev *dev,
   struct rte_flow_error *error);
 static int i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
 struct i40e_ethertype_filter *filter);
+static int i40e_dev_destroy_macvlan_filter(struct i40e_pf *pf,
+  struct i40e_vsi *vsi,
+  struct i40e_mac_filter *filter);
 static int i40e_flow_destroy(struct rte_eth_dev *dev,
 struct rte_flow *flow,
 struct rte_flow_error *error);
@@ -11708,6 +11711,29 @@ i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
 }
 
 static int
+i40e_dev_destroy_macvlan_filter(struct i40e_pf *pf,
+   struct i40e_vsi *vsi,
+   struct i40e_mac_filter *filter)
+{
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+   int ret;
+
+   (void)rte_memcpy(hw->mac.addr, hw->mac.perm_addr,
+ETHER_ADDR_LEN);
+   ret = i40e_vsi_delete_mac(vsi, >mac_info.mac_addr);
+   if (ret != I40E_SUCCESS) {
+   PMD_DRV_LOG(ERR, "Failed to delete MAC filter.");
+   return -1;
+   }
+
+   /* Clear device address as it has been removed. */
+   if (is_same_ether_addr(>dev_addr, >mac_info.mac_addr))
+   memset(>dev_addr, 0, sizeof(struct ether_addr));
+
+   return 0;
+}
+
+static int
 i40e_flow_destroy(struct rte_eth_dev *dev,
  struct rte_flow *flow,
  struct rte_flow_error *error)
@@ -11722,6 +11748,10 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
ret = i40e_dev_destroy_ethertype_filter(pf,
(struct i40e_ethertype_filter *)pmd_flow->rule);
break;
+   case RTE_ETH_FILTER_MACVLAN:
+   ret = i40e_dev_destroy_macvlan_filter(pf,
+ pmd_flow->vsi, (struct i40e_mac_filter *)pmd_flow->rule);
+   break;
default:
PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
filter_type);
-- 
2.5.5



[dpdk-dev] [PATCH v3] net/i40e: fix parsing QinQ packets type issue

2016-09-12 Thread Beilei Xing
Previously, PTYPE filed in the RX descriptors is not set properly
for QinQ packets, wrong PTYPE is generated because outer Tag did
not have ORT/PIT configured. Fix this issue by configuring ORT/PIT.
Otherwise, this patch changes bitmask of outer VLAN tag in L2 header
to support RSS and flow director for QinQ.

Fixes: 4861cde46116 ("i40e: new poll mode driver")
Fixes: 4072d503aaa5 ("i40e: fix VLAN bitmasks for input set")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 55c4887..be4b530 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -202,7 +202,7 @@
 /* Source MAC address */
 #define I40E_REG_INSET_L2_SMAC   0x1C00ULL
 /* Outer (S-Tag) VLAN tag in the outer L2 header */
-#define I40E_REG_INSET_L2_OUTER_VLAN 0x0200ULL
+#define I40E_REG_INSET_L2_OUTER_VLAN 0x0400ULL
 /* Inner (C-Tag) or single VLAN tag in the outer L2 header */
 #define I40E_REG_INSET_L2_INNER_VLAN 0x0080ULL
 /* Single VLAN tag in the inner L2 header */
@@ -724,10 +724,6 @@ static struct rte_driver rte_i40e_driver = {
 PMD_REGISTER_DRIVER(rte_i40e_driver, i40e);
 DRIVER_REGISTER_PCI_TABLE(i40e, pci_id_i40e_map);

-/*
- * Initialize registers for flexible payload, which should be set by NVM.
- * This should be removed from code once it is fixed in NVM.
- */
 #ifndef I40E_GLQF_ORT
 #define I40E_GLQF_ORT(_i)(0x00268900 + ((_i) * 4))
 #endif
@@ -735,8 +731,12 @@ DRIVER_REGISTER_PCI_TABLE(i40e, pci_id_i40e_map);
 #define I40E_GLQF_PIT(_i)(0x00268C80 + ((_i) * 4))
 #endif

-static inline void i40e_flex_payload_reg_init(struct i40e_hw *hw)
+static inline void i40e_GLQF_reg_init(struct i40e_hw *hw)
 {
+   /*
+* Initialize registers for flexible payload, which should be set by 
NVM.
+* This should be removed from code once it is fixed in NVM.
+*/
I40E_WRITE_REG(hw, I40E_GLQF_ORT(18), 0x0030);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(19), 0x0030);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(26), 0x002B);
@@ -747,10 +747,12 @@ static inline void i40e_flex_payload_reg_init(struct 
i40e_hw *hw)
I40E_WRITE_REG(hw, I40E_GLQF_ORT(20), 0x0031);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(23), 0x0031);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(63), 0x002D);
-
-   /* GLQF_PIT Registers */
I40E_WRITE_REG(hw, I40E_GLQF_PIT(16), 0x7480);
I40E_WRITE_REG(hw, I40E_GLQF_PIT(17), 0x7440);
+
+   /* Initialize registers for parsing packet type of QinQ */
+   I40E_WRITE_REG(hw, I40E_GLQF_ORT(40), 0x0029);
+   I40E_WRITE_REG(hw, I40E_GLQF_PIT(9), 0x9420);
 }

 #define I40E_FLOW_CONTROL_ETHERTYPE  0x8808
@@ -1005,11 +1007,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
}

/*
-* To work around the NVM issue,initialize registers
-* for flexible payload by software.
-* It should be removed once issues are fixed in NVM.
+* To work around the NVM issue, initialize registers
+* for flexible payload and packet type of QinQ by
+* software. It should be removed once issues are fixed
+* in NVM.
 */
-   i40e_flex_payload_reg_init(hw);
+   i40e_GLQF_reg_init(hw);

/* Initialize the input set for filters (hash and fd) to default value 
*/
i40e_filter_input_set_init(pf);
-- 
2.5.0



[dpdk-dev] [PATCH] net/i40e: fix outer VLAN bitmask for input set

2016-09-12 Thread Beilei Xing
This patch changes bitmask of outer VLAN tag in L2 header to
support RSS and flow director for QinQ.

Fixes: 4072d503aaa5 ("i40e: fix VLAN bitmasks for input set")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 59ff6dc..be4b530 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -202,7 +202,7 @@
 /* Source MAC address */
 #define I40E_REG_INSET_L2_SMAC   0x1C00ULL
 /* Outer (S-Tag) VLAN tag in the outer L2 header */
-#define I40E_REG_INSET_L2_OUTER_VLAN 0x0200ULL
+#define I40E_REG_INSET_L2_OUTER_VLAN 0x0400ULL
 /* Inner (C-Tag) or single VLAN tag in the outer L2 header */
 #define I40E_REG_INSET_L2_INNER_VLAN 0x0080ULL
 /* Single VLAN tag in the inner L2 header */
-- 
2.5.0



[dpdk-dev] [PATCH v2] net/i40e: fix parsing QinQ packets type issue

2016-08-23 Thread Beilei Xing
Previously, PTYPE filed in the RX descriptors is not set properly
for QinQ packets, wrong PTYPE is generated because outer Tag did
not have ORT/PIT configured.
Fix this issue by configuring ORT/PIT.

Fixes: 4861cde46116 ("i40e: new poll mode driver")

Signed-off-by: Beilei Xing 
---
v2 changes:
 Modify function name and add comments.

 drivers/net/i40e/i40e_ethdev.c | 25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 55c4887..59ff6dc 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -724,10 +724,6 @@ static struct rte_driver rte_i40e_driver = {
 PMD_REGISTER_DRIVER(rte_i40e_driver, i40e);
 DRIVER_REGISTER_PCI_TABLE(i40e, pci_id_i40e_map);

-/*
- * Initialize registers for flexible payload, which should be set by NVM.
- * This should be removed from code once it is fixed in NVM.
- */
 #ifndef I40E_GLQF_ORT
 #define I40E_GLQF_ORT(_i)(0x00268900 + ((_i) * 4))
 #endif
@@ -735,8 +731,12 @@ DRIVER_REGISTER_PCI_TABLE(i40e, pci_id_i40e_map);
 #define I40E_GLQF_PIT(_i)(0x00268C80 + ((_i) * 4))
 #endif

-static inline void i40e_flex_payload_reg_init(struct i40e_hw *hw)
+static inline void i40e_GLQF_reg_init(struct i40e_hw *hw)
 {
+   /*
+* Initialize registers for flexible payload, which should be set by 
NVM.
+* This should be removed from code once it is fixed in NVM.
+*/
I40E_WRITE_REG(hw, I40E_GLQF_ORT(18), 0x0030);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(19), 0x0030);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(26), 0x002B);
@@ -747,10 +747,12 @@ static inline void i40e_flex_payload_reg_init(struct 
i40e_hw *hw)
I40E_WRITE_REG(hw, I40E_GLQF_ORT(20), 0x0031);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(23), 0x0031);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(63), 0x002D);
-
-   /* GLQF_PIT Registers */
I40E_WRITE_REG(hw, I40E_GLQF_PIT(16), 0x7480);
I40E_WRITE_REG(hw, I40E_GLQF_PIT(17), 0x7440);
+
+   /* Initialize registers for parsing packet type of QinQ */
+   I40E_WRITE_REG(hw, I40E_GLQF_ORT(40), 0x0029);
+   I40E_WRITE_REG(hw, I40E_GLQF_PIT(9), 0x9420);
 }

 #define I40E_FLOW_CONTROL_ETHERTYPE  0x8808
@@ -1005,11 +1007,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
}

/*
-* To work around the NVM issue,initialize registers
-* for flexible payload by software.
-* It should be removed once issues are fixed in NVM.
+* To work around the NVM issue, initialize registers
+* for flexible payload and packet type of QinQ by
+* software. It should be removed once issues are fixed
+* in NVM.
 */
-   i40e_flex_payload_reg_init(hw);
+   i40e_GLQF_reg_init(hw);

/* Initialize the input set for filters (hash and fd) to default value 
*/
i40e_filter_input_set_init(pf);
-- 
2.5.0



[dpdk-dev] [PATCH] net/i40e: fix parsing QinQ packets type issue

2016-08-19 Thread Beilei Xing
Previously, PTYPE filed in the RX descriptors is not set properly
for QinQ packets, wrong PTYPE is generated because outer Tag did
not have ORT/PIT configured.
Fix this issue by configuring ORT/PIT.

Fixes: 4861cde46116 ("i40e: new poll mode driver")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 55c4887..ba0eca0 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -747,8 +747,10 @@ static inline void i40e_flex_payload_reg_init(struct 
i40e_hw *hw)
I40E_WRITE_REG(hw, I40E_GLQF_ORT(20), 0x0031);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(23), 0x0031);
I40E_WRITE_REG(hw, I40E_GLQF_ORT(63), 0x002D);
+   I40E_WRITE_REG(hw, I40E_GLQF_ORT(40), 0x0029);

/* GLQF_PIT Registers */
+   I40E_WRITE_REG(hw, I40E_GLQF_PIT(9), 0x9420);
I40E_WRITE_REG(hw, I40E_GLQF_PIT(16), 0x7480);
I40E_WRITE_REG(hw, I40E_GLQF_PIT(17), 0x7440);
 }
-- 
2.5.0



[dpdk-dev] [PATCH] net/i40e: fix dropping packets with Ethertype 0x88A8

2016-08-16 Thread Beilei Xing
Refer to FW default setting, Ethertype 0x88A8 is treated as S-TAG,
packects with S-TAG should be received in Port Virtualizer mode,
but Port Virtual mode is not initialized in DPDK. So X710 will
packets with Ethertype 0x88A8.
This patch fixes this issue by turning off S-TAG identification.

Fixes: 4861cde46116 ("i40e: new poll mode driver")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index d0aeb70..55c4887 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -932,6 +932,9 @@ config_floating_veb(struct rte_eth_dev *dev)
}
 }

+#define I40E_L2_TAGS_S_TAG_SHIFT 1
+#define I40E_L2_TAGS_S_TAG_MASK I40E_MASK(0x1, I40E_L2_TAGS_S_TAG_SHIFT)
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -1120,6 +1123,13 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
/* Disable double vlan by default */
i40e_vsi_config_double_vlan(vsi, FALSE);

+   /* Disable S-TAG identification by default */
+   ret = I40E_READ_REG(hw, I40E_PRT_L2TAGSEN);
+   if (ret & I40E_L2_TAGS_S_TAG_MASK) {
+   ret &= ~I40E_L2_TAGS_S_TAG_MASK;
+   I40E_WRITE_REG(hw, I40E_PRT_L2TAGSEN, ret);
+   }
+
if (!vsi->max_macaddrs)
len = ETHER_ADDR_LEN;
else
-- 
2.5.0



[dpdk-dev] [PATCH] examples/tep_term: fix out-of-bounds access

2016-07-05 Thread Beilei Xing
Coverity reported lots of out-of-bounds in function
vxlan_link, these issues should happen when index
port_id evaluates to 2, cause size of arrays is
2 in structure.
Fix this issue by modifying judgement condition, make
sure port_id is less than 2.

Coverity issue: 107121, 107122, 107123, 107124, 107125

Fixes: 4abe471ed6fc ("examples/tep_term: implement VXLAN processing")

Signed-off-by: Beilei Xing 
---
 examples/tep_termination/vxlan_setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/tep_termination/vxlan_setup.c 
b/examples/tep_termination/vxlan_setup.c
index 37575c2..8f1f15b 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -249,7 +249,7 @@ vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m)

struct rte_eth_tunnel_filter_conf tunnel_filter_conf;

-   if (unlikely(portid > VXLAN_N_PORTS)) {
+   if (unlikely(portid >= VXLAN_N_PORTS)) {
RTE_LOG(INFO, VHOST_DATA,
"(%d) WARNING: Not configuring device,"
"as already have %d ports for VXLAN.",
-- 
2.5.0



[dpdk-dev] [PATCH v2 3/3] i40e: fix out-of-bounds access

2016-07-05 Thread Beilei Xing
When calling i40e_flowtype_to_pctype in
i40e_get_hash_filter_global_config and
i40e_set_hash_filter_global_config, function
i40e_flowtype_to_pctype will be possibly
out-of-bounds accessed, because size of callee's array
is 15. So judge flow type before calling
i40e_flowtype_to_pctype.
Meanwhile do the same change in other functions.

Coverity issue: 37793, 37794

Fixes: 782c8c92f13f ("i40e: add hash configuration")
Fixes: f2b2e2354bbd ("i40e: split function for hash and flow director input")
Fixes: 98f055707685 ("i40e: configure input fields for RSS or flow director")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index a1cad37..111a552 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6908,6 +6908,9 @@ i40e_get_hash_filter_global_config(struct i40e_hw *hw,
mask &= ~(1UL << i);
/* Bit set indicats the coresponding flow type is supported */
g_cfg->valid_bit_mask[0] |= (1UL << i);
+   /* if flowtype is invalid, continue */
+   if (!I40E_VALID_FLOW(i))
+   continue;
pctype = i40e_flowtype_to_pctype(i);
reg = i40e_read_rx_ctl(hw, I40E_GLQF_HSYM(pctype));
if (reg & I40E_GLQF_HSYM_SYMH_ENA_MASK)
@@ -6979,6 +6982,9 @@ i40e_set_hash_filter_global_config(struct i40e_hw *hw,
if (!(mask0 & (1UL << i)))
continue;
mask0 &= ~(1UL << i);
+   /* if flowtype is invalid, continue */
+   if (!I40E_VALID_FLOW(i))
+   continue;
pctype = i40e_flowtype_to_pctype(i);
reg = (g_cfg->sym_hash_enable_mask[0] & (1UL << i)) ?
I40E_GLQF_HSYM_SYMH_ENA_MASK : 0;
@@ -7541,13 +7547,11 @@ i40e_hash_filter_inset_select(struct i40e_hw *hw,
return -EINVAL;
}

-   pctype = i40e_flowtype_to_pctype(conf->flow_type);
-   if (pctype == 0 || pctype > I40E_FILTER_PCTYPE_L2_PAYLOAD) {
-   PMD_DRV_LOG(ERR, "Not supported flow type (%u)",
-   conf->flow_type);
+   if (!I40E_VALID_FLOW(conf->flow_type)) {
+   PMD_DRV_LOG(ERR, "invalid flow_type input.");
return -EINVAL;
}
-
+   pctype = i40e_flowtype_to_pctype(conf->flow_type);
ret = i40e_parse_input_set(_set, pctype, conf->field,
   conf->inset_size);
if (ret) {
@@ -7612,12 +7616,11 @@ i40e_fdir_filter_inset_select(struct i40e_pf *pf,
return -EINVAL;
}

-   pctype = i40e_flowtype_to_pctype(conf->flow_type);
-   if (pctype == 0 || pctype > I40E_FILTER_PCTYPE_L2_PAYLOAD) {
-   PMD_DRV_LOG(ERR, "Not supported flow type (%u)",
-   conf->flow_type);
+   if (!I40E_VALID_FLOW(conf->flow_type)) {
+   PMD_DRV_LOG(ERR, "invalid flow_type input.");
return -EINVAL;
}
+   pctype = i40e_flowtype_to_pctype(conf->flow_type);
ret = i40e_parse_input_set(_set, pctype, conf->field,
   conf->inset_size);
if (ret) {
-- 
2.5.0



[dpdk-dev] [PATCH v2 2/3] i40e: fix dereference before null check

2016-07-05 Thread Beilei Xing
Null-checking vsi suggests that it may be null, but it
has be dereferenced before null-checking. So move if
statement to the front of assignment statement.

Coverity: 119265, 119266

Fixes: d0a349409bd7 ("i40e: support AQ based RSS config")
Fixes: 647d1eaf758b ("i40evf: support AQ based RSS config")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c| 7 +--
 drivers/net/i40e/i40e_ethdev_vf.c | 7 +--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 46ae866..a1cad37 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3168,13 +3168,16 @@ i40e_get_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, 
uint16_t lut_size)
 static int
 i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size)
 {
-   struct i40e_pf *pf = I40E_VSI_TO_PF(vsi);
-   struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+   struct i40e_pf *pf;
+   struct i40e_hw *hw;
int ret;

if (!vsi || !lut)
return -EINVAL;

+   pf = I40E_VSI_TO_PF(vsi);
+   hw = I40E_VSI_TO_HW(vsi);
+
if (pf->flags & I40E_FLAG_RSS_AQ_CAPABLE) {
ret = i40e_aq_set_rss_lut(hw, vsi->vsi_id, TRUE,
  lut, lut_size);
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 7b6df1d..d727232 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -2377,13 +2377,16 @@ i40evf_get_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, 
uint16_t lut_size)
 static int
 i40evf_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size)
 {
-   struct i40e_vf *vf = I40E_VSI_TO_VF(vsi);
-   struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+   struct i40e_vf *vf;
+   struct i40e_hw *hw;
int ret;

if (!vsi || !lut)
return -EINVAL;

+   vf = I40E_VSI_TO_VF(vsi);
+   hw = I40E_VSI_TO_HW(vsi);
+
if (vf->flags & I40E_FLAG_RSS_AQ_CAPABLE) {
ret = i40e_aq_set_rss_lut(hw, vsi->vsi_id, FALSE,
  lut, lut_size);
-- 
2.5.0



[dpdk-dev] [PATCH v2 1/3] i40e: fix log error

2016-07-05 Thread Beilei Xing
The condition, "(pf->flags | I40E_FLAG_VMDQ)" will always be true,
regardless of the value of the flags operand, because I40E_FLAG_VMDQ
is 4ULL - meaning at least one bit will always be set in the result.
That will cause log error when VMDq is disabled.
Since the original intent behind the condition is to check if VMDq
is enabled, fix the code by changing "|" to "&".

Coverity issue: 13219, 13221

Fixes: 4805ed59e957 ("i40e: enhance mac address operations")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f414d93..46ae866 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2952,9 +2952,10 @@ i40e_macaddr_add(struct rte_eth_dev *dev,
int ret;

/* If VMDQ not enabled or configured, return */
-   if (pool != 0 && (!(pf->flags | I40E_FLAG_VMDQ) || 
!pf->nb_cfg_vmdq_vsi)) {
+   if (pool != 0 && (!(pf->flags & I40E_FLAG_VMDQ) ||
+ !pf->nb_cfg_vmdq_vsi)) {
PMD_DRV_LOG(ERR, "VMDQ not %s, can't set mac to pool %u",
-   pf->flags | I40E_FLAG_VMDQ ? "configured" : "enabled",
+   pf->flags & I40E_FLAG_VMDQ ? "configured" : "enabled",
pool);
return;
}
@@ -3005,7 +3006,7 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t 
index)
vsi = pf->main_vsi;
else {
/* No VMDQ pool enabled or configured */
-   if (!(pf->flags | I40E_FLAG_VMDQ) ||
+   if (!(pf->flags & I40E_FLAG_VMDQ) ||
(i > pf->nb_cfg_vmdq_vsi)) {
PMD_DRV_LOG(ERR, "No VMDQ pool enabled"
"/configured");
-- 
2.5.0



[dpdk-dev] [PATCH v2 0/3] fix coverity defects

2016-07-05 Thread Beilei Xing
Fix some open coverity defects.

V2 changes:
 Rework commit log.
 Refactor patchset.

Beilei Xing (3):
  i40e: fix log error
  i40e: fix dereference before null check
  i40e: fix out-of-bounds access

 drivers/net/i40e/i40e_ethdev.c| 35 +--
 drivers/net/i40e/i40e_ethdev_vf.c |  7 +--
 2 files changed, 26 insertions(+), 16 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH 4/4] examples/tep_term: fix out-of-bounds access

2016-06-30 Thread Beilei Xing
Coverity reported lots of out-of-bounds in function
vxlan_link, these issues should happen when index
port_id evaluates to 2, cause size of arrays is
2 in structure.
Fix this issue by modifying judgement condition, make
sure port_id is less than 2.

Fixes: 4abe471ed6fc ("examples/tep_term: implement VXLAN processing")

Signed-off-by: Beilei Xing 
---
 examples/tep_termination/vxlan_setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/tep_termination/vxlan_setup.c 
b/examples/tep_termination/vxlan_setup.c
index 37575c2..8f1f15b 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -249,7 +249,7 @@ vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m)

struct rte_eth_tunnel_filter_conf tunnel_filter_conf;

-   if (unlikely(portid > VXLAN_N_PORTS)) {
+   if (unlikely(portid >= VXLAN_N_PORTS)) {
RTE_LOG(INFO, VHOST_DATA,
"(%d) WARNING: Not configuring device,"
"as already have %d ports for VXLAN.",
-- 
2.5.0



[dpdk-dev] [PATCH 3/4] i40e: fix out-of-bounds access

2016-06-30 Thread Beilei Xing
When calling i40e_flowtype_to_pctype in
i40e_get_hash_filter_global_config and
i40e_set_hash_filter_global_config, function
i40e_flowtype_to_pctype will be possibly
out-of-bounds accessed, because size of callee's array
is 15. So judge flow type before calling
i40e_flowtype_to_pctype.
Meanwhile do the same change in other functions.

Fixes: 782c8c92f13f ("i40e: add hash configuration")
Fixes: f2b2e2354bbd ("i40e: split function for hash and flow director input")
Fixes: 98f055707685 ("i40e: configure input fields for RSS or flow director")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 78ed6d0..678e23a 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -6625,6 +6625,9 @@ i40e_get_hash_filter_global_config(struct i40e_hw *hw,
mask &= ~(1UL << i);
/* Bit set indicats the coresponding flow type is supported */
g_cfg->valid_bit_mask[0] |= (1UL << i);
+   /* if flowtype is invalid, continue */
+   if (!I40E_VALID_FLOW(i))
+   continue;
pctype = i40e_flowtype_to_pctype(i);
reg = i40e_read_rx_ctl(hw, I40E_GLQF_HSYM(pctype));
if (reg & I40E_GLQF_HSYM_SYMH_ENA_MASK)
@@ -6696,6 +6699,9 @@ i40e_set_hash_filter_global_config(struct i40e_hw *hw,
if (!(mask0 & (1UL << i)))
continue;
mask0 &= ~(1UL << i);
+   /* if flowtype is invalid, continue */
+   if (!I40E_VALID_FLOW(i))
+   continue;
pctype = i40e_flowtype_to_pctype(i);
reg = (g_cfg->sym_hash_enable_mask[0] & (1UL << i)) ?
I40E_GLQF_HSYM_SYMH_ENA_MASK : 0;
@@ -7258,13 +7264,11 @@ i40e_hash_filter_inset_select(struct i40e_hw *hw,
return -EINVAL;
}

-   pctype = i40e_flowtype_to_pctype(conf->flow_type);
-   if (pctype == 0 || pctype > I40E_FILTER_PCTYPE_L2_PAYLOAD) {
-   PMD_DRV_LOG(ERR, "Not supported flow type (%u)",
-   conf->flow_type);
+   if (!I40E_VALID_FLOW(conf->flow_type)) {
+   PMD_DRV_LOG(ERR, "invalid flow_type input.");
return -EINVAL;
}
-
+   pctype = i40e_flowtype_to_pctype(conf->flow_type);
ret = i40e_parse_input_set(_set, pctype, conf->field,
   conf->inset_size);
if (ret) {
@@ -7329,12 +7333,11 @@ i40e_fdir_filter_inset_select(struct i40e_pf *pf,
return -EINVAL;
}

-   pctype = i40e_flowtype_to_pctype(conf->flow_type);
-   if (pctype == 0 || pctype > I40E_FILTER_PCTYPE_L2_PAYLOAD) {
-   PMD_DRV_LOG(ERR, "Not supported flow type (%u)",
-   conf->flow_type);
+   if (!I40E_VALID_FLOW(conf->flow_type)) {
+   PMD_DRV_LOG(ERR, "invalid flow_type input.");
return -EINVAL;
}
+   pctype = i40e_flowtype_to_pctype(conf->flow_type);
ret = i40e_parse_input_set(_set, pctype, conf->field,
   conf->inset_size);
if (ret) {
-- 
2.5.0



[dpdk-dev] [PATCH 2/4] i40e: fix dereference before null check

2016-06-30 Thread Beilei Xing
Null-checking vsi suggests that it may be null, but it
has be dereferenced before null-checking. So move if
statement to the front of assignment statement.

Fixes: d0a349409bd7 ("i40e: support AQ based RSS config")
Fixes: 647d1eaf758b ("i40evf: support AQ based RSS config")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c| 7 +--
 drivers/net/i40e/i40e_ethdev_vf.c | 7 +--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index eba6481..78ed6d0 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2954,13 +2954,16 @@ i40e_get_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, 
uint16_t lut_size)
 static int
 i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size)
 {
-   struct i40e_pf *pf = I40E_VSI_TO_PF(vsi);
-   struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+   struct i40e_pf *pf;
+   struct i40e_hw *hw;
int ret;

if (!vsi || !lut)
return -EINVAL;

+   pf = I40E_VSI_TO_PF(vsi);
+   hw = I40E_VSI_TO_HW(vsi);
+
if (pf->flags & I40E_FLAG_RSS_AQ_CAPABLE) {
ret = i40e_aq_set_rss_lut(hw, vsi->vsi_id, TRUE,
  lut, lut_size);
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 37af399..e9effc7 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -2378,13 +2378,16 @@ i40evf_get_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, 
uint16_t lut_size)
 static int
 i40evf_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size)
 {
-   struct i40e_vf *vf = I40E_VSI_TO_VF(vsi);
-   struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+   struct i40e_vf *vf;
+   struct i40e_hw *hw;
int ret;

if (!vsi || !lut)
return -EINVAL;

+   vf = I40E_VSI_TO_VF(vsi);
+   hw = I40E_VSI_TO_HW(vsi);
+
if (vf->flags & I40E_FLAG_RSS_AQ_CAPABLE) {
ret = i40e_aq_set_rss_lut(hw, vsi->vsi_id, FALSE,
  lut, lut_size);
-- 
2.5.0



[dpdk-dev] [PATCH 1/4] i40e: fix wrong operator

2016-06-30 Thread Beilei Xing
Previously, (pf->flags | I40E_FLAG_VMDQ) will be always true regardless
of the value of its operand, because I40E_FLAG_VMDQ is 4ULL. But he
original idea should judge if VMDQ is enabled.
Fix this issue with (pf->flags & I40E_FLAG_VMDQ).

Fixes: 4805ed59e957 ("i40e: enhance mac address operations")

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f94ad87..eba6481 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -2738,9 +2738,10 @@ i40e_macaddr_add(struct rte_eth_dev *dev,
int ret;

/* If VMDQ not enabled or configured, return */
-   if (pool != 0 && (!(pf->flags | I40E_FLAG_VMDQ) || 
!pf->nb_cfg_vmdq_vsi)) {
+   if (pool != 0 && (!(pf->flags & I40E_FLAG_VMDQ) ||
+ !pf->nb_cfg_vmdq_vsi)) {
PMD_DRV_LOG(ERR, "VMDQ not %s, can't set mac to pool %u",
-   pf->flags | I40E_FLAG_VMDQ ? "configured" : "enabled",
+   pf->flags & I40E_FLAG_VMDQ ? "configured" : "enabled",
pool);
return;
}
@@ -2791,7 +2792,7 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t 
index)
vsi = pf->main_vsi;
else {
/* No VMDQ pool enabled or configured */
-   if (!(pf->flags | I40E_FLAG_VMDQ) ||
+   if (!(pf->flags & I40E_FLAG_VMDQ) ||
(i > pf->nb_cfg_vmdq_vsi)) {
PMD_DRV_LOG(ERR, "No VMDQ pool enabled"
"/configured");
-- 
2.5.0



[dpdk-dev] [PATCH 0/4] i40e: fix coverity defects

2016-06-30 Thread Beilei Xing
Fix some open coverity defects.

Beilei Xing (4):
  i40e: fix wrong operator
  i40e: fix dereference before null check
  i40e: fix out-of-bounds access
  examples/tep_term: fix out-of-bounds access

 drivers/net/i40e/i40e_ethdev.c | 35 --
 drivers/net/i40e/i40e_ethdev_vf.c  |  7 +--
 examples/tep_termination/vxlan_setup.c |  2 +-
 3 files changed, 27 insertions(+), 17 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v2] examples/l3fwd: update usage and documentation

2016-06-27 Thread Beilei Xing
Update l3fwd example usage and documentation with missing options.

Signed-off-by: Beilei Xing 
---
v2 changes:
 Update l3fwd main.c usage
 Update format in documentation.

 doc/guides/sample_app_ug/l3_forward.rst | 42 ++---
 examples/l3fwd/main.c   | 40 ---
 2 files changed, 54 insertions(+), 28 deletions(-)

diff --git a/doc/guides/sample_app_ug/l3_forward.rst 
b/doc/guides/sample_app_ug/l3_forward.rst
index 491f99d..c885cdb 100644
--- a/doc/guides/sample_app_ug/l3_forward.rst
+++ b/doc/guides/sample_app_ug/l3_forward.rst
@@ -88,32 +88,46 @@ To compile the application:
 Running the Application
 ---

-The application has a number of command line options:
+The application has a number of command line options::

-.. code-block:: console
+./l3fwd [EAL options] -- -p PORTMASK
+ [-P]
+ [-E]
+ [-L]
+ --config(port,queue,lcore)[,(port,queue,lcore)]
+ [--eth-dest=X,MM:MM:MM:MM:MM:MM]
+ [--enable-jumbo [--max-pkt-len PKTLEN]]
+ [--no-numa]
+ [--hash-entry-num]
+ [--ipv6]
+ [--parse-ptype]
+
+Where,
+
+* ``-p PORTMASK:`` Hexadecimal bitmask of ports to configure

-./build/l3fwd [EAL options] -- -p PORTMASK [-P]  
--config(port,queue,lcore)[,(port,queue,lcore)] [--enable-jumbo [--max-pkt-len 
PKTLEN]]  [--no-numa][--hash-entry-num][--ipv6] [--parse-ptype]
+* ``-P:`` Optional, sets all ports to promiscuous mode so that packets are 
accepted regardless of the packet's Ethernet MAC destination address.
+  Without this option, only packets with the Ethernet MAC destination address 
set to the Ethernet address of the port are accepted.

-where,
+* ``-E:`` Optional, enable exact match.

-*   -p PORTMASK: Hexadecimal bitmask of ports to configure
+* ``-L:`` Optional, enable longest prefix match.

-*   -P: optional, sets all ports to promiscuous mode so that packets are 
accepted regardless of the packet's Ethernet MAC destination address.
-Without this option, only packets with the Ethernet MAC destination 
address set to the Ethernet address of the port are accepted.
+* ``--config (port,queue,lcore)[,(port,queue,lcore)]:`` Determines which 
queues from which ports are mapped to which cores.

-*   --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues 
from which ports are mapped to which cores
+* ``--eth-dest=X,MM:MM:MM:MM:MM:MM:`` Optional, ethernet destination for port 
X.

-*   --enable-jumbo: optional, enables jumbo frames
+* ``--enable-jumbo:`` Optional, enables jumbo frames.

-*   --max-pkt-len: optional, maximum packet length in decimal (64-9600)
+* ``--max-pkt-len:`` Optional, under the premise of enabling jumbo, maximum 
packet length in decimal (64-9600).

-*   --no-numa: optional, disables numa awareness
+* ``--no-numa:`` Optional, disables numa awareness.

-*   --hash-entry-num: optional, specifies the hash entry number in hexadecimal 
to be setup
+* ``--hash-entry-num:`` Optional, specifies the hash entry number in 
hexadecimal to be setup.

-*   --ipv6: optional, set it if running ipv6 packets
+* ``--ipv6:`` Optional, set if running ipv6 packets.

-*   --parse-ptype: optional, set it if use software way to analyze packet type
+* ``--parse-ptype:`` Optional, set to use software to analyze packet type. 
Without this option, hardware will check the packet type.

 For example, consider a dual processor socket platform where cores 0-7 and 
16-23 appear on socket 0, while cores 8-15 and 24-31 appear on socket 1.
 Let's say that the programmer wants to use memory from both NUMA nodes, the 
platform has only two ports, one connected to each NUMA node,
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 7a79cd2..acedd20 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -311,20 +311,32 @@ init_lcore_rx_queues(void)
 static void
 print_usage(const char *prgname)
 {
-   printf ("%s [EAL options] -- -p PORTMASK -P"
-   "  [--config (port,queue,lcore)[,(port,queue,lcore]]"
-   "  [--enable-jumbo [--max-pkt-len PKTLEN]]\n"
-   "  -p PORTMASK: hexadecimal bitmask of ports to configure\n"
-   "  -P : enable promiscuous mode\n"
-   "  -E : enable exact match\n"
-   "  -L : enable longest prefix match\n"
-   "  --config (port,queue,lcore): rx queues configuration\n"
-   "  --eth-dest=X,MM:MM:MM:MM:MM:MM: optional, ethernet 
destination for port X\n"
-   "  --no-numa: optional, disable numa awareness\n"
-   "  --ipv6: optional, specify it if running ipv6 packets\n"
-   

[dpdk-dev] [PATCH v4] ixgbe: configure VLAN TPID

2016-06-24 Thread Beilei Xing
Previously, a single VLAN header is treated as inner VLAN,
but generally, a single VLAN header is treated as the outer
VLAN header.
The patch fixes the ether type of a single VLAN type, and
enables configuring inner and outer TPID for double VLAN.

Fixes: 19b16e2f6442 ("ethdev: add vlan type when setting ether type")

Signed-off-by: Beilei Xing 
---
v4 changes:
 Update commit log.
v3 changes:
 Fix inserting vlan tpid issue for Tx.

 drivers/net/ixgbe/ixgbe_ethdev.c | 41 +---
 lib/librte_ether/rte_ethdev.h|  4 ++--
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index e11a431..a5427b4 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -157,6 +157,9 @@ enum ixgbevf_xcast_modes {
IXGBEVF_XCAST_MODE_ALLMULTI,
 };

+#define IXGBE_EXVET_VET_EXT_SHIFT  16
+#define IXGBE_DMATXCTL_VT_MASK 0x
+
 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  ixgbe_dev_configure(struct rte_eth_dev *dev);
@@ -1584,15 +1587,47 @@ ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
struct ixgbe_hw *hw =
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
int ret = 0;
+   uint32_t reg;
+   uint32_t qinq;
+
+   qinq = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
+   qinq &= IXGBE_DMATXCTL_GDV;

switch (vlan_type) {
case ETH_VLAN_TYPE_INNER:
-   /* Only the high 16-bits is valid */
-   IXGBE_WRITE_REG(hw, IXGBE_EXVET, tpid << 16);
+   if (qinq) {
+   reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
+   reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
+   IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
+   reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
+   reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
+   | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
+   IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
+   } else {
+   ret = -ENOTSUP;
+   PMD_DRV_LOG(ERR, "Inner type is not supported"
+   " by single VLAN");
+   }
+   break;
+   case ETH_VLAN_TYPE_OUTER:
+   if (qinq) {
+   /* Only the high 16-bits is valid */
+   IXGBE_WRITE_REG(hw, IXGBE_EXVET, (uint32_t)tpid <<
+   IXGBE_EXVET_VET_EXT_SHIFT);
+   } else {
+   reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
+   reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
+   IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
+   reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
+   reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
+   | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
+   IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
+   }
+
break;
default:
ret = -EINVAL;
-   PMD_DRV_LOG(ERR, "Unsupported vlan type %d\n", vlan_type);
+   PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
break;
}

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 45482f1..d04ddec 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1157,7 +1157,7 @@ typedef int (*vlan_filter_set_t)(struct rte_eth_dev *dev,

 typedef int (*vlan_tpid_set_t)(struct rte_eth_dev *dev,
   enum rte_vlan_type type, uint16_t tpid);
-/**< @internal set the outer VLAN-TPID by an Ethernet device. */
+/**< @internal set the outer/inner VLAN-TPID by an Ethernet device. */

 typedef void (*vlan_offload_set_t)(struct rte_eth_dev *dev, int mask);
 /**< @internal set VLAN offload function by an Ethernet device. */
@@ -1443,7 +1443,7 @@ struct eth_dev_ops {
/**< Get packet types supported and identified by device*/
mtu_set_t  mtu_set; /**< Set MTU. */
vlan_filter_set_t  vlan_filter_set;  /**< Filter VLAN Setup. */
-   vlan_tpid_set_tvlan_tpid_set;  /**< Outer VLAN TPID 
Setup. */
+   vlan_tpid_set_tvlan_tpid_set;  /**< Outer/Inner VLAN 
TPID Setup. */
vlan_strip_queue_set_t vlan_strip_queue_set; /**< VLAN Stripping on 
queue. */
vlan_offload_set_t vlan_offload_set; /**< Set VLAN Offload. */
vlan_pvid_set_tvlan_pvid_set; /**< Set port based TX VLAN 
insertion */
-- 
2.5.0



[dpdk-dev] [PATCH] examples/l3fwd: update documentation

2016-06-23 Thread Beilei Xing
Update l3fwd documentation with -E, -L and --eth-dest options.

Signed-off-by: Beilei Xing 
---
 doc/guides/sample_app_ug/l3_forward.rst | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/doc/guides/sample_app_ug/l3_forward.rst 
b/doc/guides/sample_app_ug/l3_forward.rst
index 491f99d..4ab5149 100644
--- a/doc/guides/sample_app_ug/l3_forward.rst
+++ b/doc/guides/sample_app_ug/l3_forward.rst
@@ -101,8 +101,14 @@ where,
 *   -P: optional, sets all ports to promiscuous mode so that packets are 
accepted regardless of the packet's Ethernet MAC destination address.
 Without this option, only packets with the Ethernet MAC destination 
address set to the Ethernet address of the port are accepted.

+*   -E: enable exact match
+
+*   -L: enable longest prefix match
+
 *   --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues 
from which ports are mapped to which cores

+*   --eth-dest=X,MM:MM:MM:MM:MM:MM: optional, ethernet destination for port X
+
 *   --enable-jumbo: optional, enables jumbo frames

 *   --max-pkt-len: optional, maximum packet length in decimal (64-9600)
@@ -113,7 +119,7 @@ where,

 *   --ipv6: optional, set it if running ipv6 packets

-*   --parse-ptype: optional, set it if use software way to analyze packet type
+*   --parse-ptype: optional, set it if use software way to analyze packet 
type. Without this option, HW will check packet type.

 For example, consider a dual processor socket platform where cores 0-7 and 
16-23 appear on socket 0, while cores 8-15 and 24-31 appear on socket 1.
 Let's say that the programmer wants to use memory from both NUMA nodes, the 
platform has only two ports, one connected to each NUMA node,
-- 
2.5.0



[dpdk-dev] [PATCH v4 29/29] ixgbe/base: update README

2016-06-23 Thread Beilei Xing
The ixgbe base driver was updated refer to version
cid-10g-shared-code.2016.04.12 released by ND.

The changes include:
Added sgmii link for X550.
Added mac link setup for X550a SFP and SFP+.
Added KR support for X550em_a.
Added new phy definitions for M88E1500.
Added support for the VLVF to be bypassed when adding/removing
a VFTA entry.
Added X550a flow control auto negotiation support.

Signed-off-by: Beilei Xing 
---
 doc/guides/rel_notes/release_16_07.rst | 11 +++
 drivers/net/ixgbe/base/README  |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index c714052..0740b99 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -15,6 +15,17 @@ DPDK Release 16.07

   firefox build/doc/html/guides/rel_notes/release_16_07.html

+* **Updated the ixgbe base driver.**
+  The ixgbe base driver was updated with changes including the
+  following:
+
+  * Added sgmii link for X550.
+  * Added mac link setup for X550a SFP and SFP+.
+  * Added KR support for X550em_a.
+  * Added new phy definitions for M88E1500.
+  * Added support for the VLVF to be bypassed when adding/removing a VFTA 
entry.
+  * Added X550a flow control auto negotiation support.
+

 New Features
 
diff --git a/drivers/net/ixgbe/base/README b/drivers/net/ixgbe/base/README
index caa2664..76e7805 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.01.07 released by ND. The sub-directory of base/
+cid-10g-shared-code.2016.04.12 released by ND. The sub-directory of base/
 contains the original source package.
 This driver is valid for the product(s) listed below

-- 
2.5.0



[dpdk-dev] [PATCH v4 28/29] ixgbe/base: define if enable crosstalk work around

2016-06-23 Thread Beilei Xing
A work around for a new crosstalk erratum that causes link flap in
entry cages has been introduced. So this patch defines the bit in
NVM that will tell software if this work around is needed.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index be51bee..83818a9 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -2405,6 +2405,7 @@ enum {
 #define IXGBE_SAN_MAC_ADDR_PORT1_OFFSET0x3
 #define IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP0x1
 #define IXGBE_DEVICE_CAPS_FCOE_OFFLOADS0x2
+#define IXGBE_DEVICE_CAPS_NO_CROSSTALK_WR  (1 << 7)
 #define IXGBE_FW_LESM_PARAMETERS_PTR   0x2
 #define IXGBE_FW_LESM_STATE_1  0x1
 #define IXGBE_FW_LESM_STATE_ENABLED0x8000 /* LESM Enable bit */
-- 
2.5.0



[dpdk-dev] [PATCH v4 27/29] ixgbe/base: add flow control autoneg for X550a

2016-06-23 Thread Beilei Xing
This patch adds X550a flow control auto negotiation support.
ixgbe_setup_fc_x550a and ixgbe_fc_autoneg_X550a functions where
added to setup and enable flow control. MAC ops function pointer
fc_autoneg was added so that hardware specific fc autoneg functions
can be called from ixgbe_fc_enable_generic.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.h|   2 +
 drivers/net/ixgbe/base/ixgbe_common.c |   5 +-
 drivers/net/ixgbe/base/ixgbe_type.h   |   6 ++
 drivers/net/ixgbe/base/ixgbe_x550.c   | 181 ++
 drivers/net/ixgbe/base/ixgbe_x550.h   |   2 +
 5 files changed, 194 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index c126982..3aad1da 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -217,5 +217,7 @@ s32 ixgbe_handle_lasi(struct ixgbe_hw *hw);
 void ixgbe_set_rate_select_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed);
 void ixgbe_disable_rx(struct ixgbe_hw *hw);
 void ixgbe_enable_rx(struct ixgbe_hw *hw);
+s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
+   u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);

 #endif /* _IXGBE_API_H_ */
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index e1d09e2..811875a 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -135,6 +135,7 @@ s32 ixgbe_init_ops_generic(struct ixgbe_hw *hw)
/* Flow Control */
mac->ops.fc_enable = ixgbe_fc_enable_generic;
mac->ops.setup_fc = ixgbe_setup_fc_generic;
+   mac->ops.fc_autoneg = ixgbe_fc_autoneg;

/* Link */
mac->ops.get_link_capabilities = NULL;
@@ -2739,7 +2740,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
}

/* Negotiate the fc mode to use */
-   ixgbe_fc_autoneg(hw);
+   hw->mac.ops.fc_autoneg(hw);

/* Disable any previous flow control settings */
mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
@@ -2849,7 +2850,7 @@ out:
  *  Find the intersection between advertised settings and link partner's
  *  advertised settings
  **/
-STATIC s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
+s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
  u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm)
 {
if ((!(adv_reg)) ||  (!(lp_reg))) {
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 5d76c72..be51bee 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3886,6 +3886,7 @@ struct ixgbe_mac_operations {
/* Flow Control */
s32 (*fc_enable)(struct ixgbe_hw *);
s32 (*setup_fc)(struct ixgbe_hw *);
+   void (*fc_autoneg)(struct ixgbe_hw *);

/* Manageability interface */
s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);
@@ -4131,10 +4132,12 @@ struct ixgbe_hw {
 #define IXGBE_FUSES0_REV_MASK  (3 << 6)

 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
+#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_8(P) ((P) ? 0x8248 : 0x4248)
 #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)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
 #define IXGBE_KRM_RX_TRN_LINKUP_CTRL(P)((P) ? 0x8B00 : 0x4B00)
@@ -4156,6 +4159,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR   (1 << 18)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX  (1 << 24)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR  (1 << 26)
+#define IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE  (1 << 28)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE   (1 << 29)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART  (1 << 31)

@@ -4164,6 +4168,8 @@ struct ixgbe_hw {

 #define IXGBE_KRM_AN_CNTL_8_LINEAR (1 << 0)
 #define IXGBE_KRM_AN_CNTL_8_LIMITING   (1 << 1)
+#define IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE  (1 << 10)
+#define IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE  (1 << 11)

 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index dfa2855..aa6e859 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -666,6 +666,10 @@ s32 ixgbe_init_ops_X5

[dpdk-dev] [PATCH v4 26/29] ixgbe/base: allow setting MAC anti spoofing per VF

2016-06-23 Thread Beilei Xing
Make ixgbe_set_mac_anti_spoofing() consistent with the other
functions that deal with setting VLAN and Ethertype spoofing by
changing the prototype to accept a VF parameter.

Also change the logic for writing the PFVFSPOOF register to be similar
to the MAC and Ethertype functions.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 40 ++-
 drivers/net/ixgbe/base/ixgbe_common.h |  2 +-
 2 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 6e54628..e1d09e2 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4203,43 +4203,25 @@ out:
 /**
  *  ixgbe_set_mac_anti_spoofing - Enable/Disable MAC anti-spoofing
  *  @hw: pointer to hardware structure
- *  @enable: enable or disable switch for anti-spoofing
- *  @pf: Physical Function pool - do not enable anti-spoofing for the PF
+ *  @enable: enable or disable switch for MAC anti-spoofing
+ *  @vf: Virtual Function pool - VF Pool to set for MAC anti-spoofing
  *
  **/
-void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf)
+void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf)
 {
-   int j;
-   int pf_target_reg = pf >> 3;
-   int pf_target_shift = pf % 8;
-   u32 pfvfspoof = 0;
+   int vf_target_reg = vf >> 3;
+   int vf_target_shift = vf % 8;
+   u32 pfvfspoof;

if (hw->mac.type == ixgbe_mac_82598EB)
return;

+   pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
if (enable)
-   pfvfspoof = IXGBE_SPOOF_MACAS_MASK;
-
-   /*
-* PFVFSPOOF register array is size 8 with 8 bits assigned to
-* MAC anti-spoof enables in each register array element.
-*/
-   for (j = 0; j < pf_target_reg; j++)
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), pfvfspoof);
-
-   /*
-* The PF should be allowed to spoof so that it can support
-* emulation mode NICs.  Do not set the bits assigned to the PF
-*/
-   pfvfspoof &= (1 << pf_target_shift) - 1;
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), pfvfspoof);
-
-   /*
-* Remaining pools belong to the PF so they do not need to have
-* anti-spoofing enabled.
-*/
-   for (j++; j < IXGBE_PFVFSPOOF_REG_COUNT; j++)
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), 0);
+   pfvfspoof |= (1 << vf_target_shift);
+   else
+   pfvfspoof &= ~(1 << vf_target_shift);
+   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_common.h 
b/drivers/net/ixgbe/base/ixgbe_common.h
index a790ede..0545f85 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.h
+++ b/drivers/net/ixgbe/base/ixgbe_common.h
@@ -148,7 +148,7 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 
*wwnn_prefix,
 u16 *wwpn_prefix);

 s32 ixgbe_get_fcoe_boot_status_generic(struct ixgbe_hw *hw, u16 *bs);
-void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf);
+void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
 void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
 s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps);
 void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, u32 headroom,
-- 
2.5.0



[dpdk-dev] [PATCH v4 25/29] ixgbe/base: fix endianness issues

2016-06-23 Thread Beilei Xing
This patch fixes endianness issues about host interface command.

Fixes: ad66a85dce9a ("ixgbe/base: new FW values")
Fixes: 0790adeb5675 ("ixgbe/base: support X550em_a device")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_osdep.h |  1 +
 drivers/net/ixgbe/base/ixgbe_type.h  | 17 ++---
 drivers/net/ixgbe/base/ixgbe_x550.c  | 29 -
 3 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_osdep.h 
b/drivers/net/ixgbe/base/ixgbe_osdep.h
index 40b0b51..31cc1be 100644
--- a/drivers/net/ixgbe/base/ixgbe_osdep.h
+++ b/drivers/net/ixgbe/base/ixgbe_osdep.h
@@ -96,6 +96,7 @@ enum {
 #define IXGBE_NTOHL(_i)rte_be_to_cpu_32(_i)
 #define IXGBE_NTOHS(_i)rte_be_to_cpu_16(_i)
 #define IXGBE_CPU_TO_LE32(_i)  rte_cpu_to_le_32(_i)
+#define IXGBE_LE32_TO_CPU(_i) rte_le_to_cpu_32(_i)
 #define IXGBE_LE32_TO_CPUS(_i) rte_le_to_cpu_32(_i)
 #define IXGBE_CPU_TO_BE16(_i)  rte_cpu_to_be_16(_i)
 #define IXGBE_CPU_TO_BE32(_i)  rte_cpu_to_be_32(_i)
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index d91c4ed..5d76c72 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3050,6 +3050,12 @@ enum ixgbe_fdir_pballoc_type {

 /* Host Interface Command Structures */

+#ifdef C99
+#pragma pack(push, 1)
+#else
+#pragma pack(1)
+#endif /* C99 */
+
 struct ixgbe_hic_hdr {
u8 cmd;
u8 buf_len;
@@ -3127,17 +3133,22 @@ struct ixgbe_hic_internal_phy_req {
struct ixgbe_hic_hdr hdr;
u8 port_number;
u8 command_type;
-   u16 address;
+   __be16 address;
u16 rsv1;
-   u32 write_data;
+   __le32 write_data;
u16 pad;
 };

 struct ixgbe_hic_internal_phy_resp {
struct ixgbe_hic_hdr hdr;
-   u32 read_data;
+   __le32 read_data;
 };

+#ifdef C99
+#pragma pack(pop)
+#else
+#pragma pack()
+#endif /* C99 */

 /* Transmit Descriptor - Legacy */
 struct ixgbe_legacy_tx_desc {
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 06b791b..dfa2855 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1273,8 +1273,8 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
write_cmd.port_number = hw->bus.lan_id;
write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
-   write_cmd.address = (u16)reg_addr;
-   write_cmd.write_data = data;
+   write_cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
+   write_cmd.write_data = IXGBE_CPU_TO_LE32(data);

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
  sizeof(write_cmd),
@@ -1294,24 +1294,27 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
 u32 device_type, u32 *data)
 {
-   struct ixgbe_hic_internal_phy_req read_cmd;
+   union {
+   struct ixgbe_hic_internal_phy_req cmd;
+   struct ixgbe_hic_internal_phy_resp rsp;
+   } hic;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

-   memset(_cmd, 0, sizeof(read_cmd));
-   read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
-   read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
-   read_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
-   read_cmd.port_number = hw->bus.lan_id;
-   read_cmd.command_type = FW_INT_PHY_REQ_READ;
-   read_cmd.address = (u16)reg_addr;
+   memset(, 0, sizeof(hic));
+   hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
+   hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
+   hic.cmd.port_number = hw->bus.lan_id;
+   hic.cmd.command_type = FW_INT_PHY_REQ_READ;
+   hic.cmd.address = IXGBE_CPU_TO_BE16(reg_addr);

-   status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
- sizeof(read_cmd),
+   status = ixgbe_host_interface_command(hw, (u32 *),
+ sizeof(hic.cmd),
  IXGBE_HI_COMMAND_TIMEOUT, true);

/* Extract the register value from the response. */
-   *data = ((struct ixgbe_hic_internal_phy_resp *)_cmd)->read_data;
+   *data = IXGBE_LE32_TO_CPU(hic.rsp.read_data);

return status;
 }
-- 
2.5.0



[dpdk-dev] [PATCH v4 24/29] ixgbe/base: use u8 to replace u16 for a variable

2016-06-23 Thread Beilei Xing
Since PCIe standard defines maximum of 8 functions per device lan_id
is a value 0..7. Because of that, lan_id don't need to be u16.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 2 +-
 drivers/net/ixgbe/base/ixgbe_type.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 80ea3b9..6e54628 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -1034,7 +1034,7 @@ void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw)

reg = IXGBE_READ_REG(hw, IXGBE_STATUS);
bus->func = (reg & IXGBE_STATUS_LAN_ID) >> IXGBE_STATUS_LAN_ID_SHIFT;
-   bus->lan_id = bus->func;
+   bus->lan_id = (u8)bus->func;

/* check for a port swap */
reg = IXGBE_READ_REG(hw, IXGBE_FACTPS_BY_MAC(hw));
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 3bf0de0..d91c4ed 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3684,7 +3684,7 @@ struct ixgbe_bus_info {
enum ixgbe_bus_type type;

u16 func;
-   u16 lan_id;
+   u8 lan_id;
u16 instance_id;
 };

-- 
2.5.0



[dpdk-dev] [PATCH v4 23/29] ixgbe/base: unify coding style

2016-06-23 Thread Beilei Xing
This patch changes static keyword to STATIC definition, which can be
redefined depending on the compiler used.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 38 ++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index a38fb50..06b791b 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "ixgbe_phy.h"

 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_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
+STATIC void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);

 /**
  *  ixgbe_init_ops_X550 - Inits func ptrs and MAC type
@@ -335,7 +335,7 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
  * @dev_type: always unused
  * @phy_data: Pointer to read data from PHY register
  */
-static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+STATIC s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
 u32 dev_type, u16 *phy_data)
 {
u32 i, data, command;
@@ -383,7 +383,7 @@ static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, 
u32 reg_addr,
  * @dev_type: always unused
  * @phy_data: Data to write to the PHY register
  */
-static s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+STATIC s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
  u32 dev_type, u16 phy_data)
 {
u32 i, command;
@@ -428,7 +428,7 @@ static s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, 
u32 reg_addr,
  *
  * Returns error code
  */
-static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
 {
u32 swfw_mask = hw->phy.phy_semaphore_mask;
u16 phy_id_high;
@@ -536,7 +536,7 @@ STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, 
u32 reg_addr,
  *
  * Returns an error code on error.
  **/
-static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
+STATIC s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
   u16 reg, u16 *val)
 {
return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
@@ -551,7 +551,7 @@ static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw 
*hw, u8 addr,
  *
  * Returns an error code on error.
  **/
-static s32
+STATIC s32
 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
 u16 reg, u16 *val)
 {
@@ -567,7 +567,7 @@ ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw 
*hw, u8 addr,
  *
  * Returns an error code on error.
  **/
-static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
+STATIC s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
u8 addr, u16 reg, u16 val)
 {
return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
@@ -582,7 +582,7 @@ static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw 
*hw,
  *
  * Returns an error code on error.
  **/
-static s32
+STATIC s32
 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
  u8 addr, u16 reg, u16 val)
 {
@@ -864,7 +864,7 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  * ixgbe_enable_eee_x550 - Enable EEE support
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
 {
u16 autoneg_eee_reg;
u32 link_reg;
@@ -919,7 +919,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
  * ixgbe_disable_eee_x550 - Disable EEE support
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
 {
u16 autoneg_eee_reg;
u32 link_reg;
@@ -1595,7 +1595,7 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
  * ixgbe_setup_sgmii - Set up link for sgmii
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
+STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
 bool autoneg_wait_to_complete)
 {
struct ixgbe_mac_info *mac = >mac;
@@ -1960,7 +1960,7 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
  *
  * Must be called while holding the PHY semaphore and token
  */
-static s32 ixgbe_set_master_slave_mode(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_set_master_slave_mode(struct ixgbe_hw *hw)
 {
u16 phy_data;
s32 rc;
@@

[dpdk-dev] [PATCH v4 22/29] ixgbe/base: add bypassing VLVF

2016-06-23 Thread Beilei Xing
This patch adds support for the VLVF to be bypassed when adding or
removing a VFTA entry.  The PF can utilize the default pool while
preserving the VLVF for the VFs use.
Meanwhile, update corresponding VF ops and drivers where corresponding
ops is invoked.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_82598.c  |  5 ++-
 drivers/net/ixgbe/base/ixgbe_82598.h  |  3 +-
 drivers/net/ixgbe/base/ixgbe_api.c| 11 --
 drivers/net/ixgbe/base/ixgbe_api.h|  5 ++-
 drivers/net/ixgbe/base/ixgbe_common.c | 71 +++
 drivers/net/ixgbe/base/ixgbe_common.h |  7 ++--
 drivers/net/ixgbe/base/ixgbe_type.h   |  5 ++-
 drivers/net/ixgbe/base/ixgbe_vf.c |  6 ++-
 drivers/net/ixgbe/base/ixgbe_vf.h |  3 +-
 drivers/net/ixgbe/ixgbe_ethdev.c  | 11 --
 drivers/net/ixgbe/ixgbe_pf.c  |  2 +-
 11 files changed, 76 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_82598.c 
b/drivers/net/ixgbe/base/ixgbe_82598.c
index 9e65fff..db80880 100644
--- a/drivers/net/ixgbe/base/ixgbe_82598.c
+++ b/drivers/net/ixgbe/base/ixgbe_82598.c
@@ -995,17 +995,20 @@ 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
  *
  *  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 vlan_on, bool bypass_vlvf)
 {
u32 regindex;
u32 bitindex;
u32 bits;
u32 vftabyte;

+   UNREFERENCED_1PARAMETER(bypass_vlvf);
+
DEBUGFUNC("ixgbe_set_vfta_82598");

if (vlan > 4095)
diff --git a/drivers/net/ixgbe/base/ixgbe_82598.h 
b/drivers/net/ixgbe/base/ixgbe_82598.h
index 89dd11a..0326e70 100644
--- a/drivers/net/ixgbe/base/ixgbe_82598.h
+++ b/drivers/net/ixgbe/base/ixgbe_82598.h
@@ -39,7 +39,8 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw);
 s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw);
 void ixgbe_enable_relaxed_ordering_82598(struct ixgbe_hw *hw);
 s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
-s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool 
vlan_on);
+s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
+bool vlvf_bypass);
 s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val);
 s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val);
 s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 90deaf1..1786867 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1082,13 +1082,15 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
  *  @vlan: VLAN id to write to VLAN filter
  *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
  *  @vlan_on: boolean flag to turn on/off VLAN
+ *  @vlvf_bypass: boolean flag indicating updating the default pool is okay
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
-s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on)
+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), IXGBE_NOT_IMPLEMENTED);
+ vlan_on, vlvf_bypass), IXGBE_NOT_IMPLEMENTED);
 }

 /**
@@ -1100,14 +1102,15 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on)
  *  @vfta_delta: pointer to the difference between the current value of VFTA
  *   and the desired value
  *  @vfta: the desired value of the VFTA
+ *  @vlvf_bypass: boolean flag indicating updating the default pool is okay
  *
  *  Turn on/off specified bit in VLVF table.
  **/
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
-  u32 *vfta_delta, u32 vfta)
+  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),
+   vlan_on, vfta_delta, vfta, vlvf_bypass),
   IXGBE_NOT_IMPLEMENTED);
 }

diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index 9431d14..c126982 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -124,9 +124,10 @@ s32 ixgbe_enable_mc(struct ixgbe_hw *hw);
 s32 ixgbe_disable_mc(struct ixgbe_hw *hw);
 s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);
 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan,
- 

[dpdk-dev] [PATCH v4 21/29] ixgbe/base: simplify add/remove VLANs

2016-06-23 Thread Beilei Xing
This patch simplifies the adding and removing VLANs from
VFTA/VLVF/VLVFB registers. The logic to determine registers has
been simplified to (vid / 32) and (1 - vid / 32). Many conditional
paths and checks are no longer needed with this patch.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c|  18 ++--
 drivers/net/ixgbe/base/ixgbe_api.h|   2 +-
 drivers/net/ixgbe/base/ixgbe_common.c | 188 ++
 drivers/net/ixgbe/base/ixgbe_common.h |   2 +-
 drivers/net/ixgbe/base/ixgbe_type.h   |   2 +-
 5 files changed, 91 insertions(+), 121 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index e117b86..90deaf1 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1080,8 +1080,8 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
  *  ixgbe_set_vfta - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @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
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
@@ -1095,18 +1095,20 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on)
  *  ixgbe_set_vlvf - Set VLAN Pool Filter
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
- *  @vfta_changed: pointer to boolean flag which indicates whether VFTA
- * should be changed
+ *  @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
+ *  @vfta: the desired value of the VFTA
  *
  *  Turn on/off specified bit in VLVF table.
  **/
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
-   bool *vfta_changed)
+  u32 *vfta_delta, u32 vfta)
 {
return ixgbe_call_func(hw, hw->mac.ops.set_vlvf, (hw, vlan, vind,
-  vlan_on, vfta_changed), IXGBE_NOT_IMPLEMENTED);
+  vlan_on, vfta_delta, vfta),
+  IXGBE_NOT_IMPLEMENTED);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index f5970a8..9431d14 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -126,7 +126,7 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);
 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan,
   u32 vind, bool vlan_on);
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
-  bool vlan_on, bool *vfta_changed);
+  bool vlan_on, u32 *vfta_delta, u32 vfta);
 s32 ixgbe_fc_enable(struct ixgbe_hw *hw);
 s32 ixgbe_setup_fc(struct ixgbe_hw *hw);
 s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build,
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 0a708cf..4551a2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -3853,24 +3853,20 @@ s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan)
  *  ixgbe_set_vfta_generic - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
 s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
   bool vlan_on)
 {
-   s32 regindex;
-   u32 bitindex;
-   u32 vfta;
-   u32 targetbit;
-   s32 ret_val = IXGBE_SUCCESS;
-   bool vfta_changed = false;
+   u32 regidx, vfta_delta, vfta;
+   s32 ret_val;

DEBUGFUNC("ixgbe_set_vfta_generic");

-   if (vlan > 4095)
+   if (vlan > 4095 || vind > 63)
return IXGBE_ERR_PARAM;

/*
@@ -3885,33 +3881,28 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 
vlan, u32 vind,
 *bits[11-5]: which register
 *bits[4-0]:  which bit in the register
 */
-   regindex = (vlan >> 5) & 0x7F;
-   bitindex = vlan & 0x1F;
-   targetbit = (1 << bitindex);
-   vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
-
-   if (vlan_on) {
-   if (!(vfta & targetbit)) {
-   vfta |= targetbit;
-   vfta_ch

[dpdk-dev] [PATCH v4 18/29] ixgbe/base: fix possible race issue

2016-06-23 Thread Beilei Xing
This patch fixes possible race issue between ports when issuing host
interface command by acquiring/releasing the management host interface
semaphore in ixgbe_host_interface_command.

Fixes: 36f43e8679ae ("ixgbe/base: refactor manageability block communication")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 40 ---
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 0a74714..0a708cf 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4373,8 +4373,9 @@ u8 ixgbe_calculate_checksum(u8 *buffer, u32 length)
  *   So we will leave this up to the caller to read back the data
  *   in these cases.
  *
- *  Communicates with the manageability block.  On success return IXGBE_SUCCESS
- *  else return IXGBE_ERR_HOST_INTERFACE_COMMAND.
+ *  Communicates with the manageability block. On success return IXGBE_SUCCESS
+ *  else returns semaphore error when encountering an error acquiring
+ *  semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
  **/
 s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
 u32 length, u32 timeout, bool return_data)
@@ -4383,6 +4384,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
u32 hdr_size = sizeof(struct ixgbe_hic_hdr);
u16 buf_len;
u16 dword_len;
+   s32 status;

DEBUGFUNC("ixgbe_host_interface_command");

@@ -4390,6 +4392,11 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
DEBUGOUT1("Buffer length failure buffersize=%d.\n", length);
return IXGBE_ERR_HOST_INTERFACE_COMMAND;
}
+   /* Take management host interface semaphore */
+   status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
+
+   if (status)
+   return status;

/* Set bit 9 of FWSTS clearing FW reset indication */
fwsts = IXGBE_READ_REG(hw, IXGBE_FWSTS);
@@ -4399,13 +4406,15 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
hicr = IXGBE_READ_REG(hw, IXGBE_HICR);
if ((hicr & IXGBE_HICR_EN) == 0) {
DEBUGOUT("IXGBE_HOST_EN bit disabled.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

/* Calculate length in DWORDs. We must be DWORD aligned */
if ((length % (sizeof(u32))) != 0) {
DEBUGOUT("Buffer length failure, not aligned to dword");
-   return IXGBE_ERR_INVALID_ARGUMENT;
+   status = IXGBE_ERR_INVALID_ARGUMENT;
+   goto rel_out;
}

dword_len = length >> 2;
@@ -4432,11 +4441,12 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV)) {
ERROR_REPORT1(IXGBE_ERROR_CAUTION,
 "Command has failed with no status valid.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

if (!return_data)
-   return 0;
+   goto rel_out;

/* Calculate length in DWORDs */
dword_len = hdr_size >> 2;
@@ -4450,11 +4460,12 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
/* If there is any thing in data position pull it in */
buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len;
if (buf_len == 0)
-   return 0;
+   goto rel_out;

if (length < buf_len + hdr_size) {
DEBUGOUT("Buffer not large enough for reply message.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

/* Calculate length in DWORDs, add 3 for odd lengths */
@@ -4466,7 +4477,10 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
IXGBE_LE32_TO_CPUS([bi]);
}

-   return 0;
+rel_out:
+   hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
+
+   return status;
 }

 /**
@@ -4491,12 +4505,6 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 
maj, u8 min,

DEBUGFUNC("ixgbe_set_fw_drv_ver_generic");

-   if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM)
-   != IXGBE_SUCCESS) {
-   ret_val = IXGBE_ERR_SWFW_SYNC;
-   goto out;
-   }
-
fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN;
fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;

[dpdk-dev] [PATCH v4 17/29] ixgbe/base: add function to reset swfw semaphore

2016-06-23 Thread Beilei Xing
For X540 and forward it is possible if a system reset occur at the
right time to leave the SWFW semaphore high. This new function will
attempt to grab and release the semaphore. If the grab times out it
will still release the semaphore placing it in a known good state.
The idea is to call this when you know no one should be holding the
semaphore (i.e. probe time)

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c| 14 ++
 drivers/net/ixgbe/base/ixgbe_api.h|  1 +
 drivers/net/ixgbe/base/ixgbe_common.c |  1 +
 drivers/net/ixgbe/base/ixgbe_type.h   |  1 +
 drivers/net/ixgbe/base/ixgbe_x540.c   | 20 
 drivers/net/ixgbe/base/ixgbe_x540.h   |  1 +
 6 files changed, 38 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 19e52c9..e117b86 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1639,6 +1639,20 @@ void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, 
u32 mask)
hw->mac.ops.release_swfw_sync(hw, mask);
 }

+/**
+ *  ixgbe_init_swfw_semaphore - Clean up SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *
+ *  Attempts to acquire the SWFW semaphore through SW_FW_SYNC register.
+ *  Regardless of whether is succeeds or not it then release the semaphore.
+ *  This is function is called to recover from catastrophic failures that
+ *  may have left the semaphore locked.
+ **/
+void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw)
+{
+   if (hw->mac.ops.init_swfw_sync)
+   hw->mac.ops.init_swfw_sync(hw);
+}

 void ixgbe_disable_rx(struct ixgbe_hw *hw)
 {
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index ae26a6a..f5970a8 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -191,6 +191,7 @@ s32 ixgbe_set_san_mac_addr(struct ixgbe_hw *hw, u8 
*san_mac_addr);
 s32 ixgbe_get_device_caps(struct ixgbe_hw *hw, u16 *device_caps);
 s32 ixgbe_acquire_swfw_semaphore(struct ixgbe_hw *hw, u32 mask);
 void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, u32 mask);
+void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw);
 s32 ixgbe_get_wwn_prefix(struct ixgbe_hw *hw, u16 *wwnn_prefix,
 u16 *wwpn_prefix);
 s32 ixgbe_get_fcoe_boot_status(struct ixgbe_hw *hw, u16 *bs);
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index d211303..0a74714 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4390,6 +4390,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
DEBUGOUT1("Buffer length failure buffersize=%d.\n", length);
return IXGBE_ERR_HOST_INTERFACE_COMMAND;
}
+
/* Set bit 9 of FWSTS clearing FW reset indication */
fwsts = IXGBE_READ_REG(hw, IXGBE_FWSTS);
IXGBE_WRITE_REG(hw, IXGBE_FWSTS, fwsts | IXGBE_FWSTS_FWRI);
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 6a837f1..f40580d 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3785,6 +3785,7 @@ struct ixgbe_mac_operations {
s32 (*enable_sec_rx_path)(struct ixgbe_hw *);
s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u32);
void (*release_swfw_sync)(struct ixgbe_hw *, u32);
+   void (*init_swfw_sync)(struct ixgbe_hw *);
s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *);
s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool);

diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c 
b/drivers/net/ixgbe/base/ixgbe_x540.c
index 0678913..31dead0 100644
--- a/drivers/net/ixgbe/base/ixgbe_x540.c
+++ b/drivers/net/ixgbe/base/ixgbe_x540.c
@@ -99,6 +99,7 @@ s32 ixgbe_init_ops_X540(struct ixgbe_hw *hw)
mac->ops.get_fcoe_boot_status = ixgbe_get_fcoe_boot_status_generic;
mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X540;
mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X540;
+   mac->ops.init_swfw_sync = ixgbe_init_swfw_sync_X540;
mac->ops.disable_sec_rx_path = ixgbe_disable_sec_rx_path_generic;
mac->ops.enable_sec_rx_path = ixgbe_enable_sec_rx_path_generic;

@@ -946,6 +947,25 @@ STATIC void ixgbe_release_swfw_sync_semaphore(struct 
ixgbe_hw *hw)
 }

 /**
+ *  ixgbe_init_swfw_sync_X540 - Release hardware semaphore
+ *  @hw: pointer to hardware structure
+ *
+ *  This function reset hardware semaphore bits for a semaphore that may
+ *  have be left locked due to a catastrophic failure.
+ **/
+void ixgbe_init_swfw_sync_X540(struct ixgbe_hw *hw)
+{
+   /* First try to grab the semaphore but we don't need to bother
+* looking to see whether we got the lock or  not since we do
+* the same thing regardless of whether we got the lock or not.
+* We got the lock - we release it.
+* We time

[dpdk-dev] [PATCH v4 16/29] ixgbe/base: change device IDs

2016-06-23 Thread Beilei Xing
There're two device IDs changed from 15C6/15C7 to 15E4/15E5 cause
PHY info changes. Make the change and use 15C6/15C7 for the backplane
SGMII. Clean up some discovery kludges from the previous shared ID,
and also add 15C6/15C7 to ixgbe_set_mdio_speed just for paranoia
to control MDIO speed even though nothing should be attached.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c  |  2 ++
 drivers/net/ixgbe/base/ixgbe_type.h |  7 ---
 drivers/net/ixgbe/base/ixgbe_x550.c | 17 -
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 12 
 4 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index cf1e516..19e52c9 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -209,6 +209,8 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_KR:
case IXGBE_DEV_ID_X550EM_A_KR_L:
case IXGBE_DEV_ID_X550EM_A_SFP_N:
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index f1379be..6a837f1 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -133,12 +133,14 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_DEV_ID_X550EM_A_KR   0x15C2
 #define IXGBE_DEV_ID_X550EM_A_KR_L 0x15C3
 #define IXGBE_DEV_ID_X550EM_A_SFP_N0x15C4
-#define IXGBE_DEV_ID_X550EM_A_1G_T 0x15C6
-#define IXGBE_DEV_ID_X550EM_A_1G_T_L   0x15C7
+#define IXGBE_DEV_ID_X550EM_A_SGMII0x15C6
+#define IXGBE_DEV_ID_X550EM_A_SGMII_L  0x15C7
 #define IXGBE_DEV_ID_X550EM_A_10G_T0x15C8
 #define IXGBE_DEV_ID_X550EM_A_QSFP 0x15CA
 #define IXGBE_DEV_ID_X550EM_A_QSFP_N   0x15CC
 #define IXGBE_DEV_ID_X550EM_A_SFP  0x15CE
+#define IXGBE_DEV_ID_X550EM_A_1G_T 0x15E4
+#define IXGBE_DEV_ID_X550EM_A_1G_T_L   0x15E5
 #define IXGBE_DEV_ID_X550EM_X_KX4  0x15AA
 #define IXGBE_DEV_ID_X550EM_X_KR   0x15AB
 #define IXGBE_DEV_ID_X550EM_X_SFP  0x15AC
@@ -3562,7 +3564,6 @@ enum ixgbe_media_type {
ixgbe_media_type_fiber_lco,
ixgbe_media_type_copper,
ixgbe_media_type_backplane,
-   ixgbe_media_type_sgmii,
ixgbe_media_type_cx4,
ixgbe_media_type_virtual
 };
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index c7b9760..359ce2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1487,10 +1487,15 @@ enum ixgbe_media_type 
ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_10G_T:
media_type = ixgbe_media_type_copper;
break;
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
+   media_type = ixgbe_media_type_backplane;
+   hw->phy.type = ixgbe_phy_sgmii;
+   break;
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
-   media_type = ixgbe_media_type_sgmii;
-   hw->phy.type = ixgbe_phy_sgmii;
+   media_type = ixgbe_media_type_copper;
+   hw->phy.type = ixgbe_phy_m88;
break;
default:
media_type = ixgbe_media_type_unknown;
@@ -1667,9 +1672,9 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.check_link = ixgbe_check_link_t_X550em;
break;
case ixgbe_media_type_backplane:
-   break;
-   case ixgbe_media_type_sgmii:
-   mac->ops.setup_link = ixgbe_setup_sgmii;
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
+   hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
+   mac->ops.setup_link = ixgbe_setup_sgmii;
break;
default:
break;
@@ -2229,6 +2234,8 @@ static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)

switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_X_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h 
b/lib/librte_eal/common/include/rte_pci_dev_ids.h
index cf7b548..63648c7 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -446,12 +446,14 @@ RTE_PCI_DEV_ID_DECL_IGB(PCI_VENDOR_ID_INTEL, 
E1000_DEV_ID_DH89XXCC_SFP)
 #defi

[dpdk-dev] [PATCH v4 15/29] ixgbe/base: add new phy definitions

2016-06-23 Thread Beilei Xing
It adds new phy definitions.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_phy.c  |  16 +-
 drivers/net/ixgbe/base/ixgbe_type.h |  14 +-
 drivers/net/ixgbe/base/ixgbe_x550.c | 303 ++--
 drivers/net/ixgbe/base/ixgbe_x550.h |  43 +
 4 files changed, 355 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c 
b/drivers/net/ixgbe/base/ixgbe_phy.c
index 6ed685e..ed1b14f 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.c
+++ b/drivers/net/ixgbe/base/ixgbe_phy.c
@@ -454,6 +454,9 @@ enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
case X557_PHY_ID:
phy_type = ixgbe_phy_x550em_ext_t;
break;
+   case IXGBE_M88E1500_E_PHY_ID:
+   phy_type = ixgbe_phy_m88;
+   break;
default:
phy_type = ixgbe_phy_unknown;
break;
@@ -615,13 +618,12 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 
reg_addr,

DEBUGFUNC("ixgbe_read_phy_reg_generic");

-   if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
-   status = ixgbe_read_phy_reg_mdi(hw, reg_addr, device_type,
-   phy_data);
-   hw->mac.ops.release_swfw_sync(hw, gssr);
-   } else {
-   status = IXGBE_ERR_SWFW_SYNC;
-   }
+   if (hw->mac.ops.acquire_swfw_sync(hw, gssr))
+   return IXGBE_ERR_SWFW_SYNC;
+
+   status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
+
+   hw->mac.ops.release_swfw_sync(hw, gssr);

return status;
 }
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index da1fe16..f1379be 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -1607,7 +1607,8 @@ struct ixgbe_dmac_config {
 #define ATH_PHY_ID 0x03429050

 /* PHY Types */
-#define IXGBE_M88E1145_E_PHY_ID0x01410CD0
+#define IXGBE_M88E1500_E_PHY_ID0x01410DD0
+#define IXGBE_M88E1543_E_PHY_ID0x01410EA0

 /* Special PHY Init Routine */
 #define IXGBE_PHY_INIT_OFFSET_NL   0x002B
@@ -3250,6 +3251,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_100_FULL  0x0008
 #define IXGBE_LINK_SPEED_1GB_FULL  0x0020
 #define IXGBE_LINK_SPEED_2_5GB_FULL0x0400
@@ -3574,6 +3576,14 @@ enum ixgbe_fc_mode {
ixgbe_fc_default
 };

+/* Master/slave control */
+enum ixgbe_ms_type {
+   ixgbe_ms_hw_default = 0,
+   ixgbe_ms_force_master,
+   ixgbe_ms_force_slave,
+   ixgbe_ms_auto
+};
+
 /* Smart Speed Settings */
 #define IXGBE_SMARTSPEED_MAX_RETRIES   3
 enum ixgbe_smart_speed {
@@ -3949,6 +3959,8 @@ struct ixgbe_phy_info {
bool reset_disable;
ixgbe_autoneg_advertised autoneg_advertised;
ixgbe_link_speed speeds_supported;
+   enum ixgbe_ms_type ms_type;
+   enum ixgbe_ms_type original_ms_type;
enum ixgbe_smart_speed smart_speed;
bool smart_speed_active;
bool multispeed_fiber;
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 22be322..c7b9760 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -329,6 +329,100 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_read_phy_reg_mdi_22 - Read from a clause 22 PHY register without lock
+ * @hw: pointer to hardware structure
+ * @reg_addr: 32 bit address of PHY register to read
+ * @dev_type: always unused
+ * @phy_data: Pointer to read data from PHY register
+ */
+static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+u32 dev_type, u16 *phy_data)
+{
+   u32 i, data, command;
+   UNREFERENCED_1PARAMETER(dev_type);
+
+   /* Setup and write the read command */
+   command = (reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
+   (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
+   (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+   IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_READ |
+   IXGBE_MSCA_MDI_COMMAND;
+
+   IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
+
+   /* Check every 10 usec to see if the access completed.
+* The MDI Command bit will clear when the operation is
+* complete
+*/
+   for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+   usec_delay(10);
+
+   command = IXGBE_READ_REG(hw, IXGBE_MSCA);
+   if (!(command & IXGBE_MSCA_MDI_COMMAND))
+   break;
+   }
+
+   if (command & IXGBE_MSCA_MDI_COMMAND) {
+   ERROR_REPORT1(IXGBE_ERROR_POLLING,
+ "PHY read comma

[dpdk-dev] [PATCH v4 14/29] ixgbe/base: optimize internal PHY mode determination

2016-06-23 Thread Beilei Xing
NW_MNG_IF_SEL register is critical PHY link configuration, add
ixgbe_read_mng_if_sel_x550em to read NW_MNG_IF_SEL, validate
register values and save fields such as PHY MDIO address, optimize
internal PHY mode determination.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |  2 ++
 drivers/net/ixgbe/base/ixgbe_x550.c | 48 +++--
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index de295e1..da1fe16 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4134,6 +4134,8 @@ struct ixgbe_hw {
 #define IXGBE_SB_IOSF_TARGET_KR_PHY0

 #define IXGBE_NW_MNG_IF_SEL0x00011178
+#define IXGBE_NW_MNG_IF_SEL_MDIO_ACT   (1 << 1)
+#define IXGBE_NW_MNG_IF_SEL_ENABLE_10_100M (1 << 23)
 #define IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE (1 << 24)
 #define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT 3
 #define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD   \
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index daa8339..22be322 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -338,9 +338,8 @@ static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
 {
u16 phy_id_high;
u16 phy_id_low;
-   u32 val = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+   u32 val;

-   hw->phy.addr = (val >> 3) & 0x1F;
val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
   hw->phy.addr, _id_high);
if (val || phy_id_high == 0x) {
@@ -1843,6 +1842,33 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
 }

 /**
+ *  ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
+ *  @hw: pointer to hardware structure
+ *
+ *  Read NW_MNG_IF_SEL register and save field values, and check for valid 
field
+ *  values.
+ **/
+STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
+{
+   /* Save NW management interface connected on board. This is used
+* to determine internal PHY mode.
+*/
+   hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+   /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
+* PHY address. This register field was has only been used for X552.
+*/
+   if (hw->mac.type == ixgbe_mac_X550EM_a &&
+   hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
+   hw->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;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
  *  ixgbe_init_phy_ops_X550em - PHY/SFP specific init
  *  @hw: pointer to hardware structure
  *
@@ -1859,14 +1885,11 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)

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);
-
-   /* Save NW management interface connected on board. This is used
-* to determine internal PHY mode.
-*/
-   phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
}

@@ -1893,11 +1916,6 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
break;
case ixgbe_phy_x550em_ext_t:
-   /* Save NW management interface connected on board. This is used
-* to determine internal PHY mode
-*/
-   phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
-
/* If internal link mode is XFI, then setup iXFI internal link,
 * else setup KR now.
 */
@@ -2256,12 +2274,6 @@ s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
/* Configure internal PHY for KR/KX. */
ixgbe_setup_kr_speed_x550em(hw, speed);

-   /* Get CS4227 MDIO address */
-   hw->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 (hw->phy.addr == 0x0 || hw->phy.addr == 0x) {
/* Find Address */
DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
-- 
2.5.0



[dpdk-dev] [PATCH v4 13/29] ixgbe/base: fix for code style

2016-06-23 Thread Beilei Xing
The ixgbe_vf.h file did not use __ and instead used
 which is not the standard used in every other file.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_vf.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_vf.h 
b/drivers/net/ixgbe/base/ixgbe_vf.h
index 411152a..9be2cda 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.h
+++ b/drivers/net/ixgbe/base/ixgbe_vf.h
@@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE.

 ***/

-#ifndef __IXGBE_VF_H__
-#define __IXGBE_VF_H__
+#ifndef _IXGBE_VF_H_
+#define _IXGBE_VF_H_

 #define IXGBE_VF_IRQ_CLEAR_MASK7
 #define IXGBE_VF_MAX_TX_QUEUES 8
-- 
2.5.0



[dpdk-dev] [PATCH v4 12/29] ixgbe/base: fix error path to release lock

2016-06-23 Thread Beilei Xing
When there is an error getting the PHY token, the error path
fails to release the locks that it has taken. Release those
locks in that failure case.

Fixes: 86b8fb293fdf ("ixgbe/base: add sw-firmware sync for resource sharing on 
X550em_a")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index f129e8c..daa8339 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -3531,17 +3531,22 @@ static s32 ixgbe_acquire_swfw_sync_X550a(struct 
ixgbe_hw *hw, u32 mask)
DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");

while (--retries) {
+   status = IXGBE_SUCCESS;
if (hmask)
status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
if (status)
-   break;
+   return status;
if (!(mask & IXGBE_GSSR_TOKEN_SM))
-   break;
+   return IXGBE_SUCCESS;
+
status = ixgbe_get_phy_token(hw);
-   if (status != IXGBE_ERR_TOKEN_RETRY)
-   break;
+   if (status == IXGBE_SUCCESS)
+   return IXGBE_SUCCESS;
+
if (hmask)
ixgbe_release_swfw_sync_X540(hw, hmask);
+   if (status != IXGBE_ERR_TOKEN_RETRY)
+   return status;
msec_delay(FW_PHY_TOKEN_DELAY);
}

-- 
2.5.0



[dpdk-dev] [PATCH v4 11/29] ixgbe/base: rename macro of TDL

2016-06-23 Thread Beilei Xing
This patch renames IXGBE_PVFTTDLEN to IXGBE_PVFTDLEN according to
abbreviation of Transmit Descriptor Length in datasheet.

Signed-off-by: Beilei Xing 
---
 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 0a35891..de295e1 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -2824,7 +2824,7 @@ enum {
 #define IXGBE_PVFPSRTYPE(P)(0x0EA00 + (4 * (P)))
 #define IXGBE_PVFTDBAL(P)  (0x06000 + (0x40 * (P)))
 #define IXGBE_PVFTDBAH(P)  (0x06004 + (0x40 * (P)))
-#define IXGBE_PVFTTDLEN(P) (0x06008 + (0x40 * (P)))
+#define IXGBE_PVFTDLEN(P)  (0x06008 + (0x40 * (P)))
 #define IXGBE_PVFTDH(P)(0x06010 + (0x40 * (P)))
 #define IXGBE_PVFTDT(P)(0x06018 + (0x40 * (P)))
 #define IXGBE_PVFTXDCTL(P) (0x06028 + (0x40 * (P)))
-- 
2.5.0



[dpdk-dev] [PATCH v4 10/29] ixgbe/base: clear stale pool mappings

2016-06-23 Thread Beilei Xing
This patch adds clearing the pool mappings when configuring default
MAC addresses for the interface. Without this there will be the risk
of leaking an address into pool 0 which really belongs to VF 0 when
SR-IOV is enabled.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_82599.c  | 9 ++---
 drivers/net/ixgbe/base/ixgbe_common.c | 7 ---
 drivers/net/ixgbe/base/ixgbe_x540.c   | 9 ++---
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_82599.c 
b/drivers/net/ixgbe/base/ixgbe_82599.c
index 154c1f1..5bc7c2b 100644
--- a/drivers/net/ixgbe/base/ixgbe_82599.c
+++ b/drivers/net/ixgbe/base/ixgbe_82599.c
@@ -1176,11 +1176,14 @@ mac_reset_top:

/* Add the SAN MAC address to the RAR only if it's a valid address */
if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
-   hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
-   hw->mac.san_addr, 0, IXGBE_RAH_AV);
-
/* 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);
+
+   /* clear VMDq pool/queue selection for this RAR */
+   hw->mac.ops.clear_vmdq(hw, hw->mac.san_mac_rar_index,
+  IXGBE_CLEAR_VMDQ_ALL);

/* Reserve the last RAR for the SAN MAC address */
hw->mac.num_rar_entries--;
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 82a8416..d211303 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -2406,10 +2406,11 @@ s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw)
  hw->mac.addr[4], hw->mac.addr[5]);

hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
-
-   /* clear VMDq pool/queue selection for RAR 0 */
-   hw->mac.ops.clear_vmdq(hw, 0, IXGBE_CLEAR_VMDQ_ALL);
}
+
+   /* clear VMDq pool/queue selection for RAR 0 */
+   hw->mac.ops.clear_vmdq(hw, 0, IXGBE_CLEAR_VMDQ_ALL);
+
hw->addr_ctrl.overflow_promisc = 0;

hw->addr_ctrl.rar_used_count = 1;
diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c 
b/drivers/net/ixgbe/base/ixgbe_x540.c
index 9ade1b5..0678913 100644
--- a/drivers/net/ixgbe/base/ixgbe_x540.c
+++ b/drivers/net/ixgbe/base/ixgbe_x540.c
@@ -268,11 +268,14 @@ mac_reset_top:

/* Add the SAN MAC address to the RAR only if it's a valid address */
if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
-   hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
-   hw->mac.san_addr, 0, IXGBE_RAH_AV);
-
/* 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);
+
+   /* clear VMDq pool/queue selection for this RAR */
+   hw->mac.ops.clear_vmdq(hw, hw->mac.san_mac_rar_index,
+  IXGBE_CLEAR_VMDQ_ALL);

/* Reserve the last RAR for the SAN MAC address */
hw->mac.num_rar_entries--;
-- 
2.5.0



[dpdk-dev] [PATCH v4 09/29] ixgbe/base: add link MAC setup for X550a SFP+

2016-06-23 Thread Beilei Xing
This patch updates ixgbe_setup_mac_link_sfp_x550a for X550 SFP+.
ixgbe_set_lan_id_multi_port_pcie has been updated to set the MAC
instance(0/1) which is needed when configuring the external PHY,
since X550a has two instances of MGPK. The MAC instance is read
from the EEPROM.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 13 +-
 drivers/net/ixgbe/base/ixgbe_phy.h|  3 ++
 drivers/net/ixgbe/base/ixgbe_type.h   |  8 
 drivers/net/ixgbe/base/ixgbe_x550.c   | 85 ++-
 4 files changed, 86 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index ec61408..82a8416 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -1020,13 +1020,15 @@ s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw)
  *  ixgbe_set_lan_id_multi_port_pcie - Set LAN id for PCIe multiple port 
devices
  *  @hw: pointer to the HW structure
  *
- *  Determines the LAN function id by reading memory-mapped registers
- *  and swaps the port value if requested.
+ *  Determines the LAN function id by reading memory-mapped registers and swaps
+ *  the port value if requested, and set MAC instance for devices that share
+ *  CS4227.
  **/
 void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw)
 {
struct ixgbe_bus_info *bus = >bus;
u32 reg;
+   u16 ee_ctrl_4;

DEBUGFUNC("ixgbe_set_lan_id_multi_port_pcie");

@@ -1038,6 +1040,13 @@ void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw 
*hw)
reg = IXGBE_READ_REG(hw, IXGBE_FACTPS_BY_MAC(hw));
if (reg & IXGBE_FACTPS_LFS)
bus->func ^= 0x1;
+
+   /* Get MAC instance from EEPROM for configuring CS4227 */
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP) {
+   hw->eeprom.ops.read(hw, IXGBE_EEPROM_CTRL_4, _ctrl_4);
+   bus->instance_id = (ee_ctrl_4 & IXGBE_EE_CTRL_4_INST_ID) >>
+   IXGBE_EE_CTRL_4_INST_ID_SHIFT;
+   }
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_phy.h 
b/drivers/net/ixgbe/base/ixgbe_phy.h
index 1a5affe..281f9fa 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.h
+++ b/drivers/net/ixgbe/base/ixgbe_phy.h
@@ -89,8 +89,11 @@ POSSIBILITY OF SUCH DAMAGE.

 #define IXGBE_CS4227   0xBE/* CS4227 address */
 #define IXGBE_CS4227_GLOBAL_ID_LSB 0
+#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_CS4227_RESET_PENDING 0x1357
 #define IXGBE_CS4227_RESET_COMPLETE0x5AA5
 #define IXGBE_CS4227_RETRIES   15
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 7bd6f2c..0a35891 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -1472,6 +1472,7 @@ struct ixgbe_dmac_config {
 #define IXGBE_CORECTL_WRITE_CMD0x0001

 /* Device Type definitions for new protocol MDIO commands */
+#define IXGBE_MDIO_ZERO_DEV_TYPE   0x0
 #define IXGBE_MDIO_PMA_PMD_DEV_TYPE0x1
 #define IXGBE_MDIO_PCS_DEV_TYPE0x3
 #define IXGBE_MDIO_PHY_XS_DEV_TYPE 0x4
@@ -2247,6 +2248,9 @@ enum {
 #define IXGBE_PBANUM_PTR_GUARD 0xFAFA
 #define IXGBE_EEPROM_CHECKSUM  0x3F
 #define IXGBE_EEPROM_SUM   0xBABA
+#define IXGBE_EEPROM_CTRL_40x45
+#define IXGBE_EE_CTRL_4_INST_ID0x10
+#define IXGBE_EE_CTRL_4_INST_ID_SHIFT  4
 #define IXGBE_PCIE_ANALOG_PTR  0x03
 #define IXGBE_ATLAS0_CONFIG_PTR0x04
 #define IXGBE_PHY_PTR  0x04
@@ -3630,6 +3634,7 @@ struct ixgbe_bus_info {

u16 func;
u16 lan_id;
+   u16 instance_id;
 };

 /* Flow control parameters */
@@ -4130,5 +4135,8 @@ struct ixgbe_hw {

 #define IXGBE_NW_MNG_IF_SEL0x00011178
 #define IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE (1 << 24)
+#define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT 3
+#define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD   \
+   (0x1F << IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT)

 #endif /* _IXGBE_TYPE_H_ */
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 1834549..f129e8c 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1551,7 +1551,8 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
mac->ops.set_rate_select_speed =
ixgbe_set_soft_rate_select_speed;
-   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N)
+   if ((hw->device_id == IXG

[dpdk-dev] [PATCH v4 08/29] ixgbe/base: change access method

2016-06-23 Thread Beilei Xing
Use the method pointers instead of direct function calls so that
the right thing will happen on X550EM_a.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 76 ++---
 1 file changed, 38 insertions(+), 38 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 242916f..1834549 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -546,8 +546,8 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
link->addr = IXGBE_CS4227;
}
if (hw->mac.type == ixgbe_mac_X550EM_a) {
-   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.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;
}
@@ -785,7 +785,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_X_KR:
case IXGBE_DEV_ID_X550EM_A_KR:
case IXGBE_DEV_ID_X550EM_A_KR_L:
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
+   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);
if (status != IXGBE_SUCCESS)
@@ -797,7 +797,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
/* Don't advertise FEC capability when EEE enabled. */
link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;

-   status = ixgbe_write_iosf_sb_reg_x550(hw,
+   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_reg);
if (status != IXGBE_SUCCESS)
@@ -840,7 +840,7 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_X_KR:
case IXGBE_DEV_ID_X550EM_A_KR:
case IXGBE_DEV_ID_X550EM_A_KR_L:
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
+   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);
if (status != IXGBE_SUCCESS)
@@ -852,7 +852,7 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
/* Advertise FEC capability when EEE is disabled. */
link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;

-   status = ixgbe_write_iosf_sb_reg_x550(hw,
+   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_reg);
if (status != IXGBE_SUCCESS)
@@ -1814,9 +1814,9 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
s32 status;
u32 reg_val;

-   status = ixgbe_read_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (status)
return status;

@@ -1834,9 +1834,9 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,

/* Restart auto-negotiation. */
reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
-   status = ixgbe_write_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+   status = hw->mac.ops.write_iosf_sb_reg(hw,
+  IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);

return status;
 }
@@ -2496,57 +2496,57 @@ s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
u32 reg_val;

/* Disable AN and force speed to 10G Serial. */
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (status != IXGBE_SUCCESS)
return status;
reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
reg_val |= IX

[dpdk-dev] [PATCH v4 07/29] ixgbe/base: add KR support for X550em_a devices

2016-06-23 Thread Beilei Xing
Implement KR support for X550em_a devices.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 53 +
 1 file changed, 42 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 388ac20..242916f 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -564,9 +564,14 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
else
mac->ops.setup_fc = ixgbe_setup_fc_X550em;

-
-   if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
+   break;
+   default:
mac->ops.setup_eee = NULL;
+   }

/* PHY */
phy->ops.init = ixgbe_init_phy_ops_X550em;
@@ -773,8 +778,13 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  autoneg_eee_reg);
-   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   return IXGBE_SUCCESS;
+   }

+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
status = ixgbe_read_iosf_sb_reg_x550(hw,
 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
 IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
@@ -792,6 +802,9 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
  IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
if (status != IXGBE_SUCCESS)
return status;
+   break;
+   default:
+   break;
}

return IXGBE_SUCCESS;
@@ -820,7 +833,13 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  autoneg_eee_reg);
-   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   return IXGBE_SUCCESS;
+   }
+
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
status = ixgbe_read_iosf_sb_reg_x550(hw,
 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
 IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
@@ -838,6 +857,9 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
  IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
if (status != IXGBE_SUCCESS)
return status;
+   break;
+   default:
+   break;
}

return IXGBE_SUCCESS;
@@ -2086,10 +2108,13 @@ s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
  *  ixgbe_setup_kr_x550em - Configure the KR PHY.
  *  @hw: pointer to hardware structure
  *
- *  Configures the integrated KR PHY.
+ *  Configures the integrated KR PHY for X550EM_x.
  **/
 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
 {
+   if (hw->mac.type != ixgbe_mac_X550EM_x)
+   return IXGBE_SUCCESS;
+
return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
 }

@@ -3357,24 +3382,30 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
goto out;
}

-   if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
ret_val = ixgbe_read_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+ IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (ret_val != IXGBE_SUCCESS)
goto out;
reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
-   IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
+IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
if (pause)
reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
if (asm_dir)
reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
ret_val = ixgbe_write_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+  IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),

[dpdk-dev] [PATCH v4 06/29] ixgbe/base: refactor eee setup for X550

2016-06-23 Thread Beilei Xing
Break ixgbe_setup_eee_X550 down to better handle a change from if
statements to switch statements needed to add X550em_a KR support.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 174 ++--
 1 file changed, 105 insertions(+), 69 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 54aab06..388ac20 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -751,6 +751,99 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_enable_eee_x550 - Enable EEE support
+ * @hw: pointer to hardware structure
+ */
+static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
+{
+   u16 autoneg_eee_reg;
+   u32 link_reg;
+   s32 status;
+
+   if (hw->mac.type == ixgbe_mac_X550) {
+   /* Advertise EEE capability */
+   hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+_eee_reg);
+
+   autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
+   IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
+   IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
+
+   hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ autoneg_eee_reg);
+   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+
+   status = ixgbe_read_iosf_sb_reg_x550(hw,
+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;
+
+   /* Don't advertise FEC capability when EEE enabled. */
+   link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
+   status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
+   if (status != IXGBE_SUCCESS)
+   return status;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_disable_eee_x550 - Disable EEE support
+ * @hw: pointer to hardware structure
+ */
+static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
+{
+   u16 autoneg_eee_reg;
+   u32 link_reg;
+   s32 status;
+
+   if (hw->mac.type == ixgbe_mac_X550) {
+   /* Disable advertised EEE capability */
+   hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+_eee_reg);
+
+   autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
+IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
+IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
+
+   hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ autoneg_eee_reg);
+   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   status = ixgbe_read_iosf_sb_reg_x550(hw,
+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);
+
+   /* Advertise FEC capability when EEE is disabled. */
+   link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
+   status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
+   if (status != IXGBE_SUCCESS)
+   return status;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
  *  ixgbe_setup_eee_X550 - Enable/disable EEE support
  *  @hw: pointer to the HW structure
  *  @enable_eee: boolean flag to enable EEE
@@ -762,10 +855,8 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  **/
 s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
 {
-   u32 eeer;
-   u16 autoneg_eee_reg;
-   u32 link_reg;
s32 status;
+   u32 eeer;

DEBUGFUNC("ixgbe_setup_eee_X550");

@@ -774,75 +865,20 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool 
enable_eee)
if (e

[dpdk-dev] [PATCH v4 05/29] ixgbe/base: fix firmware command checksum error

2016-06-23 Thread Beilei Xing
When software sends commands to firmware using the host
slave command interface, firmware fails to recieve the
request command with a checksum failed error.
This patch sets command checksum to the default value of
0xFF according to datasheet, therefore the checksum won't
be checked by firmware.

Fixes: 86b8fb293fdf ("ixgbe/base: add sw-firmware sync for resource sharing on 
X550em_a")
Fixes: 0790adeb5675 ("ixgbe/base: support X550em_a device")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 8a5b1dc..54aab06 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1041,6 +1041,7 @@ s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
+   token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
token_cmd.port_number = hw->bus.lan_id;
token_cmd.command_type = FW_PHY_TOKEN_REQ;
token_cmd.pad = 0;
@@ -1071,6 +1072,7 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
+   token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
token_cmd.port_number = hw->bus.lan_id;
token_cmd.command_type = FW_PHY_TOKEN_REL;
token_cmd.pad = 0;
@@ -1094,23 +1096,24 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
  *  @data: Data to write to the register
  **/
 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
-   u32 device_type, u32 data)
+ u32 device_type, u32 data)
 {
struct ixgbe_hic_internal_phy_req write_cmd;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

+   memset(_cmd, 0, sizeof(write_cmd));
write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
write_cmd.port_number = hw->bus.lan_id;
write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
write_cmd.address = (u16)reg_addr;
-   write_cmd.rsv1 = 0;
write_cmd.write_data = data;
-   write_cmd.pad = 0;

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
-   sizeof(write_cmd), IXGBE_HI_COMMAND_TIMEOUT, false);
+ sizeof(write_cmd),
+ IXGBE_HI_COMMAND_TIMEOUT, false);

return status;
 }
@@ -1124,23 +1127,23 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
  *  @data: Pointer to read data from the register
  **/
 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
-   u32 device_type, u32 *data)
+u32 device_type, u32 *data)
 {
struct ixgbe_hic_internal_phy_req read_cmd;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

+   memset(_cmd, 0, sizeof(read_cmd));
read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   read_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
read_cmd.port_number = hw->bus.lan_id;
read_cmd.command_type = FW_INT_PHY_REQ_READ;
read_cmd.address = (u16)reg_addr;
-   read_cmd.rsv1 = 0;
-   read_cmd.write_data = 0;
-   read_cmd.pad = 0;

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
-   sizeof(read_cmd), IXGBE_HI_COMMAND_TIMEOUT, true);
+ sizeof(read_cmd),
+ IXGBE_HI_COMMAND_TIMEOUT, true);

/* Extract the register value from the response. */
*data = ((struct ixgbe_hic_internal_phy_resp *)_cmd)->read_data;
-- 
2.5.0



[dpdk-dev] [PATCH v4 04/29] ixgbe/base: add MAC link setup for X550a SFP

2016-06-23 Thread Beilei Xing
This patch adds ixgbe_setup_mac_link_sfp_x550a for X550a SFP.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |  4 +++
 drivers/net/ixgbe/base/ixgbe_x550.c | 64 -
 drivers/net/ixgbe/base/ixgbe_x550.h |  3 ++
 3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 493bd46..7bd6f2c 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4062,6 +4062,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
 #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_8(P) ((P) ? 0x8248 : 0x4248)
 #define IXGBE_KRM_SGMII_CTRL(P)((P) ? 0x82A0 : 0x42A0)
 #define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
@@ -4090,6 +4091,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_AN_CNTL_8_LINEAR (1 << 0)
+#define IXGBE_KRM_AN_CNTL_8_LIMITING   (1 << 1)
+
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 6c00b2a..8a5b1dc 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1488,9 +1488,14 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.enable_tx_laser = NULL;
mac->ops.flap_tx_laser = NULL;
mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
-   mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_x550em;
mac->ops.set_rate_select_speed =
ixgbe_set_soft_rate_select_speed;
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N)
+   mac->ops.setup_mac_link =
+   ixgbe_setup_mac_link_sfp_x550a;
+   else
+   mac->ops.setup_mac_link =
+   ixgbe_setup_mac_link_sfp_x550em;
break;
case ixgbe_media_type_copper:
mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
@@ -2128,6 +2133,63 @@ s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
 }

 /**
+ *  ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
+ *  @hw: pointer to hardware structure
+ *
+ *  Configure the the integrated PHY for SFP support.
+ **/
+s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
+  ixgbe_link_speed speed,
+  bool autoneg_wait_to_complete)
+{
+   s32 ret_val;
+   u32 reg_val;
+   bool setup_linear = false;
+
+   UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
+
+   /* Check if SFP module is supported and linear */
+   ret_val = ixgbe_supported_sfp_modules_X550em(hw, _linear);
+
+   /* If no SFP module present, then return success. Return success since
+* SFP not present error is not excepted in the setup MAC link flow.
+*/
+   if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
+   return IXGBE_SUCCESS;
+
+   if (ret_val != IXGBE_SUCCESS)
+   return ret_val;
+
+   /* Configure internal PHY for native SFI */
+   ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
+  IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+
+   if (ret_val != IXGBE_SUCCESS)
+   return ret_val;
+
+   if (setup_linear) {
+   reg_val &= ~IXGBE_KRM_AN_CNTL_8_LIMITING;
+   reg_val |= IXGBE_KRM_AN_CNTL_8_LINEAR;
+   } else {
+   reg_val |= IXGBE_KRM_AN_CNTL_8_LIMITING;
+   reg_val &= ~IXGBE_KRM_AN_CNTL_8_LINEAR;
+   }
+
+   ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
+   IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
+   IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+
+   if (ret_val != IXGBE_SUCCESS)
+   return ret_val;
+
+   /* Setup XFI/SFI internal link. */
+   ret_val = ixgbe_setup_ixfi_x550em(hw, );
+
+   return ret_val;
+}
+
+/**
  *  ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
  *  @hw: pointer to hardware structure
  *
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.h 
b/drivers/net/ixgbe/base/ixgbe_x550.h
index a8c0a67..2966c7b 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.h
+++ b/drivers/net/ixgbe/base/ixgbe_x550.h
@@ -100,6 +100,9 @@ s32 ixgbe_setup_fc_X5

[dpdk-dev] [PATCH v4 03/29] ixgbe/base: fix problematic return value

2016-06-23 Thread Beilei Xing
An error code indicating that the PF rejects the MAC address change
should be returned, in case that the PF has already assigned a MAC
for the VF.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_vf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_vf.c 
b/drivers/net/ixgbe/base/ixgbe_vf.c
index 40dc1c8..81ea6c7 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.c
+++ b/drivers/net/ixgbe/base/ixgbe_vf.c
@@ -362,8 +362,10 @@ s32 ixgbe_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 
*addr, u32 vmdq,

/* if nacked the address was rejected, use "perm_addr" */
if (!ret_val &&
-   (msgbuf[0] == (IXGBE_VF_SET_MAC_ADDR | IXGBE_VT_MSGTYPE_NACK)))
+   (msgbuf[0] == (IXGBE_VF_SET_MAC_ADDR | IXGBE_VT_MSGTYPE_NACK))) {
ixgbe_get_mac_addr_vf(hw, hw->mac.addr);
+   return IXGBE_ERR_MBX;
+   }

return ret_val;
 }
-- 
2.5.0



[dpdk-dev] [PATCH v4 02/29] ixgbe/base: add sgmii link for X550

2016-06-23 Thread Beilei Xing
This patch adds new phy type and media type to support
sgmii link for X550, and add ixgbe_setup_sgmii to support
sgmii link setup.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |   9 +++
 drivers/net/ixgbe/base/ixgbe_x550.c | 127 +---
 2 files changed, 127 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 4dce2ac..493bd46 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3511,6 +3511,8 @@ enum ixgbe_phy_type {
ixgbe_phy_qsfp_intel,
ixgbe_phy_qsfp_unknown,
ixgbe_phy_sfp_unsupported, /*Enforce bit set with unsupported module*/
+   ixgbe_phy_sgmii,
+   ixgbe_phy_m88,
ixgbe_phy_generic
 };

@@ -3554,6 +3556,7 @@ enum ixgbe_media_type {
ixgbe_media_type_fiber_lco,
ixgbe_media_type_copper,
ixgbe_media_type_backplane,
+   ixgbe_media_type_sgmii,
ixgbe_media_type_cx4,
ixgbe_media_type_virtual
 };
@@ -4059,6 +4062,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
 #define IXGBE_KRM_LINK_CTRL_1(P)   ((P) ? 0x820C : 0x420C)
 #define IXGBE_KRM_AN_CNTL_1(P) ((P) ? 0x822C : 0x422C)
+#define IXGBE_KRM_SGMII_CTRL(P)((P) ? 0x82A0 : 0x42A0)
 #define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
 #define IXGBE_KRM_RX_TRN_LINKUP_CTRL(P)((P) ? 0x8B00 : 0x4B00)
@@ -4072,6 +4076,8 @@ struct ixgbe_hw {
 #define IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK(0x7 << 8)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G  (2 << 8)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G (4 << 8)
+#define IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN (1 << 12)
+#define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN (1 << 13)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ  (1 << 14)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC  (1 << 15)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX   (1 << 16)
@@ -4084,6 +4090,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_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
+#define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)
+
 #define IXGBE_KRM_DSP_TXFFE_STATE_C0_EN(1 << 6)
 #define IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN   (1 << 15)
 #define IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN  (1 << 16)
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 0bbaa55..6c00b2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -329,6 +329,39 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_identify_phy_1g - Get 1g PHY type based on device id
+ * @hw: pointer to hardware structure
+ *
+ * Returns error code
+ */
+static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
+{
+   u16 phy_id_high;
+   u16 phy_id_low;
+   u32 val = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+   hw->phy.addr = (val >> 3) & 0x1F;
+   val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
+  hw->phy.addr, _id_high);
+   if (val || phy_id_high == 0x) {
+   hw->phy.type = ixgbe_phy_sgmii;
+   return 0;
+   }
+
+   val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
+  hw->phy.addr, _id_low);
+   if (val)
+   return val;
+
+   hw->phy.id = (u32)phy_id_high << 16;
+   hw->phy.id |= phy_id_low & IXGBE_PHY_REVISION_MASK;
+   hw->phy.revision = (u32)phy_id_low & ~IXGBE_PHY_REVISION_MASK;
+   hw->phy.type = ixgbe_phy_m88;
+
+   return 0;
+}
+
+/**
  * ixgbe_identify_phy_x550em - Get PHY type based on device id
  * @hw: pointer to hardware structure
  *
@@ -364,10 +397,11 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
break;
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_10G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T_L:
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:
+   return ixgbe_identify_phy_1g(hw);
default:
break;
}
@@ -1286,11 +1320,14 @@ enum ixgbe_media_type 
ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
break;
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_10G_T:
-   case IXGBE_DEV_ID_X550EM_A

[dpdk-dev] [PATCH v4 01/29] ixgbe/base: add new VF requests for mailbox API

2016-06-23 Thread Beilei Xing
This patch adds two new VF requests of IXGBE_VF_GET_RETA and
IXGBE_VF_GET_RSS_KEY for mailbox API.

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

diff --git a/drivers/net/ixgbe/base/ixgbe_mbx.h 
b/drivers/net/ixgbe/base/ixgbe_mbx.h
index 4a120a3..d775142 100644
--- a/drivers/net/ixgbe/base/ixgbe_mbx.h
+++ b/drivers/net/ixgbe/base/ixgbe_mbx.h
@@ -109,7 +109,9 @@ enum ixgbe_pfvf_api_rev {
 #define IXGBE_VF_GET_QUEUES0x09 /* get queue configuration */

 /* mailbox API, version 1.2 VF requests */
-#define IXGBE_VF_UPDATE_XCAST_MODE 0x0C
+#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

 /* GET_QUEUES return data indices within the mailbox */
 #define IXGBE_VF_TX_QUEUES 1   /* number of Tx queues supported */
-- 
2.5.0



[dpdk-dev] [PATCH v4 00/29] ixgbe/base: update base driver

2016-06-23 Thread Beilei Xing
Update base driver for ixgbe, mainly work on new features and bug fixes.

v4 changes:
 Update some commit logs.
 Merge related patched.
v3 changes:
 Fix some commit log issues.

Beilei Xing (29):
  ixgbe/base: add new VF requests for mailbox API
  ixgbe/base: add sgmii link for X550
  ixgbe/base: fix problematic return value
  ixgbe/base: add MAC link setup for X550a SFP
  ixgbe/base: fix firmware command checksum error
  ixgbe/base: refactor eee setup for X550
  ixgbe/base: add KR support for X550em_a devices
  ixgbe/base: change access method
  ixgbe/base: add link MAC setup for X550a SFP+
  ixgbe/base: clear stale pool mappings
  ixgbe/base: rename macro of TDL
  ixgbe/base: fix error path to release lock
  ixgbe/base: fix for code style
  ixgbe/base: optimize internal PHY mode determination
  ixgbe/base: add new phy definitions
  ixgbe/base: change device IDs
  ixgbe/base: add function to reset swfw semaphore
  ixgbe/base: fix possible race issue
  ixgbe/base: fix register access error
  ixgbe/base: limit PHY token accessing to MDIO only
  ixgbe/base: simplify add/remove VLANs
  ixgbe/base: add bypassing VLVF
  ixgbe/base: unify coding style
  ixgbe/base: use u8 to replace u16 for a variable
  ixgbe/base: fix endianness issues
  ixgbe/base: allow setting MAC anti spoofing per VF
  ixgbe/base: add flow control autoneg for X550a
  ixgbe/base: define if enable crosstalk work around
  ixgbe/base: update README

 doc/guides/rel_notes/release_16_07.rst  |   11 +
 drivers/net/ixgbe/base/README   |2 +-
 drivers/net/ixgbe/base/ixgbe_82598.c|5 +-
 drivers/net/ixgbe/base/ixgbe_82598.h|3 +-
 drivers/net/ixgbe/base/ixgbe_82599.c|9 +-
 drivers/net/ixgbe/base/ixgbe_api.c  |   41 +-
 drivers/net/ixgbe/base/ixgbe_api.h  |8 +-
 drivers/net/ixgbe/base/ixgbe_common.c   |  361 ---
 drivers/net/ixgbe/base/ixgbe_common.h   |9 +-
 drivers/net/ixgbe/base/ixgbe_mbx.h  |4 +-
 drivers/net/ixgbe/base/ixgbe_osdep.h|1 +
 drivers/net/ixgbe/base/ixgbe_phy.c  |   16 +-
 drivers/net/ixgbe/base/ixgbe_phy.h  |3 +
 drivers/net/ixgbe/base/ixgbe_type.h |  118 ++-
 drivers/net/ixgbe/base/ixgbe_vf.c   |   10 +-
 drivers/net/ixgbe/base/ixgbe_vf.h   |7 +-
 drivers/net/ixgbe/base/ixgbe_x540.c |   29 +-
 drivers/net/ixgbe/base/ixgbe_x540.h |1 +
 drivers/net/ixgbe/base/ixgbe_x550.c | 1158 +++
 drivers/net/ixgbe/base/ixgbe_x550.h |   52 +
 drivers/net/ixgbe/ixgbe_ethdev.c|   11 +-
 drivers/net/ixgbe/ixgbe_pf.c|2 +-
 lib/librte_eal/common/include/rte_pci_dev_ids.h |   12 +-
 23 files changed, 1457 insertions(+), 416 deletions(-)

Acked-by: Helin Zhang 
-- 
2.5.0



[dpdk-dev] [PATCH v3] i40e: fix the type issue of a single VLAN type

2016-06-22 Thread Beilei Xing
In current i40e codebase, if single VLAN header is added in a packet,
it's treated as inner VLAN. Generally, a single VLAN header is
treated as the outer VLAN header. So change corresponding register
for single VLAN.

Fixes: 19b16e2f6442 ("ethdev: add vlan type when setting ether type")

Signed-off-by: Beilei Xing 
---
v3 changes:
 Note it as a "fixed issue" in the i40e driver.
 Reword the title.
v2 changes:
 Combine corresponding i40e driver changes into this patch.

 doc/guides/rel_notes/release_16_07.rst |  7 +++
 drivers/net/i40e/i40e_ethdev.c | 29 -
 lib/librte_ether/rte_ethdev.h  |  4 ++--
 3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 7aeacb2..f6912a7 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -113,6 +113,13 @@ Drivers
   info to descriptor.
   Now this issue is fixed by disabling vlan stripping from inner header.

+* **i40e: Fixed the type issue of a single VLAN type.**
+
+  Currently, if a single VLAN header is added in a packet, it's treated
+  as inner VLAN. But generally, a single VLAN header is treated as the
+  outer VLAN header.
+  This issue is fixed by changing corresponding register for single VLAN.
+

 Libraries
 ~
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f94ad87..838889e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -924,12 +924,6 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 "VLAN ether type");
goto err_setup_pf_switch;
}
-   ret = i40e_vlan_tpid_set(dev, ETH_VLAN_TYPE_INNER, ETHER_TYPE_VLAN);
-   if (ret != I40E_SUCCESS) {
-   PMD_INIT_LOG(ERR, "Failed to set the default outer "
-"VLAN ether type");
-   goto err_setup_pf_switch;
-   }

/* PF setup, which includes VSI setup */
ret = i40e_pf_setup(pf);
@@ -2442,13 +2436,24 @@ i40e_vlan_tpid_set(struct rte_eth_dev *dev,
uint64_t reg_r = 0, reg_w = 0;
uint16_t reg_id = 0;
int ret = 0;
+   int qinq = dev->data->dev_conf.rxmode.hw_vlan_extend;

switch (vlan_type) {
case ETH_VLAN_TYPE_OUTER:
-   reg_id = 2;
+   if (qinq)
+   reg_id = 2;
+   else
+   reg_id = 3;
break;
case ETH_VLAN_TYPE_INNER:
-   reg_id = 3;
+   if (qinq)
+   reg_id = 3;
+   else {
+   ret = -EINVAL;
+   PMD_DRV_LOG(ERR, "Unsupported vlan type"
+   "in single vlan.\n");
+   return ret;
+   }
break;
default:
ret = -EINVAL;
@@ -2510,8 +2515,14 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
}

if (mask & ETH_VLAN_EXTEND_MASK) {
-   if (dev->data->dev_conf.rxmode.hw_vlan_extend)
+   if (dev->data->dev_conf.rxmode.hw_vlan_extend) {
i40e_vsi_config_double_vlan(vsi, TRUE);
+   /* Set global registers with default ether type value */
+   i40e_vlan_tpid_set(dev, ETH_VLAN_TYPE_OUTER,
+  ETHER_TYPE_VLAN);
+   i40e_vlan_tpid_set(dev, ETH_VLAN_TYPE_INNER,
+  ETHER_TYPE_VLAN);
+   }
else
i40e_vsi_config_double_vlan(vsi, FALSE);
}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index bd93bf6..6804a86 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -363,8 +363,8 @@ struct rte_eth_rxmode {
  */
 enum rte_vlan_type {
ETH_VLAN_TYPE_UNKNOWN = 0,
-   ETH_VLAN_TYPE_INNER, /**< Single VLAN, or inner VLAN. */
-   ETH_VLAN_TYPE_OUTER, /**< Outer VLAN. */
+   ETH_VLAN_TYPE_INNER, /**< Inner VLAN. */
+   ETH_VLAN_TYPE_OUTER, /**< Single VLAN, or outer VLAN. */
ETH_VLAN_TYPE_MAX,
 };

-- 
2.5.0



[dpdk-dev] [PATCH v4] e1000: configure VLAN TPID

2016-06-16 Thread Beilei Xing
This patch enables configuring the outer TPID for double VLAN.
Note that all other TPID values are read only.

Signed-off-by: Beilei Xing 
---
v4 changes:
 Optimize the code to be more readable.
v3 changes:
 Update commit log and comments.
v2 changes:
 Modify return value. Cause inner TPID is not supported by single
 VLAN,  return - ENOTSUP.
 Add return value. If want to set inner TPID of double VLAN or set
 outer TPID of single VLAN, return -ENOTSUP.

 drivers/net/e1000/igb_ethdev.c | 33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index f0921ee..0ed95c8 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -86,6 +86,13 @@
 #define E1000_INCVALUE_82576 (16 << IGB_82576_TSYNC_SHIFT)
 #define E1000_TSAUXC_DISABLE_SYSTIME 0x8000

+/* External VLAN Enable bit mask */
+#define E1000_CTRL_EXT_EXT_VLAN  (1 << 26)
+
+/* External VLAN Ether Type bit mask and shift */
+#define E1000_VET_VET_EXT0x
+#define E1000_VET_VET_EXT_SHIFT  16
+
 static int  eth_igb_configure(struct rte_eth_dev *dev);
 static int  eth_igb_start(struct rte_eth_dev *dev);
 static void eth_igb_stop(struct rte_eth_dev *dev);
@@ -2237,21 +2244,25 @@ eth_igb_vlan_tpid_set(struct rte_eth_dev *dev,
 {
struct e1000_hw *hw =
E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-   uint32_t reg = ETHER_TYPE_VLAN;
-   int ret = 0;
+   uint32_t reg, qinq;
+
+   qinq = E1000_READ_REG(hw, E1000_CTRL_EXT);
+   qinq &= E1000_CTRL_EXT_EXT_VLAN;

-   switch (vlan_type) {
-   case ETH_VLAN_TYPE_INNER:
-   reg |= (tpid << 16);
+   /* only outer TPID of double VLAN can be configured*/
+   if (qinq && vlan_type == ETH_VLAN_TYPE_OUTER) {
+   reg = E1000_READ_REG(hw, E1000_VET);
+   reg = (reg & (~E1000_VET_VET_EXT)) |
+   ((uint32_t)tpid << E1000_VET_VET_EXT_SHIFT);
E1000_WRITE_REG(hw, E1000_VET, reg);
-   break;
-   default:
-   ret = -EINVAL;
-   PMD_DRV_LOG(ERR, "Unsupported vlan type %d\n", vlan_type);
-   break;
+
+   return 0;
}

-   return ret;
+   /* all other TPID values are read-only*/
+   PMD_DRV_LOG(ERR, "Not supported");
+
+   return -ENOTSUP;
 }

 static void
-- 
2.5.0



[dpdk-dev] [PATCH v3] e1000: configure VLAN TPID

2016-06-16 Thread Beilei Xing
This patch enables configuring the outer TPID for double VLAN.
Note that outer TPID of single VLAN and inner TPID of double VLAN
are read only.

Signed-off-by: Beilei Xing 
---
v3 changes:
 Update commit log and comments.

 drivers/net/e1000/igb_ethdev.c | 37 ++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index f0921ee..1a5f1f1 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -86,6 +86,13 @@
 #define E1000_INCVALUE_82576 (16 << IGB_82576_TSYNC_SHIFT)
 #define E1000_TSAUXC_DISABLE_SYSTIME 0x8000

+/* External VLAN Enable bit mask */
+#define E1000_CTRL_EXT_EXT_VLAN  (1 << 26)
+
+/* External VLAN Ether Type bit mask and shift */
+#define E1000_VET_VET_EXT0x
+#define E1000_VET_VET_EXT_SHIFT  16
+
 static int  eth_igb_configure(struct rte_eth_dev *dev);
 static int  eth_igb_start(struct rte_eth_dev *dev);
 static void eth_igb_stop(struct rte_eth_dev *dev);
@@ -2237,13 +2244,37 @@ eth_igb_vlan_tpid_set(struct rte_eth_dev *dev,
 {
struct e1000_hw *hw =
E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-   uint32_t reg = ETHER_TYPE_VLAN;
+   uint32_t reg;
+   uint32_t qinq;
int ret = 0;

+   qinq = E1000_READ_REG(hw, E1000_CTRL_EXT);
+   qinq &= E1000_CTRL_EXT_EXT_VLAN;
+
switch (vlan_type) {
case ETH_VLAN_TYPE_INNER:
-   reg |= (tpid << 16);
-   E1000_WRITE_REG(hw, E1000_VET, reg);
+   if (qinq) {
+   ret = -ENOTSUP;
+   PMD_DRV_LOG(WARNING,
+   "Inner vlan ether type is read-only\n");
+   } else {
+   ret = -ENOTSUP;
+   PMD_DRV_LOG(ERR, "Inner type is not supported"
+   " by single vlan\n");
+   }
+   break;
+   case ETH_VLAN_TYPE_OUTER:
+   if (qinq) {
+   reg = E1000_READ_REG(hw, E1000_VET);
+   reg = (reg & (~E1000_VET_VET_EXT)) |
+   ((uint32_t)tpid << E1000_VET_VET_EXT_SHIFT);
+   E1000_WRITE_REG(hw, E1000_VET, reg);
+   } else {
+   ret = -ENOTSUP;
+   PMD_DRV_LOG(WARNING,
+   "Single vlan ether type is read-only\n");
+   }
+
break;
default:
ret = -EINVAL;
-- 
2.5.0



[dpdk-dev] [PATCH v3 30/30] ixgbe/base: update README

2016-06-15 Thread Beilei Xing
The ixgbe base driver was updated refer to version
cid-10g-shared-code.2016.04.12 released by ND.

The changes include:
Added sgmii link for X550.
Added mac link setup for X550a SFP and SFP+.
Added KR support for X550em_a.
Added new phy definitions for M88E1500.
Added support for the VLVF to be bypassed when adding/removing
a VFTA entry.
Added X550a flow control auto negotiation support.

Signed-off-by: Beilei Xing 
---
 doc/guides/rel_notes/release_16_07.rst | 11 +++
 drivers/net/ixgbe/base/README  |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index c0f6b02..fa224bc 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -15,6 +15,17 @@ DPDK Release 16.07

   firefox build/doc/html/guides/rel_notes/release_16_07.html

+* **Updated the ixgbe base driver.**
+  The ixgbe base driver was updated with changes including the
+  following:
+
+  * Added sgmii link for X550.
+  * Added mac link setup for X550a SFP and SFP+.
+  * Added KR support for X550em_a.
+  * Added new phy definitions for M88E1500.
+  * Added support for the VLVF to be bypassed when adding/removing a VFTA 
entry.
+  * Added X550a flow control auto negotiation support.
+

 New Features
 
diff --git a/drivers/net/ixgbe/base/README b/drivers/net/ixgbe/base/README
index caa2664..76e7805 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.01.07 released by ND. The sub-directory of base/
+cid-10g-shared-code.2016.04.12 released by ND. The sub-directory of base/
 contains the original source package.
 This driver is valid for the product(s) listed below

-- 
2.5.0



[dpdk-dev] [PATCH v3 29/30] ixgbe/base: define if enable crosstalk work around

2016-06-15 Thread Beilei Xing
A work around for a new crosstalk erratum that causes link flap in
entry cages has been introduced. So this patch defines the bit in
NVM that will tell software if this work around is needed.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index be51bee..83818a9 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -2405,6 +2405,7 @@ enum {
 #define IXGBE_SAN_MAC_ADDR_PORT1_OFFSET0x3
 #define IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP0x1
 #define IXGBE_DEVICE_CAPS_FCOE_OFFLOADS0x2
+#define IXGBE_DEVICE_CAPS_NO_CROSSTALK_WR  (1 << 7)
 #define IXGBE_FW_LESM_PARAMETERS_PTR   0x2
 #define IXGBE_FW_LESM_STATE_1  0x1
 #define IXGBE_FW_LESM_STATE_ENABLED0x8000 /* LESM Enable bit */
-- 
2.5.0



[dpdk-dev] [PATCH v3 28/30] ixgbe/base: add flow control autoneg for X550a

2016-06-15 Thread Beilei Xing
This patch adds X550a flow control auto negotiation support.
ixgbe_setup_fc_x550a and ixgbe_fc_autoneg_X550a functions where
added to setup and enable flow control. MAC ops function pointer
fc_autoneg was added so that hardware specific fc autoneg functions
can be called from ixgbe_fc_enable_generic.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.h|   2 +
 drivers/net/ixgbe/base/ixgbe_common.c |   5 +-
 drivers/net/ixgbe/base/ixgbe_type.h   |   6 ++
 drivers/net/ixgbe/base/ixgbe_x550.c   | 181 ++
 drivers/net/ixgbe/base/ixgbe_x550.h   |   2 +
 5 files changed, 194 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index c126982..3aad1da 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -217,5 +217,7 @@ s32 ixgbe_handle_lasi(struct ixgbe_hw *hw);
 void ixgbe_set_rate_select_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed);
 void ixgbe_disable_rx(struct ixgbe_hw *hw);
 void ixgbe_enable_rx(struct ixgbe_hw *hw);
+s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
+   u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);

 #endif /* _IXGBE_API_H_ */
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index e1d09e2..811875a 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -135,6 +135,7 @@ s32 ixgbe_init_ops_generic(struct ixgbe_hw *hw)
/* Flow Control */
mac->ops.fc_enable = ixgbe_fc_enable_generic;
mac->ops.setup_fc = ixgbe_setup_fc_generic;
+   mac->ops.fc_autoneg = ixgbe_fc_autoneg;

/* Link */
mac->ops.get_link_capabilities = NULL;
@@ -2739,7 +2740,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
}

/* Negotiate the fc mode to use */
-   ixgbe_fc_autoneg(hw);
+   hw->mac.ops.fc_autoneg(hw);

/* Disable any previous flow control settings */
mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
@@ -2849,7 +2850,7 @@ out:
  *  Find the intersection between advertised settings and link partner's
  *  advertised settings
  **/
-STATIC s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
+s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
  u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm)
 {
if ((!(adv_reg)) ||  (!(lp_reg))) {
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 5d76c72..be51bee 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3886,6 +3886,7 @@ struct ixgbe_mac_operations {
/* Flow Control */
s32 (*fc_enable)(struct ixgbe_hw *);
s32 (*setup_fc)(struct ixgbe_hw *);
+   void (*fc_autoneg)(struct ixgbe_hw *);

/* Manageability interface */
s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);
@@ -4131,10 +4132,12 @@ struct ixgbe_hw {
 #define IXGBE_FUSES0_REV_MASK  (3 << 6)

 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
+#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_8(P) ((P) ? 0x8248 : 0x4248)
 #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)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
 #define IXGBE_KRM_RX_TRN_LINKUP_CTRL(P)((P) ? 0x8B00 : 0x4B00)
@@ -4156,6 +4159,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR   (1 << 18)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX  (1 << 24)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR  (1 << 26)
+#define IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE  (1 << 28)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE   (1 << 29)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART  (1 << 31)

@@ -4164,6 +4168,8 @@ struct ixgbe_hw {

 #define IXGBE_KRM_AN_CNTL_8_LINEAR (1 << 0)
 #define IXGBE_KRM_AN_CNTL_8_LIMITING   (1 << 1)
+#define IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE  (1 << 10)
+#define IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE  (1 << 11)

 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 99023e9..ae6b79f 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -666,6 +666,10 @@ s32 ixgbe_init_ops_X5

[dpdk-dev] [PATCH v3 27/30] ixgbe/base: allow setting MAC anti spoofing per VF

2016-06-15 Thread Beilei Xing
Make ixgbe_set_mac_anti_spoofing() consistent with the other
functions that deal with setting VLAN and Ethertype spoofing by
changing the prototype to accept a VF parameter.

Also change the logic for writing the PFVFSPOOF register to be similar
to the MAC and Ethertype functions.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 40 ++-
 drivers/net/ixgbe/base/ixgbe_common.h |  2 +-
 2 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 6e54628..e1d09e2 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4203,43 +4203,25 @@ out:
 /**
  *  ixgbe_set_mac_anti_spoofing - Enable/Disable MAC anti-spoofing
  *  @hw: pointer to hardware structure
- *  @enable: enable or disable switch for anti-spoofing
- *  @pf: Physical Function pool - do not enable anti-spoofing for the PF
+ *  @enable: enable or disable switch for MAC anti-spoofing
+ *  @vf: Virtual Function pool - VF Pool to set for MAC anti-spoofing
  *
  **/
-void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf)
+void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf)
 {
-   int j;
-   int pf_target_reg = pf >> 3;
-   int pf_target_shift = pf % 8;
-   u32 pfvfspoof = 0;
+   int vf_target_reg = vf >> 3;
+   int vf_target_shift = vf % 8;
+   u32 pfvfspoof;

if (hw->mac.type == ixgbe_mac_82598EB)
return;

+   pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
if (enable)
-   pfvfspoof = IXGBE_SPOOF_MACAS_MASK;
-
-   /*
-* PFVFSPOOF register array is size 8 with 8 bits assigned to
-* MAC anti-spoof enables in each register array element.
-*/
-   for (j = 0; j < pf_target_reg; j++)
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), pfvfspoof);
-
-   /*
-* The PF should be allowed to spoof so that it can support
-* emulation mode NICs.  Do not set the bits assigned to the PF
-*/
-   pfvfspoof &= (1 << pf_target_shift) - 1;
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), pfvfspoof);
-
-   /*
-* Remaining pools belong to the PF so they do not need to have
-* anti-spoofing enabled.
-*/
-   for (j++; j < IXGBE_PFVFSPOOF_REG_COUNT; j++)
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), 0);
+   pfvfspoof |= (1 << vf_target_shift);
+   else
+   pfvfspoof &= ~(1 << vf_target_shift);
+   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_common.h 
b/drivers/net/ixgbe/base/ixgbe_common.h
index a790ede..0545f85 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.h
+++ b/drivers/net/ixgbe/base/ixgbe_common.h
@@ -148,7 +148,7 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 
*wwnn_prefix,
 u16 *wwpn_prefix);

 s32 ixgbe_get_fcoe_boot_status_generic(struct ixgbe_hw *hw, u16 *bs);
-void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf);
+void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
 void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
 s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps);
 void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, u32 headroom,
-- 
2.5.0



[dpdk-dev] [PATCH v3 26/30] ixgbe/base: fix endianness issues

2016-06-15 Thread Beilei Xing
This patch fixes endianness issues about host interface command.

Fixes: ad66a85dce9a ("ixgbe/base: new FW values")
Fixes: 0790adeb5675 ("ixgbe/base: support X550em_a device")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_osdep.h |  1 +
 drivers/net/ixgbe/base/ixgbe_type.h  | 17 ++---
 drivers/net/ixgbe/base/ixgbe_x550.c  | 29 -
 3 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_osdep.h 
b/drivers/net/ixgbe/base/ixgbe_osdep.h
index 40b0b51..31cc1be 100644
--- a/drivers/net/ixgbe/base/ixgbe_osdep.h
+++ b/drivers/net/ixgbe/base/ixgbe_osdep.h
@@ -96,6 +96,7 @@ enum {
 #define IXGBE_NTOHL(_i)rte_be_to_cpu_32(_i)
 #define IXGBE_NTOHS(_i)rte_be_to_cpu_16(_i)
 #define IXGBE_CPU_TO_LE32(_i)  rte_cpu_to_le_32(_i)
+#define IXGBE_LE32_TO_CPU(_i) rte_le_to_cpu_32(_i)
 #define IXGBE_LE32_TO_CPUS(_i) rte_le_to_cpu_32(_i)
 #define IXGBE_CPU_TO_BE16(_i)  rte_cpu_to_be_16(_i)
 #define IXGBE_CPU_TO_BE32(_i)  rte_cpu_to_be_32(_i)
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index d91c4ed..5d76c72 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3050,6 +3050,12 @@ enum ixgbe_fdir_pballoc_type {

 /* Host Interface Command Structures */

+#ifdef C99
+#pragma pack(push, 1)
+#else
+#pragma pack(1)
+#endif /* C99 */
+
 struct ixgbe_hic_hdr {
u8 cmd;
u8 buf_len;
@@ -3127,17 +3133,22 @@ struct ixgbe_hic_internal_phy_req {
struct ixgbe_hic_hdr hdr;
u8 port_number;
u8 command_type;
-   u16 address;
+   __be16 address;
u16 rsv1;
-   u32 write_data;
+   __le32 write_data;
u16 pad;
 };

 struct ixgbe_hic_internal_phy_resp {
struct ixgbe_hic_hdr hdr;
-   u32 read_data;
+   __le32 read_data;
 };

+#ifdef C99
+#pragma pack(pop)
+#else
+#pragma pack()
+#endif /* C99 */

 /* Transmit Descriptor - Legacy */
 struct ixgbe_legacy_tx_desc {
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 1137179..99023e9 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1273,8 +1273,8 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
write_cmd.port_number = hw->bus.lan_id;
write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
-   write_cmd.address = (u16)reg_addr;
-   write_cmd.write_data = data;
+   write_cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
+   write_cmd.write_data = IXGBE_CPU_TO_LE32(data);

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
  sizeof(write_cmd),
@@ -1294,24 +1294,27 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
 u32 device_type, u32 *data)
 {
-   struct ixgbe_hic_internal_phy_req read_cmd;
+   union {
+   struct ixgbe_hic_internal_phy_req cmd;
+   struct ixgbe_hic_internal_phy_resp rsp;
+   } hic;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

-   memset(_cmd, 0, sizeof(read_cmd));
-   read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
-   read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
-   read_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
-   read_cmd.port_number = hw->bus.lan_id;
-   read_cmd.command_type = FW_INT_PHY_REQ_READ;
-   read_cmd.address = (u16)reg_addr;
+   memset(, 0, sizeof(hic));
+   hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
+   hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
+   hic.cmd.port_number = hw->bus.lan_id;
+   hic.cmd.command_type = FW_INT_PHY_REQ_READ;
+   hic.cmd.address = IXGBE_CPU_TO_BE16(reg_addr);

-   status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
- sizeof(read_cmd),
+   status = ixgbe_host_interface_command(hw, (u32 *),
+ sizeof(hic.cmd),
  IXGBE_HI_COMMAND_TIMEOUT, true);

/* Extract the register value from the response. */
-   *data = ((struct ixgbe_hic_internal_phy_resp *)_cmd)->read_data;
+   *data = IXGBE_LE32_TO_CPU(hic.rsp.read_data);

return status;
 }
-- 
2.5.0



[dpdk-dev] [PATCH v3 25/30] ixgbe/base: use u8 to replace u16 for a variable

2016-06-15 Thread Beilei Xing
Since PCIe standard defines maximum of 8 functions per device lan_id
is a value 0..7. Because of that, lan_id don't need to be u16.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 2 +-
 drivers/net/ixgbe/base/ixgbe_type.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 80ea3b9..6e54628 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -1034,7 +1034,7 @@ void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw)

reg = IXGBE_READ_REG(hw, IXGBE_STATUS);
bus->func = (reg & IXGBE_STATUS_LAN_ID) >> IXGBE_STATUS_LAN_ID_SHIFT;
-   bus->lan_id = bus->func;
+   bus->lan_id = (u8)bus->func;

/* check for a port swap */
reg = IXGBE_READ_REG(hw, IXGBE_FACTPS_BY_MAC(hw));
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 3bf0de0..d91c4ed 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3684,7 +3684,7 @@ struct ixgbe_bus_info {
enum ixgbe_bus_type type;

u16 func;
-   u16 lan_id;
+   u8 lan_id;
u16 instance_id;
 };

-- 
2.5.0



[dpdk-dev] [PATCH v3 24/30] ixgbe/base: unify coding style

2016-06-15 Thread Beilei Xing
This patch changes static keyword to STATIC definition, which can be
redefined depending on the compiler used.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 38 ++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 80f59fb..1137179 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "ixgbe_phy.h"

 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_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
+STATIC void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);

 /**
  *  ixgbe_init_ops_X550 - Inits func ptrs and MAC type
@@ -335,7 +335,7 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
  * @dev_type: always unused
  * @phy_data: Pointer to read data from PHY register
  */
-static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+STATIC s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
 u32 dev_type, u16 *phy_data)
 {
u32 i, data, command;
@@ -383,7 +383,7 @@ static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, 
u32 reg_addr,
  * @dev_type: always unused
  * @phy_data: Data to write to the PHY register
  */
-static s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+STATIC s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
  u32 dev_type, u16 phy_data)
 {
u32 i, command;
@@ -428,7 +428,7 @@ static s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, 
u32 reg_addr,
  *
  * Returns error code
  */
-static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
 {
u32 swfw_mask = hw->phy.phy_semaphore_mask;
u16 phy_id_high;
@@ -536,7 +536,7 @@ STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, 
u32 reg_addr,
  *
  * Returns an error code on error.
  **/
-static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
+STATIC s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
   u16 reg, u16 *val)
 {
return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
@@ -551,7 +551,7 @@ static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw 
*hw, u8 addr,
  *
  * Returns an error code on error.
  **/
-static s32
+STATIC s32
 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
 u16 reg, u16 *val)
 {
@@ -567,7 +567,7 @@ ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw 
*hw, u8 addr,
  *
  * Returns an error code on error.
  **/
-static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
+STATIC s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
u8 addr, u16 reg, u16 val)
 {
return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
@@ -582,7 +582,7 @@ static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw 
*hw,
  *
  * Returns an error code on error.
  **/
-static s32
+STATIC s32
 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
  u8 addr, u16 reg, u16 val)
 {
@@ -864,7 +864,7 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  * ixgbe_enable_eee_x550 - Enable EEE support
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
 {
u16 autoneg_eee_reg;
u32 link_reg;
@@ -919,7 +919,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
  * ixgbe_disable_eee_x550 - Disable EEE support
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
 {
u16 autoneg_eee_reg;
u32 link_reg;
@@ -1595,7 +1595,7 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
  * ixgbe_setup_sgmii - Set up link for sgmii
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
+STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
 bool autoneg_wait_to_complete)
 {
struct ixgbe_mac_info *mac = >mac;
@@ -1960,7 +1960,7 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
  *
  * Must be called while holding the PHY semaphore and token
  */
-static s32 ixgbe_set_master_slave_mode(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_set_master_slave_mode(struct ixgbe_hw *hw)
 {
u16 phy_data;
s32 rc;
@@

[dpdk-dev] [PATCH v3 23/30] ixgbe/base: add bypassing VLVF

2016-06-15 Thread Beilei Xing
This patch adds support for the VLVF to be bypassed when adding or
removing a VFTA entry.  The PF can utilize the default pool while
preserving the VLVF for the VFs use.
Meanwhile, update corresponding VF ops and drivers where corresponding
ops is invoked.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_82598.c  |  5 ++-
 drivers/net/ixgbe/base/ixgbe_82598.h  |  3 +-
 drivers/net/ixgbe/base/ixgbe_api.c| 11 --
 drivers/net/ixgbe/base/ixgbe_api.h|  5 ++-
 drivers/net/ixgbe/base/ixgbe_common.c | 71 +++
 drivers/net/ixgbe/base/ixgbe_common.h |  7 ++--
 drivers/net/ixgbe/base/ixgbe_type.h   |  5 ++-
 drivers/net/ixgbe/base/ixgbe_vf.c |  6 ++-
 drivers/net/ixgbe/base/ixgbe_vf.h |  3 +-
 drivers/net/ixgbe/ixgbe_ethdev.c  | 11 --
 drivers/net/ixgbe/ixgbe_pf.c  |  2 +-
 11 files changed, 76 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_82598.c 
b/drivers/net/ixgbe/base/ixgbe_82598.c
index 9e65fff..db80880 100644
--- a/drivers/net/ixgbe/base/ixgbe_82598.c
+++ b/drivers/net/ixgbe/base/ixgbe_82598.c
@@ -995,17 +995,20 @@ 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
  *
  *  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 vlan_on, bool bypass_vlvf)
 {
u32 regindex;
u32 bitindex;
u32 bits;
u32 vftabyte;

+   UNREFERENCED_1PARAMETER(bypass_vlvf);
+
DEBUGFUNC("ixgbe_set_vfta_82598");

if (vlan > 4095)
diff --git a/drivers/net/ixgbe/base/ixgbe_82598.h 
b/drivers/net/ixgbe/base/ixgbe_82598.h
index 89dd11a..0326e70 100644
--- a/drivers/net/ixgbe/base/ixgbe_82598.h
+++ b/drivers/net/ixgbe/base/ixgbe_82598.h
@@ -39,7 +39,8 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw);
 s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw);
 void ixgbe_enable_relaxed_ordering_82598(struct ixgbe_hw *hw);
 s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
-s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool 
vlan_on);
+s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
+bool vlvf_bypass);
 s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val);
 s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val);
 s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 90deaf1..1786867 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1082,13 +1082,15 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
  *  @vlan: VLAN id to write to VLAN filter
  *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
  *  @vlan_on: boolean flag to turn on/off VLAN
+ *  @vlvf_bypass: boolean flag indicating updating the default pool is okay
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
-s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on)
+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), IXGBE_NOT_IMPLEMENTED);
+ vlan_on, vlvf_bypass), IXGBE_NOT_IMPLEMENTED);
 }

 /**
@@ -1100,14 +1102,15 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on)
  *  @vfta_delta: pointer to the difference between the current value of VFTA
  *   and the desired value
  *  @vfta: the desired value of the VFTA
+ *  @vlvf_bypass: boolean flag indicating updating the default pool is okay
  *
  *  Turn on/off specified bit in VLVF table.
  **/
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
-  u32 *vfta_delta, u32 vfta)
+  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),
+   vlan_on, vfta_delta, vfta, vlvf_bypass),
   IXGBE_NOT_IMPLEMENTED);
 }

diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index 9431d14..c126982 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -124,9 +124,10 @@ s32 ixgbe_enable_mc(struct ixgbe_hw *hw);
 s32 ixgbe_disable_mc(struct ixgbe_hw *hw);
 s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);
 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan,
- 

[dpdk-dev] [PATCH v3 22/30] ixgbe/base: simplify add/remove VLANs

2016-06-15 Thread Beilei Xing
This patch simplifies the adding and removing VLANs from
VFTA/VLVF/VLVFB registers. The logic to determine registers has
been simplified to (vid / 32) and (1 - vid / 32). Many conditional
paths and checks are no longer needed with this patch.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c|  18 ++--
 drivers/net/ixgbe/base/ixgbe_api.h|   2 +-
 drivers/net/ixgbe/base/ixgbe_common.c | 188 ++
 drivers/net/ixgbe/base/ixgbe_common.h |   2 +-
 drivers/net/ixgbe/base/ixgbe_type.h   |   2 +-
 5 files changed, 91 insertions(+), 121 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index e117b86..90deaf1 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1080,8 +1080,8 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
  *  ixgbe_set_vfta - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @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
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
@@ -1095,18 +1095,20 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on)
  *  ixgbe_set_vlvf - Set VLAN Pool Filter
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
- *  @vfta_changed: pointer to boolean flag which indicates whether VFTA
- * should be changed
+ *  @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
+ *  @vfta: the desired value of the VFTA
  *
  *  Turn on/off specified bit in VLVF table.
  **/
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
-   bool *vfta_changed)
+  u32 *vfta_delta, u32 vfta)
 {
return ixgbe_call_func(hw, hw->mac.ops.set_vlvf, (hw, vlan, vind,
-  vlan_on, vfta_changed), IXGBE_NOT_IMPLEMENTED);
+  vlan_on, vfta_delta, vfta),
+  IXGBE_NOT_IMPLEMENTED);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index f5970a8..9431d14 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -126,7 +126,7 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);
 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan,
   u32 vind, bool vlan_on);
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
-  bool vlan_on, bool *vfta_changed);
+  bool vlan_on, u32 *vfta_delta, u32 vfta);
 s32 ixgbe_fc_enable(struct ixgbe_hw *hw);
 s32 ixgbe_setup_fc(struct ixgbe_hw *hw);
 s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build,
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 0a708cf..4551a2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -3853,24 +3853,20 @@ s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan)
  *  ixgbe_set_vfta_generic - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
 s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
   bool vlan_on)
 {
-   s32 regindex;
-   u32 bitindex;
-   u32 vfta;
-   u32 targetbit;
-   s32 ret_val = IXGBE_SUCCESS;
-   bool vfta_changed = false;
+   u32 regidx, vfta_delta, vfta;
+   s32 ret_val;

DEBUGFUNC("ixgbe_set_vfta_generic");

-   if (vlan > 4095)
+   if (vlan > 4095 || vind > 63)
return IXGBE_ERR_PARAM;

/*
@@ -3885,33 +3881,28 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 
vlan, u32 vind,
 *bits[11-5]: which register
 *bits[4-0]:  which bit in the register
 */
-   regindex = (vlan >> 5) & 0x7F;
-   bitindex = vlan & 0x1F;
-   targetbit = (1 << bitindex);
-   vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
-
-   if (vlan_on) {
-   if (!(vfta & targetbit)) {
-   vfta |= targetbit;
-   vfta_ch

[dpdk-dev] [PATCH v3 21/30] ixgbe/base: limit PHY token accessing to MDIO only

2016-06-15 Thread Beilei Xing
This patch limits getting and putting the PHY Token to PHY MDIO
access only by adding ixgbe_read_phy_reg_x550a and
ixgbe_write_phy_reg_x550a. The PHY Token is only needed to
synchronize access to the MDIO shared between the two MAC instance.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 65 +++--
 drivers/net/ixgbe/base/ixgbe_x550.h |  4 +++
 2 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 7aad0bd..80f59fb 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -469,7 +469,8 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
 {
switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_A_SFP:
-   hw->phy.phy_semaphore_mask = IXGBE_GSSR_TOKEN_SM;
+   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
@@ -499,7 +500,8 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
return ixgbe_identify_phy_generic(hw);
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
-   hw->phy.phy_semaphore_mask = IXGBE_GSSR_TOKEN_SM;
+   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
@@ -1245,6 +1247,8 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
return status;
if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
return IXGBE_SUCCESS;
+
+   DEBUGOUT("Put PHY Token host interface command failed");
return IXGBE_ERR_FW_RESP_INVALID;
 }

@@ -3870,6 +3874,63 @@ static void ixgbe_release_swfw_sync_X550a(struct 
ixgbe_hw *hw, u32 mask)
 }

 /**
+ *  ixgbe_read_phy_reg_x550a  - Reads specified PHY register
+ *  @hw: pointer to hardware structure
+ *  @reg_addr: 32 bit address of PHY register to read
+ *  @phy_data: Pointer to read data from PHY register
+ *
+ *  Reads a value from a specified PHY register using the SWFW lock and PHY
+ *  Token. The PHY Token is needed since the MDIO is shared between to MAC
+ *  instances.
+ **/
+s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+u32 device_type, u16 *phy_data)
+{
+   s32 status;
+   u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
+
+   DEBUGFUNC("ixgbe_read_phy_reg_x550a");
+
+   if (hw->mac.ops.acquire_swfw_sync(hw, mask))
+   return IXGBE_ERR_SWFW_SYNC;
+
+   status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
+
+   hw->mac.ops.release_swfw_sync(hw, mask);
+
+   return status;
+}
+
+/**
+ *  ixgbe_write_phy_reg_x550a - Writes specified PHY register
+ *  @hw: pointer to hardware structure
+ *  @reg_addr: 32 bit PHY register to write
+ *  @device_type: 5 bit device type
+ *  @phy_data: Data to write to the PHY register
+ *
+ *  Writes a value to specified PHY register using the SWFW lock and PHY Token.
+ *  The PHY Token is needed since the MDIO is shared between to MAC instances.
+ **/
+s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u16 phy_data)
+{
+   s32 status;
+   u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
+
+   DEBUGFUNC("ixgbe_write_phy_reg_x550a");
+
+   if (hw->mac.ops.acquire_swfw_sync(hw, mask) == IXGBE_SUCCESS) {
+   status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type,
+phy_data);
+   hw->mac.ops.release_swfw_sync(hw, mask);
+   } else {
+   status = IXGBE_ERR_SWFW_SYNC;
+   }
+
+   return status;
+}
+
+/**
  * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
  * @hw: pointer to hardware structure
  *
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.h 
b/drivers/net/ixgbe/base/ixgbe_x550.h
index a6ec3cb..b597b50 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.h
+++ b/drivers/net/ixgbe/base/ixgbe_x550.h
@@ -146,6 +146,10 @@ s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
 s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
   ixgbe_link_speed speed,
   bool autoneg_wait_to_complete);
+s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+u32 device_type, u16 *phy_data);
+s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device

[dpdk-dev] [PATCH v3 20/30] ixgbe/base: fix register access error

2016-06-15 Thread Beilei Xing
This patch corrects the FLA/GSCL/GSCN access offset value according
to the datasheet.

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

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 42 -
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index f40580d..ec1f4e0 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -196,7 +196,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_FLA_X540 IXGBE_FLA
 #define IXGBE_FLA_X550 IXGBE_FLA
 #define IXGBE_FLA_X550EM_x IXGBE_FLA
-#define IXGBE_FLA_X550EM_a 0x15F6C
+#define IXGBE_FLA_X550EM_a 0x15F68
 #define IXGBE_FLA_BY_MAC(_hw)  IXGBE_BY_MAC((_hw), FLA)

 #define IXGBE_EEMNGCTL 0x10110
@@ -1080,16 +1080,40 @@ struct ixgbe_dmac_config {
 #define IXGBE_PCIEPIPEDAT  0x11008
 #define IXGBE_GSCL_1   0x11010
 #define IXGBE_GSCL_2   0x11014
+#define IXGBE_GSCL_1_X540  IXGBE_GSCL_1
+#define IXGBE_GSCL_2_X540  IXGBE_GSCL_2
 #define IXGBE_GSCL_3   0x11018
 #define IXGBE_GSCL_4   0x1101C
 #define IXGBE_GSCN_0   0x11020
 #define IXGBE_GSCN_1   0x11024
 #define IXGBE_GSCN_2   0x11028
 #define IXGBE_GSCN_3   0x1102C
+#define IXGBE_GSCN_0_X540  IXGBE_GSCN_0
+#define IXGBE_GSCN_1_X540  IXGBE_GSCN_1
+#define IXGBE_GSCN_2_X540  IXGBE_GSCN_2
+#define IXGBE_GSCN_3_X540  IXGBE_GSCN_3
 #define IXGBE_FACTPS   0x10150
 #define IXGBE_FACTPS_X540  IXGBE_FACTPS
+#define IXGBE_GSCL_1_X550  0x11800
+#define IXGBE_GSCL_2_X550  0x11804
+#define IXGBE_GSCL_1_X550EM_x  IXGBE_GSCL_1_X550
+#define IXGBE_GSCL_2_X550EM_x  IXGBE_GSCL_2_X550
+#define IXGBE_GSCN_0_X550  0x11820
+#define IXGBE_GSCN_1_X550  0x11824
+#define IXGBE_GSCN_2_X550  0x11828
+#define IXGBE_GSCN_3_X550  0x1182C
+#define IXGBE_GSCN_0_X550EM_x  IXGBE_GSCN_0_X550
+#define IXGBE_GSCN_1_X550EM_x  IXGBE_GSCN_1_X550
+#define IXGBE_GSCN_2_X550EM_x  IXGBE_GSCN_2_X550
+#define IXGBE_GSCN_3_X550EM_x  IXGBE_GSCN_3_X550
 #define IXGBE_FACTPS_X550  IXGBE_FACTPS
 #define IXGBE_FACTPS_X550EM_x  IXGBE_FACTPS
+#define IXGBE_GSCL_1_X550EM_a  IXGBE_GSCL_1_X550
+#define IXGBE_GSCL_2_X550EM_a  IXGBE_GSCL_2_X550
+#define IXGBE_GSCN_0_X550EM_a  IXGBE_GSCN_0_X550
+#define IXGBE_GSCN_1_X550EM_a  IXGBE_GSCN_1_X550
+#define IXGBE_GSCN_2_X550EM_a  IXGBE_GSCN_2_X550
+#define IXGBE_GSCN_3_X550EM_a  IXGBE_GSCN_3_X550
 #define IXGBE_FACTPS_X550EM_a  0x15FEC
 #define IXGBE_FACTPS_BY_MAC(_hw)   IXGBE_BY_MAC((_hw), FACTPS)

@@ -1126,6 +1150,10 @@ struct ixgbe_dmac_config {
 #define IXGBE_GSCL_6_82599 0x11034
 #define IXGBE_GSCL_7_82599 0x11038
 #define IXGBE_GSCL_8_82599 0x1103C
+#define IXGBE_GSCL_5_X540  IXGBE_GSCL_5_82599
+#define IXGBE_GSCL_6_X540  IXGBE_GSCL_6_82599
+#define IXGBE_GSCL_7_X540  IXGBE_GSCL_7_82599
+#define IXGBE_GSCL_8_X540  IXGBE_GSCL_8_82599
 #define IXGBE_PHYADR_82599 0x11040
 #define IXGBE_PHYDAT_82599 0x11044
 #define IXGBE_PHYCTL_82599 0x11048
@@ -1136,10 +1164,22 @@ struct ixgbe_dmac_config {
 #define IXGBE_CIAD_82599   IXGBE_CIAD
 #define IXGBE_CIAA_X540IXGBE_CIAA
 #define IXGBE_CIAD_X540IXGBE_CIAD
+#define IXGBE_GSCL_5_X550  0x11810
+#define IXGBE_GSCL_6_X550  0x11814
+#define IXGBE_GSCL_7_X550  0x11818
+#define IXGBE_GSCL_8_X550  0x1181C
+#define IXGBE_GSCL_5_X550EM_x  IXGBE_GSCL_5_X550
+#define IXGBE_GSCL_6_X550EM_x  IXGBE_GSCL_6_X550
+#define IXGBE_GSCL_7_X550EM_x  IXGBE_GSCL_7_X550
+#define IXGBE_GSCL_8_X550EM_x  IXGBE_GSCL_8_X550
 #define IXGBE_CIAA_X5500x11508
 #define IXGBE_CIAD_X5500x11510
 #define IXGBE_CIAA_X550EM_xIXGBE_CIAA_X550
 #define IXGBE_CIAD_X550EM_xIXGBE_CIAD_X550
+#define IXGBE_GSCL_5_X550EM_a  IXGBE_GSCL_5_X550
+#define IXGBE_GSCL_6_X550EM_a  IXGBE_GSCL_6_X550
+#define IXGBE_GSCL_7_X550EM_a  IXGBE_GSCL_7_X550
+#define IXGBE_GSCL_8_X550EM_a  IXGBE_GSCL_8_X550
 #define IXGBE_CIAA_X550EM_aIXGBE_CIAA_X550
 #define IXGBE_CIAD_X550EM_aIXGBE_CIAD_X550
 #define IXGBE_CIAA_BY_MAC(_hw) IXGBE_BY_MAC((_hw), CIAA)
-- 
2.5.0



[dpdk-dev] [PATCH v3 19/30] ixgbe/base: fix possible race issue

2016-06-15 Thread Beilei Xing
This patch fixes possible race issue between ports when issuing host
interface command by acquiring/releasing the management host interface
semaphore in ixgbe_host_interface_command.

Fixes: 36f43e8679ae ("ixgbe/base: refactor manageability block communication")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 40 ---
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 0a74714..0a708cf 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4373,8 +4373,9 @@ u8 ixgbe_calculate_checksum(u8 *buffer, u32 length)
  *   So we will leave this up to the caller to read back the data
  *   in these cases.
  *
- *  Communicates with the manageability block.  On success return IXGBE_SUCCESS
- *  else return IXGBE_ERR_HOST_INTERFACE_COMMAND.
+ *  Communicates with the manageability block. On success return IXGBE_SUCCESS
+ *  else returns semaphore error when encountering an error acquiring
+ *  semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
  **/
 s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
 u32 length, u32 timeout, bool return_data)
@@ -4383,6 +4384,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
u32 hdr_size = sizeof(struct ixgbe_hic_hdr);
u16 buf_len;
u16 dword_len;
+   s32 status;

DEBUGFUNC("ixgbe_host_interface_command");

@@ -4390,6 +4392,11 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
DEBUGOUT1("Buffer length failure buffersize=%d.\n", length);
return IXGBE_ERR_HOST_INTERFACE_COMMAND;
}
+   /* Take management host interface semaphore */
+   status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
+
+   if (status)
+   return status;

/* Set bit 9 of FWSTS clearing FW reset indication */
fwsts = IXGBE_READ_REG(hw, IXGBE_FWSTS);
@@ -4399,13 +4406,15 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
hicr = IXGBE_READ_REG(hw, IXGBE_HICR);
if ((hicr & IXGBE_HICR_EN) == 0) {
DEBUGOUT("IXGBE_HOST_EN bit disabled.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

/* Calculate length in DWORDs. We must be DWORD aligned */
if ((length % (sizeof(u32))) != 0) {
DEBUGOUT("Buffer length failure, not aligned to dword");
-   return IXGBE_ERR_INVALID_ARGUMENT;
+   status = IXGBE_ERR_INVALID_ARGUMENT;
+   goto rel_out;
}

dword_len = length >> 2;
@@ -4432,11 +4441,12 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV)) {
ERROR_REPORT1(IXGBE_ERROR_CAUTION,
 "Command has failed with no status valid.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

if (!return_data)
-   return 0;
+   goto rel_out;

/* Calculate length in DWORDs */
dword_len = hdr_size >> 2;
@@ -4450,11 +4460,12 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
/* If there is any thing in data position pull it in */
buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len;
if (buf_len == 0)
-   return 0;
+   goto rel_out;

if (length < buf_len + hdr_size) {
DEBUGOUT("Buffer not large enough for reply message.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

/* Calculate length in DWORDs, add 3 for odd lengths */
@@ -4466,7 +4477,10 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
IXGBE_LE32_TO_CPUS([bi]);
}

-   return 0;
+rel_out:
+   hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
+
+   return status;
 }

 /**
@@ -4491,12 +4505,6 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 
maj, u8 min,

DEBUGFUNC("ixgbe_set_fw_drv_ver_generic");

-   if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM)
-   != IXGBE_SUCCESS) {
-   ret_val = IXGBE_ERR_SWFW_SYNC;
-   goto out;
-   }
-
fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN;
fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;

[dpdk-dev] [PATCH v3 18/30] ixgbe/base: add function to reset swfw semaphore

2016-06-15 Thread Beilei Xing
For X540 and forward it is possible if a system reset occur at the
right time to leave the SWFW semaphore high. This new function will
attempt to grab and release the semaphore. If the grab times out it
will still release the semaphore placing it in a known good state.
The idea is to call this when you know no one should be holding the
semaphore (i.e. probe time)

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c| 14 ++
 drivers/net/ixgbe/base/ixgbe_api.h|  1 +
 drivers/net/ixgbe/base/ixgbe_common.c |  1 +
 drivers/net/ixgbe/base/ixgbe_type.h   |  1 +
 drivers/net/ixgbe/base/ixgbe_x540.c   | 20 
 drivers/net/ixgbe/base/ixgbe_x540.h   |  1 +
 6 files changed, 38 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 19e52c9..e117b86 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1639,6 +1639,20 @@ void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, 
u32 mask)
hw->mac.ops.release_swfw_sync(hw, mask);
 }

+/**
+ *  ixgbe_init_swfw_semaphore - Clean up SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *
+ *  Attempts to acquire the SWFW semaphore through SW_FW_SYNC register.
+ *  Regardless of whether is succeeds or not it then release the semaphore.
+ *  This is function is called to recover from catastrophic failures that
+ *  may have left the semaphore locked.
+ **/
+void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw)
+{
+   if (hw->mac.ops.init_swfw_sync)
+   hw->mac.ops.init_swfw_sync(hw);
+}

 void ixgbe_disable_rx(struct ixgbe_hw *hw)
 {
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index ae26a6a..f5970a8 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -191,6 +191,7 @@ s32 ixgbe_set_san_mac_addr(struct ixgbe_hw *hw, u8 
*san_mac_addr);
 s32 ixgbe_get_device_caps(struct ixgbe_hw *hw, u16 *device_caps);
 s32 ixgbe_acquire_swfw_semaphore(struct ixgbe_hw *hw, u32 mask);
 void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, u32 mask);
+void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw);
 s32 ixgbe_get_wwn_prefix(struct ixgbe_hw *hw, u16 *wwnn_prefix,
 u16 *wwpn_prefix);
 s32 ixgbe_get_fcoe_boot_status(struct ixgbe_hw *hw, u16 *bs);
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index d211303..0a74714 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4390,6 +4390,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
DEBUGOUT1("Buffer length failure buffersize=%d.\n", length);
return IXGBE_ERR_HOST_INTERFACE_COMMAND;
}
+
/* Set bit 9 of FWSTS clearing FW reset indication */
fwsts = IXGBE_READ_REG(hw, IXGBE_FWSTS);
IXGBE_WRITE_REG(hw, IXGBE_FWSTS, fwsts | IXGBE_FWSTS_FWRI);
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 6a837f1..f40580d 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3785,6 +3785,7 @@ struct ixgbe_mac_operations {
s32 (*enable_sec_rx_path)(struct ixgbe_hw *);
s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u32);
void (*release_swfw_sync)(struct ixgbe_hw *, u32);
+   void (*init_swfw_sync)(struct ixgbe_hw *);
s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *);
s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool);

diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c 
b/drivers/net/ixgbe/base/ixgbe_x540.c
index 0678913..31dead0 100644
--- a/drivers/net/ixgbe/base/ixgbe_x540.c
+++ b/drivers/net/ixgbe/base/ixgbe_x540.c
@@ -99,6 +99,7 @@ s32 ixgbe_init_ops_X540(struct ixgbe_hw *hw)
mac->ops.get_fcoe_boot_status = ixgbe_get_fcoe_boot_status_generic;
mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X540;
mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X540;
+   mac->ops.init_swfw_sync = ixgbe_init_swfw_sync_X540;
mac->ops.disable_sec_rx_path = ixgbe_disable_sec_rx_path_generic;
mac->ops.enable_sec_rx_path = ixgbe_enable_sec_rx_path_generic;

@@ -946,6 +947,25 @@ STATIC void ixgbe_release_swfw_sync_semaphore(struct 
ixgbe_hw *hw)
 }

 /**
+ *  ixgbe_init_swfw_sync_X540 - Release hardware semaphore
+ *  @hw: pointer to hardware structure
+ *
+ *  This function reset hardware semaphore bits for a semaphore that may
+ *  have be left locked due to a catastrophic failure.
+ **/
+void ixgbe_init_swfw_sync_X540(struct ixgbe_hw *hw)
+{
+   /* First try to grab the semaphore but we don't need to bother
+* looking to see whether we got the lock or  not since we do
+* the same thing regardless of whether we got the lock or not.
+* We got the lock - we release it.
+* We time

[dpdk-dev] [PATCH v3 17/30] ixgbe/base: change device IDs

2016-06-15 Thread Beilei Xing
There're two device IDs changed from 15C6/15C7 to 15E4/15E5 cause
PHY info changes. Make the change and use 15C6/15C7 for the backplane
SGMII. Clean up some discovery kludges from the previous shared ID,
and also add 15C6/15C7 to ixgbe_set_mdio_speed just for paranoia
to control MDIO speed even though nothing should be attached.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c  |  2 ++
 drivers/net/ixgbe/base/ixgbe_type.h |  7 ---
 drivers/net/ixgbe/base/ixgbe_x550.c | 17 -
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 12 
 4 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index cf1e516..19e52c9 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -209,6 +209,8 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_KR:
case IXGBE_DEV_ID_X550EM_A_KR_L:
case IXGBE_DEV_ID_X550EM_A_SFP_N:
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index f1379be..6a837f1 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -133,12 +133,14 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_DEV_ID_X550EM_A_KR   0x15C2
 #define IXGBE_DEV_ID_X550EM_A_KR_L 0x15C3
 #define IXGBE_DEV_ID_X550EM_A_SFP_N0x15C4
-#define IXGBE_DEV_ID_X550EM_A_1G_T 0x15C6
-#define IXGBE_DEV_ID_X550EM_A_1G_T_L   0x15C7
+#define IXGBE_DEV_ID_X550EM_A_SGMII0x15C6
+#define IXGBE_DEV_ID_X550EM_A_SGMII_L  0x15C7
 #define IXGBE_DEV_ID_X550EM_A_10G_T0x15C8
 #define IXGBE_DEV_ID_X550EM_A_QSFP 0x15CA
 #define IXGBE_DEV_ID_X550EM_A_QSFP_N   0x15CC
 #define IXGBE_DEV_ID_X550EM_A_SFP  0x15CE
+#define IXGBE_DEV_ID_X550EM_A_1G_T 0x15E4
+#define IXGBE_DEV_ID_X550EM_A_1G_T_L   0x15E5
 #define IXGBE_DEV_ID_X550EM_X_KX4  0x15AA
 #define IXGBE_DEV_ID_X550EM_X_KR   0x15AB
 #define IXGBE_DEV_ID_X550EM_X_SFP  0x15AC
@@ -3562,7 +3564,6 @@ enum ixgbe_media_type {
ixgbe_media_type_fiber_lco,
ixgbe_media_type_copper,
ixgbe_media_type_backplane,
-   ixgbe_media_type_sgmii,
ixgbe_media_type_cx4,
ixgbe_media_type_virtual
 };
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index a4b444b..7aad0bd 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1487,10 +1487,15 @@ enum ixgbe_media_type 
ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_10G_T:
media_type = ixgbe_media_type_copper;
break;
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
+   media_type = ixgbe_media_type_backplane;
+   hw->phy.type = ixgbe_phy_sgmii;
+   break;
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
-   media_type = ixgbe_media_type_sgmii;
-   hw->phy.type = ixgbe_phy_sgmii;
+   media_type = ixgbe_media_type_copper;
+   hw->phy.type = ixgbe_phy_m88;
break;
default:
media_type = ixgbe_media_type_unknown;
@@ -1667,9 +1672,9 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.check_link = ixgbe_check_link_t_X550em;
break;
case ixgbe_media_type_backplane:
-   break;
-   case ixgbe_media_type_sgmii:
-   mac->ops.setup_link = ixgbe_setup_sgmii;
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
+   hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
+   mac->ops.setup_link = ixgbe_setup_sgmii;
break;
default:
break;
@@ -2229,6 +2234,8 @@ static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)

switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_X_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h 
b/lib/librte_eal/common/include/rte_pci_dev_ids.h
index cf7b548..63648c7 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -446,12 +446,14 @@ RTE_PCI_DEV_ID_DECL_IGB(PCI_VENDOR_ID_INTEL, 
E1000_DEV_ID_DH89XXCC_SFP)
 #defi

[dpdk-dev] [PATCH v3 16/30] ixgbe/base: add new phy definitions

2016-06-15 Thread Beilei Xing
It adds new phy definitions.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_phy.c  |  16 +-
 drivers/net/ixgbe/base/ixgbe_type.h |  14 +-
 drivers/net/ixgbe/base/ixgbe_x550.c | 303 ++--
 drivers/net/ixgbe/base/ixgbe_x550.h |  43 +
 4 files changed, 355 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c 
b/drivers/net/ixgbe/base/ixgbe_phy.c
index 6ed685e..ed1b14f 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.c
+++ b/drivers/net/ixgbe/base/ixgbe_phy.c
@@ -454,6 +454,9 @@ enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
case X557_PHY_ID:
phy_type = ixgbe_phy_x550em_ext_t;
break;
+   case IXGBE_M88E1500_E_PHY_ID:
+   phy_type = ixgbe_phy_m88;
+   break;
default:
phy_type = ixgbe_phy_unknown;
break;
@@ -615,13 +618,12 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 
reg_addr,

DEBUGFUNC("ixgbe_read_phy_reg_generic");

-   if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
-   status = ixgbe_read_phy_reg_mdi(hw, reg_addr, device_type,
-   phy_data);
-   hw->mac.ops.release_swfw_sync(hw, gssr);
-   } else {
-   status = IXGBE_ERR_SWFW_SYNC;
-   }
+   if (hw->mac.ops.acquire_swfw_sync(hw, gssr))
+   return IXGBE_ERR_SWFW_SYNC;
+
+   status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
+
+   hw->mac.ops.release_swfw_sync(hw, gssr);

return status;
 }
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index da1fe16..f1379be 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -1607,7 +1607,8 @@ struct ixgbe_dmac_config {
 #define ATH_PHY_ID 0x03429050

 /* PHY Types */
-#define IXGBE_M88E1145_E_PHY_ID0x01410CD0
+#define IXGBE_M88E1500_E_PHY_ID0x01410DD0
+#define IXGBE_M88E1543_E_PHY_ID0x01410EA0

 /* Special PHY Init Routine */
 #define IXGBE_PHY_INIT_OFFSET_NL   0x002B
@@ -3250,6 +3251,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_100_FULL  0x0008
 #define IXGBE_LINK_SPEED_1GB_FULL  0x0020
 #define IXGBE_LINK_SPEED_2_5GB_FULL0x0400
@@ -3574,6 +3576,14 @@ enum ixgbe_fc_mode {
ixgbe_fc_default
 };

+/* Master/slave control */
+enum ixgbe_ms_type {
+   ixgbe_ms_hw_default = 0,
+   ixgbe_ms_force_master,
+   ixgbe_ms_force_slave,
+   ixgbe_ms_auto
+};
+
 /* Smart Speed Settings */
 #define IXGBE_SMARTSPEED_MAX_RETRIES   3
 enum ixgbe_smart_speed {
@@ -3949,6 +3959,8 @@ struct ixgbe_phy_info {
bool reset_disable;
ixgbe_autoneg_advertised autoneg_advertised;
ixgbe_link_speed speeds_supported;
+   enum ixgbe_ms_type ms_type;
+   enum ixgbe_ms_type original_ms_type;
enum ixgbe_smart_speed smart_speed;
bool smart_speed_active;
bool multispeed_fiber;
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 993ef16..a4b444b 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -329,6 +329,100 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_read_phy_reg_mdi_22 - Read from a clause 22 PHY register without lock
+ * @hw: pointer to hardware structure
+ * @reg_addr: 32 bit address of PHY register to read
+ * @dev_type: always unused
+ * @phy_data: Pointer to read data from PHY register
+ */
+static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+u32 dev_type, u16 *phy_data)
+{
+   u32 i, data, command;
+   UNREFERENCED_1PARAMETER(dev_type);
+
+   /* Setup and write the read command */
+   command = (reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
+   (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
+   (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+   IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_READ |
+   IXGBE_MSCA_MDI_COMMAND;
+
+   IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
+
+   /* Check every 10 usec to see if the access completed.
+* The MDI Command bit will clear when the operation is
+* complete
+*/
+   for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+   usec_delay(10);
+
+   command = IXGBE_READ_REG(hw, IXGBE_MSCA);
+   if (!(command & IXGBE_MSCA_MDI_COMMAND))
+   break;
+   }
+
+   if (command & IXGBE_MSCA_MDI_COMMAND) {
+   ERROR_REPORT1(IXGBE_ERROR_POLLING,
+ "PHY read comma

[dpdk-dev] [PATCH v3 15/30] ixgbe/base: refactor NW management interface ops

2016-06-15 Thread Beilei Xing
This patch adds ixgbe_read_mng_if_sel_x550em to read NW_MNG_IF_SEL
register and save fields such as PHY MDIO_ADD.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |  2 ++
 drivers/net/ixgbe/base/ixgbe_x550.c | 48 +++--
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index de295e1..da1fe16 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4134,6 +4134,8 @@ struct ixgbe_hw {
 #define IXGBE_SB_IOSF_TARGET_KR_PHY0

 #define IXGBE_NW_MNG_IF_SEL0x00011178
+#define IXGBE_NW_MNG_IF_SEL_MDIO_ACT   (1 << 1)
+#define IXGBE_NW_MNG_IF_SEL_ENABLE_10_100M (1 << 23)
 #define IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE (1 << 24)
 #define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT 3
 #define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD   \
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index aaf6572..993ef16 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -338,9 +338,8 @@ static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
 {
u16 phy_id_high;
u16 phy_id_low;
-   u32 val = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+   u32 val;

-   hw->phy.addr = (val >> 3) & 0x1F;
val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
   hw->phy.addr, _id_high);
if (val || phy_id_high == 0x) {
@@ -1843,6 +1842,33 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
 }

 /**
+ *  ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
+ *  @hw: pointer to hardware structure
+ *
+ *  Read NW_MNG_IF_SEL register and save field values, and check for valid 
field
+ *  values.
+ **/
+STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
+{
+   /* Save NW management interface connected on board. This is used
+* to determine internal PHY mode.
+*/
+   hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+   /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
+* PHY address. This register field was has only been used for X552.
+*/
+   if (hw->mac.type == ixgbe_mac_X550EM_a &&
+   hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
+   hw->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;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
  *  ixgbe_init_phy_ops_X550em - PHY/SFP specific init
  *  @hw: pointer to hardware structure
  *
@@ -1859,14 +1885,11 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)

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);
-
-   /* Save NW management interface connected on board. This is used
-* to determine internal PHY mode.
-*/
-   phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
}

@@ -1893,11 +1916,6 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
break;
case ixgbe_phy_x550em_ext_t:
-   /* Save NW management interface connected on board. This is used
-* to determine internal PHY mode
-*/
-   phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
-
/* If internal link mode is XFI, then setup iXFI internal link,
 * else setup KR now.
 */
@@ -2256,12 +2274,6 @@ s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
/* Configure internal PHY for KR/KX. */
ixgbe_setup_kr_speed_x550em(hw, speed);

-   /* Get CS4227 MDIO address */
-   hw->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 (hw->phy.addr == 0x0 || hw->phy.addr == 0x) {
/* Find Address */
DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
-- 
2.5.0



[dpdk-dev] [PATCH v3 14/30] ixgbe/base: fix firmware commands on X550em_a

2016-06-15 Thread Beilei Xing
This patch fixes firmware commands on X550em_a. For one thing,
the checksum value was not being set.

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

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index e91546c..aaf6572 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1154,23 +1154,24 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
  *  @data: Data to write to the register
  **/
 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
-   u32 device_type, u32 data)
+ u32 device_type, u32 data)
 {
struct ixgbe_hic_internal_phy_req write_cmd;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

+   memset(_cmd, 0, sizeof(write_cmd));
write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
write_cmd.port_number = hw->bus.lan_id;
write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
write_cmd.address = (u16)reg_addr;
-   write_cmd.rsv1 = 0;
write_cmd.write_data = data;
-   write_cmd.pad = 0;

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
-   sizeof(write_cmd), IXGBE_HI_COMMAND_TIMEOUT, false);
+ sizeof(write_cmd),
+ IXGBE_HI_COMMAND_TIMEOUT, false);

return status;
 }
@@ -1184,23 +1185,23 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
  *  @data: Pointer to read data from the register
  **/
 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
-   u32 device_type, u32 *data)
+u32 device_type, u32 *data)
 {
struct ixgbe_hic_internal_phy_req read_cmd;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

+   memset(_cmd, 0, sizeof(read_cmd));
read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   read_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
read_cmd.port_number = hw->bus.lan_id;
read_cmd.command_type = FW_INT_PHY_REQ_READ;
read_cmd.address = (u16)reg_addr;
-   read_cmd.rsv1 = 0;
-   read_cmd.write_data = 0;
-   read_cmd.pad = 0;

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
-   sizeof(read_cmd), IXGBE_HI_COMMAND_TIMEOUT, true);
+ sizeof(read_cmd),
+ IXGBE_HI_COMMAND_TIMEOUT, true);

/* Extract the register value from the response. */
*data = ((struct ixgbe_hic_internal_phy_resp *)_cmd)->read_data;
-- 
2.5.0



[dpdk-dev] [PATCH v3 13/30] ixgbe/base: fix for code style

2016-06-15 Thread Beilei Xing
The ixgbe_vf.h file did not use __ and instead used
 which is not the standard used in every other file.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_vf.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_vf.h 
b/drivers/net/ixgbe/base/ixgbe_vf.h
index 411152a..9be2cda 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.h
+++ b/drivers/net/ixgbe/base/ixgbe_vf.h
@@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE.

 ***/

-#ifndef __IXGBE_VF_H__
-#define __IXGBE_VF_H__
+#ifndef _IXGBE_VF_H_
+#define _IXGBE_VF_H_

 #define IXGBE_VF_IRQ_CLEAR_MASK7
 #define IXGBE_VF_MAX_TX_QUEUES 8
-- 
2.5.0



[dpdk-dev] [PATCH v3 12/30] ixgbe/base: fix error path to release lock

2016-06-15 Thread Beilei Xing
When there is an error getting the PHY token, the error path
fails to release the locks that it has taken. Release those
locks in that failure case.

Fixes: 86b8fb293fdf ("ixgbe/base: add sw-firmware sync for resource sharing on 
X550em_a")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 0bb3436..e91546c 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -3530,17 +3530,22 @@ static s32 ixgbe_acquire_swfw_sync_X550a(struct 
ixgbe_hw *hw, u32 mask)
DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");

while (--retries) {
+   status = IXGBE_SUCCESS;
if (hmask)
status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
if (status)
-   break;
+   return status;
if (!(mask & IXGBE_GSSR_TOKEN_SM))
-   break;
+   return IXGBE_SUCCESS;
+
status = ixgbe_get_phy_token(hw);
-   if (status != IXGBE_ERR_TOKEN_RETRY)
-   break;
+   if (status == IXGBE_SUCCESS)
+   return IXGBE_SUCCESS;
+
if (hmask)
ixgbe_release_swfw_sync_X540(hw, hmask);
+   if (status != IXGBE_ERR_TOKEN_RETRY)
+   return status;
msec_delay(FW_PHY_TOKEN_DELAY);
}

-- 
2.5.0



[dpdk-dev] [PATCH v3 11/30] ixgbe/base: rename macro of TDL

2016-06-15 Thread Beilei Xing
This patch renames IXGBE_PVFTTDLEN to IXGBE_PVFTDLEN according to
abbreviation of Transmit Descriptor Length in datasheet.

Signed-off-by: Beilei Xing 
---
 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 0a35891..de295e1 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -2824,7 +2824,7 @@ enum {
 #define IXGBE_PVFPSRTYPE(P)(0x0EA00 + (4 * (P)))
 #define IXGBE_PVFTDBAL(P)  (0x06000 + (0x40 * (P)))
 #define IXGBE_PVFTDBAH(P)  (0x06004 + (0x40 * (P)))
-#define IXGBE_PVFTTDLEN(P) (0x06008 + (0x40 * (P)))
+#define IXGBE_PVFTDLEN(P)  (0x06008 + (0x40 * (P)))
 #define IXGBE_PVFTDH(P)(0x06010 + (0x40 * (P)))
 #define IXGBE_PVFTDT(P)(0x06018 + (0x40 * (P)))
 #define IXGBE_PVFTXDCTL(P) (0x06028 + (0x40 * (P)))
-- 
2.5.0



[dpdk-dev] [PATCH v3 10/30] ixgbe/base: clear stale pool mappings

2016-06-15 Thread Beilei Xing
This patch adds clearing the pool mappings when configuring default
MAC addresses for the interface. Without this there will be the risk
of leaking an address into pool 0 which really belongs to VF 0 when
SR-IOV is enabled.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_82599.c  | 9 ++---
 drivers/net/ixgbe/base/ixgbe_common.c | 7 ---
 drivers/net/ixgbe/base/ixgbe_x540.c   | 9 ++---
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_82599.c 
b/drivers/net/ixgbe/base/ixgbe_82599.c
index 154c1f1..5bc7c2b 100644
--- a/drivers/net/ixgbe/base/ixgbe_82599.c
+++ b/drivers/net/ixgbe/base/ixgbe_82599.c
@@ -1176,11 +1176,14 @@ mac_reset_top:

/* Add the SAN MAC address to the RAR only if it's a valid address */
if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
-   hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
-   hw->mac.san_addr, 0, IXGBE_RAH_AV);
-
/* 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);
+
+   /* clear VMDq pool/queue selection for this RAR */
+   hw->mac.ops.clear_vmdq(hw, hw->mac.san_mac_rar_index,
+  IXGBE_CLEAR_VMDQ_ALL);

/* Reserve the last RAR for the SAN MAC address */
hw->mac.num_rar_entries--;
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 82a8416..d211303 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -2406,10 +2406,11 @@ s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw)
  hw->mac.addr[4], hw->mac.addr[5]);

hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
-
-   /* clear VMDq pool/queue selection for RAR 0 */
-   hw->mac.ops.clear_vmdq(hw, 0, IXGBE_CLEAR_VMDQ_ALL);
}
+
+   /* clear VMDq pool/queue selection for RAR 0 */
+   hw->mac.ops.clear_vmdq(hw, 0, IXGBE_CLEAR_VMDQ_ALL);
+
hw->addr_ctrl.overflow_promisc = 0;

hw->addr_ctrl.rar_used_count = 1;
diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c 
b/drivers/net/ixgbe/base/ixgbe_x540.c
index 9ade1b5..0678913 100644
--- a/drivers/net/ixgbe/base/ixgbe_x540.c
+++ b/drivers/net/ixgbe/base/ixgbe_x540.c
@@ -268,11 +268,14 @@ mac_reset_top:

/* Add the SAN MAC address to the RAR only if it's a valid address */
if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
-   hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
-   hw->mac.san_addr, 0, IXGBE_RAH_AV);
-
/* 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);
+
+   /* clear VMDq pool/queue selection for this RAR */
+   hw->mac.ops.clear_vmdq(hw, hw->mac.san_mac_rar_index,
+  IXGBE_CLEAR_VMDQ_ALL);

/* Reserve the last RAR for the SAN MAC address */
hw->mac.num_rar_entries--;
-- 
2.5.0



[dpdk-dev] [PATCH v3 09/30] ixgbe/base: add link MAC setup for X550a SFP+

2016-06-15 Thread Beilei Xing
This patch updates ixgbe_setup_mac_link_sfp_x550a for X550 SFP+.
ixgbe_set_lan_id_multi_port_pcie has been updated to set the MAC
instance(0/1) which is needed when configuring the external PHY,
since X550a has two instances of MGPK. The MAC instance is read
from the EEPROM.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 13 +-
 drivers/net/ixgbe/base/ixgbe_phy.h|  3 ++
 drivers/net/ixgbe/base/ixgbe_type.h   |  8 
 drivers/net/ixgbe/base/ixgbe_x550.c   | 85 ++-
 4 files changed, 86 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index ec61408..82a8416 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -1020,13 +1020,15 @@ s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw)
  *  ixgbe_set_lan_id_multi_port_pcie - Set LAN id for PCIe multiple port 
devices
  *  @hw: pointer to the HW structure
  *
- *  Determines the LAN function id by reading memory-mapped registers
- *  and swaps the port value if requested.
+ *  Determines the LAN function id by reading memory-mapped registers and swaps
+ *  the port value if requested, and set MAC instance for devices that share
+ *  CS4227.
  **/
 void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw)
 {
struct ixgbe_bus_info *bus = >bus;
u32 reg;
+   u16 ee_ctrl_4;

DEBUGFUNC("ixgbe_set_lan_id_multi_port_pcie");

@@ -1038,6 +1040,13 @@ void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw 
*hw)
reg = IXGBE_READ_REG(hw, IXGBE_FACTPS_BY_MAC(hw));
if (reg & IXGBE_FACTPS_LFS)
bus->func ^= 0x1;
+
+   /* Get MAC instance from EEPROM for configuring CS4227 */
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP) {
+   hw->eeprom.ops.read(hw, IXGBE_EEPROM_CTRL_4, _ctrl_4);
+   bus->instance_id = (ee_ctrl_4 & IXGBE_EE_CTRL_4_INST_ID) >>
+   IXGBE_EE_CTRL_4_INST_ID_SHIFT;
+   }
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_phy.h 
b/drivers/net/ixgbe/base/ixgbe_phy.h
index 1a5affe..281f9fa 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.h
+++ b/drivers/net/ixgbe/base/ixgbe_phy.h
@@ -89,8 +89,11 @@ POSSIBILITY OF SUCH DAMAGE.

 #define IXGBE_CS4227   0xBE/* CS4227 address */
 #define IXGBE_CS4227_GLOBAL_ID_LSB 0
+#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_CS4227_RESET_PENDING 0x1357
 #define IXGBE_CS4227_RESET_COMPLETE0x5AA5
 #define IXGBE_CS4227_RETRIES   15
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 7bd6f2c..0a35891 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -1472,6 +1472,7 @@ struct ixgbe_dmac_config {
 #define IXGBE_CORECTL_WRITE_CMD0x0001

 /* Device Type definitions for new protocol MDIO commands */
+#define IXGBE_MDIO_ZERO_DEV_TYPE   0x0
 #define IXGBE_MDIO_PMA_PMD_DEV_TYPE0x1
 #define IXGBE_MDIO_PCS_DEV_TYPE0x3
 #define IXGBE_MDIO_PHY_XS_DEV_TYPE 0x4
@@ -2247,6 +2248,9 @@ enum {
 #define IXGBE_PBANUM_PTR_GUARD 0xFAFA
 #define IXGBE_EEPROM_CHECKSUM  0x3F
 #define IXGBE_EEPROM_SUM   0xBABA
+#define IXGBE_EEPROM_CTRL_40x45
+#define IXGBE_EE_CTRL_4_INST_ID0x10
+#define IXGBE_EE_CTRL_4_INST_ID_SHIFT  4
 #define IXGBE_PCIE_ANALOG_PTR  0x03
 #define IXGBE_ATLAS0_CONFIG_PTR0x04
 #define IXGBE_PHY_PTR  0x04
@@ -3630,6 +3634,7 @@ struct ixgbe_bus_info {

u16 func;
u16 lan_id;
+   u16 instance_id;
 };

 /* Flow control parameters */
@@ -4130,5 +4135,8 @@ struct ixgbe_hw {

 #define IXGBE_NW_MNG_IF_SEL0x00011178
 #define IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE (1 << 24)
+#define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT 3
+#define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD   \
+   (0x1F << IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT)

 #endif /* _IXGBE_TYPE_H_ */
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 1ae79f5..0bb3436 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1550,7 +1550,8 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
mac->ops.set_rate_select_speed =
ixgbe_set_soft_rate_select_speed;
-   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N)
+   if ((hw->device_id == IXG

[dpdk-dev] [PATCH v3 08/30] ixgbe/base: add KR support for X550em_a devices

2016-06-15 Thread Beilei Xing
Implement KR support for X550em_a devices.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 51 +
 1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 40060c0..1ae79f5 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -564,9 +564,14 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
else
mac->ops.setup_fc = ixgbe_setup_fc_X550em;

-
-   if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
+   break;
+   default:
mac->ops.setup_eee = NULL;
+   }

/* PHY */
phy->ops.init = ixgbe_init_phy_ops_X550em;
@@ -773,11 +778,16 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  autoneg_eee_reg);
-   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   return IXGBE_SUCCESS;
+   }

+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   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;

@@ -788,10 +798,13 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;

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_reg);
+  IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
if (status != IXGBE_SUCCESS)
return status;
+   break;
+   default:
+   break;
}

return IXGBE_SUCCESS;
@@ -820,7 +833,13 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  autoneg_eee_reg);
-   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   return IXGBE_SUCCESS;
+   }
+
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   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);
@@ -838,6 +857,9 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
  IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
if (status != IXGBE_SUCCESS)
return status;
+   break;
+   default:
+   break;
}

return IXGBE_SUCCESS;
@@ -2085,10 +2107,13 @@ s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
  *  ixgbe_setup_kr_x550em - Configure the KR PHY.
  *  @hw: pointer to hardware structure
  *
- *  Configures the integrated KR PHY.
+ *  Configures the integrated KR PHY for X550EM_x.
  **/
 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
 {
+   if (hw->mac.type != ixgbe_mac_X550EM_x)
+   return IXGBE_SUCCESS;
+
return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
 }

@@ -3356,7 +3381,10 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
goto out;
}

-   if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
   IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
   IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
@@ -3374,6 +3402,9 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)

/* This device does not fully support AN. */
hw->fc.disable_fc_autoneg = true;
+   break;
+   default:
+   break;
}

 out:
-- 
2.5.0



[dpdk-dev] [PATCH v3 07/30] ixgbe/base: change access method

2016-06-15 Thread Beilei Xing
Use the method pointers instead of direct function calls so that
the right thing will happen on X550EM_a.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 84 ++---
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 78672a6..40060c0 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -546,8 +546,8 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
link->addr = IXGBE_CS4227;
}
if (hw->mac.type == ixgbe_mac_X550EM_a) {
-   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.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;
}
@@ -775,7 +775,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
  autoneg_eee_reg);
} else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {

-   status = ixgbe_read_iosf_sb_reg_x550(hw,
+   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);
if (status != IXGBE_SUCCESS)
@@ -787,7 +787,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
/* Don't advertise FEC capability when EEE enabled. */
link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;

-   status = ixgbe_write_iosf_sb_reg_x550(hw,
+   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_reg);
if (status != IXGBE_SUCCESS)
@@ -821,7 +821,7 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  autoneg_eee_reg);
} else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
+   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);
if (status != IXGBE_SUCCESS)
@@ -833,7 +833,7 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
/* Advertise FEC capability when EEE is disabled. */
link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;

-   status = ixgbe_write_iosf_sb_reg_x550(hw,
+   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_reg);
if (status != IXGBE_SUCCESS)
@@ -1791,9 +1791,9 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
s32 status;
u32 reg_val;

-   status = ixgbe_read_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (status)
return status;

@@ -1811,9 +1811,9 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,

/* Restart auto-negotiation. */
reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
-   status = ixgbe_write_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+   status = hw->mac.ops.write_iosf_sb_reg(hw,
+  IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);

return status;
 }
@@ -2470,57 +2470,57 @@ s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
u32 reg_val;

/* Disable AN and force speed to 10G Serial. */
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (status != IXGBE_SUCCESS)
return status;
reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN

[dpdk-dev] [PATCH v3 06/30] ixgbe/base: refactor eee setup for X550

2016-06-15 Thread Beilei Xing
Break ixgbe_setup_eee_X550 down to better handle a change from if
statements to switch statements needed to add X550em_a KR support.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 174 ++--
 1 file changed, 105 insertions(+), 69 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 36df3c3..78672a6 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -751,6 +751,99 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_enable_eee_x550 - Enable EEE support
+ * @hw: pointer to hardware structure
+ */
+static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
+{
+   u16 autoneg_eee_reg;
+   u32 link_reg;
+   s32 status;
+
+   if (hw->mac.type == ixgbe_mac_X550) {
+   /* Advertise EEE capability */
+   hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+_eee_reg);
+
+   autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
+   IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
+   IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
+
+   hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ autoneg_eee_reg);
+   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+
+   status = ixgbe_read_iosf_sb_reg_x550(hw,
+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;
+
+   /* Don't advertise FEC capability when EEE enabled. */
+   link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
+   status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
+   if (status != IXGBE_SUCCESS)
+   return status;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_disable_eee_x550 - Disable EEE support
+ * @hw: pointer to hardware structure
+ */
+static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
+{
+   u16 autoneg_eee_reg;
+   u32 link_reg;
+   s32 status;
+
+   if (hw->mac.type == ixgbe_mac_X550) {
+   /* Disable advertised EEE capability */
+   hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+_eee_reg);
+
+   autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
+IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
+IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
+
+   hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ autoneg_eee_reg);
+   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   status = ixgbe_read_iosf_sb_reg_x550(hw,
+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);
+
+   /* Advertise FEC capability when EEE is disabled. */
+   link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
+   status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
+   if (status != IXGBE_SUCCESS)
+   return status;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
  *  ixgbe_setup_eee_X550 - Enable/disable EEE support
  *  @hw: pointer to the HW structure
  *  @enable_eee: boolean flag to enable EEE
@@ -762,10 +855,8 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  **/
 s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
 {
-   u32 eeer;
-   u16 autoneg_eee_reg;
-   u32 link_reg;
s32 status;
+   u32 eeer;

DEBUGFUNC("ixgbe_setup_eee_X550");

@@ -774,75 +865,20 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool 
enable_eee)
if (e

[dpdk-dev] [PATCH v3 05/30] ixgbe/base: fix checksum error of checking PHY token

2016-06-15 Thread Beilei Xing
This patch sets the Host Interface PHY token command
checksum to the checksum default of 0xFF, therefore
the checksum is not checked by the firmware. Otherwise
the command fails with a checksum failed error.

Fixes: 86b8fb293fdf ("ixgbe/base: add sw-firmware sync for resource sharing on 
X550em_a")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 8a5b1dc..36df3c3 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1041,6 +1041,7 @@ s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
+   token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
token_cmd.port_number = hw->bus.lan_id;
token_cmd.command_type = FW_PHY_TOKEN_REQ;
token_cmd.pad = 0;
@@ -1071,6 +1072,7 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
+   token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
token_cmd.port_number = hw->bus.lan_id;
token_cmd.command_type = FW_PHY_TOKEN_REL;
token_cmd.pad = 0;
-- 
2.5.0



[dpdk-dev] [PATCH v3 04/30] ixgbe/base: add MAC link setup for X550a SFP

2016-06-15 Thread Beilei Xing
This patch adds ixgbe_setup_mac_link_sfp_x550a for X550a SFP.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |  4 +++
 drivers/net/ixgbe/base/ixgbe_x550.c | 64 -
 drivers/net/ixgbe/base/ixgbe_x550.h |  3 ++
 3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 493bd46..7bd6f2c 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4062,6 +4062,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
 #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_8(P) ((P) ? 0x8248 : 0x4248)
 #define IXGBE_KRM_SGMII_CTRL(P)((P) ? 0x82A0 : 0x42A0)
 #define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
@@ -4090,6 +4091,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_AN_CNTL_8_LINEAR (1 << 0)
+#define IXGBE_KRM_AN_CNTL_8_LIMITING   (1 << 1)
+
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 6c00b2a..8a5b1dc 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1488,9 +1488,14 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.enable_tx_laser = NULL;
mac->ops.flap_tx_laser = NULL;
mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
-   mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_x550em;
mac->ops.set_rate_select_speed =
ixgbe_set_soft_rate_select_speed;
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N)
+   mac->ops.setup_mac_link =
+   ixgbe_setup_mac_link_sfp_x550a;
+   else
+   mac->ops.setup_mac_link =
+   ixgbe_setup_mac_link_sfp_x550em;
break;
case ixgbe_media_type_copper:
mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
@@ -2128,6 +2133,63 @@ s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
 }

 /**
+ *  ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
+ *  @hw: pointer to hardware structure
+ *
+ *  Configure the the integrated PHY for SFP support.
+ **/
+s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
+  ixgbe_link_speed speed,
+  bool autoneg_wait_to_complete)
+{
+   s32 ret_val;
+   u32 reg_val;
+   bool setup_linear = false;
+
+   UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
+
+   /* Check if SFP module is supported and linear */
+   ret_val = ixgbe_supported_sfp_modules_X550em(hw, _linear);
+
+   /* If no SFP module present, then return success. Return success since
+* SFP not present error is not excepted in the setup MAC link flow.
+*/
+   if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
+   return IXGBE_SUCCESS;
+
+   if (ret_val != IXGBE_SUCCESS)
+   return ret_val;
+
+   /* Configure internal PHY for native SFI */
+   ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
+  IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+
+   if (ret_val != IXGBE_SUCCESS)
+   return ret_val;
+
+   if (setup_linear) {
+   reg_val &= ~IXGBE_KRM_AN_CNTL_8_LIMITING;
+   reg_val |= IXGBE_KRM_AN_CNTL_8_LINEAR;
+   } else {
+   reg_val |= IXGBE_KRM_AN_CNTL_8_LIMITING;
+   reg_val &= ~IXGBE_KRM_AN_CNTL_8_LINEAR;
+   }
+
+   ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
+   IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
+   IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+
+   if (ret_val != IXGBE_SUCCESS)
+   return ret_val;
+
+   /* Setup XFI/SFI internal link. */
+   ret_val = ixgbe_setup_ixfi_x550em(hw, );
+
+   return ret_val;
+}
+
+/**
  *  ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
  *  @hw: pointer to hardware structure
  *
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.h 
b/drivers/net/ixgbe/base/ixgbe_x550.h
index a8c0a67..2966c7b 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.h
+++ b/drivers/net/ixgbe/base/ixgbe_x550.h
@@ -100,6 +100,9 @@ s32 ixgbe_setup_fc_X5

[dpdk-dev] [PATCH v3 03/30] ixgbe/base: fix problematic return value

2016-06-15 Thread Beilei Xing
An error code indicating that the PF rejects the MAC address change
should be returned, in case that the PF has already assigned a MAC
for the VF.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_vf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_vf.c 
b/drivers/net/ixgbe/base/ixgbe_vf.c
index 40dc1c8..81ea6c7 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.c
+++ b/drivers/net/ixgbe/base/ixgbe_vf.c
@@ -362,8 +362,10 @@ s32 ixgbe_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 
*addr, u32 vmdq,

/* if nacked the address was rejected, use "perm_addr" */
if (!ret_val &&
-   (msgbuf[0] == (IXGBE_VF_SET_MAC_ADDR | IXGBE_VT_MSGTYPE_NACK)))
+   (msgbuf[0] == (IXGBE_VF_SET_MAC_ADDR | IXGBE_VT_MSGTYPE_NACK))) {
ixgbe_get_mac_addr_vf(hw, hw->mac.addr);
+   return IXGBE_ERR_MBX;
+   }

return ret_val;
 }
-- 
2.5.0



[dpdk-dev] [PATCH v3 02/30] ixgbe/base: add sgmii link for X550

2016-06-15 Thread Beilei Xing
It adds sgmii link for X550.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |   9 +++
 drivers/net/ixgbe/base/ixgbe_x550.c | 127 +---
 2 files changed, 127 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 4dce2ac..493bd46 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3511,6 +3511,8 @@ enum ixgbe_phy_type {
ixgbe_phy_qsfp_intel,
ixgbe_phy_qsfp_unknown,
ixgbe_phy_sfp_unsupported, /*Enforce bit set with unsupported module*/
+   ixgbe_phy_sgmii,
+   ixgbe_phy_m88,
ixgbe_phy_generic
 };

@@ -3554,6 +3556,7 @@ enum ixgbe_media_type {
ixgbe_media_type_fiber_lco,
ixgbe_media_type_copper,
ixgbe_media_type_backplane,
+   ixgbe_media_type_sgmii,
ixgbe_media_type_cx4,
ixgbe_media_type_virtual
 };
@@ -4059,6 +4062,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
 #define IXGBE_KRM_LINK_CTRL_1(P)   ((P) ? 0x820C : 0x420C)
 #define IXGBE_KRM_AN_CNTL_1(P) ((P) ? 0x822C : 0x422C)
+#define IXGBE_KRM_SGMII_CTRL(P)((P) ? 0x82A0 : 0x42A0)
 #define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
 #define IXGBE_KRM_RX_TRN_LINKUP_CTRL(P)((P) ? 0x8B00 : 0x4B00)
@@ -4072,6 +4076,8 @@ struct ixgbe_hw {
 #define IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK(0x7 << 8)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G  (2 << 8)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G (4 << 8)
+#define IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN (1 << 12)
+#define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN (1 << 13)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ  (1 << 14)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC  (1 << 15)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX   (1 << 16)
@@ -4084,6 +4090,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_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
+#define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)
+
 #define IXGBE_KRM_DSP_TXFFE_STATE_C0_EN(1 << 6)
 #define IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN   (1 << 15)
 #define IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN  (1 << 16)
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 0bbaa55..6c00b2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -329,6 +329,39 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_identify_phy_1g - Get 1g PHY type based on device id
+ * @hw: pointer to hardware structure
+ *
+ * Returns error code
+ */
+static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
+{
+   u16 phy_id_high;
+   u16 phy_id_low;
+   u32 val = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+   hw->phy.addr = (val >> 3) & 0x1F;
+   val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
+  hw->phy.addr, _id_high);
+   if (val || phy_id_high == 0x) {
+   hw->phy.type = ixgbe_phy_sgmii;
+   return 0;
+   }
+
+   val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
+  hw->phy.addr, _id_low);
+   if (val)
+   return val;
+
+   hw->phy.id = (u32)phy_id_high << 16;
+   hw->phy.id |= phy_id_low & IXGBE_PHY_REVISION_MASK;
+   hw->phy.revision = (u32)phy_id_low & ~IXGBE_PHY_REVISION_MASK;
+   hw->phy.type = ixgbe_phy_m88;
+
+   return 0;
+}
+
+/**
  * ixgbe_identify_phy_x550em - Get PHY type based on device id
  * @hw: pointer to hardware structure
  *
@@ -364,10 +397,11 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
break;
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_10G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T_L:
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:
+   return ixgbe_identify_phy_1g(hw);
default:
break;
}
@@ -1286,11 +1320,14 @@ enum ixgbe_media_type 
ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
break;
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_10G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
   

[dpdk-dev] [PATCH v3 01/30] ixgbe/base: add new VF requests for mailbox API

2016-06-15 Thread Beilei Xing
It adds two new VF requests of IXGBE_VF_GET_RETA and
IXGBE_VF_GET_RSS_KEY for mailbox API.

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

diff --git a/drivers/net/ixgbe/base/ixgbe_mbx.h 
b/drivers/net/ixgbe/base/ixgbe_mbx.h
index 4a120a3..d775142 100644
--- a/drivers/net/ixgbe/base/ixgbe_mbx.h
+++ b/drivers/net/ixgbe/base/ixgbe_mbx.h
@@ -109,7 +109,9 @@ enum ixgbe_pfvf_api_rev {
 #define IXGBE_VF_GET_QUEUES0x09 /* get queue configuration */

 /* mailbox API, version 1.2 VF requests */
-#define IXGBE_VF_UPDATE_XCAST_MODE 0x0C
+#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

 /* GET_QUEUES return data indices within the mailbox */
 #define IXGBE_VF_TX_QUEUES 1   /* number of Tx queues supported */
-- 
2.5.0



[dpdk-dev] [PATCH v3 00/30]

2016-06-15 Thread Beilei Xing
Update base driver for ixgbe, mainly work on
new features and bug fixes.

v3 changes:
 Fix some commit log issues.

Beilei Xing (30):
  ixgbe/base: add new VF requests for mailbox API
  ixgbe/base: add sgmii link for X550
  ixgbe/base: fix problematic return value
  ixgbe/base: add MAC link setup for X550a SFP
  ixgbe/base: fix checksum error of checking PHY token
  ixgbe/base: refactor eee setup for X550
  ixgbe/base: change access method
  ixgbe/base: add KR support for X550em_a devices
  ixgbe/base: add link MAC setup for X550a SFP+
  ixgbe/base: clear stale pool mappings
  ixgbe/base: rename macro of TDL
  ixgbe/base: fix error path to release lock
  ixgbe/base: fix for code style
  ixgbe/base: fix firmware commands on X550em_a
  ixgbe/base: refactor NW management interface ops
  ixgbe/base: add new phy definitions
  ixgbe/base: change device IDs
  ixgbe/base: add function to reset swfw semaphore
  ixgbe/base: fix possible race issue
  ixgbe/base: fix register access error
  ixgbe/base: limit PHY token accessing to MDIO only
  ixgbe/base: simplify add/remove VLANs
  ixgbe/base: add bypassing VLVF
  ixgbe/base: unify coding style
  ixgbe/base: use u8 to replace u16 for a variable
  ixgbe/base: fix endianness issues
  ixgbe/base: allow setting MAC anti spoofing per VF
  ixgbe/base: add flow control autoneg for X550a
  ixgbe/base: define if enable crosstalk work around
  ixgbe/base: update README

 doc/guides/rel_notes/release_16_07.rst  |   11 +
 drivers/net/ixgbe/base/README   |2 +-
 drivers/net/ixgbe/base/ixgbe_82598.c|5 +-
 drivers/net/ixgbe/base/ixgbe_82598.h|3 +-
 drivers/net/ixgbe/base/ixgbe_82599.c|9 +-
 drivers/net/ixgbe/base/ixgbe_api.c  |   41 +-
 drivers/net/ixgbe/base/ixgbe_api.h  |8 +-
 drivers/net/ixgbe/base/ixgbe_common.c   |  361 ---
 drivers/net/ixgbe/base/ixgbe_common.h   |9 +-
 drivers/net/ixgbe/base/ixgbe_mbx.h  |4 +-
 drivers/net/ixgbe/base/ixgbe_osdep.h|1 +
 drivers/net/ixgbe/base/ixgbe_phy.c  |   16 +-
 drivers/net/ixgbe/base/ixgbe_phy.h  |3 +
 drivers/net/ixgbe/base/ixgbe_type.h |  118 ++-
 drivers/net/ixgbe/base/ixgbe_vf.c   |   10 +-
 drivers/net/ixgbe/base/ixgbe_vf.h   |7 +-
 drivers/net/ixgbe/base/ixgbe_x540.c |   29 +-
 drivers/net/ixgbe/base/ixgbe_x540.h |1 +
 drivers/net/ixgbe/base/ixgbe_x550.c | 1156 +++
 drivers/net/ixgbe/base/ixgbe_x550.h |   52 +
 drivers/net/ixgbe/ixgbe_ethdev.c|   11 +-
 drivers/net/ixgbe/ixgbe_pf.c|2 +-
 lib/librte_eal/common/include/rte_pci_dev_ids.h |   12 +-
 23 files changed, 1456 insertions(+), 415 deletions(-)

Acked-by: Helin Zhang 
-- 
2.5.0



[dpdk-dev] [PATCH v2 30/30] ixgbe/base: update README

2016-06-14 Thread Beilei Xing
The ixgbe base driver was updated according to version
cid-10g-shared-code.2016.04.12 released by ND.

The changes include:
Added sgmii link for X550.
Added mac link setup for x550a SFP and SFP+.
Added KR support for x550em_a.
Added new phy definitions for M88E1500.
Added support for the VLVF to be bypassed when adding/removing a VFTA entry.
Added x550a flow control auto negotiation support.

Signed-off-by: Beilei Xing 
---
 doc/guides/rel_notes/release_16_07.rst | 11 +++
 drivers/net/ixgbe/base/README  |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index c0f6b02..9e89b52 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -15,6 +15,17 @@ DPDK Release 16.07

   firefox build/doc/html/guides/rel_notes/release_16_07.html

+* **Updated the ixgbe base driver.**
+  The ixgbe base driver was updated with changes including the
+  following:
+
+  * Added sgmii link for X550.
+  * Added mac link setup for x550a SFP and SFP+.
+  * Added KR support for x550em_a.
+  * Added new phy definitions for M88E1500.
+  * Added support for the VLVF to be bypassed when adding/removing a VFTA 
entry.
+  * Added x550a flow control auto negotiation support.
+

 New Features
 
diff --git a/drivers/net/ixgbe/base/README b/drivers/net/ixgbe/base/README
index caa2664..76e7805 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.01.07 released by ND. The sub-directory of base/
+cid-10g-shared-code.2016.04.12 released by ND. The sub-directory of base/
 contains the original source package.
 This driver is valid for the product(s) listed below

-- 
2.5.0



[dpdk-dev] [PATCH v2 29/30] ixgbe/base: define if enable crosstalk work around

2016-06-14 Thread Beilei Xing
A work around for a new crosstalk erratum that causes link flap in
entry cages has been introduced. So this patch defines the bit in
NVM that will tell software if this work around is needed.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index be51bee..83818a9 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -2405,6 +2405,7 @@ enum {
 #define IXGBE_SAN_MAC_ADDR_PORT1_OFFSET0x3
 #define IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP0x1
 #define IXGBE_DEVICE_CAPS_FCOE_OFFLOADS0x2
+#define IXGBE_DEVICE_CAPS_NO_CROSSTALK_WR  (1 << 7)
 #define IXGBE_FW_LESM_PARAMETERS_PTR   0x2
 #define IXGBE_FW_LESM_STATE_1  0x1
 #define IXGBE_FW_LESM_STATE_ENABLED0x8000 /* LESM Enable bit */
-- 
2.5.0



[dpdk-dev] [PATCH v2 28/30] ixgbe/base: add flow control autoneg for x550a

2016-06-14 Thread Beilei Xing
This patch adds x550a flow control auto negotiation support.
ixgbe_setup_fc_x550a and ixgbe_fc_autoneg_X550a functions where
added to setup and enable flow control. MAC ops function pointer
fc_autoneg was added so that hardware specific fc autoneg functions
can be called from ixgbe_fc_enable_generic.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.h|   2 +
 drivers/net/ixgbe/base/ixgbe_common.c |   5 +-
 drivers/net/ixgbe/base/ixgbe_type.h   |   6 ++
 drivers/net/ixgbe/base/ixgbe_x550.c   | 181 ++
 drivers/net/ixgbe/base/ixgbe_x550.h   |   2 +
 5 files changed, 194 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index c126982..3aad1da 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -217,5 +217,7 @@ s32 ixgbe_handle_lasi(struct ixgbe_hw *hw);
 void ixgbe_set_rate_select_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed);
 void ixgbe_disable_rx(struct ixgbe_hw *hw);
 void ixgbe_enable_rx(struct ixgbe_hw *hw);
+s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
+   u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);

 #endif /* _IXGBE_API_H_ */
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index e1d09e2..811875a 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -135,6 +135,7 @@ s32 ixgbe_init_ops_generic(struct ixgbe_hw *hw)
/* Flow Control */
mac->ops.fc_enable = ixgbe_fc_enable_generic;
mac->ops.setup_fc = ixgbe_setup_fc_generic;
+   mac->ops.fc_autoneg = ixgbe_fc_autoneg;

/* Link */
mac->ops.get_link_capabilities = NULL;
@@ -2739,7 +2740,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
}

/* Negotiate the fc mode to use */
-   ixgbe_fc_autoneg(hw);
+   hw->mac.ops.fc_autoneg(hw);

/* Disable any previous flow control settings */
mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
@@ -2849,7 +2850,7 @@ out:
  *  Find the intersection between advertised settings and link partner's
  *  advertised settings
  **/
-STATIC s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
+s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
  u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm)
 {
if ((!(adv_reg)) ||  (!(lp_reg))) {
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 5d76c72..be51bee 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3886,6 +3886,7 @@ struct ixgbe_mac_operations {
/* Flow Control */
s32 (*fc_enable)(struct ixgbe_hw *);
s32 (*setup_fc)(struct ixgbe_hw *);
+   void (*fc_autoneg)(struct ixgbe_hw *);

/* Manageability interface */
s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);
@@ -4131,10 +4132,12 @@ struct ixgbe_hw {
 #define IXGBE_FUSES0_REV_MASK  (3 << 6)

 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
+#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_8(P) ((P) ? 0x8248 : 0x4248)
 #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)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
 #define IXGBE_KRM_RX_TRN_LINKUP_CTRL(P)((P) ? 0x8B00 : 0x4B00)
@@ -4156,6 +4159,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR   (1 << 18)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX  (1 << 24)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR  (1 << 26)
+#define IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE  (1 << 28)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE   (1 << 29)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART  (1 << 31)

@@ -4164,6 +4168,8 @@ struct ixgbe_hw {

 #define IXGBE_KRM_AN_CNTL_8_LINEAR (1 << 0)
 #define IXGBE_KRM_AN_CNTL_8_LIMITING   (1 << 1)
+#define IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE  (1 << 10)
+#define IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE  (1 << 11)

 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 99023e9..ae6b79f 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -666,6 +666,10 @@ s32 ixgbe_init_ops_X5

[dpdk-dev] [PATCH v2 27/30] ixgbe/base: allow setting mac anti spoofing per vf

2016-06-14 Thread Beilei Xing
Make ixgbe_set_mac_anti_spoofing() consistent with the other
functions that deal with setting VLAN and Ethertype spoofing by
changing the prototype to accept a VF parameter.

Also change the logic for writing the PFVFSPOOF register to be similar
to the MAC and Ethertype functions.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 40 ++-
 drivers/net/ixgbe/base/ixgbe_common.h |  2 +-
 2 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 6e54628..e1d09e2 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4203,43 +4203,25 @@ out:
 /**
  *  ixgbe_set_mac_anti_spoofing - Enable/Disable MAC anti-spoofing
  *  @hw: pointer to hardware structure
- *  @enable: enable or disable switch for anti-spoofing
- *  @pf: Physical Function pool - do not enable anti-spoofing for the PF
+ *  @enable: enable or disable switch for MAC anti-spoofing
+ *  @vf: Virtual Function pool - VF Pool to set for MAC anti-spoofing
  *
  **/
-void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf)
+void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf)
 {
-   int j;
-   int pf_target_reg = pf >> 3;
-   int pf_target_shift = pf % 8;
-   u32 pfvfspoof = 0;
+   int vf_target_reg = vf >> 3;
+   int vf_target_shift = vf % 8;
+   u32 pfvfspoof;

if (hw->mac.type == ixgbe_mac_82598EB)
return;

+   pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
if (enable)
-   pfvfspoof = IXGBE_SPOOF_MACAS_MASK;
-
-   /*
-* PFVFSPOOF register array is size 8 with 8 bits assigned to
-* MAC anti-spoof enables in each register array element.
-*/
-   for (j = 0; j < pf_target_reg; j++)
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), pfvfspoof);
-
-   /*
-* The PF should be allowed to spoof so that it can support
-* emulation mode NICs.  Do not set the bits assigned to the PF
-*/
-   pfvfspoof &= (1 << pf_target_shift) - 1;
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), pfvfspoof);
-
-   /*
-* Remaining pools belong to the PF so they do not need to have
-* anti-spoofing enabled.
-*/
-   for (j++; j < IXGBE_PFVFSPOOF_REG_COUNT; j++)
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), 0);
+   pfvfspoof |= (1 << vf_target_shift);
+   else
+   pfvfspoof &= ~(1 << vf_target_shift);
+   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_common.h 
b/drivers/net/ixgbe/base/ixgbe_common.h
index a790ede..0545f85 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.h
+++ b/drivers/net/ixgbe/base/ixgbe_common.h
@@ -148,7 +148,7 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 
*wwnn_prefix,
 u16 *wwpn_prefix);

 s32 ixgbe_get_fcoe_boot_status_generic(struct ixgbe_hw *hw, u16 *bs);
-void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf);
+void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
 void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
 s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps);
 void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, u32 headroom,
-- 
2.5.0



[dpdk-dev] [PATCH v2 26/30] ixgbe/base: fix endianness issues

2016-06-14 Thread Beilei Xing
This patch fixes endianness issues about host interface command.

Fixes: ad66a85dce9a ("ixgbe/base: new FW values")
Fixes: 0790adeb5675 ("ixgbe/base: support X550em_a device")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_osdep.h |  1 +
 drivers/net/ixgbe/base/ixgbe_type.h  | 17 ++---
 drivers/net/ixgbe/base/ixgbe_x550.c  | 29 -
 3 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_osdep.h 
b/drivers/net/ixgbe/base/ixgbe_osdep.h
index 40b0b51..31cc1be 100644
--- a/drivers/net/ixgbe/base/ixgbe_osdep.h
+++ b/drivers/net/ixgbe/base/ixgbe_osdep.h
@@ -96,6 +96,7 @@ enum {
 #define IXGBE_NTOHL(_i)rte_be_to_cpu_32(_i)
 #define IXGBE_NTOHS(_i)rte_be_to_cpu_16(_i)
 #define IXGBE_CPU_TO_LE32(_i)  rte_cpu_to_le_32(_i)
+#define IXGBE_LE32_TO_CPU(_i) rte_le_to_cpu_32(_i)
 #define IXGBE_LE32_TO_CPUS(_i) rte_le_to_cpu_32(_i)
 #define IXGBE_CPU_TO_BE16(_i)  rte_cpu_to_be_16(_i)
 #define IXGBE_CPU_TO_BE32(_i)  rte_cpu_to_be_32(_i)
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index d91c4ed..5d76c72 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3050,6 +3050,12 @@ enum ixgbe_fdir_pballoc_type {

 /* Host Interface Command Structures */

+#ifdef C99
+#pragma pack(push, 1)
+#else
+#pragma pack(1)
+#endif /* C99 */
+
 struct ixgbe_hic_hdr {
u8 cmd;
u8 buf_len;
@@ -3127,17 +3133,22 @@ struct ixgbe_hic_internal_phy_req {
struct ixgbe_hic_hdr hdr;
u8 port_number;
u8 command_type;
-   u16 address;
+   __be16 address;
u16 rsv1;
-   u32 write_data;
+   __le32 write_data;
u16 pad;
 };

 struct ixgbe_hic_internal_phy_resp {
struct ixgbe_hic_hdr hdr;
-   u32 read_data;
+   __le32 read_data;
 };

+#ifdef C99
+#pragma pack(pop)
+#else
+#pragma pack()
+#endif /* C99 */

 /* Transmit Descriptor - Legacy */
 struct ixgbe_legacy_tx_desc {
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 1137179..99023e9 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1273,8 +1273,8 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
write_cmd.port_number = hw->bus.lan_id;
write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
-   write_cmd.address = (u16)reg_addr;
-   write_cmd.write_data = data;
+   write_cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
+   write_cmd.write_data = IXGBE_CPU_TO_LE32(data);

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
  sizeof(write_cmd),
@@ -1294,24 +1294,27 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
 u32 device_type, u32 *data)
 {
-   struct ixgbe_hic_internal_phy_req read_cmd;
+   union {
+   struct ixgbe_hic_internal_phy_req cmd;
+   struct ixgbe_hic_internal_phy_resp rsp;
+   } hic;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

-   memset(_cmd, 0, sizeof(read_cmd));
-   read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
-   read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
-   read_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
-   read_cmd.port_number = hw->bus.lan_id;
-   read_cmd.command_type = FW_INT_PHY_REQ_READ;
-   read_cmd.address = (u16)reg_addr;
+   memset(, 0, sizeof(hic));
+   hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
+   hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
+   hic.cmd.port_number = hw->bus.lan_id;
+   hic.cmd.command_type = FW_INT_PHY_REQ_READ;
+   hic.cmd.address = IXGBE_CPU_TO_BE16(reg_addr);

-   status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
- sizeof(read_cmd),
+   status = ixgbe_host_interface_command(hw, (u32 *),
+ sizeof(hic.cmd),
  IXGBE_HI_COMMAND_TIMEOUT, true);

/* Extract the register value from the response. */
-   *data = ((struct ixgbe_hic_internal_phy_resp *)_cmd)->read_data;
+   *data = IXGBE_LE32_TO_CPU(hic.rsp.read_data);

return status;
 }
-- 
2.5.0



[dpdk-dev] [PATCH v2 25/30] ixgbe/base: use u8 to replace u16 for a variable

2016-06-14 Thread Beilei Xing
Since PCIe standard defines maximum of 8 functions per device lan_id
is a value 0..7. Because of that, lan_id don't need to be u16.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 2 +-
 drivers/net/ixgbe/base/ixgbe_type.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 80ea3b9..6e54628 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -1034,7 +1034,7 @@ void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw)

reg = IXGBE_READ_REG(hw, IXGBE_STATUS);
bus->func = (reg & IXGBE_STATUS_LAN_ID) >> IXGBE_STATUS_LAN_ID_SHIFT;
-   bus->lan_id = bus->func;
+   bus->lan_id = (u8)bus->func;

/* check for a port swap */
reg = IXGBE_READ_REG(hw, IXGBE_FACTPS_BY_MAC(hw));
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 3bf0de0..d91c4ed 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3684,7 +3684,7 @@ struct ixgbe_bus_info {
enum ixgbe_bus_type type;

u16 func;
-   u16 lan_id;
+   u8 lan_id;
u16 instance_id;
 };

-- 
2.5.0



[dpdk-dev] [PATCH v2 24/30] ixgbe/base: unify coding style

2016-06-14 Thread Beilei Xing
This patch changes static keyword to STATIC definition, which can be
redefined depending on the compiler used.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 38 ++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 80f59fb..1137179 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "ixgbe_phy.h"

 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_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
+STATIC void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);

 /**
  *  ixgbe_init_ops_X550 - Inits func ptrs and MAC type
@@ -335,7 +335,7 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
  * @dev_type: always unused
  * @phy_data: Pointer to read data from PHY register
  */
-static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+STATIC s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
 u32 dev_type, u16 *phy_data)
 {
u32 i, data, command;
@@ -383,7 +383,7 @@ static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, 
u32 reg_addr,
  * @dev_type: always unused
  * @phy_data: Data to write to the PHY register
  */
-static s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+STATIC s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
  u32 dev_type, u16 phy_data)
 {
u32 i, command;
@@ -428,7 +428,7 @@ static s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, 
u32 reg_addr,
  *
  * Returns error code
  */
-static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
 {
u32 swfw_mask = hw->phy.phy_semaphore_mask;
u16 phy_id_high;
@@ -536,7 +536,7 @@ STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, 
u32 reg_addr,
  *
  * Returns an error code on error.
  **/
-static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
+STATIC s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
   u16 reg, u16 *val)
 {
return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
@@ -551,7 +551,7 @@ static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw 
*hw, u8 addr,
  *
  * Returns an error code on error.
  **/
-static s32
+STATIC s32
 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
 u16 reg, u16 *val)
 {
@@ -567,7 +567,7 @@ ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw 
*hw, u8 addr,
  *
  * Returns an error code on error.
  **/
-static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
+STATIC s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
u8 addr, u16 reg, u16 val)
 {
return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
@@ -582,7 +582,7 @@ static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw 
*hw,
  *
  * Returns an error code on error.
  **/
-static s32
+STATIC s32
 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
  u8 addr, u16 reg, u16 val)
 {
@@ -864,7 +864,7 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  * ixgbe_enable_eee_x550 - Enable EEE support
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
 {
u16 autoneg_eee_reg;
u32 link_reg;
@@ -919,7 +919,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
  * ixgbe_disable_eee_x550 - Disable EEE support
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
 {
u16 autoneg_eee_reg;
u32 link_reg;
@@ -1595,7 +1595,7 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
  * ixgbe_setup_sgmii - Set up link for sgmii
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
+STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
 bool autoneg_wait_to_complete)
 {
struct ixgbe_mac_info *mac = >mac;
@@ -1960,7 +1960,7 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
  *
  * Must be called while holding the PHY semaphore and token
  */
-static s32 ixgbe_set_master_slave_mode(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_set_master_slave_mode(struct ixgbe_hw *hw)
 {
u16 phy_data;
s32 rc;
@@

[dpdk-dev] [PATCH v2 23/30] ixgbe/base: add bypassing VLVF

2016-06-14 Thread Beilei Xing
This patch adds support for the VLVF to be bypassed when adding or
removing a VFTA entry.  The PF can utilize the default pool while
preserving the VLVF for the VFs use.
Meanwhile, update corresponding VF ops and drivers where corresponding
ops is invoked.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_82598.c  |  5 ++-
 drivers/net/ixgbe/base/ixgbe_82598.h  |  3 +-
 drivers/net/ixgbe/base/ixgbe_api.c| 11 --
 drivers/net/ixgbe/base/ixgbe_api.h|  5 ++-
 drivers/net/ixgbe/base/ixgbe_common.c | 71 +++
 drivers/net/ixgbe/base/ixgbe_common.h |  7 ++--
 drivers/net/ixgbe/base/ixgbe_type.h   |  5 ++-
 drivers/net/ixgbe/base/ixgbe_vf.c |  6 ++-
 drivers/net/ixgbe/base/ixgbe_vf.h |  3 +-
 drivers/net/ixgbe/ixgbe_ethdev.c  | 11 --
 drivers/net/ixgbe/ixgbe_pf.c  |  2 +-
 11 files changed, 76 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_82598.c 
b/drivers/net/ixgbe/base/ixgbe_82598.c
index 9e65fff..db80880 100644
--- a/drivers/net/ixgbe/base/ixgbe_82598.c
+++ b/drivers/net/ixgbe/base/ixgbe_82598.c
@@ -995,17 +995,20 @@ 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
  *
  *  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 vlan_on, bool bypass_vlvf)
 {
u32 regindex;
u32 bitindex;
u32 bits;
u32 vftabyte;

+   UNREFERENCED_1PARAMETER(bypass_vlvf);
+
DEBUGFUNC("ixgbe_set_vfta_82598");

if (vlan > 4095)
diff --git a/drivers/net/ixgbe/base/ixgbe_82598.h 
b/drivers/net/ixgbe/base/ixgbe_82598.h
index 89dd11a..0326e70 100644
--- a/drivers/net/ixgbe/base/ixgbe_82598.h
+++ b/drivers/net/ixgbe/base/ixgbe_82598.h
@@ -39,7 +39,8 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw);
 s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw);
 void ixgbe_enable_relaxed_ordering_82598(struct ixgbe_hw *hw);
 s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
-s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool 
vlan_on);
+s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
+bool vlvf_bypass);
 s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val);
 s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val);
 s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 90deaf1..1786867 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1082,13 +1082,15 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
  *  @vlan: VLAN id to write to VLAN filter
  *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
  *  @vlan_on: boolean flag to turn on/off VLAN
+ *  @vlvf_bypass: boolean flag indicating updating the default pool is okay
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
-s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on)
+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), IXGBE_NOT_IMPLEMENTED);
+ vlan_on, vlvf_bypass), IXGBE_NOT_IMPLEMENTED);
 }

 /**
@@ -1100,14 +1102,15 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on)
  *  @vfta_delta: pointer to the difference between the current value of VFTA
  *   and the desired value
  *  @vfta: the desired value of the VFTA
+ *  @vlvf_bypass: boolean flag indicating updating the default pool is okay
  *
  *  Turn on/off specified bit in VLVF table.
  **/
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
-  u32 *vfta_delta, u32 vfta)
+  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),
+   vlan_on, vfta_delta, vfta, vlvf_bypass),
   IXGBE_NOT_IMPLEMENTED);
 }

diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index 9431d14..c126982 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -124,9 +124,10 @@ s32 ixgbe_enable_mc(struct ixgbe_hw *hw);
 s32 ixgbe_disable_mc(struct ixgbe_hw *hw);
 s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);
 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan,
- 

[dpdk-dev] [PATCH v2 22/30] ixgbe/base: simplify add/remove VLANs

2016-06-14 Thread Beilei Xing
This patch simplifies the adding and removing VLANs from
VFTA/VLVF/VLVFB registers. The logic to determine registers has
been simplified to (vid / 32) and (1 - vid / 32). Many conditional
paths and checks are no longer needed with this patch.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c|  18 ++--
 drivers/net/ixgbe/base/ixgbe_api.h|   2 +-
 drivers/net/ixgbe/base/ixgbe_common.c | 188 ++
 drivers/net/ixgbe/base/ixgbe_common.h |   2 +-
 drivers/net/ixgbe/base/ixgbe_type.h   |   2 +-
 5 files changed, 91 insertions(+), 121 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index e117b86..90deaf1 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1080,8 +1080,8 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
  *  ixgbe_set_vfta - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @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
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
@@ -1095,18 +1095,20 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on)
  *  ixgbe_set_vlvf - Set VLAN Pool Filter
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
- *  @vfta_changed: pointer to boolean flag which indicates whether VFTA
- * should be changed
+ *  @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
+ *  @vfta: the desired value of the VFTA
  *
  *  Turn on/off specified bit in VLVF table.
  **/
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
-   bool *vfta_changed)
+  u32 *vfta_delta, u32 vfta)
 {
return ixgbe_call_func(hw, hw->mac.ops.set_vlvf, (hw, vlan, vind,
-  vlan_on, vfta_changed), IXGBE_NOT_IMPLEMENTED);
+  vlan_on, vfta_delta, vfta),
+  IXGBE_NOT_IMPLEMENTED);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index f5970a8..9431d14 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -126,7 +126,7 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);
 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan,
   u32 vind, bool vlan_on);
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
-  bool vlan_on, bool *vfta_changed);
+  bool vlan_on, u32 *vfta_delta, u32 vfta);
 s32 ixgbe_fc_enable(struct ixgbe_hw *hw);
 s32 ixgbe_setup_fc(struct ixgbe_hw *hw);
 s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build,
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 0a708cf..4551a2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -3853,24 +3853,20 @@ s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan)
  *  ixgbe_set_vfta_generic - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
 s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
   bool vlan_on)
 {
-   s32 regindex;
-   u32 bitindex;
-   u32 vfta;
-   u32 targetbit;
-   s32 ret_val = IXGBE_SUCCESS;
-   bool vfta_changed = false;
+   u32 regidx, vfta_delta, vfta;
+   s32 ret_val;

DEBUGFUNC("ixgbe_set_vfta_generic");

-   if (vlan > 4095)
+   if (vlan > 4095 || vind > 63)
return IXGBE_ERR_PARAM;

/*
@@ -3885,33 +3881,28 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 
vlan, u32 vind,
 *bits[11-5]: which register
 *bits[4-0]:  which bit in the register
 */
-   regindex = (vlan >> 5) & 0x7F;
-   bitindex = vlan & 0x1F;
-   targetbit = (1 << bitindex);
-   vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
-
-   if (vlan_on) {
-   if (!(vfta & targetbit)) {
-   vfta |= targetbit;
-   vfta_ch

[dpdk-dev] [PATCH v2 21/30] ixgbe/base: limit PHY token accessing to MDIO only

2016-06-14 Thread Beilei Xing
This patch limits getting and putting the PHY Token to PHY MDIO
access only by adding ixgbe_read_phy_reg_x550a and
ixgbe_write_phy_reg_x550a. The PHY Token is only needed to
synchronize access to the MDIO shared between the two MAC instance.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 65 +++--
 drivers/net/ixgbe/base/ixgbe_x550.h |  4 +++
 2 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 7aad0bd..80f59fb 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -469,7 +469,8 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
 {
switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_A_SFP:
-   hw->phy.phy_semaphore_mask = IXGBE_GSSR_TOKEN_SM;
+   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
@@ -499,7 +500,8 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
return ixgbe_identify_phy_generic(hw);
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
-   hw->phy.phy_semaphore_mask = IXGBE_GSSR_TOKEN_SM;
+   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
@@ -1245,6 +1247,8 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
return status;
if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
return IXGBE_SUCCESS;
+
+   DEBUGOUT("Put PHY Token host interface command failed");
return IXGBE_ERR_FW_RESP_INVALID;
 }

@@ -3870,6 +3874,63 @@ static void ixgbe_release_swfw_sync_X550a(struct 
ixgbe_hw *hw, u32 mask)
 }

 /**
+ *  ixgbe_read_phy_reg_x550a  - Reads specified PHY register
+ *  @hw: pointer to hardware structure
+ *  @reg_addr: 32 bit address of PHY register to read
+ *  @phy_data: Pointer to read data from PHY register
+ *
+ *  Reads a value from a specified PHY register using the SWFW lock and PHY
+ *  Token. The PHY Token is needed since the MDIO is shared between to MAC
+ *  instances.
+ **/
+s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+u32 device_type, u16 *phy_data)
+{
+   s32 status;
+   u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
+
+   DEBUGFUNC("ixgbe_read_phy_reg_x550a");
+
+   if (hw->mac.ops.acquire_swfw_sync(hw, mask))
+   return IXGBE_ERR_SWFW_SYNC;
+
+   status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
+
+   hw->mac.ops.release_swfw_sync(hw, mask);
+
+   return status;
+}
+
+/**
+ *  ixgbe_write_phy_reg_x550a - Writes specified PHY register
+ *  @hw: pointer to hardware structure
+ *  @reg_addr: 32 bit PHY register to write
+ *  @device_type: 5 bit device type
+ *  @phy_data: Data to write to the PHY register
+ *
+ *  Writes a value to specified PHY register using the SWFW lock and PHY Token.
+ *  The PHY Token is needed since the MDIO is shared between to MAC instances.
+ **/
+s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u16 phy_data)
+{
+   s32 status;
+   u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
+
+   DEBUGFUNC("ixgbe_write_phy_reg_x550a");
+
+   if (hw->mac.ops.acquire_swfw_sync(hw, mask) == IXGBE_SUCCESS) {
+   status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type,
+phy_data);
+   hw->mac.ops.release_swfw_sync(hw, mask);
+   } else {
+   status = IXGBE_ERR_SWFW_SYNC;
+   }
+
+   return status;
+}
+
+/**
  * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
  * @hw: pointer to hardware structure
  *
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.h 
b/drivers/net/ixgbe/base/ixgbe_x550.h
index a6ec3cb..b597b50 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.h
+++ b/drivers/net/ixgbe/base/ixgbe_x550.h
@@ -146,6 +146,10 @@ s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
 s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
   ixgbe_link_speed speed,
   bool autoneg_wait_to_complete);
+s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+u32 device_type, u16 *phy_data);
+s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device

[dpdk-dev] [PATCH v2 20/30] ixgbe/base: fix register access error

2016-06-14 Thread Beilei Xing
This patch corrects the FLA/GSCL/GSCN access offset value according
to the datasheet.

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

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 42 -
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index f40580d..ec1f4e0 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -196,7 +196,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_FLA_X540 IXGBE_FLA
 #define IXGBE_FLA_X550 IXGBE_FLA
 #define IXGBE_FLA_X550EM_x IXGBE_FLA
-#define IXGBE_FLA_X550EM_a 0x15F6C
+#define IXGBE_FLA_X550EM_a 0x15F68
 #define IXGBE_FLA_BY_MAC(_hw)  IXGBE_BY_MAC((_hw), FLA)

 #define IXGBE_EEMNGCTL 0x10110
@@ -1080,16 +1080,40 @@ struct ixgbe_dmac_config {
 #define IXGBE_PCIEPIPEDAT  0x11008
 #define IXGBE_GSCL_1   0x11010
 #define IXGBE_GSCL_2   0x11014
+#define IXGBE_GSCL_1_X540  IXGBE_GSCL_1
+#define IXGBE_GSCL_2_X540  IXGBE_GSCL_2
 #define IXGBE_GSCL_3   0x11018
 #define IXGBE_GSCL_4   0x1101C
 #define IXGBE_GSCN_0   0x11020
 #define IXGBE_GSCN_1   0x11024
 #define IXGBE_GSCN_2   0x11028
 #define IXGBE_GSCN_3   0x1102C
+#define IXGBE_GSCN_0_X540  IXGBE_GSCN_0
+#define IXGBE_GSCN_1_X540  IXGBE_GSCN_1
+#define IXGBE_GSCN_2_X540  IXGBE_GSCN_2
+#define IXGBE_GSCN_3_X540  IXGBE_GSCN_3
 #define IXGBE_FACTPS   0x10150
 #define IXGBE_FACTPS_X540  IXGBE_FACTPS
+#define IXGBE_GSCL_1_X550  0x11800
+#define IXGBE_GSCL_2_X550  0x11804
+#define IXGBE_GSCL_1_X550EM_x  IXGBE_GSCL_1_X550
+#define IXGBE_GSCL_2_X550EM_x  IXGBE_GSCL_2_X550
+#define IXGBE_GSCN_0_X550  0x11820
+#define IXGBE_GSCN_1_X550  0x11824
+#define IXGBE_GSCN_2_X550  0x11828
+#define IXGBE_GSCN_3_X550  0x1182C
+#define IXGBE_GSCN_0_X550EM_x  IXGBE_GSCN_0_X550
+#define IXGBE_GSCN_1_X550EM_x  IXGBE_GSCN_1_X550
+#define IXGBE_GSCN_2_X550EM_x  IXGBE_GSCN_2_X550
+#define IXGBE_GSCN_3_X550EM_x  IXGBE_GSCN_3_X550
 #define IXGBE_FACTPS_X550  IXGBE_FACTPS
 #define IXGBE_FACTPS_X550EM_x  IXGBE_FACTPS
+#define IXGBE_GSCL_1_X550EM_a  IXGBE_GSCL_1_X550
+#define IXGBE_GSCL_2_X550EM_a  IXGBE_GSCL_2_X550
+#define IXGBE_GSCN_0_X550EM_a  IXGBE_GSCN_0_X550
+#define IXGBE_GSCN_1_X550EM_a  IXGBE_GSCN_1_X550
+#define IXGBE_GSCN_2_X550EM_a  IXGBE_GSCN_2_X550
+#define IXGBE_GSCN_3_X550EM_a  IXGBE_GSCN_3_X550
 #define IXGBE_FACTPS_X550EM_a  0x15FEC
 #define IXGBE_FACTPS_BY_MAC(_hw)   IXGBE_BY_MAC((_hw), FACTPS)

@@ -1126,6 +1150,10 @@ struct ixgbe_dmac_config {
 #define IXGBE_GSCL_6_82599 0x11034
 #define IXGBE_GSCL_7_82599 0x11038
 #define IXGBE_GSCL_8_82599 0x1103C
+#define IXGBE_GSCL_5_X540  IXGBE_GSCL_5_82599
+#define IXGBE_GSCL_6_X540  IXGBE_GSCL_6_82599
+#define IXGBE_GSCL_7_X540  IXGBE_GSCL_7_82599
+#define IXGBE_GSCL_8_X540  IXGBE_GSCL_8_82599
 #define IXGBE_PHYADR_82599 0x11040
 #define IXGBE_PHYDAT_82599 0x11044
 #define IXGBE_PHYCTL_82599 0x11048
@@ -1136,10 +1164,22 @@ struct ixgbe_dmac_config {
 #define IXGBE_CIAD_82599   IXGBE_CIAD
 #define IXGBE_CIAA_X540IXGBE_CIAA
 #define IXGBE_CIAD_X540IXGBE_CIAD
+#define IXGBE_GSCL_5_X550  0x11810
+#define IXGBE_GSCL_6_X550  0x11814
+#define IXGBE_GSCL_7_X550  0x11818
+#define IXGBE_GSCL_8_X550  0x1181C
+#define IXGBE_GSCL_5_X550EM_x  IXGBE_GSCL_5_X550
+#define IXGBE_GSCL_6_X550EM_x  IXGBE_GSCL_6_X550
+#define IXGBE_GSCL_7_X550EM_x  IXGBE_GSCL_7_X550
+#define IXGBE_GSCL_8_X550EM_x  IXGBE_GSCL_8_X550
 #define IXGBE_CIAA_X5500x11508
 #define IXGBE_CIAD_X5500x11510
 #define IXGBE_CIAA_X550EM_xIXGBE_CIAA_X550
 #define IXGBE_CIAD_X550EM_xIXGBE_CIAD_X550
+#define IXGBE_GSCL_5_X550EM_a  IXGBE_GSCL_5_X550
+#define IXGBE_GSCL_6_X550EM_a  IXGBE_GSCL_6_X550
+#define IXGBE_GSCL_7_X550EM_a  IXGBE_GSCL_7_X550
+#define IXGBE_GSCL_8_X550EM_a  IXGBE_GSCL_8_X550
 #define IXGBE_CIAA_X550EM_aIXGBE_CIAA_X550
 #define IXGBE_CIAD_X550EM_aIXGBE_CIAD_X550
 #define IXGBE_CIAA_BY_MAC(_hw) IXGBE_BY_MAC((_hw), CIAA)
-- 
2.5.0



[dpdk-dev] [PATCH v2 19/30] ixgbe/base: fix possible race issue

2016-06-14 Thread Beilei Xing
This patch fixes possible race issue between ports when issuing host
interface command by acquiring/releasing the management host interface
semaphore in ixgbe_host_interface_command.

Fixes: 36f43e8679ae ("ixgbe/base: refactor manageability block communication")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 40 ---
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 0a74714..0a708cf 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4373,8 +4373,9 @@ u8 ixgbe_calculate_checksum(u8 *buffer, u32 length)
  *   So we will leave this up to the caller to read back the data
  *   in these cases.
  *
- *  Communicates with the manageability block.  On success return IXGBE_SUCCESS
- *  else return IXGBE_ERR_HOST_INTERFACE_COMMAND.
+ *  Communicates with the manageability block. On success return IXGBE_SUCCESS
+ *  else returns semaphore error when encountering an error acquiring
+ *  semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
  **/
 s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
 u32 length, u32 timeout, bool return_data)
@@ -4383,6 +4384,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
u32 hdr_size = sizeof(struct ixgbe_hic_hdr);
u16 buf_len;
u16 dword_len;
+   s32 status;

DEBUGFUNC("ixgbe_host_interface_command");

@@ -4390,6 +4392,11 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
DEBUGOUT1("Buffer length failure buffersize=%d.\n", length);
return IXGBE_ERR_HOST_INTERFACE_COMMAND;
}
+   /* Take management host interface semaphore */
+   status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
+
+   if (status)
+   return status;

/* Set bit 9 of FWSTS clearing FW reset indication */
fwsts = IXGBE_READ_REG(hw, IXGBE_FWSTS);
@@ -4399,13 +4406,15 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
hicr = IXGBE_READ_REG(hw, IXGBE_HICR);
if ((hicr & IXGBE_HICR_EN) == 0) {
DEBUGOUT("IXGBE_HOST_EN bit disabled.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

/* Calculate length in DWORDs. We must be DWORD aligned */
if ((length % (sizeof(u32))) != 0) {
DEBUGOUT("Buffer length failure, not aligned to dword");
-   return IXGBE_ERR_INVALID_ARGUMENT;
+   status = IXGBE_ERR_INVALID_ARGUMENT;
+   goto rel_out;
}

dword_len = length >> 2;
@@ -4432,11 +4441,12 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV)) {
ERROR_REPORT1(IXGBE_ERROR_CAUTION,
 "Command has failed with no status valid.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

if (!return_data)
-   return 0;
+   goto rel_out;

/* Calculate length in DWORDs */
dword_len = hdr_size >> 2;
@@ -4450,11 +4460,12 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
/* If there is any thing in data position pull it in */
buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len;
if (buf_len == 0)
-   return 0;
+   goto rel_out;

if (length < buf_len + hdr_size) {
DEBUGOUT("Buffer not large enough for reply message.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

/* Calculate length in DWORDs, add 3 for odd lengths */
@@ -4466,7 +4477,10 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
IXGBE_LE32_TO_CPUS([bi]);
}

-   return 0;
+rel_out:
+   hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
+
+   return status;
 }

 /**
@@ -4491,12 +4505,6 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 
maj, u8 min,

DEBUGFUNC("ixgbe_set_fw_drv_ver_generic");

-   if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM)
-   != IXGBE_SUCCESS) {
-   ret_val = IXGBE_ERR_SWFW_SYNC;
-   goto out;
-   }
-
fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN;
fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;

[dpdk-dev] [PATCH v2 18/30] ixgbe/base: add function to reset swfw semaphore

2016-06-14 Thread Beilei Xing
For X540 and forward it is possible if a system reset occur at the
right time to leave the SWFW semaphore high. This new function will
attempt to grab and release the semaphore. If the grab times out it
will still release the semaphore placing it in a known good state.
The idea is to call this when you know no one should be holding the
semaphore (i.e. probe time).

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c| 14 ++
 drivers/net/ixgbe/base/ixgbe_api.h|  1 +
 drivers/net/ixgbe/base/ixgbe_common.c |  1 +
 drivers/net/ixgbe/base/ixgbe_type.h   |  1 +
 drivers/net/ixgbe/base/ixgbe_x540.c   | 20 
 drivers/net/ixgbe/base/ixgbe_x540.h   |  1 +
 6 files changed, 38 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 19e52c9..e117b86 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1639,6 +1639,20 @@ void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, 
u32 mask)
hw->mac.ops.release_swfw_sync(hw, mask);
 }

+/**
+ *  ixgbe_init_swfw_semaphore - Clean up SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *
+ *  Attempts to acquire the SWFW semaphore through SW_FW_SYNC register.
+ *  Regardless of whether is succeeds or not it then release the semaphore.
+ *  This is function is called to recover from catastrophic failures that
+ *  may have left the semaphore locked.
+ **/
+void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw)
+{
+   if (hw->mac.ops.init_swfw_sync)
+   hw->mac.ops.init_swfw_sync(hw);
+}

 void ixgbe_disable_rx(struct ixgbe_hw *hw)
 {
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index ae26a6a..f5970a8 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -191,6 +191,7 @@ s32 ixgbe_set_san_mac_addr(struct ixgbe_hw *hw, u8 
*san_mac_addr);
 s32 ixgbe_get_device_caps(struct ixgbe_hw *hw, u16 *device_caps);
 s32 ixgbe_acquire_swfw_semaphore(struct ixgbe_hw *hw, u32 mask);
 void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, u32 mask);
+void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw);
 s32 ixgbe_get_wwn_prefix(struct ixgbe_hw *hw, u16 *wwnn_prefix,
 u16 *wwpn_prefix);
 s32 ixgbe_get_fcoe_boot_status(struct ixgbe_hw *hw, u16 *bs);
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index d211303..0a74714 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4390,6 +4390,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
DEBUGOUT1("Buffer length failure buffersize=%d.\n", length);
return IXGBE_ERR_HOST_INTERFACE_COMMAND;
}
+
/* Set bit 9 of FWSTS clearing FW reset indication */
fwsts = IXGBE_READ_REG(hw, IXGBE_FWSTS);
IXGBE_WRITE_REG(hw, IXGBE_FWSTS, fwsts | IXGBE_FWSTS_FWRI);
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 6a837f1..f40580d 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3785,6 +3785,7 @@ struct ixgbe_mac_operations {
s32 (*enable_sec_rx_path)(struct ixgbe_hw *);
s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u32);
void (*release_swfw_sync)(struct ixgbe_hw *, u32);
+   void (*init_swfw_sync)(struct ixgbe_hw *);
s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *);
s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool);

diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c 
b/drivers/net/ixgbe/base/ixgbe_x540.c
index 0678913..31dead0 100644
--- a/drivers/net/ixgbe/base/ixgbe_x540.c
+++ b/drivers/net/ixgbe/base/ixgbe_x540.c
@@ -99,6 +99,7 @@ s32 ixgbe_init_ops_X540(struct ixgbe_hw *hw)
mac->ops.get_fcoe_boot_status = ixgbe_get_fcoe_boot_status_generic;
mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X540;
mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X540;
+   mac->ops.init_swfw_sync = ixgbe_init_swfw_sync_X540;
mac->ops.disable_sec_rx_path = ixgbe_disable_sec_rx_path_generic;
mac->ops.enable_sec_rx_path = ixgbe_enable_sec_rx_path_generic;

@@ -946,6 +947,25 @@ STATIC void ixgbe_release_swfw_sync_semaphore(struct 
ixgbe_hw *hw)
 }

 /**
+ *  ixgbe_init_swfw_sync_X540 - Release hardware semaphore
+ *  @hw: pointer to hardware structure
+ *
+ *  This function reset hardware semaphore bits for a semaphore that may
+ *  have be left locked due to a catastrophic failure.
+ **/
+void ixgbe_init_swfw_sync_X540(struct ixgbe_hw *hw)
+{
+   /* First try to grab the semaphore but we don't need to bother
+* looking to see whether we got the lock or  not since we do
+* the same thing regardless of whether we got the lock or not.
+* We got the lock - we release it.
+* We time

[dpdk-dev] [PATCH v2 17/30] ixgbe/base: change device IDs

2016-06-14 Thread Beilei Xing
There're two device IDs changed from 15C6/15C7 to 15E4/15E5 cause
PHY info changes. Make the change and use 15C6/15C7 for the backplane
SGMII. Clean up some discovery kludges from the previous shared ID,
and also add 15C6/15C7 to ixgbe_set_mdio_speed just for paranoia
to control MDIO speed even though nothing should be attached.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c  |  2 ++
 drivers/net/ixgbe/base/ixgbe_type.h |  7 ---
 drivers/net/ixgbe/base/ixgbe_x550.c | 17 -
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 12 
 4 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index cf1e516..19e52c9 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -209,6 +209,8 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_KR:
case IXGBE_DEV_ID_X550EM_A_KR_L:
case IXGBE_DEV_ID_X550EM_A_SFP_N:
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index f1379be..6a837f1 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -133,12 +133,14 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_DEV_ID_X550EM_A_KR   0x15C2
 #define IXGBE_DEV_ID_X550EM_A_KR_L 0x15C3
 #define IXGBE_DEV_ID_X550EM_A_SFP_N0x15C4
-#define IXGBE_DEV_ID_X550EM_A_1G_T 0x15C6
-#define IXGBE_DEV_ID_X550EM_A_1G_T_L   0x15C7
+#define IXGBE_DEV_ID_X550EM_A_SGMII0x15C6
+#define IXGBE_DEV_ID_X550EM_A_SGMII_L  0x15C7
 #define IXGBE_DEV_ID_X550EM_A_10G_T0x15C8
 #define IXGBE_DEV_ID_X550EM_A_QSFP 0x15CA
 #define IXGBE_DEV_ID_X550EM_A_QSFP_N   0x15CC
 #define IXGBE_DEV_ID_X550EM_A_SFP  0x15CE
+#define IXGBE_DEV_ID_X550EM_A_1G_T 0x15E4
+#define IXGBE_DEV_ID_X550EM_A_1G_T_L   0x15E5
 #define IXGBE_DEV_ID_X550EM_X_KX4  0x15AA
 #define IXGBE_DEV_ID_X550EM_X_KR   0x15AB
 #define IXGBE_DEV_ID_X550EM_X_SFP  0x15AC
@@ -3562,7 +3564,6 @@ enum ixgbe_media_type {
ixgbe_media_type_fiber_lco,
ixgbe_media_type_copper,
ixgbe_media_type_backplane,
-   ixgbe_media_type_sgmii,
ixgbe_media_type_cx4,
ixgbe_media_type_virtual
 };
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index a4b444b..7aad0bd 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1487,10 +1487,15 @@ enum ixgbe_media_type 
ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_10G_T:
media_type = ixgbe_media_type_copper;
break;
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
+   media_type = ixgbe_media_type_backplane;
+   hw->phy.type = ixgbe_phy_sgmii;
+   break;
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
-   media_type = ixgbe_media_type_sgmii;
-   hw->phy.type = ixgbe_phy_sgmii;
+   media_type = ixgbe_media_type_copper;
+   hw->phy.type = ixgbe_phy_m88;
break;
default:
media_type = ixgbe_media_type_unknown;
@@ -1667,9 +1672,9 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.check_link = ixgbe_check_link_t_X550em;
break;
case ixgbe_media_type_backplane:
-   break;
-   case ixgbe_media_type_sgmii:
-   mac->ops.setup_link = ixgbe_setup_sgmii;
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
+   hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
+   mac->ops.setup_link = ixgbe_setup_sgmii;
break;
default:
break;
@@ -2229,6 +2234,8 @@ static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)

switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_X_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h 
b/lib/librte_eal/common/include/rte_pci_dev_ids.h
index cf7b548..63648c7 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -446,12 +446,14 @@ RTE_PCI_DEV_ID_DECL_IGB(PCI_VENDOR_ID_INTEL, 
E1000_DEV_ID_DH89XXCC_SFP)
 #defi

[dpdk-dev] [PATCH v2 16/30] ixgbe/base: add new phy definitions

2016-06-14 Thread Beilei Xing
It adds new phy definitions.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_phy.c  |  16 +-
 drivers/net/ixgbe/base/ixgbe_type.h |  14 +-
 drivers/net/ixgbe/base/ixgbe_x550.c | 303 ++--
 drivers/net/ixgbe/base/ixgbe_x550.h |  43 +
 4 files changed, 355 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c 
b/drivers/net/ixgbe/base/ixgbe_phy.c
index 6ed685e..ed1b14f 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.c
+++ b/drivers/net/ixgbe/base/ixgbe_phy.c
@@ -454,6 +454,9 @@ enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
case X557_PHY_ID:
phy_type = ixgbe_phy_x550em_ext_t;
break;
+   case IXGBE_M88E1500_E_PHY_ID:
+   phy_type = ixgbe_phy_m88;
+   break;
default:
phy_type = ixgbe_phy_unknown;
break;
@@ -615,13 +618,12 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 
reg_addr,

DEBUGFUNC("ixgbe_read_phy_reg_generic");

-   if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
-   status = ixgbe_read_phy_reg_mdi(hw, reg_addr, device_type,
-   phy_data);
-   hw->mac.ops.release_swfw_sync(hw, gssr);
-   } else {
-   status = IXGBE_ERR_SWFW_SYNC;
-   }
+   if (hw->mac.ops.acquire_swfw_sync(hw, gssr))
+   return IXGBE_ERR_SWFW_SYNC;
+
+   status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
+
+   hw->mac.ops.release_swfw_sync(hw, gssr);

return status;
 }
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index da1fe16..f1379be 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -1607,7 +1607,8 @@ struct ixgbe_dmac_config {
 #define ATH_PHY_ID 0x03429050

 /* PHY Types */
-#define IXGBE_M88E1145_E_PHY_ID0x01410CD0
+#define IXGBE_M88E1500_E_PHY_ID0x01410DD0
+#define IXGBE_M88E1543_E_PHY_ID0x01410EA0

 /* Special PHY Init Routine */
 #define IXGBE_PHY_INIT_OFFSET_NL   0x002B
@@ -3250,6 +3251,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_100_FULL  0x0008
 #define IXGBE_LINK_SPEED_1GB_FULL  0x0020
 #define IXGBE_LINK_SPEED_2_5GB_FULL0x0400
@@ -3574,6 +3576,14 @@ enum ixgbe_fc_mode {
ixgbe_fc_default
 };

+/* Master/slave control */
+enum ixgbe_ms_type {
+   ixgbe_ms_hw_default = 0,
+   ixgbe_ms_force_master,
+   ixgbe_ms_force_slave,
+   ixgbe_ms_auto
+};
+
 /* Smart Speed Settings */
 #define IXGBE_SMARTSPEED_MAX_RETRIES   3
 enum ixgbe_smart_speed {
@@ -3949,6 +3959,8 @@ struct ixgbe_phy_info {
bool reset_disable;
ixgbe_autoneg_advertised autoneg_advertised;
ixgbe_link_speed speeds_supported;
+   enum ixgbe_ms_type ms_type;
+   enum ixgbe_ms_type original_ms_type;
enum ixgbe_smart_speed smart_speed;
bool smart_speed_active;
bool multispeed_fiber;
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 993ef16..a4b444b 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -329,6 +329,100 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_read_phy_reg_mdi_22 - Read from a clause 22 PHY register without lock
+ * @hw: pointer to hardware structure
+ * @reg_addr: 32 bit address of PHY register to read
+ * @dev_type: always unused
+ * @phy_data: Pointer to read data from PHY register
+ */
+static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+u32 dev_type, u16 *phy_data)
+{
+   u32 i, data, command;
+   UNREFERENCED_1PARAMETER(dev_type);
+
+   /* Setup and write the read command */
+   command = (reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
+   (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
+   (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+   IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_READ |
+   IXGBE_MSCA_MDI_COMMAND;
+
+   IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
+
+   /* Check every 10 usec to see if the access completed.
+* The MDI Command bit will clear when the operation is
+* complete
+*/
+   for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+   usec_delay(10);
+
+   command = IXGBE_READ_REG(hw, IXGBE_MSCA);
+   if (!(command & IXGBE_MSCA_MDI_COMMAND))
+   break;
+   }
+
+   if (command & IXGBE_MSCA_MDI_COMMAND) {
+   ERROR_REPORT1(IXGBE_ERROR_POLLING,
+ "PHY read comma

[dpdk-dev] [PATCH v2 15/30] ixgbe/base: refactor NW management interface ops

2016-06-14 Thread Beilei Xing
This patch adds ixgbe_read_mng_if_sel_x550em to read NW_MNG_IF_SEL
register and save fields such as PHY MDIO_ADD.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |  2 ++
 drivers/net/ixgbe/base/ixgbe_x550.c | 48 +++--
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index de295e1..da1fe16 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4134,6 +4134,8 @@ struct ixgbe_hw {
 #define IXGBE_SB_IOSF_TARGET_KR_PHY0

 #define IXGBE_NW_MNG_IF_SEL0x00011178
+#define IXGBE_NW_MNG_IF_SEL_MDIO_ACT   (1 << 1)
+#define IXGBE_NW_MNG_IF_SEL_ENABLE_10_100M (1 << 23)
 #define IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE (1 << 24)
 #define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT 3
 #define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD   \
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index aaf6572..993ef16 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -338,9 +338,8 @@ static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
 {
u16 phy_id_high;
u16 phy_id_low;
-   u32 val = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+   u32 val;

-   hw->phy.addr = (val >> 3) & 0x1F;
val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
   hw->phy.addr, _id_high);
if (val || phy_id_high == 0x) {
@@ -1843,6 +1842,33 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
 }

 /**
+ *  ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
+ *  @hw: pointer to hardware structure
+ *
+ *  Read NW_MNG_IF_SEL register and save field values, and check for valid 
field
+ *  values.
+ **/
+STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
+{
+   /* Save NW management interface connected on board. This is used
+* to determine internal PHY mode.
+*/
+   hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+   /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
+* PHY address. This register field was has only been used for X552.
+*/
+   if (hw->mac.type == ixgbe_mac_X550EM_a &&
+   hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
+   hw->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;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
  *  ixgbe_init_phy_ops_X550em - PHY/SFP specific init
  *  @hw: pointer to hardware structure
  *
@@ -1859,14 +1885,11 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)

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);
-
-   /* Save NW management interface connected on board. This is used
-* to determine internal PHY mode.
-*/
-   phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
}

@@ -1893,11 +1916,6 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
break;
case ixgbe_phy_x550em_ext_t:
-   /* Save NW management interface connected on board. This is used
-* to determine internal PHY mode
-*/
-   phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
-
/* If internal link mode is XFI, then setup iXFI internal link,
 * else setup KR now.
 */
@@ -2256,12 +2274,6 @@ s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
/* Configure internal PHY for KR/KX. */
ixgbe_setup_kr_speed_x550em(hw, speed);

-   /* Get CS4227 MDIO address */
-   hw->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 (hw->phy.addr == 0x0 || hw->phy.addr == 0x) {
/* Find Address */
DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
-- 
2.5.0



[dpdk-dev] [PATCH v2 14/30] ixgbe/base: fix firmware commands on x550em_a

2016-06-14 Thread Beilei Xing
This patch fixes firmware commands on x550em_a. For one thing,
the checksum value was not being set.

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

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index e91546c..aaf6572 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1154,23 +1154,24 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
  *  @data: Data to write to the register
  **/
 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
-   u32 device_type, u32 data)
+ u32 device_type, u32 data)
 {
struct ixgbe_hic_internal_phy_req write_cmd;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

+   memset(_cmd, 0, sizeof(write_cmd));
write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
write_cmd.port_number = hw->bus.lan_id;
write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
write_cmd.address = (u16)reg_addr;
-   write_cmd.rsv1 = 0;
write_cmd.write_data = data;
-   write_cmd.pad = 0;

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
-   sizeof(write_cmd), IXGBE_HI_COMMAND_TIMEOUT, false);
+ sizeof(write_cmd),
+ IXGBE_HI_COMMAND_TIMEOUT, false);

return status;
 }
@@ -1184,23 +1185,23 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
  *  @data: Pointer to read data from the register
  **/
 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
-   u32 device_type, u32 *data)
+u32 device_type, u32 *data)
 {
struct ixgbe_hic_internal_phy_req read_cmd;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

+   memset(_cmd, 0, sizeof(read_cmd));
read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   read_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
read_cmd.port_number = hw->bus.lan_id;
read_cmd.command_type = FW_INT_PHY_REQ_READ;
read_cmd.address = (u16)reg_addr;
-   read_cmd.rsv1 = 0;
-   read_cmd.write_data = 0;
-   read_cmd.pad = 0;

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
-   sizeof(read_cmd), IXGBE_HI_COMMAND_TIMEOUT, true);
+ sizeof(read_cmd),
+ IXGBE_HI_COMMAND_TIMEOUT, true);

/* Extract the register value from the response. */
*data = ((struct ixgbe_hic_internal_phy_resp *)_cmd)->read_data;
-- 
2.5.0



  1   2   >