[dpdk-dev] [PATCH v2 1/2] i40e: fix problematic dereference

2016-06-27 Thread Helin Zhang
It fixes the issue reported by Coverity of 'Dereference before
null check', by deleting null checks as they are not necessary
at all, or move null checks before where uses it.

Coverity ID 119267: Dereference before null check.
Coverity ID 13301: Dereference before null check.
Coverity ID 13294: Dereference before null check.
Coverity ID 13299: Dereference before null check.
Coverity ID 13298: Dereference before null check.

Fixes: 8e109464c022 ("i40e: allow vector Rx and Tx usage")
Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")
Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")
Fixes: 4861cde46116 ("i40e: new poll mode driver")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_pf.c   |  5 +++--
 drivers/net/i40e/i40e_rxtx.c | 12 
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 5afd61a..1bd599b 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -123,7 +123,7 @@ int
 i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool do_hw_reset)
 {
uint32_t val, i;
-   struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
+   struct i40e_hw *hw;
uint16_t vf_id, abs_vf_id, vf_msix_num;
int ret;
struct i40e_virtchnl_queue_select qsel;
@@ -131,6 +131,7 @@ i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool 
do_hw_reset)
if (vf == NULL)
return -EINVAL;

+   hw = I40E_PF_TO_HW(vf->pf);
vf_id = vf->vf_idx;
abs_vf_id = vf_id + hw->func_caps.vf_base_id;

@@ -913,7 +914,7 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
/* AdminQ will pass absolute VF id, transfer to internal vf id */
uint16_t vf_id = abs_vf_id - hw->func_caps.vf_base_id;

-   if (!dev || vf_id > pf->vf_num - 1 || !pf->vfs) {
+   if (vf_id > pf->vf_num - 1 || !pf->vfs) {
PMD_DRV_LOG(ERR, "invalid argument");
return;
}
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 049a813..7bb0aa9 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2614,8 +2614,8 @@ i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq)
return;
}

-   if (!rxq || !rxq->sw_ring) {
-   PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
+   if (!rxq->sw_ring) {
+   PMD_DRV_LOG(DEBUG, "Pointer to sw_ring is NULL");
return;
}

@@ -3002,13 +3002,15 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
struct i40e_tx_queue *txq;
const struct rte_memzone *tz = NULL;
uint32_t ring_size;
-   struct rte_eth_dev *dev = pf->adapter->eth_dev;
+   struct rte_eth_dev *dev;

if (!pf) {
PMD_DRV_LOG(ERR, "PF is not available");
return I40E_ERR_BAD_PTR;
}

+   dev = pf->adapter->eth_dev;
+
/* Allocate the TX queue data structure. */
txq = rte_zmalloc_socket("i40e fdir tx queue",
  sizeof(struct i40e_tx_queue),
@@ -3056,13 +3058,15 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
struct i40e_rx_queue *rxq;
const struct rte_memzone *rz = NULL;
uint32_t ring_size;
-   struct rte_eth_dev *dev = pf->adapter->eth_dev;
+   struct rte_eth_dev *dev;

if (!pf) {
PMD_DRV_LOG(ERR, "PF is not available");
return I40E_ERR_BAD_PTR;
}

+   dev = pf->adapter->eth_dev;
+
/* Allocate the RX queue data structure. */
rxq = rte_zmalloc_socket("i40e fdir rx queue",
  sizeof(struct i40e_rx_queue),
-- 
2.5.0



[dpdk-dev] [PATCH v2 0/2] fix coverity issues

2016-06-27 Thread Helin Zhang
It fixes several problematic dereference issues and missing
break issue reported by Coverity.

Helin Zhang (2):
  i40e: fix problematic dereference
  i40e: fix missing break in switch

 drivers/net/i40e/i40e_pf.c   | 11 +--
 drivers/net/i40e/i40e_rxtx.c | 12 
 2 files changed, 13 insertions(+), 10 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v2 15/15] i40e/base: add capability of disabling all link

2016-05-24 Thread Helin Zhang
It adds a flag, which can be used to tell the firmware to
disable the link on all ports.

Signed-off-by: Helin Zhang 
---
 doc/guides/rel_notes/release_16_07.rst  | 4 
 drivers/net/i40e/Makefile   | 2 +-
 drivers/net/i40e/base/i40e_adminq_cmd.h | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)

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

+* **Updated the i40e base driver.**
+
+  It updated the i40e base driver, which includes supporting new devices IDs.
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 56b20d5..a95a44a 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -85,7 +85,7 @@ VPATH += $(SRCDIR)/base

 #
 # all source are stored in SRCS-y
-# base driver is based on the package of dpdk-i40e.2016.01.07.14.tar.gz.
+# base driver is based on the package of dpdk-i40e.2016.04.18.12.tar.gz.
 #
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_adminq.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_common.c
diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 968..2b7a760 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -1899,7 +1899,10 @@ struct i40e_aqc_set_phy_debug {
 #define I40E_AQ_PHY_DEBUG_RESET_EXTERNAL_NONE  0x00
 #define I40E_AQ_PHY_DEBUG_RESET_EXTERNAL_HARD  0x01
 #define I40E_AQ_PHY_DEBUG_RESET_EXTERNAL_SOFT  0x02
+/* Disable link manageability on a single port */
 #define I40E_AQ_PHY_DEBUG_DISABLE_LINK_FW  0x10
+/* Disable link manageability on all ports needs both bits 4 and 5 */
+#define I40E_AQ_PHY_DEBUG_DISABLE_ALL_LINK_FW  0x20
u8  reserved[15];
 };

-- 
2.5.0



[dpdk-dev] [PATCH v2 14/15] i40e/base: add RSS config to virtual channel

2016-05-24 Thread Helin Zhang
It add opcodes and structures to support RSS configuration
by PF driver on behalf of the VF drivers.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_virtchnl.h | 45 ---
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_virtchnl.h 
b/drivers/net/i40e/base/i40e_virtchnl.h
index 26208f3..fd51ec3 100644
--- a/drivers/net/i40e/base/i40e_virtchnl.h
+++ b/drivers/net/i40e/base/i40e_virtchnl.h
@@ -87,10 +87,15 @@ enum i40e_virtchnl_ops {
I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
I40E_VIRTCHNL_OP_GET_STATS = 15,
I40E_VIRTCHNL_OP_FCOE = 16,
-   I40E_VIRTCHNL_OP_EVENT = 17,
+   I40E_VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
 #ifdef I40E_SOL_VF_SUPPORT
I40E_VIRTCHNL_OP_GET_ADDNL_SOL_CONFIG = 19,
 #endif
+   I40E_VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
+   I40E_VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
+   I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
+   I40E_VIRTCHNL_OP_SET_RSS_HENA = 26,
+
 };

 /* Virtual channel message descriptor. This overlays the admin queue
@@ -164,6 +169,7 @@ struct i40e_virtchnl_vsi_resource {
 #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN  0x0001
 #define I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING0x0002
 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x0004
+#define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF0X0008

 struct i40e_virtchnl_vf_resource {
u16 num_vsis;
@@ -172,8 +178,8 @@ struct i40e_virtchnl_vf_resource {
u16 max_mtu;

u32 vf_offload_flags;
-   u32 max_fcoe_contexts;
-   u32 max_fcoe_filters;
+   u32 rss_key_size;
+   u32 rss_lut_size;

struct i40e_virtchnl_vsi_resource vsi_res[1];
 };
@@ -349,6 +355,39 @@ struct i40e_virtchnl_promisc_info {
  * PF replies with struct i40e_eth_stats in an external buffer.
  */

+/* I40E_VIRTCHNL_OP_CONFIG_RSS_KEY
+ * I40E_VIRTCHNL_OP_CONFIG_RSS_LUT
+ * VF sends these messages to configure RSS. Only supported if both PF
+ * and VF drivers set the I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
+ * configuration negotiation. If this is the case, then the rss fields in
+ * the vf resource struct are valid.
+ * Both the key and LUT are initialized to 0 by the PF, meaning that
+ * RSS is effectively disabled until set up by the VF.
+ */
+struct i40e_virtchnl_rss_key {
+   u16 vsi_id;
+   u16 key_len;
+   u8 key[1]; /* RSS hash key, packed bytes */
+};
+
+struct i40e_virtchnl_rss_lut {
+   u16 vsi_id;
+   u16 lut_entries;
+   u8 lut[1];/* RSS lookup table*/
+};
+
+/* I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS
+ * I40E_VIRTCHNL_OP_SET_RSS_HENA
+ * VF sends these messages to get and set the hash filter enable bits for RSS.
+ * By default, the PF sets these to all possible traffic types that the
+ * hardware supports. The VF can query this value if it wants to change the
+ * traffic types that are hashed by the hardware.
+ * Traffic types are defined in the i40e_filter_pctype enum in i40e_type.h
+ */
+struct i40e_virtchnl_rss_hena {
+   u64 hena;
+};
+
 /* I40E_VIRTCHNL_OP_EVENT
  * PF sends this message to inform the VF driver of events that may affect it.
  * No direct response is expected from the VF, though it may generate other
-- 
2.5.0



[dpdk-dev] [PATCH v2 13/15] i40e/base: add input set mask definitions

2016-05-24 Thread Helin Zhang
It adds input set mask definitions for RSS, flow director
and flex bytes.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_type.h | 33 +
 1 file changed, 33 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index bc68b47..5349419 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -1638,4 +1638,37 @@ struct i40e_lldp_variables {

 /* RSS Hash Table Size */
 #define I40E_PFQF_CTL_0_HASHLUTSIZE_5120x0001
+
+/* INPUT SET MASK for RSS, flow director, and flexible payload */
+#define I40E_L3_SRC_SHIFT  47
+#define I40E_L3_SRC_MASK   (0x3ULL << I40E_L3_SRC_SHIFT)
+#define I40E_L3_V6_SRC_SHIFT   43
+#define I40E_L3_V6_SRC_MASK(0xFFULL << I40E_L3_V6_SRC_SHIFT)
+#define I40E_L3_DST_SHIFT  35
+#define I40E_L3_DST_MASK   (0x3ULL << I40E_L3_DST_SHIFT)
+#define I40E_L3_V6_DST_SHIFT   35
+#define I40E_L3_V6_DST_MASK(0xFFULL << I40E_L3_V6_DST_SHIFT)
+#define I40E_L4_SRC_SHIFT  34
+#define I40E_L4_SRC_MASK   (0x1ULL << I40E_L4_SRC_SHIFT)
+#define I40E_L4_DST_SHIFT  33
+#define I40E_L4_DST_MASK   (0x1ULL << I40E_L4_DST_SHIFT)
+#define I40E_VERIFY_TAG_SHIFT  31
+#define I40E_VERIFY_TAG_MASK   (0x3ULL << I40E_VERIFY_TAG_SHIFT)
+
+#define I40E_FLEX_50_SHIFT 13
+#define I40E_FLEX_50_MASK  (0x1ULL << I40E_FLEX_50_SHIFT)
+#define I40E_FLEX_51_SHIFT 12
+#define I40E_FLEX_51_MASK  (0x1ULL << I40E_FLEX_51_SHIFT)
+#define I40E_FLEX_52_SHIFT 11
+#define I40E_FLEX_52_MASK  (0x1ULL << I40E_FLEX_52_SHIFT)
+#define I40E_FLEX_53_SHIFT 10
+#define I40E_FLEX_53_MASK  (0x1ULL << I40E_FLEX_53_SHIFT)
+#define I40E_FLEX_54_SHIFT 9
+#define I40E_FLEX_54_MASK  (0x1ULL << I40E_FLEX_54_SHIFT)
+#define I40E_FLEX_55_SHIFT 8
+#define I40E_FLEX_55_MASK  (0x1ULL << I40E_FLEX_55_SHIFT)
+#define I40E_FLEX_56_SHIFT 7
+#define I40E_FLEX_56_MASK  (0x1ULL << I40E_FLEX_56_SHIFT)
+#define I40E_FLEX_57_SHIFT 6
+#define I40E_FLEX_57_MASK  (0x1ULL << I40E_FLEX_57_SHIFT)
 #endif /* _I40E_TYPE_H_ */
-- 
2.5.0



[dpdk-dev] [PATCH v2 12/15] i40e/base: increase supported AQ API version

2016-05-24 Thread Helin Zhang
It increases the supported AQ API version to 1.5
for X722.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_type.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 7ed3048..bc68b47 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -188,7 +188,7 @@ enum i40e_memcpy_type {
 };

 #ifdef X722_SUPPORT
-#define I40E_FW_API_VERSION_MINOR_X722 0x0004
+#define I40E_FW_API_VERSION_MINOR_X722 0x0005
 #endif
 #define I40E_FW_API_VERSION_MINOR_X710 0x0005

-- 
2.5.0



[dpdk-dev] [PATCH v2 11/15] i40e/base: add more device capabilities

2016-05-24 Thread Helin Zhang
It adds more device capabilities for NVM management.
- if update is available
- if security check is needed

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 1 +
 drivers/net/i40e/base/i40e_common.c | 6 ++
 drivers/net/i40e/base/i40e_type.h   | 5 +
 3 files changed, 12 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 00c2c0a..968 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -446,6 +446,7 @@ struct i40e_aqc_list_capabilities_element_resp {
 #define I40E_AQ_CAP_ID_SDP 0x0062
 #define I40E_AQ_CAP_ID_MDIO0x0063
 #define I40E_AQ_CAP_ID_WSR_PROT0x0064
+#define I40E_AQ_CAP_ID_NVM_MGMT0x0080
 #define I40E_AQ_CAP_ID_FLEX10  0x00F1
 #define I40E_AQ_CAP_ID_CEM 0x00F2

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 80d69dd..98ed4b6 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3762,6 +3762,12 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
   "HW Capability: wr_csr_prot = 0x%llX\n\n",
   (p->wr_csr_prot & 0x));
break;
+   case I40E_AQ_CAP_ID_NVM_MGMT:
+   if (number & I40E_NVM_MGMT_SEC_REV_DISABLED)
+   p->sec_rev_disabled = true;
+   if (number & I40E_NVM_MGMT_UPDATE_DISABLED)
+   p->update_disabled = true;
+   break;
 #ifdef X722_SUPPORT
case I40E_AQ_CAP_ID_WOL_AND_PROXY:
hw->num_wol_proxy_filters = (u16)number;
diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 73a18e1..7ed3048 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -376,6 +376,11 @@ struct i40e_hw_capabilities {
 #define I40E_FLEX10_STATUS_DCC_ERROR   0x1
 #define I40E_FLEX10_STATUS_VC_MODE 0x2

+   bool sec_rev_disabled;
+   bool update_disabled;
+#define I40E_NVM_MGMT_SEC_REV_DISABLED 0x1
+#define I40E_NVM_MGMT_UPDATE_DISABLED  0x2
+
bool mgmt_cem;
bool ieee_1588;
bool iwarp;
-- 
2.5.0



[dpdk-dev] [PATCH v2 10/15] i40e/base: fix debug output

2016-05-24 Thread Helin Zhang
It fixes the debug output messages.

Fixes: f388b435bc33 ("i40e/base: clean adminq debug")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index ebc4ebb..80d69dd 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -375,14 +375,16 @@ void i40e_debug_aq(struct i40e_hw *hw, enum 
i40e_debug_mask mask, void *desc,
/* the most we could have left is 16 bytes, pad with zeros */
if (i < len) {
char d_buf[16];
-   int j;
+   int j, i_sav;

+   i_sav = i;
memset(d_buf, 0, sizeof(d_buf));
for (j = 0; i < len; j++, i++)
d_buf[j] = buf[i];
i40e_debug(hw, mask,
   "\t0x%04X  %02X %02X %02X %02X %02X %02X 
%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
-  i, d_buf[0], d_buf[1], d_buf[2], d_buf[3],
+  i_sav, d_buf[0], d_buf[1],
+  d_buf[2], d_buf[3],
   d_buf[4], d_buf[5], d_buf[6], d_buf[7],
   d_buf[8], d_buf[9], d_buf[10], d_buf[11],
   d_buf[12], d_buf[13], d_buf[14], d_buf[15]);
-- 
2.5.0



[dpdk-dev] [PATCH v2 09/15] i40e/base: fix the number of MSIX vector

2016-05-24 Thread Helin Zhang
It corrects the number of MSIX vector in a debug info.

Fixes: 889bc9f0cd3a ("i40e/base: unify the capability function")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index b911ef2..ebc4ebb 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3670,7 +3670,7 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
p->num_msix_vectors = number;
i40e_debug(hw, I40E_DEBUG_INIT,
   "HW Capability: MSIX vector count = %d\n",
-  p->num_msix_vectors_vf);
+  p->num_msix_vectors);
break;
case I40E_AQ_CAP_ID_VF_MSIX:
p->num_msix_vectors_vf = number;
-- 
2.5.0



[dpdk-dev] [PATCH v2 08/15] i40e/base: add new devices

2016-05-24 Thread Helin Zhang
It adds new device IDs and PHY types.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 4 
 drivers/net/i40e/base/i40e_common.c | 4 
 drivers/net/i40e/base/i40e_devids.h | 4 
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 8 
 4 files changed, 20 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 687eaa5..00c2c0a 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -1678,6 +1678,10 @@ enum i40e_aq_phy_type {
I40E_PHY_TYPE_1000BASE_LX   = 0x1C,
I40E_PHY_TYPE_1000BASE_T_OPTICAL= 0x1D,
I40E_PHY_TYPE_20GBASE_KR2   = 0x1E,
+   I40E_PHY_TYPE_25GBASE_KR= 0x1F,
+   I40E_PHY_TYPE_25GBASE_CR= 0x20,
+   I40E_PHY_TYPE_25GBASE_SR= 0x21,
+   I40E_PHY_TYPE_25GBASE_LR= 0x22,
I40E_PHY_TYPE_MAX
 };

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index ef6b270..b911ef2 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -67,6 +67,8 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw 
*hw)
case I40E_DEV_ID_10G_BASE_T4:
case I40E_DEV_ID_20G_KR2:
case I40E_DEV_ID_20G_KR2_A:
+   case I40E_DEV_ID_25G_B:
+   case I40E_DEV_ID_25G_SFP28:
hw->mac.type = I40E_MAC_XL710;
break;
 #ifdef X722_SUPPORT
@@ -78,6 +80,8 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw 
*hw)
case I40E_DEV_ID_SFP_X722:
case I40E_DEV_ID_1G_BASE_T_X722:
case I40E_DEV_ID_10G_BASE_T_X722:
+   case I40E_DEV_ID_SFP_I_X722:
+   case I40E_DEV_ID_QSFP_I_X722:
hw->mac.type = I40E_MAC_X722;
break;
 #endif
diff --git a/drivers/net/i40e/base/i40e_devids.h 
b/drivers/net/i40e/base/i40e_devids.h
index f844340..ed73e1d 100644
--- a/drivers/net/i40e/base/i40e_devids.h
+++ b/drivers/net/i40e/base/i40e_devids.h
@@ -49,6 +49,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_DEV_ID_20G_KR20x1587
 #define I40E_DEV_ID_20G_KR2_A  0x1588
 #define I40E_DEV_ID_10G_BASE_T40x1589
+#define I40E_DEV_ID_25G_B  0x158A
+#define I40E_DEV_ID_25G_SFP28  0x158B
 #if defined(INTEGRATED_VF) || defined(VF_DRIVER) || defined(I40E_NDIS_SUPPORT)
 #define I40E_DEV_ID_VF 0x154C
 #define I40E_DEV_ID_VF_HV  0x1571
@@ -65,6 +67,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_DEV_ID_SFP_X722   0x37D0
 #define I40E_DEV_ID_1G_BASE_T_X722 0x37D1
 #define I40E_DEV_ID_10G_BASE_T_X7220x37D2
+#define I40E_DEV_ID_SFP_I_X722 0x37D3
+#define I40E_DEV_ID_QSFP_I_X7220x37D4
 #if defined(INTEGRATED_VF) || defined(VF_DRIVER) || defined(I40E_NDIS_SUPPORT)
 #define I40E_DEV_ID_X722_VF0x37CD
 #define I40E_DEV_ID_X722_VF_HV 0x37D9
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..c812b64 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -532,12 +532,16 @@ RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, 
IXGBE_DEV_ID_82599_BYPASS)
 #define I40E_DEV_ID_20G_KR2 0x1587
 #define I40E_DEV_ID_20G_KR2_A   0x1588
 #define I40E_DEV_ID_10G_BASE_T4 0x1589
+#define I40E_DEV_ID_25G_B   0x158A
+#define I40E_DEV_ID_25G_SFP28   0x158B
 #define I40E_DEV_ID_X722_A0 0x374C
 #define I40E_DEV_ID_KX_X722 0x37CE
 #define I40E_DEV_ID_QSFP_X722   0x37CF
 #define I40E_DEV_ID_SFP_X7220x37D0
 #define I40E_DEV_ID_1G_BASE_T_X722  0x37D1
 #define I40E_DEV_ID_10G_BASE_T_X722 0x37D2
+#define I40E_DEV_ID_SFP_I_X722  0x37D3
+#define I40E_DEV_ID_QSFP_I_X722 0x37D4

 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_SFP_XL710)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_QEMU)
@@ -550,12 +554,16 @@ RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, 
I40E_DEV_ID_10G_BASE_T)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_20G_KR2)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_20G_KR2_A)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_10G_BASE_T4)
+RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_25G_B)
+RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_25G_SFP28)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_X722_A0)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_KX_X722)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_QSFP_X722)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID

[dpdk-dev] [PATCH v2 07/15] i40e/base: fix problematic mirror rule ID check

2016-05-24 Thread Helin Zhang
It removes the problematic mirror rule ID check. It
returns an error if the mirror rule ID is 0, which is
a valid value.

Fixes: 0bf2dbbe077c ("i40e/base: support mirroring rules")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index ace5b84..ef6b270 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3042,10 +3042,7 @@ enum i40e_status_code i40e_aq_delete_mirrorrule(struct 
i40e_hw *hw, u16 sw_seid,
u16 *rules_used, u16 *rules_free)
 {
/* Rule ID has to be valid except rule_type: INGRESS VLAN mirroring */
-   if (rule_type != I40E_AQC_MIRROR_RULE_TYPE_VLAN) {
-   if (!rule_id)
-   return I40E_ERR_PARAM;
-   } else {
+   if (rule_type == I40E_AQC_MIRROR_RULE_TYPE_VLAN) {
/* count and mr_list shall be valid for rule_type INGRESS VLAN
 * mirroring. For other rule_type, count and rule_type should
 * not matter.
-- 
2.5.0



[dpdk-dev] [PATCH v2 06/15] i40e/base: expose mirroring config

2016-05-24 Thread Helin Zhang
It exposes the configuration of mirroring or not egress
traffic to VSIs in promiscuous mode, as latest firmware
supports that from API version 1.5.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c| 9 ++---
 drivers/net/i40e/base/i40e_prototype.h | 4 ++--
 drivers/net/i40e/i40e_ethdev.c | 4 ++--
 drivers/net/i40e/i40e_pf.c | 2 +-
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index e958099..ace5b84 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2214,10 +2214,12 @@ enum i40e_status_code i40e_aq_set_default_vsi(struct 
i40e_hw *hw,
  * @seid: vsi number
  * @set: set unicast promiscuous enable/disable
  * @cmd_details: pointer to command details structure or NULL
+ * @rx_only_promisc: flag to decide if egress traffic gets mirrored in promisc
  **/
 enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
u16 seid, bool set,
-   struct i40e_asq_cmd_details *cmd_details)
+   struct i40e_asq_cmd_details *cmd_details,
+   bool rx_only_promisc)
 {
struct i40e_aq_desc desc;
struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
@@ -2230,8 +2232,9 @@ enum i40e_status_code 
i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,

if (set) {
flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
-   if (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
-(hw->aq.api_maj_ver > 1))
+   if (rx_only_promisc &&
+   (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
+(hw->aq.api_maj_ver > 1)))
flags |= I40E_AQC_SET_VSI_PROMISC_TX;
}

diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index 48a08fd..03dda93 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -166,7 +166,8 @@ enum i40e_status_code i40e_aq_set_vsi_broadcast(struct 
i40e_hw *hw,
u16 vsi_id, bool set_filter,
struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
-   u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details);
+   u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details,
+   bool rx_only_promisc);
 enum i40e_status_code i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw,
u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_set_vsi_mc_promisc_on_vlan(struct i40e_hw *hw,
@@ -404,7 +405,6 @@ enum i40e_status_code i40e_aq_remove_cloud_filters(struct 
i40e_hw *hw,
u16 vsi,
struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
u8 filter_count);
-
 enum i40e_status_code i40e_aq_alternate_read(struct i40e_hw *hw,
u32 reg_addr0, u32 *reg_val0,
u32 reg_addr1, u32 *reg_val1);
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..113fca6 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1664,7 +1664,7 @@ i40e_dev_promiscuous_enable(struct rte_eth_dev *dev)
int status;

status = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
-   true, NULL);
+true, NULL, true);
if (status != I40E_SUCCESS)
PMD_DRV_LOG(ERR, "Failed to enable unicast promiscuous");

@@ -1684,7 +1684,7 @@ i40e_dev_promiscuous_disable(struct rte_eth_dev *dev)
int status;

status = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
-   false, NULL);
+false, NULL, true);
if (status != I40E_SUCCESS)
PMD_DRV_LOG(ERR, "Failed to disable unicast promiscuous");

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 5afd61a..b549caa 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -810,7 +810,7 @@ i40e_pf_host_process_cmd_config_promisc_mode(
if (promisc->flags & I40E_FLAG_VF_UNICAST_PROMISC)
unicast = TRUE;
ret = i40e_aq_set_vsi_unicast_promiscuous(hw,
-   vf->vsi->seid, unicast, NULL);
+   vf->vsi->seid, unicast, NULL, true);
if (ret != I40E_SUCCESS)
goto send_msg;

-- 
2.5.0



[dpdk-dev] [PATCH v2 05/15] i40e/base: fixup Geneve VNI for HW use

2016-05-24 Thread Helin Zhang
The hardware doesn't layout the Geneve VNI (Virtual Network
Identifier) quite the same as the VxLAN VNI, so it needs to
adjust it before sending through the AQ commands as the
workaround.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c | 35 ++-
 drivers/net/i40e/base/i40e_osdep.h  |  7 +++
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index f7dff12..e958099 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5422,6 +5422,35 @@ void 
i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
 }

 /**
+ * i40e_fix_up_geneve_vni - adjust Geneve VNI for HW issue
+ * @filters: list of cloud filters
+ * @filter_count: length of list
+ *
+ * There's an issue in the device where the Geneve VNI layout needs
+ * to be shifted 1 byte over from the VxLAN VNI
+ **/
+STATIC void i40e_fix_up_geneve_vni(
+   struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
+   u8 filter_count)
+{
+   struct i40e_aqc_add_remove_cloud_filters_element_data *f = filters;
+   int i;
+
+   for (i = 0; i < filter_count; i++) {
+   u16 tnl_type;
+   u32 ti;
+
+   tnl_type = (le16_to_cpu(f[i].flags) &
+  I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
+  I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
+   if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
+   ti = le32_to_cpu(f[i].tenant_id);
+   f[i].tenant_id = cpu_to_le32(ti << 8);
+   }
+   }
+}
+
+/**
  * i40e_aq_add_cloud_filters
  * @hw: pointer to the hardware structure
  * @seid: VSI seid to add cloud filters from
@@ -5441,8 +5470,8 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct 
i40e_hw *hw,
struct i40e_aq_desc desc;
struct i40e_aqc_add_remove_cloud_filters *cmd =
(struct i40e_aqc_add_remove_cloud_filters *)
-   u16 buff_len;
enum i40e_status_code status;
+   u16 buff_len;

i40e_fill_default_direct_cmd_desc(,
  i40e_aqc_opc_add_cloud_filters);
@@ -5453,6 +5482,8 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct 
i40e_hw *hw,
cmd->num_filters = filter_count;
cmd->seid = CPU_TO_LE16(seid);

+   i40e_fix_up_geneve_vni(filters, filter_count);
+
status = i40e_asq_send_command(hw, , filters, buff_len, NULL);

return status;
@@ -5490,6 +5521,8 @@ enum i40e_status_code i40e_aq_remove_cloud_filters(struct 
i40e_hw *hw,
cmd->num_filters = filter_count;
cmd->seid = CPU_TO_LE16(seid);

+   i40e_fix_up_geneve_vni(filters, filter_count);
+
status = i40e_asq_send_command(hw, , filters, buff_len, NULL);

return status;
diff --git a/drivers/net/i40e/base/i40e_osdep.h 
b/drivers/net/i40e/base/i40e_osdep.h
index 8c84ed8..38e7ba5 100644
--- a/drivers/net/i40e/base/i40e_osdep.h
+++ b/drivers/net/i40e/base/i40e_osdep.h
@@ -204,6 +204,13 @@ struct i40e_virt_mem {
 #define LE32_TO_CPU(c) rte_le_to_cpu_32(c)
 #define LE64_TO_CPU(k) rte_le_to_cpu_64(k)

+#define cpu_to_le16(o) rte_cpu_to_le_16(o)
+#define cpu_to_le32(s) rte_cpu_to_le_32(s)
+#define cpu_to_le64(h) rte_cpu_to_le_64(h)
+#define le16_to_cpu(a) rte_le_to_cpu_16(a)
+#define le32_to_cpu(c) rte_le_to_cpu_32(c)
+#define le64_to_cpu(k) rte_le_to_cpu_64(k)
+
 /* SW spinlock */
 struct i40e_spinlock {
rte_spinlock_t spinlock;
-- 
2.5.0



[dpdk-dev] [PATCH v2 04/15] i40e/base: trim the code

2016-05-24 Thread Helin Zhang
It trim the source code, with limiting pieces of code for
PF or VF driver only, code style fixes, and annotation
rewording.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq.c | 52 +++--
 drivers/net/i40e/base/i40e_adminq.h |  4 +--
 drivers/net/i40e/base/i40e_adminq_cmd.h | 21 +++--
 drivers/net/i40e/base/i40e_common.c |  5 ++--
 drivers/net/i40e/base/i40e_prototype.h  |  3 +-
 5 files changed, 48 insertions(+), 37 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index ba7ef42..0d3a83f 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -572,6 +572,26 @@ shutdown_arq_out:
i40e_release_spinlock(>aq.arq_spinlock);
return ret_code;
 }
+#ifdef PF_DRIVER
+
+/**
+ *  i40e_resume_aq - resume AQ processing from 0
+ *  @hw: pointer to the hardware structure
+ **/
+STATIC void i40e_resume_aq(struct i40e_hw *hw)
+{
+   /* Registers are reset after PF reset */
+   hw->aq.asq.next_to_use = 0;
+   hw->aq.asq.next_to_clean = 0;
+
+   i40e_config_asq_regs(hw);
+
+   hw->aq.arq.next_to_use = 0;
+   hw->aq.arq.next_to_clean = 0;
+
+   i40e_config_arq_regs(hw);
+}
+#endif /* PF_DRIVER */

 /**
  *  i40e_init_adminq - main initialization routine for Admin Queue
@@ -586,12 +606,15 @@ shutdown_arq_out:
  **/
 enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
 {
-   enum i40e_status_code ret_code;
 #ifdef PF_DRIVER
-   u16 eetrack_lo, eetrack_hi;
u16 cfg_ptr, oem_hi, oem_lo;
+   u16 eetrack_lo, eetrack_hi;
+#endif
+   enum i40e_status_code ret_code;
+#ifdef PF_DRIVER
int retry = 0;
 #endif
+
/* verify input for valid configuration */
if ((hw->aq.num_arq_entries == 0) ||
(hw->aq.num_asq_entries == 0) ||
@@ -600,8 +623,6 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
ret_code = I40E_ERR_CONFIG;
goto init_adminq_exit;
}
-
-   /* initialize spin locks */
i40e_init_spinlock(>aq.asq_spinlock);
i40e_init_spinlock(>aq.arq_spinlock);

@@ -704,8 +725,6 @@ enum i40e_status_code i40e_shutdown_adminq(struct i40e_hw 
*hw)

i40e_shutdown_asq(hw);
i40e_shutdown_arq(hw);
-
-   /* destroy the spinlocks */
i40e_destroy_spinlock(>aq.asq_spinlock);
i40e_destroy_spinlock(>aq.arq_spinlock);

@@ -731,7 +750,6 @@ u16 i40e_clean_asq(struct i40e_hw *hw)

desc = I40E_ADMINQ_DESC(*asq, ntc);
details = I40E_ADMINQ_DETAILS(*asq, ntc);
-
while (rd32(hw, hw->aq.asq.head) != ntc) {
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
   "ntc %d head %d.\n", ntc, rd32(hw, hw->aq.asq.head));
@@ -764,7 +782,11 @@ u16 i40e_clean_asq(struct i40e_hw *hw)
  *  Returns true if the firmware has processed all descriptors on the
  *  admin send queue. Returns false if there are still requests pending.
  **/
+#ifdef VF_DRIVER
 bool i40e_asq_done(struct i40e_hw *hw)
+#else
+STATIC bool i40e_asq_done(struct i40e_hw *hw)
+#endif
 {
/* AQ designers suggest use of head for better
 * timing reliability than DD bit
@@ -922,7 +944,6 @@ enum i40e_status_code i40e_asq_send_command(struct i40e_hw 
*hw,
 */
if (i40e_asq_done(hw))
break;
-   /* ugh! delay while spin_lock */
i40e_msec_delay(1);
total_delay++;
} while (total_delay < hw->aq.asq_cmd_timeout);
@@ -1105,7 +1126,7 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,

 #ifdef PF_DRIVER
i40e_nvmupd_check_wait_event(hw, LE16_TO_CPU(e->desc.opcode));
-#endif
+#endif /* PF_DRIVER */
 clean_arq_element_out:
/* Set pending if needed, unlock and return */
if (pending != NULL)
@@ -1116,16 +1137,3 @@ clean_arq_element_err:
return ret_code;
 }

-void i40e_resume_aq(struct i40e_hw *hw)
-{
-   /* Registers are reset after PF reset */
-   hw->aq.asq.next_to_use = 0;
-   hw->aq.asq.next_to_clean = 0;
-
-   i40e_config_asq_regs(hw);
-
-   hw->aq.arq.next_to_use = 0;
-   hw->aq.arq.next_to_clean = 0;
-
-   i40e_config_arq_regs(hw);
-}
diff --git a/drivers/net/i40e/base/i40e_adminq.h 
b/drivers/net/i40e/base/i40e_adminq.h
index 29c04a3..750973c 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -157,8 +157,8 @@ STATIC INLINE int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
 }

 /* general information */
-#define I40E_AQ_LARGE_BUF  512
-#define I40E_ASQ_CMD_TIMEOUT   250  /* msecs */
+#define I40E_AQ_LARGE_BUF  512
+#define I40E_ASQ_CMD_TIMEOUT   250  /* msecs */
 #ifdef I40E_ESS_SUPPORT
 #define I40E_ASQ_CMD_TIMEOUT_E

[dpdk-dev] [PATCH v2 03/15] i40e/base: refactor NVM update command processing

2016-05-24 Thread Helin Zhang
It refactors the NVM update command processing, with adding
a new element of nvm_wait_opcode in struct i40e_hw to indicate
the opcode it waits on, and putting the wait event check into
a function. In addition, that element needs to be initialized
or updated properly.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq.c| 33 +--
 drivers/net/i40e/base/i40e_nvm.c   | 76 +++---
 drivers/net/i40e/base/i40e_prototype.h |  1 +
 drivers/net/i40e/base/i40e_type.h  |  1 +
 4 files changed, 74 insertions(+), 37 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 15d5f5a..ba7ef42 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -37,18 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "i40e_adminq.h"
 #include "i40e_prototype.h"

-#ifdef PF_DRIVER
-/**
- * i40e_is_nvm_update_op - return true if this is an NVM update operation
- * @desc: API request descriptor
- **/
-STATIC INLINE bool i40e_is_nvm_update_op(struct i40e_aq_desc *desc)
-{
-   return (desc->opcode == CPU_TO_LE16(i40e_aqc_opc_nvm_erase) ||
-   desc->opcode == CPU_TO_LE16(i40e_aqc_opc_nvm_update));
-}
-
-#endif /* PF_DRIVER */
 /**
  *  i40e_adminq_init_regs - Initialize AdminQ registers
  *  @hw: pointer to the hardware structure
@@ -1116,26 +1104,7 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,
hw->aq.arq.next_to_use = ntu;

 #ifdef PF_DRIVER
-   if (i40e_is_nvm_update_op(>desc)) {
-   if (hw->nvm_release_on_done) {
-   i40e_release_nvm(hw);
-   hw->nvm_release_on_done = false;
-   }
-
-   switch (hw->nvmupd_state) {
-   case I40E_NVMUPD_STATE_INIT_WAIT:
-   hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
-   break;
-
-   case I40E_NVMUPD_STATE_WRITE_WAIT:
-   hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING;
-   break;
-
-   default:
-   break;
-   }
-   }
-
+   i40e_nvmupd_check_wait_event(hw, LE16_TO_CPU(e->desc.opcode));
 #endif
 clean_arq_element_out:
/* Set pending if needed, unlock and return */
diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index 04e422f..4fa1220 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -872,10 +872,10 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,
/* early check for status command and debug msgs */
upd_cmd = i40e_nvmupd_validate_command(hw, cmd, perrno);

-   i40e_debug(hw, I40E_DEBUG_NVM, "%s state %d nvm_release_on_hold %d cmd 
0x%08x config 0x%08x offset 0x%08x data_size 0x%08x\n",
+   i40e_debug(hw, I40E_DEBUG_NVM, "%s state %d nvm_release_on_hold %d opc 
0x%04x cmd 0x%08x config 0x%08x offset 0x%08x data_size 0x%08x\n",
   i40e_nvm_update_state_str[upd_cmd],
   hw->nvmupd_state,
-  hw->nvm_release_on_done,
+  hw->nvm_release_on_done, hw->nvm_wait_opcode,
   cmd->command, cmd->config, cmd->offset, cmd->data_size);

if (upd_cmd == I40E_NVMUPD_INVALID) {
@@ -889,7 +889,18 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,
 * going into the state machine
 */
if (upd_cmd == I40E_NVMUPD_STATUS) {
+   if (!cmd->data_size) {
+   *perrno = -EFAULT;
+   return I40E_ERR_BUF_TOO_SHORT;
+   }
+
bytes[0] = hw->nvmupd_state;
+
+   if (cmd->data_size >= 4) {
+   bytes[1] = 0;
+   *((u16 *)[2]) = hw->nvm_wait_opcode;
+   }
+
return I40E_SUCCESS;
}

@@ -908,6 +919,14 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,

case I40E_NVMUPD_STATE_INIT_WAIT:
case I40E_NVMUPD_STATE_WRITE_WAIT:
+   /* if we need to stop waiting for an event, clear
+* the wait info and return before doing anything else
+*/
+   if (cmd->offset == 0x) {
+   i40e_nvmupd_check_wait_event(hw, hw->nvm_wait_opcode);
+   return I40E_SUCCESS;
+   }
+
status = I40E_ERR_NOT_READY;
*perrno = -EBUSY;
break;
@@ -981,6 +1000,7 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct 
i40e_hw *hw,
i40e_release_nvm(hw);
} else {
hw->nvm_release_on_done = true;
+   hw->

[dpdk-dev] [PATCH v2 02/15] i40e/base: move field of NVM update status info

2016-05-24 Thread Helin Zhang
It centralizes all NVM update status info into a single
structure, by moving nvm_release_on_done from struct
i40e_adminq_info to struct i40e_hw, for better management.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq.c |  6 +++---
 drivers/net/i40e/base/i40e_adminq.h |  1 -
 drivers/net/i40e/base/i40e_nvm.c| 12 ++--
 drivers/net/i40e/base/i40e_type.h   |  1 +
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 0e4198e..15d5f5a 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -680,7 +680,7 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)

/* pre-emptive resource lock release */
i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
-   hw->aq.nvm_release_on_done = false;
+   hw->nvm_release_on_done = false;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;

 #endif /* PF_DRIVER */
@@ -1117,9 +1117,9 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,

 #ifdef PF_DRIVER
if (i40e_is_nvm_update_op(>desc)) {
-   if (hw->aq.nvm_release_on_done) {
+   if (hw->nvm_release_on_done) {
i40e_release_nvm(hw);
-   hw->aq.nvm_release_on_done = false;
+   hw->nvm_release_on_done = false;
}

switch (hw->nvmupd_state) {
diff --git a/drivers/net/i40e/base/i40e_adminq.h 
b/drivers/net/i40e/base/i40e_adminq.h
index 40c86d9..29c04a3 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -104,7 +104,6 @@ struct i40e_adminq_info {
u32 fw_build;   /* firmware build number */
u16 api_maj_ver;/* api major version */
u16 api_min_ver;/* api minor version */
-   bool nvm_release_on_done;

struct i40e_spinlock asq_spinlock; /* Send queue spinlock */
struct i40e_spinlock arq_spinlock; /* Receive queue spinlock */
diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index f4e4eaa..04e422f 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -875,7 +875,7 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,
i40e_debug(hw, I40E_DEBUG_NVM, "%s state %d nvm_release_on_hold %d cmd 
0x%08x config 0x%08x offset 0x%08x data_size 0x%08x\n",
   i40e_nvm_update_state_str[upd_cmd],
   hw->nvmupd_state,
-  hw->aq.nvm_release_on_done,
+  hw->nvm_release_on_done,
   cmd->command, cmd->config, cmd->offset, cmd->data_size);

if (upd_cmd == I40E_NVMUPD_INVALID) {
@@ -980,7 +980,7 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct 
i40e_hw *hw,
if (status) {
i40e_release_nvm(hw);
} else {
-   hw->aq.nvm_release_on_done = true;
+   hw->nvm_release_on_done = true;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
}
@@ -996,7 +996,7 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct 
i40e_hw *hw,
if (status) {
i40e_release_nvm(hw);
} else {
-   hw->aq.nvm_release_on_done = true;
+   hw->nvm_release_on_done = true;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
}
@@ -1030,7 +1030,7 @@ STATIC enum i40e_status_code 
i40e_nvmupd_state_init(struct i40e_hw *hw,
   -EIO;
i40e_release_nvm(hw);
} else {
-   hw->aq.nvm_release_on_done = true;
+   hw->nvm_release_on_done = true;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
}
@@ -1138,7 +1138,7 @@ retry:
   -EIO;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
} else {
-   hw->aq.nvm_release_on_done = true;
+   hw->nvm_release_on_done = true;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
break;
@@ -1167,7 +1167,7 @@ retry:
   -EIO;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
} else {
-   hw->aq.nvm_release_on_done = true;
+  

[dpdk-dev] [PATCH v2 01/15] i40e/base: remove HMC AQ APIs

2016-05-24 Thread Helin Zhang
HMC AQ APIs were removed from the latest datasheet, and
hence remove its implementations and relevant.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq.c |  4 ---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 25 --
 drivers/net/i40e/base/i40e_common.c | 61 -
 drivers/net/i40e/base/i40e_prototype.h  |  8 -
 4 files changed, 98 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 222add4..0e4198e 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -683,10 +683,6 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
hw->aq.nvm_release_on_done = false;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;

-   ret_code = i40e_aq_set_hmc_resource_profile(hw,
-   I40E_HMC_PROFILE_DEFAULT,
-   0,
-   NULL);
 #endif /* PF_DRIVER */
ret_code = I40E_SUCCESS;

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index fe9d5b5..58ba609 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -224,10 +224,6 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_resume_port_tx = 0x041C,
i40e_aqc_opc_configure_partition_bw = 0x041D,

-   /* hmc */
-   i40e_aqc_opc_query_hmc_resource_profile = 0x0500,
-   i40e_aqc_opc_set_hmc_resource_profile   = 0x0501,
-
/* phy commands*/
i40e_aqc_opc_get_phy_abilities  = 0x0600,
i40e_aqc_opc_set_phy_config = 0x0601,
@@ -1646,27 +1642,6 @@ struct i40e_aqc_configure_partition_bw_data {

 I40E_CHECK_STRUCT_LEN(0x22, i40e_aqc_configure_partition_bw_data);

-/* Get and set the active HMC resource profile and status.
- * (direct 0x0500) and (direct 0x0501)
- */
-struct i40e_aq_get_set_hmc_resource_profile {
-   u8  pm_profile;
-   u8  pe_vf_enabled;
-   u8  reserved[14];
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aq_get_set_hmc_resource_profile);
-
-enum i40e_aq_hmc_profile {
-   /* I40E_HMC_PROFILE_NO_CHANGE= 0, reserved */
-   I40E_HMC_PROFILE_DEFAULT= 1,
-   I40E_HMC_PROFILE_FAVOR_VF   = 2,
-   I40E_HMC_PROFILE_EQUAL  = 3,
-};
-
-#define I40E_AQ_GET_HMC_RESOURCE_PROFILE_PM_MASK   0xF
-#define I40E_AQ_GET_HMC_RESOURCE_PROFILE_COUNT_MASK0x3F
-
 /* Get PHY Abilities (indirect 0x0600) uses the generic indirect struct */

 /* set in param0 for get phy abilities to report qualified modules */
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index ef3425e..7a5f754 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3240,67 +3240,6 @@ enum i40e_status_code 
i40e_aq_debug_write_register(struct i40e_hw *hw,
 }

 /**
- * i40e_aq_get_hmc_resource_profile
- * @hw: pointer to the hw struct
- * @profile: type of profile the HMC is to be set as
- * @pe_vf_enabled_count: the number of PE enabled VFs the system has
- * @cmd_details: pointer to command details structure or NULL
- *
- * query the HMC profile of the device.
- **/
-enum i40e_status_code i40e_aq_get_hmc_resource_profile(struct i40e_hw *hw,
-   enum i40e_aq_hmc_profile *profile,
-   u8 *pe_vf_enabled_count,
-   struct i40e_asq_cmd_details *cmd_details)
-{
-   struct i40e_aq_desc desc;
-   struct i40e_aq_get_set_hmc_resource_profile *resp =
-   (struct i40e_aq_get_set_hmc_resource_profile *)
-   enum i40e_status_code status;
-
-   i40e_fill_default_direct_cmd_desc(,
-   i40e_aqc_opc_query_hmc_resource_profile);
-   status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
-
-   *profile = (enum i40e_aq_hmc_profile)(resp->pm_profile &
-  I40E_AQ_GET_HMC_RESOURCE_PROFILE_PM_MASK);
-   *pe_vf_enabled_count = resp->pe_vf_enabled &
-  I40E_AQ_GET_HMC_RESOURCE_PROFILE_COUNT_MASK;
-
-   return status;
-}
-
-/**
- * i40e_aq_set_hmc_resource_profile
- * @hw: pointer to the hw struct
- * @profile: type of profile the HMC is to be set as
- * @pe_vf_enabled_count: the number of PE enabled VFs the system has
- * @cmd_details: pointer to command details structure or NULL
- *
- * set the HMC profile of the device.
- **/
-enum i40e_status_code i40e_aq_set_hmc_resource_profile(struct i40e_hw *hw,
-   enum i40e_aq_hmc_profile profile,
-   u8 pe_vf_enabled_count,
-   struct i40e_asq_cmd_details *cmd_details)
-{
-   struct i40e_aq_desc desc;
-   struct i40e_aq_get_set_hmc_r

[dpdk-dev] [PATCH v2 00/15] i40e base driver update

2016-05-24 Thread Helin Zhang
This is the i40e base driver update, which includes bug fixes,
enhancements, refactoring, and new device enabling. Below are
the details.

v2:
 - reworded commit titles and logs.

Helin Zhang (15):
  i40e/base: remove HMC AQ APIs
  i40e/base: move field of NVM update status info
  i40e/base: refactor NVM update command processing
  i40e/base: trim the code
  i40e/base: fixup Geneve VNI for HW use
  i40e/base: expose mirroring config
  i40e/base: fix problematic mirror rule ID check
  i40e/base: add new devices
  i40e/base: fix the number of MSIX vector
  i40e/base: fix debug output
  i40e/base: add more device capabilities
  i40e/base: increase supported AQ API version
  i40e/base: add input set mask definitions
  i40e/base: add RSS config to virtual channel
  i40e/base: add capability of disabling all link

 doc/guides/rel_notes/release_16_07.rst  |   4 +
 drivers/net/i40e/Makefile   |   2 +-
 drivers/net/i40e/base/i40e_adminq.c |  91 ++--
 drivers/net/i40e/base/i40e_adminq.h |   5 +-
 drivers/net/i40e/base/i40e_adminq_cmd.h |  54 --
 drivers/net/i40e/base/i40e_common.c | 133 +++-
 drivers/net/i40e/base/i40e_devids.h |   4 +
 drivers/net/i40e/base/i40e_nvm.c|  86 +--
 drivers/net/i40e/base/i40e_osdep.h  |   7 ++
 drivers/net/i40e/base/i40e_prototype.h  |  16 +--
 drivers/net/i40e/base/i40e_type.h   |  42 +++-
 drivers/net/i40e/base/i40e_virtchnl.h   |  45 +++-
 drivers/net/i40e/i40e_ethdev.c  |   4 +-
 drivers/net/i40e/i40e_pf.c  |   2 +-
 lib/librte_eal/common/include/rte_pci_dev_ids.h |   8 ++
 15 files changed, 303 insertions(+), 200 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH 15/15] i40e/base: add capability of disabling all link

2016-05-05 Thread Helin Zhang
It adds a flag, which can be used to tell the firmware to
disable the link on all ports.

Signed-off-by: Helin Zhang 
---
 doc/guides/rel_notes/release_16_07.rst  | 7 +++
 drivers/net/i40e/Makefile   | 2 +-
 drivers/net/i40e/base/i40e_adminq_cmd.h | 3 +++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 001888f..235f3cb 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -34,6 +34,13 @@ This section should contain new features added in this 
release. Sample format:

   Refer to the previous release notes for examples.

+* **Updated the i40e base driver.**
+
+  The i40e base driver was updated with changes which includes the
+  following:
+
+  * Add new X722 and XXV710 device IDs
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 6dd6eaa..dd941f4 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -85,7 +85,7 @@ VPATH += $(SRCDIR)/base

 #
 # all source are stored in SRCS-y
-# base driver is based on the package of dpdk-i40e.2016.01.07.14.tar.gz.
+# base driver is based on the package of dpdk-i40e.2016.04.18.12.tar.gz.
 #
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_adminq.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_common.c
diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 968..2b7a760 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -1899,7 +1899,10 @@ struct i40e_aqc_set_phy_debug {
 #define I40E_AQ_PHY_DEBUG_RESET_EXTERNAL_NONE  0x00
 #define I40E_AQ_PHY_DEBUG_RESET_EXTERNAL_HARD  0x01
 #define I40E_AQ_PHY_DEBUG_RESET_EXTERNAL_SOFT  0x02
+/* Disable link manageability on a single port */
 #define I40E_AQ_PHY_DEBUG_DISABLE_LINK_FW  0x10
+/* Disable link manageability on all ports needs both bits 4 and 5 */
+#define I40E_AQ_PHY_DEBUG_DISABLE_ALL_LINK_FW  0x20
u8  reserved[15];
 };

-- 
2.5.0



[dpdk-dev] [PATCH 14/15] i40e/base: add RSS config to virtual channel

2016-05-05 Thread Helin Zhang
It add opcodes and structures to support RSS configuration
by PF driver on behalf of the VF drivers.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_virtchnl.h | 45 ---
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_virtchnl.h 
b/drivers/net/i40e/base/i40e_virtchnl.h
index 26208f3..fd51ec3 100644
--- a/drivers/net/i40e/base/i40e_virtchnl.h
+++ b/drivers/net/i40e/base/i40e_virtchnl.h
@@ -87,10 +87,15 @@ enum i40e_virtchnl_ops {
I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE = 14,
I40E_VIRTCHNL_OP_GET_STATS = 15,
I40E_VIRTCHNL_OP_FCOE = 16,
-   I40E_VIRTCHNL_OP_EVENT = 17,
+   I40E_VIRTCHNL_OP_EVENT = 17, /* must ALWAYS be 17 */
 #ifdef I40E_SOL_VF_SUPPORT
I40E_VIRTCHNL_OP_GET_ADDNL_SOL_CONFIG = 19,
 #endif
+   I40E_VIRTCHNL_OP_CONFIG_RSS_KEY = 23,
+   I40E_VIRTCHNL_OP_CONFIG_RSS_LUT = 24,
+   I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS = 25,
+   I40E_VIRTCHNL_OP_SET_RSS_HENA = 26,
+
 };

 /* Virtual channel message descriptor. This overlays the admin queue
@@ -164,6 +169,7 @@ struct i40e_virtchnl_vsi_resource {
 #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN  0x0001
 #define I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING0x0002
 #define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x0004
+#define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF0X0008

 struct i40e_virtchnl_vf_resource {
u16 num_vsis;
@@ -172,8 +178,8 @@ struct i40e_virtchnl_vf_resource {
u16 max_mtu;

u32 vf_offload_flags;
-   u32 max_fcoe_contexts;
-   u32 max_fcoe_filters;
+   u32 rss_key_size;
+   u32 rss_lut_size;

struct i40e_virtchnl_vsi_resource vsi_res[1];
 };
@@ -349,6 +355,39 @@ struct i40e_virtchnl_promisc_info {
  * PF replies with struct i40e_eth_stats in an external buffer.
  */

+/* I40E_VIRTCHNL_OP_CONFIG_RSS_KEY
+ * I40E_VIRTCHNL_OP_CONFIG_RSS_LUT
+ * VF sends these messages to configure RSS. Only supported if both PF
+ * and VF drivers set the I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF bit during
+ * configuration negotiation. If this is the case, then the rss fields in
+ * the vf resource struct are valid.
+ * Both the key and LUT are initialized to 0 by the PF, meaning that
+ * RSS is effectively disabled until set up by the VF.
+ */
+struct i40e_virtchnl_rss_key {
+   u16 vsi_id;
+   u16 key_len;
+   u8 key[1]; /* RSS hash key, packed bytes */
+};
+
+struct i40e_virtchnl_rss_lut {
+   u16 vsi_id;
+   u16 lut_entries;
+   u8 lut[1];/* RSS lookup table*/
+};
+
+/* I40E_VIRTCHNL_OP_GET_RSS_HENA_CAPS
+ * I40E_VIRTCHNL_OP_SET_RSS_HENA
+ * VF sends these messages to get and set the hash filter enable bits for RSS.
+ * By default, the PF sets these to all possible traffic types that the
+ * hardware supports. The VF can query this value if it wants to change the
+ * traffic types that are hashed by the hardware.
+ * Traffic types are defined in the i40e_filter_pctype enum in i40e_type.h
+ */
+struct i40e_virtchnl_rss_hena {
+   u64 hena;
+};
+
 /* I40E_VIRTCHNL_OP_EVENT
  * PF sends this message to inform the VF driver of events that may affect it.
  * No direct response is expected from the VF, though it may generate other
-- 
2.5.0



[dpdk-dev] [PATCH 13/15] i40e/base: add input set mask definitions

2016-05-05 Thread Helin Zhang
It adds input set mask definitions for RSS, flow director
and flex bytes.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_type.h | 33 +
 1 file changed, 33 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index bc68b47..5349419 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -1638,4 +1638,37 @@ struct i40e_lldp_variables {

 /* RSS Hash Table Size */
 #define I40E_PFQF_CTL_0_HASHLUTSIZE_5120x0001
+
+/* INPUT SET MASK for RSS, flow director, and flexible payload */
+#define I40E_L3_SRC_SHIFT  47
+#define I40E_L3_SRC_MASK   (0x3ULL << I40E_L3_SRC_SHIFT)
+#define I40E_L3_V6_SRC_SHIFT   43
+#define I40E_L3_V6_SRC_MASK(0xFFULL << I40E_L3_V6_SRC_SHIFT)
+#define I40E_L3_DST_SHIFT  35
+#define I40E_L3_DST_MASK   (0x3ULL << I40E_L3_DST_SHIFT)
+#define I40E_L3_V6_DST_SHIFT   35
+#define I40E_L3_V6_DST_MASK(0xFFULL << I40E_L3_V6_DST_SHIFT)
+#define I40E_L4_SRC_SHIFT  34
+#define I40E_L4_SRC_MASK   (0x1ULL << I40E_L4_SRC_SHIFT)
+#define I40E_L4_DST_SHIFT  33
+#define I40E_L4_DST_MASK   (0x1ULL << I40E_L4_DST_SHIFT)
+#define I40E_VERIFY_TAG_SHIFT  31
+#define I40E_VERIFY_TAG_MASK   (0x3ULL << I40E_VERIFY_TAG_SHIFT)
+
+#define I40E_FLEX_50_SHIFT 13
+#define I40E_FLEX_50_MASK  (0x1ULL << I40E_FLEX_50_SHIFT)
+#define I40E_FLEX_51_SHIFT 12
+#define I40E_FLEX_51_MASK  (0x1ULL << I40E_FLEX_51_SHIFT)
+#define I40E_FLEX_52_SHIFT 11
+#define I40E_FLEX_52_MASK  (0x1ULL << I40E_FLEX_52_SHIFT)
+#define I40E_FLEX_53_SHIFT 10
+#define I40E_FLEX_53_MASK  (0x1ULL << I40E_FLEX_53_SHIFT)
+#define I40E_FLEX_54_SHIFT 9
+#define I40E_FLEX_54_MASK  (0x1ULL << I40E_FLEX_54_SHIFT)
+#define I40E_FLEX_55_SHIFT 8
+#define I40E_FLEX_55_MASK  (0x1ULL << I40E_FLEX_55_SHIFT)
+#define I40E_FLEX_56_SHIFT 7
+#define I40E_FLEX_56_MASK  (0x1ULL << I40E_FLEX_56_SHIFT)
+#define I40E_FLEX_57_SHIFT 6
+#define I40E_FLEX_57_MASK  (0x1ULL << I40E_FLEX_57_SHIFT)
 #endif /* _I40E_TYPE_H_ */
-- 
2.5.0



[dpdk-dev] [PATCH 12/15] i40e/base: increase supported AQ API version

2016-05-05 Thread Helin Zhang
It increases the supported AQ API version to 1.5
for X722.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_type.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 7ed3048..bc68b47 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -188,7 +188,7 @@ enum i40e_memcpy_type {
 };

 #ifdef X722_SUPPORT
-#define I40E_FW_API_VERSION_MINOR_X722 0x0004
+#define I40E_FW_API_VERSION_MINOR_X722 0x0005
 #endif
 #define I40E_FW_API_VERSION_MINOR_X710 0x0005

-- 
2.5.0



[dpdk-dev] [PATCH 11/15] i40e/base: add more device capabilities

2016-05-05 Thread Helin Zhang
It adds more device capabilities for NVM management.
- if update is available
- if security check is needed

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 1 +
 drivers/net/i40e/base/i40e_common.c | 6 ++
 drivers/net/i40e/base/i40e_type.h   | 5 +
 3 files changed, 12 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 00c2c0a..968 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -446,6 +446,7 @@ struct i40e_aqc_list_capabilities_element_resp {
 #define I40E_AQ_CAP_ID_SDP 0x0062
 #define I40E_AQ_CAP_ID_MDIO0x0063
 #define I40E_AQ_CAP_ID_WSR_PROT0x0064
+#define I40E_AQ_CAP_ID_NVM_MGMT0x0080
 #define I40E_AQ_CAP_ID_FLEX10  0x00F1
 #define I40E_AQ_CAP_ID_CEM 0x00F2

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 9c0a018..09bf6d5 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3761,6 +3761,12 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
   "HW Capability: wr_csr_prot = 0x%llX\n\n",
   (p->wr_csr_prot & 0x));
break;
+   case I40E_AQ_CAP_ID_NVM_MGMT:
+   if (number & I40E_NVM_MGMT_SEC_REV_DISABLED)
+   p->sec_rev_disabled = true;
+   if (number & I40E_NVM_MGMT_UPDATE_DISABLED)
+   p->update_disabled = true;
+   break;
 #ifdef X722_SUPPORT
case I40E_AQ_CAP_ID_WOL_AND_PROXY:
hw->num_wol_proxy_filters = (u16)number;
diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 73a18e1..7ed3048 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -376,6 +376,11 @@ struct i40e_hw_capabilities {
 #define I40E_FLEX10_STATUS_DCC_ERROR   0x1
 #define I40E_FLEX10_STATUS_VC_MODE 0x2

+   bool sec_rev_disabled;
+   bool update_disabled;
+#define I40E_NVM_MGMT_SEC_REV_DISABLED 0x1
+#define I40E_NVM_MGMT_UPDATE_DISABLED  0x2
+
bool mgmt_cem;
bool ieee_1588;
bool iwarp;
-- 
2.5.0



[dpdk-dev] [PATCH 10/15] i40e/base: fix debug output

2016-05-05 Thread Helin Zhang
It fixes the debug output messages.

Fixes: f388b435bc33 ("i40e/base: clean adminq debug")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index ebc4ebb..9c0a018 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -375,14 +375,15 @@ void i40e_debug_aq(struct i40e_hw *hw, enum 
i40e_debug_mask mask, void *desc,
/* the most we could have left is 16 bytes, pad with zeros */
if (i < len) {
char d_buf[16];
-   int j;
+   int j, i_sav;

+   i_sav = i;
memset(d_buf, 0, sizeof(d_buf));
for (j = 0; i < len; j++, i++)
d_buf[j] = buf[i];
i40e_debug(hw, mask,
   "\t0x%04X  %02X %02X %02X %02X %02X %02X 
%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
-  i, d_buf[0], d_buf[1], d_buf[2], d_buf[3],
+  i_sav, d_buf[0], d_buf[1], d_buf[2], 
d_buf[3],
   d_buf[4], d_buf[5], d_buf[6], d_buf[7],
   d_buf[8], d_buf[9], d_buf[10], d_buf[11],
   d_buf[12], d_buf[13], d_buf[14], d_buf[15]);
-- 
2.5.0



[dpdk-dev] [PATCH 09/15] i40e/base: fix the number of MSIX vector

2016-05-05 Thread Helin Zhang
It corrects the number of MSIX vector in a debug info.

Fixes: 889bc9f0cd3a ("i40e/base: unify the capability function")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index b911ef2..ebc4ebb 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3670,7 +3670,7 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
p->num_msix_vectors = number;
i40e_debug(hw, I40E_DEBUG_INIT,
   "HW Capability: MSIX vector count = %d\n",
-  p->num_msix_vectors_vf);
+  p->num_msix_vectors);
break;
case I40E_AQ_CAP_ID_VF_MSIX:
p->num_msix_vectors_vf = number;
-- 
2.5.0



[dpdk-dev] [PATCH 08/15] i40e/base: add new devices

2016-05-05 Thread Helin Zhang
It adds new device IDs of both X722 and XXV710, and
new PHY types.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 4 
 drivers/net/i40e/base/i40e_common.c | 4 
 drivers/net/i40e/base/i40e_devids.h | 4 
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 8 
 4 files changed, 20 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 687eaa5..00c2c0a 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -1678,6 +1678,10 @@ enum i40e_aq_phy_type {
I40E_PHY_TYPE_1000BASE_LX   = 0x1C,
I40E_PHY_TYPE_1000BASE_T_OPTICAL= 0x1D,
I40E_PHY_TYPE_20GBASE_KR2   = 0x1E,
+   I40E_PHY_TYPE_25GBASE_KR= 0x1F,
+   I40E_PHY_TYPE_25GBASE_CR= 0x20,
+   I40E_PHY_TYPE_25GBASE_SR= 0x21,
+   I40E_PHY_TYPE_25GBASE_LR= 0x22,
I40E_PHY_TYPE_MAX
 };

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index ef6b270..b911ef2 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -67,6 +67,8 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw 
*hw)
case I40E_DEV_ID_10G_BASE_T4:
case I40E_DEV_ID_20G_KR2:
case I40E_DEV_ID_20G_KR2_A:
+   case I40E_DEV_ID_25G_B:
+   case I40E_DEV_ID_25G_SFP28:
hw->mac.type = I40E_MAC_XL710;
break;
 #ifdef X722_SUPPORT
@@ -78,6 +80,8 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw 
*hw)
case I40E_DEV_ID_SFP_X722:
case I40E_DEV_ID_1G_BASE_T_X722:
case I40E_DEV_ID_10G_BASE_T_X722:
+   case I40E_DEV_ID_SFP_I_X722:
+   case I40E_DEV_ID_QSFP_I_X722:
hw->mac.type = I40E_MAC_X722;
break;
 #endif
diff --git a/drivers/net/i40e/base/i40e_devids.h 
b/drivers/net/i40e/base/i40e_devids.h
index f844340..ed73e1d 100644
--- a/drivers/net/i40e/base/i40e_devids.h
+++ b/drivers/net/i40e/base/i40e_devids.h
@@ -49,6 +49,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_DEV_ID_20G_KR20x1587
 #define I40E_DEV_ID_20G_KR2_A  0x1588
 #define I40E_DEV_ID_10G_BASE_T40x1589
+#define I40E_DEV_ID_25G_B  0x158A
+#define I40E_DEV_ID_25G_SFP28  0x158B
 #if defined(INTEGRATED_VF) || defined(VF_DRIVER) || defined(I40E_NDIS_SUPPORT)
 #define I40E_DEV_ID_VF 0x154C
 #define I40E_DEV_ID_VF_HV  0x1571
@@ -65,6 +67,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_DEV_ID_SFP_X722   0x37D0
 #define I40E_DEV_ID_1G_BASE_T_X722 0x37D1
 #define I40E_DEV_ID_10G_BASE_T_X7220x37D2
+#define I40E_DEV_ID_SFP_I_X722 0x37D3
+#define I40E_DEV_ID_QSFP_I_X7220x37D4
 #if defined(INTEGRATED_VF) || defined(VF_DRIVER) || defined(I40E_NDIS_SUPPORT)
 #define I40E_DEV_ID_X722_VF0x37CD
 #define I40E_DEV_ID_X722_VF_HV 0x37D9
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..c812b64 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -532,12 +532,16 @@ RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, 
IXGBE_DEV_ID_82599_BYPASS)
 #define I40E_DEV_ID_20G_KR2 0x1587
 #define I40E_DEV_ID_20G_KR2_A   0x1588
 #define I40E_DEV_ID_10G_BASE_T4 0x1589
+#define I40E_DEV_ID_25G_B   0x158A
+#define I40E_DEV_ID_25G_SFP28   0x158B
 #define I40E_DEV_ID_X722_A0 0x374C
 #define I40E_DEV_ID_KX_X722 0x37CE
 #define I40E_DEV_ID_QSFP_X722   0x37CF
 #define I40E_DEV_ID_SFP_X7220x37D0
 #define I40E_DEV_ID_1G_BASE_T_X722  0x37D1
 #define I40E_DEV_ID_10G_BASE_T_X722 0x37D2
+#define I40E_DEV_ID_SFP_I_X722  0x37D3
+#define I40E_DEV_ID_QSFP_I_X722 0x37D4

 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_SFP_XL710)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_QEMU)
@@ -550,12 +554,16 @@ RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, 
I40E_DEV_ID_10G_BASE_T)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_20G_KR2)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_20G_KR2_A)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_10G_BASE_T4)
+RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_25G_B)
+RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_25G_SFP28)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_X722_A0)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_KX_X722)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_QSFP_X722)
 RTE_PCI_DEV_ID_DEC

[dpdk-dev] [PATCH 07/15] i40e/base: fix problematic mirror rule ID check

2016-05-05 Thread Helin Zhang
It removes the problematic mirror rule ID check. It
returns an error if the mirror rule ID is 0, which is
a valid value.

