[dpdk-dev] DDPK use of MAP_FIXED in mmap

2014-12-08 Thread Karmarkar Suyash
Hello,

In DPDK when we use mmap why are we passing the MAP_FIXED flag when Linux man 
page itself says that the option is discouraged? Any specific reason for 
passing the MAP_FIXED flag?


http://linux.die.net/man/2/mmap

MAP_FIXED
Don't interpret addr as a hint: place the mapping at exactly that address. addr 
must be a multiple of the page size. If the memory region specified by addr and 
len overlaps pages of any existing mapping(s), then the overlapped part of the 
existing mapping(s) will be discarded. If the specified address cannot be used, 
mmap() will fail. Because requiring a fixed address for a mapping is less 
portable, the use of this option is discouraged.


Regards
Suyash Karmarkar


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

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

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

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

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

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

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

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

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

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

 #include 
+#include 
+#include 
+#include 

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

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

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

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


[dpdk-dev] (no subject)

2014-12-08 Thread
>From stephen at networkplumber.org Mon Dec  8 09:46:51 2014
Message-Id: <20141208174651.333788346 at networkplumber.org>
User-Agent: quilt/0.63-1
Date: Mon, 08 Dec 2014 09:46:00 -0800
From: Stephen Hemminger 
To: Thomas Monjalon 
Cc: dev at dpdk.org,
 Stephen Hemminger 
Subject: [PATCH 6/6] rte_sched: dont put tabs in log messages
References: <20141208174554.889069531 at networkplumber.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Disposition: inline; filename=rte-sched-no-tab.patch

syslog does not like tabs in log messages; tab gets translated to #011

Signed-off-by: Stephen Hemminger 


--- a/lib/librte_sched/rte_sched.c  2014-12-08 09:37:08.741006405 -0800
+++ b/lib/librte_sched/rte_sched.c  2014-12-08 09:37:56.641264631 -0800
@@ -495,10 +495,10 @@ rte_sched_port_log_pipe_profile(struct r
struct rte_sched_pipe_profile *p = port->pipe_profiles + i;

RTE_LOG(INFO, SCHED, "Low level config for pipe profile %u:\n"
-   "\tToken bucket: period = %u, credits per period = %u, size = 
%u\n"
-   "\tTraffic classes: period = %u, credits per period = [%u, %u, 
%u, %u]\n"
-   "\tTraffic class 3 oversubscription: weight = %hhu\n"
-   "\tWRR cost: [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, 
%hhu], [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, %hhu]\n",
+   "Token bucket: period = %u, credits per period = %u, size = 
%u\n"
+   "Traffic classes: period = %u, credits per period = [%u, 
%u, %u, %u]\n"
+   "Traffic class 3 oversubscription: weight = %hhu\n"
+   "WRR cost: [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, 
%hhu], [%hhu, %hhu, %hhu, %hhu], [%hhu, %hhu, %hhu, %hhu]\n",
i,

/* Token bucket */
@@ -716,9 +716,9 @@ rte_sched_port_log_subport_config(struct
struct rte_sched_subport *s = port->subport + i;

RTE_LOG(INFO, SCHED, "Low level config for subport %u:\n"
-   "\tToken bucket: period = %u, credits per period = %u, size = 
%u\n"
-   "\tTraffic classes: period = %u, credits per period = [%u, %u, 
%u, %u]\n"
-   "\tTraffic class 3 oversubscription: wm min = %u, wm max = 
%u\n",
+   "Token bucket: period = %u, credits per period = %u, size = 
%u\n"
+   "Traffic classes: period = %u, credits per period = [%u, 
%u, %u, %u]\n"
+   "Traffic class 3 oversubscription: wm min = %u, wm max = 
%u\n",
i,

/* Token bucket */




[dpdk-dev] (no subject)

2014-12-08 Thread
>From stephen at networkplumber.org Mon Dec  8 09:46:51 2014
Message-Id: <20141208174651.232055974 at networkplumber.org>
User-Agent: quilt/0.63-1
Date: Mon, 08 Dec 2014 09:45:58 -0800
From: Stephen Hemminger 
To: Thomas Monjalon 
Cc: dev at dpdk.org,
 Stephen Hemminger 
Subject: [PATCH 4/6] rte_sched: keep track of RED drops
References: <20141208174554.889069531 at networkplumber.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Disposition: inline; filename=red-stats.patch

Add new statistic to keep track of drops due to RED.

Signed-off-by: Stephen Hemminger 

--- a/lib/librte_sched/rte_sched.c  2014-12-08 09:28:37.810590895 -0800
+++ b/lib/librte_sched/rte_sched.c  2014-12-08 09:28:37.810590895 -0800
@@ -1028,7 +1028,9 @@ rte_sched_port_update_subport_stats(stru
 }

 static inline void
-rte_sched_port_update_subport_stats_on_drop(struct rte_sched_port *port, 
uint32_t qindex, struct rte_mbuf *pkt)
+rte_sched_port_update_subport_stats_on_drop(struct rte_sched_port *port,
+   uint32_t qindex,
+   struct rte_mbuf *pkt, uint32_t red)
 {
struct rte_sched_subport *s = port->subport + (qindex / 
rte_sched_port_queues_per_subport(port));
uint32_t tc_index = (qindex >> 2) & 0x3;
@@ -1036,6 +1038,9 @@ rte_sched_port_update_subport_stats_on_d

s->stats.n_pkts_tc_dropped[tc_index] += 1;
s->stats.n_bytes_tc_dropped[tc_index] += pkt_len;
+#ifdef RTE_SCHED_RED
+   s->stats.n_pkts_red_dropped[tc_index] += red;
+#endif
 }

 static inline void
