[dpdk-dev] ixgbe: account more Rx errors Issue

2015-09-06 Thread Tahhan, Maryam
> From: Andriy Berestovskyy [mailto:aber at semihalf.com]
> Sent: Friday, September 4, 2015 5:59 PM
> To: Tahhan, Maryam
> Cc: dev at dpdk.org; Olivier MATZ
> Subject: Re: ixgbe: account more Rx errors Issue
> 
> Hi Maryam,
> Please see below.
> 
> > XEC counts the Number of receive IPv4, TCP, UDP or SCTP XSUM errors
> 
> Please note than UDP checksum is optional for IPv4, but UDP packets with
> zero checksum hit XEC.
> 

I understand, but this is what the hardware register is picking up and what I 
included previously is the definitions of the registers from the datasheet.

> > And general crc errors counts Counts the number of receive packets with
> CRC errors.
> 
> Let me explain you with an example.
> 
> DPDK 2.0 behavior:
> host A sends 10M IPv4 UDP packets (no checksum) to host B host B stats: 9M
> ipackets + 1M ierrors (missed) = 10M
> 
> DPDK 2.1 behavior:
> host A sends 10M IPv4 UDP packets (no checksum) to host B host B stats: 9M
> ipackets + 11M in ierrors (1M missed + 10M XEC) = 20M?

Because it's hitting the 2 error registers. If you had packets with multiple 
errors that are added up as part of ierrors you'll still be getting more than 
10M errors which is why I asked for feedback on the 3 suggestions below. What 
I'm saying is the number of errors being > the number of received packets will 
be seen if you hit multiple error registers on the NIC.

> 
> > So our options are we can:
> > 1. Add only one of these into the error stats.
> > 2. We can introduce some cooking of stats in this scenario, so only add
> either or if they are equal or one is higher than the other.
> > 3. Add them all which means you can have more errors than the number of
> received packets, but TBH this is going to be the case if your packets have
> multiple errors anyway.
> 
> 4. ierrors should reflect NIC drops only.

I may have misinterpreted this, but ierrors in rte_ethdev.h ierrors is defined 
as the Total number of erroneous received packets.
Maybe we need a clear definition or a separate drop counter as I see uint64_t 
q_errors defined as: Total number of queue packets received that are dropped.

> XEC does not count drops, so IMO it should be removed from ierrors.

While it's picking up the 0 checksum as an error (which it shouldn't 
necessarily be doing), removing it could mean missing other valid L3/L4 
checksum errors... Let me experiment some more with L3/L4 checksum errors and 
crcerrs to see if we can cook the stats around this register in particular. I 
would hate to remove it and miss genuine errors 

> 
> Please note that we still can access the XEC using rte_eth_xstats_get()
> 
> 
> Regards,
> Andriy


[dpdk-dev] [PATCH 52/52] eal/common: add new i40e device id

2015-09-06 Thread Jingjing Wu
Signed-off-by: Jingjing Wu 
---
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 6 ++
 1 file changed, 6 insertions(+)

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 cf2cf70..265e66c 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -496,6 +496,9 @@ RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, 
IXGBE_DEV_ID_82599_BYPASS)
 #define I40E_DEV_ID_QSFP_B  0x1584
 #define I40E_DEV_ID_QSFP_C  0x1585
 #define I40E_DEV_ID_10G_BASE_T  0x1586
+#define I40E_DEV_ID_20G_KR2 0x1587
+#define I40E_DEV_ID_20G_KR2_A   0x1588
+#define I40E_DEV_ID_10G_BASE_T4 0x1589

 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)
@@ -506,6 +509,9 @@ RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, 
I40E_DEV_ID_QSFP_A)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_QSFP_B)
 RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_QSFP_C)
 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)

 /*** Physical FM10K devices from fm10k_type.h ***/

-- 
2.4.0



[dpdk-dev] [PATCH 51/52] i40e/base: Explicitly assign enum index for VSI type

2015-09-06 Thread Jingjing Wu
The change is to explicitly assign enum index for each VSI type
so that PF and VF always reference to the same VSI type event if the
enum lists are different.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_type.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index c38265a..9483884 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -226,14 +226,14 @@ enum i40e_set_fc_aq_failures {
 };

 enum i40e_vsi_type {
-   I40E_VSI_MAIN = 0,
-   I40E_VSI_VMDQ1,
-   I40E_VSI_VMDQ2,
-   I40E_VSI_CTRL,
-   I40E_VSI_FCOE,
-   I40E_VSI_MIRROR,
-   I40E_VSI_SRIOV,
-   I40E_VSI_FDIR,
+   I40E_VSI_MAIN   = 0,
+   I40E_VSI_VMDQ1  = 1,
+   I40E_VSI_VMDQ2  = 2,
+   I40E_VSI_CTRL   = 3,
+   I40E_VSI_FCOE   = 4,
+   I40E_VSI_MIRROR = 5,
+   I40E_VSI_SRIOV  = 6,
+   I40E_VSI_FDIR   = 7,
I40E_VSI_TYPE_UNKNOWN
 };

-- 
2.4.0



[dpdk-dev] [PATCH 50/52] i40e/base: Add ATR command bit definition for FortPark

2015-09-06 Thread Jingjing Wu
Add a new bit in the filter programming descriptor applicable to
FortPark only.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_type.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index dbe561d..c38265a 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -1296,6 +1296,12 @@ enum i40e_filter_program_desc_pcmd {
 I40E_TXD_FLTR_QW1_CMD_SHIFT)
 #define I40E_TXD_FLTR_QW1_FD_STATUS_MASK (0x3ULL << \
  I40E_TXD_FLTR_QW1_FD_STATUS_SHIFT)
+#ifdef X722_SUPPORT
+
+#define I40E_TXD_FLTR_QW1_ATR_SHIFT(0xEULL + \
+I40E_TXD_FLTR_QW1_CMD_SHIFT)
+#define I40E_TXD_FLTR_QW1_ATR_MASK BIT_ULL(I40E_TXD_FLTR_QW1_ATR_SHIFT)
+#endif

 #define I40E_TXD_FLTR_QW1_CNTINDEX_SHIFT 20
 #define I40E_TXD_FLTR_QW1_CNTINDEX_MASK(0x1FFUL << \
-- 
2.4.0



[dpdk-dev] [PATCH 49/52] i40e/base: Allow for per-device FW API version

2015-09-06 Thread Jingjing Wu
Allow for unique FW API versions for different HW

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_type.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 2175505..dbe561d 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -171,6 +171,13 @@ enum i40e_memcpy_type {
I40E_DMA_TO_NONDMA
 };

+
+#ifdef X722_SUPPORT
+#define I40E_FW_API_VERSION_MINOR_X722 0x0003
+#endif
+#define I40E_FW_API_VERSION_MINOR_X710 0x0004
+
+
 /* These are structs for managing the hardware information and the operations.
  * The structures of function pointers are filled out at init time when we
  * know for sure exactly which hardware we're working with.  This gives us the
-- 
2.4.0



[dpdk-dev] [PATCH 48/52] i40e/base: Add FortPark specific registers

2015-09-06 Thread Jingjing Wu
This patch adds registers and bit field definitions specific to FortPark.
Most of these new registers are related to PE (IWARP), Reset, NVM, RSS
and ATR changes.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_register.h | 1934 +
 1 file changed, 1934 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_register.h 
b/drivers/net/i40e/base/i40e_register.h
index 00a49a4..6e56620 100644
--- a/drivers/net/i40e/base/i40e_register.h
+++ b/drivers/net/i40e/base/i40e_register.h
@@ -3385,4 +3385,1938 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_VFQF_HREGION_OVERRIDE_ENA_7_MASK  I40E_MASK(0x1, 
I40E_VFQF_HREGION_OVERRIDE_ENA_7_SHIFT)
 #define I40E_VFQF_HREGION_REGION_7_SHIFT   29
 #define I40E_VFQF_HREGION_REGION_7_MASKI40E_MASK(0x7, 
I40E_VFQF_HREGION_REGION_7_SHIFT)
+#ifdef X722_SUPPORT
+
+#ifdef PF_DRIVER
+#define I40E_MNGSB_FDCRC   0x000B7050 /* Reset: POR */
+#define I40E_MNGSB_FDCRC_CRC_RES_SHIFT 0
+#define I40E_MNGSB_FDCRC_CRC_RES_MASK  I40E_MASK(0xFF, 
I40E_MNGSB_FDCRC_CRC_RES_SHIFT)
+#define I40E_MNGSB_FDCS   0x000B7040 /* Reset: POR */
+#define I40E_MNGSB_FDCS_CRC_CONT_SHIFT2
+#define I40E_MNGSB_FDCS_CRC_CONT_MASK I40E_MASK(0x1, 
I40E_MNGSB_FDCS_CRC_CONT_SHIFT)
+#define I40E_MNGSB_FDCS_CRC_SEED_EN_SHIFT 3
+#define I40E_MNGSB_FDCS_CRC_SEED_EN_MASK  I40E_MASK(0x1, 
I40E_MNGSB_FDCS_CRC_SEED_EN_SHIFT)
+#define I40E_MNGSB_FDCS_CRC_WR_INH_SHIFT  4
+#define I40E_MNGSB_FDCS_CRC_WR_INH_MASK   I40E_MASK(0x1, 
I40E_MNGSB_FDCS_CRC_WR_INH_SHIFT)
+#define I40E_MNGSB_FDCS_CRC_SEED_SHIFT8
+#define I40E_MNGSB_FDCS_CRC_SEED_MASK I40E_MASK(0xFF, 
I40E_MNGSB_FDCS_CRC_SEED_SHIFT)
+#define I40E_MNGSB_FDS0x000B7048 /* Reset: POR */
+#define I40E_MNGSB_FDS_START_BC_SHIFT 0
+#define I40E_MNGSB_FDS_START_BC_MASK  I40E_MASK(0xFFF, 
I40E_MNGSB_FDS_START_BC_SHIFT)
+#define I40E_MNGSB_FDS_LAST_BC_SHIFT  16
+#define I40E_MNGSB_FDS_LAST_BC_MASK   I40E_MASK(0xFFF, 
I40E_MNGSB_FDS_LAST_BC_SHIFT)
+
+#define I40E_GL_VF_CTRL_RX(_VF)   (0x00083600 + ((_VF) * 4)) /* 
_i=0...127 */ /* Reset: EMPR */
+#define I40E_GL_VF_CTRL_RX_MAX_INDEX  127
+#define I40E_GL_VF_CTRL_RX_AQ_RX_EN_SHIFT 0
+#define I40E_GL_VF_CTRL_RX_AQ_RX_EN_MASK  I40E_MASK(0x1, 
I40E_GL_VF_CTRL_RX_AQ_RX_EN_SHIFT)
+#define I40E_GL_VF_CTRL_TX(_VF)   (0x00083400 + ((_VF) * 4)) /* 
_i=0...127 */ /* Reset: EMPR */
+#define I40E_GL_VF_CTRL_TX_MAX_INDEX  127
+#define I40E_GL_VF_CTRL_TX_AQ_TX_EN_SHIFT 0
+#define I40E_GL_VF_CTRL_TX_AQ_TX_EN_MASK  I40E_MASK(0x1, 
I40E_GL_VF_CTRL_TX_AQ_TX_EN_SHIFT)
+
+#define I40E_GLCM_LAN_CACHESIZE 0x0010C4D8 /* Reset: CORER */
+#define I40E_GLCM_LAN_CACHESIZE_WORD_SIZE_SHIFT 0
+#define I40E_GLCM_LAN_CACHESIZE_WORD_SIZE_MASK  I40E_MASK(0xFFF, 
I40E_GLCM_LAN_CACHESIZE_WORD_SIZE_SHIFT)
+#define I40E_GLCM_LAN_CACHESIZE_SETS_SHIFT  12
+#define I40E_GLCM_LAN_CACHESIZE_SETS_MASK   I40E_MASK(0xF, 
I40E_GLCM_LAN_CACHESIZE_SETS_SHIFT)
+#define I40E_GLCM_LAN_CACHESIZE_WAYS_SHIFT  16
+#define I40E_GLCM_LAN_CACHESIZE_WAYS_MASK   I40E_MASK(0x3FF, 
I40E_GLCM_LAN_CACHESIZE_WAYS_SHIFT)
+#define I40E_GLCM_PE_CACHESIZE 0x00138FE4 /* Reset: CORER */
+#define I40E_GLCM_PE_CACHESIZE_WORD_SIZE_SHIFT 0
+#define I40E_GLCM_PE_CACHESIZE_WORD_SIZE_MASK  I40E_MASK(0xFFF, 
I40E_GLCM_PE_CACHESIZE_WORD_SIZE_SHIFT)
+#define I40E_GLCM_PE_CACHESIZE_SETS_SHIFT  12
+#define I40E_GLCM_PE_CACHESIZE_SETS_MASK   I40E_MASK(0xF, 
I40E_GLCM_PE_CACHESIZE_SETS_SHIFT)
+#define I40E_GLCM_PE_CACHESIZE_WAYS_SHIFT  16
+#define I40E_GLCM_PE_CACHESIZE_WAYS_MASK   I40E_MASK(0x1FF, 
I40E_GLCM_PE_CACHESIZE_WAYS_SHIFT)
+#define I40E_PFCM_PE_ERRDATA  0x00138D00 /* Reset: PFR */
+#define I40E_PFCM_PE_ERRDATA_ERROR_CODE_SHIFT 0
+#define I40E_PFCM_PE_ERRDATA_ERROR_CODE_MASK  I40E_MASK(0xF, 
I40E_PFCM_PE_ERRDATA_ERROR_CODE_SHIFT)
+#define I40E_PFCM_PE_ERRDATA_Q_TYPE_SHIFT 4
+#define I40E_PFCM_PE_ERRDATA_Q_TYPE_MASK  I40E_MASK(0x7, 
I40E_PFCM_PE_ERRDATA_Q_TYPE_SHIFT)
+#define I40E_PFCM_PE_ERRDATA_Q_NUM_SHIFT  8
+#define I40E_PFCM_PE_ERRDATA_Q_NUM_MASK   I40E_MASK(0x3, 
I40E_PFCM_PE_ERRDATA_Q_NUM_SHIFT)
+#define I40E_PFCM_PE_ERRINFO 0x00138C80 /* Reset: PFR */
+#define I40E_PFCM_PE_ERRINFO_ERROR_VALID_SHIFT   0
+#define I40E_PFCM_PE_ERRINFO_ERROR_VALID_MASKI40E_MASK(0x1, 
I40E_PFCM_PE_ERRINFO_ERROR_VALID_SHIFT)
+#define I40E_PFCM_PE_ERRINFO_ERROR_INST_SHIFT4
+#define I40E_PFCM_PE_ERRINFO_ERROR_INST_MASK I40E_MASK(0x7, 
I40E_PFCM_PE_ERRINFO_ERROR_INST_SHIFT)
+#define I40E_PFCM_PE_ERRINFO_DBL_ERROR_CNT_SHIFT 8
+#define I40E_PFCM_PE_ERRINFO_DBL_ERROR_CNT_MASK  I40E_MASK(0xFF, 
I40E_PFCM_PE_ERRINFO_DBL_ERROR_CNT_SHIFT)
+#define I40E_PFCM_PE_ERRINFO_RLU_ERROR_CNT_SHIFT 16
+#define I40E_PFCM_PE_ERRINFO_RLU_ERROR_CNT_MASK  I40E_MASK(0xFF, 
I40E_PFCM_PE_ERRINFO_RLU_ERROR_CNT_SHIFT)
+#define I40E_PFCM_PE_ERRINFO_RLS_ERROR_CNT_SHIFT 24
+#define 

[dpdk-dev] [PATCH 47/52] i40e/base: Increase pf reset max loop limit

2015-09-06 Thread Jingjing Wu
With latest LANconf and NVMupdate tools, pf_reset failed due to Firmware not
being ready, so this patch increases I40E_PF_RESET_WAIT_COUNT to 200, using
original value defined for A0 silicon, in order to make sure that FW is ready.

Test result indicates that firmware became ready at the loop count of 114.

Signed-off-by: Jingjing Wu 
---
 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 023dcbc..d7c940d 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -1281,7 +1281,7 @@ STATIC enum i40e_media_type i40e_get_media_type(struct 
i40e_hw *hw)
return media;
 }

-#define I40E_PF_RESET_WAIT_COUNT   110
+#define I40E_PF_RESET_WAIT_COUNT   200
 /**
  * i40e_pf_reset - Reset the PF
  * @hw: pointer to the hardware structure
-- 
2.4.0



[dpdk-dev] [PATCH 46/52] i40e/base: remove useless assignments

2015-09-06 Thread Jingjing Wu
The assignments of addr_high and addr_low were not only wrong because
they were assigning virtual addresses to a hardware accessed variable,
but they were shortly thereafter overwritten by the send_asq_command
call with a non-NULL third argument (buffer) with correctly formatted
data.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 727e2c3..023dcbc 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5323,8 +5323,6 @@ enum i40e_status_code 
i40e_aq_alternate_write_indirect(struct i40e_hw *hw,

cmd_resp->address = CPU_TO_LE32(addr);
cmd_resp->length = CPU_TO_LE32(dw_count);
-   cmd_resp->addr_high = CPU_TO_LE32(I40E_HI_WORD((u64)buffer));
-   cmd_resp->addr_low = CPU_TO_LE32(I40E_LO_DWORD((u64)buffer));

status = i40e_asq_send_command(hw, , buffer,
   I40E_LO_DWORD(4*dw_count), NULL);
@@ -5406,8 +5404,6 @@ enum i40e_status_code 
i40e_aq_alternate_read_indirect(struct i40e_hw *hw,

cmd_resp->address = CPU_TO_LE32(addr);
cmd_resp->length = CPU_TO_LE32(dw_count);
-   cmd_resp->addr_high = CPU_TO_LE32(I40E_HI_DWORD((u64)buffer));
-   cmd_resp->addr_low = CPU_TO_LE32(I40E_LO_DWORD((u64)buffer));

status = i40e_asq_send_command(hw, , buffer,
   I40E_LO_DWORD(4*dw_count), NULL);
-- 
2.4.0



[dpdk-dev] [PATCH 45/52] i40e/base: print FCoE capability reported by the device function

2015-09-06 Thread Jingjing Wu
This is to allow quick check for FCoE capability is enabled or not
in device function before any SW overrides.

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

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 4c995fc..727e2c3 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3540,6 +3540,9 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
}
}

+   if (p->fcoe)
+   i40e_debug(hw, I40E_DEBUG_ALL, "device is FCoE capable\n");
+
 #ifdef I40E_FCOE_ENA
/* Software override ensuring FCoE is disabled if npar or mfp
 * mode because it is not supported in these modes.
-- 
2.4.0



[dpdk-dev] [PATCH 44/52] i40e/base: ESS Support

2015-09-06 Thread Jingjing Wu
Add some delays specific to ESS/Veloce system.
This patch requires driver changes to define ESS_SUPPORT.

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

diff --git a/drivers/net/i40e/base/i40e_adminq.h 
b/drivers/net/i40e/base/i40e_adminq.h
index 1ac054e..40c86d9 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -160,6 +160,9 @@ 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 */
+#ifdef I40E_ESS_SUPPORT
+#define I40E_ASQ_CMD_TIMEOUT_ESS   5  /* msecs */
+#endif

 void i40e_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
   u16 opcode);
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 320428f..4c995fc 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -1303,7 +1303,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;
-   for (cnt = 0; cnt < grst_del + 2; cnt++) {
+#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++) {
reg = rd32(hw, I40E_GLGEN_RSTAT);
if (!(reg & I40E_GLGEN_RSTAT_DEVSTATE_MASK))
break;
-- 
2.4.0



[dpdk-dev] [PATCH 43/52] i40e/base: use INLINE macro for better cross-platform code management

2015-09-06 Thread Jingjing Wu
Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.h | 2 +-
 drivers/net/i40e/base/i40e_nvm.c| 4 ++--
 drivers/net/i40e/base/i40e_type.h   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.h 
b/drivers/net/i40e/base/i40e_adminq.h
index 434c754..1ac054e 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -119,7 +119,7 @@ struct i40e_adminq_info {
  * aq_ret: AdminQ handler error code can override aq_rc
  * aq_rc: AdminQ firmware error code to convert
  **/
-STATIC inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
+STATIC INLINE int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
 {
int aq_to_posix[] = {
0,   /* I40E_AQ_RC_OK */
diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index 00f86aa..60f2bb9 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -737,11 +737,11 @@ STATIC enum i40e_status_code i40e_nvmupd_exec_aq(struct 
i40e_hw *hw,
 STATIC enum i40e_status_code i40e_nvmupd_get_aq_result(struct i40e_hw *hw,
struct i40e_nvm_access *cmd,
u8 *bytes, int *perrno);
-STATIC inline u8 i40e_nvmupd_get_module(u32 val)
+STATIC INLINE u8 i40e_nvmupd_get_module(u32 val)
 {
return (u8)(val & I40E_NVM_MOD_PNT_MASK);
 }
-STATIC inline u8 i40e_nvmupd_get_transaction(u32 val)
+STATIC INLINE u8 i40e_nvmupd_get_transaction(u32 val)
 {
return (u8)((val & I40E_NVM_TRANS_MASK) >> I40E_NVM_TRANS_SHIFT);
 }
diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index c1722a8..2175505 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -658,7 +658,7 @@ struct i40e_hw {
 #endif /* I40E_NDIS_SUPPORT */
 };

-static inline bool i40e_is_vf(struct i40e_hw *hw)
+STATIC INLINE bool i40e_is_vf(struct i40e_hw *hw)
 {
 #ifdef X722_SUPPORT
return (hw->mac.type == I40E_MAC_VF ||
-- 
2.4.0



[dpdk-dev] [PATCH 42/52] i40e/base: FortPark changes to Rx and Tx descriptor for Outer UDP checksum offloads

2015-09-06 Thread Jingjing Wu
Fixes a minor definition change in the Rx descriptor.
Also adds FortPark specific changes to the Descriptors.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_type.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 4fca1ca..c1722a8 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -769,7 +769,11 @@ enum i40e_rx_desc_status_bits {
I40E_RX_DESC_STATUS_CRCP_SHIFT  = 4,
I40E_RX_DESC_STATUS_TSYNINDX_SHIFT  = 5, /* 2 BITS */
I40E_RX_DESC_STATUS_TSYNVALID_SHIFT = 7,
+#ifdef X722_SUPPORT
+   I40E_RX_DESC_STATUS_EXT_UDP_0_SHIFT = 8,
+#else
I40E_RX_DESC_STATUS_RESERVED1_SHIFT = 8,
+#endif

I40E_RX_DESC_STATUS_UMBCAST_SHIFT   = 9, /* 2 BITS */
I40E_RX_DESC_STATUS_FLM_SHIFT   = 11,
@@ -777,7 +781,11 @@ enum i40e_rx_desc_status_bits {
I40E_RX_DESC_STATUS_LPBK_SHIFT  = 14,
I40E_RX_DESC_STATUS_IPV6EXADD_SHIFT = 15,
I40E_RX_DESC_STATUS_RESERVED2_SHIFT = 16, /* 2 BITS */
+#ifdef X722_SUPPORT
+   I40E_RX_DESC_STATUS_INT_UDP_0_SHIFT = 18,
+#else
I40E_RX_DESC_STATUS_UDP_0_SHIFT = 18,
+#endif
I40E_RX_DESC_STATUS_LAST /* this entry must be last!!! */
 };

@@ -1155,6 +1163,10 @@ enum i40e_tx_ctx_desc_eipt_offload {
 #define I40E_TXD_CTX_QW0_DECTTL_MASK   (0xFULL << \
 I40E_TXD_CTX_QW0_DECTTL_SHIFT)

+#ifdef X722_SUPPORT
+#define I40E_TXD_CTX_QW0_L4T_CS_SHIFT  23
+#define I40E_TXD_CTX_QW0_L4T_CS_MASK   BIT_ULL(I40E_TXD_CTX_QW0_L4T_CS_SHIFT)
+#endif
 struct i40e_nop_desc {
__le64 rsvd;
__le64 dtype_cmd;
-- 
2.4.0



[dpdk-dev] [PATCH 40/52] i40e/base: add WR_CSR_PROT wol/proxy capability parsing

2015-09-06 Thread Jingjing Wu
Adds support to retrieve and parse WoL/Proxy capabilities from the
device/function list.
Also saves WR_CSR_PROT field from DEV/FUNC capabilities.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 29 +
 drivers/net/i40e/base/i40e_type.h   | 23 +++
 2 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index fe86096..320428f 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3330,6 +3330,9 @@ i40e_aq_erase_nvm_exit:
 #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
@@ -3352,6 +3355,7 @@ i40e_aq_erase_nvm_exit:
 #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
@@ -3510,6 +3514,23 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
p->fd_filters_guaranteed = number;
p->fd_filters_best_effort = logical_id;
break;
+   case I40E_DEV_FUNC_CAP_WR_CSR_PROT:
+   p->wr_csr_prot = (u64)number;
+   p->wr_csr_prot |= (u64)logical_id << 32;
+   break;
+#ifdef X722_SUPPORT
+   case I40E_DEV_FUNC_CAP_WOL_PROXY:
+   hw->num_wol_proxy_filters = (u16)number;
+   hw->wol_proxy_vsi_seid = (u16)logical_id;
+   p->apm_wol_support = phys_id & I40E_WOL_SUPPORT_MASK;
+   if (phys_id & I40E_ACPI_PROGRAMMING_METHOD_MASK)
+   p->acpi_prog_method = 
I40E_ACPI_PROGRAMMING_METHOD_AQC_FPK;
+   else
+   p->acpi_prog_method = 
I40E_ACPI_PROGRAMMING_METHOD_HW_FVL;
+   p->proxy_support = (phys_id & I40E_PROXY_SUPPORT_MASK) 
? 1 : 0;
+   p->proxy_support = p->proxy_support;
+   break;
+#endif
default:
break;
}
@@ -5609,11 +5630,11 @@ enum i40e_status_code i40e_read_bw_from_alt_ram(struct 
i40e_hw *hw,

/* Calculate the address of the min/max bw registers */
max_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET +
-   I40E_ALT_STRUCT_MAX_BW_OFFSET +
-   (I40E_ALT_STRUCT_DWORDS_PER_PF*hw->pf_id);
+ I40E_ALT_STRUCT_MAX_BW_OFFSET +
+ (I40E_ALT_STRUCT_DWORDS_PER_PF * hw->pf_id);
min_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET +
-   I40E_ALT_STRUCT_MIN_BW_OFFSET +
-   (I40E_ALT_STRUCT_DWORDS_PER_PF*hw->pf_id);
+ I40E_ALT_STRUCT_MIN_BW_OFFSET +
+ (I40E_ALT_STRUCT_DWORDS_PER_PF * hw->pf_id);

/* Read the bandwidths from alt ram */
status = i40e_aq_alternate_read(hw, max_bw_addr, max_bw,
diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index b5b5890..39d8a89 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -314,6 +314,17 @@ struct i40e_phy_info {
 #define I40E_HW_CAP_MDIO_PORT_MODE_MDIO0
 #define I40E_HW_CAP_MDIO_PORT_MODE_I2C 1

+#ifdef X722_SUPPORT
+enum i40e_acpi_programming_method {
+   I40E_ACPI_PROGRAMMING_METHOD_HW_FVL = 0,
+   I40E_ACPI_PROGRAMMING_METHOD_AQC_FPK = 1
+};
+
+#define I40E_WOL_SUPPORT_MASK  1
+#define I40E_ACPI_PROGRAMMING_METHOD_MASK  (1 << 1)
+#define I40E_PROXY_SUPPORT_MASK(1 << 2)
+
+#endif
 /* Capabilities of a PF or a VF or the whole device */
 struct i40e_hw_capabilities {
u32  switch_mode;
@@ -371,6 +382,12 @@ struct i40e_hw_capabilities {
u8 rx_buf_chain_len;
u32 enabled_tcmap;
u32 maxtc;
+   u64 wr_csr_prot;
+#ifdef X722_SUPPORT
+   bool apm_wol_support;
+   enum i40e_acpi_programming_method acpi_prog_method;
+   bool proxy_support;
+#endif
 };

 struct i40e_mac_info {
@@ -628,6 +645,12 @@ struct i40e_hw {
struct i40e_dcbx_config remote_dcbx_config; /* Peer Cfg */
struct i40e_dcbx_config desired_dcbx_config; /* CEE Desired Cfg */

+#ifdef X722_SUPPORT
+   /* WoL and proxy support */
+   u16 num_wol_proxy_filters;
+   u16 wol_proxy_vsi_seid;
+
+#endif
/* debug mask */
u32 debug_mask;
 #ifndef I40E_NDIS_SUPPORT
-- 
2.4.0



[dpdk-dev] [PATCH 39/52] i40e/base: add wol config admin queue functions

2015-09-06 Thread Jingjing Wu
Adds admin q function for "Set Wake on LAN Filter AQ"
and "Get Wake Up Reason AQ".

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 47 ++
 drivers/net/i40e/base/i40e_common.c | 87 +
 drivers/net/i40e/base/i40e_prototype.h  |  9 
 3 files changed, 143 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index c072ef8..1874653 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -270,6 +270,10 @@ 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 */
@@ -2458,5 +2462,48 @@ 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_ */
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 92b2ae8..fe86096 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5836,4 +5836,91 @@ enum i40e_status_code 
i40e_aq_set_ns_proxy_table_entry(struct i40e_hw *hw,
return status;
 }

+/**
+ * i40e_aq_set_clear_wol_filter
+ * @hw: pointer to the hw struct
+ * @filter_index: index of filter to modify (0-7)
+ * @filter: buffer containing filter to be set
+ * @set_filter: true to set filter, false to clear filter
+ * @no_wol_tco: if true, pass through packets cannot cause wake-up
+ * if false, pass through packets may cause wake-up
+ * @filter_valid: true if filter action is valid
+ * @no_wol_tco_valid: true if no WoL in TCO traffic action valid
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Set or clear WoL filter for port attached to the PF
+ **/
+enum i40e_status_code i40e_aq_set_clear_wol_filter(struct i40e_hw *hw,
+   u8 filter_index,
+   struct i40e_aqc_set_wol_filter_data *filter,
+   bool set_filter, bool no_wol_tco,
+   bool filter_valid, bool no_wol_tco_valid,
+   struct i40e_asq_cmd_details *cmd_details)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_set_wol_filter *cmd =
+   (struct i40e_aqc_set_wol_filter *)
+   enum i40e_status_code status;
+   u16 cmd_flags = 0;
+   u16 valid_flags = 0;
+   u16 buff_len = 0;
+
+   i40e_fill_default_direct_cmd_desc(, i40e_aqc_opc_set_wol_filter);
+
+   if (filter_index >= I40E_AQC_MAX_NUM_WOL_FILTERS)
+   return  I40E_ERR_PARAM;
+   cmd->filter_index = CPU_TO_LE16(filter_index);
+
+   if (set_filter) {
+   if (!filter)
+   return  I40E_ERR_PARAM;
+   cmd_flags |= I40E_AQC_SET_WOL_FILTER;
+   buff_len = sizeof(*filter);
+   }
+   if (no_wol_tco)
+   cmd_flags |= I40E_AQC_SET_WOL_FILTER_NO_TCO_WOL;
+   cmd->cmd_flags = CPU_TO_LE16(cmd_flags);
+
+   if (filter_valid)
+   valid_flags |= I40E_AQC_SET_WOL_FILTER_ACTION_VALID;
+   if (no_wol_tco_valid)
+   valid_flags |= I40E_AQC_SET_WOL_FILTER_NO_TCO_ACTION_VALID;
+   cmd->valid_flags = CPU_TO_LE16(valid_flags);
+
+   cmd->address_high = CPU_TO_LE32(I40E_HI_DWORD((u64)filter));
+   cmd->address_low = CPU_TO_LE32(I40E_LO_DWORD((u64)filter));
+
+   status = i40e_asq_send_command(hw, , filter,
+  buff_len, cmd_details);
+
+   return status;
+}
+
+/**
+ * 

[dpdk-dev] [PATCH 38/52] i40e/base: add proxy config admin q functions

2015-09-06 Thread Jingjing Wu
Adds admin q functions for "Set Proxying Configuration Command"
and "Set NS Proxy Table Entry Command".

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 41 +++
 drivers/net/i40e/base/i40e_common.c | 72 +
 drivers/net/i40e/base/i40e_prototype.h  |  8 
 3 files changed, 121 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index c98971f..c072ef8 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -272,6 +272,10 @@ 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,

@@ -2418,4 +2422,41 @@ 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 976d98d..92b2ae8 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5765,3 +5765,75 @@ enum i40e_status_code i40e_vf_reset(struct i40e_hw *hw)
  I40E_SUCCESS, NULL, 0, NULL);
 }
 #endif /* VF_DRIVER */
+#ifdef X722_SUPPORT
+
+/**
+ * i40e_aq_set_arp_proxy_config
+ * @hw: pointer to the HW structure
+ * @proxy_config - pointer to proxy config command table struct
+ * @cmd_details: pointer to command details
+ *
+ * Set ARP offload parameters from pre-populated
+ * i40e_aqc_arp_proxy_data struct
+ **/
+enum i40e_status_code i40e_aq_set_arp_proxy_config(struct i40e_hw *hw,
+   struct i40e_aqc_arp_proxy_data *proxy_config,
+   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)
+   return I40E_ERR_PARAM;
+
+   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));
+
+   status = i40e_asq_send_command(hw, , proxy_config,
+  sizeof(struct i40e_aqc_arp_proxy_data),
+  cmd_details);
+
+   return status;
+}
+
+/**
+ * i40e_aq_opc_set_ns_proxy_table_entry
+ * @hw: pointer to the HW structure
+ * @ns_proxy_table_entry: pointer to NS table entry command struct
+ * @cmd_details: pointer to command details
+ *
+ * Set IPv6 Neighbor Solicitation (NS) protocol offload parameters
+ * from pre-populated i40e_aqc_ns_proxy_data struct
+ **/
+enum i40e_status_code i40e_aq_set_ns_proxy_table_entry(struct i40e_hw *hw,
+   struct i40e_aqc_ns_proxy_data *ns_proxy_table_entry,
+   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)
+   return I40E_ERR_PARAM;
+
+   i40e_fill_default_direct_cmd_desc(,
+   i40e_aqc_opc_set_ns_proxy_table_entry);
+
+   cmd->address_high =
+   CPU_TO_LE32(I40E_HI_DWORD((u64)ns_proxy_table_entry));
+   cmd->address_low =
+   CPU_TO_LE32(I40E_LO_DWORD((u64)ns_proxy_table_entry));
+
+   status = i40e_asq_send_command(hw, , ns_proxy_table_entry,
+  sizeof(struct i40e_aqc_ns_proxy_data),
+  cmd_details);
+
+   return status;
+}
+
+#endif /* X722_SUPPORT */
diff --git a/drivers/net/i40e/base/i40e_prototype.h 

[dpdk-dev] [PATCH 37/52] i40e/base: Add AQ functions to handle RSS Key and LUT programming

2015-09-06 Thread Jingjing Wu
This is needed for FortPark RSS support.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h |  52 +++
 drivers/net/i40e/base/i40e_common.c | 160 
 drivers/net/i40e/base/i40e_prototype.h  |  13 +++
 3 files changed, 225 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index e8bab3c..c98971f 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -265,6 +265,12 @@ enum i40e_admin_queue_opc {
/* Tunnel commands */
i40e_aqc_opc_add_udp_tunnel = 0x0B00,
i40e_aqc_opc_del_udp_tunnel = 0x0B01,
+#ifdef X722_SUPPORT
+   i40e_aqc_opc_set_rss_key= 0x0B02,
+   i40e_aqc_opc_set_rss_lut= 0x0B03,
+   i40e_aqc_opc_get_rss_key= 0x0B04,
+   i40e_aqc_opc_get_rss_lut= 0x0B05,
+#endif

/* Async Events */
i40e_aqc_opc_event_lan_overflow = 0x1001,
@@ -831,6 +837,10 @@ struct i40e_aqc_vsi_properties_data {
u8  queueing_opt_flags;
 #define I40E_AQ_VSI_QUE_OPT_TCP_ENA0x10
 #define I40E_AQ_VSI_QUE_OPT_FCOE_ENA   0x20
+#ifdef X722_SUPPORT
+#define I40E_AQ_VSI_QUE_OPT_RSS_LUT_PF 0x00
+#define I40E_AQ_VSI_QUE_OPT_RSS_LUT_VSI0x40
+#endif
u8  queueing_opt_reserved[3];
/* scheduler section */
u8  up_enable_bits;
@@ -2208,6 +2218,48 @@ struct i40e_aqc_del_udp_tunnel_completion {
 };

 I40E_CHECK_CMD_LENGTH(i40e_aqc_del_udp_tunnel_completion);
+#ifdef X722_SUPPORT
+
+struct i40e_aqc_get_set_rss_key {
+#define I40E_AQC_SET_RSS_KEY_VSI_VALID (0x1 << 15)
+#define I40E_AQC_SET_RSS_KEY_VSI_ID_SHIFT  0
+#define I40E_AQC_SET_RSS_KEY_VSI_ID_MASK   (0x3FF << \
+   I40E_AQC_SET_RSS_KEY_VSI_ID_SHIFT)
+   __le16  vsi_id;
+   u8  reserved[6];
+   __le32  addr_high;
+   __le32  addr_low;
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_get_set_rss_key);
+
+struct i40e_aqc_get_set_rss_key_data {
+   u8 standard_rss_key[0x28];
+   u8 extended_hash_key[0xc];
+};
+
+I40E_CHECK_STRUCT_LEN(0x34, i40e_aqc_get_set_rss_key_data);
+
+struct  i40e_aqc_get_set_rss_lut {
+#define I40E_AQC_SET_RSS_LUT_VSI_VALID (0x1 << 15)
+#define I40E_AQC_SET_RSS_LUT_VSI_ID_SHIFT  0
+#define I40E_AQC_SET_RSS_LUT_VSI_ID_MASK   (0x3FF << \
+   I40E_AQC_SET_RSS_LUT_VSI_ID_SHIFT)
+   __le16  vsi_id;
+#define I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT  0
+#define I40E_AQC_SET_RSS_LUT_TABLE_TYPE_MASK   (0x1 << \
+   I40E_AQC_SET_RSS_LUT_TABLE_TYPE_SHIFT)
+
+#define I40E_AQC_SET_RSS_LUT_TABLE_TYPE_VSI0
+#define I40E_AQC_SET_RSS_LUT_TABLE_TYPE_PF 1
+   __le16  flags;
+   u8  reserved[4];
+   __le32  addr_high;
+   __le32  addr_low;
+};
+
+I40E_CHECK_CMD_LENGTH(i40e_aqc_get_set_rss_lut);
+#endif

 /* tunnel key structure 0x0B10 */

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 4329d68..976d98d 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -435,6 +435,166 @@ enum i40e_status_code i40e_aq_queue_shutdown(struct 
i40e_hw *hw,

return status;
 }
+#ifdef X722_SUPPORT
+
+/**
+ * i40e_aq_get_set_rss_lut
+ * @hw: pointer to the hardware structure
+ * @vsi_id: vsi fw index
+ * @pf_lut: for PF table set true, for VSI table set false
+ * @lut: pointer to the lut buffer provided by the caller
+ * @lut_size: size of the lut buffer
+ * @set: set true to set the table, false to get the table
+ *
+ * Internal function to get or set RSS look up table
+ **/
+STATIC enum i40e_status_code i40e_aq_get_set_rss_lut(struct i40e_hw *hw,
+u16 vsi_id, bool pf_lut,
+u8 *lut, u16 lut_size,
+bool set)
+{
+   enum i40e_status_code status;
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_get_set_rss_lut *cmd_resp =
+  (struct i40e_aqc_get_set_rss_lut *)
+
+   if (set)
+   i40e_fill_default_direct_cmd_desc(,
+ i40e_aqc_opc_set_rss_lut);
+   else
+   i40e_fill_default_direct_cmd_desc(,
+ i40e_aqc_opc_get_rss_lut);
+
+   /* Indirect command */
+   desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
+   desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_RD);
+
+   cmd_resp->vsi_id =
+   CPU_TO_LE16((u16)((vsi_id <<
+ I40E_AQC_SET_RSS_LUT_VSI_ID_SHIFT) &
+ I40E_AQC_SET_RSS_LUT_VSI_ID_MASK));
+   cmd_resp->vsi_id |= CPU_TO_LE16((u16)I40E_AQC_SET_RSS_LUT_VSI_VALID);
+
+   if (pf_lut)
+   

[dpdk-dev] [PATCH 36/52] i40e/base: add new X722 device

2015-09-06 Thread Jingjing Wu
Add device ids for X722 devices

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 19 +++
 drivers/net/i40e/base/i40e_devids.h | 10 ++
 drivers/net/i40e/base/i40e_nvm.c|  8 
 drivers/net/i40e/base/i40e_type.h   |  9 +
 4 files changed, 46 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 6c4cea8..4329d68 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -70,6 +70,22 @@ STATIC enum i40e_status_code i40e_set_mac_type(struct 
i40e_hw *hw)
case I40E_DEV_ID_20G_KR2_A:
hw->mac.type = I40E_MAC_XL710;
break;
+#ifdef X722_SUPPORT
+#ifdef X722_A0_SUPPORT
+   case I40E_DEV_ID_X722_A0:
+#endif
+   case I40E_DEV_ID_SFP_X722:
+   case I40E_DEV_ID_1G_BASE_T_X722:
+   case I40E_DEV_ID_10G_BASE_T_X722:
+   hw->mac.type = I40E_MAC_X722;
+   break;
+#endif
+#ifdef X722_SUPPORT
+   case I40E_DEV_ID_X722_VF:
+   case I40E_DEV_ID_X722_VF_HV:
+   hw->mac.type = I40E_MAC_X722_VF;
+   break;
+#endif
case I40E_DEV_ID_VF:
case I40E_DEV_ID_VF_HV:
hw->mac.type = I40E_MAC_VF;
@@ -834,6 +850,9 @@ enum i40e_status_code i40e_init_shared_code(struct i40e_hw 
*hw)

switch (hw->mac.type) {
case I40E_MAC_XL710:
+#ifdef X722_SUPPORT
+   case I40E_MAC_X722:
+#endif
break;
default:
return I40E_ERR_DEVICE_NOT_SUPPORTED;
diff --git a/drivers/net/i40e/base/i40e_devids.h 
b/drivers/net/i40e/base/i40e_devids.h
index 39820fc..26cfd54 100644
--- a/drivers/net/i40e/base/i40e_devids.h
+++ b/drivers/net/i40e/base/i40e_devids.h
@@ -52,6 +52,16 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_DEV_ID_10G_BASE_T40x1589
 #define I40E_DEV_ID_VF 0x154C
 #define I40E_DEV_ID_VF_HV  0x1571
+#ifdef X722_SUPPORT
+#ifdef X722_A0_SUPPORT
+#define I40E_DEV_ID_X722_A00x374C
+#endif
+#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_X722_VF0x37CD
+#define I40E_DEV_ID_X722_VF_HV 0x37D9
+#endif /* X722_SUPPORT */

 #define i40e_is_40G_device(d)  ((d) == I40E_DEV_ID_QSFP_A  || \
 (d) == I40E_DEV_ID_QSFP_B  || \
diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index 10c2d77..00f86aa 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -217,6 +217,10 @@ 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)
 {
+#ifdef X722_SUPPORT
+   if (hw->mac.type == I40E_MAC_X722)
+   return i40e_read_nvm_word_aq(hw, offset, data);
+#endif
return i40e_read_nvm_word_srctl(hw, offset, data);
 }

@@ -305,6 +309,10 @@ 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)
 {
+#ifdef X722_SUPPORT
+   if (hw->mac.type == I40E_MAC_X722)
+   return i40e_read_nvm_buffer_aq(hw, offset, words, data);
+#endif
return i40e_read_nvm_buffer_srctl(hw, offset, words, data);
 }

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 2d9b4a3..b5b5890 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -184,6 +184,10 @@ enum i40e_mac_type {
I40E_MAC_X710,
I40E_MAC_XL710,
I40E_MAC_VF,
+#ifdef X722_SUPPORT
+   I40E_MAC_X722,
+   I40E_MAC_X722_VF,
+#endif
I40E_MAC_GENERIC,
 };

@@ -633,7 +637,12 @@ struct i40e_hw {

 static inline bool i40e_is_vf(struct i40e_hw *hw)
 {
+#ifdef X722_SUPPORT
+   return (hw->mac.type == I40E_MAC_VF ||
+   hw->mac.type == I40E_MAC_X722_VF);
+#else
return hw->mac.type == I40E_MAC_VF;
+#endif
 }

 struct i40e_driver_version {
-- 
2.4.0



[dpdk-dev] [PATCH 35/52] i40e/base: drop func from debug print

2015-09-06 Thread Jingjing Wu
There was one more __FUNCTION__ reference that wasn't needed.

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

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 4ffb788..998582c 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -747,16 +747,16 @@ 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,
-  "%s: ntc %d head %d.\n", __FUNCTION__, ntc,
-  rd32(hw, hw->aq.asq.head));
+  "ntc %d head %d.\n", ntc, rd32(hw, hw->aq.asq.head));

if (details->callback) {
I40E_ADMINQ_CALLBACK cb_func =
(I40E_ADMINQ_CALLBACK)details->callback;
-   i40e_memcpy(_cb, desc,
-   sizeof(struct i40e_aq_desc), 
I40E_DMA_TO_DMA);
+   i40e_memcpy(_cb, desc, sizeof(struct i40e_aq_desc),
+   I40E_DMA_TO_DMA);
cb_func(hw, _cb);
}
i40e_memset(desc, 0, sizeof(*desc), I40E_DMA_MEM);
-- 
2.4.0



[dpdk-dev] [PATCH 34/52] i40e/base: Add virtchnl op for additional solaris config

2015-09-06 Thread Jingjing Wu
In order to support some extra Solaris features the Solaris VF drivers need
additional configuration data from the PF that aren't provided with the current
virtual channel commands.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_virtchnl.h | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/base/i40e_virtchnl.h 
b/drivers/net/i40e/base/i40e_virtchnl.h
index 06de1fb5..8106582 100644
--- a/drivers/net/i40e/base/i40e_virtchnl.h
+++ b/drivers/net/i40e/base/i40e_virtchnl.h
@@ -88,7 +88,9 @@ enum i40e_virtchnl_ops {
I40E_VIRTCHNL_OP_GET_STATS = 15,
I40E_VIRTCHNL_OP_FCOE = 16,
I40E_VIRTCHNL_OP_EVENT = 17,
-   I40E_VIRTCHNL_OP_CONFIG_RSS = 18,
+#ifdef I40E_SOL_VF_SUPPORT
+   I40E_VIRTCHNL_OP_GET_ADDNL_SOL_CONFIG = 19,
+#endif
 };

 /* Virtual channel message descriptor. This overlays the admin queue
@@ -288,6 +290,23 @@ struct i40e_virtchnl_ether_addr_list {
struct i40e_virtchnl_ether_addr list[1];
 };

+#ifdef I40E_SOL_VF_SUPPORT
+/* I40E_VIRTCHNL_OP_GET_ADDNL_SOL_CONFIG
+ * VF sends this message to get the default MTU and list of additional ethernet
+ * addresses it is allowed to use.
+ * PF responds with an indirect message containing
+ * i40e_virtchnl_addnl_solaris_config with zero or more
+ * i40e_virtchnl_ether_addr structures.
+ *
+ * It is expected that this operation will only ever be needed for Solaris VFs
+ * running under a Solaris PF.
+ */
+struct i40e_virtchnl_addnl_solaris_config {
+   u16 default_mtu;
+   struct i40e_virtchnl_ether_addr_list al;
+};
+
+#endif
 /* I40E_VIRTCHNL_OP_ADD_VLAN
  * VF sends this message to add one or more VLAN tag filters for receives.
  * PF adds the filters and returns status.
-- 
2.4.0



[dpdk-dev] [PATCH 33/52] i40e/base: Add definition of GLINT_CTL register

2015-09-06 Thread Jingjing Wu
Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_register.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_register.h 
b/drivers/net/i40e/base/i40e_register.h
index 4cc2b90..00a49a4 100644
--- a/drivers/net/i40e/base/i40e_register.h
+++ b/drivers/net/i40e/base/i40e_register.h
@@ -882,6 +882,13 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_PFINT_CEQCTL_CAUSE_ENA_MASK   I40E_MASK(0x1, 
I40E_PFINT_CEQCTL_CAUSE_ENA_SHIFT)
 #define I40E_PFINT_CEQCTL_INTEVENT_SHIFT   31
 #define I40E_PFINT_CEQCTL_INTEVENT_MASKI40E_MASK(0x1, 
I40E_PFINT_CEQCTL_INTEVENT_SHIFT)
+#define I40E_GLINT_CTL 0x0003F800 /* Reset: CORER */
+#define I40E_GLINT_CTL_DIS_AUTOMASK_PF0_SHIFT  0
+#define I40E_GLINT_CTL_DIS_AUTOMASK_PF0_MASK   I40E_MASK(0x1, 
I40E_GLINT_CTL_DIS_AUTOMASK_PF0_SHIFT)
+#define I40E_GLINT_CTL_DIS_AUTOMASK_VF0_SHIFT  1
+#define I40E_GLINT_CTL_DIS_AUTOMASK_VF0_MASK   I40E_MASK(0x1, 
I40E_GLINT_CTL_DIS_AUTOMASK_VF0_SHIFT)
+#define I40E_GLINT_CTL_DIS_AUTOMASK_N_SHIFT2
+#define I40E_GLINT_CTL_DIS_AUTOMASK_N_MASK I40E_MASK(0x1, 
I40E_GLINT_CTL_DIS_AUTOMASK_N_SHIFT)
 #define I40E_PFINT_DYN_CTL0   0x00038480 /* Reset: PFR */
 #define I40E_PFINT_DYN_CTL0_INTENA_SHIFT  0
 #define I40E_PFINT_DYN_CTL0_INTENA_MASK   I40E_MASK(0x1, 
I40E_PFINT_DYN_CTL0_INTENA_SHIFT)
-- 
2.4.0



[dpdk-dev] [PATCH 32/52] i40e/base: Handle admin Q timeout when releasing NVM

2015-09-06 Thread Jingjing Wu
There are some rare cases where the release resource call will return an
admin Q timeout. In these cases the code needs to try to release the
resource again until it succeeds or it times out.

Also add little endian conversion for checksum

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_nvm.c | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index 1c93c56..10c2d77 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -157,10 +157,26 @@ i40e_i40e_acquire_nvm_exit:
  **/
 void i40e_release_nvm(struct i40e_hw *hw)
 {
+   enum i40e_status_code ret_code = I40E_SUCCESS;
+   u32 total_delay = 0;
+
DEBUGFUNC("i40e_release_nvm");

-   if (!hw->nvm.blank_nvm_mode)
-   i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
+   if (hw->nvm.blank_nvm_mode)
+   return;
+
+   ret_code = i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
+
+   /* there are some rare cases when trying to release the resource
+* results in an admin Q timeout, so handle them correctly
+*/
+   while ((ret_code == I40E_ERR_ADMIN_QUEUE_TIMEOUT) &&
+  (total_delay < hw->aq.asq_cmd_timeout)) {
+   i40e_msec_delay(1);
+   ret_code = i40e_aq_release_resource(hw,
+   I40E_NVM_RESOURCE_ID, 0, NULL);
+   total_delay++;
+   }
 }

 /**
@@ -587,6 +603,7 @@ enum i40e_status_code i40e_calc_nvm_checksum(struct i40e_hw 
*hw, u16 *checksum)
/* Read SR page */
if ((i % I40E_SR_SECTOR_SIZE_IN_WORDS) == 0) {
u16 words = I40E_SR_SECTOR_SIZE_IN_WORDS;
+
ret_code = i40e_read_nvm_buffer(hw, i, , data);
if (ret_code != I40E_SUCCESS) {
ret_code = I40E_ERR_NVM_CHECKSUM;
@@ -632,13 +649,15 @@ enum i40e_status_code i40e_update_nvm_checksum(struct 
i40e_hw *hw)
 {
enum i40e_status_code ret_code = I40E_SUCCESS;
u16 checksum;
+   __le16 le_sum;

DEBUGFUNC("i40e_update_nvm_checksum");

ret_code = i40e_calc_nvm_checksum(hw, );
+   le_sum = CPU_TO_LE16(checksum);
if (ret_code == I40E_SUCCESS)
ret_code = i40e_write_nvm_aq(hw, 0x00, I40E_SR_SW_CHECKSUM_WORD,
-1, , true);
+1, _sum, true);

return ret_code;
 }
-- 
2.4.0



[dpdk-dev] [PATCH 31/52] i40e/base: clean up unneeded gotos

2015-09-06 Thread Jingjing Wu
Clean up some unnecessary logic jumping and drop a variable.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_hmc.c | 37 
 drivers/net/i40e/base/i40e_lan_hmc.c |  3 +--
 2 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_hmc.c b/drivers/net/i40e/base/i40e_hmc.c
index 7e2362d..75d3841 100644
--- a/drivers/net/i40e/base/i40e_hmc.c
+++ b/drivers/net/i40e/base/i40e_hmc.c
@@ -310,21 +310,15 @@ enum i40e_status_code i40e_remove_sd_bp_new(struct 
i40e_hw *hw,
u32 idx, bool is_pf)
 {
struct i40e_hmc_sd_entry *sd_entry;
-   enum i40e_status_code ret_code = I40E_SUCCESS;
+
+   if (!is_pf)
+   return I40E_NOT_SUPPORTED;

/* get the entry and decrease its ref counter */
sd_entry = _info->sd_table.sd_entry[idx];
-   if (is_pf) {
-   I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_DIRECT);
-   } else {
-   ret_code = I40E_NOT_SUPPORTED;
-   goto exit;
-   }
-   ret_code = i40e_free_dma_mem(hw, &(sd_entry->u.bp.addr));
-   if (I40E_SUCCESS != ret_code)
-   goto exit;
-exit:
-   return ret_code;
+   I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_DIRECT);
+
+   return i40e_free_dma_mem(hw, &(sd_entry->u.bp.addr));
 }

 /**
@@ -364,20 +358,13 @@ enum i40e_status_code i40e_remove_pd_page_new(struct 
i40e_hw *hw,
  struct i40e_hmc_info *hmc_info,
  u32 idx, bool is_pf)
 {
-   enum i40e_status_code ret_code = I40E_SUCCESS;
struct i40e_hmc_sd_entry *sd_entry;

+   if (!is_pf)
+   return I40E_NOT_SUPPORTED;
+
sd_entry = _info->sd_table.sd_entry[idx];
-   if (is_pf) {
-   I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_PAGED);
-   } else {
-   ret_code = I40E_NOT_SUPPORTED;
-   goto exit;
-   }
-   /* free memory here */
-   ret_code = i40e_free_dma_mem(hw, &(sd_entry->u.pd_table.pd_page_addr));
-   if (I40E_SUCCESS != ret_code)
-   goto exit;
-exit:
-   return ret_code;
+   I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_PAGED);
+
+   return i40e_free_dma_mem(hw, &(sd_entry->u.pd_table.pd_page_addr));
 }
diff --git a/drivers/net/i40e/base/i40e_lan_hmc.c 
b/drivers/net/i40e/base/i40e_lan_hmc.c
index 4eab959..6511767 100644
--- a/drivers/net/i40e/base/i40e_lan_hmc.c
+++ b/drivers/net/i40e/base/i40e_lan_hmc.c
@@ -438,9 +438,8 @@ exit_sd_error:
pd_idx1 = max(pd_idx,
  ((j - 1) * I40E_HMC_MAX_BP_COUNT));
pd_lmt1 = min(pd_lmt, (j * I40E_HMC_MAX_BP_COUNT));
-   for (i = pd_idx1; i < pd_lmt1; i++) {
+   for (i = pd_idx1; i < pd_lmt1; i++)
i40e_remove_pd_bp(hw, info->hmc_info, i);
-   }
i40e_remove_pd_page(hw, info->hmc_info, (j - 1));
break;
case I40E_SD_TYPE_DIRECT:
-- 
2.4.0



[dpdk-dev] [PATCH 30/52] i40e/base: Add support for pre-allocated pages for pd

2015-09-06 Thread Jingjing Wu
The i40e_add_pd_table_entry() routine is being modified to handle both
cases where a backing page is passed and where backing page is allocated
in i40e_add_pd_table_entry().

For pble resource management, it is more efficient for it to manage its
backing pages. For VF, pble backing page addresses will be send to PF
driver for pble resource.

The i40e_remove_pd_bp() is also modified to not free pre-allocated pages and
free only ones which were allocated in i40e_add_pd_table_entry().

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_hmc.c | 30 --
 drivers/net/i40e/base/i40e_hmc.h |  4 +++-
 drivers/net/i40e/base/i40e_lan_hmc.c |  2 +-
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_hmc.c b/drivers/net/i40e/base/i40e_hmc.c
index 6ddf8b3..7e2362d 100644
--- a/drivers/net/i40e/base/i40e_hmc.c
+++ b/drivers/net/i40e/base/i40e_hmc.c
@@ -127,6 +127,7 @@ exit:
  * @hw: pointer to our HW structure
  * @hmc_info: pointer to the HMC configuration information structure
  * @pd_index: which page descriptor index to manipulate
+ * @rsrc_pg: if not NULL, use preallocated page instead of allocating new one.
  *
  * This function:
  * 1. Initializes the pd entry
@@ -140,12 +141,14 @@ exit:
  **/
 enum i40e_status_code i40e_add_pd_table_entry(struct i40e_hw *hw,
  struct i40e_hmc_info *hmc_info,
- u32 pd_index)
+ u32 pd_index,
+ struct i40e_dma_mem *rsrc_pg)
 {
enum i40e_status_code ret_code = I40E_SUCCESS;
struct i40e_hmc_pd_table *pd_table;
struct i40e_hmc_pd_entry *pd_entry;
struct i40e_dma_mem mem;
+   struct i40e_dma_mem *page = 
u32 sd_idx, rel_pd_idx;
u64 *pd_addr;
u64 page_desc;
@@ -166,19 +169,25 @@ enum i40e_status_code i40e_add_pd_table_entry(struct 
i40e_hw *hw,
pd_table = _info->sd_table.sd_entry[sd_idx].u.pd_table;
pd_entry = _table->pd_entry[rel_pd_idx];
if (!pd_entry->valid) {
-   /* allocate a 4K backing page */
-   ret_code = i40e_allocate_dma_mem(hw, , i40e_mem_bp,
-I40E_HMC_PAGED_BP_SIZE,
-I40E_HMC_PD_BP_BUF_ALIGNMENT);
-   if (ret_code)
-   goto exit;
+   if (rsrc_pg) {
+   pd_entry->rsrc_pg = true;
+   page = rsrc_pg;
+   } else {
+   /* allocate a 4K backing page */
+   ret_code = i40e_allocate_dma_mem(hw, page, i40e_mem_bp,
+   I40E_HMC_PAGED_BP_SIZE,
+   I40E_HMC_PD_BP_BUF_ALIGNMENT);
+   if (ret_code)
+   goto exit;
+   pd_entry->rsrc_pg = false;
+   }

-   i40e_memcpy(_entry->bp.addr, ,
+   i40e_memcpy(_entry->bp.addr, page,
sizeof(struct i40e_dma_mem), I40E_NONDMA_TO_NONDMA);
pd_entry->bp.sd_pd_index = pd_index;
pd_entry->bp.entry_type = I40E_SD_TYPE_PAGED;
/* Set page address and valid bit */
-   page_desc = mem.pa | 0x1;
+   page_desc = page->pa | 0x1;

pd_addr = (u64 *)pd_table->pd_page_addr.va;
pd_addr += rel_pd_idx;
@@ -253,7 +262,8 @@ enum i40e_status_code i40e_remove_pd_bp(struct i40e_hw *hw,
I40E_INVALIDATE_PF_HMC_PD(hw, sd_idx, idx);

/* free memory here */
-   ret_code = i40e_free_dma_mem(hw, &(pd_entry->bp.addr));
+   if (!pd_entry->rsrc_pg)
+   ret_code = i40e_free_dma_mem(hw, &(pd_entry->bp.addr));
if (I40E_SUCCESS != ret_code)
goto exit;
if (!pd_table->ref_cnt)
diff --git a/drivers/net/i40e/base/i40e_hmc.h b/drivers/net/i40e/base/i40e_hmc.h
index c2cdc92..343b251 100644
--- a/drivers/net/i40e/base/i40e_hmc.h
+++ b/drivers/net/i40e/base/i40e_hmc.h
@@ -69,6 +69,7 @@ struct i40e_hmc_bp {
 struct i40e_hmc_pd_entry {
struct i40e_hmc_bp bp;
u32 sd_index;
+   bool rsrc_pg;
bool valid;
 };

@@ -225,7 +226,8 @@ enum i40e_status_code i40e_add_sd_table_entry(struct 
i40e_hw *hw,

 enum i40e_status_code i40e_add_pd_table_entry(struct i40e_hw *hw,
  struct i40e_hmc_info *hmc_info,
- u32 pd_index);
+ u32 pd_index,
+ struct i40e_dma_mem *rsrc_pg);
 enum i40e_status_code i40e_remove_pd_bp(struct i40e_hw *hw,
struct i40e_hmc_info *hmc_info,

[dpdk-dev] [PATCH 29/52] i40e/base: Additional checks for CEE APP priority validity

2015-09-06 Thread Jingjing Wu
The firmware has added additional status information to allow software
to determine if the APP priority for FCoE/iSCSI/FIP is valid or not in
CEE DCBX mode.

This patch adds to support those additional checks and will only add
applications to the software table that have oper and sync bits set
without any error.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_dcb.c | 59 +++-
 1 file changed, 40 insertions(+), 19 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_dcb.c b/drivers/net/i40e/base/i40e_dcb.c
index 65d74fa..d71387f 100644
--- a/drivers/net/i40e/base/i40e_dcb.c
+++ b/drivers/net/i40e/base/i40e_dcb.c
@@ -697,14 +697,17 @@ static void i40e_cee_to_dcb_config(
/* CEE PG data to ETS config */
dcbcfg->etscfg.maxtcs = cee_cfg->oper_num_tc;

+   /* Note that the FW creates the oper_prio_tc nibbles reversed
+* from those in the CEE Priority Group sub-TLV.
+*/
for (i = 0; i < 4; i++) {
tc = (u8)((cee_cfg->oper_prio_tc[i] &
-I40E_CEE_PGID_PRIO_1_MASK) >>
-I40E_CEE_PGID_PRIO_1_SHIFT);
-   dcbcfg->etscfg.prioritytable[i*2] =  tc;
-   tc = (u8)((cee_cfg->oper_prio_tc[i] &
 I40E_CEE_PGID_PRIO_0_MASK) >>
 I40E_CEE_PGID_PRIO_0_SHIFT);
+   dcbcfg->etscfg.prioritytable[i*2] =  tc;
+   tc = (u8)((cee_cfg->oper_prio_tc[i] &
+I40E_CEE_PGID_PRIO_1_MASK) >>
+I40E_CEE_PGID_PRIO_1_SHIFT);
dcbcfg->etscfg.prioritytable[i*2 + 1] = tc;
}

@@ -726,37 +729,55 @@ static void i40e_cee_to_dcb_config(
dcbcfg->pfc.pfcenable = cee_cfg->oper_pfc_en;
dcbcfg->pfc.pfccap = I40E_MAX_TRAFFIC_CLASS;

-   status = (tlv_status & I40E_AQC_CEE_APP_STATUS_MASK) >>
- I40E_AQC_CEE_APP_STATUS_SHIFT;
+   i = 0;
+   status = (tlv_status & I40E_AQC_CEE_FCOE_STATUS_MASK) >>
+ I40E_AQC_CEE_FCOE_STATUS_SHIFT;
err = (status & I40E_TLV_STATUS_ERR) ? 1 : 0;
sync = (status & I40E_TLV_STATUS_SYNC) ? 1 : 0;
oper = (status & I40E_TLV_STATUS_OPER) ? 1 : 0;
-   /* Add APPs if Error is False and Oper/Sync is True */
+   /* Add FCoE APP if Error is False and Oper/Sync is True */
if (!err && sync && oper) {
-   /* CEE operating configuration supports FCoE/iSCSI/FIP only */
-   dcbcfg->numapps = I40E_CEE_OPER_MAX_APPS;
-
/* FCoE APP */
-   dcbcfg->app[0].priority =
+   dcbcfg->app[i].priority =
(app_prio & I40E_AQC_CEE_APP_FCOE_MASK) >>
 I40E_AQC_CEE_APP_FCOE_SHIFT;
-   dcbcfg->app[0].selector = I40E_APP_SEL_ETHTYPE;
-   dcbcfg->app[0].protocolid = I40E_APP_PROTOID_FCOE;
+   dcbcfg->app[i].selector = I40E_APP_SEL_ETHTYPE;
+   dcbcfg->app[i].protocolid = I40E_APP_PROTOID_FCOE;
+   i++;
+   }

+   status = (tlv_status & I40E_AQC_CEE_ISCSI_STATUS_MASK) >>
+ I40E_AQC_CEE_ISCSI_STATUS_SHIFT;
+   err = (status & I40E_TLV_STATUS_ERR) ? 1 : 0;
+   sync = (status & I40E_TLV_STATUS_SYNC) ? 1 : 0;
+   oper = (status & I40E_TLV_STATUS_OPER) ? 1 : 0;
+   /* Add iSCSI APP if Error is False and Oper/Sync is True */
+   if (!err && sync && oper) {
/* iSCSI APP */
-   dcbcfg->app[1].priority =
+   dcbcfg->app[i].priority =
(app_prio & I40E_AQC_CEE_APP_ISCSI_MASK) >>
 I40E_AQC_CEE_APP_ISCSI_SHIFT;
-   dcbcfg->app[1].selector = I40E_APP_SEL_TCPIP;
-   dcbcfg->app[1].protocolid = I40E_APP_PROTOID_ISCSI;
+   dcbcfg->app[i].selector = I40E_APP_SEL_TCPIP;
+   dcbcfg->app[i].protocolid = I40E_APP_PROTOID_ISCSI;
+   i++;
+   }

+   status = (tlv_status & I40E_AQC_CEE_FIP_STATUS_MASK) >>
+ I40E_AQC_CEE_FIP_STATUS_SHIFT;
+   err = (status & I40E_TLV_STATUS_ERR) ? 1 : 0;
+   sync = (status & I40E_TLV_STATUS_SYNC) ? 1 : 0;
+   oper = (status & I40E_TLV_STATUS_OPER) ? 1 : 0;
+   /* Add FIP APP if Error is False and Oper/Sync is True */
+   if (!err && sync && oper) {
/* FIP APP */
-   dcbcfg->app[2].priority =
+   dcbcfg->app[i].priority =
(app_prio & I40E_AQC_CEE_APP_FIP_MASK) >>
 I40E_AQC_CEE_APP_FIP_SHIFT;
-   dcbcfg->app[2].selector = I40E_APP_SEL_ETHTYPE;
-   dcbcfg->app[2].protocolid = I40E_APP_PROTOID_FIP;
+   dcbcfg->app[i].selector = I40E_APP_SEL_ETHTYPE;
+   dcbcfg->app[i].protocolid = I40E_APP_PROTOID_FIP;
+   i++;
}
+   dcbcfg->numapps = i;
 }

 /**
-- 
2.4.0



[dpdk-dev] [PATCH 28/52] i40e/base: Add Tx Scheduling related AQ commands

2015-09-06 Thread Jingjing Wu
This patch adds support for AQ commands related to Tx scheduling.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c| 34 ++
 drivers/net/i40e/base/i40e_prototype.h |  9 +
 2 files changed, 43 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index df30f64..6c4cea8 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -4594,6 +4594,40 @@ enum i40e_status_code i40e_aq_config_vsi_tc_bw(struct 
i40e_hw *hw,
 }

 /**
+ * i40e_aq_config_switch_comp_ets - Enable/Disable/Modify ETS on the port
+ * @hw: pointer to the hw struct
+ * @seid: seid of the switching component connected to Physical Port
+ * @ets_data: Buffer holding ETS parameters
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum i40e_status_code i40e_aq_config_switch_comp_ets(struct i40e_hw *hw,
+   u16 seid,
+   struct i40e_aqc_configure_switching_comp_ets_data *ets_data,
+   enum i40e_admin_queue_opc opcode,
+   struct i40e_asq_cmd_details *cmd_details)
+{
+   return i40e_aq_tx_sched_cmd(hw, seid, (void *)ets_data,
+   sizeof(*ets_data), opcode, cmd_details);
+}
+
+/**
+ * i40e_aq_config_switch_comp_bw_config - Config Switch comp BW Alloc per TC
+ * @hw: pointer to the hw struct
+ * @seid: seid of the switching component
+ * @bw_data: Buffer holding enabled TCs, relative/absolute TC BW limit/credits
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum i40e_status_code i40e_aq_config_switch_comp_bw_config(struct i40e_hw *hw,
+   u16 seid,
+   struct i40e_aqc_configure_switching_comp_bw_config_data *bw_data,
+   struct i40e_asq_cmd_details *cmd_details)
+{
+   return i40e_aq_tx_sched_cmd(hw, seid, (void *)bw_data, sizeof(*bw_data),
+   i40e_aqc_opc_configure_switching_comp_bw_config,
+   cmd_details);
+}
+
+/**
  * i40e_aq_config_switch_comp_ets_bw_limit - Config Switch comp BW Limit per TC
  * @hw: pointer to the hw struct
  * @seid: seid of the switching component
diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index 5c271e3..f4f21c8 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -335,6 +335,15 @@ enum i40e_status_code 
i40e_aq_config_switch_comp_bw_limit(struct i40e_hw *hw,
 enum i40e_status_code i40e_aq_config_vsi_tc_bw(struct i40e_hw *hw, u16 seid,
struct i40e_aqc_configure_vsi_tc_bw_data *bw_data,
struct i40e_asq_cmd_details *cmd_details);
+enum i40e_status_code i40e_aq_config_switch_comp_ets(struct i40e_hw *hw,
+   u16 seid,
+   struct i40e_aqc_configure_switching_comp_ets_data *ets_data,
+   enum i40e_admin_queue_opc opcode,
+   struct i40e_asq_cmd_details *cmd_details);
+enum i40e_status_code i40e_aq_config_switch_comp_bw_config(struct i40e_hw *hw,
+   u16 seid,
+   struct i40e_aqc_configure_switching_comp_bw_config_data *bw_data,
+   struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_query_vsi_bw_config(struct i40e_hw *hw,
u16 seid,
struct i40e_aqc_query_vsi_bw_config_resp *bw_data,
-- 
2.4.0



[dpdk-dev] [PATCH 27/52] i40e/base: fixup padding issue in get_cee_dcb_cfg_v1_resp

2015-09-06 Thread Jingjing Wu
The struct i40e_aqc_get_cee_dcb_cfg_v1_resp was originally defined with
word boundary layout issues, which most compilers deal with by silently
adding padding, making the actual struct larger than designed.
This patch adds an extra byte in fields reserved3 and reserved4 to directly
acknowledge that padding.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index e80b723..e8bab3c 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -2082,6 +2082,7 @@ I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_start);
 #define I40E_AQC_CEE_APP_ISCSI_MASK(0x7 << I40E_AQC_CEE_APP_ISCSI_SHIFT)
 #define I40E_AQC_CEE_APP_FIP_SHIFT 0x8
 #define I40E_AQC_CEE_APP_FIP_MASK  (0x7 << I40E_AQC_CEE_APP_FIP_SHIFT)
+
 #define I40E_AQC_CEE_PG_STATUS_SHIFT   0x0
 #define I40E_AQC_CEE_PG_STATUS_MASK(0x7 << I40E_AQC_CEE_PG_STATUS_SHIFT)
 #define I40E_AQC_CEE_PFC_STATUS_SHIFT  0x3
@@ -2095,6 +2096,14 @@ I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_start);
 #define I40E_AQC_CEE_FIP_STATUS_SHIFT  0x10
 #define I40E_AQC_CEE_FIP_STATUS_MASK   (0x7 << I40E_AQC_CEE_FIP_STATUS_SHIFT)

+/* struct i40e_aqc_get_cee_dcb_cfg_v1_resp was originally defined with
+ * word boundary layout issues, which the Linux compilers silently deal
+ * with by adding padding, making the actual struct larger than designed.
+ * However, the FW compiler for the NIC is less lenient and complains
+ * about the struct.  Hence, the struct defined here has an extra byte in
+ * fields reserved3 and reserved4 to directly acknowledge that padding,
+ * and the new length is used in the length check macro.
+ */
 struct i40e_aqc_get_cee_dcb_cfg_v1_resp {
u8  reserved1;
u8  oper_num_tc;
@@ -2102,9 +2111,9 @@ struct i40e_aqc_get_cee_dcb_cfg_v1_resp {
u8  reserved2;
u8  oper_tc_bw[8];
u8  oper_pfc_en;
-   u8  reserved3;
+   u8  reserved3[2];
__le16  oper_app_prio;
-   u8  reserved4;
+   u8  reserved4[2];
__le16  tlv_status;
 };

-- 
2.4.0



[dpdk-dev] [PATCH 26/52] i40e/base: Add new link status defines

2015-09-06 Thread Jingjing Wu
Add the new Port link status bit and rename the link status to function
link status.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 4bbc368..e80b723 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -1721,11 +1721,13 @@ struct i40e_aqc_get_link_status {
u8  phy_type;/* i40e_aq_phy_type   */
u8  link_speed;  /* i40e_aq_link_speed */
u8  link_info;
-#define I40E_AQ_LINK_UP0x01
+#define I40E_AQ_LINK_UP0x01/* obsolete */
+#define I40E_AQ_LINK_UP_FUNCTION   0x01
 #define I40E_AQ_LINK_FAULT 0x02
 #define I40E_AQ_LINK_FAULT_TX  0x04
 #define I40E_AQ_LINK_FAULT_RX  0x08
 #define I40E_AQ_LINK_FAULT_REMOTE  0x10
+#define I40E_AQ_LINK_UP_PORT   0x20
 #define I40E_AQ_MEDIA_AVAILABLE0x40
 #define I40E_AQ_SIGNAL_DETECT  0x80
u8  an_info;
-- 
2.4.0



[dpdk-dev] [PATCH 25/52] i40e/base: fix up type clash in i40e_aq_rc_to_posix conversion

2015-09-06 Thread Jingjing Wu
The error code sent into i40e_aq_rc_to_posix() are signed values, so we
really need to treat them as such.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.h | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.h 
b/drivers/net/i40e/base/i40e_adminq.h
index 3d267bc..434c754 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -116,9 +116,10 @@ struct i40e_adminq_info {

 /**
  * i40e_aq_rc_to_posix - convert errors to user-land codes
- * aq_rc: AdminQ error code to convert
+ * aq_ret: AdminQ handler error code can override aq_rc
+ * aq_rc: AdminQ firmware error code to convert
  **/
-STATIC inline int i40e_aq_rc_to_posix(int aq_ret, u16 aq_rc)
+STATIC inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
 {
int aq_to_posix[] = {
0,   /* I40E_AQ_RC_OK */
@@ -150,8 +151,9 @@ STATIC inline int i40e_aq_rc_to_posix(int aq_ret, u16 aq_rc)
if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
return -EAGAIN;

-   if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))
+   if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]
return -ERANGE;
+
return aq_to_posix[aq_rc];
 }

-- 
2.4.0



[dpdk-dev] [PATCH 24/52] i40e/base: Wrap the register definitions for PF and VF driver

2015-09-06 Thread Jingjing Wu
There were quite a few issues when the wrong defines were getting used
in the VF driver. This patch defines a new #define PF_DRIVER.
All the PF specific register definitions are wrapped in it.

The drivers will have to be updated to use the define in the PF
driver builds. Makes for a very short register.h for VF drivers.

Also fixes the code where PF driver register fields were getting used for
VF driver.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.c   | 56 +--
 drivers/net/i40e/base/i40e_common.c   | 24 +--
 drivers/net/i40e/base/i40e_register.h |  4 +++
 3 files changed, 78 insertions(+), 6 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index b2a96fa..4ffb788 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -69,6 +69,7 @@ STATIC void i40e_adminq_init_regs(struct i40e_hw *hw)
hw->aq.arq.len  = I40E_VF_ARQLEN1;
hw->aq.arq.bal  = I40E_VF_ARQBAL1;
hw->aq.arq.bah  = I40E_VF_ARQBAH1;
+#ifdef PF_DRIVER
} else {
hw->aq.asq.tail = I40E_PF_ATQT;
hw->aq.asq.head = I40E_PF_ATQH;
@@ -80,6 +81,7 @@ STATIC void i40e_adminq_init_regs(struct i40e_hw *hw)
hw->aq.arq.len  = I40E_PF_ARQLEN;
hw->aq.arq.bal  = I40E_PF_ARQBAL;
hw->aq.arq.bah  = I40E_PF_ARQBAH;
+#endif
}
 }

@@ -316,8 +318,26 @@ STATIC enum i40e_status_code i40e_config_asq_regs(struct 
i40e_hw *hw)
wr32(hw, hw->aq.asq.tail, 0);

/* set starting point */
+#ifdef PF_DRIVER
+#ifdef INTEGRATED_VF
+   if (!i40e_is_vf(hw))
+   wr32(hw, hw->aq.asq.len, (hw->aq.num_asq_entries |
+ I40E_PF_ATQLEN_ATQENABLE_MASK));
+#else
wr32(hw, hw->aq.asq.len, (hw->aq.num_asq_entries |
  I40E_PF_ATQLEN_ATQENABLE_MASK));
+#endif /* INTEGRATED_VF */
+#endif /* PF_DRIVER */
+#ifdef VF_DRIVER
+#ifdef INTEGRATED_VF
+   if (i40e_is_vf(hw))
+   wr32(hw, hw->aq.asq.len, (hw->aq.num_asq_entries |
+ I40E_VF_ATQLEN1_ATQENABLE_MASK));
+#else
+   wr32(hw, hw->aq.asq.len, (hw->aq.num_asq_entries |
+ I40E_VF_ATQLEN1_ATQENABLE_MASK));
+#endif /* INTEGRATED_VF */
+#endif /* VF_DRIVER */
wr32(hw, hw->aq.asq.bal, I40E_LO_DWORD(hw->aq.asq.desc_buf.pa));
wr32(hw, hw->aq.asq.bah, I40E_HI_DWORD(hw->aq.asq.desc_buf.pa));

@@ -345,8 +365,26 @@ STATIC enum i40e_status_code i40e_config_arq_regs(struct 
i40e_hw *hw)
wr32(hw, hw->aq.arq.tail, 0);

/* set starting point */
+#ifdef PF_DRIVER
+#ifdef INTEGRATED_VF
+   if (!i40e_is_vf(hw))
+   wr32(hw, hw->aq.arq.len, (hw->aq.num_arq_entries |
+ I40E_PF_ARQLEN_ARQENABLE_MASK));
+#else
wr32(hw, hw->aq.arq.len, (hw->aq.num_arq_entries |
  I40E_PF_ARQLEN_ARQENABLE_MASK));
+#endif /* INTEGRATED_VF */
+#endif /* PF_DRIVER */
+#ifdef VF_DRIVER
+#ifdef INTEGRATED_VF
+   if (i40e_is_vf(hw))
+   wr32(hw, hw->aq.arq.len, (hw->aq.num_arq_entries |
+ I40E_VF_ARQLEN1_ARQENABLE_MASK));
+#else
+   wr32(hw, hw->aq.arq.len, (hw->aq.num_arq_entries |
+ I40E_VF_ARQLEN1_ARQENABLE_MASK));
+#endif /* INTEGRATED_VF */
+#endif /* VF_DRIVER */
wr32(hw, hw->aq.arq.bal, I40E_LO_DWORD(hw->aq.arq.desc_buf.pa));
wr32(hw, hw->aq.arq.bah, I40E_HI_DWORD(hw->aq.arq.desc_buf.pa));

@@ -998,7 +1036,22 @@ enum i40e_status_code i40e_clean_arq_element(struct 
i40e_hw *hw,
i40e_acquire_spinlock(>aq.arq_spinlock);

/* set next_to_use to head */
+#ifdef PF_DRIVER
+#ifdef INTEGRATED_VF
+   if (!i40e_is_vf(hw))
+   ntu = (rd32(hw, hw->aq.arq.head) & I40E_PF_ARQH_ARQH_MASK);
+#else
ntu = (rd32(hw, hw->aq.arq.head) & I40E_PF_ARQH_ARQH_MASK);
+#endif /* INTEGRATED_VF */
+#endif /* PF_DRIVER */
+#ifdef VF_DRIVER
+#ifdef INTEGRATED_VF
+   if (i40e_is_vf(hw))
+   ntu = (rd32(hw, hw->aq.arq.head) & I40E_VF_ARQH1_ARQH_MASK);
+#else
+   ntu = (rd32(hw, hw->aq.arq.head) & I40E_VF_ARQH1_ARQH_MASK);
+#endif /* INTEGRATED_VF */
+#endif /* VF_DRIVER */
if (ntu == ntc) {
/* nothing to do - shouldn't need to update ring's values */
ret_code = I40E_ERR_ADMIN_QUEUE_NO_WORK;
@@ -1093,9 +1146,6 @@ void i40e_resume_aq(struct i40e_hw *hw)
hw->aq.asq.next_to_use = 0;
hw->aq.asq.next_to_clean = 0;

-#if (I40E_VF_ATQLEN_ATQENABLE_MASK != I40E_PF_ATQLEN_ATQENABLE_MASK)
-#error I40E_VF_ATQLEN_ATQENABLE_MASK != I40E_PF_ATQLEN_ATQENABLE_MASK
-#endif
i40e_config_asq_regs(hw);

hw->aq.arq.next_to_use = 0;
diff --git a/drivers/net/i40e/base/i40e_common.c 

[dpdk-dev] [PATCH 23/52] i40e/base: Update Flex-10 related device/function capabilities

2015-09-06 Thread Jingjing Wu
The Flex10 device/function capability has been upgraded to revision 2
to include information needed to support Flex-10 DCC and DCI
configurations. This patch adds new fields to the i40e_hw_capabilities
structure and updates i40e_parse_discover_capabilities functions to
extract them from the AQ response. Naming convention has changed to use
flex10 mode instead of existing mfp_mode_1.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 24 +++-
 drivers/net/i40e/base/i40e_type.h   | 12 +++-
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index dca051f..fccbdcb 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3149,7 +3149,7 @@ i40e_aq_erase_nvm_exit:
 #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_MFP_MODE_1   0xF1
+#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
@@ -3173,6 +3173,7 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
u32 valid_functions, num_functions;
u32 number, logical_id, phys_id;
struct i40e_hw_capabilities *p;
+   u8 major_rev;
u32 i = 0;
u16 id;

@@ -3190,6 +3191,7 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
number = LE32_TO_CPU(cap->number);
logical_id = LE32_TO_CPU(cap->logical_id);
phys_id = LE32_TO_CPU(cap->phys_id);
+   major_rev = cap->major_rev;

switch (id) {
case I40E_DEV_FUNC_CAP_SWITCH_MODE:
@@ -3264,9 +3266,21 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
case I40E_DEV_FUNC_CAP_MSIX_VF:
p->num_msix_vectors_vf = number;
break;
-   case I40E_DEV_FUNC_CAP_MFP_MODE_1:
-   if (number == 1)
-   p->mfp_mode_1 = true;
+   case I40E_DEV_FUNC_CAP_FLEX10:
+   if (major_rev == 1) {
+   if (number == 1) {
+   p->flex10_enable = true;
+   p->flex10_capable = true;
+   }
+   } else {
+   /* Capability revision >= 2 */
+   if (number & 1)
+   p->flex10_enable = true;
+   if (number & 2)
+   p->flex10_capable = true;
+   }
+   p->flex10_mode = logical_id;
+   p->flex10_status = phys_id;
break;
case I40E_DEV_FUNC_CAP_CEM:
if (number == 1)
@@ -3308,7 +3322,7 @@ STATIC void i40e_parse_discover_capabilities(struct 
i40e_hw *hw, void *buff,
/* Software override ensuring FCoE is disabled if npar or mfp
 * mode because it is not supported in these modes.
 */
-   if (p->npar_enable || p->mfp_mode_1)
+   if (p->npar_enable || p->flex10_enable)
p->fcoe = false;
 #else
/* Always disable FCoE if compiled without the I40E_FCOE_ENA flag */
diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 694e202..2d9b4a3 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -328,7 +328,17 @@ struct i40e_hw_capabilities {
bool dcb;
bool fcoe;
bool iscsi; /* Indicates iSCSI enabled */
-   bool mfp_mode_1;
+   bool flex10_enable;
+   bool flex10_capable;
+   u32  flex10_mode;
+#define I40E_FLEX10_MODE_UNKNOWN   0x0
+#define I40E_FLEX10_MODE_DCC   0x1
+#define I40E_FLEX10_MODE_DCI   0x2
+
+   u32 flex10_status;
+#define I40E_FLEX10_STATUS_DCC_ERROR   0x1
+#define I40E_FLEX10_STATUS_VC_MODE 0x2
+
bool mgmt_cem;
bool ieee_1588;
bool iwarp;
-- 
2.4.0



[dpdk-dev] [PATCH 22/52] i40e/base: Add some more stats for FD SB and ATR status

2015-09-06 Thread Jingjing Wu
This will help us avoid a whole bunch of log messages when the driver
is running.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_type.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 5245795..694e202 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -1318,6 +1318,9 @@ struct i40e_hw_port_stats {
/* flow director stats */
u64 fd_atr_match;
u64 fd_sb_match;
+   u64 fd_atr_tunnel_match;
+   u32 fd_atr_status;
+   u32 fd_sb_status;
/* EEE LPI */
u32 tx_lpi_status;
u32 rx_lpi_status;
-- 
2.4.0



[dpdk-dev] [PATCH 21/52] i40e/base: Store CEE DCBX cfg from firmware and Cache the CEE TLV status

2015-09-06 Thread Jingjing Wu
This patch adds capability to query and store the CEE DCBX DesiredCfg
and RemoteCfg data from the LLDP MIB.
Added new member "desired_dcbx_config" in the i40e_hw data structure
to hold CEE only DesiredCfg data.

Store the CEE TLV status returned by firmware to allow drivers to dump that
for debug purposes.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_dcb.c  | 48 ---
 drivers/net/i40e/base/i40e_type.h |  6 +++--
 2 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_dcb.c b/drivers/net/i40e/base/i40e_dcb.c
index ab4decd..65d74fa 100644
--- a/drivers/net/i40e/base/i40e_dcb.c
+++ b/drivers/net/i40e/base/i40e_dcb.c
@@ -760,6 +760,36 @@ static void i40e_cee_to_dcb_config(
 }

 /**
+ * i40e_get_ieee_dcb_config
+ * @hw: pointer to the hw struct
+ *
+ * Get IEEE mode DCB configuration from the Firmware
+ **/
+STATIC enum i40e_status_code i40e_get_ieee_dcb_config(struct i40e_hw *hw)
+{
+   enum i40e_status_code ret = I40E_SUCCESS;
+
+   /* IEEE mode */
+   hw->local_dcbx_config.dcbx_mode = I40E_DCBX_MODE_IEEE;
+   /* Get Local DCB Config */
+   ret = i40e_aq_get_dcb_config(hw, I40E_AQ_LLDP_MIB_LOCAL, 0,
+>local_dcbx_config);
+   if (ret)
+   goto out;
+
+   /* Get Remote DCB Config */
+   ret = i40e_aq_get_dcb_config(hw, I40E_AQ_LLDP_MIB_REMOTE,
+I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE,
+>remote_dcbx_config);
+   /* Don't treat ENOENT as an error for Remote MIBs */
+   if (hw->aq.asq_last_status == I40E_AQ_RC_ENOENT)
+   ret = I40E_SUCCESS;
+
+out:
+   return ret;
+}
+
+/**
  * i40e_get_dcb_config
  * @hw: pointer to the hw struct
  *
@@ -774,7 +804,7 @@ enum i40e_status_code i40e_get_dcb_config(struct i40e_hw 
*hw)
/* 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))
-   goto ieee;
+   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)) {
@@ -783,6 +813,8 @@ enum i40e_status_code i40e_get_dcb_config(struct i40e_hw 
*hw)
if (ret == I40E_SUCCESS) {
/* CEE mode */
hw->local_dcbx_config.dcbx_mode = I40E_DCBX_MODE_CEE;
+   hw->local_dcbx_config.tlv_status =
+   LE16_TO_CPU(cee_v1_cfg.tlv_status);
i40e_cee_to_dcb_v1_config(_v1_cfg,
  >local_dcbx_config);
}
@@ -792,6 +824,8 @@ enum i40e_status_code i40e_get_dcb_config(struct i40e_hw 
*hw)
if (ret == I40E_SUCCESS) {
/* CEE mode */
hw->local_dcbx_config.dcbx_mode = I40E_DCBX_MODE_CEE;
+   hw->local_dcbx_config.tlv_status =
+   LE32_TO_CPU(cee_cfg.tlv_status);
i40e_cee_to_dcb_config(_cfg,
   >local_dcbx_config);
}
@@ -799,16 +833,14 @@ enum i40e_status_code i40e_get_dcb_config(struct i40e_hw 
*hw)

/* CEE mode not enabled try querying IEEE data */
if (hw->aq.asq_last_status == I40E_AQ_RC_ENOENT)
-   goto ieee;
-   else
+   return i40e_get_ieee_dcb_config(hw);
+
+   if (ret != I40E_SUCCESS)
goto out;

-ieee:
-   /* IEEE mode */
-   hw->local_dcbx_config.dcbx_mode = I40E_DCBX_MODE_IEEE;
-   /* Get Local DCB Config */
+   /* Get CEE DCB Desired Config */
ret = i40e_aq_get_dcb_config(hw, I40E_AQ_LLDP_MIB_LOCAL, 0,
->local_dcbx_config);
+>desired_dcbx_config);
if (ret)
goto out;

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index de01584..5245795 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -548,6 +548,7 @@ struct i40e_dcbx_config {
u8  app_mode;
 #define I40E_DCBX_APPS_NON_WILLING 0x1
u32 numapps;
+   u32 tlv_status; /* CEE mode TLV status */
struct i40e_dcb_ets_config etscfg;
struct i40e_dcb_ets_config etsrec;
struct i40e_dcb_pfc_config pfc;
@@ -609,8 +610,9 @@ struct i40e_hw {
u16 dcbx_status;

/* DCBX info */
-   struct i40e_dcbx_config local_dcbx_config;
-   struct i40e_dcbx_config remote_dcbx_config;
+   struct i40e_dcbx_config local_dcbx_config; /* Oper/Local Cfg */
+   struct i40e_dcbx_config remote_dcbx_config; /* Peer Cfg */
+   struct i40e_dcbx_config desired_dcbx_config; /* CEE Desired Cfg */

/* debug mask 

[dpdk-dev] [PATCH 20/52] i40e/base: Refactor PHY structure and add phy_capabilities enum

2015-09-06 Thread Jingjing Wu
Remove unused members in the PHY structure and add a new member to store
all the capabilities the PHY has as reported by the FW. This information will
help us determine what speeds the device is capable of when link is
down.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c |  3 +++
 drivers/net/i40e/base/i40e_type.h   | 36 +---
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 8c96f5f..dca051f 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -1447,6 +1447,9 @@ enum i40e_status_code i40e_aq_get_phy_capabilities(struct 
i40e_hw *hw,
if (hw->aq.asq_last_status == I40E_AQ_RC_EIO)
status = I40E_ERR_UNKNOWN_PHY;

+   if (report_init)
+   hw->phy.phy_types = LE32_TO_CPU(abilities->phy_type);
+
return status;
 }

diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 8618a58..de01584 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -266,14 +266,44 @@ struct i40e_link_status {
 #define I40E_MODULE_TYPE_1000BASE_T0x08
 };

+enum i40e_aq_capabilities_phy_type {
+   I40E_CAP_PHY_TYPE_SGMII = BIT(I40E_PHY_TYPE_SGMII),
+   I40E_CAP_PHY_TYPE_1000BASE_KX   = 
BIT(I40E_PHY_TYPE_1000BASE_KX),
+   I40E_CAP_PHY_TYPE_10GBASE_KX4   = 
BIT(I40E_PHY_TYPE_10GBASE_KX4),
+   I40E_CAP_PHY_TYPE_10GBASE_KR= BIT(I40E_PHY_TYPE_10GBASE_KR),
+   I40E_CAP_PHY_TYPE_40GBASE_KR4   = 
BIT(I40E_PHY_TYPE_40GBASE_KR4),
+   I40E_CAP_PHY_TYPE_XAUI  = BIT(I40E_PHY_TYPE_XAUI),
+   I40E_CAP_PHY_TYPE_XFI   = BIT(I40E_PHY_TYPE_XFI),
+   I40E_CAP_PHY_TYPE_SFI   = BIT(I40E_PHY_TYPE_SFI),
+   I40E_CAP_PHY_TYPE_XLAUI = BIT(I40E_PHY_TYPE_XLAUI),
+   I40E_CAP_PHY_TYPE_XLPPI = BIT(I40E_PHY_TYPE_XLPPI),
+   I40E_CAP_PHY_TYPE_40GBASE_CR4_CU= 
BIT(I40E_PHY_TYPE_40GBASE_CR4_CU),
+   I40E_CAP_PHY_TYPE_10GBASE_CR1_CU= 
BIT(I40E_PHY_TYPE_10GBASE_CR1_CU),
+   I40E_CAP_PHY_TYPE_10GBASE_AOC   = 
BIT(I40E_PHY_TYPE_10GBASE_AOC),
+   I40E_CAP_PHY_TYPE_40GBASE_AOC   = 
BIT(I40E_PHY_TYPE_40GBASE_AOC),
+   I40E_CAP_PHY_TYPE_100BASE_TX= BIT(I40E_PHY_TYPE_100BASE_TX),
+   I40E_CAP_PHY_TYPE_1000BASE_T= BIT(I40E_PHY_TYPE_1000BASE_T),
+   I40E_CAP_PHY_TYPE_10GBASE_T = BIT(I40E_PHY_TYPE_10GBASE_T),
+   I40E_CAP_PHY_TYPE_10GBASE_SR= BIT(I40E_PHY_TYPE_10GBASE_SR),
+   I40E_CAP_PHY_TYPE_10GBASE_LR= BIT(I40E_PHY_TYPE_10GBASE_LR),
+   I40E_CAP_PHY_TYPE_10GBASE_SFPP_CU   = 
BIT(I40E_PHY_TYPE_10GBASE_SFPP_CU),
+   I40E_CAP_PHY_TYPE_10GBASE_CR1   = 
BIT(I40E_PHY_TYPE_10GBASE_CR1),
+   I40E_CAP_PHY_TYPE_40GBASE_CR4   = 
BIT(I40E_PHY_TYPE_40GBASE_CR4),
+   I40E_CAP_PHY_TYPE_40GBASE_SR4   = 
BIT(I40E_PHY_TYPE_40GBASE_SR4),
+   I40E_CAP_PHY_TYPE_40GBASE_LR4   = 
BIT(I40E_PHY_TYPE_40GBASE_LR4),
+   I40E_CAP_PHY_TYPE_1000BASE_SX   = 
BIT(I40E_PHY_TYPE_1000BASE_SX),
+   I40E_CAP_PHY_TYPE_1000BASE_LX   = 
BIT(I40E_PHY_TYPE_1000BASE_LX),
+   I40E_CAP_PHY_TYPE_1000BASE_T_OPTICAL= 
BIT(I40E_PHY_TYPE_1000BASE_T_OPTICAL),
+   I40E_CAP_PHY_TYPE_20GBASE_KR2   = BIT(I40E_PHY_TYPE_20GBASE_KR2)
+};
+
 struct i40e_phy_info {
struct i40e_link_status link_info;
struct i40e_link_status link_info_old;
-   u32 autoneg_advertised;
-   u32 phy_id;
-   u32 module_type;
bool get_link_info;
enum i40e_media_type media_type;
+   /* all the phy types the NVM is capable of */
+   u32 phy_types;
 };

 #define I40E_HW_CAP_MAX_GPIO   30
-- 
2.4.0



[dpdk-dev] [PATCH 19/52] i40e/base: Prepare the local LLDP MIB in IEEE TLV Format

2015-09-06 Thread Jingjing Wu
This patch prepares the LLDP MIB in IEEE TLV format based on
the local dcb config.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h |   8 +-
 drivers/net/i40e/base/i40e_dcb.c| 327 
 drivers/net/i40e/base/i40e_dcb.h|   3 +
 drivers/net/i40e/base/i40e_type.h   |   2 +
 4 files changed, 339 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 6365e55..4bbc368 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -2125,7 +2125,13 @@ I40E_CHECK_STRUCT_LEN(0x20, 
i40e_aqc_get_cee_dcb_cfg_resp);
  */
 struct i40e_aqc_lldp_set_local_mib {
 #define SET_LOCAL_MIB_AC_TYPE_DCBX_SHIFT   0
-#define SET_LOCAL_MIB_AC_TYPE_DCBX_MASK(1 << 
SET_LOCAL_MIB_AC_TYPE_DCBX_SHIFT)
+#define SET_LOCAL_MIB_AC_TYPE_DCBX_MASK(1 << \
+   SET_LOCAL_MIB_AC_TYPE_DCBX_SHIFT)
+#define SET_LOCAL_MIB_AC_TYPE_LOCAL_MIB0x0
+#define SET_LOCAL_MIB_AC_TYPE_NON_WILLING_APPS_SHIFT   (1)
+#define SET_LOCAL_MIB_AC_TYPE_NON_WILLING_APPS_MASK(1 << \
+   SET_LOCAL_MIB_AC_TYPE_NON_WILLING_APPS_SHIFT)
+#define SET_LOCAL_MIB_AC_TYPE_NON_WILLING_APPS 0x1
u8  type;
u8  reserved0;
__le16  length;
diff --git a/drivers/net/i40e/base/i40e_dcb.c b/drivers/net/i40e/base/i40e_dcb.c
index 9c8e044..ab4decd 100644
--- a/drivers/net/i40e/base/i40e_dcb.c
+++ b/drivers/net/i40e/base/i40e_dcb.c
@@ -884,6 +884,333 @@ enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw)
return ret;
 }

+/**
+ * i40e_add_ieee_ets_tlv - Prepare ETS TLV in IEEE format
+ * @tlv: Fill the ETS config data in IEEE format
+ * @dcbcfg: Local store which holds the DCB Config
+ *
+ * Prepare IEEE 802.1Qaz ETS CFG TLV
+ **/
+static void i40e_add_ieee_ets_tlv(struct i40e_lldp_org_tlv *tlv,
+ struct i40e_dcbx_config *dcbcfg)
+{
+   u8 priority0, priority1, maxtcwilling = 0;
+   struct i40e_dcb_ets_config *etscfg;
+   u16 offset = 0, typelength, i;
+   u8 *buf = tlv->tlvinfo;
+   u32 ouisubtype;
+
+   typelength = (u16)((I40E_TLV_TYPE_ORG << I40E_LLDP_TLV_TYPE_SHIFT) |
+   I40E_IEEE_ETS_TLV_LENGTH);
+   tlv->typelength = I40E_HTONS(typelength);
+
+   ouisubtype = (u32)((I40E_IEEE_8021QAZ_OUI << I40E_LLDP_TLV_OUI_SHIFT) |
+   I40E_IEEE_SUBTYPE_ETS_CFG);
+   tlv->ouisubtype = I40E_HTONL(ouisubtype);
+
+   /* First Octet post subtype
+* --
+* |will-|CBS  | Re-  | Max |
+* |ing  | |served| TCs |
+* --
+* |1bit | 1bit|3 bits|3bits|
+*/
+   etscfg = >etscfg;
+   if (etscfg->willing)
+   maxtcwilling = BIT(I40E_IEEE_ETS_WILLING_SHIFT);
+   maxtcwilling |= etscfg->maxtcs & I40E_IEEE_ETS_MAXTC_MASK;
+   buf[offset] = maxtcwilling;
+
+   /* Move offset to Priority Assignment Table */
+   offset++;
+
+   /* Priority Assignment Table (4 octets)
+* Octets:|1|2|3|4|
+*-
+*|pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
+*-
+*   Bits:|7  4|3  0|7  4|3  0|7  4|3  0|7  4|3  0|
+*-
+*/
+   for (i = 0; i < 4; i++) {
+   priority0 = etscfg->prioritytable[i * 2] & 0xF;
+   priority1 = etscfg->prioritytable[i * 2 + 1] & 0xF;
+   buf[offset] = (priority0 << I40E_IEEE_ETS_PRIO_1_SHIFT) |
+   priority1;
+   offset++;
+   }
+
+   /* TC Bandwidth Table (8 octets)
+* Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
+*-
+*|tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
+*-
+*/
+   for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++)
+   buf[offset++] = etscfg->tcbwtable[i];
+
+   /* TSA Assignment Table (8 octets)
+* Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
+*-
+*|tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
+*-
+*/
+   for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++)
+   buf[offset++] = etscfg->tsatable[i];
+}
+
+/**
+ * i40e_add_ieee_etsrec_tlv - Prepare ETS Recommended TLV in IEEE format
+ * @tlv: Fill ETS Recommended TLV in IEEE format
+ * @dcbcfg: Local store which holds the DCB Config
+ *
+ * Prepare IEEE 802.1Qaz ETS REC TLV
+ **/
+static void i40e_add_ieee_etsrec_tlv(struct i40e_lldp_org_tlv *tlv,
+struct i40e_dcbx_config *dcbcfg)
+{
+  

[dpdk-dev] [PATCH 18/52] i40e/base: Add parsing for CEE DCBX TLVs

2015-09-06 Thread Jingjing Wu
This patch adds parsing for CEE DCBX TLVs from the LLDP MIB.

While the driver gets the DCB CEE operational configuration from Firmware
using the "Get CEE DCBX Oper Config" AQ command there is a need to get
the CEE DesiredCfg Tx by firmware and DCB configuration Rx from peer; for
debug and other application purposes.

Also gets rid of unused locals variables.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_dcb.c  | 191 +-
 drivers/net/i40e/base/i40e_dcb.h  |  39 
 drivers/net/i40e/base/i40e_type.h |   2 +
 3 files changed, 228 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_dcb.c b/drivers/net/i40e/base/i40e_dcb.c
index 033e52d..9c8e044 100644
--- a/drivers/net/i40e/base/i40e_dcb.c
+++ b/drivers/net/i40e/base/i40e_dcb.c
@@ -299,6 +299,188 @@ static void i40e_parse_ieee_tlv(struct i40e_lldp_org_tlv 
*tlv,
 }

 /**
+ * i40e_parse_cee_pgcfg_tlv
+ * @tlv: CEE DCBX PG CFG TLV
+ * @dcbcfg: Local store to update ETS CFG data
+ *
+ * Parses CEE DCBX PG CFG TLV
+ **/
+static void i40e_parse_cee_pgcfg_tlv(struct i40e_cee_feat_tlv *tlv,
+struct i40e_dcbx_config *dcbcfg)
+{
+   struct i40e_dcb_ets_config *etscfg;
+   u8 *buf = tlv->tlvinfo;
+   u16 offset = 0;
+   u8 priority;
+   int i;
+
+   etscfg = >etscfg;
+
+   if (tlv->en_will_err & I40E_CEE_FEAT_TLV_WILLING_MASK)
+   etscfg->willing = 1;
+
+   etscfg->cbs = 0;
+   /* Priority Group Table (4 octets)
+* Octets:|1|2|3|4|
+*-
+*|pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
+*-
+*   Bits:|7  4|3  0|7  4|3  0|7  4|3  0|7  4|3  0|
+*-
+*/
+   for (i = 0; i < 4; i++) {
+   priority = (u8)((buf[offset] & I40E_CEE_PGID_PRIO_1_MASK) >>
+I40E_CEE_PGID_PRIO_1_SHIFT);
+   etscfg->prioritytable[i * 2] =  priority;
+   priority = (u8)((buf[offset] & I40E_CEE_PGID_PRIO_0_MASK) >>
+I40E_CEE_PGID_PRIO_0_SHIFT);
+   etscfg->prioritytable[i * 2 + 1] = priority;
+   offset++;
+   }
+
+   /* PG Percentage Table (8 octets)
+* Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
+*-
+*|pg0|pg1|pg2|pg3|pg4|pg5|pg6|pg7|
+*-
+*/
+   for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++)
+   etscfg->tcbwtable[i] = buf[offset++];
+
+   /* Number of TCs supported (1 octet) */
+   etscfg->maxtcs = buf[offset];
+}
+
+/**
+ * i40e_parse_cee_pfccfg_tlv
+ * @tlv: CEE DCBX PFC CFG TLV
+ * @dcbcfg: Local store to update PFC CFG data
+ *
+ * Parses CEE DCBX PFC CFG TLV
+ **/
+static void i40e_parse_cee_pfccfg_tlv(struct i40e_cee_feat_tlv *tlv,
+ struct i40e_dcbx_config *dcbcfg)
+{
+   u8 *buf = tlv->tlvinfo;
+
+   if (tlv->en_will_err & I40E_CEE_FEAT_TLV_WILLING_MASK)
+   dcbcfg->pfc.willing = 1;
+
+   /* 
+* | PFC Enable | PFC TCs |
+* 
+* | 1 octet| 1 octet |
+*/
+   dcbcfg->pfc.pfcenable = buf[0];
+   dcbcfg->pfc.pfccap = buf[1];
+}
+
+/**
+ * i40e_parse_cee_app_tlv
+ * @tlv: CEE DCBX APP TLV
+ * @dcbcfg: Local store to update APP PRIO data
+ *
+ * Parses CEE DCBX APP PRIO TLV
+ **/
+static void i40e_parse_cee_app_tlv(struct i40e_cee_feat_tlv *tlv,
+  struct i40e_dcbx_config *dcbcfg)
+{
+   u16 length, typelength, offset = 0;
+   struct i40e_cee_app_prio *app;
+   u8 i, up, selector;
+
+   typelength = I40E_NTOHS(tlv->hdr.typelen);
+   length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >>
+  I40E_LLDP_TLV_LEN_SHIFT);
+
+   dcbcfg->numapps = length/sizeof(*app);
+   if (!dcbcfg->numapps)
+   return;
+
+   for (i = 0; i < dcbcfg->numapps; i++) {
+   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)
+   dcbcfg->app[i].selector = I40E_APP_SEL_ETHTYPE;
+   else if (selector == I40E_CEE_APP_SEL_TCPIP)
+   dcbcfg->app[i].selector = I40E_APP_SEL_TCPIP;
+   else
+   /* Keep 

[dpdk-dev] [PATCH 17/52] i40e/base: create new BIT and BIT_ULL macros

2015-09-06 Thread Jingjing Wu
Use macros for abstracting (1 << foo) to BIT(foo)
and (1ULL << foo64) to BIT_ULL(foo64) in order to match
better with linux kernel requirements.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c  |  4 ++--
 drivers/net/i40e/base/i40e_dcb.h |  8 
 drivers/net/i40e/base/i40e_diag.c| 11 ---
 drivers/net/i40e/base/i40e_hmc.h |  6 +++---
 drivers/net/i40e/base/i40e_lan_hmc.c | 24 
 drivers/net/i40e/base/i40e_nvm.c |  6 +++---
 drivers/net/i40e/base/i40e_type.h| 25 +++--
 7 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 8c8c4a9..8c96f5f 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -1393,9 +1393,9 @@ void i40e_led_set(struct i40e_hw *hw, u32 mode, bool 
blink)
blink = false;

if (blink)
-   gpio_val |= (1 << I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT);
+   gpio_val |= BIT(I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT);
else
-   gpio_val &= ~(1 << I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT);
+   gpio_val &= ~BIT(I40E_GLGEN_GPIO_CTL_LED_BLINK_SHIFT);

wr32(hw, I40E_GLGEN_GPIO_CTL(i), gpio_val);
break;
diff --git a/drivers/net/i40e/base/i40e_dcb.h b/drivers/net/i40e/base/i40e_dcb.h
index 2d4a3d0..841cfc3 100644
--- a/drivers/net/i40e/base/i40e_dcb.h
+++ b/drivers/net/i40e/base/i40e_dcb.h
@@ -74,9 +74,9 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_IEEE_ETS_MAXTC_SHIFT  0
 #define I40E_IEEE_ETS_MAXTC_MASK   (0x7 << I40E_IEEE_ETS_MAXTC_SHIFT)
 #define I40E_IEEE_ETS_CBS_SHIFT6
-#define I40E_IEEE_ETS_CBS_MASK (0x1 << I40E_IEEE_ETS_CBS_SHIFT)
+#define I40E_IEEE_ETS_CBS_MASK BIT(I40E_IEEE_ETS_CBS_SHIFT)
 #define I40E_IEEE_ETS_WILLING_SHIFT7
-#define I40E_IEEE_ETS_WILLING_MASK (0x1 << I40E_IEEE_ETS_WILLING_SHIFT)
+#define I40E_IEEE_ETS_WILLING_MASK BIT(I40E_IEEE_ETS_WILLING_SHIFT)
 #define I40E_IEEE_ETS_PRIO_0_SHIFT 0
 #define I40E_IEEE_ETS_PRIO_0_MASK  (0x7 << I40E_IEEE_ETS_PRIO_0_SHIFT)
 #define I40E_IEEE_ETS_PRIO_1_SHIFT 4
@@ -97,9 +97,9 @@ POSSIBILITY OF SUCH DAMAGE.
 #define I40E_IEEE_PFC_CAP_SHIFT0
 #define I40E_IEEE_PFC_CAP_MASK (0xF << I40E_IEEE_PFC_CAP_SHIFT)
 #define I40E_IEEE_PFC_MBC_SHIFT6
-#define I40E_IEEE_PFC_MBC_MASK (0x1 << I40E_IEEE_PFC_MBC_SHIFT)
+#define I40E_IEEE_PFC_MBC_MASK BIT(I40E_IEEE_PFC_MBC_SHIFT)
 #define I40E_IEEE_PFC_WILLING_SHIFT7
-#define I40E_IEEE_PFC_WILLING_MASK (0x1 << I40E_IEEE_PFC_WILLING_SHIFT)
+#define I40E_IEEE_PFC_WILLING_MASK BIT(I40E_IEEE_PFC_WILLING_SHIFT)

 /* Defines for IEEE APP TLV */
 #define I40E_IEEE_APP_SEL_SHIFT0
diff --git a/drivers/net/i40e/base/i40e_diag.c 
b/drivers/net/i40e/base/i40e_diag.c
index 55787c7..c3c76a0 100644
--- a/drivers/net/i40e/base/i40e_diag.c
+++ b/drivers/net/i40e/base/i40e_diag.c
@@ -156,13 +156,10 @@ enum i40e_status_code i40e_diag_eeprom_test(struct 
i40e_hw *hw)
ret_code = i40e_read_nvm_word(hw, I40E_SR_NVM_CONTROL_WORD, _val);
if ((ret_code == I40E_SUCCESS) &&
((reg_val & I40E_SR_CONTROL_WORD_1_MASK) ==
-(0x01 << I40E_SR_CONTROL_WORD_1_SHIFT))) {
-   ret_code = i40e_validate_nvm_checksum(hw, NULL);
-   } else {
-   ret_code = I40E_ERR_DIAG_TEST_FAILED;
-   }
-
-   return ret_code;
+BIT(I40E_SR_CONTROL_WORD_1_SHIFT)))
+   return i40e_validate_nvm_checksum(hw, NULL);
+   else
+   return I40E_ERR_DIAG_TEST_FAILED;
 }

 /**
diff --git a/drivers/net/i40e/base/i40e_hmc.h b/drivers/net/i40e/base/i40e_hmc.h
index 41507e0..c2cdc92 100644
--- a/drivers/net/i40e/base/i40e_hmc.h
+++ b/drivers/net/i40e/base/i40e_hmc.h
@@ -133,8 +133,8 @@ struct i40e_hmc_info {
 I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT) |  \
type) == I40E_SD_TYPE_PAGED) ? 0 : 1) <<\
I40E_PFHMC_SDDATALOW_PMSDTYPE_SHIFT) |  \
-   (1 << I40E_PFHMC_SDDATALOW_PMSDVALID_SHIFT);\
-   val3 = (sd_index) | (1u << I40E_PFHMC_SDCMD_PMSDWR_SHIFT);  \
+   BIT(I40E_PFHMC_SDDATALOW_PMSDVALID_SHIFT);  \
+   val3 = (sd_index) | BIT_ULL(I40E_PFHMC_SDCMD_PMSDWR_SHIFT); \
wr32((hw), I40E_PFHMC_SDDATAHIGH, val1);\
wr32((hw), I40E_PFHMC_SDDATALOW, val2); \
wr32((hw), I40E_PFHMC_SDCMD, val3); \
@@ -153,7 +153,7 @@ struct i40e_hmc_info {
I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT) |   \
type) == I40E_SD_TYPE_PAGED) ? 0 : 1) <<\

[dpdk-dev] [PATCH 16/52] i40e/base: add VF capabilities to virtual channel interface

2015-09-06 Thread Jingjing Wu
To prepare for the changes coming up in the X722 device and future
devices, the virtual channel interface has to change slightly. The VF
driver can now report what its capable of supporting, which then informs
the PF driver when it sends the configuration information back to the
VF.

A 1.1 VF driver on a 1.0 PF driver should not send its capabilities.
Likewise, a 1.1 PF driver controlling a 1.0 VF driver should not expect
or depend upon receiving the VF capabilities.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_virtchnl.h | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_virtchnl.h 
b/drivers/net/i40e/base/i40e_virtchnl.h
index 98a2e0b..06de1fb5 100644
--- a/drivers/net/i40e/base/i40e_virtchnl.h
+++ b/drivers/net/i40e/base/i40e_virtchnl.h
@@ -117,7 +117,9 @@ struct i40e_virtchnl_msg {
  * error regardless of version mismatch.
  */
 #define I40E_VIRTCHNL_VERSION_MAJOR1
-#define I40E_VIRTCHNL_VERSION_MINOR0
+#define I40E_VIRTCHNL_VERSION_MINOR1
+#define I40E_VIRTCHNL_VERSION_MINOR_NO_VF_CAPS 0
+
 struct i40e_virtchnl_version_info {
u32 major;
u32 minor;
@@ -136,7 +138,8 @@ struct i40e_virtchnl_version_info {
  */

 /* I40E_VIRTCHNL_OP_GET_VF_RESOURCES
- * VF sends this request to PF with no parameters
+ * Version 1.0 VF sends this request to PF with no parameters
+ * Version 1.1 VF sends this request to PF with u32 bitmap of its capabilities
  * PF responds with an indirect message containing
  * i40e_virtchnl_vf_resource and one or more
  * i40e_virtchnl_vsi_resource structures.
@@ -150,10 +153,14 @@ struct i40e_virtchnl_vsi_resource {
u8 default_mac_addr[I40E_ETH_LENGTH_OF_ADDRESS];
 };
 /* VF offload flags */
-#define I40E_VIRTCHNL_VF_OFFLOAD_L20x0001
-#define I40E_VIRTCHNL_VF_OFFLOAD_IWARP 0x0002
-#define I40E_VIRTCHNL_VF_OFFLOAD_FCOE  0x0004
-#define I40E_VIRTCHNL_VF_OFFLOAD_VLAN  0x0001
+#define I40E_VIRTCHNL_VF_OFFLOAD_L20x0001
+#define I40E_VIRTCHNL_VF_OFFLOAD_IWARP 0x0002
+#define I40E_VIRTCHNL_VF_OFFLOAD_FCOE  0x0004
+#define I40E_VIRTCHNL_VF_OFFLOAD_RSS_AQ0x0008
+#define I40E_VIRTCHNL_VF_OFFLOAD_RSS_REG   0x0010
+#define I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR 0x0020
+#define I40E_VIRTCHNL_VF_OFFLOAD_VLAN  0x0001
+#define I40E_VIRTCHNL_VF_OFFLOAD_RX_POLLING0x0002

 struct i40e_virtchnl_vf_resource {
u16 num_vsis;
-- 
2.4.0



[dpdk-dev] [PATCH 15/52] i40e/base: OEM Post Update AQ command implementation

2015-09-06 Thread Jingjing Wu
Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 21 +
 drivers/net/i40e/base/i40e_common.c | 22 ++
 drivers/net/i40e/base/i40e_prototype.h  |  3 +++
 3 files changed, 46 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index aaf9f22..6365e55 100644
--- a/drivers/net/i40e/base/i40e_adminq_cmd.h
+++ b/drivers/net/i40e/base/i40e_adminq_cmd.h
@@ -234,6 +234,7 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_nvm_update = 0x0703,
i40e_aqc_opc_nvm_config_read= 0x0704,
i40e_aqc_opc_nvm_config_write   = 0x0705,
+   i40e_aqc_opc_oem_post_update= 0x0720,

/* virtualization commands */
i40e_aqc_opc_send_msg_to_pf = 0x0801,
@@ -1886,6 +1887,26 @@ struct i40e_aqc_nvm_config_data_immediate_field {

 I40E_CHECK_STRUCT_LEN(0xc, i40e_aqc_nvm_config_data_immediate_field);

+/* OEM Post Update (indirect 0x0720)
+ * no command data struct used
+ */
+ struct i40e_aqc_nvm_oem_post_update {
+#define I40E_AQ_NVM_OEM_POST_UPDATE_EXTERNAL_DATA  0x01
+   u8 sel_data;
+   u8 reserved[7];
+};
+
+I40E_CHECK_STRUCT_LEN(0x8, i40e_aqc_nvm_oem_post_update);
+
+struct i40e_aqc_nvm_oem_post_update_buffer {
+   u8 str_len;
+   u8 dev_addr;
+   __le16 eeprom_addr;
+   u8 data[36];
+};
+
+I40E_CHECK_STRUCT_LEN(0x28, i40e_aqc_nvm_oem_post_update_buffer);
+
 /* 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)
diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 3617f01..8c8c4a9 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -3061,6 +3061,28 @@ enum i40e_status_code i40e_aq_write_nvm_config(struct 
i40e_hw *hw,
 }

 /**
+ * i40e_aq_oem_post_update - triggers an OEM specific flow after update
+ * @hw: pointer to the hw struct
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum i40e_status_code i40e_aq_oem_post_update(struct i40e_hw *hw,
+   void *buff, u16 buff_size,
+   struct i40e_asq_cmd_details *cmd_details)
+{
+   struct i40e_aq_desc desc;
+   enum i40e_status_code status;
+
+   UNREFERENCED_2PARAMETER(buff, buff_size);
+
+   i40e_fill_default_direct_cmd_desc(, i40e_aqc_opc_oem_post_update);
+   status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
+   if (status && LE16_TO_CPU(desc.retval) == I40E_AQ_RC_ESRCH)
+   status = I40E_ERR_NOT_IMPLEMENTED;
+
+   return status;
+}
+
+/**
  * i40e_aq_erase_nvm
  * @hw: pointer to the hw struct
  * @module_pointer: module pointer location in words from the NVM beginning
diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index eadbebe..5c271e3 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -214,6 +214,9 @@ enum i40e_status_code i40e_aq_write_nvm_config(struct 
i40e_hw *hw,
u8 cmd_flags, void *data, u16 buf_size,
u16 element_count,
struct i40e_asq_cmd_details *cmd_details);
+enum i40e_status_code i40e_aq_oem_post_update(struct i40e_hw *hw,
+   void *buff, u16 buff_size,
+   struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_discover_capabilities(struct i40e_hw *hw,
void *buff, u16 buff_size, u16 *data_size,
enum i40e_admin_queue_opc list_type_opc,
-- 
2.4.0



[dpdk-dev] [PATCH 14/52] i40e/base: Add Debug Dump Internal Data AQ command

2015-09-06 Thread Jingjing Wu
This patch adds support for "Debug Dump Internal Data" AQ command.
It is used to dump internal firmware or hardware data for debug
purposes.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c| 57 ++
 drivers/net/i40e/base/i40e_prototype.h |  5 +++
 2 files changed, 62 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index c21beba..3617f01 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -5264,6 +5264,63 @@ void i40e_set_pci_config_data(struct i40e_hw *hw, u16 
link_status)
 }

 /**
+ * i40e_aq_debug_dump
+ * @hw: pointer to the hardware structure
+ * @cluster_id: specific cluster to dump
+ * @table_id: table id within cluster
+ * @start_index: index of line in the block to read
+ * @buff_size: dump buffer size
+ * @buff: dump buffer
+ * @ret_buff_size: actual buffer size returned
+ * @ret_next_table: next block to read
+ * @ret_next_index: next index to read
+ *
+ * Dump internal FW/HW data for debug purposes.
+ *
+ **/
+enum i40e_status_code i40e_aq_debug_dump(struct i40e_hw *hw, u8 cluster_id,
+   u8 table_id, u32 start_index, u16 buff_size,
+   void *buff, u16 *ret_buff_size,
+   u8 *ret_next_table, u32 *ret_next_index,
+   struct i40e_asq_cmd_details *cmd_details)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_debug_dump_internals *cmd =
+   (struct i40e_aqc_debug_dump_internals *)
+   struct i40e_aqc_debug_dump_internals *resp =
+   (struct i40e_aqc_debug_dump_internals *)
+   enum i40e_status_code status;
+
+   if (buff_size == 0 || !buff)
+   return I40E_ERR_PARAM;
+
+   i40e_fill_default_direct_cmd_desc(,
+ i40e_aqc_opc_debug_dump_internals);
+   /* Indirect Command */
+   desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_BUF);
+   if (buff_size > I40E_AQ_LARGE_BUF)
+   desc.flags |= CPU_TO_LE16((u16)I40E_AQ_FLAG_LB);
+
+   cmd->cluster_id = cluster_id;
+   cmd->table_id = table_id;
+   cmd->idx = CPU_TO_LE32(start_index);
+
+   desc.datalen = CPU_TO_LE16(buff_size);
+
+   status = i40e_asq_send_command(hw, , buff, buff_size, cmd_details);
+   if (!status) {
+   if (ret_buff_size != NULL)
+   *ret_buff_size = LE16_TO_CPU(desc.datalen);
+   if (ret_next_table != NULL)
+   *ret_next_table = resp->table_id;
+   if (ret_next_index != NULL)
+   *ret_next_index = LE32_TO_CPU(resp->idx);
+   }
+
+   return status;
+}
+
+/**
  * i40e_read_bw_from_alt_ram
  * @hw: pointer to the hardware structure
  * @max_bw: pointer for max_bw read
diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index 139ff19..eadbebe 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -459,6 +459,11 @@ enum i40e_status_code 
i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
u16 vsi_seid, u16 queue, bool is_add,
struct i40e_control_filter_stats *stats,
struct i40e_asq_cmd_details *cmd_details);
+enum i40e_status_code i40e_aq_debug_dump(struct i40e_hw *hw, u8 cluster_id,
+   u8 table_id, u32 start_index, u16 buff_size,
+   void *buff, u16 *ret_buff_size,
+   u8 *ret_next_table, u32 *ret_next_index,
+   struct i40e_asq_cmd_details *cmd_details);
 void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
u16 vsi_seid);
 #endif /* _I40E_PROTOTYPE_H_ */
-- 
2.4.0



[dpdk-dev] [PATCH 13/52] i40e/base: Add a workaround to drop all flow control frames

2015-09-06 Thread Jingjing Wu
This patch adds a workaround to drop any flow control frames from being
transmitted from any VSI. FW can still send Flow control frames if Flow
control is enabled.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c| 22 ++
 drivers/net/i40e/base/i40e_prototype.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 20dbb07..c21beba 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -4865,6 +4865,28 @@ enum i40e_status_code 
i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
 }

 /**
+ * i40e_add_filter_to_drop_tx_flow_control_frames- filter to drop flow control
+ * @hw: pointer to the hw struct
+ * @seid: VSI seid to add ethertype filter from
+ **/
+#define I40E_FLOW_CONTROL_ETHTYPE 0x8808
+void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
+   u16 seid)
+{
+   u16 flag = I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC |
+  I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP |
+  I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX;
+   u16 ethtype = I40E_FLOW_CONTROL_ETHTYPE;
+   enum i40e_status_code status;
+
+   status = i40e_aq_add_rem_control_packet_filter(hw, 0, ethtype, flag,
+  seid, 0, true, NULL,
+  NULL);
+   if (status)
+   DEBUGOUT("Ethtype Filter Add failed: Error pruning Tx flow 
control frames\n");
+}
+
+/**
  * i40e_aq_add_cloud_filters
  * @hw: pointer to the hardware structure
  * @seid: VSI seid to add cloud filters from
diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index ee83659..139ff19 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -459,4 +459,6 @@ enum i40e_status_code 
i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
u16 vsi_seid, u16 queue, bool is_add,
struct i40e_control_filter_stats *stats,
struct i40e_asq_cmd_details *cmd_details);
+void i40e_add_filter_to_drop_tx_flow_control_frames(struct i40e_hw *hw,
+   u16 vsi_seid);
 #endif /* _I40E_PROTOTYPE_H_ */
-- 
2.4.0



[dpdk-dev] [PATCH 12/52] i40e/base: Add promiscuous on VLAN support

2015-09-06 Thread Jingjing Wu
NFV use cases require the ability to steer packets to VSIs by VLAN tag
alone while being in promiscuous mode for multicast and unicast MAC
addresses.  These two new functions support that ability.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c| 68 ++
 drivers/net/i40e/base/i40e_prototype.h |  6 +++
 2 files changed, 74 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 2a3da6e..20dbb07 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -2054,6 +2054,74 @@ enum i40e_status_code 
i40e_aq_set_vsi_multicast_promiscuous(struct i40e_hw *hw,
 }

 /**
+ * i40e_aq_set_vsi_mc_promisc_on_vlan
+ * @hw: pointer to the hw struct
+ * @seid: vsi number
+ * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given 
VLAN
+ * @vid: The VLAN tag filter - capture any multicast packet with this VLAN tag
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum i40e_status_code i40e_aq_set_vsi_mc_promisc_on_vlan(struct i40e_hw *hw,
+   u16 seid, bool enable, u16 vid,
+   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_MULTICAST;
+
+   cmd->promiscuous_flags = CPU_TO_LE16(flags);
+   cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_MULTICAST);
+   cmd->seid = CPU_TO_LE16(seid);
+   cmd->vlan_tag = CPU_TO_LE16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
+
+   status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
+
+   return status;
+}
+
+/**
+ * i40e_aq_set_vsi_uc_promisc_on_vlan
+ * @hw: pointer to the hw struct
+ * @seid: vsi number
+ * @enable: set MAC L2 layer unicast promiscuous enable/disable for a given 
VLAN
+ * @vid: The VLAN tag filter - capture any unicast packet with this VLAN tag
+ * @cmd_details: pointer to command details structure or NULL
+ **/
+enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
+   u16 seid, bool enable, u16 vid,
+   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_UNICAST;
+
+   cmd->promiscuous_flags = CPU_TO_LE16(flags);
+   cmd->valid_flags = CPU_TO_LE16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
+   cmd->seid = CPU_TO_LE16(seid);
+   cmd->vlan_tag = CPU_TO_LE16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
+
+   status = i40e_asq_send_command(hw, , NULL, 0, cmd_details);
+
+   return status;
+}
+
+/**
  * i40e_aq_set_vsi_broadcast
  * @hw: pointer to the hw struct
  * @seid: vsi number
diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index 0c66af7..ee83659 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -149,6 +149,12 @@ 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);
 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,
+   u16 seid, bool enable, u16 vid,
+   struct i40e_asq_cmd_details *cmd_details);
+enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
+   u16 seid, bool enable, u16 vid,
+   struct i40e_asq_cmd_details *cmd_details);
 enum i40e_status_code i40e_aq_get_vsi_params(struct i40e_hw *hw,
struct i40e_vsi_context *vsi_ctx,
struct i40e_asq_cmd_details *cmd_details);
-- 
2.4.0



[dpdk-dev] [PATCH 11/52] i40e/base: add commands to nvmupdate utility

2015-09-06 Thread Jingjing Wu
Add a new GetStatus command so that the NVM update tool can query
the current status instead of doing fake write requests to probe for
readiness.
Add a facility to run AQ commands through the nvmupdate utility in order
to allow the update tools to interact with the FW and do special
commands needed for updates and configuration changes.
Add a facility to recover the result of a previously run AQ command.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.c |   3 +
 drivers/net/i40e/base/i40e_nvm.c| 201 ++--
 drivers/net/i40e/base/i40e_type.h   |   5 +
 3 files changed, 199 insertions(+), 10 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 7589b39..b2a96fa 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -687,6 +687,9 @@ enum i40e_status_code i40e_shutdown_adminq(struct i40e_hw 
*hw)
i40e_destroy_spinlock(>aq.asq_spinlock);
i40e_destroy_spinlock(>aq.arq_spinlock);

+   if (hw->nvm_buff.va)
+   i40e_free_virt_mem(hw, >nvm_buff);
+
return ret_code;
 }

diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index f4ea289..14b4e84 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -704,6 +704,12 @@ STATIC enum i40e_status_code i40e_nvmupd_nvm_write(struct 
i40e_hw *hw,
 STATIC enum i40e_status_code i40e_nvmupd_nvm_read(struct i40e_hw *hw,
  struct i40e_nvm_access *cmd,
  u8 *bytes, int *perrno);
+STATIC enum i40e_status_code i40e_nvmupd_exec_aq(struct i40e_hw *hw,
+struct i40e_nvm_access *cmd,
+u8 *bytes, int *perrno);
+STATIC enum i40e_status_code i40e_nvmupd_get_aq_result(struct i40e_hw *hw,
+   struct i40e_nvm_access *cmd,
+   u8 *bytes, int *perrno);
 STATIC inline u8 i40e_nvmupd_get_module(u32 val)
 {
return (u8)(val & I40E_NVM_MOD_PNT_MASK);
@@ -727,6 +733,9 @@ STATIC const char *i40e_nvm_update_state_str[] = {
"I40E_NVMUPD_CSUM_CON",
"I40E_NVMUPD_CSUM_SA",
"I40E_NVMUPD_CSUM_LCB",
+   "I40E_NVMUPD_STATUS",
+   "I40E_NVMUPD_EXEC_AQ",
+   "I40E_NVMUPD_GET_AQ_RESULT",
 };

 /**
@@ -743,12 +752,36 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,
  u8 *bytes, int *perrno)
 {
enum i40e_status_code status;
+   enum i40e_nvmupd_cmd upd_cmd;

DEBUGFUNC("i40e_nvmupd_command");

/* assume success */
*perrno = 0;

+   /* 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\n",
+  i40e_nvm_update_state_str[upd_cmd],
+  hw->nvmupd_state,
+  hw->aq.nvm_release_on_done);
+
+   if (upd_cmd == I40E_NVMUPD_INVALID) {
+   *perrno = -EFAULT;
+   i40e_debug(hw, I40E_DEBUG_NVM,
+  "i40e_nvmupd_validate_command returns %d errno %d\n",
+  upd_cmd, *perrno);
+   }
+
+   /* a status request returns immediately rather than
+* going into the state machine
+*/
+   if (upd_cmd == I40E_NVMUPD_STATUS) {
+   bytes[0] = hw->nvmupd_state;
+   return I40E_SUCCESS;
+   }
+
switch (hw->nvmupd_state) {
case I40E_NVMUPD_STATE_INIT:
status = i40e_nvmupd_state_init(hw, cmd, bytes, perrno);
@@ -892,6 +925,14 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct 
i40e_hw *hw,
}
break;

+   case I40E_NVMUPD_EXEC_AQ:
+   status = i40e_nvmupd_exec_aq(hw, cmd, bytes, perrno);
+   break;
+
+   case I40E_NVMUPD_GET_AQ_RESULT:
+   status = i40e_nvmupd_get_aq_result(hw, cmd, bytes, perrno);
+   break;
+
default:
i40e_debug(hw, I40E_DEBUG_NVM,
   "NVMUPD: bad cmd %s in init state\n",
@@ -1075,7 +1116,7 @@ STATIC enum i40e_nvmupd_cmd 
i40e_nvmupd_validate_command(struct i40e_hw *hw,
int *perrno)
 {
enum i40e_nvmupd_cmd upd_cmd;
-   u8 transaction, module;
+   u8 module, transaction;

DEBUGFUNC("i40e_nvmupd_validate_command\n");

@@ -1110,6 +1151,12 @@ STATIC enum i40e_nvmupd_cmd 
i40e_nvmupd_validate_command(struct i40e_hw *hw,
case I40E_NVM_SA:
upd_cmd = I40E_NVMUPD_READ_SA;
break;
+   case I40E_NVM_EXEC:
+   if (module == 0xf)

[dpdk-dev] [PATCH 10/52] i40e/base: add wait states to NVM state machine

2015-09-06 Thread Jingjing Wu
This adds wait states to the NVM update state machine to signify when
waiting for an update operation to finish, whether we're in the middle
of a set of Write operations, or we're now idle but waiting.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.c | 13 ++
 drivers/net/i40e/base/i40e_nvm.c| 48 +++--
 drivers/net/i40e/base/i40e_type.h   |  4 +++-
 3 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index c83476c..7589b39 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -1065,6 +1065,19 @@ clean_arq_element_out:
i40e_release_nvm(hw);
hw->aq.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;
+   }
}

 #endif
diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index 1da81a7..f4ea289 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -762,6 +762,12 @@ enum i40e_status_code i40e_nvmupd_command(struct i40e_hw 
*hw,
status = i40e_nvmupd_state_writing(hw, cmd, bytes, perrno);
break;

+   case I40E_NVMUPD_STATE_INIT_WAIT:
+   case I40E_NVMUPD_STATE_WRITE_WAIT:
+   status = I40E_ERR_NOT_READY;
+   *perrno = -EBUSY;
+   break;
+
default:
/* invalid state, should never happen */
i40e_debug(hw, I40E_DEBUG_NVM,
@@ -827,10 +833,12 @@ STATIC enum i40e_status_code 
i40e_nvmupd_state_init(struct i40e_hw *hw,
 hw->aq.asq_last_status);
} else {
status = i40e_nvmupd_nvm_erase(hw, cmd, perrno);
-   if (status)
+   if (status) {
i40e_release_nvm(hw);
-   else
+   } else {
hw->aq.nvm_release_on_done = true;
+   hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
+   }
}
break;

@@ -841,10 +849,12 @@ STATIC enum i40e_status_code 
i40e_nvmupd_state_init(struct i40e_hw *hw,
 hw->aq.asq_last_status);
} else {
status = i40e_nvmupd_nvm_write(hw, cmd, bytes, perrno);
-   if (status)
+   if (status) {
i40e_release_nvm(hw);
-   else
+   } else {
hw->aq.nvm_release_on_done = true;
+   hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
+   }
}
break;

@@ -858,7 +868,7 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct 
i40e_hw *hw,
if (status)
i40e_release_nvm(hw);
else
-   hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING;
+   hw->nvmupd_state = I40E_NVMUPD_STATE_WRITE_WAIT;
}
break;

@@ -877,6 +887,7 @@ STATIC enum i40e_status_code i40e_nvmupd_state_init(struct 
i40e_hw *hw,
i40e_release_nvm(hw);
} else {
hw->aq.nvm_release_on_done = true;
+   hw->nvmupd_state = I40E_NVMUPD_STATE_INIT_WAIT;
}
}
break;
@@ -906,7 +917,7 @@ STATIC enum i40e_status_code 
i40e_nvmupd_state_reading(struct i40e_hw *hw,
struct i40e_nvm_access *cmd,
u8 *bytes, int *perrno)
 {
-   enum i40e_status_code status;
+   enum i40e_status_code status = I40E_SUCCESS;
enum i40e_nvmupd_cmd upd_cmd;

DEBUGFUNC("i40e_nvmupd_state_reading");
@@ -950,7 +961,7 @@ STATIC enum i40e_status_code 
i40e_nvmupd_state_writing(struct i40e_hw *hw,
struct i40e_nvm_access *cmd,
u8 *bytes, int *perrno)
 {
-   enum i40e_status_code status;
+   enum i40e_status_code status = I40E_SUCCESS;
enum i40e_nvmupd_cmd upd_cmd;
bool retry_attempt = false;

@@ -962,13 

[dpdk-dev] [PATCH 09/52] i40e/base: Add info to nvm info struct for OEM version data

2015-09-06 Thread Jingjing Wu
This patch adds a member to the nvm_info struct for oem_ver info to be
output either by OID or ethtool.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.c | 7 +++
 drivers/net/i40e/base/i40e_type.h   | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 8f0a63b..c83476c 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -563,6 +563,7 @@ 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;
int retry = 0;
 #endif
/* verify input for valid configuration */
@@ -627,6 +628,12 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
i40e_read_nvm_word(hw, I40E_SR_NVM_EETRACK_LO, _lo);
i40e_read_nvm_word(hw, I40E_SR_NVM_EETRACK_HI, _hi);
hw->nvm.eetrack = (eetrack_hi << 16) | eetrack_lo;
+   i40e_read_nvm_word(hw, I40E_SR_BOOT_CONFIG_PTR, _ptr);
+   i40e_read_nvm_word(hw, (cfg_ptr + I40E_NVM_OEM_VER_OFF),
+  _hi);
+   i40e_read_nvm_word(hw, (cfg_ptr + (I40E_NVM_OEM_VER_OFF + 1)),
+  _lo);
+   hw->nvm.oem_ver = ((u32)oem_hi << 16) | oem_lo;

if (hw->aq.api_maj_ver > I40E_FW_API_VERSION_MAJOR) {
ret_code = I40E_ERR_FIRMWARE_API_VERSION;
diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index b6626f1..e1cb5fd 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -345,6 +345,7 @@ struct i40e_nvm_info {
bool blank_nvm_mode;  /* is NVM empty (no FW present)*/
u16 version;  /* NVM package version */
u32 eetrack;  /* NVM data version */
+   u32 oem_ver;  /* OEM version info */
 };

 /* definitions used in NVM update support */
@@ -1294,6 +1295,7 @@ struct i40e_hw_port_stats {
 #define I40E_SR_PBA_FLAGS  0x15
 #define I40E_SR_PBA_BLOCK_PTR  0x16
 #define I40E_SR_BOOT_CONFIG_PTR0x17
+#define I40E_NVM_OEM_VER_OFF   0x83
 #define I40E_SR_NVM_DEV_STARTER_VERSION0x18
 #define I40E_SR_NVM_WAKE_ON_LAN0x19
 #define I40E_SR_ALTERNATE_SAN_MAC_ADDRESS_PTR  0x27
-- 
2.4.0



[dpdk-dev] [PATCH 08/52] i40e/base: add handling of writeback descriptor

2015-09-06 Thread Jingjing Wu
Add the ability to save the AdminQ write back descriptor. If the writeback
descriptor buffer was previously created, this gives it to the AQ command
request to be used to save the results.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.c |  5 +
 drivers/net/i40e/base/i40e_adminq.h |  1 +
 drivers/net/i40e/base/i40e_nvm.c| 32 +++-
 drivers/net/i40e/base/i40e_type.h   |  1 +
 4 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 175daab..8f0a63b 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -925,6 +925,11 @@ enum i40e_status_code i40e_asq_send_command(struct i40e_hw 
*hw,
   "AQTX: desc and buffer writeback:\n");
i40e_debug_aq(hw, I40E_DEBUG_AQ_COMMAND, (void *)desc, buff, buff_size);

+   /* save writeback aq if requested */
+   if (details->wb_desc)
+   i40e_memcpy(details->wb_desc, desc_on_ring,
+   sizeof(struct i40e_aq_desc), I40E_DMA_TO_NONDMA);
+
/* update the error if time out occurred */
if ((!cmd_completed) &&
(!details->async && !details->postpone)) {
diff --git a/drivers/net/i40e/base/i40e_adminq.h 
b/drivers/net/i40e/base/i40e_adminq.h
index 410d07e..3d267bc 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -76,6 +76,7 @@ struct i40e_asq_cmd_details {
u16 flags_dis;
bool async;
bool postpone;
+   struct i40e_aq_desc *wb_desc;
 };

 #define I40E_ADMINQ_DETAILS(R, i)   \
diff --git a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
index f1a1e88..1da81a7 100644
--- a/drivers/net/i40e/base/i40e_nvm.c
+++ b/drivers/net/i40e/base/i40e_nvm.c
@@ -400,9 +400,13 @@ enum i40e_status_code i40e_read_nvm_aq(struct i40e_hw *hw, 
u8 module_pointer,
   bool last_command)
 {
enum i40e_status_code ret_code = I40E_ERR_NVM;
+   struct i40e_asq_cmd_details cmd_details;

DEBUGFUNC("i40e_read_nvm_aq");

+   memset(_details, 0, sizeof(cmd_details));
+   cmd_details.wb_desc = >nvm_wb_desc;
+
/* Here we are checking the SR limit only for the flat memory model.
 * We cannot do it for the module-based model, as we did not acquire
 * the NVM resource yet (we cannot get the module pointer value).
@@ -427,7 +431,7 @@ enum i40e_status_code i40e_read_nvm_aq(struct i40e_hw *hw, 
u8 module_pointer,
ret_code = i40e_aq_read_nvm(hw, module_pointer,
2 * offset,  /*bytes*/
2 * words,   /*bytes*/
-   data, last_command, NULL);
+   data, last_command, _details);

return ret_code;
 }
@@ -448,9 +452,13 @@ enum i40e_status_code i40e_write_nvm_aq(struct i40e_hw 
*hw, u8 module_pointer,
bool last_command)
 {
enum i40e_status_code ret_code = I40E_ERR_NVM;
+   struct i40e_asq_cmd_details cmd_details;

DEBUGFUNC("i40e_write_nvm_aq");

+   memset(_details, 0, sizeof(cmd_details));
+   cmd_details.wb_desc = >nvm_wb_desc;
+
/* Here we are checking the SR limit only for the flat memory model.
 * We cannot do it for the module-based model, as we did not acquire
 * the NVM resource yet (we cannot get the module pointer value).
@@ -469,7 +477,7 @@ enum i40e_status_code i40e_write_nvm_aq(struct i40e_hw *hw, 
u8 module_pointer,
ret_code = i40e_aq_update_nvm(hw, module_pointer,
  2 * offset,  /*bytes*/
  2 * words,   /*bytes*/
- data, last_command, NULL);
+ data, last_command, _details);

return ret_code;
 }
@@ -1137,6 +1145,7 @@ STATIC enum i40e_status_code i40e_nvmupd_nvm_read(struct 
i40e_hw *hw,
  struct i40e_nvm_access *cmd,
  u8 *bytes, int *perrno)
 {
+   struct i40e_asq_cmd_details cmd_details;
enum i40e_status_code status;
u8 module, transaction;
bool last;
@@ -1145,8 +1154,11 @@ STATIC enum i40e_status_code i40e_nvmupd_nvm_read(struct 
i40e_hw *hw,
module = i40e_nvmupd_get_module(cmd->config);
last = (transaction == I40E_NVM_LCB) || (transaction == I40E_NVM_SA);

+   memset(_details, 0, sizeof(cmd_details));
+   cmd_details.wb_desc = >nvm_wb_desc;
+
status = i40e_aq_read_nvm(hw, module, cmd->offset, (u16)cmd->data_size,
- bytes, last, NULL);
+ bytes, last, _details);
if (status) {
   

[dpdk-dev] [PATCH 07/52] i40e/base: grab the AQ spinlocks before clearing registers

2015-09-06 Thread Jingjing Wu
Make sure we have the spinlocks before we clear the ARQ and ASQ management
registers.  Also, widen the locked portion and make a sanity check earlier
in the send function to be sure we're working with safe register values.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq.c | 47 -
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.c 
b/drivers/net/i40e/base/i40e_adminq.c
index 8f9e870..175daab 100644
--- a/drivers/net/i40e/base/i40e_adminq.c
+++ b/drivers/net/i40e/base/i40e_adminq.c
@@ -489,8 +489,12 @@ enum i40e_status_code i40e_shutdown_asq(struct i40e_hw *hw)
 {
enum i40e_status_code ret_code = I40E_SUCCESS;

-   if (hw->aq.asq.count == 0)
-   return I40E_ERR_NOT_READY;
+   i40e_acquire_spinlock(>aq.asq_spinlock);
+
+   if (hw->aq.asq.count == 0) {
+   ret_code = I40E_ERR_NOT_READY;
+   goto shutdown_asq_out;
+   }

/* Stop firmware AdminQ processing */
wr32(hw, hw->aq.asq.head, 0);
@@ -499,16 +503,13 @@ enum i40e_status_code i40e_shutdown_asq(struct i40e_hw 
*hw)
wr32(hw, hw->aq.asq.bal, 0);
wr32(hw, hw->aq.asq.bah, 0);

-   /* make sure spinlock is available */
-   i40e_acquire_spinlock(>aq.asq_spinlock);
-
hw->aq.asq.count = 0; /* to indicate uninitialized queue */

/* free ring buffers */
i40e_free_asq_bufs(hw);

+shutdown_asq_out:
i40e_release_spinlock(>aq.asq_spinlock);
-
return ret_code;
 }

@@ -522,8 +523,12 @@ enum i40e_status_code i40e_shutdown_arq(struct i40e_hw *hw)
 {
enum i40e_status_code ret_code = I40E_SUCCESS;

-   if (hw->aq.arq.count == 0)
-   return I40E_ERR_NOT_READY;
+   i40e_acquire_spinlock(>aq.arq_spinlock);
+
+   if (hw->aq.arq.count == 0) {
+   ret_code = I40E_ERR_NOT_READY;
+   goto shutdown_arq_out;
+   }

/* Stop firmware AdminQ processing */
wr32(hw, hw->aq.arq.head, 0);
@@ -532,16 +537,13 @@ enum i40e_status_code i40e_shutdown_arq(struct i40e_hw 
*hw)
wr32(hw, hw->aq.arq.bal, 0);
wr32(hw, hw->aq.arq.bah, 0);

-   /* make sure spinlock is available */
-   i40e_acquire_spinlock(>aq.arq_spinlock);
-
hw->aq.arq.count = 0; /* to indicate uninitialized queue */

/* free ring buffers */
i40e_free_arq_bufs(hw);

+shutdown_arq_out:
i40e_release_spinlock(>aq.arq_spinlock);
-
return ret_code;
 }

@@ -764,19 +766,23 @@ enum i40e_status_code i40e_asq_send_command(struct 
i40e_hw *hw,
u16  retval = 0;
u32  val = 0;

-   val = rd32(hw, hw->aq.asq.head);
-   if (val >= hw->aq.num_asq_entries) {
+   i40e_acquire_spinlock(>aq.asq_spinlock);
+
+   hw->aq.asq_last_status = I40E_AQ_RC_OK;
+
+   if (hw->aq.asq.count == 0) {
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
-  "AQTX: head overrun at %d\n", val);
+  "AQTX: Admin queue not initialized.\n");
status = I40E_ERR_QUEUE_EMPTY;
-   goto asq_send_command_exit;
+   goto asq_send_command_error;
}

-   if (hw->aq.asq.count == 0) {
+   val = rd32(hw, hw->aq.asq.head);
+   if (val >= hw->aq.num_asq_entries) {
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
-  "AQTX: Admin queue not initialized.\n");
+  "AQTX: head overrun at %d\n", val);
status = I40E_ERR_QUEUE_EMPTY;
-   goto asq_send_command_exit;
+   goto asq_send_command_error;
}

details = I40E_ADMINQ_DETAILS(hw->aq.asq, hw->aq.asq.next_to_use);
@@ -806,8 +812,6 @@ enum i40e_status_code i40e_asq_send_command(struct i40e_hw 
*hw,
desc->flags &= ~CPU_TO_LE16(details->flags_dis);
desc->flags |= CPU_TO_LE16(details->flags_ena);

-   i40e_acquire_spinlock(>aq.asq_spinlock);
-
if (buff_size > hw->aq.asq_buf_size) {
i40e_debug(hw,
   I40E_DEBUG_AQ_MESSAGE,
@@ -932,7 +936,6 @@ enum i40e_status_code i40e_asq_send_command(struct i40e_hw 
*hw,

 asq_send_command_error:
i40e_release_spinlock(>aq.asq_spinlock);
-asq_send_command_exit:
return status;
 }

-- 
2.4.0



[dpdk-dev] [PATCH 06/52] i40e/base: Add module_types and update_link_info

2015-09-06 Thread Jingjing Wu
Add a module_types variable to the link_info struct to save the module
information from get_phy_capabilities. This information can be used to
determine which speeds the module supports.

Also add a new function update_link_info which updates the module_types
parameter and then calls get_link_info. This function should be called
in place of get_link_info so that the module_types variable stays
up-to-date with the rest of the link information.

Also rework the function get_link_status to allow caller to get all
return values in the call chain bubbled back to the source, which keeps
information about failures from being lost.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c| 46 ++
 drivers/net/i40e/base/i40e_prototype.h |  3 ++-
 drivers/net/i40e/base/i40e_type.h  | 18 +
 3 files changed, 55 insertions(+), 12 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index 455f98d..2a3da6e 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -1547,14 +1547,14 @@ enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, 
u8 *aq_failures,
*aq_failures |= I40E_SET_FC_AQ_FAIL_SET;
}
/* Update the link info */
-   status = i40e_aq_get_link_info(hw, true, NULL, NULL);
+   status = i40e_update_link_info(hw);
if (status) {
/* Wait a little bit (on 40G cards it sometimes takes a really
 * long time for link to come back from the atomic reset)
 * and try once more
 */
i40e_msec_delay(1000);
-   status = i40e_aq_get_link_info(hw, true, NULL, NULL);
+   status = i40e_update_link_info(hw);
}
if (status)
*aq_failures |= I40E_SET_FC_AQ_FAIL_UPDATE;
@@ -1743,7 +1743,6 @@ aq_get_link_info_exit:
return status;
 }

-
 /**
  * i40e_aq_set_phy_int_mask
  * @hw: pointer to the hw struct
@@ -2286,27 +2285,52 @@ enum i40e_status_code 
i40e_aq_send_driver_version(struct i40e_hw *hw,
 /**
  * i40e_get_link_status - get status of the HW network link
  * @hw: pointer to the hw struct
+ * @link_up: pointer to bool (true/false = linkup/linkdown)
  *
- * Returns true if link is up, false if link is down.
+ * Variable link_up true if link is up, false if link is down.
+ * The variable link_up is invalid if returned value of status != I40E_SUCCESS
  *
  * Side effect: LinkStatusEvent reporting becomes enabled
  **/
-bool i40e_get_link_status(struct i40e_hw *hw)
+enum i40e_status_code i40e_get_link_status(struct i40e_hw *hw, bool *link_up)
 {
enum i40e_status_code status = I40E_SUCCESS;
-   bool link_status = false;

if (hw->phy.get_link_info) {
-   status = i40e_aq_get_link_info(hw, true, NULL, NULL);
+   status = i40e_update_link_info(hw);

if (status != I40E_SUCCESS)
-   goto i40e_get_link_status_exit;
+   i40e_debug(hw, I40E_DEBUG_LINK, "get link failed: 
status %d\n",
+  status);
}

-   link_status = hw->phy.link_info.link_info & I40E_AQ_LINK_UP;
+   *link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP;
+
+   return status;
+}

-i40e_get_link_status_exit:
-   return link_status;
+/**
+ * i40e_updatelink_status - update status of the HW network link
+ * @hw: pointer to the hw struct
+ **/
+enum i40e_status_code i40e_update_link_info(struct i40e_hw *hw)
+{
+   struct i40e_aq_get_phy_abilities_resp abilities;
+   enum i40e_status_code status = I40E_SUCCESS;
+
+   status = i40e_aq_get_link_info(hw, true, NULL, NULL);
+   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));
+
+   return status;
 }

 /**
diff --git a/drivers/net/i40e/base/i40e_prototype.h 
b/drivers/net/i40e/base/i40e_prototype.h
index 54df577..0c66af7 100644
--- a/drivers/net/i40e/base/i40e_prototype.h
+++ b/drivers/net/i40e/base/i40e_prototype.h
@@ -381,7 +381,8 @@ enum i40e_status_code i40e_init_shared_code(struct i40e_hw 
*hw);
 enum i40e_status_code i40e_pf_reset(struct i40e_hw *hw);
 void i40e_clear_hw(struct i40e_hw *hw);
 void i40e_clear_pxe_mode(struct i40e_hw *hw);
-bool i40e_get_link_status(struct i40e_hw *hw);
+enum i40e_status_code i40e_get_link_status(struct i40e_hw *hw, bool *link_up);
+enum i40e_status_code i40e_update_link_info(struct i40e_hw *hw);
 enum i40e_status_code i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr);
 enum i40e_status_code i40e_read_bw_from_alt_ram(struct i40e_hw *hw,
u32 *max_bw, u32 *min_bw, bool *min_valid, bool *max_valid);

[dpdk-dev] [PATCH 05/52] i40e/base: Merge Fortville SW 4 admin Q command header

2015-09-06 Thread Jingjing Wu
Update the admin queue command header for the Fortville SW 4 Release. As
part of this release the minor FW API version number is bumped to 4 so
that the FW API version for the FVLSW4 release will now be 1.4.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_adminq_cmd.h | 25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq_cmd.h 
b/drivers/net/i40e/base/i40e_adminq_cmd.h
index 6fd99b7..aaf9f22 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  0x0002
+#define I40E_FW_API_VERSION_MINOR  0x0004

 struct i40e_aq_desc {
__le16 flags;
@@ -139,12 +139,7 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_list_func_capabilities = 0x000A,
i40e_aqc_opc_list_dev_capabilities  = 0x000B,

-   i40e_aqc_opc_set_cppm_configuration = 0x0103,
-   i40e_aqc_opc_set_arp_proxy_entry= 0x0104,
-   i40e_aqc_opc_set_ns_proxy_entry = 0x0105,
-
/* LAA */
-   i40e_aqc_opc_mng_laa= 0x0106,   /* AQ obsolete */
i40e_aqc_opc_mac_address_read   = 0x0107,
i40e_aqc_opc_mac_address_write  = 0x0108,

@@ -269,7 +264,6 @@ enum i40e_admin_queue_opc {
/* Tunnel commands */
i40e_aqc_opc_add_udp_tunnel = 0x0B00,
i40e_aqc_opc_del_udp_tunnel = 0x0B01,
-   i40e_aqc_opc_tunnel_key_structure   = 0x0B10,

/* Async Events */
i40e_aqc_opc_event_lan_overflow = 0x1001,
@@ -281,8 +275,6 @@ enum i40e_admin_queue_opc {
i40e_aqc_opc_oem_ocbb_initialize= 0xFE03,

/* debug commands */
-   i40e_aqc_opc_debug_get_deviceid = 0xFF00,
-   i40e_aqc_opc_debug_set_mode = 0xFF01,
i40e_aqc_opc_debug_read_reg = 0xFF03,
i40e_aqc_opc_debug_write_reg= 0xFF04,
i40e_aqc_opc_debug_modify_reg   = 0xFF07,
@@ -516,7 +508,8 @@ struct i40e_aqc_mac_address_read {
 #define I40E_AQC_SAN_ADDR_VALID0x20
 #define I40E_AQC_PORT_ADDR_VALID   0x40
 #define I40E_AQC_WOL_ADDR_VALID0x80
-#define I40E_AQC_ADDR_VALID_MASK   0xf0
+#define I40E_AQC_MC_MAG_EN_VALID   0x100
+#define I40E_AQC_ADDR_VALID_MASK   0x1F0
u8  reserved[6];
__le32  addr_high;
__le32  addr_low;
@@ -539,7 +532,9 @@ struct i40e_aqc_mac_address_write {
 #define I40E_AQC_WRITE_TYPE_LAA_ONLY   0x
 #define I40E_AQC_WRITE_TYPE_LAA_WOL0x4000
 #define I40E_AQC_WRITE_TYPE_PORT   0x8000
-#define I40E_AQC_WRITE_TYPE_MASK   0xc000
+#define I40E_AQC_WRITE_TYPE_UPDATE_MC_MAG  0xC000
+#define I40E_AQC_WRITE_TYPE_MASK   0xC000
+
__le16  mac_sah;
__le32  mac_sal;
u8  reserved[8];
@@ -1075,6 +1070,7 @@ struct i40e_aqc_set_vsi_promiscuous_modes {
__le16  seid;
 #define I40E_AQC_VSI_PROM_CMD_SEID_MASK0x3FF
__le16  vlan_tag;
+#define I40E_AQC_SET_VSI_VLAN_MASK 0x0FFF
 #define I40E_AQC_SET_VSI_VLAN_VALID0x8000
u8  reserved[8];
 };
@@ -2069,6 +2065,13 @@ I40E_CHECK_CMD_LENGTH(i40e_aqc_lldp_start);
 #define I40E_AQC_CEE_PFC_STATUS_MASK   (0x7 << I40E_AQC_CEE_PFC_STATUS_SHIFT)
 #define I40E_AQC_CEE_APP_STATUS_SHIFT  0x8
 #define I40E_AQC_CEE_APP_STATUS_MASK   (0x7 << I40E_AQC_CEE_APP_STATUS_SHIFT)
+#define I40E_AQC_CEE_FCOE_STATUS_SHIFT 0x8
+#define I40E_AQC_CEE_FCOE_STATUS_MASK  (0x7 << I40E_AQC_CEE_FCOE_STATUS_SHIFT)
+#define I40E_AQC_CEE_ISCSI_STATUS_SHIFT0xB
+#define I40E_AQC_CEE_ISCSI_STATUS_MASK (0x7 << I40E_AQC_CEE_ISCSI_STATUS_SHIFT)
+#define I40E_AQC_CEE_FIP_STATUS_SHIFT  0x10
+#define I40E_AQC_CEE_FIP_STATUS_MASK   (0x7 << I40E_AQC_CEE_FIP_STATUS_SHIFT)
+
 struct i40e_aqc_get_cee_dcb_cfg_v1_resp {
u8  reserved1;
u8  oper_num_tc;
-- 
2.4.0



[dpdk-dev] [PATCH 04/52] i40e/base: Replace sprintf with i40e_debug

2015-09-06 Thread Jingjing Wu
Replace sprintf with i40e_debug. Pad the line out with zeros to get to 16 bytes.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_common.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_common.c 
b/drivers/net/i40e/base/i40e_common.c
index ba7bc67..455f98d 100644
--- a/drivers/net/i40e/base/i40e_common.c
+++ b/drivers/net/i40e/base/i40e_common.c
@@ -344,16 +344,20 @@ void i40e_debug_aq(struct i40e_hw *hw, enum 
i40e_debug_mask mask, void *desc,
   buf[i+4], buf[i+5], buf[i+6], buf[i+7],
   buf[i+8], buf[i+9], buf[i+10], buf[i+11],
   buf[i+12], buf[i+13], buf[i+14], buf[i+15]);
-   /* write whatever's left over without overrunning the buffer */
+   /* the most we could have left is 16 bytes, pad with zeros */
if (i < len) {
-   char d_buf[80];
-   int j = 0;
+   char d_buf[16];
+   int j;

memset(d_buf, 0, sizeof(d_buf));
-   j += sprintf(d_buf, "\t0x%04X ", i);
-   while (i < len)
-   j += sprintf(_buf[j], " %02X", buf[i++]);
-   i40e_debug(hw, mask, "%s\n", 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],
+  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.4.0



[dpdk-dev] [PATCH 01/52] i40e/base: split device ids into a separate file

2015-09-06 Thread Jingjing Wu
Due to desires to write userland drivers such as for DPDK support, and
other requests, without needing the rest of the include files, the device
ids are pulled out into a standalone file.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/base/i40e_devids.h | 57 +
 drivers/net/i40e/base/i40e_type.h   | 21 +-
 2 files changed, 58 insertions(+), 20 deletions(-)
 create mode 100644 drivers/net/i40e/base/i40e_devids.h

diff --git a/drivers/net/i40e/base/i40e_devids.h 
b/drivers/net/i40e/base/i40e_devids.h
new file mode 100644
index 000..0ebaf0a
--- /dev/null
+++ b/drivers/net/i40e/base/i40e_devids.h
@@ -0,0 +1,57 @@
+/***
+
+Copyright (c) 2013 - 2015, Intel Corporation
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the Intel Corporation nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+***/
+
+#ifndef _I40E_DEVIDS_H_
+#define _I40E_DEVIDS_H_
+
+/* Vendor ID */
+#define I40E_INTEL_VENDOR_ID   0x8086
+
+/* 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
+#define I40E_DEV_ID_QSFP_B 0x1584
+#define I40E_DEV_ID_QSFP_C 0x1585
+#define I40E_DEV_ID_10G_BASE_T 0x1586
+#define I40E_DEV_ID_VF 0x154C
+#define I40E_DEV_ID_VF_HV  0x1571
+
+#define i40e_is_40G_device(d)  ((d) == I40E_DEV_ID_QSFP_A  || \
+(d) == I40E_DEV_ID_QSFP_B  || \
+(d) == I40E_DEV_ID_QSFP_C)
+
+#endif /* _I40E_DEVIDS_H_ */
diff --git a/drivers/net/i40e/base/i40e_type.h 
b/drivers/net/i40e/base/i40e_type.h
index 6ee398e..237e3be 100644
--- a/drivers/net/i40e/base/i40e_type.h
+++ b/drivers/net/i40e/base/i40e_type.h
@@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "i40e_adminq.h"
 #include "i40e_hmc.h"
 #include "i40e_lan_hmc.h"
+#include "i40e_devids.h"

 #define UNREFERENCED_XPARAMETER
 #define UNREFERENCED_1PARAMETER(_p) (_p);
@@ -48,26 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
 #define UNREFERENCED_4PARAMETER(_p, _q, _r, _s) (_p); (_q); (_r); (_s);
 #define UNREFERENCED_5PARAMETER(_p, _q, _r, _s, _t) (_p); (_q); (_r); (_s); 
(_t);

-/* Vendor ID */
-#define I40E_INTEL_VENDOR_ID   0x8086
-
-/* 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
-#define I40E_DEV_ID_QSFP_B 0x1584
-#define I40E_DEV_ID_QSFP_C 0x1585
-#define I40E_DEV_ID_10G_BASE_T 0x1586
-#define I40E_DEV_ID_VF 0x154C
-#define I40E_DEV_ID_VF_HV  0x1571
-
-#define i40e_is_40G_device(d)  ((d) == I40E_DEV_ID_QSFP_A  || \
-(d) == I40E_DEV_ID_QSFP_B  || \
-(d) == I40E_DEV_ID_QSFP_C)
-
 #ifndef I40E_MASK
 /* I40E_MASK is a macro used on 32 bit registers */
 #define I40E_MASK(mask, shift) (mask << shift)
-- 
2.4.0



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

2015-09-06 Thread Jingjing Wu
Here is the update of i40e base driver. 
Main update:
 - support New X722 Device (FortPark)
 - extend virtual channel interface
 - support CEE DCBX
 - support promiscuous on VLAN
 - support Tx Scheduling related AQ functions
 - support RSS AQ related functions
 - code clean up

Jingjing Wu (52):
  i40e/base: split device ids into a separate file
  i40e/base: Add new device id for 20Gb and Fort pond device.
  i40e/base: add error status value decoding
  i40e/base: Replace sprintf with i40e_debug
  i40e/base: Merge Fortville SW 4 admin Q command header
  i40e/base: Add module_types and update_link_info
  i40e/base: grab the AQ spinlocks before clearing registers
  i40e/base: add handling of writeback descriptor
  i40e/base: Add info to nvm info struct for OEM version data
  i40e/base: add wait states to NVM state machine
  i40e/base: add commands to nvmupdate utility
  i40e/base: Add promiscuous on VLAN support
  i40e/base: Add a workaround to drop all flow control frames
  i40e/base: Add Debug Dump Internal Data AQ command
  i40e/base: OEM Post Update AQ command implementation
  i40e/base: add VF capabilities to virtual channel interface
  i40e/base: create new BIT and BIT_ULL macros
  i40e/base: Add parsing for CEE DCBX TLVs
  i40e/base: Prepare the local LLDP MIB in IEEE TLV Format
  i40e/base: Refactor PHY structure and add phy_capabilities enum
  i40e/base: Store CEE DCBX cfg from firmware and Cache the CEE TLV
status
  i40e/base: Add some more stats for FD SB and ATR status
  i40e/base: Update Flex-10 related device/function capabilities
  i40e/base: Wrap the register definitions for PF and VF driver
  i40e/base: fix up type clash in i40e_aq_rc_to_posix conversion
  i40e/base: Add new link status defines
  i40e/base: fixup padding issue in get_cee_dcb_cfg_v1_resp
  i40e/base: Add Tx Scheduling related AQ commands
  i40e/base: Additional checks for CEE APP priority validity
  i40e/base: Add support for pre-allocated pages for pd
  i40e/base: clean up unneeded gotos
  i40e/base: Handle admin Q timeout when releasing NVM
  i40e/base: Add definition of GLINT_CTL register
  i40e/base: Add virtchnl op for additional solaris config
  i40e/base: drop func from debug print
  i40e/base: add new X722 device
  i40e/base: Add AQ functions to handle RSS Key and LUT programming
  i40e/base: add proxy config admin q functions
  i40e/base: add wol config admin queue functions
  i40e/base: add WR_CSR_PROT wol/proxy capability parsing
  i40e/base: FortPark has additional PCTYPES supported for RSS
  i40e/base: FortPark changes to Rx and Tx descriptor for Outer UDP
checksum offloads
  i40e/base: use INLINE macro for better cross-platform code management
  i40e/base: ESS Support
  i40e/base: print FCoE capability reported by the device function
  i40e/base: remove useless assignments
  i40e/base: Increase pf reset max loop limit
  i40e/base: Add FortPark specific registers
  i40e/base: Allow for per-device FW API version
  i40e/base: Add ATR command bit definition for FortPark
  i40e/base: Explicitly assign enum index for VSI type
  eal/common: add new i40e device id

 drivers/net/i40e/base/i40e_adminq.c |  139 +-
 drivers/net/i40e/base/i40e_adminq.h |   12 +-
 drivers/net/i40e/base/i40e_adminq_cmd.h |  211 ++-
 drivers/net/i40e/base/i40e_common.c |  916 ++-
 drivers/net/i40e/base/i40e_dcb.c|  625 +++-
 drivers/net/i40e/base/i40e_dcb.h|   50 +-
 drivers/net/i40e/base/i40e_devids.h |   70 +
 drivers/net/i40e/base/i40e_diag.c   |   11 +-
 drivers/net/i40e/base/i40e_hmc.c|   67 +-
 drivers/net/i40e/base/i40e_hmc.h|   10 +-
 drivers/net/i40e/base/i40e_lan_hmc.c|   29 +-
 drivers/net/i40e/base/i40e_nvm.c|  324 +++-
 drivers/net/i40e/base/i40e_prototype.h  |   62 +-
 drivers/net/i40e/base/i40e_register.h   | 1945 +++
 drivers/net/i40e/base/i40e_type.h   |  236 ++-
 drivers/net/i40e/base/i40e_virtchnl.h   |   40 +-
 lib/librte_eal/common/include/rte_pci_dev_ids.h |6 +
 17 files changed, 4484 insertions(+), 269 deletions(-)
 create mode 100644 drivers/net/i40e/base/i40e_devids.h

-- 
2.4.0



[dpdk-dev] [PATCH 3/4] virtio: use indirect ring elements

2015-09-06 Thread Stephen Hemminger
On Sun, 6 Sep 2015 08:40:44 +
"Ouyang, Changchun"  wrote:

> > @@ -220,11 +221,26 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq,
> > struct rte_mbuf *cookie)
> > dxp = >vq_descx[idx];
> > dxp->cookie = (void *)cookie;
> > dxp->ndescs = needed;
> > -
> > start_dp = txvq->vq_ring.desc;
> > -   start_dp[idx].addr =
> > -   txvq->virtio_net_hdr_mem + idx * head_size;
> > -   start_dp[idx].len = (uint32_t)head_size;
> > +
> > +   if (use_indirect) {
> > +   offs = offsetof(struct virtio_tx_region, tx_indir)
> > +   + idx * sizeof(struct virtio_tx_region);
> > +
> > +   start_dp[idx].addr = txvq->virtio_net_hdr_mem + offs;
> > +   start_dp[idx].len = sizeof(struct vring_desc);  
> 
> Should the length be N * sizeof(struct vring_desc)?

Yes.


[dpdk-dev] [PATCH 3/4] virtio: use indirect ring elements

2015-09-06 Thread Stephen Hemminger
On Sun, 6 Sep 2015 08:36:10 +
"Ouyang, Changchun"  wrote:

> > -Original Message-
> > From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> > Sent: Saturday, September 5, 2015 4:58 AM
> > To: Xie, Huawei; Ouyang, Changchun
> > Cc: dev at dpdk.org; Stephen Hemminger
> > Subject: [PATCH 3/4] virtio: use indirect ring elements
> > 
> > The virtio ring in QEMU/KVM is usually limited to 256 entries and the normal
> > way that virtio driver was queuing mbufs required nsegs + 1 ring elements.
> > By using the indirect ring element feature if available, each packet will 
> > take
> > only one ring slot even for multi-segment packets.
> > 
> > Signed-off-by: Stephen Hemminger 
> > ---
> >  drivers/net/virtio/virtio_ethdev.c | 11 +---
> > drivers/net/virtio/virtio_ethdev.h |  3 ++-
> >  drivers/net/virtio/virtio_rxtx.c   | 51 ++-
> > ---
> >  drivers/net/virtio/virtqueue.h |  8 ++
> >  4 files changed, 57 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/net/virtio/virtio_ethdev.c
> > b/drivers/net/virtio/virtio_ethdev.c
> > index 465d3cd..bcfb87b 100644
> > --- a/drivers/net/virtio/virtio_ethdev.c
> > +++ b/drivers/net/virtio/virtio_ethdev.c
> > @@ -359,12 +359,15 @@ int virtio_dev_queue_setup(struct rte_eth_dev
> > *dev,
> > if (queue_type == VTNET_TQ) {  
> 
> Do we also need implement indirect ring elements for RX path?

No. Look at Linux driver, indirect elements are never passed to RX driver.


[dpdk-dev] [PATCH 3/4] virtio: use indirect ring elements

2015-09-06 Thread Ouyang, Changchun


> -Original Message-
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Saturday, September 5, 2015 4:58 AM
> To: Xie, Huawei; Ouyang, Changchun
> Cc: dev at dpdk.org; Stephen Hemminger
> Subject: [PATCH 3/4] virtio: use indirect ring elements
> 
> The virtio ring in QEMU/KVM is usually limited to 256 entries and the normal
> way that virtio driver was queuing mbufs required nsegs + 1 ring elements.
> By using the indirect ring element feature if available, each packet will take
> only one ring slot even for multi-segment packets.
> 
> Signed-off-by: Stephen Hemminger 
> ---
>  drivers/net/virtio/virtio_ethdev.c | 11 +---
> drivers/net/virtio/virtio_ethdev.h |  3 ++-
>  drivers/net/virtio/virtio_rxtx.c   | 51 ++-
> ---
>  drivers/net/virtio/virtqueue.h |  8 ++
>  4 files changed, 57 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c
> b/drivers/net/virtio/virtio_ethdev.c
> index 465d3cd..bcfb87b 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -359,12 +359,15 @@ int virtio_dev_queue_setup(struct rte_eth_dev
> *dev,
>   if (queue_type == VTNET_TQ) {
>   /*
>* For each xmit packet, allocate a virtio_net_hdr
> +  * and indirect ring elements
>*/
>   snprintf(vq_name, sizeof(vq_name),
> "port%d_tvq%d_hdrzone",
> - dev->data->port_id, queue_idx);
> - vq->virtio_net_hdr_mz =
> rte_memzone_reserve_aligned(vq_name,
> - vq_size * hw->vtnet_hdr_size,
> - socket_id, 0, RTE_CACHE_LINE_SIZE);
> +  dev->data->port_id, queue_idx);
> +
> + vq->virtio_net_hdr_mz =
> + rte_memzone_reserve_aligned(vq_name,
> + vq_size * sizeof(struct
> virtio_tx_region),
> + socket_id, 0,
> RTE_CACHE_LINE_SIZE);
>   if (vq->virtio_net_hdr_mz == NULL) {
>   if (rte_errno == EEXIST)
>   vq->virtio_net_hdr_mz =
> diff --git a/drivers/net/virtio/virtio_ethdev.h
> b/drivers/net/virtio/virtio_ethdev.h
> index 9026d42..07a9265 100644
> --- a/drivers/net/virtio/virtio_ethdev.h
> +++ b/drivers/net/virtio/virtio_ethdev.h
> @@ -64,7 +64,8 @@
>1u << VIRTIO_NET_F_CTRL_VQ   | \
>1u << VIRTIO_NET_F_CTRL_RX   | \
>1u << VIRTIO_NET_F_CTRL_VLAN | \
> -  1u << VIRTIO_NET_F_MRG_RXBUF)
> +  1u << VIRTIO_NET_F_MRG_RXBUF | \
> +  1u << VIRTIO_RING_F_INDIRECT_DESC)
> 
>  /*
>   * CQ function prototype
> diff --git a/drivers/net/virtio/virtio_rxtx.c 
> b/drivers/net/virtio/virtio_rxtx.c
> index dbe6665..8979695 100644
> --- a/drivers/net/virtio/virtio_rxtx.c
> +++ b/drivers/net/virtio/virtio_rxtx.c
> @@ -199,14 +199,15 @@ virtqueue_enqueue_recv_refill(struct virtqueue
> *vq, struct rte_mbuf *cookie)  }
> 
>  static int
> -virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
> +virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie,
> +int use_indirect)
>  {
>   struct vq_desc_extra *dxp;
>   struct vring_desc *start_dp;
>   uint16_t seg_num = cookie->nb_segs;
> - uint16_t needed = 1 + seg_num;
> + uint16_t needed = use_indirect ? 1 : 1 + seg_num;
>   uint16_t head_idx, idx;
> - uint16_t head_size = txvq->hw->vtnet_hdr_size;
> + unsigned long offs;
> 
>   if (unlikely(txvq->vq_free_cnt == 0))
>   return -ENOSPC;
> @@ -220,11 +221,26 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq,
> struct rte_mbuf *cookie)
>   dxp = >vq_descx[idx];
>   dxp->cookie = (void *)cookie;
>   dxp->ndescs = needed;
> -
>   start_dp = txvq->vq_ring.desc;
> - start_dp[idx].addr =
> - txvq->virtio_net_hdr_mem + idx * head_size;
> - start_dp[idx].len = (uint32_t)head_size;
> +
> + if (use_indirect) {
> + offs = offsetof(struct virtio_tx_region, tx_indir)
> + + idx * sizeof(struct virtio_tx_region);
> +
> + start_dp[idx].addr = txvq->virtio_net_hdr_mem + offs;
> + start_dp[idx].len = sizeof(struct vring_desc);

Should the length be N * sizeof(struct vring_desc)?

> + start_dp[idx].flags = VRING_DESC_F_INDIRECT;
> +
> + start_dp = (struct vring_desc *)
> + ((char *)txvq->virtio_net_hdr_mz->addr + offs);
> + idx = 0;
> + }
> +
> + offs = offsetof(struct virtio_tx_region, tx_hdr)
> + + idx * sizeof(struct virtio_tx_region);
> +
> + start_dp[idx].addr = txvq->virtio_net_hdr_mem + offs;
> + start_dp[idx].len = txvq->hw->vtnet_hdr_size;
>   start_dp[idx].flags = VRING_DESC_F_NEXT;
> 
>   for (; ((seg_num > 0) && (cookie != NULL)); seg_num--) { @@ 

[dpdk-dev] [PATCH 3/4] virtio: use indirect ring elements

2015-09-06 Thread Ouyang, Changchun


> -Original Message-
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Saturday, September 5, 2015 4:58 AM
> To: Xie, Huawei; Ouyang, Changchun
> Cc: dev at dpdk.org; Stephen Hemminger
> Subject: [PATCH 3/4] virtio: use indirect ring elements
> 
> The virtio ring in QEMU/KVM is usually limited to 256 entries and the normal
> way that virtio driver was queuing mbufs required nsegs + 1 ring elements.
> By using the indirect ring element feature if available, each packet will take
> only one ring slot even for multi-segment packets.
> 
> Signed-off-by: Stephen Hemminger 
> ---
>  drivers/net/virtio/virtio_ethdev.c | 11 +---
> drivers/net/virtio/virtio_ethdev.h |  3 ++-
>  drivers/net/virtio/virtio_rxtx.c   | 51 ++-
> ---
>  drivers/net/virtio/virtqueue.h |  8 ++
>  4 files changed, 57 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c
> b/drivers/net/virtio/virtio_ethdev.c
> index 465d3cd..bcfb87b 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -359,12 +359,15 @@ int virtio_dev_queue_setup(struct rte_eth_dev
> *dev,
>   if (queue_type == VTNET_TQ) {

Do we also need implement indirect ring elements for RX path?

>   /*
>* For each xmit packet, allocate a virtio_net_hdr
> +  * and indirect ring elements
>*/
>   snprintf(vq_name, sizeof(vq_name),
> "port%d_tvq%d_hdrzone",
> - dev->data->port_id, queue_idx);
> - vq->virtio_net_hdr_mz =
> rte_memzone_reserve_aligned(vq_name,
> - vq_size * hw->vtnet_hdr_size,
> - socket_id, 0, RTE_CACHE_LINE_SIZE);
> +  dev->data->port_id, queue_idx);
> +
> + vq->virtio_net_hdr_mz =
> + rte_memzone_reserve_aligned(vq_name,
> + vq_size * sizeof(struct
> virtio_tx_region),
> + socket_id, 0,
> RTE_CACHE_LINE_SIZE);
>   if (vq->virtio_net_hdr_mz == NULL) {
>   if (rte_errno == EEXIST)
>   vq->virtio_net_hdr_mz =
> diff --git a/drivers/net/virtio/virtio_ethdev.h
> b/drivers/net/virtio/virtio_ethdev.h
> index 9026d42..07a9265 100644
> --- a/drivers/net/virtio/virtio_ethdev.h
> +++ b/drivers/net/virtio/virtio_ethdev.h
> @@ -64,7 +64,8 @@
>1u << VIRTIO_NET_F_CTRL_VQ   | \
>1u << VIRTIO_NET_F_CTRL_RX   | \
>1u << VIRTIO_NET_F_CTRL_VLAN | \
> -  1u << VIRTIO_NET_F_MRG_RXBUF)
> +  1u << VIRTIO_NET_F_MRG_RXBUF | \
> +  1u << VIRTIO_RING_F_INDIRECT_DESC)
> 
>  /*
>   * CQ function prototype
> diff --git a/drivers/net/virtio/virtio_rxtx.c 
> b/drivers/net/virtio/virtio_rxtx.c
> index dbe6665..8979695 100644
> --- a/drivers/net/virtio/virtio_rxtx.c
> +++ b/drivers/net/virtio/virtio_rxtx.c
> @@ -199,14 +199,15 @@ virtqueue_enqueue_recv_refill(struct virtqueue
> *vq, struct rte_mbuf *cookie)  }
> 
>  static int
> -virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
> +virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie,
> +int use_indirect)
>  {
>   struct vq_desc_extra *dxp;
>   struct vring_desc *start_dp;
>   uint16_t seg_num = cookie->nb_segs;
> - uint16_t needed = 1 + seg_num;
> + uint16_t needed = use_indirect ? 1 : 1 + seg_num;

Do we need check if seg_num > VIRTIO_MAX_TX_INDIRECT?
That mean one slot is not enough for the whole big packet even it is indirect 
ring.

>   uint16_t head_idx, idx;
> - uint16_t head_size = txvq->hw->vtnet_hdr_size;
> + unsigned long offs;
> 
>   if (unlikely(txvq->vq_free_cnt == 0))
>   return -ENOSPC;
> @@ -220,11 +221,26 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq,
> struct rte_mbuf *cookie)
>   dxp = >vq_descx[idx];
>   dxp->cookie = (void *)cookie;
>   dxp->ndescs = needed;
> -
>   start_dp = txvq->vq_ring.desc;
> - start_dp[idx].addr =
> - txvq->virtio_net_hdr_mem + idx * head_size;
> - start_dp[idx].len = (uint32_t)head_size;
> +
> + if (use_indirect) {
> + offs = offsetof(struct virtio_tx_region, tx_indir)
> + + idx * sizeof(struct virtio_tx_region);
> +
> + start_dp[idx].addr = txvq->virtio_net_hdr_mem + offs;
> + start_dp[idx].len = sizeof(struct vring_desc);
> + start_dp[idx].flags = VRING_DESC_F_INDIRECT;
> +
> + start_dp = (struct vring_desc *)
> + ((char *)txvq->virtio_net_hdr_mz->addr + offs);
> + idx = 0;
> + }
> +
> + offs = offsetof(struct virtio_tx_region, tx_hdr)
> + + idx * sizeof(struct virtio_tx_region);
> +
> + start_dp[idx].addr = txvq->virtio_net_hdr_mem + offs;
> + 

[dpdk-dev] [PATCH v4 02/12] vhost: support multiple queues in virtio dev

2015-09-06 Thread Ouyang, Changchun
Hi Tetsuya,

> -Original Message-
> From: Tetsuya Mukawa [mailto:mukawa at igel.co.jp]
> Sent: Thursday, September 3, 2015 10:27 AM
> To: dev at dpdk.org; Ouyang, Changchun
> Subject: Re: [dpdk-dev] [PATCH v4 02/12] vhost: support multiple queues in
> virtio dev
> 
> On 2015/08/12 17:02, Ouyang Changchun wrote:
> > diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.h
> > b/lib/librte_vhost/vhost_user/virtio-net-user.h
> > index df24860..2429836 100644
> > --- a/lib/librte_vhost/vhost_user/virtio-net-user.h
> > +++ b/lib/librte_vhost/vhost_user/virtio-net-user.h
> > @@ -46,4 +46,6 @@ void user_set_vring_kick(struct vhost_device_ctx,
> > struct VhostUserMsg *);
> >
> >  /*
> > @@ -206,9 +213,17 @@ cleanup_device(struct virtio_net *dev)  static
> > void  free_device(struct virtio_net_config_ll *ll_dev)  {
> > -   /* Free any malloc'd memory */
> > -   rte_free(ll_dev->dev.virtqueue[VIRTIO_RXQ]);
> > -   rte_free(ll_dev->dev.virtqueue[VIRTIO_TXQ]);
> > +   uint32_t qp_idx;
> > +
> > +   /*
> > +* Free any malloc'd memory.
> > +*/
> > +   /* Free every queue pair. */
> > +   for (qp_idx = 0; qp_idx < ll_dev->dev.virt_qp_nb; qp_idx++) {
> > +   uint32_t virt_rx_q_idx = qp_idx * VIRTIO_QNUM +
> VIRTIO_RXQ;
> > +   rte_free(ll_dev->dev.virtqueue[virt_rx_q_idx]);
> 
> Hi Changchun,
> 
> Should we free tx queue also here?
>

We don't need do it, as we allocate once for both rx and tx queue.
Thus, we allocate once, free once.
Pls see the following code snippet:

+ *  Alloc mem for vring queue pair.
+ */
+int
+alloc_vring_queue_pair(struct virtio_net *dev, uint16_t qp_idx) {
+   struct vhost_virtqueue *virtqueue = NULL;
+   uint32_t virt_rx_q_idx = qp_idx * VIRTIO_QNUM + VIRTIO_RXQ;
+   uint32_t virt_tx_q_idx = qp_idx * VIRTIO_QNUM + VIRTIO_TXQ;

-   /* Backends are set to -1 indicating an inactive device. */
-   dev->virtqueue[VIRTIO_RXQ]->backend = VIRTIO_DEV_STOPPED;
-   dev->virtqueue[VIRTIO_TXQ]->backend = VIRTIO_DEV_STOPPED;
+   virtqueue = rte_malloc(NULL, sizeof(struct vhost_virtqueue) * 
VIRTIO_QNUM, 0);
+   if (virtqueue == NULL) {
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "Failed to allocate memory for virt qp:%d.\n", qp_idx);
+   return -1;
+   }
+
+   dev->virtqueue[virt_rx_q_idx] = virtqueue;
+   dev->virtqueue[virt_tx_q_idx] = virtqueue + VIRTIO_TXQ;
+
+   init_vring_queue_pair(dev, qp_idx);
+
+   return 0;
 }

Thanks
Changchun

> 
> > +   }
> > +   rte_free(ll_dev->dev.virtqueue);
> > rte_free(ll_dev);
> >  }
> >
> >



[dpdk-dev] [PATCH] i40e: fix base driver allocation when on numa != 0

2015-09-06 Thread Zhang, Helin


> -Original Message-
> From: David Marchand [mailto:david.marchand at 6wind.com]
> Sent: Thursday, September 3, 2015 9:24 PM
> To: dev at dpdk.org
> Cc: Zhang, Helin
> Subject: [PATCH] i40e: fix base driver allocation when on numa != 0
> 
> Seen by code review.
> 
> If dpdk is run with memory only available on socket 0, then i40e pmd refuses 
> to
> initialize ports as this pmd requires some memory on socket 0.
> Fix this by setting socket to SOCKET_ID_ANY, so that allocations happen on the
> caller socket.
> 
> Signed-off-by: David Marchand 
Acked-by: Helin Zhang