[dpdk-dev] Explanation of the QoS offset values used in the QoS scheduler example app.

2015-02-14 Thread Aws Ismail
Hi everyone,

I am looking at this portion of the code in the app_thread.c file of the
QoS scheduler example application:

/*
* QoS parameters are encoded as follows:
* Outer VLAN ID defines subport
* Inner VLAN ID defines pipe
* Destination IP 0.0.XXX.0 defines traffic class
* Destination IP host (0.0.0.XXX) defines queue
* Values below define offset to each field from start of frame
*/
#define SUBPORT_OFFSET 7
#define PIPE_OFFSET 9
#define TC_OFFSET 20
#define QUEUE_OFFSET 20
#define COLOR_OFFSET 19

static inline int get_pkt_sched(struct rte_mbuf *m, uint32_t *subport,
uint32_t *pipe, uint32_t *traffic_class, uint32_t *queue, uint32_t *color)
{
uint16_t *pdata = rte_pktmbuf_mtod(m, uint16_t *);

*subport = (rte_be_to_cpu_16(pdata[SUBPORT_OFFSET]) & 0x0FFF) &
(port_params.n_subports_per_port - 1); /* Outer VLAN ID*/

*pipe = (rte_be_to_cpu_16(pdata[PIPE_OFFSET]) & 0x0FFF) &
(port_params.n_pipes_per_subport - 1); /* Inner VLAN ID */

*traffic_class = (pdata[QUEUE_OFFSET] & 0x0F) &
(RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE - 1); /* Destination IP */

*queue = ((pdata[QUEUE_OFFSET] >> 8) & 0x0F) &
(RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS - 1) ; /* Destination IP */

*color = pdata[COLOR_OFFSET] & 0x03; /* Destination IP */

return 0;
}

The offset values do not make sense to me. According to the programmer
guide, the queue selection is SVID/CVID/TC/QID based. And those offset seem
off in this case. Is this because it is assuming that the packet is being
altered before it gets to this stage ?

Can anyone provide a better explanation or at least the reason behind
choosing those offset values shown above.

Thanks.


[dpdk-dev] [PATCH 4/4] xen: net-front poll mode driver

2015-02-14 Thread Neil Horman
On Sat, Feb 14, 2015 at 01:06:48PM -0500, Stephen Hemminger wrote:
> This driver implements DPDK driver that has the same functionality
> as net-front driver in Linux kernel.
> 
> Signed-off-by: Stephen Hemminger 
> ---
>  config/common_linuxapp|   6 +
>  lib/Makefile  |   1 +
>  lib/librte_eal/common/eal_private.h   |   7 +
>  lib/librte_eal/linuxapp/eal/eal.c |   8 +
>  lib/librte_pmd_xen/Makefile   |  30 ++
>  lib/librte_pmd_xen/virt_dev.c | 400 +
>  lib/librte_pmd_xen/virt_dev.h |  30 ++
>  lib/librte_pmd_xen/xen_adapter_info.h |  64 
>  lib/librte_pmd_xen/xen_dev.c  | 369 +++
>  lib/librte_pmd_xen/xen_dev.h  |  96 ++
>  lib/librte_pmd_xen/xen_logs.h |  23 ++
>  lib/librte_pmd_xen/xen_rxtx.c | 546 
> ++
>  lib/librte_pmd_xen/xen_rxtx.h | 110 +++
>  mk/rte.app.mk |   4 +
>  14 files changed, 1694 insertions(+)
>  create mode 100644 lib/librte_pmd_xen/Makefile
>  create mode 100644 lib/librte_pmd_xen/virt_dev.c
>  create mode 100644 lib/librte_pmd_xen/virt_dev.h
>  create mode 100644 lib/librte_pmd_xen/xen_adapter_info.h
>  create mode 100644 lib/librte_pmd_xen/xen_dev.c
>  create mode 100644 lib/librte_pmd_xen/xen_dev.h
>  create mode 100644 lib/librte_pmd_xen/xen_logs.h
>  create mode 100644 lib/librte_pmd_xen/xen_rxtx.c
>  create mode 100644 lib/librte_pmd_xen/xen_rxtx.h
>
> +
> +int
> +rte_xen_pmd_init(void)
> +{
> + PMD_INIT_FUNC_TRACE();
> +
> + xen_evt_fd = open("/dev/"XEN_PMD_UIO_NAME, O_RDWR);
> +
> + if (xen_evt_fd == -1) {
> + if (errno != ENOENT)
> + PMD_INIT_LOG(ERR, "cannot open event device %s",
> + "/dev/"XEN_PMD_UIO_NAME);
> + return 0;
> + }
> +
> + return virt_eth_driver_register(_xen_pmd);
> +}
It looks like you've created a new method of registering a pmd here?  Why not
use the existing REGISTER_PMD_DRIVER macro?  It seems like this method will
break the DSO build.