@@ -1206,12 +1211,20 @@ rte_sched_port_enqueue_qwa(struct rte_sc
qlen = q->qw - q->qr;

/* Drop the packet (and update drop stats) when queue is full */
-   if (unlikely(rte_sched_port_red_drop(port, pkt, qindex, qlen) || (qlen 
>= qsize))) {
+   if (unlikely(rte_sched_port_red_drop(port, pkt, qindex, qlen))) {
+#ifdef RTE_SCHED_COLLECT_STATS
+   rte_sched_port_update_subport_stats_on_drop(port, qindex, pkt, 
1);
+   rte_sched_port_update_queue_stats_on_drop(port, qindex, pkt, 1);
+#endif
rte_pktmbuf_free(pkt);
+   }
+
+   if (qlen >= qsize) {
 #ifdef RTE_SCHED_COLLECT_STATS
-   rte_sched_port_update_subport_stats_on_drop(port, qindex, pkt);
-   rte_sched_port_update_queue_stats_on_drop(port, qindex, pkt);
+   rte_sched_port_update_subport_stats_on_drop(port, qindex, pkt, 
0);
+   rte_sched_port_update_queue_stats_on_drop(port, qindex, pkt, 0);
 #endif
+   rte_pktmbuf_free(pkt);
return 0;
}

--- a/lib/librte_sched/rte_sched.h  2014-12-08 09:28:37.810590895 -0800
+++ b/lib/librte_sched/rte_sched.h  2014-12-08 09:29:11.402692026 -0800
@@ -140,6 +140,9 @@ struct rte_sched_subport_stats {
  subport for each traffic class*/
uint32_t n_bytes_tc_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< 
Number of bytes dropped by the current
   subport for each traffic class due 
to subport queues being full or congested */
+#ifdef RTE_SCHED_RED
+   uint32_t n_pkts_red_dropped[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /**< 
Number of packets dropped by red */
+#endif
 };

 /** Pipe configuration parameters. The period and credits_per_period 
parameters are measured
@@ -168,7 +171,9 @@ struct rte_sched_queue_stats {
/* Packets */
uint32_t n_pkts; /**< Number of packets successfully 
written to current queue */
uint32_t n_pkts_dropped; /**< Number of packets dropped due to 
current queue being full or congested */
-
+#ifdef RTE_SCHED_RED
+   uint32_t n_pkts_red_dropped;
+#endif
/* Bytes */
uint32_t n_bytes;/**< Number of bytes successfully 
written to current queue */
uint32_t n_bytes_dropped;/**< Number of bytes dropped due to 
current queue being full or congested */




[dpdk-dev] (no subject)

2014-12-08 Thread
>From stephen at networkplumber.org Mon Dec  8 09:46:51 2014
Message-Id: <20141208174651.130426937 at networkplumber.org>
User-Agent: quilt/0.63-1
Date: Mon, 08 Dec 2014 09:45:56 -0800
From: Stephen Hemminger 
To: Thomas Monjalon 
Cc: dev at dpdk.org,
 Stephen Hemminger 
Subject: [PATCH 2/6] ixgbe: support X540 VF
References: <20141208174554.889069531 at networkplumber.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Disposition: inline; filename=ixgbe-x540-vf.patch

Add missing setup for X540 MAC type when setting up VF.
Additional check exists in Linux driver but not in DPDK.

Signed-off-yb: Bill Hong  
Signed-off-by: Stephen Hemminger 

--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c 2014-12-08 09:26:18.150170081 -0800
+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c 2014-12-08 09:26:18.150170081 -0800
@@ -1911,7 +1911,8 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_
/*
 * Modification to set VFTDT for virtual function if vf is detected
 */
-   if (hw->mac.type == ixgbe_mac_82599_vf)
+   if (hw->mac.type == ixgbe_mac_82599_vf ||
+   hw->mac.type == ixgbe_mac_X540_vf)
txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, 
IXGBE_VFTDT(queue_idx));
else
txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, 
IXGBE_TDT(txq->reg_idx));
@@ -2198,7 +2199,8 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_
/*
 * Modified to setup VFRDT for Virtual Function
 */
-   if (hw->mac.type == ixgbe_mac_82599_vf) {
+   if (hw->mac.type == ixgbe_mac_82599_vf ||
+   hw->mac.type == ixgbe_mac_X540_vf) {
rxq->rdt_reg_addr =
IXGBE_PCI_REG_ADDR(hw, IXGBE_VFRDT(queue_idx));
rxq->rdh_reg_addr =




[dpdk-dev] [PATCH] doc: add bsd license to svg file

2014-12-08 Thread Bernard Iremonger

Signed-off-by: Bernard Iremonger 
---
 .../sample_app_ug/img/exception_path_example.svg   |   36 
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/doc/guides/sample_app_ug/img/exception_path_example.svg 
b/doc/guides/sample_app_ug/img/exception_path_example.svg
index 5b12974..e72f7ba 100644
--- a/doc/guides/sample_app_ug/img/exception_path_example.svg
+++ b/doc/guides/sample_app_ug/img/exception_path_example.svg
@@ -1,4 +1,40 @@
 
+
+
+
 http://www.w3.org/1999/02/22-rdf-syntax-ns#; 
xmlns="http://www.w3.org/2000/svg; height="330.16" width="568.88" version="1.0" 
xmlns:cc="http://creativecommons.org/ns#; 
xmlns:dc="http://purl.org/dc/elements/1.1/;>
  
   
-- 
1.7.4.1



[dpdk-dev] [PATCH 15/15] eal: allow empty set of compile time cpuflags

2014-12-08 Thread Zhigang Lu
On architectures that do not rely on RTE_COMPILE_TIME_CPUFLAGS, the
compile_time_flags[] array can end up being zero sized.  This results in a
compiler complaint in the subsequent loop.  Pulling out the array size
computation silences this complaint.

Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 lib/librte_eal/common/eal_common_cpuflags.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_cpuflags.c 
b/lib/librte_eal/common/eal_common_cpuflags.c
index 6fd360c..7a1ca26 100644
--- a/lib/librte_eal/common/eal_common_cpuflags.c
+++ b/lib/librte_eal/common/eal_common_cpuflags.c
@@ -62,10 +62,12 @@ rte_cpu_check_supported(void)
static const enum rte_cpu_flag_t compile_time_flags[] = {
RTE_COMPILE_TIME_CPUFLAGS
};
+   unsigned count =
+   sizeof(compile_time_flags)/sizeof(compile_time_flags[0]);
unsigned i;
int ret;

-   for (i = 0; i < 
sizeof(compile_time_flags)/sizeof(compile_time_flags[0]); i++) {
+   for (i = 0; i < count; i++) {
ret = rte_cpu_get_flag_enabled(compile_time_flags[i]);

if (ret < 0) {
-- 
2.1.2



[dpdk-dev] [PATCH 13/15] pmd/tile: add mPIPE poll mode driver for TileGx

2014-12-08 Thread Zhigang Lu
Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 lib/Makefile |1 +
 lib/librte_pmd_mpipe/Makefile|   24 +
 lib/librte_pmd_mpipe/pmd_mpipe.c | 1343 ++
 mk/rte.app.mk|4 +
 4 files changed, 1372 insertions(+)
 create mode 100644 lib/librte_pmd_mpipe/Makefile
 create mode 100644 lib/librte_pmd_mpipe/pmd_mpipe.c

diff --git a/lib/Makefile b/lib/Makefile
index 60aa0ff..c5e44bb 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -49,6 +49,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
 DIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += librte_pmd_enic
+DIRS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += librte_pmd_mpipe
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
diff --git a/lib/librte_pmd_mpipe/Makefile b/lib/librte_pmd_mpipe/Makefile
new file mode 100644
index 000..db75cf3
--- /dev/null
+++ b/lib/librte_pmd_mpipe/Makefile
@@ -0,0 +1,24 @@
+# FIXME: License
+# referred librte_pmd_mpipe/Makefile
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_mpipe.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += pmd_mpipe.c
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += lib/librte_eal lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += lib/librte_mempool lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += lib/librte_net lib/librte_malloc
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_mpipe/pmd_mpipe.c b/lib/librte_pmd_mpipe/pmd_mpipe.c
new file mode 100644
index 000..bac880c
--- /dev/null
+++ b/lib/librte_pmd_mpipe/pmd_mpipe.c
@@ -0,0 +1,1343 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014 Tilera 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 Tilera 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 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#ifdef RTE_LIBRTE_MPIPE_DEBUG_INIT
+#define MPIPE_DEBUG_INIT
+#endif
+#ifdef RTE_LIBRTE_MPIPE_DEBUG_RX
+#define MPIPE_DEBUG_RX
+#endif
+#ifdef RTE_LIBRTE_MPIPE_DEBUG_TX
+#define MPIPE_DEBUG_TX
+#endif
+
+#ifdef MPIPE_DEBUG_INIT
+#define PMD_INIT_LOG(level, fmt, args...) \
+   RTE_LOG(level, PMD, "%s(): " fmt, __func__, ## args)
+#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
+#else
+#define PMD_INIT_LOG(level, fmt, args...) do { } while (0)
+#define PMD_INIT_FUNC_TRACE() do { } while (0)
+#endif
+
+#ifdef MPIPE_DEBUG_RX
+#define PMD_RX_LOG(level, fmt, args...) \
+   RTE_LOG(level, PMD, "%s() rx: " fmt, __func__, ## args)
+#else
+#define PMD_RX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#ifdef MPIPE_DEBUG_TX
+#define PMD_TX_LOG(level, fmt, args...) \
+   RTE_LOG(level, PMD, "%s() tx: " fmt, __func__, ## args)
+#else
+#define PMD_TX_LOG(level, fmt, args...) do { } while (0)
+#endif
+
+#define MPIPE_TX_MAX_QUEUES128
+#define MPIPE_TX_DESCS 512
+#define MPIPE_RX_MAX_QUEUES16
+#define MPIPE_RX_BUCKETS   256
+
+#define MPIPE_LINK_UPDATE_TIMEOUT  10  /*  s */
+#define MPIPE_LINK_UPDATE_INTERVAL 10  

[dpdk-dev] [PATCH 12/15] eal/tile: add mPIPE buffer stack mempool provider

2014-12-08 Thread Zhigang Lu
TileGX: Modified mempool to allow for variable metadata.
Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 app/test-pmd/mempool_anon.c   |   2 +-
 app/test/Makefile |   6 +-
 app/test/test_mempool_tile.c  | 217 
 lib/Makefile  |   5 +
 lib/librte_eal/linuxapp/eal/Makefile  |   4 +
 lib/librte_mempool_tile/Makefile  |  48 +++
 lib/librte_mempool_tile/rte_mempool.c | 381 
 lib/librte_mempool_tile/rte_mempool.h | 634 ++
 8 files changed, 1295 insertions(+), 2 deletions(-)
 create mode 100644 app/test/test_mempool_tile.c
 create mode 100644 lib/librte_mempool_tile/Makefile
 create mode 100644 lib/librte_mempool_tile/rte_mempool.c
 create mode 100644 lib/librte_mempool_tile/rte_mempool.h

diff --git a/app/test-pmd/mempool_anon.c b/app/test-pmd/mempool_anon.c
index 559a625..05b4c77 100644
--- a/app/test-pmd/mempool_anon.c
+++ b/app/test-pmd/mempool_anon.c
@@ -36,7 +36,7 @@
 #include "mempool_osdep.h"
 #include 

-#ifdef RTE_EXEC_ENV_LINUXAPP
+#if defined(RTE_EXEC_ENV_LINUXAPP) && !defined(RTE_ARCH_TILE)

 #include 
 #include 
diff --git a/app/test/Makefile b/app/test/Makefile
index 4311f96..40ad971 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -72,10 +72,14 @@ SRCS-y += test_rwlock.c
 SRCS-$(CONFIG_RTE_LIBRTE_TIMER) += test_timer.c
 SRCS-$(CONFIG_RTE_LIBRTE_TIMER) += test_timer_perf.c

+ifeq ($(CONFIG_RTE_ARCH),"tile")
+SRCS-y += test_mempool_tile.c
+else
 SRCS-y += test_mempool.c
 SRCS-y += test_mempool_perf.c
-
 SRCS-y += test_mbuf.c
+endif
+
 SRCS-y += test_logs.c

 SRCS-y += test_memcpy.c
diff --git a/app/test/test_mempool_tile.c b/app/test/test_mempool_tile.c
new file mode 100644
index 000..41a375d
--- /dev/null
+++ b/app/test/test_mempool_tile.c
@@ -0,0 +1,217 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 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 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test.h"
+
+/*
+ * Mempool
+ * ===
+ *
+ * Basic tests: done on one core with and without cache:
+ *
+ *- Get one object, put one object
+ *- Get two objects, put two objects
+ *- Get all objects, test that their content is not modified and
+ *  put them back in the pool.
+ */
+
+#define MEMPOOL_ELT_SIZE 2048
+#define MEMPOOL_SIZE (8 * 1024)
+
+static struct rte_mempool *mp;
+
+
+/*
+ * save the object number in the first 4 bytes of object data. All
+ * other bytes are set to 0.
+ */
+static void
+my_obj_init(struct rte_mempool *mp, __attribute__((unused)) void *arg,
+   void *obj, unsigned i)
+{
+   uint32_t *objnum = obj;
+
+   memset(obj, 0, mp->elt_size);
+   *objnum = i;
+}
+
+/* basic tests (done on one core) */
+static int
+test_mempool_basic(void)
+{
+   uint32_t *objnum;
+   void **objtable;
+   void *obj, *obj2;
+   char *obj_data;
+   int ret = 0;
+   unsigned i, j;
+
+   /* dump the mempool status */
+   rte_mempool_dump(stdout, mp);
+
+   printf("get an object\n");
+   if (rte_mempool_get(mp, ) < 0)
+   return 

[dpdk-dev] [PATCH 11/15] eal/tile: add EAL support for global mPIPE initialization

2014-12-08 Thread Zhigang Lu
The TileGx mPIPE hardware provides Ethernet connectivity,
packet classification, and packet load balancing services.

Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 .../common/include/arch/tile/rte_mpipe.h   |  67 ++
 lib/librte_eal/linuxapp/eal/Makefile   |   3 +
 lib/librte_eal/linuxapp/eal/eal.c  |   9 ++
 lib/librte_eal/linuxapp/eal/eal_mpipe_tile.c   | 147 +
 mk/rte.app.mk  |   4 +
 5 files changed, 230 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_mpipe.h
 create mode 100644 lib/librte_eal/linuxapp/eal/eal_mpipe_tile.c

diff --git a/lib/librte_eal/common/include/arch/tile/rte_mpipe.h 
b/lib/librte_eal/common/include/arch/tile/rte_mpipe.h
new file mode 100644
index 000..11b6485
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/tile/rte_mpipe.h
@@ -0,0 +1,67 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014 Tilera 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 Tilera 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_TILE_MPIPE_H_
+#define _RTE_TILE_MPIPE_H_
+
+#define ARCH_ATOMIC_NO_NICKNAMES
+
+#include 
+#include 
+#include 
+
+#define BSM_ALIGN_SIZE 128
+
+struct rte_eal_mpipe_channel_config {
+   int enable;
+   int first_bucket;
+   int num_buckets;
+   int headroom;
+   gxio_mpipe_rules_stacks_t stacks;
+};
+
+#define __bsm_aligned __attribute__((__aligned__(BSM_ALIGN_SIZE)))
+
+extern int rte_eal_mpipe_instances;
+
+extern int
+rte_eal_mpipe_init(void);
+
+extern gxio_mpipe_context_t *
+rte_eal_mpipe_context(int instance);
+
+extern int
+rte_eal_mpipe_channel_config(int instance, int channel,
+struct rte_eal_mpipe_channel_config *config);
+
+#endif /* _RTE_TILE_MPIPE_H_ */
diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index 72ecf3a..99536b6 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -70,6 +70,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_alarm.c
 ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_ivshmem.c
 endif
+ifeq ($(CONFIG_RTE_ARCH),"tile")
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_mpipe_tile.c
+endif

 # from common dir
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_memzone.c
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index 89f3b5e..c97a090 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -78,6 +78,10 @@
 #include 
 #include 

+#ifdef RTE_ARCH_TILE
+#include 
+#endif
+
 #include "eal_private.h"
 #include "eal_thread.h"
 #include "eal_internal_cfg.h"
@@ -755,6 +759,11 @@ rte_eal_init(int argc, char **argv)
if (rte_eal_pci_init() < 0)
rte_panic("Cannot init PCI\n");

+#ifdef RTE_ARCH_TILE
+   if (rte_eal_mpipe_init() < 0)
+   rte_panic("Cannot init mPIPE\n");
+#endif
+
 #ifdef RTE_LIBRTE_IVSHMEM
if (rte_eal_ivshmem_init() < 0)
rte_panic("Cannot init IVSHMEM\n");
diff --git a/lib/librte_eal/linuxapp/eal/eal_mpipe_tile.c 
b/lib/librte_eal/linuxapp/eal/eal_mpipe_tile.c
new file mode 100644
index 000..7b0f94b
--- /dev/null
+++ b/lib/librte_eal/linuxapp/eal/eal_mpipe_tile.c
@@ -0,0 +1,147 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014 

[dpdk-dev] [PATCH 10/15] eal/tile: add vector operations for TileGx

2014-12-08 Thread Zhigang Lu
Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 .../common/include/arch/tile/rte_common_vect.h | 49 ++
 1 file changed, 49 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_common_vect.h

diff --git a/lib/librte_eal/common/include/arch/tile/rte_common_vect.h 
b/lib/librte_eal/common/include/arch/tile/rte_common_vect.h
new file mode 100644
index 000..f759a20
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/tile/rte_common_vect.h
@@ -0,0 +1,49 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014 Tilera 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 Tilera 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_COMMON_VECT_TILE_H_
+#define _RTE_COMMON_VECT_TILE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_common_vect.h"
+
+typedef long __m128i __attribute__ ((__vector_size__ (16)));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_COMMON__VECT_X86_H_ */
-- 
2.1.2



[dpdk-dev] [PATCH 09/15] eal: split vector operations to architecture specific

2014-12-08 Thread Zhigang Lu
This patch splits vector operations from DPDK and push them
to architecture specific arch directories, so that other processor
architecture can implement its own vector functions to support DPDK.

Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 lib/librte_eal/common/Makefile |  3 +-
 .../common/include/arch/ppc_64/rte_common_vect.h   | 73 +
 .../common/include/arch/x86/rte_common_vect.h  | 81 +++
 .../common/include/generic/rte_common_vect.h   | 51 
 lib/librte_eal/common/include/rte_common_vect.h| 93 --
 5 files changed, 206 insertions(+), 95 deletions(-)
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_common_vect.h
 create mode 100644 lib/librte_eal/common/include/arch/x86/rte_common_vect.h
 create mode 100644 lib/librte_eal/common/include/generic/rte_common_vect.h
 delete mode 100644 lib/librte_eal/common/include/rte_common_vect.h

diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile
index 52c1a5f..02cac22 100644
--- a/lib/librte_eal/common/Makefile
+++ b/lib/librte_eal/common/Makefile
@@ -39,7 +39,6 @@ INC += rte_rwlock.h rte_tailq.h rte_interrupts.h rte_alarm.h
 INC += rte_string_fns.h rte_version.h rte_tailq_elem.h
 INC += rte_eal_memconfig.h rte_malloc_heap.h
 INC += rte_hexdump.h rte_devargs.h rte_dev.h
-INC += rte_common_vect.h
 INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h

 ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y)
@@ -47,7 +46,7 @@ INC += rte_warnings.h
 endif

 GENERIC_INC := rte_atomic.h rte_byteorder.h rte_cycles.h rte_prefetch.h
-GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h
+GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h rte_common_vect.h
 # defined in mk/arch/$(RTE_ARCH)/rte.vars.mk
 ARCH_DIR ?= $(RTE_ARCH)
 ARCH_INC := $(notdir $(wildcard 
$(RTE_SDK)/lib/librte_eal/common/include/arch/$(ARCH_DIR)/*.h))
diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_common_vect.h 
b/lib/librte_eal/common/include/arch/ppc_64/rte_common_vect.h
new file mode 100644
index 000..485b7eb
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_common_vect.h
@@ -0,0 +1,73 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 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 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_COMMON_VECT_PPC_64_H_
+#define _RTE_COMMON_VECT_PPC_64_H_
+
+/**
+ * @file
+ *
+ * RTE SSE/AVX related header.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_common_vect.h"
+
+#if (defined(__ICC) || (__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
+
+#ifdef __SSE__
+#include 
+#endif
+
+#ifdef __SSE2__
+#include 
+#endif
+
+#if defined(__SSE4_2__) || defined(__SSE4_1__)
+#include 
+#endif
+
+#else
+
+#include 
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_COMMON__VECT_PPC_64_H_ */
diff --git a/lib/librte_eal/common/include/arch/x86/rte_common_vect.h 
b/lib/librte_eal/common/include/arch/x86/rte_common_vect.h
new file mode 100644
index 000..5ffe3fb
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/x86/rte_common_vect.h
@@ -0,0 +1,81 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided 

[dpdk-dev] [PATCH 08/15] eal/tile: add cycle operations for TileGx

2014-12-08 Thread Zhigang Lu
This patch adds CPU TSC read operations for TileGx.

Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 .../common/include/arch/tile/rte_cycles.h  | 64 ++
 1 file changed, 64 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_cycles.h

diff --git a/lib/librte_eal/common/include/arch/tile/rte_cycles.h 
b/lib/librte_eal/common/include/arch/tile/rte_cycles.h
new file mode 100644
index 000..74e11cf
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/tile/rte_cycles.h
@@ -0,0 +1,64 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014 Tilera 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 Tilera 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_CYCLES_TILE_H_
+#define _RTE_CYCLES_TILE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_cycles.h"
+
+#include 
+
+static inline uint64_t
+rte_rdtsc(void)
+{
+   return get_cycle_count();
+}
+
+static inline uint64_t
+rte_rdtsc_precise(void)
+{
+   return rte_rdtsc();
+}
+
+static inline uint64_t
+rte_get_tsc_cycles(void) { return rte_rdtsc(); }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_CYCLES_TILE_H_ */
-- 
2.1.2



[dpdk-dev] [PATCH 05/15] eal/tile: add prefetch operations for TileGx

2014-12-08 Thread Zhigang Lu
Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 .../common/include/arch/tile/rte_prefetch.h| 62 ++
 1 file changed, 62 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_prefetch.h

diff --git a/lib/librte_eal/common/include/arch/tile/rte_prefetch.h 
b/lib/librte_eal/common/include/arch/tile/rte_prefetch.h
new file mode 100644
index 000..01a5d21
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/tile/rte_prefetch.h
@@ -0,0 +1,62 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014 Tilera 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 Tilera 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_PREFETCH_TILE_H_
+#define _RTE_PREFETCH_TILE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_prefetch.h"
+
+static inline void rte_prefetch0(volatile void *p)
+{
+   __builtin_prefetch((const void *)(uintptr_t)p, 0, 3);
+}
+
+static inline void rte_prefetch1(volatile void *p)
+{
+   __builtin_prefetch((const void *)(uintptr_t)p, 0, 2);
+}
+
+static inline void rte_prefetch2(volatile void *p)
+{
+   __builtin_prefetch((const void *)(uintptr_t)p, 0, 1);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_PREFETCH_TILE_H_ */
-- 
2.1.2



[dpdk-dev] [PATCH 04/15] eal/tile: add spinlock operations for TileGx

2014-12-08 Thread Zhigang Lu
TileGx uses generic spinlock operations.

Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 .../common/include/arch/tile/rte_spinlock.h| 47 ++
 1 file changed, 47 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_spinlock.h

diff --git a/lib/librte_eal/common/include/arch/tile/rte_spinlock.h 
b/lib/librte_eal/common/include/arch/tile/rte_spinlock.h
new file mode 100644
index 000..1dc224e
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/tile/rte_spinlock.h
@@ -0,0 +1,47 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014 Tilera 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 Tilera 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_SPINLOCK_TILE_H_
+#define _RTE_SPINLOCK_TILE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_spinlock.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_SPINLOCK_TILE_H_ */
-- 
2.1.2



[dpdk-dev] [PATCH 03/15] eal/tile: add byte order operations for TileGx

2014-12-08 Thread Zhigang Lu
This patch adds architecture specific byte swap and endianness
operations for TileGx.

Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 .../common/include/arch/tile/rte_byteorder.h   | 70 ++
 1 file changed, 70 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_byteorder.h

diff --git a/lib/librte_eal/common/include/arch/tile/rte_byteorder.h 
b/lib/librte_eal/common/include/arch/tile/rte_byteorder.h
new file mode 100644
index 000..38f3a23
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/tile/rte_byteorder.h
@@ -0,0 +1,70 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014 Tilera 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 Tilera 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_BYTEORDER_TILE_H_
+#define _RTE_BYTEORDER_TILE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_byteorder.h"
+
+/*
+ * __builtin_bswap16 is only available gcc 4.8 and upwards
+ */
+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
+#define rte_bswap16(x) ((uint16_t)rte_constant_bswap16(x))
+#endif
+
+#define rte_cpu_to_le_16(x) (x)
+#define rte_cpu_to_le_32(x) (x)
+#define rte_cpu_to_le_64(x) (x)
+
+#define rte_cpu_to_be_16(x) rte_bswap16(x)
+#define rte_cpu_to_be_32(x) rte_bswap32(x)
+#define rte_cpu_to_be_64(x) rte_bswap64(x)
+
+#define rte_le_to_cpu_16(x) (x)
+#define rte_le_to_cpu_32(x) (x)
+#define rte_le_to_cpu_64(x) (x)
+
+#define rte_be_to_cpu_16(x) rte_bswap16(x)
+#define rte_be_to_cpu_32(x) rte_bswap32(x)
+#define rte_be_to_cpu_64(x) rte_bswap64(x)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_BYTEORDER_TILE_H_ */
-- 
2.1.2



[dpdk-dev] [PATCH 02/15] eal/tile: add atomic operations for TileGx

2014-12-08 Thread Zhigang Lu
This patch adds architecture specific memory barrier operations for
TileGx.

Signed-off-by: Zhigang Lu 
Signed-off-by: Cyril Chemparathy 
---
 .../common/include/arch/tile/rte_atomic.h  | 62 ++
 1 file changed, 62 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_atomic.h

diff --git a/lib/librte_eal/common/include/arch/tile/rte_atomic.h 
b/lib/librte_eal/common/include/arch/tile/rte_atomic.h
new file mode 100644
index 000..24c9b0a
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/tile/rte_atomic.h
@@ -0,0 +1,62 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2014 Tilera 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 Tilera 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_ATOMIC_TILE_H_
+#define _RTE_ATOMIC_TILE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_atomic.h"
+
+static inline void rte_mb(void)
+{
+   __sync_synchronize();
+}
+
+static inline void rte_wmb(void)
+{
+   __sync_synchronize();
+}
+
+static inline void rte_rmb(void)
+{
+   __sync_synchronize();
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_ATOMIC_TILE_H_ */
-- 
2.1.2



[dpdk-dev] [PATCH 00/15] Patches for DPDK to support tile architecture

2014-12-08 Thread Zhigang Lu
This patch set adds default configuration, compiling related rte.vars.mk
files for tile, and architecture-specific operations for EAL. TileGx
processor, as a SOC, contains a on-chip networking engine named mPIPE(
multicore Programmable Intelligent Packet Engine). This patch set also
adds poll mode driver for the mPIPE device. And to improve the performance
of memory allocation, mPIPE's buffer stack is used as the mempool provider.

Zhigang Lu (15):
  mk: introduce Tilera Tile architecture
  eal/tile: add atomic operations for TileGx
  eal/tile: add byte order operations for TileGx
  eal/tile: add spinlock operations for TileGx
  eal/tile: add prefetch operations for TileGx
  eal/tile: add memcpy operations for TileGx
  eal/tile: add CPU flags operations for TileGx
  eal/tile: add cycle operations for TileGx
  eal: split vector operations to architecture specific
  eal/tile: add vector operations for TileGx
  eal/tile: add EAL support for global mPIPE initialization
  eal/tile: add mPIPE buffer stack mempool provider
  pmd/tile: add mPIPE poll mode driver for TileGx
  app/test: turn off cpu flag checks for tile architecture
  eal: allow empty set of compile time cpuflags

 app/test-pmd/mempool_anon.c|2 +-
 app/test/Makefile  |6 +-
 app/test/test_cpuflags.c   |2 +-
 app/test/test_mempool_tile.c   |  217 
 config/defconfig_tile-tilegx-linuxapp-gcc  |   78 ++
 lib/Makefile   |6 +
 lib/librte_eal/common/Makefile |3 +-
 lib/librte_eal/common/eal_common_cpuflags.c|4 +-
 .../common/include/arch/ppc_64/rte_common_vect.h   |   73 ++
 .../common/include/arch/tile/rte_atomic.h  |   62 +
 .../common/include/arch/tile/rte_byteorder.h   |   70 +
 .../common/include/arch/tile/rte_common_vect.h |   49 +
 .../common/include/arch/tile/rte_cpuflags.h|   69 +
 .../common/include/arch/tile/rte_cycles.h  |   64 +
 .../common/include/arch/tile/rte_memcpy.h  |   97 ++
 .../common/include/arch/tile/rte_mpipe.h   |   67 +
 .../common/include/arch/tile/rte_prefetch.h|   62 +
 .../common/include/arch/tile/rte_spinlock.h|   47 +
 .../common/include/arch/x86/rte_common_vect.h  |   81 ++
 .../common/include/generic/rte_common_vect.h   |   51 +
 lib/librte_eal/common/include/rte_common_vect.h|   93 --
 lib/librte_eal/linuxapp/eal/Makefile   |7 +
 lib/librte_eal/linuxapp/eal/eal.c  |9 +
 lib/librte_eal/linuxapp/eal/eal_mpipe_tile.c   |  147 +++
 lib/librte_mempool_tile/Makefile   |   48 +
 lib/librte_mempool_tile/rte_mempool.c  |  381 ++
 lib/librte_mempool_tile/rte_mempool.h  |  634 +
 lib/librte_pmd_mpipe/Makefile  |   24 +
 lib/librte_pmd_mpipe/pmd_mpipe.c   | 1343 
 mk/arch/tile/rte.vars.mk   |   59 +
 mk/machine/tilegx/rte.vars.mk  |   58 +
 mk/rte.app.mk  |8 +
 32 files changed, 3822 insertions(+), 99 deletions(-)
 create mode 100644 app/test/test_mempool_tile.c
 create mode 100644 config/defconfig_tile-tilegx-linuxapp-gcc
 create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_common_vect.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_atomic.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_byteorder.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_common_vect.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_cpuflags.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_cycles.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_memcpy.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_mpipe.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_prefetch.h
 create mode 100644 lib/librte_eal/common/include/arch/tile/rte_spinlock.h
 create mode 100644 lib/librte_eal/common/include/arch/x86/rte_common_vect.h
 create mode 100644 lib/librte_eal/common/include/generic/rte_common_vect.h
 delete mode 100644 lib/librte_eal/common/include/rte_common_vect.h
 create mode 100644 lib/librte_eal/linuxapp/eal/eal_mpipe_tile.c
 create mode 100644 lib/librte_mempool_tile/Makefile
 create mode 100644 lib/librte_mempool_tile/rte_mempool.c
 create mode 100644 lib/librte_mempool_tile/rte_mempool.h
 create mode 100644 lib/librte_pmd_mpipe/Makefile
 create mode 100644 lib/librte_pmd_mpipe/pmd_mpipe.c
 create mode 100644 mk/arch/tile/rte.vars.mk
 create mode 100644 mk/machine/tilegx/rte.vars.mk

-- 
2.1.2



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

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

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

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

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

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

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

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

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

 #include 
+#include 
+#include 
+#include 

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

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

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

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

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

2014-12-08 Thread Qiu, Michael
On 2014/12/8 20:19, Burakov, Anatoly wrote:
>> When vfio module is not loaded when kernel support vfio feature, the
>> routine still try to open the container to get file description.
>>
>> This action is not safe, and of cause got error messages:
>>
>> EAL: Detected 40 lcore(s)
>> EAL:   unsupported IOMMU type!
>> EAL: VFIO support could not be initialized
>> EAL: Setting up memory...
>>
>> This may make user confuse, this patch make it reasonable and much more
>> soomth to user.
>>
>> Signed-off-by: Michael Qiu 
>> ---
>> v4 --> v3:
>>  1. Remove RTE_LOG for params check
>>  2. Remove "vfio" module check as "vfio_iommu_type1"
>> loaded indecated "vfio" loaded
>>
>> v3 --> v2:
>> 1. Add error log in rte_eal_check_module()
>> 2. Some code clean up.
>>
>> v2 --> v1:
>> 1. Move check_module() from rte_common.h to eal_private.h
>>and rename to rte_eal_check_module().
>>To make it linuxapp only.
>> 2. Some code clean up.
>>
>>  lib/librte_eal/common/eal_private.h| 42
>> ++
>>  lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 29 ++---
>>  2 files changed, 68 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/librte_eal/common/eal_private.h
>> b/lib/librte_eal/common/eal_private.h
>> index 232fcec..e877a25 100644
>> --- a/lib/librte_eal/common/eal_private.h
>> +++ b/lib/librte_eal/common/eal_private.h
>> @@ -35,6 +35,9 @@
>>  #define _EAL_PRIVATE_H_
>>
>>  #include 
>> +#include 
>> +#include 
>> +#include 
>>
>>  /**
>>   * Initialize the memzone subsystem (private to eal).
>> @@ -203,4 +206,43 @@ int rte_eal_alarm_init(void);
>>   */
>>  int rte_eal_dev_init(void);
>>
>> +/**
>> + * Function is to check if the kernel module(like, vfio,
>> +vfio_iommu_type1,
>> + * etc.) loaded.
>> + *
>> + * @param module_name
>> + *  The module's name which need to be checked
>> + *
>> + * @return
>> + *  -1 means some error happens(NULL pointer or open failure)
>> + *  0  means the module not loaded
>> + *  1  means the module loaded
>> + */
>> +static inline int
>> +rte_eal_check_module(const char *module_name) {
>> +char mod_name[30]; /* Any module names can be longer than 30
>> bytes? */
>> +int ret = 0;
>> +
>> +if (NULL == module_name)
>> +return -1;
>> +
>> +FILE * fd = fopen("/proc/modules", "r");
>> +if (NULL == fd) {
>> +RTE_LOG(ERR, EAL, "Open /proc/modules failed!"
>> +" error %i (%s)\n", errno, strerror(errno));
>> +return -1;
>> +}
>> +while(!feof(fd)) {
>> +fscanf(fd, "%s %*[^\n]", mod_name);
>> +if(!strcmp(mod_name, module_name)) {
>> +ret = 1;
>> +break;
>> +}
>> +}
>> +fclose(fd);
>> +
>> +return ret;
>> +}
>> +
> Apologies for not bringing this up before, but do we really want the 
> rte_eal_check_module inline in the header? I think it would be better to 
> declare it in eal_private but move the definition into eal.c.

No need, actually, I'm very appreciate that you can spend your time to
review my patch again and again. I really want to say thank you to you.

For rte_eal_check_module inline in the header, it really no need stay in
header, so ugly. I will make new version of it, and re-post.


>>  #endif /* _EAL_PRIVATE_H_ */
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> index c1246e8..8c54d2a 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> @@ -44,6 +44,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include "eal_filesystem.h"
>>  #include "eal_pci_init.h"
>> @@ -339,10 +340,15 @@ pci_vfio_get_container_fd(void)
>>  ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION,
>> VFIO_TYPE1_IOMMU);
>>  if (ret != 1) {
>>  if (ret < 0)
>> -RTE_LOG(ERR, EAL, "  could not get IOMMU
>> type, "
>> -"error %i (%s)\n", errno,
>> strerror(errno));
>> +RTE_LOG(ERR, EAL, "  could not get IOMMU
>> type,"
>> +" error %i (%s)\n", errno,
>> +strerror(errno));
>>  else
>> -RTE_LOG(ERR, EAL, "  unsupported IOMMU
>> type!\n");
>> +/* Better to show the IOMMU type return
>> from
>> + * kernel for easy debug
>> + */
>> +RTE_LOG(ERR, EAL, "  unsupported IOMMU
>> type"
>> +" detected: %d in VFIO\n", ret);
> I'm not sure this message is meaningful. That ioctl call can either -1, 0 or 
> 1. We already handle 1 separately; -1 means an error; 0 means IOMMU type 1 is 
> not supported. The return 

[dpdk-dev] error: value computed is not used

2014-12-08 Thread Wodkowski, PawelX


> -Original Message-
> From: Qiu, Michael
> Sent: Monday, December 08, 2014 4:24 PM
> To: Wodkowski, PawelX; dev at dpdk.org
> Subject: Re: error: value computed is not used
> 
> On 2014/12/8 19:00, Wodkowski, PawelX wrote:
> >> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> >> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
> >>
> >> I dig out that, it was ome issue of  the macros rte_memcpy()
> >> #define rte_memcpy(dst, src, n)  \
> >> ((__builtin_constant_p(n)) ?  \
> >> memcpy((dst), (src), (n)) :  \
> >> rte_memcpy_func((dst), (src), (n)))
> >>
> >> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> >> know that it was incorrect, just a experiment).
> >>
> >> But I try to use inline function instead of macros:
> >> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> >> {
> >> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> >>  rte_memcpy_func(dst, src, n);
> >> }
> >>
> >> It will pass:), and works, this could be one potential workaround fix.
> >>
> >> Who knows why? The root cause is what?
> >>
> >> I've no idea about this.
> >>
> > I got the same issue while ago. I don't remember exactly everything
> > but my conclusion was that there was some bug in compiler. I think,
> > when 'n' I constant and/or small compiler is inlining memcpy and throwing
> > everything else (including returned value). In that case error is not
> > produced (I think this is a bug in compiler). In other case it is computing
> > some value calling memcpy or rte_ memcpy and you should at least
> > explicitly throw it away by casting to void. I like solution with static
> 
> Actually, I try to pass "n" as a Int value like 4, it still report this
> error :)

My workaround was:
(void) rte_memcpy(...);

But this is only a workaround.

> 
> > inline but someone else should spoke about possible side effects.
> 
> Yes, but as I know inline is better than macros.
> 
> Thanks,
> Michael
> >
> > Pawel
> >
> >



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

2014-12-08 Thread Qiu, Michael
On 2014/12/8 19:38, Neil Horman wrote:
> On Mon, Dec 08, 2014 at 03:37:19AM +, Qiu, Michael wrote:
>> On 12/8/2014 11:00 AM, Neil Horman wrote:
>>> On Mon, Dec 08, 2014 at 02:46:51AM +, Qiu, Michael wrote:
 On 12/5/2014 11:25 PM, Neil Horman wrote:
> On Fri, Dec 05, 2014 at 03:02:33PM +, Bruce Richardson wrote:
>> On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
>>> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
 On 2014/12/4 17:12, Michael Qiu wrote:
> lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
> is always false due to limited range of data type 
> [-Werror=type-limits]
> || (hugepage_sz == RTE_PGSIZE_16G)) {
> ^
> cc1: all warnings being treated as errors
>
> lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
> conversion from "long long" to "void *" may lose significant bits
>RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);
>
> This was introuduced by commit b77b5639:
> mem: add huge page sizes for IBM Power
>
> The root cause is that size_t and uintptr_t are 32-bit in i686
> platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.
>
> Define RTE_PGSIZE_16G only in 64 bit platform to avoid
> this issue.
>
> Signed-off-by: Michael Qiu 
> ---
>  v3 ---> v2
>   Change RTE_PGSIZE_16G from ULL to UL
>   to keep all entries consistent
>
>  V2 ---> v1
>   Change two type entries to one, and
>   leave RTE_PGSIZE_16G only valid for
>   64-bit platform
>
>>> NACK, this is the wrong way to fix this problem.  Pagesizes are 
>>> independent of
>>> architecutre.  While a system can't have a hugepage size that exceeds 
>>> its
>>> virtual address limit, theres no need to do per-architecture special 
>>> casing of
>>> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
>>> everytime you want to check a page size, just convert the size_t to a 
>>> uint64_t
>>> and you can allow all of the enumerated page types on all 
>>> architecutres, and
>>> save yourself some ifdeffing in the process.
>>>
>>> Neil
>> While I get your point, I find it distasteful to use a uint64_t for 
>> memory sizes,
>> when there is the size_t type defined for that particular purpose.
>> However, I suppose that reducing the number of #ifdefs compared to using 
>> the
>> "correct" datatypes for objects is a more practical optino - however 
>> distastful
>> I find it.
> size_t isn't defined for memory sizes in the sense that we're using them 
> here.
> size_t is meant to address the need for a type to describe object sizes 
> on a
> particular system, and it itself is sized accordingly (32 bits on a 32 
> bit arch,
> 64 on 64), so that you can safely store a size that the system in 
> question might
> maximally allocate/return.  In this situation we are describing memory 
> sizes
> that might occur no a plurality of arches, and so size_t is inappropriate
> because it as a type is not sized for anything other than the arch it is 
> being
> built for.  The pragmatic benefits of ennumerating page sizes in a single
> canonical location far outweigh the desire to use a misappropriated type 
> to
> describe them.
 Neil,

 This patch fix two compile issues, and we need to do *dpdk testing
 affairs*,  if it is blocked in build stage, we can do *nothing* for 
 testing.

 I've get you mind and your concern. But we should take care of changing
 the type of "hugepage_sz", because lots of places using it.

 Would you mind if we consider this as hot fix, and we can post a better
 fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.

>>> Honestly, no.  Because intels testing schedule shouldn't drive the 
>>> inclusion of
>>> upstream fixes.  Also, I'm not asking for a major redesign of anything, I'm
>>> asking for a proper fix for a very straightforward problem.  I've attached 
>>> the
>>> proper fix below.
>>>
>>> Regards
>>> Neil
>> We test dpdk upstream now as 1,8 rc2 and rc3 released :)
>>
> Yes, I don't take issue with you testing dpdk, on the contrary, I appreciate 
> it.
> What I take issue with is that you are asserting that the blockage of your
> testing is reason to ignore a proper fix an issue, rather than some 
> substandard
> one.

Agree :)

>> I know that what you mean. but lots of please using "hugepage_sz" do you
>> confirm it will not affect other issue?
>>
> 5.  There are 5 placees that use hugepage_sz, as the patch below indicates.
> Thats no alot.
>
> Also, I take issue with the assertion that this patch creates no 

[dpdk-dev] [RFC PATCH 17/17] virtio: Use port IO to get PCI resource.

2014-12-08 Thread Ouyang Changchun
Make virtio not require UIO for some security reasons, this is to match 6Wind's 
virtio-net-pmd.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_eal/common/include/rte_pci.h |  2 +
 lib/librte_eal/linuxapp/eal/eal_pci.c   |  3 +-
 lib/librte_pmd_virtio/virtio_ethdev.c   | 75 -
 3 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h 
b/lib/librte_eal/common/include/rte_pci.h
index 66ed793..2021b3b 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -193,6 +193,8 @@ struct rte_pci_driver {

 /** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
 #define RTE_PCI_DRV_NEED_MAPPING 0x0001
+/** Device needs port IO(done with /proc/ioports) */
+#define RTE_PCI_DRV_IO_PORT 0x0002
 /** Device driver must be registered several times until failure - deprecated 
*/
 #pragma GCC poison RTE_PCI_DRV_MULTIPLE
 /** Device needs to be unbound even if no module is provided */
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index b5f5410..dd60793 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -573,7 +573,8 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, 
struct rte_pci_device *d
 #endif
/* map resources for devices that use igb_uio */
ret = pci_map_device(dev);
-   if (ret != 0)
+   if ((ret != 0) &&
+   ((dr->drv_flags & RTE_PCI_DRV_IO_PORT) == 0))
return ret;
} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
   rte_eal_process_type() == RTE_PROC_PRIMARY) {
diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index 1ec29e1..4490a06 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -961,6 +961,69 @@ static int virtio_resource_init(struct rte_pci_device 
*pci_dev)
 start, size);
return 0;
 }
+
+/* Extract I/O port numbers from proc/ioports */
+static int virtio_resource_init_by_ioport(struct rte_pci_device *pci_dev)
+{
+   uint16_t start, end;
+   int size;
+   FILE* fp;
+   char* line = NULL;
+   char pci_id[16];
+   int found = 0;
+   size_t linesz;
+
+   snprintf(pci_id, sizeof(pci_id), PCI_PRI_FMT,
+pci_dev->addr.domain,
+pci_dev->addr.bus,
+pci_dev->addr.devid,
+pci_dev->addr.function);
+
+   fp = fopen("/proc/ioports", "r");
+   if (fp == NULL) {
+   PMD_INIT_LOG(ERR, "%s(): can't open ioports", __func__);
+   return -1;
+   }
+
+   while (getdelim(, , '\n', fp) > 0) {
+   char* ptr = line;
+   char* left;
+   int n;
+
+   n = strcspn(ptr, ":");
+   ptr[n]= 0;
+   left = [n+1];
+
+   while (*left && isspace(*left))
+   left++;
+
+   if (!strncmp(left, pci_id, strlen(pci_id))) {
+   found = 1;
+
+   while (*ptr && isspace(*ptr))
+   ptr++;
+
+   sscanf(ptr, "%04hx-%04hx", , );
+   size = end - start + 1;
+
+   break;
+   }
+   }
+
+   free(line);
+   fclose(fp);
+
+   if (!found)
+   return -1;
+
+   pci_dev->mem_resource[0].addr = (void *)(uintptr_t)(uint32_t)start;
+   pci_dev->mem_resource[0].len =  (uint64_t)size;
+   PMD_INIT_LOG(DEBUG,
+"PCI Port IO found start=0x%lx with size=0x%lx",
+start, size);
+   return 0;
+}
+
 #else
 static int
 virtio_has_msix(const struct rte_pci_addr *loc __rte_unused)
@@ -974,6 +1037,12 @@ static int virtio_resource_init(struct rte_pci_device 
*pci_dev __rte_unused)
/* no setup required */
return 0;
 }
+
+static int virtio_resource_init_by_ioport(struct rte_pci_device *pci_dev)
+{
+   /* no setup required */
+   return 0;
+}
 #endif

 /*
@@ -1039,7 +1108,8 @@ eth_virtio_dev_init(__rte_unused struct eth_driver 
*eth_drv,

pci_dev = eth_dev->pci_dev;
if (virtio_resource_init(pci_dev) < 0)
-   return -1;
+   if (virtio_resource_init_by_ioport(pci_dev) < 0)
+   return -1;

hw->use_msix = virtio_has_msix(_dev->addr);
hw->io_base = (uint32_t)(uintptr_t)pci_dev->mem_resource[0].addr;
@@ -1136,7 +1206,8 @@ static struct eth_driver rte_virtio_pmd = {
{
.name = "rte_virtio_pmd",
.id_table = pci_id_virtio_map,
-   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING 

[dpdk-dev] [RFC PATCH 16/17] virtio: Free mbuf's with threshold

2014-12-08 Thread Ouyang Changchun
This makes virtio driver work like ixgbe. Transmit buffers are
held until a transmit threshold is reached. The previous behavior
was to hold mbuf's until the ring entry was reused which caused
more memory usage than needed.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_virtio/virtio_ethdev.c |  7 ++--
 lib/librte_pmd_virtio/virtio_rxtx.c   | 70 +--
 lib/librte_pmd_virtio/virtqueue.h |  3 +-
 3 files changed, 64 insertions(+), 16 deletions(-)

diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index c5f21c1..1ec29e1 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -176,15 +176,16 @@ virtio_send_command(struct virtqueue *vq, struct 
virtio_pmd_ctrl *ctrl,

virtqueue_notify(vq);

-   while (vq->vq_used_cons_idx == vq->vq_ring.used->idx)
+   rte_rmb();
+   while (vq->vq_used_cons_idx == vq->vq_ring.used->idx) {
+   rte_rmb();
usleep(100);
+   }

while (vq->vq_used_cons_idx != vq->vq_ring.used->idx) {
uint32_t idx, desc_idx, used_idx;
struct vring_used_elem *uep;

-   virtio_rmb();
-
used_idx = (uint32_t)(vq->vq_used_cons_idx
& (vq->vq_nentries - 1));
uep = >vq_ring.used->ring[used_idx];
diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c 
b/lib/librte_pmd_virtio/virtio_rxtx.c
index b44f091..26c0a1d 100644
--- a/lib/librte_pmd_virtio/virtio_rxtx.c
+++ b/lib/librte_pmd_virtio/virtio_rxtx.c
@@ -129,9 +129,15 @@ virtqueue_dequeue_burst_rx(struct virtqueue *vq, struct 
rte_mbuf **rx_pkts,
return i;
 }

+#ifndef DEFAULT_TX_FREE_THRESH
+#define DEFAULT_TX_FREE_THRESH 32
+#endif
+
+/* Cleanup from completed transmits. */
 static void
-virtqueue_dequeue_pkt_tx(struct virtqueue *vq)
+virtio_xmit_cleanup(struct virtqueue *vq, uint16_t num)
 {
+#if 0
struct vring_used_elem *uep;
uint16_t used_idx, desc_idx;

@@ -140,6 +146,25 @@ virtqueue_dequeue_pkt_tx(struct virtqueue *vq)
desc_idx = (uint16_t) uep->id;
vq->vq_used_cons_idx++;
vq_ring_free_chain(vq, desc_idx);
+#endif
+   uint16_t i, used_idx, desc_idx;
+   for (i = 0; i < num ; i++) {
+   struct vring_used_elem *uep;
+   struct vq_desc_extra *dxp;
+
+   used_idx = (uint16_t)(vq->vq_used_cons_idx & (vq->vq_nentries - 
1));
+   uep = >vq_ring.used->ring[used_idx];
+   dxp = >vq_descx[used_idx];
+
+   desc_idx = (uint16_t) uep->id;
+   vq->vq_used_cons_idx++;
+   vq_ring_free_chain(vq, desc_idx);
+
+   if (dxp->cookie != NULL) {
+   rte_pktmbuf_free(dxp->cookie);
+   dxp->cookie = NULL;
+   }
+   }
 }


@@ -203,8 +228,10 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct 
rte_mbuf *cookie)

idx = head_idx;
dxp = >vq_descx[idx];
+#if 0
if (dxp->cookie != NULL)
rte_pktmbuf_free(dxp->cookie);
+#endif
dxp->cookie = (void *)cookie;
dxp->ndescs = needed;

@@ -404,6 +431,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 {
uint8_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
struct virtqueue *vq;
+   uint16_t tx_free_thresh;
int ret;

PMD_INIT_FUNC_TRACE();
@@ -421,6 +449,21 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
return ret;
}

+   tx_free_thresh = tx_conf->tx_free_thresh;
+   if (tx_free_thresh == 0)
+   tx_free_thresh = RTE_MIN(vq->vq_nentries / 4, 
DEFAULT_TX_FREE_THRESH);
+
+   if (tx_free_thresh >= (vq->vq_nentries - 3)) {
+   RTE_LOG(ERR, PMD, "tx_free_thresh must be less than the "
+   "number of TX entries minus 3 (%u)."
+   " (tx_free_thresh=%u port=%u queue=%u)\n",
+   vq->vq_nentries - 3,
+   tx_free_thresh, dev->data->port_id, queue_idx);
+   return -EINVAL;
+   }
+
+   vq->vq_free_thresh = tx_free_thresh;
+
dev->data->tx_queues[queue_idx] = vq;
return 0;
 }
@@ -688,11 +731,9 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)
 {
struct virtqueue *txvq = tx_queue;
struct rte_mbuf *txm;
-   uint16_t nb_used, nb_tx, num;
+   uint16_t nb_used, nb_tx;
int error;

-   nb_tx = 0;
-
if (unlikely(nb_pkts < 1))
return nb_pkts;

@@ -700,21 +741,26 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)
nb_used = VIRTQUEUE_NUSED(txvq);

virtio_rmb();
+   if (likely(nb_used > txvq->vq_free_thresh))
+   virtio_xmit_cleanup(txvq, nb_used);

-   num = (uint16_t)(likely(nb_used < 

[dpdk-dev] [RFC PATCH 15/17] virtio: Add ability to set MAC address

2014-12-08 Thread Ouyang Changchun
Need to have do special things to set default mac address.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_ether/rte_ethdev.h |  5 +
 lib/librte_pmd_virtio/virtio_ethdev.c | 24 
 2 files changed, 29 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 07d55b8..cbe3fdf 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1249,6 +1249,10 @@ typedef void (*eth_mac_addr_add_t)(struct rte_eth_dev 
*dev,
  uint32_t vmdq);
 /**< @internal Set a MAC address into Receive Address Address Register */

+typedef void (*eth_mac_addr_set_t)(struct rte_eth_dev *dev,
+ struct ether_addr *mac_addr);
+/**< @internal Set a MAC address into Receive Address Address Register */
+
 typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev,
  struct ether_addr *mac_addr,
  uint8_t on);
@@ -1482,6 +1486,7 @@ struct eth_dev_ops {
priority_flow_ctrl_set_t   priority_flow_ctrl_set; /**< Setup priority 
flow control.*/
eth_mac_addr_remove_t  mac_addr_remove; /**< Remove MAC address */
eth_mac_addr_add_t mac_addr_add;  /**< Add a MAC address */
+   eth_mac_addr_set_t mac_addr_set;  /**< Set a MAC address */
eth_uc_hash_table_set_tuc_hash_table_set;  /**< Set Unicast Table 
Array */
eth_uc_all_hash_table_set_t uc_all_hash_table_set;  /**< Set Unicast 
hash bitmap */
eth_mirror_rule_set_t  mirror_rule_set;  /**< Add a traffic mirror 
rule.*/
diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index e469ac2..c5f21c1 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -90,6 +90,8 @@ static void virtio_mac_addr_add(struct rte_eth_dev *dev,
struct ether_addr *mac_addr,
uint32_t index, uint32_t vmdq __rte_unused);
 static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
+static void virtio_mac_addr_set(struct rte_eth_dev *dev,
+   struct ether_addr *mac_addr);

 static int virtio_dev_queue_stats_mapping_set(
__rte_unused struct rte_eth_dev *eth_dev,
@@ -518,6 +520,7 @@ static struct eth_dev_ops virtio_eth_dev_ops = {
.vlan_filter_set = virtio_vlan_filter_set,
.mac_addr_add= virtio_mac_addr_add,
.mac_addr_remove = virtio_mac_addr_remove,
+   .mac_addr_set= virtio_mac_addr_set,
 };

 static inline int
@@ -733,6 +736,27 @@ virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t 
index)
virtio_mac_table_set(hw, uc, mc);
 }

+static void
+virtio_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
+{
+   struct virtio_hw *hw = dev->data->dev_private;
+
+   memcpy(hw->mac_addr, mac_addr, ETHER_ADDR_LEN);
+
+   /* Use atomic update if available */
+   if (vtpci_with_feature(hw, VIRTIO_NET_F_CTRL_MAC_ADDR)) {
+   struct virtio_pmd_ctrl ctrl;
+   int len = ETHER_ADDR_LEN;
+
+   ctrl.hdr.class = VIRTIO_NET_CTRL_MAC;
+   ctrl.hdr.cmd = VIRTIO_NET_CTRL_MAC_ADDR_SET;
+
+   memcpy(ctrl.data, mac_addr, ETHER_ADDR_LEN);
+   virtio_send_command(hw->cvq, , , 1);
+   } else if (vtpci_with_feature(hw, VIRTIO_NET_F_MAC))
+   virtio_set_hwaddr(hw);
+}
+
 static int
 virtio_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 {
-- 
1.8.4.2



[dpdk-dev] [RFC PATCH 14/17] virtio: Add suport for multiple mac addresses

2014-12-08 Thread Ouyang Changchun
Virtio support multiple MAC addresses.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_virtio/virtio_ethdev.c | 94 ++-
 lib/librte_pmd_virtio/virtio_ethdev.h |  3 +-
 lib/librte_pmd_virtio/virtqueue.h | 34 -
 3 files changed, 127 insertions(+), 4 deletions(-)

diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index ec5a51e..e469ac2 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -86,6 +86,10 @@ static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
 static int virtio_vlan_filter_set(struct rte_eth_dev *dev,
uint16_t vlan_id, int on);
+static void virtio_mac_addr_add(struct rte_eth_dev *dev,
+   struct ether_addr *mac_addr,
+   uint32_t index, uint32_t vmdq __rte_unused);
+static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);

 static int virtio_dev_queue_stats_mapping_set(
__rte_unused struct rte_eth_dev *eth_dev,
@@ -503,8 +507,6 @@ static struct eth_dev_ops virtio_eth_dev_ops = {
.stats_get   = virtio_dev_stats_get,
.stats_reset = virtio_dev_stats_reset,
.link_update = virtio_dev_link_update,
-   .mac_addr_add= NULL,
-   .mac_addr_remove = NULL,
.rx_queue_setup  = virtio_dev_rx_queue_setup,
/* meaningfull only to multiple queue */
.rx_queue_release= virtio_dev_rx_queue_release,
@@ -514,6 +516,8 @@ static struct eth_dev_ops virtio_eth_dev_ops = {
/* collect stats per queue */
.queue_stats_mapping_set = virtio_dev_queue_stats_mapping_set,
.vlan_filter_set = virtio_vlan_filter_set,
+   .mac_addr_add= virtio_mac_addr_add,
+   .mac_addr_remove = virtio_mac_addr_remove,
 };

 static inline int
@@ -644,6 +648,92 @@ virtio_get_hwaddr(struct virtio_hw *hw)
 }

 static int
+virtio_mac_table_set(struct virtio_hw *hw,
+const struct virtio_net_ctrl_mac *uc,
+const struct virtio_net_ctrl_mac *mc)
+{
+   struct virtio_pmd_ctrl ctrl;
+   int err, len[2];
+
+   ctrl.hdr.class = VIRTIO_NET_CTRL_MAC;
+   ctrl.hdr.cmd = VIRTIO_NET_CTRL_MAC_TABLE_SET;
+
+   len[0] = uc->entries * ETHER_ADDR_LEN + sizeof(uc->entries);
+   memcpy(ctrl.data, uc, len[0]);
+
+   len[1] = mc->entries * ETHER_ADDR_LEN + sizeof(mc->entries);
+   memcpy(ctrl.data + len[0], mc, len[1]);
+
+   err = virtio_send_command(hw->cvq, , len, 2);
+   if (err != 0)
+   PMD_DRV_LOG(NOTICE, "mac table set failed: %d", err);
+
+   return err;
+}
+
+static void
+virtio_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
+   uint32_t index, uint32_t vmdq __rte_unused)
+{
+   struct virtio_hw *hw = dev->data->dev_private;
+   const struct ether_addr *addrs = dev->data->mac_addrs;
+   unsigned int i;
+   struct virtio_net_ctrl_mac *uc, *mc;
+
+   if (index >= VIRTIO_MAX_MAC_ADDRS) {
+   PMD_DRV_LOG(ERR, "mac address index %u out of range", index);
+   return;
+   }
+
+   uc = alloca(VIRTIO_MAX_MAC_ADDRS * ETHER_ADDR_LEN + 
sizeof(uc->entries));
+   uc->entries = 0;
+   mc = alloca(VIRTIO_MAX_MAC_ADDRS * ETHER_ADDR_LEN + 
sizeof(mc->entries));
+   mc->entries = 0;
+
+   for (i = 0; i < VIRTIO_MAX_MAC_ADDRS; i++) {
+   const struct ether_addr *addr
+   = (i == index) ? mac_addr : addrs + i;
+   struct virtio_net_ctrl_mac *tbl
+   = is_multicast_ether_addr(addr) ? mc : uc;
+
+   memcpy(>macs[tbl->entries++], addr, ETHER_ADDR_LEN);
+   }
+
+   virtio_mac_table_set(hw, uc, mc);
+}
+
+static void
+virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
+{
+   struct virtio_hw *hw = dev->data->dev_private;
+   struct ether_addr *addrs = dev->data->mac_addrs;
+   struct virtio_net_ctrl_mac *uc, *mc;
+   unsigned int i;
+
+   if (index >= VIRTIO_MAX_MAC_ADDRS) {
+   PMD_DRV_LOG(ERR, "mac address index %u out of range", index);
+   return;
+   }
+
+   uc = alloca(VIRTIO_MAX_MAC_ADDRS * ETHER_ADDR_LEN + 
sizeof(uc->entries));
+   uc->entries = 0;
+   mc = alloca(VIRTIO_MAX_MAC_ADDRS * ETHER_ADDR_LEN + 
sizeof(mc->entries));
+   mc->entries = 0;
+
+   for (i = 0; i < VIRTIO_MAX_MAC_ADDRS; i++) {
+   struct virtio_net_ctrl_mac *tbl;
+
+   if (i == index || is_zero_ether_addr(addrs + i))
+   continue;
+
+   tbl = is_multicast_ether_addr(addrs + i) ? mc : uc;
+   memcpy(>macs[tbl->entries++], addrs + i, ETHER_ADDR_LEN);
+   

[dpdk-dev] [RFC PATCH 13/17] virtio: Add support for vlan filtering

2014-12-08 Thread Ouyang Changchun
Virtio supports vlan filtering.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_virtio/virtio_ethdev.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index 13feda5..ec5a51e 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -84,6 +84,8 @@ static void virtio_dev_tx_queue_release(__rte_unused void 
*txq);
 static void virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats 
*stats);
 static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
+static int virtio_vlan_filter_set(struct rte_eth_dev *dev,
+   uint16_t vlan_id, int on);

 static int virtio_dev_queue_stats_mapping_set(
__rte_unused struct rte_eth_dev *eth_dev,
@@ -511,6 +513,7 @@ static struct eth_dev_ops virtio_eth_dev_ops = {
.tx_queue_release= virtio_dev_tx_queue_release,
/* collect stats per queue */
.queue_stats_mapping_set = virtio_dev_queue_stats_mapping_set,
+   .vlan_filter_set = virtio_vlan_filter_set,
 };

 static inline int
@@ -640,14 +643,31 @@ virtio_get_hwaddr(struct virtio_hw *hw)
}
 }

+static int
+virtio_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
+{
+   struct virtio_hw *hw = dev->data->dev_private;
+   struct virtio_pmd_ctrl ctrl;
+   int len;
+
+   if (!vtpci_with_feature(hw, VIRTIO_NET_F_CTRL_VLAN))
+   return -ENOTSUP;
+
+   ctrl.hdr.class = VIRTIO_NET_CTRL_VLAN;
+   ctrl.hdr.cmd = on ? VIRTIO_NET_CTRL_VLAN_ADD : VIRTIO_NET_CTRL_VLAN_DEL;
+   memcpy(ctrl.data, _id, sizeof(vlan_id));
+   len = sizeof(vlan_id);
+
+   return virtio_send_command(hw->cvq, , , 1);
+}

 static void
 virtio_negotiate_features(struct virtio_hw *hw)
 {
uint32_t host_features, mask;

-   mask = VIRTIO_NET_F_CTRL_VLAN;
-   mask |= VIRTIO_NET_F_CSUM | VIRTIO_NET_F_GUEST_CSUM;
+   /* checksum offload not implemented */
+   mask = VIRTIO_NET_F_CSUM | VIRTIO_NET_F_GUEST_CSUM;

/* TSO and LRO are only available when their corresponding
 * checksum offload feature is also negotiated.
@@ -1058,6 +1078,13 @@ virtio_dev_configure(struct rte_eth_dev *dev)

hw->vlan_strip = rxmode->hw_vlan_strip;

+   if (rxmode->hw_vlan_filter
+   && !vtpci_with_feature(hw, VIRTIO_NET_F_CTRL_VLAN)) {
+   PMD_DRV_LOG(NOTICE,
+   "vlan filtering not available on this host");
+   return -ENOTSUP;
+   }
+
if (vtpci_irq_config(hw, 0) == VIRTIO_MSI_NO_VECTOR) {
PMD_DRV_LOG(ERR, "failed to set config vector");
return -EBUSY;
-- 
1.8.4.2



[dpdk-dev] [RFC PATCH 12/17] virtio: Move allocation before initialization

2014-12-08 Thread Ouyang Changchun
If allocation fails, don't want to leave virtio device stuck
in middle of initialization sequence.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_virtio/virtio_ethdev.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index c17cac8..13feda5 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -890,6 +890,15 @@ eth_virtio_dev_init(__rte_unused struct eth_driver 
*eth_drv,
if (rte_eal_process_type() == RTE_PROC_SECONDARY)
return 0;

+   /* Allocate memory for storing MAC addresses */
+   eth_dev->data->mac_addrs = rte_zmalloc("virtio", ETHER_ADDR_LEN, 0);
+   if (eth_dev->data->mac_addrs == NULL) {
+   PMD_INIT_LOG(ERR,
+   "Failed to allocate %d bytes needed to store MAC 
addresses",
+   ETHER_ADDR_LEN);
+   return -ENOMEM;
+   }
+
/* Tell the host we've noticed this device. */
vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);

@@ -916,15 +925,6 @@ eth_virtio_dev_init(__rte_unused struct eth_driver 
*eth_drv,
hw->vtnet_hdr_size = sizeof(struct virtio_net_hdr);
}

-   /* Allocate memory for storing MAC addresses */
-   eth_dev->data->mac_addrs = rte_zmalloc("virtio", ETHER_ADDR_LEN, 0);
-   if (eth_dev->data->mac_addrs == NULL) {
-   PMD_INIT_LOG(ERR,
-   "Failed to allocate %d bytes needed to store MAC 
addresses",
-   ETHER_ADDR_LEN);
-   return -ENOMEM;
-   }
-
/* Copy the permanent MAC address to: virtio_hw */
virtio_get_hwaddr(hw);
ether_addr_copy((struct ether_addr *) hw->mac_addr,
-- 
1.8.4.2



[dpdk-dev] [RFC PATCH 11/17] virtio: Check for packet headroom at compile time

2014-12-08 Thread Ouyang Changchun
Better to check at compile time than fail at runtime.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_virtio/virtio_ethdev.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index a07f4ca..c17cac8 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -882,11 +882,7 @@ eth_virtio_dev_init(__rte_unused struct eth_driver 
*eth_drv,
uint32_t offset_conf = sizeof(config->mac);
struct rte_pci_device *pci_dev;

-   if (RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr)) {
-   PMD_INIT_LOG(ERR,
-   "MBUF HEADROOM should be enough to hold virtio net 
hdr\n");
-   return -1;
-   }
+   RTE_BUILD_BUG_ON(RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr));

eth_dev->dev_ops = _eth_dev_ops;
eth_dev->tx_pkt_burst = _xmit_pkts;
-- 
1.8.4.2



[dpdk-dev] [RFC PATCH 09/17] virtio: Fix how states are handled during initialization

2014-12-08 Thread Ouyang Changchun
Change order of initialiazation to match Linux kernel.
Don't blow away control queue by doing reset when stopped.

Calling dev_stop then dev_start would not work.
Dev_stop was calling virtio reset and that would clear all queues
and clear all feature negotiation.
Resolved by only doing reset on device removal.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_virtio/virtio_ethdev.c | 58 ---
 lib/librte_pmd_virtio/virtio_pci.c| 10 ++
 lib/librte_pmd_virtio/virtio_pci.h|  3 +-
 3 files changed, 37 insertions(+), 34 deletions(-)

diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index b7f65b9..a07f4ca 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -398,9 +398,14 @@ virtio_dev_cq_queue_setup(struct rte_eth_dev *dev, 
uint16_t vtpci_queue_idx,
 static void
 virtio_dev_close(struct rte_eth_dev *dev)
 {
+   struct virtio_hw *hw = dev->data->dev_private;
+
PMD_INIT_LOG(DEBUG, "virtio_dev_close");

-   virtio_dev_stop(dev);
+   /* reset the NIC */
+   vtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR);
+   vtpci_reset(hw);
+   virtio_dev_free_mbufs(dev);
 }

 static void
@@ -889,6 +894,9 @@ eth_virtio_dev_init(__rte_unused struct eth_driver *eth_drv,
if (rte_eal_process_type() == RTE_PROC_SECONDARY)
return 0;

+   /* Tell the host we've noticed this device. */
+   vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);
+
pci_dev = eth_dev->pci_dev;
if (virtio_resource_init(pci_dev) < 0)
return -1;
@@ -899,9 +907,6 @@ eth_virtio_dev_init(__rte_unused struct eth_driver *eth_drv,
/* Reset the device although not necessary at startup */
vtpci_reset(hw);

-   /* Tell the host we've noticed this device. */
-   vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);
-
/* Tell the host we've known how to drive the device. */
vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER);
virtio_negotiate_features(hw);
@@ -990,6 +995,9 @@ eth_virtio_dev_init(__rte_unused struct eth_driver *eth_drv,
/* Setup interrupt callback  */
rte_intr_callback_register(_dev->intr_handle,
   virtio_interrupt_handler, eth_dev);
+
+   virtio_dev_cq_start(eth_dev);
+
return 0;
 }

@@ -1044,7 +1052,6 @@ virtio_dev_configure(struct rte_eth_dev *dev)
 {
const struct rte_eth_rxmode *rxmode = >data->dev_conf.rxmode;
struct virtio_hw *hw = dev->data->dev_private;
-   int ret;

PMD_INIT_LOG(DEBUG, "configure");

@@ -1055,11 +1062,12 @@ virtio_dev_configure(struct rte_eth_dev *dev)

hw->vlan_strip = rxmode->hw_vlan_strip;

-   ret = vtpci_irq_config(hw, 0);
-   if (ret != 0)
+   if (vtpci_irq_config(hw, 0) == VIRTIO_MSI_NO_VECTOR) {
PMD_DRV_LOG(ERR, "failed to set config vector");
+   return -EBUSY;
+   }

-   return ret;
+   return 0;
 }


@@ -1069,17 +1077,6 @@ virtio_dev_start(struct rte_eth_dev *dev)
uint16_t nb_queues, i;
struct virtio_hw *hw = dev->data->dev_private;

-   /* Tell the host we've noticed this device. */
-   vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);
-
-   /* Tell the host we've known how to drive the device. */
-   vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER);
-
-   virtio_dev_cq_start(dev);
-
-   /* Do final configuration before rx/tx engine starts */
-   virtio_dev_rxtx_start(dev);
-
/* check if lsc interrupt feature is enabled */
if (dev->data->dev_conf.intr_conf.lsc) {
if (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
@@ -1096,8 +1093,16 @@ virtio_dev_start(struct rte_eth_dev *dev)
/* Initialize Link state */
virtio_dev_link_update(dev, 0);

+   /* On restart after stop do not touch queues */
+   if (hw->started)
+   return 0;
+
vtpci_reinit_complete(hw);

+   /* Do final configuration before rx/tx engine starts */
+   virtio_dev_rxtx_start(dev);
+   hw->started = 1;
+
/*Notify the backend
 *Otherwise the tap backend might already stop its queue due to 
fullness.
 *vhost backend will have no chance to be waked up
@@ -1168,17 +1173,20 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev 
*dev)
 }

 /*
- * Stop device: disable rx and tx functions to allow for reconfiguring.
+ * Stop device: disable interrupt and mark link down
  */
 static void
 virtio_dev_stop(struct rte_eth_dev *dev)
 {
-   struct virtio_hw *hw = dev->data->dev_private;
+   struct rte_eth_link link;

-   /* reset the NIC */
-   vtpci_irq_config(hw, 0);
-   vtpci_reset(hw);
-   virtio_dev_free_mbufs(dev);
+   PMD_INIT_LOG(DEBUG, "stop");
+
+   if (dev->data->dev_conf.intr_conf.lsc)
+   

[dpdk-dev] [RFC PATCH 05/17] ether: Add soft vlan encap/decap functions

2014-12-08 Thread Ouyang Changchun
It is helpful to allow device drivers that don't support hardware
VLAN stripping to emulate this in software. This allows application
to be device independent.

Avoid discarding shared mbufs. Make a copy in rte_vlan_insert() of any
packet to be tagged that has a reference count > 1.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_ether/rte_ether.h | 76 
 1 file changed, 76 insertions(+)

diff --git a/lib/librte_ether/rte_ether.h b/lib/librte_ether/rte_ether.h
index 187608d..3b6ab4b 100644
--- a/lib/librte_ether/rte_ether.h
+++ b/lib/librte_ether/rte_ether.h
@@ -49,6 +49,8 @@ extern "C" {

 #include 
 #include 
+#include 
+#include 

 #define ETHER_ADDR_LEN  6 /**< Length of Ethernet address. */
 #define ETHER_TYPE_LEN  2 /**< Length of Ethernet type field. */
@@ -332,6 +334,80 @@ struct vxlan_hdr {
 #define ETHER_VXLAN_HLEN (sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr))
 /**< VXLAN tunnel header length. */

+/**
+ * Extract VLAN tag information into mbuf
+ *
+ * Software version of VLAN stripping
+ *
+ * @param m
+ *   The packet mbuf.
+ * @return
+ *   - 0: Success
+ *   - 1: not a vlan packet
+ */
+static inline int rte_vlan_strip(struct rte_mbuf *m)
+{
+   struct ether_hdr *eh
+= rte_pktmbuf_mtod(m, struct ether_hdr *);
+
+   if (eh->ether_type != ETHER_TYPE_VLAN)
+   return -1;
+
+   struct vlan_hdr *vh = (struct vlan_hdr *)(eh + 1);
+   m->ol_flags |= PKT_RX_VLAN_PKT;
+   m->vlan_tci = rte_be_to_cpu_16(vh->vlan_tci);
+
+   /* Copy ether header over rather than moving whole packet */
+   memmove(rte_pktmbuf_adj(m, sizeof(struct vlan_hdr)),
+   eh, 2 * ETHER_ADDR_LEN);
+
+   return 0;
+}
+
+/**
+ * Insert VLAN tag into mbuf.
+ *
+ * Software version of VLAN unstripping
+ *
+ * @param m
+ *   The packet mbuf.
+ * @return
+ *   - 0: On success
+ *   -EPERM: mbuf is is shared overwriting would be unsafe
+ *   -ENOSPC: not enough headroom in mbuf
+ */
+static inline int rte_vlan_insert(struct rte_mbuf **m)
+{
+   struct ether_hdr *oh, *nh;
+   struct vlan_hdr *vh;
+
+#ifdef RTE_MBUF_REFCNT
+   /* Can't insert header if mbuf is shared */
+   if (rte_mbuf_refcnt_read(*m) > 1) {
+   struct rte_mbuf *copy;
+
+   copy = rte_pktmbuf_clone(*m, (*m)->pool);
+   if (unlikely(copy == NULL))
+   return -ENOMEM;
+   rte_pktmbuf_free(*m);
+   *m = copy;
+   }
+#endif
+   oh = rte_pktmbuf_mtod(*m, struct ether_hdr *);
+   nh = (struct ether_hdr *)
+   rte_pktmbuf_prepend(*m, sizeof(struct vlan_hdr));
+   if (nh == NULL)
+   return -ENOSPC;
+
+   memmove(nh, oh, 2 * ETHER_ADDR_LEN);
+   nh->ether_type = ETHER_TYPE_VLAN;
+
+   vh = (struct vlan_hdr *) (nh + 1);
+   vh->vlan_tci = rte_cpu_to_be_16((*m)->vlan_tci);
+
+   return 0;
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.8.4.2



[dpdk-dev] [RFC PATCH 04/17] virtio: Add support for Link State interrupt

2014-12-08 Thread Ouyang Changchun
Virtio has link state interrupt which can be used.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_virtio/virtio_ethdev.c | 78 +++
 lib/librte_pmd_virtio/virtio_pci.c| 22 ++
 lib/librte_pmd_virtio/virtio_pci.h|  4 ++
 3 files changed, 86 insertions(+), 18 deletions(-)

diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index 4bff0fe..d37f2e9 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -845,6 +845,34 @@ static int virtio_resource_init(struct rte_pci_device 
*pci_dev __rte_unused)
 #endif

 /*
+ * Process Virtio Config changed interrupt and call the callback
+ * if link state changed.
+ */
+static void
+virtio_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
+void *param)
+{
+   struct rte_eth_dev *dev = param;
+   struct virtio_hw *hw =
+   VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   uint8_t isr;
+
+   /* Read interrupt status which clears interrupt */
+   isr = vtpci_isr(hw);
+   PMD_DRV_LOG(INFO, "interrupt status = %#x", isr);
+
+   if (rte_intr_enable(>pci_dev->intr_handle) < 0)
+   PMD_DRV_LOG(ERR, "interrupt enable failed");
+
+   if (isr & VIRTIO_PCI_ISR_CONFIG) {
+   if (virtio_dev_link_update(dev, 0) == 0)
+   _rte_eth_dev_callback_process(dev,
+ RTE_ETH_EVENT_INTR_LSC);
+   }
+
+}
+
+/*
  * This function is based on probe() function in virtio_pci.c
  * It returns 0 on success.
  */
@@ -968,6 +996,10 @@ eth_virtio_dev_init(__rte_unused struct eth_driver 
*eth_drv,
PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
eth_dev->data->port_id, pci_dev->id.vendor_id,
pci_dev->id.device_id);
+
+   /* Setup interrupt callback  */
+   rte_intr_callback_register(_dev->intr_handle,
+  virtio_interrupt_handler, eth_dev);
return 0;
 }

@@ -975,7 +1007,7 @@ static struct eth_driver rte_virtio_pmd = {
{
.name = "rte_virtio_pmd",
.id_table = pci_id_virtio_map,
-   .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+   .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
},
.eth_dev_init = eth_virtio_dev_init,
.dev_private_size = sizeof(struct virtio_adapter),
@@ -1021,6 +1053,9 @@ static int
 virtio_dev_configure(struct rte_eth_dev *dev)
 {
const struct rte_eth_rxmode *rxmode = >data->dev_conf.rxmode;
+   struct virtio_hw *hw =
+   VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   int ret;

PMD_INIT_LOG(DEBUG, "configure");

@@ -1029,7 +1064,11 @@ virtio_dev_configure(struct rte_eth_dev *dev)
return (-EINVAL);
}

-   return 0;
+   ret = vtpci_irq_config(hw, 0);
+   if (ret != 0)
+   PMD_DRV_LOG(ERR, "failed to set config vector");
+
+   return ret;
 }


@@ -1037,7 +1076,6 @@ static int
 virtio_dev_start(struct rte_eth_dev *dev)
 {
uint16_t nb_queues, i;
-   uint16_t status;
struct virtio_hw *hw =
VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);

@@ -1052,18 +1090,22 @@ virtio_dev_start(struct rte_eth_dev *dev)
/* Do final configuration before rx/tx engine starts */
virtio_dev_rxtx_start(dev);

-   /* Check VIRTIO_NET_F_STATUS for link status*/
-   if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
-   vtpci_read_dev_config(hw,
-   offsetof(struct virtio_net_config, status),
-   , sizeof(status));
-   if ((status & VIRTIO_NET_S_LINK_UP) == 0)
-   PMD_INIT_LOG(ERR, "Port: %d Link is DOWN",
-dev->data->port_id);
-   else
-   PMD_INIT_LOG(DEBUG, "Port: %d Link is UP",
-dev->data->port_id);
+   /* check if lsc interrupt feature is enabled */
+   if (dev->data->dev_conf.intr_conf.lsc) {
+   if (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
+   PMD_DRV_LOG(ERR, "link status not supported by host");
+   return -ENOTSUP;
+   }
+
+   if (rte_intr_enable(>pci_dev->intr_handle) < 0) {
+   PMD_DRV_LOG(ERR, "interrupt enable failed");
+   return -EIO;
+   }
}
+
+   /* Initialize Link state */
+   virtio_dev_link_update(dev, 0);
+
vtpci_reinit_complete(hw);

/*Notify the backend
@@ -1145,6 +1187,7 @@ virtio_dev_stop(struct rte_eth_dev *dev)
VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);

/* reset the NIC */
+   

[dpdk-dev] [RFC PATCH 01/17] virtio: Rearrange resource initialization

2014-12-08 Thread Ouyang Changchun
For clarity make the setup of PCI resources for Linux into a function rather
than block of code #ifdef'd in middle of dev_init.

Signed-off-by: Changchun Ouyang 
Signed-off-by: Stephen Hemminger 
---
 lib/librte_pmd_virtio/virtio_ethdev.c | 76 ---
 1 file changed, 43 insertions(+), 33 deletions(-)

diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c 
b/lib/librte_pmd_virtio/virtio_ethdev.c
index c009f2a..6c31598 100644
--- a/lib/librte_pmd_virtio/virtio_ethdev.c
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c
@@ -794,6 +794,41 @@ virtio_has_msix(const struct rte_pci_addr *loc)

return (d != NULL);
 }
+
+/* Extract I/O port numbers from sysfs */
+static int virtio_resource_init(struct rte_pci_device *pci_dev)
+{
+   char dirname[PATH_MAX];
+   char filename[PATH_MAX];
+   unsigned long start, size;
+
+   if (get_uio_dev(_dev->addr, dirname, sizeof(dirname)) < 0)
+   return -1;
+
+   /* get portio size */
+   snprintf(filename, sizeof(filename),
+"%s/portio/port0/size", dirname);
+   if (parse_sysfs_value(filename, ) < 0) {
+   PMD_INIT_LOG(ERR, "%s(): cannot parse size",
+__func__);
+   return -1;
+   }
+
+   /* get portio start */
+   snprintf(filename, sizeof(filename),
+"%s/portio/port0/start", dirname);
+   if (parse_sysfs_value(filename, ) < 0) {
+   PMD_INIT_LOG(ERR, "%s(): cannot parse portio start",
+__func__);
+   return -1;
+   }
+   pci_dev->mem_resource[0].addr = (void *)(uintptr_t)start;
+   pci_dev->mem_resource[0].len =  (uint64_t)size;
+   PMD_INIT_LOG(DEBUG,
+"PCI Port IO found start=0x%lx with size=0x%lx",
+start, size);
+   return 0;
+}
 #else
 static int
 virtio_has_msix(const struct rte_pci_addr *loc __rte_unused)
@@ -801,6 +836,12 @@ virtio_has_msix(const struct rte_pci_addr *loc 
__rte_unused)
/* nic_uio does not enable interrupts, return 0 (false). */
return 0;
 }
+
+static int virtio_resource_init(struct rte_pci_device *pci_dev __rte_unused)
+{
+   /* no setup required */
+   return 0;
+}
 #endif

 /*
@@ -831,40 +872,9 @@ eth_virtio_dev_init(__rte_unused struct eth_driver 
*eth_drv,
return 0;

pci_dev = eth_dev->pci_dev;
+   if (virtio_resource_init(pci_dev) < 0)
+   return -1;

-#ifdef RTE_EXEC_ENV_LINUXAPP
-   {
-   char dirname[PATH_MAX];
-   char filename[PATH_MAX];
-   unsigned long start, size;
-
-   if (get_uio_dev(_dev->addr, dirname, sizeof(dirname)) < 0)
-   return -1;
-
-   /* get portio size */
-   snprintf(filename, sizeof(filename),
-"%s/portio/port0/size", dirname);
-   if (parse_sysfs_value(filename, ) < 0) {
-   PMD_INIT_LOG(ERR, "%s(): cannot parse size",
-__func__);
-   return -1;
-   }
-
-   /* get portio start */
-   snprintf(filename, sizeof(filename),
-"%s/portio/port0/start", dirname);
-   if (parse_sysfs_value(filename, ) < 0) {
-   PMD_INIT_LOG(ERR, "%s(): cannot parse portio start",
-__func__);
-   return -1;
-   }
-   pci_dev->mem_resource[0].addr = (void *)(uintptr_t)start;
-   pci_dev->mem_resource[0].len =  (uint64_t)size;
-   PMD_INIT_LOG(DEBUG,
-"PCI Port IO found start=0x%lx with size=0x%lx",
-start, size);
-   }
-#endif
hw->use_msix = virtio_has_msix(_dev->addr);
hw->io_base = (uint32_t)(uintptr_t)pci_dev->mem_resource[0].addr;

-- 
1.8.4.2



[dpdk-dev] [RFC PATCH 00/17] Single virtio implementation

2014-12-08 Thread Ouyang Changchun
This is RFC patch for single virtio implementation.

Why we need single virtio?

As we know currently there are at least 3 virtio PMD driver implementations:
A) lib/librte_pmd_virtio(refer as virtio A);
B) virtio_net_pmd by 6wind(refer as virtio B);
C) virtio by Brocade/vyatta(refer as virtio C);

Integrating 3 implementations into one could reduce the maintaining cost and 
time,
in other hand, user don't need practice their application on 3 variant one by 
one to see
which one is the best for them;


What's the status?

Currently virtio A has covered most features of virtio B, we could regard they 
have
similar behavior as virtio driver. But there are some differences between
virtio A and virtio C, so it need integrate features/codes from virtio C into 
virtio A.
This patch set bases on two original RFC patch sets from Stephen 
Hemminger[stephen at networkplumber.org]
Refer to [http://dpdk.org/ml/archives/dev/2014-August/004845.html ] for the 
original one.
This patch set also resolves some conflict with latest codes and removed 
duplicated codes.


What this patch set contains:
===
  1) virtio: Rearrange resource initialization, it extracts a function to setup 
PCI resources;
  2) virtio: Use weaker barriers, as DPDK driver only has to deal with the case 
of running on PCI
 and with SMP, In this case, the code can use the weaker barriers instead 
of using hard (fence)
 barriers. This may help performance a bit;
  3) virtio: Allow starting with link down, other driver has similar behavior;
  4) virtio: Add support for Link State interrupt;
  5) ether: Add soft vlan encap/decap functions, it helps if HW don't support 
vlan strip;
  6) virtio: Use software vlan stripping;
  7) virtio: Remove unnecessary adapter structure;
  8) virtio: Remove redundant vq_alignment, as vq alignment is always 4K, so 
use constant when needed;
  9) virtio: Fix how states are handled during initialization, this is to match 
Linux kernel;
  10) virtio: Make vtpci_get_status a local function as it is used in one file;
  11) virtio: Check for packet headroom at compile time;
  12) virtio: Move allocation before initialization to avoid being stuck in 
middle of virtio init;
  13) virtio: Add support for vlan filtering;
  14) virtio: Add support for multiple mac addresses;
  15) virtio: Add ability to set MAC address;
  16) virtio: Free mbuf's with threshold, this makes its behavior more like 
ixgbe;
  17) virtio: Use port IO to get PCI resource for security reasons and match 
virtio-net-pmd.

Any feedback and comments for this RFC are welcome.

Changchun Ouyang (17):
  virtio: Rearrange resource initialization
  virtio: Use weaker barriers
  virtio: Allow starting with link down
  virtio: Add support for Link State interrupt
  ether: Add soft vlan encap/decap functions
  virtio: Use software vlan stripping
  virtio: Remove unnecessary adapter structure
  virtio: Remove redundant vq_alignment
  virtio: Fix how states are handled during initialization
  virtio: Make vtpci_get_status local
  virtio: Check for packet headroom at compile time
  virtio: Move allocation before initialization
  virtio: Add support for vlan filtering
  virtio: Add suport for multiple mac addresses
  virtio: Add ability to set MAC address
  virtio: Free mbuf's with threshold
  virtio: Use port IO to get PCI resource.

 lib/librte_eal/common/include/rte_pci.h |   2 +
 lib/librte_eal/linuxapp/eal/eal_pci.c   |   3 +-
 lib/librte_ether/rte_ethdev.h   |   8 +
 lib/librte_ether/rte_ether.h|  76 +
 lib/librte_pmd_virtio/virtio_ethdev.c   | 479 
 lib/librte_pmd_virtio/virtio_ethdev.h   |  12 +-
 lib/librte_pmd_virtio/virtio_pci.c  |  20 +-
 lib/librte_pmd_virtio/virtio_pci.h  |   8 +-
 lib/librte_pmd_virtio/virtio_rxtx.c | 101 +--
 lib/librte_pmd_virtio/virtqueue.h   |  59 +++-
 10 files changed, 614 insertions(+), 154 deletions(-)

