[dpdk-dev] [PATCH 0/6] Support NVGRE on i40e

2015-01-26 Thread Jijiang Liu
The patch set supports NVGRE on i40e.

It includes:
 - Support RX filters for NVGRE packet. It uses MAC and VLAN to point
   to a queue. The filter types supported are listed below:

   1. Inner MAC and Inner VLAN ID

   2. Inner MAC address, inner VLAN ID and tenant ID.

   3. Inner MAC and tenant ID

   4. Inner MAC address

   5. Outer MAC address, tenant ID and inner MAC

   6. Inner IP

 - Support TX checksum offload for NVGRE packet, which include outer L3(IP), 
inner L3(IP) and inner L4(UDP, TCP and SCTP)

Jijiang Liu (6):
  add gre header defination
  add nvgre RX filter in i40e
  test nvgre RX filters
  add GRE packet offload flag 
  support GRE packet TX checksum offload
  test nvgre TX checksum offload

 app/test-pmd/cmdline.c|   37 -
 app/test-pmd/csumonly.c   |  105 +++--
 app/test-pmd/testpmd.h|4 +-
 lib/librte_ether/rte_ether.h  |   12 
 lib/librte_mbuf/rte_mbuf.h|6 ++
 lib/librte_pmd_i40e/i40e_ethdev.c |6 ++
 lib/librte_pmd_i40e/i40e_rxtx.c   |   15 -
 7 files changed, 139 insertions(+), 46 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH 3/3] lib/eal:igb_uio driver change

2015-01-23 Thread Jijiang Liu
Replace the CONFIG_XEN_DOM0 with the CONFIG_XEN and RTE_LIBRTE_XEN_DOM0 in the 
driver in order to mmap IO memory correctly.

Signed-off-by: Jijiang Liu 
---
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c 
b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
index ba1364b..7f643be 100644
--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
@@ -32,7 +32,7 @@
 #include 
 #include 

-#ifdef CONFIG_XEN_DOM0
+#ifdef CONFIG_XEN
 #include 
 #endif
 #include 
@@ -279,7 +279,7 @@ igbuio_pci_irqhandler(int irq, struct uio_info *info)
return IRQ_HANDLED;
 }

-#ifdef CONFIG_XEN_DOM0
+#ifdef RTE_LIBRTE_XEN_DOM0 
 static int
 igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct *vma)
 {
@@ -287,9 +287,7 @@ igbuio_dom0_mmap_phys(struct uio_info *info, struct 
vm_area_struct *vma)

idx = (int)vma->vm_pgoff;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-#ifdef HAVE_PTE_MASK_PAGE_IOMAP
vma->vm_page_prot.pgprot |= _PAGE_IOMAP;
-#endif

return remap_pfn_range(vma,
vma->vm_start,
@@ -487,7 +485,7 @@ igbuio_pci_probe(struct pci_dev *dev, const struct 
pci_device_id *id)
udev->info.version = "0.1";
udev->info.handler = igbuio_pci_irqhandler;
udev->info.irqcontrol = igbuio_pci_irqcontrol;
-#ifdef CONFIG_XEN_DOM0
+#ifdef RTE_LIBRTE_XEN_DOM0
/* check if the driver run on Xen Dom0 */
if (xen_initial_domain())
udev->info.mmap = igbuio_dom0_pci_mmap;
-- 
1.7.7.6



[dpdk-dev] [PATCH 2/3] lib/xen:DPDK dom0 Driver change

2015-01-23 Thread Jijiang Liu
Fixed all the compilation issues due to using SUSE Linux 11 SP3.

Signed-off-by: Jijiang Liu 
---
 lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c 
b/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c
index 543bf57..2715826 100644
--- a/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c
+++ b/lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c
@@ -67,7 +67,7 @@
 #include 

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

@@ -392,7 +392,7 @@ find_memseg(int count, struct dom0_mm_data * mm_data)
 static int
 dom0_memory_reserve(uint32_t rsv_size)
 {
-   uint64_t pfn, vstart, vaddr;
+   uint64_t pfn, mfn, vstart, vaddr;
uint32_t i, num_block, size, allocated_size = 0;

 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
@@ -429,7 +429,8 @@ dom0_memory_reserve(uint32_t rsv_size)
size -= PAGE_SIZE;
}

-   pfn = virt_to_pfn(vstart);
+   mfn = virt_to_mfn(vstart);
+   pfn = mfn_to_pfn(mfn);
rsv_mm_info[i].pfn = pfn;
rsv_mm_info[i].vir_addr = vstart;
rsv_mm_info[i + 1].pfn =
@@ -457,7 +458,8 @@ dom0_memory_reserve(uint32_t rsv_size)
vaddr += PAGE_SIZE;
size -= PAGE_SIZE;
}
-   pfn = virt_to_pfn(vstart);
+   mfn = virt_to_mfn(vstart);
+   pfn = mfn_to_pfn(mfn);
rsv_mm_info[i].pfn = pfn;
rsv_mm_info[i].vir_addr = vstart;
}
-- 
1.7.7.6



[dpdk-dev] [PATCH 1/3] compilation:fix compilation issues of using gcc-4.3.4

2015-01-23 Thread Jijiang Liu
Fixed a compilation issue when using gcc-4.3.4 in SUSE Linux 11 SP3.

Signe-off-by: Jijiang Liu 
---
 app/test/test.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/app/test/test.h b/app/test/test.h
index 896f7db..8b76ccf 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -149,7 +149,7 @@ struct test_command {
 void add_test_command(struct test_command *t);

 #define REGISTER_TEST_COMMAND(t) \
-static void testfn_##t(void);\
+void testfn_##t(void);\
 void __attribute__((constructor, used)) testfn_##t(void)\
 {\
add_test_command(&t);\
-- 
1.7.7.6



[dpdk-dev] [PATCH 0/3] dpdk/xen:support DPDK running on Xen Dom0 of SUSE Linux

2015-01-23 Thread Jijiang Liu
Because SUSE linux kernel doesn't not fully follow Linux kernel in main branch, 
there are some diffirences between them, and DPDK can't run on Xen Dom0 of SUSE 
Linux. Recently, some customers want us to support this, so we provide this 
patch set for it.

Now this patch set V1 is not compatible with Linux kernel in main branch, this 
purpose of sending the patch set is to help those customers who have an urgent 
need;we probably cooperate with SUSE to eliminate the gap in the future.   

The patch set was validated with the following SW version:

SUSE 11 SP3 (Linux Kernel: 3.0.76-0.11-xen)

Hypervisor: XEN 4.2

GCC: gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) 

DPDK: 1.8

In addition, users have to a small change in the source codes in SUSE 11 SP3 
Linux kernel for this patch set:
comment the 'CONFIG_XEN' define out in ./include/linux/msi.h, or esle there 
will be some compilation errors. 

//#ifndef CONFIG_XEN

struct msi_msg {
u32 address_lo; /* low 32 bits of msi message address */
u32 address_hi; /* high 32 bits of msi message address */
u32 data;   /* 16 bits of msi message data */
};
...

//#else /* CONFIG_XEN */
//struct pci_dev;
//struct msi_desc;
//#endif /* CONFIG_XEN */



Jijiang Liu (3):
  fix compilation issue
  Dom0 driver change
  igb_uio driver change

 app/test/test.h |2 +-
 config/common_linuxapp  |2 +-
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c   |8 +++-
 lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c |   10 ++
 4 files changed, 11 insertions(+), 11 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH 2/2] app/testpmd:csum fwd engine change

2015-01-16 Thread Jijiang Liu
change the palce of setting UDP tunneling packet offload flag.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 41711fd..57afdfc 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -256,9 +256,6 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
struct udp_hdr *udp_hdr;
uint64_t ol_flags = 0;

-   if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
-   ol_flags |= PKT_TX_UDP_TUNNEL_PKT;
-
if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
ipv4_hdr->hdr_checksum = 0;

@@ -392,6 +389,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
tunnel = 1;

if (tunnel == 1) {
+   if (testpmd_ol_flags &
+   TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
+   ol_flags |= PKT_TX_UDP_TUNNEL_PKT;
+
outer_ethertype = ethertype;
outer_l2_len = l2_len;
outer_l3_len = l3_len;
-- 
1.7.7.6



[dpdk-dev] [PATCH 1/2] i40e:support i40e TSO

2015-01-16 Thread Jijiang Liu
This patch enables i40e TSO feature for both non-tunneling packet and UDP 
tunneling packet.

Signed-off-by: Jijiang Liu 
Signed-off-by: Miroslaw Walukiewicz 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |3 +-
 lib/librte_pmd_i40e/i40e_rxtx.c   |  111 +++-
 lib/librte_pmd_i40e/i40e_rxtx.h   |   13 
 3 files changed, 98 insertions(+), 29 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index b47a3d2..af95296 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1516,7 +1516,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_IPV4_CKSUM |
DEV_TX_OFFLOAD_UDP_CKSUM |
DEV_TX_OFFLOAD_TCP_CKSUM |
-   DEV_TX_OFFLOAD_SCTP_CKSUM;
+   DEV_TX_OFFLOAD_SCTP_CKSUM |
+   DEV_TX_OFFLOAD_TCP_TSO;
dev_info->reta_size = pf->hash_lut_size;

dev_info->default_rxconf = (struct rte_eth_rxconf) {
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2beae3c..529ffb2 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -460,18 +460,15 @@ static inline void
 i40e_txd_enable_checksum(uint64_t ol_flags,
uint32_t *td_cmd,
uint32_t *td_offset,
-   uint8_t l2_len,
-   uint16_t l3_len,
-   uint8_t outer_l2_len,
-   uint16_t outer_l3_len,
+   union i40e_tx_offload tx_offload,
uint32_t *cd_tunneling)
 {
-   if (!l2_len) {
+   if (!tx_offload.l2_len) {
PMD_DRV_LOG(DEBUG, "L2 length set to 0");
return;
}

-   if (!l3_len) {
+   if (!tx_offload.l3_len) {
PMD_DRV_LOG(DEBUG, "L3 length set to 0");
return;
}
@@ -479,7 +476,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
/* UDP tunneling packet TX checksum offload */
if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) {

-   *td_offset |= (outer_l2_len >> 1)
+   *td_offset |= (tx_offload.outer_l2_len >> 1)
<< I40E_TX_DESC_LENGTH_MACLEN_SHIFT;

if (ol_flags & PKT_TX_OUTER_IP_CKSUM)
@@ -490,26 +487,36 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;

/* Now set the ctx descriptor fields */
-   *cd_tunneling |= (outer_l3_len >> 2) <<
+   *cd_tunneling |= (tx_offload.outer_l3_len >> 2) <<
I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
I40E_TXD_CTX_UDP_TUNNELING |
-   (l2_len >> 1) <<
+   (tx_offload.l2_len >> 1) <<
I40E_TXD_CTX_QW0_NATLEN_SHIFT;

} else
-   *td_offset |= (l2_len >> 1)
+   *td_offset |= (tx_offload.l2_len >> 1)
<< I40E_TX_DESC_LENGTH_MACLEN_SHIFT;

/* Enable L3 checksum offloads */
if (ol_flags & PKT_TX_IPV4_CSUM) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
-   *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
+   *td_offset |= (tx_offload.l3_len >> 2)
+   << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
} else if (ol_flags & PKT_TX_IPV4) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4;
-   *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
+   *td_offset |= (tx_offload.l3_len >> 2)
+   << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
} else if (ol_flags & PKT_TX_IPV6) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV6;
-   *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
+   *td_offset |= (tx_offload.l3_len >> 2)
+   << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
+   }
+
+   if (ol_flags & PKT_TX_TCP_SEG) {
+   *td_cmd |= I40E_TX_DESC_CMD_L4T_EOFT_TCP;
+   *td_offset |= (tx_offload.l4_len >> 2)
+   << I40E_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
+   return;
}

/* Enable L4 checksum offloads */
@@ -1160,8 +1167,11 @@ i40e_calc_context_desc(uint64_t flags)
 {
uint64_t mask = 0ULL;

-   if (flags | PKT_TX_UDP_TUNNEL_PKT)
+   if (flags & PKT_TX_UDP_TUNNEL_PKT)
mask |= PKT_TX_UDP_TUNNEL_PKT;
+   if (flags & PKT_TX_TCP_SEG)
+   /* need for context descr

[dpdk-dev] [PATCH 0/2] support TSO on i40e

2015-01-16 Thread Jijiang Liu
This patch set enables i40e TSO feature for both non-tunneling packet and UDP 
tunneling packet.

Jijiang Liu (2):
  support i40e TSO
  csum fwd engine testpmd change

 app/test-pmd/csumonly.c   |7 +-
 lib/librte_pmd_i40e/i40e_ethdev.c |3 +-
 lib/librte_pmd_i40e/i40e_rxtx.c   |  111 +++-
 lib/librte_pmd_i40e/i40e_rxtx.h   |   13 
 4 files changed, 102 insertions(+), 32 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v3 3/3] app/testpmd:change tx_checksum command and csum forwarding engine

2014-12-10 Thread Jijiang Liu
The patch enhances the tx_checksum command and reworks csum forwarding engine 
due to the change of tx_checksum command.
The main changes of the tx_checksum command are listed below,

1. add "tx_checksum set tunnel (hw|sw|none) (port-id)" command

2. add "tx_checksum set outer-ip (hw|sw) (port-id)" command

3. remove the "vxlan" option from the "tx_checksum set(ip|udp|tcp|sctp|vxlan) 
(hw|sw) (port-id)" command

Moreover, replace the TESTPMD_TX_OFFLOAD_VXLAN_CKSUM flag with 
TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM flag, and add the 
TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM and TESTPMD_TX_OFFLOAD_NON_TUNNEL_CKSUM flag.


Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c  |  209 ---
 app/test-pmd/csumonly.c |   38 ++---
 app/test-pmd/testpmd.h  |   14 +++-
 3 files changed, 234 insertions(+), 27 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f79ea3e..9bfa9ef 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -316,16 +316,30 @@ static void cmd_help_long_parsed(void *parsed_result,
"Disable hardware insertion of a VLAN header in"
" packets sent on a port.\n\n"

-   "tx_cksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) 
(port_id)\n"
+   "tx_cksum set (ip|udp|tcp|sctp) (hw|sw) (port_id)\n"
"Select hardware or software calculation of the"
" checksum with when transmitting a packet using the"
" csum forward engine.\n"
-   "ip|udp|tcp|sctp always concern the inner layer.\n"
-   "vxlan concerns the outer IP and UDP layer (in"
-   " case the packet is recognized as a vxlan packet by"
-   " the forward engine)\n"
+   "In the case of tunneling packet, ip|udp|tcp|sctp"
+   " always concern the inner layer.\n\n"
+
+   "tx_cksum set tunnel (hw|sw|none) (port_id)\n"
+   " Select hardware or software calculation of the"
+   " checksum with when transmitting a tunneling packet"
+   " using the csum forward engine.\n"
+   " The none option means treat tunneling packet as 
ordinary"
+   " packet when using the csum forward engine\n."
+   "Tunneling packet concerns the outer IP, inner IP"
+   " and inner L4\n"
"Please check the NIC datasheet for HW limits.\n\n"

+   "tx_cksum set (outer-ip) (hw|sw) (port_id)\n"
+   "Select hardware or software calculation of the"
+   " checksum with when transmitting a packet using the"
+   " csum forward engine.\n"
+   "outer-ip always concern the outer layer of"
+   " tunneling packet.\n\n"
+
"tx_checksum show (port_id)\n"
"Display tx checksum offload configuration\n\n"

@@ -2861,6 +2875,181 @@ cmdline_parse_inst_t cmd_tx_vlan_reset = {
},
 };

+/* ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS FOR TUNNELING */
+struct cmd_tx_cksum_tunnel_result {
+   cmdline_fixed_string_t tx_cksum;
+   cmdline_fixed_string_t mode;
+   cmdline_fixed_string_t type;
+   cmdline_fixed_string_t hwsw;
+   uint8_t port_id;
+};
+
+static void
+cmd_tx_cksum_tunnel_parsed(void *parsed_result,
+  __attribute__((unused)) struct cmdline *cl,
+  __attribute__((unused)) void *data)
+{
+   struct cmd_tx_cksum_tunnel_result *res = parsed_result;
+   int hw = 0;
+   uint16_t ol_flags, mask = 0;
+
+   if (port_id_is_invalid(res->port_id)) {
+   printf("invalid port %d\n", res->port_id);
+   return;
+   }
+
+   if (!strcmp(res->mode, "set")) {
+
+   if (!strcmp(res->hwsw, "hw"))
+   hw = 1;
+   else if (!strcmp(res->hwsw, "none")) {
+   ports[res->port_id].tx_ol_flags &=
+   ~(TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM
+   | TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM);
+   ports[res->port_id].tx_ol_flags |=
+   TESTPMD_TX_OFFLOAD_NON_TUNNEL_CKSUM;
+   return;
+   }
+
+ 

[dpdk-dev] [PATCH v3 2/3] i40e:support outer IPv4 checksum capability

2014-12-10 Thread Jijiang Liu
The DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM flag is added in i40e capability set, which 
means the i40e supports TX checksum offload of tunneling packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 87e750a..deddd0b 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1491,7 +1491,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_IPV4_CKSUM |
DEV_TX_OFFLOAD_UDP_CKSUM |
DEV_TX_OFFLOAD_TCP_CKSUM |
-   DEV_TX_OFFLOAD_SCTP_CKSUM;
+   DEV_TX_OFFLOAD_SCTP_CKSUM |
+   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
dev_info->reta_size = pf->hash_lut_size;

dev_info->default_rxconf = (struct rte_eth_rxconf) {
-- 
1.7.7.6



[dpdk-dev] [PATCH v3 1/3] librte_ether:add outer IP offload capability flag

2014-12-10 Thread Jijiang Liu
If the flag is set in a PMD, which means the NIC(s) support TX checksum offload 
of tunneling packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_ethdev.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index f66805d..bae59c3 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -916,6 +916,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_SCTP_CKSUM  0x0010
 #define DEV_TX_OFFLOAD_TCP_TSO 0x0020
 #define DEV_TX_OFFLOAD_UDP_TSO 0x0040
+#define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x0080 /**< Used for tunneling 
packet. */

 struct rte_eth_dev_info {
struct rte_pci_device *pci_dev; /**< Device PCI information. */
-- 
1.7.7.6



[dpdk-dev] [PATCH v3 0/3] enhance TX checksum command and csum forwarding engine

2014-12-10 Thread Jijiang Liu
In the current codes, the "tx_checksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) 
(port-id)" command is not easy to understand and extend, so the patch set 
enhances the tx_checksum command and reworks csum forwarding engine due to the 
change of tx_checksum command. 
The main changes of the tx_checksum command are listed below,

1> add "tx_checksum set tunnel (hw|sw|none) (port-id)" command

The command is used to set/clear tunnel flag that is used to tell the NIC that 
the packetg is a tunneing packet and application want hardware TX checksum 
offload for outer layer, or inner layer, or both.

The 'none' option means that user treat tunneling packet as ordinary packet 
when using the csum forward engine.
for example, let say we have a tunnel packet: 
eth_hdr_out/ipv4_hdr_out/udp_hdr_out/vxlan_hdr/ehtr_hdr_in/ipv4_hdr_in/tcp_hdr_in.
 one of several scenarios:

1) User requests HW offload for ipv4_hdr_out  checksum, and doesn't care is it 
a tunnelled packet or not. So he sets:

tx_checksum set tunnel none 0

tx_checksum set ip hw 0

So for such case we should set tx_tunnel to 'none'.

2> add "tx_checksum set outer-ip (hw|sw) (port-id)" command

The command is used to set/clear outer IP flag that is used to tell the NIC 
that application want hardware offload for outer layer.

3> remove the 'vxlan' option from the  "tx_checksum set (ip|udp|tcp|sctp|vxlan) 
(hw|sw) (port-id)" command

The command is used to set IP, UDP, TCP and SCTP TX checksum flag. In the case 
of tunneling packet, the IP, UDP, TCP and SCTP flags always concern inner layer.

Moreover, replace the TESTPMD_TX_OFFLOAD_VXLAN_CKSUM flag with 
TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM flag and add the 
TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM and TESTPMD_TX_OFFLOAD_NON_TUNNEL_CKSUM flag 
in test-pmd application.

v2 change:
 redefine the 'none' behaviour for "tx_checksum set tunnel (hw|sw|none) 
(port-id)" command.
v3 change:
 typo correction in cmdline help 

Jijiang Liu (3):
  add outer IP offload capability in librte_ether.
  add outer IP checksum capability in i40e PMD
  testpmd command lines of the tx_checksum and csum forwarding rework

 app/test-pmd/cmdline.c|  201 +++--
 app/test-pmd/csumonly.c   |   35 ---
 app/test-pmd/testpmd.h|6 +-
 lib/librte_ether/rte_ethdev.h |1 +
 lib/librte_pmd_i40e/i40e_ethdev.c |3 +-
 5 files changed, 218 insertions(+), 28 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v2 3/3] app/testpmd:change tx_checksum command and csum forwarding engine

2014-12-09 Thread Jijiang Liu
The patch enhances the tx_checksum command and reworks csum forwarding engine 
due to the change of tx_checksum command.
The main changes of the tx_checksum command are listed below,

1. add "tx_checksum set tunnel (hw|sw|none) (port-id)" command

2. add "tx_checksum set outer-ip (hw|sw) (port-id)" command

3. remove the "vxlan" option from the "tx_checksum set(ip|udp|tcp|sctp|vxlan) 
(hw|sw) (port-id)" command

Moreover, replace the TESTPMD_TX_OFFLOAD_VXLAN_CKSUM flag with 
TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM flag, and add the 
TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM and TESTPMD_TX_OFFLOAD_NON_TUNNEL_CKSUM flag.


Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c  |  209 ---
 app/test-pmd/csumonly.c |   38 ++---
 app/test-pmd/testpmd.h  |   14 +++-
 3 files changed, 234 insertions(+), 27 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f79ea3e..9bfa9ef 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -316,16 +316,30 @@ static void cmd_help_long_parsed(void *parsed_result,
"Disable hardware insertion of a VLAN header in"
" packets sent on a port.\n\n"

-   "tx_cksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) 
(port_id)\n"
+   "tx_cksum set (ip|udp|tcp|sctp) (hw|sw) (port_id)\n"
"Select hardware or software calculation of the"
" checksum with when transmitting a packet using the"
" csum forward engine.\n"
-   "ip|udp|tcp|sctp always concern the inner layer.\n"
-   "vxlan concerns the outer IP and UDP layer (in"
-   " case the packet is recognized as a vxlan packet by"
-   " the forward engine)\n"
+   "In the case of tunneling packet, ip|udp|tcp|sctp"
+   " always concern the inner layer.\n\n"
+
+   "tx_cksum set tunnel (hw|sw|none) (port_id)\n"
+   " Select hardware or software calculation of the"
+   " checksum with when transmitting a tunneling packet"
+   " using the csum forward engine.\n"
+   " The none option means treat tunneling packet as 
ordinary
+   " packet when using the csum forward engine.
+   "Tunneling packet concerns the outer IP, inner IP"
+   " and inner L4\n"
"Please check the NIC datasheet for HW limits.\n\n"

+   "tx_cksum set (outer-ip) (hw|sw) (port_id)\n"
+   "Select hardware or software calculation of the"
+   " checksum with when transmitting a packet using the"
+   " csum forward engine.\n"
+   "outer-ip always concern the outer layer of"
+   " tunneling packet.\n\n"
+
"tx_checksum show (port_id)\n"
"Display tx checksum offload configuration\n\n"

@@ -2861,6 +2875,181 @@ cmdline_parse_inst_t cmd_tx_vlan_reset = {
},
 };

+/* ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS FOR TUNNELING */
+struct cmd_tx_cksum_tunnel_result {
+   cmdline_fixed_string_t tx_cksum;
+   cmdline_fixed_string_t mode;
+   cmdline_fixed_string_t type;
+   cmdline_fixed_string_t hwsw;
+   uint8_t port_id;
+};
+
+static void
+cmd_tx_cksum_tunnel_parsed(void *parsed_result,
+  __attribute__((unused)) struct cmdline *cl,
+  __attribute__((unused)) void *data)
+{
+   struct cmd_tx_cksum_tunnel_result *res = parsed_result;
+   int hw = 0;
+   uint16_t ol_flags, mask = 0;
+
+   if (port_id_is_invalid(res->port_id)) {
+   printf("invalid port %d\n", res->port_id);
+   return;
+   }
+
+   if (!strcmp(res->mode, "set")) {
+
+   if (!strcmp(res->hwsw, "hw"))
+   hw = 1;
+   else if (!strcmp(res->hwsw, "none")) {
+   ports[res->port_id].tx_ol_flags &=
+   ~(TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM
+   | TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM);
+   ports[res->port_id].tx_ol_flags |=
+   TESTPMD_TX_OFFLOAD_NON_TUNNEL_CKSUM;
+   return;
+   }
+
+   ports[res->port_id].t

[dpdk-dev] [PATCH v2 2/3] i40e:support outer IPv4 checksum capability

2014-12-09 Thread Jijiang Liu
The DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM flag is added in i40e capability set, which 
means the i40e supports TX checksum offload of tunneling packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 87e750a..deddd0b 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1491,7 +1491,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_IPV4_CKSUM |
DEV_TX_OFFLOAD_UDP_CKSUM |
DEV_TX_OFFLOAD_TCP_CKSUM |
-   DEV_TX_OFFLOAD_SCTP_CKSUM;
+   DEV_TX_OFFLOAD_SCTP_CKSUM |
+   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
dev_info->reta_size = pf->hash_lut_size;

dev_info->default_rxconf = (struct rte_eth_rxconf) {
-- 
1.7.7.6



[dpdk-dev] [PATCH v2 1/3] librte_ether:add outer IP offload capability flag

2014-12-09 Thread Jijiang Liu
If the flag is set in a PMD, which means the NIC(s) support TX checksum offload 
of tunneling packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_ethdev.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index f66805d..bae59c3 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -916,6 +916,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_SCTP_CKSUM  0x0010
 #define DEV_TX_OFFLOAD_TCP_TSO 0x0020
 #define DEV_TX_OFFLOAD_UDP_TSO 0x0040
+#define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x0080 /**< Used for tunneling 
packet. */

 struct rte_eth_dev_info {
struct rte_pci_device *pci_dev; /**< Device PCI information. */
-- 
1.7.7.6



[dpdk-dev] [PATCH v2 0/3] enhance TX checksum command and csum forwarding engine

2014-12-09 Thread Jijiang Liu
In the current codes, the "tx_checksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) 
(port-id)" command is not easy to understand and extend, so the patch set 
enhances the tx_checksum command and reworks csum forwarding engine due to the 
change of tx_checksum command. 
The main changes of the tx_checksum command are listed below,

1> add "tx_checksum set tunnel (hw|sw|none) (port-id)" command

The command is used to set/clear tunnel flag that is used to tell the NIC that 
the packetg is a tunneing packet and application want hardware TX checksum 
offload for outer layer, or inner layer, or both.

The 'none' option means that user treat tunneling packet as ordinary packet 
when using the csum forward engine.
for example, let say we have a tunnel packet: 
eth_hdr_out/ipv4_hdr_out/udp_hdr_out/vxlan_hdr/ehtr_hdr_in/ipv4_hdr_in/tcp_hdr_in.
 one of several scenarios:

1) User requests HW offload for ipv4_hdr_out  checksum, and doesn't care is it 
a tunnelled packet or not. So he sets:

tx_checksum set tunnel none 0

tx_checksum set ip hw 0

So for such case we should set tx_tunnel to 'none'.

2> add "tx_checksum set outer-ip (hw|sw) (port-id)" command

The command is used to set/clear outer IP flag that is used to tell the NIC 
that application want hardware offload for outer layer.

3> remove the 'vxlan' option from the  "tx_checksum set (ip|udp|tcp|sctp|vxlan) 
(hw|sw) (port-id)" command

The command is used to set IP, UDP, TCP and SCTP TX checksum flag. In the case 
of tunneling packet, the IP, UDP, TCP and SCTP flags always concern inner layer.

Moreover, replace the TESTPMD_TX_OFFLOAD_VXLAN_CKSUM flag with 
TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM flag and add the 
TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM and TESTPMD_TX_OFFLOAD_NON_TUNNEL_CKSUM flag 
in test-pmd application.

v2 change:
 redefine the 'none' behaviour for "tx_checksum set tunnel (hw|sw|none) 
(port-id)" command.

Jijiang Liu (3):
  add outer IP offload capability in librte_ether.
  add outer IP checksum capability in i40e PMD
  testpmd command lines of the tx_checksum and csum forwarding rework

 app/test-pmd/cmdline.c|  201 +++--
 app/test-pmd/csumonly.c   |   35 ---
 app/test-pmd/testpmd.h|6 +-
 lib/librte_ether/rte_ethdev.h |1 +
 lib/librte_pmd_i40e/i40e_ethdev.c |3 +-
 5 files changed, 218 insertions(+), 28 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH 3/3] test-pmd:change tx_checksum command and csum forwarding engine

2014-12-07 Thread Jijiang Liu
The patch enhances the tx_checksum command and reworks csum forwarding engine 
due to the change of tx_checksum command.
The main changes of the tx_checksum command are listed below,

1. add "tx_checksum set tunnel (hw|sw|none) (port-id)" command

2. add "tx_checksum set outer-ip (hw|sw) (port-id)" command

3. remove the "vxlan" option from the "tx_checksum set(ip|udp|tcp|sctp|vxlan) 
(hw|sw) (port-id)" command

Moreover, replace the TESTPMD_TX_OFFLOAD_VXLAN_CKSUM flag with 
TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM flag, and add the 
TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM flag.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c  |  201 ---
 app/test-pmd/csumonly.c |   34 +---
 app/test-pmd/testpmd.h  |6 +-
 3 files changed, 215 insertions(+), 26 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f79ea3e..cf8b594 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -316,16 +316,28 @@ static void cmd_help_long_parsed(void *parsed_result,
"Disable hardware insertion of a VLAN header in"
" packets sent on a port.\n\n"

-   "tx_cksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) 
(port_id)\n"
+   "tx_cksum set (ip|udp|tcp|sctp) (hw|sw) (port_id)\n"
"Select hardware or software calculation of the"
" checksum with when transmitting a packet using the"
" csum forward engine.\n"
-   "ip|udp|tcp|sctp always concern the inner layer.\n"
-   "vxlan concerns the outer IP and UDP layer (in"
-   " case the packet is recognized as a vxlan packet by"
-   " the forward engine)\n"
+   "In the case of tunneling packet,ip|udp|tcp|sctp"
+   " always concern the inner layer.\n\n"
+
+   "tx_cksum set tunnel (hw|sw|none) (port_id)\n"
+   " Select hardware or software calculation of the"
+   " checksum with when transmitting a tunneling packet"
+   " using the csum forward engine.\n"
+   "Tunneling packet concerns the outer IP, inner IP"
+   " and inner L4\n"
"Please check the NIC datasheet for HW limits.\n\n"

+   "tx_cksum set (outer-ip) (hw|sw) (port_id)\n"
+   "Select hardware or software calculation of the"
+   " checksum with when transmitting a packet using the"
+   " csum forward engine.\n"
+   "outer-ip always concern the outer layer of"
+   " tunneling packet.\n\n"
+
"tx_checksum show (port_id)\n"
"Display tx checksum offload configuration\n\n"

@@ -2861,6 +2873,175 @@ cmdline_parse_inst_t cmd_tx_vlan_reset = {
},
 };

+/* ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS FOR TUNNELING */
+struct cmd_tx_cksum_tunnel_result {
+   cmdline_fixed_string_t tx_cksum;
+   cmdline_fixed_string_t mode;
+   cmdline_fixed_string_t type;
+   cmdline_fixed_string_t hwsw;
+   uint8_t port_id;
+};
+
+static void
+cmd_tx_cksum_tunnel_parsed(void *parsed_result,
+  __attribute__((unused)) struct cmdline *cl,
+  __attribute__((unused)) void *data)
+{
+   struct cmd_tx_cksum_tunnel_result *res = parsed_result;
+   int hw = 0;
+   uint16_t ol_flags, mask = 0;
+
+   if (port_id_is_invalid(res->port_id)) {
+   printf("invalid port %d\n", res->port_id);
+   return;
+   }
+
+   if (!strcmp(res->mode, "set")) {
+
+   if (!strcmp(res->hwsw, "hw"))
+   hw = 1;
+   else if (!strcmp(res->hwsw, "none")) {
+   ports[res->port_id].tx_ol_flags = 0;
+   return;
+   }
+
+   mask = TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM;
+
+   if (hw)
+   ports[res->port_id].tx_ol_flags |= mask;
+   else
+   ports[res->port_id].tx_ol_flags &= (~mask);
+   }
+
+   ol_flags = ports[res->port_id].tx_ol_flags;
+   printf("Tunnel checksum offload is %s\n",
+   (ol_flags & TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM) ? "hw" : "sw");
+}
+
+cmdline_parse_token_string_t

[dpdk-dev] [PATCH 2/3] i40e:support outer IPv4 checksum capability

2014-12-07 Thread Jijiang Liu
The DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM flag is added in i40e capability set, which 
means the i40e supports TX checksum offload of tunneling packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 87e750a..deddd0b 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1491,7 +1491,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct 
rte_eth_dev_info *dev_info)
DEV_TX_OFFLOAD_IPV4_CKSUM |
DEV_TX_OFFLOAD_UDP_CKSUM |
DEV_TX_OFFLOAD_TCP_CKSUM |
-   DEV_TX_OFFLOAD_SCTP_CKSUM;
+   DEV_TX_OFFLOAD_SCTP_CKSUM |
+   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
dev_info->reta_size = pf->hash_lut_size;

dev_info->default_rxconf = (struct rte_eth_rxconf) {
-- 
1.7.7.6



[dpdk-dev] [PATCH 1/3] librte_ether:add outer IP offload capability flag

2014-12-07 Thread Jijiang Liu
If the flag is set in a PMD, which means the NIC(s) support TX checksum offload 
of tunneling packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_ethdev.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index f66805d..bae59c3 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -916,6 +916,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_SCTP_CKSUM  0x0010
 #define DEV_TX_OFFLOAD_TCP_TSO 0x0020
 #define DEV_TX_OFFLOAD_UDP_TSO 0x0040
+#define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x0080 /**< Used for tunneling 
packet. */

 struct rte_eth_dev_info {
struct rte_pci_device *pci_dev; /**< Device PCI information. */
-- 
1.7.7.6



[dpdk-dev] [PATCH 0/3] enhance TX checksum command and csum forwarding engine

2014-12-07 Thread Jijiang Liu
In the current codes, the "tx_checksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) 
(port-id)" command is not easy to understand and extend, so the patch set 
enhances the tx_checksum command and reworks csum forwarding engine due to the 
change of tx_checksum command. 
The main changes of the tx_checksum command are listed below, 
1> add "tx_checksum set tunnel (hw|sw|none) (port-id)" command
The command is used to set/clear tunnel flag that is used to tell the NIC that 
the packetg is a tunneing packet and application want hardware TX checksum 
offload for outer layer, or inner layer, or both.
2> add "tx_checksum set outer-ip (hw|sw) (port-id)" command
The command is used to set/clear outer IP flag that is used to tell the NIC 
that application want hardware offload for outer layer.
3> remove the vxlan option from the  "tx_checksum set (ip|udp|tcp|sctp|vxlan) 
(hw|sw) (port-id)" command
The command is used to set IP, UDP, TCP and SCTP TX checksum flag. In the case 
of tunneling packet, the IP, UDP, TCP and SCTP flags always concern inner layer.

Moreover, replace the TESTPMD_TX_OFFLOAD_VXLAN_CKSUM flag with 
TESTPMD_TX_OFFLOAD_TUNNEL_CKSUM flag and add the 
TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM flagin test-pmd application.

Jijiang Liu (3):
  add outer IP offload capability in librte_ether.
  add outer IP checksum capability in i40e PMD
  testpmd command lines of the tx_checksum and csum forwarding rework

 app/test-pmd/cmdline.c|  201 +++--
 app/test-pmd/csumonly.c   |   35 ---
 app/test-pmd/testpmd.h|6 +-
 lib/librte_ether/rte_ethdev.h |1 +
 lib/librte_pmd_i40e/i40e_ethdev.c |3 +-
 5 files changed, 218 insertions(+), 28 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v5 3/3] mbuf:replace the inner_l2_len and the inner_l3_len fields

2014-12-02 Thread Jijiang Liu
Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field, and rework csum forward engine and i40e PMD due to  these 
changes.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |   58 +--
 lib/librte_mbuf/rte_mbuf.h  |4 +-
 lib/librte_pmd_i40e/i40e_rxtx.c |   38 +
 3 files changed, 53 insertions(+), 47 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 9094967..33ef377 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -189,11 +189,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, 
uint16_t l3_len,
} else {
if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)
ol_flags |= PKT_TX_IP_CKSUM;
-   else
+   else {
ipv4_hdr->hdr_checksum =
rte_ipv4_cksum(ipv4_hdr);
+   ol_flags |= PKT_TX_IPV4;
+   }
}
-   ol_flags |= PKT_TX_IPV4;
} else if (ethertype == _htons(ETHER_TYPE_IPv6))
ol_flags |= PKT_TX_IPV6;
else
@@ -262,22 +263,23 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
ipv4_hdr->hdr_checksum = 0;

-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0)
+   if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
+   ol_flags |= PKT_TX_OUTER_IP_CKSUM;
+   else
ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr);
-   }
+   } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
+   ol_flags |= PKT_TX_OUTER_IPV6;

udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len);
/* do not recalculate udp cksum if it was 0 */
if (udp_hdr->dgram_cksum != 0) {
udp_hdr->dgram_cksum = 0;
-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0) {
-   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
-   udp_hdr->dgram_cksum =
-   rte_ipv4_udptcp_cksum(ipv4_hdr, 
udp_hdr);
-   else
-   udp_hdr->dgram_cksum =
-   rte_ipv6_udptcp_cksum(ipv6_hdr, 
udp_hdr);
-   }
+   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
+   udp_hdr->dgram_cksum =
+   rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr);
+   else
+   udp_hdr->dgram_cksum =
+   rte_ipv6_udptcp_cksum(ipv6_hdr, udp_hdr);
}

return ol_flags;
@@ -303,8 +305,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
  * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control
  * wether a checksum must be calculated in software or in hardware. The
  * IP, UDP, TCP and SCTP flags always concern the inner layer.  The
- * VxLAN flag concerns the outer IP and UDP layer (if packet is
- * recognized as a vxlan packet).
+ * VxLAN flag concerns the outer IP(if packet is recognized as a vxlan packet).
  */
 static void
 pkt_burst_checksum_forward(struct fwd_stream *fs)
@@ -320,7 +321,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint16_t i;
uint64_t ol_flags;
uint16_t testpmd_ol_flags;
-   uint8_t l4_proto;
+   uint8_t l4_proto, l4_tun_len = 0;
uint16_t ethertype = 0, outer_ethertype = 0;
uint16_t l2_len = 0, l3_len = 0, l4_len = 0;
uint16_t outer_l2_len = 0, outer_l3_len = 0;
@@ -360,6 +361,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)

