[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-15 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

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);




[dpdk-dev] [PATCH] i40e: fix i40e_reset_tx_queue cmd_type_offset_bsz init

2014-10-01 Thread Jim Harris
Fix the descriptor initialization loop, so that it initializes
the i40e_tx_desc::cmd_type_offset_bsz for the correct index
into the tx_ring array.

Previously it would use the index once to initialize the txd
local variable, then again when setting cmd_type_offset_bsz.

Signed-off-by: Jim Harris 
---
 lib/librte_pmd_i40e/i40e_rxtx.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 7c5b6a8..2b53677 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -2072,7 +2072,7 @@ i40e_reset_tx_queue(struct i40e_tx_queue *txq)
for (i = 0; i < txq->nb_tx_desc; i++) {
volatile struct i40e_tx_desc *txd = >tx_ring[i];

-   txd[i].cmd_type_offset_bsz =
+   txd->cmd_type_offset_bsz =
rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE);
txe[i].mbuf =  NULL;
txe[i].last_id = i;