[dpdk-dev] [PATCH v1 2/2] Test cases for rte_memcmp functions

2016-06-06 Thread Ravi Kerur
Zhilong, Thomas,

If there is enough interest within DPDK community I can work on adding
support for 'unaligned access' and 'test cases' for it. Please let me know
either way.

Thanks,
Ravi


On Thu, May 26, 2016 at 2:05 AM, Wang, Zhihong 
wrote:

>
>
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ravi Kerur
> > Sent: Tuesday, March 8, 2016 7:01 AM
> > To: dev at dpdk.org
> > Subject: [dpdk-dev] [PATCH v1 2/2] Test cases for rte_memcmp functions
> >
> > v1:
> > This patch adds test cases for rte_memcmp functions.
> > New rte_memcmp functions can be tested via 'make test'
> > and 'testpmd' utility.
> >
> > Compiled and tested on Ubuntu 14.04(non-NUMA) and
> > 15.10(NUMA) systems.
> [...]
>
> > +/
> > ***
> > + * Memcmp function performance test configuration section. Each
> performance
> > test
> > + * will be performed MEMCMP_ITERATIONS times.
> > + *
> > + * The five arrays below control what tests are performed. Every
> combination
> > + * from the array entries is tested.
> > + */
> > +#define MEMCMP_ITERATIONS (500 * 500 * 500)
>
>
> Maybe less iteration will make the test faster without compromise precison?
>
>
> > +
> > +static size_t memcmp_sizes[] = {
> > + 2, 5, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65, 127, 128,
> > + 129, 191, 192, 193, 255, 256, 257, 319, 320, 321, 383, 384,
> > + 385, 447, 448, 449, 511, 512, 513, 767, 768, 769, 1023, 1024,
> > + 1025, 1522, 1536, 1600, 2048, 2560, 3072, 3584, 4096, 4608,
> > + 5632, 6144, 6656, 7168, 7680, 8192, 16834
> > +};
> > +
> [...]
> > +/*
> > + * Do all performance tests.
> > + */
> > +static int
> > +test_memcmp_perf(void)
> > +{
> > + if (run_all_memcmp_eq_perf_tests() != 0)
> > + return -1;
> > +
> > + if (run_all_memcmp_gt_perf_tests() != 0)
> > + return -1;
> > +
> > + if (run_all_memcmp_lt_perf_tests() != 0)
> > + return -1;
> > +
>
>
> Perhaps unaligned test cases are needed here.
> How do you think?
>
>
> > +
> > + return 0;
> > +}
> > +
> > +static struct test_command memcmp_perf_cmd = {
> > + .command = "memcmp_perf_autotest",
> > + .callback = test_memcmp_perf,
> > +};
> > +REGISTER_TEST_COMMAND(memcmp_perf_cmd);
> > --
> > 1.9.1
>
>


[dpdk-dev] [PATCH v1 2/2] Test cases for rte_memcmp functions

2016-03-07 Thread Ravi Kerur
v1:
This patch adds test cases for rte_memcmp functions.
New rte_memcmp functions can be tested via 'make test'
and 'testpmd' utility.

Compiled and tested on Ubuntu 14.04(non-NUMA) and
15.10(NUMA) systems.

Signed-off-by: Ravi Kerur 
---
 app/test/Makefile   |  31 +++-
 app/test/autotest_data.py   |  19 +++
 app/test/test_memcmp.c  | 250 
 app/test/test_memcmp_perf.c | 396 
 4 files changed, 695 insertions(+), 1 deletion(-)
 create mode 100644 app/test/test_memcmp.c
 create mode 100644 app/test/test_memcmp_perf.c

diff --git a/app/test/Makefile b/app/test/Makefile
index ec33e1a..f6ecaa9 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -82,6 +82,9 @@ SRCS-y += test_logs.c
 SRCS-y += test_memcpy.c
 SRCS-y += test_memcpy_perf.c

+SRCS-y += test_memcmp.c
+SRCS-y += test_memcmp_perf.c
+
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash.c
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_thash.c
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_perf.c
@@ -160,14 +163,40 @@ CFLAGS += $(WERROR_FLAGS)

 CFLAGS += -D_GNU_SOURCE

-# Disable VTA for memcpy test
+# Disable VTA for memcpy and memcmp tests
 ifeq ($(CC), gcc)
 ifeq ($(shell test $(GCC_VERSION) -ge 44 && echo 1), 1)
 CFLAGS_test_memcpy.o += -fno-var-tracking-assignments
 CFLAGS_test_memcpy_perf.o += -fno-var-tracking-assignments
+
+CFLAGS_test_memcmp.o += -fno-var-tracking-assignments
+CFLAGS_test_memcmp_perf.o += -fno-var-tracking-assignments
+
 endif
 endif

+CMP_AVX2_SUPPORT=$(shell $(CC) -march=core-avx2 -dM -E - &1 | \
+   grep -q AVX2 && echo 1)
+
+ifeq ($(CMP_AVX2_SUPPORT), 1)
+   ifeq ($(CC), icc)
+   CFLAGS_test_memcmp.o += -march=core-avx2
+   CFLAGS_test_memcmp_perf.o += -march=core-avx2
+   else
+   CFLAGS_test_memcmp.o += -mavx2
+   CFLAGS_test_memcmp_perf.o += -mavx2
+   endif
+else
+   ifeq ($(CC), icc)
+   CFLAGS_test_memcmp.o += -march=core-sse4.1
+   CFLAGS_test_memcmp_perf.o += -march=core-sse4.1
+   else
+   CFLAGS_test_memcmp.o += -msse4.1
+   CFLAGS_test_memcmp_perf.o += -msse4.1
+   endif
+endif
+
+
 # this application needs libraries first
 DEPDIRS-y += lib drivers

diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py
index 6f34d6b..5113327 100644
--- a/app/test/autotest_data.py
+++ b/app/test/autotest_data.py
@@ -186,6 +186,12 @@ parallel_test_group_list = [
 "Report" : None,
},
{
+"Name" :   "Memcmp autotest",
+"Command" :"memcmp_autotest",
+"Func" :   default_autotest,
+"Report" : None,
+   },
+   {
 "Name" :   "Memzone autotest",
 "Command" :"memzone_autotest",
 "Func" :   default_autotest,
@@ -398,6 +404,19 @@ non_parallel_test_group_list = [
]
 },
 {
+   "Prefix":   "memcmp_perf",
+   "Memory" :  per_sockets(512),
+   "Tests" :
+   [
+   {
+"Name" :   "Memcmp performance autotest",
+"Command" :"memcmp_perf_autotest",
+"Func" :   default_autotest,
+"Report" : None,
+   },
+   ]
+},
+{
"Prefix":   "hash_perf",
"Memory" :  per_sockets(512),
"Tests" :
diff --git a/app/test/test_memcmp.c b/app/test/test_memcmp.c
new file mode 100644
index 000..e3b0bf7
--- /dev/null
+++ b/app/test/test_memcmp.c
@@ -0,0 +1,250 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR 

[dpdk-dev] [PATCH v1 1/2] rte_memcmp functions using Intel AVX and SSE intrinsics

2016-03-07 Thread Ravi Kerur
v1:
This patch adds memcmp functionality using AVX and SSE
intrinsics provided by Intel. For other architectures
supported by DPDK regular memcmp function is used.

Compiled and tested on Ubuntu 14.04(non-NUMA) and 15.10(NUMA)
systems.

Signed-off-by: Ravi Kerur 
---
 .../common/include/arch/arm/rte_memcmp.h   |  60 ++
 .../common/include/arch/ppc_64/rte_memcmp.h|  62 ++
 .../common/include/arch/tile/rte_memcmp.h  |  60 ++
 .../common/include/arch/x86/rte_memcmp.h   | 786 +
 lib/librte_eal/common/include/generic/rte_memcmp.h | 175 +
 5 files changed, 1143 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/x86/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/generic/rte_memcmp.h

diff --git a/lib/librte_eal/common/include/arch/arm/rte_memcmp.h 
b/lib/librte_eal/common/include/arch/arm/rte_memcmp.h
new file mode 100644
index 000..fcbacb4
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/arm/rte_memcmp.h
@@ -0,0 +1,60 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 RehiveTech. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of IBM Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef _RTE_MEMCMP_ARM_H_
+#define _RTE_MEMCMP_ARM_H_
+
+#include 
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_memcmp.h"
+
+#define rte_memcmp(dst, src, n)  \
+   ({ (__builtin_constant_p(n)) ?   \
+   memcmp((dst), (src), (n)) :  \
+   rte_memcmp_func((dst), (src), (n)); })
+
+static inline bool
+rte_memcmp_func(void *dst, const void *src, size_t n)
+{
+   return memcmp(dst, src, n);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_MEMCMP_ARM_H_ */
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h 
b/lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h
new file mode 100644
index 000..5839a2d
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h
@@ -0,0 +1,62 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright (C) IBM Corporation 2016.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of IBM Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIA

[dpdk-dev] [PATCH v1 0/2] rte_memcmp functions

2016-03-07 Thread Ravi Kerur
9.8415 ***
 ***   4096,   230.2136 ***
 ***   8192,   366.2912 ***
 ***  16384,   647.0217 ***
 *** RTE memcmp less than performance test results ***
 *** Length (bytes), Ticks/Op. ***
 ***  1,22.6627 ***
 ***  8,26.2665 ***
 *** 15,26.8192 ***
 *** 16,21.7960 ***
 *** 32,23.9878 ***
 *** 64,24.2074 ***
 ***128,26.8111 ***
 ***256,28.3444 ***
 ***512,34.7882 ***
 ***   1024,44.4824 ***
 ***   2048,63.4154 ***
 ***   4096,   101.4360 ***
 ***   8192,   179.1029 ***
 ***  16384,   333.9357 ***
 *** memcmp less than performance test results ***
 *** Length (bytes), Ticks/Op. ***
 ***  1,22.2894 ***
 ***  8,24.9805 ***
 *** 15,24.8632 ***
 *** 16,24.3448 ***
 *** 32,24.8554 ***
 *** 64,25.7541 ***
 ***128,29.1831 ***
 ***256,36.2345 ***
 ***512,45.8233 ***
 ***   1024,   103.4597 ***
 ***   2048,   163.5588 ***
 ***   4096,   232.7368 ***
 ***   8192,   368.1143 ***
 ***  16384,   649.0326 ***
Test OK
RTE>>quit


Ravi Kerur (2):
  rte_memcmp functions using Intel AVX and SSE intrinsics
  Test cases for rte_memcmp functions

 app/test/Makefile  |  31 +-
 app/test/autotest_data.py  |  19 +
 app/test/test_memcmp.c | 250 +++
 app/test/test_memcmp_perf.c| 396 +++
 .../common/include/arch/arm/rte_memcmp.h   |  60 ++
 .../common/include/arch/ppc_64/rte_memcmp.h|  62 ++
 .../common/include/arch/tile/rte_memcmp.h  |  60 ++
 .../common/include/arch/x86/rte_memcmp.h   | 786 +
 lib/librte_eal/common/include/generic/rte_memcmp.h | 175 +
 9 files changed, 1838 insertions(+), 1 deletion(-)
 create mode 100644 app/test/test_memcmp.c
 create mode 100644 app/test/test_memcmp_perf.c
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/x86/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/generic/rte_memcmp.h

-- 
1.9.1



[dpdk-dev] [PATCH v2] I217 and I218 changes

2016-03-02 Thread Ravi Kerur
Hi, Wenzhuo, Bruce, I have superseded old patch with a new submission.
Please let me know if that approach is ok.

Thanks,
Ravi

On Tue, Mar 1, 2016 at 5:21 PM, Lu, Wenzhuo  wrote:

> Hi Ravi,
>
>
>
> >Do you want me to resend it as 'v1' and include your comments in commit
> message? let me know.
>
> I think it?s better if you withdraw this one, send a new one and make the
> commit log easy to understand J And you can keep my ack.
>
>
>


[dpdk-dev] [PATCH v1] I217 and I218 changes

2016-03-02 Thread Ravi Kerur
v1: Make necessary changes to support I217 and I218 NICs.
Use v2' incorporating internal review comments as a base.
Internal review done by Wenzhuo Lu (Intel) and internal
review versions and testing shown below

v2':
Incorporate Wenzhuo's comments, remove superfluous
assignment to fc.requested_mode in em_hardware_init
function.
Compiled and tested (via testpmd) on Ubuntu 14.04 on target
x86_64-native-linuxapp-gcc
Compiled for target x86_64-native-linuxapp-clang

v1':
Modified driver and eal code to support I217 and I218
Intel NICs.
Compiled and tested (via testpmd) on Ubuntu 14.04 for target
x86_64-native-linuxapp-gcc
Compiled for target x86_64-native-linuxapp-clang
M. Jay(Intel) had used the patch for DPDK demo.

Signed-off-by: Ravi Kerur 
Acked-by: Wenzhuo Lu 
---
 drivers/net/e1000/base/e1000_osdep.h| 26 +++-
 drivers/net/e1000/em_ethdev.c   | 32 +
 lib/librte_eal/common/include/rte_pci_dev_ids.h |  9 +++
 3 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/drivers/net/e1000/base/e1000_osdep.h 
b/drivers/net/e1000/base/e1000_osdep.h
index b2c76e3..47a1948 100644
--- a/drivers/net/e1000/base/e1000_osdep.h
+++ b/drivers/net/e1000/base/e1000_osdep.h
@@ -96,21 +96,35 @@ typedef int bool;

 #define E1000_PCI_REG(reg) (*((volatile uint32_t *)(reg)))

+#define E1000_PCI_REG16(reg) (*((volatile uint16_t *)(reg)))
+
 #define E1000_PCI_REG_WRITE(reg, value) do { \
E1000_PCI_REG((reg)) = (rte_cpu_to_le_32(value)); \
 } while (0)

+#define E1000_PCI_REG_WRITE16(reg, value) do { \
+   E1000_PCI_REG16((reg)) = (rte_cpu_to_le_16(value)); \
+} while (0)
+
 #define E1000_PCI_REG_ADDR(hw, reg) \
((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))

 #define E1000_PCI_REG_ARRAY_ADDR(hw, reg, index) \
E1000_PCI_REG_ADDR((hw), (reg) + ((index) << 2))

-static inline uint32_t e1000_read_addr(volatile void* addr)
+#define E1000_PCI_REG_FLASH_ADDR(hw, reg) \
+   ((volatile uint32_t *)((char *)(hw)->flash_address + (reg)))
+
+static inline uint32_t e1000_read_addr(volatile void *addr)
 {
return rte_le_to_cpu_32(E1000_PCI_REG(addr));
 }

+static inline uint16_t e1000_read_addr16(volatile void *addr)
+{
+   return rte_le_to_cpu_16(E1000_PCI_REG16(addr));
+}
+
 /* Necessary defines */
 #define E1000_MRQC_ENABLE_MASK  0x0007
 #define E1000_MRQC_RSS_FIELD_IPV6_EX   0x0008
@@ -155,20 +169,20 @@ static inline uint32_t e1000_read_addr(volatile void* 
addr)
E1000_WRITE_REG(hw, reg, value)

 /*
- * Not implemented.
+ * Tested on I217/I218 chipset.
  */

 #define E1000_READ_FLASH_REG(hw, reg) \
-   (E1000_ACCESS_PANIC(E1000_READ_FLASH_REG, hw, reg, 0), 0)
+   e1000_read_addr(E1000_PCI_REG_FLASH_ADDR((hw), (reg)))

 #define E1000_READ_FLASH_REG16(hw, reg)  \
-   (E1000_ACCESS_PANIC(E1000_READ_FLASH_REG16, hw, reg, 0), 0)
+   e1000_read_addr16(E1000_PCI_REG_FLASH_ADDR((hw), (reg)))

 #define E1000_WRITE_FLASH_REG(hw, reg, value)  \
-   E1000_ACCESS_PANIC(E1000_WRITE_FLASH_REG, hw, reg, value)
+   E1000_PCI_REG_WRITE(E1000_PCI_REG_FLASH_ADDR((hw), (reg)), (value))

 #define E1000_WRITE_FLASH_REG16(hw, reg, value) \
-   E1000_ACCESS_PANIC(E1000_WRITE_FLASH_REG16, hw, reg, value)
+   E1000_PCI_REG_WRITE16(E1000_PCI_REG_FLASH_ADDR((hw), (reg)), (value))

 #define STATIC static

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 4a843fe..a8c26ed 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -231,6 +231,32 @@ rte_em_dev_atomic_write_link_status(struct rte_eth_dev 
*dev,
return 0;
 }

+/**
+ *  eth_em_dev_is_ich8 - Check for ICH8 device
+ *  @hw: pointer to the HW structure
+ *
+ *  return TRUE for ICH8, otherwise FALSE
+ **/
+static bool
+eth_em_dev_is_ich8(struct e1000_hw *hw)
+{
+   DEBUGFUNC("eth_em_dev_is_ich8");
+
+   switch (hw->device_id) {
+   case E1000_DEV_ID_PCH_LPT_I217_LM:
+   case E1000_DEV_ID_PCH_LPT_I217_V:
+   case E1000_DEV_ID_PCH_LPTLP_I218_LM:
+   case E1000_DEV_ID_PCH_LPTLP_I218_V:
+   case E1000_DEV_ID_PCH_I218_V2:
+   case E1000_DEV_ID_PCH_I218_LM2:
+   case E1000_DEV_ID_PCH_I218_V3:
+   case E1000_DEV_ID_PCH_I218_LM3:
+   return 1;
+   default:
+   return 0;
+   }
+}
+
 static int
 eth_em_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -265,6 +291,8 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
adapter->stopped = 0;

/* For ICH8 support we'll need to map the flash memory BAR */
+   if (eth_em_dev_is_ich8(hw))
+   hw->flash_address = (void 

[dpdk-dev] [PATCH v1] I217 and I218 changes

2016-03-02 Thread Ravi Kerur
v1: Make necessary changes to support I217 and I218 NICs.
Use v2' incorporating internal review comments as a base.
Internal review done by Wenzhou Lu (Intel) and internal
review versions and testing shown below

v2':
Incorporate Wenzhou's comments, remove superfluous
assignment to fc.requested_mode in em_hardware_init
function.
Compiled and tested (via testpmd) on Ubuntu 14.04 on target
x86_64-native-linuxapp-gcc
Compiled for target x86_64-native-linuxapp-clang

v1':
Modified driver and eal code to support I217 and I218
Intel NICs.
Compiled and tested (via testpmd) on Ubuntu 14.04 for target
x86_64-native-linuxapp-gcc
Compiled for target x86_64-native-linuxapp-clang
M. Jay(Intel) had used the patch for DPDK demo.

Signed-off-by: Ravi Kerur 
Acked-by: Wenzhuo Lu 
---
 drivers/net/e1000/base/e1000_osdep.h| 26 +++-
 drivers/net/e1000/em_ethdev.c   | 32 +
 lib/librte_eal/common/include/rte_pci_dev_ids.h |  9 +++
 3 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/drivers/net/e1000/base/e1000_osdep.h 
b/drivers/net/e1000/base/e1000_osdep.h
index b2c76e3..47a1948 100644
--- a/drivers/net/e1000/base/e1000_osdep.h
+++ b/drivers/net/e1000/base/e1000_osdep.h
@@ -96,21 +96,35 @@ typedef int bool;

 #define E1000_PCI_REG(reg) (*((volatile uint32_t *)(reg)))

+#define E1000_PCI_REG16(reg) (*((volatile uint16_t *)(reg)))
+
 #define E1000_PCI_REG_WRITE(reg, value) do { \
E1000_PCI_REG((reg)) = (rte_cpu_to_le_32(value)); \
 } while (0)

+#define E1000_PCI_REG_WRITE16(reg, value) do { \
+   E1000_PCI_REG16((reg)) = (rte_cpu_to_le_16(value)); \
+} while (0)
+
 #define E1000_PCI_REG_ADDR(hw, reg) \
((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))

 #define E1000_PCI_REG_ARRAY_ADDR(hw, reg, index) \
E1000_PCI_REG_ADDR((hw), (reg) + ((index) << 2))

-static inline uint32_t e1000_read_addr(volatile void* addr)
+#define E1000_PCI_REG_FLASH_ADDR(hw, reg) \
+   ((volatile uint32_t *)((char *)(hw)->flash_address + (reg)))
+
+static inline uint32_t e1000_read_addr(volatile void *addr)
 {
return rte_le_to_cpu_32(E1000_PCI_REG(addr));
 }

+static inline uint16_t e1000_read_addr16(volatile void *addr)
+{
+   return rte_le_to_cpu_16(E1000_PCI_REG16(addr));
+}
+
 /* Necessary defines */
 #define E1000_MRQC_ENABLE_MASK  0x0007
 #define E1000_MRQC_RSS_FIELD_IPV6_EX   0x0008
@@ -155,20 +169,20 @@ static inline uint32_t e1000_read_addr(volatile void* 
addr)
E1000_WRITE_REG(hw, reg, value)

 /*
- * Not implemented.
+ * Tested on I217/I218 chipset.
  */

 #define E1000_READ_FLASH_REG(hw, reg) \
-   (E1000_ACCESS_PANIC(E1000_READ_FLASH_REG, hw, reg, 0), 0)
+   e1000_read_addr(E1000_PCI_REG_FLASH_ADDR((hw), (reg)))

 #define E1000_READ_FLASH_REG16(hw, reg)  \
-   (E1000_ACCESS_PANIC(E1000_READ_FLASH_REG16, hw, reg, 0), 0)
+   e1000_read_addr16(E1000_PCI_REG_FLASH_ADDR((hw), (reg)))

 #define E1000_WRITE_FLASH_REG(hw, reg, value)  \
-   E1000_ACCESS_PANIC(E1000_WRITE_FLASH_REG, hw, reg, value)
+   E1000_PCI_REG_WRITE(E1000_PCI_REG_FLASH_ADDR((hw), (reg)), (value))

 #define E1000_WRITE_FLASH_REG16(hw, reg, value) \
-   E1000_ACCESS_PANIC(E1000_WRITE_FLASH_REG16, hw, reg, value)
+   E1000_PCI_REG_WRITE16(E1000_PCI_REG_FLASH_ADDR((hw), (reg)), (value))

 #define STATIC static

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 4a843fe..a8c26ed 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -231,6 +231,32 @@ rte_em_dev_atomic_write_link_status(struct rte_eth_dev 
*dev,
return 0;
 }

+/**
+ *  eth_em_dev_is_ich8 - Check for ICH8 device
+ *  @hw: pointer to the HW structure
+ *
+ *  return TRUE for ICH8, otherwise FALSE
+ **/
+static bool
+eth_em_dev_is_ich8(struct e1000_hw *hw)
+{
+   DEBUGFUNC("eth_em_dev_is_ich8");
+
+   switch (hw->device_id) {
+   case E1000_DEV_ID_PCH_LPT_I217_LM:
+   case E1000_DEV_ID_PCH_LPT_I217_V:
+   case E1000_DEV_ID_PCH_LPTLP_I218_LM:
+   case E1000_DEV_ID_PCH_LPTLP_I218_V:
+   case E1000_DEV_ID_PCH_I218_V2:
+   case E1000_DEV_ID_PCH_I218_LM2:
+   case E1000_DEV_ID_PCH_I218_V3:
+   case E1000_DEV_ID_PCH_I218_LM3:
+   return 1;
+   default:
+   return 0;
+   }
+}
+
 static int
 eth_em_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -265,6 +291,8 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
adapter->stopped = 0;

/* For ICH8 support we'll need to map the flash memory BAR */
+   if (eth_em_dev_is_ich8(hw))
+   hw->flash_address = (void 

[dpdk-dev] [PATCH v2] I217 and I218 changes

2016-03-01 Thread Ravi Kerur
On Mon, Feb 29, 2016 at 9:18 PM, Lu, Wenzhuo  wrote:

> Hi,
>
> > -Original Message-
> > From: Ravi Kerur [mailto:rkerur at gmail.com]
> > Sent: Tuesday, March 1, 2016 2:31 AM
> > To: Lu, Wenzhuo; dev at dpdk.org
> > Cc: Ravi Kerur
> > Subject: [PATCH v2] I217 and I218 changes
> >
> > v2:
> >   Incorporate Wenzhou's comments
> >   Compiled and tested (via testpmd) on Ubuntu 14.04 on target
> >   x86_64-native-linuxapp-gcc
> >   Compiled for target x86_64-native-linuxapp-clang
> >
> > v1:
> >   Modified driver and eal code to recognize and support I217 and
> >   I218 Intel NICs.
> >   Compiled and tested (via testpmd) on Ubuntu 14.04 for target
> >   x86_64-native-linuxapp-gcc
> >   Compiled for target x86_64-native-linuxapp-clang
> >
> > Signed-off-by: Ravi Kerur 
> Acked-by: Wenzhuo Lu 
> But the v1, v2 info in the commit log is a little strange. For you didn't
> send a v1 and others don't know our discussion :)
>
> Do you want me to resend it as 'v1' and include your comments in commit
message? let me know.

Thanks.


[dpdk-dev] [PATCH v2] I217 and I218 changes

2016-02-29 Thread Ravi Kerur
v2:
Incorporate Wenzhou's comments
Compiled and tested (via testpmd) on Ubuntu 14.04 on target
x86_64-native-linuxapp-gcc
Compiled for target x86_64-native-linuxapp-clang

v1:
Modified driver and eal code to recognize and support I217 and
I218 Intel NICs.
Compiled and tested (via testpmd) on Ubuntu 14.04 for target
x86_64-native-linuxapp-gcc
Compiled for target x86_64-native-linuxapp-clang

Signed-off-by: Ravi Kerur 
---
 drivers/net/e1000/base/e1000_osdep.h| 26 +++-
 drivers/net/e1000/em_ethdev.c   | 32 +
 lib/librte_eal/common/include/rte_pci_dev_ids.h |  9 +++
 3 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/drivers/net/e1000/base/e1000_osdep.h 
b/drivers/net/e1000/base/e1000_osdep.h
index b2c76e3..47a1948 100644
--- a/drivers/net/e1000/base/e1000_osdep.h
+++ b/drivers/net/e1000/base/e1000_osdep.h
@@ -96,21 +96,35 @@ typedef int bool;

 #define E1000_PCI_REG(reg) (*((volatile uint32_t *)(reg)))

+#define E1000_PCI_REG16(reg) (*((volatile uint16_t *)(reg)))
+
 #define E1000_PCI_REG_WRITE(reg, value) do { \
E1000_PCI_REG((reg)) = (rte_cpu_to_le_32(value)); \
 } while (0)

+#define E1000_PCI_REG_WRITE16(reg, value) do { \
+   E1000_PCI_REG16((reg)) = (rte_cpu_to_le_16(value)); \
+} while (0)
+
 #define E1000_PCI_REG_ADDR(hw, reg) \
((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))

 #define E1000_PCI_REG_ARRAY_ADDR(hw, reg, index) \
E1000_PCI_REG_ADDR((hw), (reg) + ((index) << 2))

-static inline uint32_t e1000_read_addr(volatile void* addr)
+#define E1000_PCI_REG_FLASH_ADDR(hw, reg) \
+   ((volatile uint32_t *)((char *)(hw)->flash_address + (reg)))
+
+static inline uint32_t e1000_read_addr(volatile void *addr)
 {
return rte_le_to_cpu_32(E1000_PCI_REG(addr));
 }

+static inline uint16_t e1000_read_addr16(volatile void *addr)
+{
+   return rte_le_to_cpu_16(E1000_PCI_REG16(addr));
+}
+
 /* Necessary defines */
 #define E1000_MRQC_ENABLE_MASK  0x0007
 #define E1000_MRQC_RSS_FIELD_IPV6_EX   0x0008
@@ -155,20 +169,20 @@ static inline uint32_t e1000_read_addr(volatile void* 
addr)
E1000_WRITE_REG(hw, reg, value)

 /*
- * Not implemented.
+ * Tested on I217/I218 chipset.
  */

 #define E1000_READ_FLASH_REG(hw, reg) \
-   (E1000_ACCESS_PANIC(E1000_READ_FLASH_REG, hw, reg, 0), 0)
+   e1000_read_addr(E1000_PCI_REG_FLASH_ADDR((hw), (reg)))

 #define E1000_READ_FLASH_REG16(hw, reg)  \
-   (E1000_ACCESS_PANIC(E1000_READ_FLASH_REG16, hw, reg, 0), 0)
+   e1000_read_addr16(E1000_PCI_REG_FLASH_ADDR((hw), (reg)))

 #define E1000_WRITE_FLASH_REG(hw, reg, value)  \
-   E1000_ACCESS_PANIC(E1000_WRITE_FLASH_REG, hw, reg, value)
+   E1000_PCI_REG_WRITE(E1000_PCI_REG_FLASH_ADDR((hw), (reg)), (value))

 #define E1000_WRITE_FLASH_REG16(hw, reg, value) \
-   E1000_ACCESS_PANIC(E1000_WRITE_FLASH_REG16, hw, reg, value)
+   E1000_PCI_REG_WRITE16(E1000_PCI_REG_FLASH_ADDR((hw), (reg)), (value))

 #define STATIC static

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 4a843fe..a8c26ed 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -231,6 +231,32 @@ rte_em_dev_atomic_write_link_status(struct rte_eth_dev 
*dev,
return 0;
 }

+/**
+ *  eth_em_dev_is_ich8 - Check for ICH8 device
+ *  @hw: pointer to the HW structure
+ *
+ *  return TRUE for ICH8, otherwise FALSE
+ **/
+static bool
+eth_em_dev_is_ich8(struct e1000_hw *hw)
+{
+   DEBUGFUNC("eth_em_dev_is_ich8");
+
+   switch (hw->device_id) {
+   case E1000_DEV_ID_PCH_LPT_I217_LM:
+   case E1000_DEV_ID_PCH_LPT_I217_V:
+   case E1000_DEV_ID_PCH_LPTLP_I218_LM:
+   case E1000_DEV_ID_PCH_LPTLP_I218_V:
+   case E1000_DEV_ID_PCH_I218_V2:
+   case E1000_DEV_ID_PCH_I218_LM2:
+   case E1000_DEV_ID_PCH_I218_V3:
+   case E1000_DEV_ID_PCH_I218_LM3:
+   return 1;
+   default:
+   return 0;
+   }
+}
+
 static int
 eth_em_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -265,6 +291,8 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
adapter->stopped = 0;

/* For ICH8 support we'll need to map the flash memory BAR */
+   if (eth_em_dev_is_ich8(hw))
+   hw->flash_address = (void *)pci_dev->mem_resource[1].addr;

if (e1000_setup_init_funcs(hw, TRUE) != E1000_SUCCESS ||
em_hw_init(hw) != 0) {
@@ -490,6 +518,7 @@ em_set_pba(struct e1000_hw *hw)
break;
case e1000_pchlan:
case e1000_pch2lan:
+   case e1000_pch_lpt:
pba = E1000_PBA_26K;
break;
default:
@@ -798,6 +827,8 @@ em_hardware_init(struct e1000_hw *hw)
hw->fc.low_water = 0x50

[dpdk-dev] [dpdk-dev, v3] Implement memcmp using Intel SIMD instrinsics.

2016-02-23 Thread Ravi Kerur
On Tue, Feb 23, 2016 at 4:22 AM, Wang, Zhihong 
wrote:

> > > It'd be great if you could format this patch into a patch set with
> several
> > > little ones. :-)
> > > Also, the kernel checkpatch is very helpful.
> > > Good coding style and patch organization make it easy for in-depth
> reviews.
> > >
> > Combination of scalar and vector (32/64/128) was done to get optimal
> performance numbers. If there is enough interest in this I can work on it
> and provide an updated patch set.
>
> That'll be very helpful! Looking forward to your patch :)
> BTW, have you tested real example performance with your patch?
>

Yes it was tested with hash functions in dpdk code.I will work on it and
send updated patch. Thanks for your inputs I will incorporate them in next
patch series.


[dpdk-dev] [dpdk-dev, v3] Implement memcmp using Intel SIMD instrinsics.

2016-02-19 Thread Ravi Kerur
On Wed, Jan 27, 2016 at 7:08 PM, Zhihong Wang 
wrote:

> > diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcmp.h b/lib
> > /librte_eal/common/include/arch/x86/rte_memcmp.h
>
> [...]
>
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +/**
> > + * Compare bytes between two locations. The locations must not overlap.
> > + *
>
> Parameter names should be kept consistent as they are in function body.
>
> > + * @param src_1
> > + *   Pointer to the first source of the data.
> > + * @param src_2
> > + *   Pointer to the second source of the data.
> > + * @param n
> > + *   Number of bytes to compare.
> > + * @return
> > + *   zero if src_1 equal src_2
> > + *   -ve if src_1 less than src_2
> > + *   +ve if src_1 greater than src_2
> > + */
> > +static inline int
> > +rte_memcmp(const void *src_1, const void *src,
> > + size_t n) __attribute__((always_inline));
> > +
> > +/**
> > + * Find the first different bit for comparison.
> > + */
> > +static inline int
> > +rte_cmpffd (uint32_t x, uint32_t y)
> > +{
> > + int i;
> > + int pos = x ^ y;
> > + for (i = 0; i < 32; i++)
> > + if (pos & (1<
> Coding style check :-)
> BTW, does the bsf instruction provide this check?
>
> > + return i;
> > + return -1;
> > +}
> > +
>
> [...]
>
> > +/**
> > + * Compare 48 bytes between two locations.
> > + * Locations should not overlap.
> > + */
> > +static inline int
> > +rte_cmp48(const void *src_1, const void *src_2)
>
> Guess this is not used.
>

I had left _unused_ with the assumption that it might be needed when actual
performance tests are done on high end servers.

>
> [...]
>
> > +/**
> > + * Compare 256 bytes between two locations.
> > + * Locations should not overlap.
> > + */
> > +static inline int
> > +rte_cmp256(const void *src_1, const void *src_2)
> > +{
> > + int ret;
> > +
> > + ret = rte_cmp64((const uint8_t *)src_1 + 0 * 64,
> > + (const uint8_t *)src_2 + 0 * 64);
>
> Why not just use rte_cmp128?
>
>
> [...]
>
> > +static inline int
> > +rte_memcmp(const void *_src_1, const void *_src_2, size_t n)
> > +{
> > + const uint8_t *src_1 = (const uint8_t *)_src_1;
> > + const uint8_t *src_2 = (const uint8_t *)_src_2;
> > + int ret = 0;
> > +
> > + if (n < 16)
> > + return rte_memcmp_regular(src_1, src_2, n);
> > +
> > + if (n <= 32) {
> > + ret = rte_cmp16(src_1, src_2);
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + return rte_cmp16(src_1 - 16 + n, src_2 - 16 + n);
> > + }
> > +
>
> Too many conditions here may harm the overall performance.
> It's a trade-off thing, all about balancing the overhead.
> Just make sure this is tuned based on actual test numbers.
>
>
> > + if (n <= 48) {
> > + ret = rte_cmp32(src_1, src_2);
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + return rte_cmp16(src_1 - 16 + n, src_2 - 16 + n);
> > + }
> > +
> > + if (n <= 64) {
> > + ret = rte_cmp32(src_1, src_2);
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + ret = rte_cmp16(src_1 + 32, src_2 + 32);
> > +
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + return rte_cmp16(src_1 - 16 + n, src_2 - 16 + n);
> > + }
> > +
> > + if (n <= 96) {
> > + ret = rte_cmp64(src_1, src_2);
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + ret = rte_cmp16(src_1 + 64, src_2 + 64);
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + return rte_cmp16(src_1 - 16 + n, src_2 - 16 + n);
> > + }
> > +
> > + if (n <= 128) {
> > + ret = rte_cmp64(src_1, src_2);
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + ret = rte_cmp32(src_1 + 64, src_2 + 64);
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + ret = rte_cmp16(src_1 + 96, src_2 + 96);
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + return rte_cmp16(src_1 - 16 + n, src_2 - 16 + n);
> > + }
>
> [...]
>
> > +/**
> > + * Compare 48 bytes between two locations.
> > + * Locations should not overlap.
> > + */
> > +static inline int
> > +rte_cmp48(const void *src_1, const void *src_2)
>
> Not used.
>
> > +{
> > + int ret;
> > +
> > + ret = rte_cmp16((const uint8_t *)src_1 + 0 * 16,
> > + (const uint8_t *)src_2 + 0 * 16);
> > +
> > + if (unlikely(ret != 0))
> > + return ret;
> > +
> > + ret = rte_cmp16((const uint8_t *)src_1 + 1 * 16,
> > + (const uint8_t *)src_2 + 1 * 16);
> > +
> > + if (unlikely(ret != 0))
> > +

[dpdk-dev] [dpdk-dev,v2] Clean up rte_memcpy.h file

2016-02-19 Thread Ravi Kerur
On Wed, Jan 27, 2016 at 8:18 PM, Zhihong Wang 
wrote:

> > Remove unnecessary type casting in functions.
> >
> > Tested on Ubuntu (14.04 x86_64) with "make test".
> > "make test" results match the results with baseline.
> > "Memcpy perf" results match the results with baseline.
> >
> > Signed-off-by: Ravi Kerur 
> > Acked-by: Stephen Hemminger 
> >
> > ---
> > .../common/include/arch/x86/rte_memcpy.h   | 340
> +++--
> >  1 file changed, 175 insertions(+), 165 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 6a57426..839d4ec 100644
> > --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
> > +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
>
> [...]
>
> >  /**
> > @@ -150,13 +150,16 @@ rte_mov64blocks(uint8_t *dst, const uint8_t *src,
> size_t n)
> >   __m256i ymm0, ymm1;
> >
> >   while (n >= 64) {
> > - ymm0 = _mm256_loadu_si256((const __m256i *)((const uint8_t
> *)src + 0 * 32));
> > +
> > + ymm0 = _mm256_loadu_si256((const __m256i *)(src + 0 * 32));
> > + ymm1 = _mm256_loadu_si256((const __m256i *)(src + 1 * 32));
> > +
> > + _mm256_storeu_si256((__m256i *)(dst + 0 * 32), ymm0);
> > + _mm256_storeu_si256((__m256i *)(dst + 1 * 32), ymm1);
> > +
>
> Any particular reason to change the order of the statements here? :)
> Overall this patch looks good.
>

Sorry for the late response. Let me double check and get back to you, it's
been a while since I did the changes.


> >   n -= 64;
> > - ymm1 = _mm256_loadu_si256((const __m256i *)((const uint8_t
> *)src + 1 * 32));
> > - src = (const uint8_t *)src + 64;
> > - _mm256_storeu_si256((__m256i *)((uint8_t *)dst + 0 * 32),
> ymm0);
> > - _mm256_storeu_si256((__m256i *)((uint8_t *)dst + 1 * 32),
> ymm1);
> > - dst = (uint8_t *)dst + 64;
> > + src = src + 64;
> > + dst = dst + 64;
> >   }
> >  }
> >
>
>


[dpdk-dev] [PATCH v1] Modify and modularize l3fwd code

2015-12-21 Thread Ravi Kerur
v1:
> Rebase to latest code base for DPDK team review.

Intel team's (Konstantin, Bruce and Declan) review comments

v4<-v3:
> Fix code review comments from Konstantin
> Move buffer optimization code into l3fwd_lpm_sse.h
  and l3fwd_em_sse.h for LPM and EM respectively
> Add compile time __SSE4_1__ for header file inclusion
> Tested with CONFIG_RTE_MACHINE=default for non
  __SSE4_1__ compilation and build
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v3<-v2:
> Fix code review comments from Bruce
> Fix multiple static definitions
> Move local #defines to C files, common #defines
to H file.
> Rename ipv4_l3fwd_route to ipv4_l3fwd_lpm and ipv4_l3fwd_em
> Rename ipv6_l3fwd_route to ipv6_l3fwd_lpm and ipv6_l3fwd_lpm
> Pass additional parameter to send_single_packet
> Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04

v2<-v1:
> Fix errors in GCC 5.1
> Restore "static inline" functions, rearrange
functions to take "static inline" into account
> Duplicate main_loop for LPM and EM

v1:
> Split main.c into following 3 files
> main.c, (parsing, buffer alloc, and other utilities)
> l3fwd_lpm.c, (Longest Prefix Match functions)
> l3fwd_em.c, (Exact Match f.e. Hash functions)
> l3fwd.h, (Common defines and prototypes)

> Select LPM or EM based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (Exact Match)
> l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

> Options "E" and "L" are mutualy-exclusive.

> Use function pointers during initialiation of relevant
data structures.

> Remove unwanted #ifdefs in the code with exception to
> DO_RFC_1812_CHECKS
> RTE_MACHINE_CPUFLAG_SSE4_2

> Compiled for
> i686-native-linuxapp-gcc
> x86_64-native-linuxapp-gcc
> x86_x32-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc

> Tested on
    > Ubuntu 14.04 (GCC 4.8.4)
> FreeBSD 10.0 (GCC 4.8)
> I217 and I218 respectively.

Signed-off-by: Ravi Kerur 
---
 examples/l3fwd/Makefile|9 +-
 examples/l3fwd/l3fwd.h |  209 
 examples/l3fwd/l3fwd_em.c  |  773 ++
 examples/l3fwd/l3fwd_em_sse.h  |  479 +
 examples/l3fwd/l3fwd_lpm.c |  414 
 examples/l3fwd/l3fwd_lpm_sse.h |  610 +++
 examples/l3fwd/main.c  | 2202 
 7 files changed, 2694 insertions(+), 2002 deletions(-)
 create mode 100644 examples/l3fwd/l3fwd.h
 create mode 100644 examples/l3fwd/l3fwd_em.c
 create mode 100644 examples/l3fwd/l3fwd_em_sse.h
 create mode 100644 examples/l3fwd/l3fwd_lpm.c
 create mode 100644 examples/l3fwd/l3fwd_lpm_sse.h

diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile
index 68de8fc..94a2282 100644
--- a/examples/l3fwd/Makefile
+++ b/examples/l3fwd/Makefile
@@ -42,15 +42,10 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l3fwd

 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c

+CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3 $(USER_FLAGS)
 CFLAGS += $(WERROR_FLAGS)

-# workaround for a gcc bug with noreturn attribute
-# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
-ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
-CFLAGS_main.o += -Wno-return-type
-endif
-
 include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h
new file mode 100644
index 000..50e40fe
--- /dev/null
+++ b/examples/l3fwd/l3fwd.h
@@ -0,0 +1,209 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTI

[dpdk-dev] [PATCH v1] Modify and modularize l3fwd code

2015-12-21 Thread Ravi Kerur
Many thanks to Intel team (Konstantin, Bruce and Declan) for below proposal to
make changes to l3fwd code, their valuable inputs during interal review and help
in performance tests.

The main problem with l3fwd is that it is too monolithic with everything being
in one file, and the various options all controlled by compile time flags. This 
means that it's hard to read and understand, and when making any changes, you 
need
to go to a lot of work to try and ensure you cover all the code paths, since a 
compile of the app will not touch large parts of the l3fwd codebase.

Following changes were done to fix the issues mentioned above

> Split out the various lpm and hash specific functionality into 
separate
  files, so that l3fwd code has one file for common code e.g. args 
  processing, mempool creation, and then individual files for the 
various
  forwarding approaches.

  Following are new file lists

  main.c (Common code for args processing, memppol creation, etc)
  l3fwd_em.c (Hash/Exact match aka 'EM' functionality)
  l3fwd_em_sse.h (SSE4_1 buffer optimizated 'EM' code)
  l3fwd_lpm.c (Longest Prefix Match aka 'LPM' functionality)
  l3fwd_lpm_sse.h (SSE4_1 buffer optimizated 'LPM' code)
  l3fwd.h (Common include for 'EM' and 'LPM')


> The choosing of the lpm/hash path should be done at runtime, not
  compile time, via a command-line argument. This will ensure that 
  both code paths get compiled in a single go

  Following examples show runtime options provided

  Select 'LPM' or 'EM' based on run time selection f.e.
> l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (EM)
> l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM)

  Options "E" and "L" are mutualy-exclusive.

  If none selected, "L" is default.

Ravi Kerur (1):
  Modify and modularize l3fwd code

 examples/l3fwd/Makefile|9 +-
 examples/l3fwd/l3fwd.h |  209 
 examples/l3fwd/l3fwd_em.c  |  773 ++
 examples/l3fwd/l3fwd_em_sse.h  |  479 +
 examples/l3fwd/l3fwd_lpm.c |  414 
 examples/l3fwd/l3fwd_lpm_sse.h |  610 +++
 examples/l3fwd/main.c  | 2202 
 7 files changed, 2694 insertions(+), 2002 deletions(-)
 create mode 100644 examples/l3fwd/l3fwd.h
 create mode 100644 examples/l3fwd/l3fwd_em.c
 create mode 100644 examples/l3fwd/l3fwd_em_sse.h
 create mode 100644 examples/l3fwd/l3fwd_lpm.c
 create mode 100644 examples/l3fwd/l3fwd_lpm_sse.h

-- 
1.9.1



[dpdk-dev] [PATCH v4] Move rte_mbuf macros to common header file

2015-10-01 Thread Ravi Kerur
Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
are defined in each PMD driver file. Convert macros to inline
functions and move them to common lib/librte_mbuf/rte_mbuf.h file.
PMD drivers include rte_mbuf.h file directly/indirectly hence no
additionl header file inclusion is necessary.

v4:
> Remove un-necessary cast and braces in inline functions.
> Add 'const' for function parameters

v3:
> Changed converted macro->inline names to lower-case
> Fix checkpatch.pl errors and warnings
(camelcase warning is not fixed)

> Compiled following targets
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc
> x86_64-native-bsdapp-clang

> Tested on:
> x86_64 ubuntu 14.04,  make test

v2:
> Changed both macros to inline functions in all PMD
> Changed macro to rte_pktmbuf_mtod in xenvirt module

> Compiled following targets:
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc

> Tested on:
> x86_64 ubuntu 14.04, testpmd and make test

v1:
> Move macros into common rte_mbuf header file.

> Compiled following targets:
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc
> x86_64-native-bsdapp-clang

Tested on:
> x86_64 Ubuntu 14.04, testpmd and make test
> FreeBSD 10.1, testpmd

Signed-off-by: Ravi Kerur 
---
 drivers/net/bnx2x/bnx2x.c  |  2 +-
 drivers/net/bnx2x/bnx2x.h  |  3 ---
 drivers/net/cxgbe/sge.c|  3 ---
 drivers/net/e1000/em_rxtx.c| 15 +--
 drivers/net/e1000/igb_rxtx.c   | 14 --
 drivers/net/i40e/i40e_rxtx.c   | 20 +++-
 drivers/net/ixgbe/ixgbe_rxtx.c | 14 +++---
 drivers/net/ixgbe/ixgbe_rxtx.h |  6 --
 drivers/net/virtio/virtio_rxtx.c   |  2 +-
 drivers/net/virtio/virtqueue.h |  3 ---
 drivers/net/vmxnet3/vmxnet3_rxtx.c | 11 +++
 drivers/net/xenvirt/virtqueue.h|  5 +
 lib/librte_mbuf/rte_mbuf.h | 12 
 13 files changed, 41 insertions(+), 69 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index fed7a06..a3f118c 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -2147,7 +2147,7 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct 
rte_mbuf **m_head, int m_p
tx_start_bd = >tx_ring[TX_BD(bd_prod, txq)].start_bd;

tx_start_bd->addr =
-   rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR(m0));
+   rte_cpu_to_le_64(rte_mbuf_data_dma_addr(m0));
tx_start_bd->nbytes = rte_cpu_to_le_16(m0->data_len);
tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD;
tx_start_bd->general_data =
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 867b92a..28bd83f 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -141,9 +141,6 @@ struct bnx2x_device_type {
char *bnx2x_name;
 };

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   ((uint64_t)((mb)->buf_physaddr + (mb)->data_off))
-
 #define BNX2X_PAGE_SHIFT   12
 #define BNX2X_PAGE_SIZE(1 << BNX2X_PAGE_SHIFT)
 #define BNX2X_PAGE_MASK(~(BNX2X_PAGE_SIZE - 1))
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 6eb1244..8f4c025 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1267,9 +1267,6 @@ static struct rte_mbuf *t4_pktgl_to_mbuf(const struct 
pkt_gl *gl)
return t4_pktgl_to_mbuf_usembufs(gl);
 }

-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   ((dma_addr_t) ((mb)->buf_physaddr + (mb)->data_off))
-
 /**
  * t4_ethrx_handler - process an ingress ethernet packet
  * @q: the response queue that received the packet
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 3b8776d..39c9744 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -88,12 +88,6 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
return (m);
 }

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
 /**
  * Structure associated with each descriptor of the RX ring of a RX queue.
  */
@@ -585,7 +579,7 @@ eth_em_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,

[dpdk-dev] [PATCH v4] Move rte_mbuf macros to common header file

2015-10-01 Thread Ravi Kerur
Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
are defined in each PMD driver file. Convert macros to inline
functions and move them to common lib/librte_mbuf/rte_mbuf.h file.
PMD drivers include rte_mbuf.h file directly/indirectly hence no
additionl header file inclusion is necessary.

v4:
> Remove un-necessary cast and braces in inline functions.

v3:
> Changed converted macro->inline names to lower-case
> Fix checkpatch.pl errors and warnings
(camelcase warning is not fixed)

> Compiled following targets
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc
> x86_64-native-bsdapp-clang

> Tested on:
> x86_64 ubuntu 14.04,  make test

v2:
> Changed both macros to inline functions in all PMD
> Changed macro to rte_pktmbuf_mtod in xenvirt module

> Compiled following targets:
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc

> Tested on:
> x86_64 ubuntu 14.04, testpmd and make test

v1:
> Move macros into common rte_mbuf header file.

> Compiled following targets:
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc
> x86_64-native-bsdapp-clang

Tested on:
> x86_64 Ubuntu 14.04, testpmd and 'make test'
> FreeBSD 10.1, testpmd

Signed-off-by: Ravi Kerur 
---
 drivers/net/bnx2x/bnx2x.c  |  2 +-
 drivers/net/bnx2x/bnx2x.h  |  3 ---
 drivers/net/cxgbe/sge.c|  3 ---
 drivers/net/e1000/em_rxtx.c| 15 +--
 drivers/net/e1000/igb_rxtx.c   | 14 --
 drivers/net/i40e/i40e_rxtx.c   | 20 +++-
 drivers/net/ixgbe/ixgbe_rxtx.c | 14 +++---
 drivers/net/ixgbe/ixgbe_rxtx.h |  6 --
 drivers/net/virtio/virtio_rxtx.c   |  2 +-
 drivers/net/virtio/virtqueue.h |  3 ---
 drivers/net/vmxnet3/vmxnet3_rxtx.c | 11 +++
 drivers/net/xenvirt/virtqueue.h|  5 +
 lib/librte_mbuf/rte_mbuf.h | 13 +
 13 files changed, 42 insertions(+), 69 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index fed7a06..a3f118c 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -2147,7 +2147,7 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct 
rte_mbuf **m_head, int m_p
tx_start_bd = >tx_ring[TX_BD(bd_prod, txq)].start_bd;

tx_start_bd->addr =
-   rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR(m0));
+   rte_cpu_to_le_64(rte_mbuf_data_dma_addr(m0));
tx_start_bd->nbytes = rte_cpu_to_le_16(m0->data_len);
tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD;
tx_start_bd->general_data =
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 867b92a..28bd83f 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -141,9 +141,6 @@ struct bnx2x_device_type {
char *bnx2x_name;
 };

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   ((uint64_t)((mb)->buf_physaddr + (mb)->data_off))
-
 #define BNX2X_PAGE_SHIFT   12
 #define BNX2X_PAGE_SIZE(1 << BNX2X_PAGE_SHIFT)
 #define BNX2X_PAGE_MASK(~(BNX2X_PAGE_SIZE - 1))
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 6eb1244..8f4c025 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1267,9 +1267,6 @@ static struct rte_mbuf *t4_pktgl_to_mbuf(const struct 
pkt_gl *gl)
return t4_pktgl_to_mbuf_usembufs(gl);
 }

-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   ((dma_addr_t) ((mb)->buf_physaddr + (mb)->data_off))
-
 /**
  * t4_ethrx_handler - process an ingress ethernet packet
  * @q: the response queue that received the packet
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 3b8776d..39c9744 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -88,12 +88,6 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
return (m);
 }

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
 /**
  * Structure associated with each descriptor of the RX ring of a RX queue.
  */
@@ -585,7 +579,7 @@ eth_em_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 * Set up Transmit Data Descriptor.
 

[dpdk-dev] [PATCH v2] Move rte_mbuf macros to common header file

2015-09-30 Thread Ravi Kerur
On Wed, Sep 30, 2015 at 12:41 PM, Aaron Conole  wrote:

> Ravi Kerur  writes:
>
> > Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
> > are defined in each PMD driver file. Move those macros into common
> > lib/librte_mbuf/rte_mbuf.h file. PMD drivers include rte_mbuf.h
> > file directly/indirectly hence no additionl header file inclusion
> > is necessary.
> I think this should also mention that they are no longer macros, as
> well.
>
> <>
> > --- a/lib/librte_mbuf/rte_mbuf.h
> > +++ b/lib/librte_mbuf/rte_mbuf.h
> > @@ -843,6 +843,16 @@ struct rte_mbuf {
> >   uint16_t timesync;
> >  } __rte_cache_aligned;
> >
> > +static inline uint64_t RTE_MBUF_DATA_DMA_ADDR(struct rte_mbuf* mb)
> > +{
> > + return ((uint64_t)((mb)->buf_physaddr + (mb)->data_off));
> > +}
> > +
> > +static inline uint64_t RTE_MBUF_DATA_DMA_ADDR_DEFAULT(struct rte_mbuf
> *mb)
> > +{
> > + return ((uint64_t)((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM));
> > +}
> > +
> I think these names should be made lower case as well.
>

Thanks, I was waiting for one explicit input on this. I have sent v3 patch.


[dpdk-dev] [PATCH v3] Move rte_mbuf macros to common header file

2015-09-30 Thread Ravi Kerur
Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
are defined in each PMD driver file. Convert macros to inline
functions and move them to common lib/librte_mbuf/rte_mbuf.h file.
PMD drivers include rte_mbuf.h file directly/indirectly hence no
additionl header file inclusion is necessary.

v3:
> Changed converted macro->inline names to lower-case
> Fix checkpatch.pl errors and warnings
(camelcase warning is not fixed)
> Compiled following targets
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc
> x86_64-native-bsdapp-clang

> Tested x86_64 ubuntu 14.04
> make test
v2:
> Changed both macros to inline functions in all PMD
> Changed macro to rte_pktmbuf_mtod in xenvirt module

> Compiled following targets
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc

> Tested x86_64 ubuntu 14.04
> testpmd and make test
v1:
> Move macros into common rte_mbuf header file.

> Compiled for:
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc
> x86_64-native-bsdapp-clang

Tested on:
> x86_64 Ubuntu 14.04, testpmd and 'make test'
> FreeBSD 10.1, testpmd

Signed-off-by: Ravi Kerur 
---
 drivers/net/bnx2x/bnx2x.c  |  2 +-
 drivers/net/bnx2x/bnx2x.h  |  3 ---
 drivers/net/cxgbe/sge.c|  3 ---
 drivers/net/e1000/em_rxtx.c| 15 +--
 drivers/net/e1000/igb_rxtx.c   | 14 --
 drivers/net/i40e/i40e_rxtx.c   | 20 +++-
 drivers/net/ixgbe/ixgbe_rxtx.c | 14 +++---
 drivers/net/ixgbe/ixgbe_rxtx.h |  6 --
 drivers/net/virtio/virtio_rxtx.c   |  2 +-
 drivers/net/virtio/virtqueue.h |  3 ---
 drivers/net/vmxnet3/vmxnet3_rxtx.c | 11 +++
 drivers/net/xenvirt/virtqueue.h|  5 +
 lib/librte_mbuf/rte_mbuf.h | 10 ++
 13 files changed, 39 insertions(+), 69 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index fed7a06..a3f118c 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -2147,7 +2147,7 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct 
rte_mbuf **m_head, int m_p
tx_start_bd = >tx_ring[TX_BD(bd_prod, txq)].start_bd;

tx_start_bd->addr =
-   rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR(m0));
+   rte_cpu_to_le_64(rte_mbuf_data_dma_addr(m0));
tx_start_bd->nbytes = rte_cpu_to_le_16(m0->data_len);
tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD;
tx_start_bd->general_data =
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 867b92a..28bd83f 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -141,9 +141,6 @@ struct bnx2x_device_type {
char *bnx2x_name;
 };

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   ((uint64_t)((mb)->buf_physaddr + (mb)->data_off))
-
 #define BNX2X_PAGE_SHIFT   12
 #define BNX2X_PAGE_SIZE(1 << BNX2X_PAGE_SHIFT)
 #define BNX2X_PAGE_MASK(~(BNX2X_PAGE_SIZE - 1))
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 6eb1244..8f4c025 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1267,9 +1267,6 @@ static struct rte_mbuf *t4_pktgl_to_mbuf(const struct 
pkt_gl *gl)
return t4_pktgl_to_mbuf_usembufs(gl);
 }

-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   ((dma_addr_t) ((mb)->buf_physaddr + (mb)->data_off))
-
 /**
  * t4_ethrx_handler - process an ingress ethernet packet
  * @q: the response queue that received the packet
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 3b8776d..39c9744 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -88,12 +88,6 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
return (m);
 }

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
 /**
  * Structure associated with each descriptor of the RX ring of a RX queue.
  */
@@ -585,7 +579,7 @@ eth_em_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 * Set up Transmit Data Descriptor.
 */
slen = m_seg->data_len;
-   buf_dma_addr

[dpdk-dev] [PATCH v2] Move rte_mbuf macros to common header file

2015-09-30 Thread Ravi Kerur
Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
are defined in each PMD driver file. Move those macros into common
lib/librte_mbuf/rte_mbuf.h file. PMD drivers include rte_mbuf.h
file directly/indirectly hence no additionl header file inclusion
is necessary.

v2:
> Changed both macros to inline functions in all PMD
> Changed macro to rte_pktmbuf_mtod in xenvirt module

v1:
> Move macros into common rte_mbuf header file.

Compiled for:
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc
> x86_64-native-bsdapp-clang

Tested on:
> x86_64 Ubuntu 14.04, testpmd and 'make test'
> FreeBSD 10.1, testpmd

Signed-off-by: Ravi Kerur 
---
 drivers/net/bnx2x/bnx2x.h  |  3 ---
 drivers/net/cxgbe/sge.c|  3 ---
 drivers/net/e1000/em_rxtx.c|  6 --
 drivers/net/e1000/igb_rxtx.c   |  6 --
 drivers/net/i40e/i40e_rxtx.c   |  6 --
 drivers/net/ixgbe/ixgbe_rxtx.h |  6 --
 drivers/net/virtio/virtqueue.h |  3 ---
 drivers/net/vmxnet3/vmxnet3_rxtx.c |  6 --
 drivers/net/xenvirt/virtqueue.h|  5 +
 lib/librte_mbuf/rte_mbuf.h | 10 ++
 10 files changed, 11 insertions(+), 43 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 867b92a..28bd83f 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -141,9 +141,6 @@ struct bnx2x_device_type {
char *bnx2x_name;
 };

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   ((uint64_t)((mb)->buf_physaddr + (mb)->data_off))
-
 #define BNX2X_PAGE_SHIFT   12
 #define BNX2X_PAGE_SIZE(1 << BNX2X_PAGE_SHIFT)
 #define BNX2X_PAGE_MASK(~(BNX2X_PAGE_SIZE - 1))
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 6eb1244..8f4c025 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1267,9 +1267,6 @@ static struct rte_mbuf *t4_pktgl_to_mbuf(const struct 
pkt_gl *gl)
return t4_pktgl_to_mbuf_usembufs(gl);
 }

-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   ((dma_addr_t) ((mb)->buf_physaddr + (mb)->data_off))
-
 /**
  * t4_ethrx_handler - process an ingress ethernet packet
  * @q: the response queue that received the packet
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 3b8776d..c7d97c1 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -88,12 +88,6 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
return (m);
 }

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
 /**
  * Structure associated with each descriptor of the RX ring of a RX queue.
  */
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 19905fd..a217cea 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -88,12 +88,6 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
return (m);
 }

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
 /**
  * Structure associated with each descriptor of the RX ring of a RX queue.
  */
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index fd656d5..5ba6d27 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -78,12 +78,6 @@
PKT_TX_L4_MASK | \
PKT_TX_OUTER_IP_CKSUM)

-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   ((uint64_t)((mb)->buf_physaddr + (mb)->data_off))
-
 static const struct rte_memzone *
 i40e_ring_dma_zone_reserve(struct rte_eth_dev *dev,
   const char *ring_name,
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index b9eca67..dbb9f00 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -40,12 +40,6 @@

 #define RTE_IXGBE_DESCS_PER_LOOP4

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
 #ifdef RTE_IXGBE_INC_VECTOR
 #define RTE_IXGBE_RXQ_REARM_THRESH  32
 #define RTE_IXGBE_MAX_RX_BURST  RTE_IXGBE_RXQ_REARM_THRESH
diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index 7789411..9ea9b96 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -68,9 +68,6 @@ struct rte_mbuf;

 #define VIRTQUEUE_MAX_NAME_SZ 32

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-  

[dpdk-dev] [PATCH v2] Change rte_eal_vdev_init to update port_id

2015-09-30 Thread Ravi Kerur
Hi Tetsuya,


On Mon, Sep 28, 2015 at 8:32 PM, Tetsuya Mukawa  wrote:

> On 2015/09/24 6:22, Ravi Kerur wrote:
> > Hi David, Tetsuya,
> >
> > I have sent V3 (changes isolated to rte_ether component) for formal
> review.
> > Please look into it and let me know your inputs.
>
> Hi Ravi,
>
> I've checked the patch.
> I guess your patch is good.
>
> >
> > @David: I looked at "rte_eth_dev_get_port_by_name()", this function is
> > similar to "rte_eth_dev_get_name_by_port" and I have used same logic. Let
> > me know if this not correct I can fix both.
>
> Do you comment about rte_eth_dev_get_port_by_name and
> rte_eth_dev_get_port_by_addr?
> If so, I guess we don't need to merge.
>
>
I just mentioned that new functions are using same logic as existing
function.

Thanks,
Ravi


> > Thanks,
> > Ravi
> >
> >
> > On Tue, Sep 15, 2015 at 4:28 AM, Ravi Kerur  wrote:
> >
> >> Hi David,
> >>
> >>
> >> On Thu, Sep 3, 2015 at 7:04 AM, David Marchand <
> david.marchand at 6wind.com>
> >> wrote:
> >>
> >>> Hello Ravi, Tetsuya,
> >>>
> >>> On Tue, Aug 25, 2015 at 7:59 PM, Ravi Kerur  wrote:
> >>>
> >>>> Let us know how you want us to fix this? To fix rte_eal_vdev_init and
> >>>> rte_eal_pci_probe_one to return allocated port_id we had 2 approaches
> >>>> mentioned in earlier discussion. In addition to those we have another
> >>>> approach with changes isolated only to rte_ether component. I am
> attaching
> >>>> diffs (preliminary) with this email. Please let us know your inputs
> since
> >>>> it involves EAL component.
> >>>>
> >>> - This patch looks like a good ethdev cleanup (even if it really lacks
> >>> some context / commit log).
> >>>
> >>> I wonder just why you only take the first part of the name in
> >>> rte_eth_dev_get_port_by_name().
> >>> Would not this match, let's say, both toto and toto0 vdevs ?
> >>> Is this intended ?
> >>>
> >>> It was not intended, i will look into it.
> >>> - In the end, with this patch, do we still need to update eal ?
> >>> Looking at the code, I am not sure anymore.
> >>>
> >> Approach 3 (preliminary diffs sent as an attachment) doesn't involve EAL
> >> but the other two solutions do. So please let us know which one you
> prefer.
> >> I will send updated patch.
> >>
> >> Thanks,
> >> Ravi
> >>
> >>
> >>>
> >>>
> >>> --
> >>> David Marchand
> >>>
> >>
>
>


[dpdk-dev] [PATCH v1] Move rte_mbuf macros to common header file

2015-09-30 Thread Ravi Kerur
Thanks Konstantin. I will send out v2 shortly.

On Tue, Sep 29, 2015 at 2:55 AM, Ananyev, Konstantin <
konstantin.ananyev at intel.com> wrote:

>
> Hi Ravi,
>
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ravi Kerur
> > Sent: Saturday, September 26, 2015 3:47 AM
> > To: Stephen Hemminger; Olivier Matz
> > Cc: dev at dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v1] Move rte_mbuf macros to common header
> file
> >
> > On Thu, Sep 24, 2015 at 4:25 PM, Stephen Hemminger <
> > stephen at networkplumber.org> wrote:
> >
> > > On Thu, 24 Sep 2015 15:50:41 -0700
> > > Ravi Kerur  wrote:
> > >
> > > > Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
> > > > are defined in each PMD driver file. Move those macros into common
> > > > lib/librte_mbuf/rte_mbuf.h file. All PMD drivers include rte_mbuf.h
> > > > file directly/indirectly hence no additionl header file inclusion
> > > > is necessary.
> > > >
> > > > Compiled for:
> > > > > x86_64-native-linuxapp-clang
> > > > > x86_64-native-linuxapp-gcc
> > > > > i686-native-linuxapp-gcc
> > > > > x86_64-native-bsdapp-gcc
> > > > > x86_64-native-bsdapp-clang
> > > >
> > > > Tested on:
> > > > > x86_64 Ubuntu 14.04, testpmd and 'make test'
> > > > > FreeBSD 10.1, testpmd
> > > >
> > > > Signed-off-by: Ravi Kerur 
> > >
> > > I like the idea, should have been done long ago.
> > >
> > > My only gripe is that you should do this as inline functions
> > > rather than macros. Inline functions are type safe, macros are not.
> > >
> >
> > Agreed. However, I see another variation of the macro, users are
> primarily
> > from "app" directory and lone user from drivers/net/xenvirt/virtqueue.h
> >
> > #define RTE_MBUF_DATA_DMA_ADDR(mb) \
> > rte_pktmbuf_mtod(mb, uint64_t)
>
>
> As I can see, it is used only in one place inside xenvirt:
>
> drivers/net/xenvirt/virtqueue.h:start_dp[idx].addr  =
> RTE_MBUF_DATA_DMA_ADDR(cookie);
>
> So we probably can remove that macro definition here and use
> rte_pktmbuf_mtod(mb, uint64_t) directly.
>
> Konstantin
>
> >
> > #define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0)
> >
> > #define rte_pktmbuf_mtod_offset(m, t, o)\
> > ((t)((char *)(m)->buf_addr + (m)->data_off + (o)))
> >
> > Let me know should I still go ahead and do inline variation for drivers
> or
> > use above macro?
>


[dpdk-dev] [PATCH v1] Move rte_mbuf macros to common header file

2015-09-25 Thread Ravi Kerur
On Thu, Sep 24, 2015 at 4:25 PM, Stephen Hemminger <
stephen at networkplumber.org> wrote:

> On Thu, 24 Sep 2015 15:50:41 -0700
> Ravi Kerur  wrote:
>
> > Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
> > are defined in each PMD driver file. Move those macros into common
> > lib/librte_mbuf/rte_mbuf.h file. All PMD drivers include rte_mbuf.h
> > file directly/indirectly hence no additionl header file inclusion
> > is necessary.
> >
> > Compiled for:
> > > x86_64-native-linuxapp-clang
> > > x86_64-native-linuxapp-gcc
> > > i686-native-linuxapp-gcc
> > > x86_64-native-bsdapp-gcc
> > > x86_64-native-bsdapp-clang
> >
> > Tested on:
> > > x86_64 Ubuntu 14.04, testpmd and 'make test'
> > > FreeBSD 10.1, testpmd
> >
> > Signed-off-by: Ravi Kerur 
>
> I like the idea, should have been done long ago.
>
> My only gripe is that you should do this as inline functions
> rather than macros. Inline functions are type safe, macros are not.
>

Agreed. However, I see another variation of the macro, users are primarily
from "app" directory and lone user from drivers/net/xenvirt/virtqueue.h

#define RTE_MBUF_DATA_DMA_ADDR(mb) \
rte_pktmbuf_mtod(mb, uint64_t)

#define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0)

#define rte_pktmbuf_mtod_offset(m, t, o)\
((t)((char *)(m)->buf_addr + (m)->data_off + (o)))

Let me know should I still go ahead and do inline variation for drivers or
use above macro?


[dpdk-dev] [PATCH v1] Add support for Intel chipsets

2015-09-25 Thread Ravi Kerur
On Fri, Sep 25, 2015 at 1:04 AM, Lu, Wenzhuo  wrote:

> Hi all,
>
> > -Original Message-
> > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > Sent: Friday, September 25, 2015 3:08 PM
> > To: Ravi Kerur
> > Cc: dev at dpdk.org; Lu, Wenzhuo
> > Subject: Re: [dpdk-dev] [PATCH v1] Add support for Intel chipsets
> >
> > 2015-09-24 15:13, Ravi Kerur:
> > > M. Jay(Jayakumar, Muthurajan) and I
> > > discussed and decided to include support for I217/I218 chipsets
> > [...]
> > >  drivers/net/e1000/base/e1000_api.c  |  1 +
> > >  drivers/net/e1000/base/e1000_hw.h   |  1 +
> > >  drivers/net/e1000/base/e1000_ich8lan.c  | 30
> +++-
> > >  drivers/net/e1000/base/e1000_osdep.h| 24
> +++
> >
> > You are modifying the base driver which is only allowed by Intel. But
> there can
> > be exceptions. Wenzhuo, is it an exception?
> I'm afraid it's not an exception.  We plan to update e1000 base code
> recently. Hope it will help.
> Thanks.
>

Ok thanks was not aware of it. Can you let me know what version of
e1000/e1000e you plan to update just to make sure it has support for these.

Thanks,
Ravi


[dpdk-dev] [PATCH v1] Move rte_mbuf macros to common header file

2015-09-24 Thread Ravi Kerur
Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
are defined in each PMD driver file. Move those macros into common
lib/librte_mbuf/rte_mbuf.h file. All PMD drivers include rte_mbuf.h
file directly/indirectly hence no additionl header file inclusion
is necessary.

Compiled for:
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> i686-native-linuxapp-gcc
> x86_64-native-bsdapp-gcc
> x86_64-native-bsdapp-clang

Tested on:
> x86_64 Ubuntu 14.04, testpmd and 'make test'
> FreeBSD 10.1, testpmd

Signed-off-by: Ravi Kerur 
---
 drivers/net/bnx2x/bnx2x.h  | 3 ---
 drivers/net/cxgbe/sge.c| 3 ---
 drivers/net/e1000/em_rxtx.c| 6 --
 drivers/net/e1000/igb_rxtx.c   | 6 --
 drivers/net/i40e/i40e_rxtx.c   | 6 --
 drivers/net/ixgbe/ixgbe_rxtx.h | 6 --
 drivers/net/virtio/virtqueue.h | 3 ---
 drivers/net/vmxnet3/vmxnet3_rxtx.c | 6 --
 lib/librte_mbuf/rte_mbuf.h | 6 ++
 9 files changed, 6 insertions(+), 39 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 867b92a..28bd83f 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -141,9 +141,6 @@ struct bnx2x_device_type {
char *bnx2x_name;
 };

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   ((uint64_t)((mb)->buf_physaddr + (mb)->data_off))
-
 #define BNX2X_PAGE_SHIFT   12
 #define BNX2X_PAGE_SIZE(1 << BNX2X_PAGE_SHIFT)
 #define BNX2X_PAGE_MASK(~(BNX2X_PAGE_SIZE - 1))
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 6eb1244..8f4c025 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -1267,9 +1267,6 @@ static struct rte_mbuf *t4_pktgl_to_mbuf(const struct 
pkt_gl *gl)
return t4_pktgl_to_mbuf_usembufs(gl);
 }

-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   ((dma_addr_t) ((mb)->buf_physaddr + (mb)->data_off))
-
 /**
  * t4_ethrx_handler - process an ingress ethernet packet
  * @q: the response queue that received the packet
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 3b8776d..c7d97c1 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -88,12 +88,6 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
return (m);
 }

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
 /**
  * Structure associated with each descriptor of the RX ring of a RX queue.
  */
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 19905fd..a217cea 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -88,12 +88,6 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
return (m);
 }

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
 /**
  * Structure associated with each descriptor of the RX ring of a RX queue.
  */
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index fd656d5..5ba6d27 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -78,12 +78,6 @@
PKT_TX_L4_MASK | \
PKT_TX_OUTER_IP_CKSUM)

-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   ((uint64_t)((mb)->buf_physaddr + (mb)->data_off))
-
 static const struct rte_memzone *
 i40e_ring_dma_zone_reserve(struct rte_eth_dev *dev,
   const char *ring_name,
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h
index b9eca67..dbb9f00 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.h
+++ b/drivers/net/ixgbe/ixgbe_rxtx.h
@@ -40,12 +40,6 @@

 #define RTE_IXGBE_DESCS_PER_LOOP4

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
-#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
-   (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
-
 #ifdef RTE_IXGBE_INC_VECTOR
 #define RTE_IXGBE_RXQ_REARM_THRESH  32
 #define RTE_IXGBE_MAX_RX_BURST  RTE_IXGBE_RXQ_REARM_THRESH
diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index 7789411..9ea9b96 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -68,9 +68,6 @@ struct rte_mbuf;

 #define VIRTQUEUE_MAX_NAME_SZ 32

-#define RTE_MBUF_DATA_DMA_ADDR(mb) \
-   (uint64_t) ((mb)->buf_physaddr + (mb)->data_off)
-
 #define VTNET_SQ_RQ_QUEUE_IDX 0
 #define VTNET_SQ_TQ_QUEUE_IDX 1
 #define VTNET_SQ_CQ_QUEUE_IDX 2
diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c 
b/drivers/net/vmxnet3/vmxnet3_rx

[dpdk-dev] [PATCH v1] Move rte_mbuf macros to common header file

2015-09-24 Thread Ravi Kerur
Macros RTE_MBUF_DATA_DMA_ADDR and RTE_MBUF_DATA_DMA_ADDR_DEFAULT
are defined in each PMD driver file. Move those macros into common
lib/librte_mbuf/rte_mbuf.h file. All PMD drivers include rte_mbuf.h
file directly/indirectly hence no additionl header file inclusion 
is necessary.

Ravi Kerur (1):
  Move rte_buf macros to common header file

 drivers/net/bnx2x/bnx2x.h  | 3 ---
 drivers/net/cxgbe/sge.c| 3 ---
 drivers/net/e1000/em_rxtx.c| 6 --
 drivers/net/e1000/igb_rxtx.c   | 6 --
 drivers/net/i40e/i40e_rxtx.c   | 6 --
 drivers/net/ixgbe/ixgbe_rxtx.h | 6 --
 drivers/net/virtio/virtqueue.h | 3 ---
 drivers/net/vmxnet3/vmxnet3_rxtx.c | 6 --
 lib/librte_mbuf/rte_mbuf.h | 6 ++
 9 files changed, 6 insertions(+), 39 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH v1] Add support for I217 and I218 Intel 1G chipsets.

2015-09-24 Thread Ravi Kerur
This patch adds I217 and I218 Intel chipsets.

Compiled for:
> i686-native-linuxapp-gcc
> x86_64-native-linuxapp-clang
> x86_64-native-linuxapp-gcc
> x86_x32-native-linuxapp-gcc

Tested on:
> x86_64 Ubuntu 14.04 with Intel I218-V and I217-LM chipsets.

Signed-off-by: Ravi Kerur 
---
 drivers/net/e1000/base/e1000_api.c  |  1 +
 drivers/net/e1000/base/e1000_hw.h   |  1 +
 drivers/net/e1000/base/e1000_ich8lan.c  | 30 +++-
 drivers/net/e1000/base/e1000_osdep.h| 24 +++
 drivers/net/e1000/em_ethdev.c   | 31 -
 lib/librte_eal/common/include/rte_pci_dev_ids.h |  6 +
 6 files changed, 65 insertions(+), 28 deletions(-)

diff --git a/drivers/net/e1000/base/e1000_api.c 
b/drivers/net/e1000/base/e1000_api.c
index a064565..018a9a3 100644
--- a/drivers/net/e1000/base/e1000_api.c
+++ b/drivers/net/e1000/base/e1000_api.c
@@ -292,6 +292,7 @@ s32 e1000_set_mac_type(struct e1000_hw *hw)
case E1000_DEV_ID_PCH_LPT_I217_V:
case E1000_DEV_ID_PCH_LPTLP_I218_LM:
case E1000_DEV_ID_PCH_LPTLP_I218_V:
+   case E1000_DEV_ID_PCH_LPTLP_I218_V2:
mac->type = e1000_pch_lpt;
break;
case E1000_DEV_ID_82575EB_COPPER:
diff --git a/drivers/net/e1000/base/e1000_hw.h 
b/drivers/net/e1000/base/e1000_hw.h
index 4dd92a3..c4b6212 100644
--- a/drivers/net/e1000/base/e1000_hw.h
+++ b/drivers/net/e1000/base/e1000_hw.h
@@ -132,6 +132,7 @@ struct e1000_hw;
 #define E1000_DEV_ID_PCH_LPT_I217_V0x153B
 #define E1000_DEV_ID_PCH_LPTLP_I218_LM 0x155A
 #define E1000_DEV_ID_PCH_LPTLP_I218_V  0x1559
+#define E1000_DEV_ID_PCH_LPTLP_I218_V2 0x15A1
 #define E1000_DEV_ID_82576 0x10C9
 #define E1000_DEV_ID_82576_FIBER   0x10E6
 #define E1000_DEV_ID_82576_SERDES  0x10E7
diff --git a/drivers/net/e1000/base/e1000_ich8lan.c 
b/drivers/net/e1000/base/e1000_ich8lan.c
index 3b1627b..c7fa1ad 100644
--- a/drivers/net/e1000/base/e1000_ich8lan.c
+++ b/drivers/net/e1000/base/e1000_ich8lan.c
@@ -1386,29 +1386,15 @@ STATIC s32 e1000_check_for_copper_link_ich8lan(struct 
e1000_hw *hw)
if (!mac->get_link_status)
return E1000_SUCCESS;

-   if ((hw->mac.type < e1000_pch_lpt) ||
-   (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_LM) ||
-   (hw->device_id == E1000_DEV_ID_PCH_LPT_I217_V)) {
-   /* First we want to see if the MII Status Register reports
-* link.  If so, then we want to get the current speed/duplex
-* of the PHY.
-*/
-   ret_val = e1000_phy_has_link_generic(hw, 1, 0, );
-   if (ret_val)
-   return ret_val;
-   } else {
-   /* Check the MAC's STATUS register to determine link state
-* since the PHY could be inaccessible while in ULP mode.
-*/
-   link = !!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU);
-   if (link)
-   ret_val = e1000_disable_ulp_lpt_lp(hw, false);
-   else
-   ret_val = e1000_enable_ulp_lpt_lp(hw, false);
+   /* First we want to see if the MII Status Register reports
+* link.  If so, then we want to get the current speed/duplex
+* of the PHY.
+*/
+   ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 10, 
);
+   if (ret_val)
+   return ret_val;

-   if (ret_val)
-   return ret_val;
-   }
+   DEBUGOUT1("After phy_has_link_generic link state is %d\n", link);

if (hw->mac.type == e1000_pchlan) {
ret_val = e1000_k1_gig_workaround_hv(hw, link);
diff --git a/drivers/net/e1000/base/e1000_osdep.h 
b/drivers/net/e1000/base/e1000_osdep.h
index d04ec73..3255d37 100644
--- a/drivers/net/e1000/base/e1000_osdep.h
+++ b/drivers/net/e1000/base/e1000_osdep.h
@@ -96,13 +96,22 @@ typedef int bool;

 #define E1000_PCI_REG(reg) (*((volatile uint32_t *)(reg)))

+#define E1000_PCI_REG16(reg) (*((volatile uint16_t *)(reg)))
+
 #define E1000_PCI_REG_WRITE(reg, value) do { \
E1000_PCI_REG((reg)) = (rte_cpu_to_le_32(value)); \
 } while (0)

+#define E1000_PCI_REG_WRITE16(reg, value) do { \
+   E1000_PCI_REG16((reg)) = (value); \
+} while (0)
+
 #define E1000_PCI_REG_ADDR(hw, reg) \
((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))

+#define E1000_PCI_REG_FLASH_ADDR(hw, reg) \
+   ((volatile uint32_t *)((char *)(hw)->flash_address + (reg)))
+
 #define E1000_PCI_REG_ARRAY_ADDR(hw, reg, index) \
E1000_PCI_REG_ADDR((hw), (reg) + ((index) << 2))

@@ -111,6 +120,11 @@ static inline uint32_t e1000_read_addr(volatile void* addr)
return rte_le_to_cpu_32(E1000_PCI_REG(addr));
 }

+static inline uin

[dpdk-dev] [PATCH v1] Add support for Intel chipsets

2015-09-24 Thread Ravi Kerur
M. Jay(Jayakumar, Muthurajan) and I
discussed and decided to include support for I217/I218 chipsets since
these chipsets are found everywhere f.e. on laptops, low-end servers and
we found it useful and helpful for testing simple functionality. Hence we
decided to send this patch to be included in the mainline.

Ravi Kerur (1):
  Add support for I217 and I218 Intel 1G chipsets.

 drivers/net/e1000/base/e1000_api.c  |  1 +
 drivers/net/e1000/base/e1000_hw.h   |  1 +
 drivers/net/e1000/base/e1000_ich8lan.c  | 30 +++-
 drivers/net/e1000/base/e1000_osdep.h| 24 +++
 drivers/net/e1000/em_ethdev.c   | 31 -
 lib/librte_eal/common/include/rte_pci_dev_ids.h |  6 +
 6 files changed, 65 insertions(+), 28 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH v2] Change rte_eal_vdev_init to update port_id

2015-09-23 Thread Ravi Kerur
Hi David, Tetsuya,

I have sent V3 (changes isolated to rte_ether component) for formal review.
Please look into it and let me know your inputs.

@David: I looked at "rte_eth_dev_get_port_by_name()", this function is
similar to "rte_eth_dev_get_name_by_port" and I have used same logic. Let
me know if this not correct I can fix both.

Thanks,
Ravi


On Tue, Sep 15, 2015 at 4:28 AM, Ravi Kerur  wrote:

> Hi David,
>
>
> On Thu, Sep 3, 2015 at 7:04 AM, David Marchand 
> wrote:
>
>> Hello Ravi, Tetsuya,
>>
>> On Tue, Aug 25, 2015 at 7:59 PM, Ravi Kerur  wrote:
>>
>>> Let us know how you want us to fix this? To fix rte_eal_vdev_init and
>>> rte_eal_pci_probe_one to return allocated port_id we had 2 approaches
>>> mentioned in earlier discussion. In addition to those we have another
>>> approach with changes isolated only to rte_ether component. I am attaching
>>> diffs (preliminary) with this email. Please let us know your inputs since
>>> it involves EAL component.
>>>
>>
>> - This patch looks like a good ethdev cleanup (even if it really lacks
>> some context / commit log).
>>
>> I wonder just why you only take the first part of the name in
>> rte_eth_dev_get_port_by_name().
>> Would not this match, let's say, both toto and toto0 vdevs ?
>> Is this intended ?
>>
>> It was not intended, i will look into it.
>
>>
>> - In the end, with this patch, do we still need to update eal ?
>> Looking at the code, I am not sure anymore.
>>
>
> Approach 3 (preliminary diffs sent as an attachment) doesn't involve EAL
> but the other two solutions do. So please let us know which one you prefer.
> I will send updated patch.
>
> Thanks,
> Ravi
>
>
>>
>>
>>
>> --
>> David Marchand
>>
>
>


[dpdk-dev] [PATCH v3] Change rte_eal_vdev_init to update port_id

2015-09-23 Thread Ravi Kerur
v3:
   > Isolate changes within rte_ether component.

v2:
   > Remove tilegx changes
   > Use rte_eal_compare_pci_addr for address comparison
   > Use dpdk_2.2 in version map file for new functions

v1:
Changes include
   > Modify rte_eal_vdev_init to return allocated port_id
   > Modify rte_eal_probe_one to return allocated port_id

2. Removed following functions
   > rte_eth_dev_save and
   > rte_eth_dev_get_changed_port

3. Added 2 new functions
   > rte_eth_dev_get_port_by_name
   > rte_eth_dev_get_port_by_addr

4. Fix return error(ENOMEM) in function rte_pmd_mpipe_devinit

Compiled on Linux for following targets
   > x86_64-native-linuxapp-gcc
   > x86_64-native-linuxapp-clang
   > x86_x32-native-linuxapp-gcc

Compiled on FreeBSD for following targets
   > x86_64-native-bsdapp-clang
   > x86_64-native-bsdapp-gcc

Tested on Linux/FreeBSD:
   > port attach eth_null
   > port start all
   > port stop all
   > port close all
   > port detach 0
   > port attach eth_null
   > port start all
   > port stop all
   > port close all
   > port detach 0

Successful run of checkpatch.pl on the diffs

Successful validate_abi on Linux for following targets

   > x86_64-native-linuxapp-gcc
   > x86_64-native-linuxapp-clang

Signed-off-by: Ravi Kerur 
---
 lib/librte_ether/rte_ethdev.c | 116 +++---
 1 file changed, 63 insertions(+), 53 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b309309..e4b8e41 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -442,32 +442,6 @@ rte_eth_dev_get_device_type(uint8_t port_id)
 }

 static int
-rte_eth_dev_save(struct rte_eth_dev *devs, size_t size)
-{
-   if ((devs == NULL) ||
-   (size != sizeof(struct rte_eth_dev) * RTE_MAX_ETHPORTS))
-   return -EINVAL;
-
-   /* save current rte_eth_devices */
-   memcpy(devs, rte_eth_devices, size);
-   return 0;
-}
-
-static int
-rte_eth_dev_get_changed_port(struct rte_eth_dev *devs, uint8_t *port_id)
-{
-   if ((devs == NULL) || (port_id == NULL))
-   return -EINVAL;
-
-   /* check which port was attached or detached */
-   for (*port_id = 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++, devs++) {
-   if (rte_eth_devices[*port_id].attached ^ devs->attached)
-   return 0;
-   }
-   return -ENODEV;
-}
-
-static int
 rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
 {
VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -501,6 +475,59 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 }

 static int
+rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id)
+{
+   int i;
+
+   if (name == NULL) {
+   PMD_DEBUG_TRACE("Null pointer is specified\n");
+   return -EINVAL;
+   }
+
+   *port_id = RTE_MAX_ETHPORTS;
+
+   for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+
+   if (!strncmp(name,
+   rte_eth_dev_data[i].name, strlen(name))) {
+
+   *port_id = i;
+
+   return 0;
+   }
+   }
+   return -ENODEV;
+}
+
+static int
+rte_eth_dev_get_port_by_addr(const struct rte_pci_addr *addr, uint8_t *port_id)
+{
+   int i;
+   struct rte_pci_device *pci_dev = NULL;
+
+   if (addr == NULL) {
+   PMD_DEBUG_TRACE("Null pointer is specified\n");
+   return -EINVAL;
+   }
+
+   *port_id = RTE_MAX_ETHPORTS;
+
+   for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+
+   pci_dev = rte_eth_devices[i].pci_dev;
+
+   if (pci_dev &&
+   !rte_eal_compare_pci_addr(_dev->addr, addr)) {
+
+   *port_id = i;
+
+   return 0;
+   }
+   }
+   return -ENODEV;
+}
+
+static int
 rte_eth_dev_is_detachable(uint8_t port_id)
 {
uint32_t drv_flags;
@@ -530,30 +557,19 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 static int
 rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
 {
-   uint8_t new_port_id;
-   struct rte_eth_dev devs[RTE_MAX_ETHPORTS];
-
if ((addr == NULL) || (port_id == NULL))
goto err;

-   /* save current port status */
-   if (rte_eth_dev_save(devs, sizeof(devs)))
-   goto err;
/* re-construct pci_device_list */
if (rte_eal_pci_scan())
goto err;
-   /* invoke probe func of the driver can handle the new device.
-* TODO:
-* rte_eal_pci_probe_one() should return port_id.
-* And rte_eth_dev_save() and rte_eth_dev_get_changed_port()
-* should be removed. */
+   /* Invoke probe func of the driver can handle the new device. */
if (rte_eal_pci_probe_one(addr))
   

[dpdk-dev] [PATCH v3] Send updated port_id in vdev_init functions

2015-09-23 Thread Ravi Kerur
Instead of executing following functions before and after vdev_init
   > rte_eth_dev_save and
   > rte_eth_dev_get_changed_port

update following functions to return allocated port_id.
   > rte_eal_vdev_init
   > rte_eal_probe_one

Ravi Kerur (1):
  Change rte_eal_vdev_init to update port_id

 lib/librte_ether/rte_ethdev.c | 116 +++---
 1 file changed, 63 insertions(+), 53 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH v2] Change rte_eal_vdev_init to update port_id

2015-09-15 Thread Ravi Kerur
Hi David,


On Thu, Sep 3, 2015 at 7:04 AM, David Marchand 
wrote:

> Hello Ravi, Tetsuya,
>
> On Tue, Aug 25, 2015 at 7:59 PM, Ravi Kerur  wrote:
>
>> Let us know how you want us to fix this? To fix rte_eal_vdev_init and
>> rte_eal_pci_probe_one to return allocated port_id we had 2 approaches
>> mentioned in earlier discussion. In addition to those we have another
>> approach with changes isolated only to rte_ether component. I am attaching
>> diffs (preliminary) with this email. Please let us know your inputs since
>> it involves EAL component.
>>
>
> - This patch looks like a good ethdev cleanup (even if it really lacks
> some context / commit log).
>
> I wonder just why you only take the first part of the name in
> rte_eth_dev_get_port_by_name().
> Would not this match, let's say, both toto and toto0 vdevs ?
> Is this intended ?
>
> It was not intended, i will look into it.

>
> - In the end, with this patch, do we still need to update eal ?
> Looking at the code, I am not sure anymore.
>

Approach 3 (preliminary diffs sent as an attachment) doesn't involve EAL
but the other two solutions do. So please let us know which one you prefer.
I will send updated patch.

Thanks,
Ravi


>
>
>
> --
> David Marchand
>


[dpdk-dev] [PATCH v2] Change rte_eal_vdev_init to update port_id

2015-08-25 Thread Ravi Kerur
Hi Thomas, David

Let us know how you want us to fix this? To fix rte_eal_vdev_init and
rte_eal_pci_probe_one to return allocated port_id we had 2 approaches
mentioned in earlier discussion. In addition to those we have another
approach with changes isolated only to rte_ether component. I am attaching
diffs (preliminary) with this email. Please let us know your inputs since
it involves EAL component.

Thanks,
Ravi


On Thu, Aug 20, 2015 at 8:33 PM, Tetsuya Mukawa  wrote:

> On 2015/08/21 4:16, Ravi Kerur wrote:
> >
> > >  /**
> > >   * Uninitalize a driver specified by name.
> > > @@ -125,6 +127,38 @@ int rte_eal_vdev_init(const char *name,
> > const char *args);
> > >   */
> > >  int rte_eal_vdev_uninit(const char *name);
> > >
> > > +/**
> > > + * Given name, return port_id associated with the device.
> > > + *
> > > + * @param name
> > > + *   Name associated with device.
> > > + * @param port_id
> > > + *   The port identifier of the device.
> > > + *
> > > + * @return
> > > + *   - 0: Success.
> > > + *   - -EINVAL: NULL string (name)
> > > + *   - -ENODEV failure
> >
> > Please define above in 'rte_ethdev.h.'
> >
> >
> > Hi Tetsuya,
> >
> > I would like to take a step back and explain why function declarations
> > are in rte_dev.h and not in rte_ethdev.h
> >
> > Approach 1:
> > Initially I thought of modifying driver init routine to return/update
> > port_id as the init routine is the place port_id gets allocated and it
> > would have been clean approach. However, it required changes to all
> > PMD_VDEV driver init routine to modify function signature for the
> > changes which I thought may be an overkill.
> >
> > Approach 2:
> > Instead I chose to define 2 functions in librte_ether/rte_ethdev.c and
> > make use of it. In this approach new functions are invoked from
> > librte_eal/common/.c to get port_id. If I had new function
> > declarations in rte_ethdev.h and included that file in
> > librte_eal/common/.c files it creates circular dependancy and
> > compilation fails, hence I took hybrid approach of definitions in
> > librte_ether and declarations in librte_eal.
> >
> > Please let me know if there is a better approach to take care of your
> > comments. As it stands declarations cannot be moved to rte_ethdev.h
> > for compilation reasons.
> >
> > Thanks,
> > Ravi
> >
>
> Hi Ravi,
> (Adding David)
>
> I appreciate your description. I understand why you define the functions
> in rte_dev.h.
>
> About Approach2, I don't know a way to implement cleanly.
> I guess if we define the functions in rte_dev.h, the developers who want
> to use the functions will be confused because the functions are
> implemented in ethdev.c, but it is needed to include rte_dev.h.
>
> To avoid such a confusion, following implementation might be worked, but
> I am not sure this cording style is allowed in eal library.
>
> 
> Define the functions in rte_ethdev.h, then fix librte_eal/common/.c
> files like below
>
> ex) lib/librte_eal/common/eal_common_dev.c
> 
> +#include 
>  #include 
>  #include 
>  #include 
>
>  #include "eal_private.h"
>
> +extern int rte_eth_dev_get_port_by_name(const char *name, uint8_t
> *port_id);
> +extern int rte_eth_dev_get_port_by_addr(const struct rte_pci_addr
> *addr, uint8_t *port_id);
> 
>
> In this case, the developer might be able to notice that above usage in
> eal library is some kind of exception. But I guess the DPDK code won't
> be clean if we start having a exception.
> So it might be good to choose Approach1, because apparently it is
> straight forward.
> Anyone won't be confused and complained about coding style.
>
>
> Hi David,
>
> Could you please let us know what you think?
> Do you have a good approach for this?
>
> Thanks,
> Tetsuya
>
>


[dpdk-dev] [PATCH v2] Move common functions in eal_thread.c

2015-08-19 Thread Ravi Kerur
v2:
   > Remove un-needed header file eal_private.h from freeBSD
 eal_thread.c after code movement.

v1:
Changes include
   > Moving common functions in eal_thread.c in
 linuxapp and bsdapp into common/eal_common_thread.c file.
   > Rearrange eal_common_thread.c compilation in Makefile
 for ABI.

Compiled successfully for following targets
   > x86_64-native-linuxapp-clang
   > x86_64-native-linuxapp-gcc
   > x86_x32-native-linuxapp-gcc
   > i686-native-linuxapp-gcc
   > x86_64-native-bsdapp-clang
   > x86_64-native-bsdapp-gcc

Tested on
   > Ubuntu 14.04, testpmd functionality
   > FreeBSD 10.1, testpmd functionality

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile|   3 +-
 lib/librte_eal/bsdapp/eal/eal_thread.c| 153 --
 lib/librte_eal/common/eal_common_thread.c | 147 +++-
 lib/librte_eal/linuxapp/eal/Makefile  |   3 +-
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 153 --
 5 files changed, 150 insertions(+), 309 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index a969435..93d76bb 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -51,6 +51,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) := eal.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_memory.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_hugepage_info.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_thread.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c
@@ -76,7 +77,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c
-SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += rte_malloc.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += malloc_elem.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += malloc_heap.c
@@ -90,6 +90,7 @@ CFLAGS_eal_common_log.o := -D_GNU_SOURCE
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 CFLAGS_eal_thread.o += -Wno-return-type
+CFLAGS_eal_common_thread.o += -Wno-return-type
 CFLAGS_eal_hpet.o += -Wno-return-type
 endif

diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index 9a03437..4036d21 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -35,163 +35,10 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 

-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "eal_private.h"
 #include "eal_thread.h"

-RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
-RTE_DEFINE_PER_LCORE(unsigned, _socket_id) = (unsigned)SOCKET_ID_ANY;
-RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);
-
-/*
- * Send a message to a slave lcore identified by slave_id to call a
- * function f with argument arg. Once the execution is done, the
- * remote lcore switch in FINISHED state.
- */
-int
-rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
-{
-   int n;
-   char c = 0;
-   int m2s = lcore_config[slave_id].pipe_master2slave[1];
-   int s2m = lcore_config[slave_id].pipe_slave2master[0];
-
-   if (lcore_config[slave_id].state != WAIT)
-   return -EBUSY;
-
-   lcore_config[slave_id].f = f;
-   lcore_config[slave_id].arg = arg;
-
-   /* send message */
-   n = 0;
-   while (n == 0 || (n < 0 && errno == EINTR))
-   n = write(m2s, , 1);
-   if (n < 0)
-   rte_panic("cannot write on configuration pipe\n");
-
-   /* wait ack */
-   do {
-   n = read(s2m, , 1);
-   } while (n < 0 && errno == EINTR);
-
-   if (n <= 0)
-   rte_panic("cannot read on configuration pipe\n");
-
-   return 0;
-}
-
-/* set affinity for current thread */
-static int
-eal_thread_set_affinity(void)
-{
-   unsigned lcore_id = rte_lcore_id();
-
-   /* acquire system unique id  */
-   rte_gettid();
-
-   /* update EAL thread core affinity */
-   return rte_thread_set_affinity(_config[lcore_id].cpuset);
-}
-
-void eal_thread_init_master(unsigned lcore_id)
-{
-   /* set the lcore ID in per-lcore memory area */
-   RTE_PER_LCORE(_lcore_id) = lcore_id;
-
-   /* set CPU affinity */
-   if (eal_thread_set_affinity() < 0)
-   rte_panic("cannot set affinity\n");
-}
-
-/* main loop of threads */
-__attribute__((noreturn)) void *
-eal_thread_loop(__attribute__(

[dpdk-dev] [PATCH v1] Return ENOMEM during mpipe_devinit failure

2015-08-19 Thread Ravi Kerur
In function rte_pmd_mpipe_devinit, if rte_eth_dev_allocate
fails return error which is inline with other drivers.

Signed-off-by: Ravi Kerur 
---
 drivers/net/mpipe/mpipe_tilegx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index 743feef..6e3e304 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -1582,6 +1582,7 @@ rte_pmd_mpipe_devinit(const char *ifname,
if (!eth_dev) {
RTE_LOG(ERR, PMD, "%s: Failed to allocate device.\n", ifname);
rte_free(priv);
+   return -ENOMEM;
}

RTE_LOG(INFO, PMD, "%s: Initialized mpipe device"
-- 
1.9.1



[dpdk-dev] [PATCH v2] Change rte_eal_vdev_init to update port_id

2015-08-19 Thread Ravi Kerur
v2:
   > Remove rte_pmd_mpipe_devinit changes
   > Use rte_eal_compare_pci_addr for address comparison
   > Use dpdk_2.2 in version map file for new functions

v1:
Changes include
   > Modify rte_eal_vdev_init to return allocated port_id
   > Modify rte_eal_probe_one to return allocated port_id

2. Removed following functions
   > rte_eth_dev_save and
   > rte_eth_dev_get_changed_port

3. Added 2 new functions
   > rte_eth_dev_get_port_by_name
   > rte_eth_dev_get_port_by_addr

4. Fix return error(ENOMEM) in function rte_pmd_mpipe_devinit

Compiled on Linux for following targets
   > x86_64-native-linuxapp-gcc
   > x86_64-native-linuxapp-clang
   > x86_x32-native-linuxapp-gcc

Compiled on FreeBSD for following targets
   > x86_64-native-bsdapp-clang
   > x86_64-native-bsdapp-gcc

Tested on Linux/FreeBSD:
   > port attach eth_null
   > port start all
   > port stop all
   > port close all
   > port detach 0
   > port attach eth_null
   > port start all
   > port stop all
   > port close all
   > port detach 0

Successful run of checkpatch.pl on the diffs

Successful validate_abi on Linux for following targets

   > x86_64-native-linuxapp-gcc
   > x86_64-native-linuxapp-clang

Signed-off-by: Ravi Kerur 
---
 drivers/net/enic/enic_ethdev.c  |   2 +-
 lib/librte_eal/common/eal_common_dev.c  |  13 ++--
 lib/librte_eal/common/eal_common_pci.c  |   6 +-
 lib/librte_eal/common/include/rte_dev.h |  36 +-
 lib/librte_eal/common/include/rte_pci.h |   4 +-
 lib/librte_ether/rte_ethdev.c   | 122 +---
 lib/librte_ether/rte_ether_version.map  |   8 +++
 7 files changed, 125 insertions(+), 66 deletions(-)

diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 8280cea..472ef5a 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -36,8 +36,8 @@
 #include 
 #include 

-#include 
 #include 
+#include 
 #include 
 #include 

diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 4089d66..ffdb3b5 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -37,6 +37,7 @@
 #include 
 #include 

+#include 
 #include 
 #include 
 #include 
@@ -64,7 +65,7 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
-rte_eal_vdev_init(const char *name, const char *args)
+rte_eal_vdev_init(const char *name, const char *args, uint8_t *port_id)
 {
struct rte_driver *driver;

@@ -81,8 +82,12 @@ rte_eal_vdev_init(const char *name, const char *args)
 * will be "eth_pcap", but "name" will be "eth_pcapN".
 * So use strncmp to compare.
 */
-   if (!strncmp(driver->name, name, strlen(driver->name)))
-   return driver->init(name, args);
+   if (!strncmp(driver->name, name, strlen(driver->name))) {
+   if (!driver->init(name, args))
+   return rte_eth_dev_get_port_by_name(
+   name, port_id);
+   }
+
}

RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
@@ -108,7 +113,7 @@ rte_eal_dev_init(void)
continue;

if (rte_eal_vdev_init(devargs->virtual.drv_name,
-   devargs->args)) {
+   devargs->args, NULL)) {
RTE_LOG(ERR, EAL, "failed to initialize %s device\n",
devargs->virtual.drv_name);
return -1;
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 16e8629..3d97892 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -79,6 +79,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "eal_private.h"

@@ -322,7 +323,7 @@ pci_detach_all_drivers(struct rte_pci_device *dev)
  * the driver of the devive.
  */
 int
-rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
+rte_eal_pci_probe_one(const struct rte_pci_addr *addr, uint8_t *port_id)
 {
struct rte_pci_device *dev = NULL;
int ret = 0;
@@ -337,7 +338,8 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
ret = pci_probe_all_drivers(dev);
if (ret < 0)
goto err_return;
-   return 0;
+
+   return rte_eth_dev_get_port_by_addr(addr, port_id);
}
return -1;

diff --git a/lib/librte_eal/common/include/rte_dev.h 
b/lib/librte_eal/common/include/rte_dev.h
index f601d21..564cdf3 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -110,10 +110,12 @@ int rte

[dpdk-dev] [PATCH v2] Send updated port_id in vdev_init functions

2015-08-19 Thread Ravi Kerur
Instead of executing following functions before and after vdev_init
   > rte_eth_dev_save and
   > rte_eth_dev_get_changed_port

update following functions to return allocated port_id.
   > rte_eal_vdev_init
   > rte_eal_probe_one

Thanks to Tetsuya for his valuable inputs.

Ravi Kerur (1):
  Change rte_eal_vdev_init to update port_id

 drivers/net/enic/enic_ethdev.c  |   2 +-
 lib/librte_eal/common/eal_common_dev.c  |  13 ++--
 lib/librte_eal/common/eal_common_pci.c  |   6 +-
 lib/librte_eal/common/include/rte_dev.h |  36 +-
 lib/librte_eal/common/include/rte_pci.h |   4 +-
 lib/librte_ether/rte_ethdev.c   | 122 +---
 lib/librte_ether/rte_ether_version.map  |   8 +++
 7 files changed, 125 insertions(+), 66 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH v1] Move EAL thread common functions

2015-08-07 Thread Ravi Kerur
Changes include moving common functions in eal_thread.c in
linuxapp and bsdapp into common/eal_common_thread.c file.

Compiled on Linux for following targets
   > x86_64-native-linuxapp-gcc
   > x86_64-native-linuxapp-clang
   > x86_x32-native-linuxapp-gcc

Compiled on FreeBSD for following targets
   > x86_64-native-bsdapp-clang
   > x86_64-native-bsdapp-gcc

Tested on Linux:
   > testpmd (pmd_perf_autotest)

Tested on FreeBSD:
   > testpmd

Successful run of checkpatch.pl on the diffs

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile|   3 +-
 lib/librte_eal/bsdapp/eal/eal_thread.c| 152 -
 lib/librte_eal/common/eal_common_thread.c | 147 +++-
 lib/librte_eal/linuxapp/eal/Makefile  |   3 +-
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 153 --
 5 files changed, 150 insertions(+), 308 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index a969435..93d76bb 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -51,6 +51,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) := eal.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_memory.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_hugepage_info.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_thread.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c
@@ -76,7 +77,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c
-SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += rte_malloc.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += malloc_elem.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += malloc_heap.c
@@ -90,6 +90,7 @@ CFLAGS_eal_common_log.o := -D_GNU_SOURCE
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 CFLAGS_eal_thread.o += -Wno-return-type
+CFLAGS_eal_common_thread.o += -Wno-return-type
 CFLAGS_eal_hpet.o += -Wno-return-type
 endif

diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index 9a03437..5714b8f 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -35,163 +35,11 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 

-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 #include "eal_private.h"
 #include "eal_thread.h"

-RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
-RTE_DEFINE_PER_LCORE(unsigned, _socket_id) = (unsigned)SOCKET_ID_ANY;
-RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);
-
-/*
- * Send a message to a slave lcore identified by slave_id to call a
- * function f with argument arg. Once the execution is done, the
- * remote lcore switch in FINISHED state.
- */
-int
-rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
-{
-   int n;
-   char c = 0;
-   int m2s = lcore_config[slave_id].pipe_master2slave[1];
-   int s2m = lcore_config[slave_id].pipe_slave2master[0];
-
-   if (lcore_config[slave_id].state != WAIT)
-   return -EBUSY;
-
-   lcore_config[slave_id].f = f;
-   lcore_config[slave_id].arg = arg;
-
-   /* send message */
-   n = 0;
-   while (n == 0 || (n < 0 && errno == EINTR))
-   n = write(m2s, , 1);
-   if (n < 0)
-   rte_panic("cannot write on configuration pipe\n");
-
-   /* wait ack */
-   do {
-   n = read(s2m, , 1);
-   } while (n < 0 && errno == EINTR);
-
-   if (n <= 0)
-   rte_panic("cannot read on configuration pipe\n");
-
-   return 0;
-}
-
-/* set affinity for current thread */
-static int
-eal_thread_set_affinity(void)
-{
-   unsigned lcore_id = rte_lcore_id();
-
-   /* acquire system unique id  */
-   rte_gettid();
-
-   /* update EAL thread core affinity */
-   return rte_thread_set_affinity(_config[lcore_id].cpuset);
-}
-
-void eal_thread_init_master(unsigned lcore_id)
-{
-   /* set the lcore ID in per-lcore memory area */
-   RTE_PER_LCORE(_lcore_id) = lcore_id;
-
-   /* set CPU affinity */
-   if (eal_thread_set_affinity() < 0)
-   rte_panic("cannot set affinity\n");
-}
-
-/* main loop of threads */
-__attribute__((noreturn)) void *
-eal_thread_loop(__attribute__((unused)) void *arg)
-{
-   char c;
-   int n, ret;
-   unsigned lcore_id;
-   pthread_t thread_id;
-   int m2s, s2m;
-   char cpuset[RT

[dpdk-dev] [PATCH v1] Move eal_thread.c common functions.

2015-08-07 Thread Ravi Kerur
As per Thomas's suggestion we will split remaining files in EAL cleanup
effort into multiple patches, eal_thread.c is first in this series.

Ravi Kerur (1):
  Move EAL thread common functions

 lib/librte_eal/bsdapp/eal/Makefile|   3 +-
 lib/librte_eal/bsdapp/eal/eal_thread.c| 152 -
 lib/librte_eal/common/eal_common_thread.c | 147 +++-
 lib/librte_eal/linuxapp/eal/Makefile  |   3 +-
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 153 --
 5 files changed, 150 insertions(+), 308 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH v1] Change rte_eal_vdev_init to update port_id

2015-08-07 Thread Ravi Kerur
Hi Tetsuya,

On Thu, Aug 6, 2015 at 7:25 PM, Tetsuya Mukawa  wrote:

> On 2015/08/07 3:04, Ravi Kerur wrote:
> > diff --git a/drivers/net/enic/enic_ethdev.c
> b/drivers/net/enic/enic_ethdev.c
> > index 8280cea..472ef5a 100644
> > --- a/drivers/net/enic/enic_ethdev.c
> > +++ b/drivers/net/enic/enic_ethdev.c
> > @@ -36,8 +36,8 @@
> >  #include 
> >  #include 
> >
> > -#include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
>
> Hi Ravi,
>
> Do we need this fixing?
>
> >
> > diff --git a/drivers/net/mpipe/mpipe_tilegx.c
> b/drivers/net/mpipe/mpipe_tilegx.c
> > index 743feef..6e3e304 100644
> > --- a/drivers/net/mpipe/mpipe_tilegx.c
> > +++ b/drivers/net/mpipe/mpipe_tilegx.c
> > @@ -1582,6 +1582,7 @@ rte_pmd_mpipe_devinit(const char *ifname,
> >   if (!eth_dev) {
> >   RTE_LOG(ERR, PMD, "%s: Failed to allocate device.\n",
> ifname);
> >   rte_free(priv);
> > + return -ENOMEM;
>
> How about separating this fixing from the patch, and put it as an one of
> cleanup patch series?
>
>
rte_pmd_mpipe_devinit is the init func pointer called via
rte_eal_vdev_init. Since we were fixing rte_eal_vdev_init thought of taking
care of mpipe issue. If you think it's unrelated to this patch I will send
a separate one.

>   }
> >
> >   RTE_LOG(INFO, PMD, "%s: Initialized mpipe device"
> > diff --git a/lib/librte_eal/common/eal_common_dev.c
> b/lib/librte_eal/common/eal_common_dev.c
> > index 4089d66..82d5693 100644
> > --- a/lib/librte_eal/common/eal_common_dev.c
> > +++ b/lib/librte_eal/common/eal_common_dev.c
> >
> >   RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
> > @@ -94,6 +99,7 @@ rte_eal_dev_init(void)
> >  {
> >   struct rte_devargs *devargs;
> >   struct rte_driver *driver;
> > + uint8_t port_id;
> >
> >   /*
> >* Note that the dev_driver_list is populated here
> > @@ -108,7 +114,7 @@ rte_eal_dev_init(void)
> >   continue;
> >
> >   if (rte_eal_vdev_init(devargs->virtual.drv_name,
> > - devargs->args)) {
> > + devargs->args, _id)) {
>
> After this line, 'port_id' is actually not used by anywhere in this
> function.
> Also, I guess we will not use port_id in this function in the future.
> How about fixing rte_eal_vdev_init() to handle NULL value correctly to
> remove port_id from this function?
> But I agree your current implementation is also one of choice.
>
> > diff --git a/lib/librte_ether/rte_ethdev.c
> b/lib/librte_ether/rte_ethdev.c
> > index 5fe1906..355d709 100644
> > --- a/lib/librte_ether/rte_ethdev.c
> > +++ b/lib/librte_ether/rte_ethdev.c
> > +int
> > +rte_eth_dev_get_port_by_addr(const struct rte_pci_addr *addr, uint8_t
> *port_id)
> > +{
> > + int i;
> > + struct rte_pci_device *pci_dev = NULL;
> > +
> > + if (addr == NULL || port_id == NULL) {
> > + PMD_DEBUG_TRACE("Null pointer is specified\n");
> > + return -EINVAL;
> > + }
> > +
> > + *port_id = RTE_MAX_ETHPORTS;
> > +
> > + for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
> > +
> > + pci_dev = rte_eth_devices[i].pci_dev;
> > +
> > + if (pci_dev != NULL &&
> > + pci_dev->addr.domain == addr->domain &&
> > + pci_dev->addr.bus == addr->bus &&
> > + pci_dev->addr.devid == addr->devid &&
> > + pci_dev->addr.function == addr->function) {
>
> You can use rte_eal_compare_pci_addr() here.
>

Will fix this.

>
> > +
> > + *port_id = i;
> > + return 0;
> > + }
> > + }
> > + return -ENODEV;
> > +}
> > diff --git a/lib/librte_ether/rte_ether_version.map
> b/lib/librte_ether/rte_ether_version.map
> > index 8345a6c..3d5cb23 100644
> > --- a/lib/librte_ether/rte_ether_version.map
> > +++ b/lib/librte_ether/rte_ether_version.map
> > @@ -125,5 +125,7 @@ DPDK_2.1 {
> >   rte_eth_timesync_enable;
> >   rte_eth_timesync_read_rx_timestamp;
> >   rte_eth_timesync_read_tx_timestamp;
> > + rte_eth_dev_get_port_by_name;
> > + rte_eth_dev_get_port_by_addr;
> >
> >  } DPDK_2.0;
>
> Hi Thomas,
>
> Could you please make sure API consistency?
> Is it ok to add above functions to DPDK_2.1 even though we are in RC
> phase, or need to add to DPDK_2.2?
>
>
Same question. If it's targeted for 2.2 then I will modify this.

Thanks,
Ravi


> Thanks,
> Tetsuya
>
>
>


[dpdk-dev] [PATCH v1] Change rte_eal_vdev_init to update port_id

2015-08-06 Thread Ravi Kerur
Changes include
   > Modify rte_eal_vdev_init to return allocated port_id
   > Modify rte_eal_probe_one to return allocated port_id

2. Removed following functions
   > rte_eth_dev_save and
   > rte_eth_dev_get_changed_port

3. Added 2 new functions
   > rte_eth_dev_get_port_by_name
   > rte_eth_dev_get_port_by_addr

4. Fix return error(ENOMEM) in function rte_pmd_mpipe_devinit

Compiled on Linux for following targets
   > x86_64-native-linuxapp-gcc
   > x86_64-native-linuxapp-clang
   > x86_x32-native-linuxapp-gcc

Compiled on FreeBSD for following targets
   > x86_64-native-bsdapp-clang
   > x86_64-native-bsdapp-gcc

Tested on Linux/FreeBSD:
   > port attach eth_null
   > port start all
   > port stop all
   > port close all
   > port detach 0
   > port attach eth_null
   > port start all
   > port stop all
   > port close all
   > port detach 0

Successful run of checkpatch.pl on the diffs

Successful validate_abi on Linux for following targets

   > x86_64-native-linuxapp-gcc
   > x86_64-native-linuxapp-clang

Signed-off-by: Ravi Kerur 
---
 drivers/net/enic/enic_ethdev.c  |   2 +-
 drivers/net/mpipe/mpipe_tilegx.c|   1 +
 lib/librte_eal/common/eal_common_dev.c  |  14 ++--
 lib/librte_eal/common/eal_common_pci.c  |   6 +-
 lib/librte_eal/common/include/rte_dev.h |  36 +-
 lib/librte_eal/common/include/rte_pci.h |   4 +-
 lib/librte_ether/rte_ethdev.c   | 119 +---
 lib/librte_ether/rte_ether_version.map  |   2 +
 8 files changed, 118 insertions(+), 66 deletions(-)

diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 8280cea..472ef5a 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -36,8 +36,8 @@
 #include 
 #include 

-#include 
 #include 
+#include 
 #include 
 #include 

diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c
index 743feef..6e3e304 100644
--- a/drivers/net/mpipe/mpipe_tilegx.c
+++ b/drivers/net/mpipe/mpipe_tilegx.c
@@ -1582,6 +1582,7 @@ rte_pmd_mpipe_devinit(const char *ifname,
if (!eth_dev) {
RTE_LOG(ERR, PMD, "%s: Failed to allocate device.\n", ifname);
rte_free(priv);
+   return -ENOMEM;
}

RTE_LOG(INFO, PMD, "%s: Initialized mpipe device"
diff --git a/lib/librte_eal/common/eal_common_dev.c 
b/lib/librte_eal/common/eal_common_dev.c
index 4089d66..82d5693 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -37,6 +37,7 @@
 #include 
 #include 

+#include 
 #include 
 #include 
 #include 
@@ -64,7 +65,7 @@ rte_eal_driver_unregister(struct rte_driver *driver)
 }

 int
-rte_eal_vdev_init(const char *name, const char *args)
+rte_eal_vdev_init(const char *name, const char *args, uint8_t *port_id)
 {
struct rte_driver *driver;

@@ -81,8 +82,12 @@ rte_eal_vdev_init(const char *name, const char *args)
 * will be "eth_pcap", but "name" will be "eth_pcapN".
 * So use strncmp to compare.
 */
-   if (!strncmp(driver->name, name, strlen(driver->name)))
-   return driver->init(name, args);
+   if (!strncmp(driver->name, name, strlen(driver->name))) {
+   if (!driver->init(name, args))
+   return rte_eth_dev_get_port_by_name(
+   name, port_id);
+   }
+
}

RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
@@ -94,6 +99,7 @@ rte_eal_dev_init(void)
 {
struct rte_devargs *devargs;
struct rte_driver *driver;
+   uint8_t port_id;

/*
 * Note that the dev_driver_list is populated here
@@ -108,7 +114,7 @@ rte_eal_dev_init(void)
continue;

if (rte_eal_vdev_init(devargs->virtual.drv_name,
-   devargs->args)) {
+   devargs->args, _id)) {
RTE_LOG(ERR, EAL, "failed to initialize %s device\n",
devargs->virtual.drv_name);
return -1;
diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index 16e8629..3d97892 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -79,6 +79,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "eal_private.h"

@@ -322,7 +323,7 @@ pci_detach_all_drivers(struct rte_pci_device *dev)
  * the driver of the devive.
  */
 int
-rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
+rte_eal_pci_probe_one(const struct rte_pci_addr *addr, uint8_t *port_id)
 {
struct rte_pci_device *dev = 

[dpdk-dev] lost when learning how to test dpdk

2015-07-30 Thread Ravi Kerur
On Thu, Jul 30, 2015 at 10:06 AM, Ravi Kerur  wrote:

>
>
> On Thu, Jul 30, 2015 at 9:19 AM, Jan Viktorin 
> wrote:
>
>> OK, I've added the card into RTE_PCI_DEVEM_ID_DECL_EM list.
>> Much better now:
>>
>> EAL: Requesting 64 pages of size 2MB from socket 0
>> EAL: TSC frequency is ~365 KHz
>> EAL: Master lcore 0 is ready (tid=467d78c0;cpuset=[0])
>> EAL: lcore 1 is ready (tid=3a5ff700;cpuset=[1])
>> EAL: PCI device :03:00.0 on NUMA socket -1
>> EAL:   probe driver: 8086:1026 rte_em_pmd
>> EAL:   PCI memory mapped at 0x7fde44a0
>> EAL:   PCI memory mapped at 0x7fde44a2
>> PMD: eth_em_dev_init(): port_id 0 vendorID=0x8086 deviceID=0x1026
>> EAL: PCI device :03:02.0 on NUMA socket -1
>> EAL:   probe driver: 8086:1026 rte_em_pmd
>> EAL:   Not managed by a supported kernel driver, skipped
>> Interactive-mode selected
>> EAL: Error - exiting with code: 1
>>   Cause: Creation of mbuf pool for socket 0 failed
>>
>> I've tried both uio_pci_generic and igb_uio. Is there anything else
>> I can do about it?
>>
>
> I am attaching patch from M Jay/Cuming (Intel engineers), it's not yet
> integrated into DPDK mainline. You need it to fix above mbuf error.
>

In addition if you are allocating too little hugepages it can cause issues
esp 64. I usually allocate > 1024 hugepages.

>
>> Jan V.
>>
>> On Thu, 30 Jul 2015 08:41:47 -0700
>> Ravi Kerur  wrote:
>>
>> > On Thu, Jul 30, 2015 at 8:22 AM, Jan Viktorin 
>> > wrote:
>> >
>> > > The 82545 is listed at http://dpdk.org/doc/nics and I can see it in
>> > > rte_pci_dev_ids.h/e1000_hw.h:
>> > >
>> > > 196 #define E1000_DEV_ID_82545GM_COPPER   0x1026
>> > >
>> > > $ lspci -nn
>> > > ...
>> > > 03:00.0 Ethernet controller [0200]: Intel Corporation 82545GM Gigabit
>> > > Ethernet Controller [8086:1026] (rev 04)
>> > > 03:02.0 Ethernet controller [0200]: Intel Corporation 82545GM Gigabit
>> > > Ethernet Controller [8086:1026] (rev 04)
>> > >
>> > > However, it is rev 04 and in e1000_hw.h there is just
>> e1000_82545_rev_3.
>> > > But this should not avoid the match (?). Is it possible to grow the
>> > > verbosity
>> > > level of the device matching process in DPDK?
>> > >
>> >
>> > Check lib/librte_eal/common/include/rte_pci_dev_ids.h, you need to add
>> > device-id via RTE_PCI_DEVEM_ID_DECL_EM.
>> >
>> > >
>> > > I do not expect any support, I just wanted to use it for sending
>> traffic
>> > > at 1 Gbps because there are two such cards mostly unused in my
>> computer.
>> > > I did not plan to use I217-V (in fact, I did not expect much from this
>> > > integrated NIC and I did not even notice it is an Intel one...).
>> > >
>> > > Regards
>> > > Jan Viktorin
>> > >
>> > > On Thu, 30 Jul 2015 07:44:14 -0700
>> > > Ravi Kerur  wrote:
>> > >
>> > > > On Thu, Jul 30, 2015 at 5:03 AM, Jan Viktorin <
>> viktorin at rehivetech.com>
>> > > > wrote:
>> > > >
>> > > > > Hi,
>> > > > >
>> > > > > thanks for reply. I could see those docs but it does not help me
>> a lot.
>> > > > > I still do not understand very well the principle of the tool.
>> How it
>> > > > > chooses the NICs to use? Previously I confused -b in
>> dpdk_nic_bind and
>> > > > > testpmd. They have somehow opposite meaning. I can start testpmd
>> now,
>> > > > > however, it does ot probe any NIC. I've tried -w to whitelist
>> certain
>> > > > > NICs but with no success.
>> > > > >
>> > > > > $ dpdk_nic_bind --status
>> > > > >
>> > > > > Network devices using DPDK-compatible driver
>> > > > > 
>> > > > > :03:00.0 '82545GM Gigabit Ethernet Controller'
>> drv=uio_pci_generic
>> > > > > unused=e1000
>> > > > > :03:02.0 '82545GM Gigabit Ethernet Controller'
>> drv=uio_pci_generic
>> > > > > unused=e1000
>> > > > >
>> > > >
>> > > > NICs may not be supported by PMD drivers yet. Do "lspci -nn" and
>> check
>> > > the
>> > > > device-id.  Adding support

[dpdk-dev] lost when learning how to test dpdk

2015-07-30 Thread Ravi Kerur
On Thu, Jul 30, 2015 at 9:19 AM, Jan Viktorin 
wrote:

> OK, I've added the card into RTE_PCI_DEVEM_ID_DECL_EM list.
> Much better now:
>
> EAL: Requesting 64 pages of size 2MB from socket 0
> EAL: TSC frequency is ~365 KHz
> EAL: Master lcore 0 is ready (tid=467d78c0;cpuset=[0])
> EAL: lcore 1 is ready (tid=3a5ff700;cpuset=[1])
> EAL: PCI device :03:00.0 on NUMA socket -1
> EAL:   probe driver: 8086:1026 rte_em_pmd
> EAL:   PCI memory mapped at 0x7fde44a0
> EAL:   PCI memory mapped at 0x7fde44a2
> PMD: eth_em_dev_init(): port_id 0 vendorID=0x8086 deviceID=0x1026
> EAL: PCI device :03:02.0 on NUMA socket -1
> EAL:   probe driver: 8086:1026 rte_em_pmd
> EAL:   Not managed by a supported kernel driver, skipped
> Interactive-mode selected
> EAL: Error - exiting with code: 1
>   Cause: Creation of mbuf pool for socket 0 failed
>
> I've tried both uio_pci_generic and igb_uio. Is there anything else
> I can do about it?
>

I am attaching patch from M Jay/Cuming (Intel engineers), it's not yet
integrated into DPDK mainline. You need it to fix above mbuf error.

>
> Jan V.
>
> On Thu, 30 Jul 2015 08:41:47 -0700
> Ravi Kerur  wrote:
>
> > On Thu, Jul 30, 2015 at 8:22 AM, Jan Viktorin 
> > wrote:
> >
> > > The 82545 is listed at http://dpdk.org/doc/nics and I can see it in
> > > rte_pci_dev_ids.h/e1000_hw.h:
> > >
> > > 196 #define E1000_DEV_ID_82545GM_COPPER   0x1026
> > >
> > > $ lspci -nn
> > > ...
> > > 03:00.0 Ethernet controller [0200]: Intel Corporation 82545GM Gigabit
> > > Ethernet Controller [8086:1026] (rev 04)
> > > 03:02.0 Ethernet controller [0200]: Intel Corporation 82545GM Gigabit
> > > Ethernet Controller [8086:1026] (rev 04)
> > >
> > > However, it is rev 04 and in e1000_hw.h there is just
> e1000_82545_rev_3.
> > > But this should not avoid the match (?). Is it possible to grow the
> > > verbosity
> > > level of the device matching process in DPDK?
> > >
> >
> > Check lib/librte_eal/common/include/rte_pci_dev_ids.h, you need to add
> > device-id via RTE_PCI_DEVEM_ID_DECL_EM.
> >
> > >
> > > I do not expect any support, I just wanted to use it for sending
> traffic
> > > at 1 Gbps because there are two such cards mostly unused in my
> computer.
> > > I did not plan to use I217-V (in fact, I did not expect much from this
> > > integrated NIC and I did not even notice it is an Intel one...).
> > >
> > > Regards
> > > Jan Viktorin
> > >
> > > On Thu, 30 Jul 2015 07:44:14 -0700
> > > Ravi Kerur  wrote:
> > >
> > > > On Thu, Jul 30, 2015 at 5:03 AM, Jan Viktorin <
> viktorin at rehivetech.com>
> > > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > thanks for reply. I could see those docs but it does not help me a
> lot.
> > > > > I still do not understand very well the principle of the tool. How
> it
> > > > > chooses the NICs to use? Previously I confused -b in dpdk_nic_bind
> and
> > > > > testpmd. They have somehow opposite meaning. I can start testpmd
> now,
> > > > > however, it does ot probe any NIC. I've tried -w to whitelist
> certain
> > > > > NICs but with no success.
> > > > >
> > > > > $ dpdk_nic_bind --status
> > > > >
> > > > > Network devices using DPDK-compatible driver
> > > > > 
> > > > > :03:00.0 '82545GM Gigabit Ethernet Controller'
> drv=uio_pci_generic
> > > > > unused=e1000
> > > > > :03:02.0 '82545GM Gigabit Ethernet Controller'
> drv=uio_pci_generic
> > > > > unused=e1000
> > > > >
> > > >
> > > > NICs may not be supported by PMD drivers yet. Do "lspci -nn" and
> check
> > > the
> > > > device-id.  Adding support in PMD should not be a problem, but I am
> not
> > > > sure on support since there is End of Life listed on Intel Website
> > > >
> > > >
> > >
> http://ark.intel.com/products/4964/Intel-82545GM-Gigabit-Ethernet-Controller
> > > >
> > > >
> > > > > Network devices using kernel driver
> > > > > ===
> > > > > :00:19.0 'Ethernet Connection I217-V' if=eno1 drv=e1000e
> > > > > unused=uio_pci_generic *Active*
> > > > >
> > > &

[dpdk-dev] lost when learning how to test dpdk

2015-07-30 Thread Ravi Kerur
On Thu, Jul 30, 2015 at 5:03 AM, Jan Viktorin 
wrote:

> Hi,
>
> thanks for reply. I could see those docs but it does not help me a lot.
> I still do not understand very well the principle of the tool. How it
> chooses the NICs to use? Previously I confused -b in dpdk_nic_bind and
> testpmd. They have somehow opposite meaning. I can start testpmd now,
> however, it does ot probe any NIC. I've tried -w to whitelist certain
> NICs but with no success.
>
> $ dpdk_nic_bind --status
>
> Network devices using DPDK-compatible driver
> 
> :03:00.0 '82545GM Gigabit Ethernet Controller' drv=uio_pci_generic
> unused=e1000
> :03:02.0 '82545GM Gigabit Ethernet Controller' drv=uio_pci_generic
> unused=e1000
>

NICs may not be supported by PMD drivers yet. Do "lspci -nn" and check the
device-id.  Adding support in PMD should not be a problem, but I am not
sure on support since there is End of Life listed on Intel Website

http://ark.intel.com/products/4964/Intel-82545GM-Gigabit-Ethernet-Controller


> Network devices using kernel driver
> ===
> :00:19.0 'Ethernet Connection I217-V' if=eno1 drv=e1000e
> unused=uio_pci_generic *Active*
>

DPDK doesn't bind Active NIC, support for I217-V in PMD is being tested
currently.


>
> Other network devices
> =
> 
>
> $ sudo testpmd -c 0x3 -n 2 -- -i --total-num-mbufs=2048
> EAL: Detected lcore 0 as core 0 on socket 0
> EAL: Detected lcore 1 as core 1 on socket 0
> EAL: Detected lcore 2 as core 0 on socket 0
> EAL: Detected lcore 3 as core 1 on socket 0
> EAL: Support maximum 128 logical core(s) by configuration.
> EAL: Detected 4 lcore(s)
> EAL: VFIO modules not all loaded, skip VFIO support...
> EAL: Setting up physically contiguous memory...
> EAL: Ask a virtual area of 0x3c0 bytes
> EAL: Virtual area found at 0x7fe973e0 (size = 0x3c0)
> EAL: Ask a virtual area of 0x20 bytes
> EAL: Virtual area found at 0x7fe973a0 (size = 0x20)
> EAL: Ask a virtual area of 0x20 bytes
> EAL: Virtual area found at 0x7fe97360 (size = 0x20)
> EAL: Ask a virtual area of 0x3c0 bytes
> EAL: Virtual area found at 0x7fe96f80 (size = 0x3c0)
> EAL: Ask a virtual area of 0x20 bytes
> EAL: Virtual area found at 0x7fe96f40 (size = 0x20)
> EAL: Ask a virtual area of 0x20 bytes
> EAL: Virtual area found at 0x7fe96f00 (size = 0x20)
> EAL: Requesting 64 pages of size 2MB from socket 0
> EAL: TSC frequency is ~368 KHz
> EAL: Master lcore 0 is ready (tid=7989d8c0;cpuset=[0])
> EAL: lcore 1 is ready (tid=6efff700;cpuset=[1])
> EAL: No probed ethernet devices
> Interactive-mode selected
> Done
> testpmd>
>
> Thanks
> Jan Viktorin
>
> On Wed, 29 Jul 2015 12:09:06 +0300
> ciprian.barbu  wrote:
>
> >
> >
> > On 28.07.2015 21:13, Jan Viktorin wrote:
> > > Hello all,
> > >
> > > I am learning how to measure throughput with dpdk. I have 4 cores
> > > Intel(R) Core(TM) i3-4360 CPU @ 3.70GHz and two 82545GM NICs connected
> > > together. I do not understand very well, how to setup testpmd.
> >
> > http://dpdk.org/doc
> > http://dpdk.org/doc/guides/testpmd_app_ug/run_app.html
> > http://dpdk.org/doc/quick-start
> >
> > >
> > > I've successfully bound the NICs to dpdk:
> > >
> > > $ dpdk_nic_bind --status
> > >
> > > Network devices using DPDK-compatible driver
> > > 
> > > :03:00.0 '82545GM Gigabit Ethernet Controller' drv=uio_pci_generic
> unused=e1000
> > > :03:02.0 '82545GM Gigabit Ethernet Controller' drv=uio_pci_generic
> unused=e1000
> > >
> > > Network devices using kernel driver
> > > ===
> > > :00:19.0 'Ethernet Connection I217-V' if=eno1 drv=e1000e
> unused=uio_pci_generic *Active*
> > >
> > > Other network devices
> > > =
> > > 
> > >
> > > and then I tried to run testpmd:
> > >
> > > sudo ./testpmd -b :03:00.0 -b :03:02.0 -c 0xf -n2 --
> --nb-cores=1 --nb-ports=0 --rxd=2048 --txd=2048 --mbcache=512 --burst=512
> >
> >
> http://dpdk.org/doc/guides/testpmd_app_ug/run_app.html#testpmd-command-line-options
> >
> > The -b option black lists your PCI devices, you don't need those. The
> > --nb-ports is of course the number of ports, it cannot be 0.
> >
> > > ...
> > > EAL: Ask a virtual area of 0x40 bytes
> > > EAL: Virtual area found at 0x7f154980 (size = 0x40)
> > > EAL: Requesting 1024 pages of size 2MB from socket 0
> > > EAL: TSC frequency is ~369 KHz
> > > EAL: Master lcore 0 is ready (tid=de94a8c0;cpuset=[0])
> > > EAL: lcore 2 is ready (tid=487fd700;cpuset=[2])
> > > EAL: lcore 3 is ready (tid=47ffc700;cpuset=[3])
> > > EAL: lcore 1 is ready (tid=48ffe700;cpuset=[1])
> > > EAL: No probed ethernet devices
> > > EAL: Error - exiting with code: 1
> > >Cause: Invalid port 0
> > >
> > > I tried --nb-ports={0,1,2} but neither of them works. BTW, what does
> this option it mean? :)
> > > I could not find 

[dpdk-dev] [PATCH v10 0/3] deduplicate EAL common functions

2015-07-30 Thread Ravi Kerur
Hi Olivier,


On Thu, Jul 30, 2015 at 1:12 AM, Olivier MATZ 
wrote:

> Hi Thomas & Ravi,
>
>
> On 07/27/2015 02:59 AM, Thomas Monjalon wrote:
>
>> 2015-07-27 02:56, Thomas Monjalon:
>>
>>> v9 was a subset of previous deduplications by Ravi Kerur.
>>> This v10 address the comments I've done on v9.
>>>
>>> Ravi Kerur (3):
>>>eal: deduplicate lcore initialization
>>>eal: deduplicate timer functions
>>>eal: deduplicate memory initialization
>>>
>>
>> Applied shortly to integrate this old pending cleanup in RC2.
>>
>>
> When I try to compile the dpdk for x86_x32-native-linuxapp-gcc , I
> get the following compilation error:
>
>   CC eal_common_timer.o
> In file included from /usr/include/sys/sysctl.h:63:0,
>  from /home/matz/dpdk-pkg-cron/
> dpdk.org/lib/librte_eal/common/eal_common_timer.c:39:
> /usr/include/bits/sysctl.h:19:3: error: #error "sysctl system call is
> unsupported in x32 kernel"
>  # error "sysctl system call is unsupported in x32 kernel"
>^
>
> Removing the "#include " line fixes the issue without
> impacting the compilation. I think this include is not needed and
> could be removed.
> I can provide a patch if it's ok for you.
>
>
If it compiles fine on FreeBSD then it should be fine. It primarily needed
for eal_timer.c in FreeBSD environment, during code movement it slipped
through my mind. Sorry for the inconvenience.

Thanks,
Ravi


> Regards,
> Olivier
>
>


[dpdk-dev] [PATCH v2] Add support for pthreads setname.

2015-07-28 Thread Ravi Kerur
This patch adds support for pthread_setname_np on Linux and
pthread_set_name_np on FreeBSD.

Changes in V2:
Remove config support for max thread name len.
Restrict max thread name len to 16 on Linux and FreeBSD.
Fix checkpatch.pl errors.
Changes based on code review comments from Thomas.

Changes in V1:
Add support for _setname_ on Linux and FreeBSD.

Signed-off-by: Ravi Kerur 
---
 examples/vhost/Makefile|  1 +
 examples/vhost/main.c  | 21 +++--
 examples/vhost_xen/Makefile|  1 +
 examples/vhost_xen/main.c  | 21 +++--
 lib/librte_eal/bsdapp/eal/eal.c|  7 +++
 lib/librte_eal/common/include/rte_eal.h|  3 +++
 lib/librte_eal/linuxapp/eal/Makefile   |  2 ++
 lib/librte_eal/linuxapp/eal/eal.c  | 11 +++
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 21 +++--
 lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 18 --
 lib/librte_eal/linuxapp/eal/eal_timer.c| 14 +-
 11 files changed, 111 insertions(+), 9 deletions(-)

diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
index c269466..e95c68a 100644
--- a/examples/vhost/Makefile
+++ b/examples/vhost/Makefile
@@ -52,6 +52,7 @@ SRCS-y := main.c

 CFLAGS += -O2 -D_FILE_OFFSET_BITS=64
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -D_GNU_SOURCE

 include $(RTE_SDK)/mk/rte.extapp.mk

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 1b137b9..cfe3c6c 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2896,6 +2896,7 @@ main(int argc, char *argv[])
uint8_t portid;
uint16_t queue_id;
static pthread_t tid;
+   char thread_name[RTE_MAX_THREAD_NAME_LEN];

signal(SIGINT, sigint_handler);

@@ -3018,8 +3019,24 @@ main(int argc, char *argv[])
memset(_statistics, 0, sizeof(dev_statistics));

/* Enable stats if the user option is set. */
-   if (enable_stats)
-   pthread_create(, NULL, (void*)print_stats, NULL );
+   if (enable_stats) {
+
+   ret = pthread_create(, NULL, (void *)print_stats, NULL);
+
+   if (ret != 0)
+   rte_exit(EXIT_FAILURE,
+   "Cannot create print-stats thread\n");
+
+   /* Set thread_name for aid in debugging.  */
+   snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+   "print-stats");
+
+   ret = pthread_setname_np(tid, thread_name);
+
+   if (ret != 0)
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "Cannot set print-stats name\n");
+   }

/* Launch all data cores. */
if (zero_copy == 0) {
diff --git a/examples/vhost_xen/Makefile b/examples/vhost_xen/Makefile
index e6fa1a1..47e1489 100644
--- a/examples/vhost_xen/Makefile
+++ b/examples/vhost_xen/Makefile
@@ -46,6 +46,7 @@ SRCS-y := main.c vhost_monitor.c xenstore_parse.c

 CFLAGS += -O2 -I/usr/local/include -D_FILE_OFFSET_BITS=64 -Wno-unused-parameter
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -D_GNU_SOURCE
 LDFLAGS += -lxenstore

 include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c
index 5d20700..fb79efa 100644
--- a/examples/vhost_xen/main.c
+++ b/examples/vhost_xen/main.c
@@ -1432,6 +1432,7 @@ main(int argc, char *argv[])
int ret;
uint8_t portid;
static pthread_t tid;
+   char thread_name[RTE_MAX_THREAD_NAME_LEN];

/* init EAL */
ret = rte_eal_init(argc, argv);
@@ -1501,8 +1502,24 @@ main(int argc, char *argv[])
memset(_statistics, 0, sizeof(dev_statistics));

/* Enable stats if the user option is set. */
-   if (enable_stats)
-   pthread_create(, NULL, (void*)print_stats, NULL );
+   if (enable_stats) {
+
+   ret = pthread_create(, NULL, (void *)print_stats, NULL);
+
+   if (ret != 0)
+   rte_exit(EXIT_FAILURE,
+   "Cannot create print-stats thread\n");
+
+   /* Set thread_name for aid in debugging. */
+   snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+   "print-xen-stats");
+
+   ret = pthread_setname_np(tid, thread_name);
+
+   if (ret != 0)
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "Cannot set print-stats name\n");
+   }

/* Launch all data cores. */
RTE_LCORE_FOREACH_SLAVE(lcore_id) {
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 1b6f705..7c1cd7a 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -467,6 +467,7 @@ rte_eal_init(int argc, char **argv)
pthread_t thread_id;

[dpdk-dev] [PATCH v2] Add support for pthread_setname

2015-07-28 Thread Ravi Kerur
This patch adds support for pthread_setname_np on Linux
and pthread_set_name_np on FreeBSD to aid in debugging by
identifying DPDK threads by it name. Following is the sample
output on Linux and FreeBSD.

On Linux:
rkerur at dpdk-ubuntu# ps H -C testpmd -o 'pid tid cmd comm'
  PID   TID CMD COMMAND
32590 32590 x86_64-native-linuxapp-gcc/ testpmd
32590 32591 x86_64-native-linuxapp-gcc/ eal-intr-thread
32590 32592 x86_64-native-linuxapp-gcc/ lcore-slave-1
32590 32593 x86_64-native-linuxapp-gcc/ lcore-slave-2
32590 32594 x86_64-native-linuxapp-gcc/ lcore-slave-3
32590 32595 x86_64-native-linuxapp-gcc/ lcore-slave-4
32590 32596 x86_64-native-linuxapp-gcc/ lcore-slave-5
32590 32597 x86_64-native-linuxapp-gcc/ lcore-slave-6
32590 32598 x86_64-native-linuxapp-gcc/ lcore-slave-7

On FreeBSD:
rkerur at dpdk-bsd:~ # procstat -t 28630
  PIDTID COMM TDNAME   CPU  PRI STATE   WCHAN
28630 100066 cmdline  -  0  133 sleep   ttyin
28630 100170 cmdline  lcore-slave-1  1  152 sleep   piperd
28630 100171 cmdline  lcore-slave-2  2  152 sleep   piperd
28630 100172 cmdline  lcore-slave-3  3  152 sleep   piperd

Ravi Kerur (1):
  Add support for pthreads_setname.

 examples/vhost/Makefile|  1 +
 examples/vhost/main.c  | 21 +++--
 examples/vhost_xen/Makefile|  1 +
 examples/vhost_xen/main.c  | 21 +++--
 lib/librte_eal/bsdapp/eal/eal.c|  7 +++
 lib/librte_eal/common/include/rte_eal.h|  3 +++
 lib/librte_eal/linuxapp/eal/Makefile   |  2 ++
 lib/librte_eal/linuxapp/eal/eal.c  | 11 +++
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 21 +++--
 lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 18 --
 lib/librte_eal/linuxapp/eal/eal_timer.c| 14 +-
 11 files changed, 111 insertions(+), 9 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH] Use pthread_setname APIs

2015-07-27 Thread Ravi Kerur
On Mon, Jul 27, 2015 at 2:09 PM, Stephen Hemminger <
stephen at networkplumber.org> wrote:

> On Mon, 27 Jul 2015 13:40:08 -0700
> Ravi Kerur  wrote:
>
> > On Sun, Jul 26, 2015 at 2:54 PM, Thomas Monjalon <
> thomas.monjalon at 6wind.com>
> > wrote:
> >
> > > Hi Ravi,
> > > It seems to be a nice improvement but it needs some cleanup.
> > >
> > > Checkpatch returns some errors.
> > >
> > > 2015-04-22 14:06, Ravi Kerur:
> > > > use pthread_setname_np and pthread_set_name_np for Linux and
> > > > FreeBSD respectively.
> > > > Restrict pthread name len to 16 via config for both Linux and
> FreeBSD.
> > >
> > > One of the most important part of the commit message is to answer why.
> > > Here you probably should explain that the goal is to help debugging.
> > >
> >
> > Sure will do it and will run checkpatch before next version.
> >
> > >
> > > >  #
> > > > +# Max pthread name len
> > > > +#
> > > > +CONFIG_RTE_MAX_THREAD_NAME_LEN=16
> > >
> > > It doesn't have to be configurable. A define would be sufficient.
> > >
>
> Definitely should not be in the DPDK config.
> It is property of system, which change some config parameter doesn't
> change.
>
> Manpage implies it is fixed in glibc.
>
>The pthread_setname_np() function can be used to  set  a
>unique  name  for  a  thread,  which can be useful for debugging
> multi?
>threaded applications.  The thread name  is  a  meaningful  C
> language
>string, whose length is restricted to 16 characters, including the
> ter?
>minating null byte ('\0').
>
> > Had run into issues(reported by Bruce) as name_len = 32 worked fine for
> > FreeBSD but not for Linux, hence thought of making it configurable for
> > Linux/FreeBSD and be able to have different name len's. Found out that
> > there is also a definition PTHREAD_MAX_NAMELEN_NP, if it's available on
> > both Linux and FreeBSD  I will use this, else should I restrict name_len
> =
> > 16?
>
> Not that I see on Linux
> $ find /usr/include -type f | xargs grep PTHREAD_MAX_NAMELEN_NP
>
>
That's correct on Linux and look like it's not defined for FreeBSD as
well.  FreeBSD man page doesn't mention anything about string length too.

>
>
> > >
> > > > + snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
> > > "print-stats");
> > >
> > > Why not put this line just before use of thread_name?
> > >
> >
> > Will do it.
> >
> > >
> > > > +
> > > > + ret = pthread_create(, NULL, (void*)print_stats,
> NULL
> > > );
> > > > +
> > > > + if (ret != 0)
> > > > + rte_exit(EXIT_FAILURE,
> > > > + "Cannot create print-stats thread\n");
> > > > +
> > > > + ret = pthread_setname_np(tid, thread_name);
> > > > +
> > > > + if (ret != 0)
> > > > + RTE_LOG(ERR, VHOST_CONFIG,
> > > > + "Cannot set print-stats name\n");
> > > [...]
> > >
> > > > + pthread_set_name_np(lcore_config[i].thread_id,
> > > > + (const char *)thread_name);
> > >
> > > Is const casting really needed?
> > >
> >
> > Function signature has a (const char *) for second parameter, I will
> double
> > check and remove if not needed.
>
> You can always pass a char * when function takes const char *
>

That's correct, will remove it.


[dpdk-dev] [PATCH] Use pthread_setname APIs

2015-07-27 Thread Ravi Kerur
On Sun, Jul 26, 2015 at 2:54 PM, Thomas Monjalon 
wrote:

> Hi Ravi,
> It seems to be a nice improvement but it needs some cleanup.
>
> Checkpatch returns some errors.
>
> 2015-04-22 14:06, Ravi Kerur:
> > use pthread_setname_np and pthread_set_name_np for Linux and
> > FreeBSD respectively.
> > Restrict pthread name len to 16 via config for both Linux and FreeBSD.
>
> One of the most important part of the commit message is to answer why.
> Here you probably should explain that the goal is to help debugging.
>

Sure will do it and will run checkpatch before next version.

>
> >  #
> > +# Max pthread name len
> > +#
> > +CONFIG_RTE_MAX_THREAD_NAME_LEN=16
>
> It doesn't have to be configurable. A define would be sufficient.
>

Had run into issues(reported by Bruce) as name_len = 32 worked fine for
FreeBSD but not for Linux, hence thought of making it configurable for
Linux/FreeBSD and be able to have different name len's. Found out that
there is also a definition PTHREAD_MAX_NAMELEN_NP, if it's available on
both Linux and FreeBSD  I will use this, else should I restrict name_len =
16?

>
> > + snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
> "print-stats");
>
> Why not put this line just before use of thread_name?
>

Will do it.

>
> > +
> > + ret = pthread_create(, NULL, (void*)print_stats, NULL
> );
> > +
> > + if (ret != 0)
> > + rte_exit(EXIT_FAILURE,
> > + "Cannot create print-stats thread\n");
> > +
> > + ret = pthread_setname_np(tid, thread_name);
> > +
> > + if (ret != 0)
> > + RTE_LOG(ERR, VHOST_CONFIG,
> > + "Cannot set print-stats name\n");
> [...]
>
> > + pthread_set_name_np(lcore_config[i].thread_id,
> > + (const char *)thread_name);
>
> Is const casting really needed?
>

Function signature has a (const char *) for second parameter, I will double
check and remove if not needed.


[dpdk-dev] [PATCH v9 0/3] Move EAL common functions

2015-07-25 Thread Ravi Kerur
As per Thomas's suggestion dividing v8 patch into multiple smaller
series.  This patch contains changes to eal_lcore.c, eal_timer.c
and eal_memory.c files. 

Tested on Ubuntu x86_64 14.04 GCC and Clang
Tested on FreeBSD 10.0 x86_64 GCC and Clang
testpmd, make test were run successfully.

Ravi Kerur (3):
  Move common functions in eal_lcore.c
  Move common functions in eal_timer.c
  Move common functions in eal_memory.c

 lib/librte_eal/bsdapp/eal/Makefile|   2 +
 lib/librte_eal/bsdapp/eal/eal_lcore.c |  72 +---
 lib/librte_eal/bsdapp/eal/eal_memory.c|  52 +++
 lib/librte_eal/bsdapp/eal/eal_timer.c |  52 +++
 lib/librte_eal/common/eal_common_lcore.c  | 107 ++
 lib/librte_eal/common/eal_common_memory.c |  41 +++-
 lib/librte_eal/common/eal_common_timer.c  | 102 
 lib/librte_eal/common/eal_private.h   |  63 ++
 lib/librte_eal/linuxapp/eal/Makefile  |   3 +
 lib/librte_eal/linuxapp/eal/eal_lcore.c   |  66 ++
 lib/librte_eal/linuxapp/eal/eal_memory.c  |  52 +++
 lib/librte_eal/linuxapp/eal/eal_timer.c   |  55 ++-
 12 files changed, 379 insertions(+), 288 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_lcore.c
 create mode 100644 lib/librte_eal/common/eal_common_timer.c

-- 
1.9.1



[dpdk-dev] [PATCH v9 3/3] Move common functions in eal_memory.c

2015-07-25 Thread Ravi Kerur
Changes in v9
Rebase to latest code.

Changes in v8
None

Changes in v7
None

Changes in v6
Removed unnecessary comments in function declaration.

Changes in v5
Rebase to latest code.

Changes in v4
Make rte_eal_hugepage_init and rte_eal_hugepage_attach as
wrapper functions for BSD.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
Use common function names rte_eal_hugepage_init and
rte_eal_hugepage_attach for BSD and Linux. Update comments about its
actuality in function declaration.

Changes in v1
Move common functions in eal_memory.c to librte_eal/common/
eal_common_memory.c file.

Following functions are moved to eal_common_memory.c file

static int rte_eal_memdevice_init(void); int rte_eal_memory_init(void);
Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/eal_memory.c| 52 ++-
 lib/librte_eal/common/eal_common_memory.c | 41 ++--
 lib/librte_eal/common/eal_private.h   | 29 +++--
 lib/librte_eal/linuxapp/eal/eal_memory.c  | 52 ++-
 4 files changed, 98 insertions(+), 76 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_memory.c 
b/lib/librte_eal/bsdapp/eal/eal_memory.c
index a3242a5..28231bb 100644
--- a/lib/librte_eal/bsdapp/eal/eal_memory.c
+++ b/lib/librte_eal/bsdapp/eal/eal_memory.c
@@ -59,7 +59,7 @@ rte_mem_virt2phy(const void *virtaddr)
return RTE_BAD_PHYS_ADDR;
 }

-static int
+static inline int
 rte_eal_contigmem_init(void)
 {
struct rte_mem_config *mcfg;
@@ -132,7 +132,16 @@ rte_eal_contigmem_init(void)
return 0;
 }

-static int
+/*
+ * Wrapper function to initialize contigmem.
+ */
+int
+rte_eal_hugepage_init(void)
+{
+   return rte_eal_contigmem_init();
+}
+
+static inline int
 rte_eal_contigmem_attach(void)
 {
const struct hugepage_info *hpi;
@@ -193,35 +202,20 @@ error:
return -1;
 }

-
-static int
-rte_eal_memdevice_init(void)
+/*
+ * Wrapper function to attach contigmem.
+ */
+int
+rte_eal_hugepage_attach(void)
 {
-   struct rte_config *config;
-
-   if (rte_eal_process_type() == RTE_PROC_SECONDARY)
-   return 0;
-
-   config = rte_eal_get_configuration();
-   config->mem_config->nchannel = internal_config.force_nchannel;
-   config->mem_config->nrank = internal_config.force_nrank;
-
-   return 0;
+   return rte_eal_contigmem_attach();
 }

-/* init memory subsystem */
-int
-rte_eal_memory_init(void)
+/*
+ * Wrapper function, no-op here.
+ */
+void
+test_proc_pagemap_readable(void)
 {
-   RTE_LOG(INFO, EAL, "Setting up physically contiguous memory...\n");
-   const int retval = rte_eal_process_type() == RTE_PROC_PRIMARY ?
-   rte_eal_contigmem_init() :
-   rte_eal_contigmem_attach();
-   if (retval < 0)
-   return -1;
-
-   if (internal_config.no_shconf == 0 && rte_eal_memdevice_init() < 0)
-   return -1;
-
-   return 0;
+   return;
 }
diff --git a/lib/librte_eal/common/eal_common_memory.c 
b/lib/librte_eal/common/eal_common_memory.c
index 9a07b1e..95f0a50 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -45,6 +45,7 @@
 #include 

 #include "eal_private.h"
+#include "eal_internal_cfg.h"

 /*
  * Return a pointer to a read-only table of struct rte_physmem_desc
@@ -69,7 +70,7 @@ rte_eal_get_physmem_size(void)
/* get pointer to global configuration */
mcfg = rte_eal_get_configuration()->mem_config;

-   for (i=0; i<RTE_MAX_MEMSEG; i++) {
+   for (i = 0; i < RTE_MAX_MEMSEG; i++) {
if (mcfg->memseg[i].addr == NULL)
break;

@@ -89,7 +90,7 @@ rte_dump_physmem_layout(FILE *f)
/* get pointer to global configuration */
mcfg = rte_eal_get_configuration()->mem_config;

-   for (i=0; i<RTE_MAX_MEMSEG; i++) {
+   for (i = 0; i < RTE_MAX_MEMSEG; i++) {
if (mcfg->memseg[i].addr == NULL)
break;

@@ -118,3 +119,39 @@ unsigned rte_memory_get_nrank(void)
 {
return rte_eal_get_configuration()->mem_config->nrank;
 }
+
+static int
+rte_eal_memdevice_init(void)
+{
+   struct rte_config *config;
+
+   if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+   return 0;
+
+   config = rte_eal_get_configuration();
+   config->mem_config->nchannel = internal_config.force_nchannel;
+   config->mem_config->nrank = internal_config.force_nrank;
+
+   return 0;
+}
+
+/* init memory subsystem */
+int
+rte_eal_memory_init(void)
+{
+   RTE_LOG(INFO, EAL, "Setting up physically contiguous memory...\n");
+
+   test_proc_pagemap_readable();
+
+   const int retval = rte_eal_process_type() == RTE_PROC_PRIMARY ?
+

[dpdk-dev] [PATCH v9 2/3] Move common functions in eal_timer.c

2015-07-25 Thread Ravi Kerur
Changes in v9
Rebase to latest code.

Changes in v8
Reorder eal_common_timer.c compilation.

Changes in v7
None

Changes in v6
Added new line between Copyright and header file inclusion
in eal_common_timer.c.

Changes in v5
Rebase to latest code.

Changes in v4
Removed extern declaration of eal_tsc_resolution_hz,
instead provided _set_ API.
Make set_tsc_freq_from_clock as wrapper function for BSD.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
Use common function name set_tsc_freq_from_sysctl for BSD and Linux.
Update comments about its actuality in function declaration.

Changes in v1
Move common functions in eal_timer.c to librte_eal/common/
eal_common_timer.c file.

Following functions are  moved to eal_common_timer.c file

void rte_delay_us(unsigned us);
uint64_t rte_get_tsc_hz(void);
static void set_tsc_freq_fallback(void);
void set_tsc_freq(void);

Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile   |   1 +
 lib/librte_eal/bsdapp/eal/eal_timer.c|  52 +++-
 lib/librte_eal/common/eal_common_timer.c | 102 +++
 lib/librte_eal/common/eal_private.h  |  24 
 lib/librte_eal/linuxapp/eal/Makefile |   1 +
 lib/librte_eal/linuxapp/eal/eal_timer.c  |  55 ++---
 6 files changed, 140 insertions(+), 95 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_timer.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index d5e4f4a..102f310 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -60,6 +60,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_timer.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_timer.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c

diff --git a/lib/librte_eal/bsdapp/eal/eal_timer.c 
b/lib/librte_eal/bsdapp/eal/eal_timer.c
index 7147abe..ee7a5ac 100644
--- a/lib/librte_eal/bsdapp/eal/eal_timer.c
+++ b/lib/librte_eal/bsdapp/eal/eal_timer.c
@@ -55,29 +55,12 @@

 enum timer_source eal_timer_source = EAL_TIMER_TSC;

-/* The frequency of the RDTSC timer resolution */
-static uint64_t eal_tsc_resolution_hz = 0;
-
-void
-rte_delay_us(unsigned us)
-{
-   const uint64_t start = rte_get_timer_cycles();
-   const uint64_t ticks = (uint64_t)us * rte_get_timer_hz() / 1E6;
-   while ((rte_get_timer_cycles() - start) < ticks)
-   rte_pause();
-}
-
-uint64_t
-rte_get_tsc_hz(void)
-{
-   return eal_tsc_resolution_hz;
-}
-
 static int
 set_tsc_freq_from_sysctl(void)
 {
size_t sz;
int tmp;
+   uint64_t tsc_hz;

sz = sizeof(tmp);
tmp = 0;
@@ -94,42 +77,23 @@ set_tsc_freq_from_sysctl(void)
else if (tmp != 1)
RTE_LOG(WARNING, EAL, "TSC is not invariant\n");

-   sz = sizeof(eal_tsc_resolution_hz);
-   if (sysctlbyname("machdep.tsc_freq", _tsc_resolution_hz, , NULL, 
0)) {
+   sz = sizeof(tsc_hz);
+   if (sysctlbyname("machdep.tsc_freq", _hz, , NULL, 0)) {
RTE_LOG(WARNING, EAL, "%s\n", strerror(errno));
return -1;
}
+   rte_set_tsc_hz(tsc_hz);

return 0;
 }

-static void
-set_tsc_freq_fallback(void)
-{
-   RTE_LOG(WARNING, EAL, "WARNING: clock_gettime cannot use "
-   "CLOCK_MONOTONIC_RAW and HPET is not available"
-   " - clock timings may be less accurate.\n");
-   /* assume that the sleep(1) will sleep for 1 second */
-   uint64_t start = rte_rdtsc();
-   sleep(1);
-   eal_tsc_resolution_hz = rte_rdtsc() - start;
-}
-
 /*
- * This function measures the TSC frequency. It uses a variety of approaches.
- *
- * 1. Read the TSC frequency value provided by the kernel
- * 2. If above does not work, just sleep for 1 second and tune off that,
- *printing a warning about inaccuracy of timing
+ * Wrapper function to get TSC frequency from sysctl.
  */
-static void
-set_tsc_freq(void)
+int
+set_tsc_freq_from_clock(void)
 {
-   if (set_tsc_freq_from_sysctl() < 0)
-   set_tsc_freq_fallback();
-
-   RTE_LOG(INFO, EAL, "TSC frequency is ~%"PRIu64" KHz\n",
-   eal_tsc_resolution_hz/1000);
+   return set_tsc_freq_from_sysctl();
 }

 int
diff --git a/lib/librte_eal/common/eal_common_timer.c 
b/lib/librte_eal/common/eal_common_timer.c
new file mode 100644
index 000..5fddd6e
--- /dev/null
+++ b/lib/librte_eal/common/eal_common_timer.c
@@ -0,0 +1,102 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights 

[dpdk-dev] [PATCH v9 1/3] Move common functions in eal_lcore.c

2015-07-25 Thread Ravi Kerur
Changes in v9
Rebase to latest code.

Changes in v8
Reorder eal_common_lcore.c compilation.

Changes in v7
None.

Changes in v6
None.

Changes in v5
Rebase to latest code.

Changes in v4
Implement cpu_detected() for BSD.
Have common RTE_LOG for Linux and BSD in rte_eal_cpu_init().
Remove RTE_EXEC_ENV_BSDAPP in common file.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
None

Changes in v1
Move common function in eal_lcore.c to librte_eal/common/
eal_common_lcore.c file.

Following function is  moved to eal_common_lcore.c file

int rte_eal_cpu_init(void);

Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in
common function.
Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile   |   1 +
 lib/librte_eal/bsdapp/eal/eal_lcore.c|  72 +
 lib/librte_eal/common/eal_common_lcore.c | 107 +++
 lib/librte_eal/common/eal_private.h  |  14 
 lib/librte_eal/linuxapp/eal/Makefile |   2 +
 lib/librte_eal/linuxapp/eal/eal_lcore.c  |  66 ++-
 6 files changed, 143 insertions(+), 119 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_lcore.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index 064b0c5..d5e4f4a 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -58,6 +58,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_lcore.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_timer.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c
diff --git a/lib/librte_eal/bsdapp/eal/eal_lcore.c 
b/lib/librte_eal/bsdapp/eal/eal_lcore.c
index 162fb4f..b47eb1b 100644
--- a/lib/librte_eal/bsdapp/eal/eal_lcore.c
+++ b/lib/librte_eal/bsdapp/eal/eal_lcore.c
@@ -44,11 +44,14 @@
 #include "eal_thread.h"

 /* No topology information available on FreeBSD including NUMA info */
-#define cpu_core_id(X) 0
-#define cpu_socket_id(X) 0
+unsigned
+eal_cpu_core_id(__rte_unused unsigned lcore_id)
+{
+   return 0;
+}

 static int
-get_ncpus(void)
+eal_get_ncpus(void)
 {
int mib[2] = {CTL_HW, HW_NCPU};
int ncpu;
@@ -59,63 +62,18 @@ get_ncpus(void)
return ncpu;
 }

-/*
- * fill the cpu_info structure with as much info as we can get.
- * code is similar to linux version, but sadly available info is less.
- */
-int
-rte_eal_cpu_init(void)
+unsigned
+eal_cpu_socket_id(__rte_unused unsigned cpu_id)
 {
-   /* pointer to global configuration */
-   struct rte_config *config = rte_eal_get_configuration();
-   unsigned lcore_id;
-   unsigned count = 0;
-
-   const unsigned ncpus = get_ncpus();
-   /*
-* Parse the maximum set of logical cores, detect the subset of running
-* ones and enable them by default.
-*/
-   for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
-   /* init cpuset for per lcore config */
-   CPU_ZERO(_config[lcore_id].cpuset);
-
-   lcore_config[lcore_id].detected = (lcore_id < ncpus);
-   if (lcore_config[lcore_id].detected == 0) {
-   config->lcore_role[lcore_id] = ROLE_OFF;
-   continue;
-   }
-
-   /* By default, lcore 1:1 map to cpu id */
-   CPU_SET(lcore_id, _config[lcore_id].cpuset);
-
-   /* By default, each detected core is enabled */
-   config->lcore_role[lcore_id] = ROLE_RTE;
-   lcore_config[lcore_id].core_id = cpu_core_id(lcore_id);
-   lcore_config[lcore_id].socket_id = cpu_socket_id(lcore_id);
-   if (lcore_config[lcore_id].socket_id >= RTE_MAX_NUMA_NODES)
-#ifdef RTE_EAL_ALLOW_INV_SOCKET_ID
-   lcore_config[lcore_id].socket_id = 0;
-#else
-   rte_panic("Socket ID (%u) is greater than "
-   "RTE_MAX_NUMA_NODES (%d)\n",
-   lcore_config[lcore_id].socket_id, 
RTE_MAX_NUMA_NODES);
-#endif
-   RTE_LOG(DEBUG, EAL, "Detected lcore %u\n",
-   lcore_id);
-   count++;
-   }
-   /* Set the count of enabled logical cores of the EAL configuration */
-   config->lcore_count = count;
-   RTE_LOG(DEBUG, EAL, "Support maximum %u logical core(s) by 
configuration.\n",
-   RTE_MAX_LCORE);
-   RTE_LOG(DEBUG, EAL, "Detected %u lcore(s)\n", config->lcore_count);
-
return 0;
 }

-unsigned
-eal_cpu_socket_id(__rte_unused unsigned

[dpdk-dev] [PATCH v3] Implement memcmp using SIMD intrinsics

2015-06-15 Thread Ravi Kerur
On Fri, Jun 12, 2015 at 1:30 AM, Ond?ej B?lka  wrote:

> On Mon, May 18, 2015 at 01:01:42PM -0700, Ravi Kerur wrote:
> > Background:
> > After preliminary discussion with John (Zhihong) and Tim from Intel it
> was
> > decided that it would be beneficial to use AVX/SSE intrinsics for memcmp
> > similar to memcpy that had been implemeneted. In addition, we decided to
> use
> > librte_hash as a test candidate to test both functionality and
> performance.
> >
> > Further discussions lead to complete functionality implementation of
> memory
> > comparison and v3 code reflects that.
> >
> > Test was conducted on Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz, Ubuntu
> 14.04,
> > x86_64, 16GB DDR3 system.
> >
> > Ravi Kerur (1):
> >   Implement memcmp using Intel SIMD instrinsics.
>
> As my previous mail got lost I am resending it.
>
> In short you shouldn't
> use sse2/avx2 for memcmp at all. In 95% of calls you find inequality in
> first 8 bytes so sse2 adds just unnecessary overhead versus checking
> these with.
>
>
Can you provide more details on how you found out 95% of the time
inequality results within first 8 bytes and how it applies to network
applications. Was any study or experiment done to understand from network
applications point of view? If yes, please share it.

Secondly, we (Intel engr and I) started off with non-avx and we have
slightly different version of what you have posted below for non-avx and at
that time we had focussed on 128 bytes comparison only and it couldn't beat
avx at all. No assumption on inequality i.e. byte difference can be
anywhere from 0th to 127th byte.
snippets of code below

__inline uint16_t bswap_16(uint16_t a)
{return __builtin_bswap16(a);}

__inline uint32_t bswap_32(uint32_t a)
{return __builtin_bswap32(a);}

__inline uint64_t bswap_64(uint64_t a)
{return __builtin_bswap64(a);}

#define RTE_CMP_1(a, b) { \
uint8_t   x = *(uint8_t *)(a); \
uint8_ty = *(uint8_t *)(b); \
if (x != y) return x - y; }

#define _RTE_CMP_1(a, b) \
return *(uint8_t *)(a) - *(uint8_t *)(b);
//
#define RTE_CMP_2(a, b) { \
uint16_tx = bswap_16(*(uint16_t *)(a)); \
uint16_ty = bswap_16(*(uint16_t *)(b)); \
if (x != y) return x - y; }

#define _RTE_CMP_2(a, b) { \
uint16_tx = bswap_16(*(uint16_t *)(a)); \
uint16_t   y = bswap_16(*(uint16_t *)(b)); \
return x - y; }
//
#define RTE_CMP_4(a, b) { \
uint32_tx = bswap_32(*(uint32_t *)(a)); \
uint32_ty = bswap_32(*(uint32_t *)(b)); \
if (x != y) return (x < y) ? -1 : 1; }

#define _RTE_CMP_4(a, b) { \
uint32_tx = bswap_32(*(uint32_t *)(a)); \
uint32_ty = bswap_32(*(uint32_t *)(b)); \
return (x < y) ? -1 : (x > y) ? 1 : 0; }
//
#define RTE_CMP_8(a, b) { \
uint64_tx = bswap_64(*(uint64_t *)(a)); \
uint64_ty = bswap_64(*(uint64_t *)(b)); \
if (x != y) return (x < y) ? -1 : 1; }
#define _RTE_CMP_8(a, b) { \
uint64_tx = bswap_64(*(uint64_t *)(a)); \
uint64_ty = bswap_64(*(uint64_t *)(b)); \
return (x < y) ? -1 : (x > y) ? 1 : 0; }

static inline int_32 rte_memcmp(const void *_a, const void *_b, size_t
_size)
//*
{
uint8_t*a = (uint8_t *)_a;
uint8_t*b = (uint8_t *)_b;
ptrdiff_tsize = _size;
uint64_tx, y;
ptrdiff_ti;

if (!size)
return 0;

RTE_CMP_1(a, b)

if (size >= 32)
goto cmp_long;

for (i = 0; i <= size - 16; i += 16, a += 16, b += 16)
{
RTE_CMP_8(a + 0, b + 0)
RTE_CMP_8(a + 8, b + 8)
}
...
}

Thanks.


> 190:   48 8b 4e 08 mov0x8(%rsi),%rcx
> 194:   48 39 4f 08 cmp%rcx,0x8(%rdi)
> 198:   75 f3   jne18d <memeq30+0xd>
>
> Also as you have full memcmp does in your gcc optimize out
> if (memcmp(x,y))
> like in mine?
>
> So run also implementation below in your benchmark, my guess is it will
> be faster.
>
> Original mail follows:
>
>
>
> Hi,
>
> I as glibc developer that wrote current strcmp code have some comments.
>
> First is that gcc builtins for *cmp are garbage that produce rep cmpsb
> which is slower than byte-by-byte loop. So compile your test again with
> -fno-builtin-memcmp and your performance gain will probably disappear.
>
> Then there is inlining. Its correct to do that for first 32 bytes and I
> plan to add header that does that check to improve performance. However
> not for bytes after 32'th. Thats very cold code, Only 5.6% calls reach
> 17th byte and 1.7% of calls read 33'th byte, so just do libcall to save
> size.
>
>

[dpdk-dev] [PATCH v3] Implement memcmp using Intel SIMD instrinsics.

2015-05-18 Thread Ravi Kerur
This patch implements memcmp and use librte_hash as the first candidate
to use rte_memcmp which is implemented using AVX/SSE intrinsics.

Tested with GCC(4.8.2) and Clang(3.4-1) compilers and both tests show better
performance on Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz, Ubuntu 14.04
x86_64 shows when compared to memcmp.

Changes in v3:
Implement complete memcmp functionality.
Implement functional and performance tests and add it to
"make test" infrastructure code.

Changes in v2:
Modified code to support only upto 64 bytes as that's the max bytes
used by hash for comparison.

Changes in v1:
Initial changes to support memcmp with support upto 128 bytes.

Signed-off-by: Ravi Kerur 
---
 app/test/Makefile  |   5 +-
 app/test/autotest_data.py  |  19 +
 app/test/test_hash_perf.c  |  36 +-
 app/test/test_memcmp.c | 229 ++
 app/test/test_memcmp_perf.c| 339 
 .../common/include/arch/ppc_64/rte_memcmp.h|  62 ++
 .../common/include/arch/x86/rte_memcmp.h   | 900 +
 lib/librte_eal/common/include/generic/rte_memcmp.h | 175 
 lib/librte_hash/rte_hash.c |  59 +-
 9 files changed, 1789 insertions(+), 35 deletions(-)
 create mode 100644 app/test/test_memcmp.c
 create mode 100644 app/test/test_memcmp_perf.c
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/x86/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/generic/rte_memcmp.h

diff --git a/app/test/Makefile b/app/test/Makefile
index 4aca77c..957e4f1 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -81,6 +81,9 @@ SRCS-y += test_logs.c
 SRCS-y += test_memcpy.c
 SRCS-y += test_memcpy_perf.c

+SRCS-y += test_memcmp.c
+SRCS-y += test_memcmp_perf.c
+
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash.c
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_perf.c

@@ -150,7 +153,7 @@ CFLAGS_test_kni.o += -Wno-deprecated-declarations
 endif
 CFLAGS += -D_GNU_SOURCE

-# Disable VTA for memcpy test
+# Disable VTA for memcpy tests
 ifeq ($(CC), gcc)
 ifeq ($(shell test $(GCC_VERSION) -ge 44 && echo 1), 1)
 CFLAGS_test_memcpy.o += -fno-var-tracking-assignments
diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py
index 618a946..e07f087 100644
--- a/app/test/autotest_data.py
+++ b/app/test/autotest_data.py
@@ -187,6 +187,12 @@ parallel_test_group_list = [
 "Report" : None,
},
{
+"Name" :   "Memcmp autotest",
+"Command" :"memcmp_autotest",
+"Func" :   default_autotest,
+"Report" : None,
+   },
+   {
 "Name" :   "Memzone autotest",
 "Command" :"memzone_autotest",
 "Func" :   default_autotest,
@@ -399,6 +405,19 @@ non_parallel_test_group_list = [
]
 },
 {
+   "Prefix":   "memcmp_perf",
+   "Memory" :  all_sockets(512),
+   "Tests" :
+   [
+   {
+"Name" :   "Memcmp performance autotest",
+"Command" :"memcmp_perf_autotest",
+"Func" :   default_autotest,
+"Report" : None,
+   },
+   ]
+},
+{
"Prefix":   "hash_perf",
"Memory" :  all_sockets(512),
"Tests" :   
diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index 6eabb21..6887629 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -440,7 +440,7 @@ run_single_tbl_perf_test(const struct rte_hash *h, 
hash_operation func,
uint32_t *invalid_pos_count)
 {
uint64_t begin, end, ticks = 0;
-   uint8_t *key = NULL;
+   uint8_t * volatile key = NULL;
uint32_t *bucket_occupancies = NULL;
uint32_t num_buckets, i, j;
int32_t pos;
@@ -547,30 +547,30 @@ run_tbl_perf_test(struct tbl_perf_test_params *params)
case ADD_UPDATE:
num_iterations = params->num_iterations;
params->num_iterations = params->entries;
-   run_single_tbl_perf_test(handle, rte_hash_add_key, params,
-   _occupancy, _pos);
-   params->num_iterations = num_iterations;
ticks = run_single_tbl_perf_test(handle, rte_hash_add_key,
params, _occupancy, _pos);
+   params->num_iterations = num_iterations;
+   ticks += run_single_tbl_perf_test(handle, rte_hash_add_key

[dpdk-dev] [PATCH v3] Implement memcmp using SIMD intrinsics

2015-05-18 Thread Ravi Kerur
Background:
After preliminary discussion with John (Zhihong) and Tim from Intel it was
decided that it would be beneficial to use AVX/SSE intrinsics for memcmp
similar to memcpy that had been implemeneted. In addition, we decided to use
librte_hash as a test candidate to test both functionality and performance.

Further discussions lead to complete functionality implementation of memory
comparison and v3 code reflects that.

Test was conducted on Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz, Ubuntu 14.04,
x86_64, 16GB DDR3 system.

Ravi Kerur (1):
  Implement memcmp using Intel SIMD instrinsics.

 app/test/Makefile  |   5 +-
 app/test/autotest_data.py  |  19 +
 app/test/test_hash_perf.c  |  36 +-
 app/test/test_memcmp.c | 229 ++
 app/test/test_memcmp_perf.c| 339 
 .../common/include/arch/ppc_64/rte_memcmp.h|  62 ++
 .../common/include/arch/x86/rte_memcmp.h   | 900 +
 lib/librte_eal/common/include/generic/rte_memcmp.h | 175 
 lib/librte_hash/rte_hash.c |  59 +-
 9 files changed, 1789 insertions(+), 35 deletions(-)
 create mode 100644 app/test/test_memcmp.c
 create mode 100644 app/test/test_memcmp_perf.c
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/x86/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/generic/rte_memcmp.h

-- 
1.9.1



[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-13 Thread Ravi Kerur
On Wed, May 13, 2015 at 2:03 AM, Bruce Richardson <
bruce.richardson at intel.com> wrote:

> On Tue, May 12, 2015 at 06:16:20PM -0700, Ravi Kerur wrote:
> > On Mon, May 11, 2015 at 3:29 PM, Don Provan  wrote:
> >
> > > I probably shouldn't stick my nose into this, but I can't help myself.
> > >
> > > An experienced programmer will tend to ignore the documentation for
> > > a routine named "blahblah_memcmp" and just assume it functions like
> > > memcmp. Whether or not there's currently a use case in DPDK is
> > > completely irrelevant because as soon as there *is* a use case, some
> > > poor DPDK developer will try to use rte_memcmp for that and may or
> > > may not have a test case that reveals their mistake.
> > >
> >
> > In general I agree with you. However, comparison is a hit(equal) or
> > miss(unequal) is generally the case in networking. I haven't seen cases
> > where "less than" or "greater than" has mattered.
> >
> >
> Agreed that == and != are the common operations. However, if that is what
> is returned from the function - and given other limitations on parameter
> sizes -
> I agree with previous posters that this function needs to have a different
> name
> to rte_memcmp so as to avoid confusion.
>

I will be implementing complete memcmp itself, so probably I will retain
same name.

>
> /Bruce
>
>


[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-13 Thread Ravi Kerur
On Wed, May 13, 2015 at 5:21 AM, Jay Rolette  wrote:

> On Tue, May 12, 2015 at 8:16 PM, Ravi Kerur  wrote:
>
>> On Mon, May 11, 2015 at 3:29 PM, Don Provan  wrote:
>>
>> > I probably shouldn't stick my nose into this, but I can't help myself.
>> >
>> > An experienced programmer will tend to ignore the documentation for
>> > a routine named "blahblah_memcmp" and just assume it functions like
>> > memcmp. Whether or not there's currently a use case in DPDK is
>> > completely irrelevant because as soon as there *is* a use case, some
>> > poor DPDK developer will try to use rte_memcmp for that and may or
>> > may not have a test case that reveals their mistake.
>> >
>>
>> In general I agree with you. However, comparison is a hit(equal) or
>> miss(unequal) is generally the case in networking. I haven't seen cases
>> where "less than" or "greater than" has mattered.
>>
>
> It's useful when you need to make sure packets from both sides of a
> conversation go to the same processing queue/thread. Instead of hashing the
> 5-tuple from the packet as src.ip, dst.ip, src.dport, dst.dport, etc., you
> can use lesser.ip, higher.ip, lesser.sport, higher.dport, etc.
>
> Very common when you are doing deep packet inspection.
>

Thanks for sharing this information.

>
> Jay
>


[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-13 Thread Ravi Kerur
Hi Konstanin,


On Wed, May 13, 2015 at 3:12 AM, Ananyev, Konstantin <
konstantin.ananyev at intel.com> wrote:

> Hi Ravi,
>
> > -Original Message-
> > From: Ananyev, Konstantin
> > Sent: Wednesday, May 13, 2015 11:02 AM
> > To: Ananyev, Konstantin
> > Subject: FW: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE
> instructions.
> >
> >
> >
> > From: Ravi Kerur [mailto:rkerur at gmail.com]
> > Sent: Monday, May 11, 2015 9:47 PM
> > To: Ananyev, Konstantin
> > Cc: dev at dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE
> instructions.
> >
> > Hi Konstantin,
> >
> > On Mon, May 11, 2015 at 12:35 PM, Ananyev, Konstantin <
> konstantin.ananyev at intel.com> wrote:
> >
> > Hi Ravi,
> >
> > >
> > > From: Ravi Kerur [mailto:rkerur at gmail.com]
> > > Sent: Monday, May 11, 2015 6:43 PM
> > > To: Ananyev, Konstantin
> > > Cc: Matt Laswell; dev at dpdk.org
> > > Subject: Re: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE
> instructions.
> > >
> > > Hi Konstantin,
> > >
> > >
> > > On Mon, May 11, 2015 at 2:51 AM, Ananyev, Konstantin <
> konstantin.ananyev at intel.com> wrote:
> > > Hi Ravi,
> > >
> > > > -Original Message-
> > > > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ravi Kerur
> > > > Sent: Friday, May 08, 2015 11:55 PM
> > > > To: Matt Laswell
> > > > Cc: dev at dpdk.org
> > > > Subject: Re: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE
> instructions.
> > > >
> > > > On Fri, May 8, 2015 at 3:29 PM, Matt Laswell 
> wrote:
> > > >
> > > > >
> > > > >
> > > > > On Fri, May 8, 2015 at 4:19 PM, Ravi Kerur 
> wrote:
> > > > >
> > > > >> This patch replaces memcmp in librte_hash with rte_memcmp which is
> > > > >> implemented with AVX/SSE instructions.
> > > > >>
> > > > >> +static inline int
> > > > >> +rte_memcmp(const void *_src_1, const void *_src_2, size_t n)
> > > > >> +{
> > > > >> +   const uint8_t *src_1 = (const uint8_t *)_src_1;
> > > > >> +   const uint8_t *src_2 = (const uint8_t *)_src_2;
> > > > >> +   int ret = 0;
> > > > >> +
> > > > >> +   if (n & 0x80)
> > > > >> +   return rte_cmp128(src_1, src_2);
> > > > >> +
> > > > >> +   if (n & 0x40)
> > > > >> +   return rte_cmp64(src_1, src_2);
> > > > >> +
> > > > >> +   if (n & 0x20) {
> > > > >> +   ret = rte_cmp32(src_1, src_2);
> > > > >> +   n -= 0x20;
> > > > >> +   src_1 += 0x20;
> > > > >> +   src_2 += 0x20;
> > > > >> +   }
> > > > >>
> > > > >>
> > > > > Pardon me for butting in, but this seems incorrect for the first
> two cases
> > > > > listed above, as the function as written will only compare the
> first 128 or
> > > > > 64 bytes of each source and return the result.  The pattern
> expressed in
> > > > > the 32 byte case appears more correct, as it compares the first 32
> bytes
> > > > > and then lets later pieces of the function handle the smaller
> remaining
> > > > > bits of the sources. Also, if this function is to handle
> arbitrarily large
> > > > > source data, the 128 byte case needs to be in a loop.
> > > > >
> > > > > What am I missing?
> > > > >
> > > >
> > > > Current max hash key length supported is 64 bytes, hence no
> comparison is
> > > > done after 64 bytes. 128 bytes comparison is added to measure
> performance
> > > > only and there is no use-case as of now. With the current use-cases
> its not
> > > > required but if there is a need to handle large arbitrary data upto
> 128
> > > > bytes it can be modified.
> > > So on x86 let say rte_memcmp(k1, k2, 65) might produce invalid
> results, right?
> > > While on PPC will work as expected (as it calls memcpu underneath)?
> > > That looks really weird to me.
> > > If you plan to use rte_memcmp only for hash comparisons, then probably

[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-13 Thread Ravi Kerur
On Wed, May 13, 2015 at 12:22 AM, Linhaifeng  wrote:

>
>
> On 2015/5/13 9:18, Ravi Kerur wrote:
> > If you can wait until Thursday I will probably send v3 patch which will
> > have full memcmp support.
>
> Ok, I'd like to test it:)
>
> >
> > In your program try with volatile pointer and see if it helps.
>
> like "volatile uint8_t *src, *dst" ?
>

uint8_t * volatile src


[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-12 Thread Ravi Kerur
Hi Linhaifeng,


On Tue, May 12, 2015 at 1:13 AM, Linhaifeng  wrote:

> Hi, Ravi Kerur
>
> On 2015/5/9 5:19, Ravi Kerur wrote:
> > Preliminary results on Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz, Ubuntu
> > 14.04 x86_64 shows comparisons using AVX/SSE instructions taking 1/3rd
> > CPU ticks for 16, 32, 48 and 64 bytes comparison. In addition,
>
> I had write a program to test rte_memcmp and I have a question about the
> result.
> Why cost same CPU ticks for 128 256 512 1024 1500 bytes? Is there any
> problem in
> my test?
>
>
If you can wait until Thursday I will probably send v3 patch which will
have full memcmp support.

In your program try with volatile pointer and see if it helps.

>
> [root at localhost test]# gcc avx_test.c -O3  -I
> /data/linhf/v2r2c00/open-source/dpdk/dpdk-2.0.0/x86_64-native-linuxapp-gcc/include/
> -mavx2 -DRTE_MACHINE_CPUFLAG_AVX2
> [root at localhost test]# ./a.out 0
> each test run 1 times
> copy 16 bytes costs average 7(rte_memcmp) 10(memcmp) ticks
> copy 32 bytes costs average 9(rte_memcmp) 11(memcmp) ticks
> copy 64 bytes costs average 6(rte_memcmp) 13(memcmp) ticks
> copy 128 bytes costs average 11(rte_memcmp) 14(memcmp) ticks
> copy 256 bytes costs average 9(rte_memcmp) 14(memcmp) ticks
> copy 512 bytes costs average 9(rte_memcmp) 14(memcmp) ticks
> copy 1024 bytes costs average 9(rte_memcmp) 14(memcmp) ticks
> copy 1500 bytes costs average 11(rte_memcmp) 14(memcmp) ticks
> [root at localhost test]# ./a.out 1
> each test run 1 times
> copy 16 bytes costs average 2(rte_memcpy) 10(memcpy) ticks
> copy 32 bytes costs average 2(rte_memcpy) 10(memcpy) ticks
> copy 64 bytes costs average 3(rte_memcpy) 10(memcpy) ticks
> copy 128 bytes costs average 7(rte_memcpy) 12(memcpy) ticks
> copy 256 bytes costs average 9(rte_memcpy) 23(memcpy) ticks
> copy 512 bytes costs average 14(rte_memcpy) 34(memcpy) ticks
> copy 1024 bytes costs average 37(rte_memcpy) 61(memcpy) ticks
> copy 1500 bytes costs average 62(rte_memcpy) 87(memcpy) ticks
>
>
> Here is my program:
>
> #include 
> #include 
> #include 
> #include 
> #include 
>
> #define TIMES 1L
>
> void test_memcpy(size_t n)
> {
> uint64_t start, end, i, start2, end2;
> uint8_t *src, *dst;
>
> src = (uint8_t*)malloc(n * sizeof(uint8_t));
> dst = (uint8_t*)malloc(n * sizeof(uint8_t));
>
> start = rte_rdtsc();
> for (i = 0; i < TIMES; i++) {
> rte_memcpy(dst, src, n);
> }
> end = rte_rdtsc();
>
> start2 = rte_rdtsc();
> for (i = 0; i < TIMES; i++) {
> memcpy(dst, src, n);
> }
> end2 = rte_rdtsc();
>
>
> free(src);
> free(dst);
>
> printf("copy %u bytes costs average %llu(rte_memcpy) %llu(memcpy)
> ticks\n", n, (end - start)/TIMES, (end2 - start2)/TIMES);
> }
>
> int test_memcmp(size_t n)
> {
> uint64_t start, end, i, start2, end2, j;
> uint8_t *src, *dst;
> int *ret;
>
> src = (uint8_t*)malloc(n * sizeof(uint8_t));
> dst = (uint8_t*)malloc(n * sizeof(uint8_t));
> ret = (int*)malloc(TIMES * sizeof(int));
>
> start = rte_rdtsc();
> for (i = 0; i < TIMES; i++) {
> ret[i] = rte_memcmp(dst, src, n);
> }
> end = rte_rdtsc();
>
> start2 = rte_rdtsc();
> for (i = 0; i < TIMES; i++) {
> ret[i] = memcmp(dst, src, n);
> }
> end2 = rte_rdtsc();
>
> // avoid gcc to optimize memcmp
> for (i = 0; i < TIMES; i++) {
> t += ret[i];
> }
>
> free(src);
> free(dst);
>
> printf("copy %u bytes costs average %llu(rte_memcmp) %llu(memcmp)
> ticks\n", n, (end - start)/TIMES, (end2 - start2)/TIMES);
> return t;
> }
>
>
>
>
> int main(int narg, char** args)
> {
> printf("each test run %llu times\n", TIMES);
>
> if (narg < 2) {
> printf("usage:./avx_test 0/1 1:test memcpy 0:test
> memcmp\n");
> return -1;
> }
>
> if (atoi(args[1])) {
> test_memcpy(16);
> test_memcpy(32);
> test_memcpy(64);
> test_memcpy(128);
> test_memcpy(256);
> test_memcpy(512);
> test_memcpy(1024);
> test_memcpy(1500);
> } else {
> test_memcmp(16);
> test_memcmp(32);
> test_memcmp(64);
> test_memcmp(128);
> test_memcmp(256);
> test_memcmp(512);
> test_memcmp(1024);
> test_memcmp(1500);
> }
> }
>
>
>
>
>
>
>


[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-12 Thread Ravi Kerur
On Mon, May 11, 2015 at 3:29 PM, Don Provan  wrote:

> I probably shouldn't stick my nose into this, but I can't help myself.
>
> An experienced programmer will tend to ignore the documentation for
> a routine named "blahblah_memcmp" and just assume it functions like
> memcmp. Whether or not there's currently a use case in DPDK is
> completely irrelevant because as soon as there *is* a use case, some
> poor DPDK developer will try to use rte_memcmp for that and may or
> may not have a test case that reveals their mistake.
>

In general I agree with you. However, comparison is a hit(equal) or
miss(unequal) is generally the case in networking. I haven't seen cases
where "less than" or "greater than" has mattered.


>
> The term "compare" suggests checking for larger or smaller.
> If you want to check for equality, use "equal" or "eq" in the name
> and return true if they're equal. But personally, I'd compare unless
> there was a good reason not to. Indeed, I would just implement
> full memcmp functionality and be done with it, even if that meant
> using my fancy new assembly code for the cases I handle and then
> calling memcmp itself for the cases I didn't.
>
> Agreed, I will look into implementing full functionality.


> If a routine that appears to take an arbitrary size doesn't, the name
> should in some manner reflect what sizes it takes. Better would be
> for a routine that only handles specific sizes to be split into versions
> that only take fixed sizes, but I don't know enough about your use
> cases to say whether that makes sense here.
>
>
Users of rte_memcmp will be existing dpdk test and library code.

-don provan
> dprovan at bivio.net
>
> -Original Message-
> From: Ravi Kerur [mailto:rkerur at gmail.com]
> Sent: Monday, May 11, 2015 1:47 PM
> To: Ananyev, Konstantin
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE
> instructions.
>
> ...
> Following memcmp semantics is not hard but there are no use-cases for it
> in DPDK currently. Keeping it specific to DPDK usage simplifies code as
> well.
> I can change the name to "rte_compare" and add comments to the function.
> Will it work?
> ...
>
>


[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-11 Thread Ravi Kerur
Hi Konstantin,


On Mon, May 11, 2015 at 12:35 PM, Ananyev, Konstantin <
konstantin.ananyev at intel.com> wrote:

>
> Hi Ravi,
>
> >
> > From: Ravi Kerur [mailto:rkerur at gmail.com]
> > Sent: Monday, May 11, 2015 6:43 PM
> > To: Ananyev, Konstantin
> > Cc: Matt Laswell; dev at dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE
> instructions.
> >
> > Hi Konstantin,
> >
> >
> > On Mon, May 11, 2015 at 2:51 AM, Ananyev, Konstantin <
> konstantin.ananyev at intel.com> wrote:
> > Hi Ravi,
> >
> > > -Original Message-
> > > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ravi Kerur
> > > Sent: Friday, May 08, 2015 11:55 PM
> > > To: Matt Laswell
> > > Cc: dev at dpdk.org
> > > Subject: Re: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE
> instructions.
> > >
> > > On Fri, May 8, 2015 at 3:29 PM, Matt Laswell 
> wrote:
> > >
> > > >
> > > >
> > > > On Fri, May 8, 2015 at 4:19 PM, Ravi Kerur  wrote:
> > > >
> > > >> This patch replaces memcmp in librte_hash with rte_memcmp which is
> > > >> implemented with AVX/SSE instructions.
> > > >>
> > > >> +static inline int
> > > >> +rte_memcmp(const void *_src_1, const void *_src_2, size_t n)
> > > >> +{
> > > >> +   const uint8_t *src_1 = (const uint8_t *)_src_1;
> > > >> +   const uint8_t *src_2 = (const uint8_t *)_src_2;
> > > >> +   int ret = 0;
> > > >> +
> > > >> +   if (n & 0x80)
> > > >> +   return rte_cmp128(src_1, src_2);
> > > >> +
> > > >> +   if (n & 0x40)
> > > >> +   return rte_cmp64(src_1, src_2);
> > > >> +
> > > >> +   if (n & 0x20) {
> > > >> +   ret = rte_cmp32(src_1, src_2);
> > > >> +   n -= 0x20;
> > > >> +   src_1 += 0x20;
> > > >> +   src_2 += 0x20;
> > > >> +   }
> > > >>
> > > >>
> > > > Pardon me for butting in, but this seems incorrect for the first two
> cases
> > > > listed above, as the function as written will only compare the first
> 128 or
> > > > 64 bytes of each source and return the result.  The pattern
> expressed in
> > > > the 32 byte case appears more correct, as it compares the first 32
> bytes
> > > > and then lets later pieces of the function handle the smaller
> remaining
> > > > bits of the sources. Also, if this function is to handle arbitrarily
> large
> > > > source data, the 128 byte case needs to be in a loop.
> > > >
> > > > What am I missing?
> > > >
> > >
> > > Current max hash key length supported is 64 bytes, hence no comparison
> is
> > > done after 64 bytes. 128 bytes comparison is added to measure
> performance
> > > only and there is no use-case as of now. With the current use-cases
> its not
> > > required but if there is a need to handle large arbitrary data upto 128
> > > bytes it can be modified.
> > So on x86 let say rte_memcmp(k1, k2, 65) might produce invalid results,
> right?
> > While on PPC will work as expected (as it calls memcpu underneath)?
> > That looks really weird to me.
> > If you plan to use rte_memcmp only for hash comparisons, then probably
> > you should put it somewhere into librte_hash and name it accordingly:
> rte_hash_key_cmp() or something.
> > And put a big comment around it, that it only works with particular
> lengths.
> > If you want it to be a generic function inside EAL, then it probably
> need to handle different lengths properly
> > on all supported architectures.
> > Konstantin
> >
> >
> > Let me just explain it here and probably add it to document as well.
> >
> > rte_memcmp is not
> >
> > 1. a replacement to memcmp
> >
> > 2.  restricted to hash key comparison
> >
> > rte_memcmp is
> >
> > 1. optimized comparison for 16 to 128 bytes, v1 patch series had this
> support. Changed some of the logic in v2 due to concerns raised
> > for unavailable use-cases beyond 64 bytes comparison.
>
> From what I see in v2 it supposed to work correctly for len in [0,64] and
> len=128, right?
> Not sure I get it: so for v1 it was able to handle any length correctly,
> but then y

[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-11 Thread Ravi Kerur
Hi Konstantin,


On Mon, May 11, 2015 at 2:51 AM, Ananyev, Konstantin <
konstantin.ananyev at intel.com> wrote:

> Hi Ravi,
>
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ravi Kerur
> > Sent: Friday, May 08, 2015 11:55 PM
> > To: Matt Laswell
> > Cc: dev at dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE
> instructions.
> >
> > On Fri, May 8, 2015 at 3:29 PM, Matt Laswell 
> wrote:
> >
> > >
> > >
> > > On Fri, May 8, 2015 at 4:19 PM, Ravi Kerur  wrote:
> > >
> > >> This patch replaces memcmp in librte_hash with rte_memcmp which is
> > >> implemented with AVX/SSE instructions.
> > >>
> > >> +static inline int
> > >> +rte_memcmp(const void *_src_1, const void *_src_2, size_t n)
> > >> +{
> > >> +   const uint8_t *src_1 = (const uint8_t *)_src_1;
> > >> +   const uint8_t *src_2 = (const uint8_t *)_src_2;
> > >> +   int ret = 0;
> > >> +
> > >> +   if (n & 0x80)
> > >> +   return rte_cmp128(src_1, src_2);
> > >> +
> > >> +   if (n & 0x40)
> > >> +   return rte_cmp64(src_1, src_2);
> > >> +
> > >> +   if (n & 0x20) {
> > >> +   ret = rte_cmp32(src_1, src_2);
> > >> +   n -= 0x20;
> > >> +   src_1 += 0x20;
> > >> +   src_2 += 0x20;
> > >> +   }
> > >>
> > >>
> > > Pardon me for butting in, but this seems incorrect for the first two
> cases
> > > listed above, as the function as written will only compare the first
> 128 or
> > > 64 bytes of each source and return the result.  The pattern expressed
> in
> > > the 32 byte case appears more correct, as it compares the first 32
> bytes
> > > and then lets later pieces of the function handle the smaller remaining
> > > bits of the sources. Also, if this function is to handle arbitrarily
> large
> > > source data, the 128 byte case needs to be in a loop.
> > >
> > > What am I missing?
> > >
> >
> > Current max hash key length supported is 64 bytes, hence no comparison is
> > done after 64 bytes. 128 bytes comparison is added to measure performance
> > only and there is no use-case as of now. With the current use-cases its
> not
> > required but if there is a need to handle large arbitrary data upto 128
> > bytes it can be modified.
>
> So on x86 let say rte_memcmp(k1, k2, 65) might produce invalid results,
> right?
> While on PPC will work as expected (as it calls memcpu underneath)?
> That looks really weird to me.
> If you plan to use rte_memcmp only for hash comparisons, then probably
> you should put it somewhere into librte_hash and name it accordingly:
> rte_hash_key_cmp() or something.
> And put a big comment around it, that it only works with particular
> lengths.
> If you want it to be a generic function inside EAL, then it probably need
> to handle different lengths properly
> on all supported architectures.
> Konstantin
>
>
Let me just explain it here and probably add it to document as well.

rte_memcmp is not

1. a replacement to memcmp

2.  restricted to hash key comparison

rte_memcmp is

1. optimized comparison for 16 to 128 bytes, v1 patch series had this
support. Changed some of the logic in v2 due to concerns raised for
unavailable use-cases beyond 64 bytes comparison. With minor tuning over
the weekend I am able to get better performance for anything between 16 to
128 bytes comparison.

2. will be specific to DPDK  i.e. currently all memcmp usage in DPDK are
for equality or inequality hence "less than" or "greater than"
implementation in rte_memcmp doesn't make sense and will be removed in
subsequent patches, it will return 0 or 1 for equal/unequal cases.

rte_hash will be the first candidate to move to rte_memcmp and subsequently
rte_lpm6 which uses 16 bytes comparison will be moved

Later on RING_SIZE which uses large size for comparison will be moved. I am
currently studying/understanding that logic and will make changes to
rte_memcmp to support that.

I don't want to make lot of changes in one shot and see that patch series
die a slow death with no takers.

Thanks,
Ravi

>
> > >
> > > --
> > > Matt Laswell
> > > infinite io, inc.
> > > laswell at infiniteio.com
> > >
> > >
>


[dpdk-dev] [PATCH v2] Clean up rte_memcpy.h file

2015-05-08 Thread Ravi Kerur
Any inputs here? No functionality change just cleanup. I have run "make
test" and "memcpy_perf_autotest". I have not noticed any changes in numbers.

On Mon, Apr 20, 2015 at 1:33 PM, Ravi Kerur  wrote:

> Remove unnecessary type casting in functions.
>
> Tested on Ubuntu (14.04 x86_64) with "make test".
> "make test" results match the results with baseline.
> "Memcpy perf" results match the results with baseline.
>
> Signed-off-by: Ravi Kerur 
> ---
>  .../common/include/arch/x86/rte_memcpy.h   | 340
> +++--
>  1 file changed, 175 insertions(+), 165 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 6a57426..839d4ec 100644
> --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
> +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
> @@ -106,8 +106,8 @@ rte_mov32(uint8_t *dst, const uint8_t *src)
>  static inline void
>  rte_mov64(uint8_t *dst, const uint8_t *src)
>  {
> -   rte_mov32((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32);
> -   rte_mov32((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 * 32);
> +   rte_mov32(dst + 0 * 32, src + 0 * 32);
> +   rte_mov32(dst + 1 * 32, src + 1 * 32);
>  }
>
>  /**
> @@ -117,10 +117,10 @@ rte_mov64(uint8_t *dst, const uint8_t *src)
>  static inline void
>  rte_mov128(uint8_t *dst, const uint8_t *src)
>  {
> -   rte_mov32((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32);
> -   rte_mov32((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 * 32);
> -   rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32);
> -   rte_mov32((uint8_t *)dst + 3 * 32, (const uint8_t *)src + 3 * 32);
> +   rte_mov32(dst + 0 * 32, src + 0 * 32);
> +   rte_mov32(dst + 1 * 32, src + 1 * 32);
> +   rte_mov32(dst + 2 * 32, src + 2 * 32);
> +   rte_mov32(dst + 3 * 32, src + 3 * 32);
>  }
>
>  /**
> @@ -130,14 +130,14 @@ rte_mov128(uint8_t *dst, const uint8_t *src)
>  static inline void
>  rte_mov256(uint8_t *dst, const uint8_t *src)
>  {
> -   rte_mov32((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32);
> -   rte_mov32((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 * 32);
> -   rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32);
> -   rte_mov32((uint8_t *)dst + 3 * 32, (const uint8_t *)src + 3 * 32);
> -   rte_mov32((uint8_t *)dst + 4 * 32, (const uint8_t *)src + 4 * 32);
> -   rte_mov32((uint8_t *)dst + 5 * 32, (const uint8_t *)src + 5 * 32);
> -   rte_mov32((uint8_t *)dst + 6 * 32, (const uint8_t *)src + 6 * 32);
> -   rte_mov32((uint8_t *)dst + 7 * 32, (const uint8_t *)src + 7 * 32);
> +   rte_mov32(dst + 0 * 32, src + 0 * 32);
> +   rte_mov32(dst + 1 * 32, src + 1 * 32);
> +   rte_mov32(dst + 2 * 32, src + 2 * 32);
> +   rte_mov32(dst + 3 * 32, src + 3 * 32);
> +   rte_mov32(dst + 4 * 32, src + 4 * 32);
> +   rte_mov32(dst + 5 * 32, src + 5 * 32);
> +   rte_mov32(dst + 6 * 32, src + 6 * 32);
> +   rte_mov32(dst + 7 * 32, src + 7 * 32);
>  }
>
>  /**
> @@ -150,13 +150,16 @@ rte_mov64blocks(uint8_t *dst, const uint8_t *src,
> size_t n)
> __m256i ymm0, ymm1;
>
> while (n >= 64) {
> -   ymm0 = _mm256_loadu_si256((const __m256i *)((const uint8_t
> *)src + 0 * 32));
> +
> +   ymm0 = _mm256_loadu_si256((const __m256i *)(src + 0 * 32));
> +   ymm1 = _mm256_loadu_si256((const __m256i *)(src + 1 * 32));
> +
> +   _mm256_storeu_si256((__m256i *)(dst + 0 * 32), ymm0);
> +   _mm256_storeu_si256((__m256i *)(dst + 1 * 32), ymm1);
> +
> n -= 64;
> -   ymm1 = _mm256_loadu_si256((const __m256i *)((const uint8_t
> *)src + 1 * 32));
> -   src = (const uint8_t *)src + 64;
> -   _mm256_storeu_si256((__m256i *)((uint8_t *)dst + 0 * 32),
> ymm0);
> -   _mm256_storeu_si256((__m256i *)((uint8_t *)dst + 1 * 32),
> ymm1);
> -   dst = (uint8_t *)dst + 64;
> +   src = src + 64;
> +   dst = dst + 64;
> }
>  }
>
> @@ -170,34 +173,39 @@ rte_mov256blocks(uint8_t *dst, const uint8_t *src,
> size_t n)
> __m256i ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7;
>
> while (n >= 256) {
> -   ymm0 = _mm256_loadu_si256((const __m256i *)((const uint8_t
> *)src + 0 * 32));
> +
> +   ymm0 = _mm256_loadu_si256((const __m256i *)(src + 0 * 32));
> +   ymm1 = _mm256_loadu_si256((const __m256i *)(src + 1 * 32));
> +   ymm2 = _mm256_loadu_si2

[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-08 Thread Ravi Kerur
On Fri, May 8, 2015 at 3:29 PM, Matt Laswell  wrote:

>
>
> On Fri, May 8, 2015 at 4:19 PM, Ravi Kerur  wrote:
>
>> This patch replaces memcmp in librte_hash with rte_memcmp which is
>> implemented with AVX/SSE instructions.
>>
>> +static inline int
>> +rte_memcmp(const void *_src_1, const void *_src_2, size_t n)
>> +{
>> +   const uint8_t *src_1 = (const uint8_t *)_src_1;
>> +   const uint8_t *src_2 = (const uint8_t *)_src_2;
>> +   int ret = 0;
>> +
>> +   if (n & 0x80)
>> +   return rte_cmp128(src_1, src_2);
>> +
>> +   if (n & 0x40)
>> +   return rte_cmp64(src_1, src_2);
>> +
>> +   if (n & 0x20) {
>> +   ret = rte_cmp32(src_1, src_2);
>> +   n -= 0x20;
>> +   src_1 += 0x20;
>> +   src_2 += 0x20;
>> +   }
>>
>>
> Pardon me for butting in, but this seems incorrect for the first two cases
> listed above, as the function as written will only compare the first 128 or
> 64 bytes of each source and return the result.  The pattern expressed in
> the 32 byte case appears more correct, as it compares the first 32 bytes
> and then lets later pieces of the function handle the smaller remaining
> bits of the sources. Also, if this function is to handle arbitrarily large
> source data, the 128 byte case needs to be in a loop.
>
> What am I missing?
>

Current max hash key length supported is 64 bytes, hence no comparison is
done after 64 bytes. 128 bytes comparison is added to measure performance
only and there is no use-case as of now. With the current use-cases its not
required but if there is a need to handle large arbitrary data upto 128
bytes it can be modified.

>
> --
> Matt Laswell
> infinite io, inc.
> laswell at infiniteio.com
>
>


[dpdk-dev] [PATCH v2] Implement memcmp using AVX/SSE instructions.

2015-05-08 Thread Ravi Kerur
This patch replaces memcmp in librte_hash with rte_memcmp which is
implemented with AVX/SSE instructions.

Preliminary results on Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz, Ubuntu
14.04 x86_64 shows comparisons using AVX/SSE instructions taking 1/3rd
CPU ticks for 16, 32, 48 and 64 bytes comparison. In addition,
hash_perf_autotest results shows using new comparison function results in
faster completion of hash operations than existing memcmp in all categories.

Signed-off-by: Ravi Kerur 
---
 app/test/test_hash_perf.c  |  36 +-
 .../common/include/arch/ppc_64/rte_memcmp.h|  62 +++
 .../common/include/arch/x86/rte_memcmp.h   | 421 +
 lib/librte_eal/common/include/generic/rte_memcmp.h | 131 +++
 lib/librte_hash/rte_hash.c |  59 ++-
 5 files changed, 675 insertions(+), 34 deletions(-)
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/x86/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/generic/rte_memcmp.h

diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index 6eabb21..6887629 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -440,7 +440,7 @@ run_single_tbl_perf_test(const struct rte_hash *h, 
hash_operation func,
uint32_t *invalid_pos_count)
 {
uint64_t begin, end, ticks = 0;
-   uint8_t *key = NULL;
+   uint8_t * volatile key = NULL;
uint32_t *bucket_occupancies = NULL;
uint32_t num_buckets, i, j;
int32_t pos;
@@ -547,30 +547,30 @@ run_tbl_perf_test(struct tbl_perf_test_params *params)
case ADD_UPDATE:
num_iterations = params->num_iterations;
params->num_iterations = params->entries;
-   run_single_tbl_perf_test(handle, rte_hash_add_key, params,
-   _occupancy, _pos);
-   params->num_iterations = num_iterations;
ticks = run_single_tbl_perf_test(handle, rte_hash_add_key,
params, _occupancy, _pos);
+   params->num_iterations = num_iterations;
+   ticks += run_single_tbl_perf_test(handle, rte_hash_add_key,
+   params, _occupancy, _pos);
break;
case DELETE:
num_iterations = params->num_iterations;
params->num_iterations = params->entries;
-   run_single_tbl_perf_test(handle, rte_hash_add_key, params,
-   _occupancy, _pos);
+   ticks = run_single_tbl_perf_test(handle, rte_hash_add_key,
+   params, _occupancy, _pos);

params->num_iterations = num_iterations;
-   ticks = run_single_tbl_perf_test(handle, rte_hash_del_key,
+   ticks += run_single_tbl_perf_test(handle, rte_hash_del_key,
params, _occupancy, _pos);
break;
case LOOKUP:
num_iterations = params->num_iterations;
params->num_iterations = params->entries;
-   run_single_tbl_perf_test(handle, rte_hash_add_key, params,
-   _occupancy, _pos);
+   ticks = run_single_tbl_perf_test(handle, rte_hash_add_key,
+   params, _occupancy, _pos);

params->num_iterations = num_iterations;
-   ticks = run_single_tbl_perf_test(handle, rte_hash_lookup,
+   ticks += run_single_tbl_perf_test(handle, rte_hash_lookup,
params, _occupancy, _pos);
break;
default: return -1;
@@ -623,10 +623,15 @@ static int run_all_tbl_perf_tests(void)
 static void run_hash_func_test(rte_hash_function f, uint32_t init_val,
uint32_t key_len)
 {
-   static uint8_t key[RTE_HASH_KEY_LENGTH_MAX];
+   static uint8_t * volatile key;
uint64_t ticks = 0, start, end;
unsigned i, j;

+   key = rte_zmalloc("func hash key",
+ key_len * sizeof(uint8_t), 16);
+   if (key == NULL)
+   return;
+
for (i = 0; i < HASHTEST_ITERATIONS; i++) {

for (j = 0; j < key_len; j++)
@@ -638,8 +643,11 @@ static void run_hash_func_test(rte_hash_function f, 
uint32_t init_val,
ticks += end - start;
}

-   printf("%-12s, %-18u, %-13u, %.02f\n", get_hash_name(f), (unsigned) 
key_len,
-   (unsigned) init_val, (double)ticks / 
HASHTEST_ITERATIONS);
+   rte_free(key);
+
+   printf("%-12s, %-18u, %-13u, %.02f\n",
+   get_hash_name(f), (unsigned) key_len, (unsigned) init_val,
+   (double)ticks / HASHTEST_ITERATIONS);
 }

 /*
@@ -687,7 +695,7 @@ fbk_hash_perf_test(void)
   

[dpdk-dev] [PATCH v2] Implement rte_memcmp with AVX/SSE instructions.

2015-05-08 Thread Ravi Kerur
 , 0 
  , 0.04   , 185.90
jhash   , Lookup , 16  , 1048576, 8 , 0 
  , 0.08   , 201.35
jhash   , Lookup , 16  , 1048576, 16, 0 
  , 0.15   , 223.54

Ravi Kerur (1):
  Implement memcmp using AVX/SSE instructions.

 app/test/test_hash_perf.c  |  36 +-
 .../common/include/arch/ppc_64/rte_memcmp.h|  62 +++
 .../common/include/arch/x86/rte_memcmp.h   | 421 +
 lib/librte_eal/common/include/generic/rte_memcmp.h | 131 +++
 lib/librte_hash/rte_hash.c |  59 ++-
 5 files changed, 675 insertions(+), 34 deletions(-)
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/arch/x86/rte_memcmp.h
 create mode 100644 lib/librte_eal/common/include/generic/rte_memcmp.h

-- 
1.9.1



[dpdk-dev] [PATCH] Implement memcmp using AVX/SSE instructio

2015-05-05 Thread Ravi Kerur
On Thu, Apr 23, 2015 at 3:26 PM, Ravi Kerur  wrote:

>
>
> On Thu, Apr 23, 2015 at 7:00 AM, Bruce Richardson <
> bruce.richardson at intel.com> wrote:
>
>> On Thu, Apr 23, 2015 at 06:53:44AM -0700, Ravi Kerur wrote:
>> > On Thu, Apr 23, 2015 at 2:23 AM, Ananyev, Konstantin <
>> > konstantin.ananyev at intel.com> wrote:
>> >
>> > >
>> > >
>> > > > -Original Message-
>> > > > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Bruce
>> Richardson
>> > > > Sent: Thursday, April 23, 2015 9:12 AM
>> > > > To: Wodkowski, PawelX
>> > > > Cc: dev at dpdk.org
>> > > > Subject: Re: [dpdk-dev] [PATCH] Implement memcmp using AVX/SSE
>> instructio
>> > > >
>> > > > On Thu, Apr 23, 2015 at 09:24:52AM +0200, Pawel Wodkowski wrote:
>> > > > > On 2015-04-22 17:33, Ravi Kerur wrote:
>> > > > > >+/**
>> > > > > >+ * Compare bytes between two locations. The locations must not
>> > > overlap.
>> > > > > >+ *
>> > > > > >+ * @note This is implemented as a macro, so it's address should
>> not
>> > > be taken
>> > > > > >+ * and care is needed as parameter expressions may be evaluated
>> > > multiple times.
>> > > > > >+ *
>> > > > > >+ * @param src_1
>> > > > > >+ *   Pointer to the first source of the data.
>> > > > > >+ * @param src_2
>> > > > > >+ *   Pointer to the second source of the data.
>> > > > > >+ * @param n
>> > > > > >+ *   Number of bytes to compare.
>> > > > > >+ * @return
>> > > > > >+ *   true if equal otherwise false.
>> > > > > >+ */
>> > > > > >+static inline bool
>> > > > > >+rte_memcmp(const void *src_1, const void *src,
>> > > > > >+  size_t n) __attribute__((always_inline));
>> > > > > You are exposing this as public API, so I think you should follow
>> > > > > description bellow or not call this _memcmp_
>> > > > >
>> > > > > int memcmp(const void *s1, const void *s2, size_t n);
>> > > > >
>> > > > > The memcmp() function returns an integer less than, equal  to,  or
>> > > greater
>> > > > > than
>> > > > >zero  if  the  first  n  bytes  of s1 is found,
>> respectively,
>> > > to be
>> > > > > less than, to
>> > > > >match, or be greater than the first n bytes of s2.
>> > > > >
>> > > >
>> > > > +1 to this point.
>> > > >
>> > > > Also, if I read your quoted performance numbers in your earlier mail
>> > > correctly,
>> > > > we are only looking at a 1-4% performance increase. Is the
>> additional
>> > > code to
>> > > > maintain worth the benefit?
>> > >
>> > > Yep, same thought here, is it really worth it?
>> > > Konstantin
>> > >
>> > > >
>> > > > /Bruce
>> > > >
>> > > > > --
>> > > > > Pawel
>> > >
>> >
>> > I think I haven't exploited every thing x86 has to offer to improve
>> > performance. I am looking for inputs. Until we have exhausted all
>> avenues I
>> > don't want to drop it. One thing I have noticed is that bigger key size
>> > gets better performance numbers. I plan to re-run perf tests with 64 and
>> > 128 bytes key size and will report back. Any other avenues to try out
>> > please let me know I will give it a shot.
>> >
>> > Thanks,
>> > Ravi
>>
>> Hi Ravi,
>>
>> are 128 byte comparisons realistic? An IPv6 5-tuple with double vlan tags
>> is still
>> only 41 bytes, or 48 with some padding added?
>> While for a memcpy function, you can see cases where you are going to
>> copy a whole
>> packet, meaning that sizes of 128B+ (up to multiple k) are realistic,
>> it's harder
>> to see that for a compare function.
>>
>> In any case, we await the results of your further optimization work to
>> see how
>> that goes.
>>
>>
>
Actually I was looking at wrong numbers. Wrote couple of sample programs
and found that memory comparison w

[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-30 Thread Ravi Kerur
On Thu, Apr 30, 2015 at 9:00 AM, Neil Horman  wrote:

> On Wed, Apr 29, 2015 at 10:47:04AM -0700, Ravi Kerur wrote:
> > > > I tried to run validate-abi.sh on BSD but ran into errors. If there
> is a
> > > > way to check against BSD please let me know.
> > > >
> > > The ABI checker should work on BSD as far as I know, since it only
> relies
> > > on
> > > dwarf information in the output binary.  What errors are you seeing?
> > >
> >
> > dpdk-bsd:/home/rkerur/dpdk-validate-abi-1/dpdk # sh
> > ./scripts/validate-abi.sh v2.0.0-rc3 v2.0.0-abi
> x86_64-native-bsdapp-clang
> > mktemp: illegal option -- p
> Ah, bsd mktemp doesn't support the -p option.  I'll see if I can fix that.
>

I think there are couple of other issues I found

freeBSD sed is different from Linux (GNU sed) and I get following errors
with the script

"sed 1 command c expects \ followed by text".

I have to use gsed (GNU sed) in freeBSD to get rid of that error and
similarly freeBSD uses gmake instead of make.  I have made those minor
changes and sending them with this email as an attachment.


> > usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
> >mktemp [-d] [-q] [-u] -t prefix
> > Cant find abi-compliance-checker utility
> >
> > abi-compliance-checker is installed as shown below.
> >
> > dpdk-bsd:/home/rkerur/dpdk-validate-abi-1/dpdk # pkg install
> > devel/abi-compliance-checker
> > Updating FreeBSD repository catalogue...
> > FreeBSD repository is up-to-date.
> > All repositories are up-to-date.
> > Checking integrity... done (0 conflicting)
> > The most recent version of packages are already installed
> >
>
> Whats the path for abi-compliance checker there?  It would seem that the
> binary
> isn't in your path, as which isn't locating it.
>

I am using regular freeBSD port install which doesn't install in any
/usr/bin or /usr/local/bin. I finally decided to install both abi-dumper
and abi-compliance-checker from source, compile and install it in correct
directory. Above error is fixed after that, however, abi utilities use
"eu-readelf" and I can't find that utility to install in freeBSD. I get
following errors

ERROR: can't find "eu-readelf" command

freeBSD has only readelf. Please let me know if there is a way to get rid
of this error.

Thanks,
Ravi

>
> > >
> > > Neil
> > >
> > >
>


[dpdk-dev] gmake test on freeBSD

2015-04-29 Thread Ravi Kerur
On Wed, Apr 29, 2015 at 1:29 AM, Bruce Richardson <
bruce.richardson at intel.com> wrote:

> On Tue, Apr 28, 2015 at 06:15:53PM -0700, Ravi Kerur wrote:
> > DPDK team,
> >
> > Is there a automated tests to run on freeBSD similar to Linux (make
> test).
> >
> > I ran "gmake test T=x86_64-native-bsdapp-clang CC=clang" I get following
> > output
> >
> > /usr/home/rkerur/dpdk-validate-abi-1/dpdk/build/app/test -c f -n 4
> >
> > Test name  Test result  Test
> > Total
> >
> 
> > Start group_1: Fail [Can't run]  [00m 00s]
> > Timer autotest:Fail [Can't run]  [00m 00s]
> > Debug autotest:Fail [Can't run]  [00m 00s]
> > Errno autotest:Fail [Can't run]  [00m 00s]
> > Meter autotest:Fail [Can't run]  [00m 00s]
> > Common autotest:   Fail [Can't run]  [00m 00s]
> > Dump log history:  Fail [Can't run]  [00m 00s]
> > ...
> > Start memcpy_perf: Fail [No prompt]  [00m 00s]
> > Memcpy performance autotest:   Fail [No prompt]  [00m 00s]
> [00m
> > 01s]
> > Start hash_perf:   Fail [No prompt]  [00m 00s]
> > Hash performance autotest: Fail [No prompt]  [00m 00s]
> [00m
> > 01s]
> > Start power:   Fail [No prompt]  [00m 00s]
> > Power autotest:Fail [No prompt]  [00m 00s]
> [00m
> > 01s]
> > ...
> >
> > I have contigmem and nic_uio installed. I know some applications are
> > linuxapp specific but wanted to know if there is a similar automated test
> > tool like Linux?
> >
> > Thanks,
> > Ravi
>
> There is no separate test tool for FreeBSD. Unfortunately there are a
> number of little
> things that don't really work on FreeBSD - and this looks to be one of
> them. We
> probably need to look to fix this.
>
> Thanks Bruce. Is it due to missing infra for BSD or some minor fixes in
app/test?

> /Bruce
>


[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-29 Thread Ravi Kerur
> > I tried to run validate-abi.sh on BSD but ran into errors. If there is a
> > way to check against BSD please let me know.
> >
> The ABI checker should work on BSD as far as I know, since it only relies
> on
> dwarf information in the output binary.  What errors are you seeing?
>

dpdk-bsd:/home/rkerur/dpdk-validate-abi-1/dpdk # sh
./scripts/validate-abi.sh v2.0.0-rc3 v2.0.0-abi x86_64-native-bsdapp-clang
mktemp: illegal option -- p
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
   mktemp [-d] [-q] [-u] -t prefix
Cant find abi-compliance-checker utility

abi-compliance-checker is installed as shown below.

dpdk-bsd:/home/rkerur/dpdk-validate-abi-1/dpdk # pkg install
devel/abi-compliance-checker
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
Checking integrity... done (0 conflicting)
The most recent version of packages are already installed


>
> Neil
>
>


[dpdk-dev] gmake test on freeBSD

2015-04-28 Thread Ravi Kerur
DPDK team,

Is there a automated tests to run on freeBSD similar to Linux (make test).

I ran "gmake test T=x86_64-native-bsdapp-clang CC=clang" I get following
output

/usr/home/rkerur/dpdk-validate-abi-1/dpdk/build/app/test -c f -n 4

Test name  Test result  Test
Total

Start group_1: Fail [Can't run]  [00m 00s]
Timer autotest:Fail [Can't run]  [00m 00s]
Debug autotest:Fail [Can't run]  [00m 00s]
Errno autotest:Fail [Can't run]  [00m 00s]
Meter autotest:Fail [Can't run]  [00m 00s]
Common autotest:   Fail [Can't run]  [00m 00s]
Dump log history:  Fail [Can't run]  [00m 00s]
...
Start memcpy_perf: Fail [No prompt]  [00m 00s]
Memcpy performance autotest:   Fail [No prompt]  [00m 00s] [00m
01s]
Start hash_perf:   Fail [No prompt]  [00m 00s]
Hash performance autotest: Fail [No prompt]  [00m 00s] [00m
01s]
Start power:   Fail [No prompt]  [00m 00s]
Power autotest:Fail [No prompt]  [00m 00s] [00m
01s]
...

I have contigmem and nic_uio installed. I know some applications are
linuxapp specific but wanted to know if there is a similar automated test
tool like Linux?

Thanks,
Ravi


[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-28 Thread Ravi Kerur
On Tue, Apr 28, 2015 at 12:35 PM, Neil Horman  wrote:

> On Mon, Apr 27, 2015 at 03:39:41PM -0700, Ravi Kerur wrote:
> > On Mon, Apr 27, 2015 at 6:44 AM, Neil Horman 
> wrote:
> >
> > > On Sat, Apr 25, 2015 at 05:09:01PM -0700, Ravi Kerur wrote:
> > > > On Sat, Apr 25, 2015 at 6:02 AM, Neil Horman 
> > > wrote:
> > > >
> > > > > On Sat, Apr 25, 2015 at 08:32:42AM -0400, Neil Horman wrote:
> > > > > > On Fri, Apr 24, 2015 at 06:45:06PM -0700, Ravi Kerur wrote:
> > > > > > > On Fri, Apr 24, 2015 at 2:24 PM, Ravi Kerur 
> > > wrote:
> > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On Fri, Apr 24, 2015 at 12:51 PM, Neil Horman <
> > > nhorman at tuxdriver.com
> > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > >> On Fri, Apr 24, 2015 at 12:21:23PM -0700, Ravi Kerur wrote:
> > > > > > > >> > On Fri, Apr 24, 2015 at 11:53 AM, Neil Horman <
> > > > > nhorman at tuxdriver.com>
> > > > > > > >> wrote:
> > > > > > > >> >
> > > > > > > >> > > On Fri, Apr 24, 2015 at 09:45:24AM -0700, Ravi Kerur
> wrote:
> > > > > > > >> > > > On Fri, Apr 24, 2015 at 8:22 AM, Neil Horman <
> > > > > nhorman at tuxdriver.com
> > > > > > > >> >
> > > > > > > >> > > wrote:
> > > > > > > >> > > >
> > > > > > > >> > > > > On Fri, Apr 24, 2015 at 08:14:04AM -0700, Ravi Kerur
> > > wrote:
> > > > > > > >> > > > > > On Fri, Apr 24, 2015 at 6:51 AM, Neil Horman <
> > > > > > > >> nhorman at tuxdriver.com>
> > > > > > > >> > > > > wrote:
> > > > > > > >> > > > > >
> > > > > > > >> > > > > > > On Thu, Apr 23, 2015 at 02:35:31PM -0700, Ravi
> Kerur
> > > > > wrote:
> > > > > > > >> > > > > > > > Changes in v7
> > > > > > > >> > > > > > > > Remove _setname_ pthread calls.
> > > > > > > >> > > > > > > > Use rte_gettid() API in RTE_LOG to print
> > > thread_id.
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > > Changes in v6
> > > > > > > >> > > > > > > > Remove RTE_EXEC_ENV_BSDAPP from
> > > eal_common_thread.c
> > > > > file.
> > > > > > > >> > > > > > > > Add pthread_setname_np/pthread_set_name_np for
> > > > > Linux/FreeBSD
> > > > > > > >> > > > > > > > respectively. Plan to use _getname_ in RTE_LOG
> > > when
> > > > > > > >> available.
> > > > > > > >> > > > > > > > Use existing rte_get_systid() in RTE_LOG to
> print
> > > > > thread_id.
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > > Changes in v5
> > > > > > > >> > > > > > > > Rebase to latest code.
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > > Changes in v4
> > > > > > > >> > > > > > > > None
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > > Changes in v3
> > > > > > > >> > > > > > > > Changed subject to be more explicit on file
> name
> > > > > inclusion.
> > > > > > > >> > > > > > > >
> > > > > > > >> > > > > > > > Changes in v2
> > > > > > > >> > > > > > > > None
> > > > > > > >> > > > > > > >
> > > > > > > >> &g

[dpdk-dev] [PATCH v8 6/6] Move common functions in eal_pci.c

2015-04-28 Thread Ravi Kerur
Changes in v8
None

Changes in v7
Rebase to latest code.

Changes in v6
Split changes due to complexity. v6 includes moving
rte_eal_pci_probe_one_driver function and its associated
utility functions only.

Changes in v5
Rebase to latest code.
Removed RTE_EXEC_ENV_BSDAPP from earlier changes.

Changes in v4
Move common functions in eal_pci.c to librte_eal/common/
eal_common_pci.c file.

Following functions are moved to eal_common_pci.c file.

void *pci_map_resource(void *requested_addr, const int vfio_fd,
  const char *devname, off_t offset, size_t size);
int pci_addr_comparison(struct rte_pci_addr *addr,
struct rte_pci_addr *addr2);
int rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,
struct rte_pci_device *dev);

Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in
common function.
Fix checkpatch warnings and errors.

Changes in v3
N/A

Changes in v2
N/A

Changes in v1
N/A

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/eal_pci.c| 72 +---
 lib/librte_eal/common/eal_common_pci.c | 72 
 lib/librte_eal/common/eal_private.h| 39 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 75 +-
 4 files changed, 113 insertions(+), 145 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 30f0232..f21b5b6 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -111,7 +111,7 @@ static struct rte_tailq_elem rte_uio_tailq = {
 EAL_REGISTER_TAILQ(rte_uio_tailq)

 /* unbind kernel driver for this device */
-static int
+int
 pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
 {
RTE_LOG(ERR, EAL, "RTE_PCI_DRV_FORCE_UNBIND flag is not implemented "
@@ -274,6 +274,13 @@ pci_uio_map_resource(struct rte_pci_device *dev)
return (0);
 }

+/* map the PCI resource of a PCI device in virtual memory */
+int
+pci_map_device(struct rte_pci_device *dev)
+{
+   return pci_uio_map_resource(dev);
+}
+
 /* Scan one pci sysfs entry, and fill the devices list from it. */
 static int
 pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
@@ -426,68 +433,11 @@ error:
 }

 /*
- * If vendor/device ID match, call the devinit() function of the
- * driver.
+ * This function is a no-op in BSD.
  */
-int
-rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device 
*dev)
+void
+pci_config_space_set(struct rte_pci_device *dev __rte_unused)
 {
-   struct rte_pci_id *id_table;
-   int ret;
-
-   for (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) {
-
-   /* check if device's identifiers match the driver's ones */
-   if (id_table->vendor_id != dev->id.vendor_id &&
-   id_table->vendor_id != PCI_ANY_ID)
-   continue;
-   if (id_table->device_id != dev->id.device_id &&
-   id_table->device_id != PCI_ANY_ID)
-   continue;
-   if (id_table->subsystem_vendor_id != 
dev->id.subsystem_vendor_id &&
-   id_table->subsystem_vendor_id != PCI_ANY_ID)
-   continue;
-   if (id_table->subsystem_device_id != 
dev->id.subsystem_device_id &&
-   id_table->subsystem_device_id != PCI_ANY_ID)
-   continue;
-
-   struct rte_pci_addr *loc = >addr;
-
-   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket 
%i\n",
-   loc->domain, loc->bus, loc->devid, 
loc->function,
-   dev->numa_node);
-
-   RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", 
dev->id.vendor_id,
-   dev->id.device_id, dr->name);
-
-   /* no initialization when blacklisted, return without error */
-   if (dev->devargs != NULL &&
-   dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
-
-   RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not 
initializing\n");
-   return 0;
-   }
-
-   if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
-   /* map resources for devices that use igb_uio */
-   ret = pci_uio_map_resource(dev);
-   if (ret != 0)
-   return ret;
-   } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
-  rte_eal_process_type() == RTE_PROC_PRIMARY) {
-   /* unbind current driver */
-   if (pci_unbind_kernel_driver(dev) < 

[dpdk-dev] [PATCH v8 5/6] Move common functions in eal_memory.c

2015-04-28 Thread Ravi Kerur
Changes in v8
None

Changes in v7
None

Changes in v6
Removed unnecessary comments in function declaration.

Changes in v5
Rebase to latest code.

Changes in v4
Make rte_eal_hugepage_init and rte_eal_hugepage_attach as
wrapper functions for BSD.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
Use common function names rte_eal_hugepage_init and
rte_eal_hugepage_attach for BSD and Linux. Update comments about its
actuality in function declaration.

Changes in v1
Move common functions in eal_memory.c to librte_eal/common/
eal_common_memory.c file.

Following functions are moved to eal_common_memory.c file

static int rte_eal_memdevice_init(void); int rte_eal_memory_init(void);

Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/eal_memory.c| 47 +++
 lib/librte_eal/common/eal_common_memory.c | 38 +++--
 lib/librte_eal/common/eal_private.h   | 20 +++--
 lib/librte_eal/linuxapp/eal/eal_memory.c  | 36 ++-
 4 files changed, 72 insertions(+), 69 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_memory.c 
b/lib/librte_eal/bsdapp/eal/eal_memory.c
index 33ebd0f..77c27b3 100644
--- a/lib/librte_eal/bsdapp/eal/eal_memory.c
+++ b/lib/librte_eal/bsdapp/eal/eal_memory.c
@@ -59,7 +59,7 @@ rte_mem_virt2phy(const void *virtaddr)
return RTE_BAD_PHYS_ADDR;
 }

-static int
+static inline int
 rte_eal_contigmem_init(void)
 {
struct rte_mem_config *mcfg;
@@ -131,7 +131,16 @@ rte_eal_contigmem_init(void)
return 0;
 }

-static int
+/*
+ * Wrapper function to initialize contigmem.
+ */
+int
+rte_eal_hugepage_init(void)
+{
+   return rte_eal_contigmem_init();
+}
+
+static inline int
 rte_eal_contigmem_attach(void)
 {
const struct hugepage_info *hpi;
@@ -192,35 +201,11 @@ error:
return -1;
 }

-
-static int
-rte_eal_memdevice_init(void)
-{
-   struct rte_config *config;
-
-   if (rte_eal_process_type() == RTE_PROC_SECONDARY)
-   return 0;
-
-   config = rte_eal_get_configuration();
-   config->mem_config->nchannel = internal_config.force_nchannel;
-   config->mem_config->nrank = internal_config.force_nrank;
-
-   return 0;
-}
-
-/* init memory subsystem */
+/*
+ * Wrapper function to attach contigmem.
+ */
 int
-rte_eal_memory_init(void)
+rte_eal_hugepage_attach(void)
 {
-   RTE_LOG(INFO, EAL, "Setting up physically contiguous memory...\n");
-   const int retval = rte_eal_process_type() == RTE_PROC_PRIMARY ?
-   rte_eal_contigmem_init() :
-   rte_eal_contigmem_attach();
-   if (retval < 0)
-   return -1;
-
-   if (internal_config.no_shconf == 0 && rte_eal_memdevice_init() < 0)
-   return -1;
-
-   return 0;
+   return rte_eal_contigmem_attach();
 }
diff --git a/lib/librte_eal/common/eal_common_memory.c 
b/lib/librte_eal/common/eal_common_memory.c
index 9a07b1e..10ff0bc 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -45,6 +45,7 @@
 #include 

 #include "eal_private.h"
+#include "eal_internal_cfg.h"

 /*
  * Return a pointer to a read-only table of struct rte_physmem_desc
@@ -69,7 +70,7 @@ rte_eal_get_physmem_size(void)
/* get pointer to global configuration */
mcfg = rte_eal_get_configuration()->mem_config;

-   for (i=0; i<RTE_MAX_MEMSEG; i++) {
+   for (i = 0; i < RTE_MAX_MEMSEG; i++) {
if (mcfg->memseg[i].addr == NULL)
break;

@@ -89,7 +90,7 @@ rte_dump_physmem_layout(FILE *f)
/* get pointer to global configuration */
mcfg = rte_eal_get_configuration()->mem_config;

-   for (i=0; i<RTE_MAX_MEMSEG; i++) {
+   for (i = 0; i < RTE_MAX_MEMSEG; i++) {
if (mcfg->memseg[i].addr == NULL)
break;

@@ -118,3 +119,36 @@ unsigned rte_memory_get_nrank(void)
 {
return rte_eal_get_configuration()->mem_config->nrank;
 }
+
+static int
+rte_eal_memdevice_init(void)
+{
+   struct rte_config *config;
+
+   if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+   return 0;
+
+   config = rte_eal_get_configuration();
+   config->mem_config->nchannel = internal_config.force_nchannel;
+   config->mem_config->nrank = internal_config.force_nrank;
+
+   return 0;
+}
+
+/* init memory subsystem */
+int
+rte_eal_memory_init(void)
+{
+   RTE_LOG(INFO, EAL, "Setting up physically contiguous memory...\n");
+   const int retval = rte_eal_process_type() == RTE_PROC_PRIMARY ?
+   rte_eal_hugepage_init() :
+   rte_eal_hugepage_attach();
+
+   if (retval < 0)
+   return -1;
+
+   if (internal_config.no_shconf == 0 &&

[dpdk-dev] [PATCH v8 4/6] Move common functions in eal_timer.c

2015-04-28 Thread Ravi Kerur
Changes in v8
Reorder eal_common_timer.c compilation.

Changes in v7
None

Changes in v6
Added new line between Copyright and header file inclusion
in eal_common_timer.c.

Changes in v5
Rebase to latest code.

Changes in v4
Removed extern declaration of eal_tsc_resolution_hz,
instead provided _set_ API.
Make set_tsc_freq_from_clock as wrapper function for BSD.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
Use common function name set_tsc_freq_from_sysctl for BSD and Linux.
Update comments about its actuality in function declaration.

Changes in v1
Move common functions in eal_timer.c to librte_eal/common/
eal_common_timer.c file.

Following functions are  moved to eal_common_timer.c file

void rte_delay_us(unsigned us);
uint64_t rte_get_tsc_hz(void);
static void set_tsc_freq_fallback(void);
void set_tsc_freq(void);

Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile   |   1 +
 lib/librte_eal/bsdapp/eal/eal_timer.c|  52 +++-
 lib/librte_eal/common/eal_common_timer.c | 102 +++
 lib/librte_eal/common/eal_private.h  |  24 
 lib/librte_eal/linuxapp/eal/Makefile |   1 +
 lib/librte_eal/linuxapp/eal/eal_timer.c  |  55 ++---
 6 files changed, 140 insertions(+), 95 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_timer.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index 88d783d..db52541 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -66,6 +66,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_timer.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_timer.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c

diff --git a/lib/librte_eal/bsdapp/eal/eal_timer.c 
b/lib/librte_eal/bsdapp/eal/eal_timer.c
index 7147abe..ee7a5ac 100644
--- a/lib/librte_eal/bsdapp/eal/eal_timer.c
+++ b/lib/librte_eal/bsdapp/eal/eal_timer.c
@@ -55,29 +55,12 @@

 enum timer_source eal_timer_source = EAL_TIMER_TSC;

-/* The frequency of the RDTSC timer resolution */
-static uint64_t eal_tsc_resolution_hz = 0;
-
-void
-rte_delay_us(unsigned us)
-{
-   const uint64_t start = rte_get_timer_cycles();
-   const uint64_t ticks = (uint64_t)us * rte_get_timer_hz() / 1E6;
-   while ((rte_get_timer_cycles() - start) < ticks)
-   rte_pause();
-}
-
-uint64_t
-rte_get_tsc_hz(void)
-{
-   return eal_tsc_resolution_hz;
-}
-
 static int
 set_tsc_freq_from_sysctl(void)
 {
size_t sz;
int tmp;
+   uint64_t tsc_hz;

sz = sizeof(tmp);
tmp = 0;
@@ -94,42 +77,23 @@ set_tsc_freq_from_sysctl(void)
else if (tmp != 1)
RTE_LOG(WARNING, EAL, "TSC is not invariant\n");

-   sz = sizeof(eal_tsc_resolution_hz);
-   if (sysctlbyname("machdep.tsc_freq", _tsc_resolution_hz, , NULL, 
0)) {
+   sz = sizeof(tsc_hz);
+   if (sysctlbyname("machdep.tsc_freq", _hz, , NULL, 0)) {
RTE_LOG(WARNING, EAL, "%s\n", strerror(errno));
return -1;
}
+   rte_set_tsc_hz(tsc_hz);

return 0;
 }

-static void
-set_tsc_freq_fallback(void)
-{
-   RTE_LOG(WARNING, EAL, "WARNING: clock_gettime cannot use "
-   "CLOCK_MONOTONIC_RAW and HPET is not available"
-   " - clock timings may be less accurate.\n");
-   /* assume that the sleep(1) will sleep for 1 second */
-   uint64_t start = rte_rdtsc();
-   sleep(1);
-   eal_tsc_resolution_hz = rte_rdtsc() - start;
-}
-
 /*
- * This function measures the TSC frequency. It uses a variety of approaches.
- *
- * 1. Read the TSC frequency value provided by the kernel
- * 2. If above does not work, just sleep for 1 second and tune off that,
- *printing a warning about inaccuracy of timing
+ * Wrapper function to get TSC frequency from sysctl.
  */
-static void
-set_tsc_freq(void)
+int
+set_tsc_freq_from_clock(void)
 {
-   if (set_tsc_freq_from_sysctl() < 0)
-   set_tsc_freq_fallback();
-
-   RTE_LOG(INFO, EAL, "TSC frequency is ~%"PRIu64" KHz\n",
-   eal_tsc_resolution_hz/1000);
+   return set_tsc_freq_from_sysctl();
 }

 int
diff --git a/lib/librte_eal/common/eal_common_timer.c 
b/lib/librte_eal/common/eal_common_timer.c
new file mode 100644
index 000..5fddd6e
--- /dev/null
+++ b/lib/librte_eal/common/eal_common_timer.c
@@ -0,0 +1,102 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   All rights reserved.

[dpdk-dev] [PATCH v8 3/6] Move common functions in eal_lcore.c

2015-04-28 Thread Ravi Kerur
Changes in v8
Reorder eal_common_lcore.c compilation.

Changes in v7
None

Changes in v6
None

Changes in v5
Rebase to latest code.

Changes in v4
Implement cpu_detected() for BSD.
Have common RTE_LOG for Linux and BSD in rte_eal_cpu_init().
Remove RTE_EXEC_ENV_BSDAPP in common file.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
None

Changes in v1
Move common function in eal_lcore.c to librte_eal/common/
eal_common_lcore.c file.

Following function is  moved to eal_common_lcore.c file

int rte_eal_cpu_init(void);

Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in
common function.
Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile   |   1 +
 lib/librte_eal/bsdapp/eal/eal_lcore.c|  72 +
 lib/librte_eal/common/eal_common_lcore.c | 107 +++
 lib/librte_eal/common/eal_private.h  |  14 
 lib/librte_eal/linuxapp/eal/Makefile |   2 +
 lib/librte_eal/linuxapp/eal/eal_lcore.c  |  66 ++-
 6 files changed, 143 insertions(+), 119 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_lcore.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index 67abc54..88d783d 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -64,6 +64,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_lcore.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_timer.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_interrupts.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_alarm.c
diff --git a/lib/librte_eal/bsdapp/eal/eal_lcore.c 
b/lib/librte_eal/bsdapp/eal/eal_lcore.c
index 162fb4f..b47eb1b 100644
--- a/lib/librte_eal/bsdapp/eal/eal_lcore.c
+++ b/lib/librte_eal/bsdapp/eal/eal_lcore.c
@@ -44,11 +44,14 @@
 #include "eal_thread.h"

 /* No topology information available on FreeBSD including NUMA info */
-#define cpu_core_id(X) 0
-#define cpu_socket_id(X) 0
+unsigned
+eal_cpu_core_id(__rte_unused unsigned lcore_id)
+{
+   return 0;
+}

 static int
-get_ncpus(void)
+eal_get_ncpus(void)
 {
int mib[2] = {CTL_HW, HW_NCPU};
int ncpu;
@@ -59,63 +62,18 @@ get_ncpus(void)
return ncpu;
 }

-/*
- * fill the cpu_info structure with as much info as we can get.
- * code is similar to linux version, but sadly available info is less.
- */
-int
-rte_eal_cpu_init(void)
+unsigned
+eal_cpu_socket_id(__rte_unused unsigned cpu_id)
 {
-   /* pointer to global configuration */
-   struct rte_config *config = rte_eal_get_configuration();
-   unsigned lcore_id;
-   unsigned count = 0;
-
-   const unsigned ncpus = get_ncpus();
-   /*
-* Parse the maximum set of logical cores, detect the subset of running
-* ones and enable them by default.
-*/
-   for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
-   /* init cpuset for per lcore config */
-   CPU_ZERO(_config[lcore_id].cpuset);
-
-   lcore_config[lcore_id].detected = (lcore_id < ncpus);
-   if (lcore_config[lcore_id].detected == 0) {
-   config->lcore_role[lcore_id] = ROLE_OFF;
-   continue;
-   }
-
-   /* By default, lcore 1:1 map to cpu id */
-   CPU_SET(lcore_id, _config[lcore_id].cpuset);
-
-   /* By default, each detected core is enabled */
-   config->lcore_role[lcore_id] = ROLE_RTE;
-   lcore_config[lcore_id].core_id = cpu_core_id(lcore_id);
-   lcore_config[lcore_id].socket_id = cpu_socket_id(lcore_id);
-   if (lcore_config[lcore_id].socket_id >= RTE_MAX_NUMA_NODES)
-#ifdef RTE_EAL_ALLOW_INV_SOCKET_ID
-   lcore_config[lcore_id].socket_id = 0;
-#else
-   rte_panic("Socket ID (%u) is greater than "
-   "RTE_MAX_NUMA_NODES (%d)\n",
-   lcore_config[lcore_id].socket_id, 
RTE_MAX_NUMA_NODES);
-#endif
-   RTE_LOG(DEBUG, EAL, "Detected lcore %u\n",
-   lcore_id);
-   count++;
-   }
-   /* Set the count of enabled logical cores of the EAL configuration */
-   config->lcore_count = count;
-   RTE_LOG(DEBUG, EAL, "Support maximum %u logical core(s) by 
configuration.\n",
-   RTE_MAX_LCORE);
-   RTE_LOG(DEBUG, EAL, "Detected %u lcore(s)\n", config->lcore_count);
-
return 0;
 }

-unsigned
-eal_cpu_socket_id(__rte_unused unsigned cpu_id)
+/* Check if a cpu is present by the

[dpdk-dev] [PATCH v8 2/6] Move common functions in eal.c

2015-04-28 Thread Ravi Kerur
Changes in v8
Fix ABI warnings by reordering compilation of
eal_common_sysfs.c
eal_common_mem_cfg.c
eal_common_proc_type.c
eal_common_app_usage.c

Changes in v7
Fix compilation errors in clang.

Changes in v6
Split eal_common_system.c and eal_common_runtime.c into
eal_common_sysfs.c
eal_common_mem_cfg.c
eal_common_proc_type.c
eal_common_app_usage.c
based on functionality.

Changes in v5
Rebase to latest code.

Changes in v4
Remove eal_externs.h file, instead use  _get_ and _set_ APIS
to access those variables.
Split eal_common.c into eal_common_system.c and
and eal_common_runtime.c
rte_eal prefix functions are moved to _runtime_ and
eal prefix functions are moved to _system_ files respectively.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
In function rte_eal_config_create remove #ifdef _BSDAPP_
and initialize mem_cfg_addr unconditionally.

Changes in v1
Move common functions in eal.c to librte_eal/common/eal_common.c.

Following functions are moved to eal_common.c file.

struct rte_config *rte_eal_get_configuration(void);
int eal_parse_sysfs_value(const char *filename, unsigned long *val);
static void rte_eal_config_create(void);
enum rte_proc_type_t eal_proc_type_detect(void);
void rte_eal_config_init(void);
rte_usage_hook_t rte_set_application_usage_hook(rte_usage_hook_t
usage_func);
inline size_t eal_get_hugepage_mem_size(void);
void eal_check_mem_on_local_socket(void);
int sync_func(__attribute__((unused)) void *arg);
inline void rte_eal_mcfg_complete(void);
int rte_eal_has_hugepages(void);
enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id);
enum rte_proc_type_t rte_eal_process_type(void);

Makefile changes to reflect new files added.
Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile   |   4 +
 lib/librte_eal/bsdapp/eal/eal.c  | 271 +++-
 lib/librte_eal/common/eal_common_app_usage.c |  63 ++
 lib/librte_eal/common/eal_common_mem_cfg.c   | 224 
 lib/librte_eal/common/eal_common_proc_type.c |  58 ++
 lib/librte_eal/common/eal_common_sysfs.c | 148 ++
 lib/librte_eal/common/eal_hugepages.h|   1 +
 lib/librte_eal/common/eal_private.h  |  78 +++
 lib/librte_eal/common/include/rte_eal.h  |   4 +
 lib/librte_eal/linuxapp/eal/Makefile |   4 +
 lib/librte_eal/linuxapp/eal/eal.c| 296 ---
 11 files changed, 660 insertions(+), 491 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_app_usage.c
 create mode 100644 lib/librte_eal/common/eal_common_mem_cfg.c
 create mode 100644 lib/librte_eal/common/eal_common_proc_type.c
 create mode 100644 lib/librte_eal/common/eal_common_sysfs.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index b7ca47c..67abc54 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -52,6 +52,10 @@ LIBABIVER := 1

 # specific to linuxapp exec-env
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) := eal.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_sysfs.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_mem_cfg.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_proc_type.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_app_usage.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_memory.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_hugepage_info.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_thread.c
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 43e8a47..a9b1f38 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -80,29 +80,6 @@
 #include "eal_hugepages.h"
 #include "eal_options.h"

-#define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
-
-/* Allow the application to print its usage message too if set */
-static rte_usage_hook_trte_application_usage_hook = NULL;
-/* early configuration structure, when memory config is not mmapped */
-static struct rte_mem_config early_mem_config;
-
-/* define fd variable here, because file needs to be kept open for the
- * duration of the program, as we hold a write lock on it in the primary proc 
*/
-static int mem_cfg_fd = -1;
-
-static struct flock wr_lock = {
-   .l_type = F_WRLCK,
-   .l_whence = SEEK_SET,
-   .l_start = offsetof(struct rte_mem_config, memseg),
-   .l_len = sizeof(early_mem_config.memseg),
-};
-
-/* Address of global and public configuration */
-static struct rte_config rte_config = {
-   .mem_config = _mem_config,
-};
-
 /* internal configuration (per-core) */
 struct lcore_config lcore_config[RTE_MAX_LCORE];

@@ -112,160 +89,57 @@ struct internal_config internal_config;
 /* used by rte_rdtsc() */
 int rte_cycles_vmware_tsc_map;

-/* Return a pointer to the configuration structure */
-struct rte_config *
-rte_eal_ge

[dpdk-dev] [PATCH v8 1/6] Move common functions in eal_thread.c

2015-04-28 Thread Ravi Kerur
Changes in v8
Fixed ABI warnings by reordering compilation of
eal_common_thread.c.

Changes in v7
Remove _setname_ pthread calls.
Use rte_gettid() API in RTE_LOG to print thread_id.

Changes in v6
Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c file.
Add pthread_setname_np/pthread_set_name_np for Linux/FreeBSD
respectively. Plan to use _getname_ in RTE_LOG when available.
Use existing rte_get_systid() in RTE_LOG to print thread_id.

Changes in v5
Rebase to latest code.

Changes in v4
None

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
None

Changes in v1
eal_thread.c has minor differences between Linux and BSD, move
entire file into common directory.
Use RTE_EXEC_ENV_BSDAPP to differentiate on minor differences.
Rename eal_thread.c to eal_common_thread.c
Makefile changes to reflect file move and name change.
Fix checkpatch warnings.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile|   3 +-
 lib/librte_eal/bsdapp/eal/eal_thread.c| 152 --
 lib/librte_eal/common/eal_common_thread.c | 147 -
 lib/librte_eal/linuxapp/eal/Makefile  |   3 +-
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 152 +-
 5 files changed, 151 insertions(+), 306 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index 2357cfa..b7ca47c 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -55,6 +55,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) := eal.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_memory.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_hugepage_info.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_thread.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_log.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_debug.c
@@ -77,7 +78,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c
-SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c

 CFLAGS_eal.o := -D_GNU_SOURCE
 #CFLAGS_eal_thread.o := -D_GNU_SOURCE
@@ -88,6 +88,7 @@ CFLAGS_eal_common_log.o := -D_GNU_SOURCE
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 CFLAGS_eal_thread.o += -Wno-return-type
+CFLAGS_eal_common_thread.o += -Wno-return-type
 CFLAGS_eal_hpet.o += -Wno-return-type
 endif

diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index 9a03437..5714b8f 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -35,163 +35,11 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 

-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 #include "eal_private.h"
 #include "eal_thread.h"

-RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
-RTE_DEFINE_PER_LCORE(unsigned, _socket_id) = (unsigned)SOCKET_ID_ANY;
-RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);
-
-/*
- * Send a message to a slave lcore identified by slave_id to call a
- * function f with argument arg. Once the execution is done, the
- * remote lcore switch in FINISHED state.
- */
-int
-rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
-{
-   int n;
-   char c = 0;
-   int m2s = lcore_config[slave_id].pipe_master2slave[1];
-   int s2m = lcore_config[slave_id].pipe_slave2master[0];
-
-   if (lcore_config[slave_id].state != WAIT)
-   return -EBUSY;
-
-   lcore_config[slave_id].f = f;
-   lcore_config[slave_id].arg = arg;
-
-   /* send message */
-   n = 0;
-   while (n == 0 || (n < 0 && errno == EINTR))
-   n = write(m2s, , 1);
-   if (n < 0)
-   rte_panic("cannot write on configuration pipe\n");
-
-   /* wait ack */
-   do {
-   n = read(s2m, , 1);
-   } while (n < 0 && errno == EINTR);
-
-   if (n <= 0)
-   rte_panic("cannot read on configuration pipe\n");
-
-   return 0;
-}
-
-/* set affinity for current thread */
-static int
-eal_thread_set_affinity(void)
-{
-   unsigned lcore_id = rte_lcore_id();
-
-   /* acquire system unique id  */
-   rte_gettid();
-
-   /* update EAL thread core affinity */
-   return rte_thread_set_affinity(_config[lcore_id].cpuset);
-}
-
-void eal_thread_init_master(unsigned lcore_id)
-{
-   /* set the lcore ID in per-lcore memory area */
-   RTE_PER_LCORE(_lcore_id) = lcore_id;
-
-   /* set CPU affinity */
-   if (eal_thread_set_affinity() < 0)
-   rte_panic(&q

[dpdk-dev] [PATCH v8 0/6] Move common functions in EAL

2015-04-28 Thread Ravi Kerur
Changes in v8 includes
Re-ordering source file compilation to fix ABI warning.
Ran validate-abi against x86_64-native-linuxapp-gcc,
x86_64-native-linuxapp-clang and x86_64-ivshmem-linuxapp-gcc
environments.

Testing:
Linux - Ubuntu x86_64 14.04
Compilation successful (x86_64-native-linuxapp-gcc and
x86_64-native-linuxapp-clang).
"make test" results match baseline code.
testpmd utility on I217/I218 Intel chipset.

FreeBSD 10.0 x86_64
Compilation successful (x86_64-native-bsdapp-gcc and
x86_64-native-bsdapp-clang).
Tested with helloworld, timer and cmdline examples.

Ravi Kerur (6):
  Move common functions in eal_thread.c
  Move common functions in eal.c
  Move common functions in eal_lcore.c
  Move common functions in eal_timer.c
  Move common functions in eal_memory.c
  Move common functions in eal_pci.c

 lib/librte_eal/bsdapp/eal/Makefile   |   9 +-
 lib/librte_eal/bsdapp/eal/eal.c  | 271 +++-
 lib/librte_eal/bsdapp/eal/eal_lcore.c|  72 ++-
 lib/librte_eal/bsdapp/eal/eal_memory.c   |  47 ++---
 lib/librte_eal/bsdapp/eal/eal_pci.c  |  72 +--
 lib/librte_eal/bsdapp/eal/eal_thread.c   | 152 --
 lib/librte_eal/bsdapp/eal/eal_timer.c|  52 +
 lib/librte_eal/common/eal_common_app_usage.c |  63 ++
 lib/librte_eal/common/eal_common_lcore.c | 107 ++
 lib/librte_eal/common/eal_common_mem_cfg.c   | 224 
 lib/librte_eal/common/eal_common_memory.c|  38 +++-
 lib/librte_eal/common/eal_common_pci.c   |  72 +++
 lib/librte_eal/common/eal_common_proc_type.c |  58 ++
 lib/librte_eal/common/eal_common_sysfs.c | 148 ++
 lib/librte_eal/common/eal_common_thread.c| 147 -
 lib/librte_eal/common/eal_common_timer.c | 102 +
 lib/librte_eal/common/eal_hugepages.h|   1 +
 lib/librte_eal/common/eal_private.h  | 171 +++-
 lib/librte_eal/common/include/rte_eal.h  |   4 +
 lib/librte_eal/linuxapp/eal/Makefile |  10 +-
 lib/librte_eal/linuxapp/eal/eal.c| 296 ---
 lib/librte_eal/linuxapp/eal/eal_lcore.c  |  66 +-
 lib/librte_eal/linuxapp/eal/eal_memory.c |  36 +---
 lib/librte_eal/linuxapp/eal/eal_pci.c|  75 +--
 lib/librte_eal/linuxapp/eal/eal_thread.c | 152 +-
 lib/librte_eal/linuxapp/eal/eal_timer.c  |  55 +
 26 files changed, 1277 insertions(+), 1223 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_app_usage.c
 create mode 100644 lib/librte_eal/common/eal_common_lcore.c
 create mode 100644 lib/librte_eal/common/eal_common_mem_cfg.c
 create mode 100644 lib/librte_eal/common/eal_common_proc_type.c
 create mode 100644 lib/librte_eal/common/eal_common_sysfs.c
 create mode 100644 lib/librte_eal/common/eal_common_timer.c

-- 
1.9.1



[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-27 Thread Ravi Kerur
On Mon, Apr 27, 2015 at 6:44 AM, Neil Horman  wrote:

> On Sat, Apr 25, 2015 at 05:09:01PM -0700, Ravi Kerur wrote:
> > On Sat, Apr 25, 2015 at 6:02 AM, Neil Horman 
> wrote:
> >
> > > On Sat, Apr 25, 2015 at 08:32:42AM -0400, Neil Horman wrote:
> > > > On Fri, Apr 24, 2015 at 06:45:06PM -0700, Ravi Kerur wrote:
> > > > > On Fri, Apr 24, 2015 at 2:24 PM, Ravi Kerur 
> wrote:
> > > > >
> > > > > >
> > > > > >
> > > > > > On Fri, Apr 24, 2015 at 12:51 PM, Neil Horman <
> nhorman at tuxdriver.com
> > > >
> > > > > > wrote:
> > > > > >
> > > > > >> On Fri, Apr 24, 2015 at 12:21:23PM -0700, Ravi Kerur wrote:
> > > > > >> > On Fri, Apr 24, 2015 at 11:53 AM, Neil Horman <
> > > nhorman at tuxdriver.com>
> > > > > >> wrote:
> > > > > >> >
> > > > > >> > > On Fri, Apr 24, 2015 at 09:45:24AM -0700, Ravi Kerur wrote:
> > > > > >> > > > On Fri, Apr 24, 2015 at 8:22 AM, Neil Horman <
> > > nhorman at tuxdriver.com
> > > > > >> >
> > > > > >> > > wrote:
> > > > > >> > > >
> > > > > >> > > > > On Fri, Apr 24, 2015 at 08:14:04AM -0700, Ravi Kerur
> wrote:
> > > > > >> > > > > > On Fri, Apr 24, 2015 at 6:51 AM, Neil Horman <
> > > > > >> nhorman at tuxdriver.com>
> > > > > >> > > > > wrote:
> > > > > >> > > > > >
> > > > > >> > > > > > > On Thu, Apr 23, 2015 at 02:35:31PM -0700, Ravi Kerur
> > > wrote:
> > > > > >> > > > > > > > Changes in v7
> > > > > >> > > > > > > > Remove _setname_ pthread calls.
> > > > > >> > > > > > > > Use rte_gettid() API in RTE_LOG to print
> thread_id.
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > Changes in v6
> > > > > >> > > > > > > > Remove RTE_EXEC_ENV_BSDAPP from
> eal_common_thread.c
> > > file.
> > > > > >> > > > > > > > Add pthread_setname_np/pthread_set_name_np for
> > > Linux/FreeBSD
> > > > > >> > > > > > > > respectively. Plan to use _getname_ in RTE_LOG
> when
> > > > > >> available.
> > > > > >> > > > > > > > Use existing rte_get_systid() in RTE_LOG to print
> > > thread_id.
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > Changes in v5
> > > > > >> > > > > > > > Rebase to latest code.
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > Changes in v4
> > > > > >> > > > > > > > None
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > Changes in v3
> > > > > >> > > > > > > > Changed subject to be more explicit on file name
> > > inclusion.
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > Changes in v2
> > > > > >> > > > > > > > None
> > > > > >> > > > > > > >
> > > > > >> > > > > > > > Changes in v1
> > > > > >> > > > > > > > eal_thread.c has minor differences between Linux
> and
> > > BSD,
> > > > > >> move
> > > > > >> > > > > > > > entire file into common directory.
> > > > > >> > > > > > > > Use RTE_EXEC_ENV_BSDAPP to differentiate on minor
> > > > > >> differences.
> > > > > >> > > > > > > > Rename eal_thread.c to eal_common_thread.c
> > > > > >> > > > > > > > Makefile changes to reflect file move and name
> change.
> > > > > >> > > > > > > > Fix checkpatch warnings.
> > > >

[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-25 Thread Ravi Kerur
On Sat, Apr 25, 2015 at 6:02 AM, Neil Horman  wrote:

> On Sat, Apr 25, 2015 at 08:32:42AM -0400, Neil Horman wrote:
> > On Fri, Apr 24, 2015 at 06:45:06PM -0700, Ravi Kerur wrote:
> > > On Fri, Apr 24, 2015 at 2:24 PM, Ravi Kerur  wrote:
> > >
> > > >
> > > >
> > > > On Fri, Apr 24, 2015 at 12:51 PM, Neil Horman  >
> > > > wrote:
> > > >
> > > >> On Fri, Apr 24, 2015 at 12:21:23PM -0700, Ravi Kerur wrote:
> > > >> > On Fri, Apr 24, 2015 at 11:53 AM, Neil Horman <
> nhorman at tuxdriver.com>
> > > >> wrote:
> > > >> >
> > > >> > > On Fri, Apr 24, 2015 at 09:45:24AM -0700, Ravi Kerur wrote:
> > > >> > > > On Fri, Apr 24, 2015 at 8:22 AM, Neil Horman <
> nhorman at tuxdriver.com
> > > >> >
> > > >> > > wrote:
> > > >> > > >
> > > >> > > > > On Fri, Apr 24, 2015 at 08:14:04AM -0700, Ravi Kerur wrote:
> > > >> > > > > > On Fri, Apr 24, 2015 at 6:51 AM, Neil Horman <
> > > >> nhorman at tuxdriver.com>
> > > >> > > > > wrote:
> > > >> > > > > >
> > > >> > > > > > > On Thu, Apr 23, 2015 at 02:35:31PM -0700, Ravi Kerur
> wrote:
> > > >> > > > > > > > Changes in v7
> > > >> > > > > > > > Remove _setname_ pthread calls.
> > > >> > > > > > > > Use rte_gettid() API in RTE_LOG to print thread_id.
> > > >> > > > > > > >
> > > >> > > > > > > > Changes in v6
> > > >> > > > > > > > Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c
> file.
> > > >> > > > > > > > Add pthread_setname_np/pthread_set_name_np for
> Linux/FreeBSD
> > > >> > > > > > > > respectively. Plan to use _getname_ in RTE_LOG when
> > > >> available.
> > > >> > > > > > > > Use existing rte_get_systid() in RTE_LOG to print
> thread_id.
> > > >> > > > > > > >
> > > >> > > > > > > > Changes in v5
> > > >> > > > > > > > Rebase to latest code.
> > > >> > > > > > > >
> > > >> > > > > > > > Changes in v4
> > > >> > > > > > > > None
> > > >> > > > > > > >
> > > >> > > > > > > > Changes in v3
> > > >> > > > > > > > Changed subject to be more explicit on file name
> inclusion.
> > > >> > > > > > > >
> > > >> > > > > > > > Changes in v2
> > > >> > > > > > > > None
> > > >> > > > > > > >
> > > >> > > > > > > > Changes in v1
> > > >> > > > > > > > eal_thread.c has minor differences between Linux and
> BSD,
> > > >> move
> > > >> > > > > > > > entire file into common directory.
> > > >> > > > > > > > Use RTE_EXEC_ENV_BSDAPP to differentiate on minor
> > > >> differences.
> > > >> > > > > > > > Rename eal_thread.c to eal_common_thread.c
> > > >> > > > > > > > Makefile changes to reflect file move and name change.
> > > >> > > > > > > > Fix checkpatch warnings.
> > > >> > > > > > > >
> > > >> > > > > > > > Signed-off-by: Ravi Kerur 
> > > >> > > > > > > > ---
> > > >> > > > > > > >  lib/librte_eal/bsdapp/eal/Makefile|   2 +-
> > > >> > > > > > > >  lib/librte_eal/bsdapp/eal/eal_thread.c| 152
> > > >> > > > > > > --
> > > >> > > > > > > >  lib/librte_eal/common/eal_common_thread.c | 147
> > > >> > > > > > > -
> > > >> > > > > > > >  lib/librte_eal/linuxapp/eal/eal_thread.c  | 152
> > > >> > > > > > > +

[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-24 Thread Ravi Kerur
On Fri, Apr 24, 2015 at 2:24 PM, Ravi Kerur  wrote:

>
>
> On Fri, Apr 24, 2015 at 12:51 PM, Neil Horman 
> wrote:
>
>> On Fri, Apr 24, 2015 at 12:21:23PM -0700, Ravi Kerur wrote:
>> > On Fri, Apr 24, 2015 at 11:53 AM, Neil Horman 
>> wrote:
>> >
>> > > On Fri, Apr 24, 2015 at 09:45:24AM -0700, Ravi Kerur wrote:
>> > > > On Fri, Apr 24, 2015 at 8:22 AM, Neil Horman > >
>> > > wrote:
>> > > >
>> > > > > On Fri, Apr 24, 2015 at 08:14:04AM -0700, Ravi Kerur wrote:
>> > > > > > On Fri, Apr 24, 2015 at 6:51 AM, Neil Horman <
>> nhorman at tuxdriver.com>
>> > > > > wrote:
>> > > > > >
>> > > > > > > On Thu, Apr 23, 2015 at 02:35:31PM -0700, Ravi Kerur wrote:
>> > > > > > > > Changes in v7
>> > > > > > > > Remove _setname_ pthread calls.
>> > > > > > > > Use rte_gettid() API in RTE_LOG to print thread_id.
>> > > > > > > >
>> > > > > > > > Changes in v6
>> > > > > > > > Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c file.
>> > > > > > > > Add pthread_setname_np/pthread_set_name_np for Linux/FreeBSD
>> > > > > > > > respectively. Plan to use _getname_ in RTE_LOG when
>> available.
>> > > > > > > > Use existing rte_get_systid() in RTE_LOG to print thread_id.
>> > > > > > > >
>> > > > > > > > Changes in v5
>> > > > > > > > Rebase to latest code.
>> > > > > > > >
>> > > > > > > > Changes in v4
>> > > > > > > > None
>> > > > > > > >
>> > > > > > > > Changes in v3
>> > > > > > > > Changed subject to be more explicit on file name inclusion.
>> > > > > > > >
>> > > > > > > > Changes in v2
>> > > > > > > > None
>> > > > > > > >
>> > > > > > > > Changes in v1
>> > > > > > > > eal_thread.c has minor differences between Linux and BSD,
>> move
>> > > > > > > > entire file into common directory.
>> > > > > > > > Use RTE_EXEC_ENV_BSDAPP to differentiate on minor
>> differences.
>> > > > > > > > Rename eal_thread.c to eal_common_thread.c
>> > > > > > > > Makefile changes to reflect file move and name change.
>> > > > > > > > Fix checkpatch warnings.
>> > > > > > > >
>> > > > > > > > Signed-off-by: Ravi Kerur 
>> > > > > > > > ---
>> > > > > > > >  lib/librte_eal/bsdapp/eal/Makefile|   2 +-
>> > > > > > > >  lib/librte_eal/bsdapp/eal/eal_thread.c| 152
>> > > > > > > --
>> > > > > > > >  lib/librte_eal/common/eal_common_thread.c | 147
>> > > > > > > -
>> > > > > > > >  lib/librte_eal/linuxapp/eal/eal_thread.c  | 152
>> > > > > > > +-
>> > > > > > > >  4 files changed, 148 insertions(+), 305 deletions(-)
>> > > > > > > >
>> > > > > > > > diff --git a/lib/librte_eal/bsdapp/eal/Makefile
>> > > > > > > b/lib/librte_eal/bsdapp/eal/Makefile
>> > > > > > > > index 2357cfa..55971b9 100644
>> > > > > > > > --- a/lib/librte_eal/bsdapp/eal/Makefile
>> > > > > > > > +++ b/lib/librte_eal/bsdapp/eal/Makefile
>> > > > > > > > @@ -87,7 +87,7 @@ CFLAGS_eal_common_log.o := -D_GNU_SOURCE
>> > > > > > > >  # workaround for a gcc bug with noreturn attribute
>> > > > > > > >  # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
>> > > > > > > >  ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
>> > > > > > > > -CFLAGS_eal_thread.o += -Wno-return-type
>> > > > > > > > +CFLAGS_eal_common_thread.o += -Wno-return-type
>> > > > > > > >  CFLAGS_eal_hpet.o += -Wno-return-type
>> > > > > > > >  endif
>> > > &

[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-24 Thread Ravi Kerur
On Fri, Apr 24, 2015 at 11:53 AM, Neil Horman  wrote:

> On Fri, Apr 24, 2015 at 09:45:24AM -0700, Ravi Kerur wrote:
> > On Fri, Apr 24, 2015 at 8:22 AM, Neil Horman 
> wrote:
> >
> > > On Fri, Apr 24, 2015 at 08:14:04AM -0700, Ravi Kerur wrote:
> > > > On Fri, Apr 24, 2015 at 6:51 AM, Neil Horman 
> > > wrote:
> > > >
> > > > > On Thu, Apr 23, 2015 at 02:35:31PM -0700, Ravi Kerur wrote:
> > > > > > Changes in v7
> > > > > > Remove _setname_ pthread calls.
> > > > > > Use rte_gettid() API in RTE_LOG to print thread_id.
> > > > > >
> > > > > > Changes in v6
> > > > > > Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c file.
> > > > > > Add pthread_setname_np/pthread_set_name_np for Linux/FreeBSD
> > > > > > respectively. Plan to use _getname_ in RTE_LOG when available.
> > > > > > Use existing rte_get_systid() in RTE_LOG to print thread_id.
> > > > > >
> > > > > > Changes in v5
> > > > > > Rebase to latest code.
> > > > > >
> > > > > > Changes in v4
> > > > > > None
> > > > > >
> > > > > > Changes in v3
> > > > > > Changed subject to be more explicit on file name inclusion.
> > > > > >
> > > > > > Changes in v2
> > > > > > None
> > > > > >
> > > > > > Changes in v1
> > > > > > eal_thread.c has minor differences between Linux and BSD, move
> > > > > > entire file into common directory.
> > > > > > Use RTE_EXEC_ENV_BSDAPP to differentiate on minor differences.
> > > > > > Rename eal_thread.c to eal_common_thread.c
> > > > > > Makefile changes to reflect file move and name change.
> > > > > > Fix checkpatch warnings.
> > > > > >
> > > > > > Signed-off-by: Ravi Kerur 
> > > > > > ---
> > > > > >  lib/librte_eal/bsdapp/eal/Makefile|   2 +-
> > > > > >  lib/librte_eal/bsdapp/eal/eal_thread.c| 152
> > > > > --
> > > > > >  lib/librte_eal/common/eal_common_thread.c | 147
> > > > > -
> > > > > >  lib/librte_eal/linuxapp/eal/eal_thread.c  | 152
> > > > > +-
> > > > > >  4 files changed, 148 insertions(+), 305 deletions(-)
> > > > > >
> > > > > > diff --git a/lib/librte_eal/bsdapp/eal/Makefile
> > > > > b/lib/librte_eal/bsdapp/eal/Makefile
> > > > > > index 2357cfa..55971b9 100644
> > > > > > --- a/lib/librte_eal/bsdapp/eal/Makefile
> > > > > > +++ b/lib/librte_eal/bsdapp/eal/Makefile
> > > > > > @@ -87,7 +87,7 @@ CFLAGS_eal_common_log.o := -D_GNU_SOURCE
> > > > > >  # workaround for a gcc bug with noreturn attribute
> > > > > >  # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
> > > > > >  ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
> > > > > > -CFLAGS_eal_thread.o += -Wno-return-type
> > > > > > +CFLAGS_eal_common_thread.o += -Wno-return-type
> > > > > >  CFLAGS_eal_hpet.o += -Wno-return-type
> > > > > >  endif
> > > > > >
> > > > > > diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c
> > > > > b/lib/librte_eal/bsdapp/eal/eal_thread.c
> > > > > > index 9a03437..5714b8f 100644
> > > > > > --- a/lib/librte_eal/bsdapp/eal/eal_thread.c
> > > > > > +++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
> > > > > > @@ -35,163 +35,11 @@
> > > > > >  #include 
> > > > > >  #include 
> > > > > >  #include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > >  #include 
> > > > > >
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > > > > > -#include 
> > 

[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-24 Thread Ravi Kerur
On Fri, Apr 24, 2015 at 8:22 AM, Neil Horman  wrote:

> On Fri, Apr 24, 2015 at 08:14:04AM -0700, Ravi Kerur wrote:
> > On Fri, Apr 24, 2015 at 6:51 AM, Neil Horman 
> wrote:
> >
> > > On Thu, Apr 23, 2015 at 02:35:31PM -0700, Ravi Kerur wrote:
> > > > Changes in v7
> > > > Remove _setname_ pthread calls.
> > > > Use rte_gettid() API in RTE_LOG to print thread_id.
> > > >
> > > > Changes in v6
> > > > Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c file.
> > > > Add pthread_setname_np/pthread_set_name_np for Linux/FreeBSD
> > > > respectively. Plan to use _getname_ in RTE_LOG when available.
> > > > Use existing rte_get_systid() in RTE_LOG to print thread_id.
> > > >
> > > > Changes in v5
> > > > Rebase to latest code.
> > > >
> > > > Changes in v4
> > > > None
> > > >
> > > > Changes in v3
> > > > Changed subject to be more explicit on file name inclusion.
> > > >
> > > > Changes in v2
> > > > None
> > > >
> > > > Changes in v1
> > > > eal_thread.c has minor differences between Linux and BSD, move
> > > > entire file into common directory.
> > > > Use RTE_EXEC_ENV_BSDAPP to differentiate on minor differences.
> > > > Rename eal_thread.c to eal_common_thread.c
> > > > Makefile changes to reflect file move and name change.
> > > > Fix checkpatch warnings.
> > > >
> > > > Signed-off-by: Ravi Kerur 
> > > > ---
> > > >  lib/librte_eal/bsdapp/eal/Makefile|   2 +-
> > > >  lib/librte_eal/bsdapp/eal/eal_thread.c| 152
> > > --
> > > >  lib/librte_eal/common/eal_common_thread.c | 147
> > > -
> > > >  lib/librte_eal/linuxapp/eal/eal_thread.c  | 152
> > > +-
> > > >  4 files changed, 148 insertions(+), 305 deletions(-)
> > > >
> > > > diff --git a/lib/librte_eal/bsdapp/eal/Makefile
> > > b/lib/librte_eal/bsdapp/eal/Makefile
> > > > index 2357cfa..55971b9 100644
> > > > --- a/lib/librte_eal/bsdapp/eal/Makefile
> > > > +++ b/lib/librte_eal/bsdapp/eal/Makefile
> > > > @@ -87,7 +87,7 @@ CFLAGS_eal_common_log.o := -D_GNU_SOURCE
> > > >  # workaround for a gcc bug with noreturn attribute
> > > >  # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
> > > >  ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
> > > > -CFLAGS_eal_thread.o += -Wno-return-type
> > > > +CFLAGS_eal_common_thread.o += -Wno-return-type
> > > >  CFLAGS_eal_hpet.o += -Wno-return-type
> > > >  endif
> > > >
> > > > diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c
> > > b/lib/librte_eal/bsdapp/eal/eal_thread.c
> > > > index 9a03437..5714b8f 100644
> > > > --- a/lib/librte_eal/bsdapp/eal/eal_thread.c
> > > > +++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
> > > > @@ -35,163 +35,11 @@
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > >  #include 
> > > >
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > > -#include 
> > > > -
> > > >  #include "eal_private.h"
> > > >  #include "eal_thread.h"
> > > >
> > > > -RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
> > > NAK, these are exported symbols, you can't remove them without going
> > > through the
> > > deprecation process.
> > >
> > >
> > They are not removed/deleted, they are moved from eal_thread.c to
> > eal_common_thread.c file since it is common to both Linux and BSD.
> >
> Then perhaps you forgot to export the symbol?  Its showing up as removed
> on the
> ABI checker utility.
>
> Neil
>

Can you please show me in the current code where it is being exported? I
have only moved definitions to _common_ files, not sure why it should be
exported now.  I searched in the current code for RTE_DEFINE_PER_LCORE

#home/rkerur/dpdk-tmp/dpdk# grep -ir RTE_DEFINE_PER_LCORE *
app/test/test_per_lcore.c:static RTE_DEFINE_PER_LCORE(unsigned, test) =
0x12345678;
lib/librte_eal/linuxapp/eal/eal_thread.c:RTE_DEFINE_PER_LCORE(unsigned,
_lcore_id) = LCORE_ID_ANY;
lib/librte_eal/linuxapp/eal/eal_thread.c:RTE_DEFINE_PER_LCORE(unsigned,
_socket_id) = (unsigned)SOCKET_ID_ANY;
lib/librte_eal/linuxapp/eal/eal_thread.c:RTE_DEFINE_PER_LCORE(rte_cpuset_t,
_cpuset);
lib/librte_eal/bsdapp/eal/eal_thread.c:RTE_DEFINE_PER_LCORE(unsigned,
_lcore_id) = LCORE_ID_ANY;
lib/librte_eal/bsdapp/eal/eal_thread.c:RTE_DEFINE_PER_LCORE(unsigned,
_socket_id) = (unsigned)SOCKET_ID_ANY;
lib/librte_eal/bsdapp/eal/eal_thread.c:RTE_DEFINE_PER_LCORE(rte_cpuset_t,
_cpuset);
lib/librte_eal/common/include/rte_per_lcore.h:#define
RTE_DEFINE_PER_LCORE(type, name)\
lib/librte_eal/common/include/rte_eal.h:static
RTE_DEFINE_PER_LCORE(int, _thread_id) = -1;
lib/librte_eal/common/eal_common_errno.c:RTE_DEFINE_PER_LCORE(int,
_rte_errno);
lib/librte_eal/common/eal_common_errno.c:static
RTE_DEFINE_PER_LCORE(char[RETVAL_SZ], retval);


> > Thanks
> > Ravi
> >
> > Regards
> > > Neil
> > >
> > >
>


[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-24 Thread Ravi Kerur
On Fri, Apr 24, 2015 at 6:51 AM, Neil Horman  wrote:

> On Thu, Apr 23, 2015 at 02:35:31PM -0700, Ravi Kerur wrote:
> > Changes in v7
> > Remove _setname_ pthread calls.
> > Use rte_gettid() API in RTE_LOG to print thread_id.
> >
> > Changes in v6
> > Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c file.
> > Add pthread_setname_np/pthread_set_name_np for Linux/FreeBSD
> > respectively. Plan to use _getname_ in RTE_LOG when available.
> > Use existing rte_get_systid() in RTE_LOG to print thread_id.
> >
> > Changes in v5
> > Rebase to latest code.
> >
> > Changes in v4
> > None
> >
> > Changes in v3
> > Changed subject to be more explicit on file name inclusion.
> >
> > Changes in v2
> > None
> >
> > Changes in v1
> > eal_thread.c has minor differences between Linux and BSD, move
> > entire file into common directory.
> > Use RTE_EXEC_ENV_BSDAPP to differentiate on minor differences.
> > Rename eal_thread.c to eal_common_thread.c
> > Makefile changes to reflect file move and name change.
> > Fix checkpatch warnings.
> >
> > Signed-off-by: Ravi Kerur 
> > ---
> >  lib/librte_eal/bsdapp/eal/Makefile|   2 +-
> >  lib/librte_eal/bsdapp/eal/eal_thread.c| 152
> --
> >  lib/librte_eal/common/eal_common_thread.c | 147
> -
> >  lib/librte_eal/linuxapp/eal/eal_thread.c  | 152
> +-
> >  4 files changed, 148 insertions(+), 305 deletions(-)
> >
> > diff --git a/lib/librte_eal/bsdapp/eal/Makefile
> b/lib/librte_eal/bsdapp/eal/Makefile
> > index 2357cfa..55971b9 100644
> > --- a/lib/librte_eal/bsdapp/eal/Makefile
> > +++ b/lib/librte_eal/bsdapp/eal/Makefile
> > @@ -87,7 +87,7 @@ CFLAGS_eal_common_log.o := -D_GNU_SOURCE
> >  # workaround for a gcc bug with noreturn attribute
> >  # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
> >  ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
> > -CFLAGS_eal_thread.o += -Wno-return-type
> > +CFLAGS_eal_common_thread.o += -Wno-return-type
> >  CFLAGS_eal_hpet.o += -Wno-return-type
> >  endif
> >
> > diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c
> b/lib/librte_eal/bsdapp/eal/eal_thread.c
> > index 9a03437..5714b8f 100644
> > --- a/lib/librte_eal/bsdapp/eal/eal_thread.c
> > +++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
> > @@ -35,163 +35,11 @@
> >  #include 
> >  #include 
> >  #include 
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> >  #include 
> >
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -#include 
> > -
> >  #include "eal_private.h"
> >  #include "eal_thread.h"
> >
> > -RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
> NAK, these are exported symbols, you can't remove them without going
> through the
> deprecation process.
>
>
They are not removed/deleted, they are moved from eal_thread.c to
eal_common_thread.c file since it is common to both Linux and BSD.

Thanks
Ravi

Regards
> Neil
>
>


[dpdk-dev] [PATCH] Implement memcmp using AVX/SSE instructio

2015-04-23 Thread Ravi Kerur
On Thu, Apr 23, 2015 at 7:00 AM, Bruce Richardson <
bruce.richardson at intel.com> wrote:

> On Thu, Apr 23, 2015 at 06:53:44AM -0700, Ravi Kerur wrote:
> > On Thu, Apr 23, 2015 at 2:23 AM, Ananyev, Konstantin <
> > konstantin.ananyev at intel.com> wrote:
> >
> > >
> > >
> > > > -Original Message-
> > > > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Bruce
> Richardson
> > > > Sent: Thursday, April 23, 2015 9:12 AM
> > > > To: Wodkowski, PawelX
> > > > Cc: dev at dpdk.org
> > > > Subject: Re: [dpdk-dev] [PATCH] Implement memcmp using AVX/SSE
> instructio
> > > >
> > > > On Thu, Apr 23, 2015 at 09:24:52AM +0200, Pawel Wodkowski wrote:
> > > > > On 2015-04-22 17:33, Ravi Kerur wrote:
> > > > > >+/**
> > > > > >+ * Compare bytes between two locations. The locations must not
> > > overlap.
> > > > > >+ *
> > > > > >+ * @note This is implemented as a macro, so it's address should
> not
> > > be taken
> > > > > >+ * and care is needed as parameter expressions may be evaluated
> > > multiple times.
> > > > > >+ *
> > > > > >+ * @param src_1
> > > > > >+ *   Pointer to the first source of the data.
> > > > > >+ * @param src_2
> > > > > >+ *   Pointer to the second source of the data.
> > > > > >+ * @param n
> > > > > >+ *   Number of bytes to compare.
> > > > > >+ * @return
> > > > > >+ *   true if equal otherwise false.
> > > > > >+ */
> > > > > >+static inline bool
> > > > > >+rte_memcmp(const void *src_1, const void *src,
> > > > > >+  size_t n) __attribute__((always_inline));
> > > > > You are exposing this as public API, so I think you should follow
> > > > > description bellow or not call this _memcmp_
> > > > >
> > > > > int memcmp(const void *s1, const void *s2, size_t n);
> > > > >
> > > > > The memcmp() function returns an integer less than, equal  to,  or
> > > greater
> > > > > than
> > > > >zero  if  the  first  n  bytes  of s1 is found,
> respectively,
> > > to be
> > > > > less than, to
> > > > >match, or be greater than the first n bytes of s2.
> > > > >
> > > >
> > > > +1 to this point.
> > > >
> > > > Also, if I read your quoted performance numbers in your earlier mail
> > > correctly,
> > > > we are only looking at a 1-4% performance increase. Is the additional
> > > code to
> > > > maintain worth the benefit?
> > >
> > > Yep, same thought here, is it really worth it?
> > > Konstantin
> > >
> > > >
> > > > /Bruce
> > > >
> > > > > --
> > > > > Pawel
> > >
> >
> > I think I haven't exploited every thing x86 has to offer to improve
> > performance. I am looking for inputs. Until we have exhausted all
> avenues I
> > don't want to drop it. One thing I have noticed is that bigger key size
> > gets better performance numbers. I plan to re-run perf tests with 64 and
> > 128 bytes key size and will report back. Any other avenues to try out
> > please let me know I will give it a shot.
> >
> > Thanks,
> > Ravi
>
> Hi Ravi,
>
> are 128 byte comparisons realistic? An IPv6 5-tuple with double vlan tags
> is still
> only 41 bytes, or 48 with some padding added?
> While for a memcpy function, you can see cases where you are going to copy
> a whole
> packet, meaning that sizes of 128B+ (up to multiple k) are realistic, it's
> harder
> to see that for a compare function.
>
> In any case, we await the results of your further optimization work to see
> how
> that goes.
>
>
Hi Bruce,

Couple of things I am planning to try

1. Use _xor_ and _testz_ instructions for comparison instead of _cmpeq_ and
_mask_.
2. I am using unaligned loads, not sure about the penalty, I plan to try
with aligned loads if address is aligned and compare results.

Agreed that with just L3 or even if we go with L2 + L3 + L4 tuples it will
not exceed 64 bytes, 128 bytes is just a stretch for some weird MPLSoGRE
header formats.

My focus is currently on improving performance for < 64 bytes and < 128
bytes key lengths only.

Thanks,
Ravi

Regards,
> /Bruce
>


[dpdk-dev] [PATCH v7 6/6] Move common functions in eal_pci.c

2015-04-23 Thread Ravi Kerur
Changes in v7
Rebase to latest code.

Changes in v6
Split changes due to complexity. v6 includes moving
rte_eal_pci_probe_one_driver function and its associated
utility functions only.

Changes in v5
Rebase to latest code.
Removed RTE_EXEC_ENV_BSDAPP from earlier changes.

Changes in v4
Move common functions in eal_pci.c to librte_eal/common/
eal_common_pci.c file.

Following functions are moved to eal_common_pci.c file.

void *pci_map_resource(void *requested_addr, const int vfio_fd,
  const char *devname, off_t offset, size_t size);
int pci_addr_comparison(struct rte_pci_addr *addr,
struct rte_pci_addr *addr2);
int rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,
struct rte_pci_device *dev);

Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in
common function.
Fix checkpatch warnings and errors.

Changes in v3
N/A

Changes in v2
N/A

Changes in v1
N/A

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/eal_pci.c| 72 +---
 lib/librte_eal/common/eal_common_pci.c | 72 
 lib/librte_eal/common/eal_private.h| 39 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 75 +-
 4 files changed, 113 insertions(+), 145 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 30f0232..f21b5b6 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -111,7 +111,7 @@ static struct rte_tailq_elem rte_uio_tailq = {
 EAL_REGISTER_TAILQ(rte_uio_tailq)

 /* unbind kernel driver for this device */
-static int
+int
 pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)
 {
RTE_LOG(ERR, EAL, "RTE_PCI_DRV_FORCE_UNBIND flag is not implemented "
@@ -274,6 +274,13 @@ pci_uio_map_resource(struct rte_pci_device *dev)
return (0);
 }

+/* map the PCI resource of a PCI device in virtual memory */
+int
+pci_map_device(struct rte_pci_device *dev)
+{
+   return pci_uio_map_resource(dev);
+}
+
 /* Scan one pci sysfs entry, and fill the devices list from it. */
 static int
 pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
@@ -426,68 +433,11 @@ error:
 }

 /*
- * If vendor/device ID match, call the devinit() function of the
- * driver.
+ * This function is a no-op in BSD.
  */
-int
-rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device 
*dev)
+void
+pci_config_space_set(struct rte_pci_device *dev __rte_unused)
 {
-   struct rte_pci_id *id_table;
-   int ret;
-
-   for (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) {
-
-   /* check if device's identifiers match the driver's ones */
-   if (id_table->vendor_id != dev->id.vendor_id &&
-   id_table->vendor_id != PCI_ANY_ID)
-   continue;
-   if (id_table->device_id != dev->id.device_id &&
-   id_table->device_id != PCI_ANY_ID)
-   continue;
-   if (id_table->subsystem_vendor_id != 
dev->id.subsystem_vendor_id &&
-   id_table->subsystem_vendor_id != PCI_ANY_ID)
-   continue;
-   if (id_table->subsystem_device_id != 
dev->id.subsystem_device_id &&
-   id_table->subsystem_device_id != PCI_ANY_ID)
-   continue;
-
-   struct rte_pci_addr *loc = >addr;
-
-   RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket 
%i\n",
-   loc->domain, loc->bus, loc->devid, 
loc->function,
-   dev->numa_node);
-
-   RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", 
dev->id.vendor_id,
-   dev->id.device_id, dr->name);
-
-   /* no initialization when blacklisted, return without error */
-   if (dev->devargs != NULL &&
-   dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
-
-   RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not 
initializing\n");
-   return 0;
-   }
-
-   if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
-   /* map resources for devices that use igb_uio */
-   ret = pci_uio_map_resource(dev);
-   if (ret != 0)
-   return ret;
-   } else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
-  rte_eal_process_type() == RTE_PROC_PRIMARY) {
-   /* unbind current driver */
-   if (pci_unbind_kernel_driver(dev) < 0)
-   

[dpdk-dev] [PATCH v7 5/6] Move common functions in eal_memory.c

2015-04-23 Thread Ravi Kerur
Changes in v7
None

Changes in v6
Removed unnecessary comments in function declaration.

Changes in v5
Rebase to latest code.

Changes in v4
Make rte_eal_hugepage_init and rte_eal_hugepage_attach as
wrapper functions for BSD.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
Use common function names rte_eal_hugepage_init and
rte_eal_hugepage_attach for BSD and Linux. Update comments about its
actuality in function declaration.

Changes in v1
Move common functions in eal_memory.c to librte_eal/common/
eal_common_memory.c file.

Following functions are moved to eal_common_memory.c file

static int rte_eal_memdevice_init(void); int rte_eal_memory_init(void);

Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/eal_memory.c| 47 +++
 lib/librte_eal/common/eal_common_memory.c | 38 +++--
 lib/librte_eal/common/eal_private.h   | 20 +++--
 lib/librte_eal/linuxapp/eal/eal_memory.c  | 36 ++-
 4 files changed, 72 insertions(+), 69 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_memory.c 
b/lib/librte_eal/bsdapp/eal/eal_memory.c
index 33ebd0f..77c27b3 100644
--- a/lib/librte_eal/bsdapp/eal/eal_memory.c
+++ b/lib/librte_eal/bsdapp/eal/eal_memory.c
@@ -59,7 +59,7 @@ rte_mem_virt2phy(const void *virtaddr)
return RTE_BAD_PHYS_ADDR;
 }

-static int
+static inline int
 rte_eal_contigmem_init(void)
 {
struct rte_mem_config *mcfg;
@@ -131,7 +131,16 @@ rte_eal_contigmem_init(void)
return 0;
 }

-static int
+/*
+ * Wrapper function to initialize contigmem.
+ */
+int
+rte_eal_hugepage_init(void)
+{
+   return rte_eal_contigmem_init();
+}
+
+static inline int
 rte_eal_contigmem_attach(void)
 {
const struct hugepage_info *hpi;
@@ -192,35 +201,11 @@ error:
return -1;
 }

-
-static int
-rte_eal_memdevice_init(void)
-{
-   struct rte_config *config;
-
-   if (rte_eal_process_type() == RTE_PROC_SECONDARY)
-   return 0;
-
-   config = rte_eal_get_configuration();
-   config->mem_config->nchannel = internal_config.force_nchannel;
-   config->mem_config->nrank = internal_config.force_nrank;
-
-   return 0;
-}
-
-/* init memory subsystem */
+/*
+ * Wrapper function to attach contigmem.
+ */
 int
-rte_eal_memory_init(void)
+rte_eal_hugepage_attach(void)
 {
-   RTE_LOG(INFO, EAL, "Setting up physically contiguous memory...\n");
-   const int retval = rte_eal_process_type() == RTE_PROC_PRIMARY ?
-   rte_eal_contigmem_init() :
-   rte_eal_contigmem_attach();
-   if (retval < 0)
-   return -1;
-
-   if (internal_config.no_shconf == 0 && rte_eal_memdevice_init() < 0)
-   return -1;
-
-   return 0;
+   return rte_eal_contigmem_attach();
 }
diff --git a/lib/librte_eal/common/eal_common_memory.c 
b/lib/librte_eal/common/eal_common_memory.c
index 9a07b1e..10ff0bc 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -45,6 +45,7 @@
 #include 

 #include "eal_private.h"
+#include "eal_internal_cfg.h"

 /*
  * Return a pointer to a read-only table of struct rte_physmem_desc
@@ -69,7 +70,7 @@ rte_eal_get_physmem_size(void)
/* get pointer to global configuration */
mcfg = rte_eal_get_configuration()->mem_config;

-   for (i=0; i<RTE_MAX_MEMSEG; i++) {
+   for (i = 0; i < RTE_MAX_MEMSEG; i++) {
if (mcfg->memseg[i].addr == NULL)
break;

@@ -89,7 +90,7 @@ rte_dump_physmem_layout(FILE *f)
/* get pointer to global configuration */
mcfg = rte_eal_get_configuration()->mem_config;

-   for (i=0; i<RTE_MAX_MEMSEG; i++) {
+   for (i = 0; i < RTE_MAX_MEMSEG; i++) {
if (mcfg->memseg[i].addr == NULL)
break;

@@ -118,3 +119,36 @@ unsigned rte_memory_get_nrank(void)
 {
return rte_eal_get_configuration()->mem_config->nrank;
 }
+
+static int
+rte_eal_memdevice_init(void)
+{
+   struct rte_config *config;
+
+   if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+   return 0;
+
+   config = rte_eal_get_configuration();
+   config->mem_config->nchannel = internal_config.force_nchannel;
+   config->mem_config->nrank = internal_config.force_nrank;
+
+   return 0;
+}
+
+/* init memory subsystem */
+int
+rte_eal_memory_init(void)
+{
+   RTE_LOG(INFO, EAL, "Setting up physically contiguous memory...\n");
+   const int retval = rte_eal_process_type() == RTE_PROC_PRIMARY ?
+   rte_eal_hugepage_init() :
+   rte_eal_hugepage_attach();
+
+   if (retval < 0)
+   return -1;
+
+   if (internal_config.no_shconf == 0 && rte_eal_memdevice_init() &l

[dpdk-dev] [PATCH v7 4/6] Move common functions in eal_timer.c

2015-04-23 Thread Ravi Kerur
Changes in v7
None

Changes in v6
Added new line between Copyright and header file inclusion
in eal_common_timer.c.

Changes in v5
Rebase to latest code.

Changes in v4
Removed extern declaration of eal_tsc_resolution_hz,
instead provided _set_ API.
Make set_tsc_freq_from_clock as wrapper function for BSD.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
Use common function name set_tsc_freq_from_sysctl for BSD and Linux.
Update comments about its actuality in function declaration.

Changes in v1
Move common functions in eal_timer.c to librte_eal/common/
eal_common_timer.c file.

Following functions are  moved to eal_common_timer.c file

void rte_delay_us(unsigned us);
uint64_t rte_get_tsc_hz(void);
static void set_tsc_freq_fallback(void);
void set_tsc_freq(void);

Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile   |   1 +
 lib/librte_eal/bsdapp/eal/eal_timer.c|  52 +++-
 lib/librte_eal/common/eal_common_timer.c | 102 +++
 lib/librte_eal/common/eal_private.h  |  24 
 lib/librte_eal/linuxapp/eal/Makefile |   1 +
 lib/librte_eal/linuxapp/eal/eal_timer.c  |  55 ++---
 6 files changed, 140 insertions(+), 95 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_timer.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index 1da0410..d8e6ced 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -83,6 +83,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_mem_cfg.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_proc_type.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_app_usage.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_timer.c

 CFLAGS_eal.o := -D_GNU_SOURCE
 #CFLAGS_eal_thread.o := -D_GNU_SOURCE
diff --git a/lib/librte_eal/bsdapp/eal/eal_timer.c 
b/lib/librte_eal/bsdapp/eal/eal_timer.c
index 7147abe..ee7a5ac 100644
--- a/lib/librte_eal/bsdapp/eal/eal_timer.c
+++ b/lib/librte_eal/bsdapp/eal/eal_timer.c
@@ -55,29 +55,12 @@

 enum timer_source eal_timer_source = EAL_TIMER_TSC;

-/* The frequency of the RDTSC timer resolution */
-static uint64_t eal_tsc_resolution_hz = 0;
-
-void
-rte_delay_us(unsigned us)
-{
-   const uint64_t start = rte_get_timer_cycles();
-   const uint64_t ticks = (uint64_t)us * rte_get_timer_hz() / 1E6;
-   while ((rte_get_timer_cycles() - start) < ticks)
-   rte_pause();
-}
-
-uint64_t
-rte_get_tsc_hz(void)
-{
-   return eal_tsc_resolution_hz;
-}
-
 static int
 set_tsc_freq_from_sysctl(void)
 {
size_t sz;
int tmp;
+   uint64_t tsc_hz;

sz = sizeof(tmp);
tmp = 0;
@@ -94,42 +77,23 @@ set_tsc_freq_from_sysctl(void)
else if (tmp != 1)
RTE_LOG(WARNING, EAL, "TSC is not invariant\n");

-   sz = sizeof(eal_tsc_resolution_hz);
-   if (sysctlbyname("machdep.tsc_freq", _tsc_resolution_hz, , NULL, 
0)) {
+   sz = sizeof(tsc_hz);
+   if (sysctlbyname("machdep.tsc_freq", _hz, , NULL, 0)) {
RTE_LOG(WARNING, EAL, "%s\n", strerror(errno));
return -1;
}
+   rte_set_tsc_hz(tsc_hz);

return 0;
 }

-static void
-set_tsc_freq_fallback(void)
-{
-   RTE_LOG(WARNING, EAL, "WARNING: clock_gettime cannot use "
-   "CLOCK_MONOTONIC_RAW and HPET is not available"
-   " - clock timings may be less accurate.\n");
-   /* assume that the sleep(1) will sleep for 1 second */
-   uint64_t start = rte_rdtsc();
-   sleep(1);
-   eal_tsc_resolution_hz = rte_rdtsc() - start;
-}
-
 /*
- * This function measures the TSC frequency. It uses a variety of approaches.
- *
- * 1. Read the TSC frequency value provided by the kernel
- * 2. If above does not work, just sleep for 1 second and tune off that,
- *printing a warning about inaccuracy of timing
+ * Wrapper function to get TSC frequency from sysctl.
  */
-static void
-set_tsc_freq(void)
+int
+set_tsc_freq_from_clock(void)
 {
-   if (set_tsc_freq_from_sysctl() < 0)
-   set_tsc_freq_fallback();
-
-   RTE_LOG(INFO, EAL, "TSC frequency is ~%"PRIu64" KHz\n",
-   eal_tsc_resolution_hz/1000);
+   return set_tsc_freq_from_sysctl();
 }

 int
diff --git a/lib/librte_eal/common/eal_common_timer.c 
b/lib/librte_eal/common/eal_common_timer.c
new file mode 100644
index 000..5fddd6e
--- /dev/null
+++ b/lib/librte_eal/common/eal_common_timer.c
@@ -0,0 +1,102 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with o

[dpdk-dev] [PATCH v7 3/6] Move common functions in eal_lcore.c

2015-04-23 Thread Ravi Kerur
Changes in v7
None

Changes in v6
None

Changes in v5
Rebase to latest code.

Changes in v4
Implement cpu_detected() for BSD.
Have common RTE_LOG for Linux and BSD in rte_eal_cpu_init().
Remove RTE_EXEC_ENV_BSDAPP in common file.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
None

Changes in v1
Move common function in eal_lcore.c to librte_eal/common/
eal_common_lcore.c file.

Following function is  moved to eal_common_lcore.c file

int rte_eal_cpu_init(void);

Use RTE_EXEC_ENV_BSDAPP to differentiate minor differences in
common function.
Makefile changes to reflect new file added.
Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile   |   1 +
 lib/librte_eal/bsdapp/eal/eal_lcore.c|  72 +
 lib/librte_eal/common/eal_common_lcore.c | 107 +++
 lib/librte_eal/common/eal_private.h  |  14 
 lib/librte_eal/linuxapp/eal/Makefile |   2 +
 lib/librte_eal/linuxapp/eal/eal_lcore.c  |  66 ++-
 6 files changed, 143 insertions(+), 119 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_lcore.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index 5076a05..1da0410 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -82,6 +82,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_sysfs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_mem_cfg.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_proc_type.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_app_usage.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_lcore.c

 CFLAGS_eal.o := -D_GNU_SOURCE
 #CFLAGS_eal_thread.o := -D_GNU_SOURCE
diff --git a/lib/librte_eal/bsdapp/eal/eal_lcore.c 
b/lib/librte_eal/bsdapp/eal/eal_lcore.c
index 162fb4f..b47eb1b 100644
--- a/lib/librte_eal/bsdapp/eal/eal_lcore.c
+++ b/lib/librte_eal/bsdapp/eal/eal_lcore.c
@@ -44,11 +44,14 @@
 #include "eal_thread.h"

 /* No topology information available on FreeBSD including NUMA info */
-#define cpu_core_id(X) 0
-#define cpu_socket_id(X) 0
+unsigned
+eal_cpu_core_id(__rte_unused unsigned lcore_id)
+{
+   return 0;
+}

 static int
-get_ncpus(void)
+eal_get_ncpus(void)
 {
int mib[2] = {CTL_HW, HW_NCPU};
int ncpu;
@@ -59,63 +62,18 @@ get_ncpus(void)
return ncpu;
 }

-/*
- * fill the cpu_info structure with as much info as we can get.
- * code is similar to linux version, but sadly available info is less.
- */
-int
-rte_eal_cpu_init(void)
+unsigned
+eal_cpu_socket_id(__rte_unused unsigned cpu_id)
 {
-   /* pointer to global configuration */
-   struct rte_config *config = rte_eal_get_configuration();
-   unsigned lcore_id;
-   unsigned count = 0;
-
-   const unsigned ncpus = get_ncpus();
-   /*
-* Parse the maximum set of logical cores, detect the subset of running
-* ones and enable them by default.
-*/
-   for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
-   /* init cpuset for per lcore config */
-   CPU_ZERO(_config[lcore_id].cpuset);
-
-   lcore_config[lcore_id].detected = (lcore_id < ncpus);
-   if (lcore_config[lcore_id].detected == 0) {
-   config->lcore_role[lcore_id] = ROLE_OFF;
-   continue;
-   }
-
-   /* By default, lcore 1:1 map to cpu id */
-   CPU_SET(lcore_id, _config[lcore_id].cpuset);
-
-   /* By default, each detected core is enabled */
-   config->lcore_role[lcore_id] = ROLE_RTE;
-   lcore_config[lcore_id].core_id = cpu_core_id(lcore_id);
-   lcore_config[lcore_id].socket_id = cpu_socket_id(lcore_id);
-   if (lcore_config[lcore_id].socket_id >= RTE_MAX_NUMA_NODES)
-#ifdef RTE_EAL_ALLOW_INV_SOCKET_ID
-   lcore_config[lcore_id].socket_id = 0;
-#else
-   rte_panic("Socket ID (%u) is greater than "
-   "RTE_MAX_NUMA_NODES (%d)\n",
-   lcore_config[lcore_id].socket_id, 
RTE_MAX_NUMA_NODES);
-#endif
-   RTE_LOG(DEBUG, EAL, "Detected lcore %u\n",
-   lcore_id);
-   count++;
-   }
-   /* Set the count of enabled logical cores of the EAL configuration */
-   config->lcore_count = count;
-   RTE_LOG(DEBUG, EAL, "Support maximum %u logical core(s) by 
configuration.\n",
-   RTE_MAX_LCORE);
-   RTE_LOG(DEBUG, EAL, "Detected %u lcore(s)\n", config->lcore_count);
-
return 0;
 }

-unsigned
-eal_cpu_socket_id(__rte_unused unsigned cpu_id)
+/* Check if a cpu is present by the presence of the
+ * cpu information for it.
+ */
+int
+eal_cpu_detected(unsigned lcore_id)
 {
-

[dpdk-dev] [PATCH v7 2/6] Move common functions in eal.c

2015-04-23 Thread Ravi Kerur
Changes in v7
Fix clang and ICC compilation errors.

Changes in v6
Split eal_common_system.c and eal_common_runtime.c into
eal_common_sysfs.c
eal_common_mem_cfg.c
eal_common_proc_type.c
eal_comm_app_usage.c
based on functionality.

Changes in v5
Rebase to latest code.

Changes in v4
Remove eal_externs.h file, instead use  _get_ and _set_ APIS
to access those variables.
Split eal_common.c into eal_common_system.c and
and eal_common_runtime.c
rte_eal prefix functions are moved to _runtime_ and
eal prefix functions are moved to _system_ files respectively.

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
In function rte_eal_config_create remove #ifdef _BSDAPP_
and initialize mem_cfg_addr unconditionally.

Changes in v1
Move common functions in eal.c to librte_eal/common/eal_common.c.

Following functions are moved to eal_common.c file.

struct rte_config *rte_eal_get_configuration(void);
int eal_parse_sysfs_value(const char *filename, unsigned long *val);
static void rte_eal_config_create(void);
enum rte_proc_type_t eal_proc_type_detect(void);
void rte_eal_config_init(void);
rte_usage_hook_t rte_set_application_usage_hook(rte_usage_hook_t
usage_func);
inline size_t eal_get_hugepage_mem_size(void);
void eal_check_mem_on_local_socket(void);
int sync_func(__attribute__((unused)) void *arg);
inline void rte_eal_mcfg_complete(void);
int rte_eal_has_hugepages(void);
enum rte_lcore_role_t rte_eal_lcore_role(unsigned lcore_id);
enum rte_proc_type_t rte_eal_process_type(void);

Makefile changes to reflect new files added.
Fix checkpatch warnings and errors.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile   |   4 +
 lib/librte_eal/bsdapp/eal/eal.c  | 271 +++-
 lib/librte_eal/common/eal_common_app_usage.c |  63 ++
 lib/librte_eal/common/eal_common_mem_cfg.c   | 217 
 lib/librte_eal/common/eal_common_proc_type.c |  58 ++
 lib/librte_eal/common/eal_common_sysfs.c | 163 +++
 lib/librte_eal/common/eal_hugepages.h|   1 +
 lib/librte_eal/common/eal_private.h  |  78 +++
 lib/librte_eal/common/include/rte_eal.h  |   4 +
 lib/librte_eal/linuxapp/eal/Makefile |   4 +
 lib/librte_eal/linuxapp/eal/eal.c| 296 ---
 11 files changed, 668 insertions(+), 491 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_app_usage.c
 create mode 100644 lib/librte_eal/common/eal_common_mem_cfg.c
 create mode 100644 lib/librte_eal/common/eal_common_proc_type.c
 create mode 100644 lib/librte_eal/common/eal_common_sysfs.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index 55971b9..5076a05 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -78,6 +78,10 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_sysfs.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_mem_cfg.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_proc_type.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_app_usage.c

 CFLAGS_eal.o := -D_GNU_SOURCE
 #CFLAGS_eal_thread.o := -D_GNU_SOURCE
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 871d5f4..645500c 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -80,29 +80,6 @@
 #include "eal_hugepages.h"
 #include "eal_options.h"

-#define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)
-
-/* Allow the application to print its usage message too if set */
-static rte_usage_hook_trte_application_usage_hook = NULL;
-/* early configuration structure, when memory config is not mmapped */
-static struct rte_mem_config early_mem_config;
-
-/* define fd variable here, because file needs to be kept open for the
- * duration of the program, as we hold a write lock on it in the primary proc 
*/
-static int mem_cfg_fd = -1;
-
-static struct flock wr_lock = {
-   .l_type = F_WRLCK,
-   .l_whence = SEEK_SET,
-   .l_start = offsetof(struct rte_mem_config, memseg),
-   .l_len = sizeof(early_mem_config.memseg),
-};
-
-/* Address of global and public configuration */
-static struct rte_config rte_config = {
-   .mem_config = _mem_config,
-};
-
 /* internal configuration (per-core) */
 struct lcore_config lcore_config[RTE_MAX_LCORE];

@@ -112,160 +89,57 @@ struct internal_config internal_config;
 /* used by rte_rdtsc() */
 int rte_cycles_vmware_tsc_map;

-/* Return a pointer to the configuration structure */
-struct rte_config *
-rte_eal_get_configuration(void)
-{
-   return _config;
-}
-
-/* parse a sysfs (or other) file containing one i

[dpdk-dev] [PATCH v7 1/6] Move common functions in eal_thread.c

2015-04-23 Thread Ravi Kerur
Changes in v7
Remove _setname_ pthread calls.
Use rte_gettid() API in RTE_LOG to print thread_id.

Changes in v6
Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c file.
Add pthread_setname_np/pthread_set_name_np for Linux/FreeBSD
respectively. Plan to use _getname_ in RTE_LOG when available.
Use existing rte_get_systid() in RTE_LOG to print thread_id.

Changes in v5
Rebase to latest code.

Changes in v4
None

Changes in v3
Changed subject to be more explicit on file name inclusion.

Changes in v2
None

Changes in v1
eal_thread.c has minor differences between Linux and BSD, move
entire file into common directory.
Use RTE_EXEC_ENV_BSDAPP to differentiate on minor differences.
Rename eal_thread.c to eal_common_thread.c
Makefile changes to reflect file move and name change.
Fix checkpatch warnings.

Signed-off-by: Ravi Kerur 
---
 lib/librte_eal/bsdapp/eal/Makefile|   2 +-
 lib/librte_eal/bsdapp/eal/eal_thread.c| 152 --
 lib/librte_eal/common/eal_common_thread.c | 147 -
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 152 +-
 4 files changed, 148 insertions(+), 305 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index 2357cfa..55971b9 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -87,7 +87,7 @@ CFLAGS_eal_common_log.o := -D_GNU_SOURCE
 # workaround for a gcc bug with noreturn attribute
 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
 ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
-CFLAGS_eal_thread.o += -Wno-return-type
+CFLAGS_eal_common_thread.o += -Wno-return-type
 CFLAGS_eal_hpet.o += -Wno-return-type
 endif

diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index 9a03437..5714b8f 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -35,163 +35,11 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 

-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
 #include "eal_private.h"
 #include "eal_thread.h"

-RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
-RTE_DEFINE_PER_LCORE(unsigned, _socket_id) = (unsigned)SOCKET_ID_ANY;
-RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);
-
-/*
- * Send a message to a slave lcore identified by slave_id to call a
- * function f with argument arg. Once the execution is done, the
- * remote lcore switch in FINISHED state.
- */
-int
-rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)
-{
-   int n;
-   char c = 0;
-   int m2s = lcore_config[slave_id].pipe_master2slave[1];
-   int s2m = lcore_config[slave_id].pipe_slave2master[0];
-
-   if (lcore_config[slave_id].state != WAIT)
-   return -EBUSY;
-
-   lcore_config[slave_id].f = f;
-   lcore_config[slave_id].arg = arg;
-
-   /* send message */
-   n = 0;
-   while (n == 0 || (n < 0 && errno == EINTR))
-   n = write(m2s, , 1);
-   if (n < 0)
-   rte_panic("cannot write on configuration pipe\n");
-
-   /* wait ack */
-   do {
-   n = read(s2m, , 1);
-   } while (n < 0 && errno == EINTR);
-
-   if (n <= 0)
-   rte_panic("cannot read on configuration pipe\n");
-
-   return 0;
-}
-
-/* set affinity for current thread */
-static int
-eal_thread_set_affinity(void)
-{
-   unsigned lcore_id = rte_lcore_id();
-
-   /* acquire system unique id  */
-   rte_gettid();
-
-   /* update EAL thread core affinity */
-   return rte_thread_set_affinity(_config[lcore_id].cpuset);
-}
-
-void eal_thread_init_master(unsigned lcore_id)
-{
-   /* set the lcore ID in per-lcore memory area */
-   RTE_PER_LCORE(_lcore_id) = lcore_id;
-
-   /* set CPU affinity */
-   if (eal_thread_set_affinity() < 0)
-   rte_panic("cannot set affinity\n");
-}
-
-/* main loop of threads */
-__attribute__((noreturn)) void *
-eal_thread_loop(__attribute__((unused)) void *arg)
-{
-   char c;
-   int n, ret;
-   unsigned lcore_id;
-   pthread_t thread_id;
-   int m2s, s2m;
-   char cpuset[RTE_CPU_AFFINITY_STR_LEN];
-
-   thread_id = pthread_self();
-
-   /* retrieve our lcore_id from the configuration structure */
-   RTE_LCORE_FOREACH_SLAVE(lcore_id) {
-   if (thread_id == lcore_config[lcore_id].thread_id)
-   break;
-   }
-   if (lcore_id == RTE_MAX_LCORE)
-   rte_panic("cannot retrieve lcore id\n");
-
-   m2s = lcore_config[lcore_id].pipe_master2slave[0];
-   s2m = lcore_config[lcore_id].pipe_slave2master[1];
-
-   /* set the lcore ID in per-lcore memory area */
-   RTE_PER_LCORE(_lcore_id) = lcore_id;
-
-   /* set CPU a

[dpdk-dev] [PATCH v7 0/6] Move EAL common functions.

2015-04-23 Thread Ravi Kerur
Changes in v7 includes
Fix clang and ICC compilation errors reported by Bruce.
Remove pthread _setname_ APIs introduced in v6 as a separate
patch is sent.

Testing:
Linux - Ubuntu x86_64 14.04
Compilation successful (x86_64-native-linuxapp-gcc
and x86_64-native-linuxapp-clang).
"make test" results match baseline code.
testpmd utility on I217/I218 Intel chipset.

FreeBSD 10.0 x86_64
Compilation successful (x86_64-native-bsdapp-gcc).
helloworld. 

Ravi Kerur (6):
  Move common functions in eal_thread.c
  Move common functions in eal.c
  Move common functions in eal_lcore.c
  Move common functions in eal_timer.c
  Move common functions in eal_memory.c
  Move common functions in eal_pci.c

 lib/librte_eal/bsdapp/eal/Makefile   |   8 +-
 lib/librte_eal/bsdapp/eal/eal.c  | 271 +++-
 lib/librte_eal/bsdapp/eal/eal_lcore.c|  72 ++-
 lib/librte_eal/bsdapp/eal/eal_memory.c   |  47 ++---
 lib/librte_eal/bsdapp/eal/eal_pci.c  |  72 +--
 lib/librte_eal/bsdapp/eal/eal_thread.c   | 152 --
 lib/librte_eal/bsdapp/eal/eal_timer.c|  52 +
 lib/librte_eal/common/eal_common_app_usage.c |  63 ++
 lib/librte_eal/common/eal_common_lcore.c | 107 ++
 lib/librte_eal/common/eal_common_mem_cfg.c   | 217 
 lib/librte_eal/common/eal_common_memory.c|  38 +++-
 lib/librte_eal/common/eal_common_pci.c   |  72 +++
 lib/librte_eal/common/eal_common_proc_type.c |  58 ++
 lib/librte_eal/common/eal_common_sysfs.c | 163 +++
 lib/librte_eal/common/eal_common_thread.c| 147 -
 lib/librte_eal/common/eal_common_timer.c | 102 +
 lib/librte_eal/common/eal_hugepages.h|   1 +
 lib/librte_eal/common/eal_private.h  | 171 +++-
 lib/librte_eal/common/include/rte_eal.h  |   4 +
 lib/librte_eal/linuxapp/eal/Makefile |   7 +
 lib/librte_eal/linuxapp/eal/eal.c| 296 ---
 lib/librte_eal/linuxapp/eal/eal_lcore.c  |  66 +-
 lib/librte_eal/linuxapp/eal/eal_memory.c |  36 +---
 lib/librte_eal/linuxapp/eal/eal_pci.c|  75 +--
 lib/librte_eal/linuxapp/eal/eal_thread.c | 152 +-
 lib/librte_eal/linuxapp/eal/eal_timer.c  |  55 +
 26 files changed, 1282 insertions(+), 1222 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_app_usage.c
 create mode 100644 lib/librte_eal/common/eal_common_lcore.c
 create mode 100644 lib/librte_eal/common/eal_common_mem_cfg.c
 create mode 100644 lib/librte_eal/common/eal_common_proc_type.c
 create mode 100644 lib/librte_eal/common/eal_common_sysfs.c
 create mode 100644 lib/librte_eal/common/eal_common_timer.c

-- 
1.9.1



[dpdk-dev] [PATCH] Implement memcmp using AVX/SSE instructio

2015-04-23 Thread Ravi Kerur
On Thu, Apr 23, 2015 at 2:23 AM, Ananyev, Konstantin <
konstantin.ananyev at intel.com> wrote:

>
>
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Bruce Richardson
> > Sent: Thursday, April 23, 2015 9:12 AM
> > To: Wodkowski, PawelX
> > Cc: dev at dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] Implement memcmp using AVX/SSE instructio
> >
> > On Thu, Apr 23, 2015 at 09:24:52AM +0200, Pawel Wodkowski wrote:
> > > On 2015-04-22 17:33, Ravi Kerur wrote:
> > > >+/**
> > > >+ * Compare bytes between two locations. The locations must not
> overlap.
> > > >+ *
> > > >+ * @note This is implemented as a macro, so it's address should not
> be taken
> > > >+ * and care is needed as parameter expressions may be evaluated
> multiple times.
> > > >+ *
> > > >+ * @param src_1
> > > >+ *   Pointer to the first source of the data.
> > > >+ * @param src_2
> > > >+ *   Pointer to the second source of the data.
> > > >+ * @param n
> > > >+ *   Number of bytes to compare.
> > > >+ * @return
> > > >+ *   true if equal otherwise false.
> > > >+ */
> > > >+static inline bool
> > > >+rte_memcmp(const void *src_1, const void *src,
> > > >+  size_t n) __attribute__((always_inline));
> > > You are exposing this as public API, so I think you should follow
> > > description bellow or not call this _memcmp_
> > >
> > > int memcmp(const void *s1, const void *s2, size_t n);
> > >
> > > The memcmp() function returns an integer less than, equal  to,  or
> greater
> > > than
> > >zero  if  the  first  n  bytes  of s1 is found, respectively,
> to be
> > > less than, to
> > >match, or be greater than the first n bytes of s2.
> > >
> >
> > +1 to this point.
> >
> > Also, if I read your quoted performance numbers in your earlier mail
> correctly,
> > we are only looking at a 1-4% performance increase. Is the additional
> code to
> > maintain worth the benefit?
>
> Yep, same thought here, is it really worth it?
> Konstantin
>
> >
> > /Bruce
> >
> > > --
> > > Pawel
>

I think I haven't exploited every thing x86 has to offer to improve
performance. I am looking for inputs. Until we have exhausted all avenues I
don't want to drop it. One thing I have noticed is that bigger key size
gets better performance numbers. I plan to re-run perf tests with 64 and
128 bytes key size and will report back. Any other avenues to try out
please let me know I will give it a shot.

Thanks,
Ravi


[dpdk-dev] [PATCH] Implement memcmp using AVX/SSE instructio

2015-04-23 Thread Ravi Kerur
On Thu, Apr 23, 2015 at 12:24 AM, Pawel Wodkowski <
pawelx.wodkowski at intel.com> wrote:

> On 2015-04-22 17:33, Ravi Kerur wrote:
>
>> +/**
>> + * Compare bytes between two locations. The locations must not overlap.
>> + *
>> + * @note This is implemented as a macro, so it's address should not be
>> taken
>> + * and care is needed as parameter expressions may be evaluated multiple
>> times.
>> + *
>> + * @param src_1
>> + *   Pointer to the first source of the data.
>> + * @param src_2
>> + *   Pointer to the second source of the data.
>> + * @param n
>> + *   Number of bytes to compare.
>> + * @return
>> + *   true if equal otherwise false.
>> + */
>> +static inline bool
>> +rte_memcmp(const void *src_1, const void *src,
>> +   size_t n) __attribute__((always_inline));
>>
> You are exposing this as public API, so I think you should follow
> description bellow or not call this _memcmp_
>
> int memcmp(const void *s1, const void *s2, size_t n);
>
> The memcmp() function returns an integer less than, equal  to,  or
> greater  than
>zero  if  the  first  n  bytes  of s1 is found, respectively, to be
> less than, to
>match, or be greater than the first n bytes of s2.
>
>
This can/will be fixed in future version.

Thanks.

> --
> Pawel
>


[dpdk-dev] [PATCH] Use pthread_setname APIs

2015-04-22 Thread Ravi Kerur
use pthread_setname_np and pthread_set_name_np for Linux and
FreeBSD respectively.
Restrict pthread name len to 16 via config for both Linux and FreeBSD.

Testing:
Linux:
Compiled with both clang and gcc (x86_64-native-linuxapp-gcc and
x86_64-native-linuxapp-clang).
Compiled examples/vhost.
make test.
testpmd with I217 NIC.
Check /proc//comm file for names.

FreeBSD:
Compiled with gcc (x86_64-native-bsdapp-gcc)
helloworld/testpmd with I218 NIC.

Signed-off-by: Ravi Kerur 
---
 config/common_bsdapp   |  5 +
 config/common_linuxapp |  5 +
 examples/vhost/Makefile|  1 +
 examples/vhost/main.c  | 18 --
 examples/vhost_xen/Makefile|  1 +
 examples/vhost_xen/main.c  | 20 ++--
 lib/librte_eal/bsdapp/eal/eal.c|  7 +++
 lib/librte_eal/linuxapp/eal/Makefile   |  2 ++
 lib/librte_eal/linuxapp/eal/eal.c  | 11 +++
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 20 +---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 16 ++--
 lib/librte_eal/linuxapp/eal/eal_timer.c| 11 ++-
 12 files changed, 107 insertions(+), 10 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index c2374c0..9cec72b 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -244,6 +244,11 @@ CONFIG_RTE_PMD_RING_MAX_RX_RINGS=16
 CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16

 #
+# Max pthread name len
+#
+CONFIG_RTE_MAX_THREAD_NAME_LEN=16
+
+#
 # Compile software PMD backed by PCAP files
 #
 CONFIG_RTE_LIBRTE_PMD_PCAP=y
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0078dc9..efa0db7 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -241,6 +241,11 @@ CONFIG_RTE_PMD_RING_MAX_RX_RINGS=16
 CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16

 #
+# Max pthread name len
+#
+CONFIG_RTE_MAX_THREAD_NAME_LEN=16
+
+#
 # Compile software PMD backed by PCAP files
 #
 CONFIG_RTE_LIBRTE_PMD_PCAP=n
diff --git a/examples/vhost/Makefile b/examples/vhost/Makefile
index c269466..e95c68a 100644
--- a/examples/vhost/Makefile
+++ b/examples/vhost/Makefile
@@ -52,6 +52,7 @@ SRCS-y := main.c

 CFLAGS += -O2 -D_FILE_OFFSET_BITS=64
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -D_GNU_SOURCE

 include $(RTE_SDK)/mk/rte.extapp.mk

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index ad10f82..d337e88 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2891,6 +2891,7 @@ main(int argc, char *argv[])
uint8_t portid;
uint16_t queue_id;
static pthread_t tid;
+   char thread_name[RTE_MAX_THREAD_NAME_LEN];

/* init EAL */
ret = rte_eal_init(argc, argv);
@@ -3017,8 +3018,21 @@ main(int argc, char *argv[])
memset(_statistics, 0, sizeof(dev_statistics));

/* Enable stats if the user option is set. */
-   if (enable_stats)
-   pthread_create(, NULL, (void*)print_stats, NULL );
+   if (enable_stats) {
+   snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-stats");
+
+   ret = pthread_create(, NULL, (void*)print_stats, NULL );
+
+   if (ret != 0)
+   rte_exit(EXIT_FAILURE,
+   "Cannot create print-stats thread\n");
+
+   ret = pthread_setname_np(tid, thread_name);
+
+   if (ret != 0)
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "Cannot set print-stats name\n");
+   }

/* Launch all data cores. */
if (zero_copy == 0) {
diff --git a/examples/vhost_xen/Makefile b/examples/vhost_xen/Makefile
index e6fa1a1..47e1489 100644
--- a/examples/vhost_xen/Makefile
+++ b/examples/vhost_xen/Makefile
@@ -46,6 +46,7 @@ SRCS-y := main.c vhost_monitor.c xenstore_parse.c

 CFLAGS += -O2 -I/usr/local/include -D_FILE_OFFSET_BITS=64 -Wno-unused-parameter
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -D_GNU_SOURCE
 LDFLAGS += -lxenstore

 include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c
index b4a86e3..7bce482 100644
--- a/examples/vhost_xen/main.c
+++ b/examples/vhost_xen/main.c
@@ -1433,6 +1433,7 @@ main(int argc, char *argv[])
int ret;
uint8_t portid;
static pthread_t tid;
+   char thread_name[RTE_MAX_THREAD_NAME_LEN];

/* init EAL */
ret = rte_eal_init(argc, argv);
@@ -1505,8 +1506,23 @@ main(int argc, char *argv[])
memset(_statistics, 0, sizeof(dev_statistics));

/* Enable stats if the user option is set. */
-   if (enable_stats)
-   pthread_create(, NULL, (void*)print_stats, NULL );
+   if (enable_stats) {
+
+   snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+   "print-xen-stats");
+
+ 

[dpdk-dev] [PATCH] Use pthread_setname APIs

2015-04-22 Thread Ravi Kerur
Add code to set names to threads via pthread APIs.
In Linux corresponding _getname_ is available, however, FreeBSD
doesn't have corresponding _get_name API available yet. Hence _getname_
is not yet used in the code.

Ravi Kerur (1):
  Use pthread_setname apis

 config/common_bsdapp   |  5 +
 config/common_linuxapp |  5 +
 examples/vhost/Makefile|  1 +
 examples/vhost/main.c  | 18 --
 examples/vhost_xen/Makefile|  1 +
 examples/vhost_xen/main.c  | 20 ++--
 lib/librte_eal/bsdapp/eal/eal.c|  7 +++
 lib/librte_eal/linuxapp/eal/Makefile   |  2 ++
 lib/librte_eal/linuxapp/eal/eal.c  | 11 +++
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 20 +---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 16 ++--
 lib/librte_eal/linuxapp/eal/eal_timer.c| 11 ++-
 12 files changed, 107 insertions(+), 10 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH v6 1/6] Move common functions in eal_thread.c

2015-04-21 Thread Ravi Kerur
On Tue, Apr 21, 2015 at 7:25 AM, Bruce Richardson <
bruce.richardson at intel.com> wrote:

> On Sat, Apr 18, 2015 at 12:43:06PM -0700, Ravi Kerur wrote:
> > Changes in v6
> > Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c file.
> > Add pthread_setname_np/pthread_set_name_np for Linux/FreeBSD
> > respectively. Plan to use _getname_ in RTE_LOG when available.
> > Use existing rte_get_systid() in RTE_LOG to print thread_id.
>
> Hi Ravi
>
> I think the change to add names to the threads might be better in an
> existing
> patch as it is separate from the change of making the code common.
> [The code changes for the names also seems to have issues with it, as
> described in comments below]
>

Hi Bruce,

Thanks for your comments. Linux/FreeBSD has different APIs

pthread_setname_np and pthread_getname_np in Linux
pthread_set_name_np in FreeBSD. FreeBSD has no "_get_name_" counterpart API.

API signatures are different as well. Current plan is to use
"_setname_"/"_set_name_" appropriately and leave out "_getname_" until it
is available in FreeBSD.

Are you suggesting to use separate patch for set/get pthread names?

More inline.


> >
> > Changes in v5
> > Rebase to latest code.
> >
> > Changes in v4
> > None
> >
> > Changes in v3
> > Changed subject to be more explicit on file name inclusion.
> >
> > Changes in v2
> > None
> >
> > Changes in v1
> > eal_thread.c has minor differences between Linux and BSD, move
> > entire file into common directory.
> > Use RTE_EXEC_ENV_BSDAPP to differentiate on minor differences.
> > Rename eal_thread.c to eal_common_thread.c
> > Makefile changes to reflect file move and name change.
> > Fix checkpatch warnings.
> >
> > Signed-off-by: Ravi Kerur 
> > ---
> >  examples/vhost/main.c  |  18 ++-
> >  examples/vhost_xen/main.c  |  18 ++-
> >  lib/librte_eal/bsdapp/eal/Makefile |   2 +-
> >  lib/librte_eal/bsdapp/eal/eal.c|   7 +
> >  lib/librte_eal/bsdapp/eal/eal_thread.c | 152
> -
> >  lib/librte_eal/common/eal_common_thread.c  | 147
> +++-
> >  lib/librte_eal/common/eal_thread.h |   5 +
> >  lib/librte_eal/linuxapp/eal/Makefile   |   2 +
> >  lib/librte_eal/linuxapp/eal/eal.c  |  10 ++
> >  lib/librte_eal/linuxapp/eal/eal_interrupts.c   |  11 ++
> >  lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c |  22 ++-
> >  lib/librte_eal/linuxapp/eal/eal_thread.c   | 152
> +
> >  lib/librte_eal/linuxapp/eal/eal_timer.c|  15 +-
> >  13 files changed, 250 insertions(+), 311 deletions(-)
> >
>
> <<>>
>
> > --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c
> > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c
> > @@ -34,6 +34,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  /* sys/un.h with __USE_MISC uses strlen, which is unsafe */
> >  #ifdef __USE_MISC
> > @@ -54,6 +55,7 @@
> >
> >  #include "eal_filesystem.h"
> >  #include "eal_pci_init.h"
> > +#include "eal_thread.h"
> >
> >  /**
> >   * @file
> > @@ -374,20 +376,36 @@ int
> >  pci_vfio_mp_sync_setup(void)
> >  {
> >   int ret;
> > + char thread_name[RTE_THREAD_NAME_LEN];
> >
> >   if (vfio_mp_sync_socket_setup() < 0) {
> >   RTE_LOG(ERR, EAL, "Failed to set up local socket!\n");
> >   return -1;
> >   }
> >
> > + snprintf(thread_name, RTE_THREAD_NAME_LEN,
> > + "pci-vfio-mp-sync");
>
> This string is too long. According to the man page (Fedora Linux):
> "The thread name is a meaningful C language string, whose length is
> restricted to 16  charac?
>ters, including the terminating null byte ('\0')."
> I make the string 16+ null, i.e. 17 in total.
>

My mistake, will fix it.

>
> > +
> >   ret = pthread_create(_thread, NULL,
> >   pci_vfio_mp_sync_thread, NULL);
> >   if (ret) {
> > - RTE_LOG(ERR, EAL, "Failed to create thread for
> communication with "
> > - "secondary processes!\n");
> > + RTE_LOG(ERR, EAL,
> > + "Failed to create thread for communication with "
> > + "

[dpdk-dev] [PATCH v2] Clean up rte_memcpy.h file

2015-04-20 Thread Ravi Kerur
Remove unnecessary type casting in functions.

Tested on Ubuntu (14.04 x86_64) with "make test".
"make test" results match the results with baseline.
"Memcpy perf" results match the results with baseline.

Signed-off-by: Ravi Kerur 
---
 .../common/include/arch/x86/rte_memcpy.h   | 340 +++--
 1 file changed, 175 insertions(+), 165 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 6a57426..839d4ec 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -106,8 +106,8 @@ rte_mov32(uint8_t *dst, const uint8_t *src)
 static inline void
 rte_mov64(uint8_t *dst, const uint8_t *src)
 {
-   rte_mov32((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32);
-   rte_mov32((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 * 32);
+   rte_mov32(dst + 0 * 32, src + 0 * 32);
+   rte_mov32(dst + 1 * 32, src + 1 * 32);
 }

 /**
@@ -117,10 +117,10 @@ rte_mov64(uint8_t *dst, const uint8_t *src)
 static inline void
 rte_mov128(uint8_t *dst, const uint8_t *src)
 {
-   rte_mov32((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32);
-   rte_mov32((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 * 32);
-   rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32);
-   rte_mov32((uint8_t *)dst + 3 * 32, (const uint8_t *)src + 3 * 32);
+   rte_mov32(dst + 0 * 32, src + 0 * 32);
+   rte_mov32(dst + 1 * 32, src + 1 * 32);
+   rte_mov32(dst + 2 * 32, src + 2 * 32);
+   rte_mov32(dst + 3 * 32, src + 3 * 32);
 }

 /**
@@ -130,14 +130,14 @@ rte_mov128(uint8_t *dst, const uint8_t *src)
 static inline void
 rte_mov256(uint8_t *dst, const uint8_t *src)
 {
-   rte_mov32((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32);
-   rte_mov32((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 * 32);
-   rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32);
-   rte_mov32((uint8_t *)dst + 3 * 32, (const uint8_t *)src + 3 * 32);
-   rte_mov32((uint8_t *)dst + 4 * 32, (const uint8_t *)src + 4 * 32);
-   rte_mov32((uint8_t *)dst + 5 * 32, (const uint8_t *)src + 5 * 32);
-   rte_mov32((uint8_t *)dst + 6 * 32, (const uint8_t *)src + 6 * 32);
-   rte_mov32((uint8_t *)dst + 7 * 32, (const uint8_t *)src + 7 * 32);
+   rte_mov32(dst + 0 * 32, src + 0 * 32);
+   rte_mov32(dst + 1 * 32, src + 1 * 32);
+   rte_mov32(dst + 2 * 32, src + 2 * 32);
+   rte_mov32(dst + 3 * 32, src + 3 * 32);
+   rte_mov32(dst + 4 * 32, src + 4 * 32);
+   rte_mov32(dst + 5 * 32, src + 5 * 32);
+   rte_mov32(dst + 6 * 32, src + 6 * 32);
+   rte_mov32(dst + 7 * 32, src + 7 * 32);
 }

 /**
@@ -150,13 +150,16 @@ rte_mov64blocks(uint8_t *dst, const uint8_t *src, size_t 
n)
__m256i ymm0, ymm1;

while (n >= 64) {
-   ymm0 = _mm256_loadu_si256((const __m256i *)((const uint8_t 
*)src + 0 * 32));
+
+   ymm0 = _mm256_loadu_si256((const __m256i *)(src + 0 * 32));
+   ymm1 = _mm256_loadu_si256((const __m256i *)(src + 1 * 32));
+
+   _mm256_storeu_si256((__m256i *)(dst + 0 * 32), ymm0);
+   _mm256_storeu_si256((__m256i *)(dst + 1 * 32), ymm1);
+
n -= 64;
-   ymm1 = _mm256_loadu_si256((const __m256i *)((const uint8_t 
*)src + 1 * 32));
-   src = (const uint8_t *)src + 64;
-   _mm256_storeu_si256((__m256i *)((uint8_t *)dst + 0 * 32), ymm0);
-   _mm256_storeu_si256((__m256i *)((uint8_t *)dst + 1 * 32), ymm1);
-   dst = (uint8_t *)dst + 64;
+   src = src + 64;
+   dst = dst + 64;
}
 }

@@ -170,34 +173,39 @@ rte_mov256blocks(uint8_t *dst, const uint8_t *src, size_t 
n)
__m256i ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7;

while (n >= 256) {
-   ymm0 = _mm256_loadu_si256((const __m256i *)((const uint8_t 
*)src + 0 * 32));
+
+   ymm0 = _mm256_loadu_si256((const __m256i *)(src + 0 * 32));
+   ymm1 = _mm256_loadu_si256((const __m256i *)(src + 1 * 32));
+   ymm2 = _mm256_loadu_si256((const __m256i *)(src + 2 * 32));
+   ymm3 = _mm256_loadu_si256((const __m256i *)(src + 3 * 32));
+   ymm4 = _mm256_loadu_si256((const __m256i *)(src + 4 * 32));
+   ymm5 = _mm256_loadu_si256((const __m256i *)(src + 5 * 32));
+   ymm6 = _mm256_loadu_si256((const __m256i *)(src + 6 * 32));
+   ymm7 = _mm256_loadu_si256((const __m256i *)(src + 7 * 32));
+
+   _mm256_storeu_si256((__m256i *)(dst + 0 * 32), ymm0);
+   _mm256_storeu_si256((__m256i *)(dst + 1 * 32), ymm1);
+   _mm256_storeu_si256((__m256i *)(dst + 2 * 32), ymm2);
+   _mm256_storeu_si256((__m256i *)(dst + 3 * 32), ymm3);
+   _mm256_storeu_s

  1   2   >