ol_flags = 0;
tunnel = 0;
+   l4_tun_len = 0;
m = pkts_burst[i];

/* Update the L3/L4 checksum error packet statistics */
@@ -378,14 +380,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
if (l4_proto == IPPROTO_UDP) {
udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len);

+   /* check udp destination port, 4789 is the default
+* vxlan port (rfc7348) */
+   if (udp_hdr->dst_port == _htons(4789)) {
+   l4_tun_len = ETHER_VXLAN_HLEN;
+   tunnel = 1;
+
/* currently, this flag is set by i40e only if the
 * packet is vxlan */
-   if (((m->ol_flags & PKT_RX_TUNNEL_IPV4_HDR) ||
-   (m->ol_flags & PKT_

[dpdk-dev] [PATCH v5 2/3] mbuf:add three TX ol_flags and repalce PKT_TX_VXLAN_CKSUM

2014-12-02 Thread Jijiang Liu
Replace PKT_TX_VXLAN_CKSUM with PKT_TX_UDP_TUNNEL_PKT in order to indicate a 
packet is an UDP tunneling packet, and introduce 3 TX offload flags for outer 
IP TX checksum, which are PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IPV4 and 
PKT_TX_OUTER_IPV6 respectively;Rework csum forward engine and i40e PMD due to 
these changes.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |9 +++--
 lib/librte_mbuf/rte_mbuf.c  |7 ++-
 lib/librte_mbuf/rte_mbuf.h  |   11 ++-
 lib/librte_pmd_i40e/i40e_rxtx.c |6 +++---
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d8c080a..9094967 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -257,7 +257,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
uint64_t ol_flags = 0;

if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
-   ol_flags |= PKT_TX_VXLAN_CKSUM;
+   ol_flags |= PKT_TX_UDP_TUNNEL_PKT;

if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
ipv4_hdr->hdr_checksum = 0;
@@ -470,7 +470,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
{ PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK },
{ PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK },
{ PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK },
-   { PKT_TX_VXLAN_CKSUM, PKT_TX_VXLAN_CKSUM },
+   { PKT_TX_UDP_TUNNEL_PKT, PKT_TX_UDP_TUNNEL_PKT 
},
+   { PKT_TX_IPV4, PKT_TX_IPV4 },
+   { PKT_TX_IPV6, PKT_TX_IPV6 },
+   { PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM 
},
+   { PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4 },
+   { PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6 },
{ PKT_TX_TCP_SEG, PKT_TX_TCP_SEG },
};
unsigned j;
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 87c2963..1b14e02 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -240,8 +240,13 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_SCTP_CKSUM: return "PKT_TX_SCTP_CKSUM";
case PKT_TX_UDP_CKSUM: return "PKT_TX_UDP_CKSUM";
case PKT_TX_IEEE1588_TMST: return "PKT_TX_IEEE1588_TMST";
-   case PKT_TX_VXLAN_CKSUM: return "PKT_TX_VXLAN_CKSUM";
+   case PKT_TX_UDP_TUNNEL_PKT: return "PKT_TX_UDP_TUNNEL_PKT";
case PKT_TX_TCP_SEG: return "PKT_TX_TCP_SEG";
+   case PKT_TX_IPV4: return "PKT_TX_IPV4";
+   case PKT_TX_IPV6: return "PKT_TX_IPV6";
+   case PKT_TX_OUTER_IP_CKSUM: return "PKT_TX_OUTER_IP_CKSUM";
+   case PKT_TX_OUTER_IPV4: return "PKT_TX_OUTER_IPV4";
+   case PKT_TX_OUTER_IPV6: return "PKT_TX_OUTER_IPV6";
default: return NULL;
}
 }
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index cbadf8e..6eb898f 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -118,7 +118,7 @@ extern "C" {
  */
 #define PKT_TX_TCP_SEG   (1ULL << 49)

-#define PKT_TX_VXLAN_CKSUM   (1ULL << 50) /**< TX checksum of VXLAN computed 
by NIC */
+#define PKT_TX_UDP_TUNNEL_PKT (1ULL << 50) /**< TX packet is an UDP tunneling 
packet */
 #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to 
timestamp. */

 /**
@@ -149,6 +149,15 @@ extern "C" {

 #define PKT_TX_VLAN_PKT  (1ULL << 57) /**< TX packet is a 802.1q VLAN 
packet. */

+/** Outer IP checksum of TX packet, computed by NIC for tunneling packet */
+#define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)
+
+/** Packet is outer IPv4 without requiring IP checksum offload for tunneling 
packet. */
+#define PKT_TX_OUTER_IPV4   (1ULL << 59)
+
+/** Tell the NIC it's an outer IPv6 packet for tunneling packet */
+#define PKT_TX_OUTER_IPV6(1ULL << 60)
+
 /* Use final bit of flags to indicate a control mbuf */
 #define CTRL_MBUF_FLAG   (1ULL << 63) /**< Mbuf contains control data */

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2d2ef04..078e973 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -478,7 +478,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
}

/* VXLAN packet TX checksum offload */
-   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
+   if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) {
uint8_t l4tun_len;

l4tun_len = ETHER_VXLAN_HLEN + inner_l2_len;
@@ -1158,8 +1158,8 @@ i40e_calc_context_desc(uint64_t flags)
 {
uint64_t mask = 0UL

[dpdk-dev] [PATCH v5 1/3] mbuf:redefine three TX ol_flags

2014-12-02 Thread Jijiang Liu
The reason of redefining the PKT_TX_IPV4 and the PKT_TX_IPV6 is listed below,
It will avoid to send a packet with a bad info:
  - we receive a Ether/IP6/IP4/L4/data packet
  - the driver sets PKT_RX_IPV6_HDR
  - the stack decapsulates IP6
  - the stack sends the packet, it has the PKT_TX_IPV6 flag but it's an IPv4 
packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 2e5fce5..cbadf8e 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -141,13 +141,13 @@ extern "C" {
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */

-/** Tell the NIC it's an IPv4 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV4  PKT_RX_IPV4_HDR
+/** Packet is IPv4 without requiring IP checksum offload. */
+#define PKT_TX_IPV4  (1ULL << 55)

-/** Tell the NIC it's an IPv6 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV6  PKT_RX_IPV6_HDR
+/** Tell the NIC it's an IPv6 packet.*/
+#define PKT_TX_IPV6  (1ULL << 56)

-#define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
+#define PKT_TX_VLAN_PKT  (1ULL << 57) /**< TX packet is a 802.1q VLAN 
packet. */

 /* Use final bit of flags to indicate a control mbuf */
 #define CTRL_MBUF_FLAG   (1ULL << 63) /**< Mbuf contains control data */
-- 
1.7.7.6



[dpdk-dev] [PATCH v5 0/3] i40e VXLAN TX checksum rework

2014-12-02 Thread Jijiang Liu
We have got some feedback about backward compatibility of VXLAN TX checksum 
offload API with 1G/10G NIC after the i40e VXLAN TX checksum codes were 
applied, so we have to rework the APIs on i40e, including the changes of mbuf, 
i40e PMD and csum forward engine.

The main changes in mbuf are as follows, in place of removing 
PKT_TX_VXLAN_CKSUM, we introduce 4 new flags: PKT_TX_OUTER_IP_CKSUM, 
PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV6 and PKT_TX_UDP_TUNNEL_PKT. Replace the 
inner_l2_len and the inner_l3_len field with the outer_l2_len and outer_l3_len 
field.

Let's use a few examples to demonstrate how to use these new flags and existing 
flags in rte_mbuf.h
Let say we have a tunnel packet: 
eth_hdr_out/ipv4_hdr_out/udp_hdr_out/vxlan_hdr/ehtr_hdr_in/ipv4_hdr_in/tcp_hdr_in.
 There could be several scenarios:

A) User requests HW offload for ipv4_hdr_out checksum.
He doesn't care is it a tunnelled packet or not. So he sets:

mb->l2_len = eth_hdr_out;
mb->l3_len = ipv4_hdr_out;
mb->ol_flags |= PKT_TX_IPV4_CSUM;

B) User is aware that it is a tunnelled packet and requests HW offload for 
ipv4_hdr_in and tcp_hdr_in *only*.
He doesn't care about outer IP checksum offload. In that case, for FVL  he has 
2 choices:
   1. Treat that packet as a 'proper' tunnelled packet, and fill all the fields:
 mb->l2_len = udp_hdr_out + vxlan_hdr +eth_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->ol_flags |= PKT_TX_UDP_TUNNEL_PKT | PKT_TX_IP_CKSUM |  
PKT_TX_TCP_CKSUM;

   2. As user doesn't care about outer IP hdr checksum, he can treat everything 
before ipv4_hdr_in as L2 header.
   So he knows, that it is a tunnelled packet, but makes HW to treat it as 
ordinary (non-tunnelled) packet:
 mb->l2_len = eth_hdr_out + ipv4_hdr_out + udp_hdr_out + vxlan_hdr + 
ehtr_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->ol_flags |= PKT_TX_IP_CKSUM |  PKT_TX_TCP_CKSUM;

i40e PMD will support both B.1 and B.2, but ixgbe/igb/em PMD supports only B.2.
if HW supports both - it will be up to user app which method to choose.
tespmd will support both methods, and it should be configurable by user which 
approach to use (cmdline parameter).
So the user can try/test both methods and select an appropriate for him.

C) User knows that is a tunnelled packet, and wants HW offload for all 3 
checksums:  outer IP hdr checksum, inner IP checksum, inner TCP checksum.
Then he has to setup all TX checksum fields:
 mb->l2_len =  udp_hdr_out + vxlan_hdr +eth_hdr_in;;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->ol_flags |= PKT_TX_OUT_IP_CKSUM  | PKT_TX_UDP_TUNNEL_PKT | 
PKT_TX_IP_CKSUM |  PKT_TX_TCP_CKSUM;

Change notes:
v2 changes:
 remove PKT_TX_IP_CKSUM alias.
 add PKT_TX_OUT_IP_CKSUM and PKT_TX_OUTER_IPV6 in rte_get_tx_ol_flag_name.
 spliting mbuf changes into two patches.
 fix MACLEN caculation issue in i40e driver
 fix some issues in csumonly.c
 change cover letter.
v3 changes:
 fix MACLEN caculation issue in i40e driver when non-tunneling packet 
v4 changes:
 reorganize patches to avoid compilation to be broken between patches.
 remove l4_tun_len from mbuf structure.
 add PKT_TX_OUTER_IPV4 to indicate no IP checksum offload requirement for 
tunneling packet.
 change i40e PMD and csum engine due to above changes.

v5 changes:
 according to Konstantin's comments, optimize process_outer_cksums() in 
order to avoid setting PKT_TX_OUTER_IPV4 flags for the case when user didn't 
enable TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 

Jijiang Liu (3):
  Redefine PKT_TX_IPV4, PKT_TX_IPV6 and PKT_TX_VLAN_PKT;
  Replace PKT_TX_VXLAN_CKSUM with PKT_TX_UDP_TUNNEL_PKT, and add 3 TX flags, 
which are PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IPV4 and PKT_TX_OUTER_IPV6,and 
rework csum forward engine and i40e pmd due to these changes;
  Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field, and rework csum forward engine and i40e pmd due to  these 
changes;

 app/test-pmd/csumonly.c |   69 ++
 lib/librte_mbuf/rte_mbuf.c  |7 +++-
 lib/librte_mbuf/rte_mbuf.h  |   25 +
 lib/librte_pmd_i40e/i40e_rxtx.c |   44 +
 4 files changed, 86 insertions(+), 59 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v4 3/3] mbuf:replace the inner_l2_len and the inner_l3_len fields

2014-12-02 Thread Jijiang Liu
Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field, and rework csum forward engine and i40e PMD due to  these 
changes.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |   60 +-
 lib/librte_mbuf/rte_mbuf.h  |4 +-
 lib/librte_pmd_i40e/i40e_rxtx.c |   38 +---
 3 files changed, 55 insertions(+), 47 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 9094967..e874ac5 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -189,11 +189,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, 
uint16_t l3_len,
} else {
if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)
ol_flags |= PKT_TX_IP_CKSUM;
-   else
+   else {
ipv4_hdr->hdr_checksum =
rte_ipv4_cksum(ipv4_hdr);
+   ol_flags |= PKT_TX_IPV4;
+   }
}
-   ol_flags |= PKT_TX_IPV4;
} else if (ethertype == _htons(ETHER_TYPE_IPv6))
ol_flags |= PKT_TX_IPV6;
else
@@ -262,22 +263,25 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
ipv4_hdr->hdr_checksum = 0;

-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0)
+   if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
+   ol_flags |= PKT_TX_OUTER_IP_CKSUM;
+   else {
+   ol_flags |= PKT_TX_OUTER_IPV4;
ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr);
-   }
+   }
+   } else
+   ol_flags |= PKT_TX_OUTER_IPV6;

udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len);
/* do not recalculate udp cksum if it was 0 */
if (udp_hdr->dgram_cksum != 0) {
udp_hdr->dgram_cksum = 0;
-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0) {
-   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
-   udp_hdr->dgram_cksum =
-   rte_ipv4_udptcp_cksum(ipv4_hdr, 
udp_hdr);
-   else
-   udp_hdr->dgram_cksum =
-   rte_ipv6_udptcp_cksum(ipv6_hdr, 
udp_hdr);
-   }
+   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
+   udp_hdr->dgram_cksum =
+   rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr);
+   else
+   udp_hdr->dgram_cksum =
+   rte_ipv6_udptcp_cksum(ipv6_hdr, udp_hdr);
}

return ol_flags;
@@ -303,8 +307,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
  * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control
  * wether a checksum must be calculated in software or in hardware. The
  * IP, UDP, TCP and SCTP flags always concern the inner layer.  The
- * VxLAN flag concerns the outer IP and UDP layer (if packet is
- * recognized as a vxlan packet).
+ * VxLAN flag concerns the outer IP(if packet is recognized as a vxlan packet).
  */
 static void
 pkt_burst_checksum_forward(struct fwd_stream *fs)
@@ -320,7 +323,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint16_t i;
uint64_t ol_flags;
uint16_t testpmd_ol_flags;
-   uint8_t l4_proto;
+   uint8_t l4_proto, l4_tun_len = 0;
uint16_t ethertype = 0, outer_ethertype = 0;
uint16_t l2_len = 0, l3_len = 0, l4_len = 0;
uint16_t outer_l2_len = 0, outer_l3_len = 0;
@@ -360,6 +363,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)

ol_flags = 0;
tunnel = 0;
+   l4_tun_len = 0;
m = pkts_burst[i];

/* Update the L3/L4 checksum error packet statistics */
@@ -378,14 +382,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
if (l4_proto == IPPROTO_UDP) {
udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len);

+   /* check udp destination port, 4789 is the default
+* vxlan port (rfc7348) */
+   if (udp_hdr->dst_port == _htons(4789)) {
+   l4_tun_len = ETHER_VXLAN_HLEN;
+   tunnel = 1;
+
/* currently, this flag is set by i40e only if the
 * packet is vxlan */
-   if (((m->ol_flags & PKT_RX_TUNNEL_IPV4_HDR) ||
-   (m->ol_flags & PKT_RX_T

[dpdk-dev] [PATCH v4 2/3] mbuf:add three TX ol_flags and repalce PKT_TX_VXLAN_CKSUM

2014-12-02 Thread Jijiang Liu
Replace PKT_TX_VXLAN_CKSUM with PKT_TX_UDP_TUNNEL_PKT in order to indicate a 
packet is an UDP tunneling packet, and introduce 3 TX offload flags for outer 
IP TX checksum, which are PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IPV4 and 
PKT_TX_OUTER_IPV6 respectively;Rework csum forward engine and i40e PMD due to 
these changes.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |9 +++--
 lib/librte_mbuf/rte_mbuf.c  |7 ++-
 lib/librte_mbuf/rte_mbuf.h  |   11 ++-
 lib/librte_pmd_i40e/i40e_rxtx.c |6 +++---
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d8c080a..9094967 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -257,7 +257,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
uint64_t ol_flags = 0;

if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
-   ol_flags |= PKT_TX_VXLAN_CKSUM;
+   ol_flags |= PKT_TX_UDP_TUNNEL_PKT;

if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
ipv4_hdr->hdr_checksum = 0;
@@ -470,7 +470,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
{ PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK },
{ PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK },
{ PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK },
-   { PKT_TX_VXLAN_CKSUM, PKT_TX_VXLAN_CKSUM },
+   { PKT_TX_UDP_TUNNEL_PKT, PKT_TX_UDP_TUNNEL_PKT 
},
+   { PKT_TX_IPV4, PKT_TX_IPV4 },
+   { PKT_TX_IPV6, PKT_TX_IPV6 },
+   { PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM 
},
+   { PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4 },
+   { PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6 },
{ PKT_TX_TCP_SEG, PKT_TX_TCP_SEG },
};
unsigned j;
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 87c2963..1b14e02 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -240,8 +240,13 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_SCTP_CKSUM: return "PKT_TX_SCTP_CKSUM";
case PKT_TX_UDP_CKSUM: return "PKT_TX_UDP_CKSUM";
case PKT_TX_IEEE1588_TMST: return "PKT_TX_IEEE1588_TMST";
-   case PKT_TX_VXLAN_CKSUM: return "PKT_TX_VXLAN_CKSUM";
+   case PKT_TX_UDP_TUNNEL_PKT: return "PKT_TX_UDP_TUNNEL_PKT";
case PKT_TX_TCP_SEG: return "PKT_TX_TCP_SEG";
+   case PKT_TX_IPV4: return "PKT_TX_IPV4";
+   case PKT_TX_IPV6: return "PKT_TX_IPV6";
+   case PKT_TX_OUTER_IP_CKSUM: return "PKT_TX_OUTER_IP_CKSUM";
+   case PKT_TX_OUTER_IPV4: return "PKT_TX_OUTER_IPV4";
+   case PKT_TX_OUTER_IPV6: return "PKT_TX_OUTER_IPV6";
default: return NULL;
}
 }
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index cbadf8e..6eb898f 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -118,7 +118,7 @@ extern "C" {
  */
 #define PKT_TX_TCP_SEG   (1ULL << 49)

-#define PKT_TX_VXLAN_CKSUM   (1ULL << 50) /**< TX checksum of VXLAN computed 
by NIC */
+#define PKT_TX_UDP_TUNNEL_PKT (1ULL << 50) /**< TX packet is an UDP tunneling 
packet */
 #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to 
timestamp. */

 /**
@@ -149,6 +149,15 @@ extern "C" {

 #define PKT_TX_VLAN_PKT  (1ULL << 57) /**< TX packet is a 802.1q VLAN 
packet. */

+/** Outer IP checksum of TX packet, computed by NIC for tunneling packet */
+#define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)
+
+/** Packet is outer IPv4 without requiring IP checksum offload for tunneling 
packet. */
+#define PKT_TX_OUTER_IPV4   (1ULL << 59)
+
+/** Tell the NIC it's an outer IPv6 packet for tunneling packet */
+#define PKT_TX_OUTER_IPV6(1ULL << 60)
+
 /* Use final bit of flags to indicate a control mbuf */
 #define CTRL_MBUF_FLAG   (1ULL << 63) /**< Mbuf contains control data */

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2d2ef04..078e973 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -478,7 +478,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
}

/* VXLAN packet TX checksum offload */
-   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
+   if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) {
uint8_t l4tun_len;

l4tun_len = ETHER_VXLAN_HLEN + inner_l2_len;
@@ -1158,8 +1158,8 @@ i40e_calc_context_desc(uint64_t flags)
 {
uint64_t mask = 0UL

[dpdk-dev] [PATCH v4 1/3] mbuf:redefine three TX ol_flags

2014-12-02 Thread Jijiang Liu
The reason of redefining the PKT_TX_IPV4 and the PKT_TX_IPV6 is listed below,
It will avoid to send a packet with a bad info:
  - we receive a Ether/IP6/IP4/L4/data packet
  - the driver sets PKT_RX_IPV6_HDR
  - the stack decapsulates IP6
  - the stack sends the packet, it has the PKT_TX_IPV6 flag but it's an IPv4 
packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 2e5fce5..cbadf8e 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -141,13 +141,13 @@ extern "C" {
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */

-/** Tell the NIC it's an IPv4 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV4  PKT_RX_IPV4_HDR
+/** Packet is IPv4 without requiring IP checksum offload. */
+#define PKT_TX_IPV4  (1ULL << 55)

-/** Tell the NIC it's an IPv6 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV6  PKT_RX_IPV6_HDR
+/** Tell the NIC it's an IPv6 packet.*/
+#define PKT_TX_IPV6  (1ULL << 56)

-#define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
+#define PKT_TX_VLAN_PKT  (1ULL << 57) /**< TX packet is a 802.1q VLAN 
packet. */

 /* Use final bit of flags to indicate a control mbuf */
 #define CTRL_MBUF_FLAG   (1ULL << 63) /**< Mbuf contains control data */
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 0/3] i40e VXLAN TX checksum rework

2014-12-02 Thread Jijiang Liu
We have got some feedback about backward compatibility of VXLAN TX checksum 
offload API with 1G/10G NIC after the i40e VXLAN TX checksum codes were 
applied, so we have to rework the APIs on i40e, including the changes of mbuf, 
i40e PMD and csum forward engine.

The main changes in mbuf are as follows, in place of removing 
PKT_TX_VXLAN_CKSUM, we introduce 4 new flags: PKT_TX_OUTER_IP_CKSUM, 
PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV6 and PKT_TX_UDP_TUNNEL_PKT. Replace the 
inner_l2_len and the inner_l3_len field with the outer_l2_len and outer_l3_len 
field.

Let's use a few examples to demonstrate how to use these new flags and existing 
flags in rte_mbuf.h
Let say we have a tunnel packet: 
eth_hdr_out/ipv4_hdr_out/udp_hdr_out/vxlan_hdr/ehtr_hdr_in/ipv4_hdr_in/tcp_hdr_in.
 There could be several scenarios:

A) User requests HW offload for ipv4_hdr_out checksum.
He doesn't care is it a tunnelled packet or not. So he sets:

mb->l2_len = eth_hdr_out;
mb->l3_len = ipv4_hdr_out;
mb->ol_flags |= PKT_TX_IPV4_CSUM;

B) User is aware that it is a tunnelled packet and requests HW offload for 
ipv4_hdr_in and tcp_hdr_in *only*.
He doesn't care about outer IP checksum offload. In that case, for FVL  he has 
2 choices:
   1. Treat that packet as a 'proper' tunnelled packet, and fill all the fields:
 mb->l2_len = udp_hdr_out + vxlan_hdr +eth_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->ol_flags |= PKT_TX_UDP_TUNNEL_PKT | PKT_TX_IP_CKSUM |  
PKT_TX_TCP_CKSUM;

   2. As user doesn't care about outer IP hdr checksum, he can treat everything 
before ipv4_hdr_in as L2 header.
   So he knows, that it is a tunnelled packet, but makes HW to treat it as 
ordinary (non-tunnelled) packet:
 mb->l2_len = eth_hdr_out + ipv4_hdr_out + udp_hdr_out + vxlan_hdr + 
ehtr_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->ol_flags |= PKT_TX_IP_CKSUM |  PKT_TX_TCP_CKSUM;

i40e PMD will support both B.1 and B.2, but ixgbe/igb/em PMD supports only B.2.
if HW supports both - it will be up to user app which method to choose.
tespmd will support both methods, and it should be configurable by user which 
approach to use (cmdline parameter).
So the user can try/test both methods and select an appropriate for him.

C) User knows that is a tunnelled packet, and wants HW offload for all 3 
checksums:  outer IP hdr checksum, inner IP checksum, inner TCP checksum.
Then he has to setup all TX checksum fields:
 mb->l2_len =  udp_hdr_out + vxlan_hdr +eth_hdr_in;;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->ol_flags |= PKT_TX_OUT_IP_CKSUM  | PKT_TX_UDP_TUNNEL_PKT | 
PKT_TX_IP_CKSUM |  PKT_TX_TCP_CKSUM;

Change notes:
v2 changes:
 remove PKT_TX_IP_CKSUM alias.
 add PKT_TX_OUT_IP_CKSUM and PKT_TX_OUTER_IPV6 in rte_get_tx_ol_flag_name.
 spliting mbuf changes into two patches.
 fix MACLEN caculation issue in i40e driver
 fix some issues in csumonly.c
 change cover letter.
v3 changes:
 fix MACLEN caculation issue in i40e driver when non-tunneling packet 
v4 changes:
 reorganize patches to avoid compilation to be broken between patches.
 remove l4_tun_len from mbuf structure.
 add PKT_TX_OUTER_IPV4 to indicate no IP checksum offload requirement for 
tunneling packet.
 change i40e PMD and csum engine due to above changes.

Jijiang Liu (3):
  Redefine PKT_TX_IPV4, PKT_TX_IPV6 and PKT_TX_VLAN_PKT;
  Replace PKT_TX_VXLAN_CKSUM with PKT_TX_UDP_TUNNEL_PKT, and add 3 TX flags, 
which are PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IPV4 and PKT_TX_OUTER_IPV6,and 
rework csum forward engine and i40e pmd due to these changes;
  Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field, and rework csum forward engine and i40e pmd due to  these 
changes;

 app/test-pmd/csumonly.c |   69 ++
 lib/librte_mbuf/rte_mbuf.c  |7 +++-
 lib/librte_mbuf/rte_mbuf.h  |   25 +
 lib/librte_pmd_i40e/i40e_rxtx.c |   44 +
 4 files changed, 86 insertions(+), 59 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v3 4/4] testpmd:rework csum forward engine

2014-11-28 Thread Jijiang Liu
The changes include:
1. use the new introduced ol_flags and fields in csumonly.c file;
2. fix an issue of outer UDP checksum check; 
3. change process logic in the process_inner_cksums();

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |   65 ++
 1 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d8c080a..f7ad3d8 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -189,11 +189,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, 
uint16_t l3_len,
} else {
if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)
ol_flags |= PKT_TX_IP_CKSUM;
-   else
+   else {
ipv4_hdr->hdr_checksum =
rte_ipv4_cksum(ipv4_hdr);
+   ol_flags |= PKT_TX_IPV4;
+   }
}
-   ol_flags |= PKT_TX_IPV4;
} else if (ethertype == _htons(ETHER_TYPE_IPv6))
ol_flags |= PKT_TX_IPV6;
else
@@ -257,27 +258,28 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
uint64_t ol_flags = 0;

if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
-   ol_flags |= PKT_TX_VXLAN_CKSUM;
+   ol_flags |= PKT_TX_UDP_TUNNEL_PKT;

if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
ipv4_hdr->hdr_checksum = 0;

-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0)
+   if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
+   ol_flags |= PKT_TX_OUTER_IP_CKSUM;
+   else
ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr);
-   }
+   } else if (outer_ethertype == _htons(ETHER_TYPE_IPv6))
+   ol_flags |= PKT_TX_OUTER_IPV6;

udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len);
/* do not recalculate udp cksum if it was 0 */
if (udp_hdr->dgram_cksum != 0) {
udp_hdr->dgram_cksum = 0;
-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0) {
-   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
-   udp_hdr->dgram_cksum =
-   rte_ipv4_udptcp_cksum(ipv4_hdr, 
udp_hdr);
-   else
-   udp_hdr->dgram_cksum =
-   rte_ipv6_udptcp_cksum(ipv6_hdr, 
udp_hdr);
-   }
+   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
+   udp_hdr->dgram_cksum =
+   rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr);
+   else
+   udp_hdr->dgram_cksum =
+   rte_ipv6_udptcp_cksum(ipv6_hdr, udp_hdr);
}

return ol_flags;
@@ -303,7 +305,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
  * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control
  * wether a checksum must be calculated in software or in hardware. The
  * IP, UDP, TCP and SCTP flags always concern the inner layer.  The
- * VxLAN flag concerns the outer IP and UDP layer (if packet is
+ * VxLAN flag concerns the outer IP(if packet is
  * recognized as a vxlan packet).
  */
 static void
@@ -320,7 +322,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint16_t i;
uint64_t ol_flags;
uint16_t testpmd_ol_flags;
-   uint8_t l4_proto;
+   uint8_t l4_proto, l4_tun_len = 0;
uint16_t ethertype = 0, outer_ethertype = 0;
uint16_t l2_len = 0, l3_len = 0, l4_len = 0;
uint16_t outer_l2_len = 0, outer_l3_len = 0;
@@ -360,6 +362,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)

ol_flags = 0;
tunnel = 0;
+   l4_tun_len = 0;
m = pkts_burst[i];

/* Update the L3/L4 checksum error packet statistics */
@@ -377,15 +380,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
/* check if it's a supported tunnel (only vxlan for now) */
if (l4_proto == IPPROTO_UDP) {
udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len);
+
+   /* check udp destination port, 4789 is the default
+* vxlan port (rfc7348) */
+   if (udp_hdr->dst_port == _htons(4789)) {
+   l4_tun_len = ETHER_VXLAN_HLEN;
+   tunnel = 1;

/* currently, this flag is set by i40e only if the
 * packet is vxlan */
-   if (((m->ol_flags & PKT_RX_TUNNEL_IPV

[dpdk-dev] [PATCH v3 3/4] i40e:PMD change for VXLAN TX checksum

2014-11-28 Thread Jijiang Liu
Rework the i40e PMD codes using the new introduced ol_flags and fields.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_rxtx.c |   52 +--
 1 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index cce6911..be06e8f 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -456,48 +456,48 @@ i40e_rxd_build_fdir(volatile union i40e_rx_desc *rxdp, 
struct rte_mbuf *mb)
 #endif
return flags;
 }
+
 static inline void
 i40e_txd_enable_checksum(uint64_t ol_flags,
uint32_t *td_cmd,
uint32_t *td_offset,
uint8_t l2_len,
uint16_t l3_len,
-   uint8_t inner_l2_len,
-   uint16_t inner_l3_len,
+   uint8_t outer_l2_len,
+   uint16_t outer_l3_len,
+   uint8_t l4_tun_len,
uint32_t *cd_tunneling)
 {
if (!l2_len) {
PMD_DRV_LOG(DEBUG, "L2 length set to 0");
return;
}
-   *td_offset |= (l2_len >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT;

if (!l3_len) {
PMD_DRV_LOG(DEBUG, "L3 length set to 0");
return;
}

-   /* VXLAN packet TX checksum offload */
-   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
-   uint8_t l4tun_len;
-
-   l4tun_len = ETHER_VXLAN_HLEN + inner_l2_len;
+   /* UDP tunneling packet TX checksum offload */
+   if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) {
+   uint16_t l4_tunnel_len;

-   if (ol_flags & PKT_TX_IPV4_CSUM)
+   *td_offset |= (outer_l2_len >> 1)
+   << I40E_TX_DESC_LENGTH_MACLEN_SHIFT;
+   l4_tunnel_len = l4_tun_len + l2_len;
+   if (ol_flags & PKT_TX_OUTER_IP_CKSUM)
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
-   else if (ol_flags & PKT_TX_IPV6)
+   else if (ol_flags & PKT_TX_OUTER_IPV6)
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;

/* Now set the ctx descriptor fields */
-   *cd_tunneling |= (l3_len >> 2) <<
+   *cd_tunneling |= (outer_l3_len >> 2) <<
I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
I40E_TXD_CTX_UDP_TUNNELING |
-   (l4tun_len >> 1) <<
+   (l4_tunnel_len >> 1) <<
I40E_TXD_CTX_QW0_NATLEN_SHIFT;
-
-   l3_len = inner_l3_len;
-   }
-
+   } else
+   *td_offset |= (l2_len >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT;
/* Enable L3 checksum offloads */
if (ol_flags & PKT_TX_IPV4_CSUM) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
@@ -1158,8 +1158,8 @@ i40e_calc_context_desc(uint64_t flags)
 {
uint64_t mask = 0ULL;

-   if (flags | PKT_TX_VXLAN_CKSUM)
-   mask |= PKT_TX_VXLAN_CKSUM;
+   if (flags | PKT_TX_UDP_TUNNEL_PKT)
+   mask |= PKT_TX_UDP_TUNNEL_PKT;

 #ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
@@ -1190,8 +1190,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
uint64_t ol_flags;
uint8_t l2_len;
uint16_t l3_len;
-   uint8_t inner_l2_len;
-   uint16_t inner_l3_len;
+   uint8_t outer_l2_len;
+   uint16_t outer_l3_len;
+   uint8_t l4_tun_len;
uint16_t nb_used;
uint16_t nb_ctx;
uint16_t tx_last;
@@ -1219,9 +1220,12 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)

ol_flags = tx_pkt->ol_flags;
l2_len = tx_pkt->l2_len;
-   inner_l2_len = tx_pkt->inner_l2_len;
l3_len = tx_pkt->l3_len;
-   inner_l3_len = tx_pkt->inner_l3_len;
+   outer_l2_len = tx_pkt->outer_l2_len;
+   outer_l3_len = tx_pkt->outer_l3_len;
+
+   /* L4 Tunneling Length */
+   l4_tun_len = tx_pkt->l4_tun_len;

/* Calculate the number of context descriptors needed. */
nb_ctx = i40e_calc_context_desc(ol_flags);
@@ -1271,8 +1275,8 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
/* Enable checksum offloading */
cd_tunneling_params = 0;
i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset,
-   l2_len, l3_len, inner_l2_len,
-   

[dpdk-dev] [PATCH v3 2/4] mbuf:change PKT_TX_IPV4 and PKT_TX_IPV6 definition

2014-11-28 Thread Jijiang Liu
It will avoid to send a packet with a bad info:
  - we receive a Ether/IP6/IP4/L4/data packet
  - the driver sets PKT_RX_IPV6_HDR
  - the stack decapsulates IP6
  - the stack sends the packet, it has the PKT_TX_IPV6 flag but it's an IPv4 
packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 22ee555..f6b3185 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -127,10 +127,10 @@ extern "C" {
 #define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */

 /** Tell the NIC it's an IPv4 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV4  PKT_RX_IPV4_HDR
+#define PKT_TX_IPV4  (1ULL << 56)

 /** Tell the NIC it's an IPv6 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV6  PKT_RX_IPV6_HDR
+#define PKT_TX_IPV6  (1ULL << 57)

 /** Outer IP cksum of TX pkt. computed by NIC for tunneling packet */
 #define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)
-- 
1.7.7.6



[dpdk-dev] [PATCH v3 1/4] mbuf:add three TX offload flags and change three fields

2014-11-28 Thread Jijiang Liu
In place of removing the PKT_TX_VXLAN_CKSUM, we introduce 3 new flags: 
PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IPV6 and PKT_TX_UDP_TUNNEL_PKT, and a new 
field: l4_tun_len.
Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field.

PKT_TX_OUTER_IP_CKSUM: is not used for non-tunnelling packet;hardware outer 
checksum for tunnelling packet.
PKT_TX_OUTER_IPV6: Tell the NIC it's an outer IPv6 packet for tunneling packet.
PKT_TX_UDP_TUNNEL_PKT: is used to tell PMD that the transmit packet is a UDP 
tunneling packet.
l4_tun_len: for VXLAN packet, it should be udp header length plus VXLAN header 
length.


Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.c |6 +-
 lib/librte_mbuf/rte_mbuf.h |   18 +++---
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 87c2963..3c47477 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -240,7 +240,11 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_SCTP_CKSUM: return "PKT_TX_SCTP_CKSUM";
case PKT_TX_UDP_CKSUM: return "PKT_TX_UDP_CKSUM";
case PKT_TX_IEEE1588_TMST: return "PKT_TX_IEEE1588_TMST";
-   case PKT_TX_VXLAN_CKSUM: return "PKT_TX_VXLAN_CKSUM";
+   case PKT_TX_UDP_TUNNEL_PKT: return "PKT_TX_UDP_TUNNEL_PKT";
+   case PKT_TX_IPV4: return "PKT_TX_IPV4";
+   case PKT_TX_IPV6: return "PKT_TX_IPV6";
+   case PKT_TX_OUTER_IP_CKSUM: return "PKT_TX_OUTER_IP_CKSUM";
+   case PKT_TX_OUTER_IPV6: return "PKT_TX_OUTER_IPV6";
case PKT_TX_TCP_SEG: return "PKT_TX_TCP_SEG";
default: return NULL;
}
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 367fc56..22ee555 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -99,10 +99,9 @@ extern "C" {
 #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */
 #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. */
 #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if FDIR 
match. */
-/* add new RX flags here */

 /* add new TX flags here */
-#define PKT_TX_VXLAN_CKSUM   (1ULL << 50) /**< TX checksum of VXLAN computed 
by NIC */
+#define PKT_TX_UDP_TUNNEL_PKT (1ULL << 50) /**< TX packet is an UDP tunneling 
packet */
 #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to 
timestamp. */

 /**
@@ -125,13 +124,19 @@ extern "C" {
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */

+#define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
+
 /** Tell the NIC it's an IPv4 packet. Required for L4 checksum offload or TSO. 
*/
 #define PKT_TX_IPV4  PKT_RX_IPV4_HDR

 /** Tell the NIC it's an IPv6 packet. Required for L4 checksum offload or TSO. 
*/
 #define PKT_TX_IPV6  PKT_RX_IPV6_HDR

-#define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
+/** Outer IP cksum of TX pkt. computed by NIC for tunneling packet */
+#define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)
+
+/** Tell the NIC it's an outer IPv6 packet for tunneling packet.*/
+#define PKT_TX_OUTER_IPV6(1ULL << 59)

 /**
  * TCP segmentation offload. To enable this offload feature for a
@@ -266,10 +271,9 @@ struct rte_mbuf {
uint64_t tso_segsz:16; /**< TCP TSO segment size */

/* fields for TX offloading of tunnels */
-   uint64_t inner_l3_len:9; /**< inner L3 (IP) Hdr Length. 
*/
-   uint64_t inner_l2_len:7; /**< inner L2 (MAC) Hdr 
Length. */
-
-   /* uint64_t unused:8; */
+   uint64_t outer_l3_len:9; /**< outer L3 (IP) Hdr Length. 
*/
+   uint64_t outer_l2_len:7; /**< outer L2 (MAC) Hdr 
Length. */
+   uint64_t l4_tun_len:8; /**< L4 tunnelling header length 
*/
};
};
 } __rte_cache_aligned;
-- 
1.7.7.6



[dpdk-dev] [PATCH v3 0/4] i40e VXLAN TX checksum rework

2014-11-28 Thread Jijiang Liu
We have got some feedback about backward compatibility of VXLAN TX checksum 
offload API with 1G/10G NIC after the i40e VXLAN TX checksum codes were 
applied, so we have to rework the APIs on i40e, including the changes of mbuf, 
i40e PMD and csum engine.

The main changes in mbuf are as follows,
In place of removing PKT_TX_VXLAN_CKSUM, we introducing 3 new flags: 
PKT_TX_OUTER_IP_CKSUM,PKT_TX_OUTER_IPV6 and PKT_TX_UDP_TUNNEL_PKT, and a new 
field: l4_tun_len.
Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field.

let's use a few examples to demonstrate how to use these new flags and existing 
flags in rte_mbuf.h
Let say we have a tunnel packet: 
eth_hdr_out/ipv4_hdr_out/udp_hdr_out/vxlan_hdr/ehtr_hdr_in/ipv4_hdr_in/tcp_hdr_in.There
 could be several scenarios:

A) User requests HW offload for ipv4_hdr_out checksum.
He doesn't care is it a tunnelled packet or not.
So he sets:

mb->l2_len =  eth_hdr_out;
mb->l3_len = ipv4_hdr_out;
mb->ol_flags |= PKT_TX_IPV4_CSUM;

B) User is aware that it is a tunnelled packet and requests HW offload for 
ipv4_hdr_in and tcp_hdr_in *only*.
He doesn't care about outer IP checksum offload.
In that case, for FVL  he has 2 choices:
   1. Treat that packet as a 'proper' tunnelled packet, and fill all the fields:
 mb->l2_len =  eth_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->l4tun_len = vxlan_hdr;
 mb->ol_flags |= PKT_TX_UDP_TUNNEL_PKT | PKT_TX_IP_CKSUM |  
