[dpdk-dev] [PATCH 0/7] enhancements for i40e

2014-06-20 Thread Helin Zhang
These patches are enhancements for i40e or relevant. In detail,
they include:
 * fix for getting correct RSS hash result in i40e RX functions.
 * support crc stripping hw offload in VF driver.
 * ignore the failure of updating default filter setting.
 * fix for updating the hash lookup table of PF RSS.
 * disable double vlan by default during initialization.
 * fix for copying wrong size of link info, and remove an
   useless function.
 * rework in testpmd to support displaying different size
   of RX descriptors.

Helin Zhang (7):
  i40e: fix for getting correct RSS hash result
  i40evf: support configuring crc stripping hw offload
  i40e: ignore the failure of updating default filter settings
  i40e: fix for updating the hash lookup table of PF RSS
  i40e: double vlan should be specifically disabled by default
  i40evf: fix for copying wrong size of link info, and remove an useless
function
  app/testpmd: rework for displaying different size of RX descriptors

 app/test-pmd/config.c| 77 
 lib/librte_pmd_i40e/i40e_ethdev.c| 20 ++
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 32 +++
 lib/librte_pmd_i40e/i40e_rxtx.c  |  4 +-
 4 files changed, 82 insertions(+), 51 deletions(-)

-- 
1.8.1.4



[dpdk-dev] [PATCH 1/7] i40e: fix for getting correct RSS hash result

2014-06-20 Thread Helin Zhang
It wrongly gets the RSS hash result from the RX descriptor which
has been modified for receiving new packet. The fix is to get the
RSS hash result from the buffer which saves the RX descriptor.

Signed-off-by: Helin Zhang 
Acked-by: Cunming Liang 
Acked-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index d802894..22f55b9 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -864,7 +864,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
rxm->ol_flags = pkt_flags;
if (pkt_flags & PKT_RX_RSS_HASH)
rxm->pkt.hash.rss =
-   rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.rss);
+   rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);

rx_pkts[nb_rx++] = rxm;
}
@@ -1017,7 +1017,7 @@ i40e_recv_scattered_pkts(void *rx_queue,
first_seg->ol_flags = pkt_flags;
if (pkt_flags & PKT_RX_RSS_HASH)
rxm->pkt.hash.rss =
-   rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.rss);
+   rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);

/* Prefetch data of first segment, if configured to do so. */
rte_prefetch0(first_seg->pkt.data);
-- 
1.8.1.4



[dpdk-dev] [PATCH 3/7] i40e: ignore the failure of updating default filter settings

2014-06-20 Thread Helin Zhang
The failure of updating the default filter setting should be
ignored. The updating is to change the default vlan filter
behaviours configured by firmware to expected.
The failure happens on the firmware version of 4.2.2,
while doesn't happen on previous versions, as the default
settings of firmware changed.

Signed-off-by: Helin Zhang 
Acked-by: Cunming Liang 
Acked-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index a335242..102a206 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -2473,13 +2473,14 @@ i40e_vsi_setup(struct i40e_pf *pf,
(void)rte_memcpy(pf->dev_addr.addr_bytes, hw->mac.perm_addr,
ETH_ADDR_LEN);
ret = i40e_update_default_filter_setting(vsi);
-   if (ret != I40E_SUCCESS) {
-   PMD_DRV_LOG(ERR, "Failed to remove default "
-   "filter setting\n");
-   goto fail_msix_alloc;
-   }
-   }
-   else if (type == I40E_VSI_SRIOV) {
+   if (ret != I40E_SUCCESS)
+   PMD_DRV_LOG(ERR, "Failure of removing default filter "
+   "setting can be ignored\n");
+   /**
+* The failure of updating default filter setting
+* can be ignored
+*/
+   } else if (type == I40E_VSI_SRIOV) {
memset(&ctxt, 0, sizeof(ctxt));
/**
 * For other VSI, the uplink_seid equals to uplink VSI's
-- 
1.8.1.4



[dpdk-dev] [PATCH 5/7] i40e: double vlan should be specifically disabled by default

2014-06-20 Thread Helin Zhang
Double vlan should be specifically disabled by default during
port initialization which is expected.

Signed-off-by: Helin Zhang 
Acked-by: Cunming Liang 
Acked-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index f6beee6..a5fe39a 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -483,6 +483,9 @@ eth_i40e_dev_init(__rte_unused struct eth_driver *eth_drv,
}

vsi = pf->main_vsi;
+
+   /* Disable double vlan by default */
+   i40e_vsi_config_double_vlan(vsi, FALSE);
if (!vsi->max_macaddrs)
len = ETHER_ADDR_LEN;
else
-- 
1.8.1.4



[dpdk-dev] [PATCH 2/7] i40evf: support configuring crc stripping hw offload

2014-06-20 Thread Helin Zhang
In VF driver, crc stripping hw offload is enabled or not, according
to the configurations in config file.

Signed-off-by: Helin Zhang 
Acked-by: Cunming Liang 
Acked-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 4851df9..de71407 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -1062,8 +1062,22 @@ static struct rte_driver rte_i40evf_driver = {
 PMD_REGISTER_DRIVER(rte_i40evf_driver);

 static int
-i40evf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+i40evf_dev_configure(struct rte_eth_dev *dev)
 {
+   struct rte_eth_conf* conf = &dev->data->dev_conf;
+
+#ifdef RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC
+   if (conf->rxmode.hw_strip_crc) {
+   conf->rxmode.hw_strip_crc = 0;
+   PMD_DRV_LOG(INFO, "VF can not enable hw CRC stripping\n");
+   }
+#else
+   if (!conf->rxmode.hw_strip_crc) {
+   conf->rxmode.hw_strip_crc = 1;
+   PMD_DRV_LOG(INFO, "VF can not disable hw CRC stripping\n");
+}
+#endif
+
return 0;
 }

-- 
1.8.1.4



[dpdk-dev] [PATCH 7/7] app/testpmd: rework for displaying different size of RX descriptors

2014-06-20 Thread Helin Zhang
i40e supports 16 and 32 bytes RX descriptors which can be configured.
It needs to check the driver type and the configuration to determine
if 16 or 32 bytes RX descriptors is being used, for reading and
displaying the different sizes of RX descriptors.

Signed-off-by: Helin Zhang 
Acked-by: Cunming Liang 
Acked-by: Jing Chen 
---
 app/test-pmd/config.c | 77 ++-
 1 file changed, 52 insertions(+), 25 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 0023ab2..506058b 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -581,53 +581,80 @@ union igb_ring_dword {
} words;
 };

-#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
-struct igb_ring_desc_32B {
+struct igb_ring_desc_32_bytes {
union igb_ring_dword lo_dword;
union igb_ring_dword hi_dword;
union igb_ring_dword resv1;
union igb_ring_dword resv2;
 };
-#endif

-struct igb_ring_desc {
+struct igb_ring_desc_16_bytes {
union igb_ring_dword lo_dword;
union igb_ring_dword hi_dword;
 };

 static void
-ring_rx_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
+ring_rxd_display_dword(union igb_ring_dword dword)
+{
+   printf("0x%08X - 0x%08X\n", (unsigned)dword.words.lo,
+   (unsigned)dword.words.hi);
+}
+
+static void
+ring_rx_descriptor_display(const struct rte_memzone *ring_mz,
+  uint8_t port_id,
+  uint16_t desc_id)
 {
-#ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
-   struct igb_ring_desc *ring;
-   struct igb_ring_desc rd;
+   struct rte_eth_dev_info dev_info;

-   ring = (struct igb_ring_desc *) ring_mz->addr;
+   memset(&dev_info, 0, sizeof(dev_info));
+   rte_eth_dev_info_get(port_id, &dev_info);
+
+   if (strstr(dev_info.driver_name, "i40e") != NULL) { /* i40e */
+#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+   struct igb_ring_desc_32_bytes *ring =
+   (struct igb_ring_desc_32_bytes *)ring_mz->addr;
+
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].lo_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].hi_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].resv1));
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].resv2));
 #else
-   struct igb_ring_desc_32B *ring;
-   struct igb_ring_desc_32B rd;
+   struct igb_ring_desc_16_bytes *ring =
+   (struct igb_ring_desc_16_bytes *)ring_mz->addr;

-   ring = (struct igb_ring_desc_32B *) ring_mz->addr;
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].lo_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].hi_dword));
 #endif
-   rd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
-   rd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
-   printf("0x%08X - 0x%08X / 0x%08X - 0x%08X\n",
-   (unsigned)rd.lo_dword.words.lo, (unsigned)rd.lo_dword.words.hi,
-   (unsigned)rd.hi_dword.words.lo, (unsigned)rd.hi_dword.words.hi);
+   } else { /* not i40e */
+   struct igb_ring_desc_16_bytes *ring =
+   (struct igb_ring_desc_16_bytes *)ring_mz->addr;
+
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].lo_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].hi_dword));
+   }
 }

 static void
 ring_tx_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
 {
-   struct igb_ring_desc *ring;
-   struct igb_ring_desc rd;
+   struct igb_ring_desc_16_bytes *ring;
+   struct igb_ring_desc_16_bytes txd;

-   ring = (struct igb_ring_desc *) ring_mz->addr;
-   rd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
-   rd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
+   ring = (struct igb_ring_desc_16_bytes *)ring_mz->addr;
+   txd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
+   txd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
printf("0x%08X - 0x%08X / 0x%08X - 0x%08X\n",
-   (unsigned)rd.lo_dword.words.lo, (unsigned)rd.lo_dword.words.hi,
-   (unsigned)rd.hi_dword.words.lo, (unsigned)rd.hi_dword.words.hi);
+   (unsigned)txd.lo_dword.words.lo, 
(unsigned)txd.lo_dword.words.hi,
+   (unsigned)txd.hi_dword.words.lo, 
(unsigned)txd.hi_dword.words.hi);
 }

 void
@@ -644,7 +671,7 @@ rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, 
uint16_t rx

[dpdk-dev] [PATCH 4/7] i40e: fix for updating the hash lookup table of PF RSS

2014-06-20 Thread Helin Zhang
The bit shifting were written wrongly in '0x1 < j',
the correct one should be '0x1 << j'.

Signed-off-by: Helin Zhang 
Acked-by: Cunming Liang 
Acked-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 102a206..f6beee6 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1475,7 +1475,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,
l = I40E_READ_REG(hw, I40E_PFQF_HLUT(i >> 2));

for (j = 0, lut = 0; j < 4; j++) {
-   if (mask & (0x1 < j))
+   if (mask & (0x1 << j))
lut |= reta_conf->reta[i + j] << (8 * j);
else
lut |= l & (0xFF << (8 * j));
-- 
1.8.1.4



[dpdk-dev] [PATCH 6/7] i40evf: fix for copying wrong size of link info, and remove an useless function

2014-06-20 Thread Helin Zhang
Delete the inline function which is not used at this moment.
Fix the bug of copying wrong size of link info in function of
i40evf_get_link_status().

Signed-off-by: Helin Zhang 
Acked-by: Cunming Liang 
Acked-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 16 +---
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index de71407..8989753 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -809,7 +809,7 @@ i40evf_get_link_status(struct rte_eth_dev *dev, struct 
rte_eth_link *link)
}

new_link = (struct rte_eth_link *)args.out_buffer;
-   (void)rte_memcpy(link, new_link, sizeof(link));
+   (void)rte_memcpy(link, new_link, sizeof(*link));

return 0;
 }
@@ -821,20 +821,6 @@ static struct rte_pci_id pci_id_i40evf_map[] = {
 };

 static inline int
-i40evf_dev_atomic_read_link_status(struct rte_eth_dev *dev,
-  struct rte_eth_link *link)
-{
-   struct rte_eth_link *dst = link;
-   struct rte_eth_link *src = &(dev->data->dev_link);
-
-   if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
-   *(uint64_t *)src) == 0)
-   return -1;
-
-   return 0;
-}
-
-static inline int
 i40evf_dev_atomic_write_link_status(struct rte_eth_dev *dev,
struct rte_eth_link *link)
 {
-- 
1.8.1.4



[dpdk-dev] [PATCH v2 2/7] i40evf: remove an interface which is not used

2014-06-23 Thread Helin Zhang
i40evf_dev_atomic_read_link_status() was defined but not used.
To avoid possible warnings by some compilers, it needs to
delete the whole function.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 9e86285..4800902 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -883,20 +883,6 @@ static struct rte_pci_id pci_id_i40evf_map[] = {
 };

 static inline int
-i40evf_dev_atomic_read_link_status(struct rte_eth_dev *dev,
-  struct rte_eth_link *link)
-{
-   struct rte_eth_link *dst = link;
-   struct rte_eth_link *src = &(dev->data->dev_link);
-
-   if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
-   *(uint64_t *)src) == 0)
-   return -1;
-
-   return 0;
-}
-
-static inline int
 i40evf_dev_atomic_write_link_status(struct rte_eth_dev *dev,
struct rte_eth_link *link)
 {
-- 
1.8.1.4



[dpdk-dev] [PATCH v2 3/7] i40evf: fix for copying wrong size of link info

2014-06-23 Thread Helin Zhang
Fix a bug of copying wrong size of link information in the
function of i40evf_get_link_status().

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 4800902..081589c 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -871,7 +871,7 @@ i40evf_get_link_status(struct rte_eth_dev *dev, struct 
rte_eth_link *link)
}

new_link = (struct rte_eth_link *)args.out_buffer;
-   (void)rte_memcpy(link, new_link, sizeof(link));
+   (void)rte_memcpy(link, new_link, sizeof(*link));

return 0;
 }
-- 
1.8.1.4



[dpdk-dev] [PATCH v2 0/7] enhancements for i40e

2014-06-23 Thread Helin Zhang
These patches are enhancements for i40e or relevant. In detail, they include:
 * fix for getting correct RSS hash result
 * remove an interface which is not used
 * fix for copying wrong size of link info
 * fix for updating the hash lookup table of PF RSS
 * double vlan should be specifically disabled by default
 * ignore the failure of updating default macvlan filter.
 * rework for displaying different size of RX descriptors in testpmd.

Helin Zhang (7):
  i40e: fix for getting correct RSS hash result
  i40evf: remove an interface which is not used
  i40evf: fix for copying wrong size of link info
  i40e: fix for updating the hash lookup table of PF RSS
  i40e: double vlan should be specifically disabled by default
  i40e: ignore the failure of updating default macvlan filter
  app/testpmd: rework for displaying different size of RX descriptors

 app/test-pmd/config.c| 73 
 lib/librte_pmd_i40e/i40e_ethdev.c| 35 ++---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 16 +---
 lib/librte_pmd_i40e/i40e_rxtx.c  |  4 +-
 4 files changed, 73 insertions(+), 55 deletions(-)

-- 
1.8.1.4



[dpdk-dev] [PATCH v2 5/7] i40e: double vlan should be specifically disabled by default

2014-06-23 Thread Helin Zhang
Double vlan should be specifically disabled by default during
port initialization which is expected.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 0d7be44..204d2cb 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -482,6 +482,10 @@ eth_i40e_dev_init(__rte_unused struct eth_driver *eth_drv,
}

vsi = pf->main_vsi;
+
+   /* Disable double vlan by default */
+   i40e_vsi_config_double_vlan(vsi, FALSE);
+
if (!vsi->max_macaddrs)
len = ETHER_ADDR_LEN;
else
-- 
1.8.1.4



[dpdk-dev] [PATCH v2 7/7] app/testpmd: rework for displaying different size of RX descriptors

2014-06-23 Thread Helin Zhang
i40e supports 16 and 32 bytes RX descriptors which can be configured.
It needs to check the driver type and the configuration to determine
if 16 or 32 bytes RX descriptors is being used, for reading and
displaying the different sizes of RX descriptors.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 app/test-pmd/config.c | 73 +--
 1 file changed, 48 insertions(+), 25 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 0023ab2..b08b006 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -581,53 +581,76 @@ union igb_ring_dword {
} words;
 };

-#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
-struct igb_ring_desc_32B {
+struct igb_ring_desc_32_bytes {
union igb_ring_dword lo_dword;
union igb_ring_dword hi_dword;
union igb_ring_dword resv1;
union igb_ring_dword resv2;
 };
-#endif

-struct igb_ring_desc {
+struct igb_ring_desc_16_bytes {
union igb_ring_dword lo_dword;
union igb_ring_dword hi_dword;
 };

 static void
-ring_rx_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
+ring_rxd_display_dword(union igb_ring_dword dword)
 {
-#ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
-   struct igb_ring_desc *ring;
-   struct igb_ring_desc rd;
+   printf("0x%08X - 0x%08X\n", (unsigned)dword.words.lo,
+   (unsigned)dword.words.hi);
+}

-   ring = (struct igb_ring_desc *) ring_mz->addr;
+static void
+ring_rx_descriptor_display(const struct rte_memzone *ring_mz,
+#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+  uint8_t port_id,
 #else
-   struct igb_ring_desc_32B *ring;
-   struct igb_ring_desc_32B rd;
+  __rte_unused uint8_t port_id,
+#endif
+  uint16_t desc_id)
+{
+   struct igb_ring_desc_16_bytes *ring =
+   (struct igb_ring_desc_16_bytes *)ring_mz->addr;
+#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+   struct rte_eth_dev_info dev_info;
+
+   memset(&dev_info, 0, sizeof(dev_info));
+   rte_eth_dev_info_get(port_id, &dev_info);
+   if (strstr(dev_info.driver_name, "i40e") != NULL) {
+   /* 32 bytes RX descriptor, i40e only */
+   struct igb_ring_desc_32_bytes *ring =
+   (struct igb_ring_desc_32_bytes *)ring_mz->addr;

-   ring = (struct igb_ring_desc_32B *) ring_mz->addr;
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].lo_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].hi_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].resv1));
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].resv2));
+   return;
+   }
 #endif
-   rd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
-   rd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
-   printf("0x%08X - 0x%08X / 0x%08X - 0x%08X\n",
-   (unsigned)rd.lo_dword.words.lo, (unsigned)rd.lo_dword.words.hi,
-   (unsigned)rd.hi_dword.words.lo, (unsigned)rd.hi_dword.words.hi);
+   /* 16 bytes RX descriptor */
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].lo_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(\
+   ring[desc_id].hi_dword));
 }

 static void
 ring_tx_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
 {
-   struct igb_ring_desc *ring;
-   struct igb_ring_desc rd;
+   struct igb_ring_desc_16_bytes *ring;
+   struct igb_ring_desc_16_bytes txd;

-   ring = (struct igb_ring_desc *) ring_mz->addr;
-   rd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
-   rd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
+   ring = (struct igb_ring_desc_16_bytes *)ring_mz->addr;
+   txd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
+   txd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
printf("0x%08X - 0x%08X / 0x%08X - 0x%08X\n",
-   (unsigned)rd.lo_dword.words.lo, (unsigned)rd.lo_dword.words.hi,
-   (unsigned)rd.hi_dword.words.lo, (unsigned)rd.hi_dword.words.hi);
+   (unsigned)txd.lo_dword.words.lo, 
(unsigned)txd.lo_dword.words.hi,
+   (unsigned)txd.hi_dword.words.lo, 
(unsigned)txd.hi_dword.words.hi);
 }

 void
@@ -644,7 +667,7 @@ rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, 
uint16_t rxd_id)
rx_mz = ring_dma_zone_lookup("rx_ring", port_id, rxq_id);
if (rx_mz == NULL)
return;
-   ring_rx_descriptor_display(rx_mz, rxd_id);
+   ring_rx_descriptor_display(rx_mz, port_id, rxd_id);
 }

 void
-- 
1.8.1.4



[dpdk-dev] [PATCH v2 1/7] i40e: fix for getting correct RSS hash result

2014-06-23 Thread Helin Zhang
It wrongly gets the RSS hash result from the RX descriptor which
has been modified for receiving new packet. The fix is to get the
RSS hash result from the buffer which saves the RX descriptor.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 9fccbee..3a6a2d8 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -863,7 +863,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
rxm->ol_flags = pkt_flags;
if (pkt_flags & PKT_RX_RSS_HASH)
rxm->pkt.hash.rss =
-   rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.rss);
+   rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);

rx_pkts[nb_rx++] = rxm;
}
@@ -1016,7 +1016,7 @@ i40e_recv_scattered_pkts(void *rx_queue,
first_seg->ol_flags = pkt_flags;
if (pkt_flags & PKT_RX_RSS_HASH)
rxm->pkt.hash.rss =
-   rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.rss);
+   rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);

/* Prefetch data of first segment, if configured to do so. */
rte_prefetch0(first_seg->pkt.data);
-- 
1.8.1.4



[dpdk-dev] [PATCH v2 4/7] i40e: fix for updating the hash lookup table of PF RSS

2014-06-23 Thread Helin Zhang
The bit shifting were written wrongly in '0x1 < j',
the correct one should be '0x1 << j'.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 1b4e822..0d7be44 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1452,7 +1452,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,
l = I40E_READ_REG(hw, I40E_PFQF_HLUT(i >> 2));

for (j = 0, lut = 0; j < 4; j++) {
-   if (mask & (0x1 < j))
+   if (mask & (0x1 << j))
lut |= reta_conf->reta[i + j] << (8 * j);
else
lut |= l & (0xFF << (8 * j));
-- 
1.8.1.4



[dpdk-dev] [PATCH v2 6/7] i40e: ignore the failure of updating default macvlan filter

2014-06-23 Thread Helin Zhang
For NVM4.2.2 or after, the firmware has the correct configurations
and load the macvlan filter as expected. It is not needed to
Update the default macvlan filter which cannot be removed at
all during initialization.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 29 +
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 204d2cb..3311d73 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -2306,11 +2306,10 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
ret = i40e_aq_remove_macvlan(hw, vsi->seid, &def_filter, 1, NULL);
if (ret != I40E_SUCCESS) {
struct i40e_mac_filter *f;
-   PMD_DRV_LOG(WARNING, "Failed to remove default [mac,vlan] 
config\n");

-   /* Even failed to update default setting, still needs to add 
the permanent
-*  mac into mac list.
-*/
+   PMD_DRV_LOG(WARNING, "Cannot remove the default "
+   "macvlan filter\n");
+   /* It needs to add the permanent mac into mac list */
f = rte_zmalloc("macv_filter", sizeof(*f), 0);
if (f == NULL) {
PMD_DRV_LOG(ERR, "failed to allocate memory\n");
@@ -2320,6 +2319,7 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
ETH_ADDR_LEN);
TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
vsi->mac_num++;
+
return ret;
}

@@ -2516,14 +2516,19 @@ i40e_vsi_setup(struct i40e_pf *pf,

(void)rte_memcpy(pf->dev_addr.addr_bytes, hw->mac.perm_addr,
ETH_ADDR_LEN);
-   ret = i40e_update_default_filter_setting(vsi);
-   if (ret != I40E_SUCCESS) {
-   PMD_DRV_LOG(ERR, "Failed to remove default "
-   "filter setting\n");
-   goto fail_msix_alloc;
-   }
-   }
-   else if (type == I40E_VSI_SRIOV) {
+
+   /**
+* Updating default filter settings are necessary to prevent
+* reception of tagged packets.
+* Some old firmware configurations load a default macvlan
+* filter which accepts both tagged and untagged packets.
+* The updating is to use a normal filter instead if needed.
+* For NVM 4.2.2 or after, the updating is not needed anymore.
+* The firmware with correct configurations load the default
+* macvlan filter which is expected and cannot be removed.
+*/
+   i40e_update_default_filter_setting(vsi);
+   } else if (type == I40E_VSI_SRIOV) {
memset(&ctxt, 0, sizeof(ctxt));
/**
 * For other VSI, the uplink_seid equals to uplink VSI's
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 1/7] i40e: fix for getting correct RSS hash result

2014-06-24 Thread Helin Zhang
It wrongly gets the RSS hash result from the RX descriptor which
has been modified for receiving new packet. The fix is to get the
RSS hash result from the buffer which saves the RX descriptor.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 9fccbee..3a6a2d8 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -863,7 +863,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
rxm->ol_flags = pkt_flags;
if (pkt_flags & PKT_RX_RSS_HASH)
rxm->pkt.hash.rss =
-   rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.rss);
+   rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);

rx_pkts[nb_rx++] = rxm;
}
@@ -1016,7 +1016,7 @@ i40e_recv_scattered_pkts(void *rx_queue,
first_seg->ol_flags = pkt_flags;
if (pkt_flags & PKT_RX_RSS_HASH)
rxm->pkt.hash.rss =
-   rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.rss);
+   rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);

/* Prefetch data of first segment, if configured to do so. */
rte_prefetch0(first_seg->pkt.data);
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 3/7] i40evf: fix for copying wrong size of link info

2014-06-24 Thread Helin Zhang
Fix a bug of copying wrong size of link information in the
function of i40evf_get_link_status().

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 9750c6e..2726bfb 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -871,7 +871,7 @@ i40evf_get_link_status(struct rte_eth_dev *dev, struct 
rte_eth_link *link)
}

new_link = (struct rte_eth_link *)args.out_buffer;
-   (void)rte_memcpy(link, new_link, sizeof(link));
+   (void)rte_memcpy(link, new_link, sizeof(*link));

return 0;
 }
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 4/7] i40e: fix for updating the hash lookup table of PF RSS

2014-06-24 Thread Helin Zhang
The bit shifting were written wrongly in '0x1 < j',
the correct one should be '0x1 << j'.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 1b4e822..0d7be44 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1452,7 +1452,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,
l = I40E_READ_REG(hw, I40E_PFQF_HLUT(i >> 2));

for (j = 0, lut = 0; j < 4; j++) {
-   if (mask & (0x1 < j))
+   if (mask & (0x1 << j))
lut |= reta_conf->reta[i + j] << (8 * j);
else
lut |= l & (0xFF << (8 * j));
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 0/7] enhancements for i40e

2014-06-24 Thread Helin Zhang
These patches are enhancements for i40e or relevant. In detail, they include:
 * fix for getting correct RSS hash result.
 * remove an interface which is not used.
 * fix for copying wrong size of link info.
 * fix for updating the hash lookup table of PF RSS.
 * double vlan should be specifically disabled by default.
 * ignore the failure of updating default macvlan filter.
 * rework for displaying different size of RX descriptors in testpmd.

Helin Zhang (7):
  i40e: fix for getting correct RSS hash result
  i40evf: remove an interface which is not used
  i40evf: fix for copying wrong size of link info
  i40e: fix for updating the hash lookup table of PF RSS
  i40e: double vlan should be specifically disabled by default
  i40e: ignore the failure of updating default macvlan filter
  app/testpmd: rework for displaying different size of RX descriptors

 app/test-pmd/config.c| 75 
 lib/librte_pmd_i40e/i40e_ethdev.c| 35 ++---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 16 +---
 lib/librte_pmd_i40e/i40e_rxtx.c  |  4 +-
 4 files changed, 75 insertions(+), 55 deletions(-)

-- 
1.8.1.4



[dpdk-dev] [PATCH v3 5/7] i40e: double vlan should be specifically disabled by default

2014-06-24 Thread Helin Zhang
Double vlan should be specifically disabled by default during
port initialization which is expected.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 0d7be44..204d2cb 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -482,6 +482,10 @@ eth_i40e_dev_init(__rte_unused struct eth_driver *eth_drv,
}

vsi = pf->main_vsi;
+
+   /* Disable double vlan by default */
+   i40e_vsi_config_double_vlan(vsi, FALSE);
+
if (!vsi->max_macaddrs)
len = ETHER_ADDR_LEN;
else
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 6/7] i40e: ignore the failure of updating default macvlan filter

2014-06-24 Thread Helin Zhang
For NVM4.2.2 or after, the firmware has the correct configurations
and load the macvlan filter as expected. It is not needed to
Update the default macvlan filter which cannot be removed at
all during initialization.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 29 +
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 204d2cb..3311d73 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -2306,11 +2306,10 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
ret = i40e_aq_remove_macvlan(hw, vsi->seid, &def_filter, 1, NULL);
if (ret != I40E_SUCCESS) {
struct i40e_mac_filter *f;
-   PMD_DRV_LOG(WARNING, "Failed to remove default [mac,vlan] 
config\n");

-   /* Even failed to update default setting, still needs to add 
the permanent
-*  mac into mac list.
-*/
+   PMD_DRV_LOG(WARNING, "Cannot remove the default "
+   "macvlan filter\n");
+   /* It needs to add the permanent mac into mac list */
f = rte_zmalloc("macv_filter", sizeof(*f), 0);
if (f == NULL) {
PMD_DRV_LOG(ERR, "failed to allocate memory\n");
@@ -2320,6 +2319,7 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
ETH_ADDR_LEN);
TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
vsi->mac_num++;
+
return ret;
}

@@ -2516,14 +2516,19 @@ i40e_vsi_setup(struct i40e_pf *pf,

(void)rte_memcpy(pf->dev_addr.addr_bytes, hw->mac.perm_addr,
ETH_ADDR_LEN);
-   ret = i40e_update_default_filter_setting(vsi);
-   if (ret != I40E_SUCCESS) {
-   PMD_DRV_LOG(ERR, "Failed to remove default "
-   "filter setting\n");
-   goto fail_msix_alloc;
-   }
-   }
-   else if (type == I40E_VSI_SRIOV) {
+
+   /**
+* Updating default filter settings are necessary to prevent
+* reception of tagged packets.
+* Some old firmware configurations load a default macvlan
+* filter which accepts both tagged and untagged packets.
+* The updating is to use a normal filter instead if needed.
+* For NVM 4.2.2 or after, the updating is not needed anymore.
+* The firmware with correct configurations load the default
+* macvlan filter which is expected and cannot be removed.
+*/
+   i40e_update_default_filter_setting(vsi);
+   } else if (type == I40E_VSI_SRIOV) {
memset(&ctxt, 0, sizeof(ctxt));
/**
 * For other VSI, the uplink_seid equals to uplink VSI's
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 2/7] i40evf: remove an interface which is not used

2014-06-24 Thread Helin Zhang
i40evf_dev_atomic_read_link_status() was defined but not used.
To avoid possible warnings by some compilers, it needs to
delete the whole function.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index b9c1483..9750c6e 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -883,20 +883,6 @@ static struct rte_pci_id pci_id_i40evf_map[] = {
 };

 static inline int
-i40evf_dev_atomic_read_link_status(struct rte_eth_dev *dev,
-  struct rte_eth_link *link)
-{
-   struct rte_eth_link *dst = link;
-   struct rte_eth_link *src = &(dev->data->dev_link);
-
-   if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
-   *(uint64_t *)src) == 0)
-   return -1;
-
-   return 0;
-}
-
-static inline int
 i40evf_dev_atomic_write_link_status(struct rte_eth_dev *dev,
struct rte_eth_link *link)
 {
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 7/7] app/testpmd: rework for displaying different size of RX descriptors

2014-06-24 Thread Helin Zhang
i40e supports 16 and 32 bytes RX descriptors which can be configured.
It needs to check the driver type and the configuration to determine
if 16 or 32 bytes RX descriptors is being used, for reading and
displaying the different sizes of RX descriptors.

Signed-off-by: Helin Zhang 
Acked-by: Jing Chen 
Acked-by: Cunming Liang 
---
 app/test-pmd/config.c | 75 ++-
 1 file changed, 50 insertions(+), 25 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 0023ab2..255f82d 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -581,53 +581,78 @@ union igb_ring_dword {
} words;
 };

-#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
-struct igb_ring_desc_32B {
+struct igb_ring_desc_32_bytes {
union igb_ring_dword lo_dword;
union igb_ring_dword hi_dword;
union igb_ring_dword resv1;
union igb_ring_dword resv2;
 };
-#endif

-struct igb_ring_desc {
+struct igb_ring_desc_16_bytes {
union igb_ring_dword lo_dword;
union igb_ring_dword hi_dword;
 };

 static void
-ring_rx_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
+ring_rxd_display_dword(union igb_ring_dword dword)
 {
-#ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
-   struct igb_ring_desc *ring;
-   struct igb_ring_desc rd;
+   printf("0x%08X - 0x%08X\n", (unsigned)dword.words.lo,
+   (unsigned)dword.words.hi);
+}

-   ring = (struct igb_ring_desc *) ring_mz->addr;
+static void
+ring_rx_descriptor_display(const struct rte_memzone *ring_mz,
+#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+  uint8_t port_id,
 #else
-   struct igb_ring_desc_32B *ring;
-   struct igb_ring_desc_32B rd;
+  __rte_unused uint8_t port_id,
+#endif
+  uint16_t desc_id)
+{
+   struct igb_ring_desc_16_bytes *ring =
+   (struct igb_ring_desc_16_bytes *)ring_mz->addr;
+#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+   struct rte_eth_dev_info dev_info;
+
+   memset(&dev_info, 0, sizeof(dev_info));
+   rte_eth_dev_info_get(port_id, &dev_info);
+   if (strstr(dev_info.driver_name, "i40e") != NULL) {
+   /* 32 bytes RX descriptor, i40e only */
+   struct igb_ring_desc_32_bytes *ring =
+   (struct igb_ring_desc_32_bytes *)ring_mz->addr;

-   ring = (struct igb_ring_desc_32B *) ring_mz->addr;
+   ring_rxd_display_dword(rte_le_to_cpu_64(
+   ring[desc_id].lo_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(
+   ring[desc_id].hi_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(
+   ring[desc_id].resv1));
+   ring_rxd_display_dword(rte_le_to_cpu_64(
+   ring[desc_id].resv2));
+   return;
+   }
 #endif
-   rd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
-   rd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
-   printf("0x%08X - 0x%08X / 0x%08X - 0x%08X\n",
-   (unsigned)rd.lo_dword.words.lo, (unsigned)rd.lo_dword.words.hi,
-   (unsigned)rd.hi_dword.words.lo, (unsigned)rd.hi_dword.words.hi);
+   /* 16 bytes RX descriptor */
+   ring_rxd_display_dword(rte_le_to_cpu_64(
+   ring[desc_id].lo_dword));
+   ring_rxd_display_dword(rte_le_to_cpu_64(
+   ring[desc_id].hi_dword));
 }

 static void
 ring_tx_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
 {
-   struct igb_ring_desc *ring;
-   struct igb_ring_desc rd;
+   struct igb_ring_desc_16_bytes *ring;
+   struct igb_ring_desc_16_bytes txd;

-   ring = (struct igb_ring_desc *) ring_mz->addr;
-   rd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
-   rd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
+   ring = (struct igb_ring_desc_16_bytes *)ring_mz->addr;
+   txd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
+   txd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
printf("0x%08X - 0x%08X / 0x%08X - 0x%08X\n",
-   (unsigned)rd.lo_dword.words.lo, (unsigned)rd.lo_dword.words.hi,
-   (unsigned)rd.hi_dword.words.lo, (unsigned)rd.hi_dword.words.hi);
+   (unsigned)txd.lo_dword.words.lo,
+   (unsigned)txd.lo_dword.words.hi,
+   (unsigned)txd.hi_dword.words.lo,
+   (unsigned)txd.hi_dword.words.hi);
 }

 void
@@ -644,7 +669,7 @@ rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, 
uint16_t rxd_id)
rx_mz = ring_dma_zone_lookup("rx_ring", port_id, rxq_id);
if (rx_mz == NULL)
return;
-   ring_rx_descriptor_display(rx_mz, rxd_id);
+   ring_rx_descriptor_display(rx_mz, port_id, rxd_id);
 }

 void
-- 
1.8.1.4



[dpdk-dev] [PATCH] kni: bug fix of compiling KNI kernel module on Linux kernel 3.6.10

2014-05-18 Thread HELIN ZHANG
Error of "implicit-function-declaration" can be seen when building
KNI kernel module on Linux kernel 3.6.10 platform.

The root cause is as follows.
On Linux kernel 3.6.10, ETHTOOL_GEEE is defined in Linux header file
of "linux/ethtool.h", while is not defined in most of other
linux kernel versions.
mmd_eee_cap_to_ethtool_sup_t(), mmd_eee_adv_to_ethtool_adv_t() and
ethtool_adv_to_mmd_eee_adv_t() in kcompat.h are disabled by
"#if !defined(ETHTOOL_GEEE) || (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE
<= RHEL_RELEASE_VERSION(6,4))", while are called in igb_get_eee()
in igb_ethtool.c which is enabled by "#ifdef ETHTOOL_GEEE".

This patch is to fix the compile issue.

Signed-off-by: HELIN ZHANG 
---
 lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h 
b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
index 19df483..54c2ac5 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
@@ -3586,7 +3586,7 @@ static inline bool ether_addr_equal(const u8 *addr1, 
const u8 *addr2)
 #define ADVERTISED_4baseLR4_Full   (1 << 26)
 #endif

-#if !defined(ETHTOOL_GEEE) || (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE <= 
RHEL_RELEASE_VERSION(6,4))
+#if defined(ETHTOOL_GEEE) || (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE <= 
RHEL_RELEASE_VERSION(6,4))
 /**
  * mmd_eee_cap_to_ethtool_sup_t
  * @eee_cap: value of the MMD EEE Capability register
-- 
1.8.1.4



[dpdk-dev] [PATCH 00/22][PMD][I40E] *** Add i40e PMD support ***

2014-05-21 Thread Helin Zhang
Summary:
The series of patches are to add i40e PMD support.
* Add new PMD driver of i40e in the folder of librte_pmd_i40e
* Add some neccessary definitions, changes in rte_mbuf.h and eth_dev
* Add new configurations for i40e
* Add or modifiy makefiles to support i40e compilation
* Add neccessary changes in ixgbe, e1000 and vmxnet3 PMD, as hash flags
  has been enlarged from 16 bits to 64 bits to support i40e
* Add neccessary changes in example applications and testpmd to use
  ETH_RSS_IP to replace all IP hash flags, as i40e introduced more
  hash flags.
* Add command in testpmd for port based vlan insertion offload testing
* Add neccessary changes in eth_dev to support configuring maximum
  packet length of less than 1518
* Add two sys files in igb_uio to support enabling/disabling
  'Extended Tag' and resetting 'Max Read Request Size', as it has
  big impacts on i40e performance
* Add neccessary changes in pci to read/write the above two sys files
  during probing PCI

Helin Zhang (22):
  i40e: add basic shared code
  i40e: add PMD source files
  i40e: add i40e support
  e1000: enlarge the hash flags of RSS to 64 bits
  ixgbe: enlarge the hash flags of RSS to 64 bits
  vmxnet3: enlarge the hash flags of RSS to 64 bits
  app/testpmd: enlarge the hash flags of RSS to 64 bits
  examples/qos_meter: use ETH_RSS_IP to replace IP hash flags of RSS
  examples/multi_process: use ETH_RSS_IP to replace IP hash flags of RSS
  examples/l3fwd: use ETH_RSS_IP to replace IP hash flags of RSS
  examples/l3fwd-vf: use ETH_RSS_IP to replace IP hash flags of RSS
  examples/l3fwd-power: use ETH_RSS_IP to replace IP hash flags of RSS
  examples/ip_reassembly: use ETH_RSS_IP to replace IP hash flags of RSS
  examples/dpdk_qat: use ETH_RSS_IP to replace IP hash flags of RSS
  examples/load_balancer: use ETH_RSS_IP to replace IP hash flags of RSS
  app/test-pmd: tell the driver the correct packet type to support
i40e TX checksum offload
  app/test-pmd: support displaying i40e 32 bytes RX descriptor
  app/test-pmd: support setting port based VLAN ID offloading
  igb_uio: add sys files to read/write specific bits in pci config space
  pci: support reading/writing sys files of 'extended_tag' and
'max_read_request_size'
  config: add configurations for enabling 'Extended Tag' or
resetting 'Max Read Request Size'
  ethdev: support setting maximum packet length to less than 1518

 app/test-pmd/cmdline.c  |65 +-
 app/test-pmd/config.c   |45 +-
 app/test-pmd/csumonly.c | 2 +
 app/test-pmd/parameters.c   | 5 +-
 app/test-pmd/testpmd.c  | 2 +-
 app/test-pmd/testpmd.h  | 4 +-
 config/defconfig_i686-default-linuxapp-gcc  |30 +
 config/defconfig_i686-default-linuxapp-icc  |30 +
 config/defconfig_x86_64-default-bsdapp-gcc  |15 +
 config/defconfig_x86_64-default-linuxapp-gcc|30 +
 config/defconfig_x86_64-default-linuxapp-icc|30 +
 examples/dpdk_qat/main.c| 2 +-
 examples/ip_reassembly/main.c   | 2 +-
 examples/l3fwd-power/main.c | 2 +-
 examples/l3fwd-vf/main.c| 2 +-
 examples/l3fwd/main.c   | 2 +-
 examples/load_balancer/init.c   | 2 +-
 examples/multi_process/symmetric_mp/main.c  | 2 +-
 examples/qos_meter/main.c   | 2 +-
 lib/Makefile| 1 +
 lib/librte_eal/common/include/rte_pci_dev_ids.h |44 +
 lib/librte_eal/linuxapp/eal/eal_pci.c   |   101 +
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c   |   107 +
 lib/librte_ether/rte_ethdev.c   |25 +-
 lib/librte_ether/rte_ethdev.h   |   146 +-
 lib/librte_ether/rte_ether.h|24 +
 lib/librte_mbuf/rte_mbuf.h  | 8 +
 lib/librte_pmd_e1000/igb_rxtx.c |16 +-
 lib/librte_pmd_i40e/Makefile|85 +
 lib/librte_pmd_i40e/i40e/i40e_adminq.c  |  1210 ++
 lib/librte_pmd_i40e/i40e/i40e_adminq.h  |   121 +
 lib/librte_pmd_i40e/i40e/i40e_adminq_cmd.h  |  2198 
 lib/librte_pmd_i40e/i40e/i40e_alloc.h   |65 +
 lib/librte_pmd_i40e/i40e/i40e_common.c  |  5176 
 lib/librte_pmd_i40e/i40e/i40e_dcb.c |  1165 ++
 lib/librte_pmd_i40e/i40e/i40e_dcb.h |   264 +
 lib/librte_pmd_i40e/i40e/i40e_diag.c|   180 +
 lib/librte_pmd_i40e/i40e/i40e_diag.h|61 +
 lib/librte_pmd_i40e/i40e/i40e_hmc.c |   388 +
 lib/librte_pmd_i40e/i40e/i40e_hmc.h |   287 +
 lib/librte_pmd_i40e/i40e/i40e_lan_hmc.c |  1443 ++
 lib/librte_pmd_i40e/i40e/i40e_lan_hmc.h |   272 +
 li

[dpdk-dev] [PATCH 03/22] i40e: add i40e support

2014-05-21 Thread Helin Zhang
Add i40e support by modifying neccessary source files.
The componets modified are,
 - Add configurations for i40e in config/
 - Modified neccessary makefiles in both k/ and lib/
 - Modified neccessary source files in librte_ether/
 - Add more packet bit flags in rte_mbuf.h
 - Add i40e support in igb_uio
 - Add i40e support in rte_pci_dev_ids.h, including new device IDs

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 config/defconfig_i686-default-linuxapp-gcc  |  20 
 config/defconfig_i686-default-linuxapp-icc  |  20 
 config/defconfig_x86_64-default-bsdapp-gcc  |  15 +++
 config/defconfig_x86_64-default-linuxapp-gcc|  20 
 config/defconfig_x86_64-default-linuxapp-icc|  20 
 lib/Makefile|   1 +
 lib/librte_eal/common/include/rte_pci_dev_ids.h |  44 +++
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c   |   2 +
 lib/librte_ether/rte_ethdev.c   |  15 +++
 lib/librte_ether/rte_ethdev.h   | 146 +---
 lib/librte_ether/rte_ether.h|  24 
 lib/librte_mbuf/rte_mbuf.h  |   8 ++
 mk/rte.app.mk   |   4 +
 13 files changed, 323 insertions(+), 16 deletions(-)

diff --git a/config/defconfig_i686-default-linuxapp-gcc 
b/config/defconfig_i686-default-linuxapp-gcc
index 14bd3d1..931f6c5 100644
--- a/config/defconfig_i686-default-linuxapp-gcc
+++ b/config/defconfig_i686-default-linuxapp-gcc
@@ -179,6 +179,26 @@ CONFIG_RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC=y
 CONFIG_RTE_LIBRTE_IXGBE_ALLOW_UNSUPPORTED_SFP=n

 #
+# Compile burst-oriented I40E PMD driver
+#
+# CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL can be 0 to 8160 us,
+# otherwise a default value will be used instead.
+# The interval will be aligned to 2, due to the hardware restriction.
+#
+CONFIG_RTE_LIBRTE_I40E_PMD=y
+CONFIG_RTE_LIBRTE_I40E_DEBUG_INIT=n
+CONFIG_RTE_LIBRTE_I40E_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_I40E_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_I40E_DEBUG_TX_FREE=n
+CONFIG_RTE_LIBRTE_I40E_DEBUG_DRIVER=n
+CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC=n
+CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=y
+CONFIG_RTE_LIBRTE_I40E_ALLOW_UNSUPPORTED_SFP=n
+CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n
+CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4
+CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
diff --git a/config/defconfig_i686-default-linuxapp-icc 
b/config/defconfig_i686-default-linuxapp-icc
index ec3386e..b07bd76 100644
--- a/config/defconfig_i686-default-linuxapp-icc
+++ b/config/defconfig_i686-default-linuxapp-icc
@@ -179,6 +179,26 @@ CONFIG_RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC=y
 CONFIG_RTE_LIBRTE_IXGBE_ALLOW_UNSUPPORTED_SFP=n

 #
+# Compile burst-oriented I40E PMD driver
+#
+# CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL can be 0 to 8160 us,
+# otherwise a default value will be used instead.
+# The interval will be aligned to 2, due to the hardware restriction.
+#
+CONFIG_RTE_LIBRTE_I40E_PMD=y
+CONFIG_RTE_LIBRTE_I40E_DEBUG_INIT=n
+CONFIG_RTE_LIBRTE_I40E_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_I40E_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_I40E_DEBUG_TX_FREE=n
+CONFIG_RTE_LIBRTE_I40E_DEBUG_DRIVER=n
+CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC=n
+CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=y
+CONFIG_RTE_LIBRTE_I40E_ALLOW_UNSUPPORTED_SFP=n
+CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n
+CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4
+CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
diff --git a/config/defconfig_x86_64-default-bsdapp-gcc 
b/config/defconfig_x86_64-default-bsdapp-gcc
index d960e1d..b03bc98 100644
--- a/config/defconfig_x86_64-default-bsdapp-gcc
+++ b/config/defconfig_x86_64-default-bsdapp-gcc
@@ -165,6 +165,21 @@ CONFIG_RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC=y
 CONFIG_RTE_LIBRTE_IXGBE_ALLOW_UNSUPPORTED_SFP=n

 #
+# Compile burst-oriented I40E PMD driver
+#
+CONFIG_RTE_LIBRTE_I40E_PMD=y
+CONFIG_RTE_LIBRTE_I40E_DEBUG_INIT=y
+CONFIG_RTE_LIBRTE_I40E_DEBUG_RX=y
+CONFIG_RTE_LIBRTE_I40E_DEBUG_TX=y
+CONFIG_RTE_LIBRTE_I40E_DEBUG_TX_FREE=y
+CONFIG_RTE_LIBRTE_I40E_DEBUG_DRIVER=y
+CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC=y
+CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=n
+CONFIG_RTE_LIBRTE_I40E_ALLOW_UNSUPPORTED_SFP=y
+CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n
+CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=n
diff --git a/config/defconfig_x86_64-default-linuxapp-gcc 
b/config/defconfig_x86_64-default-linuxapp-gcc
index f11ffbf..b8ccb2f 100644
--- a/config/defconfig_x86_64-default-linuxapp-gcc
+++ b/config/defconfig_x86_64-default-linuxapp-gcc
@@ -179,6 +179,26 @@ CONFIG_RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC=y
 CONFIG_RTE_LIBRTE_IXGBE_ALLOW_UNSUPPORTED_SFP=n

 #
+# Compile burst-oriented I40E PMD driver
+#
+# CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL can be 0 to 8160 us,
+# otherwise a default value will be used instead

[dpdk-dev] [PATCH 06/22] vmxnet3: enlarge the hash flags of RSS to 64 bits

2014-05-21 Thread Helin Zhang
As the hash flags of RSS has been enlarged from 16 bits to 64 bits in
'struct rte_eth_rss_conf' in rte_ethdev.h, the size of it in vmxnet3 should
be enlarged as well. In addition, the flags for vmxnet3 only should be masked,
as there are flags for others in that 64 bits.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c 
b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
index 1072654..ad7cbb2 100644
--- a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
+++ b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
@@ -882,9 +882,16 @@ static uint8_t rss_intel_key[40] = {
 int
 vmxnet3_rss_configure(struct rte_eth_dev *dev)
 {
+#define VMXNET3_RSS_OFFLOAD_ALL ( \
+   ETH_RSS_IPV4 | \
+   ETH_RSS_IPV4_TCP | \
+   ETH_RSS_IPV6 | \
+   ETH_RSS_IPV6_TCP)
+
struct vmxnet3_hw *hw;
struct VMXNET3_RSSConf *dev_rss_conf;
struct rte_eth_rss_conf *port_rss_conf;
+   uint64_t rss_hf;
uint8_t i, j;

PMD_INIT_FUNC_TRACE();
@@ -916,13 +923,14 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)

/* loading hashType */
dev_rss_conf->hashType = 0;
-   if (port_rss_conf->rss_hf & ETH_RSS_IPV4)
+   rss_hf = port_rss_conf->rss_hf & VMXNET3_RSS_OFFLOAD_ALL;
+   if (rss_hf & ETH_RSS_IPV4)
dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_IPV4;
-   if (port_rss_conf->rss_hf & ETH_RSS_IPV4_TCP)
+   if (rss_hf & ETH_RSS_IPV4_TCP)
dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_TCP_IPV4;
-   if (port_rss_conf->rss_hf & ETH_RSS_IPV6)
+   if (rss_hf & ETH_RSS_IPV6)
dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_IPV6;
-   if (port_rss_conf->rss_hf & ETH_RSS_IPV6_TCP)
+   if (rss_hf & ETH_RSS_IPV6_TCP)
dev_rss_conf->hashType |= VMXNET3_RSS_HASH_TYPE_TCP_IPV6;

return VMXNET3_SUCCESS;
-- 
1.8.1.4



[dpdk-dev] [PATCH 09/22] examples/multi_process: use ETH_RSS_IP to replace IP hash flags of RSS

2014-05-21 Thread Helin Zhang
As hash flags of RSS have been enlarged from 16 bits to 64 bits to support
more possible types in all PMDs, and new macro of ETH_RSS_IP has been defined
to cover all IP hash flags of RSS. That macro should be used in multi_process
example application to support all PMDs.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 examples/multi_process/symmetric_mp/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/multi_process/symmetric_mp/main.c 
b/examples/multi_process/symmetric_mp/main.c
index 028f98d..7e0a357 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -251,7 +251,7 @@ smp_port_init(uint8_t port, struct rte_mempool *mbuf_pool, 
uint16_t num_queues)
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
-   .rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
+   .rss_hf = ETH_RSS_IP,
},
},
.txmode = {
-- 
1.8.1.4



[dpdk-dev] [PATCH 14/22] examples/dpdk_qat: use ETH_RSS_IP to replace IP hash flags of RSS

2014-05-21 Thread Helin Zhang
As hash flags of RSS have been enlarged from 16 bits to 64 bits to support
more possible types in all PMDs, and new macro of ETH_RSS_IP has been defined
to cover all IP hash flags of RSS. That macro should be used in dpdk_qat
example application to support all PMDs.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 examples/dpdk_qat/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/dpdk_qat/main.c b/examples/dpdk_qat/main.c
index 741d3f3..76a1ac5 100644
--- a/examples/dpdk_qat/main.c
+++ b/examples/dpdk_qat/main.c
@@ -170,7 +170,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
-   .rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
+   .rss_hf = ETH_RSS_IP,
},
},
.txmode = {
-- 
1.8.1.4



[dpdk-dev] [PATCH 16/22] app/test-pmd: tell the driver the correct packet type to support i40e TX checksum offload

2014-05-21 Thread Helin Zhang
As i40e PMD need to know the L3 packet type for TX checksum offloading,
modifications in testpmd should be done for that.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 app/test-pmd/csumonly.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 3568ba0..0e6441a 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -313,6 +313,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
ol_flags |= PKT_TX_IP_CKSUM;
}
else {
+   ol_flags |= PKT_TX_IPV4;
/* SW checksum calculation */
ipv4_hdr->src_addr++;
ipv4_hdr->hdr_checksum = 
get_ipv4_cksum(ipv4_hdr);
@@ -373,6 +374,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
unsigned char *) + l2_len);
l3_len = sizeof(struct ipv6_hdr) ;
l4_proto = ipv6_hdr->proto;
+   ol_flags |= PKT_TX_IPV6;

if (l4_proto == IPPROTO_UDP) {
udp_hdr = (struct udp_hdr*) 
(rte_pktmbuf_mtod(mb,
-- 
1.8.1.4



[dpdk-dev] [PATCH 17/22] app/test-pmd: support displaying i40e 32 bytes RX descriptor

2014-05-21 Thread Helin Zhang
As i40e support both 16 and 32 bytes RX descriptors, modifications should be
done to support 32 bytes RX descriptors according to the configuration.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 app/test-pmd/config.c | 36 +---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 20ad0a8..7392792 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -558,13 +558,43 @@ union igb_ring_dword {
} words;
 };

+#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+struct igb_ring_desc_32B {
+   union igb_ring_dword lo_dword;
+   union igb_ring_dword hi_dword;
+   union igb_ring_dword resv1;
+   union igb_ring_dword resv2;
+};
+#endif
+
 struct igb_ring_desc {
union igb_ring_dword lo_dword;
union igb_ring_dword hi_dword;
 };

 static void
-ring_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
+ring_rx_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
+{
+#ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
+   struct igb_ring_desc *ring;
+   struct igb_ring_desc rd;
+
+   ring = (struct igb_ring_desc *) ring_mz->addr;
+#else
+   struct igb_ring_desc_32B *ring;
+   struct igb_ring_desc_32B rd;
+
+   ring = (struct igb_ring_desc_32B *) ring_mz->addr;
+#endif
+   rd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
+   rd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
+   printf("0x%08X - 0x%08X / 0x%08X - 0x%08X\n",
+   (unsigned)rd.lo_dword.words.lo, (unsigned)rd.lo_dword.words.hi,
+   (unsigned)rd.hi_dword.words.lo, (unsigned)rd.hi_dword.words.hi);
+}
+
+static void
+ring_tx_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
 {
struct igb_ring_desc *ring;
struct igb_ring_desc rd;
@@ -591,7 +621,7 @@ rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, 
uint16_t rxd_id)
rx_mz = ring_dma_zone_lookup("rx_ring", port_id, rxq_id);
if (rx_mz == NULL)
return;
-   ring_descriptor_display(rx_mz, rxd_id);
+   ring_rx_descriptor_display(rx_mz, rxd_id);
 }

 void
@@ -608,7 +638,7 @@ tx_ring_desc_display(portid_t port_id, queueid_t txq_id, 
uint16_t txd_id)
tx_mz = ring_dma_zone_lookup("tx_ring", port_id, txq_id);
if (tx_mz == NULL)
return;
-   ring_descriptor_display(tx_mz, txd_id);
+   ring_tx_descriptor_display(tx_mz, txd_id);
 }

 void
-- 
1.8.1.4



[dpdk-dev] [PATCH 05/22] ixgbe: enlarge the hash flags of RSS to 64 bits

2014-05-21 Thread Helin Zhang
As the hash flags of RSS has been enlarged from 16 bits to 64 bits in
'struct rte_eth_rss_conf' in rte_ethdev.h, the size of it in ixgbe should be
enlarged as well. In addition, the flags for ixgbe only should be masked,
as there are flags for others in that 64 bits.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c 
b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
index 37d02aa..5138035 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
@@ -2294,19 +2294,31 @@ ixgbe_rss_disable(struct rte_eth_dev *dev)
 static void
 ixgbe_rss_configure(struct rte_eth_dev *dev)
 {
+#define IXGBE_RSS_OFFLOAD_ALL ( \
+   ETH_RSS_IPV4 | \
+   ETH_RSS_IPV4_TCP | \
+   ETH_RSS_IPV6 | \
+   ETH_RSS_IPV6_EX | \
+   ETH_RSS_IPV6_TCP | \
+   ETH_RSS_IPV6_TCP_EX | \
+   ETH_RSS_IPV4_UDP | \
+   ETH_RSS_IPV6_UDP | \
+   ETH_RSS_IPV6_UDP_EX)
+
struct ixgbe_hw *hw;
uint8_t *hash_key;
uint32_t rss_key;
uint32_t mrqc;
uint32_t reta;
-   uint16_t rss_hf;
+   uint64_t rss_hf;
uint16_t i;
uint16_t j;

PMD_INIT_FUNC_TRACE();
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);

-   rss_hf = dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf;
+   rss_hf = dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &
+   IXGBE_RSS_OFFLOAD_ALL;
if (rss_hf == 0) { /* Disable RSS */
ixgbe_rss_disable(dev);
return;
-- 
1.8.1.4



[dpdk-dev] [PATCH 13/22] examples/ip_reassembly: use ETH_RSS_IP to replace IP hash flags of RSS

2014-05-21 Thread Helin Zhang
As hash flags of RSS have been enlarged from 16 bits to 64 bits to support
more possible types in all PMDs, and new macro of ETH_RSS_IP has been defined
to cover all IP hash flags of RSS. That macro should be used in ip_reassembly
example application to support all PMDs.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 examples/ip_reassembly/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index bafa8d9..bb2f810 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -235,7 +235,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
-   .rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
+   .rss_hf = ETH_RSS_IP,
},
},
.txmode = {
-- 
1.8.1.4



[dpdk-dev] [PATCH 18/22] app/test-pmd: support setting port based VLAN ID offloading

2014-05-21 Thread Helin Zhang
As i40e support port based VLAN ID insertion offloading, new command
'tx_vlan set pvid port_id vlan_id (on|off)' is added to support that
setting.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 app/test-pmd/cmdline.c | 61 ++
 app/test-pmd/config.c  |  9 
 app/test-pmd/testpmd.h |  2 +-
 3 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 7ecfc84..e56805b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -281,6 +281,9 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set hardware insertion of VLAN ID in packets sent"
" on a port.\n\n"

+   "tx_vlan set pvid port_id vlan_id (on|off)\n"
+   "Set port based TX VLAN insertion.\n\n"
+
"tx_vlan reset (port_id)\n"
"Disable hardware insertion of a VLAN header in"
" packets sent on a port.\n\n"
@@ -2202,6 +2205,63 @@ cmdline_parse_inst_t cmd_tx_vlan_set = {
},
 };

+/* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
+struct cmd_tx_vlan_set_pvid_result {
+   cmdline_fixed_string_t tx_vlan;
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t pvid;
+   uint8_t port_id;
+   uint16_t vlan_id;
+   cmdline_fixed_string_t mode;
+};
+
+static void
+cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
+
+   if (strcmp(res->mode, "on") == 0)
+   tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
+   else
+   tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
+}
+
+cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
+   TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
+tx_vlan, "tx_vlan");
+cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
+   TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
+set, "set");
+cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
+   TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
+pvid, "pvid");
+cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
+port_id, UINT8);
+cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
+ vlan_id, UINT16);
+cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
+   TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
+mode, "on#off");
+
+cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
+   .f = cmd_tx_vlan_set_pvid_parsed,
+   .data = NULL,
+   .help_str = "",
+   .tokens = {
+   (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
+   (void *)&cmd_tx_vlan_set_pvid_set,
+   (void *)&cmd_tx_vlan_set_pvid_pvid,
+   (void *)&cmd_tx_vlan_set_pvid_port_id,
+   (void *)&cmd_tx_vlan_set_pvid_vlan_id,
+   (void *)&cmd_tx_vlan_set_pvid_mode,
+   NULL,
+   },
+};
+
 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
 struct cmd_tx_vlan_reset_result {
cmdline_fixed_string_t tx_vlan;
@@ -5189,6 +5249,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
+   (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
(cmdline_parse_inst_t *)&cmd_tx_cksum_set,
(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 7392792..ad16de2 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1510,6 +1510,15 @@ tx_vlan_reset(portid_t port_id)
 }

 void
+tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on)
+{
+   if (port_id_is_invalid(port_id))
+   return;
+
+   rte_eth_dev_set_vlan_pvid(port_id, vlan_id, on);
+}
+
+void
 set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value)
 {
uint16_t i;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 0e891cd..21a7daa 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -486,7 +486,7 @@ void vlan_extend_set(po

[dpdk-dev] [PATCH 12/22] examples/l3fwd-power: use ETH_RSS_IP to replace IP hash flags of RSS

2014-05-21 Thread Helin Zhang
As hash flags of RSS have been enlarged from 16 bits to 64 bits to support
more possible types in all PMDs, and new macro of ETH_RSS_IP has been defined
to cover all IP hash flags of RSS. That macro should be used in l3fwd-power
example application to support all PMDs.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 examples/l3fwd-power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 598b7a2..ab5d2a1 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -247,7 +247,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
-   .rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
+   .rss_hf = ETH_RSS_IP,
},
},
.txmode = {
-- 
1.8.1.4



[dpdk-dev] [PATCH 08/22] examples/qos_meter: use ETH_RSS_IP to replace IP hash flags of RSS

2014-05-21 Thread Helin Zhang
As hash flags of RSS have been enlarged from 16 bits to 64 bits to support
more possible types in all PMDs, and new macro of ETH_RSS_IP has been defined
to cover all IP hash flags of RSS. That macro should be used in qos_meter
example application to support all PMDs.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 examples/qos_meter/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index e1698cc..55a9e98 100755
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -94,7 +94,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
-   .rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
+   .rss_hf = ETH_RSS_IP,
},
},
.txmode = {
-- 
1.8.1.4



[dpdk-dev] [PATCH 02/22] i40e: add PMD source files

2014-05-21 Thread Helin Zhang
Add PMD source files to support Intel(R) 40G Ethernet Controllers.
The new files are,
i40e_osdep.h
i40e_ethdev.c
i40e_ethdev.h
i40e_ethdev_vf.c
i40e_logs.h
i40e_pf.c
i40e_pf.h
i40e_rxtx.c
i40e_rxtx.h
Makefile

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 lib/librte_pmd_i40e/Makefile  |   85 +
 lib/librte_pmd_i40e/i40e/i40e_osdep.h |  192 ++
 lib/librte_pmd_i40e/i40e_ethdev.c | 3961 +
 lib/librte_pmd_i40e/i40e_ethdev.h |  349 +++
 lib/librte_pmd_i40e/i40e_ethdev_vf.c  | 1286 +++
 lib/librte_pmd_i40e/i40e_logs.h   |   74 +
 lib/librte_pmd_i40e/i40e_pf.c |  902 
 lib/librte_pmd_i40e/i40e_pf.h |   67 +
 lib/librte_pmd_i40e/i40e_rxtx.c   | 2217 ++
 lib/librte_pmd_i40e/i40e_rxtx.h   |  187 ++
 10 files changed, 9320 insertions(+)
 create mode 100644 lib/librte_pmd_i40e/Makefile
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_osdep.h
 create mode 100644 lib/librte_pmd_i40e/i40e_ethdev.c
 create mode 100644 lib/librte_pmd_i40e/i40e_ethdev.h
 create mode 100644 lib/librte_pmd_i40e/i40e_ethdev_vf.c
 create mode 100644 lib/librte_pmd_i40e/i40e_logs.h
 create mode 100644 lib/librte_pmd_i40e/i40e_pf.c
 create mode 100644 lib/librte_pmd_i40e/i40e_pf.h
 create mode 100644 lib/librte_pmd_i40e/i40e_rxtx.c
 create mode 100644 lib/librte_pmd_i40e/i40e_rxtx.h

diff --git a/lib/librte_pmd_i40e/Makefile b/lib/librte_pmd_i40e/Makefile
new file mode 100644
index 000..7ddeeb0
--- /dev/null
+++ b/lib/librte_pmd_i40e/Makefile
@@ -0,0 +1,85 @@
+#   BSD LICENSE
+# 
+#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   All rights reserved.
+# 
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+# 
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * 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.
+# * Neither the name of 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.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_i40e.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+ifeq ($(CC), icc)
+CFLAGS_SHARED_DRIVERS = -wd593
+else
+CFLAGS_SHARED_DRIVERS =  -Wno-unused-but-set-variable
+CFLAGS_SHARED_DRIVERS += -Wno-sign-compare
+CFLAGS_SHARED_DRIVERS += -Wno-unused-value
+CFLAGS_SHARED_DRIVERS += -Wno-unused-parameter
+CFLAGS_SHARED_DRIVERS += -Wno-strict-aliasing
+CFLAGS_SHARED_DRIVERS += -Wno-format
+CFLAGS_SHARED_DRIVERS += -Wno-missing-field-initializers
+CFLAGS_SHARED_DRIVERS += -Wno-pointer-to-int-cast
+CFLAGS_SHARED_DRIVERS += -Wno-format-nonliteral
+CFLAGS_SHARED_DRIVERS += -Wno-format-security
+endif
+
+#
+# Add extra flags for ND source files to disable warnings
+#
+SHARED_DRIVERS_OBJS=$(patsubst %.c,%.o,$(notdir $(wildcard 
$(RTE_SDK)/lib/librte_pmd_i40e/i40e/*.c)))
+$(foreach obj, $(SHARED_DRIVERS_OBJS), $(eval 
CFLAGS_$(obj)+=$(CFLAGS_SHARED_DRIVERS)))
+
+VPATH += $(RTE_SDK)/lib/librte_pmd_i40e/i40e
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_adminq.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_common.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_diag.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_hmc.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_lan_hmc.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_nvm.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_dcb.c
+
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_rxtx.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_ethdev_vf.c
+SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_pf.c
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += lib/librte_eal lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRT

[dpdk-dev] [PATCH 07/22] app/testpmd: enlarge the hash flags of RSS to 64 bits

2014-05-21 Thread Helin Zhang
As the hash flags of RSS has been enlarged from 16 bits to 64 bits in
'struct rte_eth_rss_conf' in rte_ethdev.h, the size of it in testpmd
should be enlarged as well. In addition, macro of ETH_RSS_IP is used
to replace all IP hash flags of RSS.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 app/test-pmd/cmdline.c| 4 ++--
 app/test-pmd/parameters.c | 5 ++---
 app/test-pmd/testpmd.c| 2 +-
 app/test-pmd/testpmd.h| 2 +-
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b3824f9..7ecfc84 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1131,9 +1131,9 @@ cmd_config_rss_parsed(void *parsed_result,
}

if (!strcmp(res->value, "ip"))
-   rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
+   rss_hf = ETH_RSS_IP;
else if (!strcmp(res->value, "udp"))
-   rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
+   rss_hf = ETH_RSS_UDP;
else if (!strcmp(res->value, "none"))
rss_hf = 0;
else {
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 7a60048..725ca6f 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -832,10 +832,9 @@ launch_args_parse(int argc, char** argv)
if (!strcmp(lgopts[opt_idx].name, "forward-mode"))
set_pkt_forwarding_mode(optarg);
if (!strcmp(lgopts[opt_idx].name, "rss-ip"))
-   rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
+   rss_hf = ETH_RSS_IP;
if (!strcmp(lgopts[opt_idx].name, "rss-udp"))
-   rss_hf = ETH_RSS_IPV4 |
-   ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
+   rss_hf = ETH_RSS_UDP;
if (!strcmp(lgopts[opt_idx].name, "rxq")) {
n = atoi(optarg);
if (n >= 1 && n <= (int) MAX_QUEUE_ID)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index bc38305..eea2c6c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -250,7 +250,7 @@ uint32_t txq_flags = 0; /* No flags set. */
 /*
  * Receive Side Scaling (RSS) configuration.
  */
-uint16_t rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6; /* RSS IP by default. */
+uint64_t rss_hf = ETH_RSS_IP; /* RSS IP by default. */

 /*
  * Port topology configuration
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 2bdb1a2..0e891cd 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -326,7 +326,7 @@ extern portid_t fwd_ports_ids[RTE_MAX_ETHPORTS];
 extern struct rte_port *ports;

 extern struct rte_eth_rxmode rx_mode;
-extern uint16_t rss_hf;
+extern uint64_t rss_hf;

 extern queueid_t nb_rxq;
 extern queueid_t nb_txq;
-- 
1.8.1.4



[dpdk-dev] [PATCH 15/22] examples/load_balancer: use ETH_RSS_IP to replace IP hash flags of RSS

2014-05-21 Thread Helin Zhang
As hash flags of RSS have been enlarged from 16 bits to 64 bits to support
more possible types in all PMDs, and new macro of ETH_RSS_IP has been defined
to cover all IP hash flags of RSS. That macro should be used in load_balancer
example application to support all PMDs.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 examples/load_balancer/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/load_balancer/init.c b/examples/load_balancer/init.c
index e997238..160a938 100644
--- a/examples/load_balancer/init.c
+++ b/examples/load_balancer/init.c
@@ -87,7 +87,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
-   .rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
+   .rss_hf = ETH_RSS_IP,
},
},
.txmode = {
-- 
1.8.1.4



[dpdk-dev] [PATCH 21/22] config: add configurations for enabling 'Extended Tag' or resetting 'Max Read Request Size'

2014-05-21 Thread Helin Zhang
Sys files of 'extended_tag' and 'max_read_request_size' have been
supported in igb_uio, and can be changed during probing PCI. Three
items in configuration files are needed to support them at compile
time. Those three items are,
 - CONFIG_RTE_PCI_CONFIG
 - CONFIG_RTE_PCI_EXTENDED_TAG
 - CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 config/defconfig_i686-default-linuxapp-gcc   | 10 ++
 config/defconfig_i686-default-linuxapp-icc   | 10 ++
 config/defconfig_x86_64-default-linuxapp-gcc | 10 ++
 config/defconfig_x86_64-default-linuxapp-icc | 10 ++
 4 files changed, 40 insertions(+)

diff --git a/config/defconfig_i686-default-linuxapp-gcc 
b/config/defconfig_i686-default-linuxapp-gcc
index 931f6c5..21264d9 100644
--- a/config/defconfig_i686-default-linuxapp-gcc
+++ b/config/defconfig_i686-default-linuxapp-gcc
@@ -125,6 +125,16 @@ CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n
 CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n

 #
+# Special configurations in PCI Config Space for high performance
+# CONFIG_RTE_PCI_CONFIG is the compile switch for two features below
+# CONFIG_RTE_PCI_EXTENDED_TAG can be "on", "off"
+# CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE can be 128, 256, 512, 1024, 2048, 4096
+#
+CONFIG_RTE_PCI_CONFIG=n
+CONFIG_RTE_PCI_EXTENDED_TAG=""
+CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE=0
+
+#
 # Compile Environment Abstraction Layer for linux
 #
 CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
diff --git a/config/defconfig_i686-default-linuxapp-icc 
b/config/defconfig_i686-default-linuxapp-icc
index b07bd76..b32dfdf 100644
--- a/config/defconfig_i686-default-linuxapp-icc
+++ b/config/defconfig_i686-default-linuxapp-icc
@@ -125,6 +125,16 @@ CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n
 CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n

 #
+# Special configurations in PCI Config Space for high performance
+# CONFIG_RTE_PCI_CONFIG is the compile switch for two features below
+# CONFIG_RTE_PCI_EXTENDED_TAG can be "on", "off"
+# CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE can be 128, 256, 512, 1024, 2048, 4096
+#
+CONFIG_RTE_PCI_CONFIG=n
+CONFIG_RTE_PCI_EXTENDED_TAG=""
+CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE=0
+
+#
 # Compile Environment Abstraction Layer for linux
 #
 CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
diff --git a/config/defconfig_x86_64-default-linuxapp-gcc 
b/config/defconfig_x86_64-default-linuxapp-gcc
index b8ccb2f..c398906 100644
--- a/config/defconfig_x86_64-default-linuxapp-gcc
+++ b/config/defconfig_x86_64-default-linuxapp-gcc
@@ -125,6 +125,16 @@ CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n
 CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n

 #
+# Special configurations in PCI Config Space for high performance
+# CONFIG_RTE_PCI_CONFIG is the compile switch for two features below
+# CONFIG_RTE_PCI_EXTENDED_TAG can be "on", "off"
+# CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE can be 128, 256, 512, 1024, 2048, 4096
+#
+CONFIG_RTE_PCI_CONFIG=n
+CONFIG_RTE_PCI_EXTENDED_TAG=""
+CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE=0
+
+#
 # Compile Environment Abstraction Layer for linux
 #
 CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
diff --git a/config/defconfig_x86_64-default-linuxapp-icc 
b/config/defconfig_x86_64-default-linuxapp-icc
index 58a6c62..5732cd0 100644
--- a/config/defconfig_x86_64-default-linuxapp-icc
+++ b/config/defconfig_x86_64-default-linuxapp-icc
@@ -125,6 +125,16 @@ CONFIG_RTE_EAL_ALLOW_INV_SOCKET_ID=n
 CONFIG_RTE_EAL_ALWAYS_PANIC_ON_ERROR=n

 #
+# Special configurations in PCI Config Space for high performance
+# CONFIG_RTE_PCI_CONFIG is the compile switch for two features below
+# CONFIG_RTE_PCI_EXTENDED_TAG can be "on", "off"
+# CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE can be 128, 256, 512, 1024, 2048, 4096
+#
+CONFIG_RTE_PCI_CONFIG=n
+CONFIG_RTE_PCI_EXTENDED_TAG=""
+CONFIG_RTE_PCI_MAX_READ_REQUEST_SIZE=0
+
+#
 # Compile Environment Abstraction Layer for linux
 #
 CONFIG_RTE_LIBRTE_EAL_LINUXAPP=y
-- 
1.8.1.4



[dpdk-dev] [PATCH 20/22] pci: support reading/writing sys files of 'extended_tag' and 'max_read_request_size'

2014-05-21 Thread Helin Zhang
Sys files of 'extended_tag' and 'max_read_request_size' are supported by
igb_uio. Reading or writing them to enable/disable 'Extended Tag' or
reset 'Max Read Request Size' automatically according to the configurations
are added.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 101 ++
 1 file changed, 101 insertions(+)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index ac2c1fe..3956e88 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -107,6 +107,11 @@ TAILQ_HEAD(uio_res_list, uio_resource);
 static struct uio_res_list *uio_res_list = NULL;
 static int pci_parse_sysfs_value(const char *filename, uint64_t *val);

+
+#ifdef RTE_PCI_CONFIG
+static void pci_config_space_set(struct rte_pci_device *dev);
+#endif
+
 /* unbind kernel driver for this device */
 static int
 pci_unbind_kernel_driver(struct rte_pci_device *dev)
@@ -840,6 +845,13 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, 
struct rte_pci_device *d
}

if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) {
+#ifdef RTE_PCI_CONFIG
+   /*
+* Set PCIe config space for high performance.
+* Return value can be ignored.
+*/
+   pci_config_space_set(dev);
+#endif
/* map resources for devices that use igb_uio */
if (pci_uio_map_resource(dev) < 0)
return -1;
@@ -878,3 +890,92 @@ rte_eal_pci_init(void)
}
return 0;
 }
+
+#ifdef RTE_PCI_CONFIG
+static int
+pci_config_extended_tag(struct rte_pci_device *dev)
+{
+   struct rte_pci_addr *loc = &dev->addr;
+   char filename[PATH_MAX];
+   char buf[BUFSIZ];
+   FILE *f;
+
+   /* not configured, let it as is */
+   if (strncmp(RTE_PCI_EXTENDED_TAG, "on", 2) != 0 &&
+   strncmp(RTE_PCI_EXTENDED_TAG, "off", 3) != 0)
+   return 0;
+
+   rte_snprintf(filename, sizeof(filename),
+   SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/" "extended_tag",
+   loc->domain, loc->bus, loc->devid, loc->function);
+   f = fopen(filename, "rw+");
+   if (!f)
+   return -1;
+
+   fgets(buf, sizeof(buf), f);
+   if (strncmp(RTE_PCI_EXTENDED_TAG, "on", 2) == 0) {
+   /* enable Extended Tag*/
+   if (strncmp(buf, "on", 2) != 0) {
+   fseek(f, 0, SEEK_SET);
+   fputs("on", f);
+   }
+   } else {
+   /* disable Extended Tag */
+   if (strncmp(buf, "off", 3) != 0) {
+   fseek(f, 0, SEEK_SET);
+   fputs("off", f);
+   }
+   }
+   fclose(f);
+
+   return 0;
+}
+
+static int
+pci_config_max_read_request_size(struct rte_pci_device *dev)
+{
+   struct rte_pci_addr *loc = &dev->addr;
+   char filename[PATH_MAX];
+   char buf[BUFSIZ], param[BUFSIZ];
+   FILE *f;
+   uint32_t max_size = RTE_PCI_MAX_READ_REQUEST_SIZE;
+
+   /* not configured, let it as is */
+   if (!max_size)
+   return 0;
+
+   rte_snprintf(filename, sizeof(filename),
+   SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/" "max_read_request_size",
+   loc->domain, loc->bus, loc->devid, loc->function);
+   f = fopen(filename, "rw+");
+   if (!f)
+   return -1;
+
+   fgets(buf, sizeof(buf), f);
+   rte_snprintf(param, sizeof(param), "%d", max_size);
+
+   /* check if the size to be set is the same as current */
+   if (strcmp(buf, param) == 0) {
+   fclose(f);
+   return 0;
+   }
+   fseek(f, 0, SEEK_SET);
+   fputs(param, f);
+   fclose(f);
+
+   return 0;
+}
+
+static void
+pci_config_space_set(struct rte_pci_device *dev)
+{
+   if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+   return;
+
+   /* configure extended tag */
+   pci_config_extended_tag(dev);
+
+   /* configure max read request size */
+   pci_config_max_read_request_size(dev);
+}
+#endif
-- 
1.8.1.4



[dpdk-dev] [PATCH 22/22] ethdev: support setting maximum packet length to less than 1518

2014-05-21 Thread Helin Zhang
In ethdev, it will ignore setting maximum packet length to less than 1518.
The changes is to fix it and let less than 1518 can be really set for
maximum packet length.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 lib/librte_ether/rte_ethdev.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 1e2a16e..daa191b 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -553,9 +553,13 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, 
uint16_t nb_tx_q,
(unsigned)ETHER_MIN_LEN);
return (-EINVAL);
}
-   } else
-   /* Use default value */
-   dev->data->dev_conf.rxmode.max_rx_pkt_len = ETHER_MAX_LEN;
+   } else {
+   if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN ||
+   dev_conf->rxmode.max_rx_pkt_len > ETHER_MAX_LEN)
+   /* Use default value */
+   dev->data->dev_conf.rxmode.max_rx_pkt_len =
+   ETHER_MAX_LEN;
+   }

/* multipe queue mode checking */
diag = rte_eth_dev_check_mq_mode(port_id, nb_rx_q, nb_tx_q, dev_conf);
-- 
1.8.1.4



[dpdk-dev] [PATCH 10/22] examples/l3fwd: use ETH_RSS_IP to replace IP hash flags of RSS

2014-05-21 Thread Helin Zhang
As hash flags of RSS have been enlarged from 16 bits to 64 bits to support
more possible types in all PMDs, and new macro of ETH_RSS_IP has been defined
to cover all IP hash flags of RSS. That macro should be used in l3fwd example
application to support all PMDs.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 examples/l3fwd/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 8ee1af9..6588d3c 100755
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -227,7 +227,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
-   .rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
+   .rss_hf = ETH_RSS_IP,
},
},
.txmode = {
-- 
1.8.1.4



[dpdk-dev] [PATCH 04/22] e1000: enlarge the hash flags of RSS to 64 bits

2014-05-21 Thread Helin Zhang
As the hash flags of RSS has been enlarged from 16 bits to 64 bits in
'struct rte_eth_rss_conf' in rte_ethdev.h, the size of it in e1000 should be
enlarged as well. In addition, the flags for e1000 only should be masked,
as there are flags for others in that 64 bits.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 lib/librte_pmd_e1000/igb_rxtx.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_e1000/igb_rxtx.c b/lib/librte_pmd_e1000/igb_rxtx.c
index 4608595..c349f21 100644
--- a/lib/librte_pmd_e1000/igb_rxtx.c
+++ b/lib/librte_pmd_e1000/igb_rxtx.c
@@ -1521,17 +1521,29 @@ igb_rss_disable(struct rte_eth_dev *dev)
 static void
 igb_rss_configure(struct rte_eth_dev *dev)
 {
+#define IGB_RSS_OFFLOAD_ALL ( \
+   ETH_RSS_IPV4 | \
+   ETH_RSS_IPV4_TCP | \
+   ETH_RSS_IPV6 | \
+   ETH_RSS_IPV6_EX | \
+   ETH_RSS_IPV6_TCP | \
+   ETH_RSS_IPV6_TCP_EX | \
+   ETH_RSS_IPV4_UDP | \
+   ETH_RSS_IPV6_UDP | \
+   ETH_RSS_IPV6_UDP_EX)
+
struct e1000_hw *hw;
uint8_t *hash_key;
uint32_t rss_key;
uint32_t mrqc;
uint32_t shift;
-   uint16_t rss_hf;
+   uint64_t rss_hf;
uint16_t i;

hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

-   rss_hf = dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf;
+   rss_hf = dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf &
+   IGB_RSS_OFFLOAD_ALL;
if (rss_hf == 0) /* Disable RSS. */ {
igb_rss_disable(dev);
return;
-- 
1.8.1.4



[dpdk-dev] [PATCH 11/22] examples/l3fwd-vf: use ETH_RSS_IP to replace IP hash flags of RSS

2014-05-21 Thread Helin Zhang
As hash flags of RSS have been enlarged from 16 bits to 64 bits to support
more possible types in all PMDs, and new macro of ETH_RSS_IP has been defined
to cover all IP hash flags of RSS. That macro should be used in l3fwd-vf
example application to support all PMDs.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 examples/l3fwd-vf/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c
index 793cacc..d37eb35 100644
--- a/examples/l3fwd-vf/main.c
+++ b/examples/l3fwd-vf/main.c
@@ -207,7 +207,7 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
-   .rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6,
+   .rss_hf = ETH_RSS_IP,
},
},
.txmode = {
-- 
1.8.1.4



[dpdk-dev] [PATCH 19/22] igb_uio: add sys files to read/write specific bits in pci config space

2014-05-21 Thread Helin Zhang
Enabling 'Extended Tag' and resetting 'Max Read Request Size' in PCI config 
space
have big impacts to i40e performance. They cannot be changed on some BIOS
implementations, though can on others. Two sys files of 'extended_tag' and
'max_read_request_size' are added to support changing them by 'echo' in user 
space.

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 105 ++
 1 file changed, 105 insertions(+)

diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c 
b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
index 79fe97d..55e801d 100644
--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
@@ -47,6 +47,15 @@
 #define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
 #endif

+#ifdef RTE_PCI_CONFIG
+#define PCI_SYS_FILE_BUF_SIZE  10
+#define PCI_DEV_CAP_REG0xA4
+#define PCI_DEV_CTRL_REG   0xA8
+#define PCI_DEV_CAP_EXT_TAG_MASK   0x20
+#define PCI_DEV_CTRL_EXT_TAG_SHIFT 8
+#define PCI_DEV_CTRL_EXT_TAG_MASK  (1 << PCI_DEV_CTRL_EXT_TAG_SHIFT)
+#endif
+
 #define IGBUIO_NUM_MSI_VECTORS 1

 /* interrupt mode */
@@ -151,9 +160,105 @@ store_max_vfs(struct device *dev, struct device_attribute 
*attr,
return err ? err : count;   

 }

+#ifdef RTE_PCI_CONFIG
+static ssize_t
+show_extended_tag(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   struct pci_dev *pci_dev = container_of(dev, struct pci_dev, dev);
+   uint32_t val = 0;
+
+   pci_read_config_dword(pci_dev, PCI_DEV_CAP_REG, &val);
+   if (!(val & PCI_DEV_CAP_EXT_TAG_MASK)) /* Not supported */
+   return snprintf(buf, PCI_SYS_FILE_BUF_SIZE, "%s\n", "invalid");
+
+   val = 0;
+   pci_bus_read_config_dword(pci_dev->bus, pci_dev->devfn,
+   PCI_DEV_CTRL_REG, &val);
+
+   return snprintf(buf, PCI_SYS_FILE_BUF_SIZE, "%s\n",
+   (val & PCI_DEV_CTRL_EXT_TAG_MASK) ? "on" : "off");
+}
+
+static ssize_t
+store_extended_tag(struct device *dev,
+  struct device_attribute *attr,
+  const char *buf,
+  size_t count)
+{
+   struct pci_dev *pci_dev = container_of(dev, struct pci_dev, dev);
+   uint32_t val = 0, enable;
+
+   if (strncmp(buf, "on", 2) == 0)
+   enable = 1;
+   else if (strncmp(buf, "off", 3) == 0)
+   enable = 0;
+   else
+   return -EINVAL;
+
+   pci_bus_read_config_dword(pci_dev->bus, pci_dev->devfn,
+   PCI_DEV_CAP_REG, &val);
+   if (!(val & PCI_DEV_CAP_EXT_TAG_MASK)) /* Not supported */
+   return -EPERM;
+
+   val = 0;
+   pci_bus_read_config_dword(pci_dev->bus, pci_dev->devfn,
+   PCI_DEV_CTRL_REG, &val);
+   if (enable)
+   val |= PCI_DEV_CTRL_EXT_TAG_MASK;
+   else
+   val &= ~PCI_DEV_CTRL_EXT_TAG_MASK;
+   pci_bus_write_config_dword(pci_dev->bus, pci_dev->devfn,
+   PCI_DEV_CTRL_REG, val);
+
+   return count;
+}
+
+static ssize_t
+show_max_read_request_size(struct device *dev,
+  struct device_attribute *attr,
+  char *buf)
+{
+   struct pci_dev *pci_dev = container_of(dev, struct pci_dev, dev);
+   int val = pcie_get_readrq(pci_dev);
+
+   return snprintf(buf, PCI_SYS_FILE_BUF_SIZE, "%d\n", val);
+}
+
+static ssize_t
+store_max_read_request_size(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf,
+   size_t count)
+{
+   struct pci_dev *pci_dev = container_of(dev, struct pci_dev, dev);
+   unsigned long size = 0;
+   int ret;
+
+   if (strict_strtoul(buf, 0, &size) != 0)
+   return -EINVAL;
+
+   ret = pcie_set_readrq(pci_dev, (int)size);
+   if (ret < 0)
+   return ret;
+
+   return count;
+}
+#endif
+
 static DEVICE_ATTR(max_vfs, S_IRUGO | S_IWUSR, show_max_vfs, store_max_vfs);
+#ifdef RTE_PCI_CONFIG
+static DEVICE_ATTR(extended_tag, S_IRUGO | S_IWUSR, show_extended_tag, \
+   store_extended_tag);
+static DEVICE_ATTR(max_read_request_size, S_IRUGO | S_IWUSR, \
+   show_max_read_request_size, store_max_read_request_size);
+#endif
+
 static struct attribute *dev_attrs[] = {
&dev_attr_max_vfs.attr,
+#ifdef RTE_PCI_CONFIG
+   &dev_attr_extended_tag.attr,
+   &dev_attr_max_read_request_size.attr,
+#endif
 NULL,
 };

-- 
1.8.1.4



[dpdk-dev] [PATCH 01/22] i40e: add basic shared code

2014-05-21 Thread Helin Zhang
Add shared code source files to support basic operations to be called in
poll mode driver. The new files are,
i40e_adminq.c
i40e_adminq.h
i40e_adminq_cmd.h
i40e_alloc.h
i40e_common.c
i40e_dcb.c
i40e_dcb.h
i40e_diag.c
i40e_diag.h
i40e_hmc.c
i40e_hmc.h
i40e_lan_hmc.c
i40e_lan_hmc.h
i40e_nvm.c
i40e_prototype.h
i40e_register.h
i40e_register_int.h
i40e_status.h
i40e_type.h
i40e_virtchnl.h

Signed-off-by: Helin Zhang 
Signed-off-by: Mark Chen 
---
 lib/librte_pmd_i40e/i40e/i40e_adminq.c   |  1210 ++
 lib/librte_pmd_i40e/i40e/i40e_adminq.h   |   121 +
 lib/librte_pmd_i40e/i40e/i40e_adminq_cmd.h   |  2198 
 lib/librte_pmd_i40e/i40e/i40e_alloc.h|65 +
 lib/librte_pmd_i40e/i40e/i40e_common.c   |  5176 +
 lib/librte_pmd_i40e/i40e/i40e_dcb.c  |  1165 ++
 lib/librte_pmd_i40e/i40e/i40e_dcb.h  |   264 +
 lib/librte_pmd_i40e/i40e/i40e_diag.c |   180 +
 lib/librte_pmd_i40e/i40e/i40e_diag.h |61 +
 lib/librte_pmd_i40e/i40e/i40e_hmc.c  |   388 +
 lib/librte_pmd_i40e/i40e/i40e_hmc.h  |   287 +
 lib/librte_pmd_i40e/i40e/i40e_lan_hmc.c  |  1443 +++
 lib/librte_pmd_i40e/i40e/i40e_lan_hmc.h  |   272 +
 lib/librte_pmd_i40e/i40e/i40e_nvm.c  |   487 +
 lib/librte_pmd_i40e/i40e/i40e_prototype.h|   480 +
 lib/librte_pmd_i40e/i40e/i40e_register.h | 15210 +
 lib/librte_pmd_i40e/i40e/i40e_register_int.h |96 +
 lib/librte_pmd_i40e/i40e/i40e_status.h   |   107 +
 lib/librte_pmd_i40e/i40e/i40e_type.h |  1660 +++
 lib/librte_pmd_i40e/i40e/i40e_virtchnl.h |   385 +
 20 files changed, 31255 insertions(+)
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_adminq.c
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_adminq.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_adminq_cmd.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_alloc.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_common.c
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_dcb.c
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_dcb.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_diag.c
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_diag.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_hmc.c
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_hmc.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_lan_hmc.c
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_lan_hmc.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_nvm.c
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_prototype.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_register.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_register_int.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_status.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_type.h
 create mode 100644 lib/librte_pmd_i40e/i40e/i40e_virtchnl.h

diff --git a/lib/librte_pmd_i40e/i40e/i40e_adminq.c 
b/lib/librte_pmd_i40e/i40e/i40e_adminq.c
new file mode 100644
index 000..da58206
--- /dev/null
+++ b/lib/librte_pmd_i40e/i40e/i40e_adminq.c
@@ -0,0 +1,1210 @@
+/***
+
+Copyright (c) 2013 - 2014, 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.
+
+***/
+
+#include "i40e_status.h"
+#include "i40e_type.h"
+#include "i40e_register.h"
+#include "i40e_adminq.h"
+#include "i40e_prototype.h"
+
+/**
+ *  i40e_adminq_init_regs - Initialize 

[dpdk-dev] [PATCH v2] kni: bug fix for compile issue in KNI on Fedora 18 with kernel 3.6.10

2014-05-22 Thread Helin Zhang
Error of "implicit-function-declaration" can be seen when building KNI
kernel module on Linux kernel 3.6.10 platform, as follows.
"x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/kni/igb_ethtool.c:
  In function \u2018igb_get_eee\u2019:
x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/kni/igb_ethtool.c:
  2441:4: error: implicit declaration of function
  \u2018mmd_eee_adv_to_ethtool_adv_t\u2019
  [-Werror=implicit-function-declaration]
x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/kni/igb_ethtool.c:
 In function \u2018igb_set_eee\u2019:
x86_64-native-linuxapp-gcc/build/lib/librte_eal/linuxapp/kni/igb_ethtool.c:
  2551:2: error: implicit declaration of function
  \u2018ethtool_adv_to_mmd_eee_adv_t\u2019
  [-Werror=implicit-function-declaration]"

The root cause is as follows.
On Fedora 18 with kernel 3.6.10, ETHTOOL_GEEE is defined in Linux
header file of "linux/ethtool.h", while is not defined in most of other
linux kernel versions.
mmd_eee_cap_to_ethtool_sup_t(), mmd_eee_adv_to_ethtool_adv_t() and
ethtool_adv_to_mmd_eee_adv_t() in kcompat.h are disabled by "#if
!defined(ETHTOOL_GEEE) || (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE <=
RHEL_RELEASE_VERSION(6,4))", while are called in igb_get_eee() in
igb_ethtool.c which is enabled by "#ifdef ETHTOOL_GEEE".

Signed-off-by: Helin Zhang 
---
 lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h 
b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
index e9e80ea..4c27d5d 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/kcompat.h
@@ -3586,7 +3586,7 @@ static inline bool ether_addr_equal(const u8 *addr1, 
const u8 *addr2)
 #define ADVERTISED_4baseLR4_Full   (1 << 26)
 #endif

-#if !defined(ETHTOOL_GEEE) || (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE <= 
RHEL_RELEASE_VERSION(6,4))
+#if defined(ETHTOOL_GEEE) || (RHEL_RELEASE_CODE && RHEL_RELEASE_CODE <= 
RHEL_RELEASE_VERSION(6,4))
 /**
  * mmd_eee_cap_to_ethtool_sup_t
  * @eee_cap: value of the MMD EEE Capability register
-- 
1.8.1.4



[dpdk-dev] [PATCH] i40e: fix of PF interrupt handling

2014-11-04 Thread Helin Zhang
'PFINT_ICR0_ENA' shouldn't be cleared in user space ISR,
otherwise adminq interrupts might be missed during
co-working with VF initialization.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 661d146..ea10c26 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -3574,7 +3574,6 @@ i40e_dev_interrupt_delayed_handler(void *param)
i40e_dev_link_update(dev, 0);
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);

-   I40E_WRITE_REG(hw, I40E_PFINT_ICR0_ENA, I40E_PFINT_ICR0_ENA_MASK);
i40e_pf_enable_irq0(hw);
rte_intr_enable(&(dev->pci_dev->intr_handle));
 }
@@ -3601,7 +3600,6 @@ i40e_dev_interrupt_handler(__rte_unused struct 
rte_intr_handle *handle,

/* Disable interrupt */
i40e_pf_disable_irq0(hw);
-   I40E_WRITE_REG(hw, I40E_PFINT_ICR0_ENA, 0);

/* read out interrupt causes */
icr0 = I40E_READ_REG(hw, I40E_PFINT_ICR0);
@@ -3663,7 +3661,6 @@ i40e_dev_interrupt_handler(__rte_unused struct 
rte_intr_handle *handle,

 done:
/* Enable interrupt */
-   I40E_WRITE_REG(hw, I40E_PFINT_ICR0_ENA, I40E_PFINT_ICR0_ENA_MASK);
i40e_pf_enable_irq0(hw);
rte_intr_enable(&(dev->pci_dev->intr_handle));
 }
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 0/5] support of configurable CRC stripping in VF

2014-11-06 Thread Helin Zhang
To support configurable CRC stripping in both PF host
and VF, a new operation and a new structure are added
to carry more configurations from VF to PF host.

v2 changes:
* Put all the renaming and code style fixes into a patch.
* Put processing crc stripping configuration in PF host
  into a single patch.
* Put setting the crc stripping into a single patch.
* Put the configuring crc stripping in VF into a single patch.
* Added several more code style fixes reported by checkpatch.pl.

v3 changes:
* Added a macro of calculating memory size for configuring
  vsi queues.
* Used array of memory in stack to replace the memory
  allocated by rte_zmalloc().
* Added an input parameter for configuring crc stripping in
  RX queue context.
* Put configuring crc stripping of both PF host and VF
  into a single patch.
* Defined below new structures for the configuring specifically.
  - struct i40e_virtchnl_rxq_ext_info;
  - struct i40e_virtchnl_queue_pair_ext_info;
  - struct i40e_virtchnl_vsi_queue_config_ext_info;
* Renamed 'I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX' to
  'I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT'.

Helin Zhang (5):
  config: remove useless i40e items in config files
  i40evf: Remove 'host_is_dpdk', and use version number instead
  i40e: renaming and code style fix
  i40e: support of configurable crc stripping in rx queue
  i40e: support of configurable VF crc stripping

 config/common_bsdapp |   1 -
 config/common_linuxapp   |   1 -
 lib/librte_pmd_i40e/i40e_ethdev.h|   3 +-
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 218 +++
 lib/librte_pmd_i40e/i40e_pf.c| 134 +++--
 lib/librte_pmd_i40e/i40e_pf.h|  57 +++--
 6 files changed, 297 insertions(+), 117 deletions(-)

-- 
1.8.1.4



[dpdk-dev] [PATCH v3 1/5] config: remove useless i40e items in config files

2014-11-06 Thread Helin Zhang
Remove 'CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC'
from config files, as nowhere uses it.

Signed-off-by: Helin Zhang 
---
 config/common_bsdapp   | 1 -
 config/common_linuxapp | 1 -
 2 files changed, 2 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 9dc9f56..57cad76 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -179,7 +179,6 @@ CONFIG_RTE_LIBRTE_I40E_DEBUG_RX=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_TX=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_TX_FREE=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_DRIVER=n
-CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC=y
 CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=n
 CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n
 CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 8be79c3..57b61c9 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -202,7 +202,6 @@ CONFIG_RTE_LIBRTE_I40E_DEBUG_RX=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_TX=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_TX_FREE=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_DRIVER=n
-CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC=n
 CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=y
 CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n
 CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 3/5] i40e: renaming and code style fix

2014-11-06 Thread Helin Zhang
Rename some local variables to express more accurately
and briefly. Fix several code style issues reported by
checkpatch.pl. Line warpping for some source lines which
has more than 80 characters, and merge lines together for
those source lines which does not need any line wrapping
actually. Add macros for numeric or calculating memory
sizes.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 86 ++--
 lib/librte_pmd_i40e/i40e_pf.c| 46 +--
 lib/librte_pmd_i40e/i40e_pf.h| 29 +---
 3 files changed, 84 insertions(+), 77 deletions(-)

v2 changes:
* Put all the renaming and code style fixes into a patch.
* Added several more code style fixes for i40e_pf.c.

v3 changes:
* Added a macro of calculating memory size for configuring
  vsi queues.
* Used array of memory in stack to replace the memory
  allocated by rte_zmalloc().

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 966f02f..9a8cdc8 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -537,78 +537,76 @@ static int
 i40evf_configure_queues(struct rte_eth_dev *dev)
 {
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
-   struct i40e_virtchnl_vsi_queue_config_info *queue_info;
-   struct i40e_virtchnl_queue_pair_info *queue_cfg;
struct i40e_rx_queue **rxq =
(struct i40e_rx_queue **)dev->data->rx_queues;
struct i40e_tx_queue **txq =
(struct i40e_tx_queue **)dev->data->tx_queues;
-   int i, len, nb_qpairs, num_rxq, num_txq;
-   int err;
+   struct i40e_virtchnl_vsi_queue_config_info *vc_vqci;
+   struct i40e_virtchnl_queue_pair_info *vc_qpi;
struct vf_cmd_info args;
-   struct rte_pktmbuf_pool_private *mbp_priv;
+   uint16_t i, nb_qp = vf->num_queue_pairs;
+   const uint32_t size =
+   I40E_VIRTCHNL_CONFIG_VSI_QUEUES_SIZE(vc_vqci, nb_qp);
+   uint8_t buff[size];
+   int ret;

-   nb_qpairs = vf->num_queue_pairs;
-   len = sizeof(*queue_info) + sizeof(*queue_cfg) * nb_qpairs;
-   queue_info = rte_zmalloc("queue_info", len, 0);
-   if (queue_info == NULL) {
-   PMD_INIT_LOG(ERR, "failed alloc memory for queue_info");
-   return -1;
-   }
-   queue_info->vsi_id = vf->vsi_res->vsi_id;
-   queue_info->num_queue_pairs = nb_qpairs;
-   queue_cfg = queue_info->qpair;
+   memset(buff, 0, sizeof(buff));
+   vc_vqci = (struct i40e_virtchnl_vsi_queue_config_info *)buff;
+   vc_vqci->vsi_id = vf->vsi_res->vsi_id;
+   vc_vqci->num_queue_pairs = nb_qp;
+   vc_qpi = vc_vqci->qpair;

-   num_rxq = dev->data->nb_rx_queues;
-   num_txq = dev->data->nb_tx_queues;
/*
 * PF host driver required to configure queues in pairs, which means
 * rxq_num should equals to txq_num. The actual usage won't always
 * work that way. The solution is fills 0 with HW ring option in case
 * they are not equal.
 */
-   for (i = 0; i < nb_qpairs; i++) {
+   for (i = 0; i < nb_qp; i++) {
/*Fill TX info */
-   queue_cfg->txq.vsi_id = queue_info->vsi_id;
-   queue_cfg->txq.queue_id = i;
-   if (i < num_txq) {
-   queue_cfg->txq.ring_len = txq[i]->nb_tx_desc;
-   queue_cfg->txq.dma_ring_addr = 
txq[i]->tx_ring_phys_addr;
+   vc_qpi->txq.vsi_id = vc_vqci->vsi_id;
+   vc_qpi->txq.queue_id = i;
+   if (i < dev->data->nb_tx_queues) {
+   vc_qpi->txq.ring_len = txq[i]->nb_tx_desc;
+   vc_qpi->txq.dma_ring_addr = txq[i]->tx_ring_phys_addr;
} else {
-   queue_cfg->txq.ring_len = 0;
-   queue_cfg->txq.dma_ring_addr = 0;
+   vc_qpi->txq.ring_len = 0;
+   vc_qpi->txq.dma_ring_addr = 0;
}

/* Fill RX info */
-   queue_cfg->rxq.vsi_id = queue_info->vsi_id;
-   queue_cfg->rxq.queue_id = i;
-   queue_cfg->rxq.max_pkt_size = vf->max_pkt_len;
-   if (i < num_rxq) {
-   mbp_priv = rte_mempool_get_priv(rxq[i]->mp);
-   queue_cfg->rxq.databuffer_size = 
mbp_priv->mbuf_data_room_size -
-  RTE_PKTMBUF_HEADROOM;;
-   queue_cfg->rxq.ring_len = rxq[i]->nb_rx_desc;
-   queue_cfg->rxq.dma_ring_addr = 
rxq[i]->rx_ring_phys_addr;;
+   vc_qpi->rxq.vsi_id = vc_vqci->vsi_id;
+ 

[dpdk-dev] [PATCH v3 4/5] i40e: support of configurable crc stripping in rx queue

2014-11-06 Thread Helin Zhang
Support of configurable crc stripping in context of
VF RX queues.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_pf.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

v2 changes:
* Put setting the crc stripping into a single patch.

v3 changes:
* Added an input parameter for configuring crc stripping in
  RX queue context.

diff --git a/lib/librte_pmd_i40e/i40e_pf.c b/lib/librte_pmd_i40e/i40e_pf.c
index f4b4f2d..7f98636 100644
--- a/lib/librte_pmd_i40e/i40e_pf.c
+++ b/lib/librte_pmd_i40e/i40e_pf.c
@@ -56,6 +56,8 @@
 #include "i40e_rxtx.h"
 #include "i40e_pf.h"

+#define I40E_CFG_CRCSTRIP_DEFAULT 1
+
 static int
 i40e_pf_host_switch_queues(struct i40e_pf_vf *vf,
   struct i40e_virtchnl_queue_select *qsel,
@@ -325,7 +327,8 @@ send_msg:
 static int
 i40e_pf_host_hmc_config_rxq(struct i40e_hw *hw,
struct i40e_pf_vf *vf,
-   struct i40e_virtchnl_rxq_info *rxq)
+   struct i40e_virtchnl_rxq_info *rxq,
+   uint8_t crcstrip)
 {
int err = I40E_SUCCESS;
struct i40e_hmc_obj_rxq rx_ctx;
@@ -354,7 +357,7 @@ i40e_pf_host_hmc_config_rxq(struct i40e_hw *hw,
rx_ctx.tphdata_ena = 1;
rx_ctx.tphhead_ena = 1;
rx_ctx.lrxqthresh = 2;
-   rx_ctx.crcstrip = 1;
+   rx_ctx.crcstrip = crcstrip;
rx_ctx.l2tsel = 1;
rx_ctx.prefena = 1;

@@ -434,8 +437,8 @@ i40e_pf_host_process_cmd_config_vsi_queues(struct 
i40e_pf_vf *vf,
}

/* Apply VF RX queue setting to HMC */
-   if (i40e_pf_host_hmc_config_rxq(hw, vf, &vc_qpi[i].rxq)
-   != I40E_SUCCESS) {
+   if (i40e_pf_host_hmc_config_rxq(hw, vf, &vc_qpi[i].rxq,
+   I40E_CFG_CRCSTRIP_DEFAULT) != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Configure RX queue HMC failed");
ret = I40E_ERR_PARAM;
goto send_msg;
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 2/5] i40evf: Remove 'host_is_dpdk', and use version number instead

2014-11-06 Thread Helin Zhang
API version number is straightfoward enough for checking
the PF host, and no need to use 'host_is_dpdk'.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.h|  3 ++-
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 29 +++--
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.h 
b/lib/librte_pmd_i40e/i40e_ethdev.h
index afa14aa..96361c2 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.h
+++ b/lib/librte_pmd_i40e/i40e_ethdev.h
@@ -323,7 +323,8 @@ struct i40e_vf {
bool promisc_unicast_enabled;
bool promisc_multicast_enabled;

-   bool host_is_dpdk; /* The flag indicates if the host is DPDK */
+   uint32_t version_major; /* Major version number */
+   uint32_t version_minor; /* Minor version number */
uint16_t promisc_flags; /* Promiscuous setting */
uint32_t vlan[I40E_VFTA_SIZE]; /* VLAN bit map */

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index fa838e6..966f02f 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -393,17 +393,18 @@ i40evf_check_api_version(struct rte_eth_dev *dev)
}

pver = (struct i40e_virtchnl_version_info *)args.out_buffer;
-   /* We are talking with DPDK host */
-   if (pver->major == I40E_DPDK_VERSION_MAJOR) {
-   vf->host_is_dpdk = TRUE;
-   PMD_DRV_LOG(INFO, "Detect PF host is DPDK app");
-   }
-   /* It's linux host driver */
-   else if ((pver->major != version.major) ||
-   (pver->minor != version.minor)) {
-   PMD_INIT_LOG(ERR, "pf/vf API version mismatch. "
-"(%u.%u)-(%u.%u)", pver->major, pver->minor,
-version.major, version.minor);
+   vf->version_major = pver->major;
+   vf->version_minor = pver->minor;
+   if (vf->version_major == I40E_DPDK_VERSION_MAJOR)
+   PMD_DRV_LOG(INFO, "Peer is DPDK PF host");
+   else if ((vf->version_major == I40E_VIRTCHNL_VERSION_MAJOR) &&
+   (vf->version_minor == I40E_VIRTCHNL_VERSION_MINOR))
+   PMD_DRV_LOG(INFO, "Peer is Linux PF host");
+   else {
+   PMD_INIT_LOG(ERR, "PF/VF API version mismatch:(%u.%u)-(%u.%u)",
+   vf->version_major, vf->version_minor,
+   I40E_VIRTCHNL_VERSION_MAJOR,
+   I40E_VIRTCHNL_VERSION_MINOR);
return -1;
}

@@ -1182,7 +1183,7 @@ i40evf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);

/* Linux pf host doesn't support vlan offload yet */
-   if (vf->host_is_dpdk) {
+   if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
/* Vlan stripping setting */
if (mask & ETH_VLAN_STRIP_MASK) {
/* Enable or disable VLAN stripping */
@@ -1207,7 +1208,7 @@ i40evf_vlan_pvid_set(struct rte_eth_dev *dev, uint16_t 
pvid, int on)
info.on = on;

/* Linux pf host don't support vlan offload yet */
-   if (vf->host_is_dpdk) {
+   if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
if (info.on)
info.config.pvid = pvid;
else {
@@ -1480,7 +1481,7 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 * DPDK pf host provide interfacet to acquire link status
 * while Linux driver does not
 */
-   if (vf->host_is_dpdk)
+   if (vf->version_major == I40E_DPDK_VERSION_MAJOR)
i40evf_get_link_status(dev, &new_link);
else {
/* Always assume it's up, for Linux driver PF host */
-- 
1.8.1.4



[dpdk-dev] [PATCH v3 5/5] i40e: support of configurable VF crc stripping

2014-11-06 Thread Helin Zhang
Configurable CRC stripping needs to be supported in VF,
and the configuration should be finally set in relevant
RX queue context with PF host support.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 155 +--
 lib/librte_pmd_i40e/i40e_pf.c|  83 +--
 lib/librte_pmd_i40e/i40e_pf.h|  28 +++
 3 files changed, 218 insertions(+), 48 deletions(-)

v2 changes:
* Put setting the crc stripping of PF host into a single patch.
* Put configuring crc stripping in VF into a single patch.

v3 changes:
* Put configuring crc stripping of both PF host and VF
  into a single patch.
* Defined below new structures for the configuring specifically.
  - struct i40e_virtchnl_rxq_ext_info;
  - struct i40e_virtchnl_queue_pair_ext_info;
  - struct i40e_virtchnl_vsi_queue_config_ext_info;
* Renamed 'I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX' to
  'I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT'.

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 9a8cdc8..554d9d7 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -533,8 +533,46 @@ i40evf_config_vlan_pvid(struct rte_eth_dev *dev,
return err;
 }

+static void
+i40evf_fill_virtchnl_vsi_txq_info(struct i40e_virtchnl_txq_info *txq_info,
+ uint16_t vsi_id,
+ uint16_t queue_id,
+ uint16_t nb_txq,
+ struct i40e_tx_queue *txq)
+{
+   txq_info->vsi_id = vsi_id;
+   txq_info->queue_id = queue_id;
+   if (queue_id < nb_txq) {
+   txq_info->ring_len = txq->nb_tx_desc;
+   txq_info->dma_ring_addr = txq->tx_ring_phys_addr;
+   }
+}
+
+static void
+i40evf_fill_virtchnl_vsi_rxq_info(struct i40e_virtchnl_rxq_info *rxq_info,
+ uint16_t vsi_id,
+ uint16_t queue_id,
+ uint16_t nb_rxq,
+ uint32_t max_pkt_size,
+ struct i40e_rx_queue *rxq)
+{
+   rxq_info->vsi_id = vsi_id;
+   rxq_info->queue_id = queue_id;
+   rxq_info->max_pkt_size = max_pkt_size;
+   if (queue_id < nb_rxq) {
+   struct rte_pktmbuf_pool_private *mbp_priv;
+
+   rxq_info->ring_len = rxq->nb_rx_desc;
+   rxq_info->dma_ring_addr = rxq->rx_ring_phys_addr;
+   mbp_priv = rte_mempool_get_priv(rxq->mp);
+   rxq_info->databuffer_size =
+   mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
+   }
+}
+
+/* It configures VSI queues to co-work with Linux PF host */
 static int
-i40evf_configure_queues(struct rte_eth_dev *dev)
+i40evf_configure_vsi_queues(struct rte_eth_dev *dev)
 {
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
struct i40e_rx_queue **rxq =
@@ -554,47 +592,14 @@ i40evf_configure_queues(struct rte_eth_dev *dev)
vc_vqci = (struct i40e_virtchnl_vsi_queue_config_info *)buff;
vc_vqci->vsi_id = vf->vsi_res->vsi_id;
vc_vqci->num_queue_pairs = nb_qp;
-   vc_qpi = vc_vqci->qpair;
-
-   /*
-* PF host driver required to configure queues in pairs, which means
-* rxq_num should equals to txq_num. The actual usage won't always
-* work that way. The solution is fills 0 with HW ring option in case
-* they are not equal.
-*/
-   for (i = 0; i < nb_qp; i++) {
-   /*Fill TX info */
-   vc_qpi->txq.vsi_id = vc_vqci->vsi_id;
-   vc_qpi->txq.queue_id = i;
-   if (i < dev->data->nb_tx_queues) {
-   vc_qpi->txq.ring_len = txq[i]->nb_tx_desc;
-   vc_qpi->txq.dma_ring_addr = txq[i]->tx_ring_phys_addr;
-   } else {
-   vc_qpi->txq.ring_len = 0;
-   vc_qpi->txq.dma_ring_addr = 0;
-   }

-   /* Fill RX info */
-   vc_qpi->rxq.vsi_id = vc_vqci->vsi_id;
-   vc_qpi->rxq.queue_id = i;
-   vc_qpi->rxq.max_pkt_size = vf->max_pkt_len;
-   if (i < dev->data->nb_rx_queues) {
-   struct rte_pktmbuf_pool_private *mbp_priv =
-   rte_mempool_get_priv(rxq[i]->mp);
-
-   vc_qpi->rxq.databuffer_size =
-   mbp_priv->mbuf_data_room_size -
-   RTE_PKTMBUF_HEADROOM;
-   vc_qpi->rxq.ring_len = rxq[i]->nb_rx_desc;
-   vc_qpi->rxq.dma_ring_addr = rxq[i]->rx_ring_phys_addr;
-   } else {
- 

[dpdk-dev] [PATCH v5 0/8] support of multiple sizes of redirection table

2014-11-06 Thread Helin Zhang
As e1000, ixgbe and i40e hardware use different sizes of redirection table in
PF or VF, ethdev and PMDs need to be reworked to support multiple sizes of that
table. In addition, commands in testpmd also need to be reworked to support
these changes.

v2 changes:
* Reorganized the patches.
* Added code style fixes.
* Added support of reta updating/querying in i40e VF.

v3 changes:
* Reorganized the patch set.
* Added returning default RX/TX configurations in VF (igb/ixgbe/i40e), as the
  patch set of it for PF has been accepted recently.

v4 changes:
* Renamed RTE_BIT_WIDTH_64 to RTE_RETA_GROUP_SIZE.
* Added more comments to rte_eth_dev_rss_reta_update() and
  rte_eth_dev_rss_reta_query().

v5 changes:
* Reworked the annotations of macros of RETA sizes in rte_ethdev.h.

Helin Zhang (8):
  app/testpmd: code style fix
  i40evf: code style fix
  i40e: support of setting hash lookup table size
  igb: implement ops of 'dev_infos_get' for PF and VF respectively
  ixgbe: implement ops of 'dev_infos_get' for PF and VF respectively
  i40e: rework of ops of 'dev_infos_get' for both PF and VF
  ethdev: support of multiple sizes of redirection table
  i40evf: support of updating/querying redirection table

 app/test-pmd/cmdline.c   | 166 +
 app/test-pmd/config.c|  37 ---
 app/test-pmd/testpmd.h   |   4 +-
 lib/librte_ether/rte_ethdev.c| 116 
 lib/librte_ether/rte_ethdev.h|  51 ++---
 lib/librte_pmd_e1000/igb_ethdev.c| 170 +++---
 lib/librte_pmd_i40e/i40e_ethdev.c| 122 +++--
 lib/librte_pmd_i40e/i40e_ethdev.h|  25 -
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 124 +-
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c  | 198 ++-
 10 files changed, 694 insertions(+), 319 deletions(-)

-- 
1.8.1.4



[dpdk-dev] [PATCH v5 1/8] app/testpmd: code style fix

2014-11-06 Thread Helin Zhang
Fix of several code style issues.

Signed-off-by: Helin Zhang 
---
 app/test-pmd/cmdline.c | 28 +++-
 app/test-pmd/config.c  |  2 +-
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4c3fc76..daba286 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1602,7 +1602,7 @@ parse_reta_config(const char *str, struct 
rte_eth_rss_reta *reta_conf)
nb_queue = (uint8_t)int_fld[FLD_QUEUE];

if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
-   printf("Invalid RETA hash index=%d",hash_index);
+   printf("Invalid RETA hash index=%d", hash_index);
return -1;
}

@@ -1619,22 +1619,24 @@ parse_reta_config(const char *str, struct 
rte_eth_rss_reta *reta_conf)

 static void
 cmd_set_rss_reta_parsed(void *parsed_result,
-   __attribute__((unused)) struct cmdline *cl,
-   __attribute__((unused)) void *data)
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
 {
int ret;
struct rte_eth_rss_reta reta_conf;
struct cmd_config_rss_reta *res = parsed_result;

-   memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
+   memset(&reta_conf, 0, sizeof(struct rte_eth_rss_reta));
if (!strcmp(res->list_name, "reta")) {
if (parse_reta_config(res->list_of_items, &reta_conf)) {
-   printf("Invalid RSS Redirection Table config 
entered\n");
+   printf("Invalid RSS Redirection Table config "
+   "entered\n");
return;
}
ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
if (ret != 0)
-   printf("Bad redirection table parameter, return code = 
%d \n",ret);
+   printf("Bad redirection table parameter, "
+   "return code = %d \n", ret);
}
 }

@@ -1696,19 +1698,19 @@ static void cmd_showport_reta_parsed(void 
*parsed_result,
 }

 cmdline_parse_token_string_t cmd_showport_reta_show =
-TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
+   TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
 cmdline_parse_token_string_t cmd_showport_reta_port =
-TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
+   TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
 cmdline_parse_token_num_t cmd_showport_reta_port_id =
-TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
+   TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
 cmdline_parse_token_string_t cmd_showport_reta_rss =
-TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
+   TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
 cmdline_parse_token_string_t cmd_showport_reta_reta =
-TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
+   TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
-TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
+   TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, mask_lo, UINT64);
 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
-   TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
+   TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, mask_hi, UINT64);

 cmdline_parse_inst_t cmd_showport_reta = {
.f = cmd_showport_reta_parsed,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 9bc08f4..73afcf5 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -764,7 +764,7 @@ rxtx_config_display(void)
 void
 port_rss_reta_info(portid_t port_id,struct rte_eth_rss_reta *reta_conf)
 {
-   uint8_t i,j;
+   uint8_t i, j;
int ret;

if (port_id_is_invalid(port_id))
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 8/8] i40evf: support of updating/querying redirection table

2014-11-06 Thread Helin Zhang
Support of updating/querying redirection table has been added for VF.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 99 ++--
 1 file changed, 94 insertions(+), 5 deletions(-)

v2 changes:
* Add support of updating/querying i40e reta of VF.

v4 changes:
* Renamed RTE_BIT_WIDTH_64 to RTE_RETA_GROUP_SIZE.

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 3e64666..03bc28e 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -126,11 +126,6 @@ static void i40evf_dev_allmulticast_disable(struct 
rte_eth_dev *dev);
 static int i40evf_get_link_status(struct rte_eth_dev *dev,
  struct rte_eth_link *link);
 static int i40evf_init_vlan(struct rte_eth_dev *dev);
-static int i40evf_config_rss(struct i40e_vf *vf);
-static int i40evf_dev_rss_hash_update(struct rte_eth_dev *dev,
- struct rte_eth_rss_conf *rss_conf);
-static int i40evf_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
-   struct rte_eth_rss_conf *rss_conf);
 static int i40evf_dev_rx_queue_start(struct rte_eth_dev *dev,
 uint16_t rx_queue_id);
 static int i40evf_dev_rx_queue_stop(struct rte_eth_dev *dev,
@@ -139,6 +134,17 @@ static int i40evf_dev_tx_queue_start(struct rte_eth_dev 
*dev,
 uint16_t tx_queue_id);
 static int i40evf_dev_tx_queue_stop(struct rte_eth_dev *dev,
uint16_t tx_queue_id);
+static int i40evf_dev_rss_reta_update(struct rte_eth_dev *dev,
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size);
+static int i40evf_dev_rss_reta_query(struct rte_eth_dev *dev,
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size);
+static int i40evf_config_rss(struct i40e_vf *vf);
+static int i40evf_dev_rss_hash_update(struct rte_eth_dev *dev,
+ struct rte_eth_rss_conf *rss_conf);
+static int i40evf_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
+   struct rte_eth_rss_conf *rss_conf);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
@@ -166,6 +172,8 @@ static struct eth_dev_ops i40evf_eth_dev_ops = {
.rx_queue_release = i40e_dev_rx_queue_release,
.tx_queue_setup   = i40e_dev_tx_queue_setup,
.tx_queue_release = i40e_dev_tx_queue_release,
+   .reta_update  = i40evf_dev_rss_reta_update,
+   .reta_query   = i40evf_dev_rss_reta_query,
.rss_hash_update  = i40evf_dev_rss_hash_update,
.rss_hash_conf_get= i40evf_dev_rss_hash_conf_get,
 };
@@ -1611,6 +1619,87 @@ i40evf_dev_close(struct rte_eth_dev *dev)
 }

 static int
+i40evf_dev_rss_reta_update(struct rte_eth_dev *dev,
+  struct rte_eth_rss_reta_entry64 *reta_conf,
+  uint16_t reta_size)
+{
+   struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t lut, l;
+   uint16_t i, j;
+   uint16_t idx, shift;
+   uint8_t mask;
+
+   if (reta_size != ETH_RSS_RETA_SIZE_64) {
+   PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
+   "(%d) doesn't match the number of hardware can"
+   "support (%d)\n", reta_size, ETH_RSS_RETA_SIZE_64);
+   return -EINVAL;
+   }
+
+   for (i = 0; i < reta_size; i += I40E_4_BIT_WIDTH) {
+   idx = i / RTE_RETA_GROUP_SIZE;
+   shift = i % RTE_RETA_GROUP_SIZE;
+   mask = (uint8_t)((reta_conf[idx].mask >> shift) &
+   I40E_4_BIT_MASK);
+   if (!mask)
+   continue;
+   if (mask == I40E_4_BIT_MASK)
+   l = 0;
+   else
+   l = I40E_READ_REG(hw, I40E_VFQF_HLUT(i >> 2));
+
+   for (j = 0, lut = 0; j < I40E_4_BIT_WIDTH; j++) {
+   if (mask & (0x1 << j))
+   lut |= reta_conf[idx].reta[shift + j] <<
+   (CHAR_BIT * j);
+   else
+   lut |= l & (I40E_8_BIT_MASK << (CHAR_BIT * j));
+   }
+   I40E_WRITE_REG(hw, I40E_VFQF_HLUT(i >> 2), lut);
+   }
+
+   return 0;
+}
+
+static int
+i40evf_dev_rss_reta_query(struct rte_eth_dev *dev,
+ struct rte_eth_rss_reta_entry64 *reta_conf,
+ uint16_t reta_size)
+{
+   struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(de

[dpdk-dev] [PATCH v5 3/8] i40e: support of setting hash lookup table size

2014-11-06 Thread Helin Zhang
Add support of setting hash lookup table size according to the hardawre
capability.

Signed-off-by: Helin Zhang 
---
 lib/librte_ether/rte_ethdev.h |  9 -
 lib/librte_pmd_i40e/i40e_ethdev.c | 14 +-
 lib/librte_pmd_i40e/i40e_ethdev.h |  1 +
 3 files changed, 22 insertions(+), 2 deletions(-)

v5 changes:
* Reworked the annotations of macros of RETA sizes.

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 7e4c998..93df7b1 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -443,9 +443,16 @@ struct rte_eth_rss_conf {
ETH_RSS_FRAG_IPV6 | \
ETH_RSS_L2_PAYLOAD)

-/* Definitions used for redirection table entry size */
+/*
+ * Definitions used for redirection table entry size.
+ * Some RSS RETA sizes may not be supported by some drivers, check the
+ * documentation or the description of relevant functions for more details.
+ */
 #define ETH_RSS_RETA_NUM_ENTRIES 128
 #define ETH_RSS_RETA_MAX_QUEUE   16
+#define ETH_RSS_RETA_SIZE_64  64
+#define ETH_RSS_RETA_SIZE_128 128
+#define ETH_RSS_RETA_SIZE_512 512

 /* Definitions used for VMDQ and DCB functionality */
 #define ETH_VMDQ_MAX_VLAN_FILTERS   64 /**< Maximum nb. of VMDQ vlan filters. 
*/
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 4570795..c6b52be 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -3195,7 +3195,19 @@ i40e_pf_setup(struct i40e_pf *pf)

/* Configure filter control */
memset(&settings, 0, sizeof(settings));
-   settings.hash_lut_size = I40E_HASH_LUT_SIZE_128;
+   if (hw->func_caps.rss_table_size == ETH_RSS_RETA_SIZE_128)
+   settings.hash_lut_size = I40E_HASH_LUT_SIZE_128;
+   else if (hw->func_caps.rss_table_size == ETH_RSS_RETA_SIZE_512)
+   settings.hash_lut_size = I40E_HASH_LUT_SIZE_512;
+   else {
+   PMD_DRV_LOG(ERR, "Hash lookup table size (%u) not supported\n",
+   hw->func_caps.rss_table_size);
+   return I40E_ERR_PARAM;
+   }
+   PMD_DRV_LOG(INFO, "Hardware capability of hash lookup table "
+   "size: %u\n", hw->func_caps.rss_table_size);
+   pf->hash_lut_size = hw->func_caps.rss_table_size;
+
/* Enable ethtype and macvlan filters */
settings.enable_ethtype = TRUE;
settings.enable_macvlan = TRUE;
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.h 
b/lib/librte_pmd_i40e/i40e_ethdev.h
index afa14aa..28c0754 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.h
+++ b/lib/librte_pmd_i40e/i40e_ethdev.h
@@ -270,6 +270,7 @@ struct i40e_pf {
uint16_t vmdq_nb_qps; /* The number of queue pairs of VMDq */
uint16_t vf_nb_qps; /* The number of queue pairs of VF */
uint16_t fdir_nb_qps; /* The number of queue pairs of Flow Director */
+   uint16_t hash_lut_size; /* The size of hash lookup table */

/* store VXLAN UDP ports */
uint16_t vxlan_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 2/8] i40evf: code style fix

2014-11-06 Thread Helin Zhang
Fix of several code style issues.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index fa838e6..5b8a3bf 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -131,10 +131,14 @@ static int i40evf_dev_rss_hash_update(struct rte_eth_dev 
*dev,
  struct rte_eth_rss_conf *rss_conf);
 static int i40evf_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf);
-static int i40evf_dev_rx_queue_start(struct rte_eth_dev *, uint16_t);
-static int i40evf_dev_rx_queue_stop(struct rte_eth_dev *, uint16_t);
-static int i40evf_dev_tx_queue_start(struct rte_eth_dev *, uint16_t);
-static int i40evf_dev_tx_queue_stop(struct rte_eth_dev *, uint16_t);
+static int i40evf_dev_rx_queue_start(struct rte_eth_dev *dev,
+uint16_t rx_queue_id);
+static int i40evf_dev_rx_queue_stop(struct rte_eth_dev *dev,
+   uint16_t rx_queue_id);
+static int i40evf_dev_tx_queue_start(struct rte_eth_dev *dev,
+uint16_t tx_queue_id);
+static int i40evf_dev_tx_queue_stop(struct rte_eth_dev *dev,
+   uint16_t tx_queue_id);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 6/8] i40e: rework of ops of 'dev_infos_get' for both PF and VF

2014-11-06 Thread Helin Zhang
Returning redirection table size has been supported in ops of 'dev_infos_get'
for both PF and VF. Default RX/TX configurations of VF can be returned in ops
of 'dev_infos_get', while it was missed before.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c| 15 +++
 lib/librte_pmd_i40e/i40e_ethdev.h| 11 +++
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 23 +++
 3 files changed, 37 insertions(+), 12 deletions(-)

v2 changes:
* Put getting reta size of both i40e PF and VF into a single patch.

v3 changes:
* Returning default RX/TX configurations has been added in ops of
  'dev_infos_get' for VF, as it was added recently in that for PF.

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index c6b52be..fa6ad01 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -59,17 +59,6 @@
 #include "i40e_rxtx.h"
 #include "i40e_pf.h"

-#define I40E_DEFAULT_RX_FREE_THRESH  32
-#define I40E_DEFAULT_RX_PTHRESH  8
-#define I40E_DEFAULT_RX_HTHRESH  8
-#define I40E_DEFAULT_RX_WTHRESH  0
-
-#define I40E_DEFAULT_TX_FREE_THRESH  32
-#define I40E_DEFAULT_TX_PTHRESH  32
-#define I40E_DEFAULT_TX_HTHRESH  0
-#define I40E_DEFAULT_TX_WTHRESH  0
-#define I40E_DEFAULT_TX_RSBIT_THRESH 32
-
 /* Maximun number of MAC addresses */
 #define I40E_NUM_MACADDR_MAX   64
 #define I40E_CLEAR_PXE_WAIT_MS 200
@@ -1443,6 +1432,7 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_UDP_CKSUM |
DEV_TX_OFFLOAD_TCP_CKSUM |
DEV_TX_OFFLOAD_SCTP_CKSUM;
+   dev_info->reta_size = pf->hash_lut_size;

dev_info->default_rxconf = (struct rte_eth_rxconf) {
.rx_thresh = {
@@ -1462,7 +1452,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
},
.tx_free_thresh = I40E_DEFAULT_TX_FREE_THRESH,
.tx_rs_thresh = I40E_DEFAULT_TX_RSBIT_THRESH,
-   .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS | 
ETH_TXQ_FLAGS_NOOFFLOADS,
+   .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
+   ETH_TXQ_FLAGS_NOOFFLOADS,
};

if (pf->flags | I40E_FLAG_VMDQ) {
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.h 
b/lib/librte_pmd_i40e/i40e_ethdev.h
index 28c0754..afa4e5d 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.h
+++ b/lib/librte_pmd_i40e/i40e_ethdev.h
@@ -56,6 +56,17 @@
 /* Always assign pool 0 to main VSI, VMDQ will start from 1 */
 #define I40E_VMDQ_POOL_BASE   1

+#define I40E_DEFAULT_RX_FREE_THRESH  32
+#define I40E_DEFAULT_RX_PTHRESH  8
+#define I40E_DEFAULT_RX_HTHRESH  8
+#define I40E_DEFAULT_RX_WTHRESH  0
+
+#define I40E_DEFAULT_TX_FREE_THRESH  32
+#define I40E_DEFAULT_TX_PTHRESH  32
+#define I40E_DEFAULT_TX_HTHRESH  0
+#define I40E_DEFAULT_TX_WTHRESH  0
+#define I40E_DEFAULT_TX_RSBIT_THRESH 32
+
 /* i40e flags */
 #define I40E_FLAG_RSS   (1ULL << 0)
 #define I40E_FLAG_DCB   (1ULL << 1)
diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 5b8a3bf..3e64666 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -1567,6 +1567,29 @@ i40evf_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
dev_info->max_tx_queues = vf->vsi_res->num_queue_pairs;
dev_info->min_rx_bufsize = I40E_BUF_SIZE_MIN;
dev_info->max_rx_pktlen = I40E_FRAME_SIZE_MAX;
+   dev_info->reta_size = ETH_RSS_RETA_SIZE_64;
+
+   dev_info->default_rxconf = (struct rte_eth_rxconf) {
+   .rx_thresh = {
+   .pthresh = I40E_DEFAULT_RX_PTHRESH,
+   .hthresh = I40E_DEFAULT_RX_HTHRESH,
+   .wthresh = I40E_DEFAULT_RX_WTHRESH,
+   },
+   .rx_free_thresh = I40E_DEFAULT_RX_FREE_THRESH,
+   .rx_drop_en = 0,
+   };
+
+   dev_info->default_txconf = (struct rte_eth_txconf) {
+   .tx_thresh = {
+   .pthresh = I40E_DEFAULT_TX_PTHRESH,
+   .hthresh = I40E_DEFAULT_TX_HTHRESH,
+   .wthresh = I40E_DEFAULT_TX_WTHRESH,
+   },
+   .tx_free_thresh = I40E_DEFAULT_TX_FREE_THRESH,
+   .tx_rs_thresh = I40E_DEFAULT_TX_RSBIT_THRESH,
+   .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
+   ETH_TXQ_FLAGS_NOOFFLOADS,
+   };
 }

 static void
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 4/8] igb: implement ops of 'dev_infos_get' for PF and VF respectively

2014-11-06 Thread Helin Zhang
As more and more information are different between PF and VF, ops of
'dev_infos_get' has been implemented respectively. In addition, new field of
'reta_size' has been added in 'struct rte_eth_dev_info' for returning
redirection table size.

Signed-off-by: Helin Zhang 
---
 lib/librte_ether/rte_ethdev.h |  2 ++
 lib/librte_pmd_e1000/igb_ethdev.c | 61 ---
 2 files changed, 52 insertions(+), 11 deletions(-)

v2 changes:
* Added new function for ops of 'dev_infos_get' specifically for igb VF.

v3 changes:
* Put the adding new element of 'reta_size' in ethdev into this patch,
  as it is needed.
* Returning default RX/TX configurations has been added in ops of
  'dev_infos_get', as it was accepted recently in another patches.

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 93df7b1..d81629b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -939,6 +939,8 @@ struct rte_eth_dev_info {
uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
uint32_t rx_offload_capa; /**< Device RX offload capabilities. */
uint32_t tx_offload_capa; /**< Device TX offload capabilities. */
+   uint16_t reta_size;
+   /**< Device redirection table size, the total number of entries. */
struct rte_eth_rxconf default_rxconf; /**< Default RX configuration */
struct rte_eth_txconf default_txconf; /**< Default TX configuration */
uint16_t vmdq_queue_base; /**< First queue ID for VMDQ pools. */
diff --git a/lib/librte_pmd_e1000/igb_ethdev.c 
b/lib/librte_pmd_e1000/igb_ethdev.c
index c13ea05..bae4eb2 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -83,6 +83,8 @@ static void eth_igb_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
+ struct rte_eth_dev_info *dev_info);
+static void eth_igbvf_infos_get(struct rte_eth_dev *dev,
struct rte_eth_dev_info *dev_info);
 static int  eth_igb_flow_ctrl_get(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf);
@@ -282,7 +284,7 @@ static struct eth_dev_ops igbvf_eth_dev_ops = {
.stats_get= eth_igbvf_stats_get,
.stats_reset  = eth_igbvf_stats_reset,
.vlan_filter_set  = igbvf_vlan_filter_set,
-   .dev_infos_get= eth_igb_infos_get,
+   .dev_infos_get= eth_igbvf_infos_get,
.rx_queue_setup   = eth_igb_rx_queue_setup,
.rx_queue_release = eth_igb_rx_queue_release,
.tx_queue_setup   = eth_igb_tx_queue_setup,
@@ -1268,8 +1270,7 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 }

 static void
-eth_igb_infos_get(struct rte_eth_dev *dev,
-   struct rte_eth_dev_info *dev_info)
+eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

@@ -1333,23 +1334,61 @@ eth_igb_infos_get(struct rte_eth_dev *dev,
dev_info->max_vmdq_pools = 0;
break;

+   default:
+   /* Should not happen */
+   break;
+   }
+   dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
+
+   dev_info->default_rxconf = (struct rte_eth_rxconf) {
+   .rx_thresh = {
+   .pthresh = IGB_DEFAULT_RX_PTHRESH,
+   .hthresh = IGB_DEFAULT_RX_HTHRESH,
+   .wthresh = IGB_DEFAULT_RX_WTHRESH,
+   },
+   .rx_free_thresh = IGB_DEFAULT_RX_FREE_THRESH,
+   .rx_drop_en = 0,
+   };
+
+   dev_info->default_txconf = (struct rte_eth_txconf) {
+   .tx_thresh = {
+   .pthresh = IGB_DEFAULT_TX_PTHRESH,
+   .hthresh = IGB_DEFAULT_TX_HTHRESH,
+   .wthresh = IGB_DEFAULT_TX_WTHRESH,
+   },
+   .txq_flags = 0,
+   };
+}
+
+static void
+eth_igbvf_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+   struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
+   dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
+   dev_info->max_mac_addrs = hw->mac.rar_entry_count;
+   dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
+   DEV_RX_OFFLOAD_IPV4_CKSUM |
+   DEV_RX_OFFLOAD_UDP_CKSUM  |
+   DEV_RX_OFFLOAD_TCP_CKSUM;
+   dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INS

[dpdk-dev] [PATCH v5 7/8] ethdev: support of multiple sizes of redirection table

2014-11-06 Thread Helin Zhang
As 40G NIC supports different sizes (128/512/64 entries) of redirection table
from that (128 entries) of 1G and 10G NICs, support of multiple sizes of
redirection table is needed. It includes,
* Redefine 'struct rte_eth_rss_reta' in ethdev.
  - To 'struct rte_eth_rss_reta_entry64' which contains 64 entries and 64 bits
mask.
  - Array of above new structure can be used for any number of redirection
table entries, as long as the number is multiple of 64. This is quite
flexible for the future expanding of redirection table.
* Redefinition of relevant interfaces in ethdev.
  - Interface of reta update has been redefined with new parameters.
  - Interface of reta query has been redefined with new parameters.
* Rework of 1G PMD in igb.
  - reta update has been reworked.
  - reta query has been reworked.
* Rework of 10G PMD in ixgbe.
  - reta update has been reworked.
  - reta query has been reworked.
* Rework of 40G PMD (PF only) in i40e.
  - reta update has been reworked.
  - reta query has been reworked.
* Implement relevant commands in testpmd.

Signed-off-by: Helin Zhang 
---
 app/test-pmd/cmdline.c  | 150 ++--
 app/test-pmd/config.c   |  37 +
 app/test-pmd/testpmd.h  |   4 +-
 lib/librte_ether/rte_ethdev.c   | 116 +---
 lib/librte_ether/rte_ethdev.h   |  40 ++
 lib/librte_pmd_e1000/igb_ethdev.c   | 109 +-
 lib/librte_pmd_i40e/i40e_ethdev.c   |  93 --
 lib/librte_pmd_i40e/i40e_ethdev.h   |  13 +++-
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 108 ++
 9 files changed, 406 insertions(+), 264 deletions(-)

v2 changes:
* Put rework of updating/querying igb reta to a single patch.
* Put rework of updating/querying ixgbe reta to a single patch.
* Put rework of updating/querying i40e reta to a single patch.

v3 changes:
* Put all redefinitions of structures and interfaces into a single patch.
* Put all reworks of igb/igbe/i40e of supporting multiple sizes of reta into
  the same patch.
* Put all relevant testpmd reworks of supporting multiple sizes of reta into
  the same patch.

v4 changes:
* Renamed RTE_BIT_WIDTH_64 to RTE_RETA_GROUP_SIZE.
* Added more comments to rte_eth_dev_rss_reta_update() and
  rte_eth_dev_rss_reta_query().

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index daba286..cf252e1 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -59,6 +59,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -186,6 +187,11 @@ static void cmd_help_long_parsed(void *parsed_result,
"show port (info|stats|xstats|fdir|stat_qmap) 
(port_id|all)\n"
"Display information for port_id, or all.\n\n"

+   "show port X rss reta (size) (mask0,mask1,...)\n"
+   "Display the rss redirection table entry indicated"
+   " by masks on port X. size is used to indicate the"
+   " hardware supported reta size\n\n"
+
"show port rss-hash [key]\n"
"Display the RSS hash functions and RSS hash key"
" of port X\n\n"
@@ -1562,11 +1568,13 @@ struct cmd_config_rss_reta {
 };

 static int
-parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
+parse_reta_config(const char *str,
+ struct rte_eth_rss_reta_entry64 *reta_conf,
+ uint16_t nb_entries)
 {
int i;
unsigned size;
-   uint8_t hash_index;
+   uint16_t hash_index, idx, shift;
uint8_t nb_queue;
char s[256];
const char *p, *p0 = str;
@@ -1594,24 +1602,23 @@ parse_reta_config(const char *str, struct 
rte_eth_rss_reta *reta_conf)
for (i = 0; i < _NUM_FLD; i++) {
errno = 0;
int_fld[i] = strtoul(str_fld[i], &end, 0);
-   if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
+   if (errno != 0 || end == str_fld[i] ||
+   int_fld[i] > 65535)
return -1;
}

-   hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
+   hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
nb_queue = (uint8_t)int_fld[FLD_QUEUE];

-   if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
-   printf("Invalid RETA hash index=%d", hash_index);
+   if (hash_index >= nb_entries) {
+   printf("Invalid RETA hash index=%d\n", hash_index);
return -1;
}

-   if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
-  

[dpdk-dev] [PATCH v5 5/8] ixgbe: implement ops of 'dev_infos_get' for PF and VF respectively

2014-11-06 Thread Helin Zhang
As more and more information are different between PF and VF, ops of
'dev_infos_get' has been implemented respectively. In addition, returning
redirection table size has been supported in it.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 90 +
 1 file changed, 71 insertions(+), 19 deletions(-)

v2 changes:
* Added new function for ops of 'dev_infos_get' specifically for ixgbe VF.

v3 changes:
* Returning default RX/TX configurations has been added in ops of
  'dev_infos_get' for VF, as it was added recently in that for PF.

diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c 
b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 9c73a30..5a17f3a 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -132,8 +132,9 @@ static int ixgbe_dev_queue_stats_mapping_set(struct 
rte_eth_dev *eth_dev,
 uint8_t stat_idx,
 uint8_t is_rx);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
-   struct rte_eth_dev_info *dev_info);
-
+  struct rte_eth_dev_info *dev_info);
+static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
+struct rte_eth_dev_info *dev_info);
 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);

 static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
@@ -391,7 +392,7 @@ static struct eth_dev_ops ixgbevf_eth_dev_ops = {
.stats_get= ixgbevf_dev_stats_get,
.stats_reset  = ixgbevf_dev_stats_reset,
.dev_close= ixgbevf_dev_close,
-   .dev_infos_get= ixgbe_dev_info_get,
+   .dev_infos_get= ixgbevf_dev_info_get,
.mtu_set  = ixgbevf_dev_set_mtu,
.vlan_filter_set  = ixgbevf_vlan_filter_set,
.vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
@@ -1964,25 +1965,76 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_SCTP_CKSUM;

dev_info->default_rxconf = (struct rte_eth_rxconf) {
-   .rx_thresh = {
-   .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
-   .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
-   .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
-   },
-   .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
-   .rx_drop_en = 0,
+   .rx_thresh = {
+   .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
+   .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
+   .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
+   },
+   .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
+   .rx_drop_en = 0,
+   };
+
+   dev_info->default_txconf = (struct rte_eth_txconf) {
+   .tx_thresh = {
+   .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
+   .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
+   .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
+   },
+   .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
+   .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
+   .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
+   ETH_TXQ_FLAGS_NOOFFLOADS,
};
+   dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
+}

+static void
+ixgbevf_dev_info_get(struct rte_eth_dev *dev,
+struct rte_eth_dev_info *dev_info)
+{
+   struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
+   dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
+   dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
+   dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS reg */
+   dev_info->max_mac_addrs = hw->mac.num_rar_entries;
+   dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
+   dev_info->max_vfs = dev->pci_dev->max_vfs;
+   if (hw->mac.type == ixgbe_mac_82598EB)
+   dev_info->max_vmdq_pools = ETH_16_POOLS;
+   else
+   dev_info->max_vmdq_pools = ETH_64_POOLS;
+   dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
+   DEV_RX_OFFLOAD_IPV4_CKSUM |
+   DEV_RX_OFFLOAD_UDP_CKSUM  |
+   DEV_RX_OFFLOAD_TCP_CKSUM;
+   dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
+   DEV_TX_OFFLOAD_IPV4_CKSUM  |
+   DEV_TX_OFFLOAD_UDP_CKSUM   |
+   DEV_TX_OFFLOAD_TCP_CKSUM   |
+   DEV_TX_OFFLOAD_SCTP_

[dpdk-dev] [PATCH] i40e: support xen domain0

2014-08-14 Thread Helin Zhang
i40e was failing to run in XEN domain0, as the physical
memory for adminq DMA should be allocated and translated
in a different way for XEN domain0. So
rte_memzone_reserve_bounded() should be used for DMA
memory allocation, and rte_mem_phy2mch() should be used
for DMA memory address translation to support running
i40e PMD in XEN domain0.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 9ed31b5..7a823a0 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1515,14 +1515,23 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct 
i40e_hw *hw,

id++;
snprintf(z_name, sizeof(z_name), "i40e_dma_%"PRIu64, id);
+#ifdef RTE_LIBRTE_XEN_DOM0
+   mz = rte_memzone_reserve_bounded(z_name, size, 0, 0, alignment,
+   RTE_PGSIZE_2M);
+#else
mz = rte_memzone_reserve_aligned(z_name, size, 0, 0, alignment);
+#endif
if (!mz)
return I40E_ERR_NO_MEMORY;

mem->id = id;
mem->size = size;
mem->va = mz->addr;
+#ifdef RTE_LIBRTE_XEN_DOM0
+   mem->pa = rte_mem_phy2mch(mz->memseg_id, mz->phys_addr);
+#else
mem->pa = mz->phys_addr;
+#endif

return I40E_SUCCESS;
 }
-- 
1.8.1.4



[dpdk-dev] [PATCH 0/3] support of configurable CRC stripping in VF

2014-08-20 Thread Helin Zhang
To support configurable CRC stripping in VF, a new
operation of I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX
is added to carry more configuration information from
VM to Intel(r) DPDK PF host, comparing to
I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES which is supported
by Linux PF host.

Helin Zhang (3):
  i40evf: support I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX in DPDK PF host
  i40evf: support I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX in i40e VF PMD
  config: remove useless config of
CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC

 config/common_bsdapp |   1 -
 config/common_linuxapp   |   1 -
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 188 ---
 lib/librte_pmd_i40e/i40e_pf.c|  90 ++---
 lib/librte_pmd_i40e/i40e_pf.h|   7 ++
 5 files changed, 191 insertions(+), 96 deletions(-)

-- 
1.8.1.4



[dpdk-dev] [PATCH 1/3] i40evf: support I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX in DPDK PF host

2014-08-20 Thread Helin Zhang
To configure VSI queues for VF, Linux PF host supports
operation of I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES with
limited configurations. To support more configurations
(e.g configurable CRC stripping in VF), a new operation
of I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX has been
supported in DPDK PF host.

Signed-off-by: Helin Zhang 
Reviewed-by: Jingjing Wu 
Reviewed-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_pf.c | 90 ++-
 lib/librte_pmd_i40e/i40e_pf.h |  7 
 2 files changed, 61 insertions(+), 36 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_pf.c b/lib/librte_pmd_i40e/i40e_pf.c
index e8b154d..9a03e74 100644
--- a/lib/librte_pmd_i40e/i40e_pf.c
+++ b/lib/librte_pmd_i40e/i40e_pf.c
@@ -327,7 +327,8 @@ send_msg:
 static int
 i40e_pf_host_hmc_config_rxq(struct i40e_hw *hw,
struct i40e_pf_vf *vf,
-   struct i40e_virtchnl_rxq_info *rxq)
+   struct i40e_virtchnl_rxq_info *rxq,
+   struct i40e_virtchnl_queue_pair_extra_info *qpei)
 {
int err = I40E_SUCCESS;
struct i40e_hmc_obj_rxq rx_ctx;
@@ -356,7 +357,10 @@ i40e_pf_host_hmc_config_rxq(struct i40e_hw *hw,
rx_ctx.tphdata_ena = 1;
rx_ctx.tphhead_ena = 1;
rx_ctx.lrxqthresh = 2;
-   rx_ctx.crcstrip = 1;
+   if (qpei) /* For DPDK PF host */
+   rx_ctx.crcstrip = qpei->crcstrip ? 1 : 0;
+   else /* For Linux PF host */
+   rx_ctx.crcstrip = 1;
rx_ctx.l2tsel = 1;
rx_ctx.prefena = 1;

@@ -411,42 +415,56 @@ i40e_pf_host_hmc_config_txq(struct i40e_hw *hw,
 static int
 i40e_pf_host_process_cmd_config_vsi_queues(struct i40e_pf_vf *vf,
   uint8_t *msg,
-  uint16_t msglen)
+  uint16_t msglen,
+  int opcode)
 {
struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
struct i40e_vsi *vsi = vf->vsi;
-   int ret = I40E_SUCCESS;
-   struct i40e_virtchnl_vsi_queue_config_info *qconfig =
-   (struct i40e_virtchnl_vsi_queue_config_info *)msg;
-   int i;
-   struct i40e_virtchnl_queue_pair_info *qpair;
-
-   if (msg == NULL || msglen <= sizeof(*qconfig) ||
-   qconfig->num_queue_pairs > vsi->nb_qps) {
+   struct i40e_virtchnl_vsi_queue_config_info *vc_vqci =
+   (struct i40e_virtchnl_vsi_queue_config_info *)msg;
+   struct i40e_virtchnl_queue_pair_info *vc_qpi;
+   struct i40e_virtchnl_queue_pair_extra_info *vc_qpei = NULL;
+   int i, ret = I40E_SUCCESS;
+
+   if (msg == NULL || msglen <= sizeof(*vc_vqci) ||
+   vc_vqci->num_queue_pairs > vsi->nb_qps) {
PMD_DRV_LOG(ERR, "vsi_queue_config_info argument wrong\n");
ret = I40E_ERR_PARAM;
goto send_msg;
}

-   qpair = qconfig->qpair;
-   for (i = 0; i < qconfig->num_queue_pairs; i++) {
-   if (qpair[i].rxq.queue_id > vsi->nb_qps - 1 ||
-   qpair[i].txq.queue_id > vsi->nb_qps - 1) {
+   vc_qpi = vc_vqci->qpair;
+   if (opcode == I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX)
+   vc_qpei = (struct i40e_virtchnl_queue_pair_extra_info *)
+   (((uint8_t *)vc_qpi) +
+   (sizeof(struct i40e_virtchnl_queue_pair_info) *
+   vc_vqci->num_queue_pairs));
+
+   for (i = 0; i < vc_vqci->num_queue_pairs; i++) {
+   if (vc_qpi[i].rxq.queue_id > vsi->nb_qps - 1 ||
+   vc_qpi[i].txq.queue_id > vsi->nb_qps - 1) {
ret = I40E_ERR_PARAM;
goto send_msg;
}

-   /* Apply VF RX queue setting to HMC */
-   if (i40e_pf_host_hmc_config_rxq(hw, vf, &qpair[i].rxq)
-   != I40E_SUCCESS) {
+   /*
+* Apply VF RX queue setting to HMC.
+* If the opcode is I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX,
+* then the extra information of
+* 'struct i40e_virtchnl_queue_pair_extra_info' is needed,
+* otherwise set the last parameter to NULL.
+*/
+   if (i40e_pf_host_hmc_config_rxq(hw, vf, &vc_qpi[i].rxq,
+   (vc_qpei != NULL ? (&vc_qpei[i]) : NULL)) !=
+   I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Configure RX queue HMC failed");
ret = I40E_ERR_PARAM;
goto send_msg;
}

/* Apply VF TX queue setting to HMC */
-   if (i40e_pf_host_hmc_config_txq(

[dpdk-dev] [PATCH 3/3] config: remove useless config of CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC

2014-08-20 Thread Helin Zhang
As i40e support configurable CRC stripping in VF,
the useless configuration of
CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC should
be removed.

Signed-off-by: Helin Zhang 
Reviewed-by: Jingjing Wu 
Reviewed-by: Jing Chen 
---
 config/common_bsdapp   | 1 -
 config/common_linuxapp | 1 -
 2 files changed, 2 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index bf6d8a0..c62388a 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -180,7 +180,6 @@ CONFIG_RTE_LIBRTE_I40E_DEBUG_RX=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_TX=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_TX_FREE=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_DRIVER=n
-CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC=y
 CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=n
 CONFIG_RTE_LIBRTE_I40E_ALLOW_UNSUPPORTED_SFP=y
 CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 9047975..c680a63 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -203,7 +203,6 @@ CONFIG_RTE_LIBRTE_I40E_DEBUG_RX=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_TX=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_TX_FREE=n
 CONFIG_RTE_LIBRTE_I40E_DEBUG_DRIVER=n
-CONFIG_RTE_LIBRTE_I40E_PF_DISABLE_STRIP_CRC=n
 CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=y
 CONFIG_RTE_LIBRTE_I40E_ALLOW_UNSUPPORTED_SFP=n
 CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n
-- 
1.8.1.4



[dpdk-dev] [PATCH 2/3] i40evf: support I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX in i40e VF PMD

2014-08-20 Thread Helin Zhang
To support configurable CRC in VF, use operation of
I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EX to carry more
information from VM to PF host, if the peer is DPDK
PF host. Otherwise assume it is Linux PF host and
just use operation of I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES.

Signed-off-by: Helin Zhang 
Reviewed-by: Jingjing Wu 
Reviewed-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 188 ---
 1 file changed, 130 insertions(+), 58 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 2726bfb..97310ea 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -515,82 +515,154 @@ i40evf_config_vlan_pvid(struct rte_eth_dev *dev,
return err;
 }

+/* It configures VSI queues to co-work with Linux PF host */
 static int
-i40evf_configure_queues(struct rte_eth_dev *dev)
+i40evf_configure_vsi_queues(struct rte_eth_dev *dev)
 {
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
-   struct i40e_virtchnl_vsi_queue_config_info *queue_info;
-   struct i40e_virtchnl_queue_pair_info *queue_cfg;
struct i40e_rx_queue **rxq =
(struct i40e_rx_queue **)dev->data->rx_queues;
struct i40e_tx_queue **txq =
(struct i40e_tx_queue **)dev->data->tx_queues;
-   int i, len, nb_qpairs, num_rxq, num_txq;
-   int err;
+   struct i40e_virtchnl_vsi_queue_config_info *vc_vqci;
+   struct i40e_virtchnl_queue_pair_info *vc_qpi;
struct vf_cmd_info args;
-   struct rte_pktmbuf_pool_private *mbp_priv;
-
-   nb_qpairs = vf->num_queue_pairs;
-   len = sizeof(*queue_info) + sizeof(*queue_cfg) * nb_qpairs;
-   queue_info = rte_zmalloc("queue_info", len, 0);
-   if (queue_info == NULL) {
-   PMD_INIT_LOG(ERR, "failed alloc memory for queue_info\n");
-   return -1;
+   int size, i, nb_qp, ret;
+
+   nb_qp = vf->num_queue_pairs;
+   size = sizeof(struct i40e_virtchnl_vsi_queue_config_info) +
+   sizeof(struct i40e_virtchnl_queue_pair_info) * nb_qp;
+   vc_vqci = rte_zmalloc("queue_info", size, 0);
+   if (!vc_vqci) {
+   PMD_DRV_LOG(ERR, "Failed to allocate memory for VF "
+   "configuring queues\n");
+   return -ENOMEM;
}
-   queue_info->vsi_id = vf->vsi_res->vsi_id;
-   queue_info->num_queue_pairs = nb_qpairs;
-   queue_cfg = queue_info->qpair;
-
-   num_rxq = dev->data->nb_rx_queues;
-   num_txq = dev->data->nb_tx_queues;
-   /*
-* PF host driver required to configure queues in pairs, which means
-* rxq_num should equals to txq_num. The actual usage won't always
-* work that way. The solution is fills 0 with HW ring option in case
-* they are not equal.
-*/
-   for (i = 0; i < nb_qpairs; i++) {
-   /*Fill TX info */
-   queue_cfg->txq.vsi_id = queue_info->vsi_id;
-   queue_cfg->txq.queue_id = i;
-   if (i < num_txq) {
-   queue_cfg->txq.ring_len = txq[i]->nb_tx_desc;
-   queue_cfg->txq.dma_ring_addr = 
txq[i]->tx_ring_phys_addr;
-   } else {
-   queue_cfg->txq.ring_len = 0;
-   queue_cfg->txq.dma_ring_addr = 0;
+   vc_vqci->vsi_id = vf->vsi_res->vsi_id;
+   vc_vqci->num_queue_pairs = nb_qp;
+
+   for (i = 0, vc_qpi = vc_vqci->qpair; i < nb_qp; i++, vc_qpi++) {
+   vc_qpi->txq.vsi_id = vc_vqci->vsi_id;
+   vc_qpi->txq.queue_id = i;
+   if (i < dev->data->nb_tx_queues) {
+   vc_qpi->txq.ring_len = txq[i]->nb_tx_desc;
+   vc_qpi->txq.dma_ring_addr = txq[i]->tx_ring_phys_addr;
}

-   /* Fill RX info */
-   queue_cfg->rxq.vsi_id = queue_info->vsi_id;
-   queue_cfg->rxq.queue_id = i;
-   queue_cfg->rxq.max_pkt_size = vf->max_pkt_len;
-   if (i < num_rxq) {
+   vc_qpi->rxq.vsi_id = vc_vqci->vsi_id;
+   vc_qpi->rxq.queue_id = i;
+   vc_qpi->rxq.max_pkt_size = vf->max_pkt_len;
+   if (i < dev->data->nb_rx_queues) {
+   struct rte_pktmbuf_pool_private *mbp_priv;
+
+   vc_qpi->rxq.ring_len = rxq[i]->nb_rx_desc;
+   vc_qpi->rxq.dma_ring_addr = rxq[i]->rx_ring_phys_addr;
mbp_priv = rte_mempool_get_priv(rxq[i]->mp);
-   queue_cfg->rxq.databuffer_size = 
mbp_priv->mbuf_data_room_size -
-   

[dpdk-dev] [PATCH 1/5] ethdev: support of multiple sizes of redirection table

2014-08-22 Thread Helin Zhang
To support different sizes of redirection table,
* 'struct rte_eth_rss_reta' has been redefined.
* New element of 'reta_size' is added into
  'struct rte_eth_dev_info'.
* New parameter of 'redirection table size' is
  required for updating/querying redirection
  table entries.
* Interfaces of updating/querying redirection
  table entries have been reworked to support
  multiple sizes.
Currently the supported redirection table sizes
are 64, 128 and 512 entries, according to the
hardware specifications.

Signed-off-by: Helin Zhang 
Reviewed-by: Jijiang Liu 
Reviewed-by: Cunming Liang 
Reviewed-by: Jingjing Wu 
---
 lib/librte_ether/rte_ethdev.c | 116 ++
 lib/librte_ether/rte_ethdev.h |  43 ++--
 2 files changed, 99 insertions(+), 60 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index fd1010a..3b483c4 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1780,78 +1780,104 @@ rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, 
struct rte_eth_pfc_conf *pfc
return (-ENOTSUP);
 }

-int
-rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta 
*reta_conf)
+static inline int
+rte_eth_check_reta_mask(struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size)
 {
-   struct rte_eth_dev *dev;
-   uint16_t max_rxq;
-   uint8_t i,j;
+   uint16_t i, num = reta_size / RTE_BIT_WIDTH_64;

-   if (port_id >= nb_ports) {
-   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
-   return (-ENODEV);
-   }
+   if (!reta_conf)
+   return -EINVAL;

-   /* Invalid mask bit(s) setting */
-   if ((reta_conf->mask_lo == 0) && (reta_conf->mask_hi == 0)) {
-   PMD_DEBUG_TRACE("Invalid update mask bits for 
port=%d\n",port_id);
-   return (-EINVAL);
+   for (i = 0; i < num; i++) {
+   if (reta_conf[i].mask)
+   return 0;
}

-   dev = &rte_eth_devices[port_id];
-   max_rxq = (dev->data->nb_rx_queues <= ETH_RSS_RETA_MAX_QUEUE) ?
-   dev->data->nb_rx_queues : ETH_RSS_RETA_MAX_QUEUE;
-   if (reta_conf->mask_lo != 0) {
-   for (i = 0; i < ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
-   if ((reta_conf->mask_lo & (1ULL << i)) &&
-   (reta_conf->reta[i] >= max_rxq)) {
-   PMD_DEBUG_TRACE("RETA hash index output"
-   "configration for port=%d,invalid"
-   
"queue=%d\n",port_id,reta_conf->reta[i]);
+   return -EINVAL;
+}

-   return (-EINVAL);
-   }
+static inline int
+rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
+uint16_t reta_size,
+uint8_t max_rxq)
+{
+   uint16_t i, idx, shift;
+
+   if (!reta_conf)
+   return -EINVAL;
+
+   if (max_rxq == 0) {
+   PMD_DEBUG_TRACE("No receive queue is available\n");
+   return -EINVAL;
+   }
+
+   for (i = 0; i < reta_size; i++) {
+   idx = i / RTE_BIT_WIDTH_64;
+   shift = i % RTE_BIT_WIDTH_64;
+   if ((reta_conf[idx].mask & (0x1 << shift)) &&
+   (reta_conf[idx].reta[shift] >= max_rxq)) {
+   PMD_DEBUG_TRACE("reta_conf[%u]->reta[%u]: %u exceeds "
+   "the maximum rxq index: %u\n", idx, shift,
+   reta_conf[idx].reta[shift], max_rxq);
+   return -EINVAL;
}
}

-   if (reta_conf->mask_hi != 0) {
-   for (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
-   j = (uint8_t)(i + ETH_RSS_RETA_NUM_ENTRIES/2);
+   return 0;
+}

-   /* Check if the max entry >= 128 */
-   if ((reta_conf->mask_hi & (1ULL << i)) &&
-   (reta_conf->reta[j] >= max_rxq)) {
-   PMD_DEBUG_TRACE("RETA hash index output"
-   "configration for port=%d,invalid"
-   
"queue=%d\n",port_id,reta_conf->reta[j]);
+int
+rte_eth_dev_rss_reta_update(uint8_t port_id,
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size)
+{
+   struct rte_eth_dev *dev;
+   int ret;

-   return (-EINVAL);
-   }
-   }
+ 

[dpdk-dev] [PATCH 2/5] e1000: rework of updating/querying redirection table

2014-08-22 Thread Helin Zhang
As ethdev has been changed to support multiple sizes
of redirection table, the functions of updating/querying
redirection table need to be reworked. In addition,
getting the redirection table size is supported in ops
of 'dev_infos_get'.

Signed-off-by: Helin Zhang 
Reviewed-by: Jijiang Liu 
Reviewed-by: Cunming Liang 
Reviewed-by: Jingjing Wu 
---
 lib/librte_pmd_e1000/igb_ethdev.c | 184 ++
 1 file changed, 127 insertions(+), 57 deletions(-)

diff --git a/lib/librte_pmd_e1000/igb_ethdev.c 
b/lib/librte_pmd_e1000/igb_ethdev.c
index 3187d92..47438ad 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -71,6 +71,8 @@ static void eth_igb_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
+ struct rte_eth_dev_info *dev_info);
+static void eth_igbvf_infos_get(struct rte_eth_dev *dev,
struct rte_eth_dev_info *dev_info);
 static int  eth_igb_flow_ctrl_get(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf);
@@ -124,10 +126,11 @@ static int igbvf_vlan_filter_set(struct rte_eth_dev *dev,
 static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on);
 static void igbvf_set_vfta_all(struct rte_eth_dev *dev, bool on);
 static int eth_igb_rss_reta_update(struct rte_eth_dev *dev,
-struct rte_eth_rss_reta *reta_conf);
+  struct rte_eth_rss_reta_entry64 *reta_conf,
+  uint16_t reta_size);
 static int eth_igb_rss_reta_query(struct rte_eth_dev *dev,
-   struct rte_eth_rss_reta *reta_conf);
-
+ struct rte_eth_rss_reta_entry64 *reta_conf,
+ uint16_t reta_size);
 static int eth_igb_add_syn_filter(struct rte_eth_dev *dev,
struct rte_syn_filter *filter, uint16_t rx_queue);
 static int eth_igb_remove_syn_filter(struct rte_eth_dev *dev);
@@ -270,7 +273,7 @@ static struct eth_dev_ops igbvf_eth_dev_ops = {
.stats_get= eth_igbvf_stats_get,
.stats_reset  = eth_igbvf_stats_reset,
.vlan_filter_set  = igbvf_vlan_filter_set,
-   .dev_infos_get= eth_igb_infos_get,
+   .dev_infos_get= eth_igbvf_infos_get,
.rx_queue_setup   = eth_igb_rx_queue_setup,
.rx_queue_release = eth_igb_rx_queue_release,
.tx_queue_setup   = eth_igb_tx_queue_setup,
@@ -1257,8 +1260,7 @@ eth_igbvf_stats_reset(struct rte_eth_dev *dev)
 }

 static void
-eth_igb_infos_get(struct rte_eth_dev *dev,
-   struct rte_eth_dev_info *dev_info)
+eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

@@ -1331,6 +1333,72 @@ eth_igb_infos_get(struct rte_eth_dev *dev,
dev_info->max_tx_queues = 0;
dev_info->max_vmdq_pools = 0;
}
+   dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
+}
+
+static void
+eth_igbvf_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+   struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
+   dev_info->max_rx_pktlen  = 0x3FFF; /* See RLPML register. */
+   dev_info->max_mac_addrs = hw->mac.rar_entry_count;
+   dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
+   DEV_RX_OFFLOAD_IPV4_CKSUM |
+   DEV_RX_OFFLOAD_UDP_CKSUM  |
+   DEV_RX_OFFLOAD_TCP_CKSUM;
+   dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
+   DEV_TX_OFFLOAD_IPV4_CKSUM  |
+   DEV_TX_OFFLOAD_UDP_CKSUM   |
+   DEV_TX_OFFLOAD_TCP_CKSUM   |
+   DEV_TX_OFFLOAD_SCTP_CKSUM;
+   switch (hw->mac.type) {
+   case e1000_82575:
+   dev_info->max_rx_queues = 4;
+   dev_info->max_tx_queues = 4;
+   dev_info->max_vmdq_pools = 0;
+   break;
+   case e1000_82576:
+   dev_info->max_rx_queues = 16;
+   dev_info->max_tx_queues = 16;
+   dev_info->max_vmdq_pools = ETH_8_POOLS;
+   break;
+   case e1000_82580:
+   dev_info->max_rx_queues = 8;
+   dev_info->max_tx_queues = 8;
+   dev_info->max_vmdq_pools = ETH_8_POOLS;
+   break;
+   case e1000_i350:
+   dev_info->max_rx_queues = 8;
+   dev_info->max_tx_queues = 8;
+ 

[dpdk-dev] [PATCH 3/5] ixgbe: rework of updating/querying redirection table

2014-08-22 Thread Helin Zhang
As ethdev has been changed to support multiple sizes
of redirection table, the functions of updating/querying
redirection table need to be reworked. In addition,
getting the redirection table size is supported in ops
of 'dev_infos_get'.

Signed-off-by: Helin Zhang 
Reviewed-by: Jijiang Liu 
Reviewed-by: Cunming Liang 
Reviewed-by: Jingjing Wu 
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 136 +++-
 1 file changed, 87 insertions(+), 49 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c 
b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 59122a1..4f036ec 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -118,8 +118,9 @@ static int ixgbe_dev_queue_stats_mapping_set(struct 
rte_eth_dev *eth_dev,
 uint8_t stat_idx,
 uint8_t is_rx);
 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
-   struct rte_eth_dev_info *dev_info);
-
+  struct rte_eth_dev_info *dev_info);
+static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
+struct rte_eth_dev_info *dev_info);
 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);

 static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
@@ -144,9 +145,11 @@ static int ixgbe_flow_ctrl_set(struct rte_eth_dev *dev,
 static int ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
struct rte_eth_pfc_conf *pfc_conf);
 static int ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
-   struct rte_eth_rss_reta *reta_conf);
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size);
 static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
-   struct rte_eth_rss_reta *reta_conf);
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
@@ -377,7 +380,7 @@ static struct eth_dev_ops ixgbevf_eth_dev_ops = {
.stats_get= ixgbevf_dev_stats_get,
.stats_reset  = ixgbevf_dev_stats_reset,
.dev_close= ixgbevf_dev_close,
-   .dev_infos_get= ixgbe_dev_info_get,
+   .dev_infos_get= ixgbevf_dev_info_get,
.mtu_set  = ixgbevf_dev_set_mtu,
.vlan_filter_set  = ixgbevf_vlan_filter_set,
.vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
@@ -1948,6 +1951,35 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_UDP_CKSUM   |
DEV_TX_OFFLOAD_TCP_CKSUM   |
DEV_TX_OFFLOAD_SCTP_CKSUM;
+   dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
+}
+
+static void
+ixgbevf_dev_info_get(struct rte_eth_dev *dev,
+struct rte_eth_dev_info *dev_info)
+{
+   struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
+   dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
+   dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
+   dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS reg */
+   dev_info->max_mac_addrs = hw->mac.num_rar_entries;
+   dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
+   dev_info->max_vfs = dev->pci_dev->max_vfs;
+   if (hw->mac.type == ixgbe_mac_82598EB)
+   dev_info->max_vmdq_pools = ETH_16_POOLS;
+   else
+   dev_info->max_vmdq_pools = ETH_64_POOLS;
+   dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
+   DEV_RX_OFFLOAD_IPV4_CKSUM |
+   DEV_RX_OFFLOAD_UDP_CKSUM  |
+   DEV_RX_OFFLOAD_TCP_CKSUM;
+   dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
+   DEV_TX_OFFLOAD_IPV4_CKSUM  |
+   DEV_TX_OFFLOAD_UDP_CKSUM   |
+   DEV_TX_OFFLOAD_TCP_CKSUM   |
+   DEV_TX_OFFLOAD_SCTP_CKSUM;
 }

 /* return 0 means link status changed, -1 means not changed */
@@ -2624,38 +2656,41 @@ ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, 
struct rte_eth_pfc_conf *p

 static int
 ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
-   struct rte_eth_rss_reta *reta_conf)
+ struct rte_eth_rss_reta_entry64 *reta_conf,
+ uint16_t reta_size)
 {
uint8_t i,j,mask;
-   uint32_t reta;
+   uint

[dpdk-dev] [PATCH 4/5] i40e: rework of updating/querying redirection table

2014-08-22 Thread Helin Zhang
i40e can support 128 or 512 entries of redirection
table entries, according to the firmware configuration.
In addition, as ethdev has been changed to support
multiple sizes of redirection table, the functions of
updating/querying redirection table need to be reworked.
Getting the redirection table size is supported in ops
of 'dev_infos_get'.

Signed-off-by: Helin Zhang 
Reviewed-by: Jijiang Liu 
Reviewed-by: Cunming Liang 
Reviewed-by: Jingjing Wu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c| 88 
 lib/librte_pmd_i40e/i40e_ethdev.h|  1 +
 lib/librte_pmd_i40e/i40e_ethdev_vf.c |  1 +
 3 files changed, 62 insertions(+), 28 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 9ed31b5..7289f1a 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -158,9 +158,11 @@ static void i40e_macaddr_add(struct rte_eth_dev *dev,
  uint32_t pool);
 static void i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t index);
 static int i40e_dev_rss_reta_update(struct rte_eth_dev *dev,
-   struct rte_eth_rss_reta *reta_conf);
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size);
 static int i40e_dev_rss_reta_query(struct rte_eth_dev *dev,
-  struct rte_eth_rss_reta *reta_conf);
+  struct rte_eth_rss_reta_entry64 *reta_conf,
+  uint16_t reta_size);

 static int i40e_get_cap(struct i40e_hw *hw);
 static int i40e_pf_parameter_init(struct rte_eth_dev *dev);
@@ -1231,6 +1233,7 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_UDP_CKSUM |
DEV_TX_OFFLOAD_TCP_CKSUM |
DEV_TX_OFFLOAD_SCTP_CKSUM;
+   dev_info->reta_size = pf->hash_lut_size;
 }

 static int
@@ -1431,32 +1434,40 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t 
index)

 static int
 i40e_dev_rss_reta_update(struct rte_eth_dev *dev,
-struct rte_eth_rss_reta *reta_conf)
+struct rte_eth_rss_reta_entry64 *reta_conf,
+uint16_t reta_size)
 {
+   struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
uint32_t lut, l;
-   uint8_t i, j, mask, max = ETH_RSS_RETA_NUM_ENTRIES / 2;
-
-   for (i = 0; i < ETH_RSS_RETA_NUM_ENTRIES; i += 4) {
-   if (i < max)
-   mask = (uint8_t)((reta_conf->mask_lo >> i) & 0xF);
-   else
-   mask = (uint8_t)((reta_conf->mask_hi >>
-   (i - max)) & 0xF);
+   uint16_t i, j, lut_size = pf->hash_lut_size;
+   uint16_t idx, shift;
+   uint8_t mask;
+
+   if (reta_size != lut_size ||
+   reta_size > ETH_RSS_RETA_SIZE_512) {
+   PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
+   "(%d) doesn't match the number hardware can supported "
+   "(%d)\n", reta_size, lut_size);
+   return -EINVAL;
+   }

+   for (i = 0; i < reta_size; i += 4) {
+   idx = i / RTE_BIT_WIDTH_64;
+   shift = i % RTE_BIT_WIDTH_64;
+   mask = (uint8_t)((reta_conf[idx].mask >> shift) & 0xf);
if (!mask)
continue;
-
-   if (mask == 0xF)
+   if (mask == 0xf)
l = 0;
else
l = I40E_READ_REG(hw, I40E_PFQF_HLUT(i >> 2));
-
for (j = 0, lut = 0; j < 4; j++) {
if (mask & (0x1 << j))
-   lut |= reta_conf->reta[i + j] << (8 * j);
+   lut |= reta_conf[idx].reta[shift + j] <<
+   (CHAR_BIT * j);
else
-   lut |= l & (0xFF << (8 * j));
+   lut |= l & (0xff << (CHAR_BIT * j));
}
I40E_WRITE_REG(hw, I40E_PFQF_HLUT(i >> 2), lut);
}
@@ -1466,27 +1477,36 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,

 static int
 i40e_dev_rss_reta_query(struct rte_eth_dev *dev,
-   struct rte_eth_rss_reta *reta_conf)
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size)
 {
+   struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
  

[dpdk-dev] [PATCH 5/5] app/testpmd: rework of updating/querying redirection table

2014-08-22 Thread Helin Zhang
As multiple sizes (64, 128, 512) of redirection table have
been supported, the commands of updating/querying redirection
table entries have been reworked. In addition, the
redirection table size can be queried by the existing
command of 'show port info <>'.

Signed-off-by: Helin Zhang 
Reviewed-by: Jijiang Liu 
Reviewed-by: Cunming Liang 
Reviewed-by: Jingjing Wu 
---
 app/test-pmd/cmdline.c | 159 -
 app/test-pmd/config.c  |  37 ++--
 app/test-pmd/testpmd.h |   4 +-
 3 files changed, 137 insertions(+), 63 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 345be11..5ad501e 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -59,6 +59,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -186,6 +187,11 @@ static void cmd_help_long_parsed(void *parsed_result,
"show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
"Display information for port_id, or all.\n\n"

+   "show port X rss reta (size) (mask0,mask1,...)\n"
+   "Display the rss redirection table entry indicated"
+   " by masks or port X. size is used to indicate the"
+   " hardware supported reta size\n\n"
+
"show port rss-hash [key]\n"
"Display the RSS hash functions and RSS hash key"
" of port X\n\n"
@@ -1436,11 +1442,13 @@ struct cmd_config_rss_reta {
 };

 static int
-parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
+parse_reta_config(const char *str,
+ struct rte_eth_rss_reta_entry64 *reta_conf,
+ uint16_t nb_entries)
 {
int i;
unsigned size;
-   uint8_t hash_index;
+   uint16_t hash_index, idx, shift;
uint8_t nb_queue;
char s[256];
const char *p, *p0 = str;
@@ -1475,17 +1483,15 @@ parse_reta_config(const char *str, struct 
rte_eth_rss_reta *reta_conf)
hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
nb_queue = (uint8_t)int_fld[FLD_QUEUE];

-   if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
+   if (hash_index >= nb_entries) {
printf("Invalid RETA hash index=%d",hash_index);
return -1;
}

-   if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
-   reta_conf->mask_lo |= (1ULL << hash_index);
-   else
-   reta_conf->mask_hi |= (1ULL << (hash_index - 
ETH_RSS_RETA_NUM_ENTRIES/2));
-
-   reta_conf->reta[hash_index] = nb_queue;
+   idx = hash_index / RTE_BIT_WIDTH_64;
+   shift = hash_index % RTE_BIT_WIDTH_64;
+   reta_conf[idx].mask |= (1ULL << shift);
+   reta_conf[idx].reta[shift] = nb_queue;
}

return 0;
@@ -1493,22 +1499,42 @@ parse_reta_config(const char *str, struct 
rte_eth_rss_reta *reta_conf)

 static void
 cmd_set_rss_reta_parsed(void *parsed_result,
-   __attribute__((unused)) struct cmdline *cl,
-   __attribute__((unused)) void *data)
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
 {
int ret;
-   struct rte_eth_rss_reta reta_conf;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_rss_reta_entry64 reta_conf[8];
struct cmd_config_rss_reta *res = parsed_result;

-   memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
+   memset(&dev_info, 0, sizeof(dev_info));
+   rte_eth_dev_info_get(res->port_id, &dev_info);
+   if (dev_info.reta_size == 0) {
+   printf("Redirection table size is 0 which is "
+   "invalid for RSS\n");
+   return;
+   } else
+   printf("The reta size of port %d is %u\n",
+   res->port_id, dev_info.reta_size);
+   if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
+   printf("Currently do not support more than %u entries of "
+   "redirection table\n", ETH_RSS_RETA_SIZE_512);
+   return;
+   }
+
+   memset(reta_conf, 0, sizeof(reta_conf));
if (!strcmp(res->list_name, "reta")) {
-   if (parse_reta_config(res->list_of_items, &reta_conf)) {
-   printf("Invalid RSS Redirection Table config 
entered\n");
+   if (parse_reta_config(res->list_of_items, reta_conf,
+  

[dpdk-dev] [PATCH 0/5] support of multiple sizes of redirection table

2014-08-22 Thread Helin Zhang
As e1000, ixgbe and i40e hardware use different sizes of
redirection table, ethdev needs to be reworked to support
multiple sizes of that table. Also each PMD should be
reworked to support this change, and can be told the table
size directly. In addition, commands in testpmd have been
reworked to support these changes.

Helin Zhang (5):
  ethdev: support of multiple sizes of redirection table
  e1000: rework of updating/querying redirection table
  ixgbe: rework of updating/querying redirection table
  i40e: rework of updating/querying redirection table
  app/testpmd: rework of updating/querying redirection table

 app/test-pmd/cmdline.c   | 159 ++
 app/test-pmd/config.c|  37 ---
 app/test-pmd/testpmd.h   |   4 +-
 lib/librte_ether/rte_ethdev.c| 116 +-
 lib/librte_ether/rte_ethdev.h|  43 +---
 lib/librte_pmd_e1000/igb_ethdev.c| 184 ---
 lib/librte_pmd_i40e/i40e_ethdev.c|  88 +++--
 lib/librte_pmd_i40e/i40e_ethdev.h|   1 +
 lib/librte_pmd_i40e/i40e_ethdev_vf.c |   1 +
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c  | 136 --
 10 files changed, 512 insertions(+), 257 deletions(-)

-- 
1.8.1.4



[dpdk-dev] [PATCH] i40e: bug fix of compile error

2014-12-01 Thread Helin Zhang
The compile error will occur as below when set 
'RTE_LIBRTE_I40E_16BYTE_RX_DESC=y'.
The changes is just to fix it.

lib/librte_pmd_i40e/i40e_rxtx.c: In function i40e_rxd_build_fdir:
lib/librte_pmd_i40e/i40e_rxtx.c:431:28: error: volatile union  has 
no member named fd
lib/librte_pmd_i40e/i40e_rxtx.c:427:19: error: unused variable flexbl 
[-Werror=unused-variable]
lib/librte_pmd_i40e/i40e_rxtx.c:427:11: error: unused variable flexbh 
[-Werror=unused-variable]

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_rxtx.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2d2ef04..95666fd 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -424,13 +424,9 @@ static inline uint64_t
 i40e_rxd_build_fdir(volatile union i40e_rx_desc *rxdp, struct rte_mbuf *mb)
 {
uint64_t flags = 0;
+#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
uint16_t flexbh, flexbl;

-#ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
-   mb->hash.fdir.hi =
-   rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.fd);
-   flags |= PKT_RX_FDIR_ID;
-#else
flexbh = (rte_le_to_cpu_32(rxdp->wb.qword2.ext_status) >>
I40E_RX_DESC_EXT_STATUS_FLEXBH_SHIFT) &
I40E_RX_DESC_EXT_STATUS_FLEXBH_MASK;
@@ -438,22 +434,28 @@ i40e_rxd_build_fdir(volatile union i40e_rx_desc *rxdp, 
struct rte_mbuf *mb)
I40E_RX_DESC_EXT_STATUS_FLEXBL_SHIFT) &
I40E_RX_DESC_EXT_STATUS_FLEXBL_MASK;

-
if (flexbh == I40E_RX_DESC_EXT_STATUS_FLEXBH_FD_ID) {
mb->hash.fdir.hi =
rte_le_to_cpu_32(rxdp->wb.qword3.hi_dword.fd_id);
flags |= PKT_RX_FDIR_ID;
} else if (flexbh == I40E_RX_DESC_EXT_STATUS_FLEXBH_FLEX) {
mb->hash.fdir.hi =
-   
rte_le_to_cpu_32(rxdp->wb.qword3.hi_dword.flex_bytes_hi);
+   rte_le_to_cpu_32(
+   rxdp->wb.qword3.hi_dword.flex_bytes_hi);
flags |= PKT_RX_FDIR_FLX;
}
+
if (flexbl == I40E_RX_DESC_EXT_STATUS_FLEXBL_FLEX) {
mb->hash.fdir.lo =
-   
rte_le_to_cpu_32(rxdp->wb.qword3.lo_dword.flex_bytes_lo);
+   rte_le_to_cpu_32(
+   rxdp->wb.qword3.lo_dword.flex_bytes_lo);
flags |= PKT_RX_FDIR_FLX;
}
+#else
+   mb->hash.fdir.hi = rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.fd_id);
+   flags |= PKT_RX_FDIR_ID;
 #endif
+
return flags;
 }
 static inline void
-- 
1.9.3



[dpdk-dev] [PATCH v8 0/4] Support configuring hash functions

2014-12-02 Thread Helin Zhang
These patches mainly support configuring hash functions. In detail,
 - It can get/set global hash configurations.
  * Get/set symmetric hash enable per flow type.
  * Get/set hash function type.
 - It can get/set symmetric hash enable per port.
 - Four commands have been implemented in testpmd to support testing above.
   * get_sym_hash_ena_per_port
   * set_sym_hash_ena_per_port
   * get_hash_global_config
   * set_hash_global_config

It also uses constant hash keys to replace runtime generating hash keys.
Global initialization is added to correctly put registers to an initial state.

v3 changes:
* Removed renamings in rte_ethdev.h.
* Redesigned filter control API and its relevant structures/enums.
* Renamed header file from rte_eth_features.h to rte_eth_ctrol.h.
* Remove public header file of rte_i40e.h specific for i40e.
* Added hardware initialization function during port init.
* Used constant random hash keys in i40e PF.
* renamed the commands in testpmd based on the redesigned filter control API.

v4 changes:
* Fixed a bug in testpmd to support 'set_sym_hash_ena_per_port'.

v5 changes:
* Integrated with filter API defined recently.
* Remove all for filter API definition, as it has already defined and merged
  recently.

v6 changes:
* Flow type strings are used to replace Packet Classification Types, to isolate
  hardware specific things.
* Implemented the mapping function to convert RSS offload types to Packet
  Classification Types, to isolate the real hardware specific things.
* Removed initialization of global registers in i40e PMD, as global registers
  shouldn't be initialized per port.
* Added more annotations to get code more understandable.
* Corrected annotation format for documenation.

v7 changes:
* Removed swap configurations, as it is not allowed by hardware design.
* Put symmetric hash per flow type and hash function type into
  'RTE_ETH_HASH_FILTER_GLOBAL_CONFIG', as they are controlling global registers
  which will affects all the ports of the same NIC.

v8 changes:
* Removed redundant checks in i40e_ethdev.c.
* Solved compile errors on ICC.

Helin Zhang (4):
  ethdev: code style fixes
  i40e: use constant as the default hash keys
  i40e: support of controlling hash functions
  app/testpmd: add commands to support hash functions

 app/test-pmd/cmdline.c| 333 ++
 lib/librte_ether/rte_eth_ctrl.h   |  72 -
 lib/librte_pmd_i40e/i40e_ethdev.c | 308 +--
 3 files changed, 699 insertions(+), 14 deletions(-)

-- 
1.8.1.4



[dpdk-dev] [PATCH v8 1/4] ethdev: code style fixes

2014-12-02 Thread Helin Zhang
Added code style fixes.

Signed-off-by: Helin Zhang 
---
 lib/librte_ether/rte_eth_ctrl.h | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 7088d8d..6ab16c2 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -62,8 +62,8 @@ enum rte_filter_type {
  * Generic operations on filters
  */
 enum rte_filter_op {
+   /** used to check whether the type filter is supported */
RTE_ETH_FILTER_NOP = 0,
-   /**< used to check whether the type filter is supported */
RTE_ETH_FILTER_ADD,  /**< add filter entry */
RTE_ETH_FILTER_UPDATE,   /**< update filter entry */
RTE_ETH_FILTER_DELETE,   /**< delete filter entry */
@@ -75,16 +75,15 @@ enum rte_filter_op {
RTE_ETH_FILTER_OP_MAX
 };

-/**
+/*
  * MAC filter type
  */
 enum rte_mac_filter_type {
RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
-   RTE_MACVLAN_PERFECT_MATCH,
-   /**< exact match of MAC addr and VLAN ID. */
+   RTE_MACVLAN_PERFECT_MATCH, /**< exact match of MAC addr and VLAN ID. */
RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
+   /** hash match of MAC addr and exact match of VLAN ID. */
RTE_MACVLAN_HASH_MATCH,
-   /**< hash match of MAC addr and exact match of VLAN ID. */
 };

 /**
-- 
1.8.1.4



[dpdk-dev] [PATCH v8 2/4] i40e: use constant as the default hash keys

2014-12-02 Thread Helin Zhang
Calculating the default RSS hash keys at run time is not needed
at all, and may have race conditions. The alternative is to use
array of random values which were generated manually as the
default hash keys.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 87e750a..8fbe25f 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -73,7 +73,7 @@
 /* Maximun number of VSI */
 #define I40E_MAX_NUM_VSIS  (384UL)

-/* Default queue interrupt throttling time in microseconds*/
+/* Default queue interrupt throttling time in microseconds */
 #define I40E_ITR_INDEX_DEFAULT  0
 #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
 #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */
@@ -199,9 +199,6 @@ static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_op filter_op,
void *arg);

-/* Default hash key buffer for RSS */
-static uint32_t rss_key_default[I40E_PFQF_HKEY_MAX_INDEX + 1];
-
 static struct rte_pci_id pci_id_i40e_map[] = {
 #define RTE_PCI_DEV_ID_DECL_I40E(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
 #include "rte_pci_dev_ids.h"
@@ -5023,9 +5020,12 @@ i40e_pf_config_rss(struct i40e_pf *pf)
}
if (rss_conf.rss_key == NULL || rss_conf.rss_key_len <
(I40E_PFQF_HKEY_MAX_INDEX + 1) * sizeof(uint32_t)) {
-   /* Calculate the default hash key */
-   for (i = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++)
-   rss_key_default[i] = (uint32_t)rte_rand();
+   /* Random default keys */
+   static uint32_t rss_key_default[] = {0x6b793944,
+   0x23504cb5, 0x5bea75b6, 0x309f4f12, 0x3dc0a2b8,
+   0x024ddcdf, 0x339b8ca0, 0x4c4af64a, 0x34fac605,
+   0x55d85839, 0x3a58997d, 0x2ec938e1, 0x66031581};
+
rss_conf.rss_key = (uint8_t *)rss_key_default;
rss_conf.rss_key_len = (I40E_PFQF_HKEY_MAX_INDEX + 1) *
sizeof(uint32_t);
-- 
1.8.1.4



[dpdk-dev] [PATCH v8 3/4] i40e: support of controlling hash functions

2014-12-02 Thread Helin Zhang
Hash filter control has been implemented for i40e. It includes
getting/setting,
- global hash configurations (hash function type, and symmetric
  hash enable per flow type)
- symmetric hash enable per port

Signed-off-by: Helin Zhang 
---
 lib/librte_ether/rte_eth_ctrl.h   |  63 
 lib/librte_pmd_i40e/i40e_ethdev.c | 294 +-
 2 files changed, 355 insertions(+), 2 deletions(-)

v5 changes:
* Integrated with filter API defined recently.

v6 changes:
* Implemented the mapping function to convert RSS offload types to Packet
  Classification Types, to isolate the real hardware specific things.
* Removed initialization of global registers in i40e PMD, as global registers
  shouldn't be initialized per port.
* Added more annotations to get code more understandable.
* Corrected annotation format for documenation.

v7 changes:
* Removed swap configurations, as it is not allowed by hardware design.
* Put symmetric hash per flow type and hash function type into
  'RTE_ETH_HASH_FILTER_GLOBAL_CONFIG', as they are controlling global registers
  which will affects all the ports of the same NIC.

v8 changes:
* Removed redundant return value checks of i40e_flowtype_to_pctype(), as it
  should always be correct.
* Fixed the compile issue on ICC, of "error #188: enumerated type mixed with
  another type".

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 6ab16c2..827d7ba 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -55,6 +55,7 @@ enum rte_filter_type {
RTE_ETH_FILTER_ETHERTYPE,
RTE_ETH_FILTER_TUNNEL,
RTE_ETH_FILTER_FDIR,
+   RTE_ETH_FILTER_HASH,
RTE_ETH_FILTER_MAX
 };

@@ -449,6 +450,68 @@ struct rte_eth_fdir_stats {
uint32_t best_cnt; /**< Number of filters in best effort spaces. */
 };

+/**
+ * Hash filter information types.
+ * - RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT is for getting/setting the
+ *   information/configuration of 'symmetric hash enable' per port.
+ * - RTE_ETH_HASH_FILTER_GLOBAL_CONFIG is for getting/setting the global
+ *   configurations of hash filters. Those global configurations are valid
+ *   for all ports of the same NIC.
+ */
+enum rte_eth_hash_filter_info_type {
+   RTE_ETH_HASH_FILTER_INFO_TYPE_UNKNOWN = 0,
+   /** Symmetric hash enable per port */
+   RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT,
+   /** Configure globally for hash filter */
+   RTE_ETH_HASH_FILTER_GLOBAL_CONFIG,
+   RTE_ETH_HASH_FILTER_INFO_TYPE_MAX,
+};
+
+/**
+ * Hash function types.
+ */
+enum rte_eth_hash_function {
+   RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
+   RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
+   RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
+   RTE_ETH_HASH_FUNCTION_MAX,
+};
+
+#define UINT32_BIT (CHAR_BIT * sizeof(uint32_t))
+#define RTE_SYM_HASH_MASK_ARRAY_SIZE \
+   (RTE_ALIGN(RTE_ETH_FLOW_TYPE_MAX, UINT32_BIT)/UINT32_BIT)
+/**
+ * A structure used to set or get global hash function configurations which
+ * include symmetric hash enable per flow type and hash function type.
+ * Each bit in sym_hash_enable_mask[] indicates if the symmetric hash of the
+ * coresponding flow type is enabled or not.
+ * Each bit in valid_bit_mask[] indicates if the coresponding bit in
+ * sym_hash_enable_mask[] is valid or not. For the configurations gotten, it
+ * also means if the flow type is supported by hardware or not.
+ */
+struct rte_eth_hash_global_conf {
+   enum rte_eth_hash_function hash_func; /**< Hash function type */
+   /** Bit mask for symmetric hash enable per flow type */
+   uint32_t sym_hash_enable_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
+   /** Bit mask indicates if the coresponding bit is valid */
+   uint32_t valid_bit_mask[RTE_SYM_HASH_MASK_ARRAY_SIZE];
+};
+
+/**
+ * A structure used to set or get hash filter information, to support filter
+ * type of 'RTE_ETH_FILTER_HASH' and its operations.
+ */
+struct rte_eth_hash_filter_info {
+   enum rte_eth_hash_filter_info_type info_type; /**< Information type. */
+   /** Details of hash filter infomation */
+   union {
+   /* For RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT */
+   uint8_t enable;
+   /* Global configurations of hash filter */
+   struct rte_eth_hash_global_conf global_conf;
+   } info;
+};
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 8fbe25f..fa9cac8 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -93,6 +93,18 @@
I40E_PFINT_ICR0_ENA_VFLR_MASK | \
I40E_PFINT_ICR0_ENA_ADMINQ_MASK)

+#define I40E_FLOW_TYPES ( \
+   (1UL << RTE_ETH_FLOW_TYPE_UDPV4) | \
+   (1UL << RTE_ETH_FLOW_TYPE_TCPV4) | \
+   (1UL <&

[dpdk-dev] [PATCH v8 4/4] app/testpmd: add commands to support hash functions

2014-12-02 Thread Helin Zhang
To demonstrate the hash filter control, commands are added.
They are,
- get_sym_hash_ena_per_port
- set_sym_hash_ena_per_port
- get_hash_global_config
- set_hash_global_config

Signed-off-by: Helin Zhang 
---
 app/test-pmd/cmdline.c | 333 +
 1 file changed, 333 insertions(+)

v6 changes:
* Flow type strings are used to replace Packet Classification Types, to isolate
  hardware specific things.

v7 changes:
* Removed commands of,
  get_sym_hash_ena_per_pctype
  set_sym_hash_ena_per_pctype
  get_filter_swap
  set_filter_swap
  get_hash_function
  set_hash_function.
* Added new commands of,
  get_hash_global_config
  set_hash_global_config

v8 changes:
* Fixed the compile issue on ICC, of "error #188: enumerated type mixed with
  another type".

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index c61c3a0..f1b92a7 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -75,6 +75,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -740,6 +741,21 @@ static void cmd_help_long_parsed(void *parsed_result,
"flow_director_flex_payload (port_id)"
" (l2|l3|l4) (config)\n"
"Configure flex payload selection.\n\n"
+
+   "get_sym_hash_ena_per_port (port_id)\n"
+   "get symmetric hash enable configuration per 
port.\n\n"
+
+   "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
+   "set symmetric hash enable configuration per port"
+   " to enable or disable.\n\n"
+
+   "get_hash_global_config (port_id)\n"
+   "Get the global configurations of hash filters.\n\n"
+
+   "set_hash_global_config (port_id) 
(toeplitz|simple_xor|default)"
+   " 
(ip4|ip4-frag|tcp4|udp4|#sctp4|ip6|ip6-frag|tcp6|udp6|sctp6)"
+   " (enable|disable)\n"
+   "Set the global configurations of hash filters.\n\n"
);
}
 }
@@ -8697,6 +8713,319 @@ cmdline_parse_inst_t cmd_set_flow_director_flex_payload 
= {
},
 };

+/* *** Classification Filters Control *** */
+/* *** Get symmetric hash enable per port *** */
+struct cmd_get_sym_hash_ena_per_port_result {
+   cmdline_fixed_string_t get_sym_hash_ena_per_port;
+   uint8_t port_id;
+};
+
+static void
+cmd_get_sym_hash_per_port_parsed(void *parsed_result,
+__rte_unused struct cmdline *cl,
+__rte_unused void *data)
+{
+   struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
+   struct rte_eth_hash_filter_info info;
+   int ret;
+
+   if (rte_eth_dev_filter_supported(res->port_id,
+   RTE_ETH_FILTER_HASH) < 0) {
+   printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
+   res->port_id);
+   return;
+   }
+
+   memset(&info, 0, sizeof(info));
+   info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
+   ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+   RTE_ETH_FILTER_GET, &info);
+
+   if (ret < 0) {
+   printf("Cannot get symmetric hash enable per port "
+   "on port %u\n", res->port_id);
+   return;
+   }
+
+   printf("Symmetric hash is %s on port %u\n", info.info.enable ?
+   "enabled" : "disabled", res->port_id);
+}
+
+cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
+   TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
+   get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
+cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
+   .f = cmd_get_sym_hash_per_port_parsed,
+   .data = NULL,
+   .help_str = "get_sym_hash_ena_per_port port_id",
+   .tokens = {
+   (void *)&cmd_get_sym_hash_ena_per_port_all,
+   (void *)&cmd_get_sym_hash_ena_per_port_port_id,
+   NULL,
+   },
+};
+
+/* *** Set symmetric hash enable per port *** */
+struct cmd_set_sym_hash_ena_per_port_result {
+   cmdline_fixed_string_t set_sym_hash_ena_per_port;
+   cmdline_fixed_string_t enable;
+   uint8_t port_id;
+};
+
+static void
+cm

[dpdk-dev] [PATCH v2] i40e: fix of compile error

2014-12-03 Thread Helin Zhang
The compile error will occur as below when set 
'RTE_LIBRTE_I40E_16BYTE_RX_DESC=y'.
'fd_id' should be used to replace 'fd', as 'fd' is not defined in that structure
at all. In addition, local variable of 'flexbl' and 'flexbh' must be used only 
if
32 bytes RX descriptor is selected.

error logs:
lib/librte_pmd_i40e/i40e_rxtx.c: In function i40e_rxd_build_fdir:
lib/librte_pmd_i40e/i40e_rxtx.c:431:28: error: volatile union  has 
no member named fd
lib/librte_pmd_i40e/i40e_rxtx.c:427:19: error: unused variable flexbl 
[-Werror=unused-variable]
lib/librte_pmd_i40e/i40e_rxtx.c:427:11: error: unused variable flexbh 
[-Werror=unused-variable]

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

v2 changes:
* Removed the changes for code style fix, and kept it for compile error fix 
only.
* Re-word the commit logs.

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2d2ef04..63c872d 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -424,13 +424,9 @@ static inline uint64_t
 i40e_rxd_build_fdir(volatile union i40e_rx_desc *rxdp, struct rte_mbuf *mb)
 {
uint64_t flags = 0;
+#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
uint16_t flexbh, flexbl;

-#ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
-   mb->hash.fdir.hi =
-   rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.fd);
-   flags |= PKT_RX_FDIR_ID;
-#else
flexbh = (rte_le_to_cpu_32(rxdp->wb.qword2.ext_status) >>
I40E_RX_DESC_EXT_STATUS_FLEXBH_SHIFT) &
I40E_RX_DESC_EXT_STATUS_FLEXBH_MASK;
@@ -453,6 +449,10 @@ i40e_rxd_build_fdir(volatile union i40e_rx_desc *rxdp, 
struct rte_mbuf *mb)

rte_le_to_cpu_32(rxdp->wb.qword3.lo_dword.flex_bytes_lo);
flags |= PKT_RX_FDIR_FLX;
}
+#else
+   mb->hash.fdir.hi =
+   rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.fd_id);
+   flags |= PKT_RX_FDIR_ID;
 #endif
return flags;
 }
-- 
1.9.3



[dpdk-dev] [PATCH v2 0/2] fix of enabling all newly added error flags

2014-12-05 Thread Helin Zhang
Before redefining mbuf structure, there was lack of free bits in 'ol_flags'
(32 bits in total) for new RX or TX flags. So it tried to reuse existant bits
as most as possible, or even assigning 0 to some of bit flags. After new mbuf
structure defined, there are quite a lot of free bits. So those newly added
bit flags should be assigned with correct and valid bit values, and getting
their names should be enabled as well. Note that 'RECIP' should be removed,
as nowhere will use it.

v2 changes:
* Removed error flag of 'ECIPE' processing only in both i40e PMD and mbuf. All
  other error flags were added back.
* Assigned error flags with correct and valid values, as their previous values
  were invalid.
* Enabled getting all error flag names.

Helin Zhang (2):
  i40e: remove checking rxd flag which is not public
  mbuf: assign valid bit values for some RX and TX flags

 lib/librte_mbuf/rte_mbuf.c  |  9 -
 lib/librte_mbuf/rte_mbuf.h  | 19 +--
 lib/librte_pmd_i40e/i40e_rxtx.c |  6 --
 3 files changed, 13 insertions(+), 21 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH v2 1/2] i40e: remove checking rxd flag which is not public

2014-12-05 Thread Helin Zhang
According to the latest datasheet, RX descriptor error flag of
'RECIPE' is not for public use, so its checks should be removed.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_rxtx.c | 6 --
 1 file changed, 6 deletions(-)

v2 changes:
* Removed error flag of 'ECIPE' processing only in i40e PMD. All other error
  flags were added back.

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 63c872d..7ffe50e 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -126,12 +126,6 @@ i40e_rxd_error_to_pkt_flags(uint64_t qword)
flags |= PKT_RX_MAC_ERR;
return flags;
}
-
-   /* If RECIPE bit set, all other status indications should be ignored */
-   if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_RECIPE_SHIFT))) {
-   flags |= PKT_RX_RECIP_ERR;
-   return flags;
-   }
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_HBO_SHIFT)))
flags |= PKT_RX_HBUF_OVERFLOW;
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_IPE_SHIFT)))
-- 
1.9.3



[dpdk-dev] [PATCH v2 2/2] mbuf: assign valid bit values for some RX and TX flags

2014-12-05 Thread Helin Zhang
Before redefining mbuf structure, there was lack of free bits in
'ol_flags' (32 bits in total) for new RX or TX flags. So it tried
to reuse existant bits as most as possible, or even assigning 0 to
some of bit flags. After new mbuf structure defined, there are
quite a lot of free bits. So those newly added bit flags should be
assigned with correct and valid bit values, and getting their names
should be enabled as well. Note that 'RECIP' should be removed, as
nowhere will use it.

Signed-off-by: Helin Zhang 
---
 lib/librte_mbuf/rte_mbuf.c |  9 -
 lib/librte_mbuf/rte_mbuf.h | 19 +--
 2 files changed, 13 insertions(+), 15 deletions(-)

v2 changes:
* Removed error flag of 'ECIPE' processing only in mbuf. All other error flags
  were added back.
* Assigned error flags with correct and valid values, as their previous values
  were invalid.
* Enabled getting all error flag names.

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 87c2963..3ce7c8d 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -210,11 +210,10 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
case PKT_RX_FDIR: return "PKT_RX_FDIR";
case PKT_RX_L4_CKSUM_BAD: return "PKT_RX_L4_CKSUM_BAD";
case PKT_RX_IP_CKSUM_BAD: return "PKT_RX_IP_CKSUM_BAD";
-   /* case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD"; */
-   /* case PKT_RX_OVERSIZE: return "PKT_RX_OVERSIZE"; */
-   /* case PKT_RX_HBUF_OVERFLOW: return "PKT_RX_HBUF_OVERFLOW"; */
-   /* case PKT_RX_RECIP_ERR: return "PKT_RX_RECIP_ERR"; */
-   /* case PKT_RX_MAC_ERR: return "PKT_RX_MAC_ERR"; */
+   case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD";
+   case PKT_RX_OVERSIZE: return "PKT_RX_OVERSIZE";
+   case PKT_RX_HBUF_OVERFLOW: return "PKT_RX_HBUF_OVERFLOW";
+   case PKT_RX_MAC_ERR: return "PKT_RX_MAC_ERR";
case PKT_RX_IPV4_HDR: return "PKT_RX_IPV4_HDR";
case PKT_RX_IPV4_HDR_EXT: return "PKT_RX_IPV4_HDR_EXT";
case PKT_RX_IPV6_HDR: return "PKT_RX_IPV6_HDR";
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 2e5fce5..c9591c0 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -84,11 +84,6 @@ extern "C" {
 #define PKT_RX_FDIR  (1ULL << 2)  /**< RX packet with FDIR match 
indicate. */
 #define PKT_RX_L4_CKSUM_BAD  (1ULL << 3)  /**< L4 cksum of RX pkt. is not OK. 
*/
 #define PKT_RX_IP_CKSUM_BAD  (1ULL << 4)  /**< IP cksum of RX pkt. is not OK. 
*/
-#define PKT_RX_EIP_CKSUM_BAD (0ULL << 0)  /**< External IP header checksum 
error. */
-#define PKT_RX_OVERSIZE  (0ULL << 0)  /**< Num of desc of an RX pkt 
oversize. */
-#define PKT_RX_HBUF_OVERFLOW (0ULL << 0)  /**< Header buffer overflow. */
-#define PKT_RX_RECIP_ERR (0ULL << 0)  /**< Hardware processing error. */
-#define PKT_RX_MAC_ERR   (0ULL << 0)  /**< MAC error. */
 #define PKT_RX_IPV4_HDR  (1ULL << 5)  /**< RX packet with IPv4 header. */
 #define PKT_RX_IPV4_HDR_EXT  (1ULL << 6)  /**< RX packet with extended IPv4 
header. */
 #define PKT_RX_IPV6_HDR  (1ULL << 7)  /**< RX packet with IPv6 header. */
@@ -99,6 +94,10 @@ extern "C" {
 #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */
 #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. */
 #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if FDIR 
match. */
+#define PKT_RX_EIP_CKSUM_BAD (1ULL << 15)  /**< External IP header checksum 
error. */
+#define PKT_RX_OVERSIZE  (1ULL << 16)  /**< Num of desc of an RX pkt 
oversize. */
+#define PKT_RX_HBUF_OVERFLOW (1ULL << 17)  /**< Header buffer overflow. */
+#define PKT_RX_MAC_ERR   (1ULL << 18)  /**< MAC error. */
 /* add new RX flags here */

 /* add new TX flags here */
@@ -141,13 +140,13 @@ extern "C" {
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */

-/** Tell the NIC it's an IPv4 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV4  PKT_RX_IPV4_HDR
+/** Tell the NIC it's an IPv4 packet. */
+#define PKT_TX_IPV4  (1ULL << 55) /**< TX packet is a IPV4 packet. */

-/** Tell the NIC it's an IPv6 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV6  PKT_RX_IPV6_HDR
+/** Tell the NIC it's an IPv6 packet. */
+#define PKT_TX_IPV6  (1ULL << 56) /**< TX packet is a IPV6 packet. */

-#define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
+#define PKT_TX_VLAN_PKT  (1ULL << 57) /**< TX packet is a VLAN packet. */

 /* Use final bit of flags to indicate a control mbuf */
 #define CTRL_MBUF_FLAG   (1ULL << 63) /**< Mbuf contains control data */
-- 
1.9.3



[dpdk-dev] [PATCH v3] mbuf: fix of enabling all newly added RX error flags

2014-12-06 Thread Helin Zhang
Before redefining mbuf structure, there was lack of free bits in 'ol_flags'
(32 bits in total) for new RX or TX flags. So it tried to reuse existant
bits as most as possible, or even assigning 0 to some of bit flags. After
new mbuf structure defined, there are quite a lot of free bits. So those
newly added bit flags should be assigned with correct and valid bit values,
and getting their names should be enabled as well. Note that 'RECIP' should
be removed, as nowhere will use it. 'PKT_RX_ERR' is defined to replace all
other error bit flags, e.g. MAC error, Oversize error, header buffer
overflow error.

Signed-off-by: Helin Zhang 
---
 lib/librte_mbuf/rte_mbuf.c  |  7 ++-
 lib/librte_mbuf/rte_mbuf.h  |  7 ++-
 lib/librte_pmd_i40e/i40e_rxtx.c | 15 ---
 3 files changed, 8 insertions(+), 21 deletions(-)

v2 changes:
* Removed error flag of 'ECIPE' processing only in both i40e PMD and mbuf. All
  other error flags were added back.
* Assigned error flags with correct and valid values, as their previous values
  were invalid.
* Enabled getting all error flag names.

v3 changes:
* 'PKT_RX_ERR' is defined to replace error bit flags of MAC error, Oversize
  error, header buffer overflow error.
* Removed assigning values to PKT_TX_* bit flags, as it has already been done
  in another packet set.

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 1b14e02..5e6b5d0 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -210,11 +210,8 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
case PKT_RX_FDIR: return "PKT_RX_FDIR";
case PKT_RX_L4_CKSUM_BAD: return "PKT_RX_L4_CKSUM_BAD";
case PKT_RX_IP_CKSUM_BAD: return "PKT_RX_IP_CKSUM_BAD";
-   /* case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD"; */
-   /* case PKT_RX_OVERSIZE: return "PKT_RX_OVERSIZE"; */
-   /* case PKT_RX_HBUF_OVERFLOW: return "PKT_RX_HBUF_OVERFLOW"; */
-   /* case PKT_RX_RECIP_ERR: return "PKT_RX_RECIP_ERR"; */
-   /* case PKT_RX_MAC_ERR: return "PKT_RX_MAC_ERR"; */
+   case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD";
+   case PKT_RX_ERR: return "PKT_RX_ERR";
case PKT_RX_IPV4_HDR: return "PKT_RX_IPV4_HDR";
case PKT_RX_IPV4_HDR_EXT: return "PKT_RX_IPV4_HDR_EXT";
case PKT_RX_IPV6_HDR: return "PKT_RX_IPV6_HDR";
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index efdefc4..5e647a9 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -84,11 +84,6 @@ extern "C" {
 #define PKT_RX_FDIR  (1ULL << 2)  /**< RX packet with FDIR match 
indicate. */
 #define PKT_RX_L4_CKSUM_BAD  (1ULL << 3)  /**< L4 cksum of RX pkt. is not OK. 
*/
 #define PKT_RX_IP_CKSUM_BAD  (1ULL << 4)  /**< IP cksum of RX pkt. is not OK. 
*/
-#define PKT_RX_EIP_CKSUM_BAD (0ULL << 0)  /**< External IP header checksum 
error. */
-#define PKT_RX_OVERSIZE  (0ULL << 0)  /**< Num of desc of an RX pkt 
oversize. */
-#define PKT_RX_HBUF_OVERFLOW (0ULL << 0)  /**< Header buffer overflow. */
-#define PKT_RX_RECIP_ERR (0ULL << 0)  /**< Hardware processing error. */
-#define PKT_RX_MAC_ERR   (0ULL << 0)  /**< MAC error. */
 #define PKT_RX_IPV4_HDR  (1ULL << 5)  /**< RX packet with IPv4 header. */
 #define PKT_RX_IPV4_HDR_EXT  (1ULL << 6)  /**< RX packet with extended IPv4 
header. */
 #define PKT_RX_IPV6_HDR  (1ULL << 7)  /**< RX packet with IPv6 header. */
@@ -99,6 +94,8 @@ extern "C" {
 #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */
 #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. */
 #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if FDIR 
match. */
+#define PKT_RX_EIP_CKSUM_BAD (1ULL << 15)  /**< External IP header checksum 
error. */
+#define PKT_RX_ERR   (1ULL << 16)  /**< Other errors, e.g. MAC error. 
*/
 /* add new RX flags here */

 /* add new TX flags here */
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2beae3c..5d99bd2 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -123,25 +123,18 @@ i40e_rxd_error_to_pkt_flags(uint64_t qword)
return flags;
/* If RXE bit set, all other status bits are meaningless */
if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_RXE_SHIFT))) {
-   flags |= PKT_RX_MAC_ERR;
+   flags |= PKT_RX_ERR;
return flags;
}
-
-   /* If RECIPE bit set, all other status indications should be ignored */
-   if (unlikely(error_bits & (1 

[dpdk-dev] [PATCH] i40e: bug fix of querying reta

2014-12-09 Thread Helin Zhang
There is a bug in querying reta, of storing the data to the correct entry.
Code changes is straightforward for this bug.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 899cb42..008d62c 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1924,7 +1924,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,
lut = I40E_READ_REG(hw, I40E_PFQF_HLUT(i >> 2));
for (j = 0; j < I40E_4_BIT_WIDTH; j++) {
if (mask & (0x1 << j))
-   reta_conf[idx].reta[shift] = ((lut >>
+   reta_conf[idx].reta[shift + j] = ((lut >>
(CHAR_BIT * j)) & I40E_8_BIT_MASK);
}
}
-- 
1.9.3



[dpdk-dev] [PATCH] enic: fix of compile error

2014-12-09 Thread Helin Zhang
Compile warnings/errors was found on gcc 4.7.2 as follows. Variables
was reported of being used but uninitialized. Assigning an initial
value to it is needed.

lib/librte_pmd_enic/vnic/vnic_dev.c: In function vnic_dev_get_mac_addr:
lib/librte_pmd_enic/vnic/vnic_dev.c:393:16: error: a1 may be used uninitialized 
in this function [-Werror=uninitialized]
lib/librte_pmd_enic/vnic/vnic_dev.c:629:10: note: a1 was declared here
lib/librte_pmd_enic/vnic/vnic_dev.c: In function vnic_dev_set_mac_addr:
lib/librte_pmd_enic/vnic/vnic_dev.c:393:16: error: a1 may be used uninitialized 
in this function [-Werror=uninitialized]
lib/librte_pmd_enic/vnic/vnic_dev.c:980:10: note: a1 was declared here

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_enic/vnic/vnic_dev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_enic/vnic/vnic_dev.c 
b/lib/librte_pmd_enic/vnic/vnic_dev.c
index b1cd63f..6407994 100644
--- a/lib/librte_pmd_enic/vnic/vnic_dev.c
+++ b/lib/librte_pmd_enic/vnic/vnic_dev.c
@@ -626,7 +626,7 @@ int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int 
*done)

 int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr)
 {
-   u64 a0, a1;
+   u64 a0, a1 = 0;
int wait = 1000;
int err, i;

@@ -977,7 +977,7 @@ struct rte_pci_device *vnic_dev_get_pdev(struct vnic_dev 
*vdev)

 int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr)
 {
-   u64 a0, a1;
+   u64 a0, a1 = 0;
int wait = 1000;
int i;

-- 
1.8.1.4



[dpdk-dev] [PATCH] igb_uio: kernel version check for using kstrtoul or strict_strtoul

2014-12-10 Thread Helin Zhang
strict_strtoul() was just a redefinition of kstrtoul() for a long
time. From kernel version of 3.18, strict_strtoul() will not be
defined at all. A compile time kernel version check is needed to
decide which function or macro can be used for a specific version
of kernel.

Signed-off-by: Helin Zhang 
---
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c 
b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
index d1ca26e..2fcc5f4 100644
--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
@@ -83,7 +83,11 @@ store_max_vfs(struct device *dev, struct device_attribute 
*attr,
unsigned long max_vfs;
struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);

+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
if (0 != strict_strtoul(buf, 0, &max_vfs))
+#else
+   if (0 != kstrtoul(buf, 0, &max_vfs))
+#endif
return -EINVAL;

if (0 == max_vfs)
-- 
1.9.3



[dpdk-dev] [PATCH v2] i40e: bug fix of querying reta

2014-12-10 Thread Helin Zhang
There is a bug in querying reta, of storing the data to the correct entry.
Code changes is straightforward for this bug.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c| 2 +-
 lib/librte_pmd_i40e/i40e_ethdev_vf.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

v2 changes:
* Added the fix for the same issue in i40e VF driver.

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 899cb42..008d62c 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1924,7 +1924,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,
lut = I40E_READ_REG(hw, I40E_PFQF_HLUT(i >> 2));
for (j = 0; j < I40E_4_BIT_WIDTH; j++) {
if (mask & (0x1 << j))
-   reta_conf[idx].reta[shift] = ((lut >>
+   reta_conf[idx].reta[shift + j] = ((lut >>
(CHAR_BIT * j)) & I40E_8_BIT_MASK);
}
}
diff --git a/lib/librte_pmd_i40e/i40e_ethdev_vf.c 
b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
index 7ef7d58..fe46cf1 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev_vf.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev_vf.c
@@ -1760,7 +1760,7 @@ i40evf_dev_rss_reta_query(struct rte_eth_dev *dev,
lut = I40E_READ_REG(hw, I40E_VFQF_HLUT(i >> 2));
for (j = 0; j < I40E_4_BIT_WIDTH; j++) {
if (mask & (0x1 << j))
-   reta_conf[idx].reta[shift] =
+   reta_conf[idx].reta[shift + j] =
((lut >> (CHAR_BIT * j)) &
I40E_8_BIT_MASK);
}
-- 
1.9.3



[dpdk-dev] [PATCH v4] mbuf: fix of enabling all newly added RX error flags

2014-12-10 Thread Helin Zhang
Before redefining mbuf structure, there was lack of free bits in 'ol_flags'
(32 bits in total) for new RX or TX flags. So it tried to reuse existant
bits as most as possible, or even assigning 0 to some of bit flags. After
new mbuf structure defined, there are quite a lot of free bits. So those
newly added bit flags should be assigned with correct and valid bit values,
and getting their names should be enabled as well. Note that 'RECIP' should
be removed, as nowhere uses it. 'PKT_RX_ERR' is defined to replace all other
error bit flags, e.g. MAC error, Oversize error, header buffer overflow error.

Signed-off-by: Helin Zhang 
---
 lib/librte_mbuf/rte_mbuf.c  |  7 ++-
 lib/librte_mbuf/rte_mbuf.h  |  9 +++--
 lib/librte_pmd_i40e/i40e_rxtx.c | 37 -
 3 files changed, 25 insertions(+), 28 deletions(-)

v2 changes:
* Removed error flag of 'ECIPE' processing only in both i40e PMD and mbuf. All
  other error flags were added back.
* Assigned error flags with correct and valid values, as their previous values
  were invalid.
* Enabled getting all error flag names.

v3 changes:
* 'PKT_RX_ERR' is defined to replace error bit flags of MAC error, Oversize
  error, header buffer overflow error.
* Removed assigning values to PKT_TX_* bit flags, as it has already been done
  in another packet set.

v4 changes:
* Renamed 'PKT_RX_EIP_CKSUM_BAD' to 'PKT_RX_OUTER_IP_CKSUM_BAD'.
* Fixed the bug of checking error bits of 'Descriptor oversize' and
  'Header buffer oversize'.
* Added debug logs for each RX error.

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 1b14e02..7611a38 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -210,11 +210,8 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
case PKT_RX_FDIR: return "PKT_RX_FDIR";
case PKT_RX_L4_CKSUM_BAD: return "PKT_RX_L4_CKSUM_BAD";
case PKT_RX_IP_CKSUM_BAD: return "PKT_RX_IP_CKSUM_BAD";
-   /* case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD"; */
-   /* case PKT_RX_OVERSIZE: return "PKT_RX_OVERSIZE"; */
-   /* case PKT_RX_HBUF_OVERFLOW: return "PKT_RX_HBUF_OVERFLOW"; */
-   /* case PKT_RX_RECIP_ERR: return "PKT_RX_RECIP_ERR"; */
-   /* case PKT_RX_MAC_ERR: return "PKT_RX_MAC_ERR"; */
+   case PKT_RX_OUTER_IP_CKSUM_BAD: return "PKT_RX_OUTER_IP_CKSUM_BAD";
+   case PKT_RX_ERR: return "PKT_RX_ERR";
case PKT_RX_IPV4_HDR: return "PKT_RX_IPV4_HDR";
case PKT_RX_IPV4_HDR_EXT: return "PKT_RX_IPV4_HDR_EXT";
case PKT_RX_IPV6_HDR: return "PKT_RX_IPV6_HDR";
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index efdefc4..eefe8a6 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -83,12 +83,7 @@ extern "C" {
 #define PKT_RX_RSS_HASH  (1ULL << 1)  /**< RX packet with RSS hash result. 
*/
 #define PKT_RX_FDIR  (1ULL << 2)  /**< RX packet with FDIR match 
indicate. */
 #define PKT_RX_L4_CKSUM_BAD  (1ULL << 3)  /**< L4 cksum of RX pkt. is not OK. 
*/
-#define PKT_RX_IP_CKSUM_BAD  (1ULL << 4)  /**< IP cksum of RX pkt. is not OK. 
*/
-#define PKT_RX_EIP_CKSUM_BAD (0ULL << 0)  /**< External IP header checksum 
error. */
-#define PKT_RX_OVERSIZE  (0ULL << 0)  /**< Num of desc of an RX pkt 
oversize. */
-#define PKT_RX_HBUF_OVERFLOW (0ULL << 0)  /**< Header buffer overflow. */
-#define PKT_RX_RECIP_ERR (0ULL << 0)  /**< Hardware processing error. */
-#define PKT_RX_MAC_ERR   (0ULL << 0)  /**< MAC error. */
+#define PKT_RX_IP_CKSUM_BAD  (1ULL << 4)  /**< IP (or inner IP) header 
checksum error. */
 #define PKT_RX_IPV4_HDR  (1ULL << 5)  /**< RX packet with IPv4 header. */
 #define PKT_RX_IPV4_HDR_EXT  (1ULL << 6)  /**< RX packet with extended IPv4 
header. */
 #define PKT_RX_IPV6_HDR  (1ULL << 7)  /**< RX packet with IPv6 header. */
@@ -99,6 +94,8 @@ extern "C" {
 #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */
 #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. */
 #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if FDIR 
match. */
+#define PKT_RX_OUTER_IP_CKSUM_BAD (1ULL << 15)  /**< Outer IP header checksum 
error. */
+#define PKT_RX_ERR   (1ULL << 16)  /**< Other errors, e.g. MAC error. 
*/
 /* add new RX flags here */

 /* add new TX flags here */
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2beae3c..43f67c3 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -68

[dpdk-dev] [PATCH] i40e: workaround for X710 performance issues

2014-12-15 Thread Helin Zhang
As the fixes of below performance issues on X710 may not be integrated
in latest version of firmware, a workaround in software PMD is needed.
It is to re-configure 3 specific registers after being initialized.
- Cannot achieve line rate on X710.
- Performance reduction when promiscuous mode is disabled.
Note that this workaround can be removed if the fixes are integrated
in the firmware in future.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 87 +++
 1 file changed, 87 insertions(+)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 008d62c..adaab93 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -198,6 +198,7 @@ static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_type filter_type,
enum rte_filter_op filter_op,
void *arg);
+static void i40e_configure_registers(struct i40e_hw *hw);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_PFQF_HKEY_MAX_INDEX + 1];
@@ -443,6 +444,15 @@ eth_i40e_dev_init(__rte_unused struct eth_driver *eth_drv,
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

+   /*
+* On X710, as old version of firmwares may have performance issues,
+* 3 registers need to be re-configured with new values. And the latest
+* version of firmware may not contain the fixes, workaround in SW
+* driver is needed. This workaround can be removed when the fixes are
+* integrated in firmware in future.
+*/
+   i40e_configure_registers(hw);
+
/* Get hw capabilities */
ret = i40e_get_cap(hw);
if (ret != I40E_SUCCESS) {
@@ -5294,3 +5304,80 @@ i40e_pctype_to_flowtype(enum i40e_filter_pctype pctype)

return flowtype_table[pctype];
 }
+
+static int
+i40e_debug_read_register(struct i40e_hw *hw, uint32_t addr, uint64_t *val)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_debug_reg_read_write *cmd =
+   (struct i40e_aqc_debug_reg_read_write *)&desc.params.raw;
+   enum i40e_status_code status;
+
+   i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_read_reg);
+   cmd->address = rte_cpu_to_le_32(addr);
+   status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
+   if (status < 0)
+   return status;
+
+   *val = ((uint64_t)(rte_le_to_cpu_32(cmd->value_high)) << (CHAR_BIT *
+   sizeof(uint32_t))) + rte_le_to_cpu_32(cmd->value_low);
+
+   return status;
+}
+
+/*
+ * On X710, as old version of firmwares may have performance issues,
+ * 3 registers need to be re-configured with new values. And the latest version
+ * of firmware may not contain the fixes, workaround in SW driver is needed.
+ * This workaround can be removed when the fixes are integrated in firmware in
+ * future.
+ */
+static void
+i40e_configure_registers(struct i40e_hw *hw)
+{
+#define I40E_GL_SWR_PRI_JOIN_MAP_0   0x26CE00
+#define I40E_GL_SWR_PRI_JOIN_MAP_2   0x26CE08
+#define I40E_GL_SWR_PM_UP_THR0x269FBC
+#define I40E_GL_SWR_PRI_JOIN_MAP_0_VALUE 0x1200
+#define I40E_GL_SWR_PRI_JOIN_MAP_2_VALUE 0x011f0200
+#define I40E_GL_SWR_PM_UP_THR_VALUE  0x03030303
+
+   static const struct {
+   uint32_t addr;
+   uint64_t val;
+   } reg_table[] = {
+   {I40E_GL_SWR_PRI_JOIN_MAP_0, I40E_GL_SWR_PRI_JOIN_MAP_0_VALUE},
+   {I40E_GL_SWR_PRI_JOIN_MAP_2, I40E_GL_SWR_PRI_JOIN_MAP_2_VALUE},
+   {I40E_GL_SWR_PM_UP_THR, I40E_GL_SWR_PM_UP_THR_VALUE},
+   };
+   uint64_t reg;
+   uint32_t i;
+   int ret;
+
+   /* Below fix is for X710 only */
+   if (i40e_is_40G_device(hw->device_id))
+   return;
+
+   for (i = 0; i < RTE_DIM(reg_table); i++) {
+   ret = i40e_debug_read_register(hw, reg_table[i].addr, ®);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to read from 0x%x\n",
+   reg_table[i].addr);
+   break;
+   }
+   PMD_DRV_LOG(DEBUG, "Read from 0x%x: 0x%lx", reg_table[i].addr,
+   reg);
+   if (reg == reg_table[i].val)
+   continue;
+
+   ret = i40e_aq_debug_write_register(hw, reg_table[i].addr,
+   reg_table[i].val, NULL);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to write 0x%x to 0x%x\n",
+   reg_table[i].val, reg_table[i].addr);
+   break;
+   }
+   

[dpdk-dev] [PATCH v2] i40e: workaround for X710 performance issues

2014-12-15 Thread Helin Zhang
As the fixes of below performance issues on X710 may not be integrated
in latest version of firmware, a workaround in software PMD is needed.
It is to re-configure 3 specific registers after being initialized.
- Cannot achieve line rate on X710.
- Performance reduction when promiscuous mode is disabled.
Note that this workaround can be removed if the fixes are integrated
in the firmware in future.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 87 +++
 1 file changed, 87 insertions(+)

v2 changes:
* Added a compile error fix.

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 008d62c..82c072b 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -198,6 +198,7 @@ static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_type filter_type,
enum rte_filter_op filter_op,
void *arg);
+static void i40e_configure_registers(struct i40e_hw *hw);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_PFQF_HKEY_MAX_INDEX + 1];
@@ -443,6 +444,15 @@ eth_i40e_dev_init(__rte_unused struct eth_driver *eth_drv,
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

+   /*
+* On X710, as old version of firmwares may have performance issues,
+* 3 registers need to be re-configured with new values. And the latest
+* version of firmware may not contain the fixes, workaround in SW
+* driver is needed. This workaround can be removed when the fixes are
+* integrated in firmware in future.
+*/
+   i40e_configure_registers(hw);
+
/* Get hw capabilities */
ret = i40e_get_cap(hw);
if (ret != I40E_SUCCESS) {
@@ -5294,3 +5304,80 @@ i40e_pctype_to_flowtype(enum i40e_filter_pctype pctype)

return flowtype_table[pctype];
 }
+
+static int
+i40e_debug_read_register(struct i40e_hw *hw, uint32_t addr, uint64_t *val)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_debug_reg_read_write *cmd =
+   (struct i40e_aqc_debug_reg_read_write *)&desc.params.raw;
+   enum i40e_status_code status;
+
+   i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_read_reg);
+   cmd->address = rte_cpu_to_le_32(addr);
+   status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
+   if (status < 0)
+   return status;
+
+   *val = ((uint64_t)(rte_le_to_cpu_32(cmd->value_high)) << (CHAR_BIT *
+   sizeof(uint32_t))) + rte_le_to_cpu_32(cmd->value_low);
+
+   return status;
+}
+
+/*
+ * On X710, as old version of firmwares may have performance issues,
+ * 3 registers need to be re-configured with new values. And the latest version
+ * of firmware may not contain the fixes, workaround in SW driver is needed.
+ * This workaround can be removed when the fixes are integrated in firmware in
+ * future.
+ */
+static void
+i40e_configure_registers(struct i40e_hw *hw)
+{
+#define I40E_GL_SWR_PRI_JOIN_MAP_0   0x26CE00
+#define I40E_GL_SWR_PRI_JOIN_MAP_2   0x26CE08
+#define I40E_GL_SWR_PM_UP_THR0x269FBC
+#define I40E_GL_SWR_PRI_JOIN_MAP_0_VALUE 0x1200
+#define I40E_GL_SWR_PRI_JOIN_MAP_2_VALUE 0x011f0200
+#define I40E_GL_SWR_PM_UP_THR_VALUE  0x03030303
+
+   static const struct {
+   uint32_t addr;
+   uint64_t val;
+   } reg_table[] = {
+   {I40E_GL_SWR_PRI_JOIN_MAP_0, I40E_GL_SWR_PRI_JOIN_MAP_0_VALUE},
+   {I40E_GL_SWR_PRI_JOIN_MAP_2, I40E_GL_SWR_PRI_JOIN_MAP_2_VALUE},
+   {I40E_GL_SWR_PM_UP_THR, I40E_GL_SWR_PM_UP_THR_VALUE},
+   };
+   uint64_t reg;
+   uint32_t i;
+   int ret;
+
+   /* Below fix is for X710 only */
+   if (i40e_is_40G_device(hw->device_id))
+   return;
+
+   for (i = 0; i < RTE_DIM(reg_table); i++) {
+   ret = i40e_debug_read_register(hw, reg_table[i].addr, ®);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to read from 0x%x\n",
+   reg_table[i].addr);
+   break;
+   }
+   PMD_DRV_LOG(DEBUG, "Read from 0x%x: 0x%lx", reg_table[i].addr,
+   reg);
+   if (reg == reg_table[i].val)
+   continue;
+
+   ret = i40e_aq_debug_write_register(hw, reg_table[i].addr,
+   reg_table[i].val, NULL);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to write 0x%lx to 0x%x\n",
+   reg_table[i].val, reg_table[i].addr);
+   break;
+   }
+   

[dpdk-dev] [PATCH v3] i40e: workaround for X710 performance issues

2014-12-16 Thread Helin Zhang
On X710, performance number is far from the expectation on recent
firmware versions. The fix for this issue may not be integrated in
the following firmware version. So the workaround in software driver
is needed. It needs to modify the initial values of 3 internal only
registers. Note that the workaround can be removed when it is fixed
in firmware in the future.

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 89 +++
 1 file changed, 89 insertions(+)

v2 changes:
* Added a compile error fix.

v3 changes:
* Used PRIx32 and PRIx64 instead for printing uint32_t and uint64_t
  variables.
* Re-worded annotations, and commit logs.

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 008d62c..624f0ce 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -198,6 +198,7 @@ static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_type filter_type,
enum rte_filter_op filter_op,
void *arg);
+static void i40e_configure_registers(struct i40e_hw *hw);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_PFQF_HKEY_MAX_INDEX + 1];
@@ -443,6 +444,16 @@ eth_i40e_dev_init(__rte_unused struct eth_driver *eth_drv,
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

+   /*
+* On X710, performance number is far from the expectation on recent
+* firmware versions. The fix for this issue may not be integrated in
+* the following firmware version. So the workaround in software driver
+* is needed. It needs to modify the initial values of 3 internal only
+* registers. Note that the workaround can be removed when it is fixed
+* in firmware in the future.
+*/
+   i40e_configure_registers(hw);
+
/* Get hw capabilities */
ret = i40e_get_cap(hw);
if (ret != I40E_SUCCESS) {
@@ -5294,3 +5305,81 @@ i40e_pctype_to_flowtype(enum i40e_filter_pctype pctype)

return flowtype_table[pctype];
 }
+
+static int
+i40e_debug_read_register(struct i40e_hw *hw, uint32_t addr, uint64_t *val)
+{
+   struct i40e_aq_desc desc;
+   struct i40e_aqc_debug_reg_read_write *cmd =
+   (struct i40e_aqc_debug_reg_read_write *)&desc.params.raw;
+   enum i40e_status_code status;
+
+   i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_read_reg);
+   cmd->address = rte_cpu_to_le_32(addr);
+   status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
+   if (status < 0)
+   return status;
+
+   *val = ((uint64_t)(rte_le_to_cpu_32(cmd->value_high)) << (CHAR_BIT *
+   sizeof(uint32_t))) + rte_le_to_cpu_32(cmd->value_low);
+
+   return status;
+}
+
+/*
+ * On X710, performance number is far from the expectation on recent firmware
+ * versions. The fix for this issue may not be integrated in the following
+ * firmware version. So the workaround in software driver is needed. It needs
+ * to modify the initial values of 3 internal only registers. Note that the
+ * workaround can be removed when it is fixed in firmware in the future.
+ */
+static void
+i40e_configure_registers(struct i40e_hw *hw)
+{
+#define I40E_GL_SWR_PRI_JOIN_MAP_0   0x26CE00
+#define I40E_GL_SWR_PRI_JOIN_MAP_2   0x26CE08
+#define I40E_GL_SWR_PM_UP_THR0x269FBC
+#define I40E_GL_SWR_PRI_JOIN_MAP_0_VALUE 0x1200
+#define I40E_GL_SWR_PRI_JOIN_MAP_2_VALUE 0x011f0200
+#define I40E_GL_SWR_PM_UP_THR_VALUE  0x03030303
+
+   static const struct {
+   uint32_t addr;
+   uint64_t val;
+   } reg_table[] = {
+   {I40E_GL_SWR_PRI_JOIN_MAP_0, I40E_GL_SWR_PRI_JOIN_MAP_0_VALUE},
+   {I40E_GL_SWR_PRI_JOIN_MAP_2, I40E_GL_SWR_PRI_JOIN_MAP_2_VALUE},
+   {I40E_GL_SWR_PM_UP_THR, I40E_GL_SWR_PM_UP_THR_VALUE},
+   };
+   uint64_t reg;
+   uint32_t i;
+   int ret;
+
+   /* Below fix is for X710 only */
+   if (i40e_is_40G_device(hw->device_id))
+   return;
+
+   for (i = 0; i < RTE_DIM(reg_table); i++) {
+   ret = i40e_debug_read_register(hw, reg_table[i].addr, ®);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to read from 0x%"PRIx32,
+   reg_table[i].addr);
+   break;
+   }
+   PMD_DRV_LOG(DEBUG, "Read from 0x%"PRIx32": 0x%"PRIx64,
+   reg_table[i].addr, reg);
+   if (reg == reg_table[i].val)
+   continue;
+
+   ret = i40e_aq_debug_write_register(hw, reg_table[i].addr,
+   reg_table[i].val, NULL);
+

[dpdk-dev] [PATCH] i40e: fix of compile errors

2014-12-17 Thread Helin Zhang
Compile warning which is treated as error occurs on Oracle Linux
(kernel 2.6.39, gcc 4.4.7) as below. Aliasing
'struct i40e_aqc_debug_reg_read_write' should be avoided. Use the
elements inside that structure directly can fix the issue.

lib/librte_pmd_i40e/i40e_ethdev.c: In function 'eth_i40e_dev_init':
lib/librte_pmd_i40e/i40e_ethdev.c:5318: error: dereferencing pointer
  'cmd' does break strict-aliasing rules
lib/librte_pmd_i40e/i40e_ethdev.c:5314: note: initialized from here

Signed-off-by: Helin Zhang 
---
 lib/librte_pmd_i40e/i40e_ethdev.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 624f0ce..b47a3d2 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -5310,18 +5310,17 @@ static int
 i40e_debug_read_register(struct i40e_hw *hw, uint32_t addr, uint64_t *val)
 {
struct i40e_aq_desc desc;
-   struct i40e_aqc_debug_reg_read_write *cmd =
-   (struct i40e_aqc_debug_reg_read_write *)&desc.params.raw;
enum i40e_status_code status;

i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_debug_read_reg);
-   cmd->address = rte_cpu_to_le_32(addr);
+   desc.params.internal.param1 = rte_cpu_to_le_32(addr);
status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);
if (status < 0)
return status;

-   *val = ((uint64_t)(rte_le_to_cpu_32(cmd->value_high)) << (CHAR_BIT *
-   sizeof(uint32_t))) + rte_le_to_cpu_32(cmd->value_low);
+   *val = ((uint64_t)(rte_le_to_cpu_32(desc.params.internal.param2)) <<
+   (CHAR_BIT * sizeof(uint32_t))) +
+   rte_le_to_cpu_32(desc.params.internal.param3);

return status;
 }
-- 
1.8.1.4



[dpdk-dev] [PATCH RFC 1/7] app/test-pmd: code style fix

2014-12-19 Thread Helin Zhang
Added code style fixes.

Signed-off-by: Helin Zhang 
---
 app/test-pmd/config.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 97b6525..87dedf9 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1918,11 +1918,11 @@ fdir_get_infos(portid_t port_id)
   fdir_stats_border, port_id, fdir_stats_border);
printf("  MODE: ");
if (fdir_info.mode == RTE_FDIR_MODE_PERFECT)
-   printf("  PERFECT\n");
+   printf("  PERFECT\n");
else if (fdir_info.mode == RTE_FDIR_MODE_SIGNATURE)
-   printf("  SIGNATURE\n");
+   printf("  SIGNATURE\n");
else
-   printf("  DISABLE\n");
+   printf("  DISABLE\n");
printf("  SUPPORTED FLOW TYPE: ");
print_fdir_flow_type(fdir_info.flow_types_mask[0]);
printf("  FLEX PAYLOAD INFO:\n");
-- 
1.9.3



[dpdk-dev] [PATCH RFC 2/7] ethdev: code style fix

2014-12-19 Thread Helin Zhang
Added code style fixes.

Signed-off-by: Helin Zhang 
---
 lib/librte_ether/rte_eth_ctrl.h | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 5d9c387..4308eae 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -406,29 +406,29 @@ enum rte_fdir_mode {
  * It can be gotten to help taking specific configurations per device.
  */
 struct rte_eth_fdir_info {
-   enum rte_fdir_mode mode; /**< Flow director mode */
+   enum rte_fdir_mode mode; /**< Flow director mode */
+   /** Flex payload configuration information */
struct rte_eth_fdir_flex_conf flex_conf;
-   /**< Flex payload configuration information */
-   uint32_t guarant_spc;  /**< Guaranteed spaces.*/
-   uint32_t best_spc; /**< Best effort spaces.*/
+   uint32_t guarant_spc; /**< Guaranteed spaces.*/
+   uint32_t best_spc; /**< Best effort spaces.*/
+   /** Bit mask for every supported flow type. */
uint32_t flow_types_mask[RTE_ETH_FLOW_TYPE_MAX / sizeof(uint32_t)];
-   /**< Bit mask for every supported flow type. */
-   uint32_t max_flexpayload;  /**< Total flex payload in bytes. */
+   uint32_t max_flexpayload; /**< Total flex payload in bytes. */
+   /** Flexible payload unit in bytes. Size and alignments of all flex
+   payload segments should be multiplies of this value. */
uint32_t flex_payload_unit;
-   /**< Flexible payload unit in bytes. Size and alignments of all flex
-payload segments should be multiplies of this value. */
+   /** Max number of flexible payload continuous segments.
+   Each segment should be a multiple of flex_payload_unit.*/
uint32_t max_flex_payload_segment_num;
-   /**< Max number of flexible payload continuous segments.
-Each segment should be a multiple of flex_payload_unit.*/
+   /** Maximum src_offset in bytes allowed. It indicates that
+   src_offset[i] in struct rte_eth_flex_payload_cfg should be less
+   than this value. */
uint16_t flex_payload_limit;
-   /**< Maximum src_offset in bytes allowed. It indicates that
-src_offset[i] in struct rte_eth_flex_payload_cfg should be
-less than this value. */
+   /** Flex bitmask unit in bytes. Size of flex bitmasks should be a
+   multiply of this value. */
uint32_t flex_bitmask_unit;
-   /**< Flex bitmask unit in bytes. Size of flex bitmasks should
-be a multiply of this value. */
+   /** Max supported size of flex bitmasks in flex_bitmask_unit */
uint32_t max_flex_bitmask_num;
-   /**< Max supported size of flex bitmasks in flex_bitmask_unit */
 };

 /**
-- 
1.9.3



[dpdk-dev] [PATCH RFC 4/7] ethdev: fix of calculating the size of flow type mask array

2014-12-19 Thread Helin Zhang
It wrongly calculates the size of the flow type mask array. The fix
is to align the flow type maximum index ID with the number of
element bit width, and then divide the number of element bit width.

Signed-off-by: Helin Zhang 
---
 lib/librte_ether/rte_eth_ctrl.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 4308eae..1c15ed0 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -398,6 +398,10 @@ enum rte_fdir_mode {
RTE_FDIR_MODE_PERFECT,   /**< Enable FDIR perfect filter mode. */
 };

+#define UINT32_BIT (CHAR_BIT * sizeof(uint32_t))
+#define RTE_FLOW_TYPE_MASK_ARRAY_SIZE \
+   (RTE_ALIGN(RTE_ETH_FLOW_TYPE_MAX, UINT32_BIT)/UINT32_BIT)
+
 /**
  * A structure used to get the information of flow director filter.
  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_INFO operation.
@@ -412,7 +416,7 @@ struct rte_eth_fdir_info {
uint32_t guarant_spc; /**< Guaranteed spaces.*/
uint32_t best_spc; /**< Best effort spaces.*/
/** Bit mask for every supported flow type. */
-   uint32_t flow_types_mask[RTE_ETH_FLOW_TYPE_MAX / sizeof(uint32_t)];
+   uint32_t flow_types_mask[RTE_FLOW_TYPE_MASK_ARRAY_SIZE];
uint32_t max_flexpayload; /**< Total flex payload in bytes. */
/** Flexible payload unit in bytes. Size and alignments of all flex
payload segments should be multiplies of this value. */
-- 
1.9.3



[dpdk-dev] [PATCH RFC 5/7] ethdev: unification of flow types

2014-12-19 Thread Helin Zhang
Flow types was defined actually for i40e hardware specifically,
and wasn't able to be used for defining RSS offload types of all
PMDs. It removed the enum flow types, and uses macros instead
with new names. The new macros can be used for defining RSS
offload types later. Also modifications are made in i40e and
testpmd accordingly.

Signed-off-by: Helin Zhang 
---
 app/test-pmd/cmdline.c| 88 ---
 app/test-pmd/config.c | 71 +--
 lib/librte_ether/rte_eth_ctrl.h   | 55 ++--
 lib/librte_pmd_i40e/i40e_ethdev.c | 68 +-
 lib/librte_pmd_i40e/i40e_ethdev.h | 34 +++
 lib/librte_pmd_i40e/i40e_fdir.c   | 84 ++---
 6 files changed, 235 insertions(+), 165 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 882a5a2..e7bab0c 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -707,7 +707,7 @@ static void cmd_help_long_parsed(void *parsed_result,
"get info of a flex filter.\n\n"

"flow_director_filter (port_id) (add|del)"
-   " flow (ip4|ip4-frag|ip6|ip6-frag)"
+   " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
" src (src_ip_address) dst (dst_ip_address)"
" flexbytes (flexbytes_value)"
" (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
@@ -733,7 +733,8 @@ static void cmd_help_long_parsed(void *parsed_result,
"Flush all flow director entries of a device.\n\n"

"flow_director_flex_mask (port_id)"
-   " flow 
(ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
+   " flow 
(ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
+   "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|all)"
" (mask)\n"
"Configure mask of flex payload.\n\n"

@@ -8158,31 +8159,34 @@ parse_flexbytes(const char *q_arg, uint8_t *flexbytes, 
uint16_t max_num)
return ret;
 }

-static enum rte_eth_flow_type
+static uint16_t
 str2flowtype(char *string)
 {
uint8_t i = 0;
static const struct {
char str[32];
-   enum rte_eth_flow_type type;
+   uint16_t type;
} flowtype_str[] = {
-   {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
-   {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
-   {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
-   {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
-   {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
-   {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
-   {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
-   {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
-   {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
-   {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
+   {"ipv4", ETH_FLOW_TYPE_IPV4},
+   {"ipv4-frag", ETH_FLOW_TYPE_FRAG_IPV4},
+   {"ipv4-tcp", ETH_FLOW_TYPE_NONFRAG_IPV4_TCP},
+   {"ipv4-udp", ETH_FLOW_TYPE_NONFRAG_IPV4_UDP},
+   {"ipv4-sctp", ETH_FLOW_TYPE_NONFRAG_IPV4_SCTP},
+   {"ipv4-other", ETH_FLOW_TYPE_NONFRAG_IPV4_OTHER},
+   {"ipv6", ETH_FLOW_TYPE_IPV6},
+   {"ipv6-frag", ETH_FLOW_TYPE_FRAG_IPV6},
+   {"ipv6-tcp", ETH_FLOW_TYPE_NONFRAG_IPV6_TCP},
+   {"ipv6-udp", ETH_FLOW_TYPE_NONFRAG_IPV6_UDP},
+   {"ipv6-sctp", ETH_FLOW_TYPE_NONFRAG_IPV6_SCTP},
+   {"ipv6-other", ETH_FLOW_TYPE_NONFRAG_IPV6_OTHER},
+   {"l2_payload", ETH_FLOW_TYPE_L2_PAYLOAD},
};

for (i = 0; i < RTE_DIM(flowtype_str); i++) {
if (!strcmp(flowtype_str[i].str, string))
return flowtype_str[i].type;
}
-   return RTE_ETH_FLOW_TYPE_NONE;
+   return ETH_FLOW_TYPE_UNKNOWN;
 }

 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
@@ -8235,9 +8239,9 @@ cmd_flow_director_filter_parsed(void *parsed_result,

entry.input.flow_type = str2flowtype(res->flow_type);
switch (entry.input.flow_type) {
-   case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
-   case RTE_ETH_FLOW_TYPE_UDPV4:
-   case RTE_ETH_FLOW_TYPE_TCPV4:
+   case ETH_FLOW_TYPE_NONFRAG_IPV4_OTHER:
+   case ETH_FLOW_TYPE_NONFRAG_IPV4_UDP:
+   case ETH_FLOW_TYPE_NONFRAG_IPV4_TCP:
IPV4_ADDR_TO_UINT(res-&g

  1   2   3   4   5   6   7   8   9   10   >