[dpdk-dev] [dpdk-users] rte_zmalloc() returning non-zeroed memory on FreeBSD

2016-08-16 Thread Harris, James R


> -Original Message-
> From: Gonzalez Monroy, Sergio
> Sent: Tuesday, August 16, 2016 12:37 AM
> To: Harris, James R; Thomas Monjalon; users at dpdk.org; dev at dpdk.org;
> Richardson, Bruce
> Cc: Verkamp, Daniel
> Subject: Re: [dpdk-dev] [dpdk-users] rte_zmalloc() returning non-zeroed
> memory on FreeBSD
> 
> On 15/08/2016 18:23, Harris, James R wrote:
> >



> > The problem is that the FreeBSD contigmem driver does not re-zero the
> huge
> > pages each time they are mmap'd - they are only zeroed when contigmem
> > initially loads.  I will push a patch for this shortly.
> 
> So that is the case where we run the app more than once, right?
> I missed that, I only ran it once.

Correct - it works OK the first time.  The problem only occurs if you run the 
app
more than once (unless you unload and reload contigmem before running the
app a second time).

-Jim





[dpdk-dev] [PATCH] kni: add module parameter 'bind_to_core'

2016-08-16 Thread Vladyslav Buslov
Allow binding KNI thread to specific core in single threaded mode.

Signed-off-by: Vladyslav Buslov 
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c 
b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 59d15ca..e98f4a9 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -93,6 +93,7 @@ static char *lo_mode = NULL;
 /* Kernel thread mode */
 static char *kthread_mode = NULL;
 static unsigned multiple_kthread_on = 0;
+static int bind_to_core = -1;

 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */

@@ -239,12 +240,17 @@ kni_open(struct inode *inode, struct file *file)
if (multiple_kthread_on == 0) {
KNI_PRINT("Single kernel thread for all KNI devices\n");
/* Create kernel thread for RX */
-   knet->kni_kthread = kthread_run(kni_thread_single, (void *)knet,
+   knet->kni_kthread = kthread_create(kni_thread_single, (void 
*)knet,
"kni_single");
if (IS_ERR(knet->kni_kthread)) {
KNI_ERR("Unable to create kernel threaed\n");
return PTR_ERR(knet->kni_kthread);
}
+   if (bind_to_core >= 0) {
+   KNI_PRINT("Bind main thread to core %d\n", 
bind_to_core);
+   kthread_bind(knet->kni_kthread, bind_to_core);
+   }
+   wake_up_process(knet->kni_kthread);
} else
KNI_PRINT("Multiple kernel thread mode enabled\n");

@@ -698,3 +704,8 @@ MODULE_PARM_DESC(kthread_mode,
 "multiple  Multiple kernel thread mode enabled.\n"
 "\n"
 );
+
+module_param(bind_to_core, int, S_IRUGO);
+MODULE_PARM_DESC(bind_to_core,
+"Bind KNI main kernel thread to specific core (default=-1(disabled)):\n"
+);
\ No newline at end of file
-- 
2.8.3



[dpdk-dev] [PATCH] acl: use rte_calloc for temporary memory allocation

2016-08-16 Thread Vladyslav Buslov
Acl build process uses significant amount of memory
which degrades performance by causing page walks when memory
is allocated on regular heap using libc calloc.

This commit changes tb_mem to allocate temporary memory on huge pages
with rte_calloc.

Signed-off-by: Vladyslav Buslov 
---
 lib/librte_acl/tb_mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_acl/tb_mem.c b/lib/librte_acl/tb_mem.c
index 157e608..c373673 100644
--- a/lib/librte_acl/tb_mem.c
+++ b/lib/librte_acl/tb_mem.c
@@ -52,7 +52,7 @@ tb_pool(struct tb_mem_pool *pool, size_t sz)
size_t size;

size = sz + pool->alignment - 1;
-   block = calloc(1, size + sizeof(*pool->block));
+   block = rte_calloc("ACL_TBMEM_BLOCK", 1, size + sizeof(*pool->block), 
0);
if (block == NULL) {
RTE_LOG(ERR, MALLOC, "%s(%zu)\n failed, currently allocated "
"by pool: %zu bytes\n", __func__, sz, pool->alloc);
-- 
2.8.3



[dpdk-dev] [PATCH] Performance optimization of ACL build process

2016-08-16 Thread Vladyslav Buslov
Hello,

In our application we need to be able to allocate tens of thousands of ACLs at 
runtime.
Testing revealed significant performance problems. We were able to track them 
to memset in calloc function which caused multiple page walks per invocation.
Modifying tb_mem to use huge page memory resulted ~2x performance gain for that 
operation.

Regards,
Vladyslav

Vladyslav Buslov (1):
  acl: use rte_calloc for temporary memory allocation

 lib/librte_acl/tb_mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.8.3



[dpdk-dev] [PATCH] nfp: unregister interrupt callback function when closing device

2016-08-16 Thread Alejandro Lucero
With an app using hotplug feature, when a device is unplugged without
unregistering makes the interrupt handling unstable.

Fixes: 6c53f87b3497 ("nfp: add link status interrupt")

Signed-off-by: Alejandro Lucero 
---
 drivers/net/nfp/nfp_net.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 229c8e6..94c64db 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -733,6 +733,11 @@ nfp_net_close(struct rte_eth_dev *dev)
rte_intr_disable(>pci_dev->intr_handle);
nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);

+   /* unregister callback func from eal lib */
+   rte_intr_callback_unregister(>pci_dev->intr_handle,
+nfp_net_dev_interrupt_handler,
+(void *)dev);
+
/*
 * The ixgbe PMD driver disables the pcie master on the
 * device. The i40e does not...
-- 
1.9.1



[dpdk-dev] [PATCH] nfp: fixing bug when copying mac address

2016-08-16 Thread Alejandro Lucero
Fixes: defb9a5dd156 ("nfp: introduce driver initialization")

Signed-off-by: Alejandro Lucero 
---
 drivers/net/nfp/nfp_net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 45d122d..229c8e6 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -2421,8 +2421,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
eth_random_addr(>mac_addr[0]);

/* Copying mac address to DPDK eth_dev struct */
-   ether_addr_copy(_dev->data->mac_addrs[0],
-   (struct ether_addr *)hw->mac_addr);
+   ether_addr_copy((struct ether_addr *)hw->mac_addr,
+   _dev->data->mac_addrs[0]);

PMD_INIT_LOG(INFO, "port %d VendorID=0x%x DeviceID=0x%x "
 "mac=%02x:%02x:%02x:%02x:%02x:%02x",
-- 
1.9.1



[dpdk-dev] [PATCH] net/i40e: fix dropping packets with Ethertype 0x88A8

2016-08-16 Thread Beilei Xing
Refer to FW default setting, Ethertype 0x88A8 is treated as S-TAG,
packects with S-TAG should be received in Port Virtualizer mode,
but Port Virtual mode is not initialized in DPDK. So X710 will
packets with Ethertype 0x88A8.
This patch fixes this issue by turning off S-TAG identification.

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

Signed-off-by: Beilei Xing 
---
 drivers/net/i40e/i40e_ethdev.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index d0aeb70..55c4887 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -932,6 +932,9 @@ config_floating_veb(struct rte_eth_dev *dev)
}
 }

+#define I40E_L2_TAGS_S_TAG_SHIFT 1
+#define I40E_L2_TAGS_S_TAG_MASK I40E_MASK(0x1, I40E_L2_TAGS_S_TAG_SHIFT)
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -1120,6 +1123,13 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
/* Disable double vlan by default */
i40e_vsi_config_double_vlan(vsi, FALSE);

+   /* Disable S-TAG identification by default */
+   ret = I40E_READ_REG(hw, I40E_PRT_L2TAGSEN);
+   if (ret & I40E_L2_TAGS_S_TAG_MASK) {
+   ret &= ~I40E_L2_TAGS_S_TAG_MASK;
+   I40E_WRITE_REG(hw, I40E_PRT_L2TAGSEN, ret);
+   }
+
if (!vsi->max_macaddrs)
len = ETHER_ADDR_LEN;
else
-- 
2.5.0



[dpdk-dev] [PATCH] nfp: using random mac address if not a configured mac

2016-08-16 Thread Alejandro Lucero
Signed-off-by: Alejandro Lucero 
---
 drivers/net/nfp/nfp_net.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 82e3e4e..45d122d 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -607,18 +607,8 @@ nfp_net_rx_freelist_setup(struct rte_eth_dev *dev)
 static void
 nfp_net_params_setup(struct nfp_net_hw *hw)
 {
-   uint32_t *mac_address;
-
nn_cfg_writel(hw, NFP_NET_CFG_MTU, hw->mtu);
nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
-
-   /* A MAC address is 8 bytes long */
-   mac_address = (uint32_t *)(hw->mac_addr);
-
-   nn_cfg_writel(hw, NFP_NET_CFG_MACADDR,
- rte_cpu_to_be_32(*mac_address));
-   nn_cfg_writel(hw, NFP_NET_CFG_MACADDR + 4,
- rte_cpu_to_be_32(*(mac_address + 4)));
 }

 static void
@@ -627,6 +617,17 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }

+static void nfp_net_read_mac(struct nfp_net_hw *hw) {
+
+   uint32_t tmp;
+
+   tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+   memcpy(>mac_addr[0], , sizeof(struct ether_addr));
+
+   tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+   memcpy(>mac_addr[4], , 2);
+}
+
 static int
 nfp_net_start(struct rte_eth_dev *dev)
 {
@@ -2413,8 +2414,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
return -ENOMEM;
}

-   /* Using random mac addresses for VFs */
-   eth_random_addr(>mac_addr[0]);
+   nfp_net_read_mac(hw);
+
+   if (!is_valid_assigned_ether_addr((struct ether_addr 
*)>mac_addr[0]))
+   /* Using random mac addresses for VFs */
+   eth_random_addr(>mac_addr[0]);

/* Copying mac address to DPDK eth_dev struct */
ether_addr_copy(_dev->data->mac_addrs[0],
-- 
1.9.1



[dpdk-dev] [PATCH] optimize vhost enqueue

2016-08-16 Thread Maxime Coquelin
Hi Zhihong,

On 08/16/2016 05:50 AM, Zhihong Wang wrote:
> This patch optimizes the vhost enqueue function: rte_vhost_enqueue_burst.
>
> Currently there're 2 callbacks for vhost enqueue:
>  *  virtio_dev_merge_rx for mrg_rxbuf turned on cases.
>  *  virtio_dev_rx for mrg_rxbuf turned off cases.
>
> The virtio_dev_merge_rx doesn't provide optimal performance, also it is
> reported having compatibility issue working with Windows VMs.
Could you tell us more please about this compatibility issue?

>
> Besides, having 2 separated functions increases maintenance efforts.
>
> This patch uses a single function logic to replace the current 2 for
> better maintainability, and provides better performance by optimizing
> caching behavior especially for mrg_rxbuf turned on cases.
Do you have some benchmark comparison before and after your change?

Also, for maintainability, I would suggest the that the enqueue
function be split. Because vhost_enqueue_burst becomes very long (220
LoC), and max level of indentation is too high (6).

It makes the code hard to understand, and prone to miss bugs during
review and maintenance.

>
> It also fixes the issue working with Windows VMs.
Ideally, the fix should be sent separately, before the rework.
Indeed, we might want to have the fix in the stable branch, without
picking the optimization.

>
> Signed-off-by: Zhihong Wang 
> ---
>  lib/librte_vhost/vhost-net.h  |   6 +-
>  lib/librte_vhost/vhost_rxtx.c | 582 
> ++
>  lib/librte_vhost/virtio-net.c |  15 +-
>  3 files changed, 208 insertions(+), 395 deletions(-)
582 lines changed is a huge patch.
If possible, it would be better splitting it in incremental changes,
making the review process easier.

Also, for v2, please prefix the commit title with "vhost:".

Thanks for your contribution, I'm looking forward for the v2.
- Maxime


[dpdk-dev] [PATCH v6 9/9] table: align rte table hash structs for cache line size

2016-08-16 Thread Gowrishankar Muthukrishnan
rte table hash structs rte_bucket_4_8, rte_bucket_4_16 and rte_bucket_4_32 have
to be cache aligned as required by their corresponding hash create functions
rte_table_hash_create_key8_lru etc.

Signed-off-by: Gowrishankar Muthukrishnan 
---
 lib/librte_table/rte_table_hash_key16.c | 4 ++--
 lib/librte_table/rte_table_hash_key32.c | 4 ++--
 lib/librte_table/rte_table_hash_key8.c  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_table/rte_table_hash_key16.c 
b/lib/librte_table/rte_table_hash_key16.c
index b7e000f..2102326 100644
--- a/lib/librte_table/rte_table_hash_key16.c
+++ b/lib/librte_table/rte_table_hash_key16.c
@@ -68,10 +68,10 @@ struct rte_bucket_4_16 {
uint64_t next_valid;

/* Cache line 1 */
-   uint64_t key[4][2];
+   uint64_t key[4][2] __rte_cache_aligned;

/* Cache line 2 */
-   uint8_t data[0];
+   uint8_t data[0] __rte_cache_aligned;
 };

 struct rte_table_hash {
diff --git a/lib/librte_table/rte_table_hash_key32.c 
b/lib/librte_table/rte_table_hash_key32.c
index a7aba49..619f63a 100644
--- a/lib/librte_table/rte_table_hash_key32.c
+++ b/lib/librte_table/rte_table_hash_key32.c
@@ -68,10 +68,10 @@ struct rte_bucket_4_32 {
uint64_t next_valid;

/* Cache lines 1 and 2 */
-   uint64_t key[4][4];
+   uint64_t key[4][4] __rte_cache_aligned;

/* Cache line 3 */
-   uint8_t data[0];
+   uint8_t data[0] __rte_cache_aligned;
 };

 struct rte_table_hash {
diff --git a/lib/librte_table/rte_table_hash_key8.c 
b/lib/librte_table/rte_table_hash_key8.c
index e2e2bdc..4d5e0cd 100644
--- a/lib/librte_table/rte_table_hash_key8.c
+++ b/lib/librte_table/rte_table_hash_key8.c
@@ -68,7 +68,7 @@ struct rte_bucket_4_8 {
uint64_t key[4];

/* Cache line 1 */
-   uint8_t data[0];
+   uint8_t data[0] __rte_cache_aligned;
 };

 struct rte_table_hash {
-- 
1.9.1



[dpdk-dev] [PATCH v6 8/9] ip_pipeline: fix lcore mapping for varying SMT threads as in ppc64

2016-08-16 Thread Gowrishankar Muthukrishnan
This patch fixes ip_pipeline panic in app_init_core_map while preparing cpu
core map in powerpc with SMT off. cpu_core_map_compute_linux currently prepares
core mapping based on file existence in sysfs ie.

/sys/devices/system/cpu/cpu/topology/physical_package_id
  /sys/devices/system/cpu/cpu/topology/core_id

These files do not exist for lcores which are offline for any reason (as in
powerpc, while SMT is off). In this situation, this function should further
continue preparing map for other online lcores instead of returning with -1
for a first unavailable lcore.

Also, in SMT=off scenario for powerpc, lcore ids can not be always indexed from
0 upto 'number of cores present' (/sys/devices/system/cpu/present). For eg, for
an online lcore 32, core_id returned in sysfs is 112 where online lcores are
10 (as in one configuration), hence sysfs lcore id can not be checked with
indexing lcore number before positioning lcore map array.

Signed-off-by: Gowrishankar Muthukrishnan 
---
 examples/ip_pipeline/cpu_core_map.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/examples/ip_pipeline/cpu_core_map.c 
b/examples/ip_pipeline/cpu_core_map.c
index cb088b1..dd8f678 100644
--- a/examples/ip_pipeline/cpu_core_map.c
+++ b/examples/ip_pipeline/cpu_core_map.c
@@ -351,8 +351,10 @@ cpu_core_map_compute_linux(struct cpu_core_map *map)
int lcore_socket_id =
cpu_core_map_get_socket_id_linux(lcore_id);

+#if !defined(RTE_ARCH_PPC_64)
if (lcore_socket_id < 0)
return -1;
+#endif

if (((uint32_t) lcore_socket_id) == socket_id)
n_detected++;
@@ -368,6 +370,7 @@ cpu_core_map_compute_linux(struct cpu_core_map *map)
cpu_core_map_get_socket_id_linux(
lcore_id);

+#if !defined(RTE_ARCH_PPC_64)
if (lcore_socket_id < 0)
return -1;

@@ -377,9 +380,14 @@ cpu_core_map_compute_linux(struct cpu_core_map *map)

if (lcore_core_id < 0)
return -1;
+#endif

+#if !defined(RTE_ARCH_PPC_64)
if (((uint32_t) lcore_socket_id == socket_id) &&
((uint32_t) lcore_core_id == core_id)) {
+#else
+   if (((uint32_t) lcore_socket_id == socket_id)) {
+#endif
uint32_t pos = cpu_core_map_pos(map,
socket_id,
core_id_contig,
-- 
1.9.1



[dpdk-dev] [PATCH v6 7/9] pipeline: enable pipeline library for ppc64le

2016-08-16 Thread Gowrishankar Muthukrishnan
This patch enables librte_pipeline for ppc64le.

Signed-off-by: Gowrishankar Muthukrishnan 
---
 config/defconfig_ppc_64-power8-linuxapp-gcc | 2 --
 1 file changed, 2 deletions(-)

diff --git a/config/defconfig_ppc_64-power8-linuxapp-gcc 
b/config/defconfig_ppc_64-power8-linuxapp-gcc
index 1fc8df2..f953e61 100644
--- a/config/defconfig_ppc_64-power8-linuxapp-gcc
+++ b/config/defconfig_ppc_64-power8-linuxapp-gcc
@@ -56,5 +56,3 @@ CONFIG_RTE_LIBRTE_PMD_BOND=n
 CONFIG_RTE_LIBRTE_ENIC_PMD=n
 CONFIG_RTE_LIBRTE_FM10K_PMD=n

-# This following libraries are not available on Power. So they're turned off.
-CONFIG_RTE_LIBRTE_PIPELINE=n
-- 
1.9.1



[dpdk-dev] [PATCH v6 6/9] port: enable port library for ppc64le

2016-08-16 Thread Gowrishankar Muthukrishnan
This patch enables librte_port in ppc64le.

Signed-off-by: Gowrishankar Muthukrishnan 
---
 config/defconfig_ppc_64-power8-linuxapp-gcc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/config/defconfig_ppc_64-power8-linuxapp-gcc 
b/config/defconfig_ppc_64-power8-linuxapp-gcc
index 0c7060f..1fc8df2 100644
--- a/config/defconfig_ppc_64-power8-linuxapp-gcc
+++ b/config/defconfig_ppc_64-power8-linuxapp-gcc
@@ -57,5 +57,4 @@ CONFIG_RTE_LIBRTE_ENIC_PMD=n
 CONFIG_RTE_LIBRTE_FM10K_PMD=n

 # This following libraries are not available on Power. So they're turned off.
-CONFIG_RTE_LIBRTE_PORT=n
 CONFIG_RTE_LIBRTE_PIPELINE=n
-- 
1.9.1



[dpdk-dev] [PATCH v6 5/9] sched: enable sched library for ppc64le

2016-08-16 Thread Gowrishankar Muthukrishnan
This patch enables librte_sched in ppc64le.

Signed-off-by: Gowrishankar Muthukrishnan 
---
 config/defconfig_ppc_64-power8-linuxapp-gcc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/config/defconfig_ppc_64-power8-linuxapp-gcc 
b/config/defconfig_ppc_64-power8-linuxapp-gcc
index 41f67d5..0c7060f 100644
--- a/config/defconfig_ppc_64-power8-linuxapp-gcc
+++ b/config/defconfig_ppc_64-power8-linuxapp-gcc
@@ -57,6 +57,5 @@ CONFIG_RTE_LIBRTE_ENIC_PMD=n
 CONFIG_RTE_LIBRTE_FM10K_PMD=n

 # This following libraries are not available on Power. So they're turned off.
-CONFIG_RTE_LIBRTE_SCHED=n
 CONFIG_RTE_LIBRTE_PORT=n
 CONFIG_RTE_LIBRTE_PIPELINE=n
-- 
1.9.1



[dpdk-dev] [PATCH v6 4/9] table: enable table library for ppc64le

2016-08-16 Thread Gowrishankar Muthukrishnan
This patch enables librte_table in ppc64le.

Signed-off-by: Gowrishankar Muthukrishnan 
---
 config/defconfig_ppc_64-power8-linuxapp-gcc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/config/defconfig_ppc_64-power8-linuxapp-gcc 
b/config/defconfig_ppc_64-power8-linuxapp-gcc
index dede34f..41f67d5 100644
--- a/config/defconfig_ppc_64-power8-linuxapp-gcc
+++ b/config/defconfig_ppc_64-power8-linuxapp-gcc
@@ -59,5 +59,4 @@ CONFIG_RTE_LIBRTE_FM10K_PMD=n
 # This following libraries are not available on Power. So they're turned off.
 CONFIG_RTE_LIBRTE_SCHED=n
 CONFIG_RTE_LIBRTE_PORT=n
-CONFIG_RTE_LIBRTE_TABLE=n
 CONFIG_RTE_LIBRTE_PIPELINE=n
-- 
1.9.1



[dpdk-dev] [PATCH v6 3/9] l3fwd: add altivec support for em_hash_key

2016-08-16 Thread Gowrishankar Muthukrishnan
This patch adds ppc64le port for em_mask_key function.

Signed-off-by: Gowrishankar Muthukrishnan 
---
 examples/l3fwd/l3fwd_em.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c
index def5a02..6053a62 100644
--- a/examples/l3fwd/l3fwd_em.c
+++ b/examples/l3fwd/l3fwd_em.c
@@ -259,8 +259,16 @@ em_mask_key(void *key, xmm_t mask)

return vandq_s32(data, mask);
 }
+#elif defined(RTE_MACHINE_CPUFLAG_ALTIVEC)
+static inline xmm_t
+em_mask_key(void *key, xmm_t mask)
+{
+   xmm_t data = vec_ld(0, (xmm_t *)(key));
+
+   return vec_and(data, mask);
+}
 #else
-#error No vector engine (SSE, NEON) available, check your toolchain
+#error No vector engine (SSE, NEON, ALTIVEC) available, check your toolchain
 #endif

 static inline uint8_t
-- 
1.9.1



[dpdk-dev] [PATCH v6 2/9] acl: add altivec intrinsics for dpdk acl on ppc_64

2016-08-16 Thread Gowrishankar Muthukrishnan
This patch adds port for ACL library in ppc64le.

Signed-off-by: Gowrishankar Muthukrishnan 
---
 app/test-acl/main.c |   4 +
 config/defconfig_ppc_64-power8-linuxapp-gcc |   1 -
 lib/librte_acl/Makefile |   2 +
 lib/librte_acl/acl.h|   4 +
 lib/librte_acl/acl_run.h|   2 +
 lib/librte_acl/acl_run_altivec.c|  47 
 lib/librte_acl/acl_run_altivec.h| 329 
 lib/librte_acl/rte_acl.c|  13 ++
 lib/librte_acl/rte_acl.h|   1 +
 9 files changed, 402 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_acl/acl_run_altivec.c
 create mode 100644 lib/librte_acl/acl_run_altivec.h

diff --git a/app/test-acl/main.c b/app/test-acl/main.c
index d366981..1b2b176 100644
--- a/app/test-acl/main.c
+++ b/app/test-acl/main.c
@@ -105,6 +105,10 @@ static const struct acl_alg acl_alg[] = {
.name = "neon",
.alg = RTE_ACL_CLASSIFY_NEON,
},
+   {
+   .name = "altivec",
+   .alg = RTE_ACL_CLASSIFY_ALTIVEC,
+   },
 };

 static struct {
diff --git a/config/defconfig_ppc_64-power8-linuxapp-gcc 
b/config/defconfig_ppc_64-power8-linuxapp-gcc
index 9ddf3c5..dede34f 100644
--- a/config/defconfig_ppc_64-power8-linuxapp-gcc
+++ b/config/defconfig_ppc_64-power8-linuxapp-gcc
@@ -57,7 +57,6 @@ CONFIG_RTE_LIBRTE_ENIC_PMD=n
 CONFIG_RTE_LIBRTE_FM10K_PMD=n

 # This following libraries are not available on Power. So they're turned off.
-CONFIG_RTE_LIBRTE_ACL=n
 CONFIG_RTE_LIBRTE_SCHED=n
 CONFIG_RTE_LIBRTE_PORT=n
 CONFIG_RTE_LIBRTE_TABLE=n
diff --git a/lib/librte_acl/Makefile b/lib/librte_acl/Makefile
index 9803e9d..d05be66 100644
--- a/lib/librte_acl/Makefile
+++ b/lib/librte_acl/Makefile
@@ -52,6 +52,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_run_scalar.c
 ifneq ($(filter y,$(CONFIG_RTE_ARCH_ARM) $(CONFIG_RTE_ARCH_ARM64)),)
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_run_neon.c
 CFLAGS_acl_run_neon.o += -flax-vector-conversions -Wno-maybe-uninitialized
+else ifeq ($(CONFIG_RTE_ARCH_PPC_64),y)
+SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_run_altivec.c
 else
 SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_run_sse.c
 #check if flag for SSE4.1 is already on, if not set it up manually
diff --git a/lib/librte_acl/acl.h b/lib/librte_acl/acl.h
index 09d6784..6664a55 100644
--- a/lib/librte_acl/acl.h
+++ b/lib/librte_acl/acl.h
@@ -234,6 +234,10 @@ int
 rte_acl_classify_neon(const struct rte_acl_ctx *ctx, const uint8_t **data,
uint32_t *results, uint32_t num, uint32_t categories);

+int
+rte_acl_classify_altivec(const struct rte_acl_ctx *ctx, const uint8_t **data,
+   uint32_t *results, uint32_t num, uint32_t categories);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/lib/librte_acl/acl_run.h b/lib/librte_acl/acl_run.h
index b2fc42c..024f393 100644
--- a/lib/librte_acl/acl_run.h
+++ b/lib/librte_acl/acl_run.h
@@ -39,7 +39,9 @@

 #define MAX_SEARCHES_AVX16 16
 #define MAX_SEARCHES_SSE8  8
+#define MAX_SEARCHES_ALTIVEC8  8
 #define MAX_SEARCHES_SSE4  4
+#define MAX_SEARCHES_ALTIVEC4  4
 #define MAX_SEARCHES_SCALAR2

 #define GET_NEXT_4BYTES(prm, idx)  \
diff --git a/lib/librte_acl/acl_run_altivec.c b/lib/librte_acl/acl_run_altivec.c
new file mode 100644
index 000..3523526
--- /dev/null
+++ b/lib/librte_acl/acl_run_altivec.c
@@ -0,0 +1,47 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright (C) IBM Corporation 2016.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING 

[dpdk-dev] [PATCH v6 0/9] enable lpm, acl and other missing libraries in ppc64le

2016-08-16 Thread Gowrishankar Muthukrishnan
This patchset enables LPM, ACL and other few missing libs in ppc64le and also
address few patches in related examples (ip_pipeline and l3fwd).

Test report:
1. LPM and ACL unit tests passed.
   Steps:
   compile test app and run (with any needed params)
   lpm_autotest
   acl_autotest
   table_autotest
 test_table_lpm_combined fails same as in intel in current master.

2. Example ip_pipeline application verified for port forwarding.
   compile examples/ip_pipeline (adjust app_init_core_map
 param for ht to 1 in case of ppc64le in SMT=off mode).
   modify config/l3fwd.cfg as per enabled PMD ports.
   run ip_pipeline with config file option and check packets fwd.

v6 changes:
- added cache alignment fix for rte hash table structs.

v5 changes:
- no change in lpm lib enablement
- no change in acl lib enablement
- config file changes individually for sched,table,port,pipeline
  lib enablement
- ip_pipeline patch description and changes flagged only for ppc64le.
   app_init_core_map changes removed (due to bug found and under 
   investigation only on ppc64le/smt=off case).

v4 changes:
- fix transition4 in acl_run_altivec.h for gcc strict-aliasing error.
  Thanks to Chao Zhu for bringing up.

v3 changes:
- rebase over master to fix conflict in examples/l3fwd/l3fwd_em.c

v2 changes:
- enabling libs in config included as part of lib changes itself.

Gowrishankar Muthukrishnan (9):
  lpm: add altivec intrinsics for dpdk lpm on ppc_64
  acl: add altivec intrinsics for dpdk acl on ppc_64
  l3fwd: add altivec support for em_hash_key
  table: enable table library for ppc64le
  sched: enable sched library for ppc64le
  port: enable port library for ppc64le
  pipeline: enable pipeline library for ppc64le
  ip_pipeline: fix lcore mapping for varying SMT threads as in ppc64
  table: align rte table hash structs for cache line size

 app/test-acl/main.c|   4 +
 app/test/test_xmmt_ops.h   |  16 +
 config/defconfig_ppc_64-power8-linuxapp-gcc|   7 -
 examples/ip_pipeline/cpu_core_map.c|   8 +
 examples/l3fwd/l3fwd_em.c  |  10 +-
 lib/librte_acl/Makefile|   2 +
 lib/librte_acl/acl.h   |   4 +
 lib/librte_acl/acl_run.h   |   2 +
 lib/librte_acl/acl_run_altivec.c   |  47 +++
 lib/librte_acl/acl_run_altivec.h   | 329 +
 lib/librte_acl/rte_acl.c   |  13 +
 lib/librte_acl/rte_acl.h   |   1 +
 .../common/include/arch/ppc_64/rte_vect.h  |  60 
 lib/librte_lpm/Makefile|   2 +
 lib/librte_lpm/rte_lpm.h   |   2 +
 lib/librte_lpm/rte_lpm_altivec.h   | 154 ++
 lib/librte_table/rte_table_hash_key16.c|   4 +-
 lib/librte_table/rte_table_hash_key32.c|   4 +-
 lib/librte_table/rte_table_hash_key8.c |   2 +-
 19 files changed, 658 insertions(+), 13 deletions(-)
 create mode 100644 lib/librte_acl/acl_run_altivec.c
 create mode 100644 lib/librte_acl/acl_run_altivec.h
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_vect.h
 create mode 100644 lib/librte_lpm/rte_lpm_altivec.h

-- 
1.9.1



[dpdk-dev] [PATCH] kni: error rollback with kni_dev_remove could cause a kernel crash

2016-08-16 Thread zhouyangchao



[dpdk-dev] [PATCH v5 4/8] table: enable table library for ppc64le

2016-08-16 Thread Chao Zhu
Gowrishankar,

The unit test of table got failed. 
When I took a look at the code, it failed on this line in file
lib/librte_table/rte_table_hash_key8.c ,
lib/librte_table/rte_table_hash_key16.c,
lib/librte_table/rte_table_hash_key32.c:

if ((check_params_create_lru(p) != 0) ||
((sizeof(struct rte_table_hash) % RTE_CACHE_LINE_SIZE) != 0)
||
((sizeof(struct rte_bucket_4_8) % RTE_CACHE_LINE_SIZE) !=
0)) {
return NULL;
}

if ((check_params_create_lru(p) != 0) ||
((sizeof(struct rte_table_hash) % RTE_CACHE_LINE_SIZE) != 0)
||
((sizeof(struct rte_bucket_4_16) % RTE_CACHE_LINE_SIZE) !=
0)) {
return NULL;
}

if ((check_params_create_lru(p) != 0) ||
((sizeof(struct rte_table_hash) % RTE_CACHE_LINE_SIZE) != 0)
||
((sizeof(struct rte_bucket_4_32) % RTE_CACHE_LINE_SIZE) !=
0)) {
return NULL;
}

The size of rte_bucket_4_8/16/32 is not aligned to cache line size. This is
normal, because POWER has different cache line size. The change of struct
rte_bucket_4_8/16/32 may solve this problem. I didn't do further
investigation. Can you help to double check this patch?


-Original Message-
From: Gowrishankar Muthukrishnan [mailto:gowrishanka...@linux.vnet.ibm.com] 
Sent: 2016?8?12? 20:03
To: dev at dpdk.org
Cc: Chao Zhu ; Bruce Richardson
; Konstantin Ananyev
; Thomas Monjalon ;
Cristian Dumitrescu ; Pradeep
; gowrishankar 
Subject: [PATCH v5 4/8] table: enable table library for ppc64le

From: gowrishankar 

This patch enables librte_table in ppc64le.

Signed-off-by: Gowrishankar Muthukrishnan

---
 config/defconfig_ppc_64-power8-linuxapp-gcc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/config/defconfig_ppc_64-power8-linuxapp-gcc
b/config/defconfig_ppc_64-power8-linuxapp-gcc
index dede34f..41f67d5 100644
--- a/config/defconfig_ppc_64-power8-linuxapp-gcc
+++ b/config/defconfig_ppc_64-power8-linuxapp-gcc
@@ -59,5 +59,4 @@ CONFIG_RTE_LIBRTE_FM10K_PMD=n  # This following libraries
are not available on Power. So they're turned off.
 CONFIG_RTE_LIBRTE_SCHED=n
 CONFIG_RTE_LIBRTE_PORT=n
-CONFIG_RTE_LIBRTE_TABLE=n
 CONFIG_RTE_LIBRTE_PIPELINE=n
--
1.9.1




[dpdk-dev] [PATCH v2] contigmem: zero all pages during mmap

2016-08-16 Thread Jim Harris
On Linux, all huge pages are zeroed by the kernel before
first access by the DPDK application.  But on FreeBSD,
the contigmem driver would only zero the contiguous
memory regions during initial driver load.

DPDK commit b78c91751 eliminated the explicit memset()
operation for rte_zmalloc(), which was OK on Linux
because the kernel zeroes the pages during app start,
but this broke FreeBSD.  So this patch explicitly
zeroes the pages before they are mmap'd, to ensure
equivalent behavior to Linux

Fixes: b78c9175118f ("mem: do not zero out memory on zmalloc")

Reported-by: Daniel Verkamp 
Tested-by: Daniel Verkamp 
Acked-by: Sergio Gonzalez Monroy 
Signed-off-by: Jim Harris 
---
 lib/librte_eal/bsdapp/contigmem/contigmem.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/bsdapp/contigmem/contigmem.c 
b/lib/librte_eal/bsdapp/contigmem/contigmem.c
index c6ca3b9..da971de 100644
--- a/lib/librte_eal/bsdapp/contigmem/contigmem.c
+++ b/lib/librte_eal/bsdapp/contigmem/contigmem.c
@@ -216,15 +216,19 @@ static int
 contigmem_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t size,
struct vm_object **obj, int nprot)
 {
+   uint64_t buffer_index;
+
/*
 * The buffer index is encoded in the offset.  Divide the offset by
 *  PAGE_SIZE to get the index of the buffer requested by the user
 *  app.
 */
-   if ((*offset/PAGE_SIZE) >= contigmem_num_buffers)
+   buffer_index = *offset / PAGE_SIZE;
+   if (buffer_index >= contigmem_num_buffers)
return EINVAL;

-   *offset = (vm_ooffset_t)vtophys(contigmem_buffers[*offset/PAGE_SIZE]);
+   memset(contigmem_buffers[buffer_index], 0, contigmem_buffer_size);
+   *offset = (vm_ooffset_t)vtophys(contigmem_buffers[buffer_index]);
*obj = vm_pager_allocate(OBJT_DEVICE, cdev, size, nprot, *offset,
curthread->td_ucred);




[dpdk-dev] [PATCH] contigmem: zero all pages during mmap

2016-08-16 Thread Sergio Gonzalez Monroy
On 15/08/2016 19:17, Jim Harris wrote:
> On Linux, all huge pages are zeroed by the kernel before
> first access by the DPDK application.  But on FreeBSD,
> the contigmem driver would only zero the contiguous
> memory regions during initial driver load.
>
> DPDK commit b78c91751 eliminated the explicit memset()
> operation for rte_zmalloc(), which was OK on Linux
> because the kernel zeroes the pages during app start,
> but this broke FreeBSD.  So this patch explicitly
> zeroes the pages before they are mmap'd, to ensure
> equivalent behavior to Linux
>
> Reported-by: Daniel Verkamp 
> Tested-by: Daniel Verkamp 
> Signed-off-by: Jim Harris 
> ---
>   lib/librte_eal/bsdapp/contigmem/contigmem.c |8 ++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_eal/bsdapp/contigmem/contigmem.c 
> b/lib/librte_eal/bsdapp/contigmem/contigmem.c
> index c6ca3b9..da971de 100644
> --- a/lib/librte_eal/bsdapp/contigmem/contigmem.c
> +++ b/lib/librte_eal/bsdapp/contigmem/contigmem.c
> @@ -216,15 +216,19 @@ static int
>   contigmem_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t 
> size,
>   struct vm_object **obj, int nprot)
>   {
> + uint64_t buffer_index;
> +
>   /*
>* The buffer index is encoded in the offset.  Divide the offset by
>*  PAGE_SIZE to get the index of the buffer requested by the user
>*  app.
>*/
> - if ((*offset/PAGE_SIZE) >= contigmem_num_buffers)
> + buffer_index = *offset / PAGE_SIZE;
> + if (buffer_index >= contigmem_num_buffers)
>   return EINVAL;
>   
> - *offset = (vm_ooffset_t)vtophys(contigmem_buffers[*offset/PAGE_SIZE]);
> + memset(contigmem_buffers[buffer_index], 0, contigmem_buffer_size);
> + *offset = (vm_ooffset_t)vtophys(contigmem_buffers[buffer_index]);
>   *obj = vm_pager_allocate(OBJT_DEVICE, cdev, size, nprot, *offset,
>   curthread->td_ucred);
>   
>
>

I think you should include the Fixes line:
Fixes: b78c9175118f ("mem: do not zero out memory on zmalloc")

Other than that:

Acked-by: Sergio Gonzalez Monroy 




[dpdk-dev] [PATCH 1/2] examples/vhost: rename dev-basename

2016-08-16 Thread Jiayu Hu
In examples/vhost, "dev-basename" is a program option, which is to set
the vhost-net socket used by vhost-user, or the character device used
by vhost-cuse. Since vhost-cuse should be dropped, and "dev-basename"
is not a suitable name for the vhost-net socket. Therefore, this patch
is to change this option name for examples/vhost.

Signed-off-by: Jiayu Hu 
---
 examples/vhost/main.c | 41 +
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 92a9823..a718577 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -90,9 +90,6 @@
 /* Size of buffers used for snprintfs. */
 #define MAX_PRINT_BUFF 6072

-/* Maximum character device basename size. */
-#define MAX_BASENAME_SZ 10
-
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64

@@ -139,8 +136,8 @@ static uint32_t burst_rx_delay_time = BURST_RX_WAIT_US;
 /* Specify the number of retries on RX. */
 static uint32_t burst_rx_retry_num = BURST_RX_RETRIES;

-/* Character device basename. Can be set by user. */
-static char dev_basename[MAX_BASENAME_SZ] = "vhost-net";
+/* Socket file path. Can be set by user */
+static char socket_file[PATH_MAX] = "vhost-net";

 /* empty vmdq configuration structure. Filled in programatically */
 static struct rte_eth_conf vmdq_conf_default = {
@@ -392,17 +389,17 @@ port_init(uint8_t port)
 }

 /*
- * Set character device basename.
+ * Set socket file path.
  */
 static int
-us_vhost_parse_basename(const char *q_arg)
+us_vhost_parse_socket_path(const char *q_arg)
 {
/* parse number string */

-   if (strnlen(q_arg, MAX_BASENAME_SZ) > MAX_BASENAME_SZ)
+   if (strnlen(q_arg, PATH_MAX) > PATH_MAX)
return -1;
else
-   snprintf((char*)_basename, MAX_BASENAME_SZ, "%s", q_arg);
+   snprintf((char *)_file, PATH_MAX, "%s", q_arg);

return 0;
 }
@@ -462,7 +459,7 @@ us_vhost_usage(const char *prgname)
RTE_LOG(INFO, VHOST_CONFIG, "%s [EAL options] -- -p PORTMASK\n"
"   --vm2vm [0|1|2]\n"
"   --rx_retry [0|1] --mergeable [0|1] --stats [0-N]\n"
-   "   --dev-basename \n"
+   "   --socket-file \n"
"   --nb-devices ND\n"
"   -p PORTMASK: Set mask for ports to be used by 
application\n"
"   --vm2vm [0|1|2]: disable/software(default)/hardware 
vm2vm comms\n"
@@ -472,7 +469,7 @@ us_vhost_usage(const char *prgname)
"   --mergeable [0|1]: disable(default)/enable RX mergeable 
buffers\n"
"   --vlan-strip [0|1]: disable/enable(default) RX VLAN 
strip on host\n"
"   --stats [0-N]: 0: Disable stats, N: Time in seconds to 
print stats\n"
-   "   --dev-basename: The basename to be used for the 
character device.\n"
+   "   --socket-file: The path of the socket file.\n"
"   --tx-csum [0|1] disable/enable TX checksum offload.\n"
"   --tso [0|1] disable/enable TCP segment offload.\n"
"   --client register a vhost-user socket as client 
mode.\n",
@@ -497,7 +494,7 @@ us_vhost_parse_args(int argc, char **argv)
{"mergeable", required_argument, NULL, 0},
{"vlan-strip", required_argument, NULL, 0},
{"stats", required_argument, NULL, 0},
-   {"dev-basename", required_argument, NULL, 0},
+   {"socket-file", required_argument, NULL, 0},
{"tx-csum", required_argument, NULL, 0},
{"tso", required_argument, NULL, 0},
{"client", no_argument, _mode, 1},
@@ -638,7 +635,8 @@ us_vhost_parse_args(int argc, char **argv)
if (!strncmp(long_option[option_index].name, "stats", 
MAX_LONG_OPT_SZ)) {
ret = parse_num_opt(optarg, INT32_MAX);
if (ret == -1) {
-   RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for stats [0..N]\n");
+   RTE_LOG(INFO, VHOST_CONFIG,
+   "Invalid argument for stats 
[0..N]\n");
us_vhost_usage(prgname);
return -1;
} else {
@@ -646,10 +644,13 @@ us_vhost_parse_args(int argc, char **argv)
}
}

-   /* Set character device basename. */
-   if (!strncmp(long_option[option_index].name, 
"dev-basename", MAX_LONG_OPT_SZ)) {
-   if (us_vhost_parse_basename(optarg) == -1) {
-   RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for character device basename (Max %d characters)\n", 

[dpdk-dev] [PATCH 0/2] examples/vhost: rename a CLI option and support multiple socket files

2016-08-16 Thread Jiayu Hu
Patch 1: rename the CLI option "dev-basename".
Patch 2: add multiple socket files support. 

Jiayu Hu (2):
  examples/vhost: rename dev-basename
  examples/vhost: support multiple socket files

 examples/vhost/main.c | 81 ++-
 1 file changed, 54 insertions(+), 27 deletions(-)

-- 
2.7.4



[dpdk-dev] vhost [query] : support for multiple ports and non VMDQ devices in vhost switch

2016-08-16 Thread Yuanhan Liu
On Tue, Aug 09, 2016 at 04:42:33PM +0530, Pankaj Chauhan wrote:
> 
> Hi,
> 
> I am working on an NXP platform where we intend to use user space vhost
> switch (examples/vhost) as backend for VIRTIO devices. But there are two
> limitations in current vhost-switch (examples/vhost)that are restricting my
> use case:
> 
> 1. The vhost-switch application is tightly integrated with Intel VMDQ. Since
> my device doesn't have VMDQ i can not use this application directly.

Sorry being late (I was on biz trip last week).

Yes, a vhost example should not do that. We have an internal TODO to
remove it. Actually, to make it optional, and Jianfeng was working on
that. Well, seems that you two have already had some discussions.

> 2. The vhost-switch application supports only one external or physical port
> (non virtio devices), but my requirement is to have multiple physical ports
> and multiple virtio devices.

What are you going to achieve? BTW, have you tried testpmd (with vhost-pmd)?
I'm with impression that it might be a better option to you.

--yliu

> In summary my requirement is to do whatever vhost-switch is doing, in
> addition to that add support for following:
> 
> 1. support devices that don't have VMDQ.
> 2. Support multiple physical ports.
> 
> I need suggestions on the approach i should take: whether to add support of
> above mentioned in existing vhost-switch (examples/vhost) or write another
> application (based on librte_vhost only) to support my requirements.
> 
> I'll work on it after the suggestion i get from the list, and send the RFC
> patch.
> 
> Thanks,
> Pankaj
> 


[dpdk-dev] [PATCH] vhost: add back support for concurrent enqueue

2016-08-16 Thread Yuanhan Liu
On Mon, Aug 15, 2016 at 01:00:24PM -0700, Rich Lane wrote:
> Concurrent enqueue is an important performance optimization when the number
> of cores used for switching is different than the number of vhost queues.
> I've observed a 20% performance improvement compared to a strategy that
> binds queues to cores.
> 
> The atomic cmpset is only executed when the application calls
> rte_vhost_enqueue_burst_mp. Benchmarks show no performance impact
> when not using concurrent enqueue.
> 
> Mergeable RX buffers aren't supported by concurrent enqueue to minimize
> code complexity.

I think that would break things when Mergeable rx is enabled (which is
actually enabled by default).

Besides that, as mentioned in the last week f2f talk, do you think adding
a new flag RTE_VHOST_USER_CONCURRENT_ENQUEUE (for rte_vhost_driver_register())
__might__ be a better idea? That could save us a API, to which I don't object
though.

--yliu


[dpdk-dev] [dpdk-users] rte_zmalloc() returning non-zeroed memory on FreeBSD

2016-08-16 Thread Sergio Gonzalez Monroy
On 15/08/2016 18:23, Harris, James R wrote:
>
>> -Original Message-
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Thomas Monjalon
>> Sent: Thursday, August 11, 2016 12:05 AM
>> To: users at dpdk.org; dev at dpdk.org; Gonzalez Monroy, Sergio; Richardson,
>> Bruce
>> Cc: Verkamp, Daniel
>> Subject: Re: [dpdk-dev] [dpdk-users] rte_zmalloc() returning non-zeroed
>> memory on FreeBSD
>>
>> Hi,
>>
>> 2016-08-10 23:30, Verkamp, Daniel:
>>> It seems that with DPDK 16.07, rte_zmalloc() and related functions no
>>> longer return zeroed memory reliably on FreeBSD.
>>>
>>> I notice that commit b78c9175118f7d61022ddc5c62ce54a1bd73cea5 ("mem:
>> do
>>> not zero out memory on zmalloc") removed the explicit memset() that
>> used
>>> to ensure the buffer was zeroed; its log message says:
>>>
>>> "Zeroing out memory on rte_zmalloc_socket is not required anymore since
>>> all allocated memory is already zeroed."
>> On Linux, the memory is zeroed by the kernel.
>> Then the zero value is maintained in the rte_malloc pool by rte_free.
>>
>>> However, I don't see how this is guaranteed (at least for FreeBSD), and
>>> it is not true in practice.  I've attached a minimized reproducer program -
>>> running it twice in a row fails reliably for me.
>>>
>>> Is there a missing step in FreeBSD, or is it a more general problem for
>>> other platforms?
>> I guess the initial value from the kernel has been verified only on Linux.
>> We could re-add a memset for FreeBSD.
> The problem is that the FreeBSD contigmem driver does not re-zero the huge
> pages each time they are mmap'd - they are only zeroed when contigmem
> initially loads.  I will push a patch for this shortly.

So that is the case where we run the app more than once, right?
I missed that, I only ran it once.

Sergio


[dpdk-dev] [PATCH] optimize vhost enqueue

2016-08-16 Thread Zhihong Wang
This patch optimizes the vhost enqueue function: rte_vhost_enqueue_burst.

Currently there're 2 callbacks for vhost enqueue:
 *  virtio_dev_merge_rx for mrg_rxbuf turned on cases.
 *  virtio_dev_rx for mrg_rxbuf turned off cases.

The virtio_dev_merge_rx doesn't provide optimal performance, also it is
reported having compatibility issue working with Windows VMs.

Besides, having 2 separated functions increases maintenance efforts.

This patch uses a single function logic to replace the current 2 for
better maintainability, and provides better performance by optimizing
caching behavior especially for mrg_rxbuf turned on cases.

It also fixes the issue working with Windows VMs.

Signed-off-by: Zhihong Wang 
---
 lib/librte_vhost/vhost-net.h  |   6 +-
 lib/librte_vhost/vhost_rxtx.c | 582 ++
 lib/librte_vhost/virtio-net.c |  15 +-
 3 files changed, 208 insertions(+), 395 deletions(-)

diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h
index 38593a2..a15182c 100644
--- a/lib/librte_vhost/vhost-net.h
+++ b/lib/librte_vhost/vhost-net.h
@@ -71,7 +71,7 @@ struct vhost_virtqueue {
uint32_tsize;

/* Last index used on the available ring */
-   volatile uint16_t   last_used_idx;
+   uint16_tlast_used_idx;
 #define VIRTIO_INVALID_EVENTFD (-1)
 #define VIRTIO_UNINITIALIZED_EVENTFD   (-2)

@@ -85,6 +85,10 @@ struct vhost_virtqueue {

/* Physical address of used ring, for logging */
uint64_tlog_guest_addr;
+
+   /* Shadow used ring for performance */
+   struct vring_used_elem  *shadow_used_ring;
+   uint32_tshadow_used_idx;
 } __rte_cache_aligned;

 /* Old kernels have no such macro defined */
diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index 08a73fd..1263168 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -91,7 +91,7 @@ is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t 
qp_nb)
return (is_tx ^ (idx & 1)) == 0 && idx < qp_nb * VIRTIO_QNUM;
 }

-static void
+static inline void __attribute__((always_inline))
 virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr)
 {
if (m_buf->ol_flags & PKT_TX_L4_MASK) {
@@ -125,427 +125,227 @@ virtio_enqueue_offload(struct rte_mbuf *m_buf, struct 
virtio_net_hdr *net_hdr)
}
 }

-static inline void
-copy_virtio_net_hdr(struct virtio_net *dev, uint64_t desc_addr,
-   struct virtio_net_hdr_mrg_rxbuf hdr)
-{
-   if (dev->vhost_hlen == sizeof(struct virtio_net_hdr_mrg_rxbuf))
-   *(struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)desc_addr = hdr;
-   else
-   *(struct virtio_net_hdr *)(uintptr_t)desc_addr = hdr.hdr;
-}
-
-static inline int __attribute__((always_inline))
-copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
- struct rte_mbuf *m, uint16_t desc_idx)
+uint16_t
+rte_vhost_enqueue_burst(int vid, uint16_t queue_id,
+   struct rte_mbuf **pkts, uint16_t count)
 {
-   uint32_t desc_avail, desc_offset;
-   uint32_t mbuf_avail, mbuf_offset;
-   uint32_t cpy_len;
+   struct virtio_net_hdr_mrg_rxbuf *virtio_hdr;
+   struct vhost_virtqueue *vq;
struct vring_desc *desc;
-   uint64_t desc_addr;
-   struct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, 0, 0, 0, 0, 0}, 0};
-
-   desc = >desc[desc_idx];
-   desc_addr = gpa_to_vva(dev, desc->addr);
-   /*
-* Checking of 'desc_addr' placed outside of 'unlikely' macro to avoid
-* performance issue with some versions of gcc (4.8.4 and 5.3.0) which
-* otherwise stores offset on the stack instead of in a register.
-*/
-   if (unlikely(desc->len < dev->vhost_hlen) || !desc_addr)
-   return -1;
-
-   rte_prefetch0((void *)(uintptr_t)desc_addr);
-
-   virtio_enqueue_offload(m, _hdr.hdr);
-   copy_virtio_net_hdr(dev, desc_addr, virtio_hdr);
-   vhost_log_write(dev, desc->addr, dev->vhost_hlen);
-   PRINT_PACKET(dev, (uintptr_t)desc_addr, dev->vhost_hlen, 0);
-
-   desc_offset = dev->vhost_hlen;
-   desc_avail  = desc->len - dev->vhost_hlen;
-
-   mbuf_avail  = rte_pktmbuf_data_len(m);
-   mbuf_offset = 0;
-   while (mbuf_avail != 0 || m->next != NULL) {
-   /* done with current mbuf, fetch next */
-   if (mbuf_avail == 0) {
-   m = m->next;
-
-   mbuf_offset = 0;
-   mbuf_avail  = rte_pktmbuf_data_len(m);
-   }
-
-   /* done with current desc buf, fetch next */
-   if (desc_avail == 0) {
-   if ((desc->flags & VRING_DESC_F_NEXT) == 0) {
-   /* Room in vring buffer is not enough */
-   return -1;
-   }
-   if