PKT_TX_TCP_CKSUM;

   2. As user doesn't care about outer IP hdr checksum, he can treat everything 
before ipv4_hdr_in as L2 header.
   So he knows, that it is a tunnelled packet, but makes HW to treat it as 
ordinary (non-tunnelled) packet:
 mb->l2_len = eth_hdr_out + ipv4_hdr_out + udp_hdr_out + vxlan_hdr + 
ehtr_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->ol_flags |= PKT_TX_IP_CKSUM |  PKT_TX_TCP_CKSUM;

i40e PMD will support both B.1 and B.2.
ixgbe/igb/em PMD supports only B.2.
if HW supports both - it will be up to user app which method to choose.
tespmd will support both methods, and it should be configurable by user which 
approach to use (cmdline parameter).
So the user can try/test both methods and select an appropriate for him.

Now, B.2 is exactly what Oliver suggested.
I think it has few important advantages over B.1:
First of all - compatibility. It works across all HW we currently support 
(i40e/ixgbe/igb/em).
Second - it is probably faster even on FVL, as for it we have to fill only TXD, 
while with approach #2 we have to fill both TCD and TXD.

C) User knows that is a tunnelled packet, and wants HW offload for all 3 
checksums:  outer IP hdr checksum, inner IP checksum, inner TCP checksum.
Then he has to setup all TX checksum fields:
 mb->l2_len =  eth_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->l4tun_len = vxlan_hdr;
 mb->ol_flags |= PKT_TX_OUT_IP_CKSUM  | PKT_TX_UDP_TUNNEL | PKT_TX_IP_CKSUM 
|  PKT_TX_TCP_CKSUM;

v2 changes:
 remove PKT_TX_IP_CKSUM alias.
 add PKT_TX_OUT_IP_CKSUM and PKT_TX_OUTER_IPV6 in rte_get_tx_ol_flag_name.
 spliting mbuf changes into two patches.
 fix MACLEN caculation issue in i40e driver
 fix some issues in csumonly.c
 change cover letter.
v3 changes:
     fix MACLEN caculation issue in i40e driver when non-tunneling packet 

Jijiang Liu (4):
  mbuf change for 3 new flags and 3 fields
  mbuf change for PKT_TX_IPV4 and PKT_TX_IPV6
  i40e PMD change in i40e_rxtx.c
  rework csum forward engine


 app/test-pmd/csumonly.c |   65 ++-
 lib/librte_mbuf/rte_mbuf.c  |6 +++-
 lib/librte_mbuf/rte_mbuf.h  |   22 -
 lib/librte_pmd_i40e/i40e_rxtx.c |   49 -
 4 files changed, 82 insertions(+), 60 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v2 4/4] testpmd:rework csum forward engine

2014-11-28 Thread Jijiang Liu
The changes include:
1. use the new introduced ol_flags and fields in csumonly.c file;
2. fix an issue of outer UDP checksum check; 
3. change process logic in the process_inner_cksums();

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |   65 ++
 1 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d8c080a..f7ad3d8 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -189,11 +189,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, 
uint16_t l3_len,
} else {
if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)
ol_flags |= PKT_TX_IP_CKSUM;
-   else
+   else {
ipv4_hdr->hdr_checksum =
rte_ipv4_cksum(ipv4_hdr);
+   ol_flags |= PKT_TX_IPV4;
+   }
}
-   ol_flags |= PKT_TX_IPV4;
} else if (ethertype == _htons(ETHER_TYPE_IPv6))
ol_flags |= PKT_TX_IPV6;
else
@@ -257,27 +258,28 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
uint64_t ol_flags = 0;

if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
-   ol_flags |= PKT_TX_VXLAN_CKSUM;
+   ol_flags |= PKT_TX_UDP_TUNNEL_PKT;

if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
ipv4_hdr->hdr_checksum = 0;

-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0)
+   if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
+   ol_flags |= PKT_TX_OUTER_IP_CKSUM;
+   else
ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr);
-   }
+   } else if (outer_ethertype == _htons(ETHER_TYPE_IPv6))
+   ol_flags |= PKT_TX_OUTER_IPV6;

udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len);
/* do not recalculate udp cksum if it was 0 */
if (udp_hdr->dgram_cksum != 0) {
udp_hdr->dgram_cksum = 0;
-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0) {
-   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
-   udp_hdr->dgram_cksum =
-   rte_ipv4_udptcp_cksum(ipv4_hdr, 
udp_hdr);
-   else
-   udp_hdr->dgram_cksum =
-   rte_ipv6_udptcp_cksum(ipv6_hdr, 
udp_hdr);
-   }
+   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
+   udp_hdr->dgram_cksum =
+   rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr);
+   else
+   udp_hdr->dgram_cksum =
+   rte_ipv6_udptcp_cksum(ipv6_hdr, udp_hdr);
}

return ol_flags;
@@ -303,7 +305,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
  * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control
  * wether a checksum must be calculated in software or in hardware. The
  * IP, UDP, TCP and SCTP flags always concern the inner layer.  The
- * VxLAN flag concerns the outer IP and UDP layer (if packet is
+ * VxLAN flag concerns the outer IP(if packet is
  * recognized as a vxlan packet).
  */
 static void
@@ -320,7 +322,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint16_t i;
uint64_t ol_flags;
uint16_t testpmd_ol_flags;
-   uint8_t l4_proto;
+   uint8_t l4_proto, l4_tun_len = 0;
uint16_t ethertype = 0, outer_ethertype = 0;
uint16_t l2_len = 0, l3_len = 0, l4_len = 0;
uint16_t outer_l2_len = 0, outer_l3_len = 0;
@@ -360,6 +362,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)

ol_flags = 0;
tunnel = 0;
+   l4_tun_len = 0;
m = pkts_burst[i];

/* Update the L3/L4 checksum error packet statistics */
@@ -377,15 +380,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
/* check if it's a supported tunnel (only vxlan for now) */
if (l4_proto == IPPROTO_UDP) {
udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len);
+
+   /* check udp destination port, 4789 is the default
+* vxlan port (rfc7348) */
+   if (udp_hdr->dst_port == _htons(4789)) {
+   l4_tun_len = ETHER_VXLAN_HLEN;
+   tunnel = 1;

/* currently, this flag is set by i40e only if the
 * packet is vxlan */
-   if (((m->ol_flags & PKT_RX_TUNNEL_IPV

[dpdk-dev] [PATCH v2 3/4] i40e:PMD change for VXLAN TX checksum

2014-11-28 Thread Jijiang Liu
Rework the i40e PMD codes using the new introduced ol_flags and fields.  

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_rxtx.c |   49 +-
 1 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index cce6911..aefec9e 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -456,48 +456,49 @@ i40e_rxd_build_fdir(volatile union i40e_rx_desc *rxdp, 
struct rte_mbuf *mb)
 #endif
return flags;
 }
+
 static inline void
 i40e_txd_enable_checksum(uint64_t ol_flags,
uint32_t *td_cmd,
uint32_t *td_offset,
uint8_t l2_len,
uint16_t l3_len,
-   uint8_t inner_l2_len,
-   uint16_t inner_l3_len,
+   uint8_t outer_l2_len,
+   uint16_t outer_l3_len,
+   uint8_t l4_tun_len,
uint32_t *cd_tunneling)
 {
if (!l2_len) {
PMD_DRV_LOG(DEBUG, "L2 length set to 0");
return;
}
-   *td_offset |= (l2_len >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT;

if (!l3_len) {
PMD_DRV_LOG(DEBUG, "L3 length set to 0");
return;
}

-   /* VXLAN packet TX checksum offload */
-   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
-   uint8_t l4tun_len;
-
-   l4tun_len = ETHER_VXLAN_HLEN + inner_l2_len;
+   /* UDP tunneling packet TX checksum offload */
+   if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) {
+   uint8_t l4_tunnel_len = 0;

-   if (ol_flags & PKT_TX_IPV4_CSUM)
+   *td_offset |= (outer_l2_len >> 1)
+   << I40E_TX_DESC_LENGTH_MACLEN_SHIFT;
+   l4_tunnel_len = l4_tun_len + l2_len;
+   if (ol_flags & PKT_TX_OUTER_IP_CKSUM)
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
-   else if (ol_flags & PKT_TX_IPV6)
+   else if (ol_flags & PKT_TX_OUTER_IPV6)
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;

/* Now set the ctx descriptor fields */
-   *cd_tunneling |= (l3_len >> 2) <<
+   *cd_tunneling |= (outer_l3_len >> 2) <<
I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
I40E_TXD_CTX_UDP_TUNNELING |
-   (l4tun_len >> 1) <<
+   (l4_tunnel_len >> 1) <<
I40E_TXD_CTX_QW0_NATLEN_SHIFT;
-
-   l3_len = inner_l3_len;
}

+   *td_offset |= (l2_len >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT;
/* Enable L3 checksum offloads */
if (ol_flags & PKT_TX_IPV4_CSUM) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
@@ -1158,8 +1159,8 @@ i40e_calc_context_desc(uint64_t flags)
 {
uint64_t mask = 0ULL;

-   if (flags | PKT_TX_VXLAN_CKSUM)
-   mask |= PKT_TX_VXLAN_CKSUM;
+   if (flags | PKT_TX_UDP_TUNNEL_PKT)
+   mask |= PKT_TX_UDP_TUNNEL_PKT;

 #ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
@@ -1190,8 +1191,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
uint64_t ol_flags;
uint8_t l2_len;
uint16_t l3_len;
-   uint8_t inner_l2_len;
-   uint16_t inner_l3_len;
+   uint8_t outer_l2_len;
+   uint16_t outer_l3_len;
+   uint8_t l4_tun_len;
uint16_t nb_used;
uint16_t nb_ctx;
uint16_t tx_last;
@@ -1219,9 +1221,12 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)

ol_flags = tx_pkt->ol_flags;
l2_len = tx_pkt->l2_len;
-   inner_l2_len = tx_pkt->inner_l2_len;
l3_len = tx_pkt->l3_len;
-   inner_l3_len = tx_pkt->inner_l3_len;
+   outer_l2_len = tx_pkt->outer_l2_len;
+   outer_l3_len = tx_pkt->outer_l3_len;
+
+   /* L4 Tunneling Length */
+   l4_tun_len = tx_pkt->l4_tun_len;

/* Calculate the number of context descriptors needed. */
nb_ctx = i40e_calc_context_desc(ol_flags);
@@ -1271,8 +1276,8 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
/* Enable checksum offloading */
cd_tunneling_params = 0;
i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset,
-   l2_len, l3_len, inner_l2_len,
-   

[dpdk-dev] [PATCH v2 2/4] mbuf:change PKT_TX_IPV4 and PKT_TX_IPV6 definition

2014-11-28 Thread Jijiang Liu
It will avoid to send a packet with a bad info:
  - we receive a Ether/IP6/IP4/L4/data packet
  - the driver sets PKT_RX_IPV6_HDR
  - the stack decapsulates IP6
  - the stack sends the packet, it has the PKT_TX_IPV6 flag but it's an IPv4 
packet.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 22ee555..f6b3185 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -127,10 +127,10 @@ extern "C" {
 #define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */

 /** Tell the NIC it's an IPv4 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV4  PKT_RX_IPV4_HDR
+#define PKT_TX_IPV4  (1ULL << 56)

 /** Tell the NIC it's an IPv6 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV6  PKT_RX_IPV6_HDR
+#define PKT_TX_IPV6  (1ULL << 57)

 /** Outer IP cksum of TX pkt. computed by NIC for tunneling packet */
 #define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)
-- 
1.7.7.6



[dpdk-dev] [PATCH v2 1/4] mbuf:add three TX offload flags and change three fields

2014-11-28 Thread Jijiang Liu
In place of removing the PKT_TX_VXLAN_CKSUM, we introduce 3 new flags: 
PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IPV6 and PKT_TX_UDP_TUNNEL_PKT, and a new 
field: l4_tun_len.
Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field.

PKT_TX_OUTER_IP_CKSUM: is not used for non-tunnelling packet;hardware outer 
checksum for tunnelling packet.
PKT_TX_OUTER_IPV6: Tell the NIC it's an outer IPv6 packet for tunneling packet.
PKT_TX_UDP_TUNNEL_PKT: is used to tell PMD that the transmit packet is a UDP 
tunneling packet.
l4_tun_len: for VXLAN packet, it should be udp header length plus VXLAN header 
length.


Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.c |6 +-
 lib/librte_mbuf/rte_mbuf.h |   18 +++---
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 87c2963..3c47477 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -240,7 +240,11 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_SCTP_CKSUM: return "PKT_TX_SCTP_CKSUM";
case PKT_TX_UDP_CKSUM: return "PKT_TX_UDP_CKSUM";
case PKT_TX_IEEE1588_TMST: return "PKT_TX_IEEE1588_TMST";
-   case PKT_TX_VXLAN_CKSUM: return "PKT_TX_VXLAN_CKSUM";
+   case PKT_TX_UDP_TUNNEL_PKT: return "PKT_TX_UDP_TUNNEL_PKT";
+   case PKT_TX_IPV4: return "PKT_TX_IPV4";
+   case PKT_TX_IPV6: return "PKT_TX_IPV6";
+   case PKT_TX_OUTER_IP_CKSUM: return "PKT_TX_OUTER_IP_CKSUM";
+   case PKT_TX_OUTER_IPV6: return "PKT_TX_OUTER_IPV6";
case PKT_TX_TCP_SEG: return "PKT_TX_TCP_SEG";
default: return NULL;
}
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 367fc56..22ee555 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -99,10 +99,9 @@ extern "C" {
 #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */
 #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. */
 #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if FDIR 
match. */
-/* add new RX flags here */

 /* add new TX flags here */
-#define PKT_TX_VXLAN_CKSUM   (1ULL << 50) /**< TX checksum of VXLAN computed 
by NIC */
+#define PKT_TX_UDP_TUNNEL_PKT (1ULL << 50) /**< TX packet is an UDP tunneling 
packet */
 #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to 
timestamp. */

 /**
@@ -125,13 +124,19 @@ extern "C" {
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */

+#define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
+
 /** Tell the NIC it's an IPv4 packet. Required for L4 checksum offload or TSO. 
*/
 #define PKT_TX_IPV4  PKT_RX_IPV4_HDR

 /** Tell the NIC it's an IPv6 packet. Required for L4 checksum offload or TSO. 
*/
 #define PKT_TX_IPV6  PKT_RX_IPV6_HDR

-#define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
+/** Outer IP cksum of TX pkt. computed by NIC for tunneling packet */
+#define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)
+
+/** Tell the NIC it's an outer IPv6 packet for tunneling packet.*/
+#define PKT_TX_OUTER_IPV6(1ULL << 59)

 /**
  * TCP segmentation offload. To enable this offload feature for a
@@ -266,10 +271,9 @@ struct rte_mbuf {
uint64_t tso_segsz:16; /**< TCP TSO segment size */

/* fields for TX offloading of tunnels */
-   uint64_t inner_l3_len:9; /**< inner L3 (IP) Hdr Length. 
*/
-   uint64_t inner_l2_len:7; /**< inner L2 (MAC) Hdr 
Length. */
-
-   /* uint64_t unused:8; */
+   uint64_t outer_l3_len:9; /**< outer L3 (IP) Hdr Length. 
*/
+   uint64_t outer_l2_len:7; /**< outer L2 (MAC) Hdr 
Length. */
+   uint64_t l4_tun_len:8; /**< L4 tunnelling header length 
*/
};
};
 } __rte_cache_aligned;
-- 
1.7.7.6



[dpdk-dev] [PATCH v2 0/4] i40e VXLAN TX checksum rework

2014-11-28 Thread Jijiang Liu
We have got some feedback about backward compatibility of VXLAN TX checksum 
offload API with 1G/10G NIC after the i40e VXLAN TX checksum codes were 
applied, so we have to rework the APIs on i40e, including the changes of mbuf, 
i40e PMD and csum engine.

The main changes in mbuf are as follows,
In place of removing PKT_TX_VXLAN_CKSUM, we introducing 3 new flags: 
PKT_TX_OUTER_IP_CKSUM,PKT_TX_OUTER_IPV6 and PKT_TX_UDP_TUNNEL_PKT, and a new 
field: l4_tun_len.
Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field.

let's use a few examples to demonstrate how to use these new flags and existing 
flags in rte_mbuf.h
Let say we have a tunnel packet: 
eth_hdr_out/ipv4_hdr_out/udp_hdr_out/vxlan_hdr/ehtr_hdr_in/ipv4_hdr_in/tcp_hdr_in.There
 could be several scenarios:

A) User requests HW offload for ipv4_hdr_out checksum.
He doesn't care is it a tunnelled packet or not.
So he sets:

mb->l2_len =  eth_hdr_out;
mb->l3_len = ipv4_hdr_out;
mb->ol_flags |= PKT_TX_IPV4_CSUM;

B) User is aware that it is a tunnelled packet and requests HW offload for 
ipv4_hdr_in and tcp_hdr_in *only*.
He doesn't care about outer IP checksum offload.
In that case, for FVL  he has 2 choices:
   1. Treat that packet as a 'proper' tunnelled packet, and fill all the fields:
 mb->l2_len =  eth_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->l4tun_len = vxlan_hdr;
 mb->ol_flags |= PKT_TX_UDP_TUNNEL_PKT | PKT_TX_IP_CKSUM |  
PKT_TX_TCP_CKSUM;

   2. As user doesn't care about outer IP hdr checksum, he can treat everything 
before ipv4_hdr_in as L2 header.
   So he knows, that it is a tunnelled packet, but makes HW to treat it as 
ordinary (non-tunnelled) packet:
 mb->l2_len = eth_hdr_out + ipv4_hdr_out + udp_hdr_out + vxlan_hdr + 
ehtr_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->ol_flags |= PKT_TX_IP_CKSUM |  PKT_TX_TCP_CKSUM;

i40e PMD will support both B.1 and B.2.
ixgbe/igb/em PMD supports only B.2.
if HW supports both - it will be up to user app which method to choose.
tespmd will support both methods, and it should be configurable by user which 
approach to use (cmdline parameter).
So the user can try/test both methods and select an appropriate for him.

Now, B.2 is exactly what Oliver suggested.
I think it has few important advantages over B.1:
First of all - compatibility. It works across all HW we currently support 
(i40e/ixgbe/igb/em).
Second - it is probably faster even on FVL, as for it we have to fill only TXD, 
while with approach #2 we have to fill both TCD and TXD.

C) User knows that is a tunnelled packet, and wants HW offload for all 3 
checksums:  outer IP hdr checksum, inner IP checksum, inner TCP checksum.
Then he has to setup all TX checksum fields:
 mb->l2_len =  eth_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->l4tun_len = vxlan_hdr;
 mb->ol_flags |= PKT_TX_OUT_IP_CKSUM  | PKT_TX_UDP_TUNNEL | PKT_TX_IP_CKSUM 
|  PKT_TX_TCP_CKSUM;

v2 changes:
 remove PKT_TX_IP_CKSUM alias.
 add PKT_TX_OUT_IP_CKSUM and PKT_TX_OUTER_IPV6 in rte_get_tx_ol_flag_name.
 spliting mbuf changes into two patches.
 fix MACLEN caculation issue in i40e driver
 fix some issues in csumonly.c
 change cover letter.

Jijiang Liu (4):
  mbuf change for 3 new flags and 3 fields
  mbuf change for PKT_TX_IPV4 and PKT_TX_IPV6
  i40e PMD change in i40e_rxtx.c
  rework csum forward engine


 app/test-pmd/csumonly.c |   65 ++-
 lib/librte_mbuf/rte_mbuf.c  |6 +++-
 lib/librte_mbuf/rte_mbuf.h  |   22 -
 lib/librte_pmd_i40e/i40e_rxtx.c |   49 -
 4 files changed, 82 insertions(+), 60 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH 3/3] testpmd:rework csum forward engine

2014-11-27 Thread Jijiang Liu
The changes include:
1. use the new introduced ol_flags and fields in csumonly.c file;
2. fix an issue of outer UDP checksum check;
3. fix an issue that is if the TESTPMD_TX_OFFLOAD_IP_CKSUM is not set, and the 
"ol_flags |= PKT_TX_IPV4" should be done in the process_inner_cksums();

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |   55 +-
 1 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d8c080a..0727510 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -189,11 +189,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, 
uint16_t l3_len,
} else {
if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)
ol_flags |= PKT_TX_IP_CKSUM;
-   else
+   else {
ipv4_hdr->hdr_checksum =
rte_ipv4_cksum(ipv4_hdr);
+   ol_flags |= PKT_TX_IPV4;
+   }
}
-   ol_flags |= PKT_TX_IPV4;
} else if (ethertype == _htons(ETHER_TYPE_IPv6))
ol_flags |= PKT_TX_IPV6;
else
@@ -257,27 +258,28 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t 
outer_ethertype,
uint64_t ol_flags = 0;

if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
-   ol_flags |= PKT_TX_VXLAN_CKSUM;
+   ol_flags |= PKT_TX_UDP_TUNNEL_PKT;

if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) {
ipv4_hdr->hdr_checksum = 0;

-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0)
+   if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)
+   ol_flags |= PKT_TX_OUTER_IPV4_CSUM;
+   else
ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr);
-   }
+   } else if (outer_ethertype == _htons(ETHER_TYPE_IPv6))
+   ol_flags |= PKT_TX_OUTER_IPV6;

udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len);
/* do not recalculate udp cksum if it was 0 */
if (udp_hdr->dgram_cksum != 0) {
udp_hdr->dgram_cksum = 0;
-   if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) == 0) {
-   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
-   udp_hdr->dgram_cksum =
-   rte_ipv4_udptcp_cksum(ipv4_hdr, 
udp_hdr);
-   else
-   udp_hdr->dgram_cksum =
-   rte_ipv6_udptcp_cksum(ipv6_hdr, 
udp_hdr);
-   }
+   if (outer_ethertype == _htons(ETHER_TYPE_IPv4))
+   udp_hdr->dgram_cksum =
+   rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr);
+   else
+   udp_hdr->dgram_cksum =
+   rte_ipv6_udptcp_cksum(ipv6_hdr, udp_hdr);
}

return ol_flags;
@@ -320,7 +322,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint16_t i;
uint64_t ol_flags;
uint16_t testpmd_ol_flags;
-   uint8_t l4_proto;
+   uint8_t l4_proto, l4_tun_len = 0;
uint16_t ethertype = 0, outer_ethertype = 0;
uint16_t l2_len = 0, l3_len = 0, l4_len = 0;
uint16_t outer_l2_len = 0, outer_l3_len = 0;
@@ -383,10 +385,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
if (((m->ol_flags & PKT_RX_TUNNEL_IPV4_HDR) ||
(m->ol_flags & PKT_RX_TUNNEL_IPV6_HDR)))
tunnel = 1;
-   /* else check udp destination port, 4789 is the default
-* vxlan port (rfc7348) */
-   else if (udp_hdr->dst_port == _htons(4789))
-   tunnel = 1;

if (tunnel == 1) {
outer_ethertype = ethertype;
@@ -394,6 +392,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
outer_l3_len = l3_len;
outer_l3_hdr = l3_hdr;

+   /* check udp destination port, 4789 is the 
default
+* vxlan port (rfc7348) */
+   if (udp_hdr->dst_port == _htons(4789))
+   l4_tun_len = ETHER_VXLAN_HLEN;
+
eth_hdr = (struct ether_hdr *)((char *)udp_hdr +
sizeof(struct udp_hdr) +
sizeof(struct vxlan_hdr));
@@ -432,10 +435,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)

  

[dpdk-dev] [PATCH 2/3] i40e:PMD change for VXLAN TX checksum

2014-11-27 Thread Jijiang Liu
Rework the i40e PMD codes using the new introduced ol_flags and fields.  

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_rxtx.c |   40 +-
 1 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index cce6911..b5d14bd 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -462,8 +462,8 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
uint32_t *td_offset,
uint8_t l2_len,
uint16_t l3_len,
-   uint8_t inner_l2_len,
-   uint16_t inner_l3_len,
+   uint8_t l4_tunnel_len,
+   uint16_t outer_l3_len,
uint32_t *cd_tunneling)
 {
if (!l2_len) {
@@ -477,25 +477,19 @@ i40e_txd_enable_checksum(uint64_t ol_flags,
return;
}

-   /* VXLAN packet TX checksum offload */
-   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
-   uint8_t l4tun_len;
-
-   l4tun_len = ETHER_VXLAN_HLEN + inner_l2_len;
-
-   if (ol_flags & PKT_TX_IPV4_CSUM)
+   /* UDP tunneling packet TX checksum offload */
+   if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) {
+   if (ol_flags & PKT_TX_OUTER_IPV4_CSUM)
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
-   else if (ol_flags & PKT_TX_IPV6)
+   else if (ol_flags & PKT_TX_OUTER_IPV6)
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;

/* Now set the ctx descriptor fields */
-   *cd_tunneling |= (l3_len >> 2) <<
+   *cd_tunneling |= (outer_l3_len >> 2) <<
I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
I40E_TXD_CTX_UDP_TUNNELING |
-   (l4tun_len >> 1) <<
+   (l4_tunnel_len >> 1) <<
I40E_TXD_CTX_QW0_NATLEN_SHIFT;
-
-   l3_len = inner_l3_len;
}

/* Enable L3 checksum offloads */
@@ -1158,8 +1152,8 @@ i40e_calc_context_desc(uint64_t flags)
 {
uint64_t mask = 0ULL;

-   if (flags | PKT_TX_VXLAN_CKSUM)
-   mask |= PKT_TX_VXLAN_CKSUM;
+   if (flags | PKT_TX_UDP_TUNNEL_PKT)
+   mask |= PKT_TX_UDP_TUNNEL_PKT;

 #ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
@@ -1190,8 +1184,8 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
uint64_t ol_flags;
uint8_t l2_len;
uint16_t l3_len;
-   uint8_t inner_l2_len;
-   uint16_t inner_l3_len;
+   uint16_t outer_l3_len;
+   uint8_t l4_tunnel_len;
uint16_t nb_used;
uint16_t nb_ctx;
uint16_t tx_last;
@@ -1219,9 +1213,11 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)

ol_flags = tx_pkt->ol_flags;
l2_len = tx_pkt->l2_len;
-   inner_l2_len = tx_pkt->inner_l2_len;
l3_len = tx_pkt->l3_len;
-   inner_l3_len = tx_pkt->inner_l3_len;
+   outer_l3_len = tx_pkt->outer_l3_len;
+
+   /* L4 Tunneling Length */
+   l4_tunnel_len = tx_pkt->l4_tun_len + l2_len;

/* Calculate the number of context descriptors needed. */
nb_ctx = i40e_calc_context_desc(ol_flags);
@@ -1271,8 +1267,8 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
/* Enable checksum offloading */
cd_tunneling_params = 0;
i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset,
-   l2_len, l3_len, inner_l2_len,
-   inner_l3_len,
+   l2_len, l3_len, l4_tunnel_len,
+   outer_l3_len,
&cd_tunneling_params);

if (unlikely(nb_ctx)) {
-- 
1.7.7.6



[dpdk-dev] [PATCH 1/3] mbuf:add two TX offload flags and change three fields

2014-11-27 Thread Jijiang Liu
In place of removing the PKT_TX_VXLAN_CKSUM, we introduce 2 new flags: 
PKT_TX_OUT_IP_CKSUM, PKT_TX_UDP_TUNNEL_PKT, and a new field: l4_tun_len.
Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field.

PKT_TX_OUT_IP_CKSUM: is not used for non-tunnelling packet;hardware outer 
checksum for tunnelling packet.
PKT_TX_UDP_TUNNEL_PKT: is used to tell PMD that the transmit packet is a UDP 
tunneling packet.
l4_tun_len: for VXLAN packet, it should be udp header length plus VXLAN header 
length. 

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.c |2 +-
 lib/librte_mbuf/rte_mbuf.h |   23 ++-
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 87c2963..e89c310 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -240,7 +240,7 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_SCTP_CKSUM: return "PKT_TX_SCTP_CKSUM";
case PKT_TX_UDP_CKSUM: return "PKT_TX_UDP_CKSUM";
case PKT_TX_IEEE1588_TMST: return "PKT_TX_IEEE1588_TMST";
-   case PKT_TX_VXLAN_CKSUM: return "PKT_TX_VXLAN_CKSUM";
+   case PKT_TX_UDP_TUNNEL_PKT: return "PKT_TX_UDP_TUNNEL_PKT";
case PKT_TX_TCP_SEG: return "PKT_TX_TCP_SEG";
default: return NULL;
}
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 367fc56..48cd8e1 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -99,10 +99,9 @@ extern "C" {
 #define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */
 #define PKT_RX_FDIR_ID   (1ULL << 13) /**< FD id reported if FDIR match. */
 #define PKT_RX_FDIR_FLX  (1ULL << 14) /**< Flexible bytes reported if FDIR 
match. */
-/* add new RX flags here */

 /* add new TX flags here */
-#define PKT_TX_VXLAN_CKSUM   (1ULL << 50) /**< TX checksum of VXLAN computed 
by NIC */
+#define PKT_TX_UDP_TUNNEL_PKT (1ULL << 50) /**< TX packet is an UDP tunneling 
packet */
 #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to 
timestamp. */

 /**
@@ -125,13 +124,20 @@ extern "C" {
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */

+#define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
+
 /** Tell the NIC it's an IPv4 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV4  PKT_RX_IPV4_HDR
+#define PKT_TX_IPV4  (1ULL << 56)

 /** Tell the NIC it's an IPv6 packet. Required for L4 checksum offload or TSO. 
*/
-#define PKT_TX_IPV6  PKT_RX_IPV6_HDR
+#define PKT_TX_IPV6  (1ULL << 57)

-#define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
+/** Outer IP cksum of TX pkt. computed by NIC for tunneling packet */
+#define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)
+#define PKT_TX_OUTER_IPV4_CSUM  PKT_TX_OUTER_IP_CKSUM /**< Alias of 
PKT_TX_OUTER_IP_CKSUM. */
+
+/** Tell the NIC it's an outer IPv6 packet for tunneling packet.*/
+#define PKT_TX_OUTER_IPV6(1ULL << 59)

 /**
  * TCP segmentation offload. To enable this offload feature for a
@@ -266,10 +272,9 @@ struct rte_mbuf {
uint64_t tso_segsz:16; /**< TCP TSO segment size */

/* fields for TX offloading of tunnels */
-   uint64_t inner_l3_len:9; /**< inner L3 (IP) Hdr Length. 
*/
-   uint64_t inner_l2_len:7; /**< inner L2 (MAC) Hdr 
Length. */
-
-   /* uint64_t unused:8; */
+   uint64_t outer_l3_len:9; /**< outer L3 (IP) Hdr Length. 
*/
+   uint64_t outer_l2_len:7; /**< outer L2 (MAC) Hdr 
Length. */
+   uint64_t l4_tun_len:8; /**< L4 tunnelling header length 
*/
};
};
 } __rte_cache_aligned;
-- 
1.7.7.6



[dpdk-dev] [PATCH 0/3] i40e VXLAN TX checksum rework

2014-11-27 Thread Jijiang Liu
We have got some feedback about backward compatibility of VXLAN TX checksum 
offload API with 1G/10G NIC after the i40e VXLAN TX checksum codes were 
applied, so we have to rework the APIs on i40e, including the changes of mbuf, 
i40e PMD and csum engine.

The main changes in mbuf are as follows,
In place of removing PKT_TX_VXLAN_CKSUM, we introducing 2 new flags: 
PKT_TX_OUT_IP_CKSUM, PKT_TX_UDP_TUNNEL_PKT, and a new field: l4_tun_len.
Replace the inner_l2_len and the inner_l3_len field with the outer_l2_len and 
outer_l3_len field.

The existing flags are listed below, 
PKT_TX_IP_CKSUM: HW IPv4 checksum for non-tunnelling packet/ HW inner IPv4 
checksum for tunnelling packet
PKT_TX_TCP_CKSUM:HW TCP checksum for non-tunnelling packet/ HW inner TCP 
checksum for tunnelling packet
PKT_TX_SCTP_CKSUM:   HW SCTP checksum for non-tunnelling packet/ HW inner SCTP 
checksum for tunnelling packet
PKT_TX_UDP_CKSUM:HW SCTP checksum for non-tunnelling packet/ HW inner SCTP 
checksum for tunnelling packet
PKT_TX_IPV4:IPv4 with no HW checksum offload for non-tunnelling 
packet/inner IPv4 with no HW checksum offload for tunnelling packet 
PKT_TX_IPV6:IPv6 non-tunnelling packet/ inner IPv6 with no HW checksum 
offload for tunnelling packet

let's use a few examples to demonstrate how to use these flags:
Let say we have a tunnel packet: 
eth_hdr_out/ipv4_hdr_out/udp_hdr_out/vxlan_hdr/ehtr_hdr_in/ipv4_hdr_in/tcp_hdr_in.There
 could be several scenarios:

A) User requests HW offload for ipv4_hdr_out checksum.
He doesn't care is it a tunnelled packet or not.
So he sets:

mb->l2_len =  eth_hdr_out;
mb->l3_len = ipv4_hdr_out;
mb->ol_flags |= PKT_TX_IPV4_CSUM;

B) User is aware that it is a tunnelled packet and requests HW offload for 
ipv4_hdr_in and tcp_hdr_in *only*.
He doesn't care about outer IP checksum offload.
In that case, for FVL  he has 2 choices:
   1. Treat that packet as a 'proper' tunnelled packet, and fill all the fields:
 mb->l2_len =  eth_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->l4tun_len = vxlan_hdr; 
 mb->ol_flags |= PKT_TX_UDP_TUNNEL_PKT | PKT_TX_IP_CKSUM |  
PKT_TX_TCP_CKSUM;

   2. As user doesn't care about outer IP hdr checksum, he can treat everything 
before ipv4_hdr_in as L2 header.
   So he knows, that it is a tunnelled packet, but makes HW to treat it as 
ordinary (non-tunnelled) packet:
 mb->l2_len = eth_hdr_out + ipv4_hdr_out + udp_hdr_out + vxlan_hdr + 
ehtr_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->ol_flags |= PKT_TX_IP_CKSUM |  PKT_TX_TCP_CKSUM;

i40e PMD will support both B.1 and B.2.
ixgbe/igb/em PMD supports only B.2.
if HW supports both - it will be up to user app which method to choose.
tespmd will support both methods, and it should be configurable by user which 
approach to use (cmdline parameter).
So the user can try/test both methods and select an appropriate for him. 

Now, B.2 is exactly what Oliver suggested.
I think it has few important advantages over B.1:
First of all - compatibility. It works across all HW we currently support 
(i40e/ixgbe/igb/em).
Second - it is probably faster even on FVL, as for it we have to fill only TXD, 
while with approach #2 we have to fill both TCD and TXD.

C) User knows that is a tunnelled packet, and wants HW offload for all 3 
checksums:  outer IP hdr checksum, inner IP checksum, inner TCP checksum.
Then he has to setup all TX checksum fields: 
 mb->l2_len =  eth_hdr_in;
 mb->l3_len = ipv4_hdr_in;
 mb->outer_l2_len = eth_hdr_out;
 mb->outer_l3_len = ipv4_hdr_out;
 mb->l4tun_len = vxlan_hdr; 
 mb->ol_flags |= PKT_TX_OUT_IP_CKSUM  | PKT_TX_UDP_TUNNEL | PKT_TX_IP_CKSUM 
|  PKT_TX_TCP_CKSUM;

Jijiang Liu (3):
  mbuf change
  i40e PMD change in i40e_rxtx.c  
  rework csum forward engine 

 app/test-pmd/csumonly.c |   55 +-
 lib/librte_mbuf/rte_mbuf.c  |2 +-
 lib/librte_mbuf/rte_mbuf.h  |   23 ++--
 lib/librte_pmd_i40e/i40e_rxtx.c |   40 ---
 4 files changed, 63 insertions(+), 57 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH 4/4] testpmd:application changes

2014-11-18 Thread Jijiang Liu
Change the codes in testpmd due to introducing abstract packet type.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/csumonly.c |   12 ++--
 app/test-pmd/rxonly.c   |   20 +---
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 8d10bfd..d9948e7 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -219,6 +219,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
struct tcp_hdr   *inner_tcp_hdr;
struct sctp_hdr  *sctp_hdr;
struct sctp_hdr  *inner_sctp_hdr;
+   enum rte_eth_packet_type  packet_type;