Neil

> 


[dpdk-dev] [PATCH 4/4] xen: net-front poll mode driver

2015-02-14 Thread Stephen Hemminger
This driver implements DPDK driver that has the same functionality
as net-front driver in Linux kernel.

Signed-off-by: Stephen Hemminger 
---
 config/common_linuxapp|   6 +
 lib/Makefile  |   1 +
 lib/librte_eal/common/eal_private.h   |   7 +
 lib/librte_eal/linuxapp/eal/eal.c |   8 +
 lib/librte_pmd_xen/Makefile   |  30 ++
 lib/librte_pmd_xen/virt_dev.c | 400 +
 lib/librte_pmd_xen/virt_dev.h |  30 ++
 lib/librte_pmd_xen/xen_adapter_info.h |  64 
 lib/librte_pmd_xen/xen_dev.c  | 369 +++
 lib/librte_pmd_xen/xen_dev.h  |  96 ++
 lib/librte_pmd_xen/xen_logs.h |  23 ++
 lib/librte_pmd_xen/xen_rxtx.c | 546 ++
 lib/librte_pmd_xen/xen_rxtx.h | 110 +++
 mk/rte.app.mk |   4 +
 14 files changed, 1694 insertions(+)
 create mode 100644 lib/librte_pmd_xen/Makefile
 create mode 100644 lib/librte_pmd_xen/virt_dev.c
 create mode 100644 lib/librte_pmd_xen/virt_dev.h
 create mode 100644 lib/librte_pmd_xen/xen_adapter_info.h
 create mode 100644 lib/librte_pmd_xen/xen_dev.c
 create mode 100644 lib/librte_pmd_xen/xen_dev.h
 create mode 100644 lib/librte_pmd_xen/xen_logs.h
 create mode 100644 lib/librte_pmd_xen/xen_rxtx.c
 create mode 100644 lib/librte_pmd_xen/xen_rxtx.h

diff --git a/config/common_linuxapp b/config/common_linuxapp
index d428f84..668fc8d 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -232,6 +232,12 @@ CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
 CONFIG_RTE_LIBRTE_PMD_XENVIRT=n

 #
+# Compile XEN net-front PMD driver
+#
+CONFIG_RTE_LIBRTE_XEN_PMD=n
+CONFIG_RTE_LIBRTE_XEN_DEBUG_INIT=n
+
+#
 # Do prefetch of packet data within PMD driver receive function
 #
 CONFIG_RTE_PMD_PACKET_PREFETCH=y
diff --git a/lib/Makefile b/lib/Makefile
index d617d81..f405e40 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -52,6 +52,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_AF_PACKET) += 
librte_pmd_af_packet
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt
+DIRS-$(CONFIG_RTE_LIBRTE_XEN_PMD) += librte_pmd_xen
 DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += librte_vhost
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
diff --git a/lib/librte_eal/common/eal_private.h 
b/lib/librte_eal/common/eal_private.h
index 159cd66..0614607 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -128,6 +128,13 @@ int rte_eal_log_init(const char *id, int facility);
  */
 int rte_eal_pci_init(void);

+#ifdef RTE_LIBRTE_XEN_PMD
+/**
+ * Init of the xen driver
+ */
+extern int rte_xen_pmd_init(void);
+#endif
+
 #ifdef RTE_LIBRTE_IVSHMEM
 /**
  * Init the memory from IVSHMEM devices
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index f99e158..4e60b7c 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -760,6 +760,14 @@ rte_eal_init(int argc, char **argv)
rte_panic("Cannot init IVSHMEM\n");
 #endif

+#ifdef RTE_LIBRTE_XEN_PMD
+   ret = rte_xen_pmd_init();
+   if (ret != 0) {
+   RTE_LOG(ERR, PMD, "Cannot init xen PMD\n");
+   return ret;
+   }
+#endif /* RTE_LIBRTE_XEN_PMD */
+
if (rte_eal_memory_init() < 0)
rte_panic("Cannot init memory\n");

diff --git a/lib/librte_pmd_xen/Makefile b/lib/librte_pmd_xen/Makefile
new file mode 100644
index 000..d294d03
--- /dev/null
+++ b/lib/librte_pmd_xen/Makefile
@@ -0,0 +1,30 @@
+#
+#   Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
+#   All rights reserved.
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_xen.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+VPATH += $(RTE_SDK)/lib/librte_pmd_xen
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_XEN_PMD) += virt_dev.c
+SRCS-$(CONFIG_RTE_LIBRTE_XEN_PMD) += xen_dev.c
+SRCS-$(CONFIG_RTE_LIBRTE_XEN_PMD) += xen_rxtx.c
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_XEN_PMD) += lib/librte_eal lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_XEN_PMD) += lib/librte_mempool lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_XEN_PMD) += lib/librte_net lib/librte_malloc
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_xen/virt_dev.c b/lib/librte_pmd_xen/virt_dev.c
new file mode 100644
index 000..f824977
--- /dev/null
+++ b/lib/librte_pmd_xen/virt_dev.c
@@ -0,0 +1,400 @@
+/*
+ * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
+ * All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include "virt_dev.h"
+
+struct uio_map {
+   void *addr;
+   uint64_t offset;
+   uint64_t size;
+   uint64_t phaddr;
+};
+
+struct uio_resource {
+   

[dpdk-dev] [PATCH 3/4] xen: add uio driver

2015-02-14 Thread Stephen Hemminger
New uio helper kernel driver for use by Xen netfront UIO poll mode driver.

Signed-off-by: Stephen Hemminger 
---
 lib/librte_eal/linuxapp/Makefile  |   3 +
 lib/librte_eal/linuxapp/xen_uio/Makefile  |  55 ++
 lib/librte_eal/linuxapp/xen_uio/xen_uio.c | 837 ++
 3 files changed, 895 insertions(+)
 create mode 100644 lib/librte_eal/linuxapp/xen_uio/Makefile
 create mode 100644 lib/librte_eal/linuxapp/xen_uio/xen_uio.c

diff --git a/lib/librte_eal/linuxapp/Makefile b/lib/librte_eal/linuxapp/Makefile
index 8fcfdf6..d3893e5 100644
--- a/lib/librte_eal/linuxapp/Makefile
+++ b/lib/librte_eal/linuxapp/Makefile
@@ -41,5 +41,8 @@ endif
 ifeq ($(CONFIG_RTE_LIBRTE_XEN_DOM0),y)
 DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += xen_dom0
 endif
+ifeq ($(CONFIG_RTE_LIBRTE_XEN_PMD),y)
+DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += xen_uio
+endif

 include $(RTE_SDK)/mk/rte.subdir.mk
diff --git a/lib/librte_eal/linuxapp/xen_uio/Makefile 
b/lib/librte_eal/linuxapp/xen_uio/Makefile
new file mode 100644
index 000..25a9f35
--- /dev/null
+++ b/lib/librte_eal/linuxapp/xen_uio/Makefile
@@ -0,0 +1,55 @@
+#   BSD LICENSE
+#
+#   Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# module name and path
+#
+MODULE = xen_uio
+MODULE_PATH = drivers/net/xen_uio
+
+#
+# CFLAGS
+#
+MODULE_CFLAGS += -I$(SRCDIR) --param max-inline-insns-single=100
+MODULE_CFLAGS += -I$(RTE_OUTPUT)/include
+MODULE_CFLAGS += -Winline -Wall -Werror
+MODULE_CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-y := xen_uio.c
+
+
+include $(RTE_SDK)/mk/rte.module.mk
diff --git a/lib/librte_eal/linuxapp/xen_uio/xen_uio.c 
b/lib/librte_eal/linuxapp/xen_uio/xen_uio.c
new file mode 100644
index 000..b25b1f3
--- /dev/null
+++ b/lib/librte_eal/linuxapp/xen_uio/xen_uio.c
@@ -0,0 +1,837 @@
+/*
+ * Virtual network driver for conversing with remote driver backends.
+ *
+ * Copyright (c) 2002-2005, K A Fraser
+ * Copyright (c) 2005, XenSource Ltd
+ * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 

[dpdk-dev] [PATCH 2/4] xen: add phys-addr command line argument

2015-02-14 Thread Stephen Hemminger
Allow overriding default Xen DOM0 behavior to
use physical addresses insted of mfn.

Signed-off-by: Stephen Hemminger 
---
 lib/librte_eal/common/eal_common_options.c |  5 +
 lib/librte_eal/common/eal_internal_cfg.h   |  1 +
 lib/librte_eal/common/eal_options.h|  2 ++
 lib/librte_eal/common/include/rte_memory.h |  3 +++
 lib/librte_eal/linuxapp/eal/eal_memory.c   |  5 +
 lib/librte_mempool/rte_dom0_mempool.c  | 10 --
 6 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 67e02dc..1742364 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -83,6 +83,7 @@ eal_long_options[] = {
{OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM},
{OPT_BASE_VIRTADDR, 1, 0, OPT_BASE_VIRTADDR_NUM},
{OPT_XEN_DOM0, 0, 0, OPT_XEN_DOM0_NUM},
+   {OPT_XEN_PHYS_ADDR, 0, 0, OPT_XEN_PHYS_ADDR_NUM},
{OPT_CREATE_UIO_DEV, 1, NULL, OPT_CREATE_UIO_DEV_NUM},
{OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
{0, 0, 0, 0}
@@ -491,6 +492,10 @@ eal_parse_common_option(int opt, const char *optarg,
}
conf->log_level = log;
break;
+
+   case OPT_XEN_PHYS_ADDR_NUM:
+   conf->xen_phys_addr_support = 1;
+   break;
}

/* don't know what to do, leave this to caller */
diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
b/lib/librte_eal/common/eal_internal_cfg.h
index e2ecb0d..41b4169 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -65,6 +65,7 @@ struct internal_config {
volatile unsigned force_nrank;/**< force number of ranks */
volatile unsigned no_hugetlbfs;   /**< true to disable hugetlbfs */
volatile unsigned xen_dom0_support; /**< support app running on Xen 
Dom0*/
+   volatile unsigned xen_phys_addr_support; /**< support phys addr */
volatile unsigned no_pci; /**< true to disable PCI */
volatile unsigned no_hpet;/**< true to disable HPET */
volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping
diff --git a/lib/librte_eal/common/eal_options.h 
b/lib/librte_eal/common/eal_options.h
index e476f8d..8aee959 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -73,6 +73,8 @@ enum {
OPT_BASE_VIRTADDR_NUM,
 #define OPT_XEN_DOM0"xen-dom0"
OPT_XEN_DOM0_NUM,
+#define OPT_XEN_PHYS_ADDR "xen-phys-addr"
+   OPT_XEN_PHYS_ADDR_NUM,
 #define OPT_CREATE_UIO_DEV "create-uio-dev"
OPT_CREATE_UIO_DEV_NUM,
 #define OPT_VFIO_INTR"vfio-intr"
diff --git a/lib/librte_eal/common/include/rte_memory.h 
b/lib/librte_eal/common/include/rte_memory.h
index ab6c1ff..c3b8a98 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -180,6 +180,9 @@ unsigned rte_memory_get_nrank(void);
 /**< Internal use only - should DOM0 memory mapping be used */
 extern int is_xen_dom0_supported(void);

+/**< Internal use only - should DOM0 use physical addresses insted of mfn */
+extern int is_xen_phys_addr_supported(void);
+
 /**
  * Return the physical address of elt, which is an element of the pool mp.
  *
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 4afda2a..a759ac9 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -103,6 +103,11 @@ int is_xen_dom0_supported(void)
 {
return internal_config.xen_dom0_support;
 }
+
+int is_xen_phys_addr_supported(void)
+{
+   return internal_config.xen_phys_addr_support;
+}
 #endif

 /**
diff --git a/lib/librte_mempool/rte_dom0_mempool.c 
b/lib/librte_mempool/rte_dom0_mempool.c
index 9ec68fb..ab35826 100644
--- a/lib/librte_mempool/rte_dom0_mempool.c
+++ b/lib/librte_mempool/rte_dom0_mempool.c
@@ -74,8 +74,14 @@ get_phys_map(void *va, phys_addr_t pa[], uint32_t pg_num,
 virt_addr =(uintptr_t) mcfg->memseg[memseg_id].addr;

 for (i = 0; i != pg_num; i++) {
-mfn_id = ((uintptr_t)va + i * pg_sz - virt_addr) / RTE_PGSIZE_2M;
-pa[i] = mcfg->memseg[memseg_id].mfn[mfn_id] * page_size;
+   if (!is_xen_phys_addr_supported()) {
+   mfn_id = ((uintptr_t)va + i * pg_sz -
+   virt_addr) / RTE_PGSIZE_2M;
+   pa[i] = mcfg->memseg[memseg_id].mfn[mfn_id] * page_size;
+   } else {
+   pa[i] = mcfg->memseg[memseg_id].phys_addr + i * pg_sz +
+   (uintptr_t)va - virt_addr;
+   }
 }
 }

-- 
2.1.4



[dpdk-dev] [PATCH 1/4] xen: allow choosing dom0 support at runtime

2015-02-14 Thread Stephen Hemminger
The previous code would only allow building library and application
so that it ran on Xen DOM0 or not on DOM0. This changes that to
a runtime flag.

Signed-off-by: Stephen Hemminger 
---
 lib/librte_eal/common/include/rte_memory.h |  4 +++
 lib/librte_eal/linuxapp/eal/eal_memory.c   |  7 
 lib/librte_ether/rte_ethdev.c  | 22 
 lib/librte_ether/rte_ethdev.h  | 23 
 lib/librte_mempool/rte_mempool.c   | 26 +++---
 lib/librte_pmd_e1000/em_rxtx.c | 30 +++-
 lib/librte_pmd_e1000/igb_rxtx.c| 52 +--
 lib/librte_pmd_ixgbe/ixgbe_rxtx.c  | 58 +-
 8 files changed, 108 insertions(+), 114 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_memory.h 
b/lib/librte_eal/common/include/rte_memory.h
index 7f8103f..ab6c1ff 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -176,6 +176,10 @@ unsigned rte_memory_get_nchannel(void);
 unsigned rte_memory_get_nrank(void);

 #ifdef RTE_LIBRTE_XEN_DOM0
+
+/**< Internal use only - should DOM0 memory mapping be used */
+extern int is_xen_dom0_supported(void);
+
 /**
  * Return the physical address of elt, which is an element of the pool mp.
  *
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
b/lib/librte_eal/linuxapp/eal/eal_memory.c
index a67a1b0..4afda2a 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -98,6 +98,13 @@
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"

+#ifdef RTE_LIBRTE_XEN_DOM0
+int is_xen_dom0_supported(void)
+{
+   return internal_config.xen_dom0_support;
+}
+#endif
+
 /**
  * @file
  * Huge page mapping under linux
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ea3a1fb..457e0bc 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2825,6 +2825,27 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
}
rte_spinlock_unlock(_eth_dev_cb_lock);
 }
+
+const struct rte_memzone *
+rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
+uint16_t queue_id, size_t size, unsigned align,
+int socket_id)
+{
+   char z_name[RTE_MEMZONE_NAMESIZE];
+   const struct rte_memzone *mz;
+
+   snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
+dev->driver->pci_drv.name, ring_name,
+dev->data->port_id, queue_id);
+
+   mz = rte_memzone_lookup(z_name);
+   if (mz)
+   return mz;
+
+   return rte_memzone_reserve_bounded(z_name, size,
+  socket_id, 0, align, RTE_PGSIZE_2M);
+}
+
 #ifdef RTE_NIC_BYPASS
 int rte_eth_dev_bypass_init(uint8_t port_id)
 {
@@ -3003,6 +3024,7 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id)
(*dev->dev_ops->bypass_wd_reset)(dev);
return 0;
 }
+
 #endif

 int
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1200c1c..747acb5 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3664,6 +3664,29 @@ int rte_eth_dev_filter_supported(uint8_t port_id, enum 
rte_filter_type filter_ty
 int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
enum rte_filter_op filter_op, void *arg);

+/**
+ * Create memzone for HW rings.
+ * malloc can't be used as the physical address is needed.
+ * If the memzone is already created, then this function returns a ptr
+ * to the old one.
+ *
+ * @param eth_dev
+ *   The *eth_dev* pointer is the address of the *rte_eth_dev* structure
+ * @param name
+ *   The name of the memory zone
+ * @param queue_id
+ *   The index of the queue to add to name
+ * @param size
+ *   The sizeof of the memory area
+ * @param align
+ *   Alignment for resulting memzone. Must be a power of 2.
+ * @param socket_id
+ *   The *socket_id* argument is the socket identifier in case of NUMA.
+ */
+const struct rte_memzone *
+rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
+uint16_t queue_id, size_t size,
+unsigned align, int socket_id);
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 4cf6c25..5056a4f 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -372,19 +372,21 @@ rte_mempool_create(const char *name, unsigned n, unsigned 
elt_size,
   int socket_id, unsigned flags)
 {
 #ifdef RTE_LIBRTE_XEN_DOM0
-   return (rte_dom0_mempool_create(name, n, elt_size,
-   cache_size, private_data_size,
-   mp_init, mp_init_arg,
-   obj_init, obj_init_arg,
-   socket_id, flags));
-#else
-   return (rte_mempool_xmem_create(name, n, elt_size,
-   

[dpdk-dev] [PATCH] Add Q variable to external builds to be quite

2015-02-14 Thread Keith Wiles
Signed-off-by: Keith Wiles 
---
 mk/rte.extvars.mk | 4 
 1 file changed, 4 insertions(+)

diff --git a/mk/rte.extvars.mk b/mk/rte.extvars.mk
index 3e5a990..83a5721 100644
--- a/mk/rte.extvars.mk
+++ b/mk/rte.extvars.mk
@@ -66,6 +66,10 @@ endif
 RTE_OUTPUT ?= $(RTE_SRCDIR)/build
 export RTE_OUTPUT

+# define Q to '@' or not. $(Q) is used to prefix all shell commands to
+# be executed silently.
+Q=@
+
 # if we are building an external application, include SDK
 # configuration and include project configuration if any
 include $(RTE_SDK_BIN)/.config
-- 
2.3.0



[dpdk-dev] [PATCH 1/2] enic: replace use of printf with log

2015-02-14 Thread Neil Horman
On Sat, Feb 14, 2015 at 10:32:58AM -0500, Stephen Hemminger wrote:
> Device driver should log via DPDK log, not to printf which is
> sends to /dev/null in a daemon application.
> 
> Signed-off-by: Stephen Hemminger 
> ---
>  lib/librte_pmd_enic/enic_compat.h | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/librte_pmd_enic/enic_compat.h 
> b/lib/librte_pmd_enic/enic_compat.h
> index b1af838..c3ab76e 100644
> --- a/lib/librte_pmd_enic/enic_compat.h
> +++ b/lib/librte_pmd_enic/enic_compat.h
> @@ -75,10 +75,13 @@
>  #define kzalloc(size, flags) calloc(1, size)
>  #define kfree(x) free(x)
>  
> -#define dev_err(x, args...) printf("rte_enic_pmd : Error - " args)
> -#define dev_info(x, args...) printf("rte_enic_pmd: Info - " args)
> -#define dev_warning(x, args...) printf("rte_enic_pmd: Warning - " args)
> -#define dev_trace(x, args...) printf("rte_enic_pmd: Trace - " args)
> +#define dev_printk(level, fmt, args...)  \
> + RTE_LOG(level, PMD, "rte_enic_pmd:" fmt, ## args)
> +
> +#define dev_err(x, args...) dev_printk(ERR, args)
> +#define dev_info(x, args...) dev_printk(INFO,  args)
> +#define dev_warning(x, args...) dev_printk(WARNING, args)
> +#define dev_debug(x, args...) dev_printk(DEBUG, args)
>  
>  #define __le16 u16
>  #define __le32 u32
> -- 
> 2.1.4
> 
> 
Series
Acked-by: Neil Horman 



[dpdk-dev] [PATCH 2/2] enic: change probe log message level

2015-02-14 Thread Stephen Hemminger
Drivers should be silent on boot.

Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_enic/enic_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_pmd_enic/enic_main.c b/lib/librte_pmd_enic/enic_main.c
index 48fdca2..c66f139 100644
--- a/lib/librte_pmd_enic/enic_main.c
+++ b/lib/librte_pmd_enic/enic_main.c
@@ -1046,7 +1046,7 @@ int enic_probe(struct enic *enic)
struct rte_pci_device *pdev = enic->pdev;
int err = -1;

-   dev_info(enic, " Initializing ENIC PMD version %s\n", DRV_VERSION);
+   dev_debug(enic, " Initializing ENIC PMD version %s\n", DRV_VERSION);

enic->bar0.vaddr = (void *)pdev->mem_resource[0].addr;
enic->bar0.len = pdev->mem_resource[0].len;
-- 
2.1.4



[dpdk-dev] [PATCH 1/2] enic: replace use of printf with log

2015-02-14 Thread Stephen Hemminger
Device driver should log via DPDK log, not to printf which is
sends to /dev/null in a daemon application.

Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_enic/enic_compat.h | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/librte_pmd_enic/enic_compat.h 
b/lib/librte_pmd_enic/enic_compat.h
index b1af838..c3ab76e 100644
--- a/lib/librte_pmd_enic/enic_compat.h
+++ b/lib/librte_pmd_enic/enic_compat.h
@@ -75,10 +75,13 @@
 #define kzalloc(size, flags) calloc(1, size)
 #define kfree(x) free(x)

-#define dev_err(x, args...) printf("rte_enic_pmd : Error - " args)
-#define dev_info(x, args...) printf("rte_enic_pmd: Info - " args)
-#define dev_warning(x, args...) printf("rte_enic_pmd: Warning - " args)
-#define dev_trace(x, args...) printf("rte_enic_pmd: Trace - " args)
+#define dev_printk(level, fmt, args...)\
+   RTE_LOG(level, PMD, "rte_enic_pmd:" fmt, ## args)
+
+#define dev_err(x, args...) dev_printk(ERR, args)
+#define dev_info(x, args...) dev_printk(INFO,  args)
+#define dev_warning(x, args...) dev_printk(WARNING, args)
+#define dev_debug(x, args...) dev_printk(DEBUG, args)

 #define __le16 u16
 #define __le32 u32
-- 
2.1.4



[dpdk-dev] [PATCH 6/6] examples: remove unneeded casts

2015-02-14 Thread Stephen Hemminger
*alloc() routines return void * and therefore cast is not needed.

Signed-off-by: Stephen Hemminger 
---
 examples/kni/main.c   | 4 ++--
 examples/l3fwd-acl/main.c | 4 ++--
 examples/vhost/main.c | 7 ---
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/examples/kni/main.c b/examples/kni/main.c
index 45b96bc..2bff1e1 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -462,8 +462,8 @@ parse_config(const char *arg)
goto fail;
}
kni_port_params_array[port_id] =
-   (struct kni_port_params*)rte_zmalloc("KNI_port_params",
-   sizeof(struct kni_port_params), RTE_CACHE_LINE_SIZE);
+   rte_zmalloc("KNI_port_params",
+   sizeof(struct kni_port_params), 
RTE_CACHE_LINE_SIZE);
kni_port_params_array[port_id]->port_id = port_id;
kni_port_params_array[port_id]->lcore_rx =
(uint8_t)int_fld[i++];
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index f1f7601..20e071a 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -1047,13 +1047,13 @@ add_rules(const char *rule_path,

fseek(fh, 0, SEEK_SET);

-   acl_rules = (uint8_t *)calloc(acl_num, rule_size);
+   acl_rules = calloc(acl_num, rule_size);

if (NULL == acl_rules)
rte_exit(EXIT_FAILURE, "%s: failed to malloc memory\n",
__func__);

-   route_rules = (uint8_t *)calloc(route_num, rule_size);
+   route_rules = calloc(route_num, rule_size);

if (NULL == route_rules)
rte_exit(EXIT_FAILURE, "%s: failed to malloc memory\n",
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 3a35359..a96b19f 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2592,9 +2592,10 @@ new_device (struct virtio_net *dev)

}

-   vdev->regions_hpa = (struct virtio_memory_regions_hpa *) 
rte_zmalloc("vhost hpa region",
-   sizeof(struct virtio_memory_regions_hpa) * 
vdev->nregions_hpa,
-   RTE_CACHE_LINE_SIZE);
+   vdev->regions_hpa = rte_calloc("vhost hpa region",
+  sizeof(struct 
virtio_memory_regions_hpa),
+  vdev->nregions_hpa,
+  RTE_CACHE_LINE_SIZE);
if (vdev->regions_hpa == NULL) {
RTE_LOG(ERR, VHOST_CONFIG, "Cannot allocate memory for 
hpa region\n");
rte_free(vdev);
-- 
2.1.4



[dpdk-dev] [PATCH 5/6] eal: remove useless memset

2015-02-14 Thread Stephen Hemminger
The path variable is set via snprintf, and does not need to
memset before that.

Signed-off-by: Stephen Hemminger 
---
 lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c 
b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
index 590cb56..8d29e06 100644
--- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
+++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
@@ -84,8 +84,6 @@ get_num_hugepages(const char *subdir)
else
nr_hp_file = "free_hugepages";

-   memset(path, 0, sizeof(path));
-
snprintf(path, sizeof(path), "%s/%s/%s",
sys_dir_path, subdir, nr_hp_file);

-- 
2.1.4



[dpdk-dev] [PATCH 4/6] enic: eliminate useless cast

2015-02-14 Thread Stephen Hemminger
Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_enic/enic_clsf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/librte_pmd_enic/enic_clsf.c b/lib/librte_pmd_enic/enic_clsf.c
index 577a382..b61d625 100644
--- a/lib/librte_pmd_enic/enic_clsf.c
+++ b/lib/librte_pmd_enic/enic_clsf.c
@@ -121,9 +121,8 @@ int enic_fdir_add_fltr(struct enic *enic, struct 
rte_fdir_filter *params,
enic->fdir.stats.f_add++;
return -ENOSPC;
}
-   key = (struct enic_fdir_node *)rte_zmalloc(
-   "enic_fdir_node",
-   sizeof(struct enic_fdir_node), 0);
+   key = rte_zmalloc("enic_fdir_node",
+ sizeof(struct enic_fdir_node), 0);
if (!key) {
enic->fdir.stats.f_add++;
return -ENOMEM;
-- 
2.1.4



[dpdk-dev] [PATCH 3/6] bsd: remove useless assignments

2015-02-14 Thread Stephen Hemminger
If variable is set in the next line, it doesn't need to be
initialized.

Signed-off-by: Stephen Hemminger 
---
 lib/librte_eal/bsdapp/eal/eal.c | 3 ++-
 lib/librte_eal/bsdapp/eal/eal_pci.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 69f3c03..71ae33c 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -417,7 +417,8 @@ int rte_eal_has_hugepages(void)
 int
 rte_eal_iopl_init(void)
 {
-   int fd = -1;
+   int fd;
+
fd = open("/dev/io", O_RDWR);
if (fd < 0)
return -1;
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c 
b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 74ecce7..d191323 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -382,7 +382,7 @@ skipdev:
 static int
 pci_scan(void)
 {
-   int fd = -1;
+   int fd;
unsigned dev_count = 0;
struct pci_conf matches[16];
struct pci_conf_io conf_io = {
-- 
2.1.4



[dpdk-dev] [PATCH 2/6] vhost_xen: remove unnecessary cast

2015-02-14 Thread Stephen Hemminger
Don't need to cast malloc family of functions since they return
void *.

Signed-off-by: Stephen Hemminger 
---
 examples/vhost_xen/vhost_monitor.c  | 2 +-
 examples/vhost_xen/xenstore_parse.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/vhost_xen/vhost_monitor.c 
b/examples/vhost_xen/vhost_monitor.c
index f683989..9d99962 100644
--- a/examples/vhost_xen/vhost_monitor.c
+++ b/examples/vhost_xen/vhost_monitor.c
@@ -138,7 +138,7 @@ add_xen_guest(int32_t dom_id)
if ((guest = get_xen_guest(dom_id)) != NULL)
return guest;

-   guest = (struct xen_guest * )calloc(1, sizeof(struct xen_guest));
+   guest = calloc(1, sizeof(struct xen_guest));
if (guest) {
RTE_LOG(ERR, XENHOST, "  %s: return newly created guest with %d 
rings\n", __func__, guest->vring_num);
TAILQ_INSERT_TAIL(_root, guest, next);
diff --git a/examples/vhost_xen/xenstore_parse.c 
b/examples/vhost_xen/xenstore_parse.c
index 9441639..df191ac 100644
--- a/examples/vhost_xen/xenstore_parse.c
+++ b/examples/vhost_xen/xenstore_parse.c
@@ -248,8 +248,8 @@ parse_gntnode(int dom_id, char *path)
goto err;
}

-   gntnode = (struct xen_gntnode *)calloc(1, sizeof(struct xen_gntnode));
-   gnt = (struct xen_gnt *)calloc(gref_num, sizeof(struct xen_gnt));
+   gntnode = calloc(1, sizeof(struct xen_gntnode));
+   gnt = calloc(gref_num, sizeof(struct xen_gnt));
if (gnt == NULL || gntnode == NULL)
goto err;

-- 
2.1.4



[dpdk-dev] [PATCH 1/6] test: remove unneeded casts

2015-02-14 Thread Stephen Hemminger
The malloc family returns void * and therefore cast is unnecessary.
Use calloc rather than zmalloc with multiply for array.

Signed-off-by: Stephen Hemminger 
---
 app/test/test_hash_perf.c | 8 
 app/test/test_mempool.c   | 2 +-
 app/test/test_ring.c  | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c
index be34957..6f719fc 100644
--- a/app/test/test_hash_perf.c
+++ b/app/test/test_hash_perf.c
@@ -459,13 +459,13 @@ run_single_tbl_perf_test(const struct rte_hash *h, 
hash_operation func,

/* Initialise */
num_buckets = params->entries / params->bucket_entries;
-   key = (uint8_t *) rte_zmalloc("hash key",
-   params->key_len * sizeof(uint8_t), 16);
+   key = rte_zmalloc("hash key",
+ params->key_len * sizeof(uint8_t), 16);
if (key == NULL)
return -1;

-   bucket_occupancies = (uint32_t *) rte_zmalloc("bucket occupancies",
-   num_buckets * sizeof(uint32_t), 16);
+   bucket_occupancies = rte_calloc("bucket occupancies",
+   num_buckets, sizeof(uint32_t), 16);
if (bucket_occupancies == NULL) {
rte_free(key);
return -1;
diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index 303d2b3..de85c9c 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -360,7 +360,7 @@ test_mempool_basic_ex(struct rte_mempool * mp)
if (mp == NULL)
return ret;

-   obj = (void **)rte_zmalloc("test_mempool_basic_ex", (MEMPOOL_SIZE * 
sizeof(void *)), 0);
+   obj = rte_calloc("test_mempool_basic_ex", MEMPOOL_SIZE , sizeof(void 
*), 0);
if (obj == NULL) {
printf("test_mempool_basic_ex fail to rte_malloc\n");
return ret;
diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index 2cd8e77..ce25329 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -1259,7 +1259,7 @@ test_ring_basic_ex(void)
struct rte_ring * rp;
void **obj = NULL;

-   obj = (void **)rte_zmalloc("test_ring_basic_ex_malloc", (RING_SIZE * 
sizeof(void *)), 0);
+   obj = rte_calloc("test_ring_basic_ex_malloc", RING_SIZE, sizeof(void 
*), 0);
if (obj == NULL) {
printf("test_ring_basic_ex fail to rte_malloc\n");
goto fail_test;
-- 
2.1.4