Fixes: 0bf2dbbe077c ("i40e/base: support mirroring rules")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index ace5b84..ef6b270 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3042,10 +3042,7 @@ enum i40e_status_code i40e_aq_delete_mirrorrule(struct 
i40e_hw *hw, u16 sw_seid,
u16 *rules_used, u16 *rules_free)
 {
/* Rule ID has to be valid except rule_type: INGRESS VLAN mirroring */
-   if (rule_type != I40E_AQC_MIRROR_RULE_TYPE_VLAN) {
-   if (!rule_id)
-   return I40E_ERR_PARAM;
-   } else {
+   if (rule_type == I40E_AQC_MIRROR_RULE_TYPE_VLAN) {
/* count and mr_list shall be valid for rule_type INGRESS VLAN
 * mirroring. For other rule_type, count and rule_type should
 * not matter.
-- 
2.5.0



[dpdk-dev] [PATCH 06/15] i40e/base: expose mirroring config

2016-05-05 Thread Helin Zhang
It exposes the configuration of mirroring or not egress
traffic to VSIs in promiscuous mode, as latest firmware
supports that from API version 1.5.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c| 9 ++---
 drivers/net/i40e/base/i40e_prototype.h | 4 ++--
 drivers/net/i40e/i40e_ethdev.c | 4 ++--
 drivers/net/i40e/i40e_pf.c | 2 +-
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index e958099..ace5b84 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2214,10 +2214,12 @@ enum i40e_status_code i40e_aq_set_default_vsi(struct 
i40e_hw *hw,
  * @seid: vsi number
  * @set: set unicast promiscuous enable/disable
  * @cmd_details: pointer to command details structure or NULL
+ * @rx_only_promisc: flag to decide if egress traffic gets mirrored in promisc
  **/
 enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
u16 seid, bool set,
-   struct i40e_asq_cmd_details *cmd_details)
+   struct i40e_asq_cmd_details *cmd_details,
+   bool rx_only_promisc)
 {
struct i40e_aq_desc desc;
struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
@@ -2230,8 +2232,9 @@ enum i40e_status_code 
i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,

if (set) {
flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
-   if (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
-(hw->aq.api_maj_ver > 1))
+   if (rx_only_promisc &&
+   (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
+(hw->aq.api_maj_ver > 1)))
flags |= I40E_AQC_SET_VSI_PROMISC_TX;
}

diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index 48a08fd..03dda93 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -166,7 +166,8 @@ enum i40e_status_code i40e_aq_set_vsi_broadcast(struct 
i40e_hw *hw,
u16 vsi_id, bool set_filter,
struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
-   u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details);
+   u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details,
+   bool rx_only_promisc);
 enum i40e_status_code i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw,
u16 vsi_id, bool set, struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_set_vsi_mc_promisc_on_vlan(struct i40e_hw *hw,
@@ -404,7 +405,6 @@ enum i40e_status_code i40e_aq_remove_cloud_filters(struct 
i40e_hw *hw,
u16 vsi,
struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
u8 filter_count);
-
 enum i40e_status_code i40e_aq_alternate_read(struct i40e_hw *hw,
u32 reg_addr0, u32 *reg_val0,
u32 reg_addr1, u32 *reg_val1);
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bc28d3c..b1765fe 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1661,7 +1661,7 @@ i40e_dev_promiscuous_enable(struct rte_eth_dev *dev)
int status;

status = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
-   true, NULL);
+true, NULL, true);
if (status != I40E_SUCCESS)
PMD_DRV_LOG(ERR, "Failed to enable unicast promiscuous");

@@ -1681,7 +1681,7 @@ i40e_dev_promiscuous_disable(struct rte_eth_dev *dev)
int status;

status = i40e_aq_set_vsi_unicast_promiscuous(hw, vsi->seid,
-   false, NULL);
+false, NULL, true);
if (status != I40E_SUCCESS)
PMD_DRV_LOG(ERR, "Failed to disable unicast promiscuous");

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 5afd61a..b549caa 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -810,7 +810,7 @@ i40e_pf_host_process_cmd_config_promisc_mode(
if (promisc->flags & I40E_FLAG_VF_UNICAST_PROMISC)
unicast = TRUE;
ret = i40e_aq_set_vsi_unicast_promiscuous(hw,
-   vf->vsi->seid, unicast, NULL);
+   vf->vsi->seid, unicast, NULL, true);
if (ret != I40E_SUCCESS)
goto send_msg;

-- 
2.5.0



[dpdk-dev] [PATCH 05/15] i40e/base: fixup Geneve VNI for HW use

2016-05-05 Thread Helin Zhang
The hardware doesn't layout the Geneve VNI quite the same
as the VxLAN VNI, so it needs to adjust it before sending
through the AQ commands as the workaround.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_common.c | 35 ++-
 drivers/net/i40e/base/i40e_osdep.h  |  7 +++
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index f7dff12..e958099 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5422,6 +5422,35 @@ void 
i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
 }

 /**
+ * i40e_fix_up_geneve_vni - adjust Geneve VNI for HW issue
+ * @filters: list of cloud filters
+ * @filter_count: length of list
+ *
+ * There's an issue in the device where the Geneve VNI layout needs
+ * to be shifted 1 byte over from the VxLAN VNI
+ **/
+STATIC void i40e_fix_up_geneve_vni(
+   struct i40e_aqc_add_remove_cloud_filters_element_data *filters,
+   u8 filter_count)
+{
+   struct i40e_aqc_add_remove_cloud_filters_element_data *f = filters;
+   int i;
+
+   for (i = 0; i < filter_count; i++) {
+   u16 tnl_type;
+   u32 ti;
+
+   tnl_type = (le16_to_cpu(f[i].flags) &
+  I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
+  I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
+   if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
+   ti = le32_to_cpu(f[i].tenant_id);
+   f[i].tenant_id = cpu_to_le32(ti << 8);
+   }
+   }
+}
+
+/**
  * i40e_aq_add_cloud_filters
  * @hw: pointer to the hardware structure
  * @seid: VSI seid to add cloud filters from
@@ -5441,8 +5470,8 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct 
i40e_hw *hw,
struct i40e_aq_desc desc;
struct i40e_aqc_add_remove_cloud_filters *cmd =
(struct i40e_aqc_add_remove_cloud_filters *)
-   u16 buff_len;
enum i40e_status_code status;
+   u16 buff_len;

i40e_fill_default_direct_cmd_desc(,
  i40e_aqc_opc_add_cloud_filters);
@@ -5453,6 +5482,8 @@ enum i40e_status_code i40e_aq_add_cloud_filters(struct 
i40e_hw *hw,
cmd->num_filters = filter_count;
cmd->seid = CPU_TO_LE16(seid);

+   i40e_fix_up_geneve_vni(filters, filter_count);
+
status = i40e_asq_send_command(hw, , filters, buff_len, NULL);

return status;
@@ -5490,6 +5521,8 @@ enum i40e_status_code i40e_aq_remove_cloud_filters(struct 
i40e_hw *hw,
cmd->num_filters = filter_count;
cmd->seid = CPU_TO_LE16(seid);

+   i40e_fix_up_geneve_vni(filters, filter_count);
+
status = i40e_asq_send_command(hw, , filters, buff_len, NULL);

return status;
diff --git a/drivers/net/i40e/base/i40e_osdep.h 
b/drivers/net/i40e/base/i40e_osdep.h
index 8c84ed8..38e7ba5 100644
--- a/drivers/net/i40e/base/i40e_osdep.h
+++ b/drivers/net/i40e/base/i40e_osdep.h
@@ -204,6 +204,13 @@ struct i40e_virt_mem {
 #define LE32_TO_CPU(c) rte_le_to_cpu_32(c)
 #define LE64_TO_CPU(k) rte_le_to_cpu_64(k)

+#define cpu_to_le16(o) rte_cpu_to_le_16(o)
+#define cpu_to_le32(s) rte_cpu_to_le_32(s)
+#define cpu_to_le64(h) rte_cpu_to_le_64(h)
+#define le16_to_cpu(a) rte_le_to_cpu_16(a)
+#define le32_to_cpu(c) rte_le_to_cpu_32(c)
+#define le64_to_cpu(k) rte_le_to_cpu_64(k)
+
 /* SW spinlock */
 struct i40e_spinlock {
rte_spinlock_t spinlock;
-- 
2.5.0



[dpdk-dev] [PATCH 04/15] i40e/base: code style fixes

2016-05-05 Thread Helin Zhang
It adds code style fixes.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq.c | 52 +++--
 drivers/net/i40e/base/i40e_adminq.h |  4 +--
 drivers/net/i40e/base/i40e_adminq_cmd.h | 21 +++--
 drivers/net/i40e/base/i40e_common.c |  5 ++--
 drivers/net/i40e/base/i40e_prototype.h  |  3 +-
 5 files changed, 48 insertions(+), 37 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index ba7ef42..0d3a83f 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -572,6 +572,26 @@ shutdown_arq_out:
i40e_release_spinlock(>aq.arq_spinlock);
return ret_code;
 }
+#ifdef PF_DRIVER
+
+/**
+ *  i40e_resume_aq - resume AQ processing from 0
+ *  @hw: pointer to the hardware structure
+ **/
+STATIC void i40e_resume_aq(struct i40e_hw *hw)
+{
+   /* Registers are reset after PF reset */
+   hw->aq.asq.next_to_use = 0;
+   hw->aq.asq.next_to_clean = 0;
+
+   i40e_config_asq_regs(hw);
+
+   hw->aq.arq.next_to_use = 0;
+   hw->aq.arq.next_to_clean = 0;
+
+   i40e_config_arq_regs(hw);
+}
+#endif /* PF_DRIVER */

 /**
  *  i40e_init_adminq - main initialization routine for Admin Queue
@@ -586,12 +606,15 @@ shutdown_arq_out:
  **/
 enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
 {
-   enum i40e_status_code ret_code;
 #ifdef PF_DRIVER
-   u16 eetrack_lo, eetrack_hi;
u16 cfg_ptr, oem_hi, oem_lo;
+   u16 eetrack_lo, eetrack_hi;
+#endif
+   enum i40e_status_code ret_code;
+#ifdef PF_DRIVER
int retry = 0;
 #endif
+
/* verify input for valid configuration */
if ((hw->aq.num_arq_entries == 0) ||
(hw->aq.num_asq_entries == 0) ||
@@ -600,8 +623,6 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
ret_code = I40E_ERR_CONFIG;
goto init_adminq_exit;
}
-
-   /* initialize spin locks */
i40e_init_spinlock(>aq.asq_spinlock);
i40e_init_spinlock(>aq.arq_spinlock);

@@ -704,8 +725,6 @@ enum i40e_status_code i40e_shutdown_adminq(struct i40e_hw 
*hw)

i40e_shutdown_asq(hw);
i40e_shutdown_arq(hw);
-
-   /* destroy the spinlocks */
i40e_destroy_spinlock(>aq.asq_spinlock);
i40e_destroy_spinlock(>aq.arq_spinlock);

@@ -731,7 +750,6 @@ u16 i40e_clean_asq(struct i40e_hw *hw)

desc = I40E_ADMINQ_DESC(*asq, ntc);
details = I40E_ADMINQ_DETAILS(*asq, ntc);
-
while (rd32(hw, hw->aq.asq.head) != ntc) {
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
   "ntc %d head %d.\n", ntc, rd32(hw, hw->aq.asq.head));
@@ -764,7 +782,11 @@ u16 i40e_clean_asq(struct i40e_hw *hw)
  *  Returns true if the firmware has processed all descriptors on the
  *  admin send queue. Returns false if there are still requests pending.
  **/
+#ifdef VF_DRIVER
 bool i40e_asq_done(struct i40e_hw *hw)
+#else
+STATIC bool i40e_asq_done(struct i40e_hw *hw)
+#endif
 {
/* AQ designers suggest use of head for better
 * timing reliability than DD bit
@@ -922,7 +944,6 @@ enum i40e_status_code i40e_asq_send_command(struct i40e_hw 
*hw,
 */
if (i40e_asq_done(hw))
break;
-   /* ugh! delay while spin_lock */
i40e_msec_delay(1);
total_delay++;
} while (total_delay < hw->aq.asq_cmd_timeout);
@@ -1105,7 +1126,7 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,

 #ifdef PF_DRIVER
i40e_nvmupd_check_wait_event(hw, LE16_TO_CPU(e->desc.opcode));
-#endif
+#endif /* PF_DRIVER */
 clean_arq_element_out:
/* Set pending if needed, unlock and return */
if (pending != NULL)
@@ -1116,16 +1137,3 @@ clean_arq_element_err:
return ret_code;
 }

-void i40e_resume_aq(struct i40e_hw *hw)
-{
-   /* Registers are reset after PF reset */
-   hw->aq.asq.next_to_use = 0;
-   hw->aq.asq.next_to_clean = 0;
-
-   i40e_config_asq_regs(hw);
-
-   hw->aq.arq.next_to_use = 0;
-   hw->aq.arq.next_to_clean = 0;
-
-   i40e_config_arq_regs(hw);
-}
diff --git a/drivers/net/i40e/base/i40e_adminq.h 
b/drivers/net/i40e/base/i40e_adminq.h
index 29c04a3..750973c 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -157,8 +157,8 @@ STATIC INLINE int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
 }

 /* general information */
-#define I40E_AQ_LARGE_BUF  512
-#define I40E_ASQ_CMD_TIMEOUT   250  /* msecs */
+#define I40E_AQ_LARGE_BUF  512
+#define I40E_ASQ_CMD_TIMEOUT   250  /* msecs */
 #ifdef I40E_ESS_SUPPORT
 #define I40E_ASQ_CMD_TIMEOUT_ESS   5  /* msecs */
 #endif
diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/

[dpdk-dev] [PATCH 03/15] i40e/base: refactor NVM update event handling

2016-05-05 Thread Helin Zhang
It refactors the NVM update event handling, with specifying
the AQ event opcode to wait on.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq.c| 33 +--
 drivers/net/i40e/base/i40e_nvm.c   | 77 +++---
 drivers/net/i40e/base/i40e_prototype.h |  1 +
 drivers/net/i40e/base/i40e_type.h  |  1 +
 4 files changed, 75 insertions(+), 37 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 15d5f5a..ba7ef42 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -37,18 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "i40e_adminq.h"
 #include "i40e_prototype.h"

-#ifdef PF_DRIVER
-/**
- * i40e_is_nvm_update_op - return true if this is an NVM update operation
- * @desc: API request descriptor
- **/
-STATIC INLINE bool i40e_is_nvm_update_op(struct i40e_aq_desc *desc)
-{
-   return (desc->opcode == CPU_TO_LE16(i40e_aqc_opc_nvm_erase) ||
-   desc->opcode == CPU_TO_LE16(i40e_aqc_opc_nvm_update));
-}
-
-#endif /* PF_DRIVER */
 /**
  *  i40e_adminq_init_regs - Initialize AdminQ registers
  *  @hw: pointer to the hardware structure
@@ -1116,26 +1104,7 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,
hw->aq.arq.next_to_use = ntu;

 #ifdef PF_DRIVER
-   if (i40e_is_nvm_update_op(>desc)) {
-   if (hw->nvm_release_on_done) {
-   i40e_release_nvm(hw);
-   hw->nvm_release_on_done = false;
-   }
-
-   switch (hw->nvmupd_state) {
-   case I40E_NVMUPD_STATE_INIT_WAIT:
-   hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
-   break;
-
-   case I40E_NVMUPD_STATE_WRITE_WAIT:
-   hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING;
-   break;
-
-   default:
-   break;
-   }
-   }
-
+   i40e_nvmupd_check_wait_event(hw, LE16_TO_CPU(e->desc.opcode));
 #endif
 clean_arq_element_out:
/* Set pending if needed, unlock and return */
diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index 04e422f..dfe0dc6 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -872,10 +872,10 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,
/* early check for status command and debug msgs */
upd_cmd = i40e_nvmupd_validate_command(hw, cmd, perrno);

-   i40e_debug(hw, I40E_DEBUG_NVM, "%s state %d nvm_release_on_hold %d cmd 
0x%08x config 0x%08x offset 0x%08x data_size 0x%08x\n",
+   i40e_debug(hw, I40E_DEBUG_NVM, "%s state %d nvm_release_on_hold %d opc 
0x%04x cmd 0x%08x config 0x%08x offset 0x%08x data_size 0x%08x\n",
   i40e_nvm_update_state_str[upd_cmd],
   hw->nvmupd_state,
-  hw->nvm_release_on_done,
+  hw->nvm_release_on_done, hw->nvm_wait_opcode,
   cmd->command, cmd->config, cmd->offset, cmd->data_size);

if (upd_cmd == I40E_NVMUPD_INVALID) {
@@ -889,7 +889,18 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,
 * going into the state machine
 */
if (upd_cmd == I40E_NVMUPD_STATUS) {
+   if (!cmd->data_size) {
+   *perrno = -EFAULT;
+   return I40E_ERR_BUF_TOO_SHORT;
+   }
+
bytes[0] = hw->nvmupd_state;
+
+   if (cmd->data_size >= 4) {
+   bytes[1] = 0;
+   *((u16 *)[2]) = hw->nvm_wait_opcode;
+   }
+
return I40E_SUCCESS;
}

@@ -908,6 +919,14 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,

case I40E_NVMUPD_STATE_INIT_WAIT:
case I40E_NVMUPD_STATE_WRITE_WAIT:
+   /* if we need to stop waiting for an event, clear
+* the wait info and return before doing anything else
+*/
+   if (cmd->offset == 0x) {
+   i40e_nvmupd_check_wait_event(hw, hw->nvm_wait_opcode);
+   return I40E_SUCCESS;
+   }
+
status = I40E_ERR_NOT_READY;
*perrno = -EBUSY;
break;
@@ -981,6 +1000,7 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct 
i40e_hw *hw,
i40e_release_nvm(hw);
} else {
hw->nvm_release_on_done = true;
+   hw->nvm_wait_opcode = i40e_aqc_opc_nvm_erase;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
}
@@ -997,6 +1017,7 @@ 

[dpdk-dev] [PATCH 02/15] i40e/base: refactor NVM update status info

2016-05-05 Thread Helin Zhang
It centralizes all NVM update status info in the same
structure, for better management.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq.c |  6 +++---
 drivers/net/i40e/base/i40e_adminq.h |  1 -
 drivers/net/i40e/base/i40e_nvm.c| 12 ++--
 drivers/net/i40e/base/i40e_type.h   |  1 +
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 0e4198e..15d5f5a 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -680,7 +680,7 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)

/* pre-emptive resource lock release */
i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
-   hw->aq.nvm_release_on_done = false;
+   hw->nvm_release_on_done = false;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;

 #endif /* PF_DRIVER */
@@ -1117,9 +1117,9 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,

 #ifdef PF_DRIVER