uint16_t nb_rx;
uint16_t nb_tx;
@@ -272,11 +273,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
mb = pkts_burst[i];
l2_len  = sizeof(struct ether_hdr);
pkt_ol_flags = mb->ol_flags;
+   packet_type = (enum rte_eth_packet_type)mb->packet_type;
ol_flags = (pkt_ol_flags & (~PKT_TX_L4_MASK));
-   ipv4_tunnel = (pkt_ol_flags & PKT_RX_TUNNEL_IPV4_HDR) ?
-   1 : 0;
-   ipv6_tunnel = (pkt_ol_flags & PKT_RX_TUNNEL_IPV6_HDR) ?
-   1 : 0;
+   ipv4_tunnel = RTE_ETH_IS_TUNNEL_IPV4_HDR(packet_type);
+   ipv6_tunnel = RTE_ETH_IS_TUNNEL_IPV6_HDR(packet_type);
eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
eth_type = rte_be_to_cpu_16(eth_hdr->ether_type);
if (eth_type == ETHER_TYPE_VLAN) {
@@ -309,7 +309,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 *  + ipv4 or ipv6
 *  + udp or tcp or sctp or others
 */
-   if (pkt_ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_TUNNEL_IPV4_HDR)) {
+   if (pkt_ol_flags & PKT_RX_IPV4_HDR) {

/* Do not support ipv4 option field */
l3_len = sizeof(struct ipv4_hdr) ;
@@ -455,7 +455,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
}
}
/* End of L4 Handling*/
-   } else if (pkt_ol_flags & (PKT_RX_IPV6_HDR | 
PKT_RX_TUNNEL_IPV6_HDR)) {
+   } else if (pkt_ol_flags & PKT_RX_IPV6_HDR) {
ipv6_hdr = (struct ipv6_hdr *) (rte_pktmbuf_mtod(mb,
unsigned char *) + l2_len);
l3_len = sizeof(struct ipv6_hdr) ;
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 9ad1df6..3bf1b93 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -71,7 +71,7 @@

 #include "testpmd.h"

-#define MAX_PKT_RX_FLAGS 13
+#define MAX_PKT_RX_FLAGS 11
 static const char *pkt_rx_flag_names[MAX_PKT_RX_FLAGS] = {
"VLAN_PKT",
"RSS_HASH",
@@ -86,9 +86,6 @@ static const char *pkt_rx_flag_names[MAX_PKT_RX_FLAGS] = {

"IEEE1588_PTP",
"IEEE1588_TMST",
-
-   "TUNNEL_IPV4_HDR",
-   "TUNNEL_IPV6_HDR",
 };

 static inline void
@@ -108,11 +105,12 @@ pkt_burst_receive(struct fwd_stream *fs)
struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
struct rte_mbuf  *mb;
struct ether_hdr *eth_hdr;
+   enum rte_eth_packet_type packet_type;
uint16_t eth_type;
uint64_t ol_flags;
uint16_t nb_rx;
-   uint16_t i, packet_type;
-   uint64_t is_encapsulation;
+   uint16_t i;
+   uint32_t is_encapsulation;

 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
uint64_t start_tsc;
@@ -154,10 +152,10 @@ pkt_burst_receive(struct fwd_stream *fs)
eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
ol_flags = mb->ol_flags;
-   packet_type = mb->packet_type;
+   packet_type = (enum rte_eth_packet_type)mb->packet_type;

-   is_encapsulation = ol_flags & (PKT_RX_TUNNEL_IPV4_HDR |
-   PKT_RX_TUNNEL_IPV6_HDR);
+   is_encapsulation = RTE_ETH_IS_TUNNEL_IPV4_HDR(packet_type) |
+   RTE_ETH_IS_TUNNEL_IPV6_HDR(packet_type);

print_ether_addr("  src=", ð_hdr->s_addr);
print_ether_addr(" - dst=", ð_hdr->d_addr);
@@ -186,7 +184,7 @@ pkt_burst_receive(struct fwd_stream *fs)
l2_len  = sizeof(struct ether_hdr);

 /* Do not support ipv4 option field */
-   if (ol_flags & PKT_RX_TUNNEL_IPV4_HDR) {
+   if (RTE_ETH_IS_TUNNEL_IPV4_HDR(packet_type)) {
l3_len = sizeof(struct ipv4_hdr);
ipv4_hdr = (struct ipv4_hdr *) 
(rte

[dpdk-dev] [PATCH 3/4] i40e:translate i40e packet types

2014-11-18 Thread Jijiang Liu
Translate i40e packet types to abstract packet types, and keep the usage of the 
PKT_RX_IPV4_HDR and the PKT_RX_IPV4_HDR as before in i40e driver.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_rxtx.c |  604 +--
 1 files changed, 332 insertions(+), 272 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 487591d..80f1bc0 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -142,272 +142,320 @@ i40e_rxd_error_to_pkt_flags(uint64_t qword)
return flags;
 }

-/* Translate pkt types to pkt flags */
-static inline uint64_t
-i40e_rxd_ptype_to_pkt_flags(uint64_t qword)
+static inline enum rte_eth_packet_type
+i40e_rxd_ptype_mapping(uint64_t qword)
 {
uint8_t ptype = (uint8_t)((qword & I40E_RXD_QW1_PTYPE_MASK) >>
I40E_RXD_QW1_PTYPE_SHIFT);
-   static const uint64_t ip_ptype_map[I40E_MAX_PKT_TYPE] = {
-   0, /* PTYPE 0 */
-   0, /* PTYPE 1 */
-   0, /* PTYPE 2 */
-   0, /* PTYPE 3 */
-   0, /* PTYPE 4 */
-   0, /* PTYPE 5 */
-   0, /* PTYPE 6 */
-   0, /* PTYPE 7 */
-   0, /* PTYPE 8 */
-   0, /* PTYPE 9 */
-   0, /* PTYPE 10 */
-   0, /* PTYPE 11 */
-   0, /* PTYPE 12 */
-   0, /* PTYPE 13 */
-   0, /* PTYPE 14 */
-   0, /* PTYPE 15 */
-   0, /* PTYPE 16 */
-   0, /* PTYPE 17 */
-   0, /* PTYPE 18 */
-   0, /* PTYPE 19 */
-   0, /* PTYPE 20 */
-   0, /* PTYPE 21 */
-   PKT_RX_IPV4_HDR, /* PTYPE 22 */
-   PKT_RX_IPV4_HDR, /* PTYPE 23 */
-   PKT_RX_IPV4_HDR, /* PTYPE 24 */
-   0, /* PTYPE 25 */
-   PKT_RX_IPV4_HDR, /* PTYPE 26 */
-   PKT_RX_IPV4_HDR, /* PTYPE 27 */
-   PKT_RX_IPV4_HDR, /* PTYPE 28 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 29 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 30 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 31 */
-   0, /* PTYPE 32 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 33 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 34 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 35 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 36 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 37 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 38 */
-   0, /* PTYPE 39 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 40 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 41 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 42 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 43 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 44 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 45 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 46 */
-   0, /* PTYPE 47 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 48 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 49 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 50 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 51 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 52 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 53 */
-   0, /* PTYPE 54 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 55 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 56 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 57 */
-   PKT_RX_IPV4_HDR_EXT, /* PTYPE 58 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 59 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 60 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 61 */
-   0, /* PTYPE 62 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 63 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 64 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 65 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 66 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 67 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 68 */
-   0, /* PTYPE 69 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 70 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 71 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 72 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 73 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 74 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 75 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 76 */
-   0, /* PTYPE 77 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 78 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 79 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 80 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 81 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 82 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 83 */
-   0, /* PTYPE 84 */
-   PKT_RX_TUNNEL_IPV4_HDR, /* PTYPE 85 */
-   PKT_RX_TUNNEL_IPV4_HDR, /

[dpdk-dev] [PATCH 2/4] rte_mbuf:remove tunneling IP offload flags

2014-11-18 Thread Jijiang Liu
The PKT_RX_TUNNEL_IPV4_HDR and the PKT_RX_TUNNEL_IPV6_HDR are removed, they are 
useless now.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 678db0d..d0d395c 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -91,8 +91,6 @@ extern "C" {
 #define PKT_RX_IPV6_HDR_EXT  (1ULL << 8)  /**< RX packet with extended IPv6 
header. */
 #define PKT_RX_IEEE1588_PTP  (1ULL << 9)  /**< RX IEEE1588 L2 Ethernet PT 
Packet. */
 #define PKT_RX_IEEE1588_TMST (1ULL << 10) /**< RX IEEE1588 L2/L4 timestamped 
packet.*/
-#define PKT_RX_TUNNEL_IPV4_HDR (1ULL << 11) /**< RX tunnel packet with IPv4 
header.*/
-#define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */

 #define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
-- 
1.7.7.6



[dpdk-dev] [PATCH 1/4] rte_mbuf:add packet types

2014-11-18 Thread Jijiang Liu
This patch abstracts packet types of L2 packet, Non Tunneled IPv4/6, IP in IP, 
IP in GRE, MAC in GRE and MAC in UDP, and add 4 MACROS to check packet IP 
header.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h |  223 
 1 files changed, 223 insertions(+), 0 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index f5f8658..678db0d 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -125,6 +125,229 @@ extern "C" {
  */
 #define PKT_TX_OFFLOAD_MASK (PKT_TX_VLAN_PKT | PKT_TX_IP_CKSUM | 
PKT_TX_L4_MASK)

+/**
+ * Ethernet packet type
+ */
+enum rte_eth_packet_type {
+
+   /* undefined packet type, means HW can't recognise it */
+   RTE_PTYPE_UNDEF = 0,
+
+   /* L2 Packet types */
+   RTE_PTYPE_PAY2,
+   RTE_PTYPE_TimeSync_PAY2, /**< IEEE1588 and 802.1AS */
+   RTE_PTYPE_FIP_PAY2,  /**< FCoE Initiation Protocol */
+   RTE_PTYPE_LLDP_PAY2, /**< Link Layer Discovery Protocol */
+   RTE_PTYPE_ECP_PAY2,  /**< Edge Control Protocol */
+   RTE_PTYPE_EAPOL_PAY2,
+   /**< IEEE 802.1X Extensible Authentication Protocol over LAN */
+   RTE_PTYPE_ARP,
+   RTE_PTYPE_FCOE_PAY3,
+   RTE_PTYPE_FCOE_FCDATA,
+   RTE_PTYPE_FCOE_FCRDY,
+   RTE_PTYPE_FCOE_FCRSP,
+   RTE_PTYPE_FCOE_FCOTHER,
+   RTE_PTYPE_FCOE_VFT,
+   RTE_PTYPE_FCOE_VFT_FCDATA,
+   RTE_PTYPE_FCOE_VFT_FCRDY,
+   RTE_PTYPE_FCOE_VFT_FCRSP,
+   RTE_PTYPE_FCOE_VFT_FCOTHER,
+
+   /* Non Tunneled IPv4 */
+   RTE_PTYPE_IPv4FRAG,
+   RTE_PTYPE_IPv4,
+   RTE_PTYPE_IPv4_UDP,
+   RTE_PTYPE_IPv4_TCP,
+   RTE_PTYPE_IPv4_SCTP,
+   RTE_PTYPE_IPv4_ICMP,
+
+   /* IP in IP Tunneling (IPv4 --> IPv4) */
+   RTE_PTYPE_IPv4_IPv4FRAG,
+   RTE_PTYPE_IPv4_IPv4,
+   RTE_PTYPE_IPv4_IPv4_UDP,
+   RTE_PTYPE_IPv4_IPv4_TCP,
+   RTE_PTYPE_IPv4_IPv4_SCTP,
+   RTE_PTYPE_IPv4_IPv4_ICMP,
+
+   /* IP in IP Tunneling (IPv4 --> IPv6) */
+   RTE_PTYPE_IPv4_IPv6FRAG,
+   RTE_PTYPE_IPv4_IPv6,
+   RTE_PTYPE_IPv4_IPv6_UDP,
+   RTE_PTYPE_IPv4_IPv6_TCP,
+   RTE_PTYPE_IPv4_IPv6_SCTP,
+   RTE_PTYPE_IPv4_IPv6_ICMP,
+
+   /* IPv4 --> GRE/Teredo/VXLAN */
+   RTE_PTYPE_IPv4_GRENAT_PAY3,
+
+   /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
+   RTE_PTYPE_IPv4_GRENAT_IPv4FRAG,
+   RTE_PTYPE_IPv4_GRENAT_IPv4,
+   RTE_PTYPE_IPv4_GRENAT_IPv4_UDP,
+   RTE_PTYPE_IPv4_GRENAT_IPv4_TCP,
+   RTE_PTYPE_IPv4_GRENAT_IPv4_SCTP,
+   RTE_PTYPE_IPv4_GRENAT_IPv4_ICMP,
+
+   /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
+   RTE_PTYPE_IPv4_GRENAT_IPv6FRAG,
+   RTE_PTYPE_IPv4_GRENAT_IPv6,
+   RTE_PTYPE_IPv4_GRENAT_IPv6_UDP,
+   RTE_PTYPE_IPv4_GRENAT_IPv6_TCP,
+   RTE_PTYPE_IPv4_GRENAT_IPv6_SCTP,
+   RTE_PTYPE_IPv4_GRENAT_IPv6_ICMP,
+
+   /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
+   RTE_PTYPE_IPv4_GRENAT_MAC_PAY3,
+
+   /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv4FRAG,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv4,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv4_UDP,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv4_TCP,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv4_SCTP,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv4_ICMP,
+
+   /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv6FRAG,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv6,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv6_UDP,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv6_TCP,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv6_SCTP,
+   RTE_PTYPE_IPv4_GRENAT_MAC_IPv6_ICMP,
+
+   /* IPv4 --> GRE/Teredo/VXLAN --> MAC/VLAN */
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_PAY3,
+
+   /* IPv4 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv4 */
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4FRAG,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4_UDP,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4_TCP,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4_SCTP,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv4_ICMP,
+
+   /* IPv4 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv6 */
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6FRAG,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_UDP,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_TCP,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_SCTP,
+   RTE_PTYPE_IPv4_GRENAT_MACVLAN_IPv6_ICMP,
+
+   /* Non Tunneled IPv6 */
+   RTE_PTYPE_IPv6FRAG,
+   RTE_PTYPE_IPv6,
+   RTE_PTYPE_IPv6_UDP,
+   RTE_PTYPE_IPv6_TCP,
+   RTE_PTYPE_IPv6_SCTP,
+   RTE_PTYPE_IPv6_ICMP,
+
+   /* IP in IP Tunneling (IPv6 --> IPv4) */
+   RTE_PTYPE_IPv6_IPv4FRAG,
+   RTE_PTYPE_IPv6_IPv4,
+   RTE_PTYPE_IPv6_IPv4_UDP,
+   RTE_PTYPE_IPv6_IPv4_TCP,
+   RTE_PTYPE_IPv6_IPv4_SCTP,
+   RTE_PTYPE_IPv6_IPv4_ICMP,
+
+  

[dpdk-dev] [PATCH 0/4] Translate packet types for i40e

2014-11-18 Thread Jijiang Liu
The i40e NIC can recognize many packet types, including ordinary L2 packet 
format and tunneling packet format such as IP in IP, IP in GRE, MAC in GRE and 
MAC in UDP.

This patch set provides abstract definitions of packet types,
which can help user to use these packet types directly in their applications to 
speed up receive packet analysis.

Moreover, this patch set translates i40e packet types to abstract packet types 
in i40e driver,
and make the corresponding changes in test applications.

Jijiang Liu (4):
  Add packet type and IP header check in rte_mbuf 
  Remove the PKT_RX_TUNNEL_IPV4_HDR and the PKT_RX_TUNNEL_IPV6_HDR 
  Translate i40e packet types
  Make the corresponding changes in test-pmd 

 app/test-pmd/csumonly.c |   12 +-
 app/test-pmd/rxonly.c   |   15 +-
 lib/librte_mbuf/rte_mbuf.h  |  225 ++-
 lib/librte_pmd_i40e/i40e_rxtx.c |  604 +--
 4 files changed, 569 insertions(+), 287 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v2] i40e:fix MAC filter issues in i40e_ethdev.c

2014-10-31 Thread Jijiang Liu
This patch fixes two issues: one is to fix the log issues, the other is to set 
filter type when updating the default MAC filter.

v2 changes:
Fix the remaining PMD log issues. 

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |   17 +
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index d768a08..a860af7 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1633,33 +1633,33 @@ i40e_vf_mac_filter_set(struct i40e_pf *pf,
int ret;

if (pf == NULL) {
-   PMD_DRV_LOG(ERR, "Invalid PF argument\n");
+   PMD_DRV_LOG(ERR, "Invalid PF argument.");
return -EINVAL;
}
hw = I40E_PF_TO_HW(pf);

if (filter == NULL) {
-   PMD_DRV_LOG(ERR, "Invalid mac filter argument\n");
+   PMD_DRV_LOG(ERR, "Invalid mac filter argument.");
return -EINVAL;
}

new_mac = &filter->mac_addr;

if (is_zero_ether_addr(new_mac)) {
-   PMD_DRV_LOG(ERR, "Invalid ethernet address\n");
+   PMD_DRV_LOG(ERR, "Invalid ethernet address.");
return -EINVAL;
}

vf_id = filter->dst_id;

if (vf_id > pf->vf_num - 1 || !pf->vfs) {
-   PMD_DRV_LOG(ERR, "Invalid argument\n");
+   PMD_DRV_LOG(ERR, "Invalid argument.");
return -EINVAL;
}
vf = &pf->vfs[vf_id];

if (add && is_same_ether_addr(new_mac, &(pf->dev_addr))) {
-   PMD_DRV_LOG(INFO, "Ignore adding permanent MAC address\n");
+   PMD_DRV_LOG(INFO, "Ignore adding permanent MAC address.");
return -EINVAL;
}

@@ -1673,7 +1673,7 @@ i40e_vf_mac_filter_set(struct i40e_pf *pf,
mac_filter.filter_type = filter->filter_type;
ret = i40e_vsi_add_mac(vf->vsi, &mac_filter);
if (ret != I40E_SUCCESS) {
-   PMD_DRV_LOG(ERR, "Failed to add MAC filter\n");
+   PMD_DRV_LOG(ERR, "Failed to add MAC filter.");
return -1;
}
ether_addr_copy(new_mac, &pf->dev_addr);
@@ -1682,7 +1682,7 @@ i40e_vf_mac_filter_set(struct i40e_pf *pf,
ETHER_ADDR_LEN);
ret = i40e_vsi_delete_mac(vf->vsi, &filter->mac_addr);
if (ret != I40E_SUCCESS) {
-   PMD_DRV_LOG(ERR, "Failed to delete MAC filter\n");
+   PMD_DRV_LOG(ERR, "Failed to delete MAC filter.");
return -1;
}

@@ -1723,7 +1723,7 @@ i40e_mac_filter_handle(struct rte_eth_dev *dev, enum 
rte_filter_op filter_op,
i40e_pf_enable_irq0(hw);
break;
default:
-   PMD_DRV_LOG(ERR, "unknown operation %u\n", filter_op);
+   PMD_DRV_LOG(ERR, "unknown operation %u", filter_op);
ret = I40E_ERR_PARAM;
break;
}
@@ -2628,6 +2628,7 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
mac = &f->mac_info.mac_addr;
(void)rte_memcpy(&mac->addr_bytes, hw->mac.perm_addr,
ETH_ADDR_LEN);
+   f->mac_info.filter_type = RTE_MACVLAN_PERFECT_MATCH;
TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
vsi->mac_num++;

-- 
1.7.7.6



[dpdk-dev] [PATCH] librte_ether:change rte_eth_mac_filter structure

2014-10-31 Thread Jijiang Liu
As the filter type in i40e is defined enum type, so this patch changes the 
filter_type filed in the rte_eth_mac_filter for fixing the compilation error 
under ICC compiler. 

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_eth_ctrl.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 14a739b..91a6b64 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -91,7 +91,7 @@ enum rte_mac_filter_type {
 struct rte_eth_mac_filter {
uint8_t is_vf; /**< 1 for VF, 0 for port dev */
uint16_t dst_id; /**

[dpdk-dev] [PATCH] i40e:fix MAC filter issues in i40e_ethdev.c

2014-10-31 Thread Jijiang Liu
This patch fixes two issues: one is to fix the log issue, the other is to set 
filter type when updating the default MAC filter. 

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index d768a08..b35cdd2 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1723,7 +1723,7 @@ i40e_mac_filter_handle(struct rte_eth_dev *dev, enum 
rte_filter_op filter_op,
i40e_pf_enable_irq0(hw);
break;
default:
-   PMD_DRV_LOG(ERR, "unknown operation %u\n", filter_op);
+   PMD_DRV_LOG(ERR, "unknown operation %u", filter_op);
ret = I40E_ERR_PARAM;
break;
}
@@ -2628,6 +2628,7 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
mac = &f->mac_info.mac_addr;
(void)rte_memcpy(&mac->addr_bytes, hw->mac.perm_addr,
ETH_ADDR_LEN);
+   f->mac_info.filter_type = RTE_MACVLAN_PERFECT_MATCH;
TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
vsi->mac_num++;

-- 
1.7.7.6



[dpdk-dev] [PATCH v8 10/10] app/testpmd:test VxLAN Tx checksum offload

2014-10-27 Thread Jijiang Liu
Add test cases in testpmd to test VxLAN Tx Checksum offload, which include
 - IPv4 and IPv6 packet
 - outer L3, inner L3 and L4 checksum offload for Tx side.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c  |   13 ++-
 app/test-pmd/config.c   |6 +-
 app/test-pmd/csumonly.c |  194 +++
 3 files changed, 192 insertions(+), 21 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index da5d272..757c399 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -310,13 +310,17 @@ static void cmd_help_long_parsed(void *parsed_result,
"Disable hardware insertion of a VLAN header in"
" packets sent on a port.\n\n"

-   "tx_checksum set mask (port_id)\n"
+   "tx_checksum set (mask) (port_id)\n"
"Enable hardware insertion of checksum offload with"
-   " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
+   " the 8-bit mask, 0~0xff, in packets sent on a port.\n"
"bit 0 - insert ip   checksum offload if set\n"
"bit 1 - insert udp  checksum offload if set\n"
"bit 2 - insert tcp  checksum offload if set\n"
"bit 3 - insert sctp checksum offload if set\n"
+   "bit 4 - insert inner ip  checksum offload if 
set\n"
+   "bit 5 - insert inner udp checksum offload if 
set\n"
+   "bit 6 - insert inner tcp checksum offload if 
set\n"
+   "bit 7 - insert inner sctp checksum offload if 
set\n"
"Please check the NIC datasheet for HW limits.\n\n"

"set fwd (%s)\n"
@@ -2763,8 +2767,9 @@ cmdline_parse_inst_t cmd_tx_cksum_set = {
.f = cmd_tx_cksum_set_parsed,
.data = NULL,
.help_str = "enable hardware insertion of L3/L4checksum with a given "
-   "mask in packets sent on a port, the bit mapping is given as, Bit 0 for 
ip"
-   "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
+   "mask in packets sent on a port, the bit mapping is given as, Bit 0 for 
ip, "
+   "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
+   "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
.tokens = {
(void *)&cmd_tx_cksum_set_tx_cksum,
(void *)&cmd_tx_cksum_set_set,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 2a1b93f..9bc08f4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1753,9 +1753,9 @@ tx_cksum_set(portid_t port_id, uint64_t ol_flags)
uint64_t tx_ol_flags;
if (port_id_is_invalid(port_id))
return;
-   /* Clear last 4 bits and then set L3/4 checksum mask again */
-   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0Full);
-   ports[port_id].tx_ol_flags = ((ol_flags & 0xf) | tx_ol_flags);
+   /* Clear last 8 bits and then set L3/4 checksum mask again */
+   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0FFull);
+   ports[port_id].tx_ol_flags = ((ol_flags & 0xff) | tx_ol_flags);
 }

 void
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index fcc4876..3967476 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -209,10 +209,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
struct rte_mbuf  *mb;
struct ether_hdr *eth_hdr;
struct ipv4_hdr  *ipv4_hdr;
+   struct ether_hdr *inner_eth_hdr;
+   struct ipv4_hdr  *inner_ipv4_hdr = NULL;
struct ipv6_hdr  *ipv6_hdr;
+   struct ipv6_hdr  *inner_ipv6_hdr = NULL;
struct udp_hdr   *udp_hdr;
+   struct udp_hdr   *inner_udp_hdr;
struct tcp_hdr   *tcp_hdr;
+   struct tcp_hdr   *inner_tcp_hdr;
struct sctp_hdr  *sctp_hdr;
+   struct sctp_hdr  *inner_sctp_hdr;

uint16_t nb_rx;
uint16_t nb_tx;
@@ -221,12 +227,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint64_t pkt_ol_flags;
uint64_t tx_ol_flags;
uint16_t l4_proto;
+   uint16_t inner_l4_proto = 0;
uint16_t eth_type;
uint8_t  l2_len;
uint8_t  l3_len;
+   uint8_t  inner_l2_len = 0;
+   uint8_t  inner_l3_len = 0;

uint32_t rx_bad_ip_csum;
uint32_t rx_bad_l4_csum;
+   uint8_t  ipv4_tunnel;
+   uint8_t  ipv6_tunnel;

 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
uint64_t start_tsc;
@@ -262,7 +273,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
l

[dpdk-dev] [PATCH v8 09/10] i40e:support VxLAN Tx checksum offload

2014-10-27 Thread Jijiang Liu
Support VxLAN Tx checksum offload, which include
  - outer L3(IP) checksum offload
  - inner L3(IP) checksum offload
  - inner L4(UDP, TCP and SCTP) checksum offload

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h  |1 +
 lib/librte_pmd_i40e/i40e_rxtx.c |   46 +-
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 9af3bd9..a86dedf 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -96,6 +96,7 @@ extern "C" {

 #define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
+#define PKT_TX_VXLAN_CKSUM   (1ULL << 50) /**< TX checksum of VxLAN computed 
by NIC */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */
 #define PKT_TX_IPV4  PKT_RX_IPV4_HDR /**< IPv4 with no IP checksum 
offload. */
 #define PKT_TX_IPV6  PKT_RX_IPV6_HDR /**< IPv6 packet */
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2108290..7599df9 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -411,11 +411,14 @@ i40e_rxd_ptype_to_pkt_flags(uint64_t qword)
 }

 static inline void
-i40e_txd_enable_checksum(uint32_t ol_flags,
+i40e_txd_enable_checksum(uint64_t ol_flags,
uint32_t *td_cmd,
uint32_t *td_offset,
uint8_t l2_len,
-   uint8_t l3_len)
+   uint16_t l3_len,
+   uint8_t inner_l2_len,
+   uint16_t inner_l3_len,
+   uint32_t *cd_tunneling)
 {
if (!l2_len) {
PMD_DRV_LOG(DEBUG, "L2 length set to 0");
@@ -428,6 +431,27 @@ i40e_txd_enable_checksum(uint32_t ol_flags,
return;
}

+   /* VxLAN packet TX checksum offload */
+   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
+   uint8_t l4tun_len;
+
+   l4tun_len = ETHER_VXLAN_HLEN + inner_l2_len;
+
+   if (ol_flags & PKT_TX_IPV4_CSUM)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
+   else if (ol_flags & PKT_TX_IPV6)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;
+
+   /* Now set the ctx descriptor fields */
+   *cd_tunneling |= (l3_len >> 2) <<
+   I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
+   I40E_TXD_CTX_UDP_TUNNELING |
+   (l4tun_len >> 1) <<
+   I40E_TXD_CTX_QW0_NATLEN_SHIFT;
+
+   l3_len = inner_l3_len;
+   }
+
/* Enable L3 checksum offloads */
if (ol_flags & PKT_TX_IPV4_CSUM) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
@@ -1077,7 +1101,10 @@ i40e_recv_scattered_pkts(void *rx_queue,
 static inline uint16_t
 i40e_calc_context_desc(uint64_t flags)
 {
-   uint16_t mask = 0;
+   uint64_t mask = 0ULL;
+
+   if (flags | PKT_TX_VXLAN_CKSUM)
+   mask |= PKT_TX_VXLAN_CKSUM;

 #ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
@@ -1098,6 +1125,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
volatile struct i40e_tx_desc *txr;
struct rte_mbuf *tx_pkt;
struct rte_mbuf *m_seg;
+   uint32_t cd_tunneling_params;
uint16_t tx_id;
uint16_t nb_tx;
uint32_t td_cmd;
@@ -1106,7 +1134,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
uint32_t td_tag;
uint64_t ol_flags;
uint8_t l2_len;
-   uint8_t l3_len;
+   uint16_t l3_len;
+   uint8_t inner_l2_len;
+   uint16_t inner_l3_len;
uint16_t nb_used;
uint16_t nb_ctx;
uint16_t tx_last;
@@ -1134,7 +1164,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)

ol_flags = tx_pkt->ol_flags;
l2_len = tx_pkt->l2_len;
+   inner_l2_len = tx_pkt->inner_l2_len;
l3_len = tx_pkt->l3_len;
+   inner_l3_len = tx_pkt->inner_l3_len;

/* Calculate the number of context descriptors needed. */
nb_ctx = i40e_calc_context_desc(ol_flags);
@@ -1182,15 +1214,17 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)
td_cmd |= I40E_TX_DESC_CMD_ICRC;

/* Enable checksum offloading */
+   cd_tunneling_params = 0;
i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset,
-   l2_len, l3_len);
+  

[dpdk-dev] [PATCH v8 08/10] app/testpmd:test VxLAN packet filter

2014-10-27 Thread Jijiang Liu
Add the "tunnel_filter" command in testpmd to test the API of VxLAN packet 
filter.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c |  150 
 1 files changed, 150 insertions(+), 0 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4d7b4d1..da5d272 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -285,6 +285,14 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"

+   "tunnel_filter add (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   add a tunnel filter of a port.\n\n"
+
+   "tunnel_filter rm (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   remove a tunnel filter of a port.\n\n"
+
"rx_vxlan_port add (udp_port) (port_id)\n"
"Add an UDP port for VxLAN packet filter on a 
port\n\n"

@@ -6231,6 +6239,147 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
},
 };

+/* *** ADD TUNNEL FILTER OF A PORT *** */
+struct cmd_tunnel_filter_result {
+   cmdline_fixed_string_t cmd;
+   cmdline_fixed_string_t what;
+   uint8_t port_id;
+   struct ether_addr outer_mac;
+   struct ether_addr inner_mac;
+   cmdline_ipaddr_t ip_value;
+   uint16_t inner_vlan;
+   cmdline_fixed_string_t tunnel_type;
+   cmdline_fixed_string_t filter_type;
+   uint32_t tenant_id;
+   uint16_t queue_num;
+};
+
+static void
+cmd_tunnel_filter_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+   struct cmd_tunnel_filter_result *res = parsed_result;
+   struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
+   int ret = 0;
+
+   tunnel_filter_conf.outer_mac = &res->outer_mac;
+   tunnel_filter_conf.inner_mac = &res->inner_mac;
+   tunnel_filter_conf.inner_vlan = res->inner_vlan;
+
+   if (res->ip_value.family == AF_INET) {
+   tunnel_filter_conf.ip_addr.ipv4_addr =
+   res->ip_value.addr.ipv4.s_addr;
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
+   } else {
+   memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
+   &(res->ip_value.addr.ipv6),
+   sizeof(struct in6_addr));
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
+   }
+
+   if (!strcmp(res->filter_type, "imac-ivlan"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
+   else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
+   else if (!strcmp(res->filter_type, "imac-tenid"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
+   else if (!strcmp(res->filter_type, "imac"))
+   tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
+   else if (!strcmp(res->filter_type, "omac-imac-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
+   else {
+   printf("The filter type is not supported");
+   return;
+   }
+
+   if (!strcmp(res->tunnel_type, "vxlan"))
+   tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+   else {
+   printf("Only VxLAN is supported now.\n");
+   return;
+   }
+
+   tunnel_filter_conf.tenant_id = res->tenant_id;
+   tunnel_filter_conf.queue_id = res->queue_num;
+   if (!strcmp(res->what, "add"))
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_ADD,
+   &tunnel_filter_conf);
+   else
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_DELETE,
+   &tunnel_filter_conf);
+   if (ret < 0)
+   printf("cmd_tunnel_filter_parsed error: (%s)\n",
+   strerror(-ret));
+
+}
+cmdline_parse_token_string_t cmd_t

[dpdk-dev] [PATCH v8 07/10] i40e:implement the API of VxLAN filter in librte_pmd_i40e

2014-10-27 Thread Jijiang Liu
The filter types supported are listed below for VxLAN:
   1. Inner MAC and Inner VLAN ID.
   2. Inner MAC address, inner VLAN ID and tenant ID.
   3. Inner MAC and tenant ID.
   4. Inner MAC address.
   5. Outer MAC address, tenant ID and inner MAC address.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |  174 -
 1 files changed, 172 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index eb643e5..be83268 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "i40e_logs.h"
 #include "i40e/i40e_register_x710_int.h"
@@ -4099,6 +4100,108 @@ i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 }

 static int
+i40e_dev_get_filter_type(uint16_t filter_type, uint16_t *flag)
+{
+   switch (filter_type) {
+   case RTE_TUNNEL_FILTER_IMAC_IVLAN:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN;
+   break;
+   case RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN_TEN_ID;
+   break;
+   case RTE_TUNNEL_FILTER_IMAC_TENID:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_TEN_ID;
+   break;
+   case RTE_TUNNEL_FILTER_OMAC_TENID_IMAC:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_OMAC_TEN_ID_IMAC;
+   break;
+   case ETH_TUNNEL_FILTER_IMAC:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC;
+   break;
+   default:
+   PMD_DRV_LOG(ERR, "invalid tunnel filter type\n");
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int
+i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
+   struct rte_eth_tunnel_filter_conf *tunnel_filter,
+   uint8_t add)
+{
+   uint16_t ip_type;
+   uint8_t tun_type = 0;
+   int val, ret = 0;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+   struct i40e_vsi *vsi = pf->main_vsi;
+   struct i40e_aqc_add_remove_cloud_filters_element_data  *cld_filter;
+   struct i40e_aqc_add_remove_cloud_filters_element_data  *pfilter;
+
+   cld_filter = rte_zmalloc("tunnel_filter",
+   sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data),
+   0);
+
+   if (NULL == cld_filter) {
+   PMD_DRV_LOG(ERR, "Failed to alloc memory.\n");
+   return -EINVAL;
+   }
+   pfilter = cld_filter;
+
+   (void)rte_memcpy(&pfilter->outer_mac, tunnel_filter->outer_mac,
+   sizeof(struct ether_addr));
+   (void)rte_memcpy(&pfilter->inner_mac, tunnel_filter->inner_mac,
+   sizeof(struct ether_addr));
+
+   pfilter->inner_vlan = tunnel_filter->inner_vlan;
+   if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+   ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
+   (void)rte_memcpy(&pfilter->ipaddr.v4.data,
+   &tunnel_filter->ip_addr,
+   sizeof(pfilter->ipaddr.v4.data));
+   } else {
+   ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
+   (void)rte_memcpy(&pfilter->ipaddr.v6.data,
+   &tunnel_filter->ip_addr,
+   sizeof(pfilter->ipaddr.v6.data));
+   }
+
+   /* check tunneled type */
+   switch (tunnel_filter->tunnel_type) {
+   case RTE_TUNNEL_TYPE_VXLAN:
+   tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_XVLAN;
+   break;
+   default:
+   /* Other tunnel types is not supported. */
+   PMD_DRV_LOG(ERR, "tunnel type is not supported.\n");
+   rte_free(cld_filter);
+   return -EINVAL;
+   }
+
+   val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
+   &pfilter->flags);
+   if (val < 0) {
+   rte_free(cld_filter);
+   return -EINVAL;
+   }
+
+   pfilter->flags |= I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | ip_type |
+   (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT);
+   pfilter->tenant_id = tunnel_filter->tenant_id;
+   pfilter->queue_number = tunnel_filter->queue_id;
+
+   if (add)
+   ret = i40e_aq_add_cloud_filters(hw, vsi->seid, cld_filter, 1);
+   else
+   ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+   cld_filter, 1);
+
+   rte_free(cld_filter);
+   return ret;
+}
+
+static int
 i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)
 {
uint8_t i;
@@ -4286,6 +4389,72 @@ i40e_pf_config_rss(struct i40e_pf *pf)
 }

 stat

[dpdk-dev] [PATCH v8 06/10] librte_ether:add data structures of VxLAN filter

2014-10-27 Thread Jijiang Liu
Add definations of the data structures of tunneling packet filter in the 
rte_eth_ctrl.h file.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_eth_ctrl.h |   49 +++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 9a90d19..b4ab731 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -51,6 +51,7 @@ extern "C" {
  */
 enum rte_filter_type {
RTE_ETH_FILTER_NONE = 0,
+   RTE_ETH_FILTER_TUNNEL,
RTE_ETH_FILTER_MAX
 };

@@ -83,6 +84,54 @@ enum rte_eth_tunnel_type {
RTE_TUNNEL_TYPE_MAX,
 };

+/**
+ * filter type of tunneling packet
+ */
+#define ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
+#define ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
+#define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
+#define ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
+#define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
+#define ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
+
+#define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
+   ETH_TUNNEL_FILTER_IVLAN)
+#define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
+   ETH_TUNNEL_FILTER_IVLAN | \
+   ETH_TUNNEL_FILTER_TENID)
+#define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
+   ETH_TUNNEL_FILTER_TENID)
+#define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
+   ETH_TUNNEL_FILTER_TENID | \
+   ETH_TUNNEL_FILTER_IMAC)
+
+/**
+ *  Select IPv4 or IPv6 for tunnel filters.
+ */
+enum rte_tunnel_iptype {
+   RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
+   RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */
+};
+
+/**
+ * Tunneling Packet filter configuration.
+ */
+struct rte_eth_tunnel_filter_conf {
+   struct ether_addr *outer_mac;  /**< Outer MAC address filter. */
+   struct ether_addr *inner_mac;  /**< Inner MAC address filter. */
+   uint16_t inner_vlan;   /**< Inner VLAN filter. */
+   enum rte_tunnel_iptype ip_type; /**< IP address type. */
+   union {
+   uint32_t ipv4_addr;/**< IPv4 source address to match. */
+   uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
+   } ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
+
+   uint16_t filter_type;   /**< Filter type. */
+   enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+   uint32_t tenant_id; /** < Tenant number. */
+   uint16_t queue_id;  /** < queue number. */
+};
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.7.6



[dpdk-dev] [PATCH v8 05/10] app/test-pmd:test VxLAN packet identification

2014-10-27 Thread Jijiang Liu
Add two commands to test VxLAN packet identification.
The test steps are as follows:
 1> use commands to add/delete VxLAN UDP port.
 2> use rxonly mode to receive VxLAN packet.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c |   65 
 app/test-pmd/rxonly.c  |   55 +++-
 2 files changed, 118 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0b972f9..4d7b4d1 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -285,6 +285,12 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"

+   "rx_vxlan_port add (udp_port) (port_id)\n"
+   "Add an UDP port for VxLAN packet filter on a 
port\n\n"
+
+   "rx_vxlan_port rm (udp_port) (port_id)\n"
+   "Remove an UDP port for VxLAN packet filter on a 
port\n\n"
+
"tx_vlan set vlan_id (port_id)\n"
"Set hardware insertion of VLAN ID in packets sent"
" on a port.\n\n"
@@ -6225,6 +6231,64 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
},
 };

+/* *** CONFIGURE TUNNEL UDP PORT *** */
+struct cmd_tunnel_udp_config {
+   cmdline_fixed_string_t cmd;
+   cmdline_fixed_string_t what;
+   uint16_t udp_port;
+   uint8_t port_id;
+};
+
+static void
+cmd_tunnel_udp_config_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+   struct cmd_tunnel_udp_config *res = parsed_result;
+   struct rte_eth_udp_tunnel tunnel_udp;
+   int ret;
+
+   tunnel_udp.udp_port = res->udp_port;
+
+   if (!strcmp(res->cmd, "rx_vxlan_port"))
+   tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
+
+   if (!strcmp(res->what, "add"))
+   ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
+   else
+   ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
+
+   if (ret < 0)
+   printf("udp tunneling add error: (%s)\n", strerror(-ret));
+}
+
+cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
+   TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
+   cmd, "rx_vxlan_port");
+cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
+   TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
+   what, "add#rm");
+cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
+   TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
+   udp_port, UINT16);
+cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_tunnel_udp_config = {
+   .f = cmd_tunnel_udp_config_parsed,
+   .data = (void *)0,
+   .help_str = "add/rm an tunneling UDP port filter: "
+   "rx_vxlan_port add udp_port port_id",
+   .tokens = {
+   (void *)&cmd_tunnel_udp_config_cmd,
+   (void *)&cmd_tunnel_udp_config_what,
+   (void *)&cmd_tunnel_udp_config_udp_port,
+   (void *)&cmd_tunnel_udp_config_port_id,
+   NULL,
+   },
+};
+
 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
 struct cmd_set_mirror_mask_result {
cmdline_fixed_string_t set;
@@ -7518,6 +7582,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
+   (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
(cmdline_parse_inst_t *)&cmd_set_mirror_link,
(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 98c788b..d3be62e 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -66,10 +66,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 

 #include "testpmd.h"

-#define MAX_PKT_RX_FLAGS 11
+#define MAX_PKT_RX_FLAGS 13
 static const char *pkt_rx_flag_names[MAX_PKT_RX_FLAGS] = {
"VLAN_PKT",
"RSS_HASH",
@@ -84,6 +86,9 @@ static const char *pkt_rx_flag_names[MAX_PKT_RX_FLAGS] = {

"IEEE1588_PTP",
"IEEE1588_TMST",
+
+   "TUNNEL_IPV4_HDR",
+   "TUNNEL_IPV6_HDR",
 };

 static i

[dpdk-dev] [PATCH v8 04/10] i40e:support VxLAN packet identification in i40e

2014-10-27 Thread Jijiang Liu
Implement the configuration API of VxLAN destination UDP port in 
librte_pmd_i40e,
and add new Rx offload flags for supporting VXLAN packet offload.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h|2 +
 lib/librte_pmd_i40e/i40e_ethdev.c |  157 +
 lib/librte_pmd_i40e/i40e_ethdev.h |8 ++-
 lib/librte_pmd_i40e/i40e_rxtx.c   |  105 +---
 4 files changed, 223 insertions(+), 49 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 497d88b..9af3bd9 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -91,6 +91,8 @@ extern "C" {
 #define PKT_RX_IPV6_HDR_EXT  (1ULL << 8)  /**< RX packet with extended IPv6 
header. */
 #define PKT_RX_IEEE1588_PTP  (1ULL << 9)  /**< RX IEEE1588 L2 Ethernet PT 
Packet. */
 #define PKT_RX_IEEE1588_TMST (1ULL << 10) /**< RX IEEE1588 L2/L4 timestamped 
packet.*/
+#define PKT_RX_TUNNEL_IPV4_HDR (1ULL << 11) /**< RX tunnel packet with IPv4 
header.*/
+#define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */

 #define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 3b75f0f..eb643e5 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -186,6 +186,10 @@ static int i40e_dev_rss_hash_update(struct rte_eth_dev 
*dev,
struct rte_eth_rss_conf *rss_conf);
 static int i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
  struct rte_eth_rss_conf *rss_conf);
+static int i40e_dev_udp_tunnel_add(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *udp_tunnel);
+static int i40e_dev_udp_tunnel_del(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *udp_tunnel);
 static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_type filter_type,
enum rte_filter_op filter_op,
@@ -241,6 +245,8 @@ static struct eth_dev_ops i40e_eth_dev_ops = {
.reta_query   = i40e_dev_rss_reta_query,
.rss_hash_update  = i40e_dev_rss_hash_update,
.rss_hash_conf_get= i40e_dev_rss_hash_conf_get,
+   .udp_tunnel_add   = i40e_dev_udp_tunnel_add,
+   .udp_tunnel_del   = i40e_dev_udp_tunnel_del,
.filter_ctrl  = i40e_dev_filter_ctrl,
 };

@@ -4092,6 +4098,157 @@ i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
return 0;
 }

+static int
+i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)
+{
+   uint8_t i;
+
+   for (i = 0; i < I40E_MAX_PF_UDP_OFFLOAD_PORTS; i++) {
+   if (pf->vxlan_ports[i] == port)
+   return i;
+   }
+
+   return -1;
+}
+
+static int
+i40e_add_vxlan_port(struct i40e_pf *pf, uint16_t port)
+{
+   int  idx, ret;
+   uint8_t filter_idx;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+
+   idx = i40e_get_vxlan_port_idx(pf, port);
+
+   /* Check if port already exists */
+   if (idx >= 0) {
+   PMD_DRV_LOG(ERR, "Port %d already offloaded\n", port);
+   return -EINVAL;
+   }
+
+   /* Now check if there is space to add the new port */
+   idx = i40e_get_vxlan_port_idx(pf, 0);
+   if (idx < 0) {
+   PMD_DRV_LOG(ERR, "Maximum number of UDP ports reached,"
+   "not adding port %d\n", port);
+   return -ENOSPC;
+   }
+
+   ret =  i40e_aq_add_udp_tunnel(hw, port, I40E_AQC_TUNNEL_TYPE_VXLAN,
+   &filter_idx, NULL);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to add VxLAN UDP port %d\n", port);
+   return -1;
+   }
+
+   PMD_DRV_LOG(INFO, "Added %s port %d with AQ command with index %d\n",
+port,  filter_index);
+
+   /* New port: add it and mark its index in the bitmap */
+   pf->vxlan_ports[idx] = port;
+   pf->vxlan_bitmap |= (1 << idx);
+
+   if (!(pf->flags & I40E_FLAG_VXLAN))
+   pf->flags |= I40E_FLAG_VXLAN;
+
+   return 0;
+}
+
+static int
+i40e_del_vxlan_port(struct i40e_pf *pf, uint16_t port)
+{
+   int idx;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+
+   if (!(pf->flags & I40E_FLAG_VXLAN)) {
+   PMD_DRV_LOG(ERR, "VxLAN UDP port was not configured.\n");
+   return -EINVAL;
+   }
+
+   idx = i40e_get_vxlan_port_idx(pf, port);
+
+ 

[dpdk-dev] [PATCH v8 03/10] librte_ether:add VxLAN packet identification API

2014-10-27 Thread Jijiang Liu
There are "some" destination UDP port numbers that have unque meaning.
In terms of VxLAN, "IANA has assigned the value 4789 for the VXLAN UDP port, 
and this value SHOULD be used by default as the destination UDP port. Some 
early implementations of VXLAN have used other values for the destination port. 
To enable interoperability with these implementations, the destination port 
SHOULD be configurable."

Add two APIs in librte_ether for supporting UDP tunneling port configuration on 
i40e.
Currently, only VxLAN is implemented in this patch set.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_ethdev.c |   52 +
 lib/librte_ether/rte_ethdev.h |   46 
 2 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 50f10d9..ff1c769 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2038,6 +2038,58 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
 }

 int
+rte_eth_dev_udp_tunnel_add(uint8_t port_id,
+  struct rte_eth_udp_tunnel *udp_tunnel)
+{
+   struct rte_eth_dev *dev;
+
+   if (port_id >= nb_ports) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   if (udp_tunnel == NULL) {
+   PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+   return -EINVAL;
+   }
+
+   if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+   PMD_DEBUG_TRACE("Invalid tunnel type\n");
+   return -EINVAL;
+   }
+
+   dev = &rte_eth_devices[port_id];
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
+   return (*dev->dev_ops->udp_tunnel_add)(dev, udp_tunnel);
+}
+
+int
+rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
+ struct rte_eth_udp_tunnel *udp_tunnel)
+{
+   struct rte_eth_dev *dev;
+
+   if (port_id >= nb_ports) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+   dev = &rte_eth_devices[port_id];
+
+   if (udp_tunnel == NULL) {
+   PMD_DEBUG_TRACE("Invalid udp_tunnel parametr\n");
+   return -EINVAL;
+   }
+
+   if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+   PMD_DEBUG_TRACE("Invalid tunnel type\n");
+   return -EINVAL;
+   }
+
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
+   return (*dev->dev_ops->udp_tunnel_del)(dev, udp_tunnel);
+}
+
+int
 rte_eth_led_on(uint8_t port_id)
 {
struct rte_eth_dev *dev;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 46a5568..8bf274d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1274,6 +1274,15 @@ typedef int (*eth_mirror_rule_reset_t)(struct 
rte_eth_dev *dev,
  uint8_t rule_id);
 /**< @internal Remove a traffic mirroring rule on an Ethernet device */

+typedef int (*eth_udp_tunnel_add_t)(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *tunnel_udp);
+/**< @internal Add tunneling UDP info */
+
+typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *tunnel_udp);
+/**< @internal Delete tunneling UDP info */
+
+
 #ifdef RTE_NIC_BYPASS

 enum {
@@ -1454,6 +1463,8 @@ struct eth_dev_ops {
eth_set_vf_rx_tset_vf_rx;  /**< enable/disable a VF receive 
*/
eth_set_vf_tx_tset_vf_tx;  /**< enable/disable a VF 
transmit */
eth_set_vf_vlan_filter_t   set_vf_vlan_filter;  /**< Set VF VLAN filter 
*/
+   eth_udp_tunnel_add_t   udp_tunnel_add;
+   eth_udp_tunnel_del_t   udp_tunnel_del;
eth_set_queue_rate_limit_t set_queue_rate_limit;   /**< Set queue rate 
limit */
eth_set_vf_rate_limit_tset_vf_rate_limit;   /**< Set VF rate limit 
*/

@@ -3350,6 +3361,41 @@ int
 rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
  struct rte_eth_rss_conf *rss_conf);

+ /**
+ * Add UDP tunneling port of an Ethernet device for filtering a specific
+ * tunneling packet by UDP port number.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param tunnel_udp
+ *   UDP tunneling configuration.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if port identifier is invalid.
+ *   - (-ENOTSUP) if hardware doesn't support tunnel type.
+ */
+int
+rte_eth_dev_udp_tunnel_add(uint8_t port_id,
+  struct rte_eth_udp_tunnel *tunnel_udp);
+
+ /**
+ * Detete UDP tunneling port configuration of Ethernet device
+ *
+ * @param port_id
+ *   The port i

[dpdk-dev] [PATCH v8 02/10] librte_ether:add the basic data structures of VxLAN

2014-10-27 Thread Jijiang Liu
Add definations of basic data structures of VxLAN.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_eth_ctrl.h |   12 
 lib/librte_ether/rte_ethdev.h   |8 
 lib/librte_ether/rte_ether.h|   13 +
 3 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index df21ac6..9a90d19 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -71,6 +71,18 @@ enum rte_filter_op {
RTE_ETH_FILTER_OP_MAX
 };

+/**
+ * Tunneled type.
+ */
+enum rte_eth_tunnel_type {
+   RTE_TUNNEL_TYPE_NONE = 0,
+   RTE_TUNNEL_TYPE_VXLAN,
+   RTE_TUNNEL_TYPE_GENEVE,
+   RTE_TUNNEL_TYPE_TEREDO,
+   RTE_TUNNEL_TYPE_NVGRE,
+   RTE_TUNNEL_TYPE_MAX,
+};
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b69a6af..46a5568 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -710,6 +710,14 @@ struct rte_fdir_conf {
 };

 /**
+ * UDP tunneling configuration.
+ */
+struct rte_eth_udp_tunnel {
+   uint16_t udp_port;
+   uint8_t prot_type;
+};
+
+/**
  *  Possible l4type of FDIR filters.
  */
 enum rte_l4type {
diff --git a/lib/librte_ether/rte_ether.h b/lib/librte_ether/rte_ether.h
index 2e08f23..100cc52 100644
--- a/lib/librte_ether/rte_ether.h
+++ b/lib/librte_ether/rte_ether.h
@@ -286,6 +286,16 @@ struct vlan_hdr {
uint16_t eth_proto;/**< Ethernet type of encapsulated frame. */
 } __attribute__((__packed__));

+/**
+ * VXLAN protocol header.
+ * Contains the 8-bit flag, 24-bit VXLAN Network Identifier and
+ * Reserved fields (24 bits and 8 bits)
+ */
+struct vxlan_hdr {
+   uint32_t vx_flags; /**< flag (8) + Reserved (24). */
+   uint32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+} __attribute__((__packed__));
+
 /* Ethernet frame types */
 #define ETHER_TYPE_IPv4 0x0800 /**< IPv4 Protocol. */
 #define ETHER_TYPE_IPv6 0x86DD /**< IPv6 Protocol. */
@@ -294,6 +304,9 @@ struct vlan_hdr {
 #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */
 #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */

+#define ETHER_VXLAN_HLEN (sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr))
+/**< VxLAN tunnel header length. */
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.7.6



[dpdk-dev] [PATCH v8 01/10] librte_mbuf:the rte_mbuf structure changes

2014-10-27 Thread Jijiang Liu
Replace the "reserved2" field with the "packet_type" field and add the 
"inner_l2_l3_len" field in the rte_mbuf structure.
The "packet_type" field is used to indicate ordinary packet format and also 
tunneling packet format such as IP in IP, IP in GRE, MAC in GRE and MAC in UDP.
The "inner_l2_len" and the "inner_l3_len" fields are added in the second cache 
line, they use 2 bytes for TX offloading of tunnels.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h |   25 -
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ddadc21..497d88b 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -163,7 +163,14 @@ struct rte_mbuf {

/* remaining bytes are set on RX when pulling packet from descriptor */
MARKER rx_descriptor_fields1;
-   uint16_t reserved2;   /**< Unused field. Required for padding */
+
+   /**
+* The packet type, which is used to indicate ordinary packet and also
+* tunneled packet format, i.e. each number is represented a type of
+* packet.
+*/
+   uint16_t packet_type;
+
uint16_t data_len;/**< Amount of data in segment buffer. */
uint32_t pkt_len; /**< Total pkt len: sum of all segments. */
uint16_t vlan_tci;/**< VLAN Tag Control Identifier (CPU order) 
*/
@@ -196,6 +203,18 @@ struct rte_mbuf {
uint16_t l2_len:7;  /**< L2 (MAC) Header Length. */
};
};
+
+   /* fields for TX offloading of tunnels */
+   union {
+   uint16_t inner_l2_l3_len;
+   /**< combined inner l2/l3 lengths as single var */
+   struct {
+   uint16_t inner_l3_len:9;
+   /**< inner L3 (IP) Header Length. */
+   uint16_t inner_l2_len:7;
+   /**< inner L2 (MAC) Header Length. */
+   };
+   };
 } __rte_cache_aligned;

 /**
@@ -546,11 +565,13 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)
m->next = NULL;
m->pkt_len = 0;
m->l2_l3_len = 0;
+   m->inner_l2_l3_len = 0;
m->vlan_tci = 0;
m->nb_segs = 1;
m->port = 0xff;

m->ol_flags = 0;
+   m->packet_type = 0;
m->data_off = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ?
RTE_PKTMBUF_HEADROOM : m->buf_len;

@@ -614,12 +635,14 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf 
*mi, struct rte_mbuf *md)
mi->port = md->port;
mi->vlan_tci = md->vlan_tci;
mi->l2_l3_len = md->l2_l3_len;
+   mi->inner_l2_l3_len = md->inner_l2_l3_len;
mi->hash = md->hash;

mi->next = NULL;
mi->pkt_len = mi->data_len;
mi->nb_segs = 1;
mi->ol_flags = md->ol_flags;
+   mi->packet_type = md->packet_type;

__rte_mbuf_sanity_check(mi, 1);
__rte_mbuf_sanity_check(md, 0);
-- 
1.7.7.6



[dpdk-dev] [PATCH v8 00/10] Support VxLAN on Fortville

2014-10-27 Thread Jijiang Liu
The patch set supports VxLAN on Fortville based on latest rte_mbuf structure. 

It includes:
 - Support VxLAN packet identification by configuring UDP tunneling port.
 - Support VxLAN packet filters. It uses MAC and VLAN to point
   to a queue. The filter types supported are listed below:
   1. Inner MAC and Inner VLAN ID
   2. Inner MAC address, inner VLAN ID and tenant ID.
   3. Inner MAC and tenant ID
   4. Inner MAC address
   5. Outer MAC address, tenant ID and inner MAC
 - Support VxLAN TX checksum offload, which include outer L3(IP), inner L3(IP) 
and inner L4(UDP,TCP and SCTP)

Change notes:

 v8)  * Fix the issue of redundant "PKT_RX" and the comma missing in the 
pkt_rx_flag_names[] in the rxonly.c file.

Jijiang Liu (10):
  change rte_mbuf structures 
  add data structures of UDP tunneling 
  add VxLAN packet identification API in librte_ether
  support VxLAN packet identification in i40e
  test VxLAN packet identification in testpmd.
  add data structures of tunneling filter in rte_eth_ctrl.h
  implement the API of VxLAN packet filter in i40e
  test VxLAN packet filter
  support VxLAN Tx checksum offload in i40e
  test VxLAN Tx checksum offload


 app/test-pmd/cmdline.c|  228 +-
 app/test-pmd/config.c |6 +-
 app/test-pmd/csumonly.c   |  194 --
 app/test-pmd/rxonly.c |   50 ++-
 lib/librte_ether/rte_eth_ctrl.h   |   61 +++
 lib/librte_ether/rte_ethdev.c |   52 ++
 lib/librte_ether/rte_ethdev.h |   54 ++
 lib/librte_ether/rte_ether.h  |   13 ++
 lib/librte_mbuf/rte_mbuf.h|   28 +++-
 lib/librte_pmd_i40e/i40e_ethdev.c |  331 -
 lib/librte_pmd_i40e/i40e_ethdev.h |8 +-
 lib/librte_pmd_i40e/i40e_rxtx.c   |  151 +++--
 12 files changed, 1096 insertions(+), 80 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v2 4/4] app/testpmd:test VF MAC filter

2014-10-24 Thread Jijiang Liu
Add a test command in testpmd to test VF MAC filter feature.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c |  119 ++-
 1 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0b972f9..baa968b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -351,9 +351,14 @@ static void cmd_help_long_parsed(void *parsed_result,
"e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
" on port 0 to mapping 5.\n\n"

-   "set port (port_id) vf (vf_id) rx|tx on|off \n"
+   "set port (port_id) vf (vf_id) rx|tx on|off\n"
"Enable/Disable a VF receive/tranmit from a 
port\n\n"

+   "set port (port_id) vf (vf_id) (mac_addr)"
+   " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) 
on|off\n"
+   "   Add/Remove unicast or multicast MAC addr filter"
+   " for a VF.\n\n"
+
"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
"|MPE) (on|off)\n"
"AUPE:accepts untagged VLAN;"
@@ -5809,6 +5814,112 @@ cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
},
 };

+/* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
+struct cmd_set_vf_macvlan_filter {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t port;
+   uint8_t port_id;
+   cmdline_fixed_string_t vf;
+   uint8_t vf_id;
+   struct ether_addr address;
+   cmdline_fixed_string_t filter_type;
+   cmdline_fixed_string_t mode;
+};
+
+static void
+cmd_set_vf_macvlan_parsed(void *parsed_result,
+  __attribute__((unused)) struct cmdline *cl,
+  __attribute__((unused)) void *data)
+{
+   int is_on, ret = 0;
+   struct cmd_set_vf_macvlan_filter *res = parsed_result;
+   struct rte_eth_mac_filter filter;
+
+   memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
+
+   (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
+
+   /* set VF MAC filter */
+   filter.is_vf = 1;
+
+   /* set VF ID */
+   filter.dst_id = res->vf_id;
+
+   if (!strcmp(res->filter_type, "exact-mac"))
+   filter.filter_type = RTE_MAC_PERFECT_MATCH;
+   else if (!strcmp(res->filter_type, "exact-mac-vlan"))
+   filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+   else if (!strcmp(res->filter_type, "hashmac"))
+   filter.filter_type = RTE_MAC_HASH_MATCH;
+   else if (!strcmp(res->filter_type, "hashmac-vlan"))
+   filter.filter_type = RTE_MACVLAN_HASH_MATCH;
+
+   is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
+
+   if (is_on)
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_MACVLAN,
+   RTE_ETH_FILTER_ADD,
+&filter);
+   else
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_MACVLAN,
+   RTE_ETH_FILTER_DELETE,
+   &filter);
+
+   if (ret < 0)
+   printf("bad set MAC hash parameter, return code = %d\n", ret);
+
+}
+
+cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
+set, "set");
+cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
+port, "port");
+cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
+   TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
+ port_id, UINT8);
+cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
+vf, "vf");
+cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
+   vf_id, UINT8);
+cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
+   TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
+   address);
+cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
+   filter_type, "exact-mac#exact-mac-vlan"
+   "#hashmac#hashmac-vla

[dpdk-dev] [PATCH v2 3/4] i40e:add VF MAC filter

2014-10-24 Thread Jijiang Liu
It mainly add i40e_vf_mac_filter_set() function to support perfect match and 
hash match of MAC address and VLAN ID for VF.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |  118 -
 1 files changed, 116 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 5fae0e1..f9e3aa8 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1605,6 +1605,119 @@ i40e_macaddr_remove(struct rte_eth_dev *dev, uint32_t 
index)
memset(&pf->dev_addr, 0, sizeof(struct ether_addr));
 }

+/* Set perfect match or hash match of MAC and VLAN for a VF */
+static int
+i40e_vf_mac_filter_set(struct i40e_pf *pf,
+struct rte_eth_mac_filter *filter,
+bool add)
+{
+   struct i40e_hw *hw;
+   struct i40e_mac_filter_info mac_filter;
+   struct ether_addr old_mac;
+   struct ether_addr *new_mac;
+   struct i40e_pf_vf *vf = NULL;
+   uint16_t vf_id;
+   int ret;
+
+   if (pf == NULL) {
+   PMD_DRV_LOG(ERR, "Invalid PF argument\n");
+   return -EINVAL;
+   }
+   hw = I40E_PF_TO_HW(pf);
+
+   if (filter == NULL) {
+   PMD_DRV_LOG(ERR, "Invalid mac filter argument\n");
+   return -EINVAL;
+   }
+
+   new_mac = &filter->mac_addr;
+
+   if (is_zero_ether_addr(new_mac)) {
+   PMD_DRV_LOG(ERR, "Invalid ethernet address\n");
+   return -EINVAL;
+   }
+
+   vf_id = filter->dst_id;
+
+   if (vf_id > pf->vf_num - 1 || !pf->vfs) {
+   PMD_DRV_LOG(ERR, "Invalid argument\n");
+   return -EINVAL;
+   }
+   vf = &pf->vfs[vf_id];
+
+   if (add && is_same_ether_addr(new_mac, &(pf->dev_addr))) {
+   PMD_DRV_LOG(INFO, "Ignore adding permanent MAC address\n");
+   return -EINVAL;
+   }
+
+   if (add) {
+   (void)rte_memcpy(&old_mac, hw->mac.addr, ETHER_ADDR_LEN);
+   (void)rte_memcpy(hw->mac.addr, new_mac->addr_bytes,
+   ETHER_ADDR_LEN);
+   (void)rte_memcpy(&mac_filter.mac_addr, &filter->mac_addr,
+ETHER_ADDR_LEN);
+
+   mac_filter.filter_type = filter->filter_type;
+   ret = i40e_vsi_add_mac(vf->vsi, &mac_filter);
+   if (ret != I40E_SUCCESS) {
+   PMD_DRV_LOG(ERR, "Failed to add MAC filter\n");
+   return -1;
+   }
+   ether_addr_copy(new_mac, &pf->dev_addr);
+   } else {
+   (void)rte_memcpy(hw->mac.addr, hw->mac.perm_addr,
+   ETHER_ADDR_LEN);
+   ret = i40e_vsi_delete_mac(vf->vsi, &filter->mac_addr);
+   if (ret != I40E_SUCCESS) {
+   PMD_DRV_LOG(ERR, "Failed to delete MAC filter\n");
+   return -1;
+   }
+
+   /* Clear device address as it has been removed */
+   if (is_same_ether_addr(&(pf->dev_addr), new_mac))
+   memset(&pf->dev_addr, 0, sizeof(struct ether_addr));
+   }
+
+   return 0;
+}
+
+/* MAC filter handle */
+static int
+i40e_mac_filter_handle(struct rte_eth_dev *dev, enum rte_filter_op filter_op,
+   void *arg)
+{
+   struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+   struct rte_eth_mac_filter *filter;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+   int ret = I40E_NOT_SUPPORTED;
+
+   filter = (struct rte_eth_mac_filter *)(arg);
+
+   switch (filter_op) {
+   case RTE_ETH_FILTER_NONE:
+   ret = I40E_SUCCESS;
+   break;
+   case RTE_ETH_FILTER_ADD:
+   i40e_pf_disable_irq0(hw);
+   if (filter->is_vf)
+   ret = i40e_vf_mac_filter_set(pf, filter, 1);
+   i40e_pf_enable_irq0(hw);
+   break;
+   case RTE_ETH_FILTER_DELETE:
+   i40e_pf_disable_irq0(hw);
+   if (filter->is_vf)
+   ret = i40e_vf_mac_filter_set(pf, filter, 0);
+   i40e_pf_enable_irq0(hw);
+   break;
+   default:
+   PMD_DRV_LOG(ERR, "unknown operation %u\n", filter_op);
+   ret = I40E_ERR_PARAM;
+   break;
+   }
+
+   return ret;
+}
+
 static int
 i40e_dev_rss_reta_update(struct rte_eth_dev *dev,
 struct rte_eth_rss_reta *reta_conf)
@@ -4243,13 +4356,14 @@ i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
 void *arg)
 {
int ret = 0;
-   (void)filter_op;
-   (void)arg;


[dpdk-dev] [PATCH v2 2/4] i40e:expand MAC filter implemantation in i40e

2014-10-24 Thread Jijiang Liu
This patch mainly optimizes the i40e_add_macvlan_filters() and the 
i40e_remove_macvlan_filters() functions in order that
we are able to provide filter type configuration. And another relevant MAC 
filter codes are changed based on new data structures.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |  165 
 lib/librte_pmd_i40e/i40e_ethdev.h |   18 -
 lib/librte_pmd_i40e/i40e_pf.c |7 ++-
 3 files changed, 149 insertions(+), 41 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 3b75f0f..5fae0e1 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1529,6 +1529,7 @@ i40e_macaddr_add(struct rte_eth_dev *dev,
 {
struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct i40e_mac_filter_info mac_filter;
struct i40e_vsi *vsi = pf->main_vsi;
struct ether_addr old_mac;
int ret;
@@ -1554,8 +1555,10 @@ i40e_macaddr_add(struct rte_eth_dev *dev,
(void)rte_memcpy(&old_mac, hw->mac.addr, ETHER_ADDR_LEN);
(void)rte_memcpy(hw->mac.addr, mac_addr->addr_bytes,
ETHER_ADDR_LEN);
+   (void)rte_memcpy(&mac_filter.mac_addr, mac_addr, ETHER_ADDR_LEN);
+   mac_filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;

-   ret = i40e_vsi_add_mac(vsi, mac_addr);
+   ret = i40e_vsi_add_mac(vsi, &mac_filter);
if (ret != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Failed to add MACVLAN filter");
return;
@@ -2472,6 +2475,7 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
 {
struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
struct i40e_aqc_remove_macvlan_element_data def_filter;
+   struct i40e_mac_filter_info filter;
int ret;

if (vsi->type != I40E_VSI_MAIN)
@@ -2485,6 +2489,7 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
ret = i40e_aq_remove_macvlan(hw, vsi->seid, &def_filter, 1, NULL);
if (ret != I40E_SUCCESS) {
struct i40e_mac_filter *f;
+   struct ether_addr *mac;

PMD_DRV_LOG(WARNING, "Cannot remove the default "
"macvlan filter");
@@ -2494,15 +2499,18 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
PMD_DRV_LOG(ERR, "failed to allocate memory");
return I40E_ERR_NO_MEMORY;
}
-   (void)rte_memcpy(&f->macaddr.addr_bytes, hw->mac.perm_addr,
+   mac = &f->mac_info.mac_addr;
+   (void)rte_memcpy(&mac->addr_bytes, hw->mac.perm_addr,
ETH_ADDR_LEN);
TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
vsi->mac_num++;

return ret;
}
-
-   return i40e_vsi_add_mac(vsi, (struct ether_addr *)(hw->mac.perm_addr));
+   (void)rte_memcpy(&filter.mac_addr,
+   (struct ether_addr *)(hw->mac.perm_addr), ETH_ADDR_LEN);
+   filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+   return i40e_vsi_add_mac(vsi, &filter);
 }

 static int
@@ -2556,6 +2564,7 @@ i40e_vsi_setup(struct i40e_pf *pf,
 {
struct i40e_hw *hw = I40E_PF_TO_HW(pf);
struct i40e_vsi *vsi;
+   struct i40e_mac_filter_info filter;
int ret;
struct i40e_vsi_context ctxt;
struct ether_addr broadcast =
@@ -2766,7 +2775,10 @@ i40e_vsi_setup(struct i40e_pf *pf,
}

/* MAC/VLAN configuration */
-   ret = i40e_vsi_add_mac(vsi, &broadcast);
+   (void)rte_memcpy(&filter.mac_addr, &broadcast, ETHER_ADDR_LEN);
+   filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+
+   ret = i40e_vsi_add_mac(vsi, &filter);
if (ret != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Failed to add MACVLAN filter");
goto fail_msix_alloc;
@@ -3467,6 +3479,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,
 {
int ele_num, ele_buff_size;
int num, actual_num, i;
+   uint16_t flags;
int ret = I40E_SUCCESS;
struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
struct i40e_aqc_add_macvlan_element_data *req_list;
@@ -3492,9 +3505,31 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,
&filter[num + i].macaddr, ETH_ADDR_LEN);
req_list[i].vlan_tag =
rte_cpu_to_le_16(filter[num + i].vlan_id);
-   req_list[i].flags = rte_cpu_to_le_16(\
-   I40E_AQC_MACVLAN_ADD_PERFECT_MATCH);
+
+   switch (filter[num + i].filter_type) {
+   case RTE_M

[dpdk-dev] [PATCH v2 1/4] librte_ether:extend MAC filter data structures

2014-10-24 Thread Jijiang Liu
Add the data definations for MAC filter enhancement in rte_eth_ctrl.h file.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_eth_ctrl.h |   23 +++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index df21ac6..699ed2e 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -51,6 +51,7 @@ extern "C" {
  */
 enum rte_filter_type {
RTE_ETH_FILTER_NONE = 0,
+   RTE_ETH_FILTER_MACVLAN,
RTE_ETH_FILTER_MAX
 };

@@ -71,6 +72,28 @@ enum rte_filter_op {
RTE_ETH_FILTER_OP_MAX
 };

+/**
+ * MAC filter type
+ */
+enum rte_mac_filter_type {
+   RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
+   RTE_MACVLAN_PERFECT_MATCH,
+   /**< exact match of MAC addr and VLAN ID. */
+   RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
+   RTE_MACVLAN_HASH_MATCH,
+   /**< hash match of MAC addr and exact match of VLAN ID. */
+};
+
+/**
+ * MAC filter info
+ */
+struct rte_eth_mac_filter {
+   uint8_t is_vf; /**< 1 for VF, 0 for port dev */
+   uint16_t dst_id; /**

[dpdk-dev] [PATCH v2 0/4] support VF MAC filter on Fortville

2014-10-24 Thread Jijiang Liu
The patch set enhances configurability of MAC filter and supports VF MAC filter 
on Fortville.

It mainly includes:
 - The following filter type are configurable:
   1. Perfect match of MAC address
   2. Perfect match of MAC address and VLAN ID
   3. Hash match of MAC address
   4. Hash match of MAC address and perfect match of VLAN ID
 - Support perfect and hash match of unicast and multicast MAC address for VF 
for i40e

 v2 updates:
  * Integrate the v1 patch set into the new filter framework.
  * Optimize MAC filter data structures in rte_eth_ctrl.h file.

jijiangl (4):
  Expand data structures of MAC filter in rte_eth_ctrl.h file.
  Expand MAC filter implemantation in i40e. 
  Support VF MAC filter in i40e.
  Test VF MAC filter in testpmd 

 app/test-pmd/cmdline.c|  119 +++-
 lib/librte_ether/rte_eth_ctrl.h   |   23 +++
 lib/librte_pmd_i40e/i40e_ethdev.c |  283 -
 lib/librte_pmd_i40e/i40e_ethdev.h |   18 ++-
 lib/librte_pmd_i40e/i40e_pf.c |7 +-
 5 files changed, 404 insertions(+), 46 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v7 10/10] app/testpmd:test VxLAN Tx checksum offload

2014-10-23 Thread Jijiang Liu
Add test cases in testpmd to test VxLAN Tx Checksum offload, which include
 - IPv4 and IPv6 packet
 - outer L3, inner L3 and L4 checksum offload for Tx side.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c  |   13 ++-
 app/test-pmd/config.c   |6 +-
 app/test-pmd/csumonly.c |  194 +++
 3 files changed, 192 insertions(+), 21 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index da5d272..757c399 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -310,13 +310,17 @@ static void cmd_help_long_parsed(void *parsed_result,
"Disable hardware insertion of a VLAN header in"
" packets sent on a port.\n\n"

-   "tx_checksum set mask (port_id)\n"
+   "tx_checksum set (mask) (port_id)\n"
"Enable hardware insertion of checksum offload with"
-   " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
+   " the 8-bit mask, 0~0xff, in packets sent on a port.\n"
"bit 0 - insert ip   checksum offload if set\n"
"bit 1 - insert udp  checksum offload if set\n"
"bit 2 - insert tcp  checksum offload if set\n"
"bit 3 - insert sctp checksum offload if set\n"
+   "bit 4 - insert inner ip  checksum offload if 
set\n"
+   "bit 5 - insert inner udp checksum offload if 
set\n"
+   "bit 6 - insert inner tcp checksum offload if 
set\n"
+   "bit 7 - insert inner sctp checksum offload if 
set\n"
"Please check the NIC datasheet for HW limits.\n\n"

"set fwd (%s)\n"
@@ -2763,8 +2767,9 @@ cmdline_parse_inst_t cmd_tx_cksum_set = {
.f = cmd_tx_cksum_set_parsed,
.data = NULL,
.help_str = "enable hardware insertion of L3/L4checksum with a given "
-   "mask in packets sent on a port, the bit mapping is given as, Bit 0 for 
ip"
-   "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
+   "mask in packets sent on a port, the bit mapping is given as, Bit 0 for 
ip, "
+   "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
+   "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
.tokens = {
(void *)&cmd_tx_cksum_set_tx_cksum,
(void *)&cmd_tx_cksum_set_set,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 2a1b93f..9bc08f4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1753,9 +1753,9 @@ tx_cksum_set(portid_t port_id, uint64_t ol_flags)
uint64_t tx_ol_flags;
if (port_id_is_invalid(port_id))
return;
-   /* Clear last 4 bits and then set L3/4 checksum mask again */
-   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0Full);
-   ports[port_id].tx_ol_flags = ((ol_flags & 0xf) | tx_ol_flags);
+   /* Clear last 8 bits and then set L3/4 checksum mask again */
+   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0FFull);
+   ports[port_id].tx_ol_flags = ((ol_flags & 0xff) | tx_ol_flags);
 }

 void
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index fcc4876..3967476 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -209,10 +209,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
struct rte_mbuf  *mb;
struct ether_hdr *eth_hdr;
struct ipv4_hdr  *ipv4_hdr;
+   struct ether_hdr *inner_eth_hdr;
+   struct ipv4_hdr  *inner_ipv4_hdr = NULL;
struct ipv6_hdr  *ipv6_hdr;
+   struct ipv6_hdr  *inner_ipv6_hdr = NULL;
struct udp_hdr   *udp_hdr;
+   struct udp_hdr   *inner_udp_hdr;
struct tcp_hdr   *tcp_hdr;
+   struct tcp_hdr   *inner_tcp_hdr;
struct sctp_hdr  *sctp_hdr;
+   struct sctp_hdr  *inner_sctp_hdr;

uint16_t nb_rx;
uint16_t nb_tx;
@@ -221,12 +227,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint64_t pkt_ol_flags;
uint64_t tx_ol_flags;
uint16_t l4_proto;
+   uint16_t inner_l4_proto = 0;
uint16_t eth_type;
uint8_t  l2_len;
uint8_t  l3_len;
+   uint8_t  inner_l2_len = 0;
+   uint8_t  inner_l3_len = 0;

uint32_t rx_bad_ip_csum;
uint32_t rx_bad_l4_csum;
+   uint8_t  ipv4_tunnel;
+   uint8_t  ipv6_tunnel;

 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
uint64_t start_tsc;
@@ -262,7 +273,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
l

[dpdk-dev] [PATCH v7 09/10] i40e:support VxLAN Tx checksum offload

2014-10-23 Thread Jijiang Liu
Support VxLAN Tx checksum offload, which include
  - outer L3(IP) checksum offload
  - inner L3(IP) checksum offload
  - inner L4(UDP, TCP and SCTP) checksum offload

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h  |1 +
 lib/librte_pmd_i40e/i40e_rxtx.c |   46 +-
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 9af3bd9..a86dedf 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -96,6 +96,7 @@ extern "C" {

 #define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
+#define PKT_TX_VXLAN_CKSUM   (1ULL << 50) /**< TX checksum of VxLAN computed 
by NIC */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */
 #define PKT_TX_IPV4  PKT_RX_IPV4_HDR /**< IPv4 with no IP checksum 
offload. */
 #define PKT_TX_IPV6  PKT_RX_IPV6_HDR /**< IPv6 packet */
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 2108290..7599df9 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -411,11 +411,14 @@ i40e_rxd_ptype_to_pkt_flags(uint64_t qword)
 }

 static inline void
-i40e_txd_enable_checksum(uint32_t ol_flags,
+i40e_txd_enable_checksum(uint64_t ol_flags,
uint32_t *td_cmd,
uint32_t *td_offset,
uint8_t l2_len,
-   uint8_t l3_len)
+   uint16_t l3_len,
+   uint8_t inner_l2_len,
+   uint16_t inner_l3_len,
+   uint32_t *cd_tunneling)
 {
if (!l2_len) {
PMD_DRV_LOG(DEBUG, "L2 length set to 0");
@@ -428,6 +431,27 @@ i40e_txd_enable_checksum(uint32_t ol_flags,
return;
}

+   /* VxLAN packet TX checksum offload */
+   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
+   uint8_t l4tun_len;
+
+   l4tun_len = ETHER_VXLAN_HLEN + inner_l2_len;
+
+   if (ol_flags & PKT_TX_IPV4_CSUM)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
+   else if (ol_flags & PKT_TX_IPV6)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;
+
+   /* Now set the ctx descriptor fields */
+   *cd_tunneling |= (l3_len >> 2) <<
+   I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
+   I40E_TXD_CTX_UDP_TUNNELING |
+   (l4tun_len >> 1) <<
+   I40E_TXD_CTX_QW0_NATLEN_SHIFT;
+
+   l3_len = inner_l3_len;
+   }
+
/* Enable L3 checksum offloads */
if (ol_flags & PKT_TX_IPV4_CSUM) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
@@ -1077,7 +1101,10 @@ i40e_recv_scattered_pkts(void *rx_queue,
 static inline uint16_t
 i40e_calc_context_desc(uint64_t flags)
 {
-   uint16_t mask = 0;
+   uint64_t mask = 0ULL;
+
+   if (flags | PKT_TX_VXLAN_CKSUM)
+   mask |= PKT_TX_VXLAN_CKSUM;

 #ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
@@ -1098,6 +1125,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
volatile struct i40e_tx_desc *txr;
struct rte_mbuf *tx_pkt;
struct rte_mbuf *m_seg;
+   uint32_t cd_tunneling_params;
uint16_t tx_id;
uint16_t nb_tx;
uint32_t td_cmd;
@@ -1106,7 +1134,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
uint32_t td_tag;
uint64_t ol_flags;
uint8_t l2_len;
-   uint8_t l3_len;
+   uint16_t l3_len;
+   uint8_t inner_l2_len;
+   uint16_t inner_l3_len;
uint16_t nb_used;
uint16_t nb_ctx;
uint16_t tx_last;
@@ -1134,7 +1164,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)

ol_flags = tx_pkt->ol_flags;
l2_len = tx_pkt->l2_len;
+   inner_l2_len = tx_pkt->inner_l2_len;
l3_len = tx_pkt->l3_len;
+   inner_l3_len = tx_pkt->inner_l3_len;

/* Calculate the number of context descriptors needed. */
nb_ctx = i40e_calc_context_desc(ol_flags);
@@ -1182,15 +1214,17 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)
td_cmd |= I40E_TX_DESC_CMD_ICRC;

/* Enable checksum offloading */
+   cd_tunneling_params = 0;
i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset,
-   l2_len, l3_len);
+  

[dpdk-dev] [PATCH v7 08/10] app/testpmd:test VxLAN packet filter

2014-10-23 Thread Jijiang Liu
Add the "tunnel_filter" command in testpmd to test the API of VxLAN packet 
filter.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c |  150 
 1 files changed, 150 insertions(+), 0 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4d7b4d1..da5d272 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -285,6 +285,14 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"

+   "tunnel_filter add (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   add a tunnel filter of a port.\n\n"
+
+   "tunnel_filter rm (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   remove a tunnel filter of a port.\n\n"
+
"rx_vxlan_port add (udp_port) (port_id)\n"
"Add an UDP port for VxLAN packet filter on a 
port\n\n"

@@ -6231,6 +6239,147 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
},
 };

+/* *** ADD TUNNEL FILTER OF A PORT *** */
+struct cmd_tunnel_filter_result {
+   cmdline_fixed_string_t cmd;
+   cmdline_fixed_string_t what;
+   uint8_t port_id;
+   struct ether_addr outer_mac;
+   struct ether_addr inner_mac;
+   cmdline_ipaddr_t ip_value;
+   uint16_t inner_vlan;
+   cmdline_fixed_string_t tunnel_type;
+   cmdline_fixed_string_t filter_type;
+   uint32_t tenant_id;
+   uint16_t queue_num;
+};
+
+static void
+cmd_tunnel_filter_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+   struct cmd_tunnel_filter_result *res = parsed_result;
+   struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
+   int ret = 0;
+
+   tunnel_filter_conf.outer_mac = &res->outer_mac;
+   tunnel_filter_conf.inner_mac = &res->inner_mac;
+   tunnel_filter_conf.inner_vlan = res->inner_vlan;
+
+   if (res->ip_value.family == AF_INET) {
+   tunnel_filter_conf.ip_addr.ipv4_addr =
+   res->ip_value.addr.ipv4.s_addr;
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
+   } else {
+   memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
+   &(res->ip_value.addr.ipv6),
+   sizeof(struct in6_addr));
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
+   }
+
+   if (!strcmp(res->filter_type, "imac-ivlan"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
+   else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
+   else if (!strcmp(res->filter_type, "imac-tenid"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
+   else if (!strcmp(res->filter_type, "imac"))
+   tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
+   else if (!strcmp(res->filter_type, "omac-imac-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
+   else {
+   printf("The filter type is not supported");
+   return;
+   }
+
+   if (!strcmp(res->tunnel_type, "vxlan"))
+   tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+   else {
+   printf("Only VxLAN is supported now.\n");
+   return;
+   }
+
+   tunnel_filter_conf.tenant_id = res->tenant_id;
+   tunnel_filter_conf.queue_id = res->queue_num;
+   if (!strcmp(res->what, "add"))
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_ADD,
+   &tunnel_filter_conf);
+   else
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_DELETE,
+   &tunnel_filter_conf);
+   if (ret < 0)
+   printf("cmd_tunnel_filter_parsed error: (%s)\n",
+   strerror(-ret));
+
+}
+cmdline_parse_token_string_t cmd_t

[dpdk-dev] [PATCH v7 07/10] i40e:implement the API of VxLAN filter in librte_pmd_i40e

2014-10-23 Thread Jijiang Liu
The filter types supported are listed below for VxLAN:
   1. Inner MAC and Inner VLAN ID.
   2. Inner MAC address, inner VLAN ID and tenant ID.
   3. Inner MAC and tenant ID.
   4. Inner MAC address.
   5. Outer MAC address, tenant ID and inner MAC address.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |  174 -
 1 files changed, 172 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index eb643e5..be83268 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "i40e_logs.h"
 #include "i40e/i40e_register_x710_int.h"
@@ -4099,6 +4100,108 @@ i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 }

 static int
+i40e_dev_get_filter_type(uint16_t filter_type, uint16_t *flag)
+{
+   switch (filter_type) {
+   case RTE_TUNNEL_FILTER_IMAC_IVLAN:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN;
+   break;
+   case RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN_TEN_ID;
+   break;
+   case RTE_TUNNEL_FILTER_IMAC_TENID:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_TEN_ID;
+   break;
+   case RTE_TUNNEL_FILTER_OMAC_TENID_IMAC:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_OMAC_TEN_ID_IMAC;
+   break;
+   case ETH_TUNNEL_FILTER_IMAC:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC;
+   break;
+   default:
+   PMD_DRV_LOG(ERR, "invalid tunnel filter type\n");
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int
+i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
+   struct rte_eth_tunnel_filter_conf *tunnel_filter,
+   uint8_t add)
+{
+   uint16_t ip_type;
+   uint8_t tun_type = 0;
+   int val, ret = 0;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+   struct i40e_vsi *vsi = pf->main_vsi;
+   struct i40e_aqc_add_remove_cloud_filters_element_data  *cld_filter;
+   struct i40e_aqc_add_remove_cloud_filters_element_data  *pfilter;
+
+   cld_filter = rte_zmalloc("tunnel_filter",
+   sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data),
+   0);
+
+   if (NULL == cld_filter) {
+   PMD_DRV_LOG(ERR, "Failed to alloc memory.\n");
+   return -EINVAL;
+   }
+   pfilter = cld_filter;
+
+   (void)rte_memcpy(&pfilter->outer_mac, tunnel_filter->outer_mac,
+   sizeof(struct ether_addr));
+   (void)rte_memcpy(&pfilter->inner_mac, tunnel_filter->inner_mac,
+   sizeof(struct ether_addr));
+
+   pfilter->inner_vlan = tunnel_filter->inner_vlan;
+   if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+   ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
+   (void)rte_memcpy(&pfilter->ipaddr.v4.data,
+   &tunnel_filter->ip_addr,
+   sizeof(pfilter->ipaddr.v4.data));
+   } else {
+   ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
+   (void)rte_memcpy(&pfilter->ipaddr.v6.data,
+   &tunnel_filter->ip_addr,
+   sizeof(pfilter->ipaddr.v6.data));
+   }
+
+   /* check tunneled type */
+   switch (tunnel_filter->tunnel_type) {
+   case RTE_TUNNEL_TYPE_VXLAN:
+   tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_XVLAN;
+   break;
+   default:
+   /* Other tunnel types is not supported. */
+   PMD_DRV_LOG(ERR, "tunnel type is not supported.\n");
+   rte_free(cld_filter);
+   return -EINVAL;
+   }
+
+   val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
+   &pfilter->flags);
+   if (val < 0) {
+   rte_free(cld_filter);
+   return -EINVAL;
+   }
+
+   pfilter->flags |= I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | ip_type |
+   (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT);
+   pfilter->tenant_id = tunnel_filter->tenant_id;
+   pfilter->queue_number = tunnel_filter->queue_id;
+
+   if (add)
+   ret = i40e_aq_add_cloud_filters(hw, vsi->seid, cld_filter, 1);
+   else
+   ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+   cld_filter, 1);
+
+   rte_free(cld_filter);
+   return ret;
+}
+
+static int
 i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)
 {
uint8_t i;
@@ -4286,6 +4389,72 @@ i40e_pf_config_rss(struct i40e_pf *pf)
 }

 stat

[dpdk-dev] [PATCH v7 06/10] librte_ether:add data structures of VxLAN filter

2014-10-23 Thread Jijiang Liu
Add definations of the data structures of tunneling packet filter in the 
rte_eth_ctrl.h file.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_eth_ctrl.h |   49 +++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 9a90d19..b4ab731 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -51,6 +51,7 @@ extern "C" {
  */
 enum rte_filter_type {
RTE_ETH_FILTER_NONE = 0,
+   RTE_ETH_FILTER_TUNNEL,
RTE_ETH_FILTER_MAX
 };

@@ -83,6 +84,54 @@ enum rte_eth_tunnel_type {
RTE_TUNNEL_TYPE_MAX,
 };

+/**
+ * filter type of tunneling packet
+ */
+#define ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
+#define ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
+#define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
+#define ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
+#define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
+#define ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
+
+#define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
+   ETH_TUNNEL_FILTER_IVLAN)
+#define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
+   ETH_TUNNEL_FILTER_IVLAN | \
+   ETH_TUNNEL_FILTER_TENID)
+#define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
+   ETH_TUNNEL_FILTER_TENID)
+#define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
+   ETH_TUNNEL_FILTER_TENID | \
+   ETH_TUNNEL_FILTER_IMAC)
+
+/**
+ *  Select IPv4 or IPv6 for tunnel filters.
+ */
+enum rte_tunnel_iptype {
+   RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
+   RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */
+};
+
+/**
+ * Tunneling Packet filter configuration.
+ */
+struct rte_eth_tunnel_filter_conf {
+   struct ether_addr *outer_mac;  /**< Outer MAC address filter. */
+   struct ether_addr *inner_mac;  /**< Inner MAC address filter. */
+   uint16_t inner_vlan;   /**< Inner VLAN filter. */
+   enum rte_tunnel_iptype ip_type; /**< IP address type. */
+   union {
+   uint32_t ipv4_addr;/**< IPv4 source address to match. */
+   uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
+   } ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
+
+   uint16_t filter_type;   /**< Filter type. */
+   enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+   uint32_t tenant_id; /** < Tenant number. */
+   uint16_t queue_id;  /** < queue number. */
+};
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.7.6