-- 
1.8.4.2



[dpdk-dev] [PATCH 11/15] eal/tile: add EAL support for global mPIPE initialization

2014-12-08 Thread Cyril Chemparathy
Hi Neil,


On 12/8/2014 12:03 PM, Neil Horman wrote:
> On Mon, Dec 08, 2014 at 04:59:34PM +0800, Zhigang Lu wrote:
>> The TileGx mPIPE hardware provides Ethernet connectivity,
>> packet classification, and packet load balancing services.
>>
>> Signed-off-by: Zhigang Lu 
>> Signed-off-by: Cyril Chemparathy 
>> ---
>>   .../common/include/arch/tile/rte_mpipe.h   |  67 ++
>>   lib/librte_eal/linuxapp/eal/Makefile   |   3 +
>>   lib/librte_eal/linuxapp/eal/eal.c  |   9 ++
>>   lib/librte_eal/linuxapp/eal/eal_mpipe_tile.c   | 147 
>> +
>>   mk/rte.app.mk  |   4 +
>>   5 files changed, 230 insertions(+)
>>   create mode 100644 lib/librte_eal/common/include/arch/tile/rte_mpipe.h
>>   create mode 100644 lib/librte_eal/linuxapp/eal/eal_mpipe_tile.c
>>
> This seems like the wrong way to implement mpip access.  If you want to use it
> for networking access, you should create a pmd to talk to it.  If you just 
> want
> raw gxio access, you already have a gxio library that applications can 
> interface
> to.  Theres no need to create addtional DPDK api services just to wrap it up,
> especially given that those surfaces won't exist outside of the tile arch 
> (i.e.
> this allows for the creation of very non-portable applications).

Thanks for the taking a look.

The mPIPE hardware block includes hardware managed buffer pools, which 
we've abstracted under the mempool interface in the very next patch in 
the series.  As a result of this mempool dependency, mPIPE needs to be 
globally initialized on TileGX architecture.

The alternative is to not include support for the hardware managed 
buffer pool, but that decision incurs a significant performance hit.

Thanks
-- Cyril.


[dpdk-dev] [PATCH 02/15] eal/tile: add atomic operations for TileGx

2014-12-08 Thread Cyril Chemparathy
On 12/8/2014 6:28 AM, Neil Horman wrote:
> On Mon, Dec 08, 2014 at 04:59:25PM +0800, Zhigang Lu wrote:
>> This patch adds architecture specific memory barrier operations for
>> TileGx.
>>
>> Signed-off-by: Zhigang Lu 
>> Signed-off-by: Cyril Chemparathy 
>> ---
[...]
>> +__sync_synchronize();
> I don't see __sync_synchronize defined anywhere.  Is that an intrinsic for 
> gcc,
> or a library call?

That is a GCC primitive.


-- Cyril.


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

2014-12-08 Thread Burakov, Anatoly
> When vfio module is not loaded when kernel support vfio feature, the
> routine still try to open the container to get file description.
> 
> This action is not safe, and of cause got error messages:
> 
> EAL: Detected 40 lcore(s)
> EAL:   unsupported IOMMU type!
> EAL: VFIO support could not be initialized
> EAL: Setting up memory...
> 
> This may make user confuse, this patch make it reasonable and much more
> soomth to user.
> 
> Signed-off-by: Michael Qiu 
> ---
> v4 --> v3:
>   1. Remove RTE_LOG for params check
>   2. Remove "vfio" module check as "vfio_iommu_type1"
>  loaded indecated "vfio" loaded
> 
> v3 --> v2:
> 1. Add error log in rte_eal_check_module()
> 2. Some code clean up.
> 
> v2 --> v1:
> 1. Move check_module() from rte_common.h to eal_private.h
>and rename to rte_eal_check_module().
>To make it linuxapp only.
> 2. Some code clean up.
> 
>  lib/librte_eal/common/eal_private.h| 42
> ++
>  lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 29 ++---
>  2 files changed, 68 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_private.h
> b/lib/librte_eal/common/eal_private.h
> index 232fcec..e877a25 100644
> --- a/lib/librte_eal/common/eal_private.h
> +++ b/lib/librte_eal/common/eal_private.h
> @@ -35,6 +35,9 @@
>  #define _EAL_PRIVATE_H_
> 
>  #include 
> +#include 
> +#include 
> +#include 
> 
>  /**
>   * Initialize the memzone subsystem (private to eal).
> @@ -203,4 +206,43 @@ int rte_eal_alarm_init(void);
>   */
>  int rte_eal_dev_init(void);
> 
> +/**
> + * Function is to check if the kernel module(like, vfio,
> +vfio_iommu_type1,
> + * etc.) loaded.
> + *
> + * @param module_name
> + *   The module's name which need to be checked
> + *
> + * @return
> + *   -1 means some error happens(NULL pointer or open failure)
> + *   0  means the module not loaded
> + *   1  means the module loaded
> + */
> +static inline int
> +rte_eal_check_module(const char *module_name) {
> + char mod_name[30]; /* Any module names can be longer than 30
> bytes? */
> + int ret = 0;
> +
> + if (NULL == module_name)
> + return -1;
> +
> + FILE * fd = fopen("/proc/modules", "r");
> + if (NULL == fd) {
> + RTE_LOG(ERR, EAL, "Open /proc/modules failed!"
> + " error %i (%s)\n", errno, strerror(errno));
> + return -1;
> + }
> + while(!feof(fd)) {
> + fscanf(fd, "%s %*[^\n]", mod_name);
> + if(!strcmp(mod_name, module_name)) {
> + ret = 1;
> + break;
> + }
> + }
> + fclose(fd);
> +
> + return ret;
> +}
> +

Apologies for not bringing this up before, but do we really want the 
rte_eal_check_module inline in the header? I think it would be better to 
declare it in eal_private but move the definition into eal.c.

>  #endif /* _EAL_PRIVATE_H_ */
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> index c1246e8..8c54d2a 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> @@ -44,6 +44,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #include "eal_filesystem.h"
>  #include "eal_pci_init.h"
> @@ -339,10 +340,15 @@ pci_vfio_get_container_fd(void)
>   ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION,
> VFIO_TYPE1_IOMMU);
>   if (ret != 1) {
>   if (ret < 0)
> - RTE_LOG(ERR, EAL, "  could not get IOMMU
> type, "
> - "error %i (%s)\n", errno,
> strerror(errno));
> + RTE_LOG(ERR, EAL, "  could not get IOMMU
> type,"
> + " error %i (%s)\n", errno,
> + strerror(errno));
>   else
> - RTE_LOG(ERR, EAL, "  unsupported IOMMU
> type!\n");
> + /* Better to show the IOMMU type return
> from
> +  * kernel for easy debug
> +  */
> + RTE_LOG(ERR, EAL, "  unsupported IOMMU
> type"
> + " detected: %d in VFIO\n", ret);

I'm not sure this message is meaningful. That ioctl call can either -1, 0 or 1. 
We already handle 1 separately; -1 means an error; 0 means IOMMU type 1 is not 
supported. The return value will *not* indicate which IOMMU types *are* 
currently supported - it will only indicate that the IOMMU type you requested 
is not supported. So there's really no point in indicating the return value in 
case of ret 0 - it is best to just mention that requested IOMMU type support is 
not enabled in VFIO.

>   close(vfio_container_fd);
>   return -1;
>   }

[dpdk-dev] [PATCH v3] mbuf: fix of enabling all newly added RX error flags

2014-12-08 Thread Thomas Monjalon
Hi Helin,

2014-12-06 09:33, Helin Zhang:
> Before redefining mbuf structure, there was lack of free bits in 'ol_flags'
> (32 bits in total) for new RX or TX flags. So it tried to reuse existant
> bits as most as possible, or even assigning 0 to some of bit flags. After
> new mbuf structure defined, there are quite a lot of free bits. So those
> newly added bit flags should be assigned with correct and valid bit values,
> and getting their names should be enabled as well. Note that 'RECIP' should
> be removed, as nowhere will use it. 'PKT_RX_ERR' is defined to replace all
> other error bit flags, e.g. MAC error, Oversize error, header buffer
> overflow error.
> 
> Signed-off-by: Helin Zhang 
[...]
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -84,11 +84,6 @@ extern "C" {
>  #define PKT_RX_FDIR  (1ULL << 2)  /**< RX packet with FDIR match 
> indicate. */
>  #define PKT_RX_L4_CKSUM_BAD  (1ULL << 3)  /**< L4 cksum of RX pkt. is not 
> OK. */
>  #define PKT_RX_IP_CKSUM_BAD  (1ULL << 4)  /**< IP cksum of RX pkt. is not 
> OK. */
> -#define PKT_RX_EIP_CKSUM_BAD (0ULL << 0)  /**< External IP header checksum 
> error. */
> -#define PKT_RX_OVERSIZE  (0ULL << 0)  /**< Num of desc of an RX pkt 
> oversize. */
> -#define PKT_RX_HBUF_OVERFLOW (0ULL << 0)  /**< Header buffer overflow. */
> -#define PKT_RX_RECIP_ERR (0ULL << 0)  /**< Hardware processing error. */
> -#define PKT_RX_MAC_ERR   (0ULL << 0)  /**< MAC error. */
>  #define PKT_RX_IPV4_HDR  (1ULL << 5)  /**< RX packet with IPv4 header. */
>  #define PKT_RX_IPV4_HDR_EXT  (1ULL << 6)  /**< RX packet with extended IPv4 
> header. */
>  #define PKT_RX_IPV6_HDR  (1ULL << 7)  /**< RX packet with IPv6 header. */
> @@ -99,6 +94,8 @@ extern "C" {
>  #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
> header. */
>  #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. 
> */
>  #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if 
> FDIR match. */
> +#define PKT_RX_EIP_CKSUM_BAD (1ULL << 15)  /**< External IP header checksum 
> error. */

Could PKT_RX_EIP_CKSUM_BAD be aggregated with PKT_RX_IP_CKSUM_BAD?
The conclusion is the same: the packet is corrupted.
And some hardwares could not detect the encapsulation and use 
PKT_RX_IP_CKSUM_BAD.

Another interesting improvement would be to have PKT_RX_IP_CKSUM_OK.
I think we'll have to think about this kind of flag for next version.

Note that this patch is an API change and shouldn't be applied for 1.8.0.
But we can do an exception as it has no impact on existing applications and
fixes the 0 flags.

-- 
Thomas


[dpdk-dev] [PATCH] doc: typos corrected in distributor application

2014-12-08 Thread Iremonger, Bernard
> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Reshma Pattan
> Sent: Friday, December 5, 2014 4:08 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH] doc: typos corrected in distributor application
> 
> corrected couple of typos in distributor application
> 
> Signed-off-by: Reshma Pattan 

Acked-by: Bernard Iremonger 
 I have applied the patch to my tree next/dpdk-doc.



[dpdk-dev] [PATCH] doc: add license header to link bonding diagrams

2014-12-08 Thread Declan Doherty

Signed-off-by: Declan Doherty 
---
 doc/guides/prog_guide/img/bond-mode-0.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-1.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-2.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-3.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-4.svg   | 34 +
 doc/guides/prog_guide/img/bond-mode-5.svg   | 34 +
 doc/guides/prog_guide/img/bond-overview.svg | 34 +
 7 files changed, 238 insertions(+)

diff --git a/doc/guides/prog_guide/img/bond-mode-0.svg 
b/doc/guides/prog_guide/img/bond-mode-0.svg
index eff0edb..e9742c7 100644
--- a/doc/guides/prog_guide/img/bond-mode-0.svg
+++ b/doc/guides/prog_guide/img/bond-mode-0.svg
@@ -1,4 +1,38 @@
 
+
 

 
+
 

 
+
 

 
+
 

 
+
 

 
+
 

 
+
 http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd;>
 
 http://www.w3.org/2000/svg; 
xmlns:xlink="http://www.w3.org/1999/xlink; 
xmlns:ev="http://www.w3.org/2001/xml-events;
-- 
1.7.12.2



[dpdk-dev] [PATCH 01/15] mk: introduce Tilera Tile architecture

2014-12-08 Thread Bruce Richardson
On Mon, Dec 08, 2014 at 04:59:24PM +0800, Zhigang Lu wrote:
> Add defconfig and rte.vars.mk files for Tile architecture.
> 
> Signed-off-by: Zhigang Lu 
> Signed-off-by: Cyril Chemparathy 
> ---
>  config/defconfig_tile-tilegx-linuxapp-gcc | 78 
> +++
>  mk/arch/tile/rte.vars.mk  | 59 +++
>  mk/machine/tilegx/rte.vars.mk | 58 +++
>  3 files changed, 195 insertions(+)
>  create mode 100644 config/defconfig_tile-tilegx-linuxapp-gcc
>  create mode 100644 mk/arch/tile/rte.vars.mk
>  create mode 100644 mk/machine/tilegx/rte.vars.mk
>

I think this should probably be the final patch in the series, rather than the
first. It's generally best to set up all requirements first before enabling 
things
in the compile time configuration. Once this patch is added, there is a 
non-functional
target added for tile architecture. If it's added last, the moment the compile
time config is added it works correctly.

/Bruce



[dpdk-dev] error: value computed is not used

2014-12-08 Thread Wodkowski, PawelX
> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
> 
> I dig out that, it was ome issue of  the macros rte_memcpy()
> #define rte_memcpy(dst, src, n)  \
> ((__builtin_constant_p(n)) ?  \
> memcpy((dst), (src), (n)) :  \
> rte_memcpy_func((dst), (src), (n)))
> 
> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> know that it was incorrect, just a experiment).
> 
> But I try to use inline function instead of macros:
> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> {
> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
>  rte_memcpy_func(dst, src, n);
> }
> 
> It will pass:), and works, this could be one potential workaround fix.
> 
> Who knows why? The root cause is what?
> 
> I've no idea about this.
> 

I got the same issue while ago. I don't remember exactly everything
but my conclusion was that there was some bug in compiler. I think,
when 'n' I constant and/or small compiler is inlining memcpy and throwing
everything else (including returned value). In that case error is not
produced (I think this is a bug in compiler). In other case it is computing
some value calling memcpy or rte_ memcpy and you should at least
explicitly throw it away by casting to void. I like solution with static
inline but someone else should spoke about possible side effects.

Pawel



[dpdk-dev] [PATCH v2 2/2] mbuf: assign valid bit values for some RX and TX flags

2014-12-08 Thread Ananyev, Konstantin


> -Original Message-
> From: Zhang, Helin
> Sent: Saturday, December 06, 2014 1:08 AM
> To: Ananyev, Konstantin; dev at dpdk.org
> Cc: Cao, Waterman; Cao, Min; Wu, Jingjing; Liu, Jijiang; olivier.matz at 
> 6wind.com
> Subject: RE: [PATCH v2 2/2] mbuf: assign valid bit values for some RX and TX 
> flags
> 
> 
> 
> > -Original Message-
> > From: Zhang, Helin
> > Sent: Saturday, December 6, 2014 8:40 AM
> > To: Ananyev, Konstantin; dev at dpdk.org
> > Cc: Cao, Waterman; Cao, Min; Wu, Jingjing; Liu, Jijiang;
> > olivier.matz at 6wind.com
> > Subject: RE: [PATCH v2 2/2] mbuf: assign valid bit values for some RX and TX
> > flags
> >
> > OK. I will send out another patch according to your comments. Thanks a lot!
> >
> > Regards,
> > Helin
> >
> > > -Original Message-
> > > From: Ananyev, Konstantin
> > > Sent: Friday, December 5, 2014 6:50 PM
> > > To: Zhang, Helin; dev at dpdk.org
> > > Cc: Cao, Waterman; Cao, Min; Wu, Jingjing; Liu, Jijiang;
> > > olivier.matz at 6wind.com
> > > Subject: RE: [PATCH v2 2/2] mbuf: assign valid bit values for some RX
> > > and TX flags
> > >
> > > Hi Helin,
> > >
> > > > -Original Message-
> > > > From: Zhang, Helin
> > > > Sent: Friday, December 05, 2014 1:46 AM
> > > > To: dev at dpdk.org
> > > > Cc: Cao, Waterman; Cao, Min; Wu, Jingjing; Liu, Jijiang; Ananyev,
> > > > Konstantin; olivier.matz at 6wind.com; Zhang, Helin
> > > > Subject: [PATCH v2 2/2] mbuf: assign valid bit values for some RX
> > > > and TX flags
> > > >
> > > > Before redefining mbuf structure, there was lack of free bits in
> > > > 'ol_flags' (32 bits in total) for new RX or TX flags. So it tried to
> > > > reuse existant bits as most as possible, or even assigning 0 to some
> > > > of bit flags. After new mbuf structure defined, there are quite a
> > > > lot of free bits. So those newly added bit flags should be assigned
> > > > with correct and valid bit values, and getting their names should be
> > > > enabled as well. Note that 'RECIP' should be removed, as nowhere
> > > > will use it.
> > > >
> > > > Signed-off-by: Helin Zhang 
> > > > ---
> > > >  lib/librte_mbuf/rte_mbuf.c |  9 -
> > > > lib/librte_mbuf/rte_mbuf.h
> > > > | 19 +--
> > > >  2 files changed, 13 insertions(+), 15 deletions(-)
> > > >
> > > > v2 changes:
> > > > * Removed error flag of 'ECIPE' processing only in mbuf. All other 
> > > > error flags
> > > >   were added back.
> > > > * Assigned error flags with correct and valid values, as their previous 
> > > > values
> > > >   were invalid.
> > > > * Enabled getting all error flag names.
> > > >
> > > > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> > > > index 87c2963..3ce7c8d 100644
> > > > --- a/lib/librte_mbuf/rte_mbuf.c
> > > > +++ b/lib/librte_mbuf/rte_mbuf.c
> > > > @@ -210,11 +210,10 @@ const char *rte_get_rx_ol_flag_name(uint64_t
> > > mask)
> > > > case PKT_RX_FDIR: return "PKT_RX_FDIR";
> > > > case PKT_RX_L4_CKSUM_BAD: return "PKT_RX_L4_CKSUM_BAD";
> > > > case PKT_RX_IP_CKSUM_BAD: return "PKT_RX_IP_CKSUM_BAD";
> > > > -   /* case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD"; */
> > > > -   /* case PKT_RX_OVERSIZE: return "PKT_RX_OVERSIZE"; */
> > > > -   /* case PKT_RX_HBUF_OVERFLOW: return "PKT_RX_HBUF_OVERFLOW";
> > > */
> > > > -   /* case PKT_RX_RECIP_ERR: return "PKT_RX_RECIP_ERR"; */
> > > > -   /* case PKT_RX_MAC_ERR: return "PKT_RX_MAC_ERR"; */
> > > > +   case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD";
> > > > +   case PKT_RX_OVERSIZE: return "PKT_RX_OVERSIZE";
> > > > +   case PKT_RX_HBUF_OVERFLOW: return
> > "PKT_RX_HBUF_OVERFLOW";
> > > > +   case PKT_RX_MAC_ERR: return "PKT_RX_MAC_ERR";
> > > > case PKT_RX_IPV4_HDR: return "PKT_RX_IPV4_HDR";
> > > > case PKT_RX_IPV4_HDR_EXT: return "PKT_RX_IPV4_HDR_EXT";
> > > > case PKT_RX_IPV6_HDR: return "PKT_RX_IPV6_HDR"; diff --git
> > > > a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index
> > > > 2e5fce5..c9591c0 100644
> > > > --- a/lib/librte_mbuf/rte_mbuf.h
> > > > +++ b/lib/librte_mbuf/rte_mbuf.h
> > > > @@ -84,11 +84,6 @@ extern "C" {
> > > >  #define PKT_RX_FDIR  (1ULL << 2)  /**< RX packet with FDIR
> > > match indicate. */
> > > >  #define PKT_RX_L4_CKSUM_BAD  (1ULL << 3)  /**< L4 cksum of RX pkt.
> > > is
> > > > not OK. */  #define PKT_RX_IP_CKSUM_BAD  (1ULL << 4)  /**< IP cksum
> > > of
> > > > RX pkt. is not OK. */ -#define PKT_RX_EIP_CKSUM_BAD (0ULL << 0)
> > > > /**<
> > > External IP header checksum error. */
> > > > -#define PKT_RX_OVERSIZE  (0ULL << 0)  /**< Num of desc of an RX
> > > pkt oversize. */
> > > > -#define PKT_RX_HBUF_OVERFLOW (0ULL << 0)  /**< Header buffer
> > > overflow. */
> > > > -#define PKT_RX_RECIP_ERR (0ULL << 0)  /**< Hardware processing
> > > error. */
> > > > -#define PKT_RX_MAC_ERR   (0ULL << 0)  /**< MAC error. */
> > > >  #define PKT_RX_IPV4_HDR  (1ULL << 5)  

[dpdk-dev] [PATCH v3] mbuf: fix of enabling all newly added RX error flags

2014-12-08 Thread Ananyev, Konstantin
Hi Helin,

> -Original Message-
> From: Zhang, Helin
> Sent: Saturday, December 06, 2014 1:34 AM
> To: dev at dpdk.org
> Cc: Cao, Waterman; Cao, Min; olivier.matz at 6wind.com; Ananyev, Konstantin; 
> Zhang, Helin
> Subject: [PATCH v3] mbuf: fix of enabling all newly added RX error flags
> 
> Before redefining mbuf structure, there was lack of free bits in 'ol_flags'
> (32 bits in total) for new RX or TX flags. So it tried to reuse existant
> bits as most as possible, or even assigning 0 to some of bit flags. After
> new mbuf structure defined, there are quite a lot of free bits. So those
> newly added bit flags should be assigned with correct and valid bit values,
> and getting their names should be enabled as well. Note that 'RECIP' should
> be removed, as nowhere will use it. 'PKT_RX_ERR' is defined to replace all
> other error bit flags, e.g. MAC error, Oversize error, header buffer
> overflow error.
> 
> Signed-off-by: Helin Zhang 
> ---
>  lib/librte_mbuf/rte_mbuf.c  |  7 ++-
>  lib/librte_mbuf/rte_mbuf.h  |  7 ++-
>  lib/librte_pmd_i40e/i40e_rxtx.c | 15 ---
>  3 files changed, 8 insertions(+), 21 deletions(-)
> 
> v2 changes:
> * Removed error flag of 'ECIPE' processing only in both i40e PMD and mbuf. All
>   other error flags were added back.
> * Assigned error flags with correct and valid values, as their previous values
>   were invalid.
> * Enabled getting all error flag names.
> 
> v3 changes:
> * 'PKT_RX_ERR' is defined to replace error bit flags of MAC error, Oversize
>   error, header buffer overflow error.
> * Removed assigning values to PKT_TX_* bit flags, as it has already been done
>   in another packet set.
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> index 1b14e02..5e6b5d0 100644
> --- a/lib/librte_mbuf/rte_mbuf.c
> +++ b/lib/librte_mbuf/rte_mbuf.c
> @@ -210,11 +210,8 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
>   case PKT_RX_FDIR: return "PKT_RX_FDIR";
>   case PKT_RX_L4_CKSUM_BAD: return "PKT_RX_L4_CKSUM_BAD";
>   case PKT_RX_IP_CKSUM_BAD: return "PKT_RX_IP_CKSUM_BAD";
> - /* case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD"; */
> - /* case PKT_RX_OVERSIZE: return "PKT_RX_OVERSIZE"; */
> - /* case PKT_RX_HBUF_OVERFLOW: return "PKT_RX_HBUF_OVERFLOW"; */
> - /* case PKT_RX_RECIP_ERR: return "PKT_RX_RECIP_ERR"; */
> - /* case PKT_RX_MAC_ERR: return "PKT_RX_MAC_ERR"; */
> + case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD";
> + case PKT_RX_ERR: return "PKT_RX_ERR";
>   case PKT_RX_IPV4_HDR: return "PKT_RX_IPV4_HDR";
>   case PKT_RX_IPV4_HDR_EXT: return "PKT_RX_IPV4_HDR_EXT";
>   case PKT_RX_IPV6_HDR: return "PKT_RX_IPV6_HDR";
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index efdefc4..5e647a9 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -84,11 +84,6 @@ extern "C" {
>  #define PKT_RX_FDIR  (1ULL << 2)  /**< RX packet with FDIR match 
> indicate. */
>  #define PKT_RX_L4_CKSUM_BAD  (1ULL << 3)  /**< L4 cksum of RX pkt. is not 
> OK. */
>  #define PKT_RX_IP_CKSUM_BAD  (1ULL << 4)  /**< IP cksum of RX pkt. is not 
> OK. */
> -#define PKT_RX_EIP_CKSUM_BAD (0ULL << 0)  /**< External IP header checksum 
> error. */
> -#define PKT_RX_OVERSIZE  (0ULL << 0)  /**< Num of desc of an RX pkt 
> oversize. */
> -#define PKT_RX_HBUF_OVERFLOW (0ULL << 0)  /**< Header buffer overflow. */
> -#define PKT_RX_RECIP_ERR (0ULL << 0)  /**< Hardware processing error. */
> -#define PKT_RX_MAC_ERR   (0ULL << 0)  /**< MAC error. */
>  #define PKT_RX_IPV4_HDR  (1ULL << 5)  /**< RX packet with IPv4 header. */
>  #define PKT_RX_IPV4_HDR_EXT  (1ULL << 6)  /**< RX packet with extended IPv4 
> header. */
>  #define PKT_RX_IPV6_HDR  (1ULL << 7)  /**< RX packet with IPv6 header. */
> @@ -99,6 +94,8 @@ extern "C" {
>  #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
> header. */
>  #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. 
> */
>  #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if 
> FDIR match. */
> +#define PKT_RX_EIP_CKSUM_BAD (1ULL << 15)  /**< External IP header checksum 
> error. */
> +#define PKT_RX_ERR   (1ULL << 16)  /**< Other errors, e.g. MAC 
> error. */
>  /* add new RX flags here */
> 
>  /* add new TX flags here */
> diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
> index 2beae3c..5d99bd2 100644
> --- a/lib/librte_pmd_i40e/i40e_rxtx.c
> +++ b/lib/librte_pmd_i40e/i40e_rxtx.c
> @@ -123,25 +123,18 @@ i40e_rxd_error_to_pkt_flags(uint64_t qword)
>   return flags;
>   /* If RXE bit set, all other status bits are meaningless */
>   if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_RXE_SHIFT))) {
> - flags |= PKT_RX_MAC_ERR;
> + flags |= PKT_RX_ERR;
>   return flags;
>   }
> -
> - /* If RECIPE bit 

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

2014-12-08 Thread Qiu, Michael
On 12/8/2014 5:54 PM, Burakov, Anatoly wrote:
>> When vfio module is not loaded when kernel support vfio feature, the
>> routine still try to open the container to get file description.
>>
>> This action is not safe, and of cause got error messages:
>>
>> EAL: Detected 40 lcore(s)
>> EAL:   unsupported IOMMU type!
>> EAL: VFIO support could not be initialized
>> EAL: Setting up memory...
>>
>> This may make user confuse, this patch make it reasonable and much more
>> soomth to user.
>>
>> Signed-off-by: Michael Qiu 
>> ---
>> v3 --> v2:
>>  1. Add error log in rte_eal_check_module()
>>  2. Some code clean up.
>>
>> v2 --> v1:
>>  1. Move check_module() from rte_common.h to eal_private.h
>> and rename to rte_eal_check_module().
>> To make it linuxapp only.
>>  2. Some code clean up.
>>
>>  lib/librte_eal/common/eal_private.h| 43
>> ++
>>  lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 30 ++---
>>  2 files changed, 70 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/librte_eal/common/eal_private.h
>> b/lib/librte_eal/common/eal_private.h
>> index 232fcec..d1d8126 100644
>> --- a/lib/librte_eal/common/eal_private.h
>> +++ b/lib/librte_eal/common/eal_private.h
>> @@ -35,6 +35,9 @@
>>  #define _EAL_PRIVATE_H_
>>
>>  #include 
>> +#include 
>> +#include 
>> +#include 
>>
>>  /**
>>   * Initialize the memzone subsystem (private to eal).
>> @@ -203,4 +206,44 @@ int rte_eal_alarm_init(void);
>>   */
>>  int rte_eal_dev_init(void);
>>
>> +/**
>> + * Function is to check if the kernel module(like, vfio,
>> +vfio_iommu_type1,
>> + * etc.) loaded.
>> + *
>> + * @param module_name
>> + *  The module's name which need to be checked
>> + *
>> + * @return
>> + *  -1 means some error happens(NULL pointer or open failure)
>> + *  0  means the module not loaded
>> + *  1  means the module loaded
>> + */
>> +static inline int
>> +rte_eal_check_module(const char *module_name) {
>> +char mod_name[30]; /* Any module names can be longer than 30
>> bytes? */
>> +int ret = 0;
>> +
>> +if (NULL == module_name) {
>> +RTE_LOG(ERR, EAL, "The module name is NULL\n");
> I don't think this RTE_LOG is necessary - we never RTE_LOG invalid parameters.

OK, I will remove this.

>
>> +return -1;
>> +}
>> +FILE * fd = fopen("/proc/modules", "r");
>> +if (NULL == fd) {
>> +RTE_LOG(ERR, EAL, "Open /proc/modules failed!"
>> +" error %i (%s)\n", errno, strerror(errno));
>> +return -1;
>> +}
>> +while(!feof(fd)) {
>> +fscanf(fd, "%s %*[^\n]", mod_name);
>> +if(!strcmp(mod_name, module_name)) {
>> +ret = 1;
>> +break;
>> +}
>> +}
>> +fclose(fd);
>> +
>> +return ret;
>> +}
>> +
>>  #endif /* _EAL_PRIVATE_H_ */
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> index c1246e8..b34b3f5 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> @@ -44,6 +44,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include "eal_filesystem.h"
>>  #include "eal_pci_init.h"
>> @@ -339,10 +340,15 @@ pci_vfio_get_container_fd(void)
>>  ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION,
>> VFIO_TYPE1_IOMMU);
>>  if (ret != 1) {
>>  if (ret < 0)
>> -RTE_LOG(ERR, EAL, "  could not get IOMMU
>> type, "
>> -"error %i (%s)\n", errno,
>> strerror(errno));
>> +RTE_LOG(ERR, EAL, "  could not get IOMMU
>> type,"
>> +" error %i (%s)\n", errno,
>> +strerror(errno));
>>  else
>> -RTE_LOG(ERR, EAL, "  unsupported IOMMU
>> type!\n");
>> +/* Better to show the IOMMU type return
>> from
>> + * kernel for easy debug
>> + */
>> +RTE_LOG(ERR, EAL, "  unsupported IOMMU
>> type"
>> +" detected: %d in VFIO\n", ret);
>>  close(vfio_container_fd);
>>  return -1;
>>  }
>> @@ -783,11 +789,29 @@ pci_vfio_enable(void)  {
>>  /* initialize group list */
>>  int i;
>> +int module_vfio, module_vfio_type1;
>>
>>  for (i = 0; i < VFIO_MAX_GROUPS; i++) {
>>  vfio_cfg.vfio_groups[i].fd = -1;
>>  vfio_cfg.vfio_groups[i].group_no = -1;
>>  }
>> +
>> +module_vfio = rte_eal_check_module("vfio");
>> +module_vfio_type1 = rte_eal_check_module("vfio_iommu_type1");
> We can actually get away with checking just vfio_iommu_type1 (having it 
> loaded implies that vfio is loaded as well).

Yes, you are right. 

[dpdk-dev] lib: include rte_memory.h for __rte_cache_aligned

2014-12-08 Thread Neil Horman
On Fri, Nov 07, 2014 at 09:28:09AM -0800, Jia Yu wrote:
> Include rte_memory.h for lib files that use __rte_cache_aligned
> attribute.
> 
> Signed-off-by: Jia Yu 
> 
Why?  I presume there was a build break or something.  Please repost with a
changelog that details what this patch is for.
Neil

> ---
> lib/librte_distributor/rte_distributor.c| 1 +
>  lib/librte_eal/common/include/rte_malloc_heap.h | 1 +
>  lib/librte_ip_frag/rte_ip_frag.h| 1 +
>  lib/librte_malloc/malloc_elem.h | 2 ++
>  lib/librte_mbuf/rte_mbuf.h  | 1 +
>  lib/librte_port/rte_port_frag.c | 1 +
>  lib/librte_table/rte_table_acl.c| 1 +
>  lib/librte_table/rte_table_array.c  | 1 +
>  lib/librte_table/rte_table_hash_ext.c   | 1 +
>  lib/librte_table/rte_table_hash_key16.c | 1 +
>  lib/librte_table/rte_table_hash_key32.c | 1 +
>  lib/librte_table/rte_table_hash_key8.c  | 1 +
>  lib/librte_table/rte_table_hash_lru.c   | 1 +
>  lib/librte_table/rte_table_lpm.c| 1 +
>  lib/librte_table/rte_table_lpm_ipv6.c   | 1 +
>  15 files changed, 16 insertions(+)
> 
> diff --git a/lib/librte_distributor/rte_distributor.c 
> b/lib/librte_distributor/rte_distributor.c
> index 656ee5c..c3f7981 100644
> --- a/lib/librte_distributor/rte_distributor.c
> +++ b/lib/librte_distributor/rte_distributor.c
> @@ -35,6 +35,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/lib/librte_eal/common/include/rte_malloc_heap.h 
> b/lib/librte_eal/common/include/rte_malloc_heap.h
> index f727b7a..716216f 100644
> --- a/lib/librte_eal/common/include/rte_malloc_heap.h
> +++ b/lib/librte_eal/common/include/rte_malloc_heap.h
> @@ -37,6 +37,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /* Number of free lists per heap, grouped by size. */
>  #define RTE_HEAP_NUM_FREELISTS  5
> diff --git a/lib/librte_ip_frag/rte_ip_frag.h 
> b/lib/librte_ip_frag/rte_ip_frag.h
> index 230a903..3989a5a 100644
> --- a/lib/librte_ip_frag/rte_ip_frag.h
> +++ b/lib/librte_ip_frag/rte_ip_frag.h
> @@ -46,6 +46,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/lib/librte_malloc/malloc_elem.h b/lib/librte_malloc/malloc_elem.h
> index 1d666a5..6e8c3e8 100644
> --- a/lib/librte_malloc/malloc_elem.h
> +++ b/lib/librte_malloc/malloc_elem.h
> @@ -34,6 +34,8 @@
>  #ifndef MALLOC_ELEM_H_
>  #define MALLOC_ELEM_H_
>  
> +#include 
> +
>  /* dummy definition of struct so we can use pointers to it in malloc_elem 
> struct */
>  struct malloc_heap;
>  
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index e8f9bfc..5998db0 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -54,6 +54,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/lib/librte_port/rte_port_frag.c b/lib/librte_port/rte_port_frag.c
> index 9f1bd3c..048ae2e 100644
> --- a/lib/librte_port/rte_port_frag.c
> +++ b/lib/librte_port/rte_port_frag.c
> @@ -34,6 +34,7 @@
>  
>  #include 
>  #include 
> +#include 
>  
>  #include "rte_port_frag.h"
>  
> diff --git a/lib/librte_table/rte_table_acl.c 
> b/lib/librte_table/rte_table_acl.c
> index c6d389e..1d88201 100644
> --- a/lib/librte_table/rte_table_acl.c
> +++ b/lib/librte_table/rte_table_acl.c
> @@ -36,6 +36,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/lib/librte_table/rte_table_array.c 
> b/lib/librte_table/rte_table_array.c
> index f0f5e1e..bb1ed38 100644
> --- a/lib/librte_table/rte_table_array.c
> +++ b/lib/librte_table/rte_table_array.c
> @@ -36,6 +36,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/lib/librte_table/rte_table_hash_ext.c 
> b/lib/librte_table/rte_table_hash_ext.c
> index 6e26d98..5096be5 100644
> --- a/lib/librte_table/rte_table_hash_ext.c
> +++ b/lib/librte_table/rte_table_hash_ext.c
> @@ -36,6 +36,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/lib/librte_table/rte_table_hash_key16.c 
> b/lib/librte_table/rte_table_hash_key16.c
> index f5ec87d..6976317 100644
> --- a/lib/librte_table/rte_table_hash_key16.c
> +++ b/lib/librte_table/rte_table_hash_key16.c
> @@ -35,6 +35,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/lib/librte_table/rte_table_hash_key32.c 
> b/lib/librte_table/rte_table_hash_key32.c
> index e8f4812..5ac91c0 100644
> --- a/lib/librte_table/rte_table_hash_key32.c
> +++ b/lib/librte_table/rte_table_hash_key32.c
> @@ -35,6 +35,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/lib/librte_table/rte_table_hash_key8.c 
> b/lib/librte_table/rte_table_hash_key8.c
> index d60c96e..9216eaf 100644
> --- a/lib/librte_table/rte_table_hash_key8.c
> +++ 

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

2014-12-08 Thread Burakov, Anatoly
> When vfio module is not loaded when kernel support vfio feature, the
> routine still try to open the container to get file description.
> 
> This action is not safe, and of cause got error messages:
> 
> EAL: Detected 40 lcore(s)
> EAL:   unsupported IOMMU type!
> EAL: VFIO support could not be initialized
> EAL: Setting up memory...
> 
> This may make user confuse, this patch make it reasonable and much more
> soomth to user.
> 
> Signed-off-by: Michael Qiu 
> ---
> v3 --> v2:
>   1. Add error log in rte_eal_check_module()
>   2. Some code clean up.
> 
> v2 --> v1:
>   1. Move check_module() from rte_common.h to eal_private.h
>  and rename to rte_eal_check_module().
>  To make it linuxapp only.
>   2. Some code clean up.
> 
>  lib/librte_eal/common/eal_private.h| 43
> ++
>  lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 30 ++---
>  2 files changed, 70 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_private.h
> b/lib/librte_eal/common/eal_private.h
> index 232fcec..d1d8126 100644
> --- a/lib/librte_eal/common/eal_private.h
> +++ b/lib/librte_eal/common/eal_private.h
> @@ -35,6 +35,9 @@
>  #define _EAL_PRIVATE_H_
> 
>  #include 
> +#include 
> +#include 
> +#include 
> 
>  /**
>   * Initialize the memzone subsystem (private to eal).
> @@ -203,4 +206,44 @@ int rte_eal_alarm_init(void);
>   */
>  int rte_eal_dev_init(void);
> 
> +/**
> + * Function is to check if the kernel module(like, vfio,
> +vfio_iommu_type1,
> + * etc.) loaded.
> + *
> + * @param module_name
> + *   The module's name which need to be checked
> + *
> + * @return
> + *   -1 means some error happens(NULL pointer or open failure)
> + *   0  means the module not loaded
> + *   1  means the module loaded
> + */
> +static inline int
> +rte_eal_check_module(const char *module_name) {
> + char mod_name[30]; /* Any module names can be longer than 30
> bytes? */
> + int ret = 0;
> +
> + if (NULL == module_name) {
> + RTE_LOG(ERR, EAL, "The module name is NULL\n");

I don't think this RTE_LOG is necessary - we never RTE_LOG invalid parameters.

> + return -1;
> + }
> + FILE * fd = fopen("/proc/modules", "r");
> + if (NULL == fd) {
> + RTE_LOG(ERR, EAL, "Open /proc/modules failed!"
> + " error %i (%s)\n", errno, strerror(errno));
> + return -1;
> + }
> + while(!feof(fd)) {
> + fscanf(fd, "%s %*[^\n]", mod_name);
> + if(!strcmp(mod_name, module_name)) {
> + ret = 1;
> + break;
> + }
> + }
> + fclose(fd);
> +
> + return ret;
> +}
> +
>  #endif /* _EAL_PRIVATE_H_ */
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> index c1246e8..b34b3f5 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> @@ -44,6 +44,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #include "eal_filesystem.h"
>  #include "eal_pci_init.h"
> @@ -339,10 +340,15 @@ pci_vfio_get_container_fd(void)
>   ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION,
> VFIO_TYPE1_IOMMU);
>   if (ret != 1) {
>   if (ret < 0)
> - RTE_LOG(ERR, EAL, "  could not get IOMMU
> type, "
> - "error %i (%s)\n", errno,
> strerror(errno));
> + RTE_LOG(ERR, EAL, "  could not get IOMMU
> type,"
> + " error %i (%s)\n", errno,
> + strerror(errno));
>   else
> - RTE_LOG(ERR, EAL, "  unsupported IOMMU
> type!\n");
> + /* Better to show the IOMMU type return
> from
> +  * kernel for easy debug
> +  */
> + RTE_LOG(ERR, EAL, "  unsupported IOMMU
> type"
> + " detected: %d in VFIO\n", ret);
>   close(vfio_container_fd);
>   return -1;
>   }
> @@ -783,11 +789,29 @@ pci_vfio_enable(void)  {
>   /* initialize group list */
>   int i;
> + int module_vfio, module_vfio_type1;
> 
>   for (i = 0; i < VFIO_MAX_GROUPS; i++) {
>   vfio_cfg.vfio_groups[i].fd = -1;
>   vfio_cfg.vfio_groups[i].group_no = -1;
>   }
> +
> + module_vfio = rte_eal_check_module("vfio");
> + module_vfio_type1 = rte_eal_check_module("vfio_iommu_type1");

We can actually get away with checking just vfio_iommu_type1 (having it loaded 
implies that vfio is loaded as well).

> +
> + /* return error directly */
> + if (module_vfio == -1 || module_vfio_type1 == -1) {
> + RTE_LOG(INFO, EAL, "Could not get loaded module
> 

[dpdk-dev] [PATCH] bond: fix for mac assignment to slaves device

2014-12-08 Thread Wodkowski, PawelX
Some formatting issues during posting. I was talking about parenthesis in 
count calculation

 (sizeof(internals->slaves[0]) *
internals->slave_count - i - 1));


[dpdk-dev] [PATCH 02/15] eal/tile: add atomic operations for TileGx

2014-12-08 Thread Neil Horman
On Mon, Dec 08, 2014 at 04:59:25PM +0800, Zhigang Lu wrote:
> This patch adds architecture specific memory barrier operations for
> TileGx.
> 
> Signed-off-by: Zhigang Lu 
> Signed-off-by: Cyril Chemparathy 
> ---
>  .../common/include/arch/tile/rte_atomic.h  | 62 
> ++
>  1 file changed, 62 insertions(+)
>  create mode 100644 lib/librte_eal/common/include/arch/tile/rte_atomic.h
> 
> diff --git a/lib/librte_eal/common/include/arch/tile/rte_atomic.h 
> b/lib/librte_eal/common/include/arch/tile/rte_atomic.h
> new file mode 100644
> index 000..24c9b0a
> --- /dev/null
> +++ b/lib/librte_eal/common/include/arch/tile/rte_atomic.h
> @@ -0,0 +1,62 @@
> +/*-
> + *   BSD LICENSE
> + *
> + *   Copyright(c) 2014 Tilera 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 Tilera 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_ATOMIC_TILE_H_
> +#define _RTE_ATOMIC_TILE_H_
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include "generic/rte_atomic.h"
> +
> +static inline void rte_mb(void)
> +{
> + __sync_synchronize();
> +}
> +
> +static inline void rte_wmb(void)
> +{
> + __sync_synchronize();
> +}
> +
> +static inline void rte_rmb(void)
> +{
> + __sync_synchronize();
I don't see __sync_synchronize defined anywhere.  Is that an intrinsic for gcc,
or a library call?

Neil



[dpdk-dev] [PATCH 01/15] mk: introduce Tilera Tile architecture

2014-12-08 Thread Neil Horman
On Mon, Dec 08, 2014 at 11:09:13AM +, Bruce Richardson wrote:
> On Mon, Dec 08, 2014 at 04:59:24PM +0800, Zhigang Lu wrote:
> > Add defconfig and rte.vars.mk files for Tile architecture.
> > 
> > Signed-off-by: Zhigang Lu 
> > Signed-off-by: Cyril Chemparathy 
> > ---
> >  config/defconfig_tile-tilegx-linuxapp-gcc | 78 
> > +++
> >  mk/arch/tile/rte.vars.mk  | 59 +++
> >  mk/machine/tilegx/rte.vars.mk | 58 +++
> >  3 files changed, 195 insertions(+)
> >  create mode 100644 config/defconfig_tile-tilegx-linuxapp-gcc
> >  create mode 100644 mk/arch/tile/rte.vars.mk
> >  create mode 100644 mk/machine/tilegx/rte.vars.mk
> >
> 
> I think this should probably be the final patch in the series, rather than the
> first. It's generally best to set up all requirements first before enabling 
> things
> in the compile time configuration. Once this patch is added, there is a 
> non-functional
> target added for tile architecture. If it's added last, the moment the compile
> time config is added it works correctly.
> 
> /Bruce
> 
> 
Agreed, this should be last.  Also, just for clarity, you're posting this very
close to the 1.8 release.  I presume your intent is to add this in for the 2.0
release, correct?
Neil



[dpdk-dev] error: value computed is not used

2014-12-08 Thread Qiu, Michael
Hi all,
My platform is:

uname -a
Linux suse-11-sp3 3.0.77-0.11-xen #1 SMP Tue Mar 11 16:48:56 CST 2014
x86_64 x86_64 x86_64 GNU/Linux

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.5/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5
--enable-ssp --disable-libssp --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64
--with-system-zlib --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --program-suffix=-4.5
--enable-linux-futex --without-system-libunwind --enable-gold
--with-plugin-ld=/usr/bin/gold --with-arch-32=i586 --with-tune=generic
--build=x86_64-suse-linux
Thread model: posix
gcc version 4.5.1 20101208 [gcc-4_5-branch revision 167585] (SUSE Linux)

When I try to compile the source code to x86_64 linuxapp, I got this
error message:

lib/librte_pmd_enic/enic_main.c: In function ?enic_set_rsskey?:
lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used

I dig out that, it was ome issue of  the macros rte_memcpy()
#define rte_memcpy(dst, src, n)  \
((__builtin_constant_p(n)) ?  \
memcpy((dst), (src), (n)) :  \
rte_memcpy_func((dst), (src), (n)))

When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
know that it was incorrect, just a experiment).

But I try to use inline function instead of macros:
static inline void * rte_memcpy(void *dst, const void *src, size_t n)
{
return __builtin_constant_p(n) ? memcpy(dst, src, n) :
 rte_memcpy_func(dst, src, n);
}

It will pass:), and works, this could be one potential workaround fix.

Who knows why? The root cause is what?

I've no idea about this.

Thanks,
Michael


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

2014-12-08 Thread Qiu, Michael
On 12/5/2014 6:00 PM, Burakov, Anatoly wrote:
> Hi Michael,
>
> Few nitpicks :-) (wording of the log message I guess is up to Thomas, I won't 
> comment on that)
>
>>  lib/librte_eal/common/eal_private.h| 36
>> ++
>>  lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 24 +---
>>  2 files changed, 57 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/librte_eal/common/eal_private.h
>> b/lib/librte_eal/common/eal_private.h
>> index 232fcec..e741bdb 100644
>> --- a/lib/librte_eal/common/eal_private.h
>> +++ b/lib/librte_eal/common/eal_private.h
>> @@ -35,6 +35,7 @@
>>  #define _EAL_PRIVATE_H_
>>
>>  #include 
>> +#include 
>>
>>  /**
>>   * Initialize the memzone subsystem (private to eal).
>> @@ -203,4 +204,39 @@ int rte_eal_alarm_init(void);
>>   */
>>  int rte_eal_dev_init(void);
>>
>> +/**
>> + * Function is to check if the kernel module(like, vfio,
>> +vfio_iommu_type1,
>> + * etc.) loaded.
>> + *
>> + * @param module_name
>> + *  The module's name which need to be checked
>> + *
>> + * @return
>> + *  -1 means error happens(NULL pointer or open failure)
>> + *   0 means the module not loaded
>> + *   1 means the module loaded
>> + */
>> +static inline int
>> +rte_eal_check_module(const char *module_name) {
>> +char mod_name[30]; /* Any module names can be longer than 30
>> bytes? */
>> +int ret = 0;
>> +
>> +if (NULL == module_name)
>> +return -1;
>> +FILE * fd = fopen("/proc/modules", "r");
>> +if (fd == NULL)
>> +return -1;
> Can we add RTE_LOG statement here, with an strerror(errno) like in other 
> places? Fopen failed, we should at least know why :-)
>
>> +while(!feof(fd)) {
>> +fscanf(fd, "%s %*[^\n]", mod_name);
>> +if(!strcmp(mod_name, module_name)) {
> Probably should use strncmp instead of strcmp.

I don't think so, if we check module "vfio", but if given  module name
is "vfio_xx", it will also correct if use strncmp.

Thanks,
Michael
>
>> +ret = 1;
>> +break;
>> +}
>> +}
>> +fclose(fd);
>> +
>> +return ret;
>> +}
>> +
>>  #endif /* _EAL_PRIVATE_H_ */
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> index c1246e8..52ab2d0 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
>> @@ -44,6 +44,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include "eal_filesystem.h"
>>  #include "eal_pci_init.h"
>> @@ -339,10 +340,13 @@ pci_vfio_get_container_fd(void)
>>  ret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION,
>> VFIO_TYPE1_IOMMU);
>>  if (ret != 1) {
>>  if (ret < 0)
>> -RTE_LOG(ERR, EAL, "  could not get IOMMU
>> type, "
>> -"error %i (%s)\n", errno,
>> strerror(errno));
>> +RTE_LOG(ERR, EAL, "  could not get IOMMU
>> type,"
>> +" error %i (%s)\n", errno,
>> +strerror(errno));
>>  else
>> -RTE_LOG(ERR, EAL, "  unsupported IOMMU
>> type!\n");
>> +RTE_LOG(ERR, EAL, "  unsupported IOMMU
>> type! "
>> +"expect: VFIO_TYPE1_IOMMU, "
>> +"actual: %d\n", ret);
> I'm not even sure we need this "expected" bit at all. We don't get back the 
> IOMMU type VFIO currently supports; rather, this code checks if VFIO's 
> support for VFIO_TYPE1_IOMMU is enabled or not. So I would change the error 
> message to something more descriptive, such as " required IOMMU type support 
> not present in VFIO!\n", and get rid of the "expected".
>
>>  close(vfio_container_fd);
>>  return -1;
>>  }
>> @@ -788,6 +792,20 @@ pci_vfio_enable(void)
>>  vfio_cfg.vfio_groups[i].fd = -1;
>>  vfio_cfg.vfio_groups[i].group_no = -1;
>>  }
>> +
>> +/* return error directly */
>> +if (rte_eal_check_module("vfio") == -1 ||
>> +rte_eal_check_module("vfio_iommu_type1") == -1)
>> +return -1;
>> +
>> +/* return 0 if not all VFIO modules loaded */
>> +if (rte_eal_check_module("vfio") == 0 ||
>> +rte_eal_check_module("vfio_iommu_type1") == 0) {
>> +RTE_LOG(INFO, EAL, "VFIO modules not all loaded,"
>> +" skip VFIO support ...\n");
>> +return 0;
>> +}
> Can we perhaps make one call per module instead of two? i.e. something like:
>
> int vfio_ret, vfio_ type1_ret;
> vfio_ret = rte_eal_check_module("vfio");
> vfio_type1_ret = rte_eal_check_module("vfio_iommu_type1");
>
> if (vfio_ret == -1 || vfio_type1_ret == -1)
> return -1;
> else if (vfio_ret == 0 || vfio_type1_ret == 0) {
>  
> return 0;

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

2014-12-08 Thread Qiu, Michael
On 12/8/2014 11:39 AM, Qiu, Michael wrote:
> On 12/8/2014 11:00 AM, Neil Horman wrote:
>> On Mon, Dec 08, 2014 at 02:46:51AM +, Qiu, Michael wrote:
>>> On 12/5/2014 11:25 PM, Neil Horman wrote:
 On Fri, Dec 05, 2014 at 03:02:33PM +, Bruce Richardson wrote:
> On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
>> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
>>> On 2014/12/4 17:12, Michael Qiu wrote:
 lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
 is always false due to limited range of data type [-Werror=type-limits]
 || (hugepage_sz == RTE_PGSIZE_16G)) {
 ^
 cc1: all warnings being treated as errors

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

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

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

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

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

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

>> NACK, this is the wrong way to fix this problem.  Pagesizes are 
>> independent of
>> architecutre.  While a system can't have a hugepage size that exceeds its
>> virtual address limit, theres no need to do per-architecture special 
>> casing of
>> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
>> everytime you want to check a page size, just convert the size_t to a 
>> uint64_t
>> and you can allow all of the enumerated page types on all architecutres, 
>> and
>> save yourself some ifdeffing in the process.
>>
>> Neil
> While I get your point, I find it distasteful to use a uint64_t for 
> memory sizes,
> when there is the size_t type defined for that particular purpose.
> However, I suppose that reducing the number of #ifdefs compared to using 
> the
> "correct" datatypes for objects is a more practical optino - however 
> distastful
> I find it.
 size_t isn't defined for memory sizes in the sense that we're using them 
 here.
 size_t is meant to address the need for a type to describe object sizes on 
 a
 particular system, and it itself is sized accordingly (32 bits on a 32 bit 
 arch,
 64 on 64), so that you can safely store a size that the system in question 
 might
 maximally allocate/return.  In this situation we are describing memory 
 sizes
 that might occur no a plurality of arches, and so size_t is inappropriate
 because it as a type is not sized for anything other than the arch it is 
 being
 built for.  The pragmatic benefits of ennumerating page sizes in a single
 canonical location far outweigh the desire to use a misappropriated type to
 describe them.
>>> Neil,
>>>
>>> This patch fix two compile issues, and we need to do *dpdk testing
>>> affairs*,  if it is blocked in build stage, we can do *nothing* for testing.
>>>
>>> I've get you mind and your concern. But we should take care of changing
>>> the type of "hugepage_sz", because lots of places using it.
>>>
>>> Would you mind if we consider this as hot fix, and we can post a better
>>> fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.
>>>
>> Honestly, no.  Because intels testing schedule shouldn't drive the inclusion 
>> of
>> upstream fixes.  Also, I'm not asking for a major redesign of anything, I'm
>> asking for a proper fix for a very straightforward problem.  I've attached 
>> the
>> proper fix below.
>>
>> Regards
>> Neil
> We test dpdk upstream now as 1,8 rc2 and rc3 released :)
>
> I know that what you mean. but lots of please using "hugepage_sz" do you

Sorry, please/places
> confirm it will not affect other issue?
>
> On other hand, we use 32 bit address in 32 bit platform for better
> performance(some of places also use uintptr_t for address check and
> alignment).
>
> And it should not acceptable in 32 bit platform to use 64-bit platform
> specification affairs(like RTE_PGSIZE_16G).
>
> Thanks,
> Michael
>
>>
>> diff --git a/lib/librte_eal/common/eal_common_memory.c 
>> b/lib/librte_eal/common/eal_common_memory.c
>> index 412b432..31a391c 100644
>> --- a/lib/librte_eal/common/eal_common_memory.c
>> +++ b/lib/librte_eal/common/eal_common_memory.c
>> @@ -96,7 +96,7 @@ rte_dump_physmem_layout(FILE *f)
>>  

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

2014-12-08 Thread Qiu, Michael
On 12/8/2014 11:00 AM, Neil Horman wrote:
> On Mon, Dec 08, 2014 at 02:46:51AM +, Qiu, Michael wrote:
>> On 12/5/2014 11:25 PM, Neil Horman wrote:
>>> On Fri, Dec 05, 2014 at 03:02:33PM +, Bruce Richardson wrote:
 On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
>> On 2014/12/4 17:12, Michael Qiu wrote:
>>> lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
>>> is always false due to limited range of data type [-Werror=type-limits]
>>> || (hugepage_sz == RTE_PGSIZE_16G)) {
>>> ^
>>> cc1: all warnings being treated as errors
>>>
>>> lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
>>> conversion from "long long" to "void *" may lose significant bits
>>>RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);
>>>
>>> This was introuduced by commit b77b5639:
>>> mem: add huge page sizes for IBM Power
>>>
>>> The root cause is that size_t and uintptr_t are 32-bit in i686
>>> platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.
>>>
>>> Define RTE_PGSIZE_16G only in 64 bit platform to avoid
>>> this issue.
>>>
>>> Signed-off-by: Michael Qiu 
>>> ---
>>>  v3 ---> v2
>>> Change RTE_PGSIZE_16G from ULL to UL
>>> to keep all entries consistent
>>>
>>>  V2 ---> v1
>>> Change two type entries to one, and
>>> leave RTE_PGSIZE_16G only valid for
>>> 64-bit platform
>>>
> NACK, this is the wrong way to fix this problem.  Pagesizes are 
> independent of
> architecutre.  While a system can't have a hugepage size that exceeds its
> virtual address limit, theres no need to do per-architecture special 
> casing of
> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
> everytime you want to check a page size, just convert the size_t to a 
> uint64_t
> and you can allow all of the enumerated page types on all architecutres, 
> and
> save yourself some ifdeffing in the process.
>
> Neil
 While I get your point, I find it distasteful to use a uint64_t for memory 
 sizes,
 when there is the size_t type defined for that particular purpose.
 However, I suppose that reducing the number of #ifdefs compared to using 
 the
 "correct" datatypes for objects is a more practical optino - however 
 distastful
 I find it.
>>> size_t isn't defined for memory sizes in the sense that we're using them 
>>> here.
>>> size_t is meant to address the need for a type to describe object sizes on a
>>> particular system, and it itself is sized accordingly (32 bits on a 32 bit 
>>> arch,
>>> 64 on 64), so that you can safely store a size that the system in question 
>>> might
>>> maximally allocate/return.  In this situation we are describing memory sizes
>>> that might occur no a plurality of arches, and so size_t is inappropriate
>>> because it as a type is not sized for anything other than the arch it is 
>>> being
>>> built for.  The pragmatic benefits of ennumerating page sizes in a single
>>> canonical location far outweigh the desire to use a misappropriated type to
>>> describe them.
>> Neil,
>>
>> This patch fix two compile issues, and we need to do *dpdk testing
>> affairs*,  if it is blocked in build stage, we can do *nothing* for testing.
>>
>> I've get you mind and your concern. But we should take care of changing
>> the type of "hugepage_sz", because lots of places using it.
>>
>> Would you mind if we consider this as hot fix, and we can post a better
>> fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.
>>
> Honestly, no.  Because intels testing schedule shouldn't drive the inclusion 
> of
> upstream fixes.  Also, I'm not asking for a major redesign of anything, I'm
> asking for a proper fix for a very straightforward problem.  I've attached the
> proper fix below.
>
> Regards
> Neil

We test dpdk upstream now as 1,8 rc2 and rc3 released :)

I know that what you mean. but lots of please using "hugepage_sz" do you
confirm it will not affect other issue?

On other hand, we use 32 bit address in 32 bit platform for better
performance(some of places also use uintptr_t for address check and
alignment).

And it should not acceptable in 32 bit platform to use 64-bit platform
specification affairs(like RTE_PGSIZE_16G).

Thanks,
Michael

>
>
> diff --git a/lib/librte_eal/common/eal_common_memory.c 
> b/lib/librte_eal/common/eal_common_memory.c
> index 412b432..31a391c 100644
> --- a/lib/librte_eal/common/eal_common_memory.c
> +++ b/lib/librte_eal/common/eal_common_memory.c
> @@ -96,7 +96,7 @@ rte_dump_physmem_layout(FILE *f)
>  
>   fprintf(f, "Segment %u: phys:0x%"PRIx64", len:%zu, "
>  "virt:%p, socket_id:%"PRId32", "
> -"hugepage_sz:%zu, nchannel:%"PRIx32", "
> +   

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

2014-12-08 Thread Qiu, Michael
On 12/5/2014 11:25 PM, Neil Horman wrote:
> On Fri, Dec 05, 2014 at 03:02:33PM +, Bruce Richardson wrote:
>> On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
>>> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
 On 2014/12/4 17:12, Michael Qiu wrote:
> lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
> is always false due to limited range of data type [-Werror=type-limits]
> || (hugepage_sz == RTE_PGSIZE_16G)) {
> ^
> cc1: all warnings being treated as errors
>
> lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
> conversion from "long long" to "void *" may lose significant bits
>RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);
>
> This was introuduced by commit b77b5639:
> mem: add huge page sizes for IBM Power
>
> The root cause is that size_t and uintptr_t are 32-bit in i686
> platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.
>
> Define RTE_PGSIZE_16G only in 64 bit platform to avoid
> this issue.
>
> Signed-off-by: Michael Qiu 
> ---
>  v3 ---> v2
>   Change RTE_PGSIZE_16G from ULL to UL
>   to keep all entries consistent
>
>  V2 ---> v1
>   Change two type entries to one, and
>   leave RTE_PGSIZE_16G only valid for
>   64-bit platform
>
>>> NACK, this is the wrong way to fix this problem.  Pagesizes are independent 
>>> of
>>> architecutre.  While a system can't have a hugepage size that exceeds its
>>> virtual address limit, theres no need to do per-architecture special casing 
>>> of
>>> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
>>> everytime you want to check a page size, just convert the size_t to a 
>>> uint64_t
>>> and you can allow all of the enumerated page types on all architecutres, and
>>> save yourself some ifdeffing in the process.
>>>
>>> Neil
>> While I get your point, I find it distasteful to use a uint64_t for memory 
>> sizes,
>> when there is the size_t type defined for that particular purpose.
>> However, I suppose that reducing the number of #ifdefs compared to using the
>> "correct" datatypes for objects is a more practical optino - however 
>> distastful
>> I find it.
> size_t isn't defined for memory sizes in the sense that we're using them here.
> size_t is meant to address the need for a type to describe object sizes on a
> particular system, and it itself is sized accordingly (32 bits on a 32 bit 
> arch,
> 64 on 64), so that you can safely store a size that the system in question 
> might
> maximally allocate/return.  In this situation we are describing memory sizes
> that might occur no a plurality of arches, and so size_t is inappropriate
> because it as a type is not sized for anything other than the arch it is being
> built for.  The pragmatic benefits of ennumerating page sizes in a single
> canonical location far outweigh the desire to use a misappropriated type to
> describe them.

Neil,

This patch fix two compile issues, and we need to do *dpdk testing
affairs*,  if it is blocked in build stage, we can do *nothing* for testing.

I've get you mind and your concern. But we should take care of changing
the type of "hugepage_sz", because lots of places using it.

Would you mind if we consider this as hot fix, and we can post a better
fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.

Thanks,
Michael
> Neil
>
>



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

2014-12-08 Thread Qiu, Michael
On 12/4/2014 9:35 PM, Michael Qiu wrote:
> app/test-pmd/csumonly.c: In function ?get_psd_sum?:
> build/include/rte_ip.h:161: error: dereferencing pointer ?u16?
> does break strict-aliasing rules
> build/include/rte_ip.h:157: note: initialized from here
> ...
>
> The root cause is that, compile enable strict aliasing by default,
> while in function rte_raw_cksum() try to convert 'const char *'
> to 'const uint16_t *'.
>
> This patch is one workaround fix.
>
> Signed-off-by: Michael Qiu 
> ---
> v3 --> v2:
>   use uintptr_t instead of unsigned long to
>   save pointer.
>
> v2 --> v1:
>   Workaround solution instead of shut off the
>   gcc params.
>
>  lib/librte_net/rte_ip.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
> index 61e4457..cda3436 100644
> --- a/lib/librte_net/rte_ip.h
> +++ b/lib/librte_net/rte_ip.h
> @@ -154,7 +154,8 @@ struct ipv4_hdr {
>  static inline uint16_t
>  rte_raw_cksum(const char *buf, size_t len)
>  {
> - const uint16_t *u16 = (const uint16_t *)buf;
> + uintptr_t ptr = (uintptr_t)buf;
> + const uint16_t *u16 = (const uint16_t *)ptr;
>   uint32_t sum = 0;
>  
>   while (len >= (sizeof(*u16) * 4)) {
This workaround is to solve the compile issue of GCC strict-aliasing(Two
different type pointers should not be point to the same memory address).

For GCC 4.4.7 it will definitely occurs if  flags "-fstrict-aliasing"
and "-Wall" used.

Thanks,
Michael


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

2014-12-08 Thread Qiu, Michael
On 12/5/2014 5:26 PM, Thomas Monjalon wrote:
> 2014-12-05 05:34, Qiu, Michael:
>> Any comments about this version? a new workaround solution :)
> Yes, one comment: I think it's ugly :)
> These aliasing errors are not reliable so I think we can disable it (like
> Linux does).
> But in case you don't want to disable the warning, please add a comment to 
> your
> workaround to explain it is caused by GCC strict-aliasing check.

Yes, really ugly 

But lots of reviewer voted against with disable it as my first version
is disable.

I could not think out a better solution for all reviewers can accept.

I will add the comment with the thread of v3 patch.

Thanks,
Michael

>>> -   const uint16_t *u16 = (const uint16_t *)buf;
>>> +   uintptr_t ptr = (uintptr_t)buf;
>>> +   const uint16_t *u16 = (const uint16_t *)ptr;

> Thanks