if (i40e_is_nvm_update_op(>desc)) {
-   if (hw->aq.nvm_release_on_done) {
+   if (hw->nvm_release_on_done) {
i40e_release_nvm(hw);
-   hw->aq.nvm_release_on_done = false;
+   hw->nvm_release_on_done = false;
}

switch (hw->nvmupd_state) {
diff --git a/drivers/net/i40e/base/i40e_adminq.h 
b/drivers/net/i40e/base/i40e_adminq.h
index 40c86d9..29c04a3 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -104,7 +104,6 @@ struct i40e_adminq_info {
u32 fw_build;   /* firmware build number */
u16 api_maj_ver;/* api major version */
u16 api_min_ver;/* api minor version */
-   bool nvm_release_on_done;

struct i40e_spinlock asq_spinlock; /* Send queue spinlock */
struct i40e_spinlock arq_spinlock; /* Receive queue spinlock */
diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index f4e4eaa..04e422f 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -875,7 +875,7 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,
i40e_debug(hw, I40E_DEBUG_NVM, "%s state %d nvm_release_on_hold %d cmd 
0x%08x config 0x%08x offset 0x%08x data_size 0x%08x\n",
   i40e_nvm_update_state_str[upd_cmd],
   hw->nvmupd_state,
-  hw->aq.nvm_release_on_done,
+  hw->nvm_release_on_done,
   cmd->command, cmd->config, cmd->offset, cmd->data_size);

if (upd_cmd == I40E_NVMUPD_INVALID) {
@@ -980,7 +980,7 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct 
i40e_hw *hw,
if (status) {
i40e_release_nvm(hw);
} else {
-   hw->aq.nvm_release_on_done = true;
+   hw->nvm_release_on_done = true;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
}
@@ -996,7 +996,7 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct 
i40e_hw *hw,
if (status) {
i40e_release_nvm(hw);
} else {
-   hw->aq.nvm_release_on_done = true;
+   hw->nvm_release_on_done = true;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
}
@@ -1030,7 +1030,7 @@ STATIC enum i40e_status_code 
i40e_nvmupd_state_init(struct i40e_hw *hw,
   -EIO;
i40e_release_nvm(hw);
} else {
-   hw->aq.nvm_release_on_done = true;
+   hw->nvm_release_on_done = true;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
}
@@ -1138,7 +1138,7 @@ retry:
   -EIO;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
} else {
-   hw->aq.nvm_release_on_done = true;
+   hw->nvm_release_on_done = true;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
break;
@@ -1167,7 +1167,7 @@ retry:
   -EIO;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
} else {
-   hw->aq.nvm_release_on_done = true;
+   hw->nvm_release_on_done = true;
hw->nvmupd_state = I40E_NVMUPD_STATE_

[dpdk-dev] [PATCH 01/15] i40e/base: remove HMC AQ APIs

2016-05-05 Thread Helin Zhang
HMC AQ APIs were removed from the latest datasheet, and
hence remove its implementations and relevant.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/base/i40e_adminq.c |  4 ---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 25 --
 drivers/net/i40e/base/i40e_common.c | 61 -
 drivers/net/i40e/base/i40e_prototype.h  |  8 -
 4 files changed, 98 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 222add4..0e4198e 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -683,10 +683,6 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
hw->aq.nvm_release_on_done = false;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;

-   ret_code = i40e_aq_set_hmc_resource_profile(hw,
-   I40E_HMC_PROFILE_DEFAULT,
-   0,
-   NULL);
 #endif /* PF_DRIVER */
ret_code = I40E_SUCCESS;

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index fe9d5b5..58ba609 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -224,10 +224,6 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_resume_port_tx = 0x041C,
i40e_aqc_opc_configure_partition_bw = 0x041D,

-   /* hmc */
-   i40e_aqc_opc_query_hmc_resource_profile = 0x0500,
-   i40e_aqc_opc_set_hmc_resource_profile   = 0x0501,
-
/* phy commands*/
i40e_aqc_opc_get_phy_abilities  = 0x0600,
i40e_aqc_opc_set_phy_config = 0x0601,
@@ -1646,27 +1642,6 @@ struct i40e_aqc_configure_partition_bw_data {

 I40E_CHECK_STRUCT_LEN(0x22, i40e_aqc_configure_partition_bw_data);

-/* Get and set the active HMC resource profile and status.
- * (direct 0x0500) and (direct 0x0501)
- */
-struct i40e_aq_get_set_hmc_resource_profile {
-   u8  pm_profile;
-   u8  pe_vf_enabled;
-   u8  reserved[14];
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aq_get_set_hmc_resource_profile);
-
-enum i40e_aq_hmc_profile {
-   /* I40E_HMC_PROFILE_NO_CHANGE= 0, reserved */
-   I40E_HMC_PROFILE_DEFAULT= 1,
-   I40E_HMC_PROFILE_FAVOR_VF   = 2,
-   I40E_HMC_PROFILE_EQUAL  = 3,
-};
-
-#define I40E_AQ_GET_HMC_RESOURCE_PROFILE_PM_MASK   0xF
-#define I40E_AQ_GET_HMC_RESOURCE_PROFILE_COUNT_MASK0x3F
-
 /* Get PHY Abilities (indirect 0x0600) uses the generic indirect struct */

 /* set in param0 for get phy abilities to report qualified modules */
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index ef3425e..7a5f754 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3240,67 +3240,6 @@ enum i40e_status_code 
i40e_aq_debug_write_register(struct i40e_hw *hw,
 }

 /**
- * i40e_aq_get_hmc_resource_profile
- * @hw: pointer to the hw struct
- * @profile: type of profile the HMC is to be set as
- * @pe_vf_enabled_count: the number of PE enabled VFs the system has
- * @cmd_details: pointer to command details structure or NULL
- *
- * query the HMC profile of the device.
- **/
-enum i40e_status_code i40e_aq_get_hmc_resource_profile(struct i40e_hw *hw,
-   enum i40e_aq_hmc_profile *profile,
-   u8 *pe_vf_enabled_count,
-   struct i40e_asq_cmd_details *cmd_details)
-{
-   struct i40e_aq_desc desc;
-   struct i40e_aq_get_set_hmc_resource_profile *resp =
-   (struct i40e_aq_get_set_hmc_resource_profile *)
-   enum i40e_status_code status;
-
-   i40e_fill_default_direct_cmd_desc(,
-   i40e_aqc_opc_query_hmc_resource_profile);
-   status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
-
-   *profile = (enum i40e_aq_hmc_profile)(resp->pm_profile &
-  I40E_AQ_GET_HMC_RESOURCE_PROFILE_PM_MASK);
-   *pe_vf_enabled_count = resp->pe_vf_enabled &
-  I40E_AQ_GET_HMC_RESOURCE_PROFILE_COUNT_MASK;
-
-   return status;
-}
-
-/**
- * i40e_aq_set_hmc_resource_profile
- * @hw: pointer to the hw struct
- * @profile: type of profile the HMC is to be set as
- * @pe_vf_enabled_count: the number of PE enabled VFs the system has
- * @cmd_details: pointer to command details structure or NULL
- *
- * set the HMC profile of the device.
- **/
-enum i40e_status_code i40e_aq_set_hmc_resource_profile(struct i40e_hw *hw,
-   enum i40e_aq_hmc_profile profile,
-   u8 pe_vf_enabled_count,
-   struct i40e_asq_cmd_details *cmd_details)
-{
-   struct i40e_aq_desc desc;
-   struct i40e_aq_get_set_hmc_r

[dpdk-dev] [PATCH 00/15] i40e base driver update

2016-05-05 Thread Helin Zhang
This is the i40e base driver update, which includes
bug fixes, enhancements, refactoring, and new device
enabling. Below are the details.

Helin Zhang (15):
  i40e/base: remove HMC AQ APIs
  i40e/base: refactor NVM update status info
  i40e/base: refactor NVM update event handling
  i40e/base: code style fixes
  i40e/base: fixup Geneve VNI for HW use
  i40e/base: expose mirroring config
  i40e/base: fix problematic mirror rule ID check
  i40e/base: add new devices
  i40e/base: fix the number of MSIX vector
  i40e/base: fix debug output
  i40e/base: add more device capabilities
  i40e/base: increase supported AQ API version
  i40e/base: add input set mask definitions
  i40e/base: add RSS config to virtual channel
  i40e/base: add capability of disabling all link

 doc/guides/rel_notes/release_16_07.rst  |   7 ++
 drivers/net/i40e/Makefile   |   2 +-
 drivers/net/i40e/base/i40e_adminq.c |  91 ++--
 drivers/net/i40e/base/i40e_adminq.h |   5 +-
 drivers/net/i40e/base/i40e_adminq_cmd.h |  54 --
 drivers/net/i40e/base/i40e_common.c | 132 ++--
 drivers/net/i40e/base/i40e_devids.h |   4 +
 drivers/net/i40e/base/i40e_nvm.c|  87 ++--
 drivers/net/i40e/base/i40e_osdep.h  |   7 ++
 drivers/net/i40e/base/i40e_prototype.h  |  16 +--
 drivers/net/i40e/base/i40e_type.h   |  42 +++-
 drivers/net/i40e/base/i40e_virtchnl.h   |  45 +++-
 drivers/net/i40e/i40e_ethdev.c  |   4 +-
 drivers/net/i40e/i40e_pf.c  |   2 +-
 lib/librte_eal/common/include/rte_pci_dev_ids.h |   8 ++
 15 files changed, 306 insertions(+), 200 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v3 2/2] i40e: fix missing break in switch

2016-04-28 Thread Helin Zhang
It fixes the issue reported by Coverity of 'Missing break in
switch', by deleting 'case I40E_VIRTCHNL_OP_FCOE', as it is
not necessary at all.

Coverity ID 13265: Missing break in switch.

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

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_pf.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 1bd599b..b47a374 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -997,11 +997,9 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
PMD_DRV_LOG(INFO, "OP_CFG_VLAN_PVID received");
i40e_pf_host_process_cmd_cfg_pvid(vf, msg, msglen);
break;
-/* Don't add command supported below, which will
-*  return an error code.
+   /* Don't add command supported below, which will
+* return an error code.
 */
-   case I40E_VIRTCHNL_OP_FCOE:
-   PMD_DRV_LOG(ERR, "OP_FCOE received, not supported");
default:
PMD_DRV_LOG(ERR, "%u received, not supported", opcode);
i40e_pf_host_send_msg_to_vf(vf, opcode, I40E_ERR_PARAM,
-- 
2.5.0



[dpdk-dev] [PATCH v3 1/2] i40e: fix problematic dereference

2016-04-28 Thread Helin Zhang
It fixes the issue reported by Coverity of 'Dereference before
null check', by deleting null checks as they are not necessary
at all, or move null checks before where uses it.

Coverity ID 119267: Dereference before null check.
Coverity ID 13301: Dereference before null check.
Coverity ID 13294: Dereference before null check.
Coverity ID 13299: Dereference before null check.
Coverity ID 13298: Dereference before null check.

Fixes: 8e109464c022 ("i40e: allow vector Rx and Tx usage")
Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")
Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")
Fixes: 4861cde46116 ("i40e: new poll mode driver")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_pf.c   |  5 +++--
 drivers/net/i40e/i40e_rxtx.c | 10 +++---
 2 files changed, 10 insertions(+), 5 deletions(-)

v3:
 - Split the code changes into different patches, according
   to the issue type.
 - Reworded the commit logs.

v2:
 - Combined all the patches into a single one, as suggested.
 - Remove checking rxq, as it shouldn't be NULL at any time.

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 5afd61a..1bd599b 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -123,7 +123,7 @@ int
 i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool do_hw_reset)
 {
uint32_t val, i;
-   struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
+   struct i40e_hw *hw;
uint16_t vf_id, abs_vf_id, vf_msix_num;
int ret;
struct i40e_virtchnl_queue_select qsel;
@@ -131,6 +131,7 @@ i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool 
do_hw_reset)
if (vf == NULL)
return -EINVAL;

+   hw = I40E_PF_TO_HW(vf->pf);
vf_id = vf->vf_idx;
abs_vf_id = vf_id + hw->func_caps.vf_base_id;

@@ -913,7 +914,7 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
/* AdminQ will pass absolute VF id, transfer to internal vf id */
uint16_t vf_id = abs_vf_id - hw->func_caps.vf_base_id;

-   if (!dev || vf_id > pf->vf_num - 1 || !pf->vfs) {
+   if (vf_id > pf->vf_num - 1 || !pf->vfs) {
PMD_DRV_LOG(ERR, "invalid argument");
return;
}
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 4d35d83..f9e17fd 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2598,7 +2598,7 @@ i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq)
return;
}

-   if (!rxq || !rxq->sw_ring) {
+   if (!rxq->sw_ring) {
PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
return;
}
@@ -2981,13 +2981,15 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
struct i40e_tx_queue *txq;
const struct rte_memzone *tz = NULL;
uint32_t ring_size;
-   struct rte_eth_dev *dev = pf->adapter->eth_dev;
+   struct rte_eth_dev *dev;

if (!pf) {
PMD_DRV_LOG(ERR, "PF is not available");
return I40E_ERR_BAD_PTR;
}

+   dev = pf->adapter->eth_dev;
+
/* Allocate the TX queue data structure. */
txq = rte_zmalloc_socket("i40e fdir tx queue",
  sizeof(struct i40e_tx_queue),
@@ -3035,13 +3037,15 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
struct i40e_rx_queue *rxq;
const struct rte_memzone *rz = NULL;
uint32_t ring_size;
-   struct rte_eth_dev *dev = pf->adapter->eth_dev;
+   struct rte_eth_dev *dev;

if (!pf) {
PMD_DRV_LOG(ERR, "PF is not available");
return I40E_ERR_BAD_PTR;
}

+   dev = pf->adapter->eth_dev;
+
/* Allocate the RX queue data structure. */
rxq = rte_zmalloc_socket("i40e fdir rx queue",
  sizeof(struct i40e_rx_queue),
-- 
2.5.0



[dpdk-dev] [PATCH v3 0/2] fix Coverity reported issues

2016-04-28 Thread Helin Zhang
It fixes the issue reported by Coverity of 'Missing break in
switch', by deleting 'case I40E_VIRTCHNL_OP_FCOE', as it is
not necessary at all.
It also fixes the issue reported by Coverity of 'Dereference
before null check', by deleting null checks as they are not
necessary at all, or move null checks before where uses it.

v3:
 - Split the code changes into different patches, according
   to the issue type.
 - Reworded the commit logs.

v2:
 - Combined all the patches into a single one, as suggested.
 - Remove checking rxq, as it shouldn't be NULL at any time.

Helin Zhang (2):
  i40e: fix problematic dereference
  i40e: fix missing break in switch

 drivers/net/i40e/i40e_pf.c   | 11 +--
 drivers/net/i40e/i40e_rxtx.c | 10 +++---
 2 files changed, 12 insertions(+), 9 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v2] i40e: fix problematic dereference

2016-04-25 Thread Helin Zhang
Fix issue reported by Coverity.

Coverity ID 119267: Dereference before null check.
Coverity ID 13301: Dereference before null check.
Coverity ID 13294: Dereference before null check.
Coverity ID 13299: Dereference before null check.
Coverity ID 13298: Dereference before null check.
Coverity ID 13265: Missing break in switch.

Fixes: 8e109464c022 ("i40e: allow vector Rx and Tx usage")
Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")
Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")
Fixes: 4861cde46116 ("i40e: new poll mode driver")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_pf.c   |  7 +++
 drivers/net/i40e/i40e_rxtx.c | 10 +++---
 2 files changed, 10 insertions(+), 7 deletions(-)

v2:
 - Combined all the patches into a single one, as suggested.
 - Remove checking rxq, as it shouldn't be NULL at any time.

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 5afd61a..1ea7b0a 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -123,7 +123,7 @@ int
 i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool do_hw_reset)
 {
uint32_t val, i;
-   struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
+   struct i40e_hw *hw;
uint16_t vf_id, abs_vf_id, vf_msix_num;
int ret;
struct i40e_virtchnl_queue_select qsel;
@@ -131,6 +131,7 @@ i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool 
do_hw_reset)
if (vf == NULL)
return -EINVAL;

+   hw = I40E_PF_TO_HW(vf->pf);
vf_id = vf->vf_idx;
abs_vf_id = vf_id + hw->func_caps.vf_base_id;

@@ -913,7 +914,7 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
/* AdminQ will pass absolute VF id, transfer to internal vf id */
uint16_t vf_id = abs_vf_id - hw->func_caps.vf_base_id;

-   if (!dev || vf_id > pf->vf_num - 1 || !pf->vfs) {
+   if (vf_id > pf->vf_num - 1 || !pf->vfs) {
PMD_DRV_LOG(ERR, "invalid argument");
return;
}
@@ -999,8 +1000,6 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 /* Don't add command supported below, which will
 *  return an error code.
 */
-   case I40E_VIRTCHNL_OP_FCOE:
-   PMD_DRV_LOG(ERR, "OP_FCOE received, not supported");
default:
PMD_DRV_LOG(ERR, "%u received, not supported", opcode);
i40e_pf_host_send_msg_to_vf(vf, opcode, I40E_ERR_PARAM,
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 4d35d83..f9e17fd 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2598,7 +2598,7 @@ i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq)
return;
}

-   if (!rxq || !rxq->sw_ring) {
+   if (!rxq->sw_ring) {
PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
return;
}
@@ -2981,13 +2981,15 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
struct i40e_tx_queue *txq;
const struct rte_memzone *tz = NULL;
uint32_t ring_size;
-   struct rte_eth_dev *dev = pf->adapter->eth_dev;
+   struct rte_eth_dev *dev;

if (!pf) {
PMD_DRV_LOG(ERR, "PF is not available");
return I40E_ERR_BAD_PTR;
}

+   dev = pf->adapter->eth_dev;
+
/* Allocate the TX queue data structure. */
txq = rte_zmalloc_socket("i40e fdir tx queue",
  sizeof(struct i40e_tx_queue),
@@ -3035,13 +3037,15 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
struct i40e_rx_queue *rxq;
const struct rte_memzone *rz = NULL;
uint32_t ring_size;
-   struct rte_eth_dev *dev = pf->adapter->eth_dev;
+   struct rte_eth_dev *dev;

if (!pf) {
PMD_DRV_LOG(ERR, "PF is not available");
return I40E_ERR_BAD_PTR;
}

+   dev = pf->adapter->eth_dev;
+
/* Allocate the RX queue data structure. */
rxq = rte_zmalloc_socket("i40e fdir rx queue",
  sizeof(struct i40e_rx_queue),
-- 
2.5.0



[dpdk-dev] [PATCH 6/6] i40e: fix problematic dereference

2016-04-21 Thread Helin Zhang
Fix issue reported by Coverity.

Coverity ID 13265: Missing break in switch.

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

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_pf.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 1bd599b..1ea7b0a 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -1000,8 +1000,6 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 /* Don't add command supported below, which will
 *  return an error code.
 */
-   case I40E_VIRTCHNL_OP_FCOE:
-   PMD_DRV_LOG(ERR, "OP_FCOE received, not supported");
default:
PMD_DRV_LOG(ERR, "%u received, not supported", opcode);
i40e_pf_host_send_msg_to_vf(vf, opcode, I40E_ERR_PARAM,
-- 
2.5.0



[dpdk-dev] [PATCH 5/6] i40e: fix problematic dereference

2016-04-21 Thread Helin Zhang
Fix issue reported by Coverity.

Coverity ID 13298: Dereference before null check.

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

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_pf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 3ec8f7c..1bd599b 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -123,7 +123,7 @@ int
 i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool do_hw_reset)
 {
uint32_t val, i;
-   struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
+   struct i40e_hw *hw;
uint16_t vf_id, abs_vf_id, vf_msix_num;
int ret;
struct i40e_virtchnl_queue_select qsel;
@@ -131,6 +131,7 @@ i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool 
do_hw_reset)
if (vf == NULL)
return -EINVAL;

+   hw = I40E_PF_TO_HW(vf->pf);
vf_id = vf->vf_idx;
abs_vf_id = vf_id + hw->func_caps.vf_base_id;

-- 
2.5.0



[dpdk-dev] [PATCH 4/6] i40e: fix problematic dereference

2016-04-21 Thread Helin Zhang
Fix issue reported by Coverity.

Coverity ID 13299: Dereference before null check.

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

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_pf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 5afd61a..3ec8f7c 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -913,7 +913,7 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
/* AdminQ will pass absolute VF id, transfer to internal vf id */
uint16_t vf_id = abs_vf_id - hw->func_caps.vf_base_id;

-   if (!dev || vf_id > pf->vf_num - 1 || !pf->vfs) {
+   if (vf_id > pf->vf_num - 1 || !pf->vfs) {
PMD_DRV_LOG(ERR, "invalid argument");
return;
}
-- 
2.5.0



[dpdk-dev] [PATCH 3/6] i40e: fix problematic dereference

2016-04-21 Thread Helin Zhang
Fix issue reported by Coverity.

Coverity ID 13294: Dereference before null check.

Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_rxtx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 31bfc44..4fd96fe 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2981,13 +2981,15 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
struct i40e_tx_queue *txq;
const struct rte_memzone *tz = NULL;
uint32_t ring_size;
-   struct rte_eth_dev *dev = pf->adapter->eth_dev;
+   struct rte_eth_dev *dev;

if (!pf) {
PMD_DRV_LOG(ERR, "PF is not available");
return I40E_ERR_BAD_PTR;
}

+   dev = pf->adapter->eth_dev;
+
/* Allocate the TX queue data structure. */
txq = rte_zmalloc_socket("i40e fdir tx queue",
  sizeof(struct i40e_tx_queue),
-- 
2.5.0



[dpdk-dev] [PATCH 2/6] i40e: fix problematic dereference

2016-04-21 Thread Helin Zhang
Fix issue reported by Coverity.

Coverity ID 13301: Dereference before null check.

Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_rxtx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 9c126a3..31bfc44 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -3035,13 +3035,15 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
struct i40e_rx_queue *rxq;
const struct rte_memzone *rz = NULL;
uint32_t ring_size;
-   struct rte_eth_dev *dev = pf->adapter->eth_dev;
+   struct rte_eth_dev *dev;

if (!pf) {
PMD_DRV_LOG(ERR, "PF is not available");
return I40E_ERR_BAD_PTR;
}

+   dev = pf->adapter->eth_dev;
+
/* Allocate the RX queue data structure. */
rxq = rte_zmalloc_socket("i40e fdir rx queue",
  sizeof(struct i40e_rx_queue),
-- 
2.5.0



[dpdk-dev] [PATCH 1/6] i40e: fix problematic dereference

2016-04-21 Thread Helin Zhang
Fix issue reported by Coverity.

Coverity ID 119267: Dereference before null check.

Fixes: 8e109464c022 ("i40e: allow vector Rx and Tx usage")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_rxtx.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 4d35d83..9c126a3 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2592,14 +2592,14 @@ i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq)
 {
uint16_t i;

-   /* SSE Vector driver has a different way of releasing mbufs. */
-   if (rxq->rx_using_sse) {
-   i40e_rx_queue_release_mbufs_vec(rxq);
+   if (!rxq || !rxq->sw_ring) {
+   PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
return;
}

-   if (!rxq || !rxq->sw_ring) {
-   PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
+   /* SSE Vector driver has a different way of releasing mbufs. */
+   if (rxq->rx_using_sse) {
+   i40e_rx_queue_release_mbufs_vec(rxq);
return;
}

-- 
2.5.0



[dpdk-dev] [PATCH 0/6] fix i40e problematic dereference

2016-04-21 Thread Helin Zhang
It fixes several problematic dereferences in i40e driver,
reported by Coverity.

Helin Zhang (6):
  i40e: fix problematic dereference
  i40e: fix problematic dereference
  i40e: fix problematic dereference
  i40e: fix problematic dereference
  i40e: fix problematic dereference
  i40e: fix problematic dereference

 drivers/net/i40e/i40e_pf.c   |  7 +++
 drivers/net/i40e/i40e_rxtx.c | 18 +++---
 2 files changed, 14 insertions(+), 11 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v5 2/2] i40e: fix the overflow issue

2016-03-12 Thread Helin Zhang
The array 'ptype_table' was defined in depth of 'UINT8_MAX' which
is 255, while the querying index could be from 0 to 255. The issue
can be fixed with expanding the array to one more element.

Fixes: 9571ea028489 ("i40e: replace some offload flags with unified packet 
type")

Signed-off-by: Helin Zhang 
Acked-by: Wenzhuo Lu 
---
 drivers/net/i40e/i40e_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index f8efdce..e0c9bb6 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -198,7 +198,7 @@ i40e_get_iee15888_flags(struct rte_mbuf *mb, uint64_t qword)
 static inline uint32_t
 i40e_rxd_pkt_type_mapping(uint8_t ptype)
 {
-   static const uint32_t ptype_table[UINT8_MAX] __rte_cache_aligned = {
+   static const uint32_t type_table[UINT8_MAX + 1] __rte_cache_aligned = {
/* L2 types */
/* [0] reserved */
[1] = RTE_PTYPE_L2_ETHER,
@@ -724,7 +724,7 @@ i40e_rxd_pkt_type_mapping(uint8_t ptype)
/* All others reserved */
};

-   return ptype_table[ptype];
+   return type_table[ptype];
 }

 #define I40E_RX_DESC_EXT_STATUS_FLEXBH_MASK   0x03
-- 
2.5.0



[dpdk-dev] [PATCH v5 1/2] ethdev: add vlan type for setting ether type

2016-03-12 Thread Helin Zhang
In order to set ether type of VLAN for single VLAN, inner
and outer VLAN, the VLAN type as an input parameter is added
to 'rte_eth_dev_set_vlan_ether_type()'.
In addition, corresponding changes in e1000, ixgbe and i40e
are also added.

Signed-off-by: Helin Zhang 
Acked-by: Wenzhuo Lu 
---
 app/test-pmd/cmdline.c  | 30 +++
 app/test-pmd/config.c   |  9 ++--
 app/test-pmd/testpmd.h  |  3 +-
 doc/guides/rel_notes/release_16_04.rst  |  5 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 +---
 drivers/net/e1000/igb_ethdev.c  | 27 +++---
 drivers/net/i40e/i40e_ethdev.c  | 79 +++--
 drivers/net/ixgbe/ixgbe_ethdev.c| 25 +++--
 lib/librte_ether/rte_ethdev.c   |  7 +--
 lib/librte_ether/rte_ethdev.h   | 21 ++--
 lib/librte_ether/rte_ether_version.map  |  7 +++
 11 files changed, 179 insertions(+), 45 deletions(-)

v5:
 - Removed the versioning mechanism, as ABI broken is already
   there allowed.

v4:
 - Updated the doc of testpmd guide.

v3:
 - Used versioning mechanism to avoid ABI issue.
 - Re-organized the patch set.

v2:
 - Used RTE_NEXT_ABI to avoid ABI change issue.
 - Reworked the announcement of ABI change for release 16.07.

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 52e9f5f..1eeb8a8 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -277,8 +277,8 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the VLAN QinQ (extended queue in queue)"
" on a port.\n\n"

-   "vlan set tpid (value) (port_id)\n"
-   "Set the outer VLAN TPID for Packet Filtering on"
+   "vlan set (inner|outer) tpid (value) (port_id)\n"
+   "Set the VLAN TPID for Packet Filtering on"
" a port\n\n"

"rx_vlan add (vlan_id|all) (port_id)\n"
@@ -297,10 +297,6 @@ static void cmd_help_long_parsed(void *parsed_result,
"Remove a vlan_id, to the set of VLAN identifiers"
"filtered for VF(s) from port_id.\n\n"

-   "rx_vlan set tpid (value) (port_id)\n"
-   "Set the outer VLAN TPID for Packet Filtering on"
-   " a port\n\n"
-
"tunnel_filter add (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
"(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) 
(queue_id)\n"
"   add a tunnel filter of a port.\n\n"
@@ -2747,6 +2743,7 @@ cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
 struct cmd_vlan_offload_result {
cmdline_fixed_string_t vlan;
cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vlan_type;
cmdline_fixed_string_t what;
cmdline_fixed_string_t on;
cmdline_fixed_string_t port_id;
@@ -2847,6 +2844,7 @@ cmdline_parse_inst_t cmd_vlan_offload = {
 struct cmd_vlan_tpid_result {
cmdline_fixed_string_t vlan;
cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vlan_type;
cmdline_fixed_string_t what;
uint16_t tp_id;
uint8_t port_id;
@@ -2858,8 +2856,17 @@ cmd_vlan_tpid_parsed(void *parsed_result,
  __attribute__((unused)) void *data)
 {
struct cmd_vlan_tpid_result *res = parsed_result;
-   vlan_tpid_set(res->port_id, res->tp_id);
-   return;
+   enum rte_vlan_type vlan_type;
+
+   if (!strcmp(res->vlan_type, "inner"))
+   vlan_type = ETH_VLAN_TYPE_INNER;
+   else if (!strcmp(res->vlan_type, "outer"))
+   vlan_type = ETH_VLAN_TYPE_OUTER;
+   else {
+   printf("Unknown vlan type\n");
+   return;
+   }
+   vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
 }

 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
@@ -2868,6 +2875,9 @@ cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
 cmdline_parse_token_string_t cmd_vlan_tpid_set =
TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
 set, "set");
+cmdline_parse_token_string_t cmd_vlan_type =
+   TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
+vlan_type, "inner#outer");
 cmdline_parse_token_string_t cmd_vlan_tpid_what =
TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
 what, "tpid");
@@ -2881,10 +2891,12 @@ cmdline_parse_token_num_t cmd_vlan_tpid_portid =
 cmdline_parse_inst_t cmd_vlan_tpid = {
.f = cmd_vlan_tpid_parsed,
.data = NULL,
-   

[dpdk-dev] [PATCH v5 0/2] i40e setting ether type of VLANs

2016-03-12 Thread Helin Zhang
It adds setting ether type of both single VLAN(inner VLAN) and
outer VLAN for i40e. For ixgbe and e1000/igb, it supports setting
single VLAN(inner VLAN) only, and can be extended in the future.

The patch set was branched off rel_16_04 of repo dpdk-next-net,
on below commit.
commit 5721e6447b5c20208a32c919a509e89d78c3e68d
Author: Robin Jarry 
Date:   Thu Mar 3 15:27:40 2016 +0100
mlx4: ensure number of RX queues is a power of 2 

v5:
 - Removed the versioning mechanism, as ABI broken is already
   there allowed.

v4:
 - Updated the doc of testpmd guide.

v3:
 - Used versioning mechanism to avoid ABI issue.
 - Re-organized the patch set.

v2:
 - Used RTE_NEXT_ABI to avoid ABI change issue.
 - Reworked the announcement of ABI change for release 16.07.
 - Fixed a i40e overflow issue.

Helin Zhang (2):
  ethdev: add vlan type for setting ether type
  i40e: fix the overflow issue

 app/test-pmd/cmdline.c  | 30 +++
 app/test-pmd/config.c   |  9 ++--
 app/test-pmd/testpmd.h  |  3 +-
 doc/guides/rel_notes/release_16_04.rst  |  5 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 +---
 drivers/net/e1000/igb_ethdev.c  | 27 +++---
 drivers/net/i40e/i40e_ethdev.c  | 79 +++--
 drivers/net/i40e/i40e_rxtx.c|  4 +-
 drivers/net/ixgbe/ixgbe_ethdev.c| 25 +++--
 lib/librte_ether/rte_ethdev.c   |  7 +--
 lib/librte_ether/rte_ethdev.h   | 21 ++--
 lib/librte_ether/rte_ether_version.map  |  7 +++
 12 files changed, 181 insertions(+), 47 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v4 2/2] i40e: fix the overflow issue

2016-03-11 Thread Helin Zhang
The array 'ptype_table' was defined in depth of 'UINT8_MAX' which
is 255, while the querying index could be from 0 to 255. The issue
can be fixed with expanding the array to one more element.

Fixes: 9571ea028489 ("i40e: replace some offload flags with unified packet 
type")

Signed-off-by: Helin Zhang 
Acked-by: Wenzhuo Lu 
---
 drivers/net/i40e/i40e_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index f8efdce..e0c9bb6 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -198,7 +198,7 @@ i40e_get_iee15888_flags(struct rte_mbuf *mb, uint64_t qword)
 static inline uint32_t
 i40e_rxd_pkt_type_mapping(uint8_t ptype)
 {
-   static const uint32_t ptype_table[UINT8_MAX] __rte_cache_aligned = {
+   static const uint32_t type_table[UINT8_MAX + 1] __rte_cache_aligned = {
/* L2 types */
/* [0] reserved */
[1] = RTE_PTYPE_L2_ETHER,
@@ -724,7 +724,7 @@ i40e_rxd_pkt_type_mapping(uint8_t ptype)
/* All others reserved */
};

-   return ptype_table[ptype];
+   return type_table[ptype];
 }

 #define I40E_RX_DESC_EXT_STATUS_FLEXBH_MASK   0x03
-- 
2.5.0



[dpdk-dev] [PATCH v4 1/2] ethdev: add vlan type for setting ether type

2016-03-11 Thread Helin Zhang
In order to set ether type of VLAN for single VLAN, inner
and outer VLAN, the VLAN type as an input parameter is added
to 'rte_eth_dev_set_vlan_ether_type()'.
In addition, corresponding changes in e1000, ixgbe and i40e
are also added.

Signed-off-by: Helin Zhang 
Acked-by: Wenzhuo Lu 
---
 app/test-pmd/cmdline.c  | 30 +-
 app/test-pmd/config.c   |  9 +++--
 app/test-pmd/testpmd.h  |  3 +-
 doc/guides/rel_notes/release_16_04.rst  |  4 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 +
 drivers/net/e1000/igb_ethdev.c  | 21 +++---
 drivers/net/i40e/i40e_ethdev.c  | 63 +++--
 drivers/net/ixgbe/ixgbe_ethdev.c| 19 +++--
 lib/librte_ether/rte_ethdev.c   | 25 +++-
 lib/librte_ether/rte_ethdev.h   | 23 ++-
 lib/librte_ether/rte_ether_version.map  |  7 
 11 files changed, 175 insertions(+), 40 deletions(-)

v4:
 - Updated the doc of testpmd guide.

v3:
 - Used versioning mechanism to avoid ABI issue.
 - Re-organized the patch set.

v2:
 - Used RTE_NEXT_ABI to avoid ABI change issue.
 - Reworked the announcement of ABI change for release 16.07.

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 52e9f5f..1eeb8a8 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -277,8 +277,8 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the VLAN QinQ (extended queue in queue)"
" on a port.\n\n"

-   "vlan set tpid (value) (port_id)\n"
-   "Set the outer VLAN TPID for Packet Filtering on"
+   "vlan set (inner|outer) tpid (value) (port_id)\n"
+   "Set the VLAN TPID for Packet Filtering on"
" a port\n\n"

"rx_vlan add (vlan_id|all) (port_id)\n"
@@ -297,10 +297,6 @@ static void cmd_help_long_parsed(void *parsed_result,
"Remove a vlan_id, to the set of VLAN identifiers"
"filtered for VF(s) from port_id.\n\n"

-   "rx_vlan set tpid (value) (port_id)\n"
-   "Set the outer VLAN TPID for Packet Filtering on"
-   " a port\n\n"
-
"tunnel_filter add (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
"(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) 
(queue_id)\n"
"   add a tunnel filter of a port.\n\n"
@@ -2747,6 +2743,7 @@ cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
 struct cmd_vlan_offload_result {
cmdline_fixed_string_t vlan;
cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vlan_type;
cmdline_fixed_string_t what;
cmdline_fixed_string_t on;
cmdline_fixed_string_t port_id;
@@ -2847,6 +2844,7 @@ cmdline_parse_inst_t cmd_vlan_offload = {
 struct cmd_vlan_tpid_result {
cmdline_fixed_string_t vlan;
cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vlan_type;
cmdline_fixed_string_t what;
uint16_t tp_id;
uint8_t port_id;
@@ -2858,8 +2856,17 @@ cmd_vlan_tpid_parsed(void *parsed_result,
  __attribute__((unused)) void *data)
 {
struct cmd_vlan_tpid_result *res = parsed_result;
-   vlan_tpid_set(res->port_id, res->tp_id);
-   return;
+   enum rte_vlan_type vlan_type;
+
+   if (!strcmp(res->vlan_type, "inner"))
+   vlan_type = ETH_VLAN_TYPE_INNER;
+   else if (!strcmp(res->vlan_type, "outer"))
+   vlan_type = ETH_VLAN_TYPE_OUTER;
+   else {
+   printf("Unknown vlan type\n");
+   return;
+   }
+   vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
 }

 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
@@ -2868,6 +2875,9 @@ cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
 cmdline_parse_token_string_t cmd_vlan_tpid_set =
TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
 set, "set");
+cmdline_parse_token_string_t cmd_vlan_type =
+   TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
+vlan_type, "inner#outer");
 cmdline_parse_token_string_t cmd_vlan_tpid_what =
TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
 what, "tpid");
@@ -2881,10 +2891,12 @@ cmdline_parse_token_num_t cmd_vlan_tpid_portid =
 cmdline_parse_inst_t cmd_vlan_tpid = {
.f = cmd_vlan_tpid_parsed,
.data = NULL,
-   .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type&

[dpdk-dev] [PATCH v4 0/2] i40e setting ether type of VLANs

2016-03-11 Thread Helin Zhang
It adds setting ether type of both single VLAN(inner VLAN)
and outer VLAN for i40e. For ixgbe and e1000/igb, it supports
setting single VLAN(inner VLAN) only, and can be extended in
the future.

The patch set was branched off rel_16_04 of repo dpdk-next-net,
on below commit.
commit 5721e6447b5c20208a32c919a509e89d78c3e68d
Author: Robin Jarry 
Date:   Thu Mar 3 15:27:40 2016 +0100
mlx4: ensure number of RX queues is a power of 2

v4:
 - Updated the doc of testpmd guide.

v3:
 - Used versioning mechanism to avoid ABI issue.
 - Re-organized the patch set.

v2:
 - Used RTE_NEXT_ABI to avoid ABI change issue.
 - Reworked the announcement of ABI change for release 16.07.
 - Fixed a i40e overflow issue.

Helin Zhang (2):
  ethdev: add vlan type for setting ether type
  i40e: fix the overflow issue

 app/test-pmd/cmdline.c  | 30 +-
 app/test-pmd/config.c   |  9 +++--
 app/test-pmd/testpmd.h  |  3 +-
 doc/guides/rel_notes/release_16_04.rst  |  4 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 +
 drivers/net/e1000/igb_ethdev.c  | 21 +++---
 drivers/net/i40e/i40e_ethdev.c  | 63 +++--
 drivers/net/i40e/i40e_rxtx.c|  4 +-
 drivers/net/ixgbe/ixgbe_ethdev.c| 19 +++--
 lib/librte_ether/rte_ethdev.c   | 25 +++-
 lib/librte_ether/rte_ethdev.h   | 23 ++-
 lib/librte_ether/rte_ether_version.map  |  7 
 12 files changed, 177 insertions(+), 42 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v3 2/2] i40e: fix the overflow issue

2016-03-11 Thread Helin Zhang
The array 'ptype_table' was defined in depth of 'UINT8_MAX' which
is 255, while the querying index could be from 0 to 255. The issue
can be fixed with expanding the array to one more element.

Fixes: 9571ea028489 ("i40e: replace some offload flags with unified packet 
type")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index f8efdce..e0c9bb6 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -198,7 +198,7 @@ i40e_get_iee15888_flags(struct rte_mbuf *mb, uint64_t qword)
 static inline uint32_t
 i40e_rxd_pkt_type_mapping(uint8_t ptype)
 {
-   static const uint32_t ptype_table[UINT8_MAX] __rte_cache_aligned = {
+   static const uint32_t type_table[UINT8_MAX + 1] __rte_cache_aligned = {
/* L2 types */
/* [0] reserved */
[1] = RTE_PTYPE_L2_ETHER,
@@ -724,7 +724,7 @@ i40e_rxd_pkt_type_mapping(uint8_t ptype)
/* All others reserved */
};

-   return ptype_table[ptype];
+   return type_table[ptype];
 }

 #define I40E_RX_DESC_EXT_STATUS_FLEXBH_MASK   0x03
-- 
2.5.0



[dpdk-dev] [PATCH v3 1/2] ethdev: add vlan type for setting ether type

2016-03-11 Thread Helin Zhang
In order to set ether type of VLAN for single VLAN, inner
and outer VLAN, the VLAN type as an input parameter is added
to 'rte_eth_dev_set_vlan_ether_type()'.
In addition, corresponding changes in e1000, ixgbe and i40e
are also added.

Signed-off-by: Helin Zhang 
---
 app/test-pmd/cmdline.c | 30 +++-
 app/test-pmd/config.c  |  9 ++---
 app/test-pmd/testpmd.h |  3 +-
 doc/guides/rel_notes/release_16_04.rst |  4 +++
 drivers/net/e1000/igb_ethdev.c | 21 +---
 drivers/net/i40e/i40e_ethdev.c | 63 +++---
 drivers/net/ixgbe/ixgbe_ethdev.c   | 19 +++---
 lib/librte_ether/rte_ethdev.c  | 25 --
 lib/librte_ether/rte_ethdev.h  | 23 +++--
 lib/librte_ether/rte_ether_version.map |  7 
 10 files changed, 173 insertions(+), 31 deletions(-)

v3:
 - Used versioning mechanism to avoid ABI issue.
 - re-organized the patch set.

v2:
 - Used RTE_NEXT_ABI to avoid ABI change issue.
 - Reworked the announcement of ABI change for release 16.07.

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 52e9f5f..1eeb8a8 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -277,8 +277,8 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the VLAN QinQ (extended queue in queue)"
" on a port.\n\n"

-   "vlan set tpid (value) (port_id)\n"
-   "Set the outer VLAN TPID for Packet Filtering on"
+   "vlan set (inner|outer) tpid (value) (port_id)\n"
+   "Set the VLAN TPID for Packet Filtering on"
" a port\n\n"

"rx_vlan add (vlan_id|all) (port_id)\n"
@@ -297,10 +297,6 @@ static void cmd_help_long_parsed(void *parsed_result,
"Remove a vlan_id, to the set of VLAN identifiers"
"filtered for VF(s) from port_id.\n\n"

-   "rx_vlan set tpid (value) (port_id)\n"
-   "Set the outer VLAN TPID for Packet Filtering on"
-   " a port\n\n"
-
"tunnel_filter add (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
"(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) 
(queue_id)\n"
"   add a tunnel filter of a port.\n\n"
@@ -2747,6 +2743,7 @@ cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
 struct cmd_vlan_offload_result {
cmdline_fixed_string_t vlan;
cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vlan_type;
cmdline_fixed_string_t what;
cmdline_fixed_string_t on;
cmdline_fixed_string_t port_id;
@@ -2847,6 +2844,7 @@ cmdline_parse_inst_t cmd_vlan_offload = {
 struct cmd_vlan_tpid_result {
cmdline_fixed_string_t vlan;
cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vlan_type;
cmdline_fixed_string_t what;
uint16_t tp_id;
uint8_t port_id;
@@ -2858,8 +2856,17 @@ cmd_vlan_tpid_parsed(void *parsed_result,
  __attribute__((unused)) void *data)
 {
struct cmd_vlan_tpid_result *res = parsed_result;
-   vlan_tpid_set(res->port_id, res->tp_id);
-   return;
+   enum rte_vlan_type vlan_type;
+
+   if (!strcmp(res->vlan_type, "inner"))
+   vlan_type = ETH_VLAN_TYPE_INNER;
+   else if (!strcmp(res->vlan_type, "outer"))
+   vlan_type = ETH_VLAN_TYPE_OUTER;
+   else {
+   printf("Unknown vlan type\n");
+   return;
+   }
+   vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
 }

 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
@@ -2868,6 +2875,9 @@ cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
 cmdline_parse_token_string_t cmd_vlan_tpid_set =
TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
 set, "set");
+cmdline_parse_token_string_t cmd_vlan_type =
+   TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
+vlan_type, "inner#outer");
 cmdline_parse_token_string_t cmd_vlan_tpid_what =
TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
 what, "tpid");
@@ -2881,10 +2891,12 @@ cmdline_parse_token_num_t cmd_vlan_tpid_portid =
 cmdline_parse_inst_t cmd_vlan_tpid = {
.f = cmd_vlan_tpid_parsed,
.data = NULL,
-   .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
+   .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
+   "Ether type",
.tokens = {

[dpdk-dev] [PATCH v3 0/2] i40e setting ether type of VLANs

2016-03-11 Thread Helin Zhang
It adds setting ether type of both single VLAN(inner VLAN) and
outer VLAN for i40e. For ixgbe and e1000/igb, it supports setting
single VLAN(inner VLAN) only, and can be extended in the future.

The patch set was branched off rel_16_04 of repo dpdk-next-net,
on below commit.
commit 5cfa5d194a8a45176e70af05719f7e3b136868be
Author: Zhe Tao 
Date:   Thu Mar 10 15:26:22 2016 +
ixgbe: fix ixgbevf RX/TX function assignment

v3:
 - Used versioning mechanism to avoid ABI issue.
 - re-organized the patch set.

v2:
 - Used RTE_NEXT_ABI to avoid ABI change issue.
 - Reworked the announcement of ABI change for release 16.07.
 - Fixed a i40e overflow issue.

Helin Zhang (2):
  ethdev: add vlan type for setting ether type
  i40e: fix the overflow issue

 app/test-pmd/cmdline.c | 30 +++-
 app/test-pmd/config.c  |  9 ++---
 app/test-pmd/testpmd.h |  3 +-
 doc/guides/rel_notes/release_16_04.rst |  4 +++
 drivers/net/e1000/igb_ethdev.c | 21 +---
 drivers/net/i40e/i40e_ethdev.c | 63 +++---
 drivers/net/i40e/i40e_rxtx.c   |  4 +--
 drivers/net/ixgbe/ixgbe_ethdev.c   | 19 +++---
 lib/librte_ether/rte_ethdev.c  | 25 --
 lib/librte_ether/rte_ethdev.h  | 23 +++--
 lib/librte_ether/rte_ether_version.map |  7 
 11 files changed, 175 insertions(+), 33 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v5 29/29] i40evf: use base driver defined interface

2016-03-08 Thread Helin Zhang
It removes the i40evf_set_mac_type() defined in PMD, and reuses
i40e_set_mac_type() defined in base driver.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/i40e_ethdev_vf.c | 22 +-
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index bd5c091..4fdbdf3 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -216,26 +216,6 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
.rss_hash_conf_get= i40evf_dev_rss_hash_conf_get,
 };

-static int
-i40evf_set_mac_type(struct i40e_hw *hw)
-{
-   int status = I40E_ERR_DEVICE_NOT_SUPPORTED;
-
-   if (hw->vendor_id == I40E_INTEL_VENDOR_ID) {
-   switch (hw->device_id) {
-   case I40E_DEV_ID_VF:
-   case I40E_DEV_ID_VF_HV:
-   hw->mac.type = I40E_MAC_VF;
-   status = I40E_SUCCESS;
-   break;
-   default:
-   ;
-   }
-   }
-
-   return status;
-}
-
 /*
  * Parse admin queue message.
  *
@@ -1183,7 +1163,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)

vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
vf->dev_data = dev->data;
-   err = i40evf_set_mac_type(hw);
+   err = i40e_set_mac_type(hw);
if (err) {
PMD_INIT_LOG(ERR, "set_mac_type failed: %d", err);
goto err;
-- 
2.5.0



[dpdk-dev] [PATCH v5 28/29] i40e: add base driver release info

2016-03-08 Thread Helin Zhang
It adds base driver release information such as release date,
for better tracking in the future.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 033ee4a..6dd6eaa 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -85,6 +85,7 @@ VPATH += $(SRCDIR)/base

 #
 # all source are stored in SRCS-y
+# base driver is based on the package of dpdk-i40e.2016.01.07.14.tar.gz.
 #
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_adminq.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_common.c
-- 
2.5.0



[dpdk-dev] [PATCH v5 27/29] i40e: update structure and macro definitions

2016-03-08 Thread Helin Zhang
Several structures and macros are added or updated, such
as 'struct i40e_aqc_get_link_status',
'struct i40e_aqc_run_phy_activity' and
'struct i40e_aqc_lldp_set_local_mib_resp'.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 doc/guides/rel_notes/release_16_04.rst  |  9 +++
 drivers/net/i40e/base/i40e_adminq_cmd.h | 45 ++---
 drivers/net/i40e/base/i40e_type.h   |  5 ++--
 drivers/net/i40e/i40e_ethdev.c  |  2 +-
 4 files changed, 53 insertions(+), 8 deletions(-)

v4:
 - Reworded the commit logs.
 - Moved new feature announcement in release notes to this patch.

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 165533f..8bda16c 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -74,6 +74,15 @@ This section should contain new features added in this 
release. Sample format:

 * **szedata2: Add functions for setting link up/down.**

+* **Updated the i40e base driver.**
+
+  The i40e base driver was updated with changes including the
+  following:
+
+  * Use rx control AQ commands to read/write rx control registers.
+  * Add new X722 device IDs, and removed X710 one was never used.
+  * Expose registers for HASH/FD input set configuring.
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 5236333..fe9d5b5 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
  */

 #define I40E_FW_API_VERSION_MAJOR  0x0001
-#define I40E_FW_API_VERSION_MINOR  0x0004
+#define I40E_FW_API_VERSION_MINOR  0x0005

 struct i40e_aq_desc {
__le16 flags;
@@ -242,6 +242,7 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_get_phy_wol_caps   = 0x0621,
i40e_aqc_opc_set_phy_debug  = 0x0622,
i40e_aqc_opc_upload_ext_phy_fm  = 0x0625,
+   i40e_aqc_opc_run_phy_activity   = 0x0626,

/* NVM commands */
i40e_aqc_opc_nvm_read   = 0x0701,
@@ -915,6 +916,10 @@ struct i40e_aqc_vsi_properties_data {
 I40E_AQ_VSI_TC_QUE_NUMBER_SHIFT)
/* queueing option section */
u8  queueing_opt_flags;
+#ifdef X722_SUPPORT
+#define I40E_AQ_VSI_QUE_OPT_MULTICAST_UDP_ENA  0x04
+#define I40E_AQ_VSI_QUE_OPT_UNICAST_UDP_ENA0x08
+#endif
 #define I40E_AQ_VSI_QUE_OPT_TCP_ENA0x10
 #define I40E_AQ_VSI_QUE_OPT_FCOE_ENA   0x20
 #ifdef X722_SUPPORT
@@ -1349,10 +1354,16 @@ struct i40e_aqc_add_remove_cloud_filters_element_data {

 #define I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT  9
 #define I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK   0x1E00
-#define I40E_AQC_ADD_CLOUD_TNL_TYPE_XVLAN  0
+#define I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN  0
 #define I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC 1
-#define I40E_AQC_ADD_CLOUD_TNL_TYPE_NGE2
+#define I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE 2
 #define I40E_AQC_ADD_CLOUD_TNL_TYPE_IP 3
+#define I40E_AQC_ADD_CLOUD_TNL_TYPE_RESERVED   4
+#define I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN_GPE  5
+
+#define I40E_AQC_ADD_CLOUD_FLAGS_SHARED_OUTER_MAC  0x2000
+#define I40E_AQC_ADD_CLOUD_FLAGS_SHARED_INNER_MAC  0x4000
+#define I40E_AQC_ADD_CLOUD_FLAGS_SHARED_OUTER_IP   0x8000

__le32  tenant_id;
u8  reserved[4];
@@ -1846,7 +1857,12 @@ struct i40e_aqc_get_link_status {
u8  config;
 #define I40E_AQ_CONFIG_CRC_ENA 0x04
 #define I40E_AQ_CONFIG_PACING_MASK 0x78
-   u8  reserved[5];
+   u8  external_power_ability;
+#define I40E_AQ_LINK_POWER_CLASS_1 0x00
+#define I40E_AQ_LINK_POWER_CLASS_2 0x01
+#define I40E_AQ_LINK_POWER_CLASS_3 0x02
+#define I40E_AQ_LINK_POWER_CLASS_4 0x03
+   u8  reserved[4];
 };

 I40E_CHECK_CMD_LENGTH(i40e_aqc_get_link_status);
@@ -1914,6 +1930,18 @@ enum i40e_aq_phy_reg_type {
I40E_AQC_PHY_REG_EXERNAL_MODULE = 0x3
 };

+/* Run PHY Activity (0x0626) */
+struct i40e_aqc_run_phy_activity {
+   __le16  activity_id;
+   u8  flags;
+   u8  reserved1;
+   __le32  control;
+   __le32  data;
+   u8  reserved2[4];
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_run_phy_activity);
+
 /* NVM Read command (indirect 0x0701)
  * NVM Erase commands (direct 0x0702)
  * NVM Update commands (indirect 0x0703)
@@ -2262,6 +2290,14 @@ struct i40e_aqc_lldp_set_local_mib {

 I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_set_local_mib);

+struct i40e_aqc_lldp_set_local_mib_resp {
+#define SET_LOCAL_MIB_RESP_EVENT_TRIGGERED_MASK  0x01
+   u8  status;
+   u8  reserved[15];
+};
+
+I40E_CHECK_STRUCT_LEN(0x10, i40e_aqc_lldp_set_local_mib_resp);
+
 /* Stop/Start LLDP Agent (direct 0x0A09)
  * Used for stopping/starting specific LLDP agent. e.g. DCBx

[dpdk-dev] [PATCH v5 26/29] i40e/base: add AQ thermal sensor control struct

2016-03-08 Thread Helin Zhang
It adds the new AQ command and struct for managing a
thermal sensor.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 12ebd35..5236333 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -250,6 +250,7 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_nvm_config_read= 0x0704,
i40e_aqc_opc_nvm_config_write   = 0x0705,
i40e_aqc_opc_oem_post_update= 0x0720,
+   i40e_aqc_opc_thermal_sensor = 0x0721,

/* virtualization commands */
i40e_aqc_opc_send_msg_to_pf = 0x0801,
@@ -2001,6 +2002,22 @@ struct i40e_aqc_nvm_oem_post_update_buffer {

 I40E_CHECK_STRUCT_LEN(0x28, i40e_aqc_nvm_oem_post_update_buffer);

+/* Thermal Sensor (indirect 0x0721)
+ * read or set thermal sensor configs and values
+ * takes a sensor and command specific data buffer, not detailed here
+ */
+struct i40e_aqc_thermal_sensor {
+   u8 sensor_action;
+#define I40E_AQ_THERMAL_SENSOR_READ_CONFIG 0
+#define I40E_AQ_THERMAL_SENSOR_SET_CONFIG  1
+#define I40E_AQ_THERMAL_SENSOR_READ_TEMP   2
+   u8 reserved[7];
+   __le32  addr_high;
+   __le32  addr_low;
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_thermal_sensor);
+
 /* Send to PF command (indirect 0x0801) id is only used by PF
  * Send to VF command (indirect 0x0802) id is only used by PF
  * Send to Peer PF command (indirect 0x0803)
-- 
2.5.0



[dpdk-dev] [PATCH v5 25/29] i40e/base: add a new Virtchnl offload

2016-03-08 Thread Helin Zhang
X722 supports Expanded version of TCP, UDP PCTYPES for RSS.
Add a Virtchnl offload to support this.
Without this patch VF drivers will not be able to support
the correct PCTYPES for X722 and UDP flows will not fan out.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_virtchnl.h | 1 +
 1 file changed, 1 insertion(+)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_virtchnl.h 
b/drivers/net/i40e/base/i40e_virtchnl.h
index 8106582..26208f3 100644
--- a/drivers/net/i40e/base/i40e_virtchnl.h
+++ b/drivers/net/i40e/base/i40e_virtchnl.h
@@ -163,6 +163,7 @@ struct i40e_virtchnl_vsi_resource {
 #define I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x0020
 #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN  0x0001
 #define I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING0x0002
+#define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x0004

 struct i40e_virtchnl_vf_resource {
u16 num_vsis;
-- 
2.5.0



[dpdk-dev] [PATCH v5 24/29] i40e: expose some registers

2016-03-08 Thread Helin Zhang
This patch adds 7 new register definitions for programming the
parser, flow director and RSS blocks in the HW.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_register.h | 48 +++
 drivers/net/i40e/i40e_ethdev.c| 11 ++--
 2 files changed, 50 insertions(+), 9 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_register.h 
b/drivers/net/i40e/base/i40e_register.h
index 6e56620..fd0a723 100644
--- a/drivers/net/i40e/base/i40e_register.h
+++ b/drivers/net/i40e/base/i40e_register.h
@@ -2056,6 +2056,14 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_PRTPM_TLPIC  0x001E43C0 /* Reset: GLOBR */
 #define I40E_PRTPM_TLPIC_ETLPIC_SHIFT 0
 #define I40E_PRTPM_TLPIC_ETLPIC_MASK  I40E_MASK(0x, 
I40E_PRTPM_TLPIC_ETLPIC_SHIFT)
+#define I40E_GL_PRS_FVBM(_i) (0x00269760 + ((_i) * 4)) /* 
_i=0...3 */ /* Reset: CORER */
+#define I40E_GL_PRS_FVBM_MAX_INDEX   3
+#define I40E_GL_PRS_FVBM_FV_BYTE_INDX_SHIFT  0
+#define I40E_GL_PRS_FVBM_FV_BYTE_INDX_MASK   I40E_MASK(0x7F, 
I40E_GL_PRS_FVBM_FV_BYTE_INDX_SHIFT)
+#define I40E_GL_PRS_FVBM_RULE_BUS_INDX_SHIFT 8
+#define I40E_GL_PRS_FVBM_RULE_BUS_INDX_MASK  I40E_MASK(0x3F, 
I40E_GL_PRS_FVBM_RULE_BUS_INDX_SHIFT)
+#define I40E_GL_PRS_FVBM_MSK_ENA_SHIFT   31
+#define I40E_GL_PRS_FVBM_MSK_ENA_MASKI40E_MASK(0x1, 
I40E_GL_PRS_FVBM_MSK_ENA_SHIFT)
 #define I40E_GLRPB_DPSS   0x000AC828 /* Reset: CORER */
 #define I40E_GLRPB_DPSS_DPS_TCN_SHIFT 0
 #define I40E_GLRPB_DPSS_DPS_TCN_MASK  I40E_MASK(0xF, 
I40E_GLRPB_DPSS_DPS_TCN_SHIFT)
@@ -2227,6 +2235,14 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_PRTQF_FD_FLXINSET_MAX_INDEX   63
 #define I40E_PRTQF_FD_FLXINSET_INSET_SHIFT 0
 #define I40E_PRTQF_FD_FLXINSET_INSET_MASK  I40E_MASK(0xFF, 
I40E_PRTQF_FD_FLXINSET_INSET_SHIFT)
+#define I40E_PRTQF_FD_INSET(_i, _j)  (0x0025 + ((_i) * 64 + (_j) * 
32)) /* _i=0...63, _j=0...1 */ /* Reset: CORER */
+#define I40E_PRTQF_FD_INSET_MAX_INDEX   63
+#define I40E_PRTQF_FD_INSET_INSET_SHIFT 0
+#define I40E_PRTQF_FD_INSET_INSET_MASK  I40E_MASK(0x, 
I40E_PRTQF_FD_INSET_INSET_SHIFT)
+#define I40E_PRTQF_FD_INSET(_i, _j)  (0x0025 + ((_i) * 64 + (_j) * 
32)) /* _i=0...63, _j=0...1 */ /* Reset: CORER */
+#define I40E_PRTQF_FD_INSET_MAX_INDEX   63
+#define I40E_PRTQF_FD_INSET_INSET_SHIFT 0
+#define I40E_PRTQF_FD_INSET_INSET_MASK  I40E_MASK(0x, 
I40E_PRTQF_FD_INSET_INSET_SHIFT)
 #define I40E_PRTQF_FD_MSK(_i, _j)   (0x00252000 + ((_i) * 64 + (_j) * 32)) 
/* _i=0...63, _j=0...1 */ /* Reset: CORER */
 #define I40E_PRTQF_FD_MSK_MAX_INDEX63
 #define I40E_PRTQF_FD_MSK_MASK_SHIFT   0
@@ -5169,6 +5185,38 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_GLQF_FD_PCTYPES_MAX_INDEX   63
 #define I40E_GLQF_FD_PCTYPES_FD_PCTYPE_SHIFT 0
 #define I40E_GLQF_FD_PCTYPES_FD_PCTYPE_MASK  I40E_MASK(0x3F, 
I40E_GLQF_FD_PCTYPES_FD_PCTYPE_SHIFT)
+#define I40E_GLQF_FD_MSK(_i, _j)   (0x00267200 + ((_i) * 4 + (_j) * 8)) /* 
_i=0...1, _j=0...63 */ /* Reset: CORER */
+#define I40E_GLQF_FD_MSK_MAX_INDEX1
+#define I40E_GLQF_FD_MSK_MASK_SHIFT   0
+#define I40E_GLQF_FD_MSK_MASK_MASKI40E_MASK(0x, 
I40E_GLQF_FD_MSK_MASK_SHIFT)
+#define I40E_GLQF_FD_MSK_OFFSET_SHIFT 16
+#define I40E_GLQF_FD_MSK_OFFSET_MASK  I40E_MASK(0x3F, 
I40E_GLQF_FD_MSK_OFFSET_SHIFT)
+#define I40E_GLQF_HASH_INSET(_i, _j)  (0x00267600 + ((_i) * 4 + (_j) * 8)) 
/* _i=0...1, _j=0...63 */ /* Reset: CORER */
+#define I40E_GLQF_HASH_INSET_MAX_INDEX   1
+#define I40E_GLQF_HASH_INSET_INSET_SHIFT 0
+#define I40E_GLQF_HASH_INSET_INSET_MASK  I40E_MASK(0x, 
I40E_GLQF_HASH_INSET_INSET_SHIFT)
+#define I40E_GLQF_HASH_MSK(_i, _j)   (0x00267A00 + ((_i) * 4 + (_j) * 8)) 
/* _i=0...1, _j=0...63 */ /* Reset: CORER */
+#define I40E_GLQF_HASH_MSK_MAX_INDEX1
+#define I40E_GLQF_HASH_MSK_MASK_SHIFT   0
+#define I40E_GLQF_HASH_MSK_MASK_MASKI40E_MASK(0x, 
I40E_GLQF_HASH_MSK_MASK_SHIFT)
+#define I40E_GLQF_HASH_MSK_OFFSET_SHIFT 16
+#define I40E_GLQF_HASH_MSK_OFFSET_MASK  I40E_MASK(0x3F, 
I40E_GLQF_HASH_MSK_OFFSET_SHIFT)
+#define I40E_GLQF_ORT(_i)   (0x00268900 + ((_i) * 4)) /* _i=0...63 
*/ /* Reset: CORER */
+#define I40E_GLQF_ORT_MAX_INDEX 63
+#define I40E_GLQF_ORT_PIT_INDX_SHIFT0
+#define I40E_GLQF_ORT_PIT_INDX_MASK I40E_MASK(0x1F, 
I40E_GLQF_ORT_PIT_INDX_SHIFT)
+#define I40E_GLQF_ORT_FIELD_CNT_SHIFT   5
+#define I40E_GLQF_ORT_FIELD_CNT_MASKI40E_MASK(0x3, 
I40E_GLQF_ORT_FIELD_CNT_SHIFT)
+#define I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT 7
+#define I40E_GLQF_ORT_FLX_PAYLOAD_MASK  I40E_MASK(0x1, 
I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT)
+#define I40E_GLQF_PIT(_i)  (0x00268C80 + ((_i) * 4)) /* _i=0...23 
*/ /* Reset: CORER */
+#define I40E_GLQF_PIT_MAX_INDEX23
+#define I40E_GLQF_PIT_SOURCE_OFF_SHIFT 0
+#define I40E_GLQF_PIT_SOURCE_OFF_MASK  I40E_MASK(0x1F, 
I40E_GLQF_PIT_SOURCE_OFF_SHIFT)
+#define I40E_GLQF_PIT_FSIZE_SHIFT  5

[dpdk-dev] [PATCH v5 23/29] i40e: use AQ rx control register read/write

2016-03-08 Thread Helin Zhang
RX control register read/write functions are added, as directly
read/write may fail when under stress small traffic. After the
adminq is ready, all rx control registers should be read/written
by dedicated functions.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 doc/guides/rel_notes/release_16_04.rst  |   6 ++
 drivers/net/i40e/base/i40e_adminq_cmd.h |  16 
 drivers/net/i40e/base/i40e_common.c | 126 +++-
 drivers/net/i40e/base/i40e_osdep.h  |  36 +
 drivers/net/i40e/base/i40e_prototype.h  |   8 ++
 drivers/net/i40e/i40e_ethdev.c  |  66 +
 drivers/net/i40e/i40e_ethdev_vf.c   |  28 +++
 drivers/net/i40e/i40e_fdir.c|  13 ++--
 drivers/net/i40e/i40e_pf.c  |   6 +-
 9 files changed, 248 insertions(+), 57 deletions(-)

v4:
 - Reworded the commit logs.
 - Merged all control register read/write code changes together.
 - Moved the annoucenment of fixes into this patch.

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 73494f9..165533f 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -137,6 +137,12 @@ Drivers

 * **vmxnet3: add TSO support.**

+* **i40e: Fixed failure of reading/writing rx control registers.**
+
+  Fixed i40e issue failing to read/write rx control registers when
+  under stress small traffic, which might result in application launch
+  failure.
+

 Libraries
 ~
diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 165df9b..12ebd35 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -165,6 +165,8 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_set_port_parameters= 0x0203,
i40e_aqc_opc_get_switch_resource_alloc  = 0x0204,
i40e_aqc_opc_set_switch_config  = 0x0205,
+   i40e_aqc_opc_rx_ctl_reg_read= 0x0206,
+   i40e_aqc_opc_rx_ctl_reg_write   = 0x0207,

i40e_aqc_opc_add_vsi= 0x0210,
i40e_aqc_opc_update_vsi_parameters  = 0x0211,
@@ -752,6 +754,20 @@ struct i40e_aqc_set_switch_config {

 I40E_CHECK_CMD_LENGTH(i40e_aqc_set_switch_config);

+/* Read Receive control registers  (direct 0x0206)
+ * Write Receive control registers (direct 0x0207)
+ * used for accessing Rx control registers that can be
+ * slow and need special handling when under high Rx load
+ */
+struct i40e_aqc_rx_ctl_reg_read_write {
+   __le32 reserved1;
+   __le32 address;
+   __le32 reserved2;
+   __le32 value;
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_rx_ctl_reg_read_write);
+
 /* Add VSI (indirect 0x0210)
  *this indirect command uses struct i40e_aqc_vsi_properties_data
  *as the indirect buffer (128 bytes)
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index e94f726..ef3425e 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5356,7 +5356,7 @@ enum i40e_status_code i40e_set_filter_control(struct 
i40e_hw *hw,
return ret;

/* Read the PF Queue Filter control register */
-   val = rd32(hw, I40E_PFQF_CTL_0);
+   val = i40e_read_rx_ctl(hw, I40E_PFQF_CTL_0);

/* Program required PE hash buckets for the PF */
val &= ~I40E_PFQF_CTL_0_PEHSIZE_MASK;
@@ -5393,7 +5393,7 @@ enum i40e_status_code i40e_set_filter_control(struct 
i40e_hw *hw,
if (settings->enable_macvlan)
val |= I40E_PFQF_CTL_0_MACVLAN_ENA_MASK;

-   wr32(hw, I40E_PFQF_CTL_0, val);
+   i40e_write_rx_ctl(hw, I40E_PFQF_CTL_0, val);

return I40E_SUCCESS;
 }
@@ -6317,6 +6317,128 @@ restore_config:
return status;
 }
 #endif /* PF_DRIVER */
+
+/**
+ * i40e_aq_rx_ctl_read_register - use FW to read from an Rx control register
+ * @hw: pointer to the hw struct
+ * @reg_addr: register address
+ * @reg_val: ptr to register value
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Use the firmware to read the Rx control register,
+ * especially useful if the Rx unit is under heavy pressure
+ **/
+enum i40e_status_code i40e_aq_rx_ctl_read_register(struct i40e_hw *hw,
+   u32 reg_addr, u32 *reg_val,
+   struct i40e_asq_cmd_details *cmd_details)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_rx_ctl_reg_read_write *cmd_resp =
+   (struct i40e_aqc_rx_ctl_reg_read_write *)
+   enum i40e_status_code status;
+
+   if (reg_val == NULL)
+   return I40E_ERR_PARAM;
+
+   i40e_fill_default_direct_cmd_desc(, i40e_aqc_opc_rx_ctl_reg_read);
+
+   cmd_resp->address = CPU_TO_LE32(reg_addr);
+
+   status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
+
+   if (status == I40E_SUCCESS)
+   *reg_val = LE32_TO_CPU(cmd_r

[dpdk-dev] [PATCH v5 22/29] i40e/base: coding style fixes

2016-03-08 Thread Helin Zhang
It adds coding style fixes.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 9a0b787..e94f726 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -1540,9 +1540,11 @@ u32 i40e_led_get(struct i40e_hw *hw)
if (!gpio_val)
continue;

-   /* ignore gpio LED src mode entries related to the activity 
LEDs */
-   current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) 
>>
-   I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
+   /* ignore gpio LED src mode entries related to the activity
+*  LEDs
+*/
+   current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK)
+   >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
switch (current_mode) {
case I40E_COMBINED_ACTIVITY:
case I40E_FILTER_ACTIVITY:
@@ -1586,9 +1588,11 @@ void i40e_led_set(struct i40e_hw *hw, u32 mode, bool 
blink)
if (!gpio_val)
continue;

-   /* ignore gpio LED src mode entries related to the activity 
LEDs */
-   current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) 
>>
-   I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
+   /* ignore gpio LED src mode entries related to the activity
+* LEDs
+*/
+   current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK)
+   >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
switch (current_mode) {
case I40E_COMBINED_ACTIVITY:
case I40E_FILTER_ACTIVITY:
@@ -2821,6 +2825,7 @@ enum i40e_status_code i40e_aq_get_veb_parameters(struct 
i40e_hw *hw,
*vebs_free = LE16_TO_CPU(cmd_resp->vebs_free);
if (floating) {
u16 flags = LE16_TO_CPU(cmd_resp->veb_flags);
+
if (flags & I40E_AQC_ADD_VEB_FLOATING)
*floating = true;
else
@@ -5471,7 +5476,7 @@ void 
i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
u16 ethtype = I40E_FLOW_CONTROL_ETHTYPE;
enum i40e_status_code status;

-   status = i40e_aq_add_rem_control_packet_filter(hw, 0, ethtype, flag,
+   status = i40e_aq_add_rem_control_packet_filter(hw, NULL, ethtype, flag,
   seid, 0, true, NULL,
   NULL);
if (status)
-- 
2.5.0



[dpdk-dev] [PATCH v5 21/29] i40e/base: save off VSI resource count

2016-03-08 Thread Helin Zhang
When updating a VSI, save off the number of allocated and
unallocated VSIs as we do when adding a VSI.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 6 ++
 1 file changed, 6 insertions(+)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 925bb1c..9a0b787 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2467,6 +2467,9 @@ enum i40e_status_code i40e_aq_update_vsi_params(struct 
i40e_hw *hw,
struct i40e_aq_desc desc;
struct i40e_aqc_add_get_update_vsi *cmd =
(struct i40e_aqc_add_get_update_vsi *)
+   struct i40e_aqc_add_get_update_vsi_completion *resp =
+   (struct i40e_aqc_add_get_update_vsi_completion *)
+   
enum i40e_status_code status;

i40e_fill_default_direct_cmd_desc(,
@@ -2478,6 +2481,9 @@ enum i40e_status_code i40e_aq_update_vsi_params(struct 
i40e_hw *hw,
status = i40e_asq_send_command(hw, , _ctx->info,
sizeof(vsi_ctx->info), cmd_details);

+   vsi_ctx->vsis_allocated = LE16_TO_CPU(resp->vsi_used);
+   vsi_ctx->vsis_unallocated = LE16_TO_CPU(resp->vsi_free);
+
return status;
 }

-- 
2.5.0



[dpdk-dev] [PATCH v5 20/29] i40e/base: fix driver load failure

2016-03-08 Thread Helin Zhang
It fixes the driver load failure with linking with particular
PHY types, as the amount of time it takes for the
GLGEN_RSTAT_DEVSTATE to be set increases greatly on those PHY
types, which can lead to a timeout.

Fixes: 9aeefed05538 ("i40e/base: support ESS")

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index a4cf5cf..925bb1c 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -1316,11 +1316,11 @@ enum i40e_status_code i40e_pf_reset(struct i40e_hw *hw)
grst_del = (rd32(hw, I40E_GLGEN_RSTCTL) &
I40E_GLGEN_RSTCTL_GRSTDEL_MASK) >>
I40E_GLGEN_RSTCTL_GRSTDEL_SHIFT;
-#ifdef I40E_ESS_SUPPORT
+
/* It can take upto 15 secs for GRST steady state */
grst_del = grst_del * 20; /* bump it to 16 secs max to be safe */
-#endif
-   for (cnt = 0; cnt < grst_del + 10; cnt++) {
+
+   for (cnt = 0; cnt < grst_del; cnt++) {
reg = rd32(hw, I40E_GLGEN_RSTAT);
if (!(reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK))
break;
-- 
2.5.0



[dpdk-dev] [PATCH v5 19/29] i40e/base: apply promisc mode to Tx Traffic

2016-03-08 Thread Helin Zhang
In Multi-Function Mode (MFP) mode particularly when it sets the PF
VSI in limited promiscuous, the HW switch was still mirroring the
outgoing packets from other VSIs (VF/VMdq) onto the PF VSI.
It sets a new bit to avoid above mirroring, and it is in limited
promiscuous on the PF VSI in MFP which is similar to default port
VSI.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 1 +
 drivers/net/i40e/base/i40e_common.c | 9 -
 2 files changed, 9 insertions(+), 1 deletion(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index c84e0ec..165df9b 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -1143,6 +1143,7 @@ struct i40e_aqc_set_vsi_promiscuous_modes {
 #define I40E_AQC_SET_VSI_PROMISC_BROADCAST 0x04
 #define I40E_AQC_SET_VSI_DEFAULT   0x08
 #define I40E_AQC_SET_VSI_PROMISC_VLAN  0x10
+#define I40E_AQC_SET_VSI_PROMISC_TX0x8000
__le16  seid;
 #define I40E_AQC_VSI_PROM_CMD_SEID_MASK0x3FF
__le16  vlan_tag;
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 2383153..a4cf5cf 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2225,12 +2225,19 @@ enum i40e_status_code 
i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
i40e_fill_default_direct_cmd_desc(,
i40e_aqc_opc_set_vsi_promiscuous_modes);

-   if (set)
+   if (set) {
flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
+   if (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
+(hw->aq.api_maj_ver > 1))
+   flags |= I40E_AQC_SET_VSI_PROMISC_TX;
+   }

cmd->promiscuous_flags = CPU_TO_LE16(flags);

cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
+   if (((hw->aq.api_maj_ver >= 1) && (hw->aq.api_min_ver >= 5)) ||
+(hw->aq.api_maj_ver > 1))
+   cmd->valid_flags |= CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_TX);

cmd->seid = CPU_TO_LE16(seid);
status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
-- 
2.5.0



[dpdk-dev] [PATCH v5 18/29] i40e/base: add functions to blink led

2016-03-08 Thread Helin Zhang
This patch adds functions to blink led on devices using a new
PHY since MAC registers used in other designs do not work in
this device configuration.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c| 329 +
 drivers/net/i40e/base/i40e_prototype.h |  13 ++
 drivers/net/i40e/base/i40e_type.h  |  16 ++
 3 files changed, 358 insertions(+)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index c800fd8..2383153 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5969,6 +5969,335 @@ enum i40e_status_code 
i40e_aq_configure_partition_bw(struct i40e_hw *hw,

return status;
 }
+
+/**
+ * i40e_read_phy_register
+ * @hw: pointer to the HW structure
+ * @page: registers page number
+ * @reg: register address in the page
+ * @phy_adr: PHY address on MDIO interface
+ * @value: PHY register value
+ *
+ * Reads specified PHY register value
+ **/
+enum i40e_status_code i40e_read_phy_register(struct i40e_hw *hw,
+u8 page, u16 reg, u8 phy_addr,
+u16 *value)
+{
+   enum i40e_status_code status = I40E_ERR_TIMEOUT;
+   u32 command  = 0;
+   u16 retry = 1000;
+   u8 port_num = (u8)hw->func_caps.mdio_port_num;
+
+   command = (reg << I40E_GLGEN_MSCA_MDIADD_SHIFT) |
+ (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) |
+ (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) |
+ (I40E_MDIO_OPCODE_ADDRESS) |
+ (I40E_MDIO_STCODE) |
+ (I40E_GLGEN_MSCA_MDICMD_MASK) |
+ (I40E_GLGEN_MSCA_MDIINPROGEN_MASK);
+   wr32(hw, I40E_GLGEN_MSCA(port_num), command);
+   do {
+   command = rd32(hw, I40E_GLGEN_MSCA(port_num));
+   if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) {
+   status = I40E_SUCCESS;
+   break;
+   }
+   i40e_usec_delay(10);
+   retry--;
+   } while (retry);
+
+   if (status) {
+   i40e_debug(hw, I40E_DEBUG_PHY,
+  "PHY: Can't write command to external PHY.\n");
+   goto phy_read_end;
+   }
+
+   command = (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) |
+ (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) |
+ (I40E_MDIO_OPCODE_READ) |
+ (I40E_MDIO_STCODE) |
+ (I40E_GLGEN_MSCA_MDICMD_MASK) |
+ (I40E_GLGEN_MSCA_MDIINPROGEN_MASK);
+   status = I40E_ERR_TIMEOUT;
+   retry = 1000;
+   wr32(hw, I40E_GLGEN_MSCA(port_num), command);
+   do {
+   command = rd32(hw, I40E_GLGEN_MSCA(port_num));
+   if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) {
+   status = I40E_SUCCESS;
+   break;
+   }
+   i40e_usec_delay(10);
+   retry--;
+   } while (retry);
+
+   if (!status) {
+   command = rd32(hw, I40E_GLGEN_MSRWD(port_num));
+   *value = (command & I40E_GLGEN_MSRWD_MDIRDDATA_MASK) >>
+I40E_GLGEN_MSRWD_MDIRDDATA_SHIFT;
+   } else {
+   i40e_debug(hw, I40E_DEBUG_PHY,
+  "PHY: Can't read register value from external 
PHY.\n");
+   }
+
+phy_read_end:
+   return status;
+}
+
+/**
+ * i40e_write_phy_register
+ * @hw: pointer to the HW structure
+ * @page: registers page number
+ * @reg: register address in the page
+ * @phy_adr: PHY address on MDIO interface
+ * @value: PHY register value
+ *
+ * Writes value to specified PHY register
+ **/
+enum i40e_status_code i40e_write_phy_register(struct i40e_hw *hw,
+ u8 page, u16 reg, u8 phy_addr,
+ u16 value)
+{
+   enum i40e_status_code status = I40E_ERR_TIMEOUT;
+   u32 command  = 0;
+   u16 retry = 1000;
+   u8 port_num = (u8)hw->func_caps.mdio_port_num;
+
+   command = (reg << I40E_GLGEN_MSCA_MDIADD_SHIFT) |
+ (page << I40E_GLGEN_MSCA_DEVADD_SHIFT) |
+ (phy_addr << I40E_GLGEN_MSCA_PHYADD_SHIFT) |
+ (I40E_MDIO_OPCODE_ADDRESS) |
+ (I40E_MDIO_STCODE) |
+ (I40E_GLGEN_MSCA_MDICMD_MASK) |
+ (I40E_GLGEN_MSCA_MDIINPROGEN_MASK);
+   wr32(hw, I40E_GLGEN_MSCA(port_num), command);
+   do {
+   command = rd32(hw, I40E_GLGEN_MSCA(port_num));
+   if (!(command & I40E_GLGEN_MSCA_MDICMD_MASK)) {
+   status = I40E_SUCCESS;
+   break;
+   }
+   i40e_usec_delay(10);
+   retry

[dpdk-dev] [PATCH v5 17/29] i40e/base: implement new API function

2016-03-08 Thread Helin Zhang
Add the support code for calling the AdminQ API call
aq_set_switch_config.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 12 
 drivers/net/i40e/base/i40e_common.c | 28 
 drivers/net/i40e/base/i40e_prototype.h  |  3 +++
 3 files changed, 43 insertions(+)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 6ec29a0..c84e0ec 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -164,6 +164,7 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_remove_statistics  = 0x0202,
i40e_aqc_opc_set_port_parameters= 0x0203,
i40e_aqc_opc_get_switch_resource_alloc  = 0x0204,
+   i40e_aqc_opc_set_switch_config  = 0x0205,

i40e_aqc_opc_add_vsi= 0x0210,
i40e_aqc_opc_update_vsi_parameters  = 0x0211,
@@ -740,6 +741,17 @@ struct i40e_aqc_switch_resource_alloc_element_resp {

 I40E_CHECK_STRUCT_LEN(0x10, i40e_aqc_switch_resource_alloc_element_resp);

+/* Set Switch Configuration (direct 0x0205) */
+struct i40e_aqc_set_switch_config {
+   __le16  flags;
+#define I40E_AQ_SET_SWITCH_CFG_PROMISC 0x0001
+#define I40E_AQ_SET_SWITCH_CFG_L2_FILTER   0x0002
+   __le16  valid_flags;
+   u8  reserved[12];
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_set_switch_config);
+
 /* Add VSI (indirect 0x0210)
  *this indirect command uses struct i40e_aqc_vsi_properties_data
  *as the indirect buffer (128 bytes)
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index fdd4de7..c800fd8 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2508,6 +2508,34 @@ enum i40e_status_code i40e_aq_get_switch_config(struct 
i40e_hw *hw,
 }

 /**
+ * i40e_aq_set_switch_config
+ * @hw: pointer to the hardware structure
+ * @flags: bit flag values to set
+ * @valid_flags: which bit flags to set
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Set switch configuration bits
+ **/
+enum i40e_status_code i40e_aq_set_switch_config(struct i40e_hw *hw,
+   u16 flags, u16 valid_flags,
+   struct i40e_asq_cmd_details *cmd_details)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_set_switch_config *scfg =
+   (struct i40e_aqc_set_switch_config *)
+   enum i40e_status_code status;
+
+   i40e_fill_default_direct_cmd_desc(,
+ i40e_aqc_opc_set_switch_config);
+   scfg->flags = CPU_TO_LE16(flags);
+   scfg->valid_flags = CPU_TO_LE16(valid_flags);
+
+   status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
+
+   return status;
+}
+
+/**
  * i40e_aq_get_firmware_version
  * @hw: pointer to the hw struct
  * @fw_major_version: firmware major version
diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index 81ccc96..cbe9961 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -215,6 +215,9 @@ enum i40e_status_code i40e_aq_get_switch_config(struct 
i40e_hw *hw,
struct i40e_aqc_get_switch_config_resp *buf,
u16 buf_size, u16 *start_seid,
struct i40e_asq_cmd_details *cmd_details);
+enum i40e_status_code i40e_aq_set_switch_config(struct i40e_hw *hw,
+   u16 flags, u16 valid_flags,
+   struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_request_resource(struct i40e_hw *hw,
enum i40e_aq_resources_ids resource,
enum i40e_aq_resource_access_type access,
-- 
2.5.0



[dpdk-dev] [PATCH v5 16/29] i40e: add VEB stat control

2016-03-08 Thread Helin Zhang
With the latest firmware, statistics gathering can now be enabled and
disabled in the HW switch, so we need to add a parameter to allow the
driver to set it as desired. At the same time, the L2 cloud filtering
parameter has been removed as it was never used.
Older drivers working with the newer firmware and newer drivers working
with older firmware will not run into problems with these bits as the
defaults are reasonable and there is no overlap in the bit definitions.
Also, newer drivers will be forced to update because of the change in
function call parameters, a reminder that the functionality exists.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h |  3 ++-
 drivers/net/i40e/base/i40e_common.c | 11 ++-
 drivers/net/i40e/base/i40e_prototype.h  |  4 ++--
 drivers/net/i40e/i40e_ethdev.c  |  2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index cd55a36..6ec29a0 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -966,7 +966,8 @@ struct i40e_aqc_add_veb {
I40E_AQC_ADD_VEB_PORT_TYPE_SHIFT)
 #define I40E_AQC_ADD_VEB_PORT_TYPE_DEFAULT 0x2
 #define I40E_AQC_ADD_VEB_PORT_TYPE_DATA0x4
-#define I40E_AQC_ADD_VEB_ENABLE_L2_FILTER  0x8
+#define I40E_AQC_ADD_VEB_ENABLE_L2_FILTER  0x8 /* deprecated */
+#define I40E_AQC_ADD_VEB_ENABLE_DISABLE_STATS  0x10
u8  enable_tcs;
u8  reserved[9];
 };
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index b1d063f..fdd4de7 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2682,8 +2682,8 @@ i40e_link_speed_exit:
  * @downlink_seid: the VSI SEID
  * @enabled_tc: bitmap of TCs to be enabled
  * @default_port: true for default port VSI, false for control port
- * @enable_l2_filtering: true to add L2 filter table rules to regular 
forwarding rules for cloud support
  * @veb_seid: pointer to where to put the resulting VEB SEID
+ * @enable_stats: true to turn on VEB stats
  * @cmd_details: pointer to command details structure or NULL
  *
  * This asks the FW to add a VEB between the uplink and downlink
@@ -2691,8 +2691,8 @@ i40e_link_speed_exit:
  **/
 enum i40e_status_code i40e_aq_add_veb(struct i40e_hw *hw, u16 uplink_seid,
u16 downlink_seid, u8 enabled_tc,
-   bool default_port, bool enable_l2_filtering,
-   u16 *veb_seid,
+   bool default_port, u16 *veb_seid,
+   bool enable_stats,
struct i40e_asq_cmd_details *cmd_details)
 {
struct i40e_aq_desc desc;
@@ -2719,8 +2719,9 @@ enum i40e_status_code i40e_aq_add_veb(struct i40e_hw *hw, 
u16 uplink_seid,
else
veb_flags |= I40E_AQC_ADD_VEB_PORT_TYPE_DATA;

-   if (enable_l2_filtering)
-   veb_flags |= I40E_AQC_ADD_VEB_ENABLE_L2_FILTER;
+   /* reverse logic here: set the bitflag to disable the stats */
+   if (!enable_stats)
+   veb_flags |= I40E_AQC_ADD_VEB_ENABLE_DISABLE_STATS;

cmd->veb_flags = CPU_TO_LE16(veb_flags);

diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index b5b8935..81ccc96 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -179,8 +179,8 @@ enum i40e_status_code i40e_aq_update_vsi_params(struct 
i40e_hw *hw,
struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_add_veb(struct i40e_hw *hw, u16 uplink_seid,
u16 downlink_seid, u8 enabled_tc,
-   bool default_port, bool enable_l2_filtering,
-   u16 *pveb_seid,
+   bool default_port, u16 *pveb_seid,
+   bool enable_stats,
struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_get_veb_parameters(struct i40e_hw *hw,
u16 veb_seid, u16 *switch_id, bool *floating,
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index c86febc..00fdc0a 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3646,7 +3646,7 @@ i40e_veb_setup(struct i40e_pf *pf, struct i40e_vsi *vsi)
veb->uplink_seid = vsi->uplink_seid;

ret = i40e_aq_add_veb(hw, veb->uplink_seid, vsi->seid,
-   I40E_DEFAULT_TCMAP, false, false, >seid, NULL);
+   I40E_DEFAULT_TCMAP, false, >seid, false, NULL);

if (ret != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, &q

[dpdk-dev] [PATCH v5 15/29] i40e/base: support operating port mirroring rules

2016-03-08 Thread Helin Zhang
This patch implements necessary functions related to port
mirroring features such as add/delete mirror rule, function
to set promiscuous VLAN mode for VSI if mirror rule_type is
"VLAN Mirroring".

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c| 162 +
 drivers/net/i40e/base/i40e_prototype.h |  12 +++
 2 files changed, 174 insertions(+)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 44855b3..b1d063f 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2374,6 +2374,37 @@ enum i40e_status_code i40e_aq_set_vsi_broadcast(struct 
i40e_hw *hw,
 }

 /**
+ * i40e_aq_set_vsi_vlan_promisc - control the VLAN promiscuous setting
+ * @hw: pointer to the hw struct
+ * @seid: vsi number
+ * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given 
VLAN
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum i40e_status_code i40e_aq_set_vsi_vlan_promisc(struct i40e_hw *hw,
+   u16 seid, bool enable,
+   struct i40e_asq_cmd_details *cmd_details)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_set_vsi_promiscuous_modes *cmd =
+   (struct i40e_aqc_set_vsi_promiscuous_modes *)
+   enum i40e_status_code status;
+   u16 flags = 0;
+
+   i40e_fill_default_direct_cmd_desc(,
+   i40e_aqc_opc_set_vsi_promiscuous_modes);
+   if (enable)
+   flags |= I40E_AQC_SET_VSI_PROMISC_VLAN;
+
+   cmd->promiscuous_flags = CPU_TO_LE16(flags);
+   cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_VLAN);
+   cmd->seid = CPU_TO_LE16(seid);
+
+   status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
+
+   return status;
+}
+
+/**
  * i40e_get_vsi_params - get VSI configuration info
  * @hw: pointer to the hw struct
  * @vsi_ctx: pointer to a vsi context struct
@@ -2849,6 +2880,137 @@ enum i40e_status_code i40e_aq_remove_macvlan(struct 
i40e_hw *hw, u16 seid,
 }

 /**
+ * i40e_mirrorrule_op - Internal helper function to add/delete mirror rule
+ * @hw: pointer to the hw struct
+ * @opcode: AQ opcode for add or delete mirror rule
+ * @sw_seid: Switch SEID (to which rule refers)
+ * @rule_type: Rule Type (ingress/egress/VLAN)
+ * @id: Destination VSI SEID or Rule ID
+ * @count: length of the list
+ * @mr_list: list of mirrored VSI SEIDs or VLAN IDs
+ * @cmd_details: pointer to command details structure or NULL
+ * @rule_id: Rule ID returned from FW
+ * @rule_used: Number of rules used in internal switch
+ * @rule_free: Number of rules free in internal switch
+ *
+ * Add/Delete a mirror rule to a specific switch. Mirror rules are supported 
for
+ * VEBs/VEPA elements only
+ **/
+static enum i40e_status_code i40e_mirrorrule_op(struct i40e_hw *hw,
+   u16 opcode, u16 sw_seid, u16 rule_type, u16 id,
+   u16 count, __le16 *mr_list,
+   struct i40e_asq_cmd_details *cmd_details,
+   u16 *rule_id, u16 *rules_used, u16 *rules_free)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_add_delete_mirror_rule *cmd =
+   (struct i40e_aqc_add_delete_mirror_rule *)
+   struct i40e_aqc_add_delete_mirror_rule_completion *resp =
+   (struct i40e_aqc_add_delete_mirror_rule_completion *)
+   enum i40e_status_code status;
+   u16 buf_size;
+
+   buf_size = count * sizeof(*mr_list);
+
+   /* prep the rest of the request */
+   i40e_fill_default_direct_cmd_desc(, opcode);
+   cmd->seid = CPU_TO_LE16(sw_seid);
+   cmd->rule_type = CPU_TO_LE16(rule_type &
+I40E_AQC_MIRROR_RULE_TYPE_MASK);
+   cmd->num_entries = CPU_TO_LE16(count);
+   /* Dest VSI for add, rule_id for delete */
+   cmd->destination = CPU_TO_LE16(id);
+   if (mr_list) {
+   desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF |
+   I40E_AQ_FLAG_RD));
+   if (buf_size > I40E_AQ_LARGE_BUF)
+   desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
+   }
+
+   status = i40e_asq_send_command(hw, , mr_list, buf_size,
+  cmd_details);
+   if (status == I40E_SUCCESS ||
+   hw->aq.asq_last_status == I40E_AQ_RC_ENOSPC) {
+   if (rule_id)
+   *rule_id = LE16_TO_CPU(resp->rule_id);
+   if (rules_used)
+   *rules_used = LE16_TO_CPU(resp->mirror_rules_used);
+   if (rules_free)
+   *rules_free = LE16_TO_CPU(resp->mirror_rules_free);
+   }
+   return status;
+}
+
+/**
+ * i40e_aq_add_mirrorrule - add a mirror rule
+ * @hw: pointer to the hw stru

[dpdk-dev] [PATCH v5 14/29] i40e/base: set shared bit for multicast filters

2016-03-08 Thread Helin Zhang
It adds the use of the new shared MAC filter bit for multicast
and broadcast filters in order to make better use of the
filters available from the device.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 1 +
 drivers/net/i40e/base/i40e_common.c | 8 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index aa11bcd..cd55a36 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -1033,6 +1033,7 @@ struct i40e_aqc_add_macvlan_element_data {
 #define I40E_AQC_MACVLAN_ADD_HASH_MATCH0x0002
 #define I40E_AQC_MACVLAN_ADD_IGNORE_VLAN   0x0004
 #define I40E_AQC_MACVLAN_ADD_TO_QUEUE  0x0008
+#define I40E_AQC_MACVLAN_ADD_USE_SHARED_MAC0x0010
__le16  queue_number;
 #define I40E_AQC_MACVLAN_CMD_QUEUE_SHIFT   0
 #define I40E_AQC_MACVLAN_CMD_QUEUE_MASK(0x7FF << \
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index cc8a63e..44855b3 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2777,6 +2777,7 @@ enum i40e_status_code i40e_aq_add_macvlan(struct i40e_hw 
*hw, u16 seid,
(struct i40e_aqc_macvlan *)
enum i40e_status_code status;
u16 buf_size;
+   int i;

if (count == 0 || !mv_list || !hw)
return I40E_ERR_PARAM;
@@ -2790,12 +2791,17 @@ enum i40e_status_code i40e_aq_add_macvlan(struct 
i40e_hw *hw, u16 seid,
cmd->seid[1] = 0;
cmd->seid[2] = 0;

+   for (i = 0; i < count; i++)
+   if (I40E_IS_MULTICAST(mv_list[i].mac_addr))
+   mv_list[i].flags |=
+   CPU_TO_LE16(I40E_AQC_MACVLAN_ADD_USE_SHARED_MAC);
+
desc.flags |= CPU_TO_LE16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
if (buf_size > I40E_AQ_LARGE_BUF)
desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);

status = i40e_asq_send_command(hw, , mv_list, buf_size,
-   cmd_details);
+  cmd_details);

return status;
 }
-- 
2.5.0



[dpdk-dev] [PATCH v5 13/29] i40e/base: fix for PHY NVM interaction problem

2016-03-08 Thread Helin Zhang
This patch fixes a problem where the NVMUpdate Tool, when
using the PHY NVM feature, gets bad data from the PHY because
of contention on the MDIO interface from get phy capability
calls from the driver during regular operations. The problem
is fixed by adding a check if media is available before calling
get phy capability function because that bit is not set when
device is in PHY interaction mode.

Fixes: 842ea1996335 ("i40e/base: save link module type")

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 8d2f2c7..cc8a63e 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2607,17 +2607,19 @@ enum i40e_status_code i40e_update_link_info(struct 
i40e_hw *hw)
if (status)
return status;

-   status = i40e_aq_get_phy_capabilities(hw, false, false, ,
- NULL);
-   if (status)
-   return status;
-
-   memcpy(hw->phy.link_info.module_type, _type,
-   sizeof(hw->phy.link_info.module_type));
+   if (hw->phy.link_info.link_info & I40E_AQ_MEDIA_AVAILABLE) {
+   status = i40e_aq_get_phy_capabilities(hw, false, false,
+ , NULL);
+   if (status)
+   return status;

+   memcpy(hw->phy.link_info.module_type, _type,
+   sizeof(hw->phy.link_info.module_type));
+   }
return status;
 }

+
 /**
  * i40e_get_link_speed
  * @hw: pointer to the hw struct
-- 
2.5.0



[dpdk-dev] [PATCH v5 12/29] i40e/base: unify the capability function

2016-03-08 Thread Helin Zhang
The device capabilities were defined in two places, and neither had
all the definitions. It really belongs with the AQ API definition,
so this patch removes the other set of definitions and fills out the
missing item.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h |   1 +
 drivers/net/i40e/base/i40e_common.c | 191 ++--
 2 files changed, 131 insertions(+), 61 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index ff6449c..aa11bcd 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -444,6 +444,7 @@ struct i40e_aqc_list_capabilities_element_resp {
 #define I40E_AQ_CAP_ID_LED 0x0061
 #define I40E_AQ_CAP_ID_SDP 0x0062
 #define I40E_AQ_CAP_ID_MDIO0x0063
+#define I40E_AQ_CAP_ID_WSR_PROT0x0064
 #define I40E_AQ_CAP_ID_FLEX10  0x00F1
 #define I40E_AQ_CAP_ID_CEM 0x00F2

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index cfe071b..8d2f2c7 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3342,38 +3342,6 @@ i40e_aq_erase_nvm_exit:
return status;
 }

-#define I40E_DEV_FUNC_CAP_SWITCH_MODE  0x01
-#define I40E_DEV_FUNC_CAP_MGMT_MODE0x02
-#define I40E_DEV_FUNC_CAP_NPAR 0x03
-#define I40E_DEV_FUNC_CAP_OS2BMC   0x04
-#define I40E_DEV_FUNC_CAP_VALID_FUNC   0x05
-#ifdef X722_SUPPORT
-#define I40E_DEV_FUNC_CAP_WOL_PROXY0x08
-#endif
-#define I40E_DEV_FUNC_CAP_SRIOV_1_10x12
-#define I40E_DEV_FUNC_CAP_VF   0x13
-#define I40E_DEV_FUNC_CAP_VMDQ 0x14
-#define I40E_DEV_FUNC_CAP_802_1_QBG0x15
-#define I40E_DEV_FUNC_CAP_802_1_QBH0x16
-#define I40E_DEV_FUNC_CAP_VSI  0x17
-#define I40E_DEV_FUNC_CAP_DCB  0x18
-#define I40E_DEV_FUNC_CAP_FCOE 0x21
-#define I40E_DEV_FUNC_CAP_ISCSI0x22
-#define I40E_DEV_FUNC_CAP_RSS  0x40
-#define I40E_DEV_FUNC_CAP_RX_QUEUES0x41
-#define I40E_DEV_FUNC_CAP_TX_QUEUES0x42
-#define I40E_DEV_FUNC_CAP_MSIX 0x43
-#define I40E_DEV_FUNC_CAP_MSIX_VF  0x44
-#define I40E_DEV_FUNC_CAP_FLOW_DIRECTOR0x45
-#define I40E_DEV_FUNC_CAP_IEEE_15880x46
-#define I40E_DEV_FUNC_CAP_FLEX10   0xF1
-#define I40E_DEV_FUNC_CAP_CEM  0xF2
-#define I40E_DEV_FUNC_CAP_IWARP0x51
-#define I40E_DEV_FUNC_CAP_LED  0x61
-#define I40E_DEV_FUNC_CAP_SDP  0x62
-#define I40E_DEV_FUNC_CAP_MDIO 0x63
-#define I40E_DEV_FUNC_CAP_WR_CSR_PROT  0x64
-
 /**
  * i40e_parse_discover_capabilities
  * @hw: pointer to the hw struct
@@ -3412,79 +3380,146 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
major_rev = cap->major_rev;

switch (id) {
-   case I40E_DEV_FUNC_CAP_SWITCH_MODE:
+   case I40E_AQ_CAP_ID_SWITCH_MODE:
p->switch_mode = number;
+   i40e_debug(hw, I40E_DEBUG_INIT,
+  "HW Capability: Switch mode = %d\n",
+  p->switch_mode);
break;
-   case I40E_DEV_FUNC_CAP_MGMT_MODE:
+   case I40E_AQ_CAP_ID_MNG_MODE:
p->management_mode = number;
+   i40e_debug(hw, I40E_DEBUG_INIT,
+  "HW Capability: Management Mode = %d\n",
+  p->management_mode);
break;
-   case I40E_DEV_FUNC_CAP_NPAR:
+   case I40E_AQ_CAP_ID_NPAR_ACTIVE:
p->npar_enable = number;
+   i40e_debug(hw, I40E_DEBUG_INIT,
+  "HW Capability: NPAR enable = %d\n",
+  p->npar_enable);
break;
-   case I40E_DEV_FUNC_CAP_OS2BMC:
+   case I40E_AQ_CAP_ID_OS2BMC_CAP:
p->os2bmc = number;
+   i40e_debug(hw, I40E_DEBUG_INIT,
+  "HW Capability: OS2BMC = %d\n", p->os2bmc);
break;
-   case I40E_DEV_FUNC_CAP_VALID_FUNC:
+   case I40E_AQ_CAP_ID_FUNCTIONS_VALID:
p->valid_functions = number;
+   i40e_debug(hw, I40E_DEBUG_INIT,
+  "HW Capability: Valid Functions = %d\n",
+  p->valid_functions);
break;
-   case I40E_DEV_FUNC_CAP_SRIOV_1_1:
+   case I40E_AQ_CAP_ID_SRIOV:
if (number == 1)
 

[dpdk-dev] [PATCH v5 11/29] i40e/base: fix up recent proxy bits for X722_SUPPORT

2016-03-08 Thread Helin Zhang
The recently added proxy opcodes should be available only with
X722_SUPPORT, so move them into the #ifdef, and reorder these
to be in numerical order with the rest of the opcodes. Several
structs that were added are unnecessary, so they are removed
here.

Fixes: 788fc17b2dec ("i40e/base: support proxy config for X722")

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 46 +
 drivers/net/i40e/base/i40e_common.c | 14 +-
 2 files changed, 12 insertions(+), 48 deletions(-)

v4:
 - Reworded the commit logs.
 - Splitted proxy related code changed to a standalone patch.

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index e2e17c5..ff6449c 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -139,6 +139,12 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_list_func_capabilities = 0x000A,
i40e_aqc_opc_list_dev_capabilities  = 0x000B,

+#ifdef X722_SUPPORT
+   /* Proxy commands */
+   i40e_aqc_opc_set_proxy_config   = 0x0104,
+   i40e_aqc_opc_set_ns_proxy_table_entry   = 0x0105,
+
+#endif
/* LAA */
i40e_aqc_opc_mac_address_read   = 0x0107,
i40e_aqc_opc_mac_address_write  = 0x0108,
@@ -278,10 +284,6 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_get_rss_lut= 0x0B05,
 #endif

-   /* Proxy commands */
-   i40e_aqc_opc_set_proxy_config   = 0x0104,
-   i40e_aqc_opc_set_ns_proxy_table_entry   = 0x0105,
-
/* Async Events */
i40e_aqc_opc_event_lan_overflow = 0x1001,

@@ -2466,40 +2468,4 @@ struct i40e_aqc_debug_modify_internals {

 I40E_CHECK_CMD_LENGTH(i40e_aqc_debug_modify_internals);

-#ifdef X722_SUPPORT
-struct i40e_aqc_set_proxy_config {
-   u8 reserved_1[4];
-   u8 reserved_2[4];
-   __le32  address_high;
-   __le32  address_low;
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aqc_set_proxy_config);
-
-struct i40e_aqc_set_proxy_config_resp {
-   u8 reserved[8];
-   __le32  address_high;
-   __le32  address_low;
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aqc_set_proxy_config_resp);
-
-struct i40e_aqc_set_ns_proxy_table_entry {
-   u8 reserved_1[4];
-   u8 reserved_2[4];
-   __le32  address_high;
-   __le32  address_low;
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aqc_set_ns_proxy_table_entry);
-
-struct i40e_aqc_set_ns_proxy_table_entry_resp {
-   u8 reserved_1[4];
-   u8 reserved_2[4];
-   __le32  address_high;
-   __le32  address_low;
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aqc_set_ns_proxy_table_entry_resp);
-#endif
 #endif /* _I40E_ADMINQ_CMD_H_ */
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 67a5e21..cfe071b 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5818,8 +5818,6 @@ enum i40e_status_code i40e_aq_set_arp_proxy_config(struct 
i40e_hw *hw,
struct i40e_asq_cmd_details *cmd_details)
 {
struct i40e_aq_desc desc;
-   struct i40e_aqc_set_proxy_config *cmd =
-   (struct i40e_aqc_set_proxy_config *) 
enum i40e_status_code status;

if (!proxy_config)
@@ -5827,8 +5825,10 @@ enum i40e_status_code 
i40e_aq_set_arp_proxy_config(struct i40e_hw *hw,

i40e_fill_default_direct_cmd_desc(, i40e_aqc_opc_set_proxy_config);

-   cmd->address_high = CPU_TO_LE32(I40E_HI_DWORD((u64)proxy_config));
-   cmd->address_low = CPU_TO_LE32(I40E_LO_DWORD((u64)proxy_config));
+   desc.params.external.addr_high =
+ CPU_TO_LE32(I40E_HI_DWORD((u64)proxy_config));
+   desc.params.external.addr_low =
+ CPU_TO_LE32(I40E_LO_DWORD((u64)proxy_config));

status = i40e_asq_send_command(hw, , proxy_config,
   sizeof(struct i40e_aqc_arp_proxy_data),
@@ -5851,8 +5851,6 @@ enum i40e_status_code 
i40e_aq_set_ns_proxy_table_entry(struct i40e_hw *hw,
struct i40e_asq_cmd_details *cmd_details)
 {
struct i40e_aq_desc desc;
-   struct i40e_aqc_set_ns_proxy_table_entry *cmd =
-   (struct i40e_aqc_set_ns_proxy_table_entry *) 
enum i40e_status_code status;

if (!ns_proxy_table_entry)
@@ -5861,9 +5859,9 @@ enum i40e_status_code 
i40e_aq_set_ns_proxy_table_entry(struct i40e_hw *hw,
i40e_fill_default_direct_cmd_desc(,
i40e_aqc_opc_set_ns_proxy_table_entry);

-   cmd->address_high =
+   desc.params.external.addr_high =
CPU_TO_LE32(I40E_HI_DWORD((u64)ns_proxy_table_entry));
-   cmd->address_low =
+   desc.params.external.addr_low =
CPU_TO_LE32(I40E_LO_DWORD((u64)ns_proxy_table_entry));

status = i40e_asq_send_command(hw, , ns_proxy_table_entry,
-- 
2.5.0



[dpdk-dev] [PATCH v5 10/29] i40e/base: fix up recent wol bits for X722_SUPPORT

2016-03-08 Thread Helin Zhang
The recently added Wakeup On Line (WOL) opcodes should be
available only with X722_SUPPORT, so move them into the #ifdef,
and reorder these to be in numerical order with the rest of the
opcodes. Several structs that were added are unnecessary, so
they are removed here.

Fixes: 3c89193a36fd ("i40e/base: support WOL config for X722")

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 92 -
 1 file changed, 44 insertions(+), 48 deletions(-)

v4:
 - Reworded the commit logs.
 - Splitted WOL fixes into a standalone patch.

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 1874653..e2e17c5 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -146,6 +146,12 @@ enum i40e_admin_queue_opc {
/* PXE */
i40e_aqc_opc_clear_pxe_mode = 0x0110,

+#ifdef X722_SUPPORT
+   /* WoL commands */
+   i40e_aqc_opc_set_wol_filter = 0x0120,
+   i40e_aqc_opc_get_wake_reason= 0x0121,
+
+#endif
/* internal switch commands */
i40e_aqc_opc_get_switch_config  = 0x0200,
i40e_aqc_opc_add_statistics = 0x0201,
@@ -270,10 +276,6 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_set_rss_lut= 0x0B03,
i40e_aqc_opc_get_rss_key= 0x0B04,
i40e_aqc_opc_get_rss_lut= 0x0B05,
-
-   /* WoL commands */
-   i40e_aqc_opc_set_wol_filter = 0x0120,
-   i40e_aqc_opc_get_wake_reason = 0x0121,
 #endif

/* Proxy commands */
@@ -419,6 +421,7 @@ struct i40e_aqc_list_capabilities_element_resp {
 #define I40E_AQ_CAP_ID_OS2BMC_CAP  0x0004
 #define I40E_AQ_CAP_ID_FUNCTIONS_VALID 0x0005
 #define I40E_AQ_CAP_ID_ALTERNATE_RAM   0x0006
+#define I40E_AQ_CAP_ID_WOL_AND_PROXY   0x0008
 #define I40E_AQ_CAP_ID_SRIOV   0x0012
 #define I40E_AQ_CAP_ID_VF  0x0013
 #define I40E_AQ_CAP_ID_VMDQ0x0014
@@ -567,6 +570,43 @@ struct i40e_aqc_clear_pxe {

 I40E_CHECK_CMD_LENGTH(i40e_aqc_clear_pxe);

+#ifdef X722_SUPPORT
+/* Set WoL Filter (0x0120) */
+
+struct i40e_aqc_set_wol_filter {
+   __le16 filter_index;
+#define I40E_AQC_MAX_NUM_WOL_FILTERS   8
+   __le16 cmd_flags;
+#define I40E_AQC_SET_WOL_FILTER0x8000
+#define I40E_AQC_SET_WOL_FILTER_NO_TCO_WOL 0x4000
+   __le16 valid_flags;
+#define I40E_AQC_SET_WOL_FILTER_ACTION_VALID   0x8000
+#define I40E_AQC_SET_WOL_FILTER_NO_TCO_ACTION_VALID0x4000
+   u8 reserved[2];
+   __le32  address_high;
+   __le32  address_low;
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_set_wol_filter);
+
+/* Get Wake Reason (0x0121) */
+
+struct i40e_aqc_get_wake_reason_completion {
+   u8 reserved_1[2];
+   __le16 wake_reason;
+   u8 reserved_2[12];
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_get_wake_reason_completion);
+
+struct i40e_aqc_set_wol_filter_data {
+   u8 filter[128];
+   u8 mask[16];
+};
+
+I40E_CHECK_STRUCT_LEN(0x90, i40e_aqc_set_wol_filter_data);
+
+#endif /* X722_SUPPORT */
 /* Switch configuration commands (0x02xx) */

 /* Used by many indirect commands that only pass an seid and a buffer in the
@@ -2461,49 +2501,5 @@ struct i40e_aqc_set_ns_proxy_table_entry_resp {
 };

 I40E_CHECK_CMD_LENGTH(i40e_aqc_set_ns_proxy_table_entry_resp);
-
-struct i40e_aqc_set_wol_filter {
-   __le16 filter_index;
-#define I40E_AQC_MAX_NUM_WOL_FILTERS   8
-   __le16 cmd_flags;
-#define I40E_AQC_SET_WOL_FILTER0x8000
-#define I40E_AQC_SET_WOL_FILTER_NO_TCO_WOL 0x4000
-   __le16 valid_flags;
-#define I40E_AQC_SET_WOL_FILTER_ACTION_VALID   0x8000
-#define I40E_AQC_SET_WOL_FILTER_NO_TCO_ACTION_VALID0x4000
-   u8 reserved[2];
-   __le32  address_high;
-   __le32  address_low;
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aqc_set_wol_filter);
-
-struct i40e_aqc_set_wol_filter_resp {
-   u8 reserved[8];
-   __le32  address_high;
-   __le32  address_low;
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aqc_set_wol_filter_resp);
-
-struct i40e_aqc_get_wol_wake_reason {
-   u8 reserved[16];
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aqc_get_wol_wake_reason);
-
-struct i40e_aqc_get_wake_reason_completion {
-   u8 reserved_1[2];
-   __le16 wake_reason;
-   u8 reserved_2[12];
-};
-
-I40E_CHECK_CMD_LENGTH(i40e_aqc_get_wake_reason_completion);
-
-struct i40e_aqc_set_wol_filter_data {
-   u8 filter[128];
-   u8 mask[16];
-};
-
 #endif
 #endif /* _I40E_ADMINQ_CMD_H_ */
-- 
2.5.0



[dpdk-dev] [PATCH v5 09/29] i40e: update device id

2016-03-08 Thread Helin Zhang
Add new Device ID's for backplane and QSFP+ adapters, and delete
deprecated one for backplane.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 12 ++--
 drivers/net/i40e/base/i40e_devids.h | 10 +-
 drivers/net/i40e/i40e_ethdev.h  |  2 +-
 drivers/net/i40e/i40e_rxtx.c|  8 
 lib/librte_eal/common/include/rte_pci_dev_ids.h |  8 ++--
 5 files changed, 30 insertions(+), 10 deletions(-)

v4:
 - Reworded the commit logs.
 - Merged all device IDs related code changes together.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 5e1b39e..67a5e21 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -58,7 +58,6 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw 
*hw)
switch (hw->device_id) {
case I40E_DEV_ID_SFP_XL710:
case I40E_DEV_ID_QEMU:
-   case I40E_DEV_ID_KX_A:
case I40E_DEV_ID_KX_B:
case I40E_DEV_ID_KX_C:
case I40E_DEV_ID_QSFP_A:
@@ -74,6 +73,8 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct i40e_hw 
*hw)
 #ifdef X722_A0_SUPPORT
case I40E_DEV_ID_X722_A0:
 #endif
+   case I40E_DEV_ID_KX_X722:
+   case I40E_DEV_ID_QSFP_X722:
case I40E_DEV_ID_SFP_X722:
case I40E_DEV_ID_1G_BASE_T_X722:
case I40E_DEV_ID_10G_BASE_T_X722:
@@ -81,15 +82,22 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct 
i40e_hw *hw)
break;
 #endif
 #ifdef X722_SUPPORT
+#if defined(INTEGRATED_VF) || defined(VF_DRIVER)
case I40E_DEV_ID_X722_VF:
case I40E_DEV_ID_X722_VF_HV:
+#ifdef X722_A0_SUPPORT
+   case I40E_DEV_ID_X722_A0_VF:
+#endif
hw->mac.type = I40E_MAC_X722_VF;
break;
-#endif
+#endif /* INTEGRATED_VF || VF_DRIVER */
+#endif /* X722_SUPPORT */
+#if defined(INTEGRATED_VF) || defined(VF_DRIVER)
case I40E_DEV_ID_VF:
case I40E_DEV_ID_VF_HV:
hw->mac.type = I40E_MAC_VF;
break;
+#endif
default:
hw->mac.type = I40E_MAC_GENERIC;
break;
diff --git a/drivers/net/i40e/base/i40e_devids.h 
b/drivers/net/i40e/base/i40e_devids.h
index 26cfd54..f844340 100644
--- a/drivers/net/i40e/base/i40e_devids.h
+++ b/drivers/net/i40e/base/i40e_devids.h
@@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
 /* Device IDs */
 #define I40E_DEV_ID_SFP_XL710  0x1572
 #define I40E_DEV_ID_QEMU   0x1574
-#define I40E_DEV_ID_KX_A   0x157F
 #define I40E_DEV_ID_KX_B   0x1580
 #define I40E_DEV_ID_KX_C   0x1581
 #define I40E_DEV_ID_QSFP_A 0x1583
@@ -50,17 +49,26 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_DEV_ID_20G_KR20x1587
 #define I40E_DEV_ID_20G_KR2_A  0x1588
 #define I40E_DEV_ID_10G_BASE_T40x1589
+#if defined(INTEGRATED_VF) || defined(VF_DRIVER) || defined(I40E_NDIS_SUPPORT)
 #define I40E_DEV_ID_VF 0x154C
 #define I40E_DEV_ID_VF_HV  0x1571
+#endif /* VF_DRIVER */
 #ifdef X722_SUPPORT
 #ifdef X722_A0_SUPPORT
 #define I40E_DEV_ID_X722_A00x374C
+#if defined(INTEGRATED_VF) || defined(VF_DRIVER)
+#define I40E_DEV_ID_X722_A0_VF 0x374D
 #endif
+#endif
+#define I40E_DEV_ID_KX_X7220x37CE
+#define I40E_DEV_ID_QSFP_X722  0x37CF
 #define I40E_DEV_ID_SFP_X722   0x37D0
 #define I40E_DEV_ID_1G_BASE_T_X722 0x37D1
 #define I40E_DEV_ID_10G_BASE_T_X7220x37D2
+#if defined(INTEGRATED_VF) || defined(VF_DRIVER) || defined(I40E_NDIS_SUPPORT)
 #define I40E_DEV_ID_X722_VF0x37CD
 #define I40E_DEV_ID_X722_VF_HV 0x37D9
+#endif /* VF_DRIVER */
 #endif /* X722_SUPPORT */

 #define i40e_is_40G_device(d)  ((d) == I40E_DEV_ID_QSFP_A  || \
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index db6173a..947444d 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -600,7 +600,7 @@ i40e_get_vsi_from_adapter(struct i40e_adapter *adapter)
 return NULL;

hw = I40E_DEV_PRIVATE_TO_HW(adapter);
-   if (hw->mac.type == I40E_MAC_VF) {
+   if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(adapter);
return >vsi;
} else {
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index d5c4031..f8efdce 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2113,7 +2113,7 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
uint16_t base, bsf, tc_mapping;
in

[dpdk-dev] [PATCH v5 08/29] i40e/base: fix uncertain event descriptor issue

2016-03-08 Thread Helin Zhang
In one obscure corner case, it was possible to clear the NVM update
wait flag when no update_done message was actually received. This
patch cleans the event descriptor before use, and moves the opcode
check to where it won't get done if there was no event to clean.

Fixes: 8db9e2a1b232 ("i40e: base driver")

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index ee563e4..222add4 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -1032,6 +1032,9 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,
u16 flags;
u16 ntu;

+   /* pre-clean the event info */
+   i40e_memset(>desc, 0, sizeof(e->desc), I40E_NONDMA_MEM);
+
/* take the lock before we start messing with the ring */
i40e_acquire_spinlock(>aq.arq_spinlock);

@@ -1116,13 +1119,6 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,
hw->aq.arq.next_to_clean = ntc;
hw->aq.arq.next_to_use = ntu;

-clean_arq_element_out:
-   /* Set pending if needed, unlock and return */
-   if (pending != NULL)
-   *pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc);
-clean_arq_element_err:
-   i40e_release_spinlock(>aq.arq_spinlock);
-
 #ifdef PF_DRIVER
if (i40e_is_nvm_update_op(>desc)) {
if (hw->aq.nvm_release_on_done) {
@@ -1145,6 +1141,13 @@ clean_arq_element_err:
}

 #endif
+clean_arq_element_out:
+   /* Set pending if needed, unlock and return */
+   if (pending != NULL)
+   *pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc);
+clean_arq_element_err:
+   i40e_release_spinlock(>aq.arq_spinlock);
+
return ret_code;
 }

-- 
2.5.0



[dpdk-dev] [PATCH v5 07/29] i40e/base: set aq count after memory allocation

2016-03-08 Thread Helin Zhang
The standard way to check if the AQ is enabled is to look at
the count field. So it should only set this field after it has
successfully allocated memory.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index e1a162e..ee563e4 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -431,7 +431,6 @@ enum i40e_status_code i40e_init_asq(struct i40e_hw *hw)

hw->aq.asq.next_to_use = 0;
hw->aq.asq.next_to_clean = 0;
-   hw->aq.asq.count = hw->aq.num_asq_entries;

/* allocate the ring memory */
ret_code = i40e_alloc_adminq_asq_ring(hw);
@@ -449,6 +448,7 @@ enum i40e_status_code i40e_init_asq(struct i40e_hw *hw)
goto init_adminq_free_rings;

/* success! */
+   hw->aq.asq.count = hw->aq.num_asq_entries;
goto init_adminq_exit;

 init_adminq_free_rings:
@@ -490,7 +490,6 @@ enum i40e_status_code i40e_init_arq(struct i40e_hw *hw)

hw->aq.arq.next_to_use = 0;
hw->aq.arq.next_to_clean = 0;
-   hw->aq.arq.count = hw->aq.num_arq_entries;

/* allocate the ring memory */
ret_code = i40e_alloc_adminq_arq_ring(hw);
@@ -508,6 +507,7 @@ enum i40e_status_code i40e_init_arq(struct i40e_hw *hw)
goto init_adminq_free_rings;

/* success! */
+   hw->aq.arq.count = hw->aq.num_arq_entries;
goto init_adminq_exit;

 init_adminq_free_rings:
-- 
2.5.0



[dpdk-dev] [PATCH v5 06/29] i40e/base: fix missing check for stopped admin queue

2016-03-08 Thread Helin Zhang
It's possible that while waiting for the spinlock, another
entity (that owns the spinlock) has shut down the admin queue.
If it then attempts to use the queue, it will panic.
It adds a check for this condition on the receive side. This
matches an existing check on the send queue side.

Fixes: 8db9e2a1b232 ("i40e: base driver")

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.c | 8 
 1 file changed, 8 insertions(+)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 998582c..e1a162e 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -1035,6 +1035,13 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,
/* take the lock before we start messing with the ring */
i40e_acquire_spinlock(>aq.arq_spinlock);

+   if (hw->aq.arq.count == 0) {
+   i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
+  "AQRX: Admin queue not initialized.\n");
+   ret_code = I40E_ERR_QUEUE_EMPTY;
+   goto clean_arq_element_err;
+   }
+
/* set next_to_use to head */
 #ifdef PF_DRIVER
 #ifdef INTEGRATED_VF
@@ -1113,6 +1120,7 @@ clean_arq_element_out:
/* Set pending if needed, unlock and return */
if (pending != NULL)
*pending = (ntc > ntu ? hw->aq.arq.count : 0) + (ntu - ntc);
+clean_arq_element_err:
i40e_release_spinlock(>aq.arq_spinlock);

 #ifdef PF_DRIVER
-- 
2.5.0



[dpdk-dev] [PATCH v5 05/29] i40e/base: limit version check of DCB

2016-03-08 Thread Helin Zhang
XL710/X710 devices requires FW version checks to properly handle
DCB configurations from the FW while other devices (e.g. X722)
do not, so limit these checks to XL710/X710 only.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_dcb.c | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_dcb.c b/drivers/net/i40e/base/i40e_dcb.c
index d71387f..26c344f 100644
--- a/drivers/net/i40e/base/i40e_dcb.c
+++ b/drivers/net/i40e/base/i40e_dcb.c
@@ -387,32 +387,40 @@ static void i40e_parse_cee_app_tlv(struct 
i40e_cee_feat_tlv *tlv,
 {
u16 length, typelength, offset = 0;
struct i40e_cee_app_prio *app;
-   u8 i, up, selector;
+   u8 i;

typelength = I40E_NTOHS(tlv->hdr.typelen);
length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >>
   I40E_LLDP_TLV_LEN_SHIFT);

-   dcbcfg->numapps = length/sizeof(*app);
+   dcbcfg->numapps = length / sizeof(*app);
if (!dcbcfg->numapps)
return;

for (i = 0; i < dcbcfg->numapps; i++) {
+   u8 up, selector;
+
app = (struct i40e_cee_app_prio *)(tlv->tlvinfo + offset);
for (up = 0; up < I40E_MAX_USER_PRIORITY; up++) {
if (app->prio_map & BIT(up))
break;
}
dcbcfg->app[i].priority = up;
+
/* Get Selector from lower 2 bits, and convert to IEEE */
selector = (app->upper_oui_sel & I40E_CEE_APP_SELECTOR_MASK);
-   if (selector == I40E_CEE_APP_SEL_ETHTYPE)
+   switch (selector) {
+   case I40E_CEE_APP_SEL_ETHTYPE:
dcbcfg->app[i].selector = I40E_APP_SEL_ETHTYPE;
-   else if (selector == I40E_CEE_APP_SEL_TCPIP)
+   break;
+   case I40E_CEE_APP_SEL_TCPIP:
dcbcfg->app[i].selector = I40E_APP_SEL_TCPIP;
-   else
+   break;
+   default:
/* Keep selector as it is for unknown types */
dcbcfg->app[i].selector = selector;
+   }
+
dcbcfg->app[i].protocolid = I40E_NTOHS(app->protocol);
/* Move to next app */
offset += sizeof(*app);
@@ -822,13 +830,15 @@ enum i40e_status_code i40e_get_dcb_config(struct i40e_hw 
*hw)
struct i40e_aqc_get_cee_dcb_cfg_resp cee_cfg;
struct i40e_aqc_get_cee_dcb_cfg_v1_resp cee_v1_cfg;

-   /* If Firmware version < v4.33 IEEE only */
-   if (((hw->aq.fw_maj_ver == 4) && (hw->aq.fw_min_ver < 33)) ||
-   (hw->aq.fw_maj_ver < 4))
+   /* If Firmware version < v4.33 on X710/XL710, IEEE only */
+   if ((hw->mac.type == I40E_MAC_XL710) &&
+   (((hw->aq.fw_maj_ver == 4) && (hw->aq.fw_min_ver < 33)) ||
+ (hw->aq.fw_maj_ver < 4)))
return i40e_get_ieee_dcb_config(hw);

-   /* If Firmware version == v4.33 use old CEE struct */
-   if ((hw->aq.fw_maj_ver == 4) && (hw->aq.fw_min_ver == 33)) {
+   /* If Firmware version == v4.33 on X710/XL710, use old CEE struct */
+   if ((hw->mac.type == I40E_MAC_XL710) &&
+   ((hw->aq.fw_maj_ver == 4) && (hw->aq.fw_min_ver == 33))) {
ret = i40e_aq_get_cee_dcb_config(hw, _v1_cfg,
 sizeof(cee_v1_cfg), NULL);
if (ret == I40E_SUCCESS) {
@@ -1240,14 +1250,12 @@ enum i40e_status_code i40e_dcb_config_to_lldp(u8 
*lldpmib, u16 *miblen,
u16 length, offset = 0, tlvid = I40E_TLV_ID_START;
enum i40e_status_code ret = I40E_SUCCESS;
struct i40e_lldp_org_tlv *tlv;
-   u16 type, typelength;
+   u16 typelength;

tlv = (struct i40e_lldp_org_tlv *)lldpmib;
while (1) {
i40e_add_dcb_tlv(tlv, dcbcfg, tlvid++);
typelength = I40E_NTOHS(tlv->typelength);
-   type = (u16)((typelength & I40E_LLDP_TLV_TYPE_MASK) >>
-   I40E_LLDP_TLV_TYPE_SHIFT);
length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >>
I40E_LLDP_TLV_LEN_SHIFT);
if (length)
-- 
2.5.0



[dpdk-dev] [PATCH v5 04/29] i40e/base: add X722 support on nvm read

2016-03-08 Thread Helin Zhang
In X722, NVM reads can't be done through SRCTL registers.
And require AQ calls, which require grabbing the NVM lock.
Unfortunately some paths need the lock to be acquired once
and do a whole bunch of stuff and then release it.
This patch creates an unsafe version of the read calls, so
that it can be called from the paths that need the bulk access.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_nvm.c   | 109 ++---
 drivers/net/i40e/base/i40e_prototype.h |   8 ++-
 2 files changed, 92 insertions(+), 25 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index a1b150a..f4e4eaa 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -53,7 +53,7 @@ enum i40e_status_code i40e_read_nvm_aq(struct i40e_hw *hw, u8 
module_pointer,
  * once per NVM initialization, e.g. inside the i40e_init_shared_code().
  * Please notice that the NVM term is used here (& in all methods covered
  * in this file) as an equivalent of the FLASH part mapped into the SR.
- * We are accessing FLASH always thru the Shadow RAM.
+ * We are accessing FLASH always through the Shadow RAM.
  **/
 enum i40e_status_code i40e_init_nvm(struct i40e_hw *hw)
 {
@@ -207,7 +207,7 @@ static enum i40e_status_code 
i40e_poll_sr_srctl_done_bit(struct i40e_hw *hw)
 }

 /**
- * i40e_read_nvm_word - Reads Shadow RAM
+ * i40e_read_nvm_word - Reads nvm word and acquire lock if necessary
  * @hw: pointer to the HW structure
  * @offset: offset of the Shadow RAM word to read (0x00 - 0x001FFF)
  * @data: word read from the Shadow RAM
@@ -236,6 +236,31 @@ enum i40e_status_code i40e_read_nvm_word(struct i40e_hw 
*hw, u16 offset,
 }

 /**
+ * __i40e_read_nvm_word - Reads nvm word, assumes caller does the locking
+ * @hw: pointer to the HW structure
+ * @offset: offset of the Shadow RAM word to read (0x00 - 0x001FFF)
+ * @data: word read from the Shadow RAM
+ *
+ * Reads one 16 bit word from the Shadow RAM using the GLNVM_SRCTL register.
+ **/
+enum i40e_status_code __i40e_read_nvm_word(struct i40e_hw *hw,
+  u16 offset,
+  u16 *data)
+{
+   enum i40e_status_code ret_code = I40E_SUCCESS;
+
+#ifdef X722_SUPPORT
+   if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE)
+   ret_code = i40e_read_nvm_word_aq(hw, offset, data);
+   else
+   ret_code = i40e_read_nvm_word_srctl(hw, offset, data);
+#else
+   ret_code = i40e_read_nvm_word_srctl(hw, offset, data);
+#endif
+   return ret_code;
+}
+
+/**
  * i40e_read_nvm_word_srctl - Reads Shadow RAM via SRCTL register
  * @hw: pointer to the HW structure
  * @offset: offset of the Shadow RAM word to read (0x00 - 0x001FFF)
@@ -307,7 +332,35 @@ enum i40e_status_code i40e_read_nvm_word_aq(struct i40e_hw 
*hw, u16 offset,
 }

 /**
- * i40e_read_nvm_buffer - Reads Shadow RAM buffer
+ * __i40e_read_nvm_buffer - Reads nvm buffer, caller must acquire lock
+ * @hw: pointer to the HW structure
+ * @offset: offset of the Shadow RAM word to read (0x00 - 0x001FFF).
+ * @words: (in) number of words to read; (out) number of words actually read
+ * @data: words read from the Shadow RAM
+ *
+ * Reads 16 bit words (data buffer) from the SR using the i40e_read_nvm_srrd()
+ * method. The buffer read is preceded by the NVM ownership take
+ * and followed by the release.
+ **/
+enum i40e_status_code __i40e_read_nvm_buffer(struct i40e_hw *hw,
+u16 offset,
+u16 *words, u16 *data)
+{
+   enum i40e_status_code ret_code = I40E_SUCCESS;
+
+#ifdef X722_SUPPORT
+   if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE)
+   ret_code = i40e_read_nvm_buffer_aq(hw, offset, words, data);
+   else
+   ret_code = i40e_read_nvm_buffer_srctl(hw, offset, words, data);
+#else
+   ret_code = i40e_read_nvm_buffer_srctl(hw, offset, words, data);
+#endif
+   return ret_code;
+}
+
+/**
+ * i40e_read_nvm_buffer - Reads Shadow RAM buffer and acuire lock if necessary
  * @hw: pointer to the HW structure
  * @offset: offset of the Shadow RAM word to read (0x00 - 0x001FFF).
  * @words: (in) number of words to read; (out) number of words actually read
@@ -327,7 +380,7 @@ enum i40e_status_code i40e_read_nvm_buffer(struct i40e_hw 
*hw, u16 offset,
ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
if (!ret_code) {
ret_code = i40e_read_nvm_buffer_aq(hw, offset, words,
-  data);
+data);
i40e_release_nvm(hw);
}
} else {
@@ -358,7 +411,7 @@ enum i40e_status_code i40e_read_nvm_buffer_srctl(struct 
i40e_

[dpdk-dev] [PATCH v5 03/29] i40e/base: add hw flag for X722 register access

2016-03-08 Thread Helin Zhang
Instead of doing the MAC check, use a flag that gets set per
MAC. This way there are less chances of user error and it
can enable multiple MACs with the capability in a single place
rather than cluttering the code with MAC checks.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 5 +
 drivers/net/i40e/base/i40e_nvm.c| 4 ++--
 drivers/net/i40e/base/i40e_type.h   | 3 +++
 3 files changed, 10 insertions(+), 2 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index d7c940d..5e1b39e 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -1032,6 +1032,11 @@ enum i40e_status_code i40e_init_shared_code(struct 
i40e_hw *hw)
else
hw->pf_id = (u8)(func_rid & 0x7);

+#ifdef X722_SUPPORT
+   if (hw->mac.type == I40E_MAC_X722)
+   hw->flags |= I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE;
+
+#endif
status = i40e_init_nvm(hw);
return status;
 }
diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index bfa3315..a1b150a 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -220,7 +220,7 @@ enum i40e_status_code i40e_read_nvm_word(struct i40e_hw 
*hw, u16 offset,
enum i40e_status_code ret_code = I40E_SUCCESS;

 #ifdef X722_SUPPORT
-   if (hw->mac.type == I40E_MAC_X722) {
+   if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE) {
ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
if (!ret_code) {
ret_code = i40e_read_nvm_word_aq(hw, offset, data);
@@ -323,7 +323,7 @@ enum i40e_status_code i40e_read_nvm_buffer(struct i40e_hw 
*hw, u16 offset,
enum i40e_status_code ret_code = I40E_SUCCESS;

 #ifdef X722_SUPPORT
-   if (hw->mac.type == I40E_MAC_X722) {
+   if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE) {
ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
if (!ret_code) {
ret_code = i40e_read_nvm_buffer_aq(hw, offset, words,
diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 9483884..f566e30 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -658,6 +658,9 @@ struct i40e_hw {
u16 wol_proxy_vsi_seid;

 #endif
+#define I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE BIT_ULL(0)
+   u64 flags;
+
/* debug mask */
u32 debug_mask;
 #ifndef I40E_NDIS_SUPPORT
-- 
2.5.0



[dpdk-dev] [PATCH v5 02/29] i40e/base: acquire NVM ownership before reading it

2016-03-08 Thread Helin Zhang
It needs to acquire the NVM ownership before issuing an AQ read
to the X722 NVM otherwise it will get EBUSY from the firmware.
Also it should be released when done.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_nvm.c | 35 +--
 1 file changed, 29 insertions(+), 6 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index 60f2bb9..bfa3315 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -217,11 +217,22 @@ static enum i40e_status_code 
i40e_poll_sr_srctl_done_bit(struct i40e_hw *hw)
 enum i40e_status_code i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
 u16 *data)
 {
+   enum i40e_status_code ret_code = I40E_SUCCESS;
+
 #ifdef X722_SUPPORT
-   if (hw->mac.type == I40E_MAC_X722)
-   return i40e_read_nvm_word_aq(hw, offset, data);
+   if (hw->mac.type == I40E_MAC_X722) {
+   ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
+   if (!ret_code) {
+   ret_code = i40e_read_nvm_word_aq(hw, offset, data);
+   i40e_release_nvm(hw);
+   }
+   } else {
+   ret_code = i40e_read_nvm_word_srctl(hw, offset, data);
+   }
+#else
+   ret_code = i40e_read_nvm_word_srctl(hw, offset, data);
 #endif
-   return i40e_read_nvm_word_srctl(hw, offset, data);
+   return ret_code;
 }

 /**
@@ -309,11 +320,23 @@ enum i40e_status_code i40e_read_nvm_word_aq(struct 
i40e_hw *hw, u16 offset,
 enum i40e_status_code i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
   u16 *words, u16 *data)
 {
+   enum i40e_status_code ret_code = I40E_SUCCESS;
+
 #ifdef X722_SUPPORT
-   if (hw->mac.type == I40E_MAC_X722)
-   return i40e_read_nvm_buffer_aq(hw, offset, words, data);
+   if (hw->mac.type == I40E_MAC_X722) {
+   ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
+   if (!ret_code) {
+   ret_code = i40e_read_nvm_buffer_aq(hw, offset, words,
+  data);
+   i40e_release_nvm(hw);
+   }
+   } else {
+   ret_code = i40e_read_nvm_buffer_srctl(hw, offset, words, data);
+   }
+#else
+   ret_code = i40e_read_nvm_buffer_srctl(hw, offset, words, data);
 #endif
-   return i40e_read_nvm_buffer_srctl(hw, offset, words, data);
+   return ret_code;
 }

 /**
-- 
2.5.0



[dpdk-dev] [PATCH v5 01/29] i40e/base: fix compilation warnings

2016-03-08 Thread Helin Zhang
It fixes compilation warnings.

Fixes: bd6651c2d2d7 ("i40e/base: use bit shift macros")

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_lan_hmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_lan_hmc.c 
b/drivers/net/i40e/base/i40e_lan_hmc.c
index 6511767..2260648 100644
--- a/drivers/net/i40e/base/i40e_lan_hmc.c
+++ b/drivers/net/i40e/base/i40e_lan_hmc.c
@@ -769,7 +769,7 @@ static void i40e_write_byte(u8 *hmc_bits,

/* prepare the bits and mask */
shift_width = ce_info->lsb % 8;
-   mask = BIT(ce_info->width) - 1;
+   mask = (u8)(BIT(ce_info->width) - 1);

src_byte = *from;
src_byte &= mask;
@@ -954,7 +954,7 @@ static void i40e_read_byte(u8 *hmc_bits,

/* prepare the bits and mask */
shift_width = ce_info->lsb % 8;
-   mask = BIT(ce_info->width) - 1;
+   mask = (u8)(BIT(ce_info->width) - 1);

/* shift to correct alignment */
mask <<= shift_width;
-- 
2.5.0



[dpdk-dev] [PATCH v5 00/29] i40e base driver update

2016-03-08 Thread Helin Zhang
i40e base driver is updated, to support new X722 device IDs, and
use rx control AQ commands to read/write rx control registers.
Of cause, fixes and enhancements are added as listed as below.

The patch set branches off below commit on branch rel_16_04 of
repo dpdk-next-net.
commit 4ac366ba647909c3b71818f9be9db86ba5e871da
Author: Thomas Monjalon 
Date:   Sat Feb 6 22:51:16 2016 +0100
  nfp: fix non-x86 build

v5:
 - rebased the patch set ontop of maintainer's branch rel_16_04.

v4:
 - Reworded the commit logs.
 - Reorganized patches, in order to put together the code changes
   of the same purpose.
 - Reorganized the release notes changes.

v3:
 - As release_2_3.rst has been renamed to release_16_04.rst, then
   all modifications in release_2_3.rst should be moved into
   release_16_04.rst.

v2:
 - Used i40e_set_mac_type() in base driver to replace the similar
   in PMD source files, in order to support newly added X722 VF
   device IDs.
 - Used small letter in all commit log titles.

Helin Zhang (29):
  i40e/base: fix compilation warnings
  i40e/base: acquire NVM ownership before reading it
  i40e/base: add hw flag for X722 register access
  i40e/base: add X722 support on nvm read
  i40e/base: limit version check of DCB
  i40e/base: fix missing check for stopped admin queue
  i40e/base: set aq count after memory allocation
  i40e/base: fix uncertain event descriptor issue
  i40e: update device id
  i40e/base: fix up recent wol bits for X722_SUPPORT
  i40e/base: fix up recent proxy bits for X722_SUPPORT
  i40e/base: unify the capability function
  i40e/base: fix for PHY NVM interaction problem
  i40e/base: set shared bit for multicast filters
  i40e/base: support operating port mirroring rules
  i40e: add VEB stat control
  i40e/base: implement new API function
  i40e/base: add functions to blink led
  i40e/base: apply promisc mode to Tx Traffic
  i40e/base: fix driver load failure
  i40e/base: save off VSI resource count
  i40e/base: coding style fixes
  i40e: use AQ rx control register read/write
  i40e: expose some registers
  i40e/base: add a new Virtchnl offload
  i40e/base: add AQ thermal sensor control struct
  i40e: update structure and macro definitions
  i40e: add base driver release info
  i40evf: use base driver defined interface

 doc/guides/rel_notes/release_16_04.rst  |  15 +
 drivers/net/i40e/Makefile   |   1 +
 drivers/net/i40e/base/i40e_adminq.c |  27 +-
 drivers/net/i40e/base/i40e_adminq_cmd.h | 234 +++---
 drivers/net/i40e/base/i40e_common.c | 942 +---
 drivers/net/i40e/base/i40e_dcb.c|  34 +-
 drivers/net/i40e/base/i40e_devids.h |  10 +-
 drivers/net/i40e/base/i40e_lan_hmc.c|   4 +-
 drivers/net/i40e/base/i40e_nvm.c| 142 +++-
 drivers/net/i40e/base/i40e_osdep.h  |  36 +
 drivers/net/i40e/base/i40e_prototype.h  |  48 +-
 drivers/net/i40e/base/i40e_register.h   |  48 ++
 drivers/net/i40e/base/i40e_type.h   |  24 +-
 drivers/net/i40e/base/i40e_virtchnl.h   |   1 +
 drivers/net/i40e/i40e_ethdev.c  |  81 +-
 drivers/net/i40e/i40e_ethdev.h  |   2 +-
 drivers/net/i40e/i40e_ethdev_vf.c   |  50 +-
 drivers/net/i40e/i40e_fdir.c|  13 +-
 drivers/net/i40e/i40e_pf.c  |   6 +-
 drivers/net/i40e/i40e_rxtx.c|   8 +-
 lib/librte_eal/common/include/rte_pci_dev_ids.h |   8 +-
 21 files changed, 1391 insertions(+), 343 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v2 2/2] i40evf: use ether API to validate MAC address

2016-03-08 Thread Helin Zhang
It uses ether API of 'is_valid_assigned_ether_addr' to validate
MAC address. In the meanwhile, more annotations are added.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_ethdev_vf.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 13c5b3d..ded7c8b 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1180,6 +1180,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)
int i, err, bufsz;
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+   struct ether_addr *p_mac_addr;

vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
vf->dev_data = dev->data;
@@ -1249,13 +1250,12 @@ i40evf_init_vf(struct rte_eth_dev *dev)
vf->vsi.nb_qps = vf->vsi_res->num_queue_pairs;
vf->vsi.adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);

-   /* check mac addr, if it's not valid, genrate one */
-   if (I40E_SUCCESS != i40e_validate_mac_addr(\
-   vf->vsi_res->default_mac_addr))
-   eth_random_addr(vf->vsi_res->default_mac_addr);
-
-   ether_addr_copy((struct ether_addr *)vf->vsi_res->default_mac_addr,
-   (struct ether_addr *)hw->mac.addr);
+   /* Store the MAC address configured by host, or generate random one */
+   p_mac_addr = (struct ether_addr *)(vf->vsi_res->default_mac_addr);
+   if (is_valid_assigned_ether_addr(p_mac_addr)) /* Configured by host */
+   ether_addr_copy(p_mac_addr, (struct ether_addr *)hw->mac.addr);
+   else
+   eth_random_addr(hw->mac.addr); /* Generate a random one */

return 0;

-- 
2.5.0



[dpdk-dev] [PATCH v2 1/2] i40e: generate MAC address for VF

2016-03-08 Thread Helin Zhang
It generates a MAC address for each VFs during PF host
initialization.

Signed-off-by: Helin Zhang 
---
 doc/guides/rel_notes/release_16_04.rst | 5 +
 drivers/net/i40e/i40e_ethdev.h | 1 +
 drivers/net/i40e/i40e_pf.c | 3 +++
 3 files changed, 9 insertions(+)

v2:
 - It just generates a MAC address for each VFs during PF host
   initialization, and removes configuring from users.
 - Reworded the release notes.

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 73494f9..1b9061d 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -137,6 +137,11 @@ Drivers

 * **vmxnet3: add TSO support.**

+* **i40e: Generates MAC address for each VFs.**
+
+  It generates a MAC address for each VFs during PF host initialization,
+  and keeps the VF MAC address the same among different VF launch.
+

 Libraries
 ~
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index db6173a..9109cd9 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -312,6 +312,7 @@ struct i40e_pf_vf {
uint16_t vf_idx; /* VF index in pf->vfs */
uint16_t lan_nb_qps; /* Actual queues allocated */
uint16_t reset_cnt; /* Total vf reset times */
+   struct ether_addr mac_addr;  /* Default MAC address */
 };

 /*
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index cbf4e5b..5790377 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -315,6 +315,8 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf 
*vf)
/* As assume Vf only has single VSI now, always return 0 */
vf_res->vsi_res[0].vsi_id = 0;
vf_res->vsi_res[0].num_queue_pairs = vf->vsi->nb_qps;
+   ether_addr_copy(>mac_addr,
+   (struct ether_addr *)vf_res->vsi_res[0].default_mac_addr);

 send_msg:
i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_GET_VF_RESOURCES,
@@ -1045,6 +1047,7 @@ i40e_pf_host_init(struct rte_eth_dev *dev)
ret = i40e_pf_host_vf_reset(>vfs[i], 0);
if (ret != I40E_SUCCESS)
goto fail;
+   eth_random_addr(pf->vfs[i].mac_addr.addr_bytes);
}

/* restore irq0 */
-- 
2.5.0



[dpdk-dev] [PATCH v2 0/2] add VF MAC address generation

2016-03-08 Thread Helin Zhang
It adds generating a MAC address for each VFs during PF
host initialization.

The patch set branches off below commit on branch rel_16_04
of dpdk-next-net repo.

commit 4ac366ba647909c3b71818f9be9db86ba5e871da
Author: Thomas Monjalon 
Date:   Sat Feb 6 22:51:16 2016 +0100
nfp: fix non-x86 build

v2:
 - It just adds generating a MAC address for each VFs
   during PF host initialization, and removes configuring
   from users.
 - Reworded the release notes.
 - Removed the app changes.

Helin Zhang (2):
  i40e: generate MAC address for VF
  i40evf: use ether API to validate MAC address

 doc/guides/rel_notes/release_16_04.rst |  5 +
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_ethdev_vf.c  | 14 +++---
 drivers/net/i40e/i40e_pf.c |  3 +++
 4 files changed, 16 insertions(+), 7 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v2 3/3] i40e: fix the overflow issue

2016-03-07 Thread Helin Zhang
The array 'ptype_table' was defined in depth of 'UINT8_MAX' which
is 255, while the querying index could be from 0 to 255. The issue
can be fixed with expanding the array to one more element.

Fixes: 9571ea028489 ("i40e: replace some offload flags with unified packet 
type")

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index d5c4031..ac44901 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -198,7 +198,7 @@ i40e_get_iee15888_flags(struct rte_mbuf *mb, uint64_t qword)
 static inline uint32_t
 i40e_rxd_pkt_type_mapping(uint8_t ptype)
 {
-   static const uint32_t ptype_table[UINT8_MAX] __rte_cache_aligned = {
+   static const uint32_t type_table[UINT8_MAX + 1] __rte_cache_aligned = {
/* L2 types */
/* [0] reserved */
[1] = RTE_PTYPE_L2_ETHER,
@@ -724,7 +724,7 @@ i40e_rxd_pkt_type_mapping(uint8_t ptype)
/* All others reserved */
};

-   return ptype_table[ptype];
+   return type_table[ptype];
 }

 #define I40E_RX_DESC_EXT_STATUS_FLEXBH_MASK   0x03
-- 
2.5.0



[dpdk-dev] [PATCH v2 2/3] i40e: add VLAN ether type config

2016-03-07 Thread Helin Zhang
It adds the setting VLAN ether type of single VLAN, inner and
outer VLAN. Single VLAN is treated as inner VLAN as usual.

Signed-off-by: Helin Zhang 
---
 drivers/net/i40e/i40e_ethdev.c | 68 +++---
 1 file changed, 64 insertions(+), 4 deletions(-)

v2:
 - Used RTE_NEXT_ABI to avoid ABI change issue.

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 1da5690..a5b9289 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -273,6 +273,11 @@
 #define I40E_INSET_IPV6_TC_MASK   0x0009F00FUL
 #define I40E_INSET_IPV6_NEXT_HDR_MASK 0x000C00FFUL

+#define I40E_GL_SWT_L2TAGCTRL(_i) (0x001C0A70 + ((_i) * 4))
+#define I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT 16
+#define I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_MASK \
+   I40E_MASK(0x, I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT)
+
 static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);
 static int i40e_dev_configure(struct rte_eth_dev *dev);
@@ -2324,13 +2329,58 @@ i40e_vlan_filter_set(struct rte_eth_dev *dev, uint16_t 
vlan_id, int on)
 }

 static void
-i40e_vlan_tpid_set(__rte_unused struct rte_eth_dev *dev,
+i40e_vlan_tpid_set(struct rte_eth_dev *dev,
 #ifdef RTE_NEXT_ABI
-  __rte_unused enum rte_vlan_type vlan_type,
+  enum rte_vlan_type vlan_type,
 #endif
-  __rte_unused uint16_t tpid)
+  uint16_t tpid)
 {
-   PMD_INIT_FUNC_TRACE();
+   struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint64_t reg_r = 0, reg_w = 0;
+   uint16_t reg_id = 0;
+   int ret;
+
+#ifdef RTE_NEXT_ABI
+   switch (vlan_type) {
+   case ETH_VLAN_TYPE_OUTER:
+   reg_id = 2;
+   break;
+   case ETH_VLAN_TYPE_INNER:
+   reg_id = 3;
+   break;
+   default:
+   PMD_DRV_LOG(ERR, "Unsupported vlan type %d", vlan_type);
+   return;
+   }
+#else
+   reg_id = 3;
+#endif /* RTE_NEXT_ABI */
+
+   ret = i40e_aq_debug_read_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id),
+ _r, NULL);
+   if (ret != I40E_SUCCESS) {
+   PMD_DRV_LOG(ERR, "Fail to debug read from "
+   "I40E_GL_SWT_L2TAGCTRL[%d]", reg_id);
+   return;
+   }
+   PMD_DRV_LOG(DEBUG, "Debug read from I40E_GL_SWT_L2TAGCTRL[%d]: "
+   "0x%08"PRIx64"", reg_id, reg_r);
+
+   reg_w = reg_r & (~(I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_MASK));
+   reg_w |= ((uint64_t)tpid << I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT);
+   if (reg_r == reg_w) {
+   PMD_DRV_LOG(DEBUG, "No need to write");
+   return;
+   }
+   ret = i40e_aq_debug_write_register(hw, I40E_GL_SWT_L2TAGCTRL(reg_id),
+  reg_w, NULL);
+   if (ret != I40E_SUCCESS) {
+   PMD_DRV_LOG(ERR, "Fail to debug write to "
+   "I40E_GL_SWT_L2TAGCTRL[%d]", reg_id);
+   return;
+   }
+   PMD_DRV_LOG(DEBUG, "Debug write 0x%08"PRIx64" to "
+   "I40E_GL_SWT_L2TAGCTRL[%d]", reg_w, reg_id);
 }

 static void
@@ -7345,11 +7395,21 @@ i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
 static void
 i40e_hw_init(struct i40e_hw *hw)
 {
+   struct rte_eth_dev *dev = ((struct i40e_adapter *)(hw->back))->eth_dev;
+
/* clear the PF Queue Filter control register */
I40E_WRITE_REG(hw, I40E_PFQF_CTL_0, 0);

/* Disable symmetric hash per port */
i40e_set_symmetric_hash_enable_per_port(hw, 0);
+
+   /* Set the global registers with default ether type value */
+#ifdef RTE_NEXT_ABI
+   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_vlan_tpid_set(dev, ETHER_TYPE_VLAN);
+#endif /* RTE_NEXT_ABI */
 }

 enum i40e_filter_pctype
-- 
2.5.0



[dpdk-dev] [PATCH v2 1/3] ethdev: add vlan type for setting ether type

2016-03-07 Thread Helin Zhang
In order to set ether type of VLAN for single VLAN, inner
and outer VLAN, the VLAN type as an input parameter is added
to 'rte_eth_dev_set_vlan_ether_type()'.
In addition, corresponding changes in e1000, ixgbe and i40e are
also added.

Signed-off-by: Helin Zhang 
---
 app/test-pmd/cmdline.c | 29 -
 app/test-pmd/config.c  | 14 +++---
 app/test-pmd/testpmd.h |  3 ++-
 doc/guides/rel_notes/deprecation.rst   |  6 ++
 doc/guides/rel_notes/release_16_04.rst |  4 
 drivers/net/e1000/igb_ethdev.c | 26 +++---
 drivers/net/i40e/i40e_ethdev.c |  9 -
 drivers/net/ixgbe/ixgbe_ethdev.c   | 25 ++---
 lib/librte_ether/rte_ethdev.c  | 12 ++--
 lib/librte_ether/rte_ethdev.h  | 24 ++--
 10 files changed, 128 insertions(+), 24 deletions(-)

v2:
 - Used RTE_NEXT_ABI to avoid ABI change issue.
 - Reworked the announcement of ABI change for release 16.07.

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 52e9f5f..39a1202 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -277,8 +277,8 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the VLAN QinQ (extended queue in queue)"
" on a port.\n\n"

-   "vlan set tpid (value) (port_id)\n"
-   "Set the outer VLAN TPID for Packet Filtering on"
+   "vlan set (inner|outer) tpid (value) (port_id)\n"
+   "Set the VLAN TPID for Packet Filtering on"
" a port\n\n"

"rx_vlan add (vlan_id|all) (port_id)\n"
@@ -297,10 +297,6 @@ static void cmd_help_long_parsed(void *parsed_result,
"Remove a vlan_id, to the set of VLAN identifiers"
"filtered for VF(s) from port_id.\n\n"

-   "rx_vlan set tpid (value) (port_id)\n"
-   "Set the outer VLAN TPID for Packet Filtering on"
-   " a port\n\n"
-
"tunnel_filter add (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
"(inner_vlan) (vxlan|nvgre) (filter_type) (tenant_id) 
(queue_id)\n"
"   add a tunnel filter of a port.\n\n"
@@ -2847,6 +2843,7 @@ cmdline_parse_inst_t cmd_vlan_offload = {
 struct cmd_vlan_tpid_result {
cmdline_fixed_string_t vlan;
cmdline_fixed_string_t set;
+   cmdline_fixed_string_t vlan_type;
cmdline_fixed_string_t what;
uint16_t tp_id;
uint8_t port_id;
@@ -2858,8 +2855,17 @@ cmd_vlan_tpid_parsed(void *parsed_result,
  __attribute__((unused)) void *data)
 {
struct cmd_vlan_tpid_result *res = parsed_result;
-   vlan_tpid_set(res->port_id, res->tp_id);
-   return;
+   enum rte_vlan_type vlan_type;
+
+   if (!strcmp(res->vlan_type, "inner"))
+   vlan_type = ETH_VLAN_TYPE_INNER;
+   else if (!strcmp(res->vlan_type, "outer"))
+   vlan_type = ETH_VLAN_TYPE_OUTER;
+   else {
+   printf("Unknown vlan type\n");
+   return;
+   }
+   vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
 }

 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
@@ -2868,6 +2874,9 @@ cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
 cmdline_parse_token_string_t cmd_vlan_tpid_set =
TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
 set, "set");
+cmdline_parse_token_string_t cmd_vlan_type =
+   TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
+vlan_type, "inner#outer");
 cmdline_parse_token_string_t cmd_vlan_tpid_what =
TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
 what, "tpid");
@@ -2881,10 +2890,12 @@ cmdline_parse_token_num_t cmd_vlan_tpid_portid =
 cmdline_parse_inst_t cmd_vlan_tpid = {
.f = cmd_vlan_tpid_parsed,
.data = NULL,
-   .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
+   .help_str = "set inner|outer tpid tp_id port_id, set the VLAN "
+   "Ether type",
.tokens = {
(void *)_vlan_tpid_vlan,
(void *)_vlan_tpid_set,
+   (void *)_vlan_type,
(void *)_vlan_tpid_what,
(void *)_vlan_tpid_tpid,
(void *)_vlan_tpid_portid,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 0062484..db64d57 100644
--- a/app/test-pmd

[dpdk-dev] [PATCH v2 0/3] i40e setting ether type of VLANs

2016-03-07 Thread Helin Zhang
It adds setting ether type of both single VLAN(inner VLAN) and outer
VLAN for i40e. For ixgbe and e1000/igb, it supports setting single
VLAN(inner VLAN) only, and can be extended in the future.

The patch set was branched off rel_16_04 of repo dpdk-next-net,
on below commit.
 - commit 4ac366ba647909c3b71818f9be9db86ba5e871da
 nfp: fix non-x86 build

v2:
 - Used RTE_NEXT_ABI to avoid ABI change issue.
 - Reworked the announcement of ABI change for release 16.07.
 - Fixed a i40e overflow issue.

Helin Zhang (3):
  ethdev: add vlan type for setting ether type
  i40e: add VLAN ether type config
  i40e: fix the overflow issue

 app/test-pmd/cmdline.c | 29 +
 app/test-pmd/config.c  | 14 +--
 app/test-pmd/testpmd.h |  3 +-
 doc/guides/rel_notes/deprecation.rst   |  6 +++
 doc/guides/rel_notes/release_16_04.rst |  4 ++
 drivers/net/e1000/igb_ethdev.c | 26 ++--
 drivers/net/i40e/i40e_ethdev.c | 75 --
 drivers/net/i40e/i40e_rxtx.c   |  4 +-
 drivers/net/ixgbe/ixgbe_ethdev.c   | 25 ++--
 lib/librte_ether/rte_ethdev.c  | 12 +-
 lib/librte_ether/rte_ethdev.h  | 24 ++-
 11 files changed, 193 insertions(+), 29 deletions(-)

-- 
2.5.0



[dpdk-dev] [PATCH v4 29/29] i40evf: use base driver defined interface

2016-03-06 Thread Helin Zhang
It removes the i40evf_set_mac_type() defined in PMD, and reuses
i40e_set_mac_type() defined in base driver.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/i40e_ethdev_vf.c | 22 +-
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index bd5c091..4fdbdf3 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -216,26 +216,6 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
.rss_hash_conf_get= i40evf_dev_rss_hash_conf_get,
 };

-static int
-i40evf_set_mac_type(struct i40e_hw *hw)
-{
-   int status = I40E_ERR_DEVICE_NOT_SUPPORTED;
-
-   if (hw->vendor_id == I40E_INTEL_VENDOR_ID) {
-   switch (hw->device_id) {
-   case I40E_DEV_ID_VF:
-   case I40E_DEV_ID_VF_HV:
-   hw->mac.type = I40E_MAC_VF;
-   status = I40E_SUCCESS;
-   break;
-   default:
-   ;
-   }
-   }
-
-   return status;
-}
-
 /*
  * Parse admin queue message.
  *
@@ -1183,7 +1163,7 @@ i40evf_init_vf(struct rte_eth_dev *dev)

vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
vf->dev_data = dev->data;
-   err = i40evf_set_mac_type(hw);
+   err = i40e_set_mac_type(hw);
if (err) {
PMD_INIT_LOG(ERR, "set_mac_type failed: %d", err);
goto err;
-- 
2.5.0



[dpdk-dev] [PATCH v4 28/29] i40e: add base driver release info

2016-03-06 Thread Helin Zhang
It adds base driver release information such as release date,
for better tracking in the future.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 033ee4a..6dd6eaa 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -85,6 +85,7 @@ VPATH += $(SRCDIR)/base

 #
 # all source are stored in SRCS-y
+# base driver is based on the package of dpdk-i40e.2016.01.07.14.tar.gz.
 #
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_adminq.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_common.c
-- 
2.5.0



[dpdk-dev] [PATCH v4 27/29] i40e: update structure and macro definitions

2016-03-06 Thread Helin Zhang
Several structures and macros are added or updated, such
as 'struct i40e_aqc_get_link_status',
'struct i40e_aqc_run_phy_activity' and
'struct i40e_aqc_lldp_set_local_mib_resp'.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 doc/guides/rel_notes/release_16_04.rst  |  9 +++
 drivers/net/i40e/base/i40e_adminq_cmd.h | 45 ++---
 drivers/net/i40e/base/i40e_type.h   |  5 ++--
 drivers/net/i40e/i40e_ethdev.c  |  2 +-
 4 files changed, 53 insertions(+), 8 deletions(-)

v4:
 - Reworded the commit logs.
 - Moved new feature announcement in release notes to this patch.

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 1b1a29f..065b8b2 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -57,6 +57,15 @@ This section should contain new features added in this 
release. Sample format:

 * **Added vhost-user live migration support.**

+* **Updated the i40e base driver.**
+
+  The i40e base driver was updated with changes including the
+  following:
+
+  * Use rx control AQ commands to read/write rx control registers.
+  * Add new X722 device IDs, and removed X710 one was never used.
+  * Expose registers for HASH/FD input set configuring.
+

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 5236333..fe9d5b5 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
  */

 #define I40E_FW_API_VERSION_MAJOR  0x0001
-#define I40E_FW_API_VERSION_MINOR  0x0004
+#define I40E_FW_API_VERSION_MINOR  0x0005

 struct i40e_aq_desc {
__le16 flags;
@@ -242,6 +242,7 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_get_phy_wol_caps   = 0x0621,
i40e_aqc_opc_set_phy_debug  = 0x0622,
i40e_aqc_opc_upload_ext_phy_fm  = 0x0625,
+   i40e_aqc_opc_run_phy_activity   = 0x0626,

/* NVM commands */
i40e_aqc_opc_nvm_read   = 0x0701,
@@ -915,6 +916,10 @@ struct i40e_aqc_vsi_properties_data {
 I40E_AQ_VSI_TC_QUE_NUMBER_SHIFT)
/* queueing option section */
u8  queueing_opt_flags;
+#ifdef X722_SUPPORT
+#define I40E_AQ_VSI_QUE_OPT_MULTICAST_UDP_ENA  0x04
+#define I40E_AQ_VSI_QUE_OPT_UNICAST_UDP_ENA0x08
+#endif
 #define I40E_AQ_VSI_QUE_OPT_TCP_ENA0x10
 #define I40E_AQ_VSI_QUE_OPT_FCOE_ENA   0x20
 #ifdef X722_SUPPORT
@@ -1349,10 +1354,16 @@ struct i40e_aqc_add_remove_cloud_filters_element_data {

 #define I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT  9
 #define I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK   0x1E00
-#define I40E_AQC_ADD_CLOUD_TNL_TYPE_XVLAN  0
+#define I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN  0
 #define I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC 1
-#define I40E_AQC_ADD_CLOUD_TNL_TYPE_NGE2
+#define I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE 2
 #define I40E_AQC_ADD_CLOUD_TNL_TYPE_IP 3
+#define I40E_AQC_ADD_CLOUD_TNL_TYPE_RESERVED   4
+#define I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN_GPE  5
+
+#define I40E_AQC_ADD_CLOUD_FLAGS_SHARED_OUTER_MAC  0x2000
+#define I40E_AQC_ADD_CLOUD_FLAGS_SHARED_INNER_MAC  0x4000
+#define I40E_AQC_ADD_CLOUD_FLAGS_SHARED_OUTER_IP   0x8000

__le32  tenant_id;
u8  reserved[4];
@@ -1846,7 +1857,12 @@ struct i40e_aqc_get_link_status {
u8  config;
 #define I40E_AQ_CONFIG_CRC_ENA 0x04
 #define I40E_AQ_CONFIG_PACING_MASK 0x78
-   u8  reserved[5];
+   u8  external_power_ability;
+#define I40E_AQ_LINK_POWER_CLASS_1 0x00
+#define I40E_AQ_LINK_POWER_CLASS_2 0x01
+#define I40E_AQ_LINK_POWER_CLASS_3 0x02
+#define I40E_AQ_LINK_POWER_CLASS_4 0x03
+   u8  reserved[4];
 };

 I40E_CHECK_CMD_LENGTH(i40e_aqc_get_link_status);
@@ -1914,6 +1930,18 @@ enum i40e_aq_phy_reg_type {
I40E_AQC_PHY_REG_EXERNAL_MODULE = 0x3
 };

+/* Run PHY Activity (0x0626) */
+struct i40e_aqc_run_phy_activity {
+   __le16  activity_id;
+   u8  flags;
+   u8  reserved1;
+   __le32  control;
+   __le32  data;
+   u8  reserved2[4];
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_run_phy_activity);
+
 /* NVM Read command (indirect 0x0701)
  * NVM Erase commands (direct 0x0702)
  * NVM Update commands (indirect 0x0703)
@@ -2262,6 +2290,14 @@ struct i40e_aqc_lldp_set_local_mib {

 I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_set_local_mib);

+struct i40e_aqc_lldp_set_local_mib_resp {
+#define SET_LOCAL_MIB_RESP_EVENT_TRIGGERED_MASK  0x01
+   u8  status;
+   u8  reserved[15];
+};
+
+I40E_CHECK_STRUCT_LEN(0x10, i40e_aqc_lldp_set_local_mib_resp);
+
 /* Stop/Start LLDP Agent (direct 0x0A09)
  * Used for stopping/starting specific LLDP agent. e.g. DCBx

[dpdk-dev] [PATCH v4 26/29] i40e/base: add AQ thermal sensor control struct

2016-03-06 Thread Helin Zhang
It adds the new AQ command and struct for managing a
thermal sensor.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 12ebd35..5236333 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -250,6 +250,7 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_nvm_config_read= 0x0704,
i40e_aqc_opc_nvm_config_write   = 0x0705,
i40e_aqc_opc_oem_post_update= 0x0720,
+   i40e_aqc_opc_thermal_sensor = 0x0721,

/* virtualization commands */
i40e_aqc_opc_send_msg_to_pf = 0x0801,
@@ -2001,6 +2002,22 @@ struct i40e_aqc_nvm_oem_post_update_buffer {

 I40E_CHECK_STRUCT_LEN(0x28, i40e_aqc_nvm_oem_post_update_buffer);

+/* Thermal Sensor (indirect 0x0721)
+ * read or set thermal sensor configs and values
+ * takes a sensor and command specific data buffer, not detailed here
+ */
+struct i40e_aqc_thermal_sensor {
+   u8 sensor_action;
+#define I40E_AQ_THERMAL_SENSOR_READ_CONFIG 0
+#define I40E_AQ_THERMAL_SENSOR_SET_CONFIG  1
+#define I40E_AQ_THERMAL_SENSOR_READ_TEMP   2
+   u8 reserved[7];
+   __le32  addr_high;
+   __le32  addr_low;
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_thermal_sensor);
+
 /* Send to PF command (indirect 0x0801) id is only used by PF
  * Send to VF command (indirect 0x0802) id is only used by PF
  * Send to Peer PF command (indirect 0x0803)
-- 
2.5.0



[dpdk-dev] [PATCH v4 25/29] i40e/base: add a new Virtchnl offload

2016-03-06 Thread Helin Zhang
X722 supports Expanded version of TCP, UDP PCTYPES for RSS.
Add a Virtchnl offload to support this.
Without this patch VF drivers will not be able to support
the correct PCTYPES for X722 and UDP flows will not fan out.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_virtchnl.h | 1 +
 1 file changed, 1 insertion(+)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_virtchnl.h 
b/drivers/net/i40e/base/i40e_virtchnl.h
index 8106582..26208f3 100644
--- a/drivers/net/i40e/base/i40e_virtchnl.h
+++ b/drivers/net/i40e/base/i40e_virtchnl.h
@@ -163,6 +163,7 @@ struct i40e_virtchnl_vsi_resource {
 #define I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x0020
 #define I40E_VIRTCHNL_VF_OFFLOAD_VLAN  0x0001
 #define I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING0x0002
+#define I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 0x0004

 struct i40e_virtchnl_vf_resource {
u16 num_vsis;
-- 
2.5.0



[dpdk-dev] [PATCH v4 24/29] i40e: expose some registers

2016-03-06 Thread Helin Zhang
This patch adds 7 new register definitions for programming the
parser, flow director and RSS blocks in the HW.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_register.h | 48 +++
 drivers/net/i40e/i40e_ethdev.c| 11 ++--
 2 files changed, 50 insertions(+), 9 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_register.h 
b/drivers/net/i40e/base/i40e_register.h
index 6e56620..fd0a723 100644
--- a/drivers/net/i40e/base/i40e_register.h
+++ b/drivers/net/i40e/base/i40e_register.h
@@ -2056,6 +2056,14 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_PRTPM_TLPIC  0x001E43C0 /* Reset: GLOBR */
 #define I40E_PRTPM_TLPIC_ETLPIC_SHIFT 0
 #define I40E_PRTPM_TLPIC_ETLPIC_MASK  I40E_MASK(0x, 
I40E_PRTPM_TLPIC_ETLPIC_SHIFT)
+#define I40E_GL_PRS_FVBM(_i) (0x00269760 + ((_i) * 4)) /* 
_i=0...3 */ /* Reset: CORER */
+#define I40E_GL_PRS_FVBM_MAX_INDEX   3
+#define I40E_GL_PRS_FVBM_FV_BYTE_INDX_SHIFT  0
+#define I40E_GL_PRS_FVBM_FV_BYTE_INDX_MASK   I40E_MASK(0x7F, 
I40E_GL_PRS_FVBM_FV_BYTE_INDX_SHIFT)
+#define I40E_GL_PRS_FVBM_RULE_BUS_INDX_SHIFT 8
+#define I40E_GL_PRS_FVBM_RULE_BUS_INDX_MASK  I40E_MASK(0x3F, 
I40E_GL_PRS_FVBM_RULE_BUS_INDX_SHIFT)
+#define I40E_GL_PRS_FVBM_MSK_ENA_SHIFT   31
+#define I40E_GL_PRS_FVBM_MSK_ENA_MASKI40E_MASK(0x1, 
I40E_GL_PRS_FVBM_MSK_ENA_SHIFT)
 #define I40E_GLRPB_DPSS   0x000AC828 /* Reset: CORER */
 #define I40E_GLRPB_DPSS_DPS_TCN_SHIFT 0
 #define I40E_GLRPB_DPSS_DPS_TCN_MASK  I40E_MASK(0xF, 
I40E_GLRPB_DPSS_DPS_TCN_SHIFT)
@@ -2227,6 +2235,14 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_PRTQF_FD_FLXINSET_MAX_INDEX   63
 #define I40E_PRTQF_FD_FLXINSET_INSET_SHIFT 0
 #define I40E_PRTQF_FD_FLXINSET_INSET_MASK  I40E_MASK(0xFF, 
I40E_PRTQF_FD_FLXINSET_INSET_SHIFT)
+#define I40E_PRTQF_FD_INSET(_i, _j)  (0x0025 + ((_i) * 64 + (_j) * 
32)) /* _i=0...63, _j=0...1 */ /* Reset: CORER */
+#define I40E_PRTQF_FD_INSET_MAX_INDEX   63
+#define I40E_PRTQF_FD_INSET_INSET_SHIFT 0
+#define I40E_PRTQF_FD_INSET_INSET_MASK  I40E_MASK(0x, 
I40E_PRTQF_FD_INSET_INSET_SHIFT)
+#define I40E_PRTQF_FD_INSET(_i, _j)  (0x0025 + ((_i) * 64 + (_j) * 
32)) /* _i=0...63, _j=0...1 */ /* Reset: CORER */
+#define I40E_PRTQF_FD_INSET_MAX_INDEX   63
+#define I40E_PRTQF_FD_INSET_INSET_SHIFT 0
+#define I40E_PRTQF_FD_INSET_INSET_MASK  I40E_MASK(0x, 
I40E_PRTQF_FD_INSET_INSET_SHIFT)
 #define I40E_PRTQF_FD_MSK(_i, _j)   (0x00252000 + ((_i) * 64 + (_j) * 32)) 
/* _i=0...63, _j=0...1 */ /* Reset: CORER */
 #define I40E_PRTQF_FD_MSK_MAX_INDEX63
 #define I40E_PRTQF_FD_MSK_MASK_SHIFT   0
@@ -5169,6 +5185,38 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_GLQF_FD_PCTYPES_MAX_INDEX   63
 #define I40E_GLQF_FD_PCTYPES_FD_PCTYPE_SHIFT 0
 #define I40E_GLQF_FD_PCTYPES_FD_PCTYPE_MASK  I40E_MASK(0x3F, 
I40E_GLQF_FD_PCTYPES_FD_PCTYPE_SHIFT)
+#define I40E_GLQF_FD_MSK(_i, _j)   (0x00267200 + ((_i) * 4 + (_j) * 8)) /* 
_i=0...1, _j=0...63 */ /* Reset: CORER */
+#define I40E_GLQF_FD_MSK_MAX_INDEX1
+#define I40E_GLQF_FD_MSK_MASK_SHIFT   0
+#define I40E_GLQF_FD_MSK_MASK_MASKI40E_MASK(0x, 
I40E_GLQF_FD_MSK_MASK_SHIFT)
+#define I40E_GLQF_FD_MSK_OFFSET_SHIFT 16
+#define I40E_GLQF_FD_MSK_OFFSET_MASK  I40E_MASK(0x3F, 
I40E_GLQF_FD_MSK_OFFSET_SHIFT)
+#define I40E_GLQF_HASH_INSET(_i, _j)  (0x00267600 + ((_i) * 4 + (_j) * 8)) 
/* _i=0...1, _j=0...63 */ /* Reset: CORER */
+#define I40E_GLQF_HASH_INSET_MAX_INDEX   1
+#define I40E_GLQF_HASH_INSET_INSET_SHIFT 0
+#define I40E_GLQF_HASH_INSET_INSET_MASK  I40E_MASK(0x, 
I40E_GLQF_HASH_INSET_INSET_SHIFT)
+#define I40E_GLQF_HASH_MSK(_i, _j)   (0x00267A00 + ((_i) * 4 + (_j) * 8)) 
/* _i=0...1, _j=0...63 */ /* Reset: CORER */
+#define I40E_GLQF_HASH_MSK_MAX_INDEX1
+#define I40E_GLQF_HASH_MSK_MASK_SHIFT   0
+#define I40E_GLQF_HASH_MSK_MASK_MASKI40E_MASK(0x, 
I40E_GLQF_HASH_MSK_MASK_SHIFT)
+#define I40E_GLQF_HASH_MSK_OFFSET_SHIFT 16
+#define I40E_GLQF_HASH_MSK_OFFSET_MASK  I40E_MASK(0x3F, 
I40E_GLQF_HASH_MSK_OFFSET_SHIFT)
+#define I40E_GLQF_ORT(_i)   (0x00268900 + ((_i) * 4)) /* _i=0...63 
*/ /* Reset: CORER */
+#define I40E_GLQF_ORT_MAX_INDEX 63
+#define I40E_GLQF_ORT_PIT_INDX_SHIFT0
+#define I40E_GLQF_ORT_PIT_INDX_MASK I40E_MASK(0x1F, 
I40E_GLQF_ORT_PIT_INDX_SHIFT)
+#define I40E_GLQF_ORT_FIELD_CNT_SHIFT   5
+#define I40E_GLQF_ORT_FIELD_CNT_MASKI40E_MASK(0x3, 
I40E_GLQF_ORT_FIELD_CNT_SHIFT)
+#define I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT 7
+#define I40E_GLQF_ORT_FLX_PAYLOAD_MASK  I40E_MASK(0x1, 
I40E_GLQF_ORT_FLX_PAYLOAD_SHIFT)
+#define I40E_GLQF_PIT(_i)  (0x00268C80 + ((_i) * 4)) /* _i=0...23 
*/ /* Reset: CORER */
+#define I40E_GLQF_PIT_MAX_INDEX23
+#define I40E_GLQF_PIT_SOURCE_OFF_SHIFT 0
+#define I40E_GLQF_PIT_SOURCE_OFF_MASK  I40E_MASK(0x1F, 
I40E_GLQF_PIT_SOURCE_OFF_SHIFT)
+#define I40E_GLQF_PIT_FSIZE_SHIFT  5

[dpdk-dev] [PATCH v4 23/29] i40e: use AQ rx control register read/write

2016-03-06 Thread Helin Zhang
RX control register read/write functions are added, as directly
read/write may fail when under stress small traffic. After the
adminq is ready, all rx control registers should be read/written
by dedicated functions.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 doc/guides/rel_notes/release_16_04.rst  |   6 ++
 drivers/net/i40e/base/i40e_adminq_cmd.h |  16 
 drivers/net/i40e/base/i40e_common.c | 126 +++-
 drivers/net/i40e/base/i40e_osdep.h  |  36 +
 drivers/net/i40e/base/i40e_prototype.h  |   8 ++
 drivers/net/i40e/i40e_ethdev.c  |  66 +
 drivers/net/i40e/i40e_ethdev_vf.c   |  28 +++
 drivers/net/i40e/i40e_fdir.c|  13 ++--
 drivers/net/i40e/i40e_pf.c  |   6 +-
 9 files changed, 248 insertions(+), 57 deletions(-)

v4:
 - Reworded the commit logs.
 - Merged all control register read/write code changes together.
 - Moved the annoucenment of fixes into this patch.

diff --git a/doc/guides/rel_notes/release_16_04.rst 
b/doc/guides/rel_notes/release_16_04.rst
index 9442018..1b1a29f 100644
--- a/doc/guides/rel_notes/release_16_04.rst
+++ b/doc/guides/rel_notes/release_16_04.rst
@@ -89,6 +89,12 @@ Drivers
   This made impossible the creation of more than one aesni_mb device
   from command line.

+* **i40e: Fixed failure of reading/writing rx control registers.**
+
+  Fixed i40e issue failing to read/write rx control registers when
+  under stress small traffic, which might result in application launch
+  failure.
+

 Libraries
 ~
diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 165df9b..12ebd35 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -165,6 +165,8 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_set_port_parameters= 0x0203,
i40e_aqc_opc_get_switch_resource_alloc  = 0x0204,
i40e_aqc_opc_set_switch_config  = 0x0205,
+   i40e_aqc_opc_rx_ctl_reg_read= 0x0206,
+   i40e_aqc_opc_rx_ctl_reg_write   = 0x0207,

i40e_aqc_opc_add_vsi= 0x0210,
i40e_aqc_opc_update_vsi_parameters  = 0x0211,
@@ -752,6 +754,20 @@ struct i40e_aqc_set_switch_config {

 I40E_CHECK_CMD_LENGTH(i40e_aqc_set_switch_config);

+/* Read Receive control registers  (direct 0x0206)
+ * Write Receive control registers (direct 0x0207)
+ * used for accessing Rx control registers that can be
+ * slow and need special handling when under high Rx load
+ */
+struct i40e_aqc_rx_ctl_reg_read_write {
+   __le32 reserved1;
+   __le32 address;
+   __le32 reserved2;
+   __le32 value;
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_rx_ctl_reg_read_write);
+
 /* Add VSI (indirect 0x0210)
  *this indirect command uses struct i40e_aqc_vsi_properties_data
  *as the indirect buffer (128 bytes)
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index e94f726..ef3425e 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5356,7 +5356,7 @@ enum i40e_status_code i40e_set_filter_control(struct 
i40e_hw *hw,
return ret;

/* Read the PF Queue Filter control register */
-   val = rd32(hw, I40E_PFQF_CTL_0);
+   val = i40e_read_rx_ctl(hw, I40E_PFQF_CTL_0);

/* Program required PE hash buckets for the PF */
val &= ~I40E_PFQF_CTL_0_PEHSIZE_MASK;
@@ -5393,7 +5393,7 @@ enum i40e_status_code i40e_set_filter_control(struct 
i40e_hw *hw,
if (settings->enable_macvlan)
val |= I40E_PFQF_CTL_0_MACVLAN_ENA_MASK;

-   wr32(hw, I40E_PFQF_CTL_0, val);
+   i40e_write_rx_ctl(hw, I40E_PFQF_CTL_0, val);

return I40E_SUCCESS;
 }
@@ -6317,6 +6317,128 @@ restore_config:
return status;
 }
 #endif /* PF_DRIVER */
+
+/**
+ * i40e_aq_rx_ctl_read_register - use FW to read from an Rx control register
+ * @hw: pointer to the hw struct
+ * @reg_addr: register address
+ * @reg_val: ptr to register value
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Use the firmware to read the Rx control register,
+ * especially useful if the Rx unit is under heavy pressure
+ **/
+enum i40e_status_code i40e_aq_rx_ctl_read_register(struct i40e_hw *hw,
+   u32 reg_addr, u32 *reg_val,
+   struct i40e_asq_cmd_details *cmd_details)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_rx_ctl_reg_read_write *cmd_resp =
+   (struct i40e_aqc_rx_ctl_reg_read_write *)
+   enum i40e_status_code status;
+
+   if (reg_val == NULL)
+   return I40E_ERR_PARAM;
+
+   i40e_fill_default_direct_cmd_desc(, i40e_aqc_opc_rx_ctl_reg_read);
+
+   cmd_resp->address = CPU_TO_LE32(reg_addr);
+
+   status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
+
+   if (status == I4

[dpdk-dev] [PATCH v4 22/29] i40e/base: coding style fixes

2016-03-06 Thread Helin Zhang
It adds coding style fixes.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 9a0b787..e94f726 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -1540,9 +1540,11 @@ u32 i40e_led_get(struct i40e_hw *hw)
if (!gpio_val)
continue;

-   /* ignore gpio LED src mode entries related to the activity 
LEDs */
-   current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) 
>>
-   I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
+   /* ignore gpio LED src mode entries related to the activity
+*  LEDs
+*/
+   current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK)
+   >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
switch (current_mode) {
case I40E_COMBINED_ACTIVITY:
case I40E_FILTER_ACTIVITY:
@@ -1586,9 +1588,11 @@ void i40e_led_set(struct i40e_hw *hw, u32 mode, bool 
blink)
if (!gpio_val)
continue;

-   /* ignore gpio LED src mode entries related to the activity 
LEDs */
-   current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK) 
>>
-   I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
+   /* ignore gpio LED src mode entries related to the activity
+* LEDs
+*/
+   current_mode = ((gpio_val & I40E_GLGEN_GPIO_CTL_LED_MODE_MASK)
+   >> I40E_GLGEN_GPIO_CTL_LED_MODE_SHIFT);
switch (current_mode) {
case I40E_COMBINED_ACTIVITY:
case I40E_FILTER_ACTIVITY:
@@ -2821,6 +2825,7 @@ enum i40e_status_code i40e_aq_get_veb_parameters(struct 
i40e_hw *hw,
*vebs_free = LE16_TO_CPU(cmd_resp->vebs_free);
if (floating) {
u16 flags = LE16_TO_CPU(cmd_resp->veb_flags);
+
if (flags & I40E_AQC_ADD_VEB_FLOATING)
*floating = true;
else
@@ -5471,7 +5476,7 @@ void 
i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
u16 ethtype = I40E_FLOW_CONTROL_ETHTYPE;
enum i40e_status_code status;

-   status = i40e_aq_add_rem_control_packet_filter(hw, 0, ethtype, flag,
+   status = i40e_aq_add_rem_control_packet_filter(hw, NULL, ethtype, flag,
   seid, 0, true, NULL,
   NULL);
if (status)
-- 
2.5.0



[dpdk-dev] [PATCH v4 21/29] i40e/base: save off VSI resource count

2016-03-06 Thread Helin Zhang
When updating a VSI, save off the number of allocated and
unallocated VSIs as we do when adding a VSI.

Signed-off-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 6 ++
 1 file changed, 6 insertions(+)

v4:
 - Reworded the commit logs.

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 925bb1c..9a0b787 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2467,6 +2467,9 @@ enum i40e_status_code i40e_aq_update_vsi_params(struct 
i40e_hw *hw,
struct i40e_aq_desc desc;
struct i40e_aqc_add_get_update_vsi *cmd =
(struct i40e_aqc_add_get_update_vsi *)
+   struct i40e_aqc_add_get_update_vsi_completion *resp =
+   (struct i40e_aqc_add_get_update_vsi_completion *)
+   
enum i40e_status_code status;

i40e_fill_default_direct_cmd_desc(,
@@ -2478,6 +2481,9 @@ enum i40e_status_code i40e_aq_update_vsi_params(struct 
i40e_hw *hw,
status = i40e_asq_send_command(hw, , _ctx->info,
sizeof(vsi_ctx->info), cmd_details);

+   vsi_ctx->vsis_allocated = LE16_TO_CPU(resp->vsi_used);
+   vsi_ctx->vsis_unallocated = LE16_TO_CPU(resp->vsi_free);
+
return status;
 }

-- 
2.5.0



  1   2   3   4   5   6   7   8   9   >