[dpdk-dev] [PATCH v7 05/10] app/test-pmd:test VxLAN packet identification

2014-10-23 Thread Jijiang Liu
Add two commands to test VxLAN packet identification.
The test steps are as follows:
 1> use commands to add/delete VxLAN UDP port.
 2> use rxonly mode to receive VxLAN packet.

Signed-off-by: Jijiang Liu 
---
 app/test-pmd/cmdline.c |   65 
 app/test-pmd/rxonly.c  |   55 +++-
 2 files changed, 118 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0b972f9..4d7b4d1 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -285,6 +285,12 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"

+   "rx_vxlan_port add (udp_port) (port_id)\n"
+   "Add an UDP port for VxLAN packet filter on a 
port\n\n"
+
+   "rx_vxlan_port rm (udp_port) (port_id)\n"
+   "Remove an UDP port for VxLAN packet filter on a 
port\n\n"
+
"tx_vlan set vlan_id (port_id)\n"
"Set hardware insertion of VLAN ID in packets sent"
" on a port.\n\n"
@@ -6225,6 +6231,64 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
},
 };

+/* *** CONFIGURE TUNNEL UDP PORT *** */
+struct cmd_tunnel_udp_config {
+   cmdline_fixed_string_t cmd;
+   cmdline_fixed_string_t what;
+   uint16_t udp_port;
+   uint8_t port_id;
+};
+
+static void
+cmd_tunnel_udp_config_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+   struct cmd_tunnel_udp_config *res = parsed_result;
+   struct rte_eth_udp_tunnel tunnel_udp;
+   int ret;
+
+   tunnel_udp.udp_port = res->udp_port;
+
+   if (!strcmp(res->cmd, "rx_vxlan_port"))
+   tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
+
+   if (!strcmp(res->what, "add"))
+   ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
+   else
+   ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
+
+   if (ret < 0)
+   printf("udp tunneling add error: (%s)\n", strerror(-ret));
+}
+
+cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
+   TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
+   cmd, "rx_vxlan_port");
+cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
+   TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
+   what, "add#rm");
+cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
+   TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
+   udp_port, UINT16);
+cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_tunnel_udp_config = {
+   .f = cmd_tunnel_udp_config_parsed,
+   .data = (void *)0,
+   .help_str = "add/rm an tunneling UDP port filter: "
+   "rx_vxlan_port add udp_port port_id",
+   .tokens = {
+   (void *)&cmd_tunnel_udp_config_cmd,
+   (void *)&cmd_tunnel_udp_config_what,
+   (void *)&cmd_tunnel_udp_config_udp_port,
+   (void *)&cmd_tunnel_udp_config_port_id,
+   NULL,
+   },
+};
+
 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
 struct cmd_set_mirror_mask_result {
cmdline_fixed_string_t set;
@@ -7518,6 +7582,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
+   (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
(cmdline_parse_inst_t *)&cmd_set_mirror_link,
(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 98c788b..d3be62e 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -66,10 +66,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 

 #include "testpmd.h"

-#define MAX_PKT_RX_FLAGS 11
+#define MAX_PKT_RX_FLAGS 13
 static const char *pkt_rx_flag_names[MAX_PKT_RX_FLAGS] = {
"VLAN_PKT",
"RSS_HASH",
@@ -84,6 +86,9 @@ static const char *pkt_rx_flag_names[MAX_PKT_RX_FLAGS] = {

"IEEE1588_PTP",
"IEEE1588_TMST",
+
+   "PKT_RX_TUNNEL_IPV4_HDR"
+   "PKT_RX_TUNNEL_IP

[dpdk-dev] [PATCH v7 04/10] i40e:support VxLAN packet identification in i40e

2014-10-23 Thread Jijiang Liu
Implement the configuration API of VxLAN destination UDP port in 
librte_pmd_i40e,
and add new Rx offload flags for supporting VXLAN packet offload.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h|2 +
 lib/librte_pmd_i40e/i40e_ethdev.c |  157 +
 lib/librte_pmd_i40e/i40e_ethdev.h |8 ++-
 lib/librte_pmd_i40e/i40e_rxtx.c   |  105 +---
 4 files changed, 223 insertions(+), 49 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 497d88b..9af3bd9 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -91,6 +91,8 @@ extern "C" {
 #define PKT_RX_IPV6_HDR_EXT  (1ULL << 8)  /**< RX packet with extended IPv6 
header. */
 #define PKT_RX_IEEE1588_PTP  (1ULL << 9)  /**< RX IEEE1588 L2 Ethernet PT 
Packet. */
 #define PKT_RX_IEEE1588_TMST (1ULL << 10) /**< RX IEEE1588 L2/L4 timestamped 
packet.*/
+#define PKT_RX_TUNNEL_IPV4_HDR (1ULL << 11) /**< RX tunnel packet with IPv4 
header.*/
+#define PKT_RX_TUNNEL_IPV6_HDR (1ULL << 12) /**< RX tunnel packet with IPv6 
header. */

 #define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 3b75f0f..eb643e5 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -186,6 +186,10 @@ static int i40e_dev_rss_hash_update(struct rte_eth_dev 
*dev,
struct rte_eth_rss_conf *rss_conf);
 static int i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
  struct rte_eth_rss_conf *rss_conf);
+static int i40e_dev_udp_tunnel_add(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *udp_tunnel);
+static int i40e_dev_udp_tunnel_del(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *udp_tunnel);
 static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_type filter_type,
enum rte_filter_op filter_op,
@@ -241,6 +245,8 @@ static struct eth_dev_ops i40e_eth_dev_ops = {
.reta_query   = i40e_dev_rss_reta_query,
.rss_hash_update  = i40e_dev_rss_hash_update,
.rss_hash_conf_get= i40e_dev_rss_hash_conf_get,
+   .udp_tunnel_add   = i40e_dev_udp_tunnel_add,
+   .udp_tunnel_del   = i40e_dev_udp_tunnel_del,
.filter_ctrl  = i40e_dev_filter_ctrl,
 };

@@ -4092,6 +4098,157 @@ i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
return 0;
 }

+static int
+i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)
+{
+   uint8_t i;
+
+   for (i = 0; i < I40E_MAX_PF_UDP_OFFLOAD_PORTS; i++) {
+   if (pf->vxlan_ports[i] == port)
+   return i;
+   }
+
+   return -1;
+}
+
+static int
+i40e_add_vxlan_port(struct i40e_pf *pf, uint16_t port)
+{
+   int  idx, ret;
+   uint8_t filter_idx;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+
+   idx = i40e_get_vxlan_port_idx(pf, port);
+
+   /* Check if port already exists */
+   if (idx >= 0) {
+   PMD_DRV_LOG(ERR, "Port %d already offloaded\n", port);
+   return -EINVAL;
+   }
+
+   /* Now check if there is space to add the new port */
+   idx = i40e_get_vxlan_port_idx(pf, 0);
+   if (idx < 0) {
+   PMD_DRV_LOG(ERR, "Maximum number of UDP ports reached,"
+   "not adding port %d\n", port);
+   return -ENOSPC;
+   }
+
+   ret =  i40e_aq_add_udp_tunnel(hw, port, I40E_AQC_TUNNEL_TYPE_VXLAN,
+   &filter_idx, NULL);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to add VxLAN UDP port %d\n", port);
+   return -1;
+   }
+
+   PMD_DRV_LOG(INFO, "Added %s port %d with AQ command with index %d\n",
+port,  filter_index);
+
+   /* New port: add it and mark its index in the bitmap */
+   pf->vxlan_ports[idx] = port;
+   pf->vxlan_bitmap |= (1 << idx);
+
+   if (!(pf->flags & I40E_FLAG_VXLAN))
+   pf->flags |= I40E_FLAG_VXLAN;
+
+   return 0;
+}
+
+static int
+i40e_del_vxlan_port(struct i40e_pf *pf, uint16_t port)
+{
+   int idx;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+
+   if (!(pf->flags & I40E_FLAG_VXLAN)) {
+   PMD_DRV_LOG(ERR, "VxLAN tunneling mode is not configured\n");
+   return -EINVAL;
+   }
+
+   idx = i40e_get_vxlan_port_idx(pf, port);
+
+ 

[dpdk-dev] [PATCH v7 03/10] librte_ether:add VxLAN packet identification API

2014-10-23 Thread Jijiang Liu
There are "some" destination UDP port numbers that have unque meaning.
In terms of VxLAN, "IANA has assigned the value 4789 for the VXLAN UDP port, 
and this value SHOULD be used by default as the destination UDP port. Some 
early implementations of VXLAN have used other values for the destination port. 
To enable interoperability with these implementations, the destination port 
SHOULD be configurable."

Add two APIs in librte_ether for supporting UDP tunneling port configuration on 
i40e.
Currently, only VxLAN is implemented in this patch set.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_ethdev.c |   52 +
 lib/librte_ether/rte_ethdev.h |   46 
 2 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 50f10d9..ff1c769 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2038,6 +2038,58 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
 }

 int
+rte_eth_dev_udp_tunnel_add(uint8_t port_id,
+  struct rte_eth_udp_tunnel *udp_tunnel)
+{
+   struct rte_eth_dev *dev;
+
+   if (port_id >= nb_ports) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   if (udp_tunnel == NULL) {
+   PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+   return -EINVAL;
+   }
+
+   if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+   PMD_DEBUG_TRACE("Invalid tunnel type\n");
+   return -EINVAL;
+   }
+
+   dev = &rte_eth_devices[port_id];
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
+   return (*dev->dev_ops->udp_tunnel_add)(dev, udp_tunnel);
+}
+
+int
+rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
+ struct rte_eth_udp_tunnel *udp_tunnel)
+{
+   struct rte_eth_dev *dev;
+
+   if (port_id >= nb_ports) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+   dev = &rte_eth_devices[port_id];
+
+   if (udp_tunnel == NULL) {
+   PMD_DEBUG_TRACE("Invalid udp_tunnel parametr\n");
+   return -EINVAL;
+   }
+
+   if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+   PMD_DEBUG_TRACE("Invalid tunnel type\n");
+   return -EINVAL;
+   }
+
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
+   return (*dev->dev_ops->udp_tunnel_del)(dev, udp_tunnel);
+}
+
+int
 rte_eth_led_on(uint8_t port_id)
 {
struct rte_eth_dev *dev;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 46a5568..8bf274d 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1274,6 +1274,15 @@ typedef int (*eth_mirror_rule_reset_t)(struct 
rte_eth_dev *dev,
  uint8_t rule_id);
 /**< @internal Remove a traffic mirroring rule on an Ethernet device */

+typedef int (*eth_udp_tunnel_add_t)(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *tunnel_udp);
+/**< @internal Add tunneling UDP info */
+
+typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *tunnel_udp);
+/**< @internal Delete tunneling UDP info */
+
+
 #ifdef RTE_NIC_BYPASS

 enum {
@@ -1454,6 +1463,8 @@ struct eth_dev_ops {
eth_set_vf_rx_tset_vf_rx;  /**< enable/disable a VF receive 
*/
eth_set_vf_tx_tset_vf_tx;  /**< enable/disable a VF 
transmit */
eth_set_vf_vlan_filter_t   set_vf_vlan_filter;  /**< Set VF VLAN filter 
*/
+   eth_udp_tunnel_add_t   udp_tunnel_add;
+   eth_udp_tunnel_del_t   udp_tunnel_del;
eth_set_queue_rate_limit_t set_queue_rate_limit;   /**< Set queue rate 
limit */
eth_set_vf_rate_limit_tset_vf_rate_limit;   /**< Set VF rate limit 
*/

@@ -3350,6 +3361,41 @@ int
 rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
  struct rte_eth_rss_conf *rss_conf);

+ /**
+ * Add UDP tunneling port of an Ethernet device for filtering a specific
+ * tunneling packet by UDP port number.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param tunnel_udp
+ *   UDP tunneling configuration.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if port identifier is invalid.
+ *   - (-ENOTSUP) if hardware doesn't support tunnel type.
+ */
+int
+rte_eth_dev_udp_tunnel_add(uint8_t port_id,
+  struct rte_eth_udp_tunnel *tunnel_udp);
+
+ /**
+ * Detete UDP tunneling port configuration of Ethernet device
+ *
+ * @param port_id
+ *   The port i

[dpdk-dev] [PATCH v7 02/10] librte_ether:add the basic data structures of VxLAN

2014-10-23 Thread Jijiang Liu
Add definations of basic data structures of VxLAN.

Signed-off-by: Jijiang Liu 
---
 lib/librte_ether/rte_eth_ctrl.h |   12 
 lib/librte_ether/rte_ethdev.h   |8 
 lib/librte_ether/rte_ether.h|   13 +
 3 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index df21ac6..9a90d19 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -71,6 +71,18 @@ enum rte_filter_op {
RTE_ETH_FILTER_OP_MAX
 };

+/**
+ * Tunneled type.
+ */
+enum rte_eth_tunnel_type {
+   RTE_TUNNEL_TYPE_NONE = 0,
+   RTE_TUNNEL_TYPE_VXLAN,
+   RTE_TUNNEL_TYPE_GENEVE,
+   RTE_TUNNEL_TYPE_TEREDO,
+   RTE_TUNNEL_TYPE_NVGRE,
+   RTE_TUNNEL_TYPE_MAX,
+};
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b69a6af..46a5568 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -710,6 +710,14 @@ struct rte_fdir_conf {
 };

 /**
+ * UDP tunneling configuration.
+ */
+struct rte_eth_udp_tunnel {
+   uint16_t udp_port;
+   uint8_t prot_type;
+};
+
+/**
  *  Possible l4type of FDIR filters.
  */
 enum rte_l4type {
diff --git a/lib/librte_ether/rte_ether.h b/lib/librte_ether/rte_ether.h
index 2e08f23..100cc52 100644
--- a/lib/librte_ether/rte_ether.h
+++ b/lib/librte_ether/rte_ether.h
@@ -286,6 +286,16 @@ struct vlan_hdr {
uint16_t eth_proto;/**< Ethernet type of encapsulated frame. */
 } __attribute__((__packed__));

+/**
+ * VXLAN protocol header.
+ * Contains the 8-bit flag, 24-bit VXLAN Network Identifier and
+ * Reserved fields (24 bits and 8 bits)
+ */
+struct vxlan_hdr {
+   uint32_t vx_flags; /**< flag (8) + Reserved (24). */
+   uint32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+} __attribute__((__packed__));
+
 /* Ethernet frame types */
 #define ETHER_TYPE_IPv4 0x0800 /**< IPv4 Protocol. */
 #define ETHER_TYPE_IPv6 0x86DD /**< IPv6 Protocol. */
@@ -294,6 +304,9 @@ struct vlan_hdr {
 #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */
 #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */

+#define ETHER_VXLAN_HLEN (sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr))
+/**< VxLAN tunnel header length. */
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.7.6



[dpdk-dev] [PATCH v7 01/10] librte_mbuf:the rte_mbuf structure changes

2014-10-23 Thread Jijiang Liu
Replace the "reserved2" field with the "packet_type" field and add the 
"inner_l2_l3_len" field in the rte_mbuf structure.
The "packet_type" field is used to indicate ordinary packet format and also 
tunneling packet format such as IP in IP, IP in GRE, MAC in GRE and MAC in UDP.
The "inner_l2_len" and the "inner_l3_len" fields are added in the second cache 
line, they use 2 bytes for TX offloading of tunnels.

Signed-off-by: Jijiang Liu 
---
 lib/librte_mbuf/rte_mbuf.h |   25 -
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ddadc21..497d88b 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -163,7 +163,14 @@ struct rte_mbuf {

/* remaining bytes are set on RX when pulling packet from descriptor */
MARKER rx_descriptor_fields1;
-   uint16_t reserved2;   /**< Unused field. Required for padding */
+
+   /**
+* The packet type, which is used to indicate ordinary packet and also
+* tunneled packet format, i.e. each number is represented a type of
+* packet.
+*/
+   uint16_t packet_type;
+
uint16_t data_len;/**< Amount of data in segment buffer. */
uint32_t pkt_len; /**< Total pkt len: sum of all segments. */
uint16_t vlan_tci;/**< VLAN Tag Control Identifier (CPU order) 
*/
@@ -196,6 +203,18 @@ struct rte_mbuf {
uint16_t l2_len:7;  /**< L2 (MAC) Header Length. */
};
};
+
+   /* fields for TX offloading of tunnels */
+   union {
+   uint16_t inner_l2_l3_len;
+   /**< combined inner l2/l3 lengths as single var */
+   struct {
+   uint16_t inner_l3_len:9;
+   /**< inner L3 (IP) Header Length. */
+   uint16_t inner_l2_len:7;
+   /**< inner L2 (MAC) Header Length. */
+   };
+   };
 } __rte_cache_aligned;

 /**
@@ -546,11 +565,13 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)
m->next = NULL;
m->pkt_len = 0;
m->l2_l3_len = 0;
+   m->inner_l2_l3_len = 0;
m->vlan_tci = 0;
m->nb_segs = 1;
m->port = 0xff;

m->ol_flags = 0;
+   m->packet_type = 0;
m->data_off = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ?
RTE_PKTMBUF_HEADROOM : m->buf_len;

@@ -614,12 +635,14 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf 
*mi, struct rte_mbuf *md)
mi->port = md->port;
mi->vlan_tci = md->vlan_tci;
mi->l2_l3_len = md->l2_l3_len;
+   mi->inner_l2_l3_len = md->inner_l2_l3_len;
mi->hash = md->hash;

mi->next = NULL;
mi->pkt_len = mi->data_len;
mi->nb_segs = 1;
mi->ol_flags = md->ol_flags;
+   mi->packet_type = md->packet_type;

__rte_mbuf_sanity_check(mi, 1);
__rte_mbuf_sanity_check(md, 0);
-- 
1.7.7.6



[dpdk-dev] [PATCH v7 00/10] Support VxLAN on Fortville

2014-10-23 Thread Jijiang Liu
The patch set supports VxLAN on Fortville based on latest rte_mbuf structure. 

It includes:
 - Support VxLAN packet identification by configuring UDP tunneling port.
 - Support VxLAN packet filters. It uses MAC and VLAN to point
   to a queue. The filter types supported are listed below:
   1. Inner MAC and Inner VLAN ID
   2. Inner MAC address, inner VLAN ID and tenant ID.
   3. Inner MAC and tenant ID
   4. Inner MAC address
   5. Outer MAC address, tenant ID and inner MAC
 - Support VxLAN TX checksum offload, which include outer L3(IP), inner L3(IP) 
and inner L4(UDP,TCP and SCTP)

Change notes:

 v7)  * Remove the "tunnel_type" from rte_eth_conf structure. 
  * Remove the "to_queue" from rte_eth_tunnel_filter_conf,we probaly add it 
to be configurable later.
  * Remove the check of tunneling packet type in testpmd add Rx tunnel 
offload flag instead.
  * Split the APIs and data structures of VxLAN into two patches.

Jijiang Liu (10):
  change rte_mbuf structures 
  add data structures of UDP tunneling 
  add VxLAN packet identification API in librte_ether
  support VxLAN packet identification in i40e
  test VxLAN packet identification in testpmd.
  add data structures of tunneling filter in rte_eth_ctrl.h
  implement the API of VxLAN packet filter in i40e
  test VxLAN packet filter
  support VxLAN Tx checksum offload in i40e
  test VxLAN Tx checksum offload


 app/test-pmd/cmdline.c|  228 +-
 app/test-pmd/config.c |6 +-
 app/test-pmd/csumonly.c   |  194 --
 app/test-pmd/rxonly.c |   50 ++-
 lib/librte_ether/rte_eth_ctrl.h   |   61 +++
 lib/librte_ether/rte_ethdev.c |   52 ++
 lib/librte_ether/rte_ethdev.h |   54 ++
 lib/librte_ether/rte_ether.h  |   13 ++
 lib/librte_mbuf/rte_mbuf.h|   28 +++-
 lib/librte_pmd_i40e/i40e_ethdev.c |  331 -
 lib/librte_pmd_i40e/i40e_ethdev.h |8 +-
 lib/librte_pmd_i40e/i40e_rxtx.c   |  151 +++--
 12 files changed, 1096 insertions(+), 80 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH v6 9/9] app/testpmd:test VxLAN Tx checksum offload

2014-10-21 Thread Jijiang Liu
Add test cases in testpmd to test VxLAN Tx Checksum offload, which include
 - IPv4 and IPv6 packet 
 - outer L3, inner L3 and L4 checksum offload for Tx side.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 
---
 app/test-pmd/cmdline.c  |   13 ++-
 app/test-pmd/config.c   |6 +-
 app/test-pmd/csumonly.c |  195 +++
 3 files changed, 192 insertions(+), 22 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index bc9a30c..d738258 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -310,13 +310,17 @@ static void cmd_help_long_parsed(void *parsed_result,
"Disable hardware insertion of a VLAN header in"
" packets sent on a port.\n\n"

-   "tx_checksum set mask (port_id)\n"
+   "tx_checksum set (mask) (port_id)\n"
"Enable hardware insertion of checksum offload with"
-   " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
+   " the 8-bit mask, 0~0xff, in packets sent on a port.\n"
"bit 0 - insert ip   checksum offload if set\n"
"bit 1 - insert udp  checksum offload if set\n"
"bit 2 - insert tcp  checksum offload if set\n"
"bit 3 - insert sctp checksum offload if set\n"
+   "bit 4 - insert inner ip  checksum offload if 
set\n"
+   "bit 5 - insert inner udp checksum offload if 
set\n"
+   "bit 6 - insert inner tcp checksum offload if 
set\n"
+   "bit 7 - insert inner sctp checksum offload if 
set\n"
"Please check the NIC datasheet for HW limits.\n\n"

"set fwd (%s)\n"
@@ -2763,8 +2767,9 @@ cmdline_parse_inst_t cmd_tx_cksum_set = {
.f = cmd_tx_cksum_set_parsed,
.data = NULL,
.help_str = "enable hardware insertion of L3/L4checksum with a given "
-   "mask in packets sent on a port, the bit mapping is given as, Bit 0 for 
ip"
-   "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
+   "mask in packets sent on a port, the bit mapping is given as, Bit 0 for 
ip, "
+   "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
+   "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
.tokens = {
(void *)&cmd_tx_cksum_set_tx_cksum,
(void *)&cmd_tx_cksum_set_set,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 2a1b93f..9bc08f4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1753,9 +1753,9 @@ tx_cksum_set(portid_t port_id, uint64_t ol_flags)
uint64_t tx_ol_flags;
if (port_id_is_invalid(port_id))
return;
-   /* Clear last 4 bits and then set L3/4 checksum mask again */
-   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0Full);
-   ports[port_id].tx_ol_flags = ((ol_flags & 0xf) | tx_ol_flags);
+   /* Clear last 8 bits and then set L3/4 checksum mask again */
+   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0FFull);
+   ports[port_id].tx_ol_flags = ((ol_flags & 0xff) | tx_ol_flags);
 }

 void
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index fcc4876..e2ac129 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -196,7 +196,6 @@ get_ipv6_udptcp_checksum(struct ipv6_hdr *ipv6_hdr, 
uint16_t *l4_hdr)
return (uint16_t)cksum;
 }

-
 /*
  * Forwarding of packets. Change the checksum field with HW or SW methods
  * The HW/SW method selection depends on the ol_flags on every packet
@@ -209,10 +208,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
struct rte_mbuf  *mb;
struct ether_hdr *eth_hdr;
struct ipv4_hdr  *ipv4_hdr;
+   struct ether_hdr *inner_eth_hdr;
+   struct ipv4_hdr  *inner_ipv4_hdr = NULL;
struct ipv6_hdr  *ipv6_hdr;
+   struct ipv6_hdr  *inner_ipv6_hdr = NULL;
struct udp_hdr   *udp_hdr;
+   struct udp_hdr   *inner_udp_hdr;
struct tcp_hdr   *tcp_hdr;
+   struct tcp_hdr   *inner_tcp_hdr;
struct sctp_hdr  *sctp_hdr;
+   struct sctp_hdr  *inner_sctp_hdr;

uint16_t nb_rx;
uint16_t nb_tx;
@@ -221,12 +226,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint64_t pkt_ol_flags;
uint64_t tx_ol_flags;
uint16_t l4_proto;
+   uint16_t inner_l4_proto = 0;
uint16_t eth_type;
uint8_t  l2_len;
uint8_t  l3_len;
+  

[dpdk-dev] [PATCH v6 8/9] i40e:support VxLAN Tx checksum offload

2014-10-21 Thread Jijiang Liu
Support VxLAN Tx checksum offload, which include
  - outer L3(IP) checksum offload
  - inner L3(IP) checksum offload
  - inner L4(UDP, TCP and SCTP) checksum offload

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 
---
 lib/librte_mbuf/rte_mbuf.h  |1 +
 lib/librte_pmd_i40e/i40e_rxtx.c |   46 +-
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 98951a6..4144c0d 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -94,6 +94,7 @@ extern "C" {

 #define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
+#define PKT_TX_VXLAN_CKSUM   (1ULL << 50) /**< TX checksum of VxLAN computed 
by NIC */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */
 #define PKT_TX_IPV4  PKT_RX_IPV4_HDR /**< IPv4 with no IP checksum 
offload. */
 #define PKT_TX_IPV6  PKT_RX_IPV6_HDR /**< IPv6 packet */
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 7c3809f..592787f 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -411,11 +411,14 @@ i40e_rxd_ptype_to_pkt_flags(uint64_t qword)
 }

 static inline void
-i40e_txd_enable_checksum(uint32_t ol_flags,
+i40e_txd_enable_checksum(uint64_t ol_flags,
uint32_t *td_cmd,
uint32_t *td_offset,
uint8_t l2_len,
-   uint8_t l3_len)
+   uint16_t l3_len,
+   uint8_t inner_l2_len,
+   uint16_t inner_l3_len,
+   uint32_t *cd_tunneling)
 {
if (!l2_len) {
PMD_DRV_LOG(DEBUG, "L2 length set to 0");
@@ -428,6 +431,27 @@ i40e_txd_enable_checksum(uint32_t ol_flags,
return;
}

+   /* VxLAN packet TX checksum offload */
+   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
+   uint8_t l4tun_len;
+
+   l4tun_len = ETHER_VXLAN_HLEN + inner_l2_len;
+
+   if (ol_flags & PKT_TX_IPV4_CSUM)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
+   else if (ol_flags & PKT_TX_IPV6)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;
+
+   /* Now set the ctx descriptor fields */
+   *cd_tunneling |= (l3_len >> 2) <<
+   I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
+   I40E_TXD_CTX_UDP_TUNNELING |
+   (l4tun_len >> 1) <<
+   I40E_TXD_CTX_QW0_NATLEN_SHIFT;
+
+   l3_len = inner_l3_len;
+   }
+
/* Enable L3 checksum offloads */
if (ol_flags & PKT_TX_IPV4_CSUM) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
@@ -1077,7 +1101,10 @@ i40e_recv_scattered_pkts(void *rx_queue,
 static inline uint16_t
 i40e_calc_context_desc(uint64_t flags)
 {
-   uint16_t mask = 0;
+   uint64_t mask = 0ULL;
+
+   if (flags | PKT_TX_VXLAN_CKSUM)
+   mask |= PKT_TX_VXLAN_CKSUM;

 #ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
@@ -1098,6 +1125,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
volatile struct i40e_tx_desc *txr;
struct rte_mbuf *tx_pkt;
struct rte_mbuf *m_seg;
+   uint32_t cd_tunneling_params;
uint16_t tx_id;
uint16_t nb_tx;
uint32_t td_cmd;
@@ -1106,7 +1134,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
uint32_t td_tag;
uint64_t ol_flags;
uint8_t l2_len;
-   uint8_t l3_len;
+   uint16_t l3_len;
+   uint8_t inner_l2_len;
+   uint16_t inner_l3_len;
uint16_t nb_used;
uint16_t nb_ctx;
uint16_t tx_last;
@@ -1134,7 +1164,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)

ol_flags = tx_pkt->ol_flags;
l2_len = tx_pkt->l2_len;
+   inner_l2_len = tx_pkt->inner_l2_len;
l3_len = tx_pkt->l3_len;
+   inner_l3_len = tx_pkt->inner_l3_len;

/* Calculate the number of context descriptors needed. */
nb_ctx = i40e_calc_context_desc(ol_flags);
@@ -1182,15 +1214,17 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts)
td_cmd |= I40E_TX_DESC_CMD_ICRC;

/* Enable checksum offloading */
+   cd_tunneling_params = 0;
i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset,
- 

[dpdk-dev] [PATCH v6 7/9] app/testpmd:test VxLAN packet filter

2014-10-21 Thread Jijiang Liu
Add the tunnel_filter command in testpmd to test the API of VxLAN packet filter.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 app/test-pmd/cmdline.c |  152 
 1 files changed, 152 insertions(+), 0 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 7160e38..bc9a30c 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -285,6 +285,14 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"

+   "tunnel_filter add (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   add a tunnel filter of a port.\n\n"
+
+   "tunnel_filter rm (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   remove a tunnel filter of a port.\n\n"
+
"rx_vxlan_port add (udp_port) (port_id)\n"
"Add an UDP port for VxLAN packet filter on a 
port\n\n"

@@ -6231,6 +6239,149 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
},
 };

+/* *** ADD TUNNEL FILTER OF A PORT *** */
+struct cmd_tunnel_filter_result {
+   cmdline_fixed_string_t cmd;
+   cmdline_fixed_string_t what;
+   uint8_t port_id;
+   struct ether_addr outer_mac;
+   struct ether_addr inner_mac;
+   cmdline_ipaddr_t ip_value;
+   uint16_t inner_vlan;
+   cmdline_fixed_string_t tunnel_type;
+   cmdline_fixed_string_t filter_type;
+   uint32_t tenant_id;
+   uint16_t queue_num;
+};
+
+static void
+cmd_tunnel_filter_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+   struct cmd_tunnel_filter_result *res = parsed_result;
+   struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
+   int ret = 0;
+
+   tunnel_filter_conf.outer_mac = &res->outer_mac;
+   tunnel_filter_conf.inner_mac = &res->inner_mac;
+   tunnel_filter_conf.inner_vlan = res->inner_vlan;
+
+   if (res->ip_value.family == AF_INET) {
+   tunnel_filter_conf.ip_addr.ipv4_addr =
+   res->ip_value.addr.ipv4.s_addr;
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
+   } else {
+   memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
+   &(res->ip_value.addr.ipv6),
+   sizeof(struct in6_addr));
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
+   }
+
+   if (!strcmp(res->filter_type, "imac-ivlan"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
+   else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
+   else if (!strcmp(res->filter_type, "imac-tenid"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
+   else if (!strcmp(res->filter_type, "imac"))
+   tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
+   else if (!strcmp(res->filter_type, "omac-imac-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
+   else {
+   printf("The filter type is not supported");
+   return;
+   }
+
+   tunnel_filter_conf.to_queue = RTE_TUNNEL_FILTER_TO_QUEUE;
+
+   if (!strcmp(res->tunnel_type, "vxlan"))
+   tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+   else {
+   printf("Only VxLAN is supported now.\n");
+   return;
+   }
+
+   tunnel_filter_conf.tenant_id = res->tenant_id;
+   tunnel_filter_conf.queue_id = res->queue_num;
+   if (!strcmp(res->what, "add"))
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_ADD,
+   &tunnel_filter_conf);
+   else
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_DELETE,
+   &tunnel_filter_conf);
+   if (ret < 0)
+   printf("cm

[dpdk-dev] [PATCH v6 6/9] i40e:implement API of VxLAN packet filter in librte_pmd_i40e

2014-10-21 Thread Jijiang Liu
The implementation of VxLAN tunnel filter in librte_pmd_i40e, which include
 - add the i40e_tunnel_filter_handle() function.
 - add the i40e_dev_tunnel_filter_set() function.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |  177 -
 1 files changed, 175 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 8a84e30..726a972 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "i40e_logs.h"
 #include "i40e/i40e_register_x710_int.h"
@@ -192,6 +193,9 @@ static int i40e_dev_udp_tunnel_add(struct rte_eth_dev *dev,
 static int i40e_dev_udp_tunnel_del(struct rte_eth_dev *dev,
struct rte_eth_udp_tunnel *udp_tunnel,
uint8_t count);
+static int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
+   struct rte_eth_tunnel_filter_conf 
*tunnel_filter,
+   uint8_t add);
 static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_type filter_type,
enum rte_filter_op filter_op,
@@ -4105,6 +4109,108 @@ i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 }

 static int
+i40e_dev_get_filter_type(uint16_t filter_type, uint16_t *flag)
+{
+   switch (filter_type) {
+   case RTE_TUNNEL_FILTER_IMAC_IVLAN:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN;
+   break;
+   case RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN_TEN_ID;
+   break;
+   case RTE_TUNNEL_FILTER_IMAC_TENID:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_TEN_ID;
+   break;
+   case RTE_TUNNEL_FILTER_OMAC_TENID_IMAC:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_OMAC_TEN_ID_IMAC;
+   break;
+   case ETH_TUNNEL_FILTER_IMAC:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC;
+   break;
+   default:
+   PMD_DRV_LOG(ERR, "invalid tunnel filter type\n");
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int
+i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
+   struct rte_eth_tunnel_filter_conf *tunnel_filter,
+   uint8_t add)
+{
+   uint16_t ip_type;
+   uint8_t tun_type = 0;
+   int val, ret = 0;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+   struct i40e_vsi *vsi = pf->main_vsi;
+   struct i40e_aqc_add_remove_cloud_filters_element_data  *cld_filter;
+   struct i40e_aqc_add_remove_cloud_filters_element_data  *pfilter;
+
+   cld_filter = rte_zmalloc("tunnel_filter",
+   sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data),
+   0);
+
+   if (NULL == cld_filter) {
+   PMD_DRV_LOG(ERR, "Failed to alloc memory.\n");
+   return -EINVAL;
+   }
+   pfilter = cld_filter;
+
+   (void)rte_memcpy(&pfilter->outer_mac, tunnel_filter->outer_mac,
+   sizeof(struct ether_addr));
+   (void)rte_memcpy(&pfilter->inner_mac, tunnel_filter->inner_mac,
+   sizeof(struct ether_addr));
+
+   pfilter->inner_vlan = tunnel_filter->inner_vlan;
+   if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+   ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
+   (void)rte_memcpy(&pfilter->ipaddr.v4.data,
+   &tunnel_filter->ip_addr,
+   sizeof(pfilter->ipaddr.v4.data));
+   } else {
+   ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
+   (void)rte_memcpy(&pfilter->ipaddr.v6.data,
+   &tunnel_filter->ip_addr,
+   sizeof(pfilter->ipaddr.v6.data));
+   }
+
+   /* check tunneled type */
+   switch (tunnel_filter->tunnel_type) {
+   case RTE_TUNNEL_TYPE_VXLAN:
+   tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_XVLAN;
+   break;
+   default:
+   /* Other tunnel types is not supported. */
+   PMD_DRV_LOG(ERR, "tunnel type is not supported.\n");
+   rte_free(cld_filter);
+   return -EINVAL;
+   }
+
+   val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
+   &pfilter->flags);
+   if (val < 0) {
+   rte_free(cld_filter);
+   return -EINVAL;
+   }
+
+   pfilter->flags |= I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | ip_type |
+   (tun_type << I40E_AQC_ADD_C

[dpdk-dev] [PATCH v6 5/9] librte_ether:add data structures of VxLAN filter

2014-10-21 Thread Jijiang Liu
Add definations of the data structures of tunneling packet filter in the 
rte_eth_ctrl.h file.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 
---
 lib/librte_ether/rte_eth_ctrl.h |   64 +++
 lib/librte_ether/rte_ethdev.h   |   12 ---
 2 files changed, 64 insertions(+), 12 deletions(-)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index df21ac6..a04333c 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -51,6 +51,7 @@ extern "C" {
  */
 enum rte_filter_type {
RTE_ETH_FILTER_NONE = 0,
+   RTE_ETH_FILTER_TUNNEL,
RTE_ETH_FILTER_MAX
 };

@@ -71,6 +72,69 @@ enum rte_filter_op {
RTE_ETH_FILTER_OP_MAX
 };

+/**
+ * filter type of tunneling packet
+ */
+#define ETH_TUNNEL_FILTER_OMAC  0x01 /**< filter by outer MAC addr */
+#define ETH_TUNNEL_FILTER_OIP   0x02 /**< filter by outer IP Addr */
+#define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */
+#define ETH_TUNNEL_FILTER_IMAC  0x08 /**< filter by inner MAC addr */
+#define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */
+#define ETH_TUNNEL_FILTER_IIP   0x20 /**< filter by inner IP addr */
+
+#define RTE_TUNNEL_FILTER_TO_QUEUE 1 /**< point to an queue by filter type */
+
+#define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \
+   ETH_TUNNEL_FILTER_IVLAN)
+#define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \
+   ETH_TUNNEL_FILTER_IVLAN | \
+   ETH_TUNNEL_FILTER_TENID)
+#define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \
+   ETH_TUNNEL_FILTER_TENID)
+#define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \
+   ETH_TUNNEL_FILTER_TENID | \
+   ETH_TUNNEL_FILTER_IMAC)
+
+/**
+ *  Select IPv4 or IPv6 for tunnel filters.
+ */
+enum rte_tunnel_iptype {
+   RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */
+   RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */
+};
+
+/**
+ * Tunneled type.
+ */
+enum rte_eth_tunnel_type {
+   RTE_TUNNEL_TYPE_NONE = 0,
+   RTE_TUNNEL_TYPE_VXLAN,
+   RTE_TUNNEL_TYPE_GENEVE,
+   RTE_TUNNEL_TYPE_TEREDO,
+   RTE_TUNNEL_TYPE_NVGRE,
+   RTE_TUNNEL_TYPE_MAX,
+};
+
+/**
+ * Tunneling Packet filter configuration.
+ */
+struct rte_eth_tunnel_filter_conf {
+   struct ether_addr *outer_mac;  /**< Outer MAC address filter. */
+   struct ether_addr *inner_mac;  /**< Inner MAC address filter. */
+   uint16_t inner_vlan;   /**< Inner VLAN filter. */
+   enum rte_tunnel_iptype ip_type; /**< IP address type. */
+   union {
+   uint32_t ipv4_addr;/**< IPv4 source address to match. */
+   uint32_t ipv6_addr[4]; /**< IPv6 source address to match. */
+   } ip_addr; /**< IPv4/IPv6 source address to match (union of above). */
+
+   uint16_t filter_type;   /**< Filter type. */
+   uint8_t to_queue;   /**< Use MAC and VLAN to point to a queue. */
+   enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */
+   uint32_t tenant_id; /** < Tenant number. */
+   uint16_t queue_id;  /** < queue number. */
+};
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9ad11ec..c8fb89a 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -718,18 +718,6 @@ struct rte_eth_udp_tunnel {
 };

 /**
- * Tunneled type.
- */
-enum rte_eth_tunnel_type {
-   RTE_TUNNEL_TYPE_NONE = 0,
-   RTE_TUNNEL_TYPE_VXLAN,
-   RTE_TUNNEL_TYPE_GENEVE,
-   RTE_TUNNEL_TYPE_TEREDO,
-   RTE_TUNNEL_TYPE_NVGRE,
-   RTE_TUNNEL_TYPE_MAX,
-};
-
-/**
  *  Possible l4type of FDIR filters.
  */
 enum rte_l4type {
-- 
1.7.7.6



[dpdk-dev] [PATCH v6 4/9] app/test-pmd:test VxLAN packet identification

2014-10-21 Thread Jijiang Liu
Add two commands to test VxLAN packet identification, which include
 - use commands to add/delete VxLAN UDP port.
 - use rxonly mode to receive VxLAN packet.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 
---
 app/test-pmd/cmdline.c|   65 +
 app/test-pmd/parameters.c |   13 +
 app/test-pmd/rxonly.c |   49 ++
 app/test-pmd/testpmd.c|8 +
 app/test-pmd/testpmd.h|4 +++
 5 files changed, 139 insertions(+), 0 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0b972f9..7160e38 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -285,6 +285,12 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"

+   "rx_vxlan_port add (udp_port) (port_id)\n"
+   "Add an UDP port for VxLAN packet filter on a 
port\n\n"
+
+   "rx_vxlan_port rm (udp_port) (port_id)\n"
+   "Remove an UDP port for VxLAN packet filter on a 
port\n\n"
+
"tx_vlan set vlan_id (port_id)\n"
"Set hardware insertion of VLAN ID in packets sent"
" on a port.\n\n"
@@ -6225,6 +6231,64 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
},
 };

+/* *** CONFIGURE TUNNEL UDP PORT *** */
+struct cmd_tunnel_udp_config {
+   cmdline_fixed_string_t cmd;
+   cmdline_fixed_string_t what;
+   uint16_t udp_port;
+   uint8_t port_id;
+};
+
+static void
+cmd_tunnel_udp_config_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+   struct cmd_tunnel_udp_config *res = parsed_result;
+   struct rte_eth_udp_tunnel tunnel_udp;
+   int ret;
+
+   tunnel_udp.udp_port = res->udp_port;
+
+   if (!strcmp(res->cmd, "rx_vxlan_port"))
+   tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
+
+   if (!strcmp(res->what, "add"))
+   ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp, 1);
+   else
+   ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp, 
1);
+
+   if (ret < 0)
+   printf("udp tunneling add error: (%s)\n", strerror(-ret));
+}
+
+cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
+   TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
+   cmd, "rx_vxlan_port");
+cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
+   TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
+   what, "add#rm");
+cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
+   TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
+   udp_port, UINT16);
+cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
+   port_id, UINT8);
+
+cmdline_parse_inst_t cmd_tunnel_udp_config = {
+   .f = cmd_tunnel_udp_config_parsed,
+   .data = (void *)0,
+   .help_str = "add/rm an tunneling UDP port filter: "
+   "rx_vxlan_port add udp_port port_id",
+   .tokens = {
+   (void *)&cmd_tunnel_udp_config_cmd,
+   (void *)&cmd_tunnel_udp_config_what,
+   (void *)&cmd_tunnel_udp_config_udp_port,
+   (void *)&cmd_tunnel_udp_config_port_id,
+   NULL,
+   },
+};
+
 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
 struct cmd_set_mirror_mask_result {
cmdline_fixed_string_t set;
@@ -7518,6 +7582,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
+   (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
(cmdline_parse_inst_t *)&cmd_set_mirror_link,
(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 9573a43..fda8c1d 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -202,6 +202,10 @@ usage(char* progname)
printf("  --txpkts=X[,Y]*: set TX segment sizes.\n");
printf("  --disable-link-check: disable check on link status when "
   "starting/stopping ports.\n");
+   printf("  --tunnel-type=N: set tunneling packe

[dpdk-dev] [PATCH v6 3/9] i40e:support VxLAN packet identification in librte_pmd_i40e

2014-10-21 Thread Jijiang Liu
Implement configuration of VxLAN destination UDP port number in librte_pmd_i40e.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |  164 +
 lib/librte_pmd_i40e/i40e_ethdev.h |8 ++-
 lib/librte_pmd_i40e/i40e_rxtx.c   |9 ++
 3 files changed, 180 insertions(+), 1 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 3b75f0f..8a84e30 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -186,6 +186,12 @@ static int i40e_dev_rss_hash_update(struct rte_eth_dev 
*dev,
struct rte_eth_rss_conf *rss_conf);
 static int i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
  struct rte_eth_rss_conf *rss_conf);
+static int i40e_dev_udp_tunnel_add(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *udp_tunnel,
+   uint8_t count);
+static int i40e_dev_udp_tunnel_del(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *udp_tunnel,
+   uint8_t count);
 static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_type filter_type,
enum rte_filter_op filter_op,
@@ -241,6 +247,8 @@ static struct eth_dev_ops i40e_eth_dev_ops = {
.reta_query   = i40e_dev_rss_reta_query,
.rss_hash_update  = i40e_dev_rss_hash_update,
.rss_hash_conf_get= i40e_dev_rss_hash_conf_get,
+   .udp_tunnel_add   = i40e_dev_udp_tunnel_add,
+   .udp_tunnel_del   = i40e_dev_udp_tunnel_del,
.filter_ctrl  = i40e_dev_filter_ctrl,
 };

@@ -3178,6 +3186,10 @@ i40e_vsi_rx_init(struct i40e_vsi *vsi)
uint16_t i;

i40e_pf_config_mq_rx(pf);
+
+   if (data->dev_conf.tunnel_type == RTE_TUNNEL_TYPE_VXLAN)
+   pf->flags |= I40E_FLAG_VXLAN;
+
for (i = 0; i < data->nb_rx_queues; i++) {
ret = i40e_rx_queue_init(data->rx_queues[i]);
if (ret != I40E_SUCCESS) {
@@ -4092,6 +4104,158 @@ i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
return 0;
 }

+static int
+i40e_get_vxlan_port_idx(struct i40e_pf *pf, uint16_t port)
+{
+   uint8_t i;
+
+   for (i = 0; i < I40E_MAX_PF_UDP_OFFLOAD_PORTS; i++) {
+   if (pf->vxlan_ports[i] == port)
+   return i;
+   }
+
+   return -1;
+}
+
+static int
+i40e_add_vxlan_port(struct i40e_pf *pf, uint16_t port)
+{
+   int  idx, ret;
+   uint8_t filter_idx;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+
+   if (!(pf->flags & I40E_FLAG_VXLAN)) {
+   PMD_DRV_LOG(ERR, "VxLAN tunneling mode is not configured\n");
+   return -EINVAL;
+   }
+
+   idx = i40e_get_vxlan_port_idx(pf, port);
+
+   /* Check if port already exists */
+   if (idx >= 0) {
+   PMD_DRV_LOG(ERR, "Port %d already offloaded\n", port);
+   return -EINVAL;
+   }
+
+   /* Now check if there is space to add the new port */
+   idx = i40e_get_vxlan_port_idx(pf, 0);
+   if (idx < 0) {
+   PMD_DRV_LOG(ERR, "Maximum number of UDP ports reached,"
+   "not adding port %d\n", port);
+   return -ENOSPC;
+   }
+
+   ret =  i40e_aq_add_udp_tunnel(hw, port, I40E_AQC_TUNNEL_TYPE_VXLAN,
+   &filter_idx, NULL);
+   if (ret < 0) {
+   PMD_DRV_LOG(ERR, "Failed to add VxLAN UDP port %d\n", port);
+   return -1;
+   }
+
+   PMD_DRV_LOG(INFO, "Added %s port %d with AQ command with index %d\n",
+port,  filter_index);
+
+   /* New port: add it and mark its index in the bitmap */
+   pf->vxlan_ports[idx] = port;
+   pf->vxlan_bitmap |= (1 << idx);
+
+   return 0;
+}
+
+static int
+i40e_del_vxlan_port(struct i40e_pf *pf, uint16_t port)
+{
+   int idx;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+
+   if (!(pf->flags & I40E_FLAG_VXLAN)) {
+   PMD_DRV_LOG(ERR, "VxLAN tunneling mode is not configured\n");
+   return -EINVAL;
+   }
+
+   idx = i40e_get_vxlan_port_idx(pf, port);
+
+   if (idx < 0) {
+   PMD_DRV_LOG(ERR, "Port %d doesn't exist\n", port);
+   return -EINVAL;
+   }
+
+   if (i40e_aq_del_udp_tunnel(hw, idx, NULL) < 0) {
+   PMD_DRV_LOG(ERR, "Failed to delete VxLAN UDP port %d\n", port);
+   return -1;
+   }
+
+   PMD_DRV_LOG(INFO, "Deleted port %d with AQ comma

[dpdk-dev] [PATCH v6 2/9] librte_ether:add VxLAN packet identification API in librte_ether

2014-10-21 Thread Jijiang Liu
There are "some" destination UDP port numbers that have unque meaning.
In terms of VxLAN, "IANA has assigned the value 4789 for the VXLAN UDP port, 
and this value
SHOULD be used by default as the destination UDP port. Some early 
implementations of VXLAN
have used other values for the destination port. To enable interoperability 
with these 
implementations, the destination port SHOULD be configurable."

Add two APIs in librte_ether for supporting UDP tunneling port configuration on 
i40e.
Currently, only VxLAN is implemented in this patch set.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 
---
 lib/librte_ether/rte_ethdev.c |   63 ++
 lib/librte_ether/rte_ethdev.h |   75 +
 lib/librte_ether/rte_ether.h  |8 
 3 files changed, 146 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 50f10d9..9e111b6 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2038,6 +2038,69 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
 }

 int
+rte_eth_dev_udp_tunnel_add(uint8_t port_id,
+  struct rte_eth_udp_tunnel *udp_tunnel,
+  uint8_t count)
+{
+   uint8_t i;
+   struct rte_eth_dev *dev;
+   struct rte_eth_udp_tunnel *tunnel;
+
+   if (port_id >= nb_ports) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   if (udp_tunnel == NULL) {
+   PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+   return -EINVAL;
+   }
+   tunnel = udp_tunnel;
+
+   for (i = 0; i < count; i++, tunnel++) {
+   if (tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+   PMD_DEBUG_TRACE("Invalid tunnel type\n");
+   return -EINVAL;
+   }
+   }
+
+   dev = &rte_eth_devices[port_id];
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
+   return (*dev->dev_ops->udp_tunnel_add)(dev, udp_tunnel, count);
+}
+
+int
+rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
+ struct rte_eth_udp_tunnel *udp_tunnel,
+ uint8_t count)
+{
+   uint8_t i;
+   struct rte_eth_dev *dev;
+   struct rte_eth_udp_tunnel *tunnel;
+
+   if (port_id >= nb_ports) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+   dev = &rte_eth_devices[port_id];
+
+   if (udp_tunnel == NULL) {
+   PMD_DEBUG_TRACE("Invalid udp_tunnel parametr\n");
+   return -EINVAL;
+   }
+   tunnel = udp_tunnel;
+   for (i = 0; i < count; i++, tunnel++) {
+   if (tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+   PMD_DEBUG_TRACE("Invalid tunnel type\n");
+   return -EINVAL;
+   }
+   }
+
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
+   return (*dev->dev_ops->udp_tunnel_del)(dev, udp_tunnel, count);
+}
+
+int
 rte_eth_led_on(uint8_t port_id)
 {
struct rte_eth_dev *dev;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b69a6af..9ad11ec 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -710,6 +710,26 @@ struct rte_fdir_conf {
 };

 /**
+ * UDP tunneling configuration.
+ */
+struct rte_eth_udp_tunnel {
+   uint16_t udp_port;
+   uint8_t prot_type;
+};
+
+/**
+ * Tunneled type.
+ */
+enum rte_eth_tunnel_type {
+   RTE_TUNNEL_TYPE_NONE = 0,
+   RTE_TUNNEL_TYPE_VXLAN,
+   RTE_TUNNEL_TYPE_GENEVE,
+   RTE_TUNNEL_TYPE_TEREDO,
+   RTE_TUNNEL_TYPE_NVGRE,
+   RTE_TUNNEL_TYPE_MAX,
+};
+
+/**
  *  Possible l4type of FDIR filters.
  */
 enum rte_l4type {
@@ -831,6 +851,7 @@ struct rte_intr_conf {
  * configuration settings may be needed.
  */
 struct rte_eth_conf {
+   enum rte_eth_tunnel_type tunnel_type;
uint16_t link_speed;
/**< ETH_LINK_SPEED_10[0|00|000], or 0 for autonegotation */
uint16_t link_duplex;
@@ -1266,6 +1287,17 @@ typedef int (*eth_mirror_rule_reset_t)(struct 
rte_eth_dev *dev,
  uint8_t rule_id);
 /**< @internal Remove a traffic mirroring rule on an Ethernet device */

+typedef int (*eth_udp_tunnel_add_t)(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *tunnel_udp,
+   uint8_t count);
+/**< @internal Add tunneling UDP info */
+
+typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *tunnel_udp,
+   

[dpdk-dev] [PATCH v6 1/9] librte_mbuf:the rte_mbuf structure changes

2014-10-21 Thread Jijiang Liu
Remove the "reserved2" field and add the "packet_type" and the 
"inner_l2_l3_len" fields in the rte_mbuf structure.

The packet type field is used to indicate ordinary L2 packet format and also 
tunneling packet format such as IP in IP,
IP in GRE, MAC in GRE and MAC in UDP.

The inner L2 length and the inner L3 length are used for TX offloading of 
tunneling packet.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
---
 lib/librte_mbuf/rte_mbuf.h |   25 -
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ddadc21..98951a6 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -163,7 +163,14 @@ struct rte_mbuf {

/* remaining bytes are set on RX when pulling packet from descriptor */
MARKER rx_descriptor_fields1;
-   uint16_t reserved2;   /**< Unused field. Required for padding */
+
+   /**
+* Packet type, which is used to indicate ordinary L2 packet format and
+* also tunneled packet format such as IP in IP, IP in GRE, MAC in GRE
+* and MAC in UDP.
+*/
+   uint16_t packet_type;
+
uint16_t data_len;/**< Amount of data in segment buffer. */
uint32_t pkt_len; /**< Total pkt len: sum of all segments. */
uint16_t vlan_tci;/**< VLAN Tag Control Identifier (CPU order) 
*/
@@ -196,6 +203,18 @@ struct rte_mbuf {
uint16_t l2_len:7;  /**< L2 (MAC) Header Length. */
};
};
+
+   /* fields for TX offloading of tunnels */
+   union {
+   uint16_t inner_l2_l3_len;
+   /**< combined inner l2/l3 lengths as single var */
+   struct {
+   uint16_t inner_l3_len:9;
+   /**< inner L3 (IP) Header Length. */
+   uint16_t inner_l2_len:7;
+   /**< inner L2 (MAC) Header Length. */
+   };
+   };
 } __rte_cache_aligned;

 /**
@@ -546,11 +565,13 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)
m->next = NULL;
m->pkt_len = 0;
m->l2_l3_len = 0;
+   m->inner_l2_l3_len = 0;
m->vlan_tci = 0;
m->nb_segs = 1;
m->port = 0xff;

m->ol_flags = 0;
+   m->packet_type = 0;
m->data_off = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ?
RTE_PKTMBUF_HEADROOM : m->buf_len;

@@ -614,12 +635,14 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf 
*mi, struct rte_mbuf *md)
mi->port = md->port;
mi->vlan_tci = md->vlan_tci;
mi->l2_l3_len = md->l2_l3_len;
+   mi->inner_l2_l3_len = md->inner_l2_l3_len;
mi->hash = md->hash;

mi->next = NULL;
mi->pkt_len = mi->data_len;
mi->nb_segs = 1;
mi->ol_flags = md->ol_flags;
+   mi->packet_type = md->packet_type;

__rte_mbuf_sanity_check(mi, 1);
__rte_mbuf_sanity_check(md, 0);
-- 
1.7.7.6



[dpdk-dev] [PATCH v6 0/9] Support VxLAN on Fortville

2014-10-21 Thread Jijiang Liu
The patch set supports VxLAN on Fortville based on latest rte_mbuf structure.

It includes:
 - Support VxLAN packet identification by configuring UDP tunneling port.
 - Support VxLAN packet filters. It uses MAC and VLAN to point
   to a queue. The filter types supported are listed below:
   1. Inner MAC and Inner VLAN ID
   2. Inner MAC address, inner VLAN ID and tenant ID.
   3. Inner MAC and tenant ID
   4. Inner MAC address
   5. Outer MAC address, tenant ID and inner MAC
 - Support VxLAN TX checksum offload, which include outer L3(IP), inner L3(IP) 
and inner L4(UDP,TCP and SCTP)

Change notes:

 v6)  * Split the rte_mbuf structure changes as a seperate patch.
  * Remove the initialization configuration of VXLAN UDP port.
  * Change the filter_type field in rte_eth_tunnel_filter_conf to 
"uint16_t" type. 
  * Add more descriptions about some API comments and commit logs.


Jijiang Liu (9):
  rte_mbuf structure changes
  add VxLAN packet identification API in librte_ether
  support VxLAN packet identification in librte_pmd_i40e
  test VxLAN packet identification in testpmd.
  add data structures of tunneling filter in rte_eth_ctrl.h
  implement the API of VxLAN packet filter in librte_pmd_i40e
  test VxLAN packet filter
  support VxLAN Tx checksum offload
  test VxLAN Tx checksum offload

 app/test-pmd/cmdline.c|  230 -
 app/test-pmd/config.c |6 +-
 app/test-pmd/csumonly.c   |  195 +++--
 app/test-pmd/parameters.c |   13 ++
 app/test-pmd/rxonly.c |   49 ++
 app/test-pmd/testpmd.c|8 +
 app/test-pmd/testpmd.h|4 +
 lib/librte_ether/rte_eth_ctrl.h   |   64 +++
 lib/librte_ether/rte_ethdev.c |   63 +++
 lib/librte_ether/rte_ethdev.h |   63 +++
 lib/librte_ether/rte_ether.h  |8 +
 lib/librte_mbuf/rte_mbuf.h|   26 +++-
 lib/librte_pmd_i40e/i40e_ethdev.c |  341 -
 lib/librte_pmd_i40e/i40e_ethdev.h |8 +-
 lib/librte_pmd_i40e/i40e_rxtx.c   |   55 ++-
 15 files changed, 1101 insertions(+), 32 deletions(-)

-- 
1.7.7.6



[dpdk-dev] [PATCH] Add Rx error statistics for Fortville

2014-10-15 Thread Jijiang Liu
This patch adds incoming packet error statistics in the i40e_ethdev.c file.

Signed-off-by: Jijiang Liu 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 46c43a7..dbf231f 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1274,6 +1274,9 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)

pf->offset_loaded = true;

+   if (pf->main_vsi)
+   i40e_update_vsi_stats(pf->main_vsi);
+
stats->ipackets = ns->eth.rx_unicast + ns->eth.rx_multicast +
ns->eth.rx_broadcast;
stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
@@ -1283,8 +1286,12 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
stats->oerrors  = ns->eth.tx_errors;
stats->imcasts  = ns->eth.rx_multicast;

-   if (pf->main_vsi)
-   i40e_update_vsi_stats(pf->main_vsi);
+   /* Rx Errors */
+   stats->ibadcrc  = ns->crc_errors;
+   stats->ibadlen  = ns->rx_length_errors + ns->rx_undersize +
+   ns->rx_oversize + ns->rx_fragments + ns->rx_jabber;
+   stats->imissed  = ns->eth.rx_discards;
+   stats->ierrors  = stats->ibadcrc + stats->ibadlen + stats->imissed;

PMD_DRV_LOG(DEBUG, "* PF stats start 
***");
PMD_DRV_LOG(DEBUG, "rx_bytes:%lu", ns->eth.rx_bytes);
-- 
1.7.7.6



[dpdk-dev] [PATCH v5 8/8]app/testpmd:test VxLAN Tx checksum offload

2014-10-11 Thread Jijiang Liu
Add test cases in testpmd to test VxLAN Tx Checksum offload, which include
 - IPv4 tunnel and IPv6 tunnel
 - outer L3, inner L3 and L4 checksum offload for Tx side.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 
---
 app/test-pmd/config.c   |6 +-
 app/test-pmd/csumonly.c |  195 +++
 2 files changed, 183 insertions(+), 18 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 2a1b93f..9bc08f4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1753,9 +1753,9 @@ tx_cksum_set(portid_t port_id, uint64_t ol_flags)
uint64_t tx_ol_flags;
if (port_id_is_invalid(port_id))
return;
-   /* Clear last 4 bits and then set L3/4 checksum mask again */
-   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0Full);
-   ports[port_id].tx_ol_flags = ((ol_flags & 0xf) | tx_ol_flags);
+   /* Clear last 8 bits and then set L3/4 checksum mask again */
+   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0FFull);
+   ports[port_id].tx_ol_flags = ((ol_flags & 0xff) | tx_ol_flags);
 }

 void
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index fcc4876..e2ac129 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -196,7 +196,6 @@ get_ipv6_udptcp_checksum(struct ipv6_hdr *ipv6_hdr, 
uint16_t *l4_hdr)
return (uint16_t)cksum;
 }

-
 /*
  * Forwarding of packets. Change the checksum field with HW or SW methods
  * The HW/SW method selection depends on the ol_flags on every packet
@@ -209,10 +208,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
struct rte_mbuf  *mb;
struct ether_hdr *eth_hdr;
struct ipv4_hdr  *ipv4_hdr;
+   struct ether_hdr *inner_eth_hdr;
+   struct ipv4_hdr  *inner_ipv4_hdr = NULL;
struct ipv6_hdr  *ipv6_hdr;
+   struct ipv6_hdr  *inner_ipv6_hdr = NULL;
struct udp_hdr   *udp_hdr;
+   struct udp_hdr   *inner_udp_hdr;
struct tcp_hdr   *tcp_hdr;
+   struct tcp_hdr   *inner_tcp_hdr;
struct sctp_hdr  *sctp_hdr;
+   struct sctp_hdr  *inner_sctp_hdr;

uint16_t nb_rx;
uint16_t nb_tx;
@@ -221,12 +226,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint64_t pkt_ol_flags;
uint64_t tx_ol_flags;
uint16_t l4_proto;
+   uint16_t inner_l4_proto = 0;
uint16_t eth_type;
uint8_t  l2_len;
uint8_t  l3_len;
+   uint8_t  inner_l2_len = 0;
+   uint8_t  inner_l3_len = 0;

uint32_t rx_bad_ip_csum;
uint32_t rx_bad_l4_csum;
+   uint8_t  ipv4_tunnel;
+   uint8_t  ipv6_tunnel;
+   uint16_t ptype;

 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
uint64_t start_tsc;
@@ -262,7 +273,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
l2_len  = sizeof(struct ether_hdr);
pkt_ol_flags = mb->ol_flags;
ol_flags = (pkt_ol_flags & (~PKT_TX_L4_MASK));
-
+   ptype = mb->packet_type;
+   ipv4_tunnel = IS_ETH_IPV4_TUNNEL(ptype);
+   ipv6_tunnel = IS_ETH_IPV6_TUNNEL(ptype);
eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
eth_type = rte_be_to_cpu_16(eth_hdr->ether_type);
if (eth_type == ETHER_TYPE_VLAN) {
@@ -295,7 +308,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 *  + ipv4 or ipv6
 *  + udp or tcp or sctp or others
 */
-   if (pkt_ol_flags & PKT_RX_IPV4_HDR) {
+   if (pkt_ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_IPV4_HDR_EXT)) {

/* Do not support ipv4 option field */
l3_len = sizeof(struct ipv4_hdr) ;
@@ -325,17 +338,92 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
if (tx_ol_flags & 0x2) {
/* HW Offload */
ol_flags |= PKT_TX_UDP_CKSUM;
-   /* Pseudo header sum need be set 
properly */
-   udp_hdr->dgram_cksum = 
get_ipv4_psd_sum(ipv4_hdr);
+   if (ipv4_tunnel)
+   udp_hdr->dgram_cksum = 0;
+   else
+   /* Pseudo header sum need be 
set properly */
+   udp_hdr->dgram_cksum =
+   
get_ipv4_psd_sum(ipv4_hdr);
}
else {
/* SW Implementation, clear checksum 
field first */
udp_hdr->dgram_cksum = 0;
udp_

[dpdk-dev] [PATCH v5 7/8]i40e:support VxLAN Tx checksum offload

2014-10-11 Thread Jijiang Liu
Support VxLAN Tx checksum offload, which include
  - outer L3(IP) checksum offload
  - inner L3(IP) checksum offload
  - inner L4(UDP, TCP and SCTP) checksum offload

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 lib/librte_mbuf/rte_mbuf.h  |   17 ++
 lib/librte_pmd_i40e/i40e_rxtx.c |   46 +-
 2 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 0984650..6290f16 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -94,6 +94,7 @@ extern "C" {

 #define PKT_TX_VLAN_PKT  (1ULL << 55) /**< TX packet is a 802.1q VLAN 
packet. */
 #define PKT_TX_IP_CKSUM  (1ULL << 54) /**< IP cksum of TX pkt. computed by 
NIC. */
+#define PKT_TX_VXLAN_CKSUM   (1ULL << 50) /**< TX checksum of VxLAN computed 
by NIC */
 #define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */
 #define PKT_TX_IPV4  PKT_RX_IPV4_HDR /**< IPv4 with no IP checksum 
offload. */
 #define PKT_TX_IPV6  PKT_RX_IPV6_HDR /**< IPv6 packet */
@@ -196,6 +197,20 @@ struct rte_mbuf {
uint16_t l2_len:7;  /**< L2 (MAC) Header Length. */
};
};
+
+   /* fields to support tunnelling packet TX offloads */
+   union {
+   /**< combined inner l2/l3 lengths as single var */
+   uint16_t inner_l2_l3_len;
+
+   struct {
+   /**< inner L3 (IP) Header Length. */
+   uint16_t inner_l3_len:9;
+
+   /**< L2 (MAC) Header Length. */
+   uint16_t inner_l2_len:7;
+   };
+   };
 } __rte_cache_aligned;

 /**
@@ -546,6 +561,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)
m->next = NULL;
m->pkt_len = 0;
m->l2_l3_len = 0;
+   m->inner_l2_l3_len = 0;
m->vlan_tci = 0;
m->nb_segs = 1;
m->port = 0xff;
@@ -615,6 +631,7 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, 
struct rte_mbuf *md)
mi->port = md->port;
mi->vlan_tci = md->vlan_tci;
mi->l2_l3_len = md->l2_l3_len;
+   mi->inner_l2_l3_len = md->inner_l2_l3_len;
mi->hash = md->hash;

mi->next = NULL;
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index 369bc3b..7a880bb 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -411,11 +411,14 @@ i40e_rxd_ptype_to_pkt_flags(uint64_t qword)
 }

 static inline void
-i40e_txd_enable_checksum(uint32_t ol_flags,
+i40e_txd_enable_checksum(uint64_t ol_flags,
uint32_t *td_cmd,
uint32_t *td_offset,
uint8_t l2_len,
-   uint8_t l3_len)
+   uint16_t l3_len,
+   uint8_t inner_l2_len,
+   uint16_t inner_l3_len,
+   uint32_t *cd_tunneling)
 {
if (!l2_len) {
PMD_DRV_LOG(DEBUG, "L2 length set to 0");
@@ -428,6 +431,27 @@ i40e_txd_enable_checksum(uint32_t ol_flags,
return;
}

+   /* VxLAN packet TX checksum offload */
+   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
+   uint8_t l4tun_len;
+
+   l4tun_len = ETHER_VXLAN_HLEN + inner_l2_len;
+
+   if (ol_flags & PKT_TX_IPV4_CSUM)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
+   else if (ol_flags & PKT_TX_IPV6)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;
+
+   /* Now set the ctx descriptor fields */
+   *cd_tunneling |= (l3_len >> 2) <<
+   I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
+   I40E_TXD_CTX_UDP_TUNNELING |
+   (l4tun_len >> 1) <<
+   I40E_TXD_CTX_QW0_NATLEN_SHIFT;
+
+   l3_len = inner_l3_len;
+   }
+
/* Enable L3 checksum offloads */
if (ol_flags & PKT_TX_IPV4_CSUM) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
@@ -1077,7 +1101,10 @@ i40e_recv_scattered_pkts(void *rx_queue,
 static inline uint16_t
 i40e_calc_context_desc(uint64_t flags)
 {
-   uint16_t mask = 0;
+   uint64_t mask = 0ULL;
+
+   if (flags | PKT_TX_VXLAN_CKSUM)
+   mask |= PKT_TX_VXLAN_CKSUM;

 #ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
@@ -1098,6 +1125,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
volatile struct i40e_tx_desc *txr;
struct rte_mbuf *tx_pkt;
struct rte_mbuf *m_seg;
+   uint32_t cd_tunneling_params;

[dpdk-dev] [PATCH v5 6/8]app/testpmd:test VxLAN packet filter API

2014-10-11 Thread Jijiang Liu
Add tunnel_filter command in testpmd to test VxLAN packet filter API.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 app/test-pmd/cmdline.c |  152 
 1 files changed, 152 insertions(+), 0 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index c0b7293..a74e9dc 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -285,6 +285,14 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"

+   "tunnel_filter add (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   add a tunnel filter of a port.\n\n"
+
+   "tunnel_filter rm (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   remove a tunnel filter of a port.\n\n"
+
"rx_vxlan_port add (udp_port) (port_id)\n"
"Add an UDP port for VxLAN packet filter on a 
port\n\n"

@@ -6232,6 +6240,149 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
},
 };

+/* *** ADD TUNNEL FILTER OF A PORT *** */
+struct cmd_tunnel_filter_result {
+   cmdline_fixed_string_t cmd;
+   cmdline_fixed_string_t what;
+   uint8_t port_id;
+   struct ether_addr outer_mac;
+   struct ether_addr inner_mac;
+   cmdline_ipaddr_t ip_value;
+   uint16_t inner_vlan;
+   cmdline_fixed_string_t tunnel_type;
+   cmdline_fixed_string_t filter_type;
+   uint32_t tenant_id;
+   uint16_t queue_num;
+};
+
+static void
+cmd_tunnel_filter_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+   struct cmd_tunnel_filter_result *res = parsed_result;
+   struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
+   int ret = 0;
+
+   tunnel_filter_conf.outer_mac = &res->outer_mac;
+   tunnel_filter_conf.inner_mac = &res->inner_mac;
+   tunnel_filter_conf.inner_vlan = res->inner_vlan;
+
+   if (res->ip_value.family == AF_INET) {
+   tunnel_filter_conf.ip_addr.ipv4_addr =
+   res->ip_value.addr.ipv4.s_addr;
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
+   } else {
+   memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
+   &(res->ip_value.addr.ipv6),
+   sizeof(struct in6_addr));
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
+   }
+
+   if (!strcmp(res->filter_type, "imac-ivlan"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
+   else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
+   else if (!strcmp(res->filter_type, "imac-tenid"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
+   else if (!strcmp(res->filter_type, "imac"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC;
+   else if (!strcmp(res->filter_type, "omac-imac-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
+   else {
+   printf("The filter type is not supported");
+   return;
+   }
+
+   tunnel_filter_conf.to_queue = RTE_TUNNEL_FLAGS_TO_QUEUE;
+
+   if (!strcmp(res->tunnel_type, "vxlan"))
+   tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+   else {
+   printf("Only VxLAN is supported now.\n");
+   return;
+   }
+
+   tunnel_filter_conf.tenant_id = res->tenant_id;
+   tunnel_filter_conf.queue_id = res->queue_num;
+   if (!strcmp(res->what, "add"))
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_OP_ADD,
+   &tunnel_filter_conf);
+   else
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_OP_DELETE,
+   &tunnel_filter_conf);
+   if (ret < 0)
+   printf("cmd_tunnel_filter_parsed 

[dpdk-dev] [PATCH v5 5/8]i40e:implement API of VxLAN packet filter in librte_pmd_i40e

2014-10-11 Thread Jijiang Liu
The implementation of VxLAN tunnel filter in librte_pmd_i40e, which include
 - add the i40e_dev_filter_ctrl() function.
 - add the i40e_dev_tunnel_filter_set() function.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 lib/librte_pmd_i40e/i40e_ethdev.c |  221 -
 1 files changed, 220 insertions(+), 1 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index ed5938c..f8160eb 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "i40e_logs.h"
 #include "i40e/i40e_register_x710_int.h"
@@ -211,8 +212,15 @@ static int i40e_dev_udp_tunnel_add(struct rte_eth_dev *dev,
 static int i40e_dev_udp_tunnel_del(struct rte_eth_dev *dev,
   struct rte_eth_udp_tunnel *udp_tunnel,
   uint8_t count);
+static int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
+struct rte_eth_tunnel_filter_conf *tunnel_filter,
+uint8_t add);
 static int i40e_pf_config_vxlan(struct i40e_pf *pf);
-
+static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
+  enum rte_filter_type filter_type,
+  enum rte_filter_op filter_op,
+  void *arg);
+static void i40e_hw_init(struct i40e_hw *hw);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_PFQF_HKEY_MAX_INDEX + 1];
@@ -266,6 +274,7 @@ static struct eth_dev_ops i40e_eth_dev_ops = {
.rss_hash_conf_get= i40e_dev_rss_hash_conf_get,
.udp_tunnel_add   = i40e_dev_udp_tunnel_add,
.udp_tunnel_del   = i40e_dev_udp_tunnel_del,
+   .filter_ctrl  = i40e_dev_filter_ctrl,
 };

 static struct eth_driver rte_i40e_pmd = {
@@ -395,6 +404,9 @@ eth_i40e_dev_init(__rte_unused struct eth_driver *eth_drv,
/* Make sure all is clean before doing PF reset */
i40e_clear_hw(hw);

+   /* Initialize the hardware */
+   i40e_hw_init(hw);
+
/* Reset here to make sure all is clean for each PF */
ret = i40e_pf_reset(hw);
if (ret) {
@@ -4122,6 +4134,110 @@ i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 }

 static int
+i40e_dev_get_filter_type(enum rte_tunnel_filter_type filter_type,
+   uint16_t *flag)
+{
+   switch (filter_type) {
+   case RTE_TUNNEL_FILTER_IMAC_IVLAN:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN;
+   break;
+   case RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN_TEN_ID;
+   break;
+   case RTE_TUNNEL_FILTER_IMAC_TENID:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC_TEN_ID;
+   break;
+   case RTE_TUNNEL_FILTER_OMAC_TENID_IMAC:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_OMAC_TEN_ID_IMAC;
+   break;
+   case RTE_TUNNEL_FILTER_IMAC:
+   *flag = I40E_AQC_ADD_CLOUD_FILTER_IMAC;
+   break;
+   default:
+   PMD_DRV_LOG(ERR, "invalid tunnel filter type\n");
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static int
+i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
+   struct rte_eth_tunnel_filter_conf *tunnel_filter,
+   uint8_t add)
+{
+   uint16_t ip_type;
+   uint8_t tun_type = 0;
+   int ret = 0;
+   int val;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+   struct i40e_vsi *vsi = pf->main_vsi;
+   struct i40e_aqc_add_remove_cloud_filters_element_data  *cld_filter;
+   struct i40e_aqc_add_remove_cloud_filters_element_data  *pfilter;
+
+   cld_filter = rte_zmalloc("tunnel_filter",
+   sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data),
+   0);
+
+   if (NULL == cld_filter) {
+   PMD_DRV_LOG(ERR, "Failed to alloc memory.\n");
+   return -EINVAL;
+   }
+   pfilter = cld_filter;
+
+   (void)rte_memcpy(&pfilter->outer_mac, tunnel_filter->outer_mac,
+   sizeof(struct ether_addr));
+   (void)rte_memcpy(&pfilter->inner_mac, tunnel_filter->inner_mac,
+   sizeof(struct ether_addr));
+
+   pfilter->inner_vlan = tunnel_filter->inner_vlan;
+   if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
+   ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
+   (void)rte_memcpy(&pfilter->ipaddr.v4.data,
+   &tunnel_filter->ip_addr,
+   sizeof(pfilter->ipaddr.v4.data));
+   } else {
+   ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
+ 

[dpdk-dev] [PATCH v5 4/8]librte_ether:add a common filter API

2014-10-11 Thread Jijiang Liu
Introduce a new filter framewok in librte_ether. As to the implemetation 
discussion, please refer to
http://dpdk.org/ml/archives/dev/2014-September/005179.html, and VxLAN tunnel 
filter implementation is based on
it.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 

---
 lib/librte_ether/Makefile   |1 +
 lib/librte_ether/rte_eth_ctrl.h |  152 +++
 lib/librte_ether/rte_ethdev.c   |   32 
 lib/librte_ether/rte_ethdev.h   |   56 +++---
 4 files changed, 229 insertions(+), 12 deletions(-)
 create mode 100644 lib/librte_ether/rte_eth_ctrl.h

diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile
index b310f8b..a461c31 100644
--- a/lib/librte_ether/Makefile
+++ b/lib/librte_ether/Makefile
@@ -46,6 +46,7 @@ SRCS-y += rte_ethdev.c
 #
 SYMLINK-y-include += rte_ether.h
 SYMLINK-y-include += rte_ethdev.h
+SYMLINK-y-include += rte_eth_ctrl.h

 # this lib depends upon:
 DEPDIRS-y += lib/librte_eal lib/librte_mempool lib/librte_ring lib/librte_mbuf
diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
new file mode 100644
index 000..574e9ff
--- /dev/null
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -0,0 +1,152 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_ETH_CTRL_H_
+#define _RTE_ETH_CTRL_H_
+
+/**
+ * @file
+ *
+ * Ethernet device features and related data structures used
+ * by control APIs should be defined in this file.
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Feature filter types
+ */
+enum rte_filter_type {
+   RTE_ETH_FILTER_NONE = 0,
+   RTE_ETH_FILTER_HASH,
+   RTE_ETH_FILTER_FDIR,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_MAX,
+};
+
+/**
+ * All generic operations to filters
+ */
+enum rte_filter_op {
+   /**< used to check whether the type filter is supported */
+   RTE_ETH_FILTER_OP_NONE = 0,
+   RTE_ETH_FILTER_OP_ADD,  /**< add filter entry */
+   RTE_ETH_FILTER_OP_UPDATE,   /**< update filter entry */
+   RTE_ETH_FILTER_OP_DELETE,   /**< delete filter entry */
+   RTE_ETH_FILTER_OP_GET,  /**< get filter entry */
+   RTE_ETH_FILTER_OP_SET,  /**< configurations */
+   /**< get information of filter, such as status or statistics */
+   RTE_ETH_FILTER_OP_GET_INFO,
+   RTE_ETH_FILTER_OP_MAX,
+};
+
+/ TUNNEL FILTER DATA DEFINATION *** */
+
+#define ETH_TUNNEL_FILTER_OMAC  0x01
+#define ETH_TUNNEL_FILTER_OIP   0x02
+#define ETH_TUNNEL_FILTER_TENID 0x04
+#define ETH_TUNNEL_FILTER_IMAC  0x08
+#define ETH_TUNNEL_FILTER_IVLAN 0x10
+#define ETH_TUNNEL_FILTER_IIP   0x20
+
+#define RTE_TUNNEL_FLAGS_TO_QUEUE 1
+
+/*
+ * Tunneled filter type
+ */
+enum rte_tunnel_filter_type {
+   RTE_TUNNEL_FILTER_TYPE_NONE = 0,
+   RTE_TUNNEL_FILTER_OIP = ETH_TUNNEL_FILTER_OIP,
+   RTE_TUNNEL_FILTER_IMAC_IVLAN =
+   ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN,
+   RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID =
+   ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN |
+   ETH_TUNNEL_FILTER_TENID,
+   RTE_TUNNEL_FILTER_IMAC_TENID =
+   ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_TENID,
+   RTE_TUNNEL_FILTER_IMAC = ETH_TUNNEL_FILTER_IMAC,

[dpdk-dev] [PATCH v5 3/8]app/test-pmd:test VxLAN packet identification

2014-10-11 Thread Jijiang Liu
Add commands to test VxLAN packet identification, which include
 - use commands to add/delete VxLAN UDP port.
 - use rxonly mode to receive VxLAN packet.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 app/test-pmd/cmdline.c|   78 ++--
 app/test-pmd/parameters.c |   13 +++
 app/test-pmd/rxonly.c |   49 
 app/test-pmd/testpmd.c|8 +
 app/test-pmd/testpmd.h|4 ++
 5 files changed, 148 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 225f669..c0b7293 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -285,6 +285,12 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"

+   "rx_vxlan_port add (udp_port) (port_id)\n"
+   "Add an UDP port for VxLAN packet filter on a 
port\n\n"
+
+   "rx_vxlan_port rm (udp_port) (port_id)\n"
+   "Remove an UDP port for VxLAN packet filter on a 
port\n\n"
+
"tx_vlan set vlan_id (port_id)\n"
"Set hardware insertion of VLAN ID in packets sent"
" on a port.\n\n"
@@ -296,13 +302,17 @@ static void cmd_help_long_parsed(void *parsed_result,
"Disable hardware insertion of a VLAN header in"
" packets sent on a port.\n\n"

-   "tx_checksum set mask (port_id)\n"
+   "tx_checksum set (mask) (port_id)\n"
"Enable hardware insertion of checksum offload with"
-   " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
+   " the 8-bit mask, 0~0xff, in packets sent on a port.\n"
"bit 0 - insert ip   checksum offload if set\n"
"bit 1 - insert udp  checksum offload if set\n"
"bit 2 - insert tcp  checksum offload if set\n"
"bit 3 - insert sctp checksum offload if set\n"
+   "bit 4 - insert inner ip  checksum offload if 
set\n"
+   "bit 5 - insert inner udp checksum offload if 
set\n"
+   "bit 6 - insert inner tcp checksum offload if 
set\n"
+   "bit 7 - insert inner sctp checksum offload if 
set\n"
"Please check the NIC datasheet for HW limits.\n\n"

"set fwd (%s)\n"
@@ -2745,8 +2755,9 @@ cmdline_parse_inst_t cmd_tx_cksum_set = {
.f = cmd_tx_cksum_set_parsed,
.data = NULL,
.help_str = "enable hardware insertion of L3/L4checksum with a given "
-   "mask in packets sent on a port, the bit mapping is given as, Bit 0 for 
ip"
-   "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
+   "mask in packets sent on a port, the bit mapping is given as, Bit 0 for 
ip "
+   "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip "
+   "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
.tokens = {
(void *)&cmd_tx_cksum_set_tx_cksum,
(void *)&cmd_tx_cksum_set_set,
@@ -6221,6 +6232,64 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
},
 };

+/* *** CONFIGURE TUNNEL UDP PORT *** */
+struct cmd_tunnel_udp_config {
+   cmdline_fixed_string_t cmd;
+   cmdline_fixed_string_t what;
+   uint16_t udp_port;
+   uint8_t port_id;
+};
+
+static void
+cmd_tunnel_udp_config_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+   struct cmd_tunnel_udp_config *res = parsed_result;
+   struct rte_eth_udp_tunnel tunnel_udp;
+   int ret;
+
+   tunnel_udp.udp_port = res->udp_port;
+
+   if (!strcmp(res->cmd, "rx_vxlan_port"))
+   tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
+
+   if (!strcmp(res->what, "add"))
+   ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp, 1);
+   else
+   ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp, 
1);
+
+   if (ret < 0)
+   printf("udp tunneling add error: (%s)\n", strerror(-ret));
+}
+
+cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
+

[dpdk-dev] [PATCH v5 2/8]i40e:support VxLAN packet identification in librte_pmd_i40e

2014-10-11 Thread Jijiang Liu
Support tunneling UDP port configuration on i40e in librte_pmd_i40e.
Currently, only VxLAN is implemented, which include
 -  VxLAN UDP port initialization
 -  Implement the APIs to configure VxLAN UDP port in librte_pmd_i40e.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 config/common_linuxapp|5 +
 lib/librte_mbuf/rte_mbuf.h|4 +-
 lib/librte_pmd_i40e/i40e_ethdev.c |  200 -
 lib/librte_pmd_i40e/i40e_ethdev.h |5 +
 lib/librte_pmd_i40e/i40e_rxtx.c   |9 ++
 5 files changed, 221 insertions(+), 2 deletions(-)

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 4713eb4..185cb0f 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -210,6 +210,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1

 #
+# Compile tunneling UDP port support
+#
+CONFIG_RTE_LIBRTE_TUNNEL_UDP_PORT=4789
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ddadc21..0984650 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -163,7 +163,7 @@ struct rte_mbuf {

/* remaining bytes are set on RX when pulling packet from descriptor */
MARKER rx_descriptor_fields1;
-   uint16_t reserved2;   /**< Unused field. Required for padding */
+   uint16_t packet_type; /**< Packet type, which indicates packet 
format */
uint16_t data_len;/**< Amount of data in segment buffer. */
uint32_t pkt_len; /**< Total pkt len: sum of all segments. */
uint16_t vlan_tci;/**< VLAN Tag Control Identifier (CPU order) 
*/
@@ -551,6 +551,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)
m->port = 0xff;

m->ol_flags = 0;
+   m->packet_type = 0;
m->data_off = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ?
RTE_PKTMBUF_HEADROOM : m->buf_len;

@@ -620,6 +621,7 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, 
struct rte_mbuf *md)
mi->pkt_len = mi->data_len;
mi->nb_segs = 1;
mi->ol_flags = md->ol_flags;
+   mi->packet_type = md->packet_type;

__rte_mbuf_sanity_check(mi, 1);
__rte_mbuf_sanity_check(md, 0);
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index 52f01a5..3ebb8e2 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -189,7 +189,7 @@ static int i40e_res_pool_alloc(struct i40e_res_pool_info 
*pool,
 static int i40e_dev_init_vlan(struct rte_eth_dev *dev);
 static int i40e_veb_release(struct i40e_veb *veb);
 static struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf,
-   struct i40e_vsi *vsi);
+   struct i40e_vsi *vsi);
 static int i40e_pf_config_mq_rx(struct i40e_pf *pf);
 static int i40e_vsi_config_double_vlan(struct i40e_vsi *vsi, int on);
 static inline int i40e_find_all_vlan_for_mac(struct i40e_vsi *vsi,
@@ -205,6 +205,14 @@ static int i40e_dev_rss_hash_update(struct rte_eth_dev 
*dev,
struct rte_eth_rss_conf *rss_conf);
 static int i40e_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
  struct rte_eth_rss_conf *rss_conf);
+static int i40e_dev_udp_tunnel_add(struct rte_eth_dev *dev,
+  struct rte_eth_udp_tunnel *udp_tunnel,
+  uint8_t count);
+static int i40e_dev_udp_tunnel_del(struct rte_eth_dev *dev,
+  struct rte_eth_udp_tunnel *udp_tunnel,
+  uint8_t count);
+static int i40e_pf_config_vxlan(struct i40e_pf *pf);
+

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_PFQF_HKEY_MAX_INDEX + 1];
@@ -256,6 +264,8 @@ static struct eth_dev_ops i40e_eth_dev_ops = {
.reta_query   = i40e_dev_rss_reta_query,
.rss_hash_update  = i40e_dev_rss_hash_update,
.rss_hash_conf_get= i40e_dev_rss_hash_conf_get,
+   .udp_tunnel_add   = i40e_dev_udp_tunnel_add,
+   .udp_tunnel_del   = i40e_dev_udp_tunnel_del,
 };

 static struct eth_driver rte_i40e_pmd = {
@@ -2532,6 +2542,34 @@ i40e_vsi_dump_bw_config(struct i40e_vsi *vsi)
return 0;
 }

+static int
+i40e_vxlan_filters_init(struct i40e_pf *pf)
+{
+   uint8_t filter_index;
+   int ret = 0;
+   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+
+   if (!(pf->flags & I40E_FLAG_VXLAN))
+   return 0;
+
+   /* Init first entry in tunneling UDP table */
+   ret = i40e_aq_add_udp_tunnel(hw, RTE_LIBRTE_TUNNEL_UDP_PORT,
+   I40E_AQC_TUNNEL_TYPE_VXLAN,

[dpdk-dev] [PATCH v5 1/8]i40e:support VxLAN packet identification in librte_ether

2014-10-11 Thread Jijiang Liu
Add data structures and APIs in librte_ether for supporting tunneling UDP port 
configuration on i40e,
Currently, only VxLAN is implemented, which include
 -  VxLAN UDP port initialization
 -  Add APIs to configure VxLAN UDP port

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 lib/librte_ether/rte_ethdev.c |   63 ++
 lib/librte_ether/rte_ethdev.h |   76 +
 lib/librte_ether/rte_ether.h  |8 
 3 files changed, 147 insertions(+), 0 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b71b679..642d312 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2029,6 +2029,69 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
 }

 int
+rte_eth_dev_udp_tunnel_add(uint8_t port_id,
+  struct rte_eth_udp_tunnel *udp_tunnel,
+  uint8_t count)
+{
+   uint8_t i;
+   struct rte_eth_dev *dev;
+   struct rte_eth_udp_tunnel *tunnel;
+
+   if (port_id >= nb_ports) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   if (udp_tunnel == NULL) {
+   PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+   return -EINVAL;
+   }
+   tunnel = udp_tunnel;
+
+   for (i = 0; i < count; i++, tunnel++) {
+   if (tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+   PMD_DEBUG_TRACE("Invalid tunnel type\n");
+   return -EINVAL;
+   }
+   }
+
+   dev = &rte_eth_devices[port_id];
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
+   return (*dev->dev_ops->udp_tunnel_add)(dev, udp_tunnel, count);
+}
+
+int
+rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
+ struct rte_eth_udp_tunnel *udp_tunnel,
+ uint8_t count)
+{
+   uint8_t i;
+   struct rte_eth_dev *dev;
+   struct rte_eth_udp_tunnel *tunnel;
+
+   if (port_id >= nb_ports) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+   dev = &rte_eth_devices[port_id];
+
+   if (udp_tunnel == NULL) {
+   PMD_DEBUG_TRACE("Invalid udp_tunnel parametr\n");
+   return -EINVAL;
+   }
+   tunnel = udp_tunnel;
+   for (i = 0; i < count; i++, tunnel++) {
+   if (tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
+   PMD_DEBUG_TRACE("Invalid tunnel type\n");
+   return -EINVAL;
+   }
+   }
+
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
+   return (*dev->dev_ops->udp_tunnel_del)(dev, udp_tunnel, count);
+}
+
+int
 rte_eth_led_on(uint8_t port_id)
 {
struct rte_eth_dev *dev;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 3f79cc3..3f84c23 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -708,6 +708,26 @@ struct rte_fdir_conf {
 };

 /**
+ * UDP tunneling configuration.
+ */
+struct rte_eth_udp_tunnel {
+   uint16_t udp_port;
+   uint8_t prot_type;
+};
+
+/**
+ * Tunneled type.
+ */
+enum rte_eth_tunnel_type {
+   RTE_TUNNEL_TYPE_NONE = 0,
+   RTE_TUNNEL_TYPE_VXLAN,
+   RTE_TUNNEL_TYPE_GENEVE,
+   RTE_TUNNEL_TYPE_TEREDO,
+   RTE_TUNNEL_TYPE_NVGRE,
+   RTE_TUNNEL_TYPE_MAX,
+};
+
+/**
  *  Possible l4type of FDIR filters.
  */
 enum rte_l4type {
@@ -829,6 +849,7 @@ struct rte_intr_conf {
  * configuration settings may be needed.
  */
 struct rte_eth_conf {
+   enum rte_eth_tunnel_type tunnel_type;
uint16_t link_speed;
/**< ETH_LINK_SPEED_10[0|00|000], or 0 for autonegotation */
uint16_t link_duplex;
@@ -1262,6 +1283,17 @@ typedef int (*eth_mirror_rule_reset_t)(struct 
rte_eth_dev *dev,
  uint8_t rule_id);
 /**< @internal Remove a traffic mirroring rule on an Ethernet device */

+typedef int (*eth_udp_tunnel_add_t)(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *tunnel_udp,
+   uint8_t count);
+/**< @internal Add tunneling UDP info */
+
+typedef int (*eth_udp_tunnel_del_t)(struct rte_eth_dev *dev,
+   struct rte_eth_udp_tunnel *tunnel_udp,
+   uint8_t count);
+/**< @internal Delete tunneling UDP info */
+
+
 #ifdef RTE_NIC_BYPASS

 enum {
@@ -1436,6 +1468,8 @@ struct eth_dev_ops {
eth_set_vf_rx_tset_vf_rx;  /**< enable/disable a VF receive 
*/
eth_set_vf_tx_tset_vf_tx;  /**< enable/disable a VF 
transmit */
eth_set_vf_vlan_filte

[dpdk-dev] [PATCH v5 0/8]Support VxLAN on Fortville

2014-10-11 Thread Jijiang Liu
The patch set supports VxLAN on Fortville based on latest mbuf structure. 

It includes:
 - Support VxLAN packet identification by configuring tunneling UDP port.
 - Support VxLAN packet filters. It uses MAC and VLAN to point
   to a queue. The filter types supported include below:
   1. Inner MAC and Inner VLAN ID
   2. Inner MAC address, inner VLAN ID and tenant ID.
   3. Inner MAC and tenant ID
   4. Inner MAC address
   5. Outer MAC address, tenant ID and inner MAC
 - Support VxLAN TX checksum offload, which include outer L3(IP), inner L3(IP) 
and inner L4(UDP,TCP and SCTP)

Change notes:

 v5) * Use the "packet_type" field to replace the "reserved2" field in the 
rte_mbuf structure.
 * Add the "inner_l2_l3_len" field in the rte_mbuf structure.
 * Add an offload flag PKT_TX_VXLAN_CKSUM in rte_mbuf.h
 * Change i40e_txd_enable_checksum() function for VxLAN Tx checksum offload 
setting.

jijiangl (8):
  Support VxLAN packet identification in librte_ether
  Support VxLAN packet identification in librte_pmd_i40e
  Test vxlan packet identification
  Add new filter framework
  Implement API of VxLAN packet filter in librte_pmd_i40e
  Test VxLAN packet filter API
  Support VxLAN Tx checksum offload
  Test VxLAN Tx checksum offload


 app/test-pmd/cmdline.c|  230 -
 app/test-pmd/config.c |6 +-
 app/test-pmd/csumonly.c   |  196 --
 app/test-pmd/parameters.c |   13 ++
 app/test-pmd/rxonly.c |   49 +
 app/test-pmd/testpmd.c|8 +
 app/test-pmd/testpmd.h|4 +
 config/common_linuxapp|5 +
 lib/librte_ether/Makefile |1 +
 lib/librte_ether/rte_eth_ctrl.h   |  152 ++
 lib/librte_ether/rte_ethdev.c |   95 +
 lib/librte_ether/rte_ethdev.h |  108 ++
 lib/librte_ether/rte_ether.h  |8 +
 lib/librte_mbuf/rte_mbuf.h|   22 ++-
 lib/librte_pmd_i40e/i40e_ethdev.c |  419 -
 lib/librte_pmd_i40e/i40e_ethdev.h |5 +
 lib/librte_pmd_i40e/i40e_rxtx.c   |   53 +-
 17 files changed, 1344 insertions(+), 30 deletions(-)
 create mode 100644 lib/librte_ether/rte_eth_ctrl.h

-- 
1.7.7.6



[dpdk-dev] [PATCH v4 8/8]app/testpmd:test VxLAN Tx checksum offload

2014-09-26 Thread Jijiang Liu
Add test cases in testpmd to test VxLAN Tx Checksum offload, which include
 - IPv4 tunnel and IPv6 tunnel
 - outer L3, inner L3 and L4 checksum offload for Tx side.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 app/test-pmd/config.c   |6 +-
 app/test-pmd/csumonly.c |  200 +++
 2 files changed, 188 insertions(+), 18 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 2a1b93f..9bc08f4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1753,9 +1753,9 @@ tx_cksum_set(portid_t port_id, uint64_t ol_flags)
uint64_t tx_ol_flags;
if (port_id_is_invalid(port_id))
return;
-   /* Clear last 4 bits and then set L3/4 checksum mask again */
-   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0Full);
-   ports[port_id].tx_ol_flags = ((ol_flags & 0xf) | tx_ol_flags);
+   /* Clear last 8 bits and then set L3/4 checksum mask again */
+   tx_ol_flags = ports[port_id].tx_ol_flags & (~0x0FFull);
+   ports[port_id].tx_ol_flags = ((ol_flags & 0xff) | tx_ol_flags);
 }

 void
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index fcc4876..4c53042 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -196,7 +196,6 @@ get_ipv6_udptcp_checksum(struct ipv6_hdr *ipv6_hdr, 
uint16_t *l4_hdr)
return (uint16_t)cksum;
 }

-
 /*
  * Forwarding of packets. Change the checksum field with HW or SW methods
  * The HW/SW method selection depends on the ol_flags on every packet
@@ -209,10 +208,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
struct rte_mbuf  *mb;
struct ether_hdr *eth_hdr;
struct ipv4_hdr  *ipv4_hdr;
+   struct ether_hdr *inner_eth_hdr;
+   struct ipv4_hdr  *inner_ipv4_hdr = NULL;
struct ipv6_hdr  *ipv6_hdr;
+   struct ipv6_hdr  *inner_ipv6_hdr = NULL;
struct udp_hdr   *udp_hdr;
+   struct udp_hdr   *inner_udp_hdr;
struct tcp_hdr   *tcp_hdr;
+   struct tcp_hdr   *inner_tcp_hdr;
struct sctp_hdr  *sctp_hdr;
+   struct sctp_hdr  *inner_sctp_hdr;

uint16_t nb_rx;
uint16_t nb_tx;
@@ -221,12 +226,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
uint64_t pkt_ol_flags;
uint64_t tx_ol_flags;
uint16_t l4_proto;
+   uint16_t inner_l4_proto = 0;
uint16_t eth_type;
uint8_t  l2_len;
uint8_t  l3_len;
+   uint8_t  inner_l2_len;
+   uint8_t  inner_l3_len = 0;

uint32_t rx_bad_ip_csum;
uint32_t rx_bad_l4_csum;
+   uint8_t  ipv4_tunnel;
+   uint8_t  ipv6_tunnel;
+   uint16_t ptype;

 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
uint64_t start_tsc;
@@ -255,6 +266,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)

txp = &ports[fs->tx_port];
tx_ol_flags = txp->tx_ol_flags;
+   ptype = mb->reserved;

for (i = 0; i < nb_rx; i++) {

@@ -262,7 +274,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
l2_len  = sizeof(struct ether_hdr);
pkt_ol_flags = mb->ol_flags;
ol_flags = (pkt_ol_flags & (~PKT_TX_L4_MASK));
-
+   ptype = mb->reserved;
+   ipv4_tunnel = IS_ETH_IPV4_TUNNEL(ptype);
+   ipv6_tunnel = IS_ETH_IPV6_TUNNEL(ptype);
eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
eth_type = rte_be_to_cpu_16(eth_hdr->ether_type);
if (eth_type == ETHER_TYPE_VLAN) {
@@ -295,7 +309,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 *  + ipv4 or ipv6
 *  + udp or tcp or sctp or others
 */
-   if (pkt_ol_flags & PKT_RX_IPV4_HDR) {
+   if (pkt_ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_IPV4_HDR_EXT)) {

/* Do not support ipv4 option field */
l3_len = sizeof(struct ipv4_hdr) ;
@@ -325,17 +339,95 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
if (tx_ol_flags & 0x2) {
/* HW Offload */
ol_flags |= PKT_TX_UDP_CKSUM;
-   /* Pseudo header sum need be set 
properly */
-   udp_hdr->dgram_cksum = 
get_ipv4_psd_sum(ipv4_hdr);
+   if (ipv4_tunnel)
+   udp_hdr->dgram_cksum = 0;
+   else
+   /* Pseudo header sum need be 
set properly */
+   udp_hdr->dgram_cksum =
+   
get_ipv4_psd_sum(ipv4_hdr);
}
  

[dpdk-dev] [PATCH v4 7/8]i40e:support VxLAN Tx checksum offload

2014-09-26 Thread Jijiang Liu
Support VxLAN Tx checksum offload, which include
  - outer L3(IP) checksum offload
  - inner L3(IP) checksum offload
  - inner L4(UDP, TCP and SCTP) checksum offload

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 lib/librte_mbuf/rte_mbuf.h|2 +
 lib/librte_pmd_i40e/i40e_ethdev.c |4 +-
 lib/librte_pmd_i40e/i40e_rxtx.c   |   47 ++--
 3 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 4955684..1f3f4eb 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -86,6 +86,8 @@ extern "C" {
 #define PKT_RX_IEEE1588_PTP  0x0200 /**< RX IEEE1588 L2 Ethernet PT Packet. */
 #define PKT_RX_IEEE1588_TMST 0x0400 /**< RX IEEE1588 L2/L4 timestamped 
packet.*/

+#define PKT_TX_VXLAN_CKSUM   0x0001 /**< Checksum of TX VxLAN pkt. computed by 
NIC.. */
+#define PKT_TX_IVLAN_PKT 0x0002 /**< TX packet is VxLAN packet with an 
inner VLAN. */
 #define PKT_TX_VLAN_PKT  0x0800 /**< TX packet is a 802.1q VLAN packet. */
 #define PKT_TX_IP_CKSUM  0x1000 /**< IP cksum of TX pkt. computed by NIC. 
*/
 #define PKT_TX_IPV4_CSUM 0x1000 /**< Alias of PKT_TX_IP_CKSUM. */
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c 
b/lib/librte_pmd_i40e/i40e_ethdev.c
index a2d9111..10f15c9 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -2566,13 +2566,13 @@ i40e_vxlan_filters_init(struct i40e_pf *pf)
&filter_index, NULL);
if (ret < 0) {
PMD_DRV_LOG(ERR, "Failed to add UDP tunnel port %d "
-   "with index=%d\n", RTE_VXLAN_UDP_PORT,
+   "with index=%d\n", RTE_LIBRTE_TUNNEL_UDP_PORT,
 filter_index);
} else {
pf->vxlan_bitmap |= 1;
pf->vxlan_ports[0] = RTE_LIBRTE_TUNNEL_UDP_PORT;
PMD_DRV_LOG(INFO, "Added UDP tunnel port %d with "
-   "index=%d\n", RTE_VXLAN_UDP_PORT, filter_index);
+   "index=%d\n", RTE_LIBRTE_TUNNEL_UDP_PORT, filter_index);
}

return ret;
diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c
index abdf406..821457c 100644
--- a/lib/librte_pmd_i40e/i40e_rxtx.c
+++ b/lib/librte_pmd_i40e/i40e_rxtx.c
@@ -410,12 +410,16 @@ i40e_rxd_ptype_to_pkt_flags(uint64_t qword)
return ip_ptype_map[ptype];
 }

+#define L4TUN_LEN (sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr)\
++ sizeof(struct ether_hdr))
 static inline void
 i40e_txd_enable_checksum(uint32_t ol_flags,
uint32_t *td_cmd,
uint32_t *td_offset,
uint8_t l2_len,
-   uint8_t l3_len)
+   uint8_t l3_len,
+   uint8_t inner_l3_len,
+   uint32_t *cd_tunneling)
 {
if (!l2_len) {
PMD_DRV_LOG(DEBUG, "L2 length set to 0");
@@ -428,6 +432,31 @@ i40e_txd_enable_checksum(uint32_t ol_flags,
return;
}

+   /* VxLAN packet TX checksum offload */
+   if (unlikely(ol_flags & PKT_TX_VXLAN_CKSUM)) {
+   uint8_t l4tun_len;
+
+   /* packet with inner VLAN */
+   if (ol_flags  & PKT_TX_IVLAN_PKT)
+   l4tun_len = L4TUN_LEN + sizeof(struct vlan_hdr);
+   else
+   l4tun_len = L4TUN_LEN;
+
+   if (ol_flags & PKT_TX_IPV4_CSUM)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
+   else if (ol_flags & PKT_TX_IPV6)
+   *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;
+
+   /* Now set the ctx descriptor fields */
+   *cd_tunneling |= (l3_len >> 2) <<
+   I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
+   I40E_TXD_CTX_UDP_TUNNELING |
+   (l4tun_len >> 1) <<
+   I40E_TXD_CTX_QW0_NATLEN_SHIFT;
+
+   l3_len = inner_l3_len;
+   }
+
/* Enable L3 checksum offloads */
if (ol_flags & PKT_TX_IPV4_CSUM) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
@@ -1080,6 +1109,9 @@ i40e_calc_context_desc(uint64_t flags)
 {
uint16_t mask = 0;

+   if (flags | PKT_TX_VXLAN_CKSUM)
+   mask |= PKT_TX_VXLAN_CKSUM;
+
 #ifdef RTE_LIBRTE_IEEE1588
mask |= PKT_TX_IEEE1588_TMST;
 #endif
@@ -1099,6 +1131,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 
uint16_t nb_pkts)
volatile struct i40e_tx_desc *txr;
struct rte_mbuf *tx_pkt;
struct rte_mbuf *m_seg;
+   uint32_t cd_tunneling_params;

[dpdk-dev] [PATCH v4 6/8]app/testpmd:test VxLAN packet filter API

2014-09-26 Thread Jijiang Liu
Add tunnel_filter command in testpmd to test VxLAN packet filter API.

Signed-off-by: Jijiang Liu 
Acked-by: Helin Zhang 
Acked-by: Jingjing Wu 
Acked-by: Jing Chen 

---
 app/test-pmd/cmdline.c |  152 
 1 files changed, 152 insertions(+), 0 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index c0b7293..a74e9dc 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -285,6 +285,14 @@ static void cmd_help_long_parsed(void *parsed_result,
"Set the outer VLAN TPID for Packet Filtering on"
" a port\n\n"

+   "tunnel_filter add (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   add a tunnel filter of a port.\n\n"
+
+   "tunnel_filter rm (port_id) (outer_mac) (inner_mac) 
(ip_addr) "
+   "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) 
(queue_id)\n"
+   "   remove a tunnel filter of a port.\n\n"
+
"rx_vxlan_port add (udp_port) (port_id)\n"
"Add an UDP port for VxLAN packet filter on a 
port\n\n"

@@ -6232,6 +6240,149 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
},
 };

+/* *** ADD TUNNEL FILTER OF A PORT *** */
+struct cmd_tunnel_filter_result {
+   cmdline_fixed_string_t cmd;
+   cmdline_fixed_string_t what;
+   uint8_t port_id;
+   struct ether_addr outer_mac;
+   struct ether_addr inner_mac;
+   cmdline_ipaddr_t ip_value;
+   uint16_t inner_vlan;
+   cmdline_fixed_string_t tunnel_type;
+   cmdline_fixed_string_t filter_type;
+   uint32_t tenant_id;
+   uint16_t queue_num;
+};
+
+static void
+cmd_tunnel_filter_parsed(void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+   struct cmd_tunnel_filter_result *res = parsed_result;
+   struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
+   int ret = 0;
+
+   tunnel_filter_conf.outer_mac = &res->outer_mac;
+   tunnel_filter_conf.inner_mac = &res->inner_mac;
+   tunnel_filter_conf.inner_vlan = res->inner_vlan;
+
+   if (res->ip_value.family == AF_INET) {
+   tunnel_filter_conf.ip_addr.ipv4_addr =
+   res->ip_value.addr.ipv4.s_addr;
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
+   } else {
+   memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
+   &(res->ip_value.addr.ipv6),
+   sizeof(struct in6_addr));
+   tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
+   }
+
+   if (!strcmp(res->filter_type, "imac-ivlan"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
+   else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
+   else if (!strcmp(res->filter_type, "imac-tenid"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
+   else if (!strcmp(res->filter_type, "imac"))
+   tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC;
+   else if (!strcmp(res->filter_type, "omac-imac-tenid"))
+   tunnel_filter_conf.filter_type =
+   RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
+   else {
+   printf("The filter type is not supported");
+   return;
+   }
+
+   tunnel_filter_conf.to_queue = RTE_TUNNEL_FLAGS_TO_QUEUE;
+
+   if (!strcmp(res->tunnel_type, "vxlan"))
+   tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
+   else {
+   printf("Only VxLAN is supported now.\n");
+   return;
+   }
+
+   tunnel_filter_conf.tenant_id = res->tenant_id;
+   tunnel_filter_conf.queue_id = res->queue_num;
+   if (!strcmp(res->what, "add"))
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_OP_ADD,
+   &tunnel_filter_conf);
+   else
+   ret = rte_eth_dev_filter_ctrl(res->port_id,
+   RTE_ETH_FILTER_TUNNEL,
+   RTE_ETH_FILTER_OP_DELETE,
+   &tunnel_filter_conf);
+   if (ret < 0)
+   printf("cmd_tunnel_filter_parsed 

<    1   2   3   4   >