[dpdk-dev] [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs

2015-05-29 Thread Liang-Min Larry Wang
adding a new library based upon ethdev APIs to provide API's that bear
the same functionality as ethtool_ops (linux/ethtool.h) and net_device_ops
(linux/netdevice.h).

Signed-off-by: Liang-Min Larry Wang 
---
 MAINTAINERS|   4 +
 config/common_linuxapp |   5 +
 lib/Makefile   |   1 +
 lib/librte_ethtool/Makefile|  56 +++
 lib/librte_ethtool/rte_ethtool.c   | 155 +
 lib/librte_ethtool/rte_ethtool.h   | 257 +
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk  |   1 +
 8 files changed, 497 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index 9362c19..b8b481f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -186,6 +186,10 @@ M: Thomas Monjalon 
 F: lib/librte_ether/
 F: scripts/test-null.sh

+Ethtool API
+M: Liang-Min Larry Wang 
+F: lib/librte_ethtool/
+

 Drivers
 ---
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0078dc9..f5759fd 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -129,6 +129,11 @@ CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
 CONFIG_RTE_LIBRTE_KVARGS=y

 #
+# Compile user-space ethtool library
+#
+CONFIG_RTE_LIBRTE_ETHTOOL=y
+
+#
 # Compile generic ethernet library
 #
 CONFIG_RTE_LIBRTE_ETHER=y
diff --git a/lib/Makefile b/lib/Makefile
index 5f480f9..a6c7375 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TIMER) += librte_timer
 DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile
 DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
+DIRS-$(CONFIG_RTE_LIBRTE_ETHTOOL) += librte_ethtool
 DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += librte_vhost
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
diff --git a/lib/librte_ethtool/Makefile b/lib/librte_ethtool/Makefile
new file mode 100644
index 000..1d981f6
--- /dev/null
+++ b/lib/librte_ethtool/Makefile
@@ -0,0 +1,56 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ethtool.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+EXPORT_MAP := rte_ethtool_version.map
+
+LIBABIVER := 1
+
+SRCS-y += rte_ethtool.c
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_ethtool.h
+
+# this lib depends upon:
+DEPDIRS-y += lib/librte_ether
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_ethtool/rte_ethtool.c b/lib/librte_ethtool/rte_ethtool.c
new file mode 100644
index 000..2ccf06f
--- /dev/null
+++ b/lib/librte_ethtool/rte_ethtool.c
@@ -0,0 +1,155 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.

[dpdk-dev] [PATCH 1/2] ethdev: add api to set default mac address

2015-05-29 Thread Liang-Min Larry Wang
add a new api: rte_eth_dev_default_mac_addr_set to
support changing default mac address of a NIC

Signed-off-by: Liang-Min Larry Wang 
---
 lib/librte_ether/rte_ethdev.c  | 18 ++
 lib/librte_ether/rte_ethdev.h  | 14 ++
 lib/librte_ether/rte_ether_version.map |  1 +
 3 files changed, 33 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 024fe8b..85ce72e 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2752,6 +2752,24 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct 
ether_addr *addr)
 }

 int
+rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
+{
+   struct rte_eth_dev *dev;
+
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   dev = _eth_devices[port_id];
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
+
+   (*dev->dev_ops->mac_addr_set)(dev, addr);
+
+   return 0;
+}
+
+int
 rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
uint16_t rx_mode, uint8_t on)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 16dbe00..5f07e0d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2982,6 +2982,20 @@ int rte_eth_dev_mac_addr_add(uint8_t port, struct 
ether_addr *mac_addr,
 int rte_eth_dev_mac_addr_remove(uint8_t port, struct ether_addr *mac_addr);

 /**
+ * Set the default MAC address.
+ *
+ * @param port
+ *   The port identifier of the Ethernet device.
+ * @param mac_addr
+ *   New default MAC address.
+ * @return
+ *   - (0) if successful, or *mac_addr* didn't exist.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port* invalid.
+ */
+int rte_eth_dev_default_mac_addr_set(uint8_t port, struct ether_addr 
*mac_addr);
+
+/**
  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
  *
  * @param port
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index a2d25a6..2dbbaa7 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -102,6 +102,7 @@ DPDK_2.0 {
rte_eth_tx_queue_setup;
rte_eth_xstats_get;
rte_eth_xstats_reset;
+   rte_eth_dev_default_mac_addr_set;

local: *;
 };
-- 
2.1.4



[dpdk-dev] [PATCH 0/2] User-space Ethtool

2015-05-29 Thread Liang-Min Larry Wang
This implementation is designed to provide a familar interface for applications 
that rely on kernel-space driver to support ethtool_op and net_device_op for 
device management. The initial implementation focuses on ops that can be 
implemented through existing netdev APIs. More ops will be supported in latter 
release.
ethtool: adding new ethtool api support

v3 change:
- Fix a build issue
v2 change:
- Implement rte_eth_dev_default_mac_addr_set through dev_ops::mac_addr_set so 
it would support NIC devices other than ixgbe and igb

Liang-Min Larry Wang (2):
  ethdev: add api to set default mac address
  ethtool: add new library to provide ethtool-alike APIs

 MAINTAINERS|   4 +
 config/common_linuxapp |   5 +
 lib/Makefile   |   1 +
 lib/librte_ether/rte_ethdev.c  |  18 ++
 lib/librte_ether/rte_ethdev.h  |  14 ++
 lib/librte_ether/rte_ether_version.map |   1 +
 lib/librte_ethtool/Makefile|  56 +++
 lib/librte_ethtool/rte_ethtool.c   | 155 +
 lib/librte_ethtool/rte_ethtool.h   | 257 +
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk  |   1 +
 11 files changed, 530 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

-- 
2.1.4



[dpdk-dev] [PATCH v2 1/2] Added ETH_SPEED_CAP bitmap in rte_eth_dev_info

2015-05-29 Thread Thomas Monjalon
2015-05-27 11:15, Marc Sune:
> On 27/05/15 06:02, Thomas Monjalon wrote:
> > Why not starting with lower values? Some new drivers may be interested
> > by lower speed.
> 
> Ok, but which values? 1Mbps FD/HD? Even lower than that?
> 
> If you have some NIC(s) in mind with lower values, please point me to 
> that and I will collect the missing speeds.

No sorry, I missed how low your first values were.

> >> +#define ETH_SPEED_CAP_10M_HD  (1 << 0)  /*< 10 Mbps half-duplex> */
> >> +#define ETH_SPEED_CAP_10M_FD  (1 << 1)  /*< 10 Mbps full-duplex> */
> >> +#define ETH_SPEED_CAP_100M_HD (1 << 2)  /*< 100 Mbps half-duplex> */
> >> +#define ETH_SPEED_CAP_100M_FD (1 << 3)  /*< 100 Mbps full-duplex> */
> >> +#define ETH_SPEED_CAP_1G  (1 << 4)  /*< 1 Gbps > */
> >> +#define ETH_SPEED_CAP_2_5G(1 << 5)  /*< 2.5 Gbps > */
> >> +#define ETH_SPEED_CAP_5G  (1 << 6)  /*< 5 Gbps > */
> >> +#define ETH_SPEED_CAP_10G (1 << 7)  /*< 10 Mbps > */
> >> +#define ETH_SPEED_CAP_20G (1 << 8)  /*< 20 Gbps > */
> >> +#define ETH_SPEED_CAP_25G (1 << 9)  /*< 25 Gbps > */
> >> +#define ETH_SPEED_CAP_40G (1 << 10)  /*< 40 Gbps > */
> >> +#define ETH_SPEED_CAP_50G (1 << 11)  /*< 50 Gbps > */
> >> +#define ETH_SPEED_CAP_56G (1 << 12)  /*< 56 Gbps > */
> >> +#define ETH_SPEED_CAP_100G(1 << 13)  /*< 100 Gbps > */
> > We should note that rte_eth_link is using ETH_LINK_SPEED_* constants
> > which are not some bitmaps so we have to create these new constants.
> 
> Yes, I can add that to the patch description (1/2).
> 
> > Furthermore, rte_eth_link.link_speed is an uint16_t so it is limited
> > to 40G. Should we use some constant bitmaps here also?
> 
> I also thought about converting link_speed into a bitmap to unify the 
> constants before starting the patch (there is redundancy), but I wanted 
> to be minimally invasive; changing link to a bitmap can break existing apps.
> 
> I can also merge them if we think is a better idea.

Maybe. Someone against this idea?

> > What about removing _CAP suffix from your constants?
> 
> I added the suffix to make clearer the distinction with link speeds. I 
> can remove it if we merge both or if we consider it is not necessary.
> 
> >
> > [...]
> >> +  uint32_t speed_capa;  /**< Supported speeds bitmap (ETH_SPEED_CAP_). */
> > If the constants are ETH_SPEED_CAP, why not wording this variable speed_cap?
> 
> I followed the convention of the existing rx/tx offload capability bitmaps:
> 
> marc at dev:~/git/bisdn/msune/xdpd/libs/dpdk/lib$ grep _capa\; * -R
> librte_ether/rte_ethdev.h:uint32_t rx_offload_capa; /**< Device RX 
> offload capabilities. */
> librte_ether/rte_ethdev.h:uint32_t tx_offload_capa; /**< Device TX 
> offload capabilities. */
> 
> I am fine with speed_cap or speed_caps, but I think we should have some 
> consistency on how we name bitmaps.

You're right.

> If we would want to make the bitmaps more explicit, we could define some 
> helper typedefs in EAL:
> 
> typedef uint16_t bitmap16_t;
> typedef uint32_t bitmap32_t;
> typedef uint64_t bitmap64_t;
> 
> and replace the bitmaps of the structs, again specially the ones used by 
> the users.

No, if we want to show this variable is a bitmap, the variable name
may be changed, not the type. It would bring clarity when reading code
using this variable but I think it's not really needed.



[dpdk-dev] [PATCH] i40e:fix an issue in i40e_dev_info_get

2015-05-29 Thread Thomas Monjalon
> > To get device VMDQ info when only i40e VMDQ feature is enabled.
> > 
> > Signed-off-by: Jijiang Liu 
> Acked-by: Helin Zhang 

Applied, thanks


[dpdk-dev] [PATCH v2] Mem: Fixes small memory leak due to missing free.

2015-05-29 Thread Thomas Monjalon
2015-05-19 17:04, Erik Ziegenbalg:
> From: eziegenb 
> 
> A function in cmdline.c has a return that does not free buf properly.
> 
> Signed-off-by: Erik Ziegenbalg 

You forgot to add a changelog and the previous acked-by:
Acked-by: Stephen Hemminger 
Acked-by: John McNamara 

> - if (ret < 0)
> + if (ret < 0){

checkpatch complains about a missing space.

Applied with the above fix, thanks



[dpdk-dev] [PATCH 0/2] Add missing includes to headers

2015-05-29 Thread Thomas Monjalon
2015-05-25 13:23, Bruce Richardson:
> The convention in DPDK is that each header file should include 
> any other headers on which it depends. This patch set adds in 
> some missing header dependencies.
> 
> Bruce Richardson (2):
>   eal: add missing include  to rte_pci.h
>   kni: add missing include dependencies

Applied, thanks


[dpdk-dev] [PATCH 1/2] ethdev: add api to set default mac address

2015-05-29 Thread Wang, Liang-min

>On Fri, 29 May 2015 09:15:08 -0400
>Liang-Min Larry Wang  wrote:
>
>>  }
> > 
>>  int
>> +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr 
>> +*addr) {
>> +struct rte_eth_dev *dev;
>> +const int index = 0;
>> +const uint32_t pool = 0;
>> +
>> +if (!rte_eth_dev_is_valid_port(port_id)) {
>> +PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
>> +return -ENODEV;
>> +}
>> +
>> +dev = _eth_devices[port_id];
>> +FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
>> +FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
>> +
>> +/* Update NIC default MAC address*/
>> +(*dev->dev_ops->mac_addr_remove)(dev, index);
>> +(*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
>> +
>> +/* Update default address in NIC data structure */
>> +ether_addr_copy(addr, >data->mac_addrs[index]);
>> +
>> +return 0;
>> +}
>> +
>
>No. this won't work. for some devices.
>
>Please use mac_addr_set hook added in recent DPDK

I tested over ixgbe and igb, and both work. As for your concern, it's legit. I 
will take your suggestion and make modification.


[dpdk-dev] [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs

2015-05-29 Thread Wang, Liang-min

>On Fri, 29 May 2015 09:15:09 -0400
>Liang-Min Larry Wang  wrote:
>
>> +drvinfo->n_stats = sizeof(struct rte_eth_stats) / sizeof(uint64_t);
> >+drvinfo->testinfo_len = 0;
>
>
>Providing a hook to access more functionality is good and compatiablity with 
>old API's is helpful.  Too bad ethtool is kind of a clunky old inflexible, and 
>easily broken with changes. But >that is not your fault.
>
>Duplicating eth_stats in ethtool is not helpful.
>This is actively discouraged for Linux device drivers.

(I have a typo of David's email, and I corrected it in this email)
This new library is designed to support ethtool alike interface, some of the 
implementation will be just a placeholder. The rte_ethtool_net_get_stats64 is 
designed as a place holder to support net_device_ops::ndo_get_stats64. For the 
legacy support, it is required to provide # of statistic parameters are 
supported, so caller can allocate right size of buffer to get statistic from 
device driver.


[dpdk-dev] [PATCH v2] app/testpmd: compute checksum in icmpecho replies

2015-05-29 Thread Thomas Monjalon
2015-05-25 13:40, Olivier MATZ:
> On 05/22/2015 07:03 PM, Adrien Mazarguil wrote:
> > ICMP echo replies with invalid checksums may be dropped by network nodes or
> > ignored by the ping utility.
> > 
> > Signed-off-by: Adrien Mazarguil 
> > Acked-by: Ivan Boule 
> 
> Acked-by: Olivier Matz 

Applied, thanks


[dpdk-dev] [PATCH 1/2] app/testpmd: use correct hardware address in ARP replies

2015-05-29 Thread Thomas Monjalon
2015-05-22 13:07, Adrien Mazarguil:
> In the icmpecho forwarding mode, ARP replies from testpmd contain
> invalid zero-filled MAC addresses. This is broken since the commit below.
> 
> Fixes: 31db4d38de72 ("net: change arp header struct declaration")
> 
> Signed-off-by: Adrien Mazarguil 
> Acked-by: Ivan Boule 

Applied, thanks


[dpdk-dev] Free up completed TX buffers

2015-05-29 Thread Zoltan Kiss
Hi,

I've came across an another problem while sorting out the one fixed by 
my patch "ixgbe: fix checking for tx_free_thresh". Even when the 
threshold check is correct it can happen that the application run out of 
free buffers, and the only solution would be to get back the ones from 
the TX rings. But if their number is still less than tx_free_thresh (per 
queue), currently there is no interface to achieve that.
The bad way is to set tx_free_thresh to 1, but it has a very bad 
performance penalty. The easy way is just to increase your buffer pool's 
size to make sure that doesn't happen. But there is no bulletproof way 
to calculate such a number, and based on my experience it's hard to 
debug if it causes problem.
I'm thinking about a foolproof way, which is exposing functions like 
ixgbe_tx_free_bufs from the PMDs, so the application can call it as a 
last resort to avoid deadlock. Instead it causes probably worse 
performance, but at least fools like me will easily see that from e.g. 
oprofile.
How does that sound? Or is there a better way to solve this problem?

Regards,

Zoli


[dpdk-dev] [PATCHv3] mempool: fix pages computation to determine number of objects

2015-05-29 Thread Thomas Monjalon
2015-05-27 09:40, Konstantin Ananyev:
> v3:
> - Fixed typo in the commit message.
> 
> v2:
> - As suggested in comments use slightly different approach for the fix.
> 
> In rte_mempool_obj_iter(), when element boundary coincides with page boundary,
> even if a single page is required per object, a loop checks that the next page
> is contiguous and drops the first one otherwise.
> This commit checks subsequent pages only when several are required per object.
> 
> Signed-off-by: Konstantin Ananyev 

Applied, thanks


[dpdk-dev] [PATCH 1/2] mempool: fix returned value on 64 bit after counting objects

2015-05-29 Thread Thomas Monjalon
2015-05-27 00:43, Ananyev, Konstantin:
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Adrien Mazarguil
> > rte_mempool_xmem_usage()'s return type is ssize_t which has the same
> > architecture-dependent width as size_t but is signed.
> > 
> > On 64-bit architectures, returning a negative uint32_t value without casting
> > to ssize_t first does not work as intended, the sign bit is lost and the
> > returned value is garbage.
> > 
> > This commit fixes an assertion failure in testpmd on 64 bit architectures
> > when combining --no-huge and --mp-anon outside of Xen Dom0:
> > 
> >  PANIC in mempool_anon_create():
> >  line 170assert "elt_num == mp->size" failed
> > 
> > Fixes: 148f963fb532 ("xen: core library changes")
> > 
> > Signed-off-by: Adrien Mazarguil 
> 
> Acked-by: Konstantin Ananyev 

Applied, thanks


[dpdk-dev] [PATCH 11/11] ip_pipeline: added new implementation of flow classification pipeline

2015-05-29 Thread Maciej Gajdzica
Flow classification pipeline implementation is split to two files.
pipeline_flow_classification.c file handles front-end functions (cli
commands parsing) pipeline_flow_classification_ops.c contains
implementation of functions done by pipeline (back-end).

Signed-off-by: Maciej Gajdzica 
---
 examples/ip_pipeline/Makefile  |3 +-
 examples/ip_pipeline/init.c|2 +
 .../pipeline/pipeline_flow_classification.c| 1761 +---
 .../pipeline/pipeline_flow_classification.h|   41 +
 .../pipeline/pipeline_flow_classification_ops.c|  559 +++
 .../pipeline/pipeline_flow_classification_ops.h|  150 ++
 6 files changed, 2292 insertions(+), 224 deletions(-)
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification.h
 create mode 100644 
examples/ip_pipeline/pipeline/pipeline_flow_classification_ops.c
 create mode 100644 
examples/ip_pipeline/pipeline/pipeline_flow_classification_ops.h

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index f8c7c5f..4a1d970 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -65,7 +65,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall_ops.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing_ops.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing.c
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_flow_classification.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_flow_classification.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_flow_classification_ops.c

 CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/pipeline
 CFLAGS += -O3
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index 29caae8..a8d2f67 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -47,6 +47,7 @@
 #include "pipeline_passthrough.h"
 #include "pipeline_firewall.h"
 #include "pipeline_routing.h"
+#include "pipeline_flow_classification.h"

 #define APP_NAME_SIZE  32

@@ -1150,6 +1151,7 @@ int app_init(struct app_params *app)
app_pipeline_type_register(app, _passthrough);
app_pipeline_type_register(app, _firewall);
app_pipeline_type_register(app, _routing);
+   app_pipeline_type_register(app, _flow_classification);

app_init_pipelines(app);
app_init_threads(app);
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c 
b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
index cc0cbf1..928e2ab 100644
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
+++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -32,275 +32,1590 @@
  */

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

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

-#include 
-#include 
-#include 
+#include "app.h"
+#include "pipeline_flow_classification_ops.h"
+#include "pipeline_flow_classification.h"
+#include "pipeline_common.h"

-#include "main.h"
+#define MSG_TIMEOUT 1000

-struct app_core_fc_message_handle_params {
-   struct rte_ring *ring_req;
-   struct rte_ring *ring_resp;
+struct app_pipeline_fc_flow {
+   struct pipeline_fc_key key;
+   uint32_t port_id;
+   void *entry_ptr;

-   struct rte_pipeline *p;
-   uint32_t *port_out_id;
-   uint32_t table_id;
+   TAILQ_ENTRY(app_pipeline_fc_flow) node;
 };

+struct app_pipeline_fc {
+   TAILQ_HEAD(, app_pipeline_fc_flow) flows;
+
+   uint32_t n_flows;
+};
+
+static struct app_pipeline_fc_flow *
+app_pipeline_fc_flow_find(struct app_pipeline_fc *p,
+   struct pipeline_fc_key *key)
+{
+   struct app_pipeline_fc_flow *f;
+
+   TAILQ_FOREACH(f, >flows, node)
+   if (memcmp(key, >key, sizeof(struct pipeline_fc_key)) == 0)
+   return f;
+
+   return NULL;
+}
+
+static void
+print_fc_qinq_flow(struct app_pipeline_fc_flow *flow)
+{
+   printf("svlan = %u, "
+  "cvlan = %u "
+  "=> Port = %u "
+  "(entry_ptr = %p)\n",
+
+  flow->key.key.qinq.svlan,
+  flow->key.key.qinq.cvlan,
+  flow->port_id,
+  flow->entry_ptr);
+}
+
 static void
-app_message_handle(struct app_core_fc_message_handle_params *params);
+print_fc_ipv4_5tuple_flow(struct app_pipeline_fc_flow *flow)
+{
+   printf("SA = %u.%u.%u.%u "
+  "DA = %u.%u.%u.%u "
+  "SP = %u "
+  "DP = %u "
+  "Proto = %u "
+  

[dpdk-dev] [PATCH 10/11] ip_pipeline: added new implementation of routing pipeline

2015-05-29 Thread Maciej Gajdzica
Routing pipeline implementation is split to two files.
pipeline_routing.c file handles front-end functions (cli commands
parsing) pipeline_routing_ops.c contains implementation of functions
done by pipeline (back-end).

Signed-off-by: Pawel Wodkowski 
---
 examples/ip_pipeline/Makefile  |3 +-
 examples/ip_pipeline/init.c|2 +
 examples/ip_pipeline/pipeline/pipeline_routing.c   | 1660 +++-
 examples/ip_pipeline/pipeline/pipeline_routing.h   |   99 ++
 .../ip_pipeline/pipeline/pipeline_routing_ops.c|  978 
 .../ip_pipeline/pipeline/pipeline_routing_ops.h|  231 +++
 6 files changed, 2618 insertions(+), 355 deletions(-)
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_routing.h
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_routing_ops.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_routing_ops.h

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 0f8b1cc..f8c7c5f 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -63,8 +63,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += 
pipeline_passthrough_ops.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_passthrough.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall_ops.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing_ops.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_flow_classification.c
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing.c

 CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/pipeline
 CFLAGS += -O3
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index 29d87ae..29caae8 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -46,6 +46,7 @@
 #include "pipeline_master.h"
 #include "pipeline_passthrough.h"
 #include "pipeline_firewall.h"
+#include "pipeline_routing.h"

 #define APP_NAME_SIZE  32

@@ -1148,6 +1149,7 @@ int app_init(struct app_params *app)
app_pipeline_type_register(app, _master);
app_pipeline_type_register(app, _passthrough);
app_pipeline_type_register(app, _firewall);
+   app_pipeline_type_register(app, _routing);

app_init_pipelines(app);
app_init_threads(app);
diff --git a/examples/ip_pipeline/pipeline/pipeline_routing.c 
b/examples/ip_pipeline/pipeline/pipeline_routing.c
index b1ce624..d7dd495 100644
--- a/examples/ip_pipeline/pipeline/pipeline_routing.c
+++ b/examples/ip_pipeline/pipeline/pipeline_routing.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -31,444 +31,1396 @@
  *   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 "app.h"
+#include "pipeline_routing_ops.h"
+#include "pipeline_routing.h"

-#include 
-#include 
-#include 
-#include 
+#include "pipeline_common.h"

-#include "main.h"
+#define MSG_TIMEOUT 1000

-#include 
+struct app_pipeline_routing_arp_entry {
+   struct pipeline_routing_arp_key key;
+   struct ether_addr nh_arp;
+   void *entry_ptr;

-struct app_routing_table_entry {
-   struct rte_pipeline_table_entry head;
-   uint32_t nh_ip;
-   uint32_t nh_iface;
+   TAILQ_ENTRY(app_pipeline_routing_arp_entry) node;
 };

-struct app_arp_table_entry {
-   struct rte_pipeline_table_entry head;
-   struct ether_addr nh_arp;
+struct app_pipeline_routing_entry {
+   struct pipeline_routing_route_key key;
+   struct app_pipeline_routing_route_params params;
+   void *entry_ptr;
+
+   TAILQ_ENTRY(app_pipeline_routing_entry) node;
+};
+
+struct pipeline_routing {
+   /* parameters */
+   uint32_t n_ports_in;
+   uint32_t n_ports_out;
+
+   /* ARP entries */
+   TAILQ_HEAD(, app_pipeline_routing_arp_entry) arp_entries;
+   uint32_t n_arp_entries;
+
+   uint32_t default_arp_entry_present;
+   uint32_t default_arp_entry_port_id;
+   void *default_arp_entry_ptr;
+
+   /* Routing routes */
+   TAILQ_HEAD(, app_pipeline_routing_entry) routes;
+   uint32_t n_routes;
+
+   uint32_t default_route_present;
+   uint32_t default_route_port_id;
+   void *default_route_entry_ptr;
 };

-static inline void
-app_routing_table_write_metadata(
-   struct rte_mbuf *pkt,
-   struct app_routing_table_entry *entry)
+static void *
+pipeline_routing_init(struct pipeline_params *params,
+   __rte_unused void *arg)
 {
-   struct app_pkt_metadata *c =
-   (struct app_pkt_metadata *) 

[dpdk-dev] [PATCH 09/11] ip_pipeline: added new implementation of firewall pipeline

2015-05-29 Thread Maciej Gajdzica
Firewall pipeline implementation is split to two files.
pipeline_firewall.c file handles front-end functions (cli commands
parsing) pipeline_firewall_ops.c contains implementation of functions
done by pipeline (back-end).

Signed-off-by: Daniel Mrzyglod 
---
 examples/ip_pipeline/Makefile  |6 +-
 examples/ip_pipeline/init.c|2 +
 examples/ip_pipeline/pipeline/pipeline_firewall.c  | 1099 +++-
 examples/ip_pipeline/pipeline/pipeline_firewall.h  |   63 ++
 .../ip_pipeline/pipeline/pipeline_firewall_ops.c   |  538 ++
 .../ip_pipeline/pipeline/pipeline_firewall_ops.h   |  139 +++
 6 files changed, 1604 insertions(+), 243 deletions(-)
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall.h
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall_ops.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall_ops.h

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index fc845ce..0f8b1cc 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -61,13 +61,11 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_master_ops.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_master.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_passthrough_ops.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_passthrough.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall_ops.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_flow_classification.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing.c

-#ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall.c
-#endif
-
 CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/pipeline
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS) -Wno-error=unused-function -Wno-error=unused-variable
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index 22b2c77..29d87ae 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -45,6 +45,7 @@
 #include "pipeline.h"
 #include "pipeline_master.h"
 #include "pipeline_passthrough.h"
+#include "pipeline_firewall.h"

 #define APP_NAME_SIZE  32

@@ -1146,6 +1147,7 @@ int app_init(struct app_params *app)

app_pipeline_type_register(app, _master);
app_pipeline_type_register(app, _passthrough);
+   app_pipeline_type_register(app, _firewall);

app_init_pipelines(app);
app_init_threads(app);
diff --git a/examples/ip_pipeline/pipeline/pipeline_firewall.c 
b/examples/ip_pipeline/pipeline/pipeline_firewall.c
index b70260e..21ae403 100644
--- a/examples/ip_pipeline/pipeline/pipeline_firewall.c
+++ b/examples/ip_pipeline/pipeline/pipeline_firewall.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -32,282 +32,903 @@
  */

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

+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "app.h"
+#include "pipeline_firewall_ops.h"
+#include "pipeline_firewall.h"
+#include "pipeline_common.h"
+
+#define MSG_TIMEOUT 1000
+
+struct app_pipeline_firewall_rule {
+   struct pipeline_firewall_key key;
+   int32_t priority;
+   uint32_t port_id;
+   void *entry_ptr;
+
+   TAILQ_ENTRY(app_pipeline_firewall_rule) node;
+};
+
+struct app_pipeline_firewall {
+   /* parameters */
+   uint32_t n_ports_in;
+   uint32_t n_ports_out;
+
+   /* rules */
+   TAILQ_HEAD(, app_pipeline_firewall_rule) rules;
+   uint32_t n_rules;
+   uint32_t default_rule_present;
+   uint32_t default_rule_port_id;
+   void *default_rule_entry_ptr;
+};

-#include 
-#include 
-#include 
+static void
+print_firewall_ipv4_rule(struct app_pipeline_firewall_rule *rule)
+{
+   printf("Prio = %d (SA = %u.%u.%u.%u/%u, "
+   "DA = %u.%u.%u.%u/%u, "
+   "SP = %u-%u, "
+   "DP = %u-%u, "
+   "Proto = %u / 0x%x) => "
+   "Port = %u (entry ptr = %p)\n",
+
+   rule->priority,
+
+   (rule->key.key.ipv4_5tuple.src_ip >> 24) & 0xFF,
+   (rule->key.key.ipv4_5tuple.src_ip >> 16) & 0xFF,
+   (rule->key.key.ipv4_5tuple.src_ip >> 8) & 0xFF,
+   rule->key.key.ipv4_5tuple.src_ip & 0xFF,
+   rule->key.key.ipv4_5tuple.src_ip_mask,
+
+   (rule->key.key.ipv4_5tuple.dst_ip >> 24) & 0xFF,
+   (rule->key.key.ipv4_5tuple.dst_ip >> 16) & 0xFF,
+   (rule->key.key.ipv4_5tuple.dst_ip >> 8) & 0xFF,
+   rule->key.key.ipv4_5tuple.dst_ip & 0xFF,
+   

[dpdk-dev] [PATCH 08/11] ip_pipeline: added new implementation of passthrough pipeline

2015-05-29 Thread Maciej Gajdzica
Passthrough pipeline implementation is split to two files.
pipeline_passthrough.c file handles front-end functions (cli commands
parsing) pipeline_passthrough_ops.c contains implementation of functions
done by pipeline (back-end).

Signed-off-by: Jasvinder Singh 
---
 examples/ip_pipeline/Makefile  |7 +-
 examples/ip_pipeline/init.c|2 +
 .../ip_pipeline/pipeline/pipeline_passthrough.c|  192 +-
 .../ip_pipeline/pipeline/pipeline_passthrough.h|   41 +++
 .../pipeline/pipeline_passthrough_ops.c|  275 
 .../pipeline/pipeline_passthrough_ops.h|   41 +++
 6 files changed, 374 insertions(+), 184 deletions(-)
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough.h
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough_ops.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough_ops.h

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index db677ec..fc845ce 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -59,13 +59,10 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_ops.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_master_ops.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_master.c
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_rx.c
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_tx.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_passthrough_ops.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_passthrough.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_flow_classification.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing.c
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_passthrough.c
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_ipv4_frag.c
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_ipv4_ras.c

 #ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall.c
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index b066476..22b2c77 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -44,6 +44,7 @@
 #include "app.h"
 #include "pipeline.h"
 #include "pipeline_master.h"
+#include "pipeline_passthrough.h"

 #define APP_NAME_SIZE  32

@@ -1144,6 +1145,7 @@ int app_init(struct app_params *app)
app_init_msgq(app);

app_pipeline_type_register(app, _master);
+   app_pipeline_type_register(app, _passthrough);

app_init_pipelines(app);
app_init_threads(app);
diff --git a/examples/ip_pipeline/pipeline/pipeline_passthrough.c 
b/examples/ip_pipeline/pipeline/pipeline_passthrough.c
index 948b2c1..e39de32 100644
--- a/examples/ip_pipeline/pipeline/pipeline_passthrough.c
+++ b/examples/ip_pipeline/pipeline/pipeline_passthrough.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -31,183 +31,17 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */

-#include 
-#include 
-#include 
+#include "pipeline_passthrough_ops.h"
+#include "pipeline_passthrough.h"

-#include 
-#include 
+static struct pipeline_fe_ops pipeline_passthrough_fe_ops = {
+   .f_init = NULL,
+   .f_free = NULL,
+   .cmds = NULL,
+};

-#include 
-#include 
-#include 
-
-#include "main.h"
-
-void
-app_main_loop_pipeline_passthrough(void) {
-   struct rte_pipeline_params pipeline_params = {
-   .name = "pipeline",
-   .socket_id = rte_socket_id(),
-   };
-
-   struct rte_pipeline *p;
-   uint32_t port_in_id[APP_MAX_PORTS];
-   uint32_t port_out_id[APP_MAX_PORTS];
-   uint32_t table_id[APP_MAX_PORTS];
-   uint32_t i;
-
-   uint32_t core_id = rte_lcore_id();
-   struct app_core_params *core_params = app_get_core_params(core_id);
-
-   if ((core_params == NULL) || (core_params->core_type != APP_CORE_PT))
-   rte_panic("Core %u misconfiguration\n", core_id);
-
-   RTE_LOG(INFO, USER1, "Core %u is doing pass-through\n", core_id);
-
-   /* Pipeline configuration */
-   p = rte_pipeline_create(_params);
-   if (p == NULL)
-   rte_panic("%s: Unable to configure the pipeline\n", __func__);
-
-   /* Input port configuration */
-   for (i = 0; i < app.n_ports; i++) {
-   struct rte_port_ring_reader_params port_ring_params = {
-   .ring = app.rings[core_params->swq_in[i]],
-   };
-
-   struct rte_pipeline_port_in_params port_params = {
-   .ops = _port_ring_reader_ops,
-   .arg_create = (void *) _ring_params,
-   .f_action = NULL,
-   

[dpdk-dev] [PATCH 07/11] ip_pipeline: moved config files to separate folder

2015-05-29 Thread Maciej Gajdzica
Created new folder for config(.cfg) and script(.sh) files.

Signed-off-by: Maciej Gajdzica 
---
 examples/ip_pipeline/config/ip_pipeline.cfg |9 +
 examples/ip_pipeline/config/ip_pipeline.sh  |1 +
 examples/ip_pipeline/ip_pipeline.cfg|   56 ---
 examples/ip_pipeline/ip_pipeline.sh |   18 -
 4 files changed, 10 insertions(+), 74 deletions(-)
 create mode 100644 examples/ip_pipeline/config/ip_pipeline.cfg
 create mode 100644 examples/ip_pipeline/config/ip_pipeline.sh
 delete mode 100644 examples/ip_pipeline/ip_pipeline.cfg
 delete mode 100644 examples/ip_pipeline/ip_pipeline.sh

diff --git a/examples/ip_pipeline/config/ip_pipeline.cfg 
b/examples/ip_pipeline/config/ip_pipeline.cfg
new file mode 100644
index 000..9e7e7e4
--- /dev/null
+++ b/examples/ip_pipeline/config/ip_pipeline.cfg
@@ -0,0 +1,9 @@
+[PIPELINE0]
+type = MASTER
+core = 0
+
+[PIPELINE1]
+type = PASS-THROUGH
+core = s0c1
+pktq_in = RXQ0.0 RXQ1.0
+pktq_out = TXQ0.0 TXQ1.0
\ No newline at end of file
diff --git a/examples/ip_pipeline/config/ip_pipeline.sh 
b/examples/ip_pipeline/config/ip_pipeline.sh
new file mode 100644
index 000..f1ff544
--- /dev/null
+++ b/examples/ip_pipeline/config/ip_pipeline.sh
@@ -0,0 +1 @@
+p 1 ping
\ No newline at end of file
diff --git a/examples/ip_pipeline/ip_pipeline.cfg 
b/examples/ip_pipeline/ip_pipeline.cfg
deleted file mode 100644
index 428830d..000
--- a/examples/ip_pipeline/ip_pipeline.cfg
+++ /dev/null
@@ -1,56 +0,0 @@
-;   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.
-
-; Core configuration
-[core 0]
-type = MASTER
-queues in  = 15 16 17 -1 -1 -1 -1 -1
-queues out = 12 13 14 -1 -1 -1 -1 -1
-
-[core 1]
-type = RX
-queues in  = -1 -1 -1 -1 -1 -1 -1 12
-queues out =  0  1  2  3 -1 -1 -1 15
-
-[core 2]
-type = FC
-queues in  =  0  1  2  3 -1 -1 -1 13
-queues out =  4  5  6  7 -1 -1 -1 16
-
-[core 3]
-type = RT
-queues in  =  4  5  6  7 -1 -1 -1 14
-queues out =  8  9 10 11 -1 -1 -1 17
-
-[core 4]
-type = TX
-queues in  =  8  9 10 11 -1 -1 -1 -1
-queues out = -1 -1 -1 -1 -1 -1 -1 -1
diff --git a/examples/ip_pipeline/ip_pipeline.sh 
b/examples/ip_pipeline/ip_pipeline.sh
deleted file mode 100644
index c3419ca..000
--- a/examples/ip_pipeline/ip_pipeline.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#Address Resolution Protocol (ARP) Table
-#arp add iface ipaddr macaddr
-arp add 0 0.0.0.1 0a:0b:0c:0d:0e:0f
-arp add 1 0.128.0.1 1a:1b:1c:1d:1e:1f
-
-#Routing Table
-#route add ipaddr prefixlen iface gateway
-route add 0.0.0.0 9 0 0.0.0.1
-route add 0.128.0.0 9 1 0.128.0.1
-
-#Flow Table
-flow add all
-#flow add 0.0.0.0 1.2.3.4 0 0 6 0
-#flow add 10.11.12.13 0.0.0.0 0 0 6 1
-
-#Firewall
-#firewall add 1 0.0.0.0 0 0.0.0.0 9 0 65535 0 65535 6 0xf 0
-#firewall add 1 0.0.0.0 0 0.128.0.0 9 0 65535 0 65535 6 0xf 1
-- 
1.7.9.5



[dpdk-dev] [PATCH 06/11] ip_pipeline: added application thread

2015-05-29 Thread Maciej Gajdzica
Application thread runs pipelines on assigned cores.

Signed-off-by: Maciej Gajdzica 
---
 examples/ip_pipeline/Makefile |1 +
 examples/ip_pipeline/main.c   |6 +++
 examples/ip_pipeline/thread.c |  105 +
 3 files changed, 112 insertions(+)
 create mode 100644 examples/ip_pipeline/thread.c

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 6269be1..db677ec 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -52,6 +52,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := main.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c

 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_ops.c
diff --git a/examples/ip_pipeline/main.c b/examples/ip_pipeline/main.c
index ef68c86..862e2f2 100644
--- a/examples/ip_pipeline/main.c
+++ b/examples/ip_pipeline/main.c
@@ -52,5 +52,11 @@ main(int argc, char **argv)
/* Init */
app_init();

+   /* Run-time */
+   rte_eal_mp_remote_launch(
+   app_thread,
+   (void *) ,
+   CALL_MASTER);
+
return 0;
 }
diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c
new file mode 100644
index 000..f850a36
--- /dev/null
+++ b/examples/ip_pipeline/thread.c
@@ -0,0 +1,105 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED 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 "pipeline_common_ops.h"
+#include "app.h"
+
+int app_thread(void *arg)
+{
+   struct app_params *app = (struct app_params *) arg;
+   uint32_t core_id = rte_lcore_id(), i, j;
+   struct app_thread_data *t = >thread_data[core_id];
+
+   for (i = 0; ; i++) {
+   /* Run regular pipelines */
+   for (j = 0; j < t->n_regular; j++){
+   struct app_thread_pipeline_data *data = >regular[j];
+   struct pipeline *p = data->be;
+
+   rte_pipeline_run(p->p);
+   }
+
+   /* Run custom pipelines */
+   for (j = 0; j < t->n_custom; j++){
+   struct app_thread_pipeline_data *data = >custom[j];
+
+   data->f_run(data->be);
+   }
+
+   /* Timer */
+   if ((i & 0xF) == 0) {
+   uint64_t time = rte_get_tsc_cycles();
+   uint64_t t_deadline = UINT64_MAX;
+   
+   if (time < t->deadline)
+   continue;
+
+   /* Timer for regular pipelines */
+   for (j = 0; j < t->n_regular; j++){
+   struct app_thread_pipeline_data *data = 
>regular[j];
+   uint64_t p_deadline = data->deadline;
+
+   if (p_deadline <= time) {
+   data->f_timer(data->be);
+   p_deadline = time + data->timer_period;
+   data->deadline = p_deadline;
+   }
+
+   if 

[dpdk-dev] [PATCH 05/11] ip_pipeline: added master pipeline

2015-05-29 Thread Maciej Gajdzica
Master pipeline is responsible for command line handling and
communicationg with all other pipelines via message queues. Removed
cmdline.c file, as its functionality will be split over multiple
pipeline files.

Signed-off-by: Jasvinder Singh 
---
 examples/ip_pipeline/Makefile  |6 +-
 examples/ip_pipeline/cmdline.c | 1976 
 examples/ip_pipeline/init.c|3 +
 examples/ip_pipeline/pipeline/pipeline_common.c|  412 
 examples/ip_pipeline/pipeline/pipeline_common.h|  241 +++
 .../ip_pipeline/pipeline/pipeline_common_ops.c |  205 ++
 .../ip_pipeline/pipeline/pipeline_common_ops.h |  150 ++
 examples/ip_pipeline/pipeline/pipeline_master.c|  870 +
 examples/ip_pipeline/pipeline/pipeline_master.h|   41 +
 .../ip_pipeline/pipeline/pipeline_master_ops.c |  136 ++
 .../ip_pipeline/pipeline/pipeline_master_ops.h |   41 +
 11 files changed, 2104 insertions(+), 1977 deletions(-)
 delete mode 100644 examples/ip_pipeline/cmdline.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_common.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_common.h
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_common_ops.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_common_ops.h
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_master.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_master.h
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_master_ops.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_master_ops.h

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 9a1e19a..6269be1 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -53,7 +53,11 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cmdline.c
+
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_ops.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_master_ops.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_master.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_rx.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_tx.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_flow_classification.c
diff --git a/examples/ip_pipeline/cmdline.c b/examples/ip_pipeline/cmdline.c
deleted file mode 100644
index 3173fd0..000
--- a/examples/ip_pipeline/cmdline.c
+++ /dev/null
@@ -1,1976 +0,0 @@
-/*-
- *   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 "main.h"
-
-#define IS_RULE_PRESENT(res, rule_key, table, type)\
-do {   \
-   struct app_rule *it;\
-   \
-   (res) = NULL;   

[dpdk-dev] [PATCH 04/11] ip_pipeline: moved pipelines to separate folder

2015-05-29 Thread Maciej Gajdzica
Moved pipelines to separate folder, removed not needed pipelines and
modified Makefile to match that change.

Signed-off-by: Maciej Gajdzica 
---
 examples/ip_pipeline/Makefile  |9 +-
 examples/ip_pipeline/pipeline/pipeline_firewall.c  |  313 +
 .../pipeline/pipeline_flow_classification.c|  306 +
 .../ip_pipeline/pipeline/pipeline_passthrough.c|  213 +
 examples/ip_pipeline/pipeline/pipeline_routing.c   |  474 
 examples/ip_pipeline/pipeline_firewall.c   |  313 -
 .../ip_pipeline/pipeline_flow_classification.c |  306 -
 examples/ip_pipeline/pipeline_ipv4_frag.c  |  184 
 examples/ip_pipeline/pipeline_ipv4_ras.c   |  181 
 examples/ip_pipeline/pipeline_passthrough.c|  213 -
 examples/ip_pipeline/pipeline_routing.c|  474 
 examples/ip_pipeline/pipeline_rx.c |  385 
 examples/ip_pipeline/pipeline_tx.c |  283 
 13 files changed, 1314 insertions(+), 2340 deletions(-)
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough.c
 create mode 100644 examples/ip_pipeline/pipeline/pipeline_routing.c
 delete mode 100644 examples/ip_pipeline/pipeline_firewall.c
 delete mode 100644 examples/ip_pipeline/pipeline_flow_classification.c
 delete mode 100644 examples/ip_pipeline/pipeline_ipv4_frag.c
 delete mode 100644 examples/ip_pipeline/pipeline_ipv4_ras.c
 delete mode 100644 examples/ip_pipeline/pipeline_passthrough.c
 delete mode 100644 examples/ip_pipeline/pipeline_routing.c
 delete mode 100644 examples/ip_pipeline/pipeline_rx.c
 delete mode 100644 examples/ip_pipeline/pipeline_tx.c

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 443f7e4..9a1e19a 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -36,11 +36,17 @@ endif
 # Default target, can be overridden by command line or environment
 RTE_TARGET ?= x86_64-native-linuxapp-gcc

+DIRS-(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline
+
 include $(RTE_SDK)/mk/rte.vars.mk

 # binary name
 APP = ip_pipeline

+VPATH += $(SRCDIR)/pipeline
+
+INC += $(wildcard *.h) $(wildcard pipeline/*.h)
+
 # all source are stored in SRCS-y
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := main.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c
@@ -60,7 +66,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall.c
 #endif

+CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/pipeline
 CFLAGS += -O3
-CFLAGS += $(WERROR_FLAGS)
+CFLAGS += $(WERROR_FLAGS) -Wno-error=unused-function -Wno-error=unused-variable

 include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/ip_pipeline/pipeline/pipeline_firewall.c 
b/examples/ip_pipeline/pipeline/pipeline_firewall.c
new file mode 100644
index 000..b70260e
--- /dev/null
+++ b/examples/ip_pipeline/pipeline/pipeline_firewall.c
@@ -0,0 +1,313 @@
+/*-
+ *   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 
+

[dpdk-dev] [PATCH 03/11] ip_pipeline: modified init to match new params struct

2015-05-29 Thread Maciej Gajdzica
After changes in config parser, app params struct is changed and
requires modifications in initialization procedures.

Signed-off-by: Maciej Gajdzica 
---
 examples/ip_pipeline/Makefile |2 +-
 examples/ip_pipeline/init.c   | 1498 +
 examples/ip_pipeline/main.c   |3 +
 3 files changed, 1073 insertions(+), 430 deletions(-)

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index c893952..443f7e4 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -45,7 +45,7 @@ APP = ip_pipeline
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := main.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c
-#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cmdline.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_rx.c
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index d79762f..77d5f07 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -32,561 +32,1201 @@
  */

 #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 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
-#include 
-#include 
-#include 
-
-#include "main.h"
-
-#define NA APP_SWQ_INVALID
-
-struct app_params app = {
-   /* CPU cores */
-   .cores = {
-   {0, APP_CORE_MASTER, {15, 16, 17, NA, NA, NA, NA, NA},
-   {12, 13, 14, NA, NA, NA, NA, NA} },
-   {0, APP_CORE_RX, {NA, NA, NA, NA, NA, NA, NA, 12},
-   { 0,  1,  2,  3, NA, NA, NA, 15} },
-   {0, APP_CORE_FC, { 0,  1,  2,  3, NA, NA, NA, 13},
-   { 4,  5,  6,  7, NA, NA, NA, 16} },
-   {0, APP_CORE_RT, { 4,  5,  6,  7, NA, NA, NA, 14},
-   { 8,  9, 10, 11, NA, NA, NA, 17} },
-   {0, APP_CORE_TX, { 8,  9, 10, 11, NA, NA, NA, NA},
-   {NA, NA, NA, NA, NA, NA, NA, NA} },
-   },
-
-   /* Ports*/
-   .n_ports = APP_MAX_PORTS,
-   .rsz_hwq_rx = 128,
-   .rsz_hwq_tx = 512,
-   .bsz_hwq_rd = 64,
-   .bsz_hwq_wr = 64,
-
-   .port_conf = {
-   .rxmode = {
-   .split_hdr_size = 0,
-   .header_split   = 0, /* Header Split disabled */
-   .hw_ip_checksum = 1, /* IP checksum offload enabled */
-   .hw_vlan_filter = 0, /* VLAN filtering disabled */
-   .jumbo_frame= 1, /* Jumbo Frame Support enabled */
-   .max_rx_pkt_len = 9000, /* Jumbo Frame MAC pkt length */
-   .hw_strip_crc   = 0, /* CRC stripped by hardware */
-   },
-   .rx_adv_conf = {
-   .rss_conf = {
-   .rss_key = NULL,
-   .rss_hf = ETH_RSS_IP,
-   },
-   },
-   .txmode = {
-   .mq_mode = ETH_MQ_TX_NONE,
-   },
-   },
-
-   .rx_conf = {
-   .rx_thresh = {
-   .pthresh = 8,
-   .hthresh = 8,
-   .wthresh = 4,
-   },
-   .rx_free_thresh = 64,
-   .rx_drop_en = 0,
-   },
-
-   .tx_conf = {
-   .tx_thresh = {
-   .pthresh = 36,
-   .hthresh = 0,
-   .wthresh = 0,
-   },
-   .tx_free_thresh = 0,
-   .tx_rs_thresh = 0,
-   },
-
-   /* SWQs */
-   .rsz_swq = 128,
-   .bsz_swq_rd = 64,
-   .bsz_swq_wr = 64,
-
-   /* Buffer pool */
-   .pool_buffer_size = RTE_MBUF_DEFAULT_BUF_SIZE,
-   .pool_size = 32 * 1024,
-   .pool_cache_size = 256,
-
-   /* Message buffer pool */
-   .msg_pool_buffer_size = 256,
-   .msg_pool_size = 1024,
-   .msg_pool_cache_size = 64,
-
-   /* Rule tables */
-   .max_arp_rules = 1 << 10,
-   .max_firewall_rules = 1 << 5,
-   .max_routing_rules = 1 << 24,
-   .max_flow_rules = 1 << 24,
-
-   /* Application processing */
-   .ether_hdr_pop_push = 0,
-};
-
-struct app_core_params *
-app_get_core_params(uint32_t core_id)
+#include 
+#include 
+

[dpdk-dev] [PATCH 02/11] ip_pipeline: added config checks

2015-05-29 Thread Maciej Gajdzica
After loading configuration from a file, data integrity is checked.

Signed-off-by: Jasvinder Singh 
---
 examples/ip_pipeline/Makefile   |1 +
 examples/ip_pipeline/config_check.c |  617 +++
 examples/ip_pipeline/main.c |2 +
 3 files changed, 620 insertions(+)
 create mode 100644 examples/ip_pipeline/config_check.c

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 2f224cc..c893952 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -44,6 +44,7 @@ APP = ip_pipeline
 # all source are stored in SRCS-y
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := main.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c
 #SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cmdline.c
diff --git a/examples/ip_pipeline/config_check.c 
b/examples/ip_pipeline/config_check.c
new file mode 100644
index 000..bf400f4
--- /dev/null
+++ b/examples/ip_pipeline/config_check.c
@@ -0,0 +1,617 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED 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 "app.h"
+
+
+static uint32_t
+app_link_get_n_hwq_in(struct app_params *app, uint32_t link_id)
+{
+   uint32_t hwq_id_max = 0, i;
+
+   for (i = 0; i < APP_LINK_MAX_HWQ_IN; i++) {
+   struct app_pktq_hwq_in_params *p = 
>hwq_in_params[APP_HWQ_IN_IDX(link_id, i)];
+
+   if (APP_PARAM_VALID(p))
+   hwq_id_max++;
+   }
+
+   return hwq_id_max;
+}
+
+static uint32_t
+app_link_get_n_hwq_out(struct app_params *app, uint32_t link_id)
+{
+   uint32_t hwq_id_max = 0, i;
+
+   for (i = 0; i < APP_LINK_MAX_HWQ_OUT; i++) {
+   struct app_pktq_hwq_out_params *p = >hwq_out_params[link_id
+   * APP_LINK_MAX_HWQ_OUT + i];
+
+   if (APP_PARAM_VALID(p))
+   hwq_id_max++;
+   }
+
+   return hwq_id_max;
+}
+
+static uint32_t
+app_link_get_hwq_in_readers(uint32_t link_id, uint32_t hwq_id)
+{
+   uint32_t j, n;  
+   
+   for (n = 0, j = 0; j < APP_MAX_LINKS * APP_LINK_MAX_HWQ_IN; j++) {
+   
+   uint32_t linkId = j / APP_MAX_LINKS;
+   uint32_t q_id = j % APP_MAX_LINKS;
+   
+   if ((linkId == link_id) &&
+   (q_id == hwq_id))
+   
+   n++;
+   }
+   
+   return n;
+}
+
+static uint32_t
+app_link_get_hwq_out_writers(uint32_t link_id, uint32_t hwq_id)
+{
+   uint32_t j, n;  
+   
+   for (n = 0, j = 0; j < APP_MAX_LINKS * APP_LINK_MAX_HWQ_OUT; j++) {
+   
+   uint32_t linkId = j / APP_MAX_LINKS;
+   uint32_t q_id = j % APP_MAX_LINKS;
+   
+   if ((linkId == link_id) &&
+   (q_id == hwq_id))
+   
+   n++;
+   }
+
+   return n;
+}
+
+
+static uint32_t
+app_pipeline_hwq_in_get_n(struct app_params *app, uint32_t hwq_id)
+{
+   uint32_t i, j, n;
+   
+   for (n = 0, i = 0; i < app->n_pipelines; i++) {
+   
+   if (!APP_PARAM_VALID(>pipeline_params[i]))
+  

[dpdk-dev] [PATCH 01/11] ip_pipeline: add parsing for config files with new syntax

2015-05-29 Thread Maciej Gajdzica
New syntax of config files is needed for ip_pipeline example
enhancements. Some old files are temporarily disabled in the Makefile.
It is part of a bigger change.

Signed-off-by: Pawel Wodkowski 
---
 examples/ip_pipeline/Makefile   |   27 +-
 examples/ip_pipeline/app.h  |  586 ++
 examples/ip_pipeline/config.c   |  419 ---
 examples/ip_pipeline/config_parse.c | 2071 +++
 examples/ip_pipeline/cpu_core_map.c |  465 
 examples/ip_pipeline/cpu_core_map.h |   69 ++
 examples/ip_pipeline/main.c |  130 +--
 examples/ip_pipeline/main.h |  298 -
 examples/ip_pipeline/pipeline.h |   79 ++
 examples/ip_pipeline/pipeline_ops.h |  247 +
 10 files changed, 3539 insertions(+), 852 deletions(-)
 create mode 100644 examples/ip_pipeline/app.h
 delete mode 100644 examples/ip_pipeline/config.c
 create mode 100644 examples/ip_pipeline/config_parse.c
 create mode 100644 examples/ip_pipeline/cpu_core_map.c
 create mode 100644 examples/ip_pipeline/cpu_core_map.h
 delete mode 100644 examples/ip_pipeline/main.h
 create mode 100644 examples/ip_pipeline/pipeline.h
 create mode 100644 examples/ip_pipeline/pipeline_ops.h

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index e70fdc7..2f224cc 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -43,20 +43,21 @@ APP = ip_pipeline

 # all source are stored in SRCS-y
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := main.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cmdline.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_rx.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_tx.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_flow_classification.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_passthrough.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_ipv4_frag.c
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_ipv4_ras.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cmdline.c
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_rx.c
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_tx.c
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_flow_classification.c
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_routing.c
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_passthrough.c
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_ipv4_frag.c
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_ipv4_ras.c

-ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
-SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall.c
-endif
+#ifeq ($(CONFIG_RTE_LIBRTE_ACL),y)
+#SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_firewall.c
+#endif

 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h
new file mode 100644
index 000..9ff7454
--- /dev/null
+++ b/examples/ip_pipeline/app.h
@@ -0,0 +1,586 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED 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 __INCLUDE_APP_H__
+#define __INCLUDE_APP_H__
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 

[dpdk-dev] [PATCH 00/11] ip_pipeline: ip_pipeline application enhancements

2015-05-29 Thread Maciej Gajdzica
This patchset enhances functionality of ip_pipeline application. New config
file syntax is introduced, so parser is changed. Changed structure of the
application. Now every global variable is stored in app_struct in app.h.
Syntax of pipeline cli commands was changed. Implementation of cli commands
for every pipeline is moved to the separate file.


Maciej Gajdzica (11):
  ip_pipeline: add parsing for config files with new syntax
  ip_pipeline: added config checks
  ip_pipeline: modified init to match new params struct
  ip_pipeline: moved pipelines to separate folder
  ip_pipeline: added master pipeline
  ip_pipeline: added application thread
  ip_pipeline: moved config files to separate folder
  ip_pipeline: added new implementation of passthrough pipeline
  ip_pipeline: added new implementation of firewall pipeline
  ip_pipeline: added new implementation of routing pipeline
  ip_pipeline: added new implementation of flow classification pipeline

 examples/ip_pipeline/Makefile  |   35 +-
 examples/ip_pipeline/app.h |  586 ++
 examples/ip_pipeline/cmdline.c | 1976 ---
 examples/ip_pipeline/config.c  |  419 
 examples/ip_pipeline/config/ip_pipeline.cfg|9 +
 examples/ip_pipeline/config/ip_pipeline.sh |1 +
 examples/ip_pipeline/config_check.c|  617 ++
 examples/ip_pipeline/config_parse.c| 2071 
 examples/ip_pipeline/cpu_core_map.c|  465 +
 examples/ip_pipeline/cpu_core_map.h|   69 +
 examples/ip_pipeline/init.c| 1509 ++
 examples/ip_pipeline/ip_pipeline.cfg   |   56 -
 examples/ip_pipeline/ip_pipeline.sh|   18 -
 examples/ip_pipeline/main.c|  137 +-
 examples/ip_pipeline/main.h|  298 ---
 examples/ip_pipeline/pipeline.h|   79 +
 examples/ip_pipeline/pipeline/pipeline_common.c|  412 
 examples/ip_pipeline/pipeline/pipeline_common.h|  241 +++
 .../ip_pipeline/pipeline/pipeline_common_ops.c |  205 ++
 .../ip_pipeline/pipeline/pipeline_common_ops.h |  150 ++
 examples/ip_pipeline/pipeline/pipeline_firewall.c  |  934 +
 examples/ip_pipeline/pipeline/pipeline_firewall.h  |   63 +
 .../ip_pipeline/pipeline/pipeline_firewall_ops.c   |  538 +
 .../ip_pipeline/pipeline/pipeline_firewall_ops.h   |  139 ++
 .../pipeline/pipeline_flow_classification.c| 1621 +++
 .../pipeline/pipeline_flow_classification.h|   41 +
 .../pipeline/pipeline_flow_classification_ops.c|  559 ++
 .../pipeline/pipeline_flow_classification_ops.h|  150 ++
 examples/ip_pipeline/pipeline/pipeline_master.c|  870 
 examples/ip_pipeline/pipeline/pipeline_master.h|   41 +
 .../ip_pipeline/pipeline/pipeline_master_ops.c |  136 ++
 .../ip_pipeline/pipeline/pipeline_master_ops.h |   41 +
 .../ip_pipeline/pipeline/pipeline_passthrough.c|   47 +
 .../ip_pipeline/pipeline/pipeline_passthrough.h|   41 +
 .../pipeline/pipeline_passthrough_ops.c|  275 +++
 .../pipeline/pipeline_passthrough_ops.h|   41 +
 examples/ip_pipeline/pipeline/pipeline_routing.c   | 1426 ++
 examples/ip_pipeline/pipeline/pipeline_routing.h   |   99 +
 .../ip_pipeline/pipeline/pipeline_routing_ops.c|  978 +
 .../ip_pipeline/pipeline/pipeline_routing_ops.h|  231 +++
 examples/ip_pipeline/pipeline_firewall.c   |  313 ---
 .../ip_pipeline/pipeline_flow_classification.c |  306 ---
 examples/ip_pipeline/pipeline_ipv4_frag.c  |  184 --
 examples/ip_pipeline/pipeline_ipv4_ras.c   |  181 --
 examples/ip_pipeline/pipeline_ops.h|  247 +++
 examples/ip_pipeline/pipeline_passthrough.c|  213 --
 examples/ip_pipeline/pipeline_routing.c|  474 -
 examples/ip_pipeline/pipeline_rx.c |  385 
 examples/ip_pipeline/pipeline_tx.c |  283 ---
 examples/ip_pipeline/thread.c  |  105 +
 50 files changed, 14648 insertions(+), 5667 deletions(-)
 create mode 100644 examples/ip_pipeline/app.h
 delete mode 100644 examples/ip_pipeline/cmdline.c
 delete mode 100644 examples/ip_pipeline/config.c
 create mode 100644 examples/ip_pipeline/config/ip_pipeline.cfg
 create mode 100644 examples/ip_pipeline/config/ip_pipeline.sh
 create mode 100644 examples/ip_pipeline/config_check.c
 create mode 100644 examples/ip_pipeline/config_parse.c
 create mode 100644 examples/ip_pipeline/cpu_core_map.c
 create mode 100644 examples/ip_pipeline/cpu_core_map.h
 delete mode 100644 examples/ip_pipeline/ip_pipeline.cfg
 delete mode 100644 examples/ip_pipeline/ip_pipeline.sh
 delete mode 100644 examples/ip_pipeline/main.h
 create mode 100644 examples/ip_pipeline/pipeline.h
 create mode 100644 

[dpdk-dev] [PATCH] rte_reorder: Allow sequence numbers > 0 as starting point

2015-05-29 Thread Gonzalez Monroy, Sergio
On 20/05/2015 12:02, Simon Kagstrom wrote:
> We use sequence numbers from a generator which has potentially started
> long before the receiver. Therefore, the first number will typically
> be > 0. The rte_reorder code will not work in this case, since the
> packet is seen as outside of the buffer.
>
> The patch instead records the first sequence number inserted as the
> starting point.
>
> Signed-off-by: Simon Kagstrom 
> Signed-off-by: Johan Faltstrom 
> ---
>   lib/librte_reorder/rte_reorder.c | 8 
>   1 file changed, 8 insertions(+)
>
> diff --git a/lib/librte_reorder/rte_reorder.c 
> b/lib/librte_reorder/rte_reorder.c
> index dc0e806..4d6449e 100644
> --- a/lib/librte_reorder/rte_reorder.c
> +++ b/lib/librte_reorder/rte_reorder.c
> @@ -73,6 +73,8 @@ struct rte_reorder_buffer {
>   unsigned int memsize; /**< memory area size of reorder buffer */
>   struct cir_buffer ready_buf; /**< temp buffer for dequeued entries */
>   struct cir_buffer order_buf; /**< buffer used to reorder entries */
> +
> + int is_initialized;
>   } __rte_cache_aligned;
>   
>   static void
> @@ -325,6 +327,12 @@ rte_reorder_insert(struct rte_reorder_buffer *b, struct 
> rte_mbuf *mbuf)
>   uint32_t offset, position;
>   struct cir_buffer *order_buf = >order_buf;
>   
> + if (!b->is_initialized) {
> + b->min_seqn = mbuf->seqn;
> +
> + b->is_initialized = 1;
> + }
> +
>   /*
>* calculate the offset from the head pointer we need to go.
>* The subtraction takes care of the sequence number wrapping.

Acked-by: Sergio Gonzalez Monroy 


[dpdk-dev] [PATCH v9 12/12] abi: fix v2.1 abi broken issue

2015-05-29 Thread Vincent JARDIN
On 29/05/2015 10:45, Cunming Liang wrote:
> RTE_EAL_RX_INTR will be removed from v2.2. It's only used to avoid 
> ABI(unannounced) broken in v2.1.
> The usrs should make sure understand the impact before turning on the feature.
> There are two abi changes required in this interrupt patch set.
> They're 1) struct rte_intr_handle; 2) struct rte_intr_conf.
>
> Signed-off-by: Cunming Liang

Acked-by: vincent jardin 




[dpdk-dev] [PATCH 3/3] librte_cfgfile: rework

2015-05-29 Thread Maciej Gajdzica
From: Pawel Wodkowski 

This patch add following features:
 1. Make entry variable length - remove 64 byte limit.
 2. Add line continue character '\' to make multiline values possible.

This patch also fixes following issues:
 1. BUG: section were allocated as a block of memory. In rte_cfgfile_close()
free() was wrongly called on each section. This bug is fixed implicitly
by implementing new section allocation scheme.
 2. Protect against multiple sections/entries in sections with the same
name.

Implications:
 1. Change in struct rte_cfgfile_entry deffinition.
 2. Change in rte_cfgfile_section_entries() declaration.

Signed-off-by: Pawel Wodkowski 
---
 lib/librte_cfgfile/Makefile|   2 +-
 lib/librte_cfgfile/rte_cfgfile.c   | 792 ++---
 lib/librte_cfgfile/rte_cfgfile.h   |  31 +-
 lib/librte_cfgfile/rte_cfgfile_version.map |   8 +
 4 files changed, 633 insertions(+), 200 deletions(-)

diff --git a/lib/librte_cfgfile/Makefile b/lib/librte_cfgfile/Makefile
index 032c240..616aef0 100644
--- a/lib/librte_cfgfile/Makefile
+++ b/lib/librte_cfgfile/Makefile
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)

 EXPORT_MAP := rte_cfgfile_version.map

-LIBABIVER := 1
+LIBABIVER := 2

 #
 # all source are stored in SRCS-y
diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index b81c273..defd80e 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -35,20 +35,26 @@
 #include 
 #include 
 #include 
+#include 
+
+#include 
+#include 
 #include 

 #include "rte_cfgfile.h"

 struct rte_cfgfile_section {
char name[CFG_NAME_LEN];
-   int num_entries;
-   struct rte_cfgfile_entry *entries[0];
+   size_t num_entries;
+   size_t allocated_entries;
+   struct rte_cfgfile_entry2 **entries;
 };

 struct rte_cfgfile {
int flags;
-   int num_sections;
-   struct rte_cfgfile_section *sections[0];
+   size_t num_sections;
+   size_t allocated_sections;
+   struct rte_cfgfile_section **sections;
 };

 /** when we resize a file structure, how many extra entries
@@ -58,208 +64,565 @@ struct rte_cfgfile {
  * for new entries do we add in */
 #define CFG_ALLOC_ENTRY_BATCH 16

-static unsigned
-_strip(char *str, unsigned len)
+/* Helpers */
+
+#define _skip_spaceses(str) ({  \
+   __typeof__(str) p = (str);  \
+   while (isspace(*p)) \
+   p++;\
+   p;  \
+})
+
+static size_t
+strip_leading_spaces(char *str, size_t len)
+{
+   char *start = _skip_spaceses(str);
+
+   if (*start == '\0') {
+   str[0] = '\0';
+   return 0;
+   } else if (start == str)
+   return len;
+
+   len -= start - str;
+   memmove(str, start, len);
+   str[len] = '\0';
+
+   return len;
+}
+
+static size_t
+strip_trailing_spaces(char *str, size_t len)
 {
-   int newlen = len;
+   size_t newlen = len;
+
+   /* strip trailing whitespace */
+   while (newlen > 0 && isspace(str[newlen - 1]))
+   str[--newlen] = '\0';
+
+   return newlen;
+}
+
+static size_t
+strip_white_spaces(char *str, size_t len)
+{
+   size_t newlen;
+
if (len == 0)
return 0;

-   if (isspace(str[len-1])) {
-   /* strip trailing whitespace */
-   while (newlen > 0 && isspace(str[newlen - 1]))
-   str[--newlen] = '\0';
+   /* strip trailing whitespace */
+   newlen = strip_trailing_spaces(str, len);
+   newlen = strip_leading_spaces(str, len);
+   return newlen;
+}
+
+static size_t
+strip_comment(char *buffer, size_t len)
+{
+   char *pos = memchr(buffer, ';', len);
+
+   if (pos == NULL)
+   return len;
+
+   if (len == 1) {
+   *pos = '\0';
+   return 0;
}

-   if (isspace(str[0])) {
-   /* strip leading whitespace */
-   int i, start = 1;
-   while (isspace(str[start]) && start < newlen)
-   start++
-   ; /* do nothing */
-   newlen -= start;
-   for (i = 0; i < newlen; i++)
-   str[i] = str[i+start];
-   str[i] = '\0';
+   if (buffer[len - 1] == '\n') {
+   if (buffer[len - 2] == '\\') {
+   pos[0] = '\\';
+   pos[1] = '\n';
+   pos[2] = '\0';
+   len = pos - buffer + 2;
+   } else {
+   pos[0] = '\n';
+   pos[1] = '\0';

[dpdk-dev] [PATCH 2/3] librte_compat: fix macro deffinition

2015-05-29 Thread Maciej Gajdzica
From: Pawel Wodkowski 

Signed-off-by: Pawel Wodkowski 
---
 lib/librte_compat/rte_compat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_compat/rte_compat.h b/lib/librte_compat/rte_compat.h
index 3a0fd2d..2a89b36 100644
--- a/lib/librte_compat/rte_compat.h
+++ b/lib/librte_compat/rte_compat.h
@@ -103,7 +103,7 @@
 #define VERSION_SYMBOL(b, e, v)
 #define __vsym
 #define BASE_SYMBOL(b, n)
-#define BIND_DEFAULT_SYMBOL(b, v)
+#define BIND_DEFAULT_SYMBOL(b, v, n)

 /*
  * RTE_BUILD_SHARED_LIB=n
-- 
1.9.1



[dpdk-dev] [PATCH 1/3] librte_cfgfile: fix code formating in header file

2015-05-29 Thread Maciej Gajdzica
From: Pawel Wodkowski 

Signed-off-by: Pawel Wodkowski 
---
 lib/librte_cfgfile/rte_cfgfile.h | 27 ++-
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/lib/librte_cfgfile/rte_cfgfile.h b/lib/librte_cfgfile/rte_cfgfile.h
index 7c9fc91..860ce44 100644
--- a/lib/librte_cfgfile/rte_cfgfile.h
+++ b/lib/librte_cfgfile/rte_cfgfile.h
@@ -69,7 +69,8 @@ struct rte_cfgfile_entry {
 * @return
 *   Handle to configuration file
 */
-struct rte_cfgfile *rte_cfgfile_load(const char *filename, int flags);
+struct rte_cfgfile *
+rte_cfgfile_load(const char *filename, int flags);

 /**
 * Get number of sections in config file
@@ -83,7 +84,8 @@ struct rte_cfgfile *rte_cfgfile_load(const char *filename, 
int flags);
 * @return
 *   0 on success, error code otherwise
 */
-int rte_cfgfile_num_sections(struct rte_cfgfile *cfg, const char *sec_name,
+int
+rte_cfgfile_num_sections(struct rte_cfgfile *cfg, const char *sec_name,
size_t length);

 /**
@@ -103,7 +105,8 @@ int rte_cfgfile_num_sections(struct rte_cfgfile *cfg, const 
char *sec_name,
 * @return
 *   0 on success, error code otherwise
 */
-int rte_cfgfile_sections(struct rte_cfgfile *cfg, char *sections[],
+int
+rte_cfgfile_sections(struct rte_cfgfile *cfg, char *sections[],
int max_sections);

 /**
@@ -116,7 +119,8 @@ int rte_cfgfile_sections(struct rte_cfgfile *cfg, char 
*sections[],
 * @return
 *   TRUE (value different than 0) if section exists, FALSE (value 0) otherwise
 */
-int rte_cfgfile_has_section(struct rte_cfgfile *cfg, const char *sectionname);
+int
+rte_cfgfile_has_section(struct rte_cfgfile *cfg, const char *sectionname);

 /**
 * Get number of entries in given config file section
@@ -128,7 +132,8 @@ int rte_cfgfile_has_section(struct rte_cfgfile *cfg, const 
char *sectionname);
 * @return
 *   Number of entries in section
 */
-int rte_cfgfile_section_num_entries(struct rte_cfgfile *cfg,
+int
+rte_cfgfile_section_num_entries(struct rte_cfgfile *cfg,
const char *sectionname);

 /** Get section entries as key-value pairs
@@ -145,7 +150,8 @@ int rte_cfgfile_section_num_entries(struct rte_cfgfile *cfg,
 * @return
 *   0 on success, error code otherwise
 */
-int rte_cfgfile_section_entries(struct rte_cfgfile *cfg,
+int
+rte_cfgfile_section_entries(struct rte_cfgfile *cfg,
const char *sectionname,
struct rte_cfgfile_entry *entries,
int max_entries);
@@ -161,7 +167,8 @@ int rte_cfgfile_section_entries(struct rte_cfgfile *cfg,
 * @return
 *   Entry value
 */
-const char *rte_cfgfile_get_entry(struct rte_cfgfile *cfg,
+const char *
+rte_cfgfile_get_entry(struct rte_cfgfile *cfg,
const char *sectionname,
const char *entryname);

@@ -176,7 +183,8 @@ const char *rte_cfgfile_get_entry(struct rte_cfgfile *cfg,
 * @return
 *   TRUE (value different than 0) if entry exists, FALSE (value 0) otherwise
 */
-int rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
+int
+rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
const char *entryname);

 /** Close config file
@@ -186,7 +194,8 @@ int rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const 
char *sectionname,
 * @return
 *   0 on success, error code otherwise
 */
-int rte_cfgfile_close(struct rte_cfgfile *cfg);
+int
+rte_cfgfile_close(struct rte_cfgfile *cfg);

 #ifdef __cplusplus
 }
-- 
1.9.1



[dpdk-dev] [PATCH 0/3] librte_cfgfile rework and extension

2015-05-29 Thread Maciej Gajdzica
From: Pawel Wodkowski 

This patchset provide extension to librte_cfgfile to overcome limit of 64
characters for entry value and add line continue feature.

Pawel Wodkowski (3):
  librte_cfgfile: fix code formating in header file
  librte_compat: fix macro deffinition
  librte_cfgfile: rework

 lib/librte_cfgfile/Makefile|   2 +-
 lib/librte_cfgfile/rte_cfgfile.c   | 792 ++---
 lib/librte_cfgfile/rte_cfgfile.h   |  52 +-
 lib/librte_cfgfile/rte_cfgfile_version.map |   8 +
 lib/librte_compat/rte_compat.h |   2 +-
 5 files changed, 649 insertions(+), 207 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH v8 01/11] eal/linux: add interrupt vectors support in intr_handle

2015-05-29 Thread Liang, Cunming
Hi Neil,

On 5/22/2015 1:58 AM, Neil Horman wrote:
> On Thu, May 21, 2015 at 10:43:00AM -0700, Stephen Hemminger wrote:
>> On Thu, 21 May 2015 06:32:02 -0400
>> Neil Horman  wrote:
>>
>>> On Thu, May 21, 2015 at 04:55:53PM +0800, Cunming Liang wrote:
 The patch adds interrupt vectors support in rte_intr_handle.
 'vec_en' is set when interrupt vectors are detected and associated event 
 fds are set.
 Those event fds are stored in efds[].
 'intr_vec' is reserved for device driver to initialize the vector mapping 
 table.
 When the event fds add to a specified epoll instance, 'elist' will hold 
 the rte_epoll_event object pointer.

 Signed-off-by: Danny Zhou 
 Signed-off-by: Cunming Liang 
 ---
 v7 changes:
   - add eptrs[], it's used to store the register rte_epoll_event instances.
   - add vec_en, to log the vector capability status.

 v6 changes:
   - add mapping table between irq vector number and queue id.

 v5 changes:
   - Create this new patch file for changed struct rte_intr_handle that
 other patches depend on, to avoid breaking git bisect.

   lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h | 10 
 ++
   1 file changed, 10 insertions(+)

 diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h 
 b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
 index 6a159c7..27174df 100644
 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
 +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
 @@ -38,6 +38,8 @@
   #ifndef _RTE_LINUXAPP_INTERRUPTS_H_
   #define _RTE_LINUXAPP_INTERRUPTS_H_
   
 +#define RTE_MAX_RXTX_INTR_VEC_ID 32
 +
   enum rte_intr_handle_type {
RTE_INTR_HANDLE_UNKNOWN = 0,
RTE_INTR_HANDLE_UIO,  /**< uio device handle */
 @@ -48,6 +50,8 @@ enum rte_intr_handle_type {
RTE_INTR_HANDLE_MAX
   };
   
 +struct rte_epoll_event;
 +
   /** Handle for interrupts. */
   struct rte_intr_handle {
union {
 @@ -57,6 +61,12 @@ struct rte_intr_handle {
};
int fd;  /**< interrupt event file descriptor */
enum rte_intr_handle_type type;  /**< handle type */
 +  uint32_t max_intr;   /**< max interrupt requested */
 +  uint32_t nb_efd; /**< number of available efds */
 +  int efds[RTE_MAX_RXTX_INTR_VEC_ID];  /**< intr vectors/efds mapping */
 +  struct rte_epoll_event *elist[RTE_MAX_RXTX_INTR_VEC_ID];
 +   /**< intr vector epoll event ptr */
 +  int *intr_vec;   /**< intr vector number array */
   };
 
>>> This is going to be ABI breaking if this from test_interrupts.c:
>>> static struct rte_intr_handle intr_handles[TEST_INTERRUPT_HANDLE_MAX];
>>>
>>> is a plausible way of using this structure.  Even putting the data at the 
>>> end of
>>> the structure won't help, as the array indicies are off
>> This needs to go in 2.0 and 2.0 has to have new ABI anyway.
>>
> We've already released 2.0, I think you mean 2.1, but 2.1 can't have a new ABI
> because we didn't announce it in 1.8.  The earliest we can update the ABI
> (according to the ABI docs) at this point is 2.2, since we need to announce 
> the
> change in 2.1, then make it in 2.2
>
> Neil
>
I'll follow your guidance to send a separate patch to announce the ABI 
changes in this release.
For this code patch series, I propose to turn off the whole feature by 
default so as to avoid ABI broken in this release.
On next release v2.2, I'll send another cleanup patch to remove the 
feature macro.
In this way, we either won't block the feature code review or won't 
break ABI.
For users who are still going to use the feature in v2.1, they shall 
make sure aware of the impact of ABI changes and take risk to turn on 
the feature manually.
The v9 patch will include this part. Does it sound good to you?

Thanks,
Steve


[dpdk-dev] [PATCH v9 12/12] abi: fix v2.1 abi broken issue

2015-05-29 Thread Cunming Liang
RTE_EAL_RX_INTR will be removed from v2.2. It's only used to avoid 
ABI(unannounced) broken in v2.1.
The usrs should make sure understand the impact before turning on the feature.
There are two abi changes required in this interrupt patch set.
They're 1) struct rte_intr_handle; 2) struct rte_intr_conf.

Signed-off-by: Cunming Liang 
---
 drivers/net/e1000/igb_ethdev.c | 28 -
 drivers/net/ixgbe/ixgbe_ethdev.c   | 41 -
 examples/l3fwd-power/main.c|  4 +-
 .../bsdapp/eal/include/exec-env/rte_interrupts.h   |  7 +++
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 12 
 .../linuxapp/eal/include/exec-env/rte_interrupts.h | 68 +-
 lib/librte_ether/rte_ethdev.c  |  2 +
 lib/librte_ether/rte_ethdev.h  | 32 +-
 8 files changed, 183 insertions(+), 11 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index bbd7b74..6f29222 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -96,7 +96,9 @@ static int  eth_igb_flow_ctrl_get(struct rte_eth_dev *dev,
 static int  eth_igb_flow_ctrl_set(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf);
 static int eth_igb_lsc_interrupt_setup(struct rte_eth_dev *dev);
+#ifdef RTE_EAL_RX_INTR
 static int eth_igb_rxq_interrupt_setup(struct rte_eth_dev *dev);
+#endif
 static int eth_igb_interrupt_get_status(struct rte_eth_dev *dev);
 static int eth_igb_interrupt_action(struct rte_eth_dev *dev);
 static void eth_igb_interrupt_handler(struct rte_intr_handle *handle,
@@ -199,11 +201,15 @@ static int eth_igb_rx_queue_intr_enable(struct 
rte_eth_dev *dev,
uint16_t queue_id);
 static int eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev,
uint16_t queue_id);
+#ifdef RTE_EAL_RX_INTR
 static void eth_igb_assign_msix_vector(struct e1000_hw *hw, int8_t direction,
uint8_t queue, uint8_t msix_vector);
+#endif
 static void eth_igb_configure_msix_intr(struct rte_eth_dev *dev);
+#ifdef RTE_EAL_RX_INTR
 static void eth_igb_write_ivar(struct e1000_hw *hw, uint8_t msix_vector,
uint8_t index, uint8_t offset);
+#endif

 /*
  * Define VF Stats MACRO for Non "cleared on read" register
@@ -760,7 +766,9 @@ eth_igb_start(struct rte_eth_dev *dev)
struct e1000_hw *hw =
E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct rte_intr_handle *intr_handle = >pci_dev->intr_handle;
+#ifdef RTE_EAL_RX_INTR
uint32_t intr_vector = 0;
+#endif
int ret, mask;
uint32_t ctrl_ext;

@@ -801,6 +809,7 @@ eth_igb_start(struct rte_eth_dev *dev)
/* configure PF module if SRIOV enabled */
igb_pf_host_configure(dev);

+#ifdef RTE_EAL_RX_INTR
/* check and configure queue intr-vector mapping */
if (dev->data->dev_conf.intr_conf.rxq != 0)
intr_vector = dev->data->nb_rx_queues;
@@ -818,6 +827,7 @@ eth_igb_start(struct rte_eth_dev *dev)
return -ENOMEM;
}
}
+#endif

/* confiugre msix for rx interrupt */
eth_igb_configure_msix_intr(dev);
@@ -913,9 +923,11 @@ eth_igb_start(struct rte_eth_dev *dev)
 " no intr multiplex\n");
}

+#ifdef RTE_EAL_RX_INTR
/* check if rxq interrupt is enabled */
if (dev->data->dev_conf.intr_conf.rxq != 0)
eth_igb_rxq_interrupt_setup(dev);
+#endif

/* enable uio/vfio intr/eventfd mapping */
rte_intr_enable(intr_handle);
@@ -1007,12 +1019,14 @@ eth_igb_stop(struct rte_eth_dev *dev)
}
filter_info->twotuple_mask = 0;

+#ifdef RTE_EAL_RX_INTR
/* Clean datapath event and queue/vec mapping */
rte_intr_efd_disable(intr_handle);
if (intr_handle->intr_vec != NULL) {
rte_free(intr_handle->intr_vec);
intr_handle->intr_vec = NULL;
}
+#endif
 }

 static void
@@ -1020,7 +1034,9 @@ eth_igb_close(struct rte_eth_dev *dev)
 {
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct rte_eth_link link;
+#ifdef RTE_EAL_RX_INTR
struct rte_pci_device *pci_dev;
+#endif

eth_igb_stop(dev);
e1000_phy_hw_reset(hw);
@@ -1038,11 +1054,13 @@ eth_igb_close(struct rte_eth_dev *dev)

igb_dev_clear_queues(dev);

+#ifdef RTE_EAL_RX_INTR
pci_dev = dev->pci_dev;
if (pci_dev->intr_handle.intr_vec) {
rte_free(pci_dev->intr_handle.intr_vec);
pci_dev->intr_handle.intr_vec = NULL;
}
+#endif

memset(, 0, sizeof(link));
rte_igb_dev_atomic_write_link_status(dev, );
@@ -1867,6 +1885,7 @@ eth_igb_lsc_interrupt_setup(struct rte_eth_dev *dev)
return 0;
 }

+#ifdef RTE_EAL_RX_INTR
 

[dpdk-dev] [PATCH v9 11/12] l3fwd-power: enable one-shot rx interrupt and polling/interrupt mode switch

2015-05-29 Thread Cunming Liang
Demonstrate how to handle per rx queue interrupt in a NAPI-like
implementation in usersapce. PDK polling thread mainly works in
polling mode and switch to interrupt mode only if there is no
any packet received in recent polls.
Usersapce interrupt notification generally takes a lot more cycles
than kernel, so one-shot interrupt is used here to guarantee minimum
overhead and DPDK polling thread returns to polling mode immediately
once it receives an interrupt notificaiton for incoming packet.

Signed-off-by: Danny Zhou 
Signed-off-by: Cunming Liang 
---
v7 changes
 - using new APIs
 - demo multiple port/queue pair wait on the same epoll instance

v6 changes
 - Split event fd add and wait

v5 changes
 - Change invoked function name and parameter to accomodate EAL change

v3 changes
 - Add spinlock to ensure thread safe when accessing interrupt mask
   register

v2 changes
 - Remove unused function which is for debug purpose

 examples/l3fwd-power/main.c | 207 +++-
 1 file changed, 165 insertions(+), 42 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 6ac342b..538bb93 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -74,12 +74,14 @@
 #include 
 #include 
 #include 
+#include 
+#include 

 #define RTE_LOGTYPE_L3FWD_POWER RTE_LOGTYPE_USER1

 #define MAX_PKT_BURST 32

-#define MIN_ZERO_POLL_COUNT 5
+#define MIN_ZERO_POLL_COUNT 10

 /* around 100ms at 2 Ghz */
 #define TIMER_RESOLUTION_CYCLES   2ULL
@@ -153,6 +155,9 @@ static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
 /* ethernet addresses of ports */
 static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];

+/* ethernet addresses of ports */
+static rte_spinlock_t locks[RTE_MAX_ETHPORTS];
+
 /* mask of enabled ports */
 static uint32_t enabled_port_mask = 0;
 /* Ports set in promiscuous mode off by default. */
@@ -185,6 +190,9 @@ struct lcore_rx_queue {
 #define MAX_TX_QUEUE_PER_PORT RTE_MAX_ETHPORTS
 #define MAX_RX_QUEUE_PER_PORT 128

+#define MAX_RX_QUEUE_INTERRUPT_PER_PORT 16
+
+
 #define MAX_LCORE_PARAMS 1024
 struct lcore_params {
uint8_t port_id;
@@ -211,7 +219,7 @@ static uint16_t nb_lcore_params = 
sizeof(lcore_params_array_default) /

 static struct rte_eth_conf port_conf = {
.rxmode = {
-   .mq_mode= ETH_MQ_RX_RSS,
+   .mq_mode = ETH_MQ_RX_RSS,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
.header_split   = 0, /**< Header Split disabled */
@@ -223,11 +231,15 @@ static struct rte_eth_conf port_conf = {
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
-   .rss_hf = ETH_RSS_IP,
+   .rss_hf = ETH_RSS_UDP,
},
},
.txmode = {
-   .mq_mode = ETH_DCB_NONE,
+   .mq_mode = ETH_MQ_TX_NONE,
+   },
+   .intr_conf = {
+   .lsc = 1,
+   .rxq = 1, /**< rxq interrupt feature enabled */
},
 };

@@ -399,19 +411,22 @@ power_timer_cb(__attribute__((unused)) struct rte_timer 
*tim,
/* accumulate total execution time in us when callback is invoked */
sleep_time_ratio = (float)(stats[lcore_id].sleep_time) /
(float)SCALING_PERIOD;
-
/**
 * check whether need to scale down frequency a step if it sleep a lot.
 */
-   if (sleep_time_ratio >= SCALING_DOWN_TIME_RATIO_THRESHOLD)
-   rte_power_freq_down(lcore_id);
+   if (sleep_time_ratio >= SCALING_DOWN_TIME_RATIO_THRESHOLD) {
+   if (rte_power_freq_down)
+   rte_power_freq_down(lcore_id);
+   }
else if ( (unsigned)(stats[lcore_id].nb_rx_processed /
-   stats[lcore_id].nb_iteration_looped) < MAX_PKT_BURST)
+   stats[lcore_id].nb_iteration_looped) < MAX_PKT_BURST) {
/**
 * scale down a step if average packet per iteration less
 * than expectation.
 */
-   rte_power_freq_down(lcore_id);
+   if (rte_power_freq_down)
+   rte_power_freq_down(lcore_id);
+   }

/**
 * initialize another timer according to current frequency to ensure
@@ -704,22 +719,20 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid,

 }

-#define SLEEP_GEAR1_THRESHOLD100
-#define SLEEP_GEAR2_THRESHOLD1000
+#define MINIMUM_SLEEP_TIME 1
+#define SUSPEND_THRESHOLD  300

 static inline uint32_t
 power_idle_heuristic(uint32_t zero_rx_packet_count)
 {
-   /* If zero count is less than 100, use it as the sleep time in us */
-   if (zero_rx_packet_count < SLEEP_GEAR1_THRESHOLD)
-   return zero_rx_packet_count;
-   /* If zero count is less than 1000, sleep time should be 100 us */
-   else if 

[dpdk-dev] [PATCH v9 10/12] igb: enable rx queue interrupts for PF

2015-05-29 Thread Cunming Liang
The patch does below for igb PF:
- Setup NIC to generate MSI-X interrupts
- Set the IVAR register to map interrupt causes to vectors
- Implement interrupt enable/disable functions

Signed-off-by: Danny Zhou 
Signed-off-by: Cunming Liang 
---
v9 changes
 - move queue-vec mapping init from dev_configure to dev_start
 - fix link interrupt not working issue in vfio-msix

v8 changes
 - add vfio-msi/vfio-legacy and uio-legacy support

v7 changes
 - add condition check when intr vector is not enabled

v6 changes
 - fill queue-vector mapping table

v5 changes
 - Rebase the patchset onto the HEAD

v3 changes
 - Remove unnecessary variables in e1000_mac_info
 - Remove spinlok from PMD

v2 changes
 - Consolidate review comments related to coding style

 drivers/net/e1000/igb_ethdev.c | 285 -
 1 file changed, 252 insertions(+), 33 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index e4b370d..bbd7b74 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -96,6 +96,7 @@ static int  eth_igb_flow_ctrl_get(struct rte_eth_dev *dev,
 static int  eth_igb_flow_ctrl_set(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf);
 static int eth_igb_lsc_interrupt_setup(struct rte_eth_dev *dev);
+static int eth_igb_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int eth_igb_interrupt_get_status(struct rte_eth_dev *dev);
 static int eth_igb_interrupt_action(struct rte_eth_dev *dev);
 static void eth_igb_interrupt_handler(struct rte_intr_handle *handle,
@@ -194,6 +195,16 @@ static int eth_igb_filter_ctrl(struct rte_eth_dev *dev,
 enum rte_filter_op filter_op,
 void *arg);

+static int eth_igb_rx_queue_intr_enable(struct rte_eth_dev *dev,
+   uint16_t queue_id);
+static int eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev,
+   uint16_t queue_id);
+static void eth_igb_assign_msix_vector(struct e1000_hw *hw, int8_t direction,
+   uint8_t queue, uint8_t msix_vector);
+static void eth_igb_configure_msix_intr(struct rte_eth_dev *dev);
+static void eth_igb_write_ivar(struct e1000_hw *hw, uint8_t msix_vector,
+   uint8_t index, uint8_t offset);
+
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */
@@ -253,6 +264,8 @@ static const struct eth_dev_ops eth_igb_ops = {
.vlan_tpid_set= eth_igb_vlan_tpid_set,
.vlan_offload_set = eth_igb_vlan_offload_set,
.rx_queue_setup   = eth_igb_rx_queue_setup,
+   .rx_queue_intr_enable = eth_igb_rx_queue_intr_enable,
+   .rx_queue_intr_disable = eth_igb_rx_queue_intr_disable,
.rx_queue_release = eth_igb_rx_queue_release,
.rx_queue_count   = eth_igb_rx_queue_count,
.rx_descriptor_done   = eth_igb_rx_descriptor_done,
@@ -584,12 +597,6 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 eth_dev->data->port_id, pci_dev->id.vendor_id,
 pci_dev->id.device_id);

-   rte_intr_callback_register(&(pci_dev->intr_handle),
-   eth_igb_interrupt_handler, (void *)eth_dev);
-
-   /* enable uio intr after callback register */
-   rte_intr_enable(&(pci_dev->intr_handle));
-
/* enable support intr */
igb_intr_enable(eth_dev);

@@ -752,7 +759,9 @@ eth_igb_start(struct rte_eth_dev *dev)
 {
struct e1000_hw *hw =
E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-   int ret, i, mask;
+   struct rte_intr_handle *intr_handle = >pci_dev->intr_handle;
+   uint32_t intr_vector = 0;
+   int ret, mask;
uint32_t ctrl_ext;

PMD_INIT_FUNC_TRACE();
@@ -792,6 +801,27 @@ eth_igb_start(struct rte_eth_dev *dev)
/* configure PF module if SRIOV enabled */
igb_pf_host_configure(dev);

+   /* check and configure queue intr-vector mapping */
+   if (dev->data->dev_conf.intr_conf.rxq != 0)
+   intr_vector = dev->data->nb_rx_queues;
+
+   if (rte_intr_efd_enable(intr_handle, intr_vector))
+   return -1;
+
+   if (rte_intr_dp_is_en(intr_handle)) {
+   intr_handle->intr_vec =
+   rte_zmalloc("intr_vec",
+   dev->data->nb_rx_queues * sizeof(int), 0);
+   if (intr_handle->intr_vec == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
+" intr_vec\n", dev->data->nb_rx_queues);
+   return -ENOMEM;
+   }
+   }
+
+   /* confiugre msix for rx interrupt */
+   eth_igb_configure_msix_intr(dev);
+
/* Configure for OS presence */
igb_init_manageability(hw);

@@ -819,33 +849,9 @@ eth_igb_start(struct rte_eth_dev *dev)

[dpdk-dev] [PATCH v9 09/12] ixgbe: enable rx queue interrupts for both PF and VF

2015-05-29 Thread Cunming Liang
The patch does below things for ixgbe PF and VF:
- Setup NIC to generate MSI-X interrupts
- Set the IVAR register to map interrupt causes to vectors
- Implement interrupt enable/disable functions

Signed-off-by: Danny Zhou 
Signed-off-by: Yong Liu 
Signed-off-by: Cunming Liang 
---
v9 changes
 - move queue-vec mapping init from dev_configure to dev_start

v8 changes
 - add vfio-msi/vfio-legacy and uio-legacy support

v7 changes
 - add condition check when intr vector is not enabled

v6 changes
 - fill queue-vector mapping table

v5 changes
 - Rebase the patchset onto the HEAD

v3 changes
 - Remove spinlok from PMD

v2 changes
 - Consolidate review comments related to coding style

 drivers/net/ixgbe/ixgbe_ethdev.c | 484 ++-
 drivers/net/ixgbe/ixgbe_ethdev.h |   4 +
 2 files changed, 476 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 0d9f9b2..798bb85 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -82,6 +82,9 @@
  */
 #define IXGBE_FC_LO0x40

+/* Default minimum inter-interrupt interval for EITR configuration */
+#define IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT0x79E
+
 /* Timer value included in XOFF frames. */
 #define IXGBE_FC_PAUSE 0x680

@@ -171,6 +174,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
+static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev);
 static void ixgbe_dev_interrupt_handler(struct rte_intr_handle *handle,
@@ -183,11 +187,14 @@ static void ixgbe_dcb_init(struct ixgbe_hw *hw,struct 
ixgbe_dcb_config *dcb_conf

 /* For Virtual Function support */
 static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
+static int ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev);
+static int ixgbevf_dev_interrupt_action(struct rte_eth_dev *dev);
 static int  ixgbevf_dev_configure(struct rte_eth_dev *dev);
 static int  ixgbevf_dev_start(struct rte_eth_dev *dev);
 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
+static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
 static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *stats);
 static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
@@ -197,6 +204,15 @@ static void ixgbevf_vlan_strip_queue_set(struct 
rte_eth_dev *dev,
uint16_t queue, int on);
 static void ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
+static void ixgbevf_dev_interrupt_handler(struct rte_intr_handle *handle,
+   void *param);
+static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
+   uint16_t queue_id);
+static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
+uint16_t queue_id);
+static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
+uint8_t queue, uint8_t msix_vector);
+static void ixgbevf_configure_msix(struct rte_eth_dev *dev);

 /* For Eth VMDQ APIs support */
 static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
@@ -214,6 +230,14 @@ static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
uint8_t rule_id);

+static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
+   uint16_t queue_id);
+static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
+   uint16_t queue_id);
+static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
+   uint8_t queue, uint8_t msix_vector);
+static void ixgbe_configure_msix(struct rte_eth_dev *dev);
+
 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
uint16_t queue_idx, uint16_t tx_rate);
 static int ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
@@ -262,7 +286,7 @@ static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, 
uint16_t mtu);
  */
 #define UPDATE_VF_STAT(reg, last, cur) \
 {   \
-   u32 latest = IXGBE_READ_REG(hw, reg);   \
+   uint32_t latest = IXGBE_READ_REG(hw, reg);   \
cur += latest - last;   \
last = latest;  \
 }
@@ -343,6 +367,8 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {

[dpdk-dev] [PATCH v9 08/12] ethdev: add rx intr enable, disable and ctl functions

2015-05-29 Thread Cunming Liang
The patch adds two dev_ops functions to enable and disable rx queue interrupts.
In addtion, it adds rte_eth_dev_rx_intr_ctl/rx_intr_q to support per port or 
per queue rx intr event set.

Signed-off-by: Danny Zhou 
Signed-off-by: Cunming Liang 
---
v9 changes
 - remove unnecessary check after rte_eth_dev_is_valid_port.
   the same as http://www.dpdk.org/dev/patchwork/patch/4784

v8 changes
 - add addtion check for EEXIT

v7 changes
 - remove rx_intr_vec_get
 - add rx_intr_ctl and rx_intr_ctl_q

v6 changes
 - add rx_intr_vec_get to retrieve the vector num of the queue.

v5 changes
 - Rebase the patchset onto the HEAD

v4 changes
 - Export interrupt enable/disable functions for shared libraries
 - Put new functions at the end of eth_dev_ops to avoid breaking ABI

v3 changes
 - Add return value for interrupt enable/disable functions

 lib/librte_ether/rte_ethdev.c  | 107 +
 lib/librte_ether/rte_ethdev.h  | 104 
 lib/librte_ether/rte_ether_version.map |   4 ++
 3 files changed, 215 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 024fe8b..846d7f8 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3281,6 +3281,113 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
}
rte_spinlock_unlock(_eth_dev_cb_lock);
 }
+
+int
+rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
+{
+   uint32_t vec;
+   struct rte_eth_dev *dev;
+   struct rte_intr_handle *intr_handle;
+   uint16_t qid;
+   int rc;
+
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
+   return -ENODEV;
+   }
+
+   dev = _eth_devices[port_id];
+   intr_handle = >pci_dev->intr_handle;
+   if (!intr_handle->intr_vec) {
+   PMD_DEBUG_TRACE("RX Intr vector unset\n");
+   return -EPERM;
+   }
+
+   for (qid = 0; qid < dev->data->nb_rx_queues; qid++) {
+   vec = intr_handle->intr_vec[qid];
+   rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
+   if (rc && rc != -EEXIST) {
+   PMD_DEBUG_TRACE("p %u q %u rx ctl error"
+   " op %d epfd %d vec %u\n",
+   port_id, qid, op, epfd, vec);
+   }
+   }
+
+   return 0;
+}
+
+int
+rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,
+ int epfd, int op, void *data)
+{
+   uint32_t vec;
+   struct rte_eth_dev *dev;
+   struct rte_intr_handle *intr_handle;
+   int rc;
+
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
+   return -ENODEV;
+   }
+
+   dev = _eth_devices[port_id];
+   if (queue_id >= dev->data->nb_rx_queues) {
+   PMD_DEBUG_TRACE("Invalid RX queue_id=%u\n", queue_id);
+   return -EINVAL;
+   }
+
+   intr_handle = >pci_dev->intr_handle;
+   if (!intr_handle->intr_vec) {
+   PMD_DEBUG_TRACE("RX Intr vector unset\n");
+   return -EPERM;
+   }
+
+   vec = intr_handle->intr_vec[queue_id];
+   rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
+   if (rc && rc != -EEXIST) {
+   PMD_DEBUG_TRACE("p %u q %u rx ctl error"
+   " op %d epfd %d vec %u\n",
+   port_id, queue_id, op, epfd, vec);
+   return rc;
+   }
+
+   return 0;
+}
+
+int
+rte_eth_dev_rx_intr_enable(uint8_t port_id,
+  uint16_t queue_id)
+{
+   struct rte_eth_dev *dev;
+
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   dev = _eth_devices[port_id];
+
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_enable, -ENOTSUP);
+   return (*dev->dev_ops->rx_queue_intr_enable)(dev, queue_id);
+}
+
+int
+rte_eth_dev_rx_intr_disable(uint8_t port_id,
+   uint16_t queue_id)
+{
+   struct rte_eth_dev *dev;
+
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   dev = _eth_devices[port_id];
+
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_disable, -ENOTSUP);
+   return (*dev->dev_ops->rx_queue_intr_disable)(dev, queue_id);
+}
+
 #ifdef RTE_NIC_BYPASS
 int rte_eth_dev_bypass_init(uint8_t port_id)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 16dbe00..c199d32 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -830,6 +830,8 @@ struct rte_eth_fdir {
 struct rte_intr_conf {
/** enable/disable lsc 

[dpdk-dev] [PATCH v9 07/12] eal/bsd: dummy for new intr definition

2015-05-29 Thread Cunming Liang
To make bsd compiling happy with new intr changes.

Signed-off-by: Cunming Liang 
---
v8 changes
 - add stub for new function

v7 changes
 - remove stub 'linux only' function from source file

 lib/librte_eal/bsdapp/eal/eal_interrupts.c | 19 ++
 .../bsdapp/eal/include/exec-env/rte_interrupts.h   | 74 ++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map  |  5 ++
 3 files changed, 98 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/eal_interrupts.c 
b/lib/librte_eal/bsdapp/eal/eal_interrupts.c
index cb7d4f1..ea85be3 100644
--- a/lib/librte_eal/bsdapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/bsdapp/eal/eal_interrupts.c
@@ -69,3 +69,22 @@ rte_eal_intr_init(void)
return 0;
 }

+int
+rte_intr_rx_ctl(struct rte_intr_handle *intr_handle,
+   int epfd, int op, unsigned int vec, void *data)
+{
+   return -ENOTSUP;
+}
+
+int
+rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd)
+{
+   return 0;
+}
+
+void
+rte_intr_efd_disable(struct rte_intr_handle *intr_handle)
+{
+   return;
+}
+
diff --git a/lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h 
b/lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h
index 87a9cf6..fc2c46b 100644
--- a/lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h
+++ b/lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h
@@ -49,6 +49,80 @@ enum rte_intr_handle_type {
 struct rte_intr_handle {
int fd;  /**< file descriptor */
enum rte_intr_handle_type type;  /**< handle type */
+   int max_intr;/**< max interrupt requested */
+   uint32_t nb_efd; /**< number of available efds */
+   int *intr_vec;   /**< intr vector number array */
 };

+/**
+ * @param intr_handle
+ *   Pointer to the interrupt handle.
+ * @param epfd
+ *   Epoll instance fd which the intr vector associated to.
+ * @param op
+ *   The operation be performed for the vector.
+ *   Operation type of {ADD, DEL}.
+ * @param vec
+ *   RX intr vector number added to the epoll instance wait list.
+ * @param data
+ *   User raw data.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+int
+rte_intr_rx_ctl(struct rte_intr_handle *intr_handle,
+   int epfd, int op, unsigned int vec, void *data);
+
+/**
+ * It enables the fastpath event fds if it's necessary.
+ * It creates event fds when multi-vectors allowed,
+ * otherwise it multiplexes the single event fds.
+ *
+ * @param intr_handle
+ *   Pointer to the interrupt handle.
+ * @param nb_vec
+ *   Number of intrrupt vector trying to enable.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+int
+rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd);
+
+/**
+ * It disable the fastpath event fds.
+ * It deletes registered eventfds and closes the open fds.
+ *
+ * @param intr_handle
+ *   Pointer to the interrupt handle.
+ */
+void
+rte_intr_efd_disable(struct rte_intr_handle *intr_handle);
+
+/**
+ * The fastpath interrupt is enabled or not.
+ *
+ * @param intr_handle
+ *   Pointer to the interrupt handle.
+ */
+static inline int
+rte_intr_dp_is_en(struct rte_intr_handle *intr_handle)
+{
+   return 0;
+}
+
+/**
+ * The interrupt handle instance allows other cause or not.
+ * Other cause stands for none fastpath interrupt.
+ *
+ * @param intr_handle
+ *   Pointer to the interrupt handle.
+ */
+static inline int
+rte_intr_allow_others(struct rte_intr_handle *intr_handle)
+{
+   return 1;
+}
+
 #endif /* _RTE_LINUXAPP_INTERRUPTS_H_ */
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 67b6a6c..a74671b 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -53,8 +53,13 @@ DPDK_2.0 {
rte_hexdump;
rte_intr_callback_register;
rte_intr_callback_unregister;
+   rte_intr_allow_others;
rte_intr_disable;
+   rte_intr_dp_is_en;
+   rte_intr_efd_enable;
+   rte_intr_efd_disable;
rte_intr_enable;
+   rte_intr_rx_ctl;
rte_log;
rte_log_add_in_history;
rte_log_cur_msg_loglevel;
-- 
1.8.1.4



[dpdk-dev] [PATCH v9 06/12] eal/linux: standalone intr event fd create support

2015-05-29 Thread Cunming Liang
The patch exposes intr event fd create and release for PMD.
The device driver can assign the number of event associated with interrupt 
vector.
It also provides misc funtions to check 1) allows other slowpath intr(e.g. lsc);
2) intr event on fastpath is enabled or not.

Signed-off-by: Cunming Liang 
---
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 57 ++
 .../linuxapp/eal/include/exec-env/rte_interrupts.h | 51 +++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map|  4 ++
 3 files changed, 112 insertions(+)

diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c 
b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index c39e206..1b80359 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -68,6 +69,7 @@
 #include "eal_vfio.h"

 #define EAL_INTR_EPOLL_WAIT_FOREVER (-1)
+#define NB_OTHER_INTR   1

 static RTE_DEFINE_PER_LCORE(int, _epfd) = -1; /**< epoll fd per thread */

@@ -1108,3 +1110,58 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int 
epfd,

return rc;
 }
+
+int
+rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd)
+{
+   uint32_t i;
+   int fd;
+   uint32_t n = RTE_MIN(nb_efd, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID);
+
+   if (intr_handle->type == RTE_INTR_HANDLE_VFIO_MSIX) {
+   for (i = 0; i < n; i++) {
+   fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+   if (fd < 0) {
+   RTE_LOG(ERR, EAL,
+   "cannot setup eventfd,"
+   "error %i (%s)\n",
+   errno, strerror(errno));
+   return -1;
+   }
+   intr_handle->efds[i] = fd;
+   }
+   intr_handle->nb_efd   = n;
+   intr_handle->max_intr = NB_OTHER_INTR + n;
+   } else {
+   intr_handle->efds[0]  = intr_handle->fd;
+   intr_handle->nb_efd   = RTE_MIN(nb_efd, 1U);
+   intr_handle->max_intr = NB_OTHER_INTR;
+   }
+
+   return 0;
+}
+
+void
+rte_intr_efd_disable(struct rte_intr_handle *intr_handle)
+{
+   uint32_t i;
+   struct rte_epoll_event *rev;
+
+   for (i = 0; i < intr_handle->nb_efd; i++) {
+   rev = _handle->elist[i];
+   if (rev->status == RTE_EPOLL_INVALID)
+   continue;
+   if (rte_epoll_ctl(rev->epfd, EPOLL_CTL_DEL, rev->fd, rev)) {
+   /* force free if the entry valid */
+   eal_epoll_data_safe_free(rev);
+   rev->status = RTE_EPOLL_INVALID;
+   }
+   }
+
+   if (intr_handle->max_intr > intr_handle->nb_efd) {
+   for (i = 0; i < intr_handle->nb_efd; i++)
+   close(intr_handle->efds[i]);
+   }
+   intr_handle->nb_efd = 0;
+   intr_handle->max_intr = 0;
+}
diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h 
b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
index 8b7793f..7c8a62b 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
@@ -166,4 +166,55 @@ int
 rte_intr_rx_ctl(struct rte_intr_handle *intr_handle,
int epfd, int op, unsigned int vec, void *data);

+/**
+ * It enables the fastpath event fds if it's necessary.
+ * It creates event fds when multi-vectors allowed,
+ * otherwise it multiplexes the single event fds.
+ *
+ * @param intr_handle
+ *   Pointer to the interrupt handle.
+ * @param nb_vec
+ *   Number of intrrupt vector trying to enable.
+ * @return
+ *   - On success, zero.
+ *   - On failure, a negative value.
+ */
+int
+rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd);
+
+/**
+ * It disable the fastpath event fds.
+ * It deletes registered eventfds and closes the open fds.
+ *
+ * @param intr_handle
+ *   Pointer to the interrupt handle.
+ */
+void
+rte_intr_efd_disable(struct rte_intr_handle *intr_handle);
+
+/**
+ * The fastpath interrupt is enabled or not.
+ *
+ * @param intr_handle
+ *   Pointer to the interrupt handle.
+ */
+static inline int
+rte_intr_dp_is_en(struct rte_intr_handle *intr_handle)
+{
+   return !(!intr_handle->nb_efd);
+}
+
+/**
+ * The interrupt handle instance allows other cause or not.
+ * Other cause stands for none fastpath interrupt.
+ *
+ * @param intr_handle
+ *   Pointer to the interrupt handle.
+ */
+static inline int
+rte_intr_allow_others(struct rte_intr_handle *intr_handle)
+{
+   return !!(intr_handle->max_intr - intr_handle->nb_efd);
+}
+
 #endif /* _RTE_LINUXAPP_INTERRUPTS_H_ */
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 

[dpdk-dev] [PATCH v9 05/12] eal/linux: add interrupt vectors handling on VFIO

2015-05-29 Thread Cunming Liang
This patch does below:
 - Create VFIO eventfds for each interrupt vector (move to next)
 - Assign per interrupt vector's eventfd to VFIO by ioctl

Signed-off-by: Danny Zhou 
Signed-off-by: Cunming Liang 
---
v8 changes
 - move eventfd creation out of the setup_interrupts to a standalone function

v7 changes
 - cleanup unnecessary code change
 - split event and intr operation to other patches

 lib/librte_eal/linuxapp/eal/eal_interrupts.c | 50 
 1 file changed, 13 insertions(+), 37 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c 
b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 8891bd3..c39e206 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -128,6 +128,9 @@ static pthread_t intr_thread;
 #ifdef VFIO_PRESENT

 #define IRQ_SET_BUF_LEN  (sizeof(struct vfio_irq_set) + sizeof(int))
+/* irq set buffer length for queue interrupts and LSC interrupt */
+#define MSIX_IRQ_SET_BUF_LEN (sizeof(struct vfio_irq_set) + \
+ sizeof(int) * (RTE_MAX_RXTX_INTR_VEC_ID + 1))

 /* enable legacy (INTx) interrupts */
 static int
@@ -245,23 +248,6 @@ vfio_enable_msi(struct rte_intr_handle *intr_handle) {
intr_handle->fd);
return -1;
}
-
-   /* manually trigger interrupt to enable it */
-   memset(irq_set, 0, len);
-   len = sizeof(struct vfio_irq_set);
-   irq_set->argsz = len;
-   irq_set->count = 1;
-   irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER;
-   irq_set->index = VFIO_PCI_MSI_IRQ_INDEX;
-   irq_set->start = 0;
-
-   ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
-
-   if (ret) {
-   RTE_LOG(ERR, EAL, "Error triggering MSI interrupts for fd %d\n",
-   intr_handle->fd);
-   return -1;
-   }
return 0;
 }

@@ -294,7 +280,7 @@ vfio_disable_msi(struct rte_intr_handle *intr_handle) {
 static int
 vfio_enable_msix(struct rte_intr_handle *intr_handle) {
int len, ret;
-   char irq_set_buf[IRQ_SET_BUF_LEN];
+   char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
struct vfio_irq_set *irq_set;
int *fd_ptr;

@@ -302,12 +288,18 @@ vfio_enable_msix(struct rte_intr_handle *intr_handle) {

irq_set = (struct vfio_irq_set *) irq_set_buf;
irq_set->argsz = len;
-   irq_set->count = 1;
+   if (!intr_handle->max_intr)
+   intr_handle->max_intr = 1;
+   else if (intr_handle->max_intr > RTE_MAX_RXTX_INTR_VEC_ID)
+   intr_handle->max_intr = RTE_MAX_RXTX_INTR_VEC_ID + 1;
+
+   irq_set->count = intr_handle->max_intr;
irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | 
VFIO_IRQ_SET_ACTION_TRIGGER;
irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
irq_set->start = 0;
fd_ptr = (int *) _set->data;
-   *fd_ptr = intr_handle->fd;
+   memcpy(fd_ptr, intr_handle->efds, sizeof(intr_handle->efds));
+   fd_ptr[intr_handle->max_intr - 1] = intr_handle->fd;

ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);

@@ -317,22 +309,6 @@ vfio_enable_msix(struct rte_intr_handle *intr_handle) {
return -1;
}

-   /* manually trigger interrupt to enable it */
-   memset(irq_set, 0, len);
-   len = sizeof(struct vfio_irq_set);
-   irq_set->argsz = len;
-   irq_set->count = 1;
-   irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER;
-   irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
-   irq_set->start = 0;
-
-   ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
-
-   if (ret) {
-   RTE_LOG(ERR, EAL, "Error triggering MSI-X interrupts for fd 
%d\n",
-   intr_handle->fd);
-   return -1;
-   }
return 0;
 }

@@ -340,7 +316,7 @@ vfio_enable_msix(struct rte_intr_handle *intr_handle) {
 static int
 vfio_disable_msix(struct rte_intr_handle *intr_handle) {
struct vfio_irq_set *irq_set;
-   char irq_set_buf[IRQ_SET_BUF_LEN];
+   char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
int len, ret;

len = sizeof(struct vfio_irq_set);
-- 
1.8.1.4



[dpdk-dev] [PATCH v9 03/12] eal/linux: add API to set rx interrupt event monitor

2015-05-29 Thread Cunming Liang
The patch adds 'rte_intr_rx_ctl' to add or delete interrupt vector events 
monitor on specified epoll instance.

Signed-off-by: Cunming Liang 
---
v8 changes
 - fix EWOULDBLOCK and EINTR processing
 - add event status check

v7 changes
 - rename rte_intr_rx_set to rte_intr_rx_ctl.
 - rte_intr_rx_ctl uses rte_epoll_ctl to register epoll event instance.
 - the intr rx event instance includes a intr process callback.

v6 changes
 - split rte_intr_wait_rx_pkt into two function, wait and set.
 - rewrite rte_intr_rx_wait/rte_intr_rx_set to remove queue visibility on eal.
 - rte_intr_rx_wait to support multiplexing.
 - allow epfd as input to support flexible event fd combination.

 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 100 +
 .../linuxapp/eal/include/exec-env/rte_interrupts.h |  20 +
 lib/librte_eal/linuxapp/eal/rte_eal_version.map|   1 +
 3 files changed, 121 insertions(+)

diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c 
b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 2f56000..e2392cb 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -897,6 +897,49 @@ rte_eal_intr_init(void)
return -ret;
 }

+static void
+eal_intr_proc_rxtx_intr(int fd, const struct rte_intr_handle *intr_handle)
+{
+   union rte_intr_read_buffer buf;
+   int bytes_read = 1;
+
+   switch (intr_handle->type) {
+   case RTE_INTR_HANDLE_UIO:
+   bytes_read = sizeof(buf.uio_intr_count);
+   break;
+#ifdef VFIO_PRESENT
+   case RTE_INTR_HANDLE_VFIO_MSIX:
+   case RTE_INTR_HANDLE_VFIO_MSI:
+   case RTE_INTR_HANDLE_VFIO_LEGACY:
+   bytes_read = sizeof(buf.vfio_intr_count);
+   break;
+#endif
+   default:
+   bytes_read = 1;
+   RTE_LOG(INFO, EAL, "unexpected intr type\n");
+   break;
+   }
+
+   /**
+* read out to clear the ready-to-be-read flag
+* for epoll_wait.
+*/
+   do {
+   bytes_read = read(fd, , bytes_read);
+   if (bytes_read < 0) {
+   if (errno == EINTR || errno == EWOULDBLOCK ||
+   errno == EAGAIN)
+   continue;
+   RTE_LOG(ERR, EAL, "Error reading from file "
+   "descriptor %d: %s\n", fd,
+   strerror(errno));
+   } else if (bytes_read == 0)
+   RTE_LOG(ERR, EAL, "Read nothing from file "
+   "descriptor %d\n", fd);
+   return;
+   } while (1);
+}
+
 static int
 eal_epoll_process_event(struct epoll_event *evs, unsigned int n,
struct rte_epoll_event *events)
@@ -1032,3 +1075,60 @@ rte_epoll_ctl(int epfd, int op, int fd,

return 0;
 }
+
+int
+rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,
+   int op, unsigned int vec, void *data)
+{
+   struct rte_epoll_event *rev;
+   struct rte_epoll_data *epdata;
+   int epfd_op;
+   int rc = 0;
+
+   if (!intr_handle || intr_handle->nb_efd == 0 ||
+   vec >= intr_handle->nb_efd) {
+   RTE_LOG(ERR, EAL, "Wrong intr vector number.\n");
+   return -EPERM;
+   }
+
+   switch (op) {
+   case RTE_INTR_EVENT_ADD:
+   epfd_op = EPOLL_CTL_ADD;
+   rev = _handle->elist[vec];
+   if (rev->status != RTE_EPOLL_INVALID) {
+   RTE_LOG(INFO, EAL, "Event already been added.\n");
+   return -EEXIST;
+   }
+
+   /* attach to intr vector fd */
+   epdata = >epdata;
+   epdata->event  = EPOLLIN | EPOLLPRI | EPOLLET;
+   epdata->data   = data;
+   epdata->cb_fun = (rte_intr_event_cb_t)eal_intr_proc_rxtx_intr;
+   epdata->cb_arg = (void *)intr_handle;
+   rc = rte_epoll_ctl(epfd, epfd_op, intr_handle->efds[vec], rev);
+   if (!rc)
+   RTE_LOG(DEBUG, EAL, "eventfd %d associated with vec %d"
+   " is added on epfd %d\n", rev->fd, vec, epfd);
+   else
+   rc = -EPERM;
+   break;
+   case RTE_INTR_EVENT_DEL:
+   epfd_op = EPOLL_CTL_DEL;
+   rev = _handle->elist[vec];
+   if (rev->status == RTE_EPOLL_INVALID) {
+   RTE_LOG(INFO, EAL, "Event does not exist.\n");
+   return -EPERM;
+   }
+
+   rc = rte_epoll_ctl(rev->epfd, epfd_op, rev->fd, rev);
+   if (rc)
+   rc = -EPERM;
+   break;
+   default:
+   RTE_LOG(ERR, EAL, "event op type mismatch\n");
+   rc = -EPERM;
+   }
+
+   return rc;
+}
diff --git 

[dpdk-dev] [PATCH v9 02/12] eal/linux: add rte_epoll_wait/ctl support

2015-05-29 Thread Cunming Liang
The patch adds 'rte_epoll_wait' and 'rte_epoll_ctl' for async event wakeup.
It defines 'struct rte_epoll_event' as the event param.
The 'op' uses the same enum as epoll_wait/ctl does.
The epoll event support to carry a raw user data and to register a callback 
which is exectuted during wakeup.

Signed-off-by: Cunming Liang 
---
v9 changes
 - rework on coding style

v8 changes
 - support delete event in safety during the wakeup execution
 - add EINTR process during epoll_wait

v7 changes
 - split v6[4/8] into two patches, one for epoll event(this one)
   another for rx intr(next patch)
 - introduce rte_epoll_event definition
 - rte_epoll_wait/ctl for more generic RTE epoll API

v6 changes
 - split rte_intr_wait_rx_pkt into two function, wait and set.
 - rewrite rte_intr_rx_wait/rte_intr_rx_set to remove queue visibility on eal.
 - rte_intr_rx_wait to support multiplexing.
 - allow epfd as input to support flexible event fd combination.

 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 137 +
 .../linuxapp/eal/include/exec-env/rte_interrupts.h |  82 +++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map|   3 +
 3 files changed, 219 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c 
b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 3a84b3c..2f56000 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -69,6 +69,8 @@

 #define EAL_INTR_EPOLL_WAIT_FOREVER (-1)

+static RTE_DEFINE_PER_LCORE(int, _epfd) = -1; /**< epoll fd per thread */
+
 /**
  * union for pipe fds.
  */
@@ -895,3 +897,138 @@ rte_eal_intr_init(void)
return -ret;
 }

+static int
+eal_epoll_process_event(struct epoll_event *evs, unsigned int n,
+   struct rte_epoll_event *events)
+{
+   unsigned int i, count = 0;
+   struct rte_epoll_event *rev;
+
+   for (i = 0; i < n; i++) {
+   rev = evs[i].data.ptr;
+   if (!rev || !rte_atomic32_cmpset(>status, RTE_EPOLL_VALID,
+RTE_EPOLL_EXEC))
+   continue;
+
+   events[count].status= RTE_EPOLL_VALID;
+   events[count].fd= rev->fd;
+   events[count].epfd  = rev->epfd;
+   events[count].epdata.event  = rev->epdata.event;
+   events[count].epdata.data   = rev->epdata.data;
+   if (rev->epdata.cb_fun)
+   rev->epdata.cb_fun(rev->fd,
+  rev->epdata.cb_arg);
+
+   rte_compiler_barrier();
+   rev->status = RTE_EPOLL_VALID;
+   count++;
+   }
+   return count;
+}
+
+static inline int
+eal_init_tls_epfd(void)
+{
+   int pfd = epoll_create(255);
+   if (pfd < 0) {
+   RTE_LOG(ERR, EAL,
+   "Cannot create epoll instance\n");
+   return -1;
+   }
+   return pfd;
+}
+
+int
+rte_intr_tls_epfd(void)
+{
+   if (RTE_PER_LCORE(_epfd) == -1)
+   RTE_PER_LCORE(_epfd) = eal_init_tls_epfd();
+
+   return RTE_PER_LCORE(_epfd);
+}
+
+int
+rte_epoll_wait(int epfd, struct rte_epoll_event *events,
+  int maxevents, int timeout)
+{
+   struct epoll_event evs[maxevents];
+   int rc;
+
+   if (!events) {
+   RTE_LOG(ERR, EAL, "rte_epoll_event can't be NULL\n");
+   return -1;
+   }
+
+   /* using per thread epoll fd */
+   if (epfd == RTE_EPOLL_PER_THREAD)
+   epfd = rte_intr_tls_epfd();
+
+   while (1) {
+   rc = epoll_wait(epfd, evs, maxevents, timeout);
+   if (likely(rc > 0)) {
+   /* epoll_wait has at least one fd ready to read */
+   rc = eal_epoll_process_event(evs, rc, events);
+   break;
+   } else if (rc < 0) {
+   if (errno == EINTR)
+   continue;
+   /* epoll_wait fail */
+   RTE_LOG(ERR, EAL, "epoll_wait returns with fail %s\n",
+   strerror(errno));
+   rc = -1;
+   break;
+   }
+   }
+
+   return rc;
+}
+
+static inline void
+eal_epoll_data_safe_free(struct rte_epoll_event *ev)
+{
+   while (!rte_atomic32_cmpset(>status, RTE_EPOLL_VALID,
+   RTE_EPOLL_INVALID))
+   while (ev->status != RTE_EPOLL_VALID)
+   rte_pause();
+   memset(>epdata, 0, sizeof(ev->epdata));
+   ev->fd = -1;
+   ev->epfd = -1;
+}
+
+int
+rte_epoll_ctl(int epfd, int op, int fd,
+ struct rte_epoll_event *event)
+{
+   struct epoll_event ev;
+
+   if (!event) {
+   RTE_LOG(ERR, EAL, "rte_epoll_event can't be NULL\n");
+   return -1;
+   }
+
+ 

[dpdk-dev] [PATCH v9 01/12] eal/linux: add interrupt vectors support in intr_handle

2015-05-29 Thread Cunming Liang
The patch adds interrupt vectors support in rte_intr_handle.
'vec_en' is set when interrupt vectors are detected and associated event fds 
are set.
Those event fds are stored in efds[].
'intr_vec' is reserved for device driver to initialize the vector mapping table.
When the event fds add to a specified epoll instance, 'eptrs' will hold the 
rte_epoll_event object pointer.

Signed-off-by: Danny Zhou 
Signed-off-by: Cunming Liang 
---
v7 changes:
 - add eptrs[], it's used to store the register rte_epoll_event instances.
 - add vec_en, to log the vector capability status.

v6 changes:
 - add mapping table between irq vector number and queue id.

v5 changes:
 - Create this new patch file for changed struct rte_intr_handle that
   other patches depend on, to avoid breaking git bisect.

 lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h 
b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
index bdeb3fc..9c86a15 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
@@ -38,6 +38,8 @@
 #ifndef _RTE_LINUXAPP_INTERRUPTS_H_
 #define _RTE_LINUXAPP_INTERRUPTS_H_

+#define RTE_MAX_RXTX_INTR_VEC_ID 32
+
 enum rte_intr_handle_type {
RTE_INTR_HANDLE_UNKNOWN = 0,
RTE_INTR_HANDLE_UIO,  /**< uio device handle */
@@ -49,6 +51,8 @@ enum rte_intr_handle_type {
RTE_INTR_HANDLE_MAX
 };

+struct rte_epoll_event;
+
 /** Handle for interrupts. */
 struct rte_intr_handle {
union {
@@ -58,6 +62,12 @@ struct rte_intr_handle {
};
int fd;  /**< interrupt event file descriptor */
enum rte_intr_handle_type type;  /**< handle type */
+   uint32_t max_intr;   /**< max interrupt requested */
+   uint32_t nb_efd; /**< number of available efds */
+   int efds[RTE_MAX_RXTX_INTR_VEC_ID];  /**< intr vectors/efds mapping */
+   struct rte_epoll_event *elist[RTE_MAX_RXTX_INTR_VEC_ID];
+/**< intr vector epoll event ptr */
+   int *intr_vec;   /**< intr vector number array */
 };

 #endif /* _RTE_LINUXAPP_INTERRUPTS_H_ */
-- 
1.8.1.4



[dpdk-dev] [PATCH v9 00/12] Interrupt mode PMD

2015-05-29 Thread Cunming Liang
v9 changes
 - code rework to fix open comment
 - bug fix for igb lsc when both lsc and rxq are enabled in vfio-msix
 - new patch to turn off the feature by defalut so as to avoid v2.1 abi broken

v8 changes
 - remove condition check for only vfio-msix
 - add multiplex intr support when only one intr vector allowed
 - lsc and rxq interrupt runtime enable decision
 - add safe event delete while the event wakeup execution happens

v7 changes
 - decouple epoll event and intr operation
 - add condition check in the case intr vector is disabled
 - renaming some APIs

v6 changes
 - split rte_intr_wait_rx_pkt into two APIs 'wait' and 'set'.
 - rewrite rte_intr_rx_wait/rte_intr_rx_set.
 - using vector number instead of queue_id as interrupt API params.
 - patch reorder and split.

v5 changes
 - Rebase the patchset onto the HEAD
 - Isolate ethdev from EAL for new-added wait-for-rx interrupt function
 - Export wait-for-rx interrupt function for shared libraries
 - Split-off a new patch file for changed struct rte_intr_handle that
   other patches depend on, to avoid breaking git bisect
 - Change sample applicaiton to accomodate EAL function spec change
   accordingly

v4 changes
 - Export interrupt enable/disable functions for shared libraries
 - Adjust position of new-added structure fields and functions to
   avoid breaking ABI

v3 changes
 - Add return value for interrupt enable/disable functions
 - Move spinlok from PMD to L3fwd-power
 - Remove unnecessary variables in e1000_mac_info
 - Fix miscelleous review comments

v2 changes
 - Fix compilation issue in Makefile for missed header file.
 - Consolidate internal and community review comments of v1 patch set.

The patch series introduce low-latency one-shot rx interrupt into DPDK with
polling and interrupt mode switch control example.

DPDK userspace interrupt notification and handling mechanism is based on UIO
with below limitation:
1) It is designed to handle LSC interrupt only with inefficient suspended
   pthread wakeup procedure (e.g. UIO wakes up LSC interrupt handling thread
   which then wakes up DPDK polling thread). In this way, it introduces
   non-deterministic wakeup latency for DPDK polling thread as well as packet
   latency if it is used to handle Rx interrupt.
2) UIO only supports a single interrupt vector which has to been shared by
   LSC interrupt and interrupts assigned to dedicated rx queues.

This patchset includes below features:
1) Enable one-shot rx queue interrupt in ixgbe PMD(PF & VF) and igb PMD(PF 
only).
2) Build on top of the VFIO mechanism instead of UIO, so it could support
   up to 64 interrupt vectors for rx queue interrupts.
3) Have 1 DPDK polling thread handle per Rx queue interrupt with a dedicated
   VFIO eventfd, which eliminates non-deterministic pthread wakeup latency in
   user space.
4) Demonstrate interrupts control APIs and userspace NAIP-like polling/interrupt
   switch algorithms in L3fwd-power example.

Known limitations:
1) It does not work for UIO due to a single interrupt eventfd shared by LSC
   and rx queue interrupt handlers causes a mess. [FIXED]
2) LSC interrupt is not supported by VF driver, so it is by default disabled
   in L3fwd-power now. Feel free to turn in on if you want to support both LSC
   and rx queue interrupts on a PF.

Cunming Liang (12):
  eal/linux: add interrupt vectors support in intr_handle
  eal/linux: add rte_epoll_wait/ctl support
  eal/linux: add API to set rx interrupt event monitor
  eal/linux: fix comments typo on vfio msi
  eal/linux: add interrupt vectors handling on VFIO
  eal/linux: standalone intr event fd create support
  eal/bsd: dummy for new intr definition
  ethdev: add rx intr enable, disable and ctl functions
  ixgbe: enable rx queue interrupts for both PF and VF
  igb: enable rx queue interrupts for PF
  l3fwd-power: enable one-shot rx interrupt and polling/interrupt mode
switch
  abi: fix v2.1 abi broken issue

 drivers/net/e1000/igb_ethdev.c | 311 ++--
 drivers/net/ixgbe/ixgbe_ethdev.c   | 519 -
 drivers/net/ixgbe/ixgbe_ethdev.h   |   4 +
 examples/l3fwd-power/main.c| 207 ++--
 lib/librte_eal/bsdapp/eal/eal_interrupts.c |  19 +
 .../bsdapp/eal/include/exec-env/rte_interrupts.h   |  81 
 lib/librte_eal/bsdapp/eal/rte_eal_version.map  |   5 +
 lib/librte_eal/linuxapp/eal/eal_interrupts.c   | 358 --
 .../linuxapp/eal/include/exec-env/rte_interrupts.h | 219 +
 lib/librte_eal/linuxapp/eal/rte_eal_version.map|   8 +
 lib/librte_ether/rte_ethdev.c  | 109 +
 lib/librte_ether/rte_ethdev.h  | 132 ++
 lib/librte_ether/rte_ether_version.map |   4 +
 13 files changed, 1851 insertions(+), 125 deletions(-)

-- 
1.8.1.4



[dpdk-dev] [PATCH 6/6] fm10k: Add default mac/vlan filter to SM

2015-05-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Since the communication between PF/Switch Manager, VF/PF is
asynchronous through mailbox, it's hard to determine when Switch
Manager/PF host will send the default vlan to PF/VF. So, it's
necessary to set default vlan until the device is started.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k_ethdev.c |   18 +-
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index b6e82e3..3a26480 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -667,6 +667,17 @@ fm10k_dev_start(struct rte_eth_dev *dev)
}
}

+   if (hw->mac.default_vid && hw->mac.default_vid <= ETHER_MAX_VLAN_ID) {
+   fm10k_mbx_lock(hw);
+   /* Update default vlan */
+   hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0, true);
+
+   /* Add default mac/vlan filter to PF/Switch manger */
+   hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map, hw->mac.addr,
+   hw->mac.default_vid, true, 0);
+   fm10k_mbx_unlock(hw);
+   }
+
return 0;
 }

@@ -1839,15 +1850,12 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
/* Enable port first */
hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, 1, 1);

-   /* Update default vlan */
-   hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0, true);
-
/*
-* Add default mac/vlan filter. glort is assigned by SM for PF, while is
+* Add default mac. glort is assigned by SM for PF, while is
 * unused for VF. PF will assign correct glort for VF.
 */
hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map, hw->mac.addr,
- hw->mac.default_vid, 1, 0);
+   0, 1, 0);

/* Set unicast mode by default. App can change to other mode in other
 * API func.
-- 
1.7.7.6



[dpdk-dev] [PATCH 5/6] fm10k: Do sanity check on mac address

2015-05-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

After acquiring MAC address from HW, it's necessary to validate
MAC address before use.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k_ethdev.c |   24 ++--
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index dedfbb4..b6e82e3 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1756,24 +1756,20 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
}

diag = fm10k_read_mac_addr(hw);
-   if (diag != FM10K_SUCCESS) {
-   /*
-* TODO: remove special handling on VF. Need shared code to
-* fix first.
-*/
-   if (hw->mac.type == fm10k_mac_pf) {
-   PMD_INIT_LOG(ERR, "Read MAC addr failed: %d", diag);
-   return -EIO;
-   } else {
-   /* Generate a random addr */
-   eth_random_addr(hw->mac.addr);
-   memcpy(hw->mac.perm_addr, hw->mac.addr, ETH_ALEN);
-   }
-   }

ether_addr_copy((const struct ether_addr *)hw->mac.addr,
>data->mac_addrs[0]);

+   if (diag != FM10K_SUCCESS ||
+   !is_valid_assigned_ether_addr(dev->data->mac_addrs)) {
+
+   /* Generate a random addr */
+   eth_random_addr(hw->mac.addr);
+   memcpy(hw->mac.perm_addr, hw->mac.addr, ETH_ALEN);
+   ether_addr_copy((const struct ether_addr *)hw->mac.addr,
+   >data->mac_addrs[0]);
+   }
+
/* Reset the hw statistics */
fm10k_stats_reset(dev);

-- 
1.7.7.6



[dpdk-dev] [PATCH 3/6] fm10k: Fix data integrity issue with multi-segment frame

2015-05-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

In TX side, bit FM10K_TXD_FLAG_LAST in TX descriptor only is set
in the last descriptor for multi-segment packets. But current
implementation didn't set all the fields of TX descriptor, which
will cause descriptors processed now to re-use fields set in last
scroll. If FM10K_TXD_FLAG_LAST bit was set in the last round and
it happened this is not the last descriptor of a multi-segnment
packet, HW will send out the incomplete packet out and leads to
data intergrity issue.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k_rxtx.c |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_rxtx.c b/drivers/net/fm10k/fm10k_rxtx.c
index 56df6cd..f5d1ad0 100644
--- a/drivers/net/fm10k/fm10k_rxtx.c
+++ b/drivers/net/fm10k/fm10k_rxtx.c
@@ -402,9 +402,9 @@ static inline void tx_xmit_pkt(struct fm10k_tx_queue *q, 
struct rte_mbuf *mb)
q->nb_used = q->nb_used + mb->nb_segs;
}

-   q->hw_ring[last_id].flags = flags;
q->nb_free -= mb->nb_segs;

+   q->hw_ring[q->next_free].flags = 0;
/* set checksum flags on first descriptor of packet. SCTP checksum
 * offload is not supported, but we do not explicitly check for this
 * case in favor of greatly simplified processing. */
@@ -415,16 +415,27 @@ static inline void tx_xmit_pkt(struct fm10k_tx_queue *q, 
struct rte_mbuf *mb)
if (mb->ol_flags & PKT_TX_VLAN_PKT)
q->hw_ring[q->next_free].vlan = mb->vlan_tci;

+   q->sw_ring[q->next_free] = mb;
+   q->hw_ring[q->next_free].buffer_addr =
+   rte_cpu_to_le_64(MBUF_DMA_ADDR(mb));
+   q->hw_ring[q->next_free].buflen =
+   rte_cpu_to_le_16(rte_pktmbuf_data_len(mb));
+   if (++q->next_free == q->nb_desc)
+   q->next_free = 0;
+
/* fill up the rings */
-   for (; mb != NULL; mb = mb->next) {
+   for (mb = mb->next; mb != NULL; mb = mb->next) {
q->sw_ring[q->next_free] = mb;
q->hw_ring[q->next_free].buffer_addr =
rte_cpu_to_le_64(MBUF_DMA_ADDR(mb));
q->hw_ring[q->next_free].buflen =
rte_cpu_to_le_16(rte_pktmbuf_data_len(mb));
+   q->hw_ring[q->next_free].flags = 0;
if (++q->next_free == q->nb_desc)
q->next_free = 0;
}
+
+   q->hw_ring[last_id].flags = flags;
 }

 uint16_t
-- 
1.7.7.6



[dpdk-dev] [PATCH 2/6] fm10k: Fix jumbo frame issue

2015-05-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

fm10k can't receive frame greater than 1536 and Scatter RX
function can't work correctly. The root cause is
SRRCTL.FM10K_SRRCTL_BUFFER_CHAINING_EN bit is not enabled.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k_ethdev.c |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index a5e09a0..19e718b 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -439,9 +439,14 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev)

/* It adds dual VLAN length for supporting dual VLAN */
if ((dev->data->dev_conf.rxmode.max_rx_pkt_len +
-   2 * FM10K_VLAN_TAG_SIZE) > buf_size){
+   2 * FM10K_VLAN_TAG_SIZE) > buf_size ||
+   dev->data->dev_conf.rxmode.enable_scatter) {
+   uint32_t reg;
dev->data->scattered_rx = 1;
dev->rx_pkt_burst = fm10k_recv_scattered_pkts;
+   reg = FM10K_READ_REG(hw, FM10K_SRRCTL(i));
+   reg |= FM10K_SRRCTL_BUFFER_CHAINING_EN;
+   FM10K_WRITE_REG(hw, FM10K_SRRCTL(i), reg);
}

/* Enable drop on empty, it's RO for VF */
@@ -452,11 +457,6 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev)
FM10K_WRITE_FLUSH(hw);
}

-   if (dev->data->dev_conf.rxmode.enable_scatter) {
-   dev->rx_pkt_burst = fm10k_recv_scattered_pkts;
-   dev->data->scattered_rx = 1;
-   }
-
/* Configure RSS if applicable */
fm10k_dev_mq_rx_configure(dev);
return 0;
-- 
1.7.7.6



[dpdk-dev] [PATCH 1/6] fm10k: Fix improper RX buffer size assignment

2015-05-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

As RX buffer is aligned to 512B within mbuf, some bytes are reserved
for this purpose, and the worst case could be 511B. But SRR reg
assumes all buffers have the same size. In order to fill the gap,
we'll have to consider the worsst case and assume 512B is reserved.
If we don't do so, it's possible for HW to overwrite data to next
mbuf.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h|5 +++--
 drivers/net/fm10k/fm10k_ethdev.c |   12 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 0e31796..ad7a7d1 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -191,7 +191,8 @@ struct fm10k_tx_queue {

 /* enforce 512B alignment on default Rx DMA addresses */
 #define MBUF_DMA_ADDR_DEFAULT(mb) \
-   ((uint64_t) RTE_ALIGN(((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM), 512))
+   ((uint64_t) RTE_ALIGN(((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM),\
+   FM10K_RX_DATABUF_ALIGN))

 static inline void fifo_reset(struct fifo *fifo, uint32_t len)
 {
@@ -263,7 +264,7 @@ fm10k_addr_alignment_valid(struct rte_mbuf *mb)
uint64_t boundary1, boundary2;

/* 512B aligned? */
-   if (RTE_ALIGN(addr, 512) == addr)
+   if (RTE_ALIGN(addr, FM10K_RX_DATABUF_ALIGN) == addr)
return 1;

/* 8B aligned, and max Ethernet frame would not cross a 4KB boundary? */
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 275c19c..a5e09a0 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -41,7 +41,6 @@
 #include "fm10k.h"
 #include "base/fm10k_api.h"

-#define FM10K_RX_BUFF_ALIGN 512
 /* Default delay to acquire mailbox lock */
 #define FM10K_MBXLOCK_DELAY_US 20
 #define UINT64_LOWER_32BITS_MASK 0xULL
@@ -426,6 +425,15 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev)
/* Configure the Rx buffer size for one buff without split */
buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
RTE_PKTMBUF_HEADROOM);
+   /* As RX buffer is aligned to 512B within mbuf, some bytes are
+* reserved for this purpose, and the worst case could be 511B.
+* But SRR reg assumes all buffers have the same size. In order
+* to fill the gap, we'll have to consider the worst case and
+* assume 512B is reserved. If we don't do so, it's possible
+* for HW to overwrite data to next mbuf.
+*/
+   buf_size -= FM10K_RX_DATABUF_ALIGN;
+
FM10K_WRITE_REG(hw, FM10K_SRRCTL(i),
buf_size >> FM10K_SRRCTL_BSIZEPKT_SHIFT);

@@ -909,7 +917,7 @@ mempool_element_size_valid(struct rte_mempool *mp)
RTE_PKTMBUF_HEADROOM;

/* account for up to 512B of alignment */
-   min_size -= FM10K_RX_BUFF_ALIGN;
+   min_size -= FM10K_RX_DATABUF_ALIGN;

/* sanity check for overflow */
if (min_size > mp->elt_size)
-- 
1.7.7.6



[dpdk-dev] [PATCH 0/6] fm10k: A series of bug fixes

2015-05-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

This patch set include a few bug fixes and enhancements on fm10k driver.

Chen Jing D(Mark) (6):
  fm10k: Fix improper RX buffer size assignment
  fm10k: Fix jumbo frame issue
  fm10k: Fix data integrity issue with multi-segment frame
  fm10k: Fix issue that MAC addr can't be set to silicon
  fm10k: Do sanity check on mac address
  fm10k: Add default mac/vlan filter to SM

 drivers/net/fm10k/fm10k.h|5 +-
 drivers/net/fm10k/fm10k_ethdev.c |  100 ++---
 drivers/net/fm10k/fm10k_rxtx.c   |   15 +-
 3 files changed, 86 insertions(+), 34 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v2 10/10] examples/tep_termination:add the configuration for encapsulation and the decapsulation

2015-05-29 Thread Jijiang Liu
The two flags are enabled by default, but sometimes we want to know the 
performance influence of the encapsulation and decapsulation operations, and
I think we should add the two options

Signed-off-by: Jijiang Liu 
---
 examples/tep_termination/main.c|   36 
 examples/tep_termination/vxlan_setup.c |   13 +-
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index dd3dfea..43ff255 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -113,6 +113,8 @@
 #define CMD_LINE_OPT_TX_CHECKSUM "tx-checksum"
 #define CMD_LINE_OPT_TSO_SEGSZ "tso-segsz"
 #define CMD_LINE_OPT_FILTER_TYPE "filter-type"
+#define CMD_LINE_OPT_ENCAP "encap"
+#define CMD_LINE_OPT_DECAP "decap"
 #define CMD_LINE_OPT_RX_RETRY "rx-retry"
 #define CMD_LINE_OPT_RX_RETRY_DELAY "rx-retry-delay"
 #define CMD_LINE_OPT_RX_RETRY_NUM "rx-retry-num"
@@ -146,6 +148,12 @@ uint8_t tx_checksum;
 /* TSO segment size */
 uint16_t tso_segsz = 0;

+/* enable/disable decapsulation */
+uint8_t rx_decap = 1;
+
+/* enable/disable encapsulation */
+uint8_t tx_encap = 1;
+
 /* RX filter type for tunneling packet */
 uint8_t filter_idx;

@@ -275,6 +283,8 @@ tep_termination_usage(const char *prgname)
"   --nb-devices[1-64]: The number of virtIO device\n"
"   --tx-checksum [0|1]: inner Tx checksum offload\n"
"   --tso-segsz [0-N]: TSO segment size\n"
+   "   --decap [0|1]: tunneling packet decapsulation\n"
+   "   --encap [0|1]: tunneling packet encapsulation\n"
"   --filter-type[1-3]: filter type for tunneling packet\n"
"   1: Inner MAC and tenent ID\n"
"   2: Inner MAC and tenent ID\n"
@@ -306,6 +316,8 @@ tep_termination_parse_args(int argc, char **argv)
{CMD_LINE_OPT_UDP_PORT, required_argument, NULL, 0},
{CMD_LINE_OPT_TX_CHECKSUM, required_argument, NULL, 0},
{CMD_LINE_OPT_TSO_SEGSZ, required_argument, NULL, 0},
+   {CMD_LINE_OPT_DECAP, required_argument, NULL, 0},
+   {CMD_LINE_OPT_ENCAP, required_argument, NULL, 0},
{CMD_LINE_OPT_FILTER_TYPE, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY_DELAY, required_argument, NULL, 0},
@@ -401,6 +413,30 @@ tep_termination_parse_args(int argc, char **argv)
burst_rx_retry_num = ret;
}

+   /* Enable/disable encapsulation on RX. */
+   if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_DECAP,
+   sizeof(CMD_LINE_OPT_DECAP))) {
+   ret = parse_num_opt(optarg, 1);
+   if (ret == -1) {
+   RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for decap [0|1]\n");
+   tep_termination_usage(prgname);
+   return -1;
+   } else
+   rx_decap = ret;
+   }
+
+   /* Enable/disable encapsulation on TX. */
+   if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_ENCAP,
+   sizeof(CMD_LINE_OPT_ENCAP))) {
+   ret = parse_num_opt(optarg, 1);
+   if (ret == -1) {
+   RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for encap [0|1]\n");
+   tep_termination_usage(prgname);
+   return -1;
+   } else
+   tx_encap = ret;
+   }
+
if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_TX_CHECKSUM,
sizeof(CMD_LINE_OPT_TX_CHECKSUM))) {
ret = parse_num_opt(optarg, 1);
diff --git a/examples/tep_termination/vxlan_setup.c 
b/examples/tep_termination/vxlan_setup.c
index deb52ec..c3d9d44 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -81,6 +81,8 @@ extern uint16_t num_devices;
 extern uint16_t udp_port;
 extern uint8_t ports[RTE_MAX_ETHPORTS];
 extern uint8_t filter_idx;
+extern uint8_t rx_decap;
+extern uint8_t tx_encap;
 extern uint16_t tso_segsz;
 extern uint32_t enable_stats;
 extern struct device_statistics dev_statistics[MAX_DEVICES];
@@ -234,7 +236,12 @@ vxlan_port_init(uint8_t port, struct rte_mempool 
*mbuf_pool)
 static int
 vxlan_rx_process(struct rte_mbuf *pkt)
 {
-   return decapsulation(pkt);
+   

[dpdk-dev] [PATCH v2 09/10] examples/tep_termination:add bad Rx checksum statistics of inner IP and L4

2015-05-29 Thread Jijiang Liu
The number of packets with bad RX IP and L4 checksum in inner header is 
recorded.

Signed-off-by: Jijiang Liu 
---
 examples/tep_termination/main.c|   10 +-
 examples/tep_termination/main.h|4 
 examples/tep_termination/vxlan_setup.c |8 
 3 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index 995fd2a..dd3dfea 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -1003,7 +1003,7 @@ print_stats(void)
 {
struct virtio_net_data_ll *dev_ll;
uint64_t tx_dropped, rx_dropped;
-   uint64_t tx, tx_total, rx, rx_total;
+   uint64_t tx, tx_total, rx, rx_total, rx_ip_csum, rx_l4_csum;
uint32_t device_fh;
const char clr[] = { 27, '[', '2', 'J', '\0' };
const char top_left[] = { 27, '[', '1', ';', '1', 'H', '\0' };
@@ -1028,12 +1028,18 @@ print_stats(void)
rx = rte_atomic64_read(
_statistics[device_fh].rx_atomic);
rx_dropped = rx_total - rx;
+   rx_ip_csum = rte_atomic64_read(
+   _statistics[device_fh].rx_bad_ip_csum);
+   rx_l4_csum = rte_atomic64_read(
+   _statistics[device_fh].rx_bad_l4_csum);

printf("\nStatistics for device %"PRIu32" 
--"
"\nTX total:%"PRIu64""
"\nTX dropped:  %"PRIu64""
"\nTX successful:   
%"PRIu64""
"\nRX total:%"PRIu64""
+   "\nRX bad IP csum:  %"PRIu64""
+   "\nRX bad L4 csum:  %"PRIu64""
"\nRX dropped:  %"PRIu64""
"\nRX successful:   
%"PRIu64"",
device_fh,
@@ -1041,6 +1047,8 @@ print_stats(void)
tx_dropped,
tx,
rx_total,
+   rx_ip_csum,
+   rx_l4_csum,
rx_dropped,
rx);

diff --git a/examples/tep_termination/main.h b/examples/tep_termination/main.h
index 74c3d98..5cf1157 100644
--- a/examples/tep_termination/main.h
+++ b/examples/tep_termination/main.h
@@ -69,6 +69,10 @@ struct device_statistics {
uint64_t rx_total;
uint64_t tx;
rte_atomic64_t rx_atomic;
+   /**< Bad inner IP csum for tunneling pkt */
+   rte_atomic64_t rx_bad_ip_csum;
+   /**< Bad inner L4 csum for tunneling pkt */
+   rte_atomic64_t rx_bad_l4_csum;
 } __rte_cache_aligned;

 /**
diff --git a/examples/tep_termination/vxlan_setup.c 
b/examples/tep_termination/vxlan_setup.c
index 528b74a..deb52ec 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -82,6 +82,8 @@ extern uint16_t udp_port;
 extern uint8_t ports[RTE_MAX_ETHPORTS];
 extern uint8_t filter_idx;
 extern uint16_t tso_segsz;
+extern uint32_t enable_stats;
+extern struct device_statistics dev_statistics[MAX_DEVICES];

 /* ethernet addresses of ports */
 extern struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
@@ -433,6 +435,12 @@ vxlan_rx_pkts (struct virtio_net *dev, struct rte_mbuf 
**pkts_burst, uint32_t rx
struct rte_mbuf *pkts_valid[rx_count];

for (i = 0; i < rx_count; i++) {
+   if (enable_stats) {
+   
rte_atomic64_add(_statistics[dev->device_fh].rx_bad_ip_csum,
+   (pkts_burst[i]->ol_flags & PKT_RX_IP_CKSUM_BAD) 
!= 0);
+   
rte_atomic64_add(_statistics[dev->device_fh].rx_bad_ip_csum,
+   (pkts_burst[i]->ol_flags & PKT_RX_L4_CKSUM_BAD) 
!= 0);
+   }
ret = vxlan_rx_process(pkts_burst[i]);
if (unlikely(ret < 0))
continue;
-- 
1.7.7.6



[dpdk-dev] [PATCH v2 08/10] examples/tep_termination:add TSO offload configuration

2015-05-29 Thread Jijiang Liu
If the 'tso-segsz' is not 0, which means TSO offload is enabled.

Signed-off-by: Jijiang Liu 
---
 examples/tep_termination/main.c|   17 +
 examples/tep_termination/vxlan.c   |8 
 examples/tep_termination/vxlan.h   |1 +
 examples/tep_termination/vxlan_setup.c |8 
 4 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index 5e391c3..995fd2a 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -111,6 +111,7 @@
 #define CMD_LINE_OPT_NB_DEVICES "nb-devices"
 #define CMD_LINE_OPT_UDP_PORT "udp-port"
 #define CMD_LINE_OPT_TX_CHECKSUM "tx-checksum"
+#define CMD_LINE_OPT_TSO_SEGSZ "tso-segsz"
 #define CMD_LINE_OPT_FILTER_TYPE "filter-type"
 #define CMD_LINE_OPT_RX_RETRY "rx-retry"
 #define CMD_LINE_OPT_RX_RETRY_DELAY "rx-retry-delay"
@@ -142,6 +143,9 @@ uint16_t udp_port;
 /* enable/disable inner TX checksum */
 uint8_t tx_checksum;

+/* TSO segment size */
+uint16_t tso_segsz = 0;
+
 /* RX filter type for tunneling packet */
 uint8_t filter_idx;

@@ -270,6 +274,7 @@ tep_termination_usage(const char *prgname)
"   --udp-port: UDP destination port for VXLAN packet\n"
"   --nb-devices[1-64]: The number of virtIO device\n"
"   --tx-checksum [0|1]: inner Tx checksum offload\n"
+   "   --tso-segsz [0-N]: TSO segment size\n"
"   --filter-type[1-3]: filter type for tunneling packet\n"
"   1: Inner MAC and tenent ID\n"
"   2: Inner MAC and tenent ID\n"
@@ -300,6 +305,7 @@ tep_termination_parse_args(int argc, char **argv)
{CMD_LINE_OPT_NB_DEVICES, required_argument, NULL, 0},
{CMD_LINE_OPT_UDP_PORT, required_argument, NULL, 0},
{CMD_LINE_OPT_TX_CHECKSUM, required_argument, NULL, 0},
+   {CMD_LINE_OPT_TSO_SEGSZ, required_argument, NULL, 0},
{CMD_LINE_OPT_FILTER_TYPE, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY_DELAY, required_argument, NULL, 0},
@@ -347,6 +353,17 @@ tep_termination_parse_args(int argc, char **argv)
enable_retry = ret;
}

+   if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_TSO_SEGSZ,
+   sizeof(CMD_LINE_OPT_TSO_SEGSZ))) {
+   ret = parse_num_opt(optarg, INT16_MAX);
+   if (ret == -1) {
+   RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for TCP segment size [0-N]\n");
+   tep_termination_usage(prgname);
+   return -1;
+   } else
+   tso_segsz = ret;
+   }
+
if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_UDP_PORT,
sizeof(CMD_LINE_OPT_UDP_PORT))) {
ret = parse_num_opt(optarg, INT16_MAX);
diff --git a/examples/tep_termination/vxlan.c b/examples/tep_termination/vxlan.c
index 786281c..6d44a97 100644
--- a/examples/tep_termination/vxlan.c
+++ b/examples/tep_termination/vxlan.c
@@ -47,6 +47,7 @@ extern uint8_t tx_checksum;
 extern struct vxlan_conf vxdev;
 extern struct ipv4_hdr app_ip_hdr[VXLAN_N_PORTS];
 extern struct ether_hdr app_l2_hdr[VXLAN_N_PORTS];
+extern uint16_t tso_segsz;

 /* We cannot use rte_cpu_to_be_16() on a constant in a switch/case */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
@@ -156,6 +157,11 @@ process_inner_cksums(struct ether_hdr *eth_hdr, union 
tunnel_offload_info *info)
ol_flags |= PKT_TX_TCP_CKSUM;
tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype,
ol_flags);
+   if (tso_segsz != 0) {
+   ol_flags |= PKT_TX_TCP_SEG;
+   info->tso_segsz = tso_segsz;
+   info->l4_len = sizeof(struct tcp_hdr);
+   }

} else if (l4_proto == IPPROTO_SCTP) {
sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + info->l3_len);
@@ -228,6 +234,7 @@ encapsulation(struct rte_mbuf *m, uint8_t vport_id)
ol_flags |= process_inner_cksums(phdr, _offload);
m->l2_len = tx_offload.l2_len;
m->l3_len = tx_offload.l3_len;
+   m->l4_len = tx_offload.l4_len;
m->l2_len += ETHER_VXLAN_HLEN;
}

@@ -235,6 +242,7 @@ encapsulation(struct rte_mbuf *m, uint8_t vport_id)
m->outer_l3_len = sizeof(struct ipv4_hdr);

m->ol_flags |= ol_flags;
+   m->tso_segsz = tx_offload.tso_segsz;

/*VXLAN HEADER*/

[dpdk-dev] [PATCH v2 07/10] examples/tep_termination:add Tx checksum offload configuration for inner header

2015-05-29 Thread Jijiang Liu
For VXLAN packet, the inner Tx checksum offload means inner IPv4 and inner 
L4(TCP/UDP/SCTP).

Signed-off-by: Jijiang Liu 
---
 examples/tep_termination/main.c  |   17 
 examples/tep_termination/vxlan.c |   80 ++
 2 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index f1cb8e4..5e391c3 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -110,6 +110,7 @@

 #define CMD_LINE_OPT_NB_DEVICES "nb-devices"
 #define CMD_LINE_OPT_UDP_PORT "udp-port"
+#define CMD_LINE_OPT_TX_CHECKSUM "tx-checksum"
 #define CMD_LINE_OPT_FILTER_TYPE "filter-type"
 #define CMD_LINE_OPT_RX_RETRY "rx-retry"
 #define CMD_LINE_OPT_RX_RETRY_DELAY "rx-retry-delay"
@@ -138,6 +139,9 @@ struct vpool {
 /* VXLAN UDP destination port */
 uint16_t udp_port;

+/* enable/disable inner TX checksum */
+uint8_t tx_checksum;
+
 /* RX filter type for tunneling packet */
 uint8_t filter_idx;

@@ -265,6 +269,7 @@ tep_termination_usage(const char *prgname)
RTE_LOG(INFO, VHOST_CONFIG, "%s [EAL options] -- -p PORTMASK\n"
"   --udp-port: UDP destination port for VXLAN packet\n"
"   --nb-devices[1-64]: The number of virtIO device\n"
+   "   --tx-checksum [0|1]: inner Tx checksum offload\n"
"   --filter-type[1-3]: filter type for tunneling packet\n"
"   1: Inner MAC and tenent ID\n"
"   2: Inner MAC and tenent ID\n"
@@ -294,6 +299,7 @@ tep_termination_parse_args(int argc, char **argv)
static struct option long_option[] = {
{CMD_LINE_OPT_NB_DEVICES, required_argument, NULL, 0},
{CMD_LINE_OPT_UDP_PORT, required_argument, NULL, 0},
+   {CMD_LINE_OPT_TX_CHECKSUM, required_argument, NULL, 0},
{CMD_LINE_OPT_FILTER_TYPE, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY_DELAY, required_argument, NULL, 0},
@@ -378,6 +384,17 @@ tep_termination_parse_args(int argc, char **argv)
burst_rx_retry_num = ret;
}

+   if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_TX_CHECKSUM,
+   sizeof(CMD_LINE_OPT_TX_CHECKSUM))) {
+   ret = parse_num_opt(optarg, 1);
+   if (ret == -1) {
+   RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for tx-checksum [0|1]\n");
+   tep_termination_usage(prgname);
+   return -1;
+   } else
+   tx_checksum = ret;
+   }
+
if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_FILTER_TYPE,
sizeof(CMD_LINE_OPT_FILTER_TYPE))) {
ret = parse_num_opt(optarg, 3);
diff --git a/examples/tep_termination/vxlan.c b/examples/tep_termination/vxlan.c
index 59b5e2a..786281c 100644
--- a/examples/tep_termination/vxlan.c
+++ b/examples/tep_termination/vxlan.c
@@ -43,6 +43,7 @@
 #include "main.h"
 #include "vxlan.h"

+extern uint8_t tx_checksum;
 extern struct vxlan_conf vxdev;
 extern struct ipv4_hdr app_ip_hdr[VXLAN_N_PORTS];
 extern struct ether_hdr app_l2_hdr[VXLAN_N_PORTS];
@@ -54,6 +55,15 @@ extern struct ether_hdr app_l2_hdr[VXLAN_N_PORTS];
 #define _htons(x) (x)
 #endif

+static uint16_t
+get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags)
+{
+   if (ethertype == rte_cpu_to_be_16(ETHER_TYPE_IPv4))
+   return rte_ipv4_phdr_cksum(l3_hdr, ol_flags);
+   else /* assume ethertype == ETHER_TYPE_IPv6 */
+   return rte_ipv6_phdr_cksum(l3_hdr, ol_flags);
+}
+
 /* *
  * Parse an ethernet header to fill the ethertype, outer_l2_len, outer_l3_len 
and
  * ipproto. This function is able to recognize IPv4/IPv6 with one optional vlan
@@ -95,6 +105,67 @@ parse_ethernet(struct ether_hdr *eth_hdr, union 
tunnel_offload_info *info,

 }

+/**
+ * Calculate the checksum of a packet in hardware
+ */
+static uint64_t
+process_inner_cksums(struct ether_hdr *eth_hdr, union tunnel_offload_info 
*info)
+{
+   void *l3_hdr = NULL;
+   uint16_t ethertype, l4_proto;
+   struct ipv4_hdr *ipv4_hdr;
+   struct ipv6_hdr *ipv6_hdr;
+   struct udp_hdr *udp_hdr;
+   struct tcp_hdr *tcp_hdr;
+   struct sctp_hdr *sctp_hdr;
+   uint64_t ol_flags = 0;
+
+   info->l2_len = sizeof(struct ether_hdr);
+   ethertype = eth_hdr->ether_type;
+
+   if (ethertype == _htons(ETHER_TYPE_VLAN)) {
+   struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1);
+   info->l2_len  += sizeof(struct vlan_hdr);
+ 

[dpdk-dev] [PATCH v2 06/10] examples/tep_termination:add tunnel filter type configuration

2015-05-29 Thread Jijiang Liu
The following filter types are supported for VXLAN,

1> Inner MAC and tenent ID

2> Inner MAC and tenent ID, and Outer MAC

3> Inner MAC and tenent ID


Signed-off-by: Jijiang Liu 
---
 examples/tep_termination/main.c|   20 ++
 examples/tep_termination/vxlan_setup.c |   62 +++-
 2 files changed, 81 insertions(+), 1 deletions(-)

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index c7ffe16..f1cb8e4 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -110,6 +110,7 @@

 #define CMD_LINE_OPT_NB_DEVICES "nb-devices"
 #define CMD_LINE_OPT_UDP_PORT "udp-port"
+#define CMD_LINE_OPT_FILTER_TYPE "filter-type"
 #define CMD_LINE_OPT_RX_RETRY "rx-retry"
 #define CMD_LINE_OPT_RX_RETRY_DELAY "rx-retry-delay"
 #define CMD_LINE_OPT_RX_RETRY_NUM "rx-retry-num"
@@ -137,6 +138,9 @@ struct vpool {
 /* VXLAN UDP destination port */
 uint16_t udp_port;

+/* RX filter type for tunneling packet */
+uint8_t filter_idx;
+
 /* overlay packet operation */
 struct ol_switch_ops overlay_options = {
.port_configure = vxlan_port_init,
@@ -261,6 +265,10 @@ tep_termination_usage(const char *prgname)
RTE_LOG(INFO, VHOST_CONFIG, "%s [EAL options] -- -p PORTMASK\n"
"   --udp-port: UDP destination port for VXLAN packet\n"
"   --nb-devices[1-64]: The number of virtIO device\n"
+   "   --filter-type[1-3]: filter type for tunneling packet\n"
+   "   1: Inner MAC and tenent ID\n"
+   "   2: Inner MAC and tenent ID\n"
+   "   3: Outer MAC, Inner MAC and tenent ID\n"
"   -p PORTMASK: Set mask for ports to be used by 
application\n"
"   --rx-retry [0|1]: disable/enable(default) retries on 
rx."
"Enable retry if destintation queue is full\n"
@@ -286,6 +294,7 @@ tep_termination_parse_args(int argc, char **argv)
static struct option long_option[] = {
{CMD_LINE_OPT_NB_DEVICES, required_argument, NULL, 0},
{CMD_LINE_OPT_UDP_PORT, required_argument, NULL, 0},
+   {CMD_LINE_OPT_FILTER_TYPE, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY_DELAY, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY_NUM, required_argument, NULL, 0},
@@ -369,6 +378,17 @@ tep_termination_parse_args(int argc, char **argv)
burst_rx_retry_num = ret;
}

+   if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_FILTER_TYPE,
+   sizeof(CMD_LINE_OPT_FILTER_TYPE))) {
+   ret = parse_num_opt(optarg, 3);
+   if (ret == -1) {
+   RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for filter type [1-3]\n");
+   tep_termination_usage(prgname);
+   return -1;
+   } else
+   filter_idx = ret - 1;
+   }
+
/* Enable/disable stats. */
if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_STATS,
sizeof(CMD_LINE_OPT_STATS))) {
diff --git a/examples/tep_termination/vxlan_setup.c 
b/examples/tep_termination/vxlan_setup.c
index f6efa90..7d42b77 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -74,9 +74,13 @@
 #define RTE_TEST_RX_DESC_DEFAULT 1024
 #define RTE_TEST_TX_DESC_DEFAULT 512

+/* Default inner VLAN ID */
+#define INNER_VLAN_ID 100
+
 extern uint16_t num_devices;
 extern uint16_t udp_port;
 extern uint8_t ports[RTE_MAX_ETHPORTS];
+extern uint8_t filter_idx;

 /* ethernet addresses of ports */
 extern struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
@@ -99,6 +103,11 @@ uint8_t vxlan_overlay_ips[2][4] = { {192, 168, 10, 1}, 
{192, 168, 30, 1} };
 /* remote VTEP MAC address */
 uint8_t peer_mac[6] = {0x00, 0x11, 0x01, 0x00, 0x00, 0x01};

+/* VXLAN RX filter type */
+uint8_t tep_filter_type[] = {RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID,
+   RTE_TUNNEL_FILTER_IMAC_TENID,
+   RTE_TUNNEL_FILTER_OMAC_TENID_IMAC,};
+
 /* Options for configuring ethernet port */
 static const struct rte_eth_conf port_conf = {
.rxmode = {
@@ -238,11 +247,12 @@ vxlan_tx_process(uint8_t vport_id, struct rte_mbuf *pkt)
 int
 vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m)
 {
-   int i;
+   int i, ret;
struct ether_hdr *pkt_hdr;
struct virtio_net_data_ll *dev_ll;
struct virtio_net *dev = vdev->dev;
uint64_t portid = dev->device_fh;
+   struct rte_eth_tunnel_filter_conf 

[dpdk-dev] [PATCH v2 05/10] examples/tep_termination:add UDP port configuration for UDP tunneling packet

2015-05-29 Thread Jijiang Liu
The port number of UDP tunneling packet is configurable, which has 16 entries 
in total for i40e.

Signed-off-by: Jijiang Liu 

---
 examples/tep_termination/main.c|   18 +-
 examples/tep_termination/vxlan_setup.c |   13 -
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index 6931f07..c7ffe16 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -109,6 +109,7 @@
 #define MAC_ADDR_CMP 0xULL

 #define CMD_LINE_OPT_NB_DEVICES "nb-devices"
+#define CMD_LINE_OPT_UDP_PORT "udp-port"
 #define CMD_LINE_OPT_RX_RETRY "rx-retry"
 #define CMD_LINE_OPT_RX_RETRY_DELAY "rx-retry-delay"
 #define CMD_LINE_OPT_RX_RETRY_NUM "rx-retry-num"
@@ -133,6 +134,9 @@ struct vpool {
uint32_t buf_size;
 } vpool_array[MAX_QUEUES+MAX_QUEUES];

+/* VXLAN UDP destination port */
+uint16_t udp_port;
+
 /* overlay packet operation */
 struct ol_switch_ops overlay_options = {
.port_configure = vxlan_port_init,
@@ -255,6 +259,7 @@ static void
 tep_termination_usage(const char *prgname)
 {
RTE_LOG(INFO, VHOST_CONFIG, "%s [EAL options] -- -p PORTMASK\n"
+   "   --udp-port: UDP destination port for VXLAN packet\n"
"   --nb-devices[1-64]: The number of virtIO device\n"
"   -p PORTMASK: Set mask for ports to be used by 
application\n"
"   --rx-retry [0|1]: disable/enable(default) retries on 
rx."
@@ -280,6 +285,7 @@ tep_termination_parse_args(int argc, char **argv)
const char *prgname = argv[0];
static struct option long_option[] = {
{CMD_LINE_OPT_NB_DEVICES, required_argument, NULL, 0},
+   {CMD_LINE_OPT_UDP_PORT, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY_DELAY, required_argument, NULL, 0},
{CMD_LINE_OPT_RX_RETRY_NUM, required_argument, NULL, 0},
@@ -326,6 +332,17 @@ tep_termination_parse_args(int argc, char **argv)
enable_retry = ret;
}

+   if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_UDP_PORT,
+   sizeof(CMD_LINE_OPT_UDP_PORT))) {
+   ret = parse_num_opt(optarg, INT16_MAX);
+   if (ret == -1) {
+   RTE_LOG(INFO, VHOST_CONFIG, "Invalid 
argument for UDP port [0-N]\n");
+   tep_termination_usage(prgname);
+   return -1;
+   } else
+   udp_port = ret;
+   }
+
/* Specify the retries delay time (in useconds) on RX. 
*/
if (!strncmp(long_option[option_index].name, 
CMD_LINE_OPT_RX_RETRY_DELAY,
sizeof(CMD_LINE_OPT_RX_RETRY_DELAY))) {
@@ -1075,7 +1092,6 @@ main(int argc, char *argv[])
rte_eal_remote_launch(switch_worker,
mbuf_pool, lcore_id);
}
-
rte_vhost_feature_disable(1ULL << VIRTIO_NET_F_MRG_RXBUF);

/* Register CUSE device to handle IOCTLs. */
diff --git a/examples/tep_termination/vxlan_setup.c 
b/examples/tep_termination/vxlan_setup.c
index 71414eb..f6efa90 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -75,6 +75,7 @@
 #define RTE_TEST_TX_DESC_DEFAULT 512

 extern uint16_t num_devices;
+extern uint16_t udp_port;
 extern uint8_t ports[RTE_MAX_ETHPORTS];

 /* ethernet addresses of ports */
@@ -141,9 +142,12 @@ vxlan_port_init(uint8_t port, struct rte_mempool 
*mbuf_pool)
uint16_t rx_rings, tx_rings = (uint16_t)rte_lcore_count();
const uint16_t rx_ring_size = RTE_TEST_RX_DESC_DEFAULT;
const uint16_t tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
+   struct rte_eth_udp_tunnel tunnel_udp;
struct rte_eth_rxconf *rxconf;
struct rte_eth_txconf *txconf;
+   struct vxlan_conf *pconf = 

+   pconf->dst_port = udp_port;
rte_eth_dev_info_get (port, _info);

dev_info.max_rx_queues = num_devices;
@@ -188,6 +192,12 @@ vxlan_port_init(uint8_t port, struct rte_mempool 
*mbuf_pool)
if (retval < 0)
return retval;

+   /* Configure UDP port for VXLAN */
+   tunnel_udp.udp_port = udp_port;
+   tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
+   retval = rte_eth_dev_udp_tunnel_add(port, _udp);
+   if (retval < 0)
+   return retval;
rte_eth_macaddr_get(port, _eth_addr[port]);
RTE_LOG(INFO, PORT, "Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
@@ -198,13 +208,14 @@ 

[dpdk-dev] [PATCH v2 04/10] examples/tep_termination:implement VXLAN packet processing

2015-05-29 Thread Jijiang Liu
Implement the following functions:

1> VXLAN port configuration

2> VXLAN tunnel setup

3> VXLAN tunnel destroying

4> VXLAN packet processing for Rx side

5> VXLAN packet processing for Tx side

Signed-off-by: Jijiang Liu 
Signed-off-by: Thomas Long 
---
 examples/tep_termination/Makefile  |2 +-
 examples/tep_termination/main.c|   35 +++-
 examples/tep_termination/vxlan.c   |  174 +++
 examples/tep_termination/vxlan.h   |   17 ++-
 examples/tep_termination/vxlan_setup.c |  367 
 5 files changed, 583 insertions(+), 12 deletions(-)
 create mode 100644 examples/tep_termination/vxlan.c
 create mode 100644 examples/tep_termination/vxlan_setup.c

diff --git a/examples/tep_termination/Makefile 
b/examples/tep_termination/Makefile
index 42a380b..0a0cf4b 100644
--- a/examples/tep_termination/Makefile
+++ b/examples/tep_termination/Makefile
@@ -47,7 +47,7 @@ endif
 APP = tep_termination

 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c vxlan_setup.c vxlan.c

 CFLAGS += -O2 -D_FILE_OFFSET_BITS=64
 CFLAGS += $(WERROR_FLAGS)
diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index b5c829f..6931f07 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -133,6 +133,16 @@ struct vpool {
uint32_t buf_size;
 } vpool_array[MAX_QUEUES+MAX_QUEUES];

+/* overlay packet operation */
+struct ol_switch_ops overlay_options = {
+   .port_configure = vxlan_port_init,
+   .tunnel_setup = vxlan_link,
+   .tunnel_destroy = vxlan_unlink,
+   .tx_handle = vxlan_tx_pkts,
+   .rx_handle = vxlan_rx_pkts,
+   .param_handle = NULL,
+};
+
 /* Enable stats. */
 uint32_t enable_stats = 0;
 /* Enable retries on RX. */
@@ -312,9 +322,8 @@ tep_termination_parse_args(int argc, char **argv)
"Invalid argument for rx-retry 
[0|1]\n");
tep_termination_usage(prgname);
return -1;
-   } else {
+   } else
enable_retry = ret;
-   }
}

/* Specify the retries delay time (in useconds) on RX. 
*/
@@ -326,9 +335,8 @@ tep_termination_parse_args(int argc, char **argv)
"Invalid argument for 
rx-retry-delay [0-N]\n");
tep_termination_usage(prgname);
return -1;
-   } else {
+   } else
burst_rx_delay_time = ret;
-   }
}

/* Specify the retries number on RX. */
@@ -340,9 +348,8 @@ tep_termination_parse_args(int argc, char **argv)
"Invalid argument for 
rx-retry-num [0-N]\n");
tep_termination_usage(prgname);
return -1;
-   } else {
+   } else
burst_rx_retry_num = ret;
-   }
}

/* Enable/disable stats. */
@@ -354,9 +361,8 @@ tep_termination_parse_args(int argc, char **argv)
"Invalid argument for 
stats [0..N]\n");
tep_termination_usage(prgname);
return -1;
-   } else {
+   } else
enable_stats = ret;
-   }
}

/* Set character device basename. */
@@ -448,6 +454,8 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m)

if (unlikely(len == MAX_PKT_BURST)) {
m_table = (struct rte_mbuf **)tx_q->m_table;
+   ret = overlay_options.tx_handle(ports[0], 
(uint16_t)tx_q->txq_id,
+   m_table, (uint16_t)tx_q->len);
/* Free any buffers not handled by TX and update the port 
stats. */
if (unlikely(ret < len)) {
do {
@@ -508,6 +516,10 @@ switch_worker(__rte_unused void *arg)

if (tx_q->len) {
LOG_DEBUG(VHOST_DATA, "TX queue drained after 
timeout with burst size %u \n", tx_q->len);
+   ret = overlay_options.tx_handle(ports[0],
+   (uint16_t)tx_q->txq_id,
+   (struct rte_mbuf **)tx_q->m_table,
+   

[dpdk-dev] [PATCH v2 03/10] examples/tep_termination:add the pluggable structures for VXLAN packet processing

2015-05-29 Thread Jijiang Liu
We are trying to create a framework for tunneling packet processing, so some 
common APIs are added here, which includes 
1> tunnel port configuration

2> tunnel setup

3> tunnel destroying

4> tunneling packet processing for Rx side

5> tunneling packet processing for Tx side

6> tunnel parameter processing


Signed-off-by: Jijiang Liu 
Signed-off-by: Thomas Long 

---
 examples/tep_termination/main.c|1 +
 examples/tep_termination/vxlan_setup.h |   78 
 2 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 examples/tep_termination/vxlan_setup.h

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index f15a104..b5c829f 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -53,6 +53,7 @@

 #include "main.h"
 #include "vxlan.h"
+#include "vxlan_setup.h"

 /* the maximum number of external ports supported */
 #define MAX_SUP_PORTS 1
diff --git a/examples/tep_termination/vxlan_setup.h 
b/examples/tep_termination/vxlan_setup.h
new file mode 100644
index 000..522062e
--- /dev/null
+++ b/examples/tep_termination/vxlan_setup.h
@@ -0,0 +1,78 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED 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 VXLAN_SETUP_H_
+#define VXLAN_SETUP_H_
+
+typedef int (*ol_port_configure_t)(uint8_t port,
+  struct rte_mempool *mbuf_pool);
+
+typedef int (*ol_tunnel_setup_t)(struct vhost_dev *vdev,
+struct rte_mbuf *m);
+
+typedef void (*ol_tunnel_destroy_t)(struct vhost_dev *vdev);
+
+typedef int (*ol_tx_handle_t)(uint8_t port_id, uint16_t queue_id,
+ struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
+
+typedef int (*ol_rx_handle_t)(struct virtio_net *dev, struct rte_mbuf **pkts,
+ uint32_t count);
+
+typedef int (*ol_param_handle)(struct virtio_net *dev);
+
+struct ol_switch_ops {
+   ol_port_configure_tport_configure;
+   ol_tunnel_setup_t  tunnel_setup;
+   ol_tunnel_destroy_ttunnel_destroy;
+   ol_tx_handle_t tx_handle;
+   ol_rx_handle_t rx_handle;
+   ol_param_handleparam_handle;
+};
+
+int
+vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool);
+
+int
+vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m);
+
+void
+vxlan_unlink(struct vhost_dev *vdev);
+
+int
+vxlan_tx_pkts(uint8_t port_id, uint16_t queue_id,
+   struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
+int
+vxlan_rx_pkts(struct virtio_net *dev, struct rte_mbuf **pkts, uint32_t count);
+
+#endif /* VXLAN_SETUP_H_ */
+
-- 
1.7.7.6



[dpdk-dev] [PATCH v2 02/10] examples/tep_termination:define the basic VXLAN port information

2015-05-29 Thread Jijiang Liu
Some basic VXLAN definations are added in this file, which includes VXLAN port 
information and VXLAN device structures.

Signed-off-by: Jijiang Liu 
Signed-off-by: Thomas Long 

---
 examples/tep_termination/main.c  |1 +
 examples/tep_termination/vxlan.h |   60 ++
 2 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100644 examples/tep_termination/vxlan.h

diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index 9cbe484..f15a104 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -52,6 +52,7 @@
 #include 

 #include "main.h"
+#include "vxlan.h"

 /* the maximum number of external ports supported */
 #define MAX_SUP_PORTS 1
diff --git a/examples/tep_termination/vxlan.h b/examples/tep_termination/vxlan.h
new file mode 100644
index 000..8595eed
--- /dev/null
+++ b/examples/tep_termination/vxlan.h
@@ -0,0 +1,60 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED 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 _VXLAN_H_
+#define _VXLAN_H_
+
+#define PORT_MIN   49152
+#define PORT_MAX   65535
+#define PORT_RANGE ((PORT_MAX - PORT_MIN) + 1)
+
+#define VXLAN_N_PORTS  2
+#define VXLAN_HF_VNI 0x0800
+#define DEFAULT_VXLAN_PORT 4789
+
+struct vxlan_port {
+   uint32_t vport_id;   /**< VirtIO port id */
+   uint32_t peer_ip;/**< remote VTEP IP address */
+   struct ether_addr peer_mac;  /**< remote VTEP MAC address */
+   struct ether_addr vport_mac; /**< VirtIO port MAC address */
+} __rte_cache_aligned;
+
+struct vxlan_conf {
+   uint16_t dst_port;  /**< VXLAN UDP destination port */
+   uint32_t port_ip;   /**< DPDK port IP address*/
+   uint32_t in_key;/**< VLAN  ID */
+   uint32_t out_key;   /**< VXLAN VNI */
+   struct vxlan_port port[VXLAN_N_PORTS]; /**< VXLAN configuration */
+} __rte_cache_aligned;
+
+#endif /* _MAIN_H_ */
-- 
1.7.7.6



[dpdk-dev] [PATCH v2 01/10] examples/tep_termination:initialize the VXLAN sample

2015-05-29 Thread Jijiang Liu
This sample uses the basic virtio devices management function from the vHost 
example, which includes virtio device creation, destroying and maintenance.

Signed-off-by: Jijiang Liu 
---
 examples/Makefile |1 +
 examples/tep_termination/Makefile |   55 ++
 examples/tep_termination/main.c   | 1075 +
 examples/tep_termination/main.h   |  125 +
 4 files changed, 1256 insertions(+), 0 deletions(-)
 create mode 100644 examples/tep_termination/Makefile
 create mode 100644 examples/tep_termination/main.c
 create mode 100644 examples/tep_termination/main.h

diff --git a/examples/Makefile b/examples/Makefile
index e659f6f..d157e15 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -73,5 +73,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_XEN_DOM0) += vhost_xen
 DIRS-y += vmdq
 DIRS-y += vmdq_dcb
 DIRS-$(CONFIG_RTE_LIBRTE_POWER) += vm_power_manager
+DIRS-y += tep_termination

 include $(RTE_SDK)/mk/rte.extsubdir.mk
diff --git a/examples/tep_termination/Makefile 
b/examples/tep_termination/Makefile
new file mode 100644
index 000..42a380b
--- /dev/null
+++ b/examples/tep_termination/Makefile
@@ -0,0 +1,55 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED 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.
+
+ifeq ($(RTE_SDK),)
+$(error "Please define RTE_SDK environment variable")
+endif
+
+# Default target, can be overriden by command line or environment
+RTE_TARGET ?= x86_64-native-linuxapp-gcc
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+ifneq ($(CONFIG_RTE_EXEC_ENV),"linuxapp")
+$(error This application can only operate in a linuxapp environment, \
+please change the definition of the RTE_TARGET environment variable)
+endif
+
+# binary name
+APP = tep_termination
+
+# all source are stored in SRCS-y
+SRCS-y := main.c
+
+CFLAGS += -O2 -D_FILE_OFFSET_BITS=64
+CFLAGS += $(WERROR_FLAGS)
+
+include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
new file mode 100644
index 000..9cbe484
--- /dev/null
+++ b/examples/tep_termination/main.c
@@ -0,0 +1,1075 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED 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 

[dpdk-dev] [PATCH v2 00/10] Add a VXLAN sample

2015-05-29 Thread Jijiang Liu
This VXLAN sample simulates a VXLAN Tunnel Endpoint (VTEP) termination in DPDK, 
which is used to demonstrate the offload and filtering capabilities of i40 NIC 
for VXLAN packet.

And this sample uses the basic virtio devices management function from vHost 
example, and the US-vHost interface and tunnel filtering mechanism to direct 
the traffic to/from a specific VM.

In addition, this sample is also designed to show how tunneling protocols can 
be handled. For the vHost interface, we do not need to support zero copy/inter 
VM packet transfer, etc. The approaches we took would be of benefit to you 
because we put a pluggable structure in place so that the application could be 
easily extended to support a new tunneling protocol.

The software framework is as follows:


   |---|   |---|
   | VM-1(VNI:100) |   |  VM-2(VNI:200)|
   | |--| |--| |   | |--| |--| |
   | |vport0| |vport1| |   | |vport0| |vport1| |
   |-|--|-|--|-|   |-|--|-|--|-|  Guests
  \ /  
 |-\---/|
 | us-vHost interface   |
 |  |-||--| |
 | decap| | TEP|  | encap   |   DPDK App
 |  |-||--| |
 ||||
 ||||
  || 
|-||---|
|tunnel filter|| IP/L4 Tx csum |
|IP/L4 csum   || TSO   |
|packet type  ||   |   NIC
|packet recogn||   |
|-||---|
  ||   
  ||   
  ||   
 /---\  
VXLAN Tunnel  

The sample will support the followings:
1> Tunneling packet recognition.

2> The port of UDP tunneling is configurable

3> Directing incoming traffic to the correct queue based on the tunnel filter 
type such as inner MAC address and VNI.

 The VNI will be assigned from a static internal table based on the us-vHost 
device ID. Each device will receive a unique device ID. The inner MAC will be 
learned by  the first packet transmitted from a device.

4> Decapsulation of Rx VXLAN traffic. This is a software only operation.

5> Encapsulation of Tx VXLAN traffic. This is a software only operation.

6> Tx outer IP, inner IP and L4 checksum offload

7> TSO support for tunneling packet

The limitations:
1. No ARP support
2. There are some duplicated source codes because I used  the basic virtio 
device management function from VHOST sample. Considering that the current 
VHOST sample is quite complicated and huge enough,  I think we shall have a 
separate sample for tunneling packet processing.
3. Currently, only the i40e NIC is tested in the sample, but other types of 
NICs will also be supported if they are able to support tunneling packet filter.

V2 change:
Fixed an issue about the 'nb_ports' duplication in check_ports_num().
Removed the inaccurate comment in main.c
Fixed an issue about TSO offload.

Jijiang Liu (10):
  create VXLAN sample framework using virtio device management function 
  add basic VXLAN structures 
  addthe pluggable structures
  implement VXLAN packet processing
  add udp port configuration
  add filter type configuration
  add tx checksum offload configuration
  add TSO offload configuration
  add Rx checksum statistics
  add encapsulation and decapsulation flags

 examples/Makefile  |1 +
 examples/tep_termination/Makefile  |   55 ++
 examples/tep_termination/main.c| 1206 
 examples/tep_termination/main.h|  129 
 examples/tep_termination/vxlan.c   |  262 +++
 examples/tep_termination/vxlan.h   |   76 ++
 examples/tep_termination/vxlan_setup.c |  463 
 examples/tep_termination/vxlan_setup.h |   78 ++
 8 files changed, 2270 insertions(+), 0 deletions(-)
 create mode 100644 examples/tep_termination/Makefile
 create mode 100644 examples/tep_termination/main.c
 create mode 100644 examples/tep_termination/main.h
 create mode 100644 examples/tep_termination/vxlan.c
 create mode 100644 examples/tep_termination/vxlan.h
 create mode 100644 examples/tep_termination/vxlan_setup.c
 create mode 100644 examples/tep_termination/vxlan_setup.h

-- 
1.7.7.6



[dpdk-dev] [PATCH v2 4/4] null: fix compile on Fedora 22 (GCC 5.1)

2015-05-29 Thread Bruce Richardson
On Fedora 22, with GCC 5.1, errors are reported due to array accesses
being potentially out of bounds. This commit fixes this by adding in an
extra bounds check to the loop counters, or, in the case of stats reset,
by blindly zeroing the whole array, rather than just the part that is in
use.

Signed-off-by: Bruce Richardson 
---
 drivers/net/null/rte_eth_null.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 5895065..7792315 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -298,7 +298,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats 
*igb_stats)
internal = dev->data->dev_private;
memset(igb_stats, 0, sizeof(*igb_stats));
num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS,
-   internal->nb_rx_queues);
+   RTE_MIN(internal->nb_rx_queues,
+   RTE_DIM(internal->rx_null_queues)));
for (i = 0; i < num_stats; i++) {
igb_stats->q_ipackets[i] =
internal->rx_null_queues[i].rx_pkts.cnt;
@@ -306,7 +307,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats 
*igb_stats)
}

num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS,
-   internal->nb_tx_queues);
+   RTE_MIN(internal->nb_tx_queues,
+   RTE_DIM(internal->tx_null_queues)));
for (i = 0; i < num_stats; i++) {
igb_stats->q_opackets[i] =
internal->tx_null_queues[i].tx_pkts.cnt;
@@ -331,9 +333,9 @@ eth_stats_reset(struct rte_eth_dev *dev)
return;

internal = dev->data->dev_private;
-   for (i = 0; i < internal->nb_rx_queues; i++)
+   for (i = 0; i < RTE_DIM(internal->rx_null_queues); i++)
internal->rx_null_queues[i].rx_pkts.cnt = 0;
-   for (i = 0; i < internal->nb_tx_queues; i++) {
+   for (i = 0; i < RTE_DIM(internal->tx_null_queues); i++) {
internal->tx_null_queues[i].tx_pkts.cnt = 0;
internal->tx_null_queues[i].err_pkts.cnt = 0;
}
-- 
2.4.1



[dpdk-dev] [PATCH v2 3/4] i40e: fix compile on Fedora 22 (GCC 5.1)

2015-05-29 Thread Bruce Richardson
On Fedora 22, with GCC 5.1, errors are reported due to array accesses
being potentially out of bounds. This commit fixes this by adding in an
extra bounds check to the loop counter.

Signed-off-by: Bruce Richardson 
---
 drivers/net/i40e/i40e_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index e688b4f..4bf98d0 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -551,7 +551,7 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf,
memset(flex_pit, 0, sizeof(flex_pit));
num = i40e_srcoff_to_flx_pit(cfg->src_offset, flex_pit);

-   for (i = 0; i < num; i++) {
+   for (i = 0; i < RTE_MIN(num, RTE_DIM(flex_pit)); i++) {
field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + i;
/* record the info in fdir structure */
pf->fdir.flex_set[field_idx].src_offset =
-- 
2.4.1



[dpdk-dev] [PATCH v2 2/4] ip_frag: fix compile on Fedora 22 (GCC 5.1)

2015-05-29 Thread Bruce Richardson
On Fedora 22, with GCC 5.1, errors are reported due to array accesses
being potentially out of bounds. This commit fixes this by adding in an
extra bounds check to the loop counter.

Signed-off-by: Bruce Richardson 
---
 lib/librte_ip_frag/ip_frag_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ip_frag/ip_frag_common.h 
b/lib/librte_ip_frag/ip_frag_common.h
index 210f409..6b2acee 100644
--- a/lib/librte_ip_frag/ip_frag_common.h
+++ b/lib/librte_ip_frag/ip_frag_common.h
@@ -90,7 +90,7 @@ static inline int
 ip_frag_key_is_empty(const struct ip_frag_key * key)
 {
uint32_t i;
-   for (i = 0; i < key->key_len; i++)
+   for (i = 0; i < RTE_MIN(key->key_len, RTE_DIM(key->src_dst)); i++)
if (key->src_dst[i] != 0)
return 0;
return 1;
-- 
2.4.1



[dpdk-dev] [PATCH v2 1/4] eal: fix compile on Fedora 22 (GCC 5.1)

2015-05-29 Thread Bruce Richardson
On Fedora 22, with GCC 5.1, errors are reported due to array accesses
being potentially out of bounds. This commit fixes this by ensuring the
bounds check in the loop takes account of the array size.

Signed-off-by: Bruce Richardson 
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5f9f92e..9b8d946 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1188,7 +1188,9 @@ rte_eal_hugepage_init(void)
int socket = tmp_hp[i].socket_id;

/* find a hugepage info with right size and increment num_pages 
*/
-   for (j = 0; j < (int) internal_config.num_hugepage_sizes; j++) {
+   const int nb_hpsizes = RTE_MIN(MAX_HUGEPAGE_SIZES,
+   (int)internal_config.num_hugepage_sizes);
+   for (j = 0; j < nb_hpsizes; j++) {
if (tmp_hp[i].size ==

internal_config.hugepage_info[j].hugepage_sz) {
 #ifdef RTE_EAL_SINGLE_FILE_SEGMENTS
-- 
2.4.1



[dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22

2015-05-29 Thread Bruce Richardson
V2 Changes: 
* use RTE_MIN instead of additional comparison checks
  in some loops, as suggested by Neil.
* For stats reset in null PMD, just use the size of the
  array [which is 1] in place of the used queue counts.

GCC version 5.1 included with Fedora 22 is running stricter array 
bounds checks which are throwing up errors in a number of components 
in the DPDK code. This patchset fixes these errors to allow compilation
with GCC on Fedora 22.

Example error:
== Build lib/librte_eal/linuxapp/eal
  CC eal_memory.o
/home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c: In function 
'rte_eal_hugepage_init':
/home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c:1193:35: error: 
array subscript is above array bounds [-Werror=array-bounds]
  internal_config.hugepage_info[j].hugepage_sz) {
   ^
compilation terminated due to -Wfatal-errors.

Bruce Richardson (4):
  eal: fix compile on Fedora 22 (GCC 5.1)
  ip_frag: fix compile on Fedora 22 (GCC 5.1)
  i40e: fix compile on Fedora 22 (GCC 5.1)
  null: fix compile on Fedora 22 (GCC 5.1)

 drivers/net/i40e/i40e_fdir.c |  2 +-
 drivers/net/null/rte_eth_null.c  | 12 
 lib/librte_eal/linuxapp/eal/eal_memory.c |  4 +++-
 lib/librte_ip_frag/ip_frag_common.h  |  2 +-
 4 files changed, 13 insertions(+), 7 deletions(-)

-- 
2.4.1



[dpdk-dev] [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs

2015-05-29 Thread Liang-Min Larry Wang
adding a new library based upon ethdev APIs to provide API's that bear
the same functionality as ethtool_ops (linux/ethtool.h) and net_device_ops
(linux/netdevice.h).

Signed-off-by: Liang-Min Larry Wang 
---
 MAINTAINERS|   4 +
 config/common_linuxapp |   5 +
 lib/Makefile   |   1 +
 lib/librte_ethtool/Makefile|  56 +++
 lib/librte_ethtool/rte_ethtool.c   | 155 +
 lib/librte_ethtool/rte_ethtool.h   | 257 +
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk  |   1 +
 8 files changed, 497 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index 9362c19..b8b481f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -186,6 +186,10 @@ M: Thomas Monjalon 
 F: lib/librte_ether/
 F: scripts/test-null.sh

+Ethtool API
+M: Liang-Min Larry Wang 
+F: lib/librte_ethtool/
+

 Drivers
 ---
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0078dc9..f5759fd 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -129,6 +129,11 @@ CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
 CONFIG_RTE_LIBRTE_KVARGS=y

 #
+# Compile user-space ethtool library
+#
+CONFIG_RTE_LIBRTE_ETHTOOL=y
+
+#
 # Compile generic ethernet library
 #
 CONFIG_RTE_LIBRTE_ETHER=y
diff --git a/lib/Makefile b/lib/Makefile
index 5f480f9..a6c7375 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TIMER) += librte_timer
 DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile
 DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
+DIRS-$(CONFIG_RTE_LIBRTE_ETHTOOL) += librte_ethtool
 DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += librte_vhost
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
diff --git a/lib/librte_ethtool/Makefile b/lib/librte_ethtool/Makefile
new file mode 100644
index 000..1d981f6
--- /dev/null
+++ b/lib/librte_ethtool/Makefile
@@ -0,0 +1,56 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ethtool.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+EXPORT_MAP := rte_ethtool_version.map
+
+LIBABIVER := 1
+
+SRCS-y += rte_ethtool.c
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_ethtool.h
+
+# this lib depends upon:
+DEPDIRS-y += lib/librte_ether
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_ethtool/rte_ethtool.c b/lib/librte_ethtool/rte_ethtool.c
new file mode 100644
index 000..2ccf06f
--- /dev/null
+++ b/lib/librte_ethtool/rte_ethtool.c
@@ -0,0 +1,155 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.

[dpdk-dev] [PATCH 1/2] ethdev: add api to set default mac address

2015-05-29 Thread Liang-Min Larry Wang
add a new api: rte_eth_dev_default_mac_addr_set to
support changing default mac address of a NIC

Signed-off-by: Liang-Min Larry Wang 
---
 lib/librte_ether/rte_ethdev.c  | 16 
 lib/librte_ether/rte_ethdev.h  | 14 ++
 lib/librte_ether/rte_ether_version.map |  1 +
 3 files changed, 31 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 024fe8b..96ee00e 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2752,6 +2752,22 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct 
ether_addr *addr)
 }

 int
+rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
+{
+   struct rte_eth_dev *dev;
+
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   dev = _eth_devices[port_id];
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
+
+   return (*dev->dev_ops->mac_addr_set)(dev, addr);
+}
+
+int
 rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
uint16_t rx_mode, uint8_t on)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 16dbe00..5f07e0d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2982,6 +2982,20 @@ int rte_eth_dev_mac_addr_add(uint8_t port, struct 
ether_addr *mac_addr,
 int rte_eth_dev_mac_addr_remove(uint8_t port, struct ether_addr *mac_addr);

 /**
+ * Set the default MAC address.
+ *
+ * @param port
+ *   The port identifier of the Ethernet device.
+ * @param mac_addr
+ *   New default MAC address.
+ * @return
+ *   - (0) if successful, or *mac_addr* didn't exist.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port* invalid.
+ */
+int rte_eth_dev_default_mac_addr_set(uint8_t port, struct ether_addr 
*mac_addr);
+
+/**
  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
  *
  * @param port
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index a2d25a6..2dbbaa7 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -102,6 +102,7 @@ DPDK_2.0 {
rte_eth_tx_queue_setup;
rte_eth_xstats_get;
rte_eth_xstats_reset;
+   rte_eth_dev_default_mac_addr_set;

local: *;
 };
-- 
2.1.4



[dpdk-dev] [PATCH 0/2] User-space Ethtool

2015-05-29 Thread Liang-Min Larry Wang
This implementation is designed to provide a familar interface for applications 
that rely on kernel-space driver to support ethtool_op and net_device_op for 
device management. The initial implementation focuses on ops that can be 
implemented through existing netdev APIs. More ops will be supported in latter 
release.
ethtool: adding new ethtool api support

v2 change:
- Implement rte_eth_dev_default_mac_addr_set through dev_ops::mac_addr_set so 
it would support NIC devices other than ixgbe and igb

Liang-Min Larry Wang (2):
  ethdev: add api to set default mac address
  ethtool: add new library to provide ethtool-alike APIs

 MAINTAINERS|   4 +
 config/common_linuxapp |   5 +
 lib/Makefile   |   1 +
 lib/librte_ether/rte_ethdev.c  |  16 ++
 lib/librte_ether/rte_ethdev.h  |  14 ++
 lib/librte_ether/rte_ether_version.map |   1 +
 lib/librte_ethtool/Makefile|  56 +++
 lib/librte_ethtool/rte_ethtool.c   | 155 +
 lib/librte_ethtool/rte_ethtool.h   | 257 +
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk  |   1 +
 11 files changed, 528 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

-- 
2.1.4



[dpdk-dev] [PATCH] mem: allow mem size to be specified when no hugetblfs

2015-05-29 Thread Paul Atkins
The config option to turn off huge table support does not work with
the existing -m option to specify the amount of memory to use.  Add
a new option --no-huge-mem-size  that takes a paramater
to use as the heap size instead of the value specified by
MEMSIZE_IF_NO_HUGE_PAGE.

Signed-off-by: Paul Atkins 
---
 lib/librte_eal/common/eal_common_options.c |7 +++
 lib/librte_eal/common/eal_internal_cfg.h   |1 +
 lib/librte_eal/common/eal_options.h|2 ++
 lib/librte_eal/linuxapp/eal/eal.c  |6 +-
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 8fcb1ab..8b1f9f0 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -79,6 +79,7 @@ eal_long_options[] = {
{OPT_MASTER_LCORE,  1, NULL, OPT_MASTER_LCORE_NUM },
{OPT_NO_HPET,   0, NULL, OPT_NO_HPET_NUM  },
{OPT_NO_HUGE,   0, NULL, OPT_NO_HUGE_NUM  },
+   {OPT_NO_HUGE_MEM_SIZE,  1, NULL, OPT_NO_HUGE_MEM_SIZE_NUM },
{OPT_NO_PCI,0, NULL, OPT_NO_PCI_NUM   },
{OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM},
{OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM},
@@ -722,6 +723,11 @@ eal_parse_common_option(int opt, const char *optarg,
conf->no_hugetlbfs = 1;
break;

+   case OPT_NO_HUGE_MEM_SIZE_NUM:
+   conf->no_hugetlbfs_mem_size = atoi(optarg);
+   conf->no_hugetlbfs_mem_size *= 1024ULL * 1024ULL;
+   break;
+
case OPT_NO_PCI_NUM:
conf->no_pci = 1;
break;
@@ -907,6 +913,7 @@ eal_common_usage(void)
   "  -h, --help  This help\n"
   "\nEAL options for DEBUG use only:\n"
   "  --"OPT_NO_HUGE"   Use malloc instead of hugetlbfs\n"
+  "  --"OPT_NO_HUGE_MEM_SIZE"  Heap size when no hugetblfs\n"
   "  --"OPT_NO_PCI"Disable PCI\n"
   "  --"OPT_NO_HPET"   Disable HPET\n"
   "  --"OPT_NO_SHCONF" No shared config (mmap'd files)\n"
diff --git a/lib/librte_eal/common/eal_internal_cfg.h 
b/lib/librte_eal/common/eal_internal_cfg.h
index e2ecb0d..f1a2a7d 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -64,6 +64,7 @@ struct internal_config {
volatile unsigned force_nchannel; /**< force number of channels */
volatile unsigned force_nrank;/**< force number of ranks */
volatile unsigned no_hugetlbfs;   /**< true to disable hugetlbfs */
+   volatile unsigned no_hugetlbfs_mem_size; /**< mem size without 
hugetlbfs  */
volatile unsigned xen_dom0_support; /**< support app running on Xen 
Dom0*/
volatile unsigned no_pci; /**< true to disable PCI */
volatile unsigned no_hpet;/**< true to disable HPET */
diff --git a/lib/librte_eal/common/eal_options.h 
b/lib/librte_eal/common/eal_options.h
index f6714d9..39a0b94 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -65,6 +65,8 @@ enum {
OPT_NO_HPET_NUM,
 #define OPT_NO_HUGE   "no-huge"
OPT_NO_HUGE_NUM,
+#define OPT_NO_HUGE_MEM_SIZE  "no-huge-mem-size"
+   OPT_NO_HUGE_MEM_SIZE_NUM,
 #define OPT_NO_PCI"no-pci"
OPT_NO_PCI_NUM,
 #define OPT_NO_SHCONF "no-shconf"
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index bd770cf..3528a0e 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -735,7 +735,11 @@ rte_eal_init(int argc, char **argv)

if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
if (internal_config.no_hugetlbfs)
-   internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
+   if (internal_config.no_hugetlbfs_mem_size)
+   internal_config.memory =
+   internal_config.no_hugetlbfs_mem_size;
+   else
+   internal_config.memory = 
MEMSIZE_IF_NO_HUGE_PAGE;
else
internal_config.memory = eal_get_hugepage_mem_size();
}
-- 
1.7.10.4



[dpdk-dev] default unicast mac address - was: add multicast address filtering

2015-05-29 Thread Thomas Monjalon
Hi Stephen,

Looking at mac address management, you and Changchun added an entry in
driver ops to be able to change the default mac address with virtio:
http://dpdk.org/browse/dpdk/commit/?id=5186fb1f37fe986
Other ops functions (mac_addr_add/remove) manage the secondary unicast
mac addresses and have a wrapper function in the API:

http://dpdk.org/doc/api/rte__ethdev_8h.html#aa2b81750086f5f9e55cf65e5cf9f2c58

It seems now that the review of the above patch was too weak and I'd like
these issues to be fixed:
- mac_addr_set must be wrapped by rte_eth_dev_mac_addr_set()
- eth_mac_addr_set_t must be fixed to explicitly state that it
replaces the default address

I'm wondering what was the first intent since virtio_mac_addr_set() is
never called?


[dpdk-dev] [RFC PATCH V3] drivers/net/ring: changes to support PCI Port Hotplug

2015-05-29 Thread Bernard Iremonger
This patch depends on the Port Hotplug Framework.
It implements the rte_dev_uninit_t() function for the ring pmd.

Changes in V3:
Rebase to use drivers/net/ring directory
Handle no parameters case

Changes in V2:
Fix crash in the rte_pmd_ring_devuninit() function.

Signed-off-by: Bernard 
---
 drivers/net/ring/rte_eth_ring.c |   97 ++-
 1 files changed, 75 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 6832f01..1f160d8 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -252,6 +252,15 @@ static const struct eth_dev_ops ops = {
.mac_addr_add = eth_mac_addr_add,
 };

+static struct eth_driver rte_ring_pmd = {
+   .pci_drv = {
+   .name = "rte_ring_pmd",
+   .drv_flags = RTE_PCI_DRV_DETACHABLE,
+   },
+};
+
+static struct rte_pci_id id_table;
+
 int
 rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
const unsigned nb_rx_queues,
@@ -263,8 +272,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const 
rx_queues[],
struct rte_pci_device *pci_dev = NULL;
struct pmd_internals *internals = NULL;
struct rte_eth_dev *eth_dev = NULL;
-   struct eth_driver *eth_drv = NULL;
-   struct rte_pci_id *id_table = NULL;

unsigned i;

@@ -288,10 +295,6 @@ rte_eth_from_rings(const char *name, struct rte_ring 
*const rx_queues[],
if (pci_dev == NULL)
goto error;

-   id_table = rte_zmalloc_socket(name, sizeof(*id_table), 0, numa_node);
-   if (id_table == NULL)
-   goto error;
-
internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
if (internals == NULL)
goto error;
@@ -301,9 +304,6 @@ rte_eth_from_rings(const char *name, struct rte_ring *const 
rx_queues[],
if (eth_dev == NULL)
goto error;

-   eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, numa_node);
-   if (eth_drv == NULL)
-   goto error;

/* now put it all together
 * - store queue data in internals,
@@ -323,21 +323,22 @@ rte_eth_from_rings(const char *name, struct rte_ring 
*const rx_queues[],
internals->tx_ring_queues[i].rng = tx_queues[i];
}

-   eth_drv->pci_drv.name = ring_ethdev_driver_name;
-   eth_drv->pci_drv.id_table = id_table;
+   rte_ring_pmd.pci_drv.name = ring_ethdev_driver_name;
+   rte_ring_pmd.pci_drv.id_table = _table;

pci_dev->numa_node = numa_node;
-   pci_dev->driver = _drv->pci_drv;
+   pci_dev->driver = _ring_pmd.pci_drv;

data->dev_private = internals;
data->port_id = eth_dev->data->port_id;
+   memmove(data->name, eth_dev->data->name, sizeof(data->name));
data->nb_rx_queues = (uint16_t)nb_rx_queues;
data->nb_tx_queues = (uint16_t)nb_tx_queues;
data->dev_link = pmd_link;
data->mac_addrs = >address;

eth_dev->data = data;
-   eth_dev->driver = eth_drv;
+   eth_dev->driver = _ring_pmd;
eth_dev->dev_ops = 
eth_dev->pci_dev = pci_dev;
TAILQ_INIT(&(eth_dev->link_intr_cbs));
@@ -531,20 +532,37 @@ rte_pmd_ring_devinit(const char *name, const char *params)

RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name);

-   if (params == NULL || params[0] == '\0')
-   eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
+   if (params == NULL || params[0] == '\0') {
+   ret = eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
+   if (ret == -1) {
+   RTE_LOG(INFO, PMD,
+   "Attach to pmd_ring for %s\n", name);
+   ret = eth_dev_ring_create(name, rte_socket_id(),
+ DEV_ATTACH);
+   }
+   }
else {
kvlist = rte_kvargs_parse(params, valid_arguments);

if (!kvlist) {
RTE_LOG(INFO, PMD, "Ignoring unsupported parameters 
when creating"
" rings-backed ethernet device\n");
-   eth_dev_ring_create(name, rte_socket_id(), DEV_CREATE);
-   return 0;
+   ret = eth_dev_ring_create(name, rte_socket_id(),
+ DEV_CREATE);
+   if (ret == -1) {
+   RTE_LOG(INFO, PMD,
+   "Attach to pmd_ring for %s\n",
+   name);
+  

[dpdk-dev] mempool destroy

2015-05-29 Thread Dax Rawal
Hi,
How does one return (or destroy)  ret_mempool that was created by
rte_mempool_create() ?

Thanks.


[dpdk-dev] Packet Cloning

2015-05-29 Thread Padam Jeet Singh
Thanks Marc, Matt, Kyle, and Stephen for your inputs!

I have a possibly good solution of splitting the mbuf into parts to correctly 
mirror to multiple interfaces, else a fallback of copying the full payload into 
a new mbuf.

Though the library doesn?t offer a standard method to copy, I can submit a 
rte_mbuf_copy() patch that does a full deep copy.

Regards,
Padam


> On 28-May-2015, at 9:43 pm, Marc Sune  wrote:
> 
> 
> 
> On 28/05/15 18:06, Matt Laswell wrote:
>> Hey Kyle,
>> 
>> That's one way you can handle it, though I suspect you'll end up with some
>> complexity elsewhere in your code to deal with remembering whether you
>> should look at the original data or the copied and modified data.  Another
>> way is just to make a copy of the original mbuf, but have your copy API
>> stop after it reaches some particular point.  Perhaps just the L2-L4
>> headers, perhaps a few hundred bytes into payload, or perhaps something
>> else entirely. This all gets very application dependent, of course.  How
>> much is "enough" is going to depend heavily on what you're trying to
>> accomplish.
> 
> mbufs can be chained in multiple segments. So you could first split into two 
> segments leaving the big chunk in the original mbuf (chunk2) and copy chunk1 
> into the new mbuf (check prepend, adj and trim).
> 
> Marc
> 
> [1] http://dpdk.org/doc/api/rte__mbuf_8h.html
> 
>> 
> 

Padam J. Singh | VP Engg. | Inventum Technologies Private Limited
www.inventum.net 
+91.9810146640

Address:
C-70, Phase II Extension,
Noida 201305, UP,
India

Tel : +91.120.4647000

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you have received this email in error please notify the system manager. This 
message contains confidential information and is intended only for the 
individual named. If you are not the named addressee you should not 
disseminate, distribute or copy this e-mail. Please notify the sender 
immediately by e-mail if you have received this e-mail by mistake and delete 
this e-mail from your system. If you are not the intended recipient you are 
notified that disclosing, copying, distributing or taking any action in 
reliance on the contents of this information is strictly prohibited. No 
employee or agent is authorized to conclude any binding agreement on behalf of 
[Inventum Technologies Private Limited] with another party by email without 
express written confirmation by a whole-time Director of the Company who has 
been authorized vide a valid board resolution to the effect. Our company 
accepts no liability for the content of this email, or for the consequences of 
any actions taken on the basis of the information provided, unless that 
information is subsequently confirmed in writing. If you are not the intended 
recipient you are notified that disclosing, copying, distributing or taking any 
action in reliance on the contents of this information is strictly prohibited. 
Any views or opinions presented in this email are solely those of the author 
and do not necessarily represent those of the company. Employees of [Inventum 
Technologies Private Limited] are expressly required not to make defamatory 
statements and not to infringe or authorize any infringement of copyright or 
any other legal right by email communications. Any such communication is 
contrary to company policy and outside the scope of the employment of the 
individual concerned. The company will not accept any liability in respect of 
such communication, and the employee responsible will be personally liable for 
any damages or other liability arising.



[dpdk-dev] [PATCH 4/4] null: fix compile on Fedora 22 (GCC 5.1)

2015-05-29 Thread Bruce Richardson
On Fedora 22, with GCC 5.1, errors are reported due to array accesses
being potentially out of bounds. This commit fixes this by adding in an
extra bounds check to the loop counter.

Signed-off-by: Bruce Richardson 
---
 drivers/net/null/rte_eth_null.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 5895065..4ca7f09 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -298,7 +298,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats 
*igb_stats)
internal = dev->data->dev_private;
memset(igb_stats, 0, sizeof(*igb_stats));
num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS,
-   internal->nb_rx_queues);
+   RTE_MIN(internal->nb_rx_queues,
+   RTE_DIM(internal->rx_null_queues)));
for (i = 0; i < num_stats; i++) {
igb_stats->q_ipackets[i] =
internal->rx_null_queues[i].rx_pkts.cnt;
@@ -306,7 +307,8 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats 
*igb_stats)
}

num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS,
-   internal->nb_tx_queues);
+   RTE_MIN(internal->nb_tx_queues,
+   RTE_DIM(internal->tx_null_queues)));
for (i = 0; i < num_stats; i++) {
igb_stats->q_opackets[i] =
internal->tx_null_queues[i].tx_pkts.cnt;
@@ -331,9 +333,11 @@ eth_stats_reset(struct rte_eth_dev *dev)
return;

internal = dev->data->dev_private;
-   for (i = 0; i < internal->nb_rx_queues; i++)
+   for (i = 0; i < internal->nb_rx_queues &&
+   i < RTE_DIM(internal->rx_null_queues); i++)
internal->rx_null_queues[i].rx_pkts.cnt = 0;
-   for (i = 0; i < internal->nb_tx_queues; i++) {
+   for (i = 0; i < internal->nb_tx_queues &&
+   i < RTE_DIM(internal->tx_null_queues); i++) {
internal->tx_null_queues[i].tx_pkts.cnt = 0;
internal->tx_null_queues[i].err_pkts.cnt = 0;
}
-- 
2.4.1



[dpdk-dev] [PATCH 3/4] i40e: fix compile on Fedora 22 (GCC 5.1)

2015-05-29 Thread Bruce Richardson
On Fedora 22, with GCC 5.1, errors are reported due to array accesses
being potentially out of bounds. This commit fixes this by adding in an
extra bounds check to the loop counter.

Signed-off-by: Bruce Richardson 
---
 drivers/net/i40e/i40e_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index e688b4f..55cf2cf 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -551,7 +551,7 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf,
memset(flex_pit, 0, sizeof(flex_pit));
num = i40e_srcoff_to_flx_pit(cfg->src_offset, flex_pit);

-   for (i = 0; i < num; i++) {
+   for (i = 0; i < num && i < RTE_DIM(flex_pit); i++) {
field_idx = layer_idx * I40E_MAX_FLXPLD_FIED + i;
/* record the info in fdir structure */
pf->fdir.flex_set[field_idx].src_offset =
-- 
2.4.1



[dpdk-dev] [PATCH 2/4] ip_frag: fix compile on Fedora 22 (GCC 5.1)

2015-05-29 Thread Bruce Richardson
On Fedora 22, with GCC 5.1, errors are reported due to array accesses
being potentially out of bounds. This commit fixes this by adding in an
extra bounds check to the loop counter.

Signed-off-by: Bruce Richardson 
---
 lib/librte_ip_frag/ip_frag_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ip_frag/ip_frag_common.h 
b/lib/librte_ip_frag/ip_frag_common.h
index 210f409..e37073b 100644
--- a/lib/librte_ip_frag/ip_frag_common.h
+++ b/lib/librte_ip_frag/ip_frag_common.h
@@ -90,7 +90,7 @@ static inline int
 ip_frag_key_is_empty(const struct ip_frag_key * key)
 {
uint32_t i;
-   for (i = 0; i < key->key_len; i++)
+   for (i = 0; i < key->key_len && i < RTE_DIM(key->src_dst); i++)
if (key->src_dst[i] != 0)
return 0;
return 1;
-- 
2.4.1



[dpdk-dev] [PATCH 1/4] eal: fix compile on Fedora 22 (GCC 5.1)

2015-05-29 Thread Bruce Richardson
On Fedora 22, with GCC 5.1, errors are reported due to array accesses
being potentially out of bounds. This commit fixes this by adding in an
extra bounds check to the loop counter.

Signed-off-by: Bruce Richardson 
---
 lib/librte_eal/linuxapp/eal/eal_memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 5f9f92e..744635f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1188,7 +1188,8 @@ rte_eal_hugepage_init(void)
int socket = tmp_hp[i].socket_id;

/* find a hugepage info with right size and increment num_pages 
*/
-   for (j = 0; j < (int) internal_config.num_hugepage_sizes; j++) {
+   for (j = 0; j < (int) internal_config.num_hugepage_sizes &&
+   j < MAX_HUGEPAGE_SIZES; j++) {
if (tmp_hp[i].size ==

internal_config.hugepage_info[j].hugepage_sz) {
 #ifdef RTE_EAL_SINGLE_FILE_SEGMENTS
-- 
2.4.1



[dpdk-dev] [PATCH 0/4] fix compilation on Fedora 22

2015-05-29 Thread Bruce Richardson
GCC version 5.1 included with Fedora 22 is running stricter array 
bounds checks which are throwing up errors in a number of components 
in the DPDK code. This patchset fixes these errors to allow compilation
with GCC on Fedora 22.

Example error:
== Build lib/librte_eal/linuxapp/eal
  CC eal_memory.o
/home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c: In function 
'rte_eal_hugepage_init':
/home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c:1193:35: error: 
array subscript is above array bounds [-Werror=array-bounds]
  internal_config.hugepage_info[j].hugepage_sz) {
   ^
compilation terminated due to -Wfatal-errors.


Bruce Richardson (4):
  eal: fix compile on Fedora 22 (GCC 5.1)
  ip_frag: fix compile on Fedora 22 (GCC 5.1)
  i40e: fix compile on Fedora 22 (GCC 5.1)
  null: fix compile on Fedora 22 (GCC 5.1)

 drivers/net/i40e/i40e_fdir.c |  2 +-
 drivers/net/null/rte_eth_null.c  | 12 
 lib/librte_eal/linuxapp/eal/eal_memory.c |  3 ++-
 lib/librte_ip_frag/ip_frag_common.h  |  2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)

-- 
2.4.1



[dpdk-dev] [PATCH v2 0/4] fix compilation on Fedora 22

2015-05-29 Thread Neil Horman
On Fri, May 29, 2015 at 03:34:12PM +0100, Bruce Richardson wrote:
> V2 Changes: 
> * use RTE_MIN instead of additional comparison checks
>   in some loops, as suggested by Neil.
> * For stats reset in null PMD, just use the size of the
>   array [which is 1] in place of the used queue counts.
> 
> GCC version 5.1 included with Fedora 22 is running stricter array 
> bounds checks which are throwing up errors in a number of components 
> in the DPDK code. This patchset fixes these errors to allow compilation
> with GCC on Fedora 22.
> 
> Example error:
> == Build lib/librte_eal/linuxapp/eal
>   CC eal_memory.o
> /home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c: In function 
> 'rte_eal_hugepage_init':
> /home/bruce/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c:1193:35: error: 
> array subscript is above array bounds [-Werror=array-bounds]
>   internal_config.hugepage_info[j].hugepage_sz) {
>^
> compilation terminated due to -Wfatal-errors.
> 
> Bruce Richardson (4):
>   eal: fix compile on Fedora 22 (GCC 5.1)
>   ip_frag: fix compile on Fedora 22 (GCC 5.1)
>   i40e: fix compile on Fedora 22 (GCC 5.1)
>   null: fix compile on Fedora 22 (GCC 5.1)
> 
>  drivers/net/i40e/i40e_fdir.c |  2 +-
>  drivers/net/null/rte_eth_null.c  | 12 
>  lib/librte_eal/linuxapp/eal/eal_memory.c |  4 +++-
>  lib/librte_ip_frag/ip_frag_common.h  |  2 +-
>  4 files changed, 13 insertions(+), 7 deletions(-)
> 
> -- 
> 2.4.1
> 
> 

Series
Acked-by: Neil Horman 



[dpdk-dev] [PATCH] log: Properly reset log_history_size in rte_log_dump_history()

2015-05-29 Thread Jan Blunck
In rte_log_dump_history() the log_history list is reinitialized without
resetting the log_history_size. In the next call to rte_log_add_in_history()
the log_history_size > RTE_LOG_HISTORY and the code unconditionally tries
to remove the first entry:

Program received signal SIGSEGV, Segmentation fault.
rte_log_add_in_history (
buf=buf at entry=0x7f02035cd000 "DATAPLANE: 9:dp0s7 link RTM_NEWLINK 
[dp0s7] \nCAST,LOWER_UP>\n", size=size 
at entry=86)
at /usr/src/packages/BUILD/lib/librte_eal/common/eal_common_log.c:122

Signed-off-by: Jan Blunck 
---
 lib/librte_eal/common/eal_common_log.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_log.c 
b/lib/librte_eal/common/eal_common_log.c
index fe3d7d5..cb4311c 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -119,7 +119,8 @@ rte_log_add_in_history(const char *buf, size_t size)
/* get a buffer for adding in history */
if (log_history_size > RTE_LOG_HISTORY) {
hist_buf = STAILQ_FIRST(_history);
-   STAILQ_REMOVE_HEAD(_history, next);
+   if (hist_buf)
+   STAILQ_REMOVE_HEAD(_history, next);
}
else {
if (rte_mempool_mc_get(log_history_mp, ) < 0)
@@ -234,6 +235,7 @@ rte_log_dump_history(FILE *out)
rte_spinlock_lock(_list_lock);
tmp_log_history = log_history;
STAILQ_INIT(_history);
+   log_history_size = 0;
rte_spinlock_unlock(_list_lock);

for (i=0; i

[dpdk-dev] [PATCH 0/5] multicast address filtering

2015-05-29 Thread Ivan Boule
On 05/28/2015 06:21 PM, Stephen Hemminger wrote:
> On Thu, 28 May 2015 17:05:18 +0200
> Ivan Boule  wrote:
>
>> Introduce PMD API to set the list of multicast MAC addresses filtered
>> by a port.
>> Implemented in the following PMDs: igb, igbvf, em, ixgbe, and ixgbevf.
>> Implementation for physical PMDs i40e, i40evf, enic, and fm10k left
>> to their respective maintainers.
>>
>> Ivan Boule (5):
>>ethdev: add multicast address filtering
>>app/testpmd: new command to add/remove multicast MAC addresses
>>e1000: add multicast MAC address filtering
>>ixgbe: add multicast MAC address filtering
>>app/testpmd: fix reply to a multicast ICMP request
>>
>>   app/test-pmd/cmdline.c   |   52 ++
>>   app/test-pmd/config.c|  142 
>> ++
>>   app/test-pmd/icmpecho.c  |   65 +++--
>>   app/test-pmd/testpmd.h   |6 ++
>>   drivers/net/e1000/em_ethdev.c|   17 +
>>   drivers/net/e1000/igb_ethdev.c   |   18 +
>>   drivers/net/ixgbe/ixgbe_ethdev.c |   32 +
>>   lib/librte_ether/rte_ethdev.c|   17 +
>>   lib/librte_ether/rte_ethdev.h|   26 +++
>>   9 files changed, 369 insertions(+), 6 deletions(-)
>>
>
> Looks good, could you also add support for virtio and vmxnet3?
>
As for physical NICs (i40e, etc.) listed above, I let the maintainers of 
the remaining NICs where this function is relevant to implement and to 
test it.
By the way, I supposed that Guest front-end vNICs were always in 
promiscuous mode by construction.
Said differently: that all packets supplied "from the outside" to the 
Host vNIC back-end driver were systematically delivered to the Guest 
vNIC front-end, whatever their destination MAC address, VLAN id., etc.
Did I missed something ?



[dpdk-dev] [PATCH v2 1/5] ethdev: add multicast address filtering

2015-05-29 Thread Ivan Boule
With the current PMD API, the receipt of multicast packets on a given
port can only be enabled by invoking the "rte_eth_allmulticast_enable"
function.
This method may not work on Virtual Functions in SR-IOV architectures
when the host PF driver does not allow such operation on VFs.
In such cases, joined multicast addresses must be individually added
in the set of multicast addresses that are filtered by the [VF] port.

For this purpose, a new function "set_mc_addr_list" is introduced
into the set of functions that are exported by a Poll Mode Driver.

Signed-off-by: Ivan Boule 
---
v2:
Use the dedicated function "rte_eth_dev_is_valid_port" to check
the "port_id" parameter in "rte_eth_dev_set_mc_addr_list".

 lib/librte_ether/rte_ethdev.c |   17 +
 lib/librte_ether/rte_ethdev.h |   26 ++
 2 files changed, 43 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 024fe8b..8001b16 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3628,3 +3628,20 @@ rte_eth_remove_tx_callback(uint8_t port_id, uint16_t 
queue_id,
/* Callback wasn't found. */
return -EINVAL;
 }
+
+int
+rte_eth_dev_set_mc_addr_list(uint8_t port_id,
+struct ether_addr *mc_addr_set,
+uint32_t nb_mc_addr)
+{
+   struct rte_eth_dev *dev;
+
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   dev = _eth_devices[port_id];
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_mc_addr_list, -ENOTSUP);
+   return dev->dev_ops->set_mc_addr_list(dev, mc_addr_set, nb_mc_addr);
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 16dbe00..04c192d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1228,6 +1228,10 @@ typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev 
*dev,
struct rte_eth_udp_tunnel *tunnel_udp);
 /**< @internal Delete tunneling UDP info */

+typedef int (*eth_set_mc_addr_list_t)(struct rte_eth_dev *dev,
+ struct ether_addr *mc_addr_set,
+ uint32_t nb_mc_addr);
+/**< @internal set the list of multicast addresses on an Ethernet device */

 #ifdef RTE_NIC_BYPASS

@@ -1386,6 +1390,7 @@ struct eth_dev_ops {
/** Get current RSS hash configuration. */
rss_hash_conf_get_t rss_hash_conf_get;
eth_filter_ctrl_t  filter_ctrl;  /**< common filter 
control*/
+   eth_set_mc_addr_list_t set_mc_addr_list; /**< set list of mcast addrs */
 };

 /**
@@ -3615,4 +3620,25 @@ int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t 
queue_id,
 }
 #endif

+/**
+ * Set the list of multicast addresses to filter on an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param mc_addr_set
+ *   The array of multicast addresses to set. Equal to NULL when the function
+ *   is invoked to flush the set of filtered addresses.
+ * @param nb_mc_addr
+ *   The number of multicast addresses in the *mc_addr_set* array. Equal to 0
+ *   when the function is invoked to flush the set of filtered addresses.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-ENOTSUP) if PMD of *port_id* doesn't support multicast filtering.
+ *   - (-ENOSPC) if *port_id* has not enough multicast filtering resources.
+ */
+int rte_eth_dev_set_mc_addr_list(uint8_t port_id,
+struct ether_addr *mc_addr_set,
+uint32_t nb_mc_addr);
+
 #endif /* _RTE_ETHDEV_H_ */
-- 
1.7.10.4



[dpdk-dev] Install DPDK on FreeBSD ports is crashing

2015-05-29 Thread Victor Detoni
Hi,

You are right. I increased the memory and works fine. Thanks a lot

thanks
Victor

On Mon, May 25, 2015 at 10:45 AM, Bruce Richardson <
bruce.richardson at intel.com> wrote:

> On Mon, May 25, 2015 at 09:54:14AM -0300, Victor Detoni wrote:
> > Hi Bruce,
> >
> > Thanks for your answer. The complete output is attached.
> >
> Thanks for that. It looks like the compiler itself is crashing or getting
> killed
> by the OS. Are you running in a memory-constrained environment, by any
> chance?
>
> I ran a further test by installing from ports on a freshly installed 10.1
> VM.
> I didn't hit any problems with the installation of DPDK there.
>
> /Bruce
>
> > On Mon, May 25, 2015 at 6:49 AM, Bruce Richardson <
> > bruce.richardson at intel.com> wrote:
> >
> > > On Sat, May 23, 2015 at 10:20:46PM -0300, Victor Detoni wrote:
> > > > Hi,
> > > >
> > > > I'm trying to install dpdk through freebsd's ports and the error is
> shown
> > > > bellow. Please, someone knows if it can install on FreeBSD 10.1? And
> what
> > > > means these errors?
> > > >
> > > > If I compile with gcc48 it works fine.
> > >
> > > Thanks for the report.
> > > I've tried installing from ports on my FreeBSD 10.1 system and all went
> > > fine for
> > > me. However, I'm going to install a fresh 10.1 VM and try there, in
> case
> > > I've
> > > missed something - as this system I've been doing DPDK development on
> for
> > > some
> > > time. In the meantime, can you please send me on the complete output of
> > > running the command: "make install clean" in /usr/ports/net/dpdk on
> your
> > > system.
> > >
> > > Thanks,
> > > /Bruce
> > >
> > > >
> > > > *  CC test_lpm.o*
> > > > *clang: error: unable to execute command: Killed*
> > > > *clang: error: clang frontend command failed due to signal (use -v
> to see
> > > > invocation)*
> > > > *FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032)
> > > 20140512*
> > > > *Target: x86_64-unknown-freebsd10.1*
> > > > *Thread model: posix*
> > > > *clang: note: diagnostic msg: PLEASE submit a bug report to
> > > > https://bugs.freebsd.org/submit/ 
> and
> > > > include the crash backtrace, preprocessed source, and associated run
> > > > script.*
> > > > *clang: note: diagnostic msg: *
> > > > **
> > > >
> > > > *PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:*
> > > > *  eprocessed source(s) and associated run script(s) are located at:*
> > > > *?lang: note: diagnostic msg: /tmp/test_lpm-441ce1.c*
> > > > *clang: note: diagnostic msg: /tmp/test_lpm-441ce1.sh*
> > > > *clang: note: diagnostic msg: *
> > > >
> > > > **
> > > > */usr/ports/net/dpdk/work/dpdk-2.0.0/mk/internal/
> rte.compile-pre.mk:126
> > > > : recipe for target 'test_lpm.o'
> failed*
> > > > *gmake[6]: *** [test_lpm.o] Error 254*
> > > > */usr/ports/net/dpdk/work/dpdk-2.0.0/mk/rte.subdir.mk:61
> > > > : recipe for target 'test' failed*
> > > > *gmake[5]: *** [test] Error 2*
> > > > */usr/ports/net/dpdk/work/dpdk-2.0.0/mk/rte.sdkbuild.mk:93
> > > > : recipe for target 'app' failed*
> > > > *gmake[4]: *** [app] Error 2*
> > > > */usr/ports/net/dpdk/work/dpdk-2.0.0/mk/rte.sdkroot.mk:124
> > > > : recipe for target 'all' failed*
> > > > *gmake[3]: *** [all] Error 2*
> > > > */usr/ports/net/dpdk/work/dpdk-2.0.0/mk/rte.sdkinstall.mk:58
> > > > : recipe for target
> > > > 'x86_64-native-bsdapp-clang_install' failed*
> > > > *gmake[2]: *** [x86_64-native-bsdapp-clang_install] Error 2*
> > > > */usr/ports/net/dpdk/work/dpdk-2.0.0/mk/rte.sdkroot.mk:102
> > > > : recipe for target 'install' failed*
> > > > *gmake[1]: *** [install] Error 2*
> > > > *gmake[1]: Leaving directory '/usr/ports/net/dpdk/work/dpdk-2.0.0'*
> > > > *===> Compilation failed unexpectedly.*
> > > > *Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the
> failure
> > > > to*
> > > > *the maintainer.*
> > > >  Error code 1*
> > > >
> > > > *Stop.*
> > > > *make: stopped in /usr/ports/net/dpdk*
> > >
>
>
>


[dpdk-dev] [PATCH 1/4] eal: fix compile on Fedora 22 (GCC 5.1)

2015-05-29 Thread Neil Horman
On Fri, May 29, 2015 at 01:53:44PM +0100, Bruce Richardson wrote:
> On Fedora 22, with GCC 5.1, errors are reported due to array accesses
> being potentially out of bounds. This commit fixes this by adding in an
> extra bounds check to the loop counter.
> 
> Signed-off-by: Bruce Richardson 
> ---
>  lib/librte_eal/linuxapp/eal/eal_memory.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
> b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index 5f9f92e..744635f 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -1188,7 +1188,8 @@ rte_eal_hugepage_init(void)
>   int socket = tmp_hp[i].socket_id;
>  
>   /* find a hugepage info with right size and increment num_pages 
> */
> - for (j = 0; j < (int) internal_config.num_hugepage_sizes; j++) {
> + for (j = 0; j < (int) internal_config.num_hugepage_sizes &&
> + j < MAX_HUGEPAGE_SIZES; j++) {
>   if (tmp_hp[i].size ==
Use RTE_MIN here, it will look alot cleaner I think
Neil

>   
> internal_config.hugepage_info[j].hugepage_sz) {
>  #ifdef RTE_EAL_SINGLE_FILE_SEGMENTS
> -- 
> 2.4.1
> 
> 


[dpdk-dev] [PATCH 1/5] ethdev: add multicast address filtering

2015-05-29 Thread Ivan Boule
On 05/28/2015 06:22 PM, Stephen Hemminger wrote:
> On Thu, 28 May 2015 17:05:19 +0200
> Ivan Boule  wrote:
>
>> +if (port_id >= nb_ports) {
>> +PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
>> +return -ENODEV;
>> +}
>> +
>
> Use rte_eth_dev_is_valid_port() function instead.
>
I missed that.
Thanks.



[dpdk-dev] [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs

2015-05-29 Thread Liang-Min Larry Wang
adding a new library based upon ethdev APIs to provide API's that bear
the same functionality as ethtool_ops (linux/ethtool.h) and net_device_ops
(linux/netdevice.h).

Signed-off-by: Liang-Min Larry Wang 
---
 MAINTAINERS|   4 +
 config/common_linuxapp |   5 +
 lib/Makefile   |   1 +
 lib/librte_ethtool/Makefile|  56 +++
 lib/librte_ethtool/rte_ethtool.c   | 155 +
 lib/librte_ethtool/rte_ethtool.h   | 257 +
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk  |   1 +
 8 files changed, 497 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

diff --git a/MAINTAINERS b/MAINTAINERS
index 9362c19..b8b481f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -186,6 +186,10 @@ M: Thomas Monjalon 
 F: lib/librte_ether/
 F: scripts/test-null.sh

+Ethtool API
+M: Liang-Min Larry Wang 
+F: lib/librte_ethtool/
+

 Drivers
 ---
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 0078dc9..f5759fd 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -129,6 +129,11 @@ CONFIG_RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT=y
 CONFIG_RTE_LIBRTE_KVARGS=y

 #
+# Compile user-space ethtool library
+#
+CONFIG_RTE_LIBRTE_ETHTOOL=y
+
+#
 # Compile generic ethernet library
 #
 CONFIG_RTE_LIBRTE_ETHER=y
diff --git a/lib/Makefile b/lib/Makefile
index 5f480f9..a6c7375 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TIMER) += librte_timer
 DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile
 DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
+DIRS-$(CONFIG_RTE_LIBRTE_ETHTOOL) += librte_ethtool
 DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += librte_vhost
 DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm
diff --git a/lib/librte_ethtool/Makefile b/lib/librte_ethtool/Makefile
new file mode 100644
index 000..1d981f6
--- /dev/null
+++ b/lib/librte_ethtool/Makefile
@@ -0,0 +1,56 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ethtool.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+EXPORT_MAP := rte_ethtool_version.map
+
+LIBABIVER := 1
+
+SRCS-y += rte_ethtool.c
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_ethtool.h
+
+# this lib depends upon:
+DEPDIRS-y += lib/librte_ether
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_ethtool/rte_ethtool.c b/lib/librte_ethtool/rte_ethtool.c
new file mode 100644
index 000..2ccf06f
--- /dev/null
+++ b/lib/librte_ethtool/rte_ethtool.c
@@ -0,0 +1,155 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.

[dpdk-dev] [PATCH 1/2] ethdev: add api to set default mac address

2015-05-29 Thread Liang-Min Larry Wang
add a new api: rte_eth_dev_default_mac_addr_set to
support changing default mac address of a NIC

Signed-off-by: Liang-Min Larry Wang 
---
 lib/librte_ether/rte_ethdev.c  | 26 ++
 lib/librte_ether/rte_ethdev.h  | 14 ++
 lib/librte_ether/rte_ether_version.map |  1 +
 3 files changed, 41 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 024fe8b..850b83c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2752,6 +2752,32 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct 
ether_addr *addr)
 }

 int
+rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
+{
+   struct rte_eth_dev *dev;
+   const int index = 0;
+   const uint32_t pool = 0;
+
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   dev = _eth_devices[port_id];
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
+
+   /* Update NIC default MAC address*/
+   (*dev->dev_ops->mac_addr_remove)(dev, index);
+   (*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
+
+   /* Update default address in NIC data structure */
+   ether_addr_copy(addr, >data->mac_addrs[index]);
+
+   return 0;
+}
+
+int
 rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
uint16_t rx_mode, uint8_t on)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 16dbe00..5f07e0d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2982,6 +2982,20 @@ int rte_eth_dev_mac_addr_add(uint8_t port, struct 
ether_addr *mac_addr,
 int rte_eth_dev_mac_addr_remove(uint8_t port, struct ether_addr *mac_addr);

 /**
+ * Set the default MAC address.
+ *
+ * @param port
+ *   The port identifier of the Ethernet device.
+ * @param mac_addr
+ *   New default MAC address.
+ * @return
+ *   - (0) if successful, or *mac_addr* didn't exist.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port* invalid.
+ */
+int rte_eth_dev_default_mac_addr_set(uint8_t port, struct ether_addr 
*mac_addr);
+
+/**
  * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
  *
  * @param port
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index a2d25a6..2dbbaa7 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -102,6 +102,7 @@ DPDK_2.0 {
rte_eth_tx_queue_setup;
rte_eth_xstats_get;
rte_eth_xstats_reset;
+   rte_eth_dev_default_mac_addr_set;

local: *;
 };
-- 
2.1.4



[dpdk-dev] [PATCH 0/2] User-space Ethtool

2015-05-29 Thread Liang-Min Larry Wang
This implementation is designed to provide a familar interface for applications 
that rely on kernel-space driver to support ethtool_op and net_device_op for 
device management. The initial implementation focuses on ops that can be 
implemented through existing netdev APIs. More ops will be supported in latter 
release.


Liang-Min Larry Wang (2):
  ethdev: add api to set default mac address
  ethtool: add new library to provide ethtool-alike APIs

 MAINTAINERS|   4 +
 config/common_linuxapp |   5 +
 lib/Makefile   |   1 +
 lib/librte_ether/rte_ethdev.c  |  26 +++
 lib/librte_ether/rte_ethdev.h  |  14 ++
 lib/librte_ether/rte_ether_version.map |   1 +
 lib/librte_ethtool/Makefile|  56 +++
 lib/librte_ethtool/rte_ethtool.c   | 155 +
 lib/librte_ethtool/rte_ethtool.h   | 257 +
 lib/librte_ethtool/rte_ethtool_version.map |  18 ++
 mk/rte.app.mk  |   1 +
 11 files changed, 538 insertions(+)
 create mode 100644 lib/librte_ethtool/Makefile
 create mode 100644 lib/librte_ethtool/rte_ethtool.c
 create mode 100644 lib/librte_ethtool/rte_ethtool.h
 create mode 100644 lib/librte_ethtool/rte_ethtool_version.map

-- 
2.1.4



[dpdk-dev] [PATCH v9 09/12] ixgbe: enable rx queue interrupts for both PF and VF

2015-05-29 Thread Stephen Hemminger
On Fri, 29 May 2015 16:45:22 +0800
Cunming Liang  wrote:

> + if (intr_handle->intr_vec == NULL) {
> + PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
> +  "intr_vec\n", dev->data->nb_rx_queues);
> + return -1;
> + }
> +

Please return an actual error code (like -ENOMEM) rather than generic -1.
It allows for easier diagnosis when using API's.


[dpdk-dev] [PATCH] pmd: change initialization to indicate pci drivers

2015-05-29 Thread Stephen Hemminger
Upcoming drivers will need to be able to support other bus types.
This is a transparent change to how struct eth_driver is initialized.
It has not function or ABI layout impact, but makes adding a later
bus type (Xen, Hyper-V, ...) much easier.

Signed-off-by: Stpehen Hemminger 
---
 drivers/net/e1000/em_ethdev.c| 2 +-
 drivers/net/e1000/igb_ethdev.c   | 4 ++--
 drivers/net/enic/enic_ethdev.c   | 2 +-
 drivers/net/fm10k/fm10k_ethdev.c | 2 +-
 drivers/net/i40e/i40e_ethdev.c   | 2 +-
 drivers/net/i40e/i40e_ethdev_vf.c| 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c | 4 ++--
 drivers/net/virtio/virtio_ethdev.c   | 2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c | 2 +-
 9 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index d28030e..9960c70 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -281,7 +281,7 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 }

 static struct eth_driver rte_em_pmd = {
-   {
+   .pci_drv = {
.name = "rte_em_pmd",
.id_table = pci_id_em_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index e4b370d..bd29bc0 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -680,7 +680,7 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
 }

 static struct eth_driver rte_igb_pmd = {
-   {
+   .pci_drv = {
.name = "rte_igb_pmd",
.id_table = pci_id_igb_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
@@ -693,7 +693,7 @@ static struct eth_driver rte_igb_pmd = {
  * virtual function driver struct
  */
 static struct eth_driver rte_igbvf_pmd = {
-   {
+   .pci_drv = {
.name = "rte_igbvf_pmd",
.id_table = pci_id_igbvf_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 69ad01b..8280cea 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -609,7 +609,7 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev)
 }

 static struct eth_driver rte_enic_pmd = {
-   {
+   .pci_drv = {
.name = "rte_enic_pmd",
.id_table = pci_id_enic_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 275c19c..3de40e6 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1841,7 +1841,7 @@ static const struct rte_pci_id pci_id_fm10k_map[] = {
 };

 static struct eth_driver rte_pmd_fm10k = {
-   {
+   .pci_drv = {
.name = "rte_pmd_fm10k",
.id_table = pci_id_fm10k_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index fb64027..f283cb3 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -265,7 +265,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
 };

 static struct eth_driver rte_i40e_pmd = {
-   {
+   .pci_drv = {
.name = "rte_i40e_pmd",
.id_table = pci_id_i40e_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 9f92a2f..c730bc6 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1199,7 +1199,7 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)
  * virtual function driver struct
  */
 static struct eth_driver rte_i40evf_pmd = {
-   {
+   .pci_drv = {
.name = "rte_i40evf_pmd",
.id_table = pci_id_i40evf_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 0d9f9b2..ca65103 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1087,7 +1087,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
 }

 static struct eth_driver rte_ixgbe_pmd = {
-   {
+   .pci_drv = {
.name = "rte_ixgbe_pmd",
.id_table = pci_id_ixgbe_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
@@ -1100,7 +1100,7 @@ static struct eth_driver rte_ixgbe_pmd = {
  * virtual function driver struct
  */
 static struct eth_driver rte_ixgbevf_pmd = {
-   {
+   .pci_drv = {
.name = "rte_ixgbevf_pmd",
.id_table = pci_id_ixgbevf_map,
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index f74e413..4353ce2 100644
--- 

[dpdk-dev] [PATCH v9 12/12] abi: fix v2.1 abi broken issue

2015-05-29 Thread Stephen Hemminger
On Fri, 29 May 2015 16:45:25 +0800
Cunming Liang  wrote:

> +#ifdef RTE_EAL_RX_INTR
> +extern int
>  rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data);
> +#else
> +static inline int
> +rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
> +{
> + RTE_SET_USED(port_id);
> + RTE_SET_USED(epfd);
> + RTE_SET_USED(op);
> + RTE_SET_USED(data);
> + return -1;
> +}
> +#endif

Doing ABI compatibility is good but hard.

I think it would be better not to provide the functions for rx_intr_ctl unless
the feature was configured on. That way anyone using them with incorrect config
would detect failure at build time, rather than run time.

Also, doesn't some doc file have to be updated for the announcement?


[dpdk-dev] [PATCH 2/2] ethtool: add new library to provide ethtool-alike APIs

2015-05-29 Thread Stephen Hemminger
On Fri, 29 May 2015 09:15:09 -0400
Liang-Min Larry Wang  wrote:

> + drvinfo->n_stats = sizeof(struct rte_eth_stats) / sizeof(uint64_t);
> + drvinfo->testinfo_len = 0;


Providing a hook to access more functionality is good and compatiablity
with old API's is helpful.  Too bad ethtool is kind of a clunky old
inflexible, and easily broken with changes. But that is not your fault.

Duplicating eth_stats in ethtool is not helpful.
This is actively discouraged for Linux device drivers.


[dpdk-dev] [PATCH 1/2] ethdev: add api to set default mac address

2015-05-29 Thread Stephen Hemminger
On Fri, 29 May 2015 09:15:08 -0400
Liang-Min Larry Wang  wrote:

>  }
>  
>  int
> +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
> +{
> + struct rte_eth_dev *dev;
> + const int index = 0;
> + const uint32_t pool = 0;
> +
> + if (!rte_eth_dev_is_valid_port(port_id)) {
> + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
> + return -ENODEV;
> + }
> +
> + dev = _eth_devices[port_id];
> + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
> + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
> +
> + /* Update NIC default MAC address*/
> + (*dev->dev_ops->mac_addr_remove)(dev, index);
> + (*dev->dev_ops->mac_addr_add)(dev, addr, index, pool);
> +
> + /* Update default address in NIC data structure */
> + ether_addr_copy(addr, >data->mac_addrs[index]);
> +
> + return 0;
> +}
> +

No. this won't work. for some devices.

Please use mac_addr_set hook added in recent DPDK


[dpdk-dev] default unicast mac address - was: add multicast address filtering

2015-05-29 Thread Stephen Hemminger
On Fri, 29 May 2015 15:12:28 +0200
Thomas Monjalon  wrote:

> Hi Stephen,
> 
> Looking at mac address management, you and Changchun added an entry in
> driver ops to be able to change the default mac address with virtio:
>   http://dpdk.org/browse/dpdk/commit/?id=5186fb1f37fe986
> Other ops functions (mac_addr_add/remove) manage the secondary unicast
> mac addresses and have a wrapper function in the API:
>   
> http://dpdk.org/doc/api/rte__ethdev_8h.html#aa2b81750086f5f9e55cf65e5cf9f2c58
> 
> It seems now that the review of the above patch was too weak and I'd like
> these issues to be fixed:
>   - mac_addr_set must be wrapped by rte_eth_dev_mac_addr_set()
>   - eth_mac_addr_set_t must be fixed to explicitly state that it
> replaces the default address

Sure, also some other drivers need mac_addr_set hook.


[dpdk-dev] [PATCH 0/5] multicast address filtering

2015-05-29 Thread Stephen Hemminger
On Fri, 29 May 2015 11:33:54 +0200
Ivan Boule  wrote:

> On 05/28/2015 06:21 PM, Stephen Hemminger wrote:
> > On Thu, 28 May 2015 17:05:18 +0200
> > Ivan Boule  wrote:
> >
> >> Introduce PMD API to set the list of multicast MAC addresses filtered
> >> by a port.
> >> Implemented in the following PMDs: igb, igbvf, em, ixgbe, and ixgbevf.
> >> Implementation for physical PMDs i40e, i40evf, enic, and fm10k left
> >> to their respective maintainers.
> >>
> >> Ivan Boule (5):
> >>ethdev: add multicast address filtering
> >>app/testpmd: new command to add/remove multicast MAC addresses
> >>e1000: add multicast MAC address filtering
> >>ixgbe: add multicast MAC address filtering
> >>app/testpmd: fix reply to a multicast ICMP request
> >>
> >>   app/test-pmd/cmdline.c   |   52 ++
> >>   app/test-pmd/config.c|  142 
> >> ++
> >>   app/test-pmd/icmpecho.c  |   65 +++--
> >>   app/test-pmd/testpmd.h   |6 ++
> >>   drivers/net/e1000/em_ethdev.c|   17 +
> >>   drivers/net/e1000/igb_ethdev.c   |   18 +
> >>   drivers/net/ixgbe/ixgbe_ethdev.c |   32 +
> >>   lib/librte_ether/rte_ethdev.c|   17 +
> >>   lib/librte_ether/rte_ethdev.h|   26 +++
> >>   9 files changed, 369 insertions(+), 6 deletions(-)
> >>
> >
> > Looks good, could you also add support for virtio and vmxnet3?
> >
> As for physical NICs (i40e, etc.) listed above, I let the maintainers of 
> the remaining NICs where this function is relevant to implement and to 
> test it.
> By the way, I supposed that Guest front-end vNICs were always in 
> promiscuous mode by construction.
> Said differently: that all packets supplied "from the outside" to the 
> Host vNIC back-end driver were systematically delivered to the Guest 
> vNIC front-end, whatever their destination MAC address, VLAN id., etc.
> Did I missed something ?
> 


For virtio, there is a mac address table, and Multicast filtering is done
by adding the multicast address to the macs table.

For vmxnet3, ther is multicast address table (shared with host) so that
multicast filtering can be done hypervisor.



[dpdk-dev] Unable to bind Virtio_pci in DPDK1.7

2015-05-29 Thread Ouyang, Changchun

> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Dey, Souvik
> Sent: Friday, May 29, 2015 1:22 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] Unable to bind Virtio_pci in DPDK1.7
> 
> Hi All,
> I am currently facing a weird issue where I am not able to 
> bind the
> virtio_pci device to igb_uio in DPDK1.7 on QEMU/KVM. I can see there are
> two fold issues.
> 1.The pci_unbind.py script where the virt_path is removed from 1.6 to 1.7
> version due to which the initial status is not able to show any interface 
> name.
> 
> Network devices using DPDK-compatible driver
> 
> 
> 
> Network devices using kernel driver
> ===
> :00:03.0 'Virtio network device' if= drv=virtio-pci
> unused=virtio_pci,igb_uio
> :00:04.0 'Virtio network device' if= drv=virtio-pci
> unused=virtio_pci,igb_uio
> :00:05.0 'Virtio network device' if= drv=virtio-pci
> unused=virtio_pci,igb_uio
> :00:06.0 'Virtio network device' if= drv=virtio-pci
> unused=virtio_pci,igb_uio
> 
> Other network devices
> =
> 
> 
> 
> 2. After correcting the above issue , I am stuck where the interface is 
> failing
> to bind to igb_uio. I tried to bind the interface manually  to igb_uio but I 
> am
> getting the following error
> 
> lspci -k
> 00:05.0 Ethernet controller: Red Hat, Inc Virtio network device
> Subsystem: Red Hat, Inc Device 0001
> Kernel modules: virtio_pci
> 
> echo :00:05.0 > /sys/bus/pci/drivers/igb_uio/bind
> -bash: echo: write error: No such device
> 
> Due to this the bind fails and the virtio_pmd is not able to take and my app 
> is
> not coming up.
> EAL: PCI device :00:03.0 on NUMA socket -1
> EAL:   probe driver: 1af4:1000 rte_virtio_pmd
> EAL:   :00:06.0 not managed by UIO driver, skipping
> EAL: Error - exiting with code: 1
>   Cause: No Ethernet ports - bye
> 
> I see lots of email threads on similar issue but none had the final 
> conclusion.
> So can someone guide me on how to proceed further or get out of this error.
> 

Suggest you use the dpdk_nic_bind.py in recently released dpdk package or get 
it from dpdk.org repo.
I use it to bind virtio-pci device to igb_uio and after that, I bind it 
reversely from igb_uio back to virtio-pci again.
It works, don't find any issue.   

Thanks
Changchun



[dpdk-dev] Unable to bind Virtio_pci in DPDK1.7

2015-05-29 Thread Dey, Souvik
Hi All,
I am currently facing a weird issue where I am not able to bind 
the virtio_pci device to igb_uio in DPDK1.7 on QEMU/KVM. I can see there are 
two fold issues.
1.The pci_unbind.py script where the virt_path is removed from 1.6 to 1.7 
version due to which the initial status is not able to show any interface name.

Network devices using DPDK-compatible driver



Network devices using kernel driver
===
:00:03.0 'Virtio network device' if= drv=virtio-pci 
unused=virtio_pci,igb_uio
:00:04.0 'Virtio network device' if= drv=virtio-pci 
unused=virtio_pci,igb_uio
:00:05.0 'Virtio network device' if= drv=virtio-pci 
unused=virtio_pci,igb_uio
:00:06.0 'Virtio network device' if= drv=virtio-pci 
unused=virtio_pci,igb_uio

Other network devices
=



2. After correcting the above issue , I am stuck where the interface is failing 
to bind to igb_uio. I tried to bind the interface manually  to igb_uio but I am 
getting the following error

lspci -k
00:05.0 Ethernet controller: Red Hat, Inc Virtio network device
Subsystem: Red Hat, Inc Device 0001
Kernel modules: virtio_pci

echo :00:05.0 > /sys/bus/pci/drivers/igb_uio/bind
-bash: echo: write error: No such device

Due to this the bind fails and the virtio_pmd is not able to take and my app is 
not coming up.
EAL: PCI device :00:03.0 on NUMA socket -1
EAL:   probe driver: 1af4:1000 rte_virtio_pmd
EAL:   :00:06.0 not managed by UIO driver, skipping
EAL: Error - exiting with code: 1
  Cause: No Ethernet ports - bye

I see lots of email threads on similar issue but none had the final conclusion. 
So can someone guide me on how to proceed further or get out of this error.

--
Regards,
Souvik



[dpdk-dev] [PATCH v3] pipeline: add statistics for librte_pipeline

2015-05-29 Thread Ramia, Kannan Babu
The confusion is due to whether you consider stats as a library feature or 
Debug feature. Mostly log levels are considered as debug features in the 
production system and controlled system wide flag not per library flags. While 
statistics could be considered as a library feature which could be turned on 
and off depends on the application needs.  I am with Cristian to have per 
library feature configuration flag for statistics. 

Regards
Kannan Babu

-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Dumitrescu, Cristian
Sent: Friday, May 29, 2015 12:56 AM
To: Rajagopalan Sivaramakrishnan; dev at dpdk.org
Subject: Re: [dpdk-dev] [PATCH v3] pipeline: add statistics for librte_pipeline

Hi Raja,

Thanks for your input.

I think we have the following options identified so far for stats collection 
configuration:

1. Stats configuration through the RTE_LOG_LEVEL 2. Single configuration flag 
global for all DPDK libraries 3. Single configuration flag per DPDK library

It would be good if Thomas and Stephen, as well as others, would reply with 
their preference order.

My personal preference order is: 3., 2., 1., but I can work with any of the 
above that is identified by the majority of the replies. My goal right now is 
reaching a conclusion on this item as soon as we can.

Regards,
Cristian



> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Rajagopalan 
> Sivaramakrishnan
> Sent: Wednesday, May 27, 2015 11:45 PM
> To: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v3] pipeline: add statistics for 
> librte_pipeline
> 
> 
> > > You also reiterate that you would like to have the stats always enabled.
> You
> > can definitely do this, it is one of the available choices, but why 
> > not also accommodate the users that want to pick the opposite 
> > choice? Why force apps to spend cycles on stats if the app either 
> > does not want these
> counters
> > (library counters not relevant for that app, maybe the app is only
> interested
> > in maintaining some other stats that it implements itself) or do not 
> > want them anymore (maybe they only needed them during debug phase), etc?
> > Jay asked this question, and I did my best in my reply to describe 
> > our motivation (http://www.dpdk.org/ml/archives/dev/2015-
> May/017992.html).
> > Maybe you missed that post, it would be good to get your reply on 
> > this one too.
> >
> > I want to see DPDK get out of the config madness.
> > This is real code, not an Intel benchmark special.
> 
> 
> I agree that statistics will definitely be required in most real-world 
> production environments and the overhead from per-core stats gathering 
> will be minimal if the data structures are such that CPU cache 
> thrashing is avoided.
> However, if there are scenarios where it is desirable to turn stats 
> off, I think we can live with a config option.
> I am not comfortable with using the log level to enable/disable 
> statistics as they are not really related. A separate config option 
> for stats collection seems like a reasonable compromise.
> 
> Raja


  1   2   >