Re: [ovs-dev] [PATCH v3 00/16] port Jiri Benc's L3 patchset to ovs

2017-02-08 Thread Valentine Sinitsyn

Hi all,

This L3 patchset looks similar to what we did internally with OVS 2.6 to 
add support for IPv6 tunnels.


Could you please confirm that ovs-dpctl reports correct statistics with 
this patchset when one uses in-kernel Linux datapath? We had some issues 
with this (the counters were always zero). Largely, this was because 
userspace code (I refer to the tools and the daemon, not DPDK datapath 
here) assumes a plugged network interface is always L2, and I don't see 
this patch touching these files.


Thanks for your co-operation.

Best regards,
Valentine Sinitsyn
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] how ovs implements QoS funtion

2017-02-08 Thread lg.yue
Ben Pfaff, Hi:
i am clear now. thanks.
i have another two questions to ask.
1. how to limit port's ingress bandwidth?
2. i have moved a port to namespace vm1, and  ovs-vsctl set interface 
9129f3da-b074-4707-a499-f728e0c8e5e1 ingress_policing_rate=8. but its bandwidth 
is not limited by this rule. why?




thanks very much.








At 2017-02-09 00:49:34, "Ben Pfaff"  wrote:
>On Wed, Feb 08, 2017 at 06:27:59PM +0800, lg.yue wrote:
>> Ben Pfaff, Hi:
>>  i have to make it clear that QoS here refers to bandwidth 
>> limitation(TC), rather than  dscp or tos.   what i want to do is to limit 
>> the bandwidth of  vif and ovn's router port.
>>  allocate_chassis_queueid and dpif_queue_to_priority tell that  queue_id 
>> is a incremental number . in kernel function execute_masked_set_action just 
>> assign the value of queue_id to  skb->priority , then sent it to one queue.
>
>allocate_chassis_queueid() is in ovn-northd, so it's dealing with
>OpenFlow queue IDs (or rather OVN logical queue IDs, but so far that's
>the identity map).
>
>dpif_queue_to_priority() calls into a datapath-specific mapping
>function.  For example, the dpif-netlink mapping function (used with the
>Linux kernel datapath) is:
>
>static int
>dpif_netlink_queue_to_priority(const struct dpif *dpif OVS_UNUSED,
> uint32_t queue_id, uint32_t *priority)
>{
>if (queue_id < 0xf000) {
>*priority = TC_H_MAKE(1 << 16, queue_id + 1);
>return 0;
>} else {
>return EINVAL;
>}
>}
>
>execute_masked_set_action() is in the kernel, so anything given to it
>has already been mapped to a sbk_priority.
>
>>  my question is:
>> 1.  does the flow 'set(skb_priority(0x10002))' have something to do with 
>> class htb 1:2 ? and how?  
>
>Yes.  See the code above.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3 00/16] port Jiri Benc's L3 patchset to ovs

2017-02-08 Thread Yang, Yi Y
Then, are you merging 
https://mail.openvswitch.org/pipermail/ovs-dev/2017-February/328492.html or do 
I need to do anything else for it?

-Original Message-
From: Joe Stringer [mailto:j...@ovn.org] 
Sent: Thursday, February 9, 2017 9:44 AM
To: Yang, Yi Y 
Cc: ovs dev ; Yi-Hung Wei 
Subject: Re: [ovs-dev] [PATCH v3 00/16] port Jiri Benc's L3 patchset to ovs

On 7 February 2017 at 21:15, Yang, Yi Y  wrote:
> Joe, I investigated all the patches which changed 
> include/linux/if_vlan.h for 802.1ad in net-next again, I found ovs 
> compat mode doesn't need most of them at all, 
> datapath/linux/compat/include/linux/ only includes part of changes 
> which aren't in local  $KSRC/include/linux/ but required in 
> datapath/linux/compat/*.c

^ required in datapath/linux/compat/*.c, or datapath/*.c. If a function doesn't 
exist in an older kernel, a backport is needed - whether in the headers or 
datapath/linux/compat/*.c. Also, if the behaviour of one of those functions 
changes on a newer kernel which requires changes to the users (such as 
datapath/*.c), then they may also need updating.

> , so my conclusion is we needn't them at all, 
> https://mail.openvswitch.org/pipermail/ovs-dev/2017-February/328492.html is 
> enough for 802.1ad backport for ovs.

At a glance I think you're right.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3 00/16] port Jiri Benc's L3 patchset to ovs

2017-02-08 Thread Joe Stringer
On 7 February 2017 at 21:15, Yang, Yi Y  wrote:
> Joe, I investigated all the patches which changed include/linux/if_vlan.h for 
> 802.1ad in net-next again, I found ovs compat mode doesn't need most of them 
> at all, datapath/linux/compat/include/linux/ only includes part of changes 
> which aren't in local  $KSRC/include/linux/ but required in 
> datapath/linux/compat/*.c

^ required in datapath/linux/compat/*.c, or datapath/*.c. If a
function doesn't exist in an older kernel, a backport is needed -
whether in the headers or datapath/linux/compat/*.c. Also, if the
behaviour of one of those functions changes on a newer kernel which
requires changes to the users (such as datapath/*.c), then they may
also need updating.

> , so my conclusion is we needn't them at all, 
> https://mail.openvswitch.org/pipermail/ovs-dev/2017-February/328492.html is 
> enough for 802.1ad backport for ovs.

At a glance I think you're right.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v3 00/16] port Jiri Benc's L3 patchset to ovs

2017-02-08 Thread Joe Stringer
On 7 February 2017 at 20:55, Yang, Yi  wrote:
> On Tue, Feb 07, 2017 at 02:30:46PM -0800, Joe Stringer wrote:
>> On 7 February 2017 at 09:44, Joe Stringer  wrote:
>> > On 6 February 2017 at 16:46, Yang, Yi Y  wrote:
>> >> Joe, I checked current ovs and net-next kernel, obviously some patches 
>> >> from net-next are selectively backported to ovs, but others are not, I'm 
>> >> not sure what the policy is for a new patch. It will be better that the 
>> >> person who did the patch backports it to ovs at the same time, but nobody 
>> >> did so.
>> >
>> > That's supposed to be the policy; However, depending on the patch
>> > sometimes openvswitch isn't even the main target of the change, so the
>> > contributor may not be aware they should do so. There may be added
>> > difficulty if the previous contributor didn't do their backport. I
>> > think that lately there hasn't been particularly close co-ordination
>> > between the trees, but ideally I think that as we approach an OVS
>> > release, we would try to sync them up.
>> >
>> >> My 802.1ad backport has included all the things l3 patch set depends on, 
>> >> so I think you can give it a go :-)
>> >
>> > Kicking off a build on my local tester, I can at least report back on
>> > that. I see you've tested on a few platforms as well, that's great.
>>
>> Reporting back, I suspect that some of the older kernels don't treat
>> the double-tagged vlans right with this series?
>>
>> I was using an Ubuntu trusty VM with kernel 3.13.0-92-generic plus
>> this backport and it seems to be consistently failing this test:
>>
>> 4: datapath - ping between two ports on cvlan FAILED (system-traffic.at:88)
>>
>> The test output just shows that a ping tries about 10 times and fails
>> all of the times. I didn't investigate further.
>
> But unfortunately I can't run "make check-kmod" on Ubuntu 14.04, all the
> cases are failed, how do you know I can run "datapath - ping between two
> ports on cvlan" manually by one-by-one shell commands?

I'm not sure what's preventing you (I do this frequently), but this is
a good question:

You can find the test in tests/system-traffic:

$ git grep "ping between two ports on cv"
tests/system-traffic.at:AT_SETUP([datapath - ping between two ports on cvlan])

If we open that up in an editor, we can see the progression of the test:
https://github.com/openvswitch/ovs/blob/40c7b2fc0d181155ea87a962a522d48f4166370b/tests/system-traffic.at#L72

First, there's OVS_TRAFFIC_VSWITCHD_START(). This pretty much just
starts up OVS. You can trace this definition through
tests/system-kmod-macros.at and tests/ofproto-macros.at.

We can see lines like AT_CHECK(...) which run a command and check the
return code.

A bunch of the ADD_foo(...) commands will set up the environment in a
particular way; create namespaces, ports, vlans, etc. These are
typically defined in tests/system-kmod-macros.at or
tests/system-common-macros.at.

OVS_WAIT_UNTIL(...) will try running the command a few times, but if
it doesn't return successfully within about 10 seconds the test will
fail with something like "hard failure" (in the test logs).

NS_CHECK_EXEC(...) will run a command within a particular network
namespace and check the return condition, similar to AT_CHECK().

Finally, the test finishes by shutting down OVS -
OVS_TRAFFIC_VSWITCHD_STOP and doing autotest cleanup - AT_CLEANUP.

For this specific test, you can see that it pretty much sets up a
couple of namespaces, connects them to OVS with veth pairs, then adds
additional VLAN devices within those namespaces, which should go over
the OVS. There's three different IP ranges used for bare traffic,
single-tagged, and double-tagged. The failure I see is happening at
the OVS_WAIT_UNTIL() line, so the double-tagged VLANs never show any
connectivity. Later commands will test different packet sizes, but it
doesn't even get that far.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 1/1] doc: Clarify how user space is experimental.

2017-02-08 Thread Joe Stringer
On 8 February 2017 at 02:08, Ian Stokes  wrote:
> Clarify that the use of the user space datapath with non DPDK devices is
> considered experimental.
>
> Fixes: 602e24ee189b (doc: Remove experimental warning for DPDK.)
> Signed-off-by: Ian Stokes 
> Co-authored-by: Joe Stringer 
> ---

I suspect this got caught up in the ovs-dev filter, but it looks good
to me so I applied this to master and branch-2.7.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH branch-2.7 0/1] Upstream kernel fixes for branch-2.7

2017-02-08 Thread Joe Stringer
The following commit has provided a fix upstream to Linux but the fix has not
made its way into the OVS tree's backport yet:

75f01a4c9cc2 ("openvswitch: maintain correct checksum state in conntrack 
actions")

In the interests of providing all available fixes for v2.7 prior to release, I
propose that we apply this patch to branch-2.7. There is ongoing separate
efforts to sync the OVS tree backport on the master branch with upstream
net-next; This patch has not been applied to master yet but I would expect
those efforts to propose this patch also, but within the canonical order that
it arrived in the upstream tree. Ideally in future we would sync master with
upstream around the time of the release to ensure that the latest kernel
features and fixes are applied to the backports.

Joe Stringer (1):
  datapath: maintain correct checksum state in conntrack actions.

 datapath/conntrack.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.11.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH branch-2.7 1/1] datapath: maintain correct checksum state in conntrack actions.

2017-02-08 Thread Joe Stringer
Upstream commit:
openvswitch: maintain correct checksum state in conntrack actions

When executing conntrack actions on skbuffs with checksum mode
CHECKSUM_COMPLETE, the checksum must be updated to account for
header pushes and pulls. Otherwise we get "hw csum failure"
logs similar to this (ICMP packet received on geneve tunnel
via ixgbe NIC):

[  405.740065] genev_sys_6081: hw csum failure
[  405.740106] CPU: 3 PID: 0 Comm: swapper/3 Tainted: G  I 
4.10.0-rc3+ #1
[  405.740108] Call Trace:
[  405.740110]  
[  405.740113]  dump_stack+0x63/0x87
[  405.740116]  netdev_rx_csum_fault+0x3a/0x40
[  405.740118]  __skb_checksum_complete+0xcf/0xe0
[  405.740120]  nf_ip_checksum+0xc8/0xf0
[  405.740124]  icmp_error+0x1de/0x351 [nf_conntrack_ipv4]
[  405.740132]  nf_conntrack_in+0xe1/0x550 [nf_conntrack]
[  405.740137]  ? find_bucket.isra.2+0x62/0x70 [openvswitch]
[  405.740143]  __ovs_ct_lookup+0x95/0x980 [openvswitch]
[  405.740145]  ? netif_rx_internal+0x44/0x110
[  405.740149]  ovs_ct_execute+0x147/0x4b0 [openvswitch]
[  405.740153]  do_execute_actions+0x22e/0xa70 [openvswitch]
[  405.740157]  ovs_execute_actions+0x40/0x120 [openvswitch]
[  405.740161]  ovs_dp_process_packet+0x84/0x120 [openvswitch]
[  405.740166]  ovs_vport_receive+0x73/0xd0 [openvswitch]
[  405.740168]  ? udp_rcv+0x1a/0x20
[  405.740170]  ? ip_local_deliver_finish+0x93/0x1e0
[  405.740172]  ? ip_local_deliver+0x6f/0xe0
[  405.740174]  ? ip_rcv_finish+0x3a0/0x3a0
[  405.740176]  ? ip_rcv_finish+0xdb/0x3a0
[  405.740177]  ? ip_rcv+0x2a7/0x400
[  405.740180]  ? __netif_receive_skb_core+0x970/0xa00
[  405.740185]  netdev_frame_hook+0xd3/0x160 [openvswitch]
[  405.740187]  __netif_receive_skb_core+0x1dc/0xa00
[  405.740194]  ? ixgbe_clean_rx_irq+0x46d/0xa20 [ixgbe]
[  405.740197]  __netif_receive_skb+0x18/0x60
[  405.740199]  netif_receive_skb_internal+0x40/0xb0
[  405.740201]  napi_gro_receive+0xcd/0x120
[  405.740204]  gro_cell_poll+0x57/0x80 [geneve]
[  405.740206]  net_rx_action+0x260/0x3c0
[  405.740209]  __do_softirq+0xc9/0x28c
[  405.740211]  irq_exit+0xd9/0xf0
[  405.740213]  do_IRQ+0x51/0xd0
[  405.740215]  common_interrupt+0x93/0x93

Fixes: 7f8a436eaa2c ("openvswitch: Add conntrack action")
Signed-off-by: Lance Richardson 
Acked-by: Pravin B Shelar 
Signed-off-by: David S. Miller 

Upstream: 75f01a4c9cc2 ("openvswitch: maintain correct checksum state in 
conntrack actions")
Signed-off-by: Joe Stringer 
---
CC: Lance Richardson 
---
 datapath/conntrack.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/datapath/conntrack.c b/datapath/conntrack.c
index 3c51ce6bcfa8..a0c54438728e 100644
--- a/datapath/conntrack.c
+++ b/datapath/conntrack.c
@@ -555,7 +555,7 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct 
nf_conn *ct,
int hooknum, nh_off, err = NF_ACCEPT;
 
nh_off = skb_network_offset(skb);
-   skb_pull(skb, nh_off);
+   skb_pull_rcsum(skb, nh_off);
 
/* See HOOK2MANIP(). */
if (maniptype == NF_NAT_MANIP_SRC)
@@ -620,6 +620,7 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct 
nf_conn *ct,
err = nf_nat_packet(ct, ctinfo, hooknum, skb);
 push:
skb_push(skb, nh_off);
+   skb_postpush_rcsum(skb, skb->data, nh_off);
 
return err;
 }
@@ -931,7 +932,7 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb,
 
/* The conntrack module expects to be working at L3. */
nh_ofs = skb_network_offset(skb);
-   skb_pull(skb, nh_ofs);
+   skb_pull_rcsum(skb, nh_ofs);
 
if (key->ip.frag != OVS_FRAG_TYPE_NONE) {
err = handle_fragments(net, key, info->zone.id, skb);
@@ -945,6 +946,7 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb,
err = ovs_ct_lookup(net, key, info, skb);
 
skb_push(skb, nh_ofs);
+   skb_postpush_rcsum(skb, skb->data, nh_ofs);
if (err)
kfree_skb(skb);
return err;
-- 
2.11.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] SHIP BUILDING Z QR-INQUIRY

2017-02-08 Thread Sally Tan Bee Hwa
Good day

I came to know from some 
trusted sources of your company produce high quality product and would 
very much like to learn more about it. I would appreciate if you can 
send any information that could help me in my selection process. 
Please
 elaborate on the various options along with the different prices, 
discounts, and availability. I also need to know if you offer extended 
warranty. 
Please email me if you have any questions or need to know more about our 
requirements. Looking forward to hearing from you.
Find attached below specification on what i need note that the file is security 
protected.
Regards
Sally
Disclaimer: use of our emails are governed by terms at http://360-jambo.com/emd___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] compat: Remove unused netdevice backport code.

2017-02-08 Thread Joe Stringer
Signed-off-by: Joe Stringer 
---
 datapath/linux/compat/include/linux/netdevice.h |  5 --
 datapath/linux/compat/netdevice.c   | 71 -
 2 files changed, 76 deletions(-)

diff --git a/datapath/linux/compat/include/linux/netdevice.h 
b/datapath/linux/compat/include/linux/netdevice.h
index 9982fd7f686e..75315dc16e02 100644
--- a/datapath/linux/compat/include/linux/netdevice.h
+++ b/datapath/linux/compat/include/linux/netdevice.h
@@ -89,11 +89,6 @@ struct sk_buff *rpl_skb_gso_segment(struct sk_buff *skb, 
netdev_features_t featu
 }
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
-#define netif_skb_features rpl_netif_skb_features
-netdev_features_t rpl_netif_skb_features(struct sk_buff *skb);
-#endif
-
 #ifdef HAVE_NETIF_NEEDS_GSO_NETDEV
 #define netif_needs_gso rpl_netif_needs_gso
 static inline bool netif_needs_gso(struct sk_buff *skb,
diff --git a/datapath/linux/compat/netdevice.c 
b/datapath/linux/compat/netdevice.c
index e28b878eea16..c0ffbbd31bee 100644
--- a/datapath/linux/compat/netdevice.c
+++ b/datapath/linux/compat/netdevice.c
@@ -4,77 +4,6 @@
 
 #include "gso.h"
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
-#ifndef HAVE_CAN_CHECKSUM_PROTOCOL
-static bool can_checksum_protocol(netdev_features_t features, __be16 protocol)
-{
-   return  ((features & NETIF_F_GEN_CSUM) ||
-   ((features & NETIF_F_V4_CSUM) &&
-   protocol == htons(ETH_P_IP)) ||
-   ((features & NETIF_F_V6_CSUM) &&
-   protocol == htons(ETH_P_IPV6)) ||
-   ((features & NETIF_F_FCOE_CRC) &&
-   protocol == htons(ETH_P_FCOE)));
-}
-#endif
-
-static inline int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
-{
-#ifdef CONFIG_HIGHMEM
-   int i;
-
-   if (dev->features & NETIF_F_HIGHDMA)
-   return 0;
-
-   for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
-   if (PageHighMem(skb_shinfo(skb)->frags[i].page))
-   return 1;
-
-#endif
-   return 0;
-}
-
-static netdev_features_t harmonize_features(struct sk_buff *skb,
-   __be16 protocol,
-   netdev_features_t features)
-{
-   if (!can_checksum_protocol(features, protocol)) {
-   features &= ~NETIF_F_ALL_CSUM;
-   features &= ~NETIF_F_SG;
-   } else if (illegal_highdma(skb->dev, skb)) {
-   features &= ~NETIF_F_SG;
-   }
-
-   return features;
-}
-
-netdev_features_t rpl_netif_skb_features(struct sk_buff *skb)
-{
-   unsigned long vlan_features = skb->dev->vlan_features;
-
-   __be16 protocol = skb->protocol;
-   netdev_features_t features = skb->dev->features;
-
-   if (protocol == htons(ETH_P_8021Q)) {
-   struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data;
-   protocol = veh->h_vlan_encapsulated_proto;
-   } else if (!skb_vlan_tag_present(skb)) {
-   return harmonize_features(skb, protocol, features);
-   }
-
-   features &= (vlan_features | NETIF_F_HW_VLAN_TX);
-
-   if (protocol != htons(ETH_P_8021Q)) {
-   return harmonize_features(skb, protocol, features);
-   } else {
-   features &= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST |
-   NETIF_F_GEN_CSUM | NETIF_F_HW_VLAN_TX;
-   return harmonize_features(skb, protocol, features);
-   }
-}
-EXPORT_SYMBOL_GPL(rpl_netif_skb_features);
-#endif /* kernel version < 2.6.38 */
-
 #ifdef OVS_USE_COMPAT_GSO_SEGMENTATION
 struct sk_buff *rpl__skb_gso_segment(struct sk_buff *skb,
netdev_features_t features,
-- 
2.11.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 3/3] ovsdb: Prevent OVSDB server from replicating itself.

2017-02-08 Thread Andy Zhou
On Wed, Feb 8, 2017 at 3:25 PM, Ben Pfaff  wrote:
> On Wed, Feb 08, 2017 at 03:15:51PM -0800, Andy Zhou wrote:
>> On Wed, Feb 8, 2017 at 11:40 AM, Ben Pfaff  wrote:
>> > In replication_init(), I'd use "=" to copy the uuid, instead of
>> > memcpy().
>> >
>> O.K. I will use the brand spanking new UUID_ZERO!
>
> I was really just expecting "server_uuid = *server;"

I misunderstood. Will do.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCHv2 2/2] ovs-ofctl: fix memory leak reported by valgrind.

2017-02-08 Thread Andy Zhou
On Wed, Feb 8, 2017 at 11:40 AM, Ben Pfaff  wrote:
> On Wed, Feb 08, 2017 at 11:24:28AM -0800, Andy Zhou wrote:
>> On Wed, Feb 8, 2017 at 7:03 AM, William Tu  wrote:
>> > Testcase 1057 ofproto-dpif - fragment handling - upcall reports
>> > the following leak:
>> >   xrealloc (util.c:123)
>> >   vconn_dump_flows (vconn.c:1030)
>> >   read_flows_from_switch (ovs-ofctl.c:3360)
>> >   ofctl_replace_flows (ovs-ofctl.c:3433)
>> >   ovs_cmdl_run_command__ (command-line.c:115)
>> >
>> > Signed-off-by: William Tu 
>> Acked-by: Andy Zhou 
>
> Andy, do you want to apply these?

Yes, pushed both patches to master and branch-2.7.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 3/3] ovsdb: Prevent OVSDB server from replicating itself.

2017-02-08 Thread Ben Pfaff
On Wed, Feb 08, 2017 at 03:15:51PM -0800, Andy Zhou wrote:
> On Wed, Feb 8, 2017 at 11:40 AM, Ben Pfaff  wrote:
> > In replication_init(), I'd use "=" to copy the uuid, instead of
> > memcpy().
> >
> O.K. I will use the brand spanking new UUID_ZERO!

I was really just expecting "server_uuid = *server;"
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 3/3] ovsdb: Prevent OVSDB server from replicating itself.

2017-02-08 Thread Andy Zhou
On Wed, Feb 8, 2017 at 11:40 AM, Ben Pfaff  wrote:
> On Tue, Feb 07, 2017 at 08:40:22PM -0800, Andy Zhou wrote:
>> Replication OVSDB server from itself is usually caused by configuration
>> errors. Such configuration errors can lead to OVSDB server data loss.
>> See "reported-at" for more details.
>>
>> This patch adds logics that prevent OVSDB server from replicating
>> itself.
>>
>> Reported-by: Guishuai Li 
>> Reported-at: 
>> https://mail.openvswitch.org/pipermail/ovs-dev/2017-January/326963.html
>> Suggested-by: Ben Pfaff 
>> Signed-off-by: Andy Zhou 
>
> In the manpage, "vSwitch" is not capitalized correctly, and I'd add a
> little more detail, something like this:
>
> diff --git a/ovsdb/ovsdb-server.1.in b/ovsdb/ovsdb-server.1.in
> index b0f488e..49ff5a6 100644
> --- a/ovsdb/ovsdb-server.1.in
> +++ b/ovsdb/ovsdb-server.1.in
> @@ -578,7 +578,7 @@ but in the response object to the monitor_cond request. 
> The formatting
>  of the  object, however, is the same in either case.
>  .
>  .IP "4.1.15. Get Server ID"
> -A new RPC method added in Open vSWitch version 2.7. The request contains
> +A new RPC method added in Open vSwitch version 2.7. The request contains
>  the following members:
>  .
>  .PP
> @@ -604,7 +604,8 @@ The response object contains the following members:
>  .
>  .IP
>   is JSON string that contains a UUID that uniquely identifies
> -the OVSDB server instance.
> +the running OVSDB server process.  A fresh UUID is generated when the
> +process restarts.
>  .
>  .IP "5.1. Notation"
>  For , RFC 7047 only allows the use of \fB!=\fR, \fB==\fR,

Thanks for the improvements. I'll fold them in.

> In replication_init(), I'd use "=" to copy the uuid, instead of
> memcpy().
>
O.K. I will use the brand spanking new UUID_ZERO!

> It would be nice to get feedback from the original reporter.  Presumably
> it solves his problem but perhaps he'll have additional insight.
>
Sure, I am very much interested in their feedbacks too.

> Acked-by: Ben Pfaff 
Thanks.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 4/4] uuid: New macro UUID_ZERO for an all-zero expression or initializer.

2017-02-08 Thread Ben Pfaff
On Wed, Feb 08, 2017 at 11:29:19AM -0800, Andy Zhou wrote:
> On Wed, Feb 8, 2017 at 8:32 AM, Ben Pfaff  wrote:
> > This is convenient in expressions, e.g. "uuid = x ? *x : UUID_ZERO;".
> >
> > Signed-off-by: Ben Pfaff 
> Acked-by: Andy Zhou 

Thanks for all the reviews.  I applied these to master.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCHv2 2/2] ovs-ofctl: fix memory leak reported by valgrind.

2017-02-08 Thread Ben Pfaff
On Wed, Feb 08, 2017 at 11:24:28AM -0800, Andy Zhou wrote:
> On Wed, Feb 8, 2017 at 7:03 AM, William Tu  wrote:
> > Testcase 1057 ofproto-dpif - fragment handling - upcall reports
> > the following leak:
> >   xrealloc (util.c:123)
> >   vconn_dump_flows (vconn.c:1030)
> >   read_flows_from_switch (ovs-ofctl.c:3360)
> >   ofctl_replace_flows (ovs-ofctl.c:3433)
> >   ovs_cmdl_run_command__ (command-line.c:115)
> >
> > Signed-off-by: William Tu 
> Acked-by: Andy Zhou 

Andy, do you want to apply these?
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 4/4] uuid: New macro UUID_ZERO for an all-zero expression or initializer.

2017-02-08 Thread Andy Zhou
On Wed, Feb 8, 2017 at 8:32 AM, Ben Pfaff  wrote:
> This is convenient in expressions, e.g. "uuid = x ? *x : UUID_ZERO;".
>
> Signed-off-by: Ben Pfaff 
Acked-by: Andy Zhou 
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 3/4] jsonrpc: Fix capitalization of parameter name.

2017-02-08 Thread Andy Zhou
On Wed, Feb 8, 2017 at 8:32 AM, Ben Pfaff  wrote:
> Signed-off-by: Ben Pfaff 
Acked-by: Andy Zhou 
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 2/4] smap: Improve comment on SMAP_CONST1, SMAP_CONST2 macros.

2017-02-08 Thread Andy Zhou
On Wed, Feb 8, 2017 at 8:32 AM, Ben Pfaff  wrote:
> Signed-off-by: Ben Pfaff 

Acked-by: Andy Zhou 
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 2/3] ovsdb: Add OVSDB server per instance UUID.

2017-02-08 Thread Ben Pfaff
On Tue, Feb 07, 2017 at 08:40:21PM -0800, Andy Zhou wrote:
> Currently, there is no way for an OVSDB server to ID itself. This patch
> adds a UUID field that is populated every time OVSDB server runs.
> Later patch will make use this UUID to detect and stop and OVSDB server
> from replicating itself.
> 
> Signed-off-by: Andy Zhou 

I don't think I'd bother with ovsdb_server_get_uuid() being inline,
since it's not a fast path.  Maybe it's not worth having a helper, in
fact.

Acked-by: Ben Pfaff 
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCHv2 1/2] ovs-router: fix memory leak reported by valgrind.

2017-02-08 Thread Andy Zhou
On Wed, Feb 8, 2017 at 7:03 AM, William Tu  wrote:
> Valgrind testcase 772: appctl - route/lookup6 reports the
> following definitely lost:
>   xmalloc (util.c:112)
>   miniflow_alloc (flow.c:2500)
>   minimatch_init (match.c:1387)
>   rt_entry_delete (ovs-router.c:274)
>   ovs_router_del (ovs-router.c:384)
>   process_command (unixctl.c:313)
>
> Signed-off-by: William Tu 

Acked-by: Andy Zhou 
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] ofctrl: Free contents of symbol table in ofctrl_destroy().

2017-02-08 Thread Ben Pfaff
Thanks, applied to master and branch-2.7.

On Wed, Feb 08, 2017 at 10:46:29AM -0800, William Tu wrote:
> thanks! I tested it and found no problem.
> 
> On Wed, Feb 8, 2017 at 8:40 AM, Ben Pfaff  wrote:
> > This fixes a memory leak, although it was not a significant leak because
> > the symbol table is in use until shortly before ovn-controller exits.
> >
> > Reported-by: William Tu 
> > Signed-off-by: Ben Pfaff 
> > ---
> >  ovn/controller/ofctrl.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/ovn/controller/ofctrl.c b/ovn/controller/ofctrl.c
> > index 3876ff6..10c8105 100644
> > --- a/ovn/controller/ofctrl.c
> > +++ b/ovn/controller/ofctrl.c
> > @@ -549,6 +549,7 @@ ofctrl_destroy(void)
> >  rconn_destroy(swconn);
> >  ovn_flow_table_destroy(_flows);
> >  rconn_packet_counter_destroy(tx_counter);
> > +expr_symtab_destroy();
> >  shash_destroy();
> >  }
> >
> > --
> > 2.10.2
> >
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] ofctrl: Free contents of symbol table in ofctrl_destroy().

2017-02-08 Thread William Tu
thanks! I tested it and found no problem.

On Wed, Feb 8, 2017 at 8:40 AM, Ben Pfaff  wrote:
> This fixes a memory leak, although it was not a significant leak because
> the symbol table is in use until shortly before ovn-controller exits.
>
> Reported-by: William Tu 
> Signed-off-by: Ben Pfaff 
> ---
>  ovn/controller/ofctrl.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/ovn/controller/ofctrl.c b/ovn/controller/ofctrl.c
> index 3876ff6..10c8105 100644
> --- a/ovn/controller/ofctrl.c
> +++ b/ovn/controller/ofctrl.c
> @@ -549,6 +549,7 @@ ofctrl_destroy(void)
>  rconn_destroy(swconn);
>  ovn_flow_table_destroy(_flows);
>  rconn_packet_counter_destroy(tx_counter);
> +expr_symtab_destroy();
>  shash_destroy();
>  }
>
> --
> 2.10.2
>
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] List Procurement

2017-02-08 Thread Mark Evans
Hello,

 

Good day to you!

 

This is Mark; I'm writing to check if you would be interested to acquire the
newly released Business Database with verified emails and complete contact
information.

 

Major Industrial List:- Agriculture, Business Services, Chambers of
Commerce, Cities, Towns & Municipalities, Construction, Consumer Services,
Cultural, Education, Energy, Utilities & Waste Treatment, Finance,
Government, Healthcare, Hospitality, Insurance, Law Firms & Legal Services,
Manufacturing, Media & Internet, Metals & Mining, Organizations, Real
Estate, Retail, Software, Telecommunications, Transportation, etc.

 

Please review and let me know if you are interested in any of the contact
list for your campaigns and I will provide a sample file and more
information for the same.

 

Appreciate your time and look forward to hear from you.

 

Mark Evans

Direct Marketing Executive

P: +1-610-572-4885

PS. We respect your privacy, if you prefer to opt-out from our mailings
please   click here.

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] windows: netdev report error if query failed

2017-02-08 Thread Guru Shetty
On 7 February 2017 at 22:41, Alin Serdean 
wrote:

> The netdev Windows construct uses query_netdev to see if a port exists
> in the datapath, in the case an error occurred in the reply message
> we returned 0, meaning netdev_open was successful.
>
> This patch fixes fixes that problem.
>
> Reported-at: https://github.com/openvswitch/ovs-issues/issues/125
> Reported-by: Shashank Ram 
> Signed-off-by: Alin Gabriel Serdean 
> ---
> intended for: branch-2.5, branch-2.6, branch-2.7, master
>
Thanks, applied to all the above branches.


> ---
>  lib/netdev-windows.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/netdev-windows.c b/lib/netdev-windows.c
> index c2fbe42..b22bd09 100644
> --- a/lib/netdev-windows.c
> +++ b/lib/netdev-windows.c
> @@ -295,7 +295,7 @@ query_netdev(const char *devname,
>  }
>  }
>
> -return 0;
> +return error;
>  }
>
>  static void
> --
> 2.10.2.windows.1
> ___
> dev mailing list
> d...@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] windows: netdev report error if query failed

2017-02-08 Thread Shashank Ram
Acked-By: Shashank Ram 


From: ovs-dev-boun...@openvswitch.org  on 
behalf of Alin Serdean 
Sent: Tuesday, February 7, 2017 10:41:24 PM
To: d...@openvswitch.org
Subject: [ovs-dev] [PATCH] windows: netdev report error if query failed

The netdev Windows construct uses query_netdev to see if a port exists
in the datapath, in the case an error occurred in the reply message
we returned 0, meaning netdev_open was successful.

This patch fixes fixes that problem.

Reported-at: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_openvswitch_ovs-2Dissues_issues_125=DwICAg=uilaK90D4TOVoH58JNXRgQ=6OuVHk-mnufSWzkKa74UkQ=Cfq2dVpblyjBeHmysptpwpwwGDQJJsMQsY9ZLcKmMM0=7TnLrvAGTBkTsb7xjz-oHZhwMsoTkhGAiVLjmH5s3Zk=
Reported-by: Shashank Ram 
Signed-off-by: Alin Gabriel Serdean 
---
intended for: branch-2.5, branch-2.6, branch-2.7, master
---
 lib/netdev-windows.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/netdev-windows.c b/lib/netdev-windows.c
index c2fbe42..b22bd09 100644
--- a/lib/netdev-windows.c
+++ b/lib/netdev-windows.c
@@ -295,7 +295,7 @@ query_netdev(const char *devname,
 }
 }

-return 0;
+return error;
 }

 static void
--
2.10.2.windows.1
___
dev mailing list
d...@openvswitch.org
https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.openvswitch.org_mailman_listinfo_ovs-2Ddev=DwICAg=uilaK90D4TOVoH58JNXRgQ=6OuVHk-mnufSWzkKa74UkQ=Cfq2dVpblyjBeHmysptpwpwwGDQJJsMQsY9ZLcKmMM0=TaPnBKwCyQulIfIaR7_2ZEDcEVHQ86KQGS-M1hQbuDA=
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] how ovs implements QoS funtion

2017-02-08 Thread Ben Pfaff
On Wed, Feb 08, 2017 at 06:27:59PM +0800, lg.yue wrote:
> Ben Pfaff, Hi:
>  i have to make it clear that QoS here refers to bandwidth 
> limitation(TC), rather than  dscp or tos.   what i want to do is to limit the 
> bandwidth of  vif and ovn's router port.
>  allocate_chassis_queueid and dpif_queue_to_priority tell that  queue_id 
> is a incremental number . in kernel function execute_masked_set_action just 
> assign the value of queue_id to  skb->priority , then sent it to one queue.

allocate_chassis_queueid() is in ovn-northd, so it's dealing with
OpenFlow queue IDs (or rather OVN logical queue IDs, but so far that's
the identity map).

dpif_queue_to_priority() calls into a datapath-specific mapping
function.  For example, the dpif-netlink mapping function (used with the
Linux kernel datapath) is:

static int
dpif_netlink_queue_to_priority(const struct dpif *dpif OVS_UNUSED,
 uint32_t queue_id, uint32_t *priority)
{
if (queue_id < 0xf000) {
*priority = TC_H_MAKE(1 << 16, queue_id + 1);
return 0;
} else {
return EINVAL;
}
}

execute_masked_set_action() is in the kernel, so anything given to it
has already been mapped to a sbk_priority.

>  my question is:
> 1.  does the flow 'set(skb_priority(0x10002))' have something to do with 
> class htb 1:2 ? and how?  

Yes.  See the code above.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] ofctrl: Free contents of symbol table in ofctrl_destroy().

2017-02-08 Thread Ben Pfaff
This fixes a memory leak, although it was not a significant leak because
the symbol table is in use until shortly before ovn-controller exits.

Reported-by: William Tu 
Signed-off-by: Ben Pfaff 
---
 ovn/controller/ofctrl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ovn/controller/ofctrl.c b/ovn/controller/ofctrl.c
index 3876ff6..10c8105 100644
--- a/ovn/controller/ofctrl.c
+++ b/ovn/controller/ofctrl.c
@@ -549,6 +549,7 @@ ofctrl_destroy(void)
 rconn_destroy(swconn);
 ovn_flow_table_destroy(_flows);
 rconn_packet_counter_destroy(tx_counter);
+expr_symtab_destroy();
 shash_destroy();
 }
 
-- 
2.10.2

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] Cómo Vender con Éxito + 11 temas

2017-02-08 Thread Tenemos el plan perfecto a sus necesidades
Nos gustaría hacerle una grata invitación a adquirir nuestra Póliza de 
Capacitación Indispensable para los Responsables de Ventas.


No deje pasar la oportunidad de poner esta exclusiva colección a trabajar en 
benecio de su empresa y sus equipos de trabajo… Consulte la programación y 
compruebe que en la oferta de Conferencias de Coaching Online se encuentra una 
verdadera solución integral a sus necesidades de capacitación y entrenamiento. 

4 Grandes ventajas:

1.- su staff entero se puede capacitar por
el precio de una sola póliza.

2.- Capacitación que se ajusta a su agenda.

3.- Aprenda de los mejores.

4.- Satisfacción 100% garantizada.

Si desea que le adjuntemos el temario Sin compromiso responda este correo con 
la palabra: Info - Ventas, juntos con los datos solicitados.

Nombre:
Teléfono:
Correo:

centro telefónico: 018002129393


___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 3/4] jsonrpc: Fix capitalization of parameter name.

2017-02-08 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/jsonrpc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/jsonrpc.h b/lib/jsonrpc.h
index 5f46e3b..982017a 100644
--- a/lib/jsonrpc.h
+++ b/lib/jsonrpc.h
@@ -125,7 +125,7 @@ void jsonrpc_session_enable_reconnect(struct 
jsonrpc_session *);
 void jsonrpc_session_force_reconnect(struct jsonrpc_session *);
 
 void jsonrpc_session_set_max_backoff(struct jsonrpc_session *,
- int max_backofF);
+ int max_backoff);
 void jsonrpc_session_set_probe_interval(struct jsonrpc_session *,
 int probe_interval);
 void jsonrpc_session_set_dscp(struct jsonrpc_session *,
-- 
2.10.2

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 2/2] rhel-systemd: Document systemd behavior

2017-02-08 Thread Eelco Chaudron
This is a follow up patch to document the systemd behavior including
the change introduced by the "rhel-systemd: Restart openvswitch
service if a daemon crashes", still under review.

Signed-off-by: Eelco Chaudron 
---
 rhel/README.RHEL.rst | 33 +
 1 file changed, 33 insertions(+)

diff --git a/rhel/README.RHEL.rst b/rhel/README.RHEL.rst
index afccf17..a299799 100644
--- a/rhel/README.RHEL.rst
+++ b/rhel/README.RHEL.rst
@@ -296,6 +296,39 @@ DPDK NIC port:
 OVS_OPTIONS="bond_mode=active-backup"
 HOTPLUG=no
 
+
+===
+Red Hat systemd integration
+===
+
+The RPM packages for Open vSwitch provide support for systemd integration. It's
+recommended to use the openvswitch.service to start and stop the Open vSwitch
+daemons. The below table shows systemd's behavior:
+
+=== == == == 
=== ===
+  - Process Statussystemctk <> 
status
+--- - 
--
+Action  ovs-vswitch ovsdb-server  openvswitch
ovs-vswitchdovsdb-server
+=== == == == 
=== ===
+systemctl start openvswitch*startedstartedactive, exited 
active, running active, running
+crash of vswitchd   crash, started re-started active, exited 
active, running active, running
+crash of ovsdb  re-started crash, started active, exited 
active, running active, running
+systemctl restart openvswitch   re-started re-started active, exited 
active, running active, running
+systemctl restart ovs-vswitchd  re-started re-started active, exited 
active, running active, running
+systemctl restart ovsdb-server  re-started re-started active, exited 
active, running active, running
+systemctl stop openvswitch  stoppedstoppedinactive, dead 
inactive, dead  inactive, dead
+systemctl stop ovs-vswitchd stoppedstoppedinactive, dead 
inactive, dead  inactive, dead
+systemctl stop ovsdb-server stoppedstoppedinactive, dead 
inactive, dead  inactive, dead
+systemctl start ovs-vswitchd*   startedstartedinactive, dead 
active, running active, running
+systemctl start ovsdb-server*   not startedstartedinactive, dead 
inactive, dead  active, running
+=== == == == 
=== ===
+
+
+\* These commands where executed when no Open vSwitch related processes where
+running. All other commands where executed when Open vSwitch was successfully
+running.
+
+
 Reporting Bugs
 --
 
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 20/25] netdev-vport: Implement netdev vport get_ifindex on Linux

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

We want to use this later in the HW offloading implementation
which we currently also support Linux only.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev-linux.c |  7 +++
 lib/netdev-linux.h |  2 ++
 lib/netdev-vport.c | 27 +--
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 124d2c3..a48c6d9 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -531,7 +531,6 @@ static int set_flags(const char *, unsigned int flags);
 static int update_flags(struct netdev_linux *netdev, enum netdev_flags off,
 enum netdev_flags on, enum netdev_flags *old_flagsp)
 OVS_REQUIRES(netdev->mutex);
-static int do_get_ifindex(const char *netdev_name);
 static int get_ifindex(const struct netdev *, int *ifindexp);
 static int do_set_addr(struct netdev *netdev,
int ioctl_nr, const char *ioctl_name,
@@ -5374,8 +5373,8 @@ set_flags(const char *name, unsigned int flags)
 return af_inet_ifreq_ioctl(name, , SIOCSIFFLAGS, "SIOCSIFFLAGS");
 }
 
-static int
-do_get_ifindex(const char *netdev_name)
+int
+linux_get_ifindex(const char *netdev_name)
 {
 struct ifreq ifr;
 int error;
@@ -5398,7 +5397,7 @@ get_ifindex(const struct netdev *netdev_, int *ifindexp)
 struct netdev_linux *netdev = netdev_linux_cast(netdev_);
 
 if (!(netdev->cache_valid & VALID_IFINDEX)) {
-int ifindex = do_get_ifindex(netdev_get_name(netdev_));
+int ifindex = linux_get_ifindex(netdev_get_name(netdev_));
 
 if (ifindex < 0) {
 netdev->get_ifindex_error = -ifindex;
diff --git a/lib/netdev-linux.h b/lib/netdev-linux.h
index d944691..880f864 100644
--- a/lib/netdev-linux.h
+++ b/lib/netdev-linux.h
@@ -27,6 +27,7 @@ struct netdev;
 
 int netdev_linux_ethtool_set_flag(struct netdev *netdev, uint32_t flag,
   const char *flag_name, bool enable);
+int linux_get_ifindex(const char *netdev_name);
 
 #define LINUX_FLOW_OFFLOAD_API  \
 netdev_tc_flow_flush,   \
@@ -37,4 +38,5 @@ int netdev_linux_ethtool_set_flag(struct netdev *netdev, 
uint32_t flag,
 netdev_tc_flow_get, \
 netdev_tc_flow_del, \
 netdev_tc_init_flow_api
+
 #endif /* netdev-linux.h */
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 8cb03e6..befa4e4 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -45,6 +45,7 @@
 #include "unaligned.h"
 #include "unixctl.h"
 #include "openvswitch/vlog.h"
+#include "netdev-linux.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_vport);
 
@@ -783,7 +784,8 @@ get_stats(const struct netdev *netdev, struct netdev_stats 
*stats)
 #define VPORT_FUNCTIONS(GET_CONFIG, SET_CONFIG, \
 GET_TUNNEL_CONFIG, GET_STATUS,  \
 BUILD_HEADER,   \
-PUSH_HEADER, POP_HEADER)\
+PUSH_HEADER, POP_HEADER,\
+GET_IFINDEX)\
 NULL,   \
 netdev_vport_run,   \
 netdev_vport_wait,  \
@@ -808,7 +810,7 @@ get_stats(const struct netdev *netdev, struct netdev_stats 
*stats)
 netdev_vport_get_etheraddr, \
 NULL,   /* get_mtu */   \
 NULL,   /* set_mtu */   \
-NULL,   /* get_ifindex */   \
+GET_IFINDEX,\
 NULL,   /* get_carrier */   \
 NULL,   /* get_carrier_resets */\
 NULL,   /* get_miimon */\
@@ -859,14 +861,16 @@ get_stats(const struct netdev *netdev, struct 
netdev_stats *stats)
 NULL,   /* init_flow_api */
 
 
-#define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER)   
\
+#define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER,   
\
+ GET_IFINDEX)  
\
 { DPIF_PORT,   
\
 { NAME, false, 
\
   VPORT_FUNCTIONS(get_tunnel_config,   
\
   set_tunnel_config,   
\
   get_netdev_tunnel_config,
\
   tunnel_get_status,   
\
-  BUILD_HEADER, 

[ovs-dev] [PATCH ovs V3 25/25] compat: Add tc compatibility headers for old kernels

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Added compatibility headers for actions vlan and tunnel key.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 acinclude.m4 |  26 ++
 configure.ac |   1 +
 include/automake.mk  |   1 +
 include/linux/automake.mk|   4 +
 include/linux/pkt_cls.h  | 579 +++
 include/linux/tc_act/tc_tunnel_key.h |  48 +++
 include/linux/tc_act/tc_vlan.h   |  44 +++
 7 files changed, 703 insertions(+)
 create mode 100644 include/linux/automake.mk
 create mode 100644 include/linux/pkt_cls.h
 create mode 100644 include/linux/tc_act/tc_tunnel_key.h
 create mode 100644 include/linux/tc_act/tc_vlan.h

diff --git a/acinclude.m4 b/acinclude.m4
index e8b64b5..0e466b3 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -155,6 +155,32 @@ AC_DEFUN([OVS_CHECK_LINUX], [
   AM_CONDITIONAL(LINUX_ENABLED, test -n "$KBUILD")
 ])
 
+dnl OVS_CHECK_LINUX_TC
+dnl
+dnl Configure Linux tc compat.
+AC_DEFUN([OVS_CHECK_LINUX_TC], [
+  AC_COMPILE_IFELSE([
+AC_LANG_PROGRAM([#include ], [
+int x = TCA_FLOWER_KEY_ENC_UDP_DST_PORT;
+])],
+[AC_DEFINE([HAVE_TCA_FLOWER_KEY_ENC_UDP_DST_PORT], [1],
+   [Define to 1 if TCA_FLOWER_KEY_ENC_UDP_DST_PORT is avaiable.])])
+
+  AC_COMPILE_IFELSE([
+AC_LANG_PROGRAM([#include ], [
+int x = TCA_VLAN_PUSH_VLAN_ID;
+])],
+[AC_DEFINE([HAVE_TCA_VLAN_PUSH_VLAN_ID], [1],
+   [Define to 1 if TCA_VLAN_PUSH_VLAN_ID is avaiable.])])
+
+  AC_COMPILE_IFELSE([
+AC_LANG_PROGRAM([#include ], [
+int x = TCA_TUNNEL_KEY_ENC_DST_PORT;
+])],
+[AC_DEFINE([HAVE_TCA_TUNNEL_KEY_ENC_DST_PORT], [1],
+   [Define to 1 if TCA_TUNNEL_KEY_ENC_DST_PORT is avaiable.])])
+])
+
 dnl OVS_CHECK_DPDK
 dnl
 dnl Configure DPDK source tree
diff --git a/configure.ac b/configure.ac
index 6d75a57..1227638 100644
--- a/configure.ac
+++ b/configure.ac
@@ -175,6 +175,7 @@ OVS_ENABLE_SPARSE
 AC_ARG_VAR(KARCH, [Kernel Architecture String])
 AC_SUBST(KARCH)
 OVS_CHECK_LINUX
+OVS_CHECK_LINUX_TC
 OVS_CHECK_DPDK
 OVS_CHECK_PRAGMA_MESSAGE
 AC_SUBST([OVS_CFLAGS])
diff --git a/include/automake.mk b/include/automake.mk
index 37903fd..3f3ed1c 100644
--- a/include/automake.mk
+++ b/include/automake.mk
@@ -11,3 +11,4 @@ include include/openflow/automake.mk
 include include/openvswitch/automake.mk
 include include/sparse/automake.mk
 include include/windows/automake.mk
+include include/linux/automake.mk
diff --git a/include/linux/automake.mk b/include/linux/automake.mk
new file mode 100644
index 000..093204e
--- /dev/null
+++ b/include/linux/automake.mk
@@ -0,0 +1,4 @@
+noinst_HEADERS += \
+   include/linux/pkt_cls.h \
+   include/linux/tc_act/tc_tunnel_key.h \
+   include/linux/tc_act/tc_vlan.h
diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
new file mode 100644
index 000..9b6865b
--- /dev/null
+++ b/include/linux/pkt_cls.h
@@ -0,0 +1,579 @@
+#ifndef __LINUX_PKT_CLS_WRAPPER_H
+#define __LINUX_PKT_CLS_WRAPPER_H 1
+
+#ifdef HAVE_TCA_FLOWER_KEY_ENC_UDP_DST_PORT
+#include_next 
+#else
+
+#include 
+#include 
+
+#ifdef __KERNEL__
+/* I think i could have done better macros ; for now this is stolen from
+ * some arch/mips code - jhs
+*/
+#define _TC_MAKE32(x) ((x))
+
+#define _TC_MAKEMASK1(n) (_TC_MAKE32(1) << _TC_MAKE32(n))
+#define _TC_MAKEMASK(v,n) (_TC_MAKE32((_TC_MAKE32(1)<<(v))-1) << _TC_MAKE32(n))
+#define _TC_MAKEVALUE(v,n) (_TC_MAKE32(v) << _TC_MAKE32(n))
+#define _TC_GETVALUE(v,n,m) ((_TC_MAKE32(v) & _TC_MAKE32(m)) >> _TC_MAKE32(n))
+
+/* verdict bit breakdown 
+ *
+bit 0: when set -> this packet has been munged already
+
+bit 1: when set -> It is ok to munge this packet
+
+bit 2,3,4,5: Reclassify counter - sort of reverse TTL - if exceeded
+assume loop
+
+bit 6,7: Where this packet was last seen 
+0: Above the transmit example at the socket level
+1: on the Ingress
+2: on the Egress
+
+bit 8: when set --> Request not to classify on ingress. 
+
+bits 9,10,11: redirect counter -  redirect TTL. Loop avoidance
+
+ *
+ * */
+
+#define S_TC_FROM  _TC_MAKE32(6)
+#define M_TC_FROM  _TC_MAKEMASK(2,S_TC_FROM)
+#define G_TC_FROM(x)   _TC_GETVALUE(x,S_TC_FROM,M_TC_FROM)
+#define V_TC_FROM(x)   _TC_MAKEVALUE(x,S_TC_FROM)
+#define SET_TC_FROM(v,n)   ((V_TC_FROM(n)) | (v & ~M_TC_FROM))
+#define AT_STACK   0x0
+#define AT_INGRESS 0x1
+#define AT_EGRESS  0x2
+
+#define TC_NCLS  _TC_MAKEMASK1(8)
+#define SET_TC_NCLS(v)   ( TC_NCLS | (v & ~TC_NCLS))
+#define CLR_TC_NCLS(v)   ( v & ~TC_NCLS)
+
+#define S_TC_AT  _TC_MAKE32(12)
+#define M_TC_AT  _TC_MAKEMASK(2,S_TC_AT)
+#define G_TC_AT(x)   _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
+#define V_TC_AT(x)   _TC_MAKEVALUE(x,S_TC_AT)
+#define SET_TC_AT(v,n)   ((V_TC_AT(n)) | (v & ~M_TC_AT))
+
+#define MAX_REC_LOOP 4
+#define MAX_RED_LOOP 4
+#endif
+
+/* Action 

[ovs-dev] [PATCH ovs V3 21/25] netdev-vport: Use common offloads interface

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

netdev vports are backed by actualy netdev at the kernel
level, so they can use the common netdev-tc offloads interface
for flow offloading (if enabled).

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev-vport.c | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index befa4e4..4cc086e 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -45,6 +45,7 @@
 #include "unaligned.h"
 #include "unixctl.h"
 #include "openvswitch/vlog.h"
+#include "netdev-tc-offloads.h"
 #include "netdev-linux.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_vport);
@@ -780,7 +781,23 @@ get_stats(const struct netdev *netdev, struct netdev_stats 
*stats)
 return 0;
 }
 
-
+#ifdef __linux__
+static int
+netdev_vport_get_ifindex(const struct netdev *netdev_)
+{
+char buf[NETDEV_VPORT_NAME_BUFSIZE];
+const char *name = netdev_vport_get_dpif_port(netdev_, buf, sizeof(buf));
+
+return linux_get_ifindex(name);
+}
+
+#define NETDEV_VPORT_GET_IFINDEX netdev_vport_get_ifindex
+#define NETDEV_FLOW_OFFLOAD_API LINUX_FLOW_OFFLOAD_API
+#else /* !__linux__ */
+#define NETDEV_VPORT_GET_IFINDEX NULL
+#define NETDEV_FLOW_OFFLOAD_API NO_OFFLOAD_API
+#endif /* __linux__ */
+
 #define VPORT_FUNCTIONS(GET_CONFIG, SET_CONFIG, \
 GET_TUNNEL_CONFIG, GET_STATUS,  \
 BUILD_HEADER,   \
@@ -851,14 +868,7 @@ get_stats(const struct netdev *netdev, struct netdev_stats 
*stats)
 NULL,   /* rx_wait */   \
 NULL,   /* rx_drain */  \
 \
-NULL,   /* flow_flush */\
-NULL,   /* flow_dump_create */  \
-NULL,   /* flow_dump_destroy */ \
-NULL,   /* flow_dump_next */\
-NULL,   /* flow_put */  \
-NULL,   /* flow_get */  \
-NULL,   /* flow_del */  \
-NULL,   /* init_flow_api */
+NETDEV_FLOW_OFFLOAD_API
 
 
 #define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER,   
\
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 23/25] dpctl: Add an option to dump only certain kinds of flows

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Usage:
# to dump all datapath flows (default):
ovs-dpctl dump-flows

# to dump only flows that in kernel datapath:
ovs-dpctl dump-flows type=ovs

# to dump only flows that are offloaded:
ovs-dpctl dump-flows type=offloaded

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/dpctl.c   | 21 ++-
 lib/dpif-netdev.c |  3 ++-
 lib/dpif-netlink.c| 62 ++-
 lib/dpif-provider.h   |  6 +++--
 lib/dpif.c|  4 +--
 lib/dpif.h|  3 ++-
 ofproto/ofproto-dpif-upcall.c |  3 ++-
 ofproto/ofproto-dpif.c|  2 +-
 8 files changed, 78 insertions(+), 26 deletions(-)

diff --git a/lib/dpctl.c b/lib/dpctl.c
index 23837ce..59e2cd3 100644
--- a/lib/dpctl.c
+++ b/lib/dpctl.c
@@ -762,6 +762,7 @@ dpctl_dump_flows(int argc, const char *argv[], struct 
dpctl_params *dpctl_p)
 char *name;
 
 char *filter = NULL;
+char *type = NULL;
 struct flow flow_filter;
 struct flow_wildcards wc_filter;
 
@@ -774,22 +775,29 @@ dpctl_dump_flows(int argc, const char *argv[], struct 
dpctl_params *dpctl_p)
 struct dpif_flow_dump *flow_dump;
 struct dpif_flow f;
 int pmd_id = PMD_ID_NULL;
+int lastargc = 0;
 int error;
 
-if (argc > 1 && !strncmp(argv[argc - 1], "filter=", 7)) {
-filter = xstrdup(argv[--argc] + 7);
+while (argc > 1 && lastargc != argc) {
+lastargc = argc;
+if (!strncmp(argv[argc - 1], "filter=", 7)) {
+filter = xstrdup(argv[--argc] + 7);
+} else if (!strncmp(argv[argc - 1], "type=", 5)) {
+type = xstrdup(argv[--argc] + 5);
+}
 }
+
 name = (argc == 2) ? xstrdup(argv[1]) : get_one_dp(dpctl_p);
 if (!name) {
 error = EINVAL;
-goto out_freefilter;
+goto out_free;
 }
 
 error = parsed_dpif_open(name, false, );
 free(name);
 if (error) {
 dpctl_error(dpctl_p, error, "opening datapath");
-goto out_freefilter;
+goto out_free;
 }
 
 
@@ -818,7 +826,7 @@ dpctl_dump_flows(int argc, const char *argv[], struct 
dpctl_params *dpctl_p)
 BUILD_ASSERT(PMD_ID_NULL != NON_PMD_CORE_ID);
 
 ds_init();
-flow_dump = dpif_flow_dump_create(dpif, false);
+flow_dump = dpif_flow_dump_create(dpif, false, (type ? type : "dpctl"));
 flow_dump_thread = dpif_flow_dump_thread_create(flow_dump);
 while (dpif_flow_dump_next(flow_dump_thread, , 1)) {
 if (filter) {
@@ -870,8 +878,9 @@ out_dpifclose:
 simap_destroy(_portno);
 hmap_destroy(_names);
 dpif_close(dpif);
-out_freefilter:
+out_free:
 free(filter);
+free(type);
 return error;
 }
 
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 0be5db5..d76ecb8 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -2502,7 +2502,8 @@ dpif_netdev_flow_dump_cast(struct dpif_flow_dump *dump)
 }
 
 static struct dpif_flow_dump *
-dpif_netdev_flow_dump_create(const struct dpif *dpif_, bool terse)
+dpif_netdev_flow_dump_create(const struct dpif *dpif_, bool terse,
+ char *type OVS_UNUSED)
 {
 struct dpif_netdev_flow_dump *dump;
 
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index a9eb25f..1b830e0 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -1371,6 +1371,16 @@ dpif_netlink_init_flow_del(struct dpif_netlink *dpif,
  del->ufid, del->terse, request);
 }
 
+enum {
+DUMP_OVS_FLOWS_BIT   = 0,
+DUMP_OFFLOADED_FLOWS_BIT = 1,
+};
+
+enum {
+DUMP_OVS_FLOWS   = (1 << DUMP_OVS_FLOWS_BIT),
+DUMP_OFFLOADED_FLOWS = (1 << DUMP_OFFLOADED_FLOWS_BIT),
+};
+
 struct dpif_netlink_flow_dump {
 struct dpif_flow_dump up;
 struct nl_dump nl_dump;
@@ -1379,6 +1389,7 @@ struct dpif_netlink_flow_dump {
 int netdev_dumps_num;/* Number of netdev_flow_dumps */
 struct ovs_mutex netdev_lock;/* Guards the following. */
 int netdev_current_dump OVS_GUARDED; /* Shared current dump */
+int type;/* Type of dump */
 };
 
 static struct dpif_netlink_flow_dump *
@@ -1393,7 +1404,7 @@ start_netdev_dump(const struct dpif *dpif_,
 {
 ovs_mutex_init(>netdev_lock);
 
-if (!netdev_flow_api_enabled) {
+if (!(dump->type & DUMP_OFFLOADED_FLOWS)) {
 dump->netdev_dumps_num = 0;
 dump->netdev_dumps = NULL;
 return;
@@ -1407,8 +1418,24 @@ start_netdev_dump(const struct dpif *dpif_,
 ovs_mutex_unlock(>netdev_lock);
 }
 
+static int
+dpif_netlink_get_dump_type(char *str) {
+int type = 0;
+
+if (!str || !strcmp(str, "ovs") || !strcmp(str, "dpctl")) {
+type |= DUMP_OVS_FLOWS;
+}
+if ((netdev_flow_api_enabled && !str)
+|| (str && (!strcmp(str, "offloaded") || !strcmp(str, "dpctl" {
+type |= 

[ovs-dev] [PATCH ovs V3 24/25] tests: Add system-offloads-testsuite

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

The new system-offloads-testsuite, which can be launched via
`make check-offloads`, tests offloading capabilities
to makes sure that certian flows are actually offloaded.

The tests run on virtual netdevices (VETH).

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 tests/.gitignore   |  1 +
 tests/automake.mk  | 16 +
 tests/ofproto-macros.at|  6 ++--
 tests/system-offloaded-traffic.at  | 67 ++
 tests/system-offloads-testsuite.at | 25 ++
 5 files changed, 113 insertions(+), 2 deletions(-)
 create mode 100644 tests/system-offloaded-traffic.at
 create mode 100644 tests/system-offloads-testsuite.at

diff --git a/tests/.gitignore b/tests/.gitignore
index f4540a3..77e5a95 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -12,6 +12,7 @@
 /pki/
 /system-kmod-testsuite
 /system-userspace-testsuite
+/system-offloads-testsuite
 /test-aes128
 /test-atomic
 /test-bundle
diff --git a/tests/automake.mk b/tests/automake.mk
index f4d4879..1ae11d7 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -4,9 +4,11 @@ EXTRA_DIST += \
$(SYSTEM_TESTSUITE_AT) \
$(SYSTEM_KMOD_TESTSUITE_AT) \
$(SYSTEM_USERSPACE_TESTSUITE_AT) \
+   $(SYSTEM_OFFLOADS_TESTSUITE_AT) \
$(TESTSUITE) \
$(SYSTEM_KMOD_TESTSUITE) \
$(SYSTEM_USERSPACE_TESTSUITE) \
+   $(SYSTEM_OFFLOADS_TESTSUITE) \
tests/atlocal.in \
$(srcdir)/package.m4 \
$(srcdir)/tests/testsuite \
@@ -112,12 +114,18 @@ SYSTEM_TESTSUITE_AT = \
tests/system-ovn.at \
tests/system-traffic.at
 
+SYSTEM_OFFLOADS_TESTSUITE_AT = \
+   tests/system-common-macros.at \
+   tests/system-offloaded-traffic.at \
+   tests/system-offloads-testsuite.at
+
 check_SCRIPTS += tests/atlocal
 
 TESTSUITE = $(srcdir)/tests/testsuite
 TESTSUITE_PATCH = $(srcdir)/tests/testsuite.patch
 SYSTEM_KMOD_TESTSUITE = $(srcdir)/tests/system-kmod-testsuite
 SYSTEM_USERSPACE_TESTSUITE = $(srcdir)/tests/system-userspace-testsuite
+SYSTEM_OFFLOADS_TESTSUITE = $(srcdir)/tests/system-offloads-testsuite
 DISTCLEANFILES += tests/atconfig tests/atlocal
 
 AUTOTEST_PATH = 
utilities:vswitchd:ovsdb:vtep:tests:$(PTHREAD_WIN32_DIR_DLL):ovn/controller-vtep:ovn/northd:ovn/utilities:ovn/controller
@@ -257,6 +265,10 @@ check-system-userspace: all
set $(SHELL) '$(SYSTEM_USERSPACE_TESTSUITE)' -C tests  
AUTOTEST_PATH='$(AUTOTEST_PATH)' $(TESTSUITEFLAGS) -j1; \
"$$@" || (test X'$(RECHECK)' = Xyes && "$$@" --recheck)
 
+check-offloads: all
+   set $(SHELL) '$(SYSTEM_OFFLOADS_TESTSUITE)' -C tests  
AUTOTEST_PATH='$(AUTOTEST_PATH)' $(TESTSUITEFLAGS) -j1; \
+   "$$@" || (test X'$(RECHECK)' = Xyes && "$$@" --recheck)
+
 clean-local:
test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean
 
@@ -281,6 +293,10 @@ $(SYSTEM_USERSPACE_TESTSUITE): package.m4 
$(SYSTEM_TESTSUITE_AT) $(SYSTEM_USERSP
$(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
$(AM_V_at)mv $@.tmp $@
 
+$(SYSTEM_OFFLOADS_TESTSUITE): package.m4 $(SYSTEM_TESTSUITE_AT) 
$(SYSTEM_OFFLOADS_TESTSUITE_AT) $(COMMON_MACROS_AT)
+   $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
+   $(AM_V_at)mv $@.tmp $@
+
 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
$(AM_V_GEN):;{ \
diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at
index faff5b0..0adf555 100644
--- a/tests/ofproto-macros.at
+++ b/tests/ofproto-macros.at
@@ -317,7 +317,7 @@ m4_define([_OVS_VSWITCHD_START],
AT_CAPTURE_FILE([ovsdb-server.log])
 
dnl Initialize database.
-   AT_CHECK([ovs-vsctl --no-wait init])
+   AT_CHECK([ovs-vsctl --no-wait init $2])
 
dnl Start ovs-vswitchd.
AT_CHECK([ovs-vswitchd $1 --detach --no-chdir --pidfile --log-file -vvconn 
-vofproto_dpif -vunixctl], [0], [], [stderr])
@@ -331,7 +331,9 @@ m4_define([_OVS_VSWITCHD_START],
 /ofproto|INFO|using datapath ID/d
 /netdev_linux|INFO|.*device has unknown hardware address family/d
 /ofproto|INFO|datapath ID changed to fedcba9876543210/d
-/dpdk|INFO|DPDK Disabled - Use other_config:dpdk-init to enable/d']])
+/dpdk|INFO|DPDK Disabled - Use other_config:dpdk-init to enable/d
+/netdev: Flow API/d
+/tc: Using policy/d']])
 ])
 
 # OVS_VSWITCHD_START([vsctl-args], [vsctl-output], [=override],
diff --git a/tests/system-offloaded-traffic.at 
b/tests/system-offloaded-traffic.at
new file mode 100644
index 000..7aec8a3
--- /dev/null
+++ b/tests/system-offloaded-traffic.at
@@ -0,0 +1,67 @@
+AT_BANNER([datapath offloads])
+
+# DUMP_CLEAN_SORTED([])
+#
+# Normilizes output ports, recirc_id, packets and macs.
+#
+m4_define([DUMP_CLEAN_SORTED], [sed -e 
's/used:[[0-9]].[[0-9]]*s/used:0.001s/;s/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/actions:[[0-9,]]*/actions:output/;s/recirc_id(0),//'
 | 

[ovs-dev] [PATCH ovs V3 09/25] dpif-netlink: Dump netdevs flows on flow dump

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

While dumping flows, dump flows that were offloaded to
netdev and parse them back to dpif flow.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/dpif-netlink.c | 178 +
 1 file changed, 178 insertions(+)

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 0a2e429..5519c10 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -38,6 +38,7 @@
 #include "flow.h"
 #include "fat-rwlock.h"
 #include "netdev.h"
+#include "netdev-provider.h"
 #include "netdev-linux.h"
 #include "netdev-vport.h"
 #include "netlink-conntrack.h"
@@ -55,6 +56,7 @@
 #include "unaligned.h"
 #include "util.h"
 #include "openvswitch/vlog.h"
+#include "openvswitch/match.h"
 
 VLOG_DEFINE_THIS_MODULE(dpif_netlink);
 #ifdef _WIN32
@@ -69,6 +71,8 @@ enum { MAX_PORTS = USHRT_MAX };
  * missing if we have old headers. */
 #define ETH_FLAG_LRO  (1 << 15)/* LRO is enabled */
 
+#define FLOW_DUMP_MAX_BATCH 50
+
 struct dpif_netlink_dp {
 /* Generic Netlink header. */
 uint8_t cmd;
@@ -1370,6 +1374,10 @@ struct dpif_netlink_flow_dump {
 struct dpif_flow_dump up;
 struct nl_dump nl_dump;
 atomic_int status;
+struct netdev_flow_dump **netdev_dumps;
+int netdev_dumps_num;/* Number of netdev_flow_dumps */
+struct ovs_mutex netdev_lock;/* Guards the following. */
+int netdev_current_dump OVS_GUARDED; /* Shared current dump */
 };
 
 static struct dpif_netlink_flow_dump *
@@ -1378,6 +1386,26 @@ dpif_netlink_flow_dump_cast(struct dpif_flow_dump *dump)
 return CONTAINER_OF(dump, struct dpif_netlink_flow_dump, up);
 }
 
+static void
+start_netdev_dump(const struct dpif *dpif_,
+  struct dpif_netlink_flow_dump *dump)
+{
+ovs_mutex_init(>netdev_lock);
+
+if (!netdev_flow_api_enabled) {
+dump->netdev_dumps_num = 0;
+dump->netdev_dumps = NULL;
+return;
+}
+
+ovs_mutex_lock(>netdev_lock);
+dump->netdev_current_dump = 0;
+dump->netdev_dumps
+= netdev_ports_flow_dumps_create(DPIF_HMAP_KEY(dpif_),
+ >netdev_dumps_num);
+ovs_mutex_unlock(>netdev_lock);
+}
+
 static struct dpif_flow_dump *
 dpif_netlink_flow_dump_create(const struct dpif *dpif_, bool terse)
 {
@@ -1402,6 +1430,8 @@ dpif_netlink_flow_dump_create(const struct dpif *dpif_, 
bool terse)
 atomic_init(>status, 0);
 dump->up.terse = terse;
 
+start_netdev_dump(dpif_, dump);
+
 return >up;
 }
 
@@ -1412,6 +1442,16 @@ dpif_netlink_flow_dump_destroy(struct dpif_flow_dump 
*dump_)
 unsigned int nl_status = nl_dump_done(>nl_dump);
 int dump_status;
 
+for (int i = 0; i < dump->netdev_dumps_num; i++) {
+int err = netdev_flow_dump_destroy(dump->netdev_dumps[i]);
+if (err != 0 && err != EOPNOTSUPP) {
+VLOG_ERR("failed dumping netdev: %s", ovs_strerror(err));
+}
+}
+
+free(dump->netdev_dumps);
+ovs_mutex_destroy(>netdev_lock);
+
 /* No other thread has access to 'dump' at this point. */
 atomic_read_relaxed(>status, _status);
 free(dump);
@@ -1425,6 +1465,13 @@ struct dpif_netlink_flow_dump_thread {
 struct dpif_flow_stats stats;
 struct ofpbuf nl_flows; /* Always used to store flows. */
 struct ofpbuf *nl_actions;  /* Used if kernel does not supply actions. */
+int netdev_dump_idx;/* This thread current netdev dump index */
+bool netdev_done;   /* If we are finished dumping netdevs */
+
+/* (Key/Mask/Actions) Buffers for netdev dumpin */
+struct odputil_keybuf keybuf[FLOW_DUMP_MAX_BATCH];
+struct odputil_keybuf maskbuf[FLOW_DUMP_MAX_BATCH];
+struct odputil_keybuf actbuf[FLOW_DUMP_MAX_BATCH];
 };
 
 static struct dpif_netlink_flow_dump_thread *
@@ -1444,6 +1491,8 @@ dpif_netlink_flow_dump_thread_create(struct 
dpif_flow_dump *dump_)
 thread->dump = dump;
 ofpbuf_init(>nl_flows, NL_DUMP_BUFSIZE);
 thread->nl_actions = NULL;
+thread->netdev_dump_idx = 0;
+thread->netdev_done = !(thread->netdev_dump_idx < dump->netdev_dumps_num);
 
 return >up;
 }
@@ -1481,6 +1530,96 @@ dpif_netlink_flow_to_dpif_flow(struct dpif *dpif, struct 
dpif_flow *dpif_flow,
 dpif_netlink_flow_get_stats(datapath_flow, _flow->stats);
 }
 
+/* The design is such that all threads are working together on the first dump
+ * to the last, in order (at first they all on dump 0).
+ * When the first thread finds that the given dump is finished,
+ * they all move to the next. If two or more threads find the same dump
+ * is finished at the same time, the first one will advance the shared
+ * netdev_current_dump and the others will catch up. */
+static void
+dpif_netlink_advance_netdev_dump(struct dpif_netlink_flow_dump_thread *thread)
+{
+struct dpif_netlink_flow_dump *dump = thread->dump;
+
+ovs_mutex_lock(>netdev_lock);
+/* 

[ovs-dev] [PATCH ovs V3 22/25] netdev-tc-offloads: Add ingress on netdev flow api init

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev-tc-offloads.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 716c302..693ff04 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -72,6 +72,7 @@
 #include "openvswitch/match.h"
 #include "openvswitch/vlog.h"
 #include "tc.h"
+#include "netdev-linux.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_tc_offloads);
 
@@ -792,8 +793,28 @@ netdev_tc_flow_del(struct netdev *netdev OVS_UNUSED,
 }
 
 int
-netdev_tc_init_flow_api(struct netdev *netdev OVS_UNUSED)
+netdev_tc_init_flow_api(struct netdev *netdev)
 {
+int ifindex;
+int error;
+
+ifindex = netdev_get_ifindex(netdev);
+if (ifindex < 0) {
+VLOG_ERR_RL(_err, "failed to get ifindex for %s: %s",
+netdev_get_name(netdev), ovs_strerror(-ifindex));
+return -ifindex;
+}
+
+error = tc_add_del_ingress_qdisc(ifindex, true);
+
+if (error && error != EEXIST) {
+VLOG_ERR("failed adding ingress qdisc required for offloading: %s",
+ ovs_strerror(error));
+return error;
+}
+
+VLOG_INFO("added ingress qdisc to %s", netdev_get_name(netdev));
+
 return 0;
 }
 
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 18/25] netdev-tc-offloads: Implement flow get using tc interface

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Search the requested ufid for a offloaded flow, and if found,
dump and parse it back to required format.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev-tc-offloads.c | 49 ++--
 1 file changed, 43 insertions(+), 6 deletions(-)

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index d1c7805..716c302 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -711,13 +711,50 @@ netdev_tc_flow_put(struct netdev *netdev,
 
 int
 netdev_tc_flow_get(struct netdev *netdev OVS_UNUSED,
-   struct match *match OVS_UNUSED,
-   struct nlattr **actions OVS_UNUSED,
-   struct dpif_flow_stats *stats OVS_UNUSED,
-   const ovs_u128 *ufid OVS_UNUSED,
-   struct ofpbuf *buf OVS_UNUSED)
+   struct match *match,
+   struct nlattr **actions,
+   struct dpif_flow_stats *stats,
+   const ovs_u128 *ufid,
+   struct ofpbuf *buf)
 {
-return EOPNOTSUPP;
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
+struct netdev *dev;
+struct tc_flower flower;
+odp_port_t in_port;
+int prio = 0;
+int ifindex;
+int handle;
+int err;
+
+handle = get_ufid_tc_mapping(ufid, , );
+if (!handle) {
+return ENOENT;
+}
+
+ifindex = netdev_get_ifindex(dev);
+if (ifindex < 0) {
+VLOG_ERR_RL(_err, "failed to get ifindex for %s: %s",
+netdev_get_name(dev), ovs_strerror(-ifindex));
+return -ifindex;
+}
+
+VLOG_DBG_RL(, "flow get (dev %s prio %d handle %d)",
+netdev_get_name(dev), prio, handle);
+err = tc_get_flower(ifindex, prio, handle, );
+netdev_close(dev);
+if (err) {
+VLOG_ERR_RL(_err, "flow get failed (dev %s prio %d handle %d): %s",
+netdev_get_name(dev), prio, handle, ovs_strerror(err));
+return err;
+}
+
+in_port = netdev_hmap_port_get_byifidx(ifindex);
+parse_tc_flower_to_match(, match, actions, stats, buf);
+
+match->wc.masks.in_port.odp_port = u32_to_odp(UINT32_MAX);
+match->flow.in_port.odp_port = in_port;
+
+return 0;
 }
 
 int
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 15/25] dpif-netlink: Delete a flow from netdev

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

If a flow was offloaded to a netdev we delete it using netdev
flow api.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/dpif-netlink.c | 12 +++-
 lib/netdev.c   | 15 +++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index a7525de..b5f5694 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -2086,7 +2086,17 @@ try_send_to_netdev(struct dpif_netlink *dpif, struct 
dpif_op *op)
put->actions, put->actions_len, put->ufid, "PUT");
 return parse_flow_put(dpif, put);
 }
-case DPIF_OP_FLOW_DEL:
+case DPIF_OP_FLOW_DEL: {
+struct dpif_flow_del *del = >u.flow_del;
+
+if (!del->ufid) {
+break;
+}
+dbg_print_flow(del->key, del->key_len, NULL, 0, NULL, 0,
+   del->ufid, "DEL");
+return netdev_ports_flow_del(DPIF_HMAP_KEY(>dpif), del->ufid,
+ del->stats);
+}
 case DPIF_OP_FLOW_GET:
 case DPIF_OP_EXECUTE:
 default:
diff --git a/lib/netdev.c b/lib/netdev.c
index a0206b0..c6a4582 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -2269,6 +2269,21 @@ netdev_ports_flow_dumps_create(const void *obj, int 
*ports)
 return dumps;
 }
 
+int
+netdev_ports_flow_del(const void *obj, const ovs_u128 *ufid,
+  struct dpif_flow_stats *stats)
+{
+struct port_to_netdev_data *data;
+
+HMAP_FOR_EACH(data, node, _to_netdev) {
+if (data->obj == obj && !netdev_flow_del(data->netdev, stats, ufid)) {
+return 0;
+}
+}
+
+return ENOENT;
+}
+
 bool netdev_flow_api_enabled = false;
 
 void
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 13/25] netdev-tc-offloads: Add flower mask to priority map

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Flower classifer requires a different priority per mask,
so we hash the mask and generate a new priority for
each new mask used.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev-tc-offloads.c | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index f88e7ce..48e452a 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -176,6 +176,44 @@ add_ufid_tc_mapping(const ovs_u128 *ufid, int prio, int 
handle,
 return replace;
 }
 
+struct prio_map_data {
+struct hmap_node node;
+struct tc_flower_key mask;
+ovs_be16 protocol;
+uint16_t prio;
+};
+
+static uint16_t
+get_prio_for_tc_flower(struct tc_flower *flower)
+{
+static struct hmap prios = HMAP_INITIALIZER();
+static struct ovs_mutex prios_lock = OVS_MUTEX_INITIALIZER;
+static int last_prio = 0;
+size_t key_len = sizeof(struct tc_flower_key);
+size_t hash = hash_bytes(>mask, key_len,
+ (OVS_FORCE uint32_t) flower->key.eth_type);
+struct prio_map_data *data;
+struct prio_map_data *new_data;
+
+ovs_mutex_lock(_lock);
+HMAP_FOR_EACH_WITH_HASH(data, node, hash, ) {
+if (!memcmp(>mask, >mask, key_len)
+&& data->protocol == flower->key.eth_type) {
+ovs_mutex_unlock(_lock);
+return data->prio;
+}
+}
+
+new_data = xzalloc(sizeof *new_data);
+memcpy(_data->mask, >mask, key_len);
+new_data->prio = ++last_prio;
+new_data->protocol = flower->key.eth_type;
+hmap_insert(, _data->node, hash);
+ovs_mutex_unlock(_lock);
+
+return new_data->prio;
+}
+
 int
 netdev_tc_flow_flush(struct netdev *netdev)
 {
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 12/25] dpif-netlink: Use netdev flow put api to insert a flow

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Using the new netdev flow api operate will now try and
offload flows to the relevant netdev of the input port.
Other operate methods flows will come in later patches.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/dpif-netlink.c | 222 +++--
 lib/odp-util.c |  53 +
 lib/odp-util.h |   3 +
 3 files changed, 271 insertions(+), 7 deletions(-)

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 5519c10..a7525de 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -72,6 +72,7 @@ enum { MAX_PORTS = USHRT_MAX };
 #define ETH_FLAG_LRO  (1 << 15)/* LRO is enabled */
 
 #define FLOW_DUMP_MAX_BATCH 50
+#define OPERATE_MAX_OPS 50
 
 struct dpif_netlink_dp {
 /* Generic Netlink header. */
@@ -1764,8 +1765,6 @@ static size_t
 dpif_netlink_operate__(struct dpif_netlink *dpif,
struct dpif_op **ops, size_t n_ops)
 {
-enum { MAX_OPS = 50 };
-
 struct op_auxdata {
 struct nl_transaction txn;
 
@@ -1774,12 +1773,12 @@ dpif_netlink_operate__(struct dpif_netlink *dpif,
 
 struct ofpbuf reply;
 uint64_t reply_stub[1024 / 8];
-} auxes[MAX_OPS];
+} auxes[OPERATE_MAX_OPS];
 
-struct nl_transaction *txnsp[MAX_OPS];
+struct nl_transaction *txnsp[OPERATE_MAX_OPS];
 size_t i;
 
-n_ops = MIN(n_ops, MAX_OPS);
+n_ops = MIN(n_ops, OPERATE_MAX_OPS);
 for (i = 0; i < n_ops; i++) {
 struct op_auxdata *aux = [i];
 struct dpif_op *op = ops[i];
@@ -1922,18 +1921,227 @@ dpif_netlink_operate__(struct dpif_netlink *dpif,
 return n_ops;
 }
 
+static int
+parse_flow_get(struct dpif_netlink *dpif, struct dpif_flow_get *get)
+{
+struct dpif_flow *dpif_flow = get->flow;
+struct match match;
+struct nlattr *actions;
+struct dpif_flow_stats stats;
+struct ofpbuf buf;
+uint64_t act_buf[1024 / 8];
+struct odputil_keybuf maskbuf;
+struct odputil_keybuf keybuf;
+struct odputil_keybuf actbuf;
+struct ofpbuf key, mask, act;
+int err;
+
+ofpbuf_use_stack(, _buf, sizeof act_buf);
+err = netdev_ports_flow_get(DPIF_HMAP_KEY(>dpif), ,
+, , get->ufid, );
+if (err) {
+return err;
+}
+
+VLOG_DBG("found flow from netdev, translating to dpif flow");
+
+ofpbuf_use_stack(, , sizeof keybuf);
+ofpbuf_use_stack(, , sizeof actbuf);
+ofpbuf_use_stack(, , sizeof maskbuf);
+dpif_netlink_netdev_match_to_dpif_flow(, , , actions,
+   ,
+   (ovs_u128 *) get->ufid,
+   dpif_flow,
+   false);
+ofpbuf_put(get->buffer, nl_attr_get(actions), nl_attr_get_size(actions));
+dpif_flow->actions = ofpbuf_at(get->buffer, 0, 0);
+dpif_flow->actions_len = nl_attr_get_size(actions);
+
+// XXX: missing ofpbuf_uninit?
+return 0;
+}
+
+static int
+parse_flow_put(struct dpif_netlink *dpif, struct dpif_flow_put *put)
+{
+static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
+struct match match;
+odp_port_t in_port;
+const struct nlattr *nla;
+size_t left;
+int outputs = 0;
+struct netdev *dev;
+struct offload_info info;
+ovs_be16 dst_port = 0;
+int err = 0;
+
+if (put->flags & DPIF_FP_PROBE) {
+return EOPNOTSUPP;
+}
+
+err = parse_key_and_mask_to_match(put->key, put->key_len, put->mask,
+  put->mask_len, );
+if (err) {
+return err;
+}
+
+/* Get tunnel dst port and count outputs */
+NL_ATTR_FOR_EACH(nla, left, put->actions, put->actions_len) {
+if (nl_attr_type(nla) == OVS_ACTION_ATTR_OUTPUT) {
+const struct netdev_tunnel_config *tnl_cfg;
+struct netdev *outdev;
+odp_port_t out_port;
+
+outputs++;
+if (outputs > 1) {
+VLOG_WARN_RL(, "offloading multiple ports isn't supported");
+err = EOPNOTSUPP;
+goto err_out;
+}
+
+out_port = nl_attr_get_odp_port(nla);
+outdev = netdev_hmap_port_get(out_port, 
DPIF_HMAP_KEY(>dpif));
+tnl_cfg = netdev_get_tunnel_config(outdev);
+if (tnl_cfg && tnl_cfg->dst_port != 0) {
+dst_port = tnl_cfg->dst_port;
+}
+netdev_close(outdev);
+}
+}
+
+
+info.port_hmap_obj = DPIF_HMAP_KEY(>dpif);
+info.tp_dst_port = dst_port;
+in_port = match.flow.in_port.odp_port;
+dev = netdev_hmap_port_get(in_port, DPIF_HMAP_KEY(>dpif));
+err = netdev_flow_put(dev, ,
+  CONST_CAST(struct nlattr *, put->actions),
+  put->actions_len, put->stats,
+  CONST_CAST(ovs_u128 *, 

[ovs-dev] [PATCH ovs V3 10/25] netdev-tc-offloads: Add ufid to tc/netdev map

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Flows offloaded to tc are identified by priority
and handle pair while OVS flows are identified by ufid.
Added a hash map to convert between the two for later
retrieval and deleting of offloaded flows.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev-tc-offloads.c | 99 
 1 file changed, 99 insertions(+)

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 4f9456c..cf8f9ef 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -77,6 +77,105 @@ VLOG_DEFINE_THIS_MODULE(netdev_tc_offloads);
 
 static struct vlog_rate_limit rl_err = VLOG_RATE_LIMIT_INIT(, 5);
 
+static struct hmap ufid_to_tc = HMAP_INITIALIZER(_to_tc);
+static struct ovs_mutex ufid_lock = OVS_MUTEX_INITIALIZER;
+
+struct ufid_to_tc_data {
+struct hmap_node node;
+ovs_u128 ufid;
+uint16_t prio;
+uint32_t handle;
+struct netdev *netdev;
+};
+
+static bool
+del_ufid_tc_mapping(const ovs_u128 *ufid)
+{
+size_t hash = hash_bytes(ufid, sizeof *ufid, 0);
+struct ufid_to_tc_data *data;
+
+ovs_mutex_lock(_lock);
+HMAP_FOR_EACH_WITH_HASH(data, node, hash, _to_tc) {
+if (ovs_u128_equals(*ufid, data->ufid)) {
+break;
+}
+}
+if (data) {
+hmap_remove(_to_tc, >node);
+ovs_mutex_unlock(_lock);
+netdev_close(data->netdev);
+free(data);
+return true;
+}
+ovs_mutex_unlock(_lock);
+return false;
+}
+
+static ovs_u128 *
+find_ufid(int prio, int handle, struct netdev *netdev)
+{
+int ifindex = netdev_get_ifindex(netdev);
+struct ufid_to_tc_data *data;
+
+ovs_mutex_lock(_lock);
+HMAP_FOR_EACH(data, node, _to_tc) {
+if (data->prio == prio && data->handle == handle
+&& netdev_get_ifindex(data->netdev) == ifindex) {
+break;
+}
+}
+ovs_mutex_unlock(_lock);
+if (data) {
+return >ufid;
+}
+return NULL;
+}
+
+static int
+get_ufid_tc_mapping(const ovs_u128 *ufid, int *prio, struct netdev **netdev)
+{
+size_t hash = hash_bytes(ufid, sizeof *ufid, 0);
+struct ufid_to_tc_data *data;
+
+ovs_mutex_lock(_lock);
+HMAP_FOR_EACH_WITH_HASH(data, node, hash, _to_tc) {
+if (ovs_u128_equals(*ufid, data->ufid)) {
+break;
+}
+}
+ovs_mutex_unlock(_lock);
+if (data) {
+if (prio) {
+*prio = data->prio;
+}
+if (netdev) {
+*netdev = netdev_ref(data->netdev);
+}
+return data->handle;
+}
+return 0;
+}
+
+static bool
+add_ufid_tc_mapping(const ovs_u128 *ufid, int prio, int handle,
+struct netdev *netdev)
+{
+size_t hash = hash_bytes(ufid, sizeof *ufid, 0);
+bool replace = del_ufid_tc_mapping(ufid);
+struct ufid_to_tc_data *new_data = xzalloc(sizeof *new_data);
+
+new_data->ufid = *ufid;
+new_data->prio = prio;
+new_data->handle = handle;
+new_data->netdev = netdev_ref(netdev);
+
+ovs_mutex_lock(_lock);
+hmap_insert(_to_tc, _data->node, hash);
+ovs_mutex_unlock(_lock);
+
+return replace;
+}
+
 int
 netdev_tc_flow_flush(struct netdev *netdev)
 {
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 08/25] netdev-tc-offloads: Implement netdev flow flush using tc interface

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev-tc-offloads.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index b49d38b..4f9456c 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -75,10 +75,20 @@
 
 VLOG_DEFINE_THIS_MODULE(netdev_tc_offloads);
 
+static struct vlog_rate_limit rl_err = VLOG_RATE_LIMIT_INIT(, 5);
+
 int
-netdev_tc_flow_flush(struct netdev *netdev OVS_UNUSED)
+netdev_tc_flow_flush(struct netdev *netdev)
 {
-return EOPNOTSUPP;
+int ifindex = netdev_get_ifindex(netdev);
+
+if (ifindex < 0) {
+VLOG_ERR_RL(_err, "failed to get ifindex for %s: %s",
+netdev_get_name(netdev), ovs_strerror(-ifindex));
+return -ifindex;
+}
+
+return tc_flush(ifindex);
 }
 
 int
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 07/25] dpif-netlink: Flush added ports using netdev flow api

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

If netdev flow offloading is enabled, flush all
added ports using netdev flow api.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/dpif-netlink.c |  5 +
 lib/netdev.c   | 44 
 2 files changed, 49 insertions(+)

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 9762a87..0a2e429 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -1079,6 +1079,11 @@ dpif_netlink_flow_flush(struct dpif *dpif_)
 dpif_netlink_flow_init();
 flow.cmd = OVS_FLOW_CMD_DEL;
 flow.dp_ifindex = dpif->dp_ifindex;
+
+if (netdev_flow_api_enabled) {
+netdev_ports_flow_flush(DPIF_HMAP_KEY(dpif_));
+}
+
 return dpif_netlink_flow_transact(, NULL, NULL);
 }
 
diff --git a/lib/netdev.c b/lib/netdev.c
index 792ab8c..a0206b0 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -2225,6 +2225,50 @@ netdev_hmap_port_del(odp_port_t port_no, const void *obj)
 return ret;
 }
 
+void
+netdev_ports_flow_flush(const void *obj)
+{
+struct port_to_netdev_data *data;
+
+HMAP_FOR_EACH(data, node, _to_netdev) {
+if (data->obj == obj) {
+netdev_flow_flush(data->netdev);
+}
+}
+}
+
+struct netdev_flow_dump **
+netdev_ports_flow_dumps_create(const void *obj, int *ports)
+{
+struct port_to_netdev_data *data;
+struct netdev_flow_dump **dumps;
+int count = 0;
+int i = 0;
+
+HMAP_FOR_EACH(data, node, _to_netdev) {
+if (data->obj == obj) {
+count++;
+}
+}
+
+dumps = count ? xzalloc(sizeof(dumps[0]) * count) : NULL;
+
+HMAP_FOR_EACH(data, node, _to_netdev) {
+if (data->obj == obj) {
+int err = netdev_flow_dump_create(data->netdev, [i]);
+if (err) {
+continue;
+}
+
+dumps[i]->port = data->dpif_port.port_no;
+i++;
+}
+}
+
+*ports = i;
+return dumps;
+}
+
 bool netdev_flow_api_enabled = false;
 
 void
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 01/25] tc: Add tc flower interface

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Add tc flower interface that will be used to offload flows via tc
flower classifier. Depending on the flag used (skip_sw/hw) flower
will pass those to HW or handle them itself.

Co-authored-by: Shahar Klein 
Signed-off-by: Shahar Klein 
Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/automake.mk |   2 +
 lib/tc.c| 984 
 lib/tc.h| 108 +++
 3 files changed, 1094 insertions(+)
 create mode 100644 lib/tc.c
 create mode 100644 lib/tc.h

diff --git a/lib/automake.mk b/lib/automake.mk
index abc9d0d..a6141ea 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -351,6 +351,8 @@ if LINUX
 lib_libopenvswitch_la_SOURCES += \
lib/dpif-netlink.c \
lib/dpif-netlink.h \
+   lib/tc.h \
+   lib/tc.c \
lib/if-notifier.c \
lib/if-notifier.h \
lib/netdev-linux.c \
diff --git a/lib/tc.c b/lib/tc.c
new file mode 100644
index 000..acda7fe
--- /dev/null
+++ b/lib/tc.c
@@ -0,0 +1,984 @@
+/*
+ * Copyright (c) 2016 Mellanox Technologies, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "timeval.h"
+#include "netlink-socket.h"
+#include "netlink.h"
+#include "rtnetlink.h"
+#include "openvswitch/vlog.h"
+#include "openvswitch/ofpbuf.h"
+#include "tc.h"
+#include "util.h"
+#include "byte-order.h"
+
+VLOG_DEFINE_THIS_MODULE(tc);
+
+static struct vlog_rate_limit parse_err = VLOG_RATE_LIMIT_INIT(5, 5);
+
+/* Returns tc handle 'major':'minor'. */
+static unsigned int
+tc_make_handle(unsigned int major, unsigned int minor)
+{
+return TC_H_MAKE(major << 16, minor);
+}
+
+static struct tcmsg *
+tc_make_req(int ifindex, int type, unsigned int flags, struct ofpbuf *request)
+{
+struct tcmsg *tcmsg;
+struct nlmsghdr *nlmsghdr;
+
+ofpbuf_init(request, 512);
+
+nl_msg_reserve(request, NLMSG_HDRLEN + sizeof *tcmsg);
+nlmsghdr = nl_msg_put_uninit(request, NLMSG_HDRLEN);
+nlmsghdr->nlmsg_len = 0;
+nlmsghdr->nlmsg_type = type;
+nlmsghdr->nlmsg_flags = NLM_F_REQUEST | flags;
+nlmsghdr->nlmsg_seq = 0;
+nlmsghdr->nlmsg_pid = 0;
+
+tcmsg = ofpbuf_put_zeros(request, sizeof *tcmsg);
+tcmsg->tcm_family = AF_UNSPEC;
+tcmsg->tcm_ifindex = ifindex;
+
+return tcmsg;
+}
+
+static int
+tc_transact(struct ofpbuf *request, struct ofpbuf **replyp)
+{
+int error = nl_transact(NETLINK_ROUTE, request, replyp);
+
+ofpbuf_uninit(request);
+return error;
+}
+
+static const struct nl_policy tca_policy[] = {
+[TCA_KIND] = { .type = NL_A_STRING, .optional = false, },
+[TCA_OPTIONS] = { .type = NL_A_NESTED, .optional = false, },
+[TCA_STATS] = { .type = NL_A_UNSPEC,
+.min_len = sizeof(struct tc_stats), .optional = true, },
+[TCA_STATS2] = { .type = NL_A_NESTED, .optional = true, },
+};
+
+static const struct nl_policy tca_flower_policy[] = {
+[TCA_FLOWER_CLASSID] = { .type = NL_A_U32, .optional = true, },
+[TCA_FLOWER_INDEV] = { .type = NL_A_STRING, .max_len = IFNAMSIZ,
+   .optional = true, },
+[TCA_FLOWER_KEY_ETH_SRC] = { .type = NL_A_UNSPEC,
+ .min_len = ETH_ALEN, .optional = true, },
+[TCA_FLOWER_KEY_ETH_DST] = { .type = NL_A_UNSPEC,
+ .min_len = ETH_ALEN, .optional = true, },
+[TCA_FLOWER_KEY_ETH_SRC_MASK] = { .type = NL_A_UNSPEC,
+  .min_len = ETH_ALEN,
+  .optional = true, },
+[TCA_FLOWER_KEY_ETH_DST_MASK] = { .type = NL_A_UNSPEC,
+  .min_len = ETH_ALEN,
+  .optional = true, },
+[TCA_FLOWER_KEY_ETH_TYPE] = { .type = NL_A_U16, .optional = false, },
+[TCA_FLOWER_FLAGS] = { .type = NL_A_U32, .optional = false, },
+[TCA_FLOWER_ACT] = { .type = NL_A_NESTED, .optional = false, },
+[TCA_FLOWER_KEY_IP_PROTO] = { .type = NL_A_U8, .optional = true, },
+[TCA_FLOWER_KEY_IPV4_SRC] = { .type = NL_A_U32, .optional = true, },
+[TCA_FLOWER_KEY_IPV4_DST] = {.type = NL_A_U32, .optional = true, },
+[TCA_FLOWER_KEY_IPV4_SRC_MASK] = { .type = NL_A_U32, .optional = true, },
+[TCA_FLOWER_KEY_IPV4_DST_MASK] = { 

[ovs-dev] [PATCH ovs V3 06/25] dpif: Save added ports in a port map for netdev flow api use

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

To use netdev flow offloading api, dpifs needs to iterate over
added ports. This addition inserts the added dpif ports in a hash map,
The map will also be used to translate dpif ports to netdevs.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/dpif.c   |  25 
 lib/dpif.h   |   2 +
 lib/netdev.c | 121 +++
 lib/netdev.h |  15 
 4 files changed, 163 insertions(+)

diff --git a/lib/dpif.c b/lib/dpif.c
index 57aa3c6..d4e4c0a 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -352,7 +352,22 @@ do_open(const char *name, const char *type, bool create, 
struct dpif **dpifp)
 error = registered_class->dpif_class->open(registered_class->dpif_class,
name, create, );
 if (!error) {
+struct dpif_port_dump port_dump;
+struct dpif_port dpif_port;
+
 ovs_assert(dpif->dpif_class == registered_class->dpif_class);
+
+DPIF_PORT_FOR_EACH(_port, _dump, dpif) {
+struct netdev *netdev;
+int err = netdev_open(dpif_port.name, dpif_port.type, );
+
+if (!err) {
+netdev_hmap_port_add(netdev, DPIF_HMAP_KEY(dpif), _port);
+netdev_close(netdev);
+} else {
+VLOG_WARN("could not open netdev %s type %s", name, type);
+}
+}
 } else {
 dp_class_unref(registered_class);
 }
@@ -545,6 +560,14 @@ dpif_port_add(struct dpif *dpif, struct netdev *netdev, 
odp_port_t *port_nop)
 if (!error) {
 VLOG_DBG_RL(_rl, "%s: added %s as port %"PRIu32,
 dpif_name(dpif), netdev_name, port_no);
+
+/* temp dpif_port, will be cloned in netdev_hmap_port_add */
+struct dpif_port dpif_port;
+
+dpif_port.type = CONST_CAST(char *, netdev_get_type(netdev));
+dpif_port.name = CONST_CAST(char *, netdev_name);
+dpif_port.port_no = port_no;
+netdev_hmap_port_add(netdev, DPIF_HMAP_KEY(dpif), _port);
 } else {
 VLOG_WARN_RL(_rl, "%s: failed to add %s as port: %s",
  dpif_name(dpif), netdev_name, ovs_strerror(error));
@@ -569,6 +592,8 @@ dpif_port_del(struct dpif *dpif, odp_port_t port_no)
 if (!error) {
 VLOG_DBG_RL(_rl, "%s: port_del(%"PRIu32")",
 dpif_name(dpif), port_no);
+
+netdev_hmap_port_del(port_no, DPIF_HMAP_KEY(dpif));
 } else {
 log_operation(dpif, "port_del", error);
 }
diff --git a/lib/dpif.h b/lib/dpif.h
index d5b4b58..44cbe95 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -400,6 +400,8 @@
 extern "C" {
 #endif
 
+#define DPIF_HMAP_KEY(x) ((x)->dpif_class)
+
 struct dpif;
 struct dpif_class;
 struct dpif_flow;
diff --git a/lib/netdev.c b/lib/netdev.c
index d5935c3..792ab8c 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -2104,6 +2104,127 @@ netdev_init_flow_api(struct netdev *netdev)
 : EOPNOTSUPP);
 }
 
+/* Protects below port hashmaps. */
+static struct ovs_mutex netdev_hmap_mutex = OVS_MUTEX_INITIALIZER;
+
+static struct hmap port_to_netdev OVS_GUARDED_BY(netdev_hmap_mutex)
+= HMAP_INITIALIZER(_to_netdev);
+static struct hmap ifindex_to_port OVS_GUARDED_BY(netdev_hmap_mutex)
+= HMAP_INITIALIZER(_to_port);
+
+struct port_to_netdev_data {
+struct hmap_node node;
+struct netdev *netdev;
+struct dpif_port dpif_port;
+const void *obj;
+};
+
+struct ifindex_to_port_data {
+struct hmap_node node;
+int ifindex;
+odp_port_t port;
+};
+
+static int
+netdev_hmap_port_del_locked(odp_port_t port_no, const void *obj)
+{
+size_t hash = hash_int(odp_to_u32(port_no), hash_pointer(obj, 0));
+struct port_to_netdev_data *data;
+
+HMAP_FOR_EACH_WITH_HASH(data, node, hash, _to_netdev) {
+if (data->obj == obj && data->dpif_port.port_no == port_no) {
+break;
+}
+}
+
+if (data) {
+dpif_port_destroy(>dpif_port);
+netdev_close(data->netdev); /* unref and possibly close */
+hmap_remove(_to_netdev, >node);
+free(data);
+return 0;
+}
+
+return ENOENT;
+}
+
+int
+netdev_hmap_port_add(struct netdev *netdev, const void *obj,
+ struct dpif_port *dpif_port)
+{
+size_t hash = hash_int(odp_to_u32(dpif_port->port_no),
+   hash_pointer(obj, 0));
+struct port_to_netdev_data *data = xzalloc(sizeof *data);
+struct ifindex_to_port_data *ifidx = xzalloc(sizeof *ifidx);
+
+ovs_mutex_lock(_hmap_mutex);
+netdev_hmap_port_del_locked(dpif_port->port_no, obj);
+
+data->netdev = netdev_ref(netdev);
+data->obj = obj;
+dpif_port_clone(>dpif_port, dpif_port);
+
+ifidx->ifindex = netdev_get_ifindex(netdev);
+ifidx->port = dpif_port->port_no;
+
+hmap_insert(_to_netdev, >node, hash);
+hmap_insert(_to_port, >node, ifidx->ifindex);
+

[ovs-dev] [PATCH ovs V3 05/25] other-config: Add tc-policy switch to control tc flower flag

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Add a new configuration tc-policy option that controls tc
flower flag. Possible options are none, skip_sw, skip_hw.
The default is none which is to insert the rule both to sw and hw.
This option is only relevant if hw-offload is enabled.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev.c |  6 ++
 lib/tc.c | 43 ++-
 lib/tc.h |  1 +
 vswitchd/vswitch.xml | 17 +
 4 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/lib/netdev.c b/lib/netdev.c
index ca727a5..d5935c3 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -54,6 +54,9 @@
 #include "openvswitch/vlog.h"
 #include "flow.h"
 #include "util.h"
+#ifdef __linux__
+#include "tc.h"
+#endif
 
 VLOG_DEFINE_THIS_MODULE(netdev);
 
@@ -2115,6 +2118,9 @@ netdev_set_flow_api_enabled(const struct smap 
*ovs_other_config)
 
 VLOG_INFO("netdev: Flow API Enabled");
 
+tc_set_policy(smap_get_def(ovs_other_config, "tc-policy",
+   TC_POLICY_DEFAULT));
+
 ovsthread_once_done();
 }
 }
diff --git a/lib/tc.c b/lib/tc.c
index 431242b..b2e3d21 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -38,6 +38,14 @@ VLOG_DEFINE_THIS_MODULE(tc);
 
 static struct vlog_rate_limit parse_err = VLOG_RATE_LIMIT_INIT(5, 5);
 
+enum tc_offload_policy {
+TC_POLICY_NONE,
+TC_POLICY_SKIP_SW,
+TC_POLICY_SKIP_HW
+};
+
+static enum tc_offload_policy tc_policy = TC_POLICY_NONE;
+
 /* Returns tc handle 'major':'minor'. */
 unsigned int
 tc_make_handle(unsigned int major, unsigned int minor)
@@ -719,6 +727,18 @@ tc_get_flower(int ifindex, int prio, int handle, struct 
tc_flower *flower)
 return error;
 }
 
+static int
+tc_get_tc_cls_policy(enum tc_offload_policy policy)
+{
+if (policy == TC_POLICY_SKIP_HW) {
+return TCA_CLS_FLAGS_SKIP_HW;
+} else if (policy == TC_POLICY_SKIP_SW) {
+return TCA_CLS_FLAGS_SKIP_SW;
+}
+
+return 0;
+}
+
 static void
 nl_msg_put_act_push_vlan(struct ofpbuf *request, uint16_t vid, uint8_t prio)
 {
@@ -989,7 +1009,7 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct 
tc_flower *flower)
 }
 }
 
-nl_msg_put_u32(request, TCA_FLOWER_FLAGS, 0);
+nl_msg_put_u32(request, TCA_FLOWER_FLAGS, tc_get_tc_cls_policy(tc_policy));
 
 if (flower->tunnel.tunnel) {
 nl_msg_put_flower_tunnel(request, flower);
@@ -1033,3 +1053,24 @@ tc_replace_flower(int ifindex, uint16_t prio, uint32_t 
handle,
 
 return error;
 }
+
+void
+tc_set_policy(const char *policy)
+{
+if (!policy) {
+return;
+}
+
+if (!strcmp(policy, "skip_sw")) {
+tc_policy = TC_POLICY_SKIP_SW;
+} else if (!strcmp(policy, "skip_hw")) {
+tc_policy = TC_POLICY_SKIP_HW;
+} else if (!strcmp(policy, "none")) {
+tc_policy = TC_POLICY_NONE;
+} else {
+VLOG_WARN("tc: Invalid policy '%s'", policy);
+return;
+}
+
+VLOG_INFO("tc: Using policy '%s'", policy);
+}
diff --git a/lib/tc.h b/lib/tc.h
index 5ca6c55..6f6cc09 100644
--- a/lib/tc.h
+++ b/lib/tc.h
@@ -115,5 +115,6 @@ int tc_flush(int ifindex);
 int tc_dump_flower_start(int ifindex, struct nl_dump *dump);
 int parse_netlink_to_tc_flower(struct ofpbuf *reply,
struct tc_flower *flower);
+void tc_set_policy(const char *policy);
 
 #endif /* tc.h */
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 942e68f..8b9bdcb 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -183,6 +183,23 @@
 
   
 
+  
+
+Specified the policy used with HW offloading.
+Options:
+none- Add software rule and offload rule to 
HW.
+skip_sw - Offload rule to HW only.
+skip_hw - Add software rule without offloading 
rule to HW.
+
+
+This is only relevant if HW offloading is enabled (hw-offload).
+
+
+  The default value is false.
+
+  
+
   
 
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 00/25] Introducing HW offload support for openvswitch

2017-02-08 Thread Roi Dayan
This patch series introduces rule offload functionality to dpif-netlink 
via netdev ports new flow offloading API. The user can specify whether to
enable rule offloading or not via OVS configuration. Netdev providers
are able to implement netdev flow offload API in order to offload rules.

This patch series also implements one offload scheme for netdev-linux,
using TC flower classifier, which was chosen because its sort of natural
to state OVS DP rules for this classifier. However, the code can be
extended to support other classifiers such as U32, eBPF, etc which support
offload as well.

The use-case we are currently addressing is the newly sriov switchdev mode
in the Linux kernel which was introduced in version 4.8 [1][2].
This series was tested against sriov vfs vports representors of the
Mellanox 100G ConnectX-4 series exposed by the mlx5 kernel driver.


V2->V3:
- Code styling fixes
- Bug fixes
- Using already available macros/functions to match current OVS code
- Refactored code according to V2 review
- Replaced bool option skip-hw for string option tc-policy
- Added hw offload tests using policy skip_hw
- Fixed most compatability compiling issues
- Travis
https://travis-ci.org/roidayan/ovs/builds/199610124
- AppVeyor
https://ci.appveyor.com/project/roidayan/ovs/build/1.0.14
- Fixed compiling with DPDK enabled

TODO:
- need to fix datapath compiling issues found in travis after adding tc
  compatability headers
- need to fix failing test cases because of get_ifindex


V1->V2:
- Added generic netdev flow offloads API.
- Implemented relevant flow API in netdev-linux (and netdev-vport).
- Added a other_config hw-offload option to enable offloading (defaults to 
false).
- Fixed coding style to conform with OVS.
- Policy removed for now. (Will be discussed how best implemented later).


Thanks,
Paul & Roi


Paul Blakey (25):
  tc: Add tc flower interface
  netdev-linux: Move some tc related functions to tc.c
  netdev: Adding a new netdev api to be used for offloading flows
  other-config: Add hw-offload switch to control netdev flow offloading
  other-config: Add tc-policy switch to control tc flower flag
  dpif: Save added ports in a port map for netdev flow api use
  dpif-netlink: Flush added ports using netdev flow api
  netdev-tc-offloads: Implement netdev flow flush using tc interface
  dpif-netlink: Dump netdevs flows on flow dump
  netdev-tc-offloads: Add ufid to tc/netdev map
  netdev-tc-offloads: Implement netdev flow dump api using tc interface
  dpif-netlink: Use netdev flow put api to insert a flow
  netdev-tc-offloads: Add flower mask to priority map
  netdev-tc-offloads: Implement netdev flow put using tc interface
  dpif-netlink: Delete a flow from netdev
  netdev-tc-offloads: Implement netdev flow del using tc interface
  dpif-netlink: Use netdev flow get api to query a flow
  netdev-tc-offloads: Implement flow get using tc interface
  netdev-linux: Disallow setting policing when configured with hw
offload
  netdev-vport: Implement netdev vport get_ifindex on Linux
  netdev-vport: Use common offloads interface
  netdev-tc-offloads: Add ingress on netdev flow api init
  dpctl: Add an option to dump only certain kinds of flows
  tests: Add system-offloads-testsuite
  compat: Add tc compatibility headers for old kernels

 acinclude.m4 |   26 +
 configure.ac |1 +
 include/automake.mk  |1 +
 include/linux/automake.mk|4 +
 include/linux/pkt_cls.h  |  579 ++
 include/linux/tc_act/tc_tunnel_key.h |   48 ++
 include/linux/tc_act/tc_vlan.h   |   44 ++
 lib/automake.mk  |4 +
 lib/dpctl.c  |   21 +-
 lib/dpif-netdev.c|3 +-
 lib/dpif-netlink.c   |  484 ++-
 lib/dpif-provider.h  |6 +-
 lib/dpif.c   |   29 +-
 lib/dpif.h   |5 +-
 lib/netdev-bsd.c |2 +
 lib/netdev-dpdk.c|1 +
 lib/netdev-dummy.c   |2 +
 lib/netdev-linux.c   |  194 ++
 lib/netdev-linux.h   |   11 +
 lib/netdev-provider.h|   53 ++
 lib/netdev-tc-offloads.c |  820 ++
 lib/netdev-tc-offloads.h |   42 ++
 lib/netdev-vport.c   |   50 +-
 lib/netdev.c |  326 ++
 lib/netdev.h |   40 ++
 lib/odp-util.c   |   53 ++
 lib/odp-util.h   |3 +
 lib/tc.c | 1076 ++
 lib/tc.h |  120 
 ofproto/ofproto-dpif-upcall.c|3 +-
 ofproto/ofproto-dpif.c   |2 +-
 

[ovs-dev] [PATCH ovs V3 04/25] other-config: Add hw-offload switch to control netdev flow offloading

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Add a new configuration option - hw-offload that enables netdev
flow api. Enabling this option will allow offloading flows
using netdev implementation instead of the kernel datapath.
This configuration option defaults to false - disabled.

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev.c | 26 ++
 lib/netdev.h |  2 ++
 vswitchd/bridge.c|  1 +
 vswitchd/vswitch.xml | 11 +++
 4 files changed, 40 insertions(+)

diff --git a/lib/netdev.c b/lib/netdev.c
index 45ea7d2..ca727a5 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -2092,7 +2092,33 @@ netdev_init_flow_api(struct netdev *netdev)
 {
 const struct netdev_class *class = netdev->netdev_class;
 
+if (!netdev_flow_api_enabled) {
+return EOPNOTSUPP;
+}
+
 return (class->init_flow_api
 ? class->init_flow_api(netdev)
 : EOPNOTSUPP);
 }
+
+bool netdev_flow_api_enabled = false;
+
+void
+netdev_set_flow_api_enabled(const struct smap *ovs_other_config)
+{
+#ifdef __linux__
+if (smap_get_bool(ovs_other_config, "hw-offload", false)) {
+static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+
+if (ovsthread_once_start()) {
+netdev_flow_api_enabled = true;
+
+VLOG_INFO("netdev: Flow API Enabled");
+
+ovsthread_once_done();
+}
+}
+#else
+netdev_flow_api_enabled = false;
+#endif
+}
diff --git a/lib/netdev.h b/lib/netdev.h
index 8638bfd..d7d4199 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -178,6 +178,8 @@ int netdev_flow_get(struct netdev *, struct match *, struct 
nlattr **actions,
 int netdev_flow_del(struct netdev *, struct dpif_flow_stats *,
 const ovs_u128 *);
 int netdev_init_flow_api(struct netdev *);
+extern bool netdev_flow_api_enabled;
+void netdev_set_flow_api_enabled(const struct smap *ovs_other_config);
 
 /* native tunnel APIs */
 /* Structure to pass parameters required to build a tunnel header. */
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 21c3c79..48fbd1d 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2937,6 +2937,7 @@ bridge_run(void)
 cfg = ovsrec_open_vswitch_first(idl);
 
 if (cfg) {
+netdev_set_flow_api_enabled(>other_config);
 dpdk_init(>other_config);
 }
 
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 146a816..942e68f 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -170,6 +170,17 @@
 
   The default is 1.
 
+
+
+  
+
+  Set this value to true to enable netdev flow offload.
+
+
+  The default value is false. Changing this value requires
+  restarting the daemon
+
   
 
   https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs V3 03/25] netdev: Adding a new netdev api to be used for offloading flows

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/automake.mk  |   2 +
 lib/netdev-bsd.c |   2 +
 lib/netdev-dpdk.c|   1 +
 lib/netdev-dummy.c   |   2 +
 lib/netdev-linux.c   |  15 +++--
 lib/netdev-linux.h   |   9 +++
 lib/netdev-provider.h|  53 
 lib/netdev-tc-offloads.c | 154 +++
 lib/netdev-tc-offloads.h |  42 +
 lib/netdev-vport.c   |  11 +++-
 lib/netdev.c |  98 ++
 lib/netdev.h |  23 +++
 12 files changed, 407 insertions(+), 5 deletions(-)
 create mode 100644 lib/netdev-tc-offloads.c
 create mode 100644 lib/netdev-tc-offloads.h

diff --git a/lib/automake.mk b/lib/automake.mk
index a6141ea..66d8ab8 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -353,6 +353,8 @@ lib_libopenvswitch_la_SOURCES += \
lib/dpif-netlink.h \
lib/tc.h \
lib/tc.c \
+   lib/netdev-tc-offloads.h \
+   lib/netdev-tc-offloads.c \
lib/if-notifier.c \
lib/if-notifier.h \
lib/netdev-linux.c \
diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c
index 94c515d..5b54d79 100644
--- a/lib/netdev-bsd.c
+++ b/lib/netdev-bsd.c
@@ -1547,6 +1547,8 @@ netdev_bsd_update_flags(struct netdev *netdev_, enum 
netdev_flags off,
 netdev_bsd_rxq_recv, \
 netdev_bsd_rxq_wait, \
 netdev_bsd_rxq_drain,\
+ \
+NO_OFFLOAD_API   \
 }
 
 const struct netdev_class netdev_bsd_class =
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 94568a1..539e388 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -3310,6 +3310,7 @@ unlock:
 RXQ_RECV, \
 NULL,   /* rx_wait */ \
 NULL,   /* rxq_drain */   \
+NO_OFFLOAD_API\
 }
 
 static const struct netdev_class dpdk_class =
diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 0657434..7e1383f 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -1409,6 +1409,8 @@ netdev_dummy_update_flags(struct netdev *netdev_,
 netdev_dummy_rxq_recv,  \
 netdev_dummy_rxq_wait,  \
 netdev_dummy_rxq_drain, \
+\
+NO_OFFLOAD_API  \
 }
 
 static const struct netdev_class dummy_class =
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 085f530..0828d96 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -73,6 +73,7 @@
 #include "openvswitch/vlog.h"
 #include "util.h"
 #include "tc.h"
+#include "netdev-tc-offloads.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_linux);
 
@@ -2762,7 +2763,8 @@ netdev_linux_update_flags(struct netdev *netdev_, enum 
netdev_flags off,
 }
 
 #define NETDEV_LINUX_CLASS(NAME, CONSTRUCT, GET_STATS,  \
-   GET_FEATURES, GET_STATUS)\
+   GET_FEATURES, GET_STATUS,\
+   FLOW_OFFLOAD_API)\
 {   \
 NAME,   \
 false,  /* is_pmd */\
@@ -2831,6 +2833,8 @@ netdev_linux_update_flags(struct netdev *netdev_, enum 
netdev_flags off,
 netdev_linux_rxq_recv,  \
 netdev_linux_rxq_wait,  \
 netdev_linux_rxq_drain, \
+\
+FLOW_OFFLOAD_API\
 }
 
 const struct netdev_class netdev_linux_class =
@@ -2839,7 +2843,8 @@ const struct netdev_class netdev_linux_class =
 netdev_linux_construct,
 netdev_linux_get_stats,
 netdev_linux_get_features,
-netdev_linux_get_status);
+netdev_linux_get_status,
+LINUX_FLOW_OFFLOAD_API);
 
 const struct netdev_class netdev_tap_class =
 NETDEV_LINUX_CLASS(
@@ -2847,7 +2852,8 @@ const struct netdev_class netdev_tap_class =
 netdev_linux_construct_tap,
 netdev_tap_get_stats,
 netdev_linux_get_features,
-netdev_linux_get_status);
+netdev_linux_get_status,
+NO_OFFLOAD_API);
 
 const struct netdev_class netdev_internal_class =
 NETDEV_LINUX_CLASS(
@@ -2855,7 +2861,8 @@ const struct netdev_class netdev_internal_class =
 netdev_linux_construct,
 netdev_internal_get_stats,
  

[ovs-dev] [PATCH ovs V3 02/25] netdev-linux: Move some tc related functions to tc.c

2017-02-08 Thread Roi Dayan
From: Paul Blakey 

Those that we want to reuse in tc.c

Signed-off-by: Paul Blakey 
Reviewed-by: Roi Dayan 
---
 lib/netdev-linux.c | 164 +
 lib/tc.c   |  81 +-
 lib/tc.h   |  11 
 3 files changed, 117 insertions(+), 139 deletions(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 9ff1333..085f530 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -29,8 +29,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -74,6 +72,7 @@
 #include "unaligned.h"
 #include "openvswitch/vlog.h"
 #include "util.h"
+#include "tc.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_linux);
 
@@ -434,18 +433,14 @@ static const struct tc_ops *const tcs[] = {
 NULL
 };
 
-static unsigned int tc_make_handle(unsigned int major, unsigned int minor);
-static unsigned int tc_get_major(unsigned int handle);
-static unsigned int tc_get_minor(unsigned int handle);
-
 static unsigned int tc_ticks_to_bytes(unsigned int rate, unsigned int ticks);
 static unsigned int tc_bytes_to_ticks(unsigned int rate, unsigned int size);
 static unsigned int tc_buffer_per_jiffy(unsigned int rate);
+static struct tcmsg *netdev_linux_tc_make_request(const struct netdev *,
+  int type,
+  unsigned int flags,
+  struct ofpbuf *);
 
-static struct tcmsg *tc_make_request(const struct netdev *, int type,
- unsigned int flags, struct ofpbuf *);
-static int tc_transact(struct ofpbuf *request, struct ofpbuf **replyp);
-static int tc_add_del_ingress_qdisc(struct netdev *netdev, bool add);
 static int tc_add_policer(struct netdev *,
   uint32_t kbits_rate, uint32_t kbits_burst);
 
@@ -2055,12 +2050,18 @@ netdev_linux_set_policing(struct netdev *netdev_,
 struct netdev_linux *netdev = netdev_linux_cast(netdev_);
 const char *netdev_name = netdev_get_name(netdev_);
 int error;
+int ifindex;
 
 kbits_burst = (!kbits_rate ? 0   /* Force to 0 if no rate specified. */
: !kbits_burst ? 8000 /* Default to 8000 kbits if 0. */
: kbits_burst);   /* Stick with user-specified value. */
 
 ovs_mutex_lock(>mutex);
+error = get_ifindex(netdev_, );
+if (error) {
+goto out;
+}
+
 if (netdev->cache_valid & VALID_POLICING) {
 error = netdev->netdev_policing_error;
 if (error || (netdev->kbits_rate == kbits_rate &&
@@ -2073,7 +2074,7 @@ netdev_linux_set_policing(struct netdev *netdev_,
 
 COVERAGE_INC(netdev_set_policing);
 /* Remove any existing ingress qdisc. */
-error = tc_add_del_ingress_qdisc(netdev_, false);
+error = tc_add_del_ingress_qdisc(ifindex, false);
 if (error) {
 VLOG_WARN_RL(, "%s: removing policing failed: %s",
  netdev_name, ovs_strerror(error));
@@ -2081,7 +2082,7 @@ netdev_linux_set_policing(struct netdev *netdev_,
 }
 
 if (kbits_rate) {
-error = tc_add_del_ingress_qdisc(netdev_, true);
+error = tc_add_del_ingress_qdisc(ifindex, true);
 if (error) {
 VLOG_WARN_RL(, "%s: adding policing qdisc failed: %s",
  netdev_name, ovs_strerror(error));
@@ -2350,7 +2351,7 @@ start_queue_dump(const struct netdev *netdev, struct 
queue_dump_state *state)
 struct ofpbuf request;
 struct tcmsg *tcmsg;
 
-tcmsg = tc_make_request(netdev, RTM_GETTCLASS, 0, );
+tcmsg = netdev_linux_tc_make_request(netdev, RTM_GETTCLASS, 0, );
 if (!tcmsg) {
 return false;
 }
@@ -2909,8 +2910,8 @@ codel_setup_qdisc__(struct netdev *netdev, uint32_t 
target, uint32_t limit,
 
 tc_del_qdisc(netdev);
 
-tcmsg = tc_make_request(netdev, RTM_NEWQDISC,
-NLM_F_EXCL | NLM_F_CREATE, );
+tcmsg = netdev_linux_tc_make_request(netdev, RTM_NEWQDISC,
+ NLM_F_EXCL | NLM_F_CREATE, );
 if (!tcmsg) {
 return ENODEV;
 }
@@ -3127,8 +3128,8 @@ fqcodel_setup_qdisc__(struct netdev *netdev, uint32_t 
target, uint32_t limit,
 
 tc_del_qdisc(netdev);
 
-tcmsg = tc_make_request(netdev, RTM_NEWQDISC,
-NLM_F_EXCL | NLM_F_CREATE, );
+tcmsg = netdev_linux_tc_make_request(netdev, RTM_NEWQDISC,
+ NLM_F_EXCL | NLM_F_CREATE, );
 if (!tcmsg) {
 return ENODEV;
 }
@@ -3351,8 +3352,8 @@ sfq_setup_qdisc__(struct netdev *netdev, uint32_t 
quantum, uint32_t perturb)
 
 tc_del_qdisc(netdev);
 
-tcmsg = tc_make_request(netdev, RTM_NEWQDISC,
-NLM_F_EXCL | NLM_F_CREATE, );
+tcmsg = netdev_linux_tc_make_request(netdev, RTM_NEWQDISC,
+   

[ovs-dev] [PATCHv2 2/2] ovs-ofctl: fix memory leak reported by valgrind.

2017-02-08 Thread William Tu
Testcase 1057 ofproto-dpif - fragment handling - upcall reports
the following leak:
  xrealloc (util.c:123)
  vconn_dump_flows (vconn.c:1030)
  read_flows_from_switch (ovs-ofctl.c:3360)
  ofctl_replace_flows (ovs-ofctl.c:3433)
  ovs_cmdl_run_command__ (command-line.c:115)

Signed-off-by: William Tu 
---
 utilities/ovs-ofctl.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 4e11623..77332e0 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -3375,6 +3375,11 @@ read_flows_from_switch(struct vconn *vconn,
 
 fte_queue(state, >match, fs->priority, version, index);
 }
+
+for (size_t i = 0; i < n_fses; i++) {
+free(CONST_CAST(struct ofpact *, fses[i].ofpacts));
+}
+free(fses);
 }
 
 static void
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCHv2 1/2] ovs-router: fix memory leak reported by valgrind.

2017-02-08 Thread William Tu
Valgrind testcase 772: appctl - route/lookup6 reports the
following definitely lost:
  xmalloc (util.c:112)
  miniflow_alloc (flow.c:2500)
  minimatch_init (match.c:1387)
  rt_entry_delete (ovs-router.c:274)
  ovs_router_del (ovs-router.c:384)
  process_command (unixctl.c:313)

Signed-off-by: William Tu 
---
 lib/ovs-router.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/ovs-router.c b/lib/ovs-router.c
index d98de20..0c5430a 100644
--- a/lib/ovs-router.c
+++ b/lib/ovs-router.c
@@ -280,6 +280,8 @@ rt_entry_delete(uint32_t mark, uint8_t priority,
 res = __rt_entry_delete(cr);
 ovs_mutex_unlock();
 }
+
+cls_rule_destroy();
 return res;
 }
 
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 1/2] ovs-router: fix memory leak reported by valgrind.

2017-02-08 Thread William Tu
yes, thanks.
I will introduce cls_rule_destroy() and free the minimatch inside.
--William

On Tue, Feb 7, 2017 at 11:33 PM, Andy Zhou  wrote:
> On Tue, Feb 7, 2017 at 10:41 PM, William Tu  wrote:
>> Valgrind testcase 772: appctl - route/lookup6 reports the
>> following definitely lost:
>>   xmalloc (util.c:112)
>>   miniflow_alloc (flow.c:2500)
>>   minimatch_init (match.c:1387)
>>   rt_entry_delete (ovs-router.c:274)
>>   ovs_router_del (ovs-router.c:384)
>>   process_command (unixctl.c:313)
>>
>> Signed-off-by: William Tu 
>> ---
>>  lib/ovs-router.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/lib/ovs-router.c b/lib/ovs-router.c
>> index d98de20..53fb834 100644
>> --- a/lib/ovs-router.c
>> +++ b/lib/ovs-router.c
>> @@ -280,6 +280,7 @@ rt_entry_delete(uint32_t mark, uint8_t priority,
>>  res = __rt_entry_delete(cr);
>>  ovs_mutex_unlock();
>>  }
>> +minimatch_destroy(CONST_CAST(struct minimatch *, ));
>>  return res;
>>  }
>>
>
> Acked-by: Andy Zhou ,
>
> May be this can be easier to read?
>
> diff --git a/lib/ovs-router.c b/lib/ovs-router.c
> index d98de20..794fdde 100644
> --- a/lib/ovs-router.c
> +++ b/lib/ovs-router.c
> @@ -280,6 +280,9 @@ rt_entry_delete(uint32_t mark, uint8_t priority,
>  res = __rt_entry_delete(cr);
>  ovs_mutex_unlock();
>  }
> +
> +cls_rule_destroy();
>  return res;
>  }
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 2/2] doc: Add info on distributions shipping openvswitch package.

2017-02-08 Thread Flavio Leitner
On Tue, Feb 07, 2017 at 09:18:23PM +, Bhanuprakash Bodireddy wrote:
> List details of various popular distributions shipping Open vSwitch
> packages. Also include the information of the distros supporting DPDK
> accelerated datapath.
> 
> Signed-off-by: Bhanuprakash Bodireddy 
> ---
>  Documentation/automake.mk |  1 +
>  Documentation/intro/install/distributions.rst | 72 
> +++
>  Documentation/intro/install/index.rst |  1 +
>  3 files changed, 74 insertions(+)
>  create mode 100644 Documentation/intro/install/distributions.rst
> 
> diff --git a/Documentation/automake.mk b/Documentation/automake.mk
> index 42553f0..456ab44 100644
> --- a/Documentation/automake.mk
> +++ b/Documentation/automake.mk
> @@ -12,6 +12,7 @@ EXTRA_DIST += \
>   Documentation/intro/install/bash-completion.rst \
>   Documentation/intro/install/debian.rst \
>   Documentation/intro/install/documentation.rst \
> + Documentation/intro/install/distributions.rst \
>   Documentation/intro/install/dpdk.rst \
>   Documentation/intro/install/fedora.rst \
>   Documentation/intro/install/general.rst \
> diff --git a/Documentation/intro/install/distributions.rst 
> b/Documentation/intro/install/distributions.rst
> new file mode 100644
> index 000..c991eda
> --- /dev/null
> +++ b/Documentation/intro/install/distributions.rst
> @@ -0,0 +1,72 @@
> +..
> +  Licensed under the Apache License, Version 2.0 (the "License"); you may
> +  not use this file except in compliance with the License. You may obtain
> +  a copy of the License at
> +
> +  http://www.apache.org/licenses/LICENSE-2.0
> +
> +  Unless required by applicable law or agreed to in writing, software
> +  distributed under the License is distributed on an "AS IS" BASIS, 
> WITHOUT
> +  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See 
> the
> +  License for the specific language governing permissions and limitations
> +  under the License.
> +
> +  Convention for heading levels in Open vSwitch documentation:
> +
> +  ===  Heading 0 (reserved for the title in a document)
> +  ---  Heading 1
> +  ~~~  Heading 2
> +  +++  Heading 3
> +  '''  Heading 4
> +
> +  Avoid deeper levels because they do not render well.
> +
> +
> +Distributions packaging Open vSwitch
> +
> +
> +This document lists various popular distributions packaging Open vSwitch.
> +Open vSwitch is packaged by various distributions for multiple platforms and
> +architectures.
> +
> +.. note::
> +  The packaged version available with distributions may not be latest
> +  Open vSwitch release.
> +
> +Debian
> +---
> +
> +You can use ``apt-get`` or ``aptitude`` to install the .deb packages and must
> +be superuser.
> +
> +1. Debian has ``openvswitch-switch`` and ``openvswitch-common`` .deb packages
> +that includes the core userspace components of the switch.
> +
> +2. For kernel datapath, ``openvswitch-datapath-dkms`` can be installed to
> +automatically build and install Open vSwitch kernel module for your running
> +kernel.
> +
> +3. For DPDK datapath, Open vSwitch with DPDK support is bundled in the 
> package
> +``openvswitch-switch-dpdk``.
> +
> +Fedora
> +--
> +
> +Fedora provides ``openvswitch``, ``openvswitch-devel``, ``openvswitch-test``
> +and ``openvswitch-debuginfo`` rpm packages. You can install ``openvswitch``
> +package in minimum installation. Use ``yum`` or ``dnf`` to install the rpm
> +packages and must be superuser.
> +
> +Redhat
> +--
> +
> +RHEL distributes ``openvswitch`` rpm package that supports kernel datapath.
> +DPDK accelerated Open vSwitch can be installed using ``openvswitch-dpdk``
> +package.


That has changed and now there is only a single package (DPDK enabled)
called ``openvswitch``.

-- 
Flavio

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] how ovs implements QoS funtion

2017-02-08 Thread lg.yue
Ben Pfaff, Hi:
 i have to make it clear that QoS here refers to bandwidth limitation(TC), 
rather than  dscp or tos.   what i want to do is to limit the bandwidth of  vif 
and ovn's router port.
 allocate_chassis_queueid and dpif_queue_to_priority tell that  queue_id is 
a incremental number . in kernel function execute_masked_set_action just assign 
the value of queue_id to  skb->priority , then sent it to one queue.
 no code tell  the connection between priority and tc's class id.   ovn 
only support htb , and all qos rules are set to physical ethernet(for example 
eth0), how vif's packets are sent to eth0's tc class?


take a look at my environment:
#ovs-dpctl dump-flows
recirc_id(0),skb_priority(0),in_port(3),eth(src=02:ac:10:ff:00:11,dst=02:ac:10:ff:00:22),eth_type(0x0800),ipv4(tos=0/0x3,frag=no),actions:set(tunnel(tun_id=0x1,dst=101.158.40.159,ttl=64,tp_dst=6081,geneve({class=0x102,type=0x80,len=4,0x10002}),flags(df|csum|key))),set(skb_priority(0x10002)),2

# tc qdisc show dev eth0
qdisc htb 1: root refcnt 2 r2q 10 default 1 direct_packets_stat 17490

#  tc class show dev eth0
class htb 1:fffe root rate 10Kbit ceil 10Kbit burst 1500b cburst 1500b 
class htb 1:2 parent 1:fffe prio 0 rate 12000bit ceil 25000bit burst 2499b 
cburst 2500b

 my question is:
1.  does the flow 'set(skb_priority(0x10002))' have something to do with class 
htb 1:2 ? and how?  
source code is preferable


thanks very much.












At 2017-02-08 00:39:36, "Ben Pfaff"  wrote:
>On Tue, Feb 07, 2017 at 09:21:05PM +0800, lg.yue wrote:
>> i want to understand how QoS is implemented in ovs.  
>> according to my understanding,  lflow 'actions=set_queue:1' is 
>> translated into a ofpbuf(type=OFPAT_RAW_QUEUE, queue_id=1).  
>> but in funxtion do_xlate_actions,when type is  OFPACT_SET_QUEUE, 
>> queue_id is translated into skb_priority, why?
>> 
>> whether  or not i miss something? please correct me and tell the 
>> complete process-flow.
>
>OVS depends on the datapath (usually, the Linux kernel) to actually
>implement QoS.  It uses the skb_priority field to tell the datapath the
>output queue, translating the queue number into a datapath-specific
>priority.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 1/1] doc: Clarify how user space is experimental.

2017-02-08 Thread Ian Stokes
Clarify that the use of the user space datapath with non DPDK devices is
considered experimental.

Fixes: 602e24ee189b (doc: Remove experimental warning for DPDK.)
Signed-off-by: Ian Stokes 
Co-authored-by: Joe Stringer 
---
 README.rst |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.rst b/README.rst
index afdd9bc..f3ae25a 100644
--- a/README.rst
+++ b/README.rst
@@ -41,8 +41,8 @@ The included Linux kernel module supports Linux 3.10 and up.
 Open vSwitch can also operate entirely in userspace without assistance from
 a kernel module.  This userspace implementation should be easier to port than
 the kernel-based switch. OVS in userspace can access Linux or DPDK devices.
-Note Open vSwitch with Linux devices in userspace is considered experimental
-and comes with a cost in performance.
+Note Open vSwitch with user space datapath and non DPDK devices is considered
+experimental and comes with a cost in performance.
 
 What's here?
 
-- 
1.7.0.7

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v4 1/1] doc: Remove experimental warning for DPDK.

2017-02-08 Thread Stokes, Ian
> On 7 February 2017 at 12:22, Stokes, Ian  wrote:
> >> On 6 February 2017 at 09:20, Ian Stokes  wrote:
> >> > Remove the experimental warning tag in documentation regarding OVS
> >> > deployed with DPDK.
> >> >
> >> > Signed-off-by: Ian Stokes 
> >>
> >> 
> >>
> >> > diff --git a/README.rst b/README.rst index f5cdaa5..afdd9bc 100644
> >> > --- a/README.rst
> >> > +++ b/README.rst
> >> > @@ -38,9 +38,11 @@ following features:
> >> >
> >> >  The included Linux kernel module supports Linux 3.10 and up.
> >> >
> >> > -Open vSwitch can also operate, at a cost in performance, entirely
> >> > in userspace, -without assistance from a kernel module.  This
> >> > userspace implementation should -be easier to port than the kernel-
> based switch.
> >> It is considered experimental.
> >> > +Open vSwitch can also operate entirely in userspace without
> >> > +assistance from a kernel module.  This userspace implementation
> >> > +should be easier to port than the kernel-based switch. OVS in
> >> > +userspace
> >> can access Linux or DPDK devices.
> >> > +Note Open vSwitch with Linux devices in userspace is considered
> >> > +experimental and comes with a cost in performance.
> >>
> >> I wonder if we can clarify this last sentence, it appears to be
> >> causing some confusion about the status of the kernel datapath.
> >
> > Do you mean it causes confunsion in terms of performance of kernel space
> vs user space?
> 
> Not related to performance, but whether kernel datapath is considered
> experimental or not.
> 
> > If that’s the case we could change it to
> >
> > +Note Open vSwitch with Linux devices in userspace is considered
> > +experimental and comes with a cost in performance when compared to
> kernel space.
> 
> I think the problem is "Open vSwitch with Linux devices in userspace".
> This doesn't precisely define usage of the userspace datapath.
> 
> Perhaps this?
> 
> Note Open vSwitch with userspace datapath and non-DPDK devices is
> considered experimental and comes with a cost in performance.

Agreed, that seems clearer. I'll submit a patch with the change.

Ian
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [DPDK:patch_v5 8/8] Update NEWS for userspace datapath NAT

2017-02-08 Thread Darrell Ball
Signed-off-by: Darrell Ball 
---
 NEWS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/NEWS b/NEWS
index aebd99c..890549f 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ Post-v2.7.0
- Tunnels:
  * Added support to set packet mark for tunnel endpoint using
`egress_pkt_mark` OVSDB option.
+   - Userspace Datapath NAT:
+ * Added NAT support for userspace datapath.
 
 v2.7.0 - xx xxx 
 -
-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [DPDK:patch_v5 7/8] Enable NAT tests for userspace datapath.

2017-02-08 Thread Darrell Ball
Signed-off-by: Darrell Ball 
---
 tests/system-userspace-macros.at | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tests/system-userspace-macros.at b/tests/system-userspace-macros.at
index 631f71a..6e3d468 100644
--- a/tests/system-userspace-macros.at
+++ b/tests/system-userspace-macros.at
@@ -99,9 +99,6 @@ m4_define([CHECK_CONNTRACK_LOCAL_STACK],
 # CHECK_CONNTRACK_NAT()
 #
 # Perform requirements checks for running conntrack NAT tests. The userspace
-# doesn't support NATs yet, so skip the tests
+# datapath supports NAT.
 #
-m4_define([CHECK_CONNTRACK_NAT],
-[
-AT_SKIP_IF([:])
-])
+m4_define([CHECK_CONNTRACK_NAT])
-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [DPDK:patch_v5 3/8] Remove batch sorting in userspace conntrack.

2017-02-08 Thread Darrell Ball
Signed-off-by: Darrell Ball 
---
 lib/conntrack.c | 49 ++---
 1 file changed, 10 insertions(+), 39 deletions(-)

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 0a611a2..ee515a0 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -284,16 +284,8 @@ conntrack_execute(struct conntrack *ct, struct 
dp_packet_batch *pkt_batch,
 enum { KEY_ARRAY_SIZE = NETDEV_MAX_BURST };
 #endif
 struct conn_lookup_ctx ctxs[KEY_ARRAY_SIZE];
-int8_t bucket_list[CONNTRACK_BUCKETS];
-struct {
-unsigned bucket;
-unsigned long maps;
-} arr[KEY_ARRAY_SIZE];
 long long now = time_msec();
 size_t i = 0;
-uint8_t arrcnt = 0;
-
-BUILD_ASSERT_DECL(sizeof arr[0].maps * CHAR_BIT >= NETDEV_MAX_BURST);
 
 if (helper) {
 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5);
@@ -302,51 +294,30 @@ conntrack_execute(struct conntrack *ct, struct 
dp_packet_batch *pkt_batch,
 /* Continue without the helper */
 }
 
-memset(bucket_list, INT8_C(-1), sizeof bucket_list);
 for (i = 0; i < cnt; i++) {
-unsigned bucket;
-
 if (!conn_key_extract(ct, pkts[i], dl_type, [i], zone)) {
 write_ct_md(pkts[i], CS_INVALID, zone, 0, OVS_U128_ZERO);
 continue;
 }
 
-bucket = hash_to_bucket(ctxs[i].hash);
-if (bucket_list[bucket] == INT8_C(-1)) {
-bucket_list[bucket] = arrcnt;
-
-arr[arrcnt].maps = 0;
-ULLONG_SET1(arr[arrcnt].maps, i);
-arr[arrcnt++].bucket = bucket;
-} else {
-ULLONG_SET1(arr[bucket_list[bucket]].maps, i);
-}
-}
-
-for (i = 0; i < arrcnt; i++) {
-struct conntrack_bucket *ctb = >buckets[arr[i].bucket];
-size_t j;
+unsigned bucket = hash_to_bucket(ctxs[i].hash);
+struct conntrack_bucket *ctb = >buckets[bucket];
 
 ct_lock_lock(>lock);
+conn_key_lookup(ctb, [i], now);
 
-ULLONG_FOR_EACH_1(j, arr[i].maps) {
-struct conn *conn;
-
-conn_key_lookup(ctb, [j], now);
+struct conn *conn = process_one(ct, pkts[i], [i], zone,
+commit, now);
 
-conn = process_one(ct, pkts[j], [j], zone, commit, now);
-
-if (conn && setmark) {
-set_mark(pkts[j], conn, setmark[0], setmark[1]);
-}
+if (conn && setmark) {
+set_mark(pkts[i], conn, setmark[0], setmark[1]);
+}
 
-if (conn && setlabel) {
-set_label(pkts[j], conn, [0], [1]);
-}
+if (conn && setlabel) {
+set_label(pkts[i], conn, [0], [1]);
 }
 ct_lock_unlock(>lock);
 }
-
 return 0;
 }
 
-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [DPDK:patch_v5 0/8] Userspace Datapath: Introduce NAT support.

2017-02-08 Thread Darrell Ball
This patch series introduces NAT support for the userspace datapath.

The per packet scope of lookups for NAT and un_NAT is at
the bucket level rather than global. One hash table is
introduced to support create/delete handling. The create/delete
events may be further optimized, if the need becomes clear.

The existing NAT tests are enabled for the dpdk datapath,
with an added enhancement to the V6 NAT test.

Some NAT options with limited utility (persistent, random) are
not supported yet, but will be supported in a later patch.

One V6 api is exported to facilitate selective editing the V6
header - packet_set_ipv6_addr().

alg and fragmentation support are not included here but are
being worked on.

I realize patch 4 is big. It may be clearer and easier to keep
as a single patch, so I have done that after some discussion.

v4->v5: Remove packet sorting in userspace datapath conntrack.
Simplify conntrack state code.
Fix sparse error.
Address code review comments from Daniele.

v3->v4: Fix rev_key vs key for nat_conn_keys access in a couple
places; this would have affected cleanup; at same time
rename some variables and change nat_conn_keys APIs to
use conn key, rather than conn.

Fix conntrack_flush() CT_CONN_TYPE_DEFAULT flag placement;
the intention was that it be the same as in sweep_bucket().

Fix nat_ipv6_addrs_delta() max boundary checking logic. I
also enhanced the conntrack - IPv6 HTTP with NAT test to
give it more coverage as partial penance.

Rebase

v2->v3: Fix a theoretical resend for closed connection restart.
Parse out a function to help and also limit
conn_state_update() to one.

I decided to cap V6 address range delta at 4 billion using
internal adjustment (user visibility not required).

Some cleanup of deprecated code path.

Parse out some more changes as separate patches.

v1->v2: Updates/fixes that were missed in v1 patches.

Darrell Ball (8):
  Export packet_set_ipv6_addr() for DPDK.
  Parse NAT netlink for userspace datapath.
  Remove batch sorting in userspace conntrack.
  Userspace Datapath: Introduce NAT Support.
  Enhance V6 NAT test.
  Add missing CHECK_CONNTRACK_ALG guards.
  Enable NAT tests for userspace datapath.
  Update NEWS for userspace datapath NAT

 NEWS |   2 +
 lib/conntrack-private.h  |  25 +-
 lib/conntrack.c  | 799 +--
 lib/conntrack.h  |  75 +++-
 lib/dpif-netdev.c|  82 +++-
 lib/packets.c|   2 +-
 lib/packets.h|   4 +
 tests/system-traffic.at  |   7 +-
 tests/system-userspace-macros.at |   7 +-
 tests/test-conntrack.c   |   8 +-
 10 files changed, 867 insertions(+), 144 deletions(-)

-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [DPDK:patch_v5 1/8] Export packet_set_ipv6_addr() for DPDK.

2017-02-08 Thread Darrell Ball
Signed-off-by: Darrell Ball 
---
 lib/packets.c | 2 +-
 lib/packets.h | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/packets.c b/lib/packets.c
index fa70df6..94e7d87 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -986,7 +986,7 @@ packet_update_csum128(struct dp_packet *packet, uint8_t 
proto,
 }
 }
 
-static void
+void
 packet_set_ipv6_addr(struct dp_packet *packet, uint8_t proto,
  ovs_16aligned_be32 addr[4],
  const struct in6_addr *new_addr,
diff --git a/lib/packets.h b/lib/packets.h
index c4d3799..850f192 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -1100,6 +1100,10 @@ void packet_set_ipv4_addr(struct dp_packet *packet, 
ovs_16aligned_be32 *addr,
 void packet_set_ipv6(struct dp_packet *, const struct in6_addr *src,
  const struct in6_addr *dst, uint8_t tc,
  ovs_be32 fl, uint8_t hlmit);
+void packet_set_ipv6_addr(struct dp_packet *packet, uint8_t proto,
+  ovs_16aligned_be32 addr[4],
+  const struct in6_addr *new_addr,
+  bool recalculate_csum);
 void packet_set_tcp_port(struct dp_packet *, ovs_be16 src, ovs_be16 dst);
 void packet_set_udp_port(struct dp_packet *, ovs_be16 src, ovs_be16 dst);
 void packet_set_sctp_port(struct dp_packet *, ovs_be16 src, ovs_be16 dst);
-- 
1.9.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev