[ovs-dev] [PATCH v12 2/2] DSCP marking on packets

2016-09-05 Thread bschanmu
From: Babu Shanmugam 

This patch adds support for marking qos on IP packets based on arbitrary
match criteria for a logical switch.

Signed-off-by: Babu Shanmugam 
Suggested-by: Mickey Spiegel 
---
 ovn/lib/logical-fields.c|  2 +-
 ovn/northd/ovn-northd.8.xml | 47 +++--
 ovn/northd/ovn-northd.c | 84 +
 ovn/ovn-nb.ovsschema| 26 --
 ovn/ovn-nb.xml  | 57 ++
 ovn/utilities/ovn-nbctl.c   |  5 +++
 tests/ovn.at| 52 
 7 files changed, 231 insertions(+), 42 deletions(-)

diff --git a/ovn/lib/logical-fields.c b/ovn/lib/logical-fields.c
index 6dbb4ae..068c000 100644
--- a/ovn/lib/logical-fields.c
+++ b/ovn/lib/logical-fields.c
@@ -134,7 +134,7 @@ ovn_init_symtab(struct shash *symtab)
 expr_symtab_add_predicate(symtab, "ip6", "eth.type == 0x86dd");
 expr_symtab_add_predicate(symtab, "ip", "ip4 || ip6");
 expr_symtab_add_field(symtab, "ip.proto", MFF_IP_PROTO, "ip", true);
-expr_symtab_add_field(symtab, "ip.dscp", MFF_IP_DSCP, "ip", false);
+expr_symtab_add_field(symtab, "ip.dscp", MFF_IP_DSCP_SHIFTED, "ip", false);
 expr_symtab_add_field(symtab, "ip.ecn", MFF_IP_ECN, "ip", false);
 expr_symtab_add_field(symtab, "ip.ttl", MFF_IP_TTL, "ip", false);
 
diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml
index 3448370..25b8564 100644
--- a/ovn/northd/ovn-northd.8.xml
+++ b/ovn/northd/ovn-northd.8.xml
@@ -362,7 +362,27 @@
   
 
 
-Ingress Table 7: LB
+Ingress Table 7: from-lport QoS marking
+
+
+  Logical flows in this table closely reproduce those in the
+  QoS table in the OVN_Northbound database
+  for the from-lport direction.
+
+
+
+  
+For every qos_rules for every logical switch a flow will be added at
+priorities mentioned in the QoS table.
+  
+
+  
+One priority-0 fallback flow that matches all packets and advances to
+the next table.
+  
+
+
+Ingress Table 8: LB
 
 
   It contains a priority-0 flow that simply moves traffic to the next
@@ -375,7 +395,7 @@
   connection.)
 
 
-Ingress Table 8: Stateful
+Ingress Table 9: Stateful
 
 
   
@@ -412,7 +432,7 @@
   
 
 
-Ingress Table 9: ARP/ND responder
+Ingress Table 10: ARP/ND responder
 
 
   This table implements ARP/ND responder for known IPs.  It contains these
@@ -484,7 +504,7 @@ nd_na {
   
 
 
-Ingress Table 10: DHCP option processing
+Ingress Table 11: DHCP option processing
 
 
   This table adds the DHCPv4 options to a DHCPv4 packet from the
@@ -544,7 +564,7 @@ next;
   
 
 
-Ingress Table 11: DHCP responses
+Ingress Table 12: DHCP responses
 
 
   This table implements DHCP responder for the DHCP replies generated by
@@ -626,7 +646,7 @@ output;
   
 
 
-Ingress Table 12: Destination Lookup
+Ingress Table 13 Destination Lookup
 
 
   This table implements switching behavior.  It contains these logical
@@ -693,7 +713,14 @@ output;
   to-lport ACLs.
 
 
-Egress Table 5: Stateful
+Egress Table 5: to-lport QoS marking
+
+
+  This is similar to ingress table QoS marking except for
+  to-lport qos rules.
+
+
+Egress Table 6: Stateful
 
 
   This is similar to ingress table Stateful except that
@@ -704,10 +731,10 @@ output;
   Also a priority 34000 logical flow is added for each logical port which
   has DHCPv4 options defined to allow the DHCPv4 reply packet and which has
   DHCPv6 options defined to allow the DHCPv6 reply packet from the
-  Ingress Table 11: DHCP responses.
+  Ingress Table 12: DHCP responses.
 
 
-Egress Table 6: Egress Port Security - IP
+Egress Table 7: Egress Port Security - IP
 
 
   This is similar to the port security logic in table
@@ -717,7 +744,7 @@ output;
   ip4.src and ip6.src
 
 
-Egress Table 7: Egress Port Security - L2
+Egress Table 8: Egress Port Security - L2
 
 
   This is similar to the ingress port security logic in ingress table
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 9ce2af9..f36eae6 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -93,21 +93,22 @@ enum ovn_datapath_type {
  * form the stage's full name, e.g. S_SWITCH_IN_PORT_SEC_L2,
  * S_ROUTER_OUT_DELIVERY. */
 enum ovn_stage {
-#define PIPELINE_STAGES   \
-/* Logical switch ingress stages. */  \
-PIPELINE_STAGE(SWITCH, IN,  PORT_SEC_L2,0, "ls_in_port_sec_l2") \
-PIPELINE_STAGE(SWITCH, IN,  PORT_SEC_IP,1, "ls_in_port_sec_ip") \
-PIPELINE_STAGE(SWITCH, IN,  PORT_SEC_ND,2, "ls_in_port_sec_nd") \
-

[ovs-dev] [PATCH v12 1/2] Check and allocate free qdisc queue id for ports with qos parameters

2016-09-05 Thread bschanmu
From: Babu Shanmugam 

ovn-northd processes the list of Port_Bindings and hashes the list of
queues per chassis. When it finds a port with qos_parameters and without
a queue_id, it allocates a free queue for the chassis that this port belongs.
The queue_id information is stored in the options field of Port_binding table.
Adds an action set_queue to the ingress table 0 of the logical flows
which will be translated to openflow set_queue by ovn-controller

ovn-controller opens the netdev corresponding to the tunnel interface's
status:tunnel_egress_iface value and configures a HTB qdisc on it. Then for
each SB port_binding that has queue_id set, it allocates a queue with the
qos_parameters of that port. It also frees up unused queues.

This patch replaces the older approach of policing

Signed-off-by: Babu Shanmugam 
---
 include/ovn/actions.h|  17 +++-
 ovn/controller/binding.c | 233 +++
 ovn/lib/actions.c|  42 +
 ovn/northd/ovn-northd.c  | 138 ++--
 ovn/ovn-nb.xml   |   8 +-
 ovn/ovn-sb.xml   |  38 +++-
 tests/ovn.at |   8 ++
 7 files changed, 451 insertions(+), 33 deletions(-)

diff --git a/include/ovn/actions.h b/include/ovn/actions.h
index d1942b3..95967f9 100644
--- a/include/ovn/actions.h
+++ b/include/ovn/actions.h
@@ -26,6 +26,14 @@
 #include "openvswitch/uuid.h"
 #include "util.h"
 
+/* Valid arguments to SET_QUEUE action.
+ *
+ * QDISC_MIN_QUEUE_ID is the default queue, so user-defined queues should
+ * start at QDISC_MIN_QUEUE_ID+1. */
+#define QDISC_MIN_QUEUE_ID  0
+#define QDISC_MAX_QUEUE_ID  0xf000
+
+struct expr;
 struct lexer;
 struct ofpbuf;
 struct shash;
@@ -66,7 +74,8 @@ struct simap;
 OVNACT(GET_ND,ovnact_get_mac_bind)  \
 OVNACT(PUT_ND,ovnact_put_mac_bind)  \
 OVNACT(PUT_DHCPV4_OPTS, ovnact_put_dhcp_opts)   \
-OVNACT(PUT_DHCPV6_OPTS, ovnact_put_dhcp_opts)
+OVNACT(PUT_DHCPV6_OPTS, ovnact_put_dhcp_opts)   \
+OVNACT(SET_QUEUE,   ovnact_set_queue)
 
 /* enum ovnact_type, with a member OVNACT_ for each action. */
 enum OVS_PACKED_ENUM ovnact_type {
@@ -219,6 +228,12 @@ struct ovnact_put_dhcp_opts {
 size_t n_options;
 };
 
+/* OVNACT_SET_QUEUE. */
+struct ovnact_set_queue {
+struct ovnact ovnact;
+uint16_t queue_id;
+};
+
 /* Internal use by the helpers below. */
 void ovnact_init(struct ovnact *, enum ovnact_type, size_t len);
 void *ovnact_put(struct ofpbuf *, enum ovnact_type, size_t len);
diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
index 0353a7b..8e14811 100644
--- a/ovn/controller/binding.c
+++ b/ovn/controller/binding.c
@@ -22,6 +22,7 @@
 #include "lib/poll-loop.h"
 #include "lib/sset.h"
 #include "lib/util.h"
+#include "lib/netdev.h"
 #include "lib/vswitch-idl.h"
 #include "openvswitch/hmap.h"
 #include "openvswitch/vlog.h"
@@ -30,6 +31,27 @@
 
 VLOG_DEFINE_THIS_MODULE(binding);
 
+#define OVN_QOS_TYPE "linux-htb"
+
+/* A set of the iface-id values of local interfaces on this chassis. */
+static struct sset local_ids = SSET_INITIALIZER(_ids);
+
+/* When this gets set to true, the next run will re-check all binding records. 
*/
+static bool process_full_binding = false;
+
+void
+binding_reset_processing(void)
+{
+process_full_binding = true;
+}
+
+struct qos_queue {
+struct hmap_node node;
+uint32_t queue_id;
+uint32_t max_rate;
+uint32_t burst;
+};
+
 void
 binding_register_ovs_idl(struct ovsdb_idl *ovs_idl)
 {
@@ -43,19 +65,22 @@ binding_register_ovs_idl(struct ovsdb_idl *ovs_idl)
 ovsdb_idl_add_table(ovs_idl, _table_port);
 ovsdb_idl_add_column(ovs_idl, _port_col_name);
 ovsdb_idl_add_column(ovs_idl, _port_col_interfaces);
+ovsdb_idl_add_column(ovs_idl, _port_col_qos);
 
 ovsdb_idl_add_table(ovs_idl, _table_interface);
 ovsdb_idl_add_column(ovs_idl, _interface_col_name);
 ovsdb_idl_add_column(ovs_idl, _interface_col_external_ids);
-ovsdb_idl_add_column(ovs_idl, _interface_col_ingress_policing_rate);
-ovsdb_idl_add_column(ovs_idl,
- _interface_col_ingress_policing_burst);
+ovsdb_idl_add_column(ovs_idl, _interface_col_status);
+
+ovsdb_idl_add_table(ovs_idl, _table_qos);
+ovsdb_idl_add_column(ovs_idl, _qos_col_type);
 }
 
 static void
 get_local_iface_ids(const struct ovsrec_bridge *br_int,
 struct shash *lport_to_iface,
-struct sset *all_lports)
+struct sset *all_lports,
+struct sset *egress_ifaces)
 {
 int i;
 
@@ -73,11 +98,20 @@ get_local_iface_ids(const struct ovsrec_bridge *br_int,
 
 iface_rec = port_rec->interfaces[j];
 iface_id = smap_get(_rec->external_ids, "iface-id");
-if (!iface_id) {
-continue;
+
+if (iface_id) {
+shash_add(lport_to_iface, iface_id, iface_rec);
+

[ovs-dev] [PATCH v12 0/2] QOS updates with DSCP support

2016-09-05 Thread bschanmu
v11 -> v12:
 - QOS dscp marking on IP packets based on arbitrary
   match criteria for a logical switch.

Babu Shanmugam (2):
  Check and allocate free qdisc queue id for ports with qos parameters
  DSCP marking on packets

 include/ovn/actions.h   |  17 +++-
 ovn/controller/binding.c| 233 
 ovn/lib/actions.c   |  42 
 ovn/lib/logical-fields.c|   2 +-
 ovn/northd/ovn-northd.8.xml |  47 +++--
 ovn/northd/ovn-northd.c | 222 ++---
 ovn/ovn-nb.ovsschema|  26 -
 ovn/ovn-nb.xml  |  65 +++-
 ovn/ovn-sb.xml  |  38 +++-
 ovn/utilities/ovn-nbctl.c   |   5 +
 tests/ovn.at|  60 
 11 files changed, 682 insertions(+), 75 deletions(-)

-- 
1.9.1

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] netdev-dpdk: fix cross compilation failure

2016-09-05 Thread Hemant Agrawal
 A gentle reminder to review this patch?

> -Original Message-
> From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Hemant
> Agrawal
> Sent: Tuesday, August 23, 2016 11:37 PM
> To: dev@openvswitch.org
> Subject: [ovs-dev] [PATCH] netdev-dpdk: fix cross compilation failure
> 
> configure with_dpdk and cross compile fails with:
> "configure: error: cannot check for file existence when cross compiling"
> 
> This is due to the usages of AC_CHECK_FILES.
> 
> AC_CHECK_FILES only works when not cross compiling. It test a feature of the
> host machine, and therefore, die when cross-compiling.
> 
> The current patch put the check in condition, i.e. check only if not cross-
> compiling.
> 
> This patch has been tested on ARM64 platform with DPDK16.07
> 
> Signed-off-by: Hemant Agrawal 
> ---
>  acinclude.m4 | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/acinclude.m4 b/acinclude.m4 index 353519d..fd446b2 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -180,9 +180,13 @@ AC_DEFUN([OVS_CHECK_DPDK], [
>  DPDK_INCLUDE="$with_dpdk/include"
>  # If 'with_dpdk' is passed install directory, point to headers
>  # installed in $DESTDIR/$prefix/include/dpdk
> -AC_CHECK_FILE([$DPDK_INCLUDE/rte_config.h], [],
> + # AC_CHECK_FILES only works when not cross compiling
> + if test "$cross_compiling" != "yes"
> + then
> + AC_CHECK_FILE([$DPDK_INCLUDE/rte_config.h], [],
>[AC_CHECK_FILE([$DPDK_INCLUDE/dpdk/rte_config.h],
>   [DPDK_INCLUDE=$DPDK_INCLUDE/dpdk], [])])
> + fi
>  DPDK_LIB_DIR="$with_dpdk/lib"
>  ;;
>  esac
> --
> 1.9.1
> 
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Bug#754482: marked as done (openvswitch: run dh-autoreconf to update config.{sub, guess} and {libtool, aclocal}.m4)

2016-09-05 Thread Debian Bug Tracking System
Your message dated Mon, 5 Sep 2016 17:05:20 -0300
with message-id 
and subject line 
has caused the Debian Bug report #754482,
regarding openvswitch: run dh-autoreconf to update config.{sub, guess} and 
{libtool, aclocal}.m4
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)


-- 
754482: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=754482
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Copy: Photo(70)

2016-09-05 Thread Margery


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] File: Photo(768)

2016-09-05 Thread Arline


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] File: Picture(819)

2016-09-05 Thread Earlene


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Emailing: Photo(16)

2016-09-05 Thread Doris


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Attached: Receipt(5373)

2016-09-05 Thread Therese


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Attached: Blank(392)

2016-09-05 Thread Angelia


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] File: Receipt(361)

2016-09-05 Thread Miquel


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Copy: Picture(324)

2016-09-05 Thread Brooke


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] File: Receipt(141)

2016-09-05 Thread Shelia


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Copy: Photo(260)

2016-09-05 Thread Otto


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Emailing: Blank(24)

2016-09-05 Thread Roxanne


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] File: Blank(910)

2016-09-05 Thread Evangeline


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 1/3] netdev-dpdk: Fix memory leak in dpdk_mp_{get, put}().

2016-09-05 Thread Ilya Maximets
'dmp' should be freed on failure and on put.

Fixes: 8a9562d21a40 ("dpif-netdev: Add DPDK netdev.")
Fixes: 8d38823bdf8b ("netdev-dpdk: fix memory leak")
Signed-off-by: Ilya Maximets 
---
 lib/netdev-dpdk.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 6d334db..f7a6f82 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -474,7 +474,7 @@ dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex)
 LIST_FOR_EACH (dmp, list_node, _mp_list) {
 if (dmp->socket_id == socket_id && dmp->mtu == mtu) {
 dmp->refcount++;
-return dmp;
+goto out;
 }
 }
 
@@ -499,7 +499,7 @@ dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex)
 do {
 if (snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "ovs_mp_%d_%d_%u",
  dmp->mtu, dmp->socket_id, mp_size) < 0) {
-return NULL;
+goto fail;
 }
 
 dmp->mp = rte_mempool_create(mp_name, mp_size, MBUF_SIZE(mtu),
@@ -511,12 +511,18 @@ dpdk_mp_get(int socket_id, int mtu) 
OVS_REQUIRES(dpdk_mutex)
 } while (!dmp->mp && rte_errno == ENOMEM && (mp_size /= 2) >= MIN_NB_MBUF);
 
 if (dmp->mp == NULL) {
-return NULL;
+goto fail;
 } else {
 VLOG_DBG("Allocated \"%s\" mempool with %u mbufs", mp_name, mp_size );
 }
 
 ovs_list_push_back(_mp_list, >list_node);
+goto out;
+
+fail:
+rte_free(dmp);
+dmp = NULL;
+out:
 return dmp;
 }
 
@@ -532,6 +538,7 @@ dpdk_mp_put(struct dpdk_mp *dmp) OVS_REQUIRES(dpdk_mutex)
 if (!--dmp->refcount) {
 ovs_list_remove(>list_node);
 rte_mempool_free(dmp->mp);
+rte_free(dmp);
 }
 }
 
-- 
2.7.4

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 2/3] netdev-dpdk: Introduce dpdk_mp_mutex.

2016-09-05 Thread Ilya Maximets
'dpdk_mutex' protects two independent things: list of dpdk devices
and list of memory pools. Let's spit it in two to avoid global blocking
inside 'netdev_dpdk.*_reconfigure()' as possible.

Signed-off-by: Ilya Maximets 
---
 lib/netdev-dpdk.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f7a6f82..be48218 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -177,8 +177,6 @@ enum dpdk_dev_type {
 
 static int rte_eal_init_ret = ENODEV;
 
-static struct ovs_mutex dpdk_mutex = OVS_MUTEX_INITIALIZER;
-
 /* Quality of Service */
 
 /* An instance of a QoS configuration.  Always associated with a particular
@@ -274,11 +272,15 @@ static const struct dpdk_qos_ops *const qos_confs[] = {
 NULL
 };
 
+static struct ovs_mutex dpdk_mutex = OVS_MUTEX_INITIALIZER;
+
 /* Contains all 'struct dpdk_dev's. */
 static struct ovs_list dpdk_list OVS_GUARDED_BY(dpdk_mutex)
 = OVS_LIST_INITIALIZER(_list);
 
-static struct ovs_list dpdk_mp_list OVS_GUARDED_BY(dpdk_mutex)
+static struct ovs_mutex dpdk_mp_mutex = OVS_MUTEX_INITIALIZER;
+
+static struct ovs_list dpdk_mp_list OVS_GUARDED_BY(dpdk_mp_mutex)
 = OVS_LIST_INITIALIZER(_mp_list);
 
 /* This mutex must be used by non pmd threads when allocating or freeing
@@ -290,7 +292,7 @@ struct dpdk_mp {
 int mtu;
 int socket_id;
 int refcount;
-struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
+struct ovs_list list_node OVS_GUARDED_BY(dpdk_mp_mutex);
 };
 
 /* There should be one 'struct dpdk_tx_queue' created for
@@ -464,13 +466,14 @@ ovs_rte_pktmbuf_init(struct rte_mempool *mp,
 }
 
 static struct dpdk_mp *
-dpdk_mp_get(int socket_id, int mtu) OVS_REQUIRES(dpdk_mutex)
+dpdk_mp_get(int socket_id, int mtu)
 {
 struct dpdk_mp *dmp = NULL;
 char mp_name[RTE_MEMPOOL_NAMESIZE];
 unsigned mp_size;
 struct rte_pktmbuf_pool_private mbp_priv;
 
+ovs_mutex_lock(_mp_mutex);
 LIST_FOR_EACH (dmp, list_node, _mp_list) {
 if (dmp->socket_id == socket_id && dmp->mtu == mtu) {
 dmp->refcount++;
@@ -523,16 +526,18 @@ fail:
 rte_free(dmp);
 dmp = NULL;
 out:
+ovs_mutex_unlock(_mp_mutex);
 return dmp;
 }
 
 static void
-dpdk_mp_put(struct dpdk_mp *dmp) OVS_REQUIRES(dpdk_mutex)
+dpdk_mp_put(struct dpdk_mp *dmp)
 {
 if (!dmp) {
 return;
 }
 
+ovs_mutex_lock(_mp_mutex);
 ovs_assert(dmp->refcount);
 
 if (!--dmp->refcount) {
@@ -540,6 +545,7 @@ dpdk_mp_put(struct dpdk_mp *dmp) OVS_REQUIRES(dpdk_mutex)
 rte_mempool_free(dmp->mp);
 rte_free(dmp);
 }
+ovs_mutex_unlock(_mp_mutex);
 }
 
 /* Tries to allocate new mempool on requested_socket_id with
@@ -548,18 +554,18 @@ dpdk_mp_put(struct dpdk_mp *dmp) OVS_REQUIRES(dpdk_mutex)
  * On error, device will be left unchanged. */
 static int
 netdev_dpdk_mempool_configure(struct netdev_dpdk *dev)
-OVS_REQUIRES(dpdk_mutex)
 OVS_REQUIRES(dev->mutex)
 {
 uint32_t buf_size = dpdk_buf_size(dev->requested_mtu);
 struct dpdk_mp *mp;
+int err = 0;
 
 mp = dpdk_mp_get(dev->requested_socket_id, FRAME_LEN_TO_MTU(buf_size));
 if (!mp) {
 VLOG_ERR("Insufficient memory to create memory pool for netdev "
  "%s, with MTU %d on socket %d\n",
  dev->up.name, dev->requested_mtu, dev->requested_socket_id);
-return ENOMEM;
+err = ENOMEM;
 } else {
 dpdk_mp_put(dev->dpdk_mp);
 dev->dpdk_mp = mp;
@@ -568,7 +574,7 @@ netdev_dpdk_mempool_configure(struct netdev_dpdk *dev)
 dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
 }
 
-return 0;
+return err;
 }
 
 static void
@@ -699,7 +705,8 @@ dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) 
OVS_REQUIRES(dev->mutex)
 }
 
 static int
-dpdk_eth_dev_init(struct netdev_dpdk *dev) OVS_REQUIRES(dpdk_mutex)
+dpdk_eth_dev_init(struct netdev_dpdk *dev)
+OVS_REQUIRES(dev->mutex)
 {
 struct rte_pktmbuf_pool_private *mbp_priv;
 struct rte_eth_dev_info info;
@@ -2922,7 +2929,6 @@ netdev_dpdk_reconfigure(struct netdev *netdev)
 struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
 int err = 0;
 
-ovs_mutex_lock(_mutex);
 ovs_mutex_lock(>mutex);
 
 if (netdev->n_txq == dev->requested_n_txq
@@ -2949,9 +2955,7 @@ netdev_dpdk_reconfigure(struct netdev *netdev)
 netdev_change_seq_changed(netdev);
 
 out:
-
 ovs_mutex_unlock(>mutex);
-ovs_mutex_unlock(_mutex);
 
 return err;
 }
@@ -2962,7 +2966,6 @@ netdev_dpdk_vhost_reconfigure(struct netdev *netdev)
 struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
 int err = 0;
 
-ovs_mutex_lock(_mutex);
 ovs_mutex_lock(>mutex);
 
 netdev->n_txq = dev->requested_n_txq;
@@ -2999,10 +3002,8 @@ netdev_dpdk_vhost_reconfigure(struct netdev *netdev)
 char *vhost_id = xstrdup(get_vhost_id(dev));
 
 ovs_mutex_unlock(>mutex);
-ovs_mutex_unlock(_mutex);
  

[ovs-dev] [PATCH 3/3] netdev-dpdk: Don't fail vHost port creation if server mode is unavailable.

2016-09-05 Thread Ilya Maximets
Currently vHost client mode feature is broken in case where QEMU and OVS
are configured to create sockets in the same place. While adding the port,
OVS will try to register vHost driver in server mode and will fail because
socket already exist if QEMU was started first.

In this situation port will not be created and will not be reconfigured
to client mode.

To fix this let's not fail creation of vhost port if server mode is
unavailable.

Fixes: c1ff66ac80b5 ("netdev-dpdk: vHost client mode and reconnect")
Signed-off-by: Ilya Maximets 
---
 lib/netdev-dpdk.c | 173 +-
 1 file changed, 105 insertions(+), 68 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index be48218..2ba57d7 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -355,6 +355,8 @@ struct netdev_dpdk {
 /* virtio identifier for vhost devices */
 ovsrcu_index vid;
 
+bool vhost_driver_registered;
+
 /* True if vHost device is 'up' and has been reconfigured at least once */
 bool vhost_reconfigured;
 
@@ -400,7 +402,8 @@ static bool dpdk_thread_is_pmd(void);
 
 static int netdev_dpdk_construct(struct netdev *);
 
-int netdev_dpdk_get_vid(const struct netdev_dpdk *dev);
+static void netdev_dpdk_vhost_clear(struct netdev_dpdk *);
+static int netdev_dpdk_get_vid(const struct netdev_dpdk *);
 
 struct ingress_policer *
 netdev_dpdk_get_ingress_policer(const struct netdev_dpdk *dev);
@@ -828,6 +831,7 @@ netdev_dpdk_init(struct netdev *netdev, unsigned int 
port_no,
 dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
 ovsrcu_index_init(>vid, -1);
 dev->vhost_reconfigured = false;
+dev->vhost_driver_registered = false;
 /* initialise vHost port in server mode */
 dev->vhost_driver_flags &= ~RTE_VHOST_USER_CLIENT;
 
@@ -903,6 +907,37 @@ get_vhost_id(struct netdev_dpdk *dev)
 }
 
 static int
+netdev_dpdk_vhost_driver_register(struct netdev_dpdk *dev)
+OVS_REQUIRES(dev->mutex)
+{
+int mode = !!(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT);
+const char *str_mode[] = {"server", "client"};
+const char *id = get_vhost_id(dev);
+int err;
+
+if (dev->vhost_driver_registered) {
+return 0;
+}
+
+err = rte_vhost_driver_register(id, dev->vhost_driver_flags);
+if (err) {
+VLOG_ERR("%s: Unable to register vhost driver in %s mode using socket 
'"
+ "%s'.\n", dev->up.name, str_mode[mode], id);
+return err;
+}
+
+dev->vhost_driver_registered = true;
+if (!mode) {
+/* OVS server mode - add this socket to list for deletion */
+fatal_signal_add_file_to_unlink(id);
+}
+VLOG_INFO("%s: vhost driver registered in %s mode using socket '%s'.\n",
+  dev->up.name, str_mode[mode], id);
+
+return 0;
+}
+
+static int
 netdev_dpdk_vhost_construct(struct netdev *netdev)
 {
 struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
@@ -924,6 +959,13 @@ netdev_dpdk_vhost_construct(struct netdev *netdev)
 }
 
 ovs_mutex_lock(_mutex);
+
+err = netdev_dpdk_init(netdev, -1, DPDK_DEV_VHOST);
+if (err) {
+goto out;
+}
+
+ovs_mutex_lock(>mutex);
 /* Take the name of the vhost-user port and append it to the location where
  * the socket is to be created, then register the socket. Sockets are
  * registered initially in 'server' mode.
@@ -931,21 +973,9 @@ netdev_dpdk_vhost_construct(struct netdev *netdev)
 snprintf(dev->vhost_server_id, sizeof dev->vhost_server_id, "%s/%s",
  vhost_sock_dir, name);
 
-err = rte_vhost_driver_register(dev->vhost_server_id,
-dev->vhost_driver_flags);
-if (err) {
-VLOG_ERR("vhost-user socket device setup failure for socket %s\n",
- dev->vhost_server_id);
-} else {
-if (!(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT)) {
-/* OVS server mode - add this socket to list for deletion */
-fatal_signal_add_file_to_unlink(dev->vhost_server_id);
-VLOG_INFO("Socket %s created for vhost-user port %s\n",
-  dev->vhost_server_id, name);
-}
-err = netdev_dpdk_init(netdev, -1, DPDK_DEV_VHOST);
-}
-
+netdev_dpdk_vhost_driver_register(dev);
+ovs_mutex_unlock(>mutex);
+out:
 ovs_mutex_unlock(_mutex);
 return err;
 }
@@ -978,6 +1008,9 @@ netdev_dpdk_destruct(struct netdev *netdev)
 struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
 
 ovs_mutex_lock(_mutex);
+ovs_list_remove(>list_node);
+ovs_mutex_unlock(_mutex);
+
 ovs_mutex_lock(>mutex);
 
 rte_eth_dev_stop(dev->port_id);
@@ -985,34 +1018,64 @@ netdev_dpdk_destruct(struct netdev *netdev)
   >ingress_policer));
 
 rte_free(dev->tx_q);
-ovs_list_remove(>list_node);
 dpdk_mp_put(dev->dpdk_mp);
 
 ovs_mutex_unlock(>mutex);
-ovs_mutex_unlock(_mutex);
 }
 
 /* 

[ovs-dev] [PATCH 0/3] netdev-dpdk: memory leak + vHost client fix.

2016-09-05 Thread Ilya Maximets
Ilya Maximets (3):
  netdev-dpdk: Fix memory leak in dpdk_mp_{get,put}().
  netdev-dpdk: Introduce dpdk_mp_mutex.
  netdev-dpdk: Don't fail vHost port creation if server mode is
unavailable.

 lib/netdev-dpdk.c | 220 --
 1 file changed, 132 insertions(+), 88 deletions(-)

-- 
2.7.4

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [CudaMailTagged] [PATCH] netdev-dpdk: in some case, needn't reconfigure pmd threads when changing MTU

2016-09-05 Thread Binbin Xu
1. The MTU configuration changes, but the size of aligned mempool
   of new MTU doesn't change.
   What we have to do is to update the netdev's MTU and max_packet_len.

2. The MTU configuration changes, and the size of aligned mempool
   of new MTU changes too.
   The mempool needed by the new MTU has already been allocated,
   and the mempool used for the old MTU is referenced by other
   netdev meantime.
   What we have to do is to reduce the reference count of old mempool,
   increase the reference count of new mempool, update the netdev's
   mempool, MTU and max_packet_len.

Signed-off-by: Binbin Xu 
---
 lib/netdev-dpdk.c | 31 ++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 6d334db..86dd5df 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1723,6 +1723,8 @@ netdev_dpdk_get_mtu(const struct netdev *netdev, int 
*mtup)
 static int
 netdev_dpdk_set_mtu(struct netdev *netdev, int mtu)
 {
+struct dpdk_mp *dmp = NULL;
+struct dpdk_mp *dmp_node = NULL;
 struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
 
 if (MTU_TO_FRAME_LEN(mtu) > NETDEV_DPDK_MAX_PKT_LEN
@@ -1731,12 +1733,39 @@ netdev_dpdk_set_mtu(struct netdev *netdev, int mtu)
 return EINVAL;
 }
 
+ovs_mutex_lock(_mutex);
 ovs_mutex_lock(>mutex);
 if (dev->requested_mtu != mtu) {
+VLOG_INFO("%s: cur MTU %d, req MTU %d, " 
+"cur buf len %d, req buf len %d\n",
+dev->up.name, dev->mtu, mtu, 
+dpdk_buf_size(dev->mtu), dpdk_buf_size(mtu));
+
 dev->requested_mtu = mtu;
-netdev_request_reconfigure(netdev);
+
+LIST_FOR_EACH (dmp_node, list_node, _mp_list) {
+if (dmp_node->mtu == FRAME_LEN_TO_MTU(dpdk_buf_size(mtu))) {
+dmp = dmp_node;
+break;
+}
+}
+
+if ((dpdk_buf_size(dev->mtu) != dpdk_buf_size(mtu)
+&& 1 == dev->dpdk_mp->refcount)
+|| dmp == NULL) {
+netdev_request_reconfigure(netdev);
+} else {
+if (dpdk_buf_size(dev->mtu) != dpdk_buf_size(mtu)) {
+dev->dpdk_mp->refcount--;
+dmp->refcount++;
+dev->dpdk_mp = dmp;
+}
+dev->mtu = mtu;
+dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
+}
 }
 ovs_mutex_unlock(>mutex);
+ovs_mutex_unlock(_mutex);
 
 return 0;
 }
-- 
2.9.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev