[dpdk-dev] [PATCH 2/2] examples/tep_term: Fix packet len for multi-seg mbuf

2016-10-18 Thread Michael Qiu
For multi-seg mbuf, ip->total_length should be pkt_len subtract
ether len.

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

Signed-off-by: Michael Qiu 
---
 examples/tep_termination/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/tep_termination/vxlan.c b/examples/tep_termination/vxlan.c
index b57f867..9142c8d 100644
--- a/examples/tep_termination/vxlan.c
+++ b/examples/tep_termination/vxlan.c
@@ -218,7 +218,7 @@ encapsulation(struct rte_mbuf *m, uint8_t queue_id)
/* copy in IP header */
ip = rte_memcpy(ip, _ip_hdr[vport_id],
sizeof(struct ipv4_hdr));
-   ip->total_length = rte_cpu_to_be_16(m->data_len
+   ip->total_length = rte_cpu_to_be_16(m->pkt_len
- sizeof(struct ether_hdr));

/* outer IP checksum */
-- 
1.8.3.1



[dpdk-dev] [PATCH 1/2] examples/tep_term: Fix l4_len issue

2016-10-18 Thread Michael Qiu
l4_len is not fixed, althrough mostly it is a fixed value,
but when guest using iperf to do some tests, the l4_len
will have another 12 bytes optional fields.

Fixes: 2bb43bd4350a("examples/tep_term: add TSO offload configuration")

Signed-off-by: Michael Qiu 
---
 examples/tep_termination/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/tep_termination/vxlan.c b/examples/tep_termination/vxlan.c
index 5ee1f95..b57f867 100644
--- a/examples/tep_termination/vxlan.c
+++ b/examples/tep_termination/vxlan.c
@@ -147,7 +147,7 @@ process_inner_cksums(struct ether_hdr *eth_hdr, union 
tunnel_offload_info *info)
if (tso_segsz != 0) {
ol_flags |= PKT_TX_TCP_SEG;
info->tso_segsz = tso_segsz;
-   info->l4_len = sizeof(struct tcp_hdr);
+   info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
}

} else if (l4_proto == IPPROTO_SCTP) {
-- 
1.8.3.1



[dpdk-dev] [PATCH 1/2 v2] lib/librte_lpm: Fix anonymous union initialization issue

2016-03-30 Thread Michael Qiu
In SUSE11-SP3 i686 platform, with gcc 4.5.1, there is a
compile issue:
rte_lpm.c: In function ?add_depth_small_v20?:
rte_lpm.c:778:7: error: unknown field ?next_hop?
specified in initializer
cc1: warnings being treated as errors
The root casue is gcc only allow anonymous union initialized
according to the field it is defined. But next_hop is defined
in different field when in different platform(Endian).

One solution is add if define in the code to avoid this issue,
but there is a simple way, initialize it separately later.

Fixes: afc5c914a083 ("lpm: fix big endian support")

Signed-off-by: Michael Qiu 
---
v2 --> v1:
Fixes whilespace issue around "="

 lib/librte_lpm/rte_lpm.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index af5811c..efd507e 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -744,11 +744,11 @@ add_depth_small_v20(struct rte_lpm_v20 *lpm, uint32_t ip, 
uint8_t depth,
lpm->tbl24[i].depth <= depth)) {

struct rte_lpm_tbl_entry_v20 new_tbl24_entry = {
-   { .next_hop = next_hop, },
.valid = VALID,
.valid_group = 0,
.depth = depth,
};
+   new_tbl24_entry.next_hop = next_hop;

/* Setting tbl24 entry in one go to avoid race
 * conditions
@@ -775,8 +775,8 @@ add_depth_small_v20(struct rte_lpm_v20 *lpm, uint32_t ip, 
uint8_t depth,
.valid = VALID,
.valid_group = VALID,
.depth = depth,
-   .next_hop = next_hop,
};
+   new_tbl8_entry.next_hop = next_hop;

/*
 * Setting tbl8 entry in one go to avoid
@@ -975,10 +975,9 @@ add_depth_big_v20(struct rte_lpm_v20 *lpm, uint32_t 
ip_masked, uint8_t depth,
struct rte_lpm_tbl_entry_v20 new_tbl8_entry = {
.valid = VALID,
.depth = depth,
-   .next_hop = next_hop,
.valid_group = lpm->tbl8[i].valid_group,
};
-
+   new_tbl8_entry.next_hop = next_hop;
/*
 * Setting tbl8 entry in one go to avoid race
 * condition
@@ -1375,9 +1374,9 @@ delete_depth_small_v20(struct rte_lpm_v20 *lpm, uint32_t 
ip_masked,
.valid = VALID,
.valid_group = VALID,
.depth = sub_rule_depth,
-   .next_hop = lpm->rules_tbl
-   [sub_rule_index].next_hop,
};
+   new_tbl8_entry.next_hop =
+   lpm->rules_tbl[sub_rule_index].next_hop;

for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) {

@@ -1639,9 +1638,10 @@ delete_depth_big_v20(struct rte_lpm_v20 *lpm, uint32_t 
ip_masked,
.valid = VALID,
.depth = sub_rule_depth,
.valid_group = lpm->tbl8[tbl8_group_start].valid_group,
-   .next_hop = lpm->rules_tbl[sub_rule_index].next_hop,
};

+   new_tbl8_entry.next_hop =
+   lpm->rules_tbl[sub_rule_index].next_hop;
/*
 * Loop through the range of entries on tbl8 for which the
 * rule_to_delete must be modified.
-- 
1.9.3



[dpdk-dev] [PATCH 2/2] drivers/crypto: Fix anonymous union initialization in crypto

2016-03-25 Thread Michael Qiu
In SUSE11-SP3 i686 platform, with gcc 4.5.1, there is a
compile issue:
null_crypto_pmd_ops.c:44:3: error:
unknown field ?sym? specified in initializer
cc1: warnings being treated as errors

The member in anonymous union initialization should be inside '{}',
otherwise it will report an error.

Fixes: 26c2e4ad5ad4 ("cryptodev: add capabilities discovery")

Signed-off-by: Michael Qiu 
---
 drivers/crypto/null/null_crypto_pmd_ops.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c 
b/drivers/crypto/null/null_crypto_pmd_ops.c
index 39f8088..b7470c0 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -41,9 +41,9 @@
 static const struct rte_cryptodev_capabilities null_crypto_pmd_capabilities[] 
= {
{   /* NULL (AUTH) */
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
-   .sym = {
+   {.sym = {
.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
-   .auth = {
+   {.auth = {
.algo = RTE_CRYPTO_AUTH_NULL,
.block_size = 1,
.key_size = {
@@ -57,14 +57,14 @@ static const struct rte_cryptodev_capabilities 
null_crypto_pmd_capabilities[] =
.increment = 0
},
.aad_size = { 0 }
-   }
-   }
+   }, },
+   }, },
},
{   /* NULL (CIPHER) */
.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
-   .sym = {
+   {.sym = {
.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
-   .cipher = {
+   {.cipher = {
.algo = RTE_CRYPTO_CIPHER_NULL,
.block_size = 1,
.key_size = {
@@ -77,8 +77,8 @@ static const struct rte_cryptodev_capabilities 
null_crypto_pmd_capabilities[] =
.max = 0,
.increment = 0
}
-   }
-   }
+   }, },
+   }, },
},
RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
-- 
1.9.3



[dpdk-dev] [PATCH 1/2] lib/librte_lpm: Fix anonymous union initialization issue

2016-03-25 Thread Michael Qiu
In SUSE11-SP3 i686 platform, with gcc 4.5.1, there is a
compile issue:
rte_lpm.c: In function ?add_depth_small_v20?:
rte_lpm.c:778:7: error: unknown field ?next_hop?
specified in initializer
cc1: warnings being treated as errors
The root casue is gcc only allow anonymous union initialized
according to the field it is defined. But next_hop is defined
in different field when in different platform(Endian).

One solution is add if define in the code to avoid this issue,
but there is a simple way, initialize it separately later.

Fixes: afc5c914a083 ("lpm: fix big endian support")

Signed-off-by: Michael Qiu 
---
 lib/librte_lpm/rte_lpm.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index af5811c..efd507e 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -744,11 +744,11 @@ add_depth_small_v20(struct rte_lpm_v20 *lpm, uint32_t ip, 
uint8_t depth,
lpm->tbl24[i].depth <= depth)) {

struct rte_lpm_tbl_entry_v20 new_tbl24_entry = {
-   { .next_hop = next_hop, },
.valid = VALID,
.valid_group = 0,
.depth = depth,
};
+   new_tbl24_entry.next_hop = next_hop;

/* Setting tbl24 entry in one go to avoid race
 * conditions
@@ -775,8 +775,8 @@ add_depth_small_v20(struct rte_lpm_v20 *lpm, uint32_t ip, 
uint8_t depth,
.valid = VALID,
.valid_group = VALID,
.depth = depth,
-   .next_hop = next_hop,
};
+   new_tbl8_entry.next_hop=next_hop;

/*
 * Setting tbl8 entry in one go to avoid
@@ -975,10 +975,9 @@ add_depth_big_v20(struct rte_lpm_v20 *lpm, uint32_t 
ip_masked, uint8_t depth,
struct rte_lpm_tbl_entry_v20 new_tbl8_entry = {
.valid = VALID,
.depth = depth,
-   .next_hop = next_hop,
.valid_group = lpm->tbl8[i].valid_group,
};
-
+   new_tbl8_entry.next_hop = next_hop;
/*
 * Setting tbl8 entry in one go to avoid race
 * condition
@@ -1375,9 +1374,9 @@ delete_depth_small_v20(struct rte_lpm_v20 *lpm, uint32_t 
ip_masked,
.valid = VALID,
.valid_group = VALID,
.depth = sub_rule_depth,
-   .next_hop = lpm->rules_tbl
-   [sub_rule_index].next_hop,
};
+   new_tbl8_entry.next_hop =
+   lpm->rules_tbl[sub_rule_index].next_hop;

for (i = tbl24_index; i < (tbl24_index + tbl24_range); i++) {

@@ -1639,9 +1638,10 @@ delete_depth_big_v20(struct rte_lpm_v20 *lpm, uint32_t 
ip_masked,
.valid = VALID,
.depth = sub_rule_depth,
.valid_group = lpm->tbl8[tbl8_group_start].valid_group,
-   .next_hop = lpm->rules_tbl[sub_rule_index].next_hop,
};

+   new_tbl8_entry.next_hop =
+   lpm->rules_tbl[sub_rule_index].next_hop;
/*
 * Loop through the range of entries on tbl8 for which the
 * rule_to_delete must be modified.
-- 
1.9.3



[dpdk-dev] [PATCH 0/2] Compile fixes in SUSE11 SP3 i686 platform

2016-03-25 Thread Michael Qiu
In SUSE11 SP3 i686 platform with gcc version 4.5.1, there is
some compile issues. This patch set is try to fix them.

Michael Qiu (2):
  lib/librte_lpm: Fix anonymous union initialization issue
  drivers/crypto: Fix anonymous union initialization in crypto

 drivers/crypto/null/null_crypto_pmd_ops.c | 16 
 lib/librte_lpm/rte_lpm.c  | 14 +++---
 2 files changed, 15 insertions(+), 15 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH 2/2 v2] fm10k: update doc for Atwood Channel

2016-02-04 Thread Michael Qiu
Atwood Channel is 25GbE NIC and belongs to Intel FM10K family,
update the doc for it.

Signed-off-by: Michael Qiu 
Acked-by: John McNamara 
---
Change log:
   1. modify 20GbE to 25GbE 

 doc/guides/rel_notes/release_2_3.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/guides/rel_notes/release_2_3.rst 
b/doc/guides/rel_notes/release_2_3.rst
index 99de186..7dd9c0f 100644
--- a/doc/guides/rel_notes/release_2_3.rst
+++ b/doc/guides/rel_notes/release_2_3.rst
@@ -3,7 +3,9 @@ DPDK Release 2.3

 New Features
 
+* **New NIC Atwood Channel support.**

+  Added support for the Atwood Channel variant of Intel's fm10k NIC family.

 Resolved Issues
 ---
-- 
1.9.3



[dpdk-dev] [PATCH 1/2 v2] fm10k: Add Atwood Channel Support

2016-02-04 Thread Michael Qiu
Atwood Channel is intel 25G NIC, and this patch add the support
in DPDK.

Signed-off-by: Michael Qiu
Acked-by: John McNamara 
---
 drivers/net/fm10k/base/fm10k_osdep.h| 4 
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/fm10k/base/fm10k_osdep.h 
b/drivers/net/fm10k/base/fm10k_osdep.h
index 6852ef0..9cb46ff 100644
--- a/drivers/net/fm10k/base/fm10k_osdep.h
+++ b/drivers/net/fm10k/base/fm10k_osdep.h
@@ -48,6 +48,10 @@ POSSIBILITY OF SUCH DAMAGE.
 #define BOULDER_RAPIDS_HW
 #endif

+#ifndef ATWOOD_CHANNEL_HW
+#define ATWOOD_CHANNEL_HW
+#endif
+
 #define STATIC  static
 #define DEBUGFUNC(F)DEBUGOUT(F "\n");
 #define DEBUGOUT(S, args...)PMD_DRV_LOG_RAW(DEBUG, S, ##args)
diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h 
b/lib/librte_eal/common/include/rte_pci_dev_ids.h
index e31b934..cb0d177 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -530,9 +530,11 @@ RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, 
I40E_DEV_ID_10G_BASE_T_X722)

 #define FM10K_DEV_ID_PF   0x15A4
 #define FM10K_DEV_ID_SDI_FM10420_QDA2 0x15D0
+#define FM10K_DEV_ID_SDI_FM10420_DA2  0x15D5

 RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_PF)
 RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_SDI_FM10420_QDA2)
+RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_SDI_FM10420_DA2)

 /** Virtual IGB devices from e1000_hw.h **/

-- 
1.9.3



[dpdk-dev] [PATCH v2] ixgbe: Fix disable interrupt twice

2016-01-29 Thread Michael Qiu
Currently, ixgbe vf and pf will disable interrupt twice in
stop stage and uninit stage. It will cause an error:

testpmd> quit

Shutting down port 0...
Stopping ports...
Done
Closing ports...
EAL: Error disabling MSI-X interrupts for fd 26
Done

Becasue the interrupt already been disabled in stop stage.
Since it is enabled in init stage, better remove from
stop stage.

Fixes: 0eb609239efd ("ixgbe: enable Rx queue interrupts for PF and VF")

Signed-off-by: Michael Qiu 
---
 v2 --> v1:
 fix error in commit log word "interrupte"

 drivers/net/ixgbe/ixgbe_ethdev.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 4c4c6df..a561f8d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -2192,9 +2192,6 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)
/* disable interrupts */
ixgbe_disable_intr(hw);

-   /* disable intr eventfd mapping */
-   rte_intr_disable(intr_handle);
-
/* reset the NIC */
ixgbe_pf_reset_hw(hw);
hw->adapter_stopped = 0;
@@ -3898,9 +3895,6 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev)

ixgbe_dev_clear_queues(dev);

-   /* disable intr eventfd mapping */
-   rte_intr_disable(intr_handle);
-
/* Clean datapath event and queue/vec mapping */
rte_intr_efd_disable(intr_handle);
if (intr_handle->intr_vec != NULL) {
-- 
1.9.3



[dpdk-dev] [PATCH] ixgbe: Fix disable interrupt twice

2016-01-29 Thread Michael Qiu
Currently, ixgbe vf and pf will disable interrupte twice in
stop stage and uninit stage. It will cause an error:

testpmd> quit

Shutting down port 0...
Stopping ports...
Done
Closing ports...
EAL: Error disabling MSI-X interrupts for fd 26
Done

Becasue the interrupt already been disabled in stop stage.
Since it is enabled in init stage, better remove from
stop stage.

Fixes: 0eb609239efd ("ixgbe: enable Rx queue interrupts for PF and VF")

Signed-off-by: Michael Qiu 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 4c4c6df..a561f8d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -2192,9 +2192,6 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)
/* disable interrupts */
ixgbe_disable_intr(hw);

-   /* disable intr eventfd mapping */
-   rte_intr_disable(intr_handle);
-
/* reset the NIC */
ixgbe_pf_reset_hw(hw);
hw->adapter_stopped = 0;
@@ -3898,9 +3895,6 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev)

ixgbe_dev_clear_queues(dev);

-   /* disable intr eventfd mapping */
-   rte_intr_disable(intr_handle);
-
/* Clean datapath event and queue/vec mapping */
rte_intr_efd_disable(intr_handle);
if (intr_handle->intr_vec != NULL) {
-- 
1.9.3



[dpdk-dev] [PATCH] lib/librte_eal: Fix compile issue with gcc 5.3.1

2016-01-28 Thread Michael Qiu
In fedora 22 with GCC version 5.3.1, when compile,
will result an error:

include/rte_memcpy.h:309:7: error: "RTE_MACHINE_CPUFLAG_AVX2"
is not defined [-Werror=undef]
#elif RTE_MACHINE_CPUFLAG_AVX2

Fixes: 9484092baad3 ("eal/x86: optimize memcpy for AVX512 platforms")

Signed-off-by: Michael Qiu 
---
 app/test/test_memcpy_perf.c | 2 +-
 lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test/test_memcpy_perf.c b/app/test/test_memcpy_perf.c
index 73babec..f150d8d 100644
--- a/app/test/test_memcpy_perf.c
+++ b/app/test/test_memcpy_perf.c
@@ -81,7 +81,7 @@ static size_t buf_sizes[TEST_VALUE_RANGE];
 /* Data is aligned on this many bytes (power of 2) */
 #ifdef RTE_MACHINE_CPUFLAG_AVX512F
 #define ALIGNMENT_UNIT  64
-#elif RTE_MACHINE_CPUFLAG_AVX2
+#elif defined RTE_MACHINE_CPUFLAG_AVX2
 #define ALIGNMENT_UNIT  32
 #else /* RTE_MACHINE_CPUFLAG */
 #define ALIGNMENT_UNIT  16
diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h 
b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index d965957..8e2c53c 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -306,7 +306,7 @@ COPY_BLOCK_128_BACK63:
goto COPY_BLOCK_128_BACK63;
 }

-#elif RTE_MACHINE_CPUFLAG_AVX2
+#elif defined RTE_MACHINE_CPUFLAG_AVX2

 /**
  * AVX2 implementation below
-- 
1.9.3



[dpdk-dev] [PATCH 2/2] fm10k: update doc for Atwood Channel

2016-01-11 Thread Michael Qiu
Atwood Channel is 20GbE NIC and belongs to Intel FM10K family,
update the doc for it.

Signed-off-by: Michael Qiu 
---
 doc/guides/rel_notes/release_2_3.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/guides/rel_notes/release_2_3.rst 
b/doc/guides/rel_notes/release_2_3.rst
index 99de186..7dd9c0f 100644
--- a/doc/guides/rel_notes/release_2_3.rst
+++ b/doc/guides/rel_notes/release_2_3.rst
@@ -3,7 +3,9 @@ DPDK Release 2.3

 New Features
 
+* **New NIC Atwood Channel support.**

+  Added support for the Atwood Channel variant of Intel's fm10k NIC family.

 Resolved Issues
 ---
-- 
1.9.3



[dpdk-dev] [PATCH 1/2] fm10k: Add Atwood Channel Support

2016-01-11 Thread Michael Qiu
Atwood Channel is intel 25G NIC, and this patch add the support
in DPDK.

Signed-off-by: Michael Qiu
---
 drivers/net/fm10k/base/fm10k_osdep.h| 4 
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/fm10k/base/fm10k_osdep.h 
b/drivers/net/fm10k/base/fm10k_osdep.h
index 6852ef0..9cb46ff 100644
--- a/drivers/net/fm10k/base/fm10k_osdep.h
+++ b/drivers/net/fm10k/base/fm10k_osdep.h
@@ -48,6 +48,10 @@ POSSIBILITY OF SUCH DAMAGE.
 #define BOULDER_RAPIDS_HW
 #endif

+#ifndef ATWOOD_CHANNEL_HW
+#define ATWOOD_CHANNEL_HW
+#endif
+
 #define STATIC  static
 #define DEBUGFUNC(F)DEBUGOUT(F "\n");
 #define DEBUGOUT(S, args...)PMD_DRV_LOG_RAW(DEBUG, S, ##args)
diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h 
b/lib/librte_eal/common/include/rte_pci_dev_ids.h
index e31b934..cb0d177 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -530,9 +530,11 @@ RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, 
I40E_DEV_ID_10G_BASE_T_X722)

 #define FM10K_DEV_ID_PF   0x15A4
 #define FM10K_DEV_ID_SDI_FM10420_QDA2 0x15D0
+#define FM10K_DEV_ID_SDI_FM10420_DA2  0x15D5

 RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_PF)
 RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_SDI_FM10420_QDA2)
+RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_SDI_FM10420_DA2)

 /** Virtual IGB devices from e1000_hw.h **/

-- 
1.9.3



[dpdk-dev] [PATCH] examples/netmap_compat: Fix compile issue with POLLRDNORM

2015-12-11 Thread Michael Qiu
 examples/netmap_compat/bridge/../lib/compat_netmap.c:880:41:
 error: ?POLLRDNORM? undeclared (first use in this function)

The root casue is POLLRDNORM is more-or-less nonstandard, and it
depends on macro "__USE_XOPEN".

Fixes: 06371afe394d (examples/netmap_compat: import netmap compatibility 
example)

In suse11 sp3, POLLRDNORM will not be defined because "__USE_XOPEN"
issue.

This patch add check if it is not defined, define it.

Signed-off-by: Michael Qiu 
---
 examples/netmap_compat/lib/compat_netmap.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/examples/netmap_compat/lib/compat_netmap.c 
b/examples/netmap_compat/lib/compat_netmap.c
index d2e079f..dd6d4f9 100644
--- a/examples/netmap_compat/lib/compat_netmap.c
+++ b/examples/netmap_compat/lib/compat_netmap.c
@@ -73,6 +73,14 @@ struct fd_port {
uint32_t port;
 };

+#ifndef POLLRDNORM
+#define POLLRDNORM 0x0040
+#endif
+
+#ifndef POLLWRNORM
+#define POLLWRNORM 0x0100
+#endif
+
 #defineFD_PORT_FREEUINT32_MAX
 #defineFD_PORT_RSRV(FD_PORT_FREE - 1)

-- 
1.9.3



[dpdk-dev] [PATCH] examples/ip_pipeline: Fix compile issue with strict-aliasing

2015-12-09 Thread Michael Qiu
Compile ip_pipeline in CentOS 6.5 with kernel 2.6.32-431
GCC 4.4.7, will lead below error:

pipeline_routing_be.c: In function 
?pipeline_routing_msg_req_arp_add_handler?:
pipeline_routing_be.c:1817: error: dereferencing pointer ?({anonymous})?
does break strict-aliasing rules

This because the code break strict-aliasing rule.
The patch solve this issue.

Fixes: 0ae7275810f1 (examples/ip_pipeline: add more functions to routing 
pipeline)

Signed-off-by: Michael Qiu 
---
 examples/ip_pipeline/pipeline/pipeline_routing_be.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/examples/ip_pipeline/pipeline/pipeline_routing_be.c 
b/examples/ip_pipeline/pipeline/pipeline_routing_be.c
index 4a95c7d..9baabd0 100644
--- a/examples/ip_pipeline/pipeline/pipeline_routing_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_routing_be.c
@@ -1461,8 +1461,7 @@ pipeline_routing_msg_req_route_add_handler(struct 
pipeline *p, void *msg)
uint64_t macaddr_dst;
uint64_t ethertype = ETHER_TYPE_IPv4;

-   *((struct ether_addr *) _dst) =
-   req->data.ethernet.macaddr;
+   macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
macaddr_dst = rte_bswap64(macaddr_dst << 16);

entry_arp0.slab[0] =
@@ -1503,8 +1502,7 @@ pipeline_routing_msg_req_route_add_handler(struct 
pipeline *p, void *msg)
uint64_t svlan = req->data.l2.qinq.svlan;
uint64_t cvlan = req->data.l2.qinq.cvlan;

-   *((struct ether_addr *) _dst) =
-   req->data.ethernet.macaddr;
+   macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
macaddr_dst = rte_bswap64(macaddr_dst << 16);

entry_arp0.slab[0] = rte_bswap64((svlan << 48) |
@@ -1563,8 +1561,7 @@ pipeline_routing_msg_req_route_add_handler(struct 
pipeline *p, void *msg)
uint64_t label3 = req->data.l2.mpls.labels[3];
uint32_t n_labels = req->data.l2.mpls.n_labels;

-   *((struct ether_addr *) _dst) =
-   req->data.ethernet.macaddr;
+   macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
macaddr_dst = rte_bswap64(macaddr_dst << 16);

switch (n_labels) {
@@ -1814,7 +1811,7 @@ pipeline_routing_msg_req_arp_add_handler(struct pipeline 
*p, void *msg)
return rsp;
}

-   *((struct ether_addr *) ) = req->macaddr;
+   entry.macaddr = *((uint64_t *)&(req->macaddr));
entry.macaddr = entry.macaddr << 16;

rsp->status = rte_pipeline_table_entry_add(p->p,
-- 
1.9.3



[dpdk-dev] [PATCH] ip_pipeline: Fix compile issue with strict-aliasing

2015-12-09 Thread Michael Qiu
From: root <root@localhost.localdomain>

strict-aliasing

Signed-off-by: Michael Qiu 
---
 .../ip_pipeline/pipeline/pipeline_routing_be.c |   11 ---
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/examples/ip_pipeline/pipeline/pipeline_routing_be.c 
b/examples/ip_pipeline/pipeline/pipeline_routing_be.c
index 4a95c7d..9baabd0 100644
--- a/examples/ip_pipeline/pipeline/pipeline_routing_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_routing_be.c
@@ -1461,8 +1461,7 @@ pipeline_routing_msg_req_route_add_handler(struct 
pipeline *p, void *msg)
uint64_t macaddr_dst;
uint64_t ethertype = ETHER_TYPE_IPv4;

-   *((struct ether_addr *) _dst) =
-   req->data.ethernet.macaddr;
+   macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
macaddr_dst = rte_bswap64(macaddr_dst << 16);

entry_arp0.slab[0] =
@@ -1503,8 +1502,7 @@ pipeline_routing_msg_req_route_add_handler(struct 
pipeline *p, void *msg)
uint64_t svlan = req->data.l2.qinq.svlan;
uint64_t cvlan = req->data.l2.qinq.cvlan;

-   *((struct ether_addr *) _dst) =
-   req->data.ethernet.macaddr;
+   macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
macaddr_dst = rte_bswap64(macaddr_dst << 16);

entry_arp0.slab[0] = rte_bswap64((svlan << 48) |
@@ -1563,8 +1561,7 @@ pipeline_routing_msg_req_route_add_handler(struct 
pipeline *p, void *msg)
uint64_t label3 = req->data.l2.mpls.labels[3];
uint32_t n_labels = req->data.l2.mpls.n_labels;

-   *((struct ether_addr *) _dst) =
-   req->data.ethernet.macaddr;
+   macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
macaddr_dst = rte_bswap64(macaddr_dst << 16);

switch (n_labels) {
@@ -1814,7 +1811,7 @@ pipeline_routing_msg_req_arp_add_handler(struct pipeline 
*p, void *msg)
return rsp;
}

-   *((struct ether_addr *) ) = req->macaddr;
+   entry.macaddr = *((uint64_t *)&(req->macaddr));
entry.macaddr = entry.macaddr << 16;

rsp->status = rte_pipeline_table_entry_add(p->p,
-- 
1.7.1



[dpdk-dev] [PATCH v3] lib/librte_sched: Fix compile with gcc 4.3.4

2015-12-02 Thread Michael Qiu
gcc 4.3.4 does not include "immintrin.h", and will post below error:
lib/librte_sched/rte_sched.c:56:23: error:
immintrin.h: No such file or directory

This compiler issue is fixed with rte_vect.h

There is another issue, need SSE2 support

Fixes: 42ec27a0178a ("sched: enable SSE optimizations in config")

Signed-off-by: Michael Qiu 
---
v3 --> v2:
reformat commit log
move rte_vect.h inside RTE_SCHED_VECTOR

v2 --> v1:
include header file rte_vect.h instead of gcc version check
change __AVX__ to __SSE2__ since all vector function are SSE2 related

 lib/librte_sched/rte_sched.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index d47cfc2..21ebf25 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -53,7 +53,12 @@
 #endif

 #ifdef RTE_SCHED_VECTOR
-#include 
+#include 
+
+#if defined(__SSE2__)
+#define SCHED_VECTOR_SSE2
+#endif
+
 #endif

 #define RTE_SCHED_TB_RATE_CONFIG_ERR  (1e-7)
@@ -1667,7 +1672,7 @@ grinder_schedule(struct rte_sched_port *port, uint32_t 
pos)
return 1;
 }

-#ifdef RTE_SCHED_VECTOR
+#ifdef SCHED_VECTOR_SSE2

 static inline int
 grinder_pipe_exists(struct rte_sched_port *port, uint32_t base_pipe)
-- 
1.9.3



[dpdk-dev] [PATCH v2] lib/librte_sched: Fix compile with gcc 4.3.4

2015-12-02 Thread Michael Qiu
gcc 4.3.4 does not include "immintrin.h", and will post below error:
lib/librte_sched/rte_sched.c:56:23: error:
immintrin.h: No such file or directory

To avoid this issue, a gcc version check is need and a flag to indicate
vector ablility.

Fixes: 42ec27a0178a ("sched: enable SSE optimizations in config")

Signed-off-by: Michael Qiu 
---
v2 --> v1:
include header file rte_vect.h instead of gcc version check
change __AVX__ to __SSE2__ since all vector function are SSE2 related.

 lib/librte_sched/rte_sched.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index d47cfc2..0d46618 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "rte_sched.h"
 #include "rte_bitmap.h"
@@ -53,7 +54,11 @@
 #endif

 #ifdef RTE_SCHED_VECTOR
-#include 
+
+#if defined(__SSE2__)
+#define SCHED_VECTOR_ENABLE
+#endif
+
 #endif

 #define RTE_SCHED_TB_RATE_CONFIG_ERR  (1e-7)
@@ -1667,7 +1672,7 @@ grinder_schedule(struct rte_sched_port *port, uint32_t 
pos)
return 1;
 }

-#ifdef RTE_SCHED_VECTOR
+#ifdef SCHED_VECTOR_ENABLE

 static inline int
 grinder_pipe_exists(struct rte_sched_port *port, uint32_t base_pipe)
-- 
1.9.3



[dpdk-dev] [PATCH 2/2 v2] Fix compile issue in i686 platform

2015-11-27 Thread Michael Qiu
In i686 platform, long is 32bit, so XXX_CYCLECOUNTER_MASK
need define as 'ULL'

Fixes: 9c857bf6be87 ("igb: support ieee1588 functions for device time")
Fixes: 1c4445e1f28e ("ixgbe: support ieee1588 functions for device time")
Fixes: f3a4e40eca0c ("i40e: support ieee1588 functions for device time")

Signed-off-by: Michael Qiu 
---
v2 --> v1:
add "Fixes" line in commit log

 drivers/net/e1000/igb_ethdev.c   | 2 +-
 drivers/net/i40e/i40e_ethdev.c   | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 31452ae..518b6c9 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -78,7 +78,7 @@
 #define IGB_8_BIT_MASK   UINT8_MAX

 /* Additional timesync values. */
-#define E1000_CYCLECOUNTER_MASK  0x
+#define E1000_CYCLECOUNTER_MASK  0xULL
 #define E1000_ETQF_FILTER_1588   3
 #define IGB_82576_TSYNC_SHIFT16
 #define E1000_INCPERIOD_82576(1 << E1000_TIMINCA_16NS_SHIFT)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 13ab81a..5cd6e88 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -131,7 +131,7 @@
 #define I40E_PTP_1GB_INCVAL  0x20ULL
 #define I40E_PRTTSYN_TSYNENA 0x8000
 #define I40E_PRTTSYN_TSYNTYPE0x0e00
-#define I40E_CYCLECOUNTER_MASK   0x
+#define I40E_CYCLECOUNTER_MASK   0xULL

 #define I40E_MAX_PERCENT100
 #define I40E_DEFAULT_DCB_APP_NUM1
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 49f2410..808ac69 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -136,7 +136,7 @@
 #define IXGBE_INCVAL_SHIFT_82599 7
 #define IXGBE_INCPER_SHIFT_82599 24

-#define IXGBE_CYCLECOUNTER_MASK   0x
+#define IXGBE_CYCLECOUNTER_MASK   0xULL

 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
-- 
1.9.3



[dpdk-dev] [PATCH 1/2 v2] examples/distributor: Fix compile issue

2015-11-27 Thread Michael Qiu
examples/distributor/main.c(338): error #167:
argument of type "struct rte_mbuf *"
is incompatible with parameter of type "const char *"
_mm_prefetch(bufs[0], 0);

The first param pass to _mm_prefetch is wrong,
need convert "struct rte_mbuf *" to "void *".

Fixes: 07db4a975094 ("examples/distributor: new sample app")

Signed-off-by: Michael Qiu 
---
v2 --> v1:
convert "const void *" to "void *" to avoid CLANG issue.
add "Fixes" line in commit log
 examples/distributor/main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 972bddb..a4d8e34 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -335,13 +335,13 @@ lcore_tx(struct rte_ring *in_r)

/* for traffic we receive, queue it up for transmit */
uint16_t i;
-   _mm_prefetch(bufs[0], 0);
-   _mm_prefetch(bufs[1], 0);
-   _mm_prefetch(bufs[2], 0);
+   _mm_prefetch((void *)bufs[0], 0);
+   _mm_prefetch((void *)bufs[1], 0);
+   _mm_prefetch((void *)bufs[2], 0);
for (i = 0; i < nb_rx; i++) {
struct output_buffer *outbuf;
uint8_t outp;
-   _mm_prefetch(bufs[i + 3], 0);
+   _mm_prefetch((void *)bufs[i + 3], 0);
/*
 * workers should update in_port to hold the
 * output port value
-- 
1.9.3



[dpdk-dev] [PATCH] lib/librte_sched: Fix compile with gcc 4.3.4

2015-11-26 Thread Michael Qiu
gcc 4.3.4 does not include "immintrin.h", and will post below error:
lib/librte_sched/rte_sched.c:56:23: error:
immintrin.h: No such file or directory

To avoid this issue, a gcc version check is need and a flag to indicate
vector ablility.

Signed-off-by: Michael Qiu 
---
 lib/librte_sched/rte_sched.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index d47cfc2..780b314 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -53,7 +53,21 @@
 #endif

 #ifdef RTE_SCHED_VECTOR
+
+#if (defined(__ICC) || (__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
+
+#if defined(__AVX__)
 #include 
+#define SCHED_VECTOR_ENABLE
+#endif
+
+#else
+
+#include 
+#define SCHED_VECTOR_ENABLE
+
+#endif
+
 #endif

 #define RTE_SCHED_TB_RATE_CONFIG_ERR  (1e-7)
@@ -1667,7 +1681,7 @@ grinder_schedule(struct rte_sched_port *port, uint32_t 
pos)
return 1;
 }

-#ifdef RTE_SCHED_VECTOR
+#ifdef SCHED_VECTOR_ENABLE

 static inline int
 grinder_pipe_exists(struct rte_sched_port *port, uint32_t base_pipe)
-- 
1.9.3



[dpdk-dev] [PATCH] app/test: Fix compile issue with icc

2015-11-26 Thread Michael Qiu
app/test/test_cryptodev_perf.c(1837): error #192: unrecognized
character escape sequence
printf("\n%u\t%u\t\%u\t\t%u\t\t%u", dev_num, 0,

"\%u" is the root cause of this issue, just fix it.

Signed-off-by: Michael Qiu 
---
 app/test/test_cryptodev_perf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c
index f0cca8b..1744e13 100644
--- a/app/test/test_cryptodev_perf.c
+++ b/app/test/test_cryptodev_perf.c
@@ -1834,7 +1834,7 @@ test_perf_crypto_qp_vary_burst_size(uint16_t dev_num)
num_received += burst_received;
}

-   printf("\n%u\t%u\t\%u\t\t%u\t\t%u", dev_num, 0,
+   printf("\n%u\t%u\t%u\t\t%u\t\t%u", dev_num, 0,
num_sent, num_received, burst_size);
printf("\t\t%"PRIu64, retries);
printf("\t\t\t%"PRIu64, total_cycles/num_received);
-- 
1.9.3



[dpdk-dev] [PATCH 2/2] Fix compile issue in i686 platform

2015-11-26 Thread Michael Qiu
In i686 platform, long is 32bit, so XXX_CYCLECOUNTER_MASK
need define as 'ULL'

Signed-off-by: Michael Qiu 
---
 drivers/net/e1000/igb_ethdev.c   | 2 +-
 drivers/net/i40e/i40e_ethdev.c   | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 31452ae..518b6c9 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -78,7 +78,7 @@
 #define IGB_8_BIT_MASK   UINT8_MAX

 /* Additional timesync values. */
-#define E1000_CYCLECOUNTER_MASK  0x
+#define E1000_CYCLECOUNTER_MASK  0xULL
 #define E1000_ETQF_FILTER_1588   3
 #define IGB_82576_TSYNC_SHIFT16
 #define E1000_INCPERIOD_82576(1 << E1000_TIMINCA_16NS_SHIFT)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 13ab81a..5cd6e88 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -131,7 +131,7 @@
 #define I40E_PTP_1GB_INCVAL  0x20ULL
 #define I40E_PRTTSYN_TSYNENA 0x8000
 #define I40E_PRTTSYN_TSYNTYPE0x0e00
-#define I40E_CYCLECOUNTER_MASK   0x
+#define I40E_CYCLECOUNTER_MASK   0xULL

 #define I40E_MAX_PERCENT100
 #define I40E_DEFAULT_DCB_APP_NUM1
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 49f2410..808ac69 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -136,7 +136,7 @@
 #define IXGBE_INCVAL_SHIFT_82599 7
 #define IXGBE_INCPER_SHIFT_82599 24

-#define IXGBE_CYCLECOUNTER_MASK   0x
+#define IXGBE_CYCLECOUNTER_MASK   0xULL

 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
-- 
1.9.3



[dpdk-dev] [PATCH 1/2] examples/distributor: Fix compile issue

2015-11-26 Thread Michael Qiu
examples/distributor/main.c(338): error #167:
argument of type "struct rte_mbuf *"
is incompatible with parameter of type "const char *"
_mm_prefetch(bufs[0], 0);

The first param of _mm_prefetch should be "const char *" and
need convert "struct rte_mbuf *" to "const void *".

Signed-off-by: Michael Qiu 
---
 examples/distributor/main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 972bddb..a4d8e34 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -335,13 +335,13 @@ lcore_tx(struct rte_ring *in_r)

/* for traffic we receive, queue it up for transmit */
uint16_t i;
-   _mm_prefetch(bufs[0], 0);
-   _mm_prefetch(bufs[1], 0);
-   _mm_prefetch(bufs[2], 0);
+   _mm_prefetch((const void *)bufs[0], 0);
+   _mm_prefetch((const void *)bufs[1], 0);
+   _mm_prefetch((const void *)bufs[2], 0);
for (i = 0; i < nb_rx; i++) {
struct output_buffer *outbuf;
uint8_t outp;
-   _mm_prefetch(bufs[i + 3], 0);
+   _mm_prefetch((const void *)bufs[i + 3], 0);
/*
 * workers should update in_port to hold the
 * output port value
-- 
1.9.3



[dpdk-dev] [PATCH v2 2/2] doc: release note update for Boulder Rapid Support

2015-10-26 Thread Michael Qiu
Update the release note for Intel's new NIC Boulder Rapid.

Signed-off-by: Michael Qiu 
---
 doc/guides/rel_notes/release_2_2.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doc/guides/rel_notes/release_2_2.rst 
b/doc/guides/rel_notes/release_2_2.rst
index ab1c25f..7b34786 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -9,6 +9,9 @@ New Features
   *  Added support for Jumbo Frames.
   *  Optimize forwarding performance for Chelsio T5 40GbE cards.

+* **Intel new NIC Boulder Rapid support.**
+
+  Boulder Rapid is a new NIC of Intel's fm10k family.

 Resolved Issues
 ---
-- 
1.9.3



[dpdk-dev] [PATCH v2 1/2] fm10k: add Intel Boulder Rapid NIC support

2015-10-26 Thread Michael Qiu
Boulder Rapid is Intel new NIC within fm10k family.
This patch make DPDK driver support this new NIC.

Signed-off-by: Michael Qiu 
Acked-by : Jing Chen 
Acked-by : Shaopeng He 
---
 drivers/net/fm10k/base/fm10k_osdep.h| 4 
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/fm10k/base/fm10k_osdep.h 
b/drivers/net/fm10k/base/fm10k_osdep.h
index 64f09dc..4ba96f1 100644
--- a/drivers/net/fm10k/base/fm10k_osdep.h
+++ b/drivers/net/fm10k/base/fm10k_osdep.h
@@ -44,6 +44,10 @@ POSSIBILITY OF SUCH DAMAGE.
 /* TODO: this does not look like it should be used... */
 #define ERROR_REPORT2(v1, v2, v3)   do { } while (0)

+#ifndef BOULDER_RAPIDS_HW
+#define BOULDER_RAPIDS_HW
+#endif
+
 #define STATIC  static
 #define DEBUGFUNC(F)DEBUGOUT(F "\n");
 #define DEBUGOUT(S, args...)PMD_DRV_LOG_RAW(DEBUG, S, ##args)
diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h 
b/lib/librte_eal/common/include/rte_pci_dev_ids.h
index 265e66c..5a44cbe 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -516,8 +516,10 @@ RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, 
I40E_DEV_ID_10G_BASE_T4)
 /*** Physical FM10K devices from fm10k_type.h ***/

 #define FM10K_DEV_ID_PF   0x15A4
+#define FM10K_DEV_ID_SDI_FM10420_QDA2 0x15D0

 RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_PF)
+RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_SDI_FM10420_QDA2)

 /** Virtual IGB devices from e1000_hw.h **/

-- 
1.9.3



[dpdk-dev] [PATCH v2 0/2] Intel new NIC Boulder Rapid support

2015-10-26 Thread Michael Qiu
Boulder Rapid is a new 100G NIC of Intel fm10k family, this patch
set enable it in DPDK.

change log:
V2 --> v1
update the release notes

Michael Qiu (2):
  fm10k: add Intel Boulder Rapid NIC support
  doc: release note update for Boulder Rapid Support

 doc/guides/rel_notes/release_2_2.rst| 3 +++
 drivers/net/fm10k/base/fm10k_osdep.h| 4 
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 2 ++
 3 files changed, 9 insertions(+)

-- 
1.9.3



[dpdk-dev] [PATCH] fm10k: add Intel Boulder Rapid NIC support

2015-09-25 Thread Michael Qiu
Boulder Rapid is Intel new NIC within fm10k family.
This patch make DPDK driver support this new NIC.

Signed-off-by: Michael Qiu 
---
 drivers/net/fm10k/base/fm10k_osdep.h| 4 
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/fm10k/base/fm10k_osdep.h 
b/drivers/net/fm10k/base/fm10k_osdep.h
index 64f09dc..4ba96f1 100644
--- a/drivers/net/fm10k/base/fm10k_osdep.h
+++ b/drivers/net/fm10k/base/fm10k_osdep.h
@@ -44,6 +44,10 @@ POSSIBILITY OF SUCH DAMAGE.
 /* TODO: this does not look like it should be used... */
 #define ERROR_REPORT2(v1, v2, v3)   do { } while (0)

+#ifndef BOULDER_RAPIDS_HW
+#define BOULDER_RAPIDS_HW
+#endif
+
 #define STATIC  static
 #define DEBUGFUNC(F)DEBUGOUT(F "\n");
 #define DEBUGOUT(S, args...)PMD_DRV_LOG_RAW(DEBUG, S, ##args)
diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h 
b/lib/librte_eal/common/include/rte_pci_dev_ids.h
index cf2cf70..b2d6964 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -510,8 +510,10 @@ RTE_PCI_DEV_ID_DECL_I40E(PCI_VENDOR_ID_INTEL, 
I40E_DEV_ID_10G_BASE_T)
 /*** Physical FM10K devices from fm10k_type.h ***/

 #define FM10K_DEV_ID_PF   0x15A4
+#define FM10K_DEV_ID_SDI_FM10420_QDA2 0x15D0

 RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_PF)
+RTE_PCI_DEV_ID_DECL_FM10K(PCI_VENDOR_ID_INTEL, FM10K_DEV_ID_SDI_FM10420_QDA2)

 /** Virtual IGB devices from e1000_hw.h **/

-- 
1.9.3



[dpdk-dev] [PATCH] librte_eal: Fix wrong header file for old gcc version

2015-08-24 Thread Michael Qiu
For __SSE3__, the corresponding header file should be pmmintrin.h,
tmmintrin.h works for __SSSE3__.

Signed-off-by: Michael Qiu 
---
 lib/librte_eal/common/include/arch/x86/rte_vect.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h 
b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index b698797..8a4dace 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -51,6 +51,10 @@
 #endif

 #ifdef __SSE3__
+#include 
+#endif
+
+#ifdef __SSSE3__
 #include 
 #endif

-- 
1.9.3



[dpdk-dev] [PATCH] testpmd: modify the mac of csum forwarding

2015-08-07 Thread Michael Qiu
For some ethnet-switch like intel RRC, all the packet forwarded
out by DPDK will be dropped in switch side, so the packet
generator will never receive the packet.

Signed-off-by: Michael Qiu 
---
 app/test-pmd/csumonly.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 1bf3485..bf8af1d 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -550,6 +550,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 * and inner headers */

eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
+   ether_addr_copy(_eth_addrs[fs->peer_addr],
+   _hdr->d_addr);
+   ether_addr_copy([fs->tx_port].eth_addr,
+   _hdr->s_addr);
parse_ethernet(eth_hdr, );
l3_hdr = (char *)eth_hdr + info.l2_len;

-- 
1.9.3



[dpdk-dev] [PATCH] test-pmd: show pci address in port info

2015-07-29 Thread Michael Qiu
pci address is one important info for port.
This patch make it visible for port info.

Signed-off-by: Michael Qiu 
---
 app/test-pmd/config.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1d29146..c7db5bc 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -297,6 +297,8 @@ port_infos_display(portid_t port_id)
 {
struct rte_port *port;
struct ether_addr mac_addr;
+   struct rte_pci_addr *addr = NULL;
+   char pci_addr[13] = ":00:00.0";
struct rte_eth_link link;
struct rte_eth_dev_info dev_info;
int vlan_offload;
@@ -317,6 +319,17 @@ port_infos_display(portid_t port_id)
   info_border, port_id, info_border);
rte_eth_macaddr_get(port_id, _addr);
print_ethaddr("MAC address: ", _addr);
+   if (port->dev_info.pci_dev) {
+   addr = >dev_info.pci_dev->addr;
+   sprintf(pci_addr, "%04x:%02x:%02x.%01x",
+   addr->domain, addr->bus, addr->devid, addr->function);
+   }
+
+   if (strncmp(":00:00.0", pci_addr, 12))
+   printf("\nPCI address: %s", pci_addr);
+   else
+   printf("\nPCI address: N/A");
+
printf("\nConnect to socket: %u", port->socket_id);

if (port_numa[port_id] != NUMA_NO_CONFIG) {
-- 
1.9.3



[dpdk-dev] [PATCH] testpmd: Fix segment fault when port ID greater than 76

2015-07-29 Thread Michael Qiu
In testpmd, when using "rx_vlan add 1 77", it will be a segment fault
Because the port ID should be less than 32.

Signed-off-by: Michael Qiu 
---
 app/test-pmd/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1d29146..cf2aa6e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -388,7 +388,7 @@ port_id_is_invalid(portid_t port_id, enum print_warning 
warning)
if (port_id == (portid_t)RTE_PORT_ALL)
return 0;

-   if (ports[port_id].enabled)
+   if (port_id < RTE_MAX_ETHPORTS && ports[port_id].enabled)
return 0;

if (warning == ENABLED_WARN)
-- 
1.9.3



[dpdk-dev] [PATCH 2/2 v5] fm10k: Add hotplug support for fm10k

2015-07-14 Thread Michael Qiu
Add hotplug support for fm10k.

Signed-off-by: Michael Qiu 
Acked-by: Jing Chen 
---
 drivers/net/fm10k/fm10k_ethdev.c | 97 +++-
 1 file changed, 96 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index b10c546..1d056f3 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1712,6 +1712,36 @@ fm10k_dev_enable_intr_pf(struct rte_eth_dev *dev)
 }

 static void
+fm10k_dev_disable_intr_pf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_Mailbox), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_PCIeFault), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchUpDown), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchEvent), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SRAM), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_VFLR), int_map);
+
+   /* Disable misc causes */
+   FM10K_WRITE_REG(hw, FM10K_EIMR, FM10K_EIMR_DISABLE(PCA_FAULT) |
+   FM10K_EIMR_DISABLE(THI_FAULT) |
+   FM10K_EIMR_DISABLE(FUM_FAULT) |
+   FM10K_EIMR_DISABLE(MAILBOX) |
+   FM10K_EIMR_DISABLE(SWITCHREADY) |
+   FM10K_EIMR_DISABLE(SWITCHNOTREADY) |
+   FM10K_EIMR_DISABLE(SRAMERROR) |
+   FM10K_EIMR_DISABLE(VFLR));
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
+static void
 fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
 {
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1729,6 +1759,22 @@ fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
FM10K_WRITE_FLUSH(hw);
 }

+static void
+fm10k_dev_disable_intr_vf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   /* Only INT 0 available, other 15 are reserved. */
+   FM10K_WRITE_REG(hw, FM10K_VFINT_MAP, int_map);
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
 static int
 fm10k_dev_handle_fault(struct fm10k_hw *hw, uint32_t eicr)
 {
@@ -2179,6 +2225,54 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
return 0;
 }

+static int
+eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* only uninitialize in the primary process */
+   if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+   return 0;
+
+   /* safe to close dev here */
+   fm10k_dev_close(dev);
+
+   dev->dev_ops = NULL;
+   dev->rx_pkt_burst = NULL;
+   dev->tx_pkt_burst = NULL;
+
+   /* disable uio/vfio intr */
+   rte_intr_disable(&(dev->pci_dev->intr_handle));
+
+   /*PF/VF has different interrupt handling mechanism */
+   if (hw->mac.type == fm10k_mac_pf) {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_pf(dev);
+
+   /* unregister callback func to eal lib */
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_pf, (void *)dev);
+   } else {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_vf(dev);
+
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_vf, (void *)dev);
+   }
+
+   /* free mac memory */
+   if (dev->data->mac_addrs) {
+   rte_free(dev->data->mac_addrs);
+   dev->data->mac_addrs = NULL;
+   }
+
+   memset(hw, 0, sizeof(*hw));
+
+   return 0;
+}
+
 /*
  * The set of PCI devices this driver supports. This driver will enable both PF
  * and SRIOV-VF devices.
@@ -2194,9 +2288,10 @@ static struct eth_driver rte_pmd_fm10k = {
.pci_drv = {
.name = "rte_pmd_fm10k",
.id_table = pci_id_fm10k_map,
-   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
},
.eth_dev_init = eth_fm10k_dev_init,
+   .eth_dev_uninit = eth_fm10k_dev_uninit,
.dev_private_size = sizeof(struct fm10k_adapter),
 };

-- 
1.9.3



[dpdk-dev] [PATCH 1/2 v5] fm10k: Free queues when close port

2015-07-14 Thread Michael Qiu
When close a port, lots of memory should be released,
such as software rings, queues, etc.

Signed-off-by: Michael Qiu 
---
 drivers/net/fm10k/fm10k_ethdev.c | 31 +++
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index c1a2069..b10c546 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -65,6 +65,8 @@ static void
 fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add);
 static void
 fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev);
+static void fm10k_tx_queue_release(void *queue);
+static void fm10k_rx_queue_release(void *queue);

 static void
 fm10k_mbx_initlock(struct fm10k_hw *hw)
@@ -809,11 +811,31 @@ fm10k_dev_stop(struct rte_eth_dev *dev)

PMD_INIT_FUNC_TRACE();

-   for (i = 0; i < dev->data->nb_tx_queues; i++)
-   fm10k_dev_tx_queue_stop(dev, i);
+   if (dev->data->tx_queues)
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_dev_tx_queue_stop(dev, i);

-   for (i = 0; i < dev->data->nb_rx_queues; i++)
-   fm10k_dev_rx_queue_stop(dev, i);
+   if (dev->data->rx_queues)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_dev_rx_queue_stop(dev, i);
+}
+
+static void
+fm10k_dev_queue_release(struct rte_eth_dev *dev)
+{
+   int i;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (dev->data->tx_queues) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_tx_queue_release(dev->data->tx_queues[i]);
+   }
+
+   if (dev->data->rx_queues) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_rx_queue_release(dev->data->rx_queues[i]);
+   }
 }

 static void
@@ -828,6 +850,7 @@ fm10k_dev_close(struct rte_eth_dev *dev)
/* Stop mailbox service first */
fm10k_close_mbx_service(hw);
fm10k_dev_stop(dev);
+   fm10k_dev_queue_release(dev);
fm10k_stop_hw(hw);
 }

-- 
1.9.3



[dpdk-dev] [PATCH 0/2 v5] Enable hotplug support for fm10k

2015-07-14 Thread Michael Qiu
Hotplug feature is supported in EAL, this patch set is to enable
this feature in driver side.

change log:
v5 --> v4:
remove rte queue memory release in PMD level
v4 --> v3:
rebase code.
v3 --> v2:
reset queue numbers to zero.
v2 --> v1:
remove __rte_unused flag

Michael Qiu (2):
  fm10k: Free queues when close port
  fm10k: Add hotplug support for fm10k

 drivers/net/fm10k/fm10k_ethdev.c | 134 +--
 1 file changed, 129 insertions(+), 5 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH] BugFix: VFIO never works

2015-07-10 Thread Michael Qiu
Commit 35b3313e322b ("pci: merge mapping functions for linux and bsd")

introduced a bug that all vfio will be
blocked.

Root cause is that VFIO_PRESENT is unaccessable in eal
common level.

This patch is to fix this.

Signed-off-by: Michael Qiu 
---
 lib/librte_eal/common/eal_common_pci.c |  2 --
 lib/librte_eal/common/eal_private.h|  3 +++
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 10 ++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 3805aed..f3dc697 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -146,10 +146,8 @@ pci_map_device(struct rte_pci_device *dev)
/* try mapping the NIC resources using VFIO if it exists */
switch (dev->kdrv) {
case RTE_KDRV_VFIO:
-#ifdef VFIO_PRESENT
if (pci_vfio_is_enabled())
ret = pci_vfio_map_resource(dev);
-#endif
break;
case RTE_KDRV_IGB_UIO:
case RTE_KDRV_UIO_GENERIC:
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index e16bb68..10995c3 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -174,6 +174,9 @@ int pci_unbind_kernel_driver(struct rte_pci_device *dev);
  */
 int pci_uio_map_resource(struct rte_pci_device *dev);

+int pci_vfio_is_enabled(void);
+
+int pci_vfio_map_resource(struct rte_pci_device *dev);
 /**
  * Unmap the PCI resource of a PCI device
  *
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 426953a..3b5da34 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -909,4 +909,14 @@ pci_vfio_is_enabled(void)
 {
return vfio_cfg.vfio_enabled;
 }
+#else
+int pci_vfio_is_enabled(void)
+{
+   return 0;
+}
+
+int pci_vfio_map_resource(__rte_unused struct rte_pci_device *dev)
+{
+   return -1;
+}
 #endif
-- 
2.1.0



[dpdk-dev] [PATCH 2/2 v4] fm10k: Add hotplug support for fm10k

2015-06-26 Thread Michael Qiu
Add hotplug support for fm10k.

Signed-off-by: Michael Qiu 
Acked-by: Jing Chen 
---
 drivers/net/fm10k/fm10k_ethdev.c | 97 +++-
 1 file changed, 96 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index eba7228..0f55686 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1710,6 +1710,36 @@ fm10k_dev_enable_intr_pf(struct rte_eth_dev *dev)
 }

 static void
+fm10k_dev_disable_intr_pf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_Mailbox), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_PCIeFault), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchUpDown), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchEvent), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SRAM), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_VFLR), int_map);
+
+   /* Disable misc causes */
+   FM10K_WRITE_REG(hw, FM10K_EIMR, FM10K_EIMR_DISABLE(PCA_FAULT) |
+   FM10K_EIMR_DISABLE(THI_FAULT) |
+   FM10K_EIMR_DISABLE(FUM_FAULT) |
+   FM10K_EIMR_DISABLE(MAILBOX) |
+   FM10K_EIMR_DISABLE(SWITCHREADY) |
+   FM10K_EIMR_DISABLE(SWITCHNOTREADY) |
+   FM10K_EIMR_DISABLE(SRAMERROR) |
+   FM10K_EIMR_DISABLE(VFLR));
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
+static void
 fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
 {
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1727,6 +1757,22 @@ fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
FM10K_WRITE_FLUSH(hw);
 }

+static void
+fm10k_dev_disable_intr_vf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   /* Only INT 0 available, other 15 are reserved. */
+   FM10K_WRITE_REG(hw, FM10K_VFINT_MAP, int_map);
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
 static int
 fm10k_dev_handle_fault(struct fm10k_hw *hw, uint32_t eicr)
 {
@@ -2177,6 +2223,54 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
return 0;
 }

+static int
+eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* only uninitialize in the primary process */
+   if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+   return 0;
+
+   /* safe to close dev here */
+   fm10k_dev_close(dev);
+
+   dev->dev_ops = NULL;
+   dev->rx_pkt_burst = NULL;
+   dev->tx_pkt_burst = NULL;
+
+   /* disable uio/vfio intr */
+   rte_intr_disable(&(dev->pci_dev->intr_handle));
+
+   /*PF/VF has different interrupt handling mechanism */
+   if (hw->mac.type == fm10k_mac_pf) {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_pf(dev);
+
+   /* unregister callback func to eal lib */
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_pf, (void *)dev);
+   } else {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_vf(dev);
+
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_vf, (void *)dev);
+   }
+
+   /* free mac memory */
+   if (dev->data->mac_addrs) {
+   rte_free(dev->data->mac_addrs);
+   dev->data->mac_addrs = NULL;
+   }
+
+   memset(hw, 0, sizeof(*hw));
+
+   return 0;
+}
+
 /*
  * The set of PCI devices this driver supports. This driver will enable both PF
  * and SRIOV-VF devices.
@@ -2192,9 +2286,10 @@ static struct eth_driver rte_pmd_fm10k = {
.pci_drv = {
.name = "rte_pmd_fm10k",
.id_table = pci_id_fm10k_map,
-   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
},
.eth_dev_init = eth_fm10k_dev_init,
+   .eth_dev_uninit = eth_fm10k_dev_uninit,
.dev_private_size = sizeof(struct fm10k_adapter),
 };

-- 
1.9.3



[dpdk-dev] [PATCH 1/2 v4] fm10k: Free queues when close port

2015-06-26 Thread Michael Qiu
When close a port, lots of memory should be released,
such as software rings, queues, etc.

Signed-off-by: Michael Qiu 
---
 drivers/net/fm10k/fm10k_ethdev.c | 37 +
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 406c350..eba7228 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -65,6 +65,8 @@ static void
 fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add);
 static void
 fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev);
+static void fm10k_tx_queue_release(void *queue);
+static void fm10k_rx_queue_release(void *queue);

 static void
 fm10k_mbx_initlock(struct fm10k_hw *hw)
@@ -809,11 +811,37 @@ fm10k_dev_stop(struct rte_eth_dev *dev)

PMD_INIT_FUNC_TRACE();

-   for (i = 0; i < dev->data->nb_tx_queues; i++)
-   fm10k_dev_tx_queue_stop(dev, i);
+   if (dev->data->tx_queues)
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_dev_tx_queue_stop(dev, i);

-   for (i = 0; i < dev->data->nb_rx_queues; i++)
-   fm10k_dev_rx_queue_stop(dev, i);
+   if (dev->data->rx_queues)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_dev_rx_queue_stop(dev, i);
+}
+
+static void
+fm10k_dev_queue_release(struct rte_eth_dev *dev)
+{
+   int i;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (dev->data->tx_queues) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_tx_queue_release(dev->data->tx_queues[i]);
+   rte_free(dev->data->tx_queues);
+   dev->data->tx_queues = NULL;
+   dev->data->nb_tx_queues = 0;
+   }
+
+   if (dev->data->rx_queues) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_rx_queue_release(dev->data->rx_queues[i]);
+   rte_free(dev->data->rx_queues);
+   dev->data->rx_queues = NULL;
+   dev->data->nb_rx_queues = 0;
+   }
 }

 static void
@@ -828,6 +856,7 @@ fm10k_dev_close(struct rte_eth_dev *dev)
/* Stop mailbox service first */
fm10k_close_mbx_service(hw);
fm10k_dev_stop(dev);
+   fm10k_dev_queue_release(dev);
fm10k_stop_hw(hw);
 }

-- 
1.9.3



[dpdk-dev] [PATCH 0/2 v4] Enable hotplug support for fm10k

2015-06-26 Thread Michael Qiu
Hotplug feature is supported in EAL, this patch set is to enable
this feature in driver side.

change log:
v4 --> v3:
rebase code.
v3 --> v2:
reset queue numbers to zero.
v2 --> v1:
remove __rte_unused flag

Michael Qiu (2):
  fm10k: Free queues when close port
  fm10k: Add hotplug support for fm10k

 drivers/net/fm10k/fm10k_ethdev.c | 134 +--
 1 file changed, 129 insertions(+), 5 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH] testpmd: Fix wrong message in testpmd

2015-06-24 Thread Michael Qiu
When close one port twice, testpmd will give out wrong messagse.

testpmd> port stop  0
Stopping ports...
Checking link statuses...
Port 0 Link Up - speed 0 Mbps - full-duplex
Port 1 Link Up - speed 0 Mbps - full-duplex
Done
testpmd> port close 0
Closing ports...
Done
testpmd> port close 0
Closing ports...
Port 0 is now not stopped
Done
testpmd> 


Signed-off-by: Michael Qiu 
---
 app/test-pmd/testpmd.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 3057791..907cda3 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1534,6 +1534,12 @@ close_port(portid_t pid)

port = [pi];
if (rte_atomic16_cmpset(&(port->port_status),
+   RTE_PORT_CLOSED, RTE_PORT_CLOSED) == 1) {
+   printf("Port %d is already closed\n", pi);
+   continue;
+   }
+
+   if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_STOPPED, RTE_PORT_HANDLING) == 0) {
printf("Port %d is now not stopped\n", pi);
continue;
-- 
2.1.0



[dpdk-dev] [PATCH 2/2 v2] fm10k: Add hotplug support for fm10k

2015-06-19 Thread Michael Qiu
Add hotplug support for fm10k.

Signed-off-by: Michael Qiu 
---
 drivers/net/fm10k/fm10k_ethdev.c | 97 +++-
 1 file changed, 96 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 6a14633..38d1eb7 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1414,6 +1414,36 @@ fm10k_dev_enable_intr_pf(struct rte_eth_dev *dev)
 }

 static void
+fm10k_dev_disable_intr_pf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_Mailbox), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_PCIeFault), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchUpDown), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchEvent), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SRAM), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_VFLR), int_map);
+
+   /* Disable misc causes */
+   FM10K_WRITE_REG(hw, FM10K_EIMR, FM10K_EIMR_DISABLE(PCA_FAULT) |
+   FM10K_EIMR_DISABLE(THI_FAULT) |
+   FM10K_EIMR_DISABLE(FUM_FAULT) |
+   FM10K_EIMR_DISABLE(MAILBOX) |
+   FM10K_EIMR_DISABLE(SWITCHREADY) |
+   FM10K_EIMR_DISABLE(SWITCHNOTREADY) |
+   FM10K_EIMR_DISABLE(SRAMERROR) |
+   FM10K_EIMR_DISABLE(VFLR));
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
+static void
 fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
 {
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1431,6 +1461,22 @@ fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
FM10K_WRITE_FLUSH(hw);
 }

+static void
+fm10k_dev_disable_intr_vf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   /* Only INT 0 available, other 15 are reserved. */
+   FM10K_WRITE_REG(hw, FM10K_VFINT_MAP, int_map);
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
 static int
 fm10k_dev_handle_fault(struct fm10k_hw *hw, uint32_t eicr)
 {
@@ -1860,6 +1906,54 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
return 0;
 }

+static int
+eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* only uninitialize in the primary process */
+   if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+   return 0;
+
+   /* safe to close dev here */
+   fm10k_dev_close(dev);
+
+   dev->dev_ops = NULL;
+   dev->rx_pkt_burst = NULL;
+   dev->tx_pkt_burst = NULL;
+
+   /* disable uio/vfio intr */
+   rte_intr_disable(&(dev->pci_dev->intr_handle));
+
+   /*PF/VF has different interrupt handling mechanism */
+   if (hw->mac.type == fm10k_mac_pf) {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_pf(dev);
+
+   /* unregister callback func to eal lib */
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_pf, (void *)dev);
+   } else {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_vf(dev);
+
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_vf, (void *)dev);
+   }
+
+   /* free mac memory */
+   if (dev->data->mac_addrs) {
+   rte_free(dev->data->mac_addrs);
+   dev->data->mac_addrs = NULL;
+   }
+
+   memset(hw, 0, sizeof(*hw));
+
+   return 0;
+}
+
 /*
  * The set of PCI devices this driver supports. This driver will enable both PF
  * and SRIOV-VF devices.
@@ -1875,9 +1969,10 @@ static struct eth_driver rte_pmd_fm10k = {
.pci_drv = {
.name = "rte_pmd_fm10k",
.id_table = pci_id_fm10k_map,
-   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
},
.eth_dev_init = eth_fm10k_dev_init,
+   .eth_dev_uninit = eth_fm10k_dev_uninit,
.dev_private_size = sizeof(struct fm10k_adapter),
 };

-- 
1.9.3



[dpdk-dev] [PATCH 1/2 v3] fm10k: Free queues when close port

2015-06-19 Thread Michael Qiu
When close a port, lots of memory should be released,
such as software rings, queues, etc.

Signed-off-by: Michael Qiu 
---
 drivers/net/fm10k/fm10k_ethdev.c | 39 +++
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 4afd5ab..6a14633 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -52,6 +52,10 @@

 static void fm10k_close_mbx_service(struct fm10k_hw *hw);

+static void fm10k_tx_queue_release(void *queue);
+
+static void fm10k_rx_queue_release(void *queue);
+
 static void
 fm10k_mbx_initlock(struct fm10k_hw *hw)
 {
@@ -665,11 +669,37 @@ fm10k_dev_stop(struct rte_eth_dev *dev)

PMD_INIT_FUNC_TRACE();

-   for (i = 0; i < dev->data->nb_tx_queues; i++)
-   fm10k_dev_tx_queue_stop(dev, i);
+   if (dev->data->tx_queues)
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_dev_tx_queue_stop(dev, i);
+
+   if (dev->data->rx_queues)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_dev_rx_queue_stop(dev, i);
+}

-   for (i = 0; i < dev->data->nb_rx_queues; i++)
-   fm10k_dev_rx_queue_stop(dev, i);
+static void
+fm10k_dev_queue_release(struct rte_eth_dev *dev)
+{
+   int i;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (dev->data->tx_queues) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_tx_queue_release(dev->data->tx_queues[i]);
+   rte_free(dev->data->tx_queues);
+   dev->data->tx_queues = NULL;
+   dev->data->nb_tx_queues = 0;
+   }
+
+   if (dev->data->rx_queues) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_rx_queue_release(dev->data->rx_queues[i]);
+   rte_free(dev->data->rx_queues);
+   dev->data->rx_queues = NULL;
+   dev->data->nb_rx_queues = 0;
+   }
 }

 static void
@@ -682,6 +712,7 @@ fm10k_dev_close(struct rte_eth_dev *dev)
/* Stop mailbox service first */
fm10k_close_mbx_service(hw);
fm10k_dev_stop(dev);
+   fm10k_dev_queue_release(dev);
fm10k_stop_hw(hw);
 }

-- 
1.9.3



[dpdk-dev] [PATCH 0/2 v3] Enable hotplug support for fm10k

2015-06-19 Thread Michael Qiu
Hotplug feature is supported in EAL, this patch set is to enable
this feature in driver side.

change log:
v3-->v2:
reset queue numbers to zero.
v2 --> v1:
remove __rte_unused flag

Michael Qiu (2):
  fm10k: Free queues when close port
  fm10k: Add hotplug support for fm10k

 drivers/net/fm10k/fm10k_ethdev.c | 134 +--
 1 file changed, 129 insertions(+), 5 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH 2/2 v2] fm10k: Add hotplug support for fm10k

2015-06-17 Thread Michael Qiu
Add hotplug support for fm10k.

Signed-off-by: Michael Qiu 
---
 drivers/net/fm10k/fm10k_ethdev.c | 97 +++-
 1 file changed, 96 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index e310698..0d3eaf1 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1412,6 +1412,36 @@ fm10k_dev_enable_intr_pf(struct rte_eth_dev *dev)
 }

 static void
+fm10k_dev_disable_intr_pf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_Mailbox), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_PCIeFault), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchUpDown), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchEvent), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SRAM), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_VFLR), int_map);
+
+   /* Disable misc causes */
+   FM10K_WRITE_REG(hw, FM10K_EIMR, FM10K_EIMR_DISABLE(PCA_FAULT) |
+   FM10K_EIMR_DISABLE(THI_FAULT) |
+   FM10K_EIMR_DISABLE(FUM_FAULT) |
+   FM10K_EIMR_DISABLE(MAILBOX) |
+   FM10K_EIMR_DISABLE(SWITCHREADY) |
+   FM10K_EIMR_DISABLE(SWITCHNOTREADY) |
+   FM10K_EIMR_DISABLE(SRAMERROR) |
+   FM10K_EIMR_DISABLE(VFLR));
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
+static void
 fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
 {
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1429,6 +1459,22 @@ fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
FM10K_WRITE_FLUSH(hw);
 }

+static void
+fm10k_dev_disable_intr_vf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   /* Only INT 0 available, other 15 are reserved. */
+   FM10K_WRITE_REG(hw, FM10K_VFINT_MAP, int_map);
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
 static int
 fm10k_dev_handle_fault(struct fm10k_hw *hw, uint32_t eicr)
 {
@@ -1858,6 +1904,54 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
return 0;
 }

+static int
+eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* only uninitialize in the primary process */
+   if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+   return 0;
+
+   /* safe to close dev here */
+   fm10k_dev_close(dev);
+
+   dev->dev_ops = NULL;
+   dev->rx_pkt_burst = NULL;
+   dev->tx_pkt_burst = NULL;
+
+   /* disable uio/vfio intr */
+   rte_intr_disable(&(dev->pci_dev->intr_handle));
+
+   /*PF/VF has different interrupt handling mechanism */
+   if (hw->mac.type == fm10k_mac_pf) {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_pf(dev);
+
+   /* unregister callback func to eal lib */
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_pf, (void *)dev);
+   } else {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_vf(dev);
+
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_vf, (void *)dev);
+   }
+
+   /* free mac memory */
+   if (dev->data->mac_addrs) {
+   rte_free(dev->data->mac_addrs);
+   dev->data->mac_addrs = NULL;
+   }
+
+   memset(hw, 0, sizeof(*hw));
+
+   return 0;
+}
+
 /*
  * The set of PCI devices this driver supports. This driver will enable both PF
  * and SRIOV-VF devices.
@@ -1873,9 +1967,10 @@ static struct eth_driver rte_pmd_fm10k = {
{
.name = "rte_pmd_fm10k",
.id_table = pci_id_fm10k_map,
-   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
},
.eth_dev_init = eth_fm10k_dev_init,
+   .eth_dev_uninit = eth_fm10k_dev_uninit,
.dev_private_size = sizeof(struct fm10k_adapter),
 };

-- 
1.9.3



[dpdk-dev] [PATCH v2] ixgbe: reset hardware stat when initialize

2015-06-11 Thread Michael Qiu
When initialize the hardware, the stat should be reset.
Otherwise when detach then attach port, the stat will not
be re-init to zero.

Signed-off-by: Michael Qiu 
---
Change log:
v2 --> v1:
change the folder of driver

 drivers/net/ixgbe/ixgbe_ethdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 0d9f9b2..e0415a7 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -840,6 +840,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
return -EIO;
}

+   /* Reset the hw statistics */
+   ixgbe_dev_stats_reset(eth_dev);
+
/* disable interrupt */
ixgbe_disable_intr(hw);

@@ -1012,6 +1015,9 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
/* init_mailbox_params */
hw->mbx.ops.init_params(hw);

+   /* Reset the hw statistics */
+   ixgbevf_dev_stats_reset(eth_dev);
+
/* Disable the interrupts for VF */
ixgbevf_intr_disable(hw);

-- 
1.9.3



[dpdk-dev] [PATCH 2/2] fm10k: Add hotplug support for fm10k

2015-06-10 Thread Michael Qiu
Add hotplug support for fm10k.

Signed-off-by: Michael Qiu 
---
 drivers/net/fm10k/fm10k_ethdev.c | 97 +++-
 1 file changed, 96 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index e310698..0d3eaf1 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1412,6 +1412,36 @@ fm10k_dev_enable_intr_pf(struct rte_eth_dev *dev)
 }

 static void
+fm10k_dev_disable_intr_pf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_Mailbox), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_PCIeFault), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchUpDown), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchEvent), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SRAM), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_VFLR), int_map);
+
+   /* Disable misc causes */
+   FM10K_WRITE_REG(hw, FM10K_EIMR, FM10K_EIMR_DISABLE(PCA_FAULT) |
+   FM10K_EIMR_DISABLE(THI_FAULT) |
+   FM10K_EIMR_DISABLE(FUM_FAULT) |
+   FM10K_EIMR_DISABLE(MAILBOX) |
+   FM10K_EIMR_DISABLE(SWITCHREADY) |
+   FM10K_EIMR_DISABLE(SWITCHNOTREADY) |
+   FM10K_EIMR_DISABLE(SRAMERROR) |
+   FM10K_EIMR_DISABLE(VFLR));
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
+static void
 fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
 {
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1429,6 +1459,22 @@ fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
FM10K_WRITE_FLUSH(hw);
 }

+static void
+fm10k_dev_disable_intr_vf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   /* Only INT 0 available, other 15 are reserved. */
+   FM10K_WRITE_REG(hw, FM10K_VFINT_MAP, int_map);
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
 static int
 fm10k_dev_handle_fault(struct fm10k_hw *hw, uint32_t eicr)
 {
@@ -1858,6 +1904,54 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
return 0;
 }

+static int
+eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* only uninitialize in the primary process */
+   if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+   return 0;
+
+   /* safe to close dev here */
+   fm10k_dev_close(dev);
+
+   dev->dev_ops = NULL;
+   dev->rx_pkt_burst = NULL;
+   dev->tx_pkt_burst = NULL;
+
+   /* disable uio/vfio intr */
+   rte_intr_disable(&(dev->pci_dev->intr_handle));
+
+   /*PF/VF has different interrupt handling mechanism */
+   if (hw->mac.type == fm10k_mac_pf) {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_pf(dev);
+
+   /* unregister callback func to eal lib */
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_pf, (void *)dev);
+   } else {
+   /* disable interrupt */
+   fm10k_dev_disable_intr_vf(dev);
+
+   rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+   fm10k_dev_interrupt_handler_vf, (void *)dev);
+   }
+
+   /* free mac memory */
+   if (dev->data->mac_addrs) {
+   rte_free(dev->data->mac_addrs);
+   dev->data->mac_addrs = NULL;
+   }
+
+   memset(hw, 0, sizeof(*hw));
+
+   return 0;
+}
+
 /*
  * The set of PCI devices this driver supports. This driver will enable both PF
  * and SRIOV-VF devices.
@@ -1873,9 +1967,10 @@ static struct eth_driver rte_pmd_fm10k = {
{
.name = "rte_pmd_fm10k",
.id_table = pci_id_fm10k_map,
-   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
},
.eth_dev_init = eth_fm10k_dev_init,
+   .eth_dev_uninit = eth_fm10k_dev_uninit,
.dev_private_size = sizeof(struct fm10k_adapter),
 };

-- 
1.9.3



[dpdk-dev] [PATCH 1/2] fm10k: Free queues when close port

2015-06-10 Thread Michael Qiu
When close a port, lots of memory should be released,
such as software rings, queues, etc.

Signed-off-by: Michael Qiu 
---
 drivers/net/fm10k/fm10k_ethdev.c | 37 +
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 87852ed..e310698 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -52,6 +52,10 @@

 static void fm10k_close_mbx_service(struct fm10k_hw *hw);

+static void fm10k_tx_queue_release(void *queue);
+
+static void fm10k_rx_queue_release(void *queue);
+
 static void
 fm10k_mbx_initlock(struct fm10k_hw *hw)
 {
@@ -665,11 +669,35 @@ fm10k_dev_stop(struct rte_eth_dev *dev)

PMD_INIT_FUNC_TRACE();

-   for (i = 0; i < dev->data->nb_tx_queues; i++)
-   fm10k_dev_tx_queue_stop(dev, i);
+   if (dev->data->tx_queues)
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_dev_tx_queue_stop(dev, i);
+
+   if (dev->data->rx_queues)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_dev_rx_queue_stop(dev, i);
+}

-   for (i = 0; i < dev->data->nb_rx_queues; i++)
-   fm10k_dev_rx_queue_stop(dev, i);
+static void
+fm10k_dev_queue_release(__rte_unused struct rte_eth_dev *dev)
+{
+   int i;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (dev->data->tx_queues) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_tx_queue_release(dev->data->tx_queues[i]);
+   rte_free(dev->data->tx_queues);
+   dev->data->tx_queues = NULL;
+   }
+
+   if (dev->data->rx_queues) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_rx_queue_release(dev->data->rx_queues[i]);
+   rte_free(dev->data->rx_queues);
+   dev->data->rx_queues = NULL;
+   }
 }

 static void
@@ -682,6 +710,7 @@ fm10k_dev_close(struct rte_eth_dev *dev)
/* Stop mailbox service first */
fm10k_close_mbx_service(hw);
fm10k_dev_stop(dev);
+   fm10k_dev_queue_release(dev);
fm10k_stop_hw(hw);
 }

-- 
1.9.3



[dpdk-dev] [PATCH 0/2 v2] Enable hotplug support for fm10k

2015-06-10 Thread Michael Qiu
Hotplug feature is supported in EAL, this patch set is to enable
this feature in driver side.

Michael Qiu (2):
  fm10k: Free queues when close port
  fm10k: Add hotplug support for fm10k

 drivers/net/fm10k/fm10k_ethdev.c | 134 +--
 1 file changed, 129 insertions(+), 5 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH] librte_pmd_fm10k: Fix max_vfs issue in fm10k PMD

2015-06-02 Thread Michael Qiu
In DPDK, max_vfs means vf numbers created, not the max number vfs
the device supported.

Signed-off-by: Michael Qiu 
Acked-by Jing Chen 
---
 lib/librte_pmd_fm10k/fm10k_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_fm10k/fm10k_ethdev.c 
b/lib/librte_pmd_fm10k/fm10k_ethdev.c
index 0312fad..297ff88 100644
--- a/lib/librte_pmd_fm10k/fm10k_ethdev.c
+++ b/lib/librte_pmd_fm10k/fm10k_ethdev.c
@@ -770,7 +770,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
dev_info->max_tx_queues  = hw->mac.max_queues;
dev_info->max_mac_addrs  = 1;
dev_info->max_hash_mac_addrs = 0;
-   dev_info->max_vfs= FM10K_MAX_VF_NUM;
+   dev_info->max_vfs= dev->pci_dev->max_vfs;
dev_info->max_vmdq_pools = ETH_64_POOLS;
dev_info->rx_offload_capa =
DEV_RX_OFFLOAD_IPV4_CKSUM |
-- 
1.9.3



[dpdk-dev] [RFC PATCH] librte_pmd_fm10k: Add hotplug support for fm10k

2015-05-31 Thread Michael Qiu
Add hotplug support for fm10k

Signed-off-by: Michael Qiu 
---
 lib/librte_pmd_fm10k/fm10k_ethdev.c | 134 ++--
 1 file changed, 129 insertions(+), 5 deletions(-)

diff --git a/lib/librte_pmd_fm10k/fm10k_ethdev.c 
b/lib/librte_pmd_fm10k/fm10k_ethdev.c
index 7f5f513..3d72607 100644
--- a/lib/librte_pmd_fm10k/fm10k_ethdev.c
+++ b/lib/librte_pmd_fm10k/fm10k_ethdev.c
@@ -55,6 +55,10 @@

 static void fm10k_close_mbx_service(struct fm10k_hw *hw);

+static void fm10k_tx_queue_release(void *queue);
+
+static void fm10k_rx_queue_release(void *queue);
+
 static void
 fm10k_mbx_initlock(struct fm10k_hw *hw)
 {
@@ -688,11 +692,35 @@ fm10k_dev_stop(struct rte_eth_dev *dev)

PMD_INIT_FUNC_TRACE();

-   for (i = 0; i < dev->data->nb_tx_queues; i++)
-   fm10k_dev_tx_queue_stop(dev, i);
+   if (dev->data->tx_queues)
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_dev_tx_queue_stop(dev, i);

-   for (i = 0; i < dev->data->nb_rx_queues; i++)
-   fm10k_dev_rx_queue_stop(dev, i);
+   if (dev->data->rx_queues)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_dev_rx_queue_stop(dev, i);
+}
+
+static void
+fm10k_dev_queue_release(__rte_unused struct rte_eth_dev *dev)
+{
+   int i;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (dev->data->tx_queues) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   fm10k_tx_queue_release(dev->data->tx_queues[i]);
+   rte_free(dev->data->tx_queues);
+   dev->data->tx_queues = NULL;
+   }
+
+   if (dev->data->rx_queues) {
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   fm10k_rx_queue_release(dev->data->rx_queues[i]);
+   rte_free(dev->data->rx_queues);
+   dev->data->rx_queues = NULL;
+   }
 }

 static void
@@ -705,6 +733,7 @@ fm10k_dev_close(struct rte_eth_dev *dev)
/* Stop mailbox service first */
fm10k_close_mbx_service(hw);
fm10k_dev_stop(dev);
+   fm10k_dev_queue_release(dev);
fm10k_stop_hw(hw);
 }

@@ -1406,6 +1435,36 @@ fm10k_dev_enable_intr_pf(struct rte_eth_dev *dev)
 }

 static void
+fm10k_dev_disable_intr_pf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_Mailbox), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_PCIeFault), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchUpDown), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchEvent), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SRAM), int_map);
+   FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_VFLR), int_map);
+
+   /* Disable misc causes */
+   FM10K_WRITE_REG(hw, FM10K_EIMR, FM10K_EIMR_DISABLE(PCA_FAULT) |
+   FM10K_EIMR_DISABLE(THI_FAULT) |
+   FM10K_EIMR_DISABLE(FUM_FAULT) |
+   FM10K_EIMR_DISABLE(MAILBOX) |
+   FM10K_EIMR_DISABLE(SWITCHREADY) |
+   FM10K_EIMR_DISABLE(SWITCHNOTREADY) |
+   FM10K_EIMR_DISABLE(SRAMERROR) |
+   FM10K_EIMR_DISABLE(VFLR));
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
+static void
 fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
 {
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1423,6 +1482,22 @@ fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)
FM10K_WRITE_FLUSH(hw);
 }

+static void
+fm10k_dev_disable_intr_vf(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint32_t int_map = FM10K_INT_MAP_DISABLE;
+
+   int_map |= 0;
+
+   /* Only INT 0 available, other 15 are reserved. */
+   FM10K_WRITE_REG(hw, FM10K_VFINT_MAP, int_map);
+
+   /* Disable ITR 0 */
+   FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_MASK_SET);
+   FM10K_WRITE_FLUSH(hw);
+}
+
 static int
 fm10k_dev_handle_fault(struct fm10k_hw *hw, uint32_t eicr)
 {
@@ -1868,6 +1943,54 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
return 0;
 }

+static int
+eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* only uninitialize in the primary process */
+   if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+   return 0;
+
+   /* safe to close dev here */
+   fm10k_d

[dpdk-dev] [PATCH] vhost: Fix Segmentation fault of NULL address

2015-03-26 Thread Michael Qiu
Function gpa_to_vva() could return zero, while this will lead
a Segmentation fault.

This patch is to fix this issue.

Signed-off-by: Michael Qiu 
---
 lib/librte_vhost/vhost_rxtx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 535c7a1..23c8acb 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -587,6 +587,9 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t 
queue_id,

/* Buffer address translation. */
vb_addr = gpa_to_vva(dev, desc->addr);
+   if (!vb_addr)
+   return entry_success;
+
/* Prefetch buffer address. */
rte_prefetch0((void *)(uintptr_t)vb_addr);

-- 
1.9.3



[dpdk-dev] [PATCH] fm10k: Fix queue start twice failed

2015-03-25 Thread Michael Qiu
When use "port 0 rxq 0 start" in testpmd twice, the rx queue 0 on
port 0 will failed to work.

The root casue is the rxqctl enable bit need to reset if already
enabled.

Signed-off-by: Michael Qiu 
---
 lib/librte_pmd_fm10k/fm10k_ethdev.c | 56 +
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/lib/librte_pmd_fm10k/fm10k_ethdev.c 
b/lib/librte_pmd_fm10k/fm10k_ethdev.c
index 0c7a80c..0312fad 100644
--- a/lib/librte_pmd_fm10k/fm10k_ethdev.c
+++ b/lib/librte_pmd_fm10k/fm10k_ethdev.c
@@ -72,6 +72,30 @@ fm10k_mbx_unlock(struct fm10k_hw *hw)
 }

 /*
+ * clean queue, descriptor rings, free software buffers used when stopping
+ * device.
+ */
+static inline void
+rx_queue_clean(struct fm10k_rx_queue *q)
+{
+   union fm10k_rx_desc zero = {.q = {0, 0, 0, 0} };
+   uint32_t i;
+   PMD_INIT_FUNC_TRACE();
+
+   /* zero descriptor rings */
+   for (i = 0; i < q->nb_desc; ++i)
+   q->hw_ring[i] = zero;
+
+   /* free software buffers */
+   for (i = 0; i < q->nb_desc; ++i) {
+   if (q->sw_ring[i]) {
+   rte_pktmbuf_free_seg(q->sw_ring[i]);
+   q->sw_ring[i] = NULL;
+   }
+   }
+}
+
+/*
  * reset queue to initial state, allocate software buffers used when starting
  * device.
  * return 0 on success
@@ -85,6 +109,9 @@ rx_queue_reset(struct fm10k_rx_queue *q)
int i, diag;
PMD_INIT_FUNC_TRACE();

+   /* clean the memory before allocate */
+   rx_queue_clean(q);
+
diag = rte_mempool_get_bulk(q->mp, (void **)q->sw_ring, q->nb_desc);
if (diag != 0)
return -ENOMEM;
@@ -109,30 +136,6 @@ rx_queue_reset(struct fm10k_rx_queue *q)
 }

 /*
- * clean queue, descriptor rings, free software buffers used when stopping
- * device.
- */
-static inline void
-rx_queue_clean(struct fm10k_rx_queue *q)
-{
-   union fm10k_rx_desc zero = {.q = {0, 0, 0, 0} };
-   uint32_t i;
-   PMD_INIT_FUNC_TRACE();
-
-   /* zero descriptor rings */
-   for (i = 0; i < q->nb_desc; ++i)
-   q->hw_ring[i] = zero;
-
-   /* free software buffers */
-   for (i = 0; i < q->nb_desc; ++i) {
-   if (q->sw_ring[i]) {
-   rte_pktmbuf_free_seg(q->sw_ring[i]);
-   q->sw_ring[i] = NULL;
-   }
-   }
-}
-
-/*
  * free all queue memory used when releasing the queue (i.e. configure)
  */
 static inline void
@@ -492,6 +495,11 @@ fm10k_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t 
rx_queue_id)
reg = FM10K_READ_REG(hw, FM10K_RXQCTL(rx_queue_id));
if (hw->mac.type == fm10k_mac_pf)
reg |= FM10K_RXQCTL_PF;
+
+   /* already enable? need reset to 0 */
+   if ((reg & FM10K_RXQCTL_ENABLE) == 1)
+   FM10K_WRITE_REG(hw, FM10K_RXQCTL(rx_queue_id), (reg & 
~FM10K_RXQCTL_ENABLE));
+
reg |= FM10K_RXQCTL_ENABLE;
/* enable RX queue */
FM10K_WRITE_REG(hw, FM10K_RXQCTL(rx_queue_id), reg);
-- 
1.9.3



[dpdk-dev] [PATCH] librte_hash: Fix crc32 error when complie i686 in x86_64

2015-03-23 Thread Michael Qiu
When compile target i686 in platform x86_64, the stud fuction will
be called, and return zero.

This patch fix this issue.

Signed-off-by: Michael Qiu 
---
 lib/librte_hash/rte_hash_crc.h | 35 ++-
 1 file changed, 6 insertions(+), 29 deletions(-)

diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h
index 3dcd362..1cd626c 100644
--- a/lib/librte_hash/rte_hash_crc.h
+++ b/lib/librte_hash/rte_hash_crc.h
@@ -366,7 +366,6 @@ crc32c_2words(uint64_t data, uint32_t init_val)
 }

 #if defined(RTE_ARCH_I686) || defined(RTE_ARCH_X86_64)
-
 static inline uint32_t
 crc32c_sse42_u32(uint32_t data, uint32_t init_val)
 {
@@ -390,27 +389,9 @@ crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
init_val = crc32c_sse42_u32(d.u32[1], init_val);
return init_val;
 }
-
-#else
-
-static inline uint32_t
-crc32c_sse42_u32(__rte_unused uint32_t data,
- __rte_unused uint32_t init_val)
-{
-   return 0;
-}
-
-static inline uint32_t
-crc32c_sse42_u64_mimic(__rte_unused uint32_t data,
-   __rte_unused uint32_t init_val)
-{
-   return 0;
-}
-
 #endif

 #ifdef RTE_ARCH_X86_64
-
 static inline uint32_t
 crc32c_sse42_u64(uint64_t data, uint64_t init_val)
 {
@@ -420,16 +401,6 @@ crc32c_sse42_u64(uint64_t data, uint64_t init_val)
: [data] "rm" (data));
return init_val;
 }
-
-#else
-
-static inline uint32_t
-crc32c_sse42_u64(__rte_unused uint64_t data,
- __rte_unused uint64_t init_val)
-{
-   return 0;
-}
-
 #endif

 #define CRC32_SW(1U << 0)
@@ -489,8 +460,10 @@ rte_hash_crc_init_alg(void)
 static inline uint32_t
 rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 {
+#if defined RTE_ARCH_I686 || defined RTE_ARCH_X86_64
if (likely(crc32_alg & CRC32_SSE42))
return crc32c_sse42_u32(data, init_val);
+#endif

return crc32c_1word(data, init_val);
 }
@@ -510,11 +483,15 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
+#ifdef RTE_ARCH_X86_64
if (likely(crc32_alg == CRC32_SSE42_x64))
return crc32c_sse42_u64(data, init_val);
+#endif

+#if defined RTE_ARCH_I686 || defined RTE_ARCH_X86_64
if (likely(crc32_alg & CRC32_SSE42))
return crc32c_sse42_u64_mimic(data, init_val);
+#endif

return crc32c_2words(data, init_val);
 }
-- 
1.9.3



[dpdk-dev] [PATCH] common/rte_memcpy: Fix x86intrin.h missed

2015-03-13 Thread Michael Qiu
rte_memcpy.h(46): catastrophic error: cannot open source file "x86intrin.h"

For icc and old gcc, this header is not included.

Signed-off-by: Michael Qiu 
---
 lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h 
b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index ac72069..bd10d36 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -43,7 +43,27 @@
 #include 
 #include 
 #include 
+#if (defined(__ICC) || (__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
+
+#ifdef __SSE__
+#include 
+#endif
+
+#ifdef __SSE2__
+#include 
+#endif
+
+#if defined(__SSE4_2__) || defined(__SSE4_1__)
+#include 
+#endif
+
+#if defined(__AVX__)
+#include 
+#endif
+
+#else
 #include 
+#endif

 #ifdef __cplusplus
 extern "C" {
-- 
1.9.3



[dpdk-dev] [PATCH] testpmd: Fix action of operationg invalid port

2015-03-09 Thread Michael Qiu
Currently, if try to  start/stop/close one invalid prot,
no error shows in testpmd.
This is a bug, need check the port number.

Signed-off-by: Michael Qiu 
---
 app/test-pmd/config.c  |  3 +++
 app/test-pmd/testpmd.c | 14 --
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 49be819..ec53923 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -384,6 +384,9 @@ port_infos_display(portid_t port_id)
 int
 port_id_is_invalid(portid_t port_id, enum print_warning warning)
 {
+   if (port_id == (portid_t)RTE_PORT_ALL)
+   return 0;
+
if (ports[port_id].enabled)
return 0;

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e556b4c..1c4c651 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1326,6 +1326,9 @@ start_port(portid_t pid)
return -1;
}

+   if (port_id_is_invalid(pid, ENABLED_WARN))
+   return 0;
+
if (init_fwd_streams() < 0) {
printf("Fail from init_fwd_streams()\n");
return -1;
@@ -1482,10 +1485,14 @@ stop_port(portid_t pid)
dcb_test = 0;
dcb_config = 0;
}
+
+   if (port_id_is_invalid(pid, ENABLED_WARN))
+   return;
+
printf("Stopping ports...\n");

FOREACH_PORT(pi, ports) {
-   if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
+   if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
continue;

port = [pi];
@@ -1517,10 +1524,13 @@ close_port(portid_t pid)
return;
}

+   if (port_id_is_invalid(pid, ENABLED_WARN))
+return;
+
printf("Closing ports...\n");

FOREACH_PORT(pi, ports) {
-   if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
+   if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
continue;

port = [pi];
-- 
1.9.3



[dpdk-dev] [PATCH 1/3 v3] librte_hash: Fix unsupported instruction `crc32' in i686 platform

2015-03-09 Thread Michael Qiu
CC rte_hash.o
Error: unsupported instruction `crc32'

The root cause is that i686 platform does not support 'crc32q'
Need make it only available in x86_64 platform

Signed-off-by: Michael Qiu 
Acked-by: Yerden Zhumabekov 
---
v3 --> v2:
Add sub function for #else which returns 0
v2 --> v1:
 Make crc32 instruction only works in X86 platform

 lib/librte_hash/rte_hash_crc.h | 46 +-
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h
index d28bb2a..f1dbded 100644
--- a/lib/librte_hash/rte_hash_crc.h
+++ b/lib/librte_hash/rte_hash_crc.h
@@ -47,6 +47,7 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 

 /* Lookup tables for software implementation of CRC32C */
 static const uint32_t crc32c_tables[8][256] = {{
@@ -364,6 +365,7 @@ crc32c_2words(uint64_t data, uint32_t init_val)
return crc;
 }

+#if defined(RTE_ARCH_I686) || defined(RTE_ARCH_X86_64)
 static inline uint32_t
 crc32c_sse42_u32(uint32_t data, uint32_t init_val)
 {
@@ -375,16 +377,6 @@ crc32c_sse42_u32(uint32_t data, uint32_t init_val)
 }

 static inline uint32_t
-crc32c_sse42_u64(uint64_t data, uint64_t init_val)
-{
-   __asm__ volatile(
-   "crc32q %[data], %[init_val];"
-   : [init_val] "+r" (init_val)
-   : [data] "rm" (data));
-   return init_val;
-}
-
-static inline uint32_t
 crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
 {
union {
@@ -397,6 +389,40 @@ crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
init_val = crc32c_sse42_u32(d.u32[1], init_val);
return init_val;
 }
+#else
+static inline uint32_t
+crc32c_sse42_u32(__rte_unused uint32_t data,
+__rte_unused uint32_t init_val)
+{
+   return 0;
+}
+
+static inline uint32_t
+crc32c_sse42_u64_mimic(__rte_unused uint32_t data,
+  __rte_unused uint32_t init_val)
+{
+   return 0;
+}
+#endif
+
+#ifdef RTE_ARCH_X86_64
+static inline uint32_t
+crc32c_sse42_u64(uint64_t data, uint64_t init_val)
+{
+   __asm__ volatile(
+   "crc32q %[data], %[init_val];"
+   : [init_val] "+r" (init_val)
+   : [data] "rm" (data));
+   return init_val;
+}
+#else
+static inline uint32_t
+crc32c_sse42_u64(__rte_unused uint64_t data,
+__rte_unused uint64_t init_val)
+{
+   return 0;
+}
+#endif

 #define CRC32_SW(1U << 0)
 #define CRC32_SSE42 (1U << 1)
-- 
1.9.3



[dpdk-dev] [PATCH] librte_pmd_fm10k: Set pointer to NULL after free

2015-03-06 Thread Michael Qiu
It could be a potential not safe issue.

Signed-off-by: Michael Qiu 
---
 lib/librte_pmd_fm10k/fm10k_ethdev.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/librte_pmd_fm10k/fm10k_ethdev.c 
b/lib/librte_pmd_fm10k/fm10k_ethdev.c
index 07ea1e7..30962d3 100644
--- a/lib/librte_pmd_fm10k/fm10k_ethdev.c
+++ b/lib/librte_pmd_fm10k/fm10k_ethdev.c
@@ -142,9 +142,12 @@ rx_queue_free(struct fm10k_rx_queue *q)
if (q) {
PMD_INIT_LOG(DEBUG, "Freeing rx queue %p", q);
rx_queue_clean(q);
-   if (q->sw_ring)
+   if (q->sw_ring) {
rte_free(q->sw_ring);
+   q->sw_ring = NULL;
+   }
rte_free(q);
+   q = NULL;
}
 }

@@ -225,11 +228,16 @@ tx_queue_free(struct fm10k_tx_queue *q)
if (q) {
PMD_INIT_LOG(DEBUG, "Freeing tx queue %p", q);
tx_queue_clean(q);
-   if (q->rs_tracker.list)
+   if (q->rs_tracker.list) {
rte_free(q->rs_tracker.list);
-   if (q->sw_ring)
+   q->rs_tracker.list = NULL;
+   }
+   if (q->sw_ring) {
rte_free(q->sw_ring);
+   q->sw_ring = NULL;
+   }
rte_free(q);
+   q = NULL;
}
 }

-- 
1.9.3



[dpdk-dev] [PATCH 2/3 v3] app/test: Fix size_t printf format issue

2015-03-06 Thread Michael Qiu
test_hash.c: In function ?test_crc32_hash_alg_equiv?:
error: format ?%lu? expects argument of type ?long unsigned int?,
but argument 2 has type ?size_t? [-Werror=format]

According to C99, for size_t type should use format "%zu"

Signed-off-by: Michael Qiu 
Acked-by: Bruce Richardson 
---
v3 --> v2:
add acked-by field 
v2 --> v1:
typo fix of "format" in commit log and title

 app/test/test_hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index 653dd86..c489b8b 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -226,7 +226,7 @@ test_crc32_hash_alg_equiv(void)
if (i == CRC32_ITERATIONS)
return 0;

-   printf("Failed test data (hex, %lu bytes total):\n", data_len);
+   printf("Failed test data (hex, %zu bytes total):\n", data_len);
for (j = 0; j < data_len; j++)
printf("%02X%c", ((uint8_t *)data64)[j],
((j+1) % 16 == 0 || j == data_len - 1) ? '\n' : 
' ');
-- 
1.9.3



[dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size

2015-03-06 Thread Michael Qiu
./i686-native-linuxapp-gcc/include/rte_memcpy.h:592:23: error:
cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]

  dstofss = 16 - (int)((long long)(void *)dst & 0x0F) + 16;

Type 'long long' is 64-bit in i686 platform while 'void *'
is 32-bit.

Signed-off-by: Michael Qiu 
Signed-off-by: Zhihong Wang 
---
v4 --> v3:
fix dstofss/bits to size_t in rte_memcpy()
v3 --> v2:
make dstofss and srcofs to be type size_t
casting type use uintptr_t

v2 --> v1:
Remove unnecessary casting (void *)

 lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h 
b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index 7b2d382..6ec4434 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -196,8 +196,8 @@ static inline void *
 rte_memcpy(void *dst, const void *src, size_t n)
 {
void *ret = dst;
-   int dstofss;
-   int bits;
+   size_t dstofss;
+   size_t bits;

/**
 * Copy less than 16 bytes
@@ -271,7 +271,7 @@ COPY_BLOCK_64_BACK31:
/**
 * Make store aligned when copy size exceeds 512 bytes
 */
-   dstofss = 32 - (int)((long long)(void *)dst & 0x1F);
+   dstofss = 32 - ((uintptr_t)dst & 0x1F);
n -= dstofss;
rte_mov32((uint8_t *)dst, (const uint8_t *)src);
src = (const uint8_t *)src + dstofss;
@@ -493,8 +493,8 @@ rte_memcpy(void *dst, const void *src, size_t n)
 {
__m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8;
void *ret = dst;
-   int dstofss;
-   int srcofs;
+   size_t dstofss;
+   size_t srcofs;

/**
 * Copy less than 16 bytes
@@ -589,12 +589,12 @@ COPY_BLOCK_64_BACK15:
 * unaligned copy functions require up to 15 bytes
 * backwards access.
 */
-   dstofss = 16 - (int)((long long)(void *)dst & 0x0F) + 16;
+   dstofss = 16 - ((uintptr_t)dst & 0x0F) + 16;
n -= dstofss;
rte_mov32((uint8_t *)dst, (const uint8_t *)src);
src = (const uint8_t *)src + dstofss;
dst = (uint8_t *)dst + dstofss;
-   srcofs = (int)((long long)(const void *)src & 0x0F);
+   srcofs = ((uintptr_t)src & 0x0F);

/**
 * For aligned copy
-- 
1.9.3



[dpdk-dev] [PATCH 1/3 v2] librte_hash: Fix unsupported instruction `crc32' in i686 platform

2015-03-06 Thread Michael Qiu
CC rte_hash.o
Error: unsupported instruction `crc32'

The root cause is that i686 platform does not support 'crc32q'
Need make it only available in x86_64 platform

Signed-off-by: Michael Qiu 
---
v2 --> v1:
 Make crc32 instruction only works in X86 platform
 lib/librte_hash/rte_hash_crc.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h
index d28bb2a..c0a789e 100644
--- a/lib/librte_hash/rte_hash_crc.h
+++ b/lib/librte_hash/rte_hash_crc.h
@@ -364,6 +364,7 @@ crc32c_2words(uint64_t data, uint32_t init_val)
return crc;
 }

+#if defined RTE_ARCH_I686 || defined RTE_ARCH_X86_64
 static inline uint32_t
 crc32c_sse42_u32(uint32_t data, uint32_t init_val)
 {
@@ -373,7 +374,9 @@ crc32c_sse42_u32(uint32_t data, uint32_t init_val)
: [data] "rm" (data));
return init_val;
 }
+#endif

+#ifdef RTE_ARCH_X86_64
 static inline uint32_t
 crc32c_sse42_u64(uint64_t data, uint64_t init_val)
 {
@@ -383,7 +386,9 @@ crc32c_sse42_u64(uint64_t data, uint64_t init_val)
: [data] "rm" (data));
return init_val;
 }
+#endif

+#if defined RTE_ARCH_I686 || defined RTE_ARCH_X86_64
 static inline uint32_t
 crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
 {
@@ -397,6 +402,7 @@ crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
init_val = crc32c_sse42_u32(d.u32[1], init_val);
return init_val;
 }
+#endif

 #define CRC32_SW(1U << 0)
 #define CRC32_SSE42 (1U << 1)
@@ -455,8 +461,10 @@ rte_hash_crc_init_alg(void)
 static inline uint32_t
 rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 {
+#if defined RTE_ARCH_I686 || defined RTE_ARCH_X86_64
if (likely(crc32_alg & CRC32_SSE42))
return crc32c_sse42_u32(data, init_val);
+#endif

return crc32c_1word(data, init_val);
 }
@@ -476,11 +484,15 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
+#ifdef RTE_ARCH_X86_64
if (likely(crc32_alg == CRC32_SSE42_x64))
return crc32c_sse42_u64(data, init_val);
+#endif

+#if defined RTE_ARCH_I686 || defined RTE_ARCH_X86_64
if (likely(crc32_alg & CRC32_SSE42))
return crc32c_sse42_u64_mimic(data, init_val);
+#endif

return crc32c_2words(data, init_val);
 }
-- 
1.9.3



[dpdk-dev] [PATCH 2/3 v2] app/test: Fix size_t printf format issue

2015-03-05 Thread Michael Qiu
test_hash.c: In function ?test_crc32_hash_alg_equiv?:
error: format ?%lu? expects argument of type ?long unsigned int?,
but argument 2 has type ?size_t? [-Werror=format]

According to C99, for size_t type should use format "%zu"

Signed-off-by: Michael Qiu 
---
v2 --> v1:
typo fix of "format" in commit log and title

 app/test/test_hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index 653dd86..c489b8b 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -226,7 +226,7 @@ test_crc32_hash_alg_equiv(void)
if (i == CRC32_ITERATIONS)
return 0;

-   printf("Failed test data (hex, %lu bytes total):\n", data_len);
+   printf("Failed test data (hex, %zu bytes total):\n", data_len);
for (j = 0; j < data_len; j++)
printf("%02X%c", ((uint8_t *)data64)[j],
((j+1) % 16 == 0 || j == data_len - 1) ? '\n' : 
' ');
-- 
1.9.3



[dpdk-dev] [PATCH 3/3 v3] =?UTF-8?q?librte=5Feal/common:=20Fix=20redeclaration=20of?= =?UTF-8?q?=20enumerator=20=E2=80=98REG=5FEAX=E2=80=99?=

2015-03-05 Thread Michael Qiu
include/rte_cpuflags.h:154:2: error: redeclaration of enumerator ?REG_EAX?
In file included from /usr/include/signal.h:358:0,
 from /usr/include/sys/wait.h:30,
 from /root/dpdk/app/test/test_mp_secondary.c:50:
/usr/include/sys/ucontext.h:180:3: note: previous definition of ?REG_EAX? was 
here

In i686, from REG_EAX to REG_EDX are all defined in
/usr/include/sys/ucontext.h

Rename to CPU_REG_EAX to avoid this issue.

Signed-off-by: Michael Qiu 
---
v3 --> v2:
Fix signed-off-by field
v2 --> v1:
rename CPU_REG_EAX to RTE_REG_EAX

 .../common/include/arch/x86/rte_cpuflags.h | 210 ++---
 1 file changed, 105 insertions(+), 105 deletions(-)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h 
b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
index a58dd7b..dd56553 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
@@ -151,104 +151,104 @@ enum rte_cpu_flag_t {
 };

 enum cpu_register_t {
-   REG_EAX = 0,
-   REG_EBX,
-   REG_ECX,
-   REG_EDX,
+   RTE_REG_EAX = 0,
+   RTE_REG_EBX,
+   RTE_REG_ECX,
+   RTE_REG_EDX,
 };

 static const struct feature_entry cpu_feature_table[] = {
-   FEAT_DEF(SSE3, 0x0001, 0, REG_ECX,  0)
-   FEAT_DEF(PCLMULQDQ, 0x0001, 0, REG_ECX,  1)
-   FEAT_DEF(DTES64, 0x0001, 0, REG_ECX,  2)
-   FEAT_DEF(MONITOR, 0x0001, 0, REG_ECX,  3)
-   FEAT_DEF(DS_CPL, 0x0001, 0, REG_ECX,  4)
-   FEAT_DEF(VMX, 0x0001, 0, REG_ECX,  5)
-   FEAT_DEF(SMX, 0x0001, 0, REG_ECX,  6)
-   FEAT_DEF(EIST, 0x0001, 0, REG_ECX,  7)
-   FEAT_DEF(TM2, 0x0001, 0, REG_ECX,  8)
-   FEAT_DEF(SSSE3, 0x0001, 0, REG_ECX,  9)
-   FEAT_DEF(CNXT_ID, 0x0001, 0, REG_ECX, 10)
-   FEAT_DEF(FMA, 0x0001, 0, REG_ECX, 12)
-   FEAT_DEF(CMPXCHG16B, 0x0001, 0, REG_ECX, 13)
-   FEAT_DEF(XTPR, 0x0001, 0, REG_ECX, 14)
-   FEAT_DEF(PDCM, 0x0001, 0, REG_ECX, 15)
-   FEAT_DEF(PCID, 0x0001, 0, REG_ECX, 17)
-   FEAT_DEF(DCA, 0x0001, 0, REG_ECX, 18)
-   FEAT_DEF(SSE4_1, 0x0001, 0, REG_ECX, 19)
-   FEAT_DEF(SSE4_2, 0x0001, 0, REG_ECX, 20)
-   FEAT_DEF(X2APIC, 0x0001, 0, REG_ECX, 21)
-   FEAT_DEF(MOVBE, 0x0001, 0, REG_ECX, 22)
-   FEAT_DEF(POPCNT, 0x0001, 0, REG_ECX, 23)
-   FEAT_DEF(TSC_DEADLINE, 0x0001, 0, REG_ECX, 24)
-   FEAT_DEF(AES, 0x0001, 0, REG_ECX, 25)
-   FEAT_DEF(XSAVE, 0x0001, 0, REG_ECX, 26)
-   FEAT_DEF(OSXSAVE, 0x0001, 0, REG_ECX, 27)
-   FEAT_DEF(AVX, 0x0001, 0, REG_ECX, 28)
-   FEAT_DEF(F16C, 0x0001, 0, REG_ECX, 29)
-   FEAT_DEF(RDRAND, 0x0001, 0, REG_ECX, 30)
-
-   FEAT_DEF(FPU, 0x0001, 0, REG_EDX,  0)
-   FEAT_DEF(VME, 0x0001, 0, REG_EDX,  1)
-   FEAT_DEF(DE, 0x0001, 0, REG_EDX,  2)
-   FEAT_DEF(PSE, 0x0001, 0, REG_EDX,  3)
-   FEAT_DEF(TSC, 0x0001, 0, REG_EDX,  4)
-   FEAT_DEF(MSR, 0x0001, 0, REG_EDX,  5)
-   FEAT_DEF(PAE, 0x0001, 0, REG_EDX,  6)
-   FEAT_DEF(MCE, 0x0001, 0, REG_EDX,  7)
-   FEAT_DEF(CX8, 0x0001, 0, REG_EDX,  8)
-   FEAT_DEF(APIC, 0x0001, 0, REG_EDX,  9)
-   FEAT_DEF(SEP, 0x0001, 0, REG_EDX, 11)
-   FEAT_DEF(MTRR, 0x0001, 0, REG_EDX, 12)
-   FEAT_DEF(PGE, 0x0001, 0, REG_EDX, 13)
-   FEAT_DEF(MCA, 0x0001, 0, REG_EDX, 14)
-   FEAT_DEF(CMOV, 0x0001, 0, REG_EDX, 15)
-   FEAT_DEF(PAT, 0x0001, 0, REG_EDX, 16)
-   FEAT_DEF(PSE36, 0x0001, 0, REG_EDX, 17)
-   FEAT_DEF(PSN, 0x0001, 0, REG_EDX, 18)
-   FEAT_DEF(CLFSH, 0x0001, 0, REG_EDX, 19)
-   FEAT_DEF(DS, 0x0001, 0, REG_EDX, 21)
-   FEAT_DEF(ACPI, 0x0001, 0, REG_EDX, 22)
-   FEAT_DEF(MMX, 0x0001, 0, REG_EDX, 23)
-   FEAT_DEF(FXSR, 0x0001, 0, REG_EDX, 24)
-   FEAT_DEF(SSE, 0x0001, 0, REG_EDX, 25)
-   FEAT_DEF(SSE2, 0x0001, 0, REG_EDX, 26)
-   FEAT_DEF(SS, 0x0001, 0, REG_EDX, 27)
-   FEAT_DEF(HTT, 0x0001, 0, REG_EDX, 28)
-   FEAT_DEF(TM, 0x0001, 0, REG_EDX, 29)
-   FEAT_DEF(PBE, 0x0001, 0, REG_EDX, 31)
-
-   FEAT_DEF(DIGTEMP, 0x0006, 0, REG_EAX,  0)
-   FEAT_DEF(TRBOBST, 0x0006, 0, REG_EAX,  1)
-   FEAT_DEF(ARAT, 0x0006, 0, REG_EAX,  2)
-   FEAT_DEF(PLN, 0x0006, 0, REG_EAX,  4)
-   FEAT_DEF(ECMD, 0x0006, 0, REG_EAX,  5)
-   FEAT_DEF(PTM, 0x0006, 0, REG_EAX,  6)
-
-   FEAT_DEF(MPERF_APERF_MSR, 0x0006, 0, REG_ECX,  0)
-   FEAT_DEF(ACNT2, 0x0006, 0, REG_ECX,  1)
-   FEAT_DEF(ENERGY_EFF, 0x0006, 0, REG_ECX,  3)
-
-   FEAT_DEF(FSGSBASE, 0x0007, 0, REG_EBX,  0)
-   FEAT_DEF(BMI1, 0x0007, 0, REG_EBX,  2)
-   FEAT_DEF(HLE, 0x0007, 0, REG_EBX,  4)
-   FEAT_DEF(AVX2, 0x0007, 0, REG_EBX,  5)
-   FEAT_DEF(SMEP, 0x00

[dpdk-dev] [PATCH 3/3 v2] =?UTF-8?q?librte=5Feal/common:=20Fix=20redeclaration=20of?= =?UTF-8?q?=20enumerator=20=E2=80=98REG=5FEAX=E2=80=99?=

2015-03-05 Thread Michael Qiu
include/rte_cpuflags.h:154:2: error: redeclaration of enumerator ?REG_EAX?
In file included from /usr/include/signal.h:358:0,
 from /usr/include/sys/wait.h:30,
 from /root/dpdk/app/test/test_mp_secondary.c:50:
/usr/include/sys/ucontext.h:180:3: note: previous definition of ?REG_EAX? was 
here

In i686, from REG_EAX to REG_EDX are all defined in
/usr/include/sys/ucontext.h

Rename to CPU_REG_EAX to avoid this issue.

Signed-off-by: Michael Qou 
---
v2 --> v1:
rename CPU_REG_EAX to RTE_REG_EAX

 .../common/include/arch/x86/rte_cpuflags.h | 210 ++---
 1 file changed, 105 insertions(+), 105 deletions(-)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h 
b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
index a58dd7b..dd56553 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
@@ -151,104 +151,104 @@ enum rte_cpu_flag_t {
 };

 enum cpu_register_t {
-   REG_EAX = 0,
-   REG_EBX,
-   REG_ECX,
-   REG_EDX,
+   RTE_REG_EAX = 0,
+   RTE_REG_EBX,
+   RTE_REG_ECX,
+   RTE_REG_EDX,
 };

 static const struct feature_entry cpu_feature_table[] = {
-   FEAT_DEF(SSE3, 0x0001, 0, REG_ECX,  0)
-   FEAT_DEF(PCLMULQDQ, 0x0001, 0, REG_ECX,  1)
-   FEAT_DEF(DTES64, 0x0001, 0, REG_ECX,  2)
-   FEAT_DEF(MONITOR, 0x0001, 0, REG_ECX,  3)
-   FEAT_DEF(DS_CPL, 0x0001, 0, REG_ECX,  4)
-   FEAT_DEF(VMX, 0x0001, 0, REG_ECX,  5)
-   FEAT_DEF(SMX, 0x0001, 0, REG_ECX,  6)
-   FEAT_DEF(EIST, 0x0001, 0, REG_ECX,  7)
-   FEAT_DEF(TM2, 0x0001, 0, REG_ECX,  8)
-   FEAT_DEF(SSSE3, 0x0001, 0, REG_ECX,  9)
-   FEAT_DEF(CNXT_ID, 0x0001, 0, REG_ECX, 10)
-   FEAT_DEF(FMA, 0x0001, 0, REG_ECX, 12)
-   FEAT_DEF(CMPXCHG16B, 0x0001, 0, REG_ECX, 13)
-   FEAT_DEF(XTPR, 0x0001, 0, REG_ECX, 14)
-   FEAT_DEF(PDCM, 0x0001, 0, REG_ECX, 15)
-   FEAT_DEF(PCID, 0x0001, 0, REG_ECX, 17)
-   FEAT_DEF(DCA, 0x0001, 0, REG_ECX, 18)
-   FEAT_DEF(SSE4_1, 0x0001, 0, REG_ECX, 19)
-   FEAT_DEF(SSE4_2, 0x0001, 0, REG_ECX, 20)
-   FEAT_DEF(X2APIC, 0x0001, 0, REG_ECX, 21)
-   FEAT_DEF(MOVBE, 0x0001, 0, REG_ECX, 22)
-   FEAT_DEF(POPCNT, 0x0001, 0, REG_ECX, 23)
-   FEAT_DEF(TSC_DEADLINE, 0x0001, 0, REG_ECX, 24)
-   FEAT_DEF(AES, 0x0001, 0, REG_ECX, 25)
-   FEAT_DEF(XSAVE, 0x0001, 0, REG_ECX, 26)
-   FEAT_DEF(OSXSAVE, 0x0001, 0, REG_ECX, 27)
-   FEAT_DEF(AVX, 0x0001, 0, REG_ECX, 28)
-   FEAT_DEF(F16C, 0x0001, 0, REG_ECX, 29)
-   FEAT_DEF(RDRAND, 0x0001, 0, REG_ECX, 30)
-
-   FEAT_DEF(FPU, 0x0001, 0, REG_EDX,  0)
-   FEAT_DEF(VME, 0x0001, 0, REG_EDX,  1)
-   FEAT_DEF(DE, 0x0001, 0, REG_EDX,  2)
-   FEAT_DEF(PSE, 0x0001, 0, REG_EDX,  3)
-   FEAT_DEF(TSC, 0x0001, 0, REG_EDX,  4)
-   FEAT_DEF(MSR, 0x0001, 0, REG_EDX,  5)
-   FEAT_DEF(PAE, 0x0001, 0, REG_EDX,  6)
-   FEAT_DEF(MCE, 0x0001, 0, REG_EDX,  7)
-   FEAT_DEF(CX8, 0x0001, 0, REG_EDX,  8)
-   FEAT_DEF(APIC, 0x0001, 0, REG_EDX,  9)
-   FEAT_DEF(SEP, 0x0001, 0, REG_EDX, 11)
-   FEAT_DEF(MTRR, 0x0001, 0, REG_EDX, 12)
-   FEAT_DEF(PGE, 0x0001, 0, REG_EDX, 13)
-   FEAT_DEF(MCA, 0x0001, 0, REG_EDX, 14)
-   FEAT_DEF(CMOV, 0x0001, 0, REG_EDX, 15)
-   FEAT_DEF(PAT, 0x0001, 0, REG_EDX, 16)
-   FEAT_DEF(PSE36, 0x0001, 0, REG_EDX, 17)
-   FEAT_DEF(PSN, 0x0001, 0, REG_EDX, 18)
-   FEAT_DEF(CLFSH, 0x0001, 0, REG_EDX, 19)
-   FEAT_DEF(DS, 0x0001, 0, REG_EDX, 21)
-   FEAT_DEF(ACPI, 0x0001, 0, REG_EDX, 22)
-   FEAT_DEF(MMX, 0x0001, 0, REG_EDX, 23)
-   FEAT_DEF(FXSR, 0x0001, 0, REG_EDX, 24)
-   FEAT_DEF(SSE, 0x0001, 0, REG_EDX, 25)
-   FEAT_DEF(SSE2, 0x0001, 0, REG_EDX, 26)
-   FEAT_DEF(SS, 0x0001, 0, REG_EDX, 27)
-   FEAT_DEF(HTT, 0x0001, 0, REG_EDX, 28)
-   FEAT_DEF(TM, 0x0001, 0, REG_EDX, 29)
-   FEAT_DEF(PBE, 0x0001, 0, REG_EDX, 31)
-
-   FEAT_DEF(DIGTEMP, 0x0006, 0, REG_EAX,  0)
-   FEAT_DEF(TRBOBST, 0x0006, 0, REG_EAX,  1)
-   FEAT_DEF(ARAT, 0x0006, 0, REG_EAX,  2)
-   FEAT_DEF(PLN, 0x0006, 0, REG_EAX,  4)
-   FEAT_DEF(ECMD, 0x0006, 0, REG_EAX,  5)
-   FEAT_DEF(PTM, 0x0006, 0, REG_EAX,  6)
-
-   FEAT_DEF(MPERF_APERF_MSR, 0x0006, 0, REG_ECX,  0)
-   FEAT_DEF(ACNT2, 0x0006, 0, REG_ECX,  1)
-   FEAT_DEF(ENERGY_EFF, 0x0006, 0, REG_ECX,  3)
-
-   FEAT_DEF(FSGSBASE, 0x0007, 0, REG_EBX,  0)
-   FEAT_DEF(BMI1, 0x0007, 0, REG_EBX,  2)
-   FEAT_DEF(HLE, 0x0007, 0, REG_EBX,  4)
-   FEAT_DEF(AVX2, 0x0007, 0, REG_EBX,  5)
-   FEAT_DEF(SMEP, 0x0007, 0, REG_EBX,  6)
-   FEAT_DEF(BMI2, 

[dpdk-dev] [PATCH 3/3] librte_eal/common: Fix redeclaration of enumerator ‘REG_EAX’

2015-03-05 Thread Michael Qiu
include/rte_cpuflags.h:154:2: error: redeclaration of enumerator ?REG_EAX?
In file included from /usr/include/signal.h:358:0,
 from /usr/include/sys/wait.h:30,
 from /root/dpdk/app/test/test_mp_secondary.c:50:
/usr/include/sys/ucontext.h:180:3: note: previous definition of ?REG_EAX? was 
here

In i686, from REG_EAX to REG_EDX are all defined in
/usr/include/sys/ucontext.h

Rename to CPU_REG_EAX to avoid this issue.

Signed-off-by: Michael Qou 
---
 .../common/include/arch/x86/rte_cpuflags.h | 210 ++---
 1 file changed, 105 insertions(+), 105 deletions(-)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h 
b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
index a58dd7b..f367b91 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cpuflags.h
@@ -151,104 +151,104 @@ enum rte_cpu_flag_t {
 };

 enum cpu_register_t {
-   REG_EAX = 0,
-   REG_EBX,
-   REG_ECX,
-   REG_EDX,
+   CPU_REG_EAX = 0,
+   CPU_REG_EBX,
+   CPU_REG_ECX,
+   CPU_REG_EDX,
 };

 static const struct feature_entry cpu_feature_table[] = {
-   FEAT_DEF(SSE3, 0x0001, 0, REG_ECX,  0)
-   FEAT_DEF(PCLMULQDQ, 0x0001, 0, REG_ECX,  1)
-   FEAT_DEF(DTES64, 0x0001, 0, REG_ECX,  2)
-   FEAT_DEF(MONITOR, 0x0001, 0, REG_ECX,  3)
-   FEAT_DEF(DS_CPL, 0x0001, 0, REG_ECX,  4)
-   FEAT_DEF(VMX, 0x0001, 0, REG_ECX,  5)
-   FEAT_DEF(SMX, 0x0001, 0, REG_ECX,  6)
-   FEAT_DEF(EIST, 0x0001, 0, REG_ECX,  7)
-   FEAT_DEF(TM2, 0x0001, 0, REG_ECX,  8)
-   FEAT_DEF(SSSE3, 0x0001, 0, REG_ECX,  9)
-   FEAT_DEF(CNXT_ID, 0x0001, 0, REG_ECX, 10)
-   FEAT_DEF(FMA, 0x0001, 0, REG_ECX, 12)
-   FEAT_DEF(CMPXCHG16B, 0x0001, 0, REG_ECX, 13)
-   FEAT_DEF(XTPR, 0x0001, 0, REG_ECX, 14)
-   FEAT_DEF(PDCM, 0x0001, 0, REG_ECX, 15)
-   FEAT_DEF(PCID, 0x0001, 0, REG_ECX, 17)
-   FEAT_DEF(DCA, 0x0001, 0, REG_ECX, 18)
-   FEAT_DEF(SSE4_1, 0x0001, 0, REG_ECX, 19)
-   FEAT_DEF(SSE4_2, 0x0001, 0, REG_ECX, 20)
-   FEAT_DEF(X2APIC, 0x0001, 0, REG_ECX, 21)
-   FEAT_DEF(MOVBE, 0x0001, 0, REG_ECX, 22)
-   FEAT_DEF(POPCNT, 0x0001, 0, REG_ECX, 23)
-   FEAT_DEF(TSC_DEADLINE, 0x0001, 0, REG_ECX, 24)
-   FEAT_DEF(AES, 0x0001, 0, REG_ECX, 25)
-   FEAT_DEF(XSAVE, 0x0001, 0, REG_ECX, 26)
-   FEAT_DEF(OSXSAVE, 0x0001, 0, REG_ECX, 27)
-   FEAT_DEF(AVX, 0x0001, 0, REG_ECX, 28)
-   FEAT_DEF(F16C, 0x0001, 0, REG_ECX, 29)
-   FEAT_DEF(RDRAND, 0x0001, 0, REG_ECX, 30)
-
-   FEAT_DEF(FPU, 0x0001, 0, REG_EDX,  0)
-   FEAT_DEF(VME, 0x0001, 0, REG_EDX,  1)
-   FEAT_DEF(DE, 0x0001, 0, REG_EDX,  2)
-   FEAT_DEF(PSE, 0x0001, 0, REG_EDX,  3)
-   FEAT_DEF(TSC, 0x0001, 0, REG_EDX,  4)
-   FEAT_DEF(MSR, 0x0001, 0, REG_EDX,  5)
-   FEAT_DEF(PAE, 0x0001, 0, REG_EDX,  6)
-   FEAT_DEF(MCE, 0x0001, 0, REG_EDX,  7)
-   FEAT_DEF(CX8, 0x0001, 0, REG_EDX,  8)
-   FEAT_DEF(APIC, 0x0001, 0, REG_EDX,  9)
-   FEAT_DEF(SEP, 0x0001, 0, REG_EDX, 11)
-   FEAT_DEF(MTRR, 0x0001, 0, REG_EDX, 12)
-   FEAT_DEF(PGE, 0x0001, 0, REG_EDX, 13)
-   FEAT_DEF(MCA, 0x0001, 0, REG_EDX, 14)
-   FEAT_DEF(CMOV, 0x0001, 0, REG_EDX, 15)
-   FEAT_DEF(PAT, 0x0001, 0, REG_EDX, 16)
-   FEAT_DEF(PSE36, 0x0001, 0, REG_EDX, 17)
-   FEAT_DEF(PSN, 0x0001, 0, REG_EDX, 18)
-   FEAT_DEF(CLFSH, 0x0001, 0, REG_EDX, 19)
-   FEAT_DEF(DS, 0x0001, 0, REG_EDX, 21)
-   FEAT_DEF(ACPI, 0x0001, 0, REG_EDX, 22)
-   FEAT_DEF(MMX, 0x0001, 0, REG_EDX, 23)
-   FEAT_DEF(FXSR, 0x0001, 0, REG_EDX, 24)
-   FEAT_DEF(SSE, 0x0001, 0, REG_EDX, 25)
-   FEAT_DEF(SSE2, 0x0001, 0, REG_EDX, 26)
-   FEAT_DEF(SS, 0x0001, 0, REG_EDX, 27)
-   FEAT_DEF(HTT, 0x0001, 0, REG_EDX, 28)
-   FEAT_DEF(TM, 0x0001, 0, REG_EDX, 29)
-   FEAT_DEF(PBE, 0x0001, 0, REG_EDX, 31)
-
-   FEAT_DEF(DIGTEMP, 0x0006, 0, REG_EAX,  0)
-   FEAT_DEF(TRBOBST, 0x0006, 0, REG_EAX,  1)
-   FEAT_DEF(ARAT, 0x0006, 0, REG_EAX,  2)
-   FEAT_DEF(PLN, 0x0006, 0, REG_EAX,  4)
-   FEAT_DEF(ECMD, 0x0006, 0, REG_EAX,  5)
-   FEAT_DEF(PTM, 0x0006, 0, REG_EAX,  6)
-
-   FEAT_DEF(MPERF_APERF_MSR, 0x0006, 0, REG_ECX,  0)
-   FEAT_DEF(ACNT2, 0x0006, 0, REG_ECX,  1)
-   FEAT_DEF(ENERGY_EFF, 0x0006, 0, REG_ECX,  3)
-
-   FEAT_DEF(FSGSBASE, 0x0007, 0, REG_EBX,  0)
-   FEAT_DEF(BMI1, 0x0007, 0, REG_EBX,  2)
-   FEAT_DEF(HLE, 0x0007, 0, REG_EBX,  4)
-   FEAT_DEF(AVX2, 0x0007, 0, REG_EBX,  5)
-   FEAT_DEF(SMEP, 0x0007, 0, REG_EBX,  6)
-   FEAT_DEF(BMI2, 0x0007, 0, REG_EBX,  7)
-   FEAT_DEF(ERMS, 

[dpdk-dev] [PATCH 2/3] app/test: Fix size_t printf formart issue

2015-03-05 Thread Michael Qiu
test_hash.c: In function ?test_crc32_hash_alg_equiv?:
error: format ?%lu? expects argument of type ?long unsigned int?,
but argument 2 has type ?size_t? [-Werror=format]

According to C99, for size_t type should use formart "%zu"

Signed-off-by: Michael Qiu 
---
 app/test/test_hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index 653dd86..c489b8b 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -226,7 +226,7 @@ test_crc32_hash_alg_equiv(void)
if (i == CRC32_ITERATIONS)
return 0;

-   printf("Failed test data (hex, %lu bytes total):\n", data_len);
+   printf("Failed test data (hex, %zu bytes total):\n", data_len);
for (j = 0; j < data_len; j++)
printf("%02X%c", ((uint8_t *)data64)[j],
((j+1) % 16 == 0 || j == data_len - 1) ? '\n' : 
' ');
-- 
1.9.3



[dpdk-dev] [PATCH 1/3] librte_hash: Fix unsupported instruction `crc32' in i686 platform

2015-03-05 Thread Michael Qiu
CC rte_hash.o
Error: unsupported instruction `crc32'

The root cause is that i686 platform does not support 'crc32q'
Need make it only available in x86_64 platform

Signed-off-by: Michael Qiu 
---
 lib/librte_hash/rte_hash_crc.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h
index d28bb2a..4e9546f 100644
--- a/lib/librte_hash/rte_hash_crc.h
+++ b/lib/librte_hash/rte_hash_crc.h
@@ -374,6 +374,7 @@ crc32c_sse42_u32(uint32_t data, uint32_t init_val)
return init_val;
 }

+#ifdef RTE_ARCH_X86_64
 static inline uint32_t
 crc32c_sse42_u64(uint64_t data, uint64_t init_val)
 {
@@ -383,6 +384,7 @@ crc32c_sse42_u64(uint64_t data, uint64_t init_val)
: [data] "rm" (data));
return init_val;
 }
+#endif

 static inline uint32_t
 crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
@@ -476,8 +478,10 @@ rte_hash_crc_4byte(uint32_t data, uint32_t init_val)
 static inline uint32_t
 rte_hash_crc_8byte(uint64_t data, uint32_t init_val)
 {
+#ifdef RTE_ARCH_X86_64
if (likely(crc32_alg == CRC32_SSE42_x64))
return crc32c_sse42_u64(data, init_val);
+#endif

if (likely(crc32_alg & CRC32_SSE42))
return crc32c_sse42_u64_mimic(data, init_val);
-- 
1.9.3



[dpdk-dev] [PATCH 0/3] dpdk2.0-rc1 build error fix

2015-03-05 Thread Michael Qiu
This patch set is to fix dpdk2.0-rc1 compile error.

Michael Qiu (3):
  librte_hash: Fix unsupported instruction `crc32' in i686 platform
  app/test: Fix size_t printf formart issue
  librte_eal/common: Fix redeclaration of enumerator ?REG_EAX?

 app/test/test_hash.c   |   2 +-
 .../common/include/arch/x86/rte_cpuflags.h | 210 ++---
 lib/librte_hash/rte_hash_crc.h |   4 +
 3 files changed, 110 insertions(+), 106 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH v3] librte_eal/common: Fix cast from pointer to integer of different size

2015-03-05 Thread Michael Qiu
./i686-native-linuxapp-gcc/include/rte_memcpy.h:592:23: error:
cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]

  dstofss = 16 - (int)((long long)(void *)dst & 0x0F) + 16;

Type 'long long' is 64-bit in i686 platform while 'void *'
is 32-bit.

Signed-off-by: Michael Qiu 
---
v3 --> v2:
make dstofss and srcofs to be type size_t
casting type use uintptr_t

v2 --> v1:
Remove unnecessary casting (void *)
 lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h 
b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index 7b2d382..aa433e4 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -493,8 +493,8 @@ rte_memcpy(void *dst, const void *src, size_t n)
 {
__m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8;
void *ret = dst;
-   int dstofss;
-   int srcofs;
+   size_t dstofss;
+   size_t srcofs;

/**
 * Copy less than 16 bytes
@@ -589,12 +589,12 @@ COPY_BLOCK_64_BACK15:
 * unaligned copy functions require up to 15 bytes
 * backwards access.
 */
-   dstofss = 16 - (int)((long long)(void *)dst & 0x0F) + 16;
+   dstofss = 16 - ((uintptr_t)dst & 0x0F) + 16;
n -= dstofss;
rte_mov32((uint8_t *)dst, (const uint8_t *)src);
src = (const uint8_t *)src + dstofss;
dst = (uint8_t *)dst + dstofss;
-   srcofs = (int)((long long)(const void *)src & 0x0F);
+   srcofs = (uintptr_t)src & 0x0F;

/**
 * For aligned copy
-- 
1.9.3



[dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size

2015-03-03 Thread Michael Qiu
/i686-native-linuxapp-gcc/include/rte_memcpy.h:592:23: error:
cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]

  dstofss = 16 - (int)((long long)(void *)dst & 0x0F) + 16;

Type 'long long' is 64-bit in i686 platform while 'void *'
is 32-bit.

Signed-off-by: Michael Qiu 
---
v2 --> v1:
Remove unnecessary casting (void *)

 lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h 
b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index 7b2d382..85a5f4d 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -589,12 +589,12 @@ COPY_BLOCK_64_BACK15:
 * unaligned copy functions require up to 15 bytes
 * backwards access.
 */
-   dstofss = 16 - (int)((long long)(void *)dst & 0x0F) + 16;
+   dstofss = 16 - (int)((long)dst & 0x0F) + 16;
n -= dstofss;
rte_mov32((uint8_t *)dst, (const uint8_t *)src);
src = (const uint8_t *)src + dstofss;
dst = (uint8_t *)dst + dstofss;
-   srcofs = (int)((long long)(const void *)src & 0x0F);
+   srcofs = (int)((long)src & 0x0F);

/**
 * For aligned copy
-- 
1.9.3



[dpdk-dev] [PATCH] app/test-pmd: Fix log issue without nic binded

2015-03-02 Thread Michael Qiu
As hotplug has been enabled, start the testpmd with no nic binded
will show one error log "Please stop the ports first":

Interactive-mode selected
Please stop the ports first
Done
testpmd>

This issue is cause by the logic of check link status.

Signed-off-by: Michael Qiu 
---
 app/test-pmd/testpmd.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 61291be..e556b4c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1315,7 +1315,7 @@ port_is_closed(portid_t port_id)
 int
 start_port(portid_t pid)
 {
-   int diag, need_check_link_status = 0;
+   int diag, need_check_link_status = -1;
portid_t pi;
queueid_t qi;
struct rte_port *port;
@@ -1337,6 +1337,7 @@ start_port(portid_t pid)
if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
continue;

+   need_check_link_status = 0;
port = [pi];
if (rte_atomic16_cmpset(&(port->port_status), RTE_PORT_STOPPED,
 RTE_PORT_HANDLING) == 0) {
@@ -1457,9 +1458,9 @@ start_port(portid_t pid)
need_check_link_status = 1;
}

-   if (need_check_link_status && !no_link_check)
+   if (need_check_link_status == 1 && !no_link_check)
check_all_ports_link_status(RTE_PORT_ALL);
-   else
+   else if (need_check_link_status == 0)
printf("Please stop the ports first\n");

printf("Done\n");
-- 
1.9.3



[dpdk-dev] [PATCH v2] eal_pci: Fix max_vfs missing for none igb_uio driver

2015-02-11 Thread Michael Qiu
max_vfs will only be created by igb_uio driver, for other
drivers like vfio or pci_uio_generic, max_vfs will miss.

But sriov_numvfs is not driver related, just get the vf numbers
from that field.

Signed-off-by: Michael Qiu 
---
v2 --> v1:
backport for kernel version less than 3.8

 lib/librte_eal/linuxapp/eal/eal_pci.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index b5f5410..fcf5511 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -272,8 +272,16 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,
dev->max_vfs = 0;
snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
if (!access(filename, F_OK) &&
-   eal_parse_sysfs_value(filename, ) == 0) {
+   eal_parse_sysfs_value(filename, ) == 0)
dev->max_vfs = (uint16_t)tmp;
+   else {
+   /* for none igb_uio driver, need kernel
+* version greater than 3.8 */
+   snprintf(filename, sizeof(filename),
+"%s/sriov_numvfs", dirname);
+   if (!access(filename, F_OK) &&
+   eal_parse_sysfs_value(filename, ) == 0)
+   dev->max_vfs = (uint16_t)tmp;
}

/* get numa node */
-- 
1.9.3



[dpdk-dev] [PATCH] eal_pci: Fix max_vfs missing for none igb_uio driver

2015-02-11 Thread Michael Qiu
max_vfs will only be created by igb_uio driver, for other
drivers like vfio or pci_uio_generic, max_vfs will miss.

But sriov_numvfs is not driver related, just get the vf numbers
from that field.

Signed-off-by: Michael Qiu 
---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 1f43688..3da4b69 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -305,7 +305,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,

/* get max_vfs */
dev->max_vfs = 0;
-   snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
+   snprintf(filename, sizeof(filename), "%s/sriov_numvfs", dirname);
if (!access(filename, F_OK) &&
eal_parse_sysfs_value(filename, ) == 0) {
dev->max_vfs = (uint16_t)tmp;
-- 
1.9.3



[dpdk-dev] [PATCH] testpmd: Fix wrong message when no port started

2015-02-03 Thread Michael Qiu
The log message is wrong when no port started.

Signed-off-by: Michael Qiu 
---
 app/test-pmd/testpmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 773b8af..ebf9448 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1423,7 +1423,7 @@ start_port(portid_t pid)
if (need_check_link_status && !no_link_check)
check_all_ports_link_status(nb_ports, RTE_PORT_ALL);
else
-   printf("Please stop the ports first\n");
+   printf("Please start at least one port first\n");

printf("Done\n");
return 0;
-- 
1.9.3



[dpdk-dev] [PATCH v2] librte_pmd_ixgbe: Add queue start failure check

2015-01-27 Thread Michael Qiu
For ixgbe, when queue start failure, for example, mbuf allocate
failure, the device will still start success, which could be
an issue.

Add return status check of queue start to avoid this issue.

Signed-off-by: Michael Qiu 
---
v2 --> v1
. remove duplicated error message in ixgbe_dev_rxtx_start()
. remove '\n' in PMD_INIT_LOG()

 lib/librte_pmd_ixgbe/ixgbe_ethdev.c |  6 +-
 lib/librte_pmd_ixgbe/ixgbe_ethdev.h |  2 +-
 lib/librte_pmd_ixgbe/ixgbe_rxtx.c   | 20 +++-
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c 
b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index b58ec45..ede8706 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -1495,7 +1495,11 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
goto error;
}

-   ixgbe_dev_rxtx_start(dev);
+   err = ixgbe_dev_rxtx_start(dev);
+   if (err < 0) {
+   PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
+   goto error;
+   }

if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
err = hw->mac.ops.setup_sfp(hw);
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h 
b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index 677c257..1383194 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -265,7 +265,7 @@ int ixgbe_dev_rx_init(struct rte_eth_dev *dev);

 void ixgbe_dev_tx_init(struct rte_eth_dev *dev);

-void ixgbe_dev_rxtx_start(struct rte_eth_dev *dev);
+int ixgbe_dev_rxtx_start(struct rte_eth_dev *dev);

 int ixgbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);

diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c 
b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
index 840bc07..0224ed0 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
@@ -3806,7 +3806,7 @@ ixgbe_setup_loopback_link_82599(struct ixgbe_hw *hw)
 /*
  * Start Transmit and Receive Units.
  */
-void
+int
 ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
 {
struct ixgbe_hw *hw;
@@ -3816,6 +3816,7 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
uint32_t dmatxctl;
uint32_t rxctrl;
uint16_t i;
+   int ret = 0;

PMD_INIT_FUNC_TRACE();
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -3838,14 +3839,22 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)

for (i = 0; i < dev->data->nb_tx_queues; i++) {
txq = dev->data->tx_queues[i];
-   if (!txq->tx_deferred_start)
-   ixgbe_dev_tx_queue_start(dev, i);
+   if (!txq->tx_deferred_start) {
+   ret = ixgbe_dev_tx_queue_start(dev, i);
+   if (ret < 0) {
+   return ret;
+   }
+   }
}

for (i = 0; i < dev->data->nb_rx_queues; i++) {
rxq = dev->data->rx_queues[i];
-   if (!rxq->rx_deferred_start)
-   ixgbe_dev_rx_queue_start(dev, i);
+   if (!rxq->rx_deferred_start) {
+   ret = ixgbe_dev_rx_queue_start(dev, i);
+   if (ret < 0) {
+   return ret;
+   }
+   }
}

/* Enable Receive engine */
@@ -3860,6 +3869,7 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
ixgbe_setup_loopback_link_82599(hw);

+   return 0;
 }

 /*
-- 
1.9.3



[dpdk-dev] [PATCH] librte_pmd_ixgbe: Add queue start failure check

2015-01-15 Thread Michael Qiu
For ixgbe, when queue start failure, for example, mbuf allocate
failure, the device will still start success, which could be
an issue.

Add return status check of queue start to avoid this issue.

Signed-off-by: Michael Qiu 
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c |  6 +-
 lib/librte_pmd_ixgbe/ixgbe_ethdev.h |  2 +-
 lib/librte_pmd_ixgbe/ixgbe_rxtx.c   | 22 +-
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c 
b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 3fc3738..59e3321 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -1491,7 +1491,11 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
goto error;
}

-   ixgbe_dev_rxtx_start(dev);
+   err = ixgbe_dev_rxtx_start(dev);
+   if (err < 0) {
+   PMD_INIT_LOG(ERR, "Unable to start rxtx queues\n");
+   goto error;
+   }

if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
err = hw->mac.ops.setup_sfp(hw);
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h 
b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index ca99170..7461450 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -251,7 +251,7 @@ int ixgbe_dev_rx_init(struct rte_eth_dev *dev);

 void ixgbe_dev_tx_init(struct rte_eth_dev *dev);

-void ixgbe_dev_rxtx_start(struct rte_eth_dev *dev);
+int ixgbe_dev_rxtx_start(struct rte_eth_dev *dev);

 int ixgbe_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);

diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c 
b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
index e10d6a2..41a930e 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
@@ -3744,7 +3744,7 @@ ixgbe_setup_loopback_link_82599(struct ixgbe_hw *hw)
 /*
  * Start Transmit and Receive Units.
  */
-void
+int
 ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
 {
struct ixgbe_hw *hw;
@@ -3754,6 +3754,7 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
uint32_t dmatxctl;
uint32_t rxctrl;
uint16_t i;
+   int ret = 0;

PMD_INIT_FUNC_TRACE();
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -3776,14 +3777,24 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)

for (i = 0; i < dev->data->nb_tx_queues; i++) {
txq = dev->data->tx_queues[i];
-   if (!txq->tx_deferred_start)
-   ixgbe_dev_tx_queue_start(dev, i);
+   if (!txq->tx_deferred_start) {
+   ret = ixgbe_dev_tx_queue_start(dev, i);
+   if (ret < 0) {
+   PMD_INIT_LOG(ERR, "Start tx queue failed\n");
+   return ret;
+   }
+   }
}

for (i = 0; i < dev->data->nb_rx_queues; i++) {
rxq = dev->data->rx_queues[i];
-   if (!rxq->rx_deferred_start)
-   ixgbe_dev_rx_queue_start(dev, i);
+   if (!rxq->rx_deferred_start) {
+   ret = ixgbe_dev_rx_queue_start(dev, i);
+   if (ret < 0) {
+   PMD_INIT_LOG(ERR, "Start rx queue failed\n");
+   return ret;
+   }
+   }
}

/* Enable Receive engine */
@@ -3798,6 +3809,7 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
ixgbe_setup_loopback_link_82599(hw);

+   return 0;
 }

 /*
-- 
1.9.3



[dpdk-dev] [PATCH v2] ixgbe: fix segmentation fault when start secondary process

2014-12-19 Thread Michael Qiu
EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
EAL:   PCI memory mapped at 0x7f18c2a0
EAL:   PCI memory mapped at 0x7f18c2a8
Segmentation fault (core dumped)

This is introduced by commit: 46bc9d75
ixgbe: fix multi-process support
When start primary process with command line:
./app/test/test -n 1 -c  -m 64
then start the second one:
./app/test/test -n 1 --proc-type=secondary --file-prefix=rte
This segment-fault will occur.

Root cause is test app on primary process only starts device, but
the queue need initialized by manually command line.
So the tx queue is still NULL when secondary process startup.

Reported-by: Yong Liu 
Signed-off-by: Michael Qiu 
---
v2 --> v1:
Log clean up

 lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c 
b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 9401916..d585aa4 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -749,9 +749,17 @@ eth_ixgbe_dev_init(__attribute__((unused)) struct 
eth_driver *eth_drv,
 */
if (rte_eal_process_type() != RTE_PROC_PRIMARY){
struct igb_tx_queue *txq;
-   /* TX queue function in primary, set by last queue initialized 
*/
-   txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
-   set_tx_function(eth_dev, txq);
+   /* TX queue function in primary, set by last queue initialized
+* Tx queue may not initialized by primary process
+* */
+   if (eth_dev->data->tx_queues) {
+   txq = 
eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
+   set_tx_function(eth_dev, txq);
+   } else {
+   /* Use default TX function if we get here */
+   PMD_INIT_LOG(INFO, "No TX queues configured yet. "
+  "Using default TX function\n");
+   }

if (eth_dev->data->scattered_rx)
eth_dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
-- 
1.9.3



[dpdk-dev] [PATCH] ixgbe: fix segmentation fault when start secondary process

2014-12-18 Thread Michael Qiu
EAL:   probe driver: 8086:10fb rte_ixgbe_pmd
EAL:   PCI memory mapped at 0x7f18c2a0
EAL:   PCI memory mapped at 0x7f18c2a8
Segmentation fault (core dumped)

This is introduced by commit: 46bc9d75
ixgbe: fix multi-process support
When start primary process with command line:
./app/test/test -n 1 -c  -m 64
then start the second one:
./app/test/test -n 1 --proc-type=secondary --file-prefix=rte
This segment-fault will occur.

Root cause is test app on primary process only starts device, but
the queue need initialized by manually command line.
So the tx queue is still NULL when secondary process startup.

Reported-by: Yong Liu 
Signed-off-by: Michael Qiu 
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c 
b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 9401916..87ed6ee 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -749,9 +749,19 @@ eth_ixgbe_dev_init(__attribute__((unused)) struct 
eth_driver *eth_drv,
 */
if (rte_eal_process_type() != RTE_PROC_PRIMARY){
struct igb_tx_queue *txq;
-   /* TX queue function in primary, set by last queue initialized 
*/
-   txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
-   set_tx_function(eth_dev, txq);
+   /* TX queue function in primary, set by last queue initialized
+* Tx queue may not initialized by primary process
+* */
+   if (eth_dev->data->tx_queues) {
+   txq = 
eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
+   set_tx_function(eth_dev, txq);
+   } else {
+   /* Shall we exit this process if we get here? */
+   PMD_INIT_LOG(INFO, "Last tx queue initialized fail in "
+"secondary process, please verify if tx "
+"queues were initialized in primary "
+"process!\n");
+   }

if (eth_dev->data->scattered_rx)
eth_dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
-- 
1.9.3



[dpdk-dev] [PATCH v6] VFIO: Avoid to enable vfio while the module not loaded

2014-12-10 Thread Michael Qiu
When vfio module is not loaded when kernel support vfio feature,
the routine still try to open the container to get file
description.

This action is not safe, and of cause got error messages:

EAL: Detected 40 lcore(s)
EAL:   unsupported IOMMU type!
EAL: VFIO support could not be initialized
EAL: Setting up memory...

This may make user confuse, this patch make it reasonable
and much more soomth to user.

Signed-off-by: Michael Qiu 
---
 v6 --> v5
1. Change rte_eal_check_module() to normal
   function instead of inline
2. limit fscanf to get 29 charactors not include '\0'

 lib/librte_eal/common/eal_private.h| 14 ++
 lib/librte_eal/linuxapp/eal/eal.c  | 27 +++
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 26 +++---
 3 files changed, 64 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 232fcec..2c751c6 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -203,4 +203,18 @@ int rte_eal_alarm_init(void);
  */
 int rte_eal_dev_init(void);

+/**
+ * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
+ * etc.) loaded.
+ *
+ * @param module_name
+ * The module's name which need to be checked
+ *
+ * @return
+ * -1 means some error happens(NULL pointer or open failure)
+ * 0  means the module not loaded
+ * 1  means the module loaded
+ */
+int rte_eal_check_module(const char *module_name);
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 89f3b5e..9c1a1cc 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -859,3 +859,30 @@ int rte_eal_has_hugepages(void)
 {
return ! internal_config.no_hugetlbfs;
 }
+
+int
+rte_eal_check_module(const char *module_name)
+{
+   char mod_name[30]; /* Any module names can be longer than 30 bytes? */
+   int ret = 0;
+
+   if (NULL == module_name)
+   return -1;
+
+   FILE * fd = fopen("/proc/modules", "r");
+   if (NULL == fd) {
+   RTE_LOG(ERR, EAL, "Open /proc/modules failed!"
+   " error %i (%s)\n", errno, strerror(errno));
+   return -1;
+   }
+   while(!feof(fd)) {
+   fscanf(fd, "%29s %*[^\n]", mod_name);
+   if(!strcmp(mod_name, module_name)) {
+   ret = 1;
+   break;
+   }
+   }
+   fclose(fd);
+
+   return ret;
+}
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index c1246e8..16fe10f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "eal_filesystem.h"
 #include "eal_pci_init.h"
@@ -339,10 +340,12 @@ pci_vfio_get_container_fd(void)
ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, 
VFIO_TYPE1_IOMMU);
if (ret != 1) {
if (ret < 0)
-   RTE_LOG(ERR, EAL, "  could not get IOMMU type, "
-   "error %i (%s)\n", errno, 
strerror(errno));
+   RTE_LOG(ERR, EAL, "  could not get IOMMU type,"
+   " error %i (%s)\n", errno,
+   strerror(errno));
else
-   RTE_LOG(ERR, EAL, "  unsupported IOMMU 
type!\n");
+   RTE_LOG(ERR, EAL, "  unsupported IOMMU type"
+   " detected in VFIO\n");
close(vfio_container_fd);
return -1;
}
@@ -783,11 +786,28 @@ pci_vfio_enable(void)
 {
/* initialize group list */
int i;
+   int module_vfio_type1;

for (i = 0; i < VFIO_MAX_GROUPS; i++) {
vfio_cfg.vfio_groups[i].fd = -1;
vfio_cfg.vfio_groups[i].group_no = -1;
}
+
+   module_vfio_type1 = rte_eal_check_module("vfio_iommu_type1");
+
+   /* return error directly */
+   if (module_vfio_type1 == -1) {
+   RTE_LOG(INFO, EAL, "Could not get loaded module details!\n");
+   return -1;
+   }
+
+   /* return 0 if VFIO modules not loaded */
+   if (module_vfio_type1 == 0) {
+   RTE_LOG(INFO, EAL, "VFIO modules not all loaded,"
+   " skip VFIO support ...\n");
+   return 0;
+   }
+
vfio_cfg.vfio_container_fd = pci_vfio_get_container_fd();

/* check if we have VFIO driver enabled */
-- 
1.9.3



[dpdk-dev] [PATCH 1/2 v4] Fix compile issue with hugepage_sz in 32-bit system

2014-12-10 Thread Michael Qiu
lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
is always false due to limited range of data type [-Werror=type-limits]
|| (hugepage_sz == RTE_PGSIZE_16G)) {
^
cc1: all warnings being treated as errors

This was introuduced by commit b77b5639:
mem: add huge page sizes for IBM Power

The root cause is that size_t is 32-bit in i686 platform,
but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.

Force hugepage_sz to always 64-bit to avoid this issue.

Signed-off-by: Michael Qiu 
---
 v4 ---> v3
Change hugepage_sz from size_t to uint64_t
split second bugfix to another patch

 v3 ---> v2
Change RTE_PGSIZE_16G from ULL to UL
to keep all entries consistent

 V2 ---> v1
Change two type entries to one, and
leave RTE_PGSIZE_16G only valid for
64-bit platform

 lib/librte_eal/common/eal_common_memory.c   | 2 +-
 lib/librte_eal/common/eal_internal_cfg.h| 2 +-
 lib/librte_eal/common/include/rte_memory.h  | 2 +-
 lib/librte_eal/common/include/rte_memzone.h | 2 +-
 lib/librte_eal/linuxapp/eal/eal_memory.c| 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_memory.c 
b/lib/librte_eal/common/eal_common_memory.c
index 412b432..77830f8 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -96,7 +96,7 @@ rte_dump_physmem_layout(FILE *f)

fprintf(f, "Segment %u: phys:0x%"PRIx64", len:%zu, "
   "virt:%p, socket_id:%"PRId32", "
-  "hugepage_sz:%zu, nchannel:%"PRIx32", "
+  "hugepage_sz:%"PRIu64", nchannel:%"PRIx32", "
   "nrank:%"PRIx32"\n", i,
   mcfg->memseg[i].phys_addr,
   mcfg->memseg[i].len,
diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
b/lib/librte_eal/common/eal_internal_cfg.h
index aac6abf..e2ecb0d 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -49,7 +49,7 @@
  * mount points of hugepages
  */
 struct hugepage_info {
-   size_t hugepage_sz;   /**< size of a huge page */
+   uint64_t hugepage_sz;   /**< size of a huge page */
const char *hugedir;/**< dir where hugetlbfs is mounted */
uint32_t num_pages[RTE_MAX_NUMA_NODES];
/**< number of hugepages of that size on each 
socket */
diff --git a/lib/librte_eal/common/include/rte_memory.h 
b/lib/librte_eal/common/include/rte_memory.h
index 1990833..7f8103f 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -92,7 +92,7 @@ struct rte_memseg {
phys_addr_t ioremap_addr; /**< Real physical address inside the VM */
 #endif
size_t len;   /**< Length of the segment. */
-   size_t hugepage_sz;   /**< The pagesize of underlying memory */
+   uint64_t hugepage_sz;   /**< The pagesize of underlying memory */
int32_t socket_id;  /**< NUMA socket ID. */
uint32_t nchannel;  /**< Number of channels. */
uint32_t nrank; /**< Number of ranks. */
diff --git a/lib/librte_eal/common/include/rte_memzone.h 
b/lib/librte_eal/common/include/rte_memzone.h
index 7d47bff..3006e81 100644
--- a/lib/librte_eal/common/include/rte_memzone.h
+++ b/lib/librte_eal/common/include/rte_memzone.h
@@ -83,7 +83,7 @@ struct rte_memzone {
 #endif
size_t len;   /**< Length of the memzone. */

-   size_t hugepage_sz;   /**< The page size of underlying 
memory */
+   uint64_t hugepage_sz;   /**< The page size of underlying 
memory */

int32_t socket_id;/**< NUMA socket ID. */

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 700aba2..566a052 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -300,7 +300,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl,
 #endif

for (i = 0; i < hpi->num_pages[0]; i++) {
-   size_t hugepage_sz = hpi->hugepage_sz;
+   uint64_t hugepage_sz = hpi->hugepage_sz;

if (orig) {
hugepg_tbl[i].file_id = i;
-- 
1.9.3



[dpdk-dev] [PATCH] Avoid possible memory cpoy when sort hugepages

2014-12-10 Thread Michael Qiu
When the first address is the compared address in the loop,
it will also do memory copy, which is meaningless,
worse more, when hugepg_tbl is mostly in order. This should
be a big deal in large hugepage memory systerm(like hunderd
or thousand GB).

Meanwhile smallest_idx never be a value of -1,so remove this check.

This patch also includes some coding style fix.

Signed-off-by: Michael Qiu 
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
b/lib/librte_eal/linuxapp/eal/eal_memory.c
index e6cb919..700aba2 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -678,14 +678,13 @@ error:
 static int
 sort_by_physaddr(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi)
 {
-   unsigned i, j;
-   int compare_idx;
+   unsigned i, j, compare_idx;
uint64_t compare_addr;
struct hugepage_file tmp;

for (i = 0; i < hpi->num_pages[0]; i++) {
compare_addr = 0;
-   compare_idx = -1;
+   compare_idx = i;

/*
 * browse all entries starting at 'i', and find the
@@ -704,11 +703,9 @@ sort_by_physaddr(struct hugepage_file *hugepg_tbl, struct 
hugepage_info *hpi)
}
}

-   /* should not happen */
-   if (compare_idx == -1) {
-   RTE_LOG(ERR, EAL, "%s(): error in physaddr sorting\n", 
__func__);
-   return -1;
-   }
+   /* avoid memory copy when the first entry is the compared */
+   if (compare_idx == i)
+   continue;

/* swap the 2 entries in the table */
memcpy(, _tbl[compare_idx],
-- 
1.9.3



[dpdk-dev] [PATCH v5] VFIO: Avoid to enable vfio while the module not loaded

2014-12-10 Thread Michael Qiu
When vfio module is not loaded when kernel support vfio feature,
the routine still try to open the container to get file
description.

This action is not safe, and of cause got error messages:

EAL: Detected 40 lcore(s)
EAL:   unsupported IOMMU type!
EAL: VFIO support could not be initialized
EAL: Setting up memory...

This may make user confuse, this patch make it reasonable
and much more soomth to user.

Signed-off-by: Michael Qiu 
---
 v5 --> v4
1. Move rte_eal_check_module() body to eal.c
2. Clean up "unsupported IOMMU type" log

v4 --> v3:
1. Remove RTE_LOG for params check
2. Remove "vfio" module check as "vfio_iommu_type1"
   loaded indecated "vfio" loaded

v3 --> v2:
1. Add error log in rte_eal_check_module()
2. Some code clean up.

v2 --> v1:
1. Move check_module() from rte_common.h to eal_private.h
   and rename to rte_eal_check_module().
   To make it linuxapp only.
2. Some code clean up.

 lib/librte_eal/common/eal_private.h| 15 +++
 lib/librte_eal/linuxapp/eal/eal.c  | 27 +++
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 26 +++---
 3 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 232fcec..4183b54 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -203,4 +203,19 @@ int rte_eal_alarm_init(void);
  */
 int rte_eal_dev_init(void);

+/**
+ * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
+ * etc.) loaded.
+ *
+ * @param module_name
+ * The module's name which need to be checked
+ *
+ * @return
+ * -1 means some error happens(NULL pointer or open failure)
+ * 0  means the module not loaded
+ * 1  means the module loaded
+ */
+inline int
+rte_eal_check_module(const char *module_name);
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 89f3b5e..40b462e 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -859,3 +859,30 @@ int rte_eal_has_hugepages(void)
 {
return ! internal_config.no_hugetlbfs;
 }
+
+inline int
+rte_eal_check_module(const char *module_name)
+{
+   char mod_name[30]; /* Any module names can be longer than 30 bytes? */
+   int ret = 0;
+
+   if (NULL == module_name)
+   return -1;
+
+   FILE * fd = fopen("/proc/modules", "r");
+   if (NULL == fd) {
+   RTE_LOG(ERR, EAL, "Open /proc/modules failed!"
+   " error %i (%s)\n", errno, strerror(errno));
+   return -1;
+   }
+   while(!feof(fd)) {
+   fscanf(fd, "%30s %*[^\n]", mod_name);
+   if(!strcmp(mod_name, module_name)) {
+   ret = 1;
+   break;
+   }
+   }
+   fclose(fd);
+
+   return ret;
+}
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index c1246e8..16fe10f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "eal_filesystem.h"
 #include "eal_pci_init.h"
@@ -339,10 +340,12 @@ pci_vfio_get_container_fd(void)
ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, 
VFIO_TYPE1_IOMMU);
if (ret != 1) {
if (ret < 0)
-   RTE_LOG(ERR, EAL, "  could not get IOMMU type, "
-   "error %i (%s)\n", errno, 
strerror(errno));
+   RTE_LOG(ERR, EAL, "  could not get IOMMU type,"
+   " error %i (%s)\n", errno,
+   strerror(errno));
else
-   RTE_LOG(ERR, EAL, "  unsupported IOMMU 
type!\n");
+   RTE_LOG(ERR, EAL, "  unsupported IOMMU type"
+   " detected in VFIO\n");
close(vfio_container_fd);
return -1;
}
@@ -783,11 +786,28 @@ pci_vfio_enable(void)
 {
/* initialize group list */
int i;
+   int module_vfio_type1;

for (i = 0; i < VFIO_MAX_GROUPS; i++) {
vfio_cfg.vfio_groups[i].fd = -1;
vfio_cfg.vfio_groups[i].group_no = -1;
}
+
+   module_vfio_type1 = rte_eal_check_module("vfio_iommu_type1");
+
+   /* return error directly */
+   if (module_vfio_type1 == -1) {
+   RTE_

[dpdk-dev] [PATCH v4] VFIO: Avoid to enable vfio while the module not loaded

2014-12-08 Thread Michael Qiu
When vfio module is not loaded when kernel support vfio feature,
the routine still try to open the container to get file
description.

This action is not safe, and of cause got error messages:

EAL: Detected 40 lcore(s)
EAL:   unsupported IOMMU type!
EAL: VFIO support could not be initialized
EAL: Setting up memory...

This may make user confuse, this patch make it reasonable
and much more soomth to user.

Signed-off-by: Michael Qiu 
---
v4 --> v3:
1. Remove RTE_LOG for params check
2. Remove "vfio" module check as "vfio_iommu_type1"
   loaded indecated "vfio" loaded

v3 --> v2:
1. Add error log in rte_eal_check_module()
2. Some code clean up.

v2 --> v1:
1. Move check_module() from rte_common.h to eal_private.h
   and rename to rte_eal_check_module().
   To make it linuxapp only.
2. Some code clean up.

 lib/librte_eal/common/eal_private.h| 42 ++
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 29 ++---
 2 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 232fcec..e877a25 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -35,6 +35,9 @@
 #define _EAL_PRIVATE_H_

 #include 
+#include 
+#include 
+#include 

 /**
  * Initialize the memzone subsystem (private to eal).
@@ -203,4 +206,43 @@ int rte_eal_alarm_init(void);
  */
 int rte_eal_dev_init(void);

+/**
+ * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
+ * etc.) loaded.
+ *
+ * @param module_name
+ * The module's name which need to be checked
+ *
+ * @return
+ * -1 means some error happens(NULL pointer or open failure)
+ * 0  means the module not loaded
+ * 1  means the module loaded
+ */
+static inline int
+rte_eal_check_module(const char *module_name)
+{
+   char mod_name[30]; /* Any module names can be longer than 30 bytes? */
+   int ret = 0;
+
+   if (NULL == module_name)
+   return -1;
+
+   FILE * fd = fopen("/proc/modules", "r");
+   if (NULL == fd) {
+   RTE_LOG(ERR, EAL, "Open /proc/modules failed!"
+   " error %i (%s)\n", errno, strerror(errno));
+   return -1;
+   }
+   while(!feof(fd)) {
+   fscanf(fd, "%s %*[^\n]", mod_name);
+   if(!strcmp(mod_name, module_name)) {
+   ret = 1;
+   break;
+   }
+   }
+   fclose(fd);
+
+   return ret;
+}
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index c1246e8..8c54d2a 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "eal_filesystem.h"
 #include "eal_pci_init.h"
@@ -339,10 +340,15 @@ pci_vfio_get_container_fd(void)
ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, 
VFIO_TYPE1_IOMMU);
if (ret != 1) {
if (ret < 0)
-   RTE_LOG(ERR, EAL, "  could not get IOMMU type, "
-   "error %i (%s)\n", errno, 
strerror(errno));
+   RTE_LOG(ERR, EAL, "  could not get IOMMU type,"
+   " error %i (%s)\n", errno,
+   strerror(errno));
else
-   RTE_LOG(ERR, EAL, "  unsupported IOMMU 
type!\n");
+   /* Better to show the IOMMU type return from
+* kernel for easy debug
+*/
+   RTE_LOG(ERR, EAL, "  unsupported IOMMU type"
+   " detected: %d in VFIO\n", ret);
close(vfio_container_fd);
return -1;
}
@@ -783,11 +789,28 @@ pci_vfio_enable(void)
 {
/* initialize group list */
int i;
+   int module_vfio_type1;

for (i = 0; i < VFIO_MAX_GROUPS; i++) {
vfio_cfg.vfio_groups[i].fd = -1;
vfio_cfg.vfio_groups[i].group_no = -1;
}
+
+   module_vfio_type1 = rte_eal_check_module("vfio_iommu_type1");
+
+   /* return error directly */
+   if (module_vfio_type1 == -1) {
+   RTE_LOG(INFO, EAL, "Could not get loaded module details!\n");
+   return -1;
+   }
+
+   /* return 0 if VFIO modules not loaded */
+   if (module_vfio_type1 == 0) {
+ 

[dpdk-dev] [PATCH v3] VFIO: Avoid to enable vfio while the module not loaded

2014-12-08 Thread Michael Qiu
When vfio module is not loaded when kernel support vfio feature,
the routine still try to open the container to get file
description.

This action is not safe, and of cause got error messages:

EAL: Detected 40 lcore(s)
EAL:   unsupported IOMMU type!
EAL: VFIO support could not be initialized
EAL: Setting up memory...

This may make user confuse, this patch make it reasonable
and much more soomth to user.

Signed-off-by: Michael Qiu 
---
v3 --> v2:
1. Add error log in rte_eal_check_module()
2. Some code clean up.

v2 --> v1:
1. Move check_module() from rte_common.h to eal_private.h
   and rename to rte_eal_check_module().
   To make it linuxapp only.
2. Some code clean up.

 lib/librte_eal/common/eal_private.h| 43 ++
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 30 ++---
 2 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 232fcec..d1d8126 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -35,6 +35,9 @@
 #define _EAL_PRIVATE_H_

 #include 
+#include 
+#include 
+#include 

 /**
  * Initialize the memzone subsystem (private to eal).
@@ -203,4 +206,44 @@ int rte_eal_alarm_init(void);
  */
 int rte_eal_dev_init(void);

+/**
+ * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
+ * etc.) loaded.
+ *
+ * @param module_name
+ * The module's name which need to be checked
+ *
+ * @return
+ * -1 means some error happens(NULL pointer or open failure)
+ * 0  means the module not loaded
+ * 1  means the module loaded
+ */
+static inline int
+rte_eal_check_module(const char *module_name)
+{
+   char mod_name[30]; /* Any module names can be longer than 30 bytes? */
+   int ret = 0;
+
+   if (NULL == module_name) {
+   RTE_LOG(ERR, EAL, "The module name is NULL\n");
+   return -1;
+   }
+   FILE * fd = fopen("/proc/modules", "r");
+   if (NULL == fd) {
+   RTE_LOG(ERR, EAL, "Open /proc/modules failed!"
+   " error %i (%s)\n", errno, strerror(errno));
+   return -1;
+   }
+   while(!feof(fd)) {
+   fscanf(fd, "%s %*[^\n]", mod_name);
+   if(!strcmp(mod_name, module_name)) {
+   ret = 1;
+   break;
+   }
+   }
+   fclose(fd);
+
+   return ret;
+}
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index c1246e8..b34b3f5 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "eal_filesystem.h"
 #include "eal_pci_init.h"
@@ -339,10 +340,15 @@ pci_vfio_get_container_fd(void)
ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, 
VFIO_TYPE1_IOMMU);
if (ret != 1) {
if (ret < 0)
-   RTE_LOG(ERR, EAL, "  could not get IOMMU type, "
-   "error %i (%s)\n", errno, 
strerror(errno));
+   RTE_LOG(ERR, EAL, "  could not get IOMMU type,"
+   " error %i (%s)\n", errno,
+   strerror(errno));
else
-   RTE_LOG(ERR, EAL, "  unsupported IOMMU 
type!\n");
+   /* Better to show the IOMMU type return from
+* kernel for easy debug
+*/
+   RTE_LOG(ERR, EAL, "  unsupported IOMMU type"
+   " detected: %d in VFIO\n", ret);
close(vfio_container_fd);
return -1;
}
@@ -783,11 +789,29 @@ pci_vfio_enable(void)
 {
/* initialize group list */
int i;
+   int module_vfio, module_vfio_type1;

for (i = 0; i < VFIO_MAX_GROUPS; i++) {
vfio_cfg.vfio_groups[i].fd = -1;
vfio_cfg.vfio_groups[i].group_no = -1;
}
+
+   module_vfio = rte_eal_check_module("vfio");
+   module_vfio_type1 = rte_eal_check_module("vfio_iommu_type1");
+
+   /* return error directly */
+   if (module_vfio == -1 || module_vfio_type1 == -1) {
+   RTE_LOG(INFO, EAL, "Could not get loaded module details!\n");
+   return -1;
+   }
+
+   /* return 0 if not all VFIO modules loaded */
+   if (module_vfio == 0 || module_vfio_type1 == 0) {

[dpdk-dev] [PATCH v3] Fix two compile issues with i686 platform

2014-12-04 Thread Michael Qiu
lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
is always false due to limited range of data type [-Werror=type-limits]
|| (hugepage_sz == RTE_PGSIZE_16G)) {
^
cc1: all warnings being treated as errors

lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
conversion from "long long" to "void *" may lose significant bits
   RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);

This was introuduced by commit b77b5639:
mem: add huge page sizes for IBM Power

The root cause is that size_t and uintptr_t are 32-bit in i686
platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.

Define RTE_PGSIZE_16G only in 64 bit platform to avoid
this issue.

Signed-off-by: Michael Qiu 
---
 v3 ---> v2
Change RTE_PGSIZE_16G from ULL to UL
to keep all entries consistent

 V2 ---> v1
Change two type entries to one, and
leave RTE_PGSIZE_16G only valid for
64-bit platform

 app/test/test_memzone.c| 18 --
 lib/librte_eal/common/eal_common_memzone.c |  2 ++
 lib/librte_eal/common/include/rte_memory.h | 14 --
 lib/librte_eal/linuxapp/eal/eal_memory.c   | 12 +---
 4 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 5da6903..7bab8b5 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -145,8 +145,10 @@ test_memzone_reserve_flags(void)
hugepage_1GB_avail = 1;
if (ms[i].hugepage_sz == RTE_PGSIZE_16M)
hugepage_16MB_avail = 1;
+#ifdef RTE_ARCH_64
if (ms[i].hugepage_sz == RTE_PGSIZE_16G)
hugepage_16GB_avail = 1;
+#endif
}
/* Display the availability of 2MB ,1GB, 16MB, 16GB pages */
if (hugepage_2MB_avail)
@@ -234,8 +236,8 @@ test_memzone_reserve_flags(void)
return -1;
}

-   /* Check if 1GB huge pages are unavailable, that function fails 
unless
-* HINT flag is indicated
+   /* Check if 2MB huge pages are unavailable, that function
+* fails unless HINT flag is indicated
 */
if (!hugepage_2MB_avail) {
mz = rte_memzone_reserve("flag_zone_2M_HINT", size, 
SOCKET_ID_ANY,
@@ -295,8 +297,9 @@ test_memzone_reserve_flags(void)
return -1;
}

-   /* Check if 1GB huge pages are unavailable, that function fails
-* unless HINT flag is indicated
+#ifdef RTE_ARCH_64
+   /* Check if 16GB huge pages are unavailable, that function
+* fails unless HINT flag is indicated
 */
if (!hugepage_16GB_avail) {
mz = rte_memzone_reserve("flag_zone_16G_HINT", size,
@@ -318,7 +321,9 @@ test_memzone_reserve_flags(void)
return -1;
}
}
+#endif
}
+#ifdef RTE_ARCH_64
/*As with 16MB tests above for 16GB huge page requests*/
if (hugepage_16GB_avail) {
mz = rte_memzone_reserve("flag_zone_16G", size, SOCKET_ID_ANY,
@@ -343,8 +348,8 @@ test_memzone_reserve_flags(void)
return -1;
}

-   /* Check if 1GB huge pages are unavailable, that function fails
-* unless HINT flag is indicated
+   /* Check if 16MB huge pages are unavailable, that function
+* fails unless HINT flag is indicated
 */
if (!hugepage_16MB_avail) {
mz = rte_memzone_reserve("flag_zone_16M_HINT", size,
@@ -376,6 +381,7 @@ test_memzone_reserve_flags(void)
}
}
}
+#endif
return 0;
 }

diff --git a/lib/librte_eal/common/eal_common_memzone.c 
b/lib/librte_eal/common/eal_common_memzone.c
index b5a5d72..ee233ad 100644
--- a/lib/librte_eal/common/eal_common_memzone.c
+++ b/lib/librte_eal/common/eal_common_memzone.c
@@ -221,12 +221,14 @@ memzone_reserve_aligned_thread_unsafe(const char *name, 
size_t len,
if ((flags & RTE_MEMZONE_1GB) &&
free_memseg[i].hugepage_sz == RTE_PGSIZE_2M)
continue;
+#ifdef RTE_ARCH_64
if ((flags & RTE_MEMZONE_16MB) &&
free_memseg[i].hugepage_sz == RTE_PGSIZE_16G)
continue;
if ((flags & RTE_MEMZONE_16GB) &&
free_memseg[i].hugepage_sz == RTE_PGSIZE_16M)
continue;
+#endif

/* this segment is the best until now */
if (memseg_idx == -1) {
diff --git a/lib/librte_eal/common/include/rte_mem

[dpdk-dev] [PATCH] VFIO: Avoid to enable vfio while the module not loaded

2014-12-04 Thread Michael Qiu
When vfio module is not loaded when kernel support vfio feature,
the routine still try to open the container to get file
description.

This action is not safe, and of cause got error messages:

EAL: Detected 40 lcore(s)
EAL:   unsupported IOMMU type!
EAL: VFIO support could not be initialized
EAL: Setting up memory...

This may make user confuse, this patch make it reasonable
and much more soomth to user.

Signed-off-by: Michael Qiu 
---
 lib/librte_eal/common/include/rte_common.h | 37 ++
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 23 +--
 2 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_common.h 
b/lib/librte_eal/common/include/rte_common.h
index 921b91f..333aa6b 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -50,6 +50,8 @@ extern "C" {
 #include 
 #include 
 #include 
+#include 
+#include 

 /*** Macros to eliminate unused variable warnings /

@@ -382,6 +384,41 @@ rte_exit(int exit_code, const char *format, ...)
__attribute__((noreturn))
__attribute__((format(printf, 2, 3)));

+/**
+ * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
+ * etc.) loaded.
+ *
+ * @param module_name
+ * The module's name which need to be checked
+ *
+ * @return
+ * -1 means some error happens(NULL pointer or open failure)
+ * 0  means the module not loaded
+ * 1  means the module loaded
+ */
+static inline int
+check_module(const char *module_name)
+{
+   char mod_name[30]; /* Any module names can be longer than 30 bytes? */
+   int ret = 0;
+
+   if (NULL == module_name)
+   return -1;
+   FILE * fd = fopen("/proc/modules", "r");
+   if( fd == NULL)
+   return -1;
+   while(!feof(fd)) {
+   fscanf(fd, "%s %*[^\n]", mod_name);
+   if(!strcmp(mod_name, module_name)) {
+   ret = 1;
+   break;
+   }
+   }
+   fclose(fd);
+
+   return ret;
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index c1246e8..a11cc4b 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "eal_filesystem.h"
 #include "eal_pci_init.h"
@@ -342,7 +343,8 @@ pci_vfio_get_container_fd(void)
RTE_LOG(ERR, EAL, "  could not get IOMMU type, "
"error %i (%s)\n", errno, 
strerror(errno));
else
-   RTE_LOG(ERR, EAL, "  unsupported IOMMU 
type!\n");
+   RTE_LOG(ERR, EAL, "  unsupported IOMMU type! "
+   "expect: 1, actual: %d\n", ret);
close(vfio_container_fd);
return -1;
}
@@ -788,13 +790,20 @@ pci_vfio_enable(void)
vfio_cfg.vfio_groups[i].fd = -1;
vfio_cfg.vfio_groups[i].group_no = -1;
}
-   vfio_cfg.vfio_container_fd = pci_vfio_get_container_fd();

-   /* check if we have VFIO driver enabled */
-   if (vfio_cfg.vfio_container_fd != -1)
-   vfio_cfg.vfio_enabled = 1;
-   else
-   RTE_LOG(INFO, EAL, "VFIO support could not be initialized\n");
+   if (check_module("vfio") == 1 &&
+   check_module("vfio_iommu_type1") == 1) {
+   vfio_cfg.vfio_container_fd = pci_vfio_get_container_fd();
+
+   /* check if we have VFIO driver enabled */
+   if (vfio_cfg.vfio_container_fd != -1)
+   vfio_cfg.vfio_enabled = 1;
+   else
+   RTE_LOG(INFO, EAL, "VFIO support could not be"
+   " initialized\n");
+   } else
+   RTE_LOG(INFO, EAL, "VFIO modules are not all loaded,"
+   " skip VFIO support ...\n");

return 0;
 }
-- 
1.9.3



[dpdk-dev] [PATCH v2] test-pmd: Fix pointer aliasing error

2014-12-04 Thread Michael Qiu

app/test-pmd/csumonly.c: In function ?get_psd_sum?:
build/include/rte_ip.h:161: error: dereferencing pointer ?u16?
does break strict-aliasing rules
build/include/rte_ip.h:157: note: initialized from here
...

The root cause is that, compile enable strict aliasing by default,
while in function rte_raw_cksum() try to convert 'const char *'
to 'const uint16_t *'.

This patch is one workaround fix.

Signed-off-by: Michael Qiu 
---
 lib/librte_net/rte_ip.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
index 61e4457..f1c7087 100644
--- a/lib/librte_net/rte_ip.h
+++ b/lib/librte_net/rte_ip.h
@@ -154,7 +154,8 @@ struct ipv4_hdr {
 static inline uint16_t
 rte_raw_cksum(const char *buf, size_t len)
 {
-   const uint16_t *u16 = (const uint16_t *)buf;
+   unsigned long ptr = (unsigned long)buf;
+   const uint16_t *u16 = (const uint16_t *)ptr;
uint32_t sum = 0;

while (len >= (sizeof(*u16) * 4)) {
-- 
1.9.3