[ovs-dev] (no subject)

2015-03-25 Thread dev-bounces

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


Re: [ovs-dev] [PATCH v2] vswitch.ovsschema: Add datapath_types and port_types.

2015-03-25 Thread O Mahony, Billy
Hi Ben,

I have verified the modified code works as expected when run with/without 
--dpdk on the vswitchd command line.

I'm wondering why there is a call to 'discover_types' in two places?

I think it might be to do with something that I could not figure out when I was 
trying to ensure discover_types was not called more often that necessary. 

I had initially tried to align the call to 'discover_types' with the 
'initial_config_done' flag in 'bridge_run'. However on the first invocation 
(the first 3 in fact) 'cfg' was NULL (i.e. there was no record in Open_vSwitch 
table). Then on the 4th invocation the idl sequence number is bumped and 
'bridge_reconfigure' is handed an empty ' ovsrec_open_vswitch' which is then 
commited to the db before vswitchd daemonizes.

However, and this is what I could not get, was that handing the empty ' 
ovsrec_open_vswitch' ('null_cfg') to discover_types when doing the initial 
config did not update the Open_vSwitch table as desired  - I was expecting 
discover_types to update the idl record and the the commit on 'daemonize_txn' 
to do the needful.  ( I had removed the separate txn create/commit from 
discover_types at this point).

Thanks,
Billy.



-Original Message-
From: O Mahony, Billy 
Sent: Tuesday, March 24, 2015 5:22 PM
To: 'Ben Pfaff'
Cc: dev@openvswitch.org
Subject: RE: [ovs-dev] [PATCH v2] vswitch.ovsschema: Add datapath_types and 
port_types.

Thanks Ben, our Open Stack guys will be happy.

/Billy.

-Original Message-
From: Ben Pfaff [mailto:b...@nicira.com]
Sent: Tuesday, March 24, 2015 4:13 PM
To: O Mahony, Billy
Cc: dev@openvswitch.org
Subject: Re: [ovs-dev] [PATCH v2] vswitch.ovsschema: Add datapath_types and 
port_types.

On Tue, Mar 24, 2015 at 10:39:11AM +, billy.o.mah...@intel.com wrote:
> From: Billy O'Mahony 
> 
> At startup enumerate datapath and port types and add this information 
> to the datapath_types and port_types columns in the ovsdb.
> 
> This allows an ovsdb client to query the datapath in order to 
> determine if certain datapath and port types exist. For example, by 
> querying the port_types column, an ovsdb client will be able to 
> determine if this instance of ovs-vswitchd was compiled with DPDK support.
> 
> Signed-off-by: Mark D. Gray 
> Signed-off-by: Billy O'Mahony 

Thanks for the patch.

I changed the name of port_types to iface_types to match the name of the 
Interface table.

I added some more documentation.

I changed the bridge.c code to refresh the types whenever we reconfigure.  This 
is just in case the admin switches out databases underneath us so that it needs 
refreshing.  (It's not necessary to do this on every trip through the main loop 
as the original patch does
though.)

I simplified discover_types() by adding a new function sset_array().

I made some style fixes.

I dropped some unrelated changes.

Applied to master as follows:

--8<--cut here-->8--

From: "Mark D. Gray" 
Date: Tue, 24 Mar 2015 10:39:11 +
Subject: [PATCH] vswitch.ovsschema: Add datapath_types and port_types.

At startup enumerate datapath and port types and add this information to the 
datapath_types and port_types columns in the ovsdb.

This allows an ovsdb client to query the datapath in order to determine if 
certain datapath and port types exist. For example, by querying the port_types 
column, an ovsdb client will be able to determine if this instance of 
ovs-vswitchd was compiled with DPDK support.

Signed-off-by: Mark D. Gray 
Signed-off-by: Billy O'Mahony  [b...@nicira.com made 
several changes]
Signed-off-by: Ben Pfaff 
---
 lib/sset.c | 38 --
 lib/sset.h |  3 ++-
 vswitchd/bridge.c  | 40 
 vswitchd/vswitch.ovsschema | 12 +---
 vswitchd/vswitch.xml   | 36 
 5 files changed, 107 insertions(+), 22 deletions(-)

diff --git a/lib/sset.c b/lib/sset.c
index 443538d..33c4298 100644
--- a/lib/sset.c
+++ b/lib/sset.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2011, 2012, 2013, 2015 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -269,21 +269,12 @@ sset_at_position(const struct sset *set, uint32_t 
*bucketp, uint32_t *offsetp)
 return SSET_NODE_FROM_HMAP_NODE(hmap_node);
 }
 
-static int
-compare_string_pointers(const void *a_, const void *b_) -{
-const char *const *a = a_;
-const char *const *b = b_;
-
-return strcmp(*a, *b);
-}
-
-/* Returns a null-terminated array of pointers to the strings in 'set', sorted
- * alphabetically.  The caller must free the returned array when it is no
+/* Returns a null-terminated array of pointers to the strings in 'set', 
+in no
+ * particular order.  The caller must free the returned array when it 
+is no
  * longe

Re: [ovs-dev] [PATCH] dpif-netdev: Wait for threads to quiesce before freeing port.

2015-03-25 Thread Daniele Di Proietto

> On 24 Mar 2015, at 17:03, Ben Pfaff  wrote:
> 
> I haven't looked at the code yet, but one restriction on
> ovsrcu_synchronize() is that the current thread can't have active
> pointers to any RCU-protected data (they can get freed).  Is that safe
> here?
> 

There’s one point where we call port_unref() inside a CMAP_FOR_EACH
loop (without external synchronization), so your intuition is correct,
we cannot use ovsrcu_synchronize() here.

I guess I should just postpone everything (including netdev_close()):
I did some quick testing and it doesn’t appear to introduce problems.
Do you guys have a better idea?

Thanks for the suggestion, Ben!

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


Re: [ovs-dev] [PATCH 2/6] netdev-dpdk: Adapt the requested number of tx and rx queues.

2015-03-25 Thread Daniele Di Proietto
Sure, I will rebase and repost soon.

Thanks,

Daniele
 
> On 24 Mar 2015, at 21:59, Ethan Jackson  wrote:
> 
> Patch no longer applies unfortunately, daniele could you please rebase
> and resend it when you have a chance?
> 
> Ethan
> 
> On Thu, Mar 12, 2015 at 11:04 AM, Daniele Di Proietto
>  wrote:
>> This commit changes the semantics of 'netdev_set_multiq()' to allow OVS
>> DPDK to run on device with limited multi queue support.
>> 
>> * If a netdev doesn't have the requested number of rxqs it can simply
>>  inform the datapath without failing.
>> * If a netdev doesn't have the requested number of txqs it should try
>>  to create as many as possible and use locking.
>> 
>> Signed-off-by: Daniele Di Proietto 
>> ---
>> lib/netdev-dpdk.c | 94 
>> +++
>> lib/netdev-provider.h | 11 ++
>> lib/netdev.c  | 10 ++
>> vswitchd/vswitch.xml  |  2 +-
>> 4 files changed, 80 insertions(+), 37 deletions(-)
>> 
>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>> index 54bc318..2278377 100644
>> --- a/lib/netdev-dpdk.c
>> +++ b/lib/netdev-dpdk.c
>> @@ -175,6 +175,10 @@ struct dpdk_tx_queue {
>> bool flush_tx; /* Set to true to flush queue everytime */
>>/* pkts are queued. */
>> int count;
>> +rte_spinlock_t tx_lock;/* Protects the members and the NIC queue
>> +* from concurrent access.  It is used 
>> only
>> +* if the queue is shared among different
>> +* pmd threads (see 
>> 'txq_needs_locking'). */
>> uint64_t tsc;
>> struct rte_mbuf *burst_pkts[MAX_TX_QUEUE_LEN];
>> };
>> @@ -216,9 +220,15 @@ struct netdev_dpdk {
>> struct rte_eth_link link;
>> int link_reset_cnt;
>> 
>> +/* The user might request more txqs than the NIC has.  We remap those
>> + * ('up.n_txq') on these ('real_n_txq').
>> + * If the numbers match, 'txq_needs_locking' is false, otherwise it is
>> + * true and we will take a spinlock on transmission */
>> +int real_n_txq;
>> +bool txq_needs_locking;
>> +
>> /* In dpdk_list. */
>> struct ovs_list list_node OVS_GUARDED_BY(dpdk_mutex);
>> -rte_spinlock_t dpdkr_tx_lock;
>> };
>> 
>> struct netdev_rxq_dpdk {
>> @@ -414,6 +424,7 @@ static int
>> dpdk_eth_dev_init(struct netdev_dpdk *dev) OVS_REQUIRES(dpdk_mutex)
>> {
>> struct rte_pktmbuf_pool_private *mbp_priv;
>> +struct rte_eth_dev_info info;
>> struct ether_addr eth_addr;
>> int diag;
>> int i;
>> @@ -422,14 +433,24 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) 
>> OVS_REQUIRES(dpdk_mutex)
>> return ENODEV;
>> }
>> 
>> -diag = rte_eth_dev_configure(dev->port_id, dev->up.n_rxq, dev->up.n_txq,
>> +rte_eth_dev_info_get(dev->port_id, &info);
>> +/* Adjust the number of rx queues to those available on the device. */
>> +dev->up.n_rxq = MIN(info.max_rx_queues, dev->up.n_rxq);
>> +
>> +/* Adjust the number of tx queues. This change is not visible to the 
>> user.
>> + * We will pretend that there are 'dev->up.n_txq', while using only
>> + * 'dev->real_n_txq'*/
>> +dev->real_n_txq = MIN(info.max_tx_queues, dev->up.n_txq);
>> +
>> +diag = rte_eth_dev_configure(dev->port_id, dev->up.n_rxq, 
>> dev->real_n_txq,
>>  &port_conf);
>> if (diag) {
>> -VLOG_ERR("eth dev config error %d",diag);
>> +VLOG_ERR("eth dev config error %d. rxq:%d txq:%d", diag, 
>> dev->up.n_rxq,
>> + dev->real_n_txq);
>> return -diag;
>> }
>> 
>> -for (i = 0; i < dev->up.n_txq; i++) {
>> +for (i = 0; i < dev->real_n_txq; i++) {
>> diag = rte_eth_tx_queue_setup(dev->port_id, i, NIC_PORT_TX_Q_SIZE,
>>   dev->socket_id, &tx_conf);
>> if (diag) {
>> @@ -491,14 +512,20 @@ netdev_dpdk_alloc_txq(struct netdev_dpdk *netdev, 
>> unsigned int n_txqs)
>> int i;
>> 
>> netdev->tx_q = dpdk_rte_mzalloc(n_txqs * sizeof *netdev->tx_q);
>> -/* Each index is considered as a cpu core id, since there should
>> - * be one tx queue for each cpu core. */
>> for (i = 0; i < n_txqs; i++) {
>> int numa_id = ovs_numa_get_numa_id(i);
>> 
>> -/* If the corresponding core is not on the same numa node
>> - * as 'netdev', flags the 'flush_tx'. */
>> -netdev->tx_q[i].flush_tx = netdev->socket_id == numa_id;
>> +if (!netdev->txq_needs_locking) {
>> +/* Each index is considered as a cpu core id, since there should
>> + * be one tx queue for each cpu core.
>> + * If the corresponding core is not on the same numa node
>> + * as 'netdev', flags the 'flush_tx'. */
>> +netdev->tx_q[i].flush_tx = netdev->socket_id == numa_id;
>> +} else {
>> +/* Queues are shared among CPUs. Always flush */
>>

Re: [ovs-dev] [dpdk-dev] ovs-dpdk: placing the metadata

2015-03-25 Thread Olivier MATZ

Hi Zoltan,

On 03/24/2015 06:42 PM, Zoltan Kiss wrote:

Hi,

I've noticed in lib/netdev-dpdk.c that __rte_pktmbuf_init() stores the
packet metadata right after "struct rte_mbuf", and before the buffer data:

 /* start of buffer is just after mbuf structure */
 m->buf_addr = (char *)m + sizeof(struct dp_packet);

(struct dp_packet has the rte_mbuf as first member if DPDK enabled)

However, lib/librte_mbuf/rte_mbuf.h seems to codify that the buffer
should start right after the rte_mbuf:

/**
  * Given the buf_addr returns the pointer to corresponding mbuf.
  */
#define RTE_MBUF_FROM_BADDR(ba) (((struct rte_mbuf *)(ba)) - 1)

/**
  * Given the pointer to mbuf returns an address where it's  buf_addr
  * should point to.
  */
#define RTE_MBUF_TO_BADDR(mb)   (((struct rte_mbuf *)(mb)) + 1)

These macros are used for attaching/detaching mbuf's to each other. This
is the way the code retrieves the direct buffer from an indirect one,
and vica versa. I think if we want to keep the metadata feature (which I
guess is quite important), we need to add a pointer to rte_mbuf, which
helps the direct and indirect structs to find each other. Something like:

 struct rte_mbuf *attach;/**< Points to the other buffer if this
one
  is (in)direct. Otherwise NULL.  */

What do you think?


I've just sent a patch that should fix this issue.
http://dpdk.org/ml/archives/dev/2015-March/015722.html

Let me know if you have any comment on it.

Regards,
Olivier

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


[ovs-dev] [PATCH] netdev-dpdk: Put cuse thread into quiescent state.

2015-03-25 Thread Kevin Traynor
As ovsrcu_synchronize() is used when setting virtio_dev to NULL,
ovsrcu_quiesce_start() must be called before destroy_device() returns.
Otherwise there will be warnings about the thread not quiescing.
Use of ovs_thread_create() instead of pthread_create() is optional but
as we are now setting quiescent state, it is added.

Signed-off-by: Kevin Traynor 
---
 lib/netdev-dpdk.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 4e16f39..d52fc96 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1586,6 +1586,8 @@ destroy_device(volatile struct virtio_net *dev)
  * setting the virtio_dev to NULL.
  */
 ovsrcu_synchronize();
+/* Put the cuse thread into quiescent state. */
+ovsrcu_quiesce_start();
 }
 }
 ovs_mutex_unlock(&dpdk_mutex);
@@ -1614,6 +1616,8 @@ static void *
 start_cuse_session_loop(void *dummy OVS_UNUSED)
 {
  pthread_detach(pthread_self());
+ /* Put the cuse thread into quiescent state. */
+ ovsrcu_quiesce_start();
  rte_vhost_driver_session_start();
  return NULL;
 }
@@ -1621,7 +1625,6 @@ start_cuse_session_loop(void *dummy OVS_UNUSED)
 static int
 dpdk_vhost_class_init(void)
 {
-pthread_t thread;
 int err = -1;
 
 rte_vhost_driver_callback_register(&virtio_net_device_ops);
@@ -1637,9 +1640,8 @@ dpdk_vhost_class_init(void)
 return -1;
 }
 
-/* start_cuse_session_loop blocks OVS RCU quiescent state, so directly use
- * pthread API. */
-return pthread_create(&thread, NULL, start_cuse_session_loop, NULL);
+ovs_thread_create("cuse_thread", start_cuse_session_loop, NULL);
+return 0;
 }
 
 static void
-- 
1.7.4.1

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


Re: [ovs-dev] [dpdk-dev] ovs-dpdk: placing the metadata

2015-03-25 Thread Zoltan Kiss

Hi Olivier,

On 25/03/15 17:04, Olivier MATZ wrote:

Hi Zoltan,

On 03/24/2015 06:42 PM, Zoltan Kiss wrote:

Hi,

I've noticed in lib/netdev-dpdk.c that __rte_pktmbuf_init() stores the
packet metadata right after "struct rte_mbuf", and before the buffer
data:

 /* start of buffer is just after mbuf structure */
 m->buf_addr = (char *)m + sizeof(struct dp_packet);

(struct dp_packet has the rte_mbuf as first member if DPDK enabled)

However, lib/librte_mbuf/rte_mbuf.h seems to codify that the buffer
should start right after the rte_mbuf:

/**
  * Given the buf_addr returns the pointer to corresponding mbuf.
  */
#define RTE_MBUF_FROM_BADDR(ba) (((struct rte_mbuf *)(ba)) - 1)

/**
  * Given the pointer to mbuf returns an address where it's  buf_addr
  * should point to.
  */
#define RTE_MBUF_TO_BADDR(mb)   (((struct rte_mbuf *)(mb)) + 1)

These macros are used for attaching/detaching mbuf's to each other. This
is the way the code retrieves the direct buffer from an indirect one,
and vica versa. I think if we want to keep the metadata feature (which I
guess is quite important), we need to add a pointer to rte_mbuf, which
helps the direct and indirect structs to find each other. Something like:

 struct rte_mbuf *attach;/**< Points to the other buffer if this
one
  is (in)direct. Otherwise NULL.  */

What do you think?


I've just sent a patch that should fix this issue.
http://dpdk.org/ml/archives/dev/2015-March/015722.html

Let me know if you have any comment on it.


I have some comments for the first patch:


diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index c3fcb80..050f3ac 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
I've sent in a separate patch for this file, I think it's just easier to 
ditch the old copy-pasted code, see "[PATCH] examples/vhost: use library 
routines instead of local copies"



diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 17ba791..4ced6d3 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -268,7 +268,7 @@ struct rte_mbuf {
uint16_t data_len;/**< Amount of data in segment buffer. */
uint32_t pkt_len; /**< Total pkt len: sum of all segments. */
uint16_t vlan_tci;/**< VLAN Tag Control Identifier (CPU order) 
*/
-   uint16_t reserved;
+   uint16_t priv_size;   /**< size of the application private data */
union {
uint32_t rss; /**< RSS hash result if RSS enabled */
struct {
@@ -320,15 +320,38 @@ struct rte_mbuf {
 } __rte_cache_aligned;

 /**
- * Given the buf_addr returns the pointer to corresponding mbuf.
+ * Return the mbuf owning the given data buffer address.
+ *
+ * @param mi
+ *   The pointer to the indirect mbuf.
+ * @param buffer_addr
+ *   The address of the data buffer of the direct mbuf.

You don't need this parameter, it's mi->buf_addr.


@@ -744,9 +767,11 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, 
struct rte_mbuf *md)
 static inline void rte_pktmbuf_detach(struct rte_mbuf *m)
 {
const struct rte_mempool *mp = m->pool;
-   void *buf = RTE_MBUF_TO_BADDR(m);
+   void *buf = rte_mbuf_to_baddr(m);
uint32_t buf_len = mp->elt_size - sizeof(*m);
I don't see any reason to keep buf and buf_len, just assign straight to 
m->buf_addr and *len.

Besides that, you need to deduct m->priv_size from buf_len.


-   m->buf_physaddr = rte_mempool_virt2phy(mp, m) + sizeof (*m);
+
+   m->buf_physaddr = rte_mempool_virt2phy(mp, m) + sizeof (*m) +
+   m->priv_size;

m->buf_addr = buf;
m->buf_len = (uint16_t)buf_len;


The rest of the series looks good,

Reviewed-by: Zoltan Kiss 
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] ovs-dpdk: ofpbuf reinitialization

2015-03-25 Thread Zoltan Kiss

Hi,

Looking around in the DPDK code I've found that it only initializes the 
packet metadata (whih contains the struct ofpbuf belonging to the 
packet) during setup, as the packet initializer of rte_mempool_create.
That means that every time a packet buffer is released back by OVS to 
the buffer pool, it retains ofpbuf state, and it doesn't change when the 
poll mode driver use the buffer again to store a new packet. "source" 
and "allocated members of ofpbuf shouldn't change, but frame, 
l2_pad_size and the offsets does at various places. Even though I 
couldn't establish an error scenario yet, I think it's quite dangerous 
to leave the packet to inherit the previous packet's ofpbuf.

Or am I missing some place where this piece is reinitialized?

Regards,

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


[ovs-dev] BANNED Seduction Method?

2015-03-25 Thread Dana Wesley
Seriously!
Getting laid is simple! All you have to do is read this email. And then watch  
this completely free video that shows 
you a scientifically-proven mind control trick that gets women  turned on,  
attracted to you, and wanting to 
bang.within seconds.

Click Here To Watch http://hop.kz/4Zr6

Best part? The trick is 100% rejection proof. And it's completely undetectable. 
Which means you'll never get "caught" using this...
And you'll never get shot-down or embaressed. Simply use this trick... And sit 
back as women do everything they can to get
YOU into bed. Sound too good to be true? Well it's NOT

And you can prove it to yourself just as soon as you watch this video and use 
it to get yourself some nice
warm pussy
Click Here To Watch Now http://vuri.d4i.es/ 
Enjoy!

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


[ovs-dev] (no subject)

2015-03-25 Thread dev-bounces

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


Re: [ovs-dev] ovs-dpdk: ofpbuf reinitialization

2015-03-25 Thread Pravin Shelar
On Wed, Mar 25, 2015 at 12:25 PM, Zoltan Kiss  wrote:
> Hi,
>
> Looking around in the DPDK code I've found that it only initializes the
> packet metadata (whih contains the struct ofpbuf belonging to the packet)
> during setup, as the packet initializer of rte_mempool_create.
> That means that every time a packet buffer is released back by OVS to the
> buffer pool, it retains ofpbuf state, and it doesn't change when the poll
> mode driver use the buffer again to store a new packet. "source" and
> "allocated members of ofpbuf shouldn't change, but frame, l2_pad_size and
> the offsets does at various places. Even though I couldn't establish an
> error scenario yet, I think it's quite dangerous to leave the packet to
> inherit the previous packet's ofpbuf.
> Or am I missing some place where this piece is reinitialized?
>

l2_pad and offsets are initialized during flow extraction. These
fields should not be accessed before this step.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 0/11] datapath-windows: Created multiple tags for memory pools

2015-03-25 Thread Sorin Vinturis
This patch series adds support for multiple memory pool tags for OVS extension.

Sorin Vinturis (11):
  [PATCH 01/11] datapath-windows: Support for allocating/releasing
  [PATCH 02/11] datapath-windows: Added specific pool tag for datapath code
  [PATCH 03/11] datapath-windows: Added specific pool tag for buffermgmt code
  [PATCH 04/11] datapath-windows: Added specific pool tag for event code
  [PATCH 05/11] datapath-windows: Added specific pool tag for flow code
  [PATCH 06/11] datapath-windows: Added specific pool tag for vxlan code
  [PATCH 07/11] datapath-windows: Added specific pool tag for iphelper code
  [PATCH 08/11] datapath-windows: Added specific pool tag for oid code
  [PATCH 09/11] datapath-windows: Added specific pool tag for switch code
  [PATCH 10/11] datapath-windows: Added specific pool tag for user code
  [PATCH 11/11] datapath-windows: Added specific pool tag for vport code

Signed-off-by: Sorin Vinturis 
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 01/11] datapath-windows: Support for allocating/releasing memory with tag

2015-03-25 Thread Sorin Vinturis
Added functions for allocating and releasing memory with specified
tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/Util.c | 15 +++
 datapath-windows/ovsext/Util.h |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/datapath-windows/ovsext/Util.c b/datapath-windows/ovsext/Util.c
index 2dfba8e..65dd132 100644
--- a/datapath-windows/ovsext/Util.c
+++ b/datapath-windows/ovsext/Util.c
@@ -24,6 +24,21 @@
 
 extern NDIS_HANDLE gOvsExtDriverHandle;
 
+VOID*
+OvsAllocateMemoryWithTag(size_t size, ULONG tag)
+{
+OVS_VERIFY_IRQL_LE(DISPATCH_LEVEL);
+return NdisAllocateMemoryWithTagPriority(gOvsExtDriverHandle,
+(UINT32)size, tag, NormalPoolPriority);
+}
+
+VOID
+OvsFreeMemoryWithTag(VOID *ptr, ULONG tag)
+{
+ASSERT(ptr);
+NdisFreeMemoryWithTagPriority(gOvsExtDriverHandle, ptr, tag);
+}
+
 VOID *
 OvsAllocateMemory(size_t size)
 {
diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h
index e752209..0303f46 100644
--- a/datapath-windows/ovsext/Util.h
+++ b/datapath-windows/ovsext/Util.h
@@ -25,8 +25,10 @@
 #define OVS_OTHER_POOL_TAG  'MSVO'
 
 VOID *OvsAllocateMemory(size_t size);
+VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag);
 VOID *OvsAllocateAlignedMemory(size_t size, UINT16 align);
 VOID OvsFreeMemory(VOID *ptr);
+VOID OvsFreeMemoryWithTag(VOID *ptr, ULONG tag);
 VOID OvsFreeAlignedMemory(VOID *ptr);
 
 #define LIST_FORALL(_headPtr, _itemPtr) \
-- 
1.9.0.msysgit.0
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 04/11] datapath-windows: Added specific pool tag for event code

2015-03-25 Thread Sorin Vinturis
All memory allocations within event code have 'ESVO' pool tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/Event.c | 18 ++
 datapath-windows/ovsext/Util.h  |  1 +
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/datapath-windows/ovsext/Event.c b/datapath-windows/ovsext/Event.c
index 00f4616..cca9575 100644
--- a/datapath-windows/ovsext/Event.c
+++ b/datapath-windows/ovsext/Event.c
@@ -96,9 +96,9 @@ OvsCleanupEvent(POVS_OPEN_INSTANCE instance)
 
 LIST_FORALL_SAFE(&queue->elemList, link, next) {
 elem = CONTAINING_RECORD(link, OVS_EVENT_QUEUE_ELEM, link);
-OvsFreeMemory(elem);
+OvsFreeMemoryWithTag(elem, OVS_EVENT_POOL_TAG);
 }
-OvsFreeMemory(queue);
+OvsFreeMemoryWithTag(queue, OVS_EVENT_POOL_TAG);
 }
 }
 
@@ -139,7 +139,8 @@ OvsPostEvent(UINT32 portNo,
 portNo == OVS_DEFAULT_PORT_NO) {
 queue->pollAll = TRUE;
 } else {
-elem = (POVS_EVENT_QUEUE_ELEM)OvsAllocateMemory(sizeof(*elem));
+elem = (POVS_EVENT_QUEUE_ELEM)OvsAllocateMemoryWithTag(
+sizeof(*elem), OVS_EVENT_POOL_TAG);
 if (elem == NULL) {
 queue->pollAll = TRUE;
 } else {
@@ -158,7 +159,7 @@ OvsPostEvent(UINT32 portNo,
 LIST_FORALL_SAFE(&queue->elemList, curr, next) {
 RemoveEntryList(curr);
 elem = CONTAINING_RECORD(curr, OVS_EVENT_QUEUE_ELEM, link);
-OvsFreeMemory(elem);
+OvsFreeMemoryWithTag(elem, OVS_EVENT_POOL_TAG);
 }
 queue->numElems = 0;
 }
@@ -243,7 +244,8 @@ OvsSubscribeEventIoctl(PFILE_OBJECT fileObject,
 }
 
 if (request->subscribe) {
-queue = (POVS_EVENT_QUEUE)OvsAllocateMemory(sizeof (OVS_EVENT_QUEUE));
+queue = (POVS_EVENT_QUEUE)OvsAllocateMemoryWithTag(
+sizeof(OVS_EVENT_QUEUE), OVS_EVENT_POOL_TAG);
 if (queue == NULL) {
 status = STATUS_NO_MEMORY;
 OVS_LOG_WARN("Fail to allocate event queue");
@@ -284,9 +286,9 @@ done_event_subscribe:
 }
 LIST_FORALL_SAFE(&queue->elemList, link, next) {
 elem = CONTAINING_RECORD(link, OVS_EVENT_QUEUE_ELEM, link);
-OvsFreeMemory(elem);
+OvsFreeMemoryWithTag(elem, OVS_EVENT_POOL_TAG);
 }
-OvsFreeMemory(queue);
+OvsFreeMemoryWithTag(queue, OVS_EVENT_POOL_TAG);
 } else {
 OvsReleaseEventQueueLock();
 }
@@ -446,7 +448,7 @@ OvsRemoveEventEntry(POVS_OPEN_INSTANCE instance,
 elem = (POVS_EVENT_QUEUE_ELEM)RemoveHeadList(&queue->elemList);
 entry->portNo = elem->portNo;
 entry->status = elem->status;
-OvsFreeMemory(elem);
+OvsFreeMemoryWithTag(elem, OVS_EVENT_POOL_TAG);
 queue->numElems--;
 status = STATUS_SUCCESS;
 }
diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h
index 6a9c169..7811288 100644
--- a/datapath-windows/ovsext/Util.h
+++ b/datapath-windows/ovsext/Util.h
@@ -25,6 +25,7 @@
 #define OVS_OTHER_POOL_TAG  'MSVO'
 #define OVS_MDL_POOL_TAG'BSVO'
 #define OVS_DATAPATH_POOL_TAG   'DSVO'
+#define OVS_EVENT_POOL_TAG  'ESVO'
 
 VOID *OvsAllocateMemory(size_t size);
 VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag);
-- 
1.9.0.msysgit.0
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 03/11] datapath-windows: Added specific pool tag for buffermgmt code

2015-03-25 Thread Sorin Vinturis
All MDL memory allocations within buffermgmt code have 'BSVO' pool
tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/BufferMgmt.c | 6 +++---
 datapath-windows/ovsext/Util.h   | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/datapath-windows/ovsext/BufferMgmt.c 
b/datapath-windows/ovsext/BufferMgmt.c
index e0377c1..572b298 100644
--- a/datapath-windows/ovsext/BufferMgmt.c
+++ b/datapath-windows/ovsext/BufferMgmt.c
@@ -433,14 +433,14 @@ OvsAllocateMDLAndData(NDIS_HANDLE ndisHandle,
 PMDL mdl;
 PVOID data;
 
-data = OvsAllocateMemory(dataSize);
+data = OvsAllocateMemoryWithTag(dataSize, OVS_MDL_POOL_TAG);
 if (data == NULL) {
 return NULL;
 }
 
 mdl = NdisAllocateMdl(ndisHandle, data, dataSize);
 if (mdl == NULL) {
-OvsFreeMemory(data);
+OvsFreeMemoryWithTag(data, OVS_MDL_POOL_TAG);
 }
 
 return mdl;
@@ -454,7 +454,7 @@ OvsFreeMDLAndData(PMDL mdl)
 
 data = MmGetMdlVirtualAddress(mdl);
 NdisFreeMdl(mdl);
-OvsFreeMemory(data);
+OvsFreeMemoryWithTag(data, OVS_MDL_POOL_TAG);
 }
 
 
diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h
index 0f32654..6a9c169 100644
--- a/datapath-windows/ovsext/Util.h
+++ b/datapath-windows/ovsext/Util.h
@@ -23,6 +23,7 @@
 #define OVS_NBL_ONLY_POOL_TAG   'OSVO'
 #define OVS_NET_BUFFER_POOL_TAG 'NSVO'
 #define OVS_OTHER_POOL_TAG  'MSVO'
+#define OVS_MDL_POOL_TAG'BSVO'
 #define OVS_DATAPATH_POOL_TAG   'DSVO'
 
 VOID *OvsAllocateMemory(size_t size);
-- 
1.9.0.msysgit.0
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 02/11] datapath-windows: Added specific pool tag for datapath code

2015-03-25 Thread Sorin Vinturis
All memory allocations within datapath code have 'DSVO' pool tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/Datapath.c | 38 +++---
 datapath-windows/ovsext/Datapath.h | 31 +++
 datapath-windows/ovsext/Util.h |  1 +
 3 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c 
b/datapath-windows/ovsext/Datapath.c
index c6fe89e..888c6ef 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -349,6 +349,37 @@ extern POVS_SWITCH_CONTEXT gOvsSwitchContext;
 NDIS_SPIN_LOCK ovsCtrlLockObj;
 PNDIS_SPIN_LOCK gOvsCtrlLock;
 
+NTSTATUS
+InitUserDumpState(POVS_OPEN_INSTANCE instance,
+  POVS_MESSAGE ovsMsg)
+{
+/* Clear the dumpState from a previous dump sequence. */
+ASSERT(instance->dumpState.ovsMsg == NULL);
+ASSERT(ovsMsg);
+
+instance->dumpState.ovsMsg =
+(POVS_MESSAGE)OvsAllocateMemoryWithTag(sizeof(OVS_MESSAGE),
+   OVS_DATAPATH_POOL_TAG);
+if (instance->dumpState.ovsMsg == NULL) {
+return STATUS_NO_MEMORY;
+}
+RtlCopyMemory(instance->dumpState.ovsMsg, ovsMsg,
+  sizeof *instance->dumpState.ovsMsg);
+RtlZeroMemory(instance->dumpState.index,
+  sizeof instance->dumpState.index);
+
+return STATUS_SUCCESS;
+}
+
+VOID
+FreeUserDumpState(POVS_OPEN_INSTANCE instance)
+{
+if (instance->dumpState.ovsMsg != NULL) {
+OvsFreeMemoryWithTag(instance->dumpState.ovsMsg,
+ OVS_DATAPATH_POOL_TAG);
+RtlZeroMemory(&instance->dumpState, sizeof instance->dumpState);
+}
+}
 
 VOID
 OvsInit()
@@ -497,7 +528,8 @@ OvsAddOpenInstance(POVS_DEVICE_EXTENSION ovsExt,
PFILE_OBJECT fileObject)
 {
 POVS_OPEN_INSTANCE instance =
-(POVS_OPEN_INSTANCE) OvsAllocateMemory(sizeof (OVS_OPEN_INSTANCE));
+(POVS_OPEN_INSTANCE)OvsAllocateMemoryWithTag(sizeof(OVS_OPEN_INSTANCE),
+ OVS_DATAPATH_POOL_TAG);
 UINT32 i;
 
 if (instance == NULL) {
@@ -508,7 +540,7 @@ OvsAddOpenInstance(POVS_DEVICE_EXTENSION ovsExt,
 
 if (ovsNumberOfOpenInstances >= OVS_MAX_OPEN_INSTANCES) {
 OvsReleaseCtrlLock();
-OvsFreeMemory(instance);
+OvsFreeMemoryWithTag(instance, OVS_DATAPATH_POOL_TAG);
 return STATUS_INSUFFICIENT_RESOURCES;
 }
 RtlZeroMemory(instance, sizeof (OVS_OPEN_INSTANCE));
@@ -559,7 +591,7 @@ OvsRemoveOpenInstance(PFILE_OBJECT fileObject)
 OvsReleaseCtrlLock();
 ASSERT(instance->eventQueue == NULL);
 ASSERT (instance->packetQueue == NULL);
-OvsFreeMemory(instance);
+OvsFreeMemoryWithTag(instance, OVS_DATAPATH_POOL_TAG);
 }
 
 NTSTATUS
diff --git a/datapath-windows/ovsext/Datapath.h 
b/datapath-windows/ovsext/Datapath.h
index ba31ece..863afc4 100644
--- a/datapath-windows/ovsext/Datapath.h
+++ b/datapath-windows/ovsext/Datapath.h
@@ -129,35 +129,10 @@ InitUserParamsCtx(PIRP irp,
 usrParamsCtx->outputLength = outputLength;
 }
 
-static __inline NTSTATUS
-InitUserDumpState(POVS_OPEN_INSTANCE instance,
-  POVS_MESSAGE ovsMsg)
-{
-/* Clear the dumpState from a previous dump sequence. */
-ASSERT(instance->dumpState.ovsMsg == NULL);
-ASSERT(ovsMsg);
-
-instance->dumpState.ovsMsg =
-(POVS_MESSAGE) OvsAllocateMemory(sizeof (OVS_MESSAGE));
-if (instance->dumpState.ovsMsg == NULL) {
-return STATUS_NO_MEMORY;
-}
-RtlCopyMemory(instance->dumpState.ovsMsg, ovsMsg,
-  sizeof *instance->dumpState.ovsMsg);
-RtlZeroMemory(instance->dumpState.index,
-  sizeof instance->dumpState.index);
-
-return STATUS_SUCCESS;
-}
+NTSTATUS InitUserDumpState(POVS_OPEN_INSTANCE instance,
+   POVS_MESSAGE ovsMsg);
 
-static __inline VOID
-FreeUserDumpState(POVS_OPEN_INSTANCE instance)
-{
-if (instance->dumpState.ovsMsg != NULL) {
-OvsFreeMemory(instance->dumpState.ovsMsg);
-RtlZeroMemory(&instance->dumpState, sizeof instance->dumpState);
-}
-}
+VOID FreeUserDumpState(POVS_OPEN_INSTANCE instance);
 
 NTSTATUS OvsSetupDumpStart(POVS_USER_PARAMS_CONTEXT usrParamsCtx);
 
diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h
index 0303f46..0f32654 100644
--- a/datapath-windows/ovsext/Util.h
+++ b/datapath-windows/ovsext/Util.h
@@ -23,6 +23,7 @@
 #define OVS_NBL_ONLY_POOL_TAG   'OSVO'
 #define OVS_NET_BUFFER_POOL_TAG 'NSVO'
 #define OVS_OTHER_POOL_TAG  'MSVO'
+#define OVS_DATAPATH_POOL_TAG   'DSVO'
 
 VOID *OvsAllocateMemory(size_t size);
 VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag);
-- 
1.9.0.msysgit.0
___
dev mailing list
dev@openvsw

[ovs-dev] [PATCH 05/11] datapath-windows: Added specific pool tag for flow code

2015-03-25 Thread Sorin Vinturis
All memory allocations within flow code have 'LSVO' pool tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/Flow.c | 11 ++-
 datapath-windows/ovsext/Util.h |  1 +
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/datapath-windows/ovsext/Flow.c b/datapath-windows/ovsext/Flow.c
index d3de8cc..97220b4 100644
--- a/datapath-windows/ovsext/Flow.c
+++ b/datapath-windows/ovsext/Flow.c
@@ -1512,7 +1512,7 @@ OvsDeleteFlowTable(OVS_DATAPATH *datapath)
 }
 
 DeleteAllFlows(datapath);
-OvsFreeMemory(datapath->flowTable);
+OvsFreeMemoryWithTag(datapath->flowTable, OVS_FLOW_POOL_TAG);
 datapath->flowTable = NULL;
 NdisFreeRWLock(datapath->lock);
 
@@ -1534,8 +1534,8 @@ OvsAllocateFlowTable(OVS_DATAPATH *datapath,
 PLIST_ENTRY bucket;
 int i;
 
-datapath->flowTable = OvsAllocateMemory(OVS_FLOW_TABLE_SIZE *
-sizeof (LIST_ENTRY));
+datapath->flowTable = OvsAllocateMemoryWithTag(
+OVS_FLOW_TABLE_SIZE * sizeof(LIST_ENTRY), OVS_FLOW_POOL_TAG);
 if (!datapath->flowTable) {
 return NDIS_STATUS_RESOURCES;
 }
@@ -1976,7 +1976,7 @@ VOID
 FreeFlow(OvsFlow *flow)
 {
 ASSERT(flow);
-OvsFreeMemory(flow);
+OvsFreeMemoryWithTag(flow, OVS_FLOW_POOL_TAG);
 }
 
 NTSTATUS
@@ -2259,7 +2259,8 @@ OvsPrepareFlow(OvsFlow **flow,
 
 do {
 *flow = localFlow =
-OvsAllocateMemory(sizeof(OvsFlow) + put->actionsLen);
+OvsAllocateMemoryWithTag(sizeof(OvsFlow) + put->actionsLen,
+ OVS_FLOW_POOL_TAG);
 if (localFlow == NULL) {
 status = STATUS_NO_MEMORY;
 break;
diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h
index 7811288..907cd3c 100644
--- a/datapath-windows/ovsext/Util.h
+++ b/datapath-windows/ovsext/Util.h
@@ -26,6 +26,7 @@
 #define OVS_MDL_POOL_TAG'BSVO'
 #define OVS_DATAPATH_POOL_TAG   'DSVO'
 #define OVS_EVENT_POOL_TAG  'ESVO'
+#define OVS_FLOW_POOL_TAG   'LSVO'
 
 VOID *OvsAllocateMemory(size_t size);
 VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag);
-- 
1.9.0.msysgit.0
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 06/11] datapath-windows: Added specific pool tag for vxlan code

2015-03-25 Thread Sorin Vinturis
All memory allocations within vxlan code have 'XSVO' pool tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/Util.h  | 1 +
 datapath-windows/ovsext/Vxlan.c | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h
index 907cd3c..c153acf 100644
--- a/datapath-windows/ovsext/Util.h
+++ b/datapath-windows/ovsext/Util.h
@@ -27,6 +27,7 @@
 #define OVS_DATAPATH_POOL_TAG   'DSVO'
 #define OVS_EVENT_POOL_TAG  'ESVO'
 #define OVS_FLOW_POOL_TAG   'LSVO'
+#define OVS_VXLAN_POOL_TAG  'XSVO'
 
 VOID *OvsAllocateMemory(size_t size);
 VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag);
diff --git a/datapath-windows/ovsext/Vxlan.c b/datapath-windows/ovsext/Vxlan.c
index 1ce5af2..8c57185 100644
--- a/datapath-windows/ovsext/Vxlan.c
+++ b/datapath-windows/ovsext/Vxlan.c
@@ -59,7 +59,8 @@ OvsInitVxlanTunnel(POVS_VPORT_ENTRY vport,
 {
 POVS_VXLAN_VPORT vxlanPort;
 
-vxlanPort = OvsAllocateMemory(sizeof (*vxlanPort));
+vxlanPort = OvsAllocateMemoryWithTag(sizeof (*vxlanPort),
+ OVS_VXLAN_POOL_TAG);
 if (vxlanPort == NULL) {
 return STATUS_INSUFFICIENT_RESOURCES;
 }
@@ -86,7 +87,7 @@ OvsCleanupVxlanTunnel(POVS_VPORT_ENTRY vport)
 return;
 }
 
-OvsFreeMemory(vport->priv);
+OvsFreeMemoryWithTag(vport->priv, OVS_VXLAN_POOL_TAG);
 vport->priv = NULL;
 }
 
-- 
1.9.0.msysgit.0
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 07/11] datapath-windows: Added specific pool tag for iphelper code

2015-03-25 Thread Sorin Vinturis
All memory allocations within iphelper code have 'HSVO' pool tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/IpHelper.c | 75 +-
 datapath-windows/ovsext/Util.h |  1 +
 2 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/datapath-windows/ovsext/IpHelper.c 
b/datapath-windows/ovsext/IpHelper.c
index 0c64be4..f3e9658 100644
--- a/datapath-windows/ovsext/IpHelper.c
+++ b/datapath-windows/ovsext/IpHelper.c
@@ -14,6 +14,11 @@
  * limitations under the License.
  */
 
+#ifdef OVS_MEMORY_TAG
+#undef OVS_MEMORY_TAG
+#endif
+#define OVS_IPHELPER_POOL_TAG  'HSVO'
+
 #include "precomp.h"
 #include "IpHelper.h"
 #include "Switch.h"
@@ -777,7 +782,8 @@ OvsCreateIPNeighEntry(PMIB_IPNET_ROW2 ipNeigh)
 UINT64 timeVal;
 
 ASSERT(ipNeigh != NULL);
-entry = (POVS_IPNEIGH_ENTRY)OvsAllocateMemory(sizeof (OVS_IPNEIGH_ENTRY));
+entry = (POVS_IPNEIGH_ENTRY)OvsAllocateMemoryWithTag(
+sizeof(OVS_IPNEIGH_ENTRY), OVS_IPHELPER_POOL_TAG);
 if (entry == NULL) {
 return NULL;
 }
@@ -802,8 +808,8 @@ OvsCreateIPForwardEntry(PMIB_IPFORWARD_ROW2 ipRoute)
 
 ASSERT(ipRoute);
 
-entry =
-   (POVS_IPFORWARD_ENTRY)OvsAllocateMemory(sizeof (OVS_IPFORWARD_ENTRY));
+entry = (POVS_IPFORWARD_ENTRY)OvsAllocateMemoryWithTag(
+sizeof(OVS_IPFORWARD_ENTRY), OVS_IPHELPER_POOL_TAG);
 if (entry == NULL) {
 return NULL;
 }
@@ -823,7 +829,8 @@ OvsCreateFwdEntry(POVS_FWD_INFO fwdInfo)
 {
 POVS_FWD_ENTRY entry;
 
-entry = (POVS_FWD_ENTRY)OvsAllocateMemory(sizeof (OVS_FWD_ENTRY));
+entry = (POVS_FWD_ENTRY)OvsAllocateMemoryWithTag(
+sizeof(OVS_FWD_ENTRY), OVS_IPHELPER_POOL_TAG);
 if (entry == NULL) {
 return NULL;
 }
@@ -855,7 +862,7 @@ OvsRemoveFwdEntry(POVS_FWD_ENTRY fwdEntry)
 if (ipf->refCount == 0) {
 ASSERT(IsListEmpty(&ipf->fwdList));
 RemoveEntryList(&ipf->link);
-OvsFreeMemory(ipf);
+OvsFreeMemoryWithTag(ipf, OVS_IPHELPER_POOL_TAG);
 }
 
 if (ipn->refCount == 0) {
@@ -864,10 +871,10 @@ OvsRemoveFwdEntry(POVS_FWD_ENTRY fwdEntry)
 NdisAcquireSpinLock(&ovsIpHelperLock);
 RemoveEntryList(&ipn->slink);
 NdisReleaseSpinLock(&ovsIpHelperLock);
-OvsFreeMemory(ipn);
+OvsFreeMemoryWithTag(ipn, OVS_IPHELPER_POOL_TAG);
 }
 
-OvsFreeMemory(fwdEntry);
+OvsFreeMemoryWithTag(fwdEntry, OVS_IPHELPER_POOL_TAG);
 }
 
 
@@ -886,7 +893,7 @@ OvsRemoveIPForwardEntry(POVS_IPFORWARD_ENTRY ipf)
 ASSERT(ipf->refCount == 1);
 
 RemoveEntryList(&ipf->link);
-OvsFreeMemory(ipf);
+OvsFreeMemoryWithTag(ipf, OVS_IPHELPER_POOL_TAG);
 }
 
 
@@ -908,7 +915,7 @@ OvsRemoveIPNeighEntry(POVS_IPNEIGH_ENTRY ipn)
 NdisAcquireSpinLock(&ovsIpHelperLock);
 RemoveEntryList(&ipn->slink);
 NdisReleaseSpinLock(&ovsIpHelperLock);
-OvsFreeMemory(ipn);
+OvsFreeMemoryWithTag(ipn, OVS_IPHELPER_POOL_TAG);
 }
 }
 
@@ -1041,7 +1048,7 @@ OvsCleanupIpHelperRequestList(VOID)
STATUS_DEVICE_NOT_READY,
NULL);
 }
-OvsFreeMemory(request);
+OvsFreeMemoryWithTag(request, OVS_IPHELPER_POOL_TAG);
 }
 }
 
@@ -1076,8 +1083,8 @@ OvsInternalAdapterUp(UINT32 portNo,
 RtlCopyMemory(&ovsInternalNetCfgId, netCfgInstanceId, sizeof (GUID));
 RtlZeroMemory(&ovsInternalRow, sizeof (MIB_IF_ROW2));
 
-request =
-  (POVS_IP_HELPER_REQUEST)OvsAllocateMemory(sizeof 
(OVS_IP_HELPER_REQUEST));
+request = (POVS_IP_HELPER_REQUEST)OvsAllocateMemoryWithTag(
+sizeof(OVS_IP_HELPER_REQUEST), OVS_IPHELPER_POOL_TAG);
 if (request == NULL) {
 OVS_LOG_ERROR("Fail to initialize Internal Adapter");
 return;
@@ -1103,7 +1110,7 @@ OvsHandleInternalAdapterUp(POVS_IP_HELPER_REQUEST request)
 MIB_UNICASTIPADDRESS_ROW ipEntry;
 GUID *netCfgInstanceId = &ovsInternalNetCfgId;
 
-OvsFreeMemory(request);
+OvsFreeMemoryWithTag(request, OVS_IPHELPER_POOL_TAG);
 
 status = OvsGetIfEntry(&ovsInternalNetCfgId, &ovsInternalRow);
 
@@ -1161,7 +1168,7 @@ OvsEnqueueIpHelperRequest(POVS_IP_HELPER_REQUEST request)
 if (ovsInternalPortNo == OVS_DEFAULT_PORT_NO ||
 ovsInternalIPConfigured == FALSE) {
 NdisReleaseSpinLock(&ovsIpHelperLock);
-OvsFreeMemory(request);
+OvsFreeMemoryWithTag(request, OVS_IPHELPER_POOL_TAG);
 return STATUS_NDIS_ADAPTER_NOT_READY;
 } else {
 InsertHeadList(&ovsIpHelperRequestList, &request->link);
@@ -1185,8 +1192,8 @@ OvsFwdIPHelperRequest(PNET_BUFFER_LIST nbl,
 {
 POVS_IP_HELPER_REQUEST request;
 
-request =
-  (POVS_IP_HELPER_REQUEST)OvsAllocateMemory(sizeof 
(OVS_IP_HELPER_REQUEST));
+request = (POVS_IP_HELPER_REQUEST)OvsAllocateMemoryWithTag(
+sizeof(OVS_IP_HELPER_REQ

[ovs-dev] [PATCH 08/11] datapath-windows: Added specific pool tag for oid code

2015-03-25 Thread Sorin Vinturis
All memory allocations within oid code have 'ASVO' pool tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/Oid.c  | 41 +
 datapath-windows/ovsext/Oid.h  |  3 +++
 datapath-windows/ovsext/Util.h |  1 +
 3 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/datapath-windows/ovsext/Oid.c b/datapath-windows/ovsext/Oid.c
index 83fa1e3..c94d17e 100644
--- a/datapath-windows/ovsext/Oid.c
+++ b/datapath-windows/ovsext/Oid.c
@@ -605,7 +605,7 @@ OvsIssueOidRequest(POVS_SWITCH_CONTEXT switchContext,
 NDIS_STATUS status;
 PNDIS_OID_REQUEST oidRequest;
 POVS_OID_CONTEXT oidContext;
-ULONG OvsExtOidRequestId = 'ISVO';
+ULONG OvsExtOidRequestId =  'ISVO';
 
 DBG_UNREFERENCED_PARAMETER(inputSize);
 DBG_UNREFERENCED_PARAMETER(oidInputBuffer);
@@ -617,15 +617,17 @@ OvsIssueOidRequest(POVS_SWITCH_CONTEXT switchContext,
 ASSERT(oidOutputBuffer == NULL || outputSize != 0);
 ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
 
-oidRequest = OvsAllocateMemory(sizeof *oidRequest);
+oidRequest = OvsAllocateMemoryWithTag(sizeof *oidRequest,
+  OVS_OID_POOL_TAG);
 if (!oidRequest) {
 status = NDIS_STATUS_RESOURCES;
 goto done;
 }
 
-oidContext = OvsAllocateMemory(sizeof *oidContext);
+oidContext = OvsAllocateMemoryWithTag(sizeof *oidContext,
+  OVS_OID_POOL_TAG);
 if (!oidContext) {
-OvsFreeMemory(oidRequest);
+OvsFreeMemoryWithTag(oidRequest, OVS_OID_POOL_TAG);
 status = NDIS_STATUS_RESOURCES;
 goto done;
 }
@@ -684,8 +686,8 @@ OvsIssueOidRequest(POVS_SWITCH_CONTEXT switchContext,
 status = oidContext->status;
 ASSERT(status != NDIS_STATUS_PENDING);
 
-OvsFreeMemory(oidRequest);
-OvsFreeMemory(oidContext);
+OvsFreeMemoryWithTag(oidRequest, OVS_OID_POOL_TAG);
+OvsFreeMemoryWithTag(oidContext, OVS_OID_POOL_TAG);
 
 done:
 OVS_LOG_TRACE("Exit: status %8x.", status);
@@ -710,7 +712,8 @@ OvsQuerySwitchActivationComplete(POVS_SWITCH_CONTEXT 
switchContext,
 OVS_LOG_TRACE("Enter: switchContext: %p, switchActive: %p",
   switchContext, switchActive);
 
-switchParams = OvsAllocateMemory(sizeof *switchParams);
+switchParams = OvsAllocateMemoryWithTag(sizeof *switchParams,
+OVS_OID_POOL_TAG);
 if (!switchParams) {
 status = NDIS_STATUS_RESOURCES;
 goto done;
@@ -741,7 +744,7 @@ OvsQuerySwitchActivationComplete(POVS_SWITCH_CONTEXT 
switchContext,
 *switchActive = switchParams->IsActive;
 }
 
-OvsFreeMemory(switchParams);
+OvsFreeMemoryWithTag(switchParams, OVS_OID_POOL_TAG);
 
 done:
 OVS_LOG_TRACE("Exit: status %8x, switchActive: %d.",
@@ -769,7 +772,7 @@ OvsGetPortsOnSwitch(POVS_SWITCH_CONTEXT switchContext,
 do {
 UINT32 reqdArraySize;
 
-portArray = OvsAllocateMemory(arraySize);
+portArray = OvsAllocateMemoryWithTag(arraySize, OVS_OID_POOL_TAG);
 if (!portArray) {
 status = NDIS_STATUS_RESOURCES;
 goto done;
@@ -794,7 +797,7 @@ OvsGetPortsOnSwitch(POVS_SWITCH_CONTEXT switchContext,
 break;
 }
 
-OvsFreeMemory(portArray);
+OvsFreeMemoryWithTag(portArray, OVS_OID_POOL_TAG);
 arraySize = reqdArraySize;
 if (status != NDIS_STATUS_INVALID_LENGTH) {
 break;
@@ -827,7 +830,7 @@ OvsGetNicsOnSwitch(POVS_SWITCH_CONTEXT switchContext,
 do {
 UINT32 reqdArraySize;
 
-nicArray = OvsAllocateMemory(arraySize);
+nicArray = OvsAllocateMemoryWithTag(arraySize, OVS_OID_POOL_TAG);
 if (!nicArray) {
 status = NDIS_STATUS_RESOURCES;
 goto done;
@@ -852,7 +855,7 @@ OvsGetNicsOnSwitch(POVS_SWITCH_CONTEXT switchContext,
 break;
 }
 
-OvsFreeMemory(nicArray);
+OvsFreeMemoryWithTag(nicArray, OVS_OID_POOL_TAG);
 arraySize = reqdArraySize;
 if (status != NDIS_STATUS_INVALID_LENGTH) {
 break;
@@ -863,3 +866,17 @@ done:
 OVS_LOG_TRACE("Exit: status %8x.", status);
 return status;
 }
+
+VOID OvsFreeSwitchPortsArray(PNDIS_SWITCH_PORT_ARRAY portsArray)
+{
+if (portsArray) {
+OvsFreeMemoryWithTag(portsArray, OVS_OID_POOL_TAG);
+}
+}
+
+VOID OvsFreeSwitchNicsArray(PNDIS_SWITCH_NIC_ARRAY nicsArray)
+{
+if (nicsArray) {
+OvsFreeMemoryWithTag(nicsArray, OVS_OID_POOL_TAG);
+}
+}
\ No newline at end of file
diff --git a/datapath-windows/ovsext/Oid.h b/datapath-windows/ovsext/Oid.h
index 88a3d7d..ffa4d60 100644
--- a/datapath-windows/ovsext/Oid.h
+++ b/datapath-windows/ovsext/Oid.h
@@ -23,4 +23,7 @@ NDIS_STATUS OvsGetPortsOnSwitch(POVS_SWITCH_CONTEXT 
switchContext,
 P

[ovs-dev] [PATCH 11/11] datapath-windows: Added specific pool tag for vport code

2015-03-25 Thread Sorin Vinturis
All memory allocations within vport code have 'PSVO' pool tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/Util.h  |  1 +
 datapath-windows/ovsext/Vport.c | 31 ---
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h
index a8eed91..9a01242 100644
--- a/datapath-windows/ovsext/Util.h
+++ b/datapath-windows/ovsext/Util.h
@@ -32,6 +32,7 @@
 #define OVS_OID_POOL_TAG'ASVO'
 #define OVS_SWITCH_POOL_TAG 'SSVO'
 #define OVS_USER_POOL_TAG   'USVO'
+#define OVS_VPORT_POOL_TAG  'PSVO'
 
 VOID *OvsAllocateMemory(size_t size);
 VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag);
diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c
index c9dfaea..12751be 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -306,7 +306,7 @@ HvCreateNic(POVS_SWITCH_CONTEXT switchContext,
 OvsInitPhysNicVport(vport, virtExtVport, nicParam->NicIndex);
 status = InitHvVportCommon(switchContext, vport, TRUE);
 if (status != NDIS_STATUS_SUCCESS) {
-OvsFreeMemory(vport);
+OvsFreeMemoryWithTag(vport, OVS_VPORT_POOL_TAG);
 goto add_nic_done;
 }
 }
@@ -658,7 +658,7 @@ OvsFindVportByHvNameA(POVS_SWITCH_CONTEXT switchContext,
 SIZE_T wstrSize = length * sizeof(WCHAR);
 UINT i;
 
-PWSTR wsName = OvsAllocateMemory(wstrSize);
+PWSTR wsName = OvsAllocateMemoryWithTag(wstrSize, OVS_VPORT_POOL_TAG);
 if (!wsName) {
 return NULL;
 }
@@ -666,7 +666,7 @@ OvsFindVportByHvNameA(POVS_SWITCH_CONTEXT switchContext,
 wsName[i] = name[i];
 }
 vport = OvsFindVportByHvNameW(switchContext, wsName, wstrSize);
-OvsFreeMemory(wsName);
+OvsFreeMemoryWithTag(wsName, OVS_VPORT_POOL_TAG);
 return vport;
 }
 
@@ -703,7 +703,8 @@ POVS_VPORT_ENTRY
 OvsAllocateVport(VOID)
 {
 POVS_VPORT_ENTRY vport;
-vport = (POVS_VPORT_ENTRY)OvsAllocateMemory(sizeof (OVS_VPORT_ENTRY));
+vport = (POVS_VPORT_ENTRY)OvsAllocateMemoryWithTag(
+sizeof(OVS_VPORT_ENTRY), OVS_VPORT_POOL_TAG);
 if (vport == NULL) {
 return NULL;
 }
@@ -1073,7 +1074,7 @@ OvsRemoveAndDeleteVport(POVS_SWITCH_CONTEXT switchContext,
 ASSERT(switchContext->numPhysicalNics == 0);
 switchContext->virtualExternalPortId = 0;
 switchContext->virtualExternalVport = NULL;
-OvsFreeMemory(vport);
+OvsFreeMemoryWithTag(vport, OVS_VPORT_POOL_TAG);
 if (vportDeallocated) {
 *vportDeallocated = TRUE;
 }
@@ -1151,7 +1152,7 @@ OvsRemoveAndDeleteVport(POVS_SWITCH_CONTEXT switchContext,
 } else {
 switchContext->numNonHvVports--;
 }
-OvsFreeMemory(vport);
+OvsFreeMemoryWithTag(vport, OVS_VPORT_POOL_TAG);
 if (vportDeallocated) {
 *vportDeallocated = TRUE;
 }
@@ -1189,19 +1190,20 @@ OvsAddConfiguredSwitchPorts(POVS_SWITCH_CONTEXT 
switchContext)
  OvsInitVportWithPortParam(vport, portParam);
  status = InitHvVportCommon(switchContext, vport, TRUE);
  if (status != NDIS_STATUS_SUCCESS) {
- OvsFreeMemory(vport);
+ OvsFreeMemoryWithTag(vport, OVS_VPORT_POOL_TAG);
  goto cleanup;
  }
 }
+
 cleanup:
 if (status != NDIS_STATUS_SUCCESS) {
 OvsClearAllSwitchVports(switchContext);
 }
 
-if (portArray != NULL) {
-OvsFreeMemory(portArray);
-}
+OvsFreeSwitchPortsArray(portArray);
+
 OVS_LOG_TRACE("Exit: status: %x", status);
+
 return status;
 }
 
@@ -1248,7 +1250,7 @@ OvsInitConfiguredSwitchNics(POVS_SWITCH_CONTEXT 
switchContext)
 nicParam->NicIndex);
 status = InitHvVportCommon(switchContext, vport, TRUE);
 if (status != NDIS_STATUS_SUCCESS) {
-OvsFreeMemory(vport);
+OvsFreeMemoryWithTag(vport, OVS_VPORT_POOL_TAG);
 vport = NULL;
 }
 }
@@ -1268,9 +1270,8 @@ OvsInitConfiguredSwitchNics(POVS_SWITCH_CONTEXT 
switchContext)
 }
 cleanup:
 
-if (nicArray != NULL) {
-OvsFreeMemory(nicArray);
-}
+OvsFreeSwitchNicsArray(nicArray);
+
 OVS_LOG_TRACE("Exit: status: %x", status);
 return status;
 }
@@ -2129,7 +2130,7 @@ Cleanup:
 OvsCleanupVxlanTunnel(vport);
 }
 }
-OvsFreeMemory(vport);
+OvsFreeMemoryWithTag(vport, OVS_VPORT_POOL_TAG);
 }
 
 NlBuildErrorMsg(msgIn, msgError, nlError);
-- 
1.9.0.msysgit.0
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman

[ovs-dev] [PATCH 09/11] datapath-windows: Added specific pool tag for switch code

2015-03-25 Thread Sorin Vinturis
All memory allocations within switch code have 'SSVO' pool tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/Switch.c | 53 +++-
 datapath-windows/ovsext/Util.h   |  1 +
 2 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c
index a228d8e..61a4531 100644
--- a/datapath-windows/ovsext/Switch.c
+++ b/datapath-windows/ovsext/Switch.c
@@ -168,8 +168,8 @@ OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,
 
 OVS_LOG_TRACE("Enter: Create switch object");
 
-switchContext =
-(POVS_SWITCH_CONTEXT) OvsAllocateMemory(sizeof(OVS_SWITCH_CONTEXT));
+switchContext = (POVS_SWITCH_CONTEXT) OvsAllocateMemoryWithTag(
+sizeof(OVS_SWITCH_CONTEXT), OVS_SWITCH_POOL_TAG);
 if (switchContext == NULL) {
 status = NDIS_STATUS_RESOURCES;
 goto create_switch_done;
@@ -187,7 +187,7 @@ OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,
 if (status != NDIS_STATUS_SUCCESS) {
 OVS_LOG_ERROR("OvsExtAttach: Extension is running in "
   "non-switch environment.");
-OvsFreeMemory(switchContext);
+OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
 goto create_switch_done;
 }
 
@@ -198,14 +198,14 @@ OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,
 
 status = OvsInitSwitchContext(switchContext);
 if (status != NDIS_STATUS_SUCCESS) {
-OvsFreeMemory(switchContext);
+OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
 goto create_switch_done;
 }
 
 status = OvsTunnelFilterInitialize(gOvsExtDriverObject);
 if (status != NDIS_STATUS_SUCCESS) {
 OvsUninitSwitchContext(switchContext);
-OvsFreeMemory(switchContext);
+OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
 goto create_switch_done;
 }
 *switchContextOut = switchContext;
@@ -264,7 +264,7 @@ OvsDeleteSwitch(POVS_SWITCH_CONTEXT switchContext)
 OvsTunnelFilterUninitialize(gOvsExtDriverObject);
 OvsClearAllSwitchVports(switchContext);
 OvsUninitSwitchContext(switchContext);
-OvsFreeMemory(switchContext);
+OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
 }
 OVS_LOG_TRACE("Exit: deleted switch %p  dpNo: %d", switchContext, dpNo);
 }
@@ -358,14 +358,14 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 switchContext->dispatchLock =
 NdisAllocateRWLock(switchContext->NdisFilterHandle);
 
-switchContext->portNoHashArray = (PLIST_ENTRY)
-OvsAllocateMemory(sizeof(LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
-switchContext->ovsPortNameHashArray = (PLIST_ENTRY)
-OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
-switchContext->portIdHashArray= (PLIST_ENTRY)
-OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
-switchContext->pidHashArray = (PLIST_ENTRY)
-OvsAllocateMemory(sizeof(LIST_ENTRY) * OVS_MAX_PID_ARRAY_SIZE);
+switchContext->portNoHashArray = (PLIST_ENTRY)OvsAllocateMemoryWithTag(
+sizeof(LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE, OVS_SWITCH_POOL_TAG);
+switchContext->ovsPortNameHashArray = 
(PLIST_ENTRY)OvsAllocateMemoryWithTag(
+sizeof(LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE, OVS_SWITCH_POOL_TAG);
+switchContext->portIdHashArray= (PLIST_ENTRY)OvsAllocateMemoryWithTag(
+sizeof(LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE, OVS_SWITCH_POOL_TAG);
+switchContext->pidHashArray = (PLIST_ENTRY)OvsAllocateMemoryWithTag(
+sizeof(LIST_ENTRY) * OVS_MAX_PID_ARRAY_SIZE, OVS_SWITCH_POOL_TAG);
 status = OvsAllocateFlowTable(&switchContext->datapath, switchContext);
 
 if (status == NDIS_STATUS_SUCCESS) {
@@ -381,17 +381,20 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
 NdisFreeRWLock(switchContext->dispatchLock);
 }
 if (switchContext->portNoHashArray) {
-OvsFreeMemory(switchContext->portNoHashArray);
+OvsFreeMemoryWithTag(switchContext->portNoHashArray,
+ OVS_SWITCH_POOL_TAG);
 }
 if (switchContext->ovsPortNameHashArray) {
-OvsFreeMemory(switchContext->ovsPortNameHashArray);
+OvsFreeMemoryWithTag(switchContext->ovsPortNameHashArray,
+ OVS_SWITCH_POOL_TAG);
 }
 if (switchContext->portIdHashArray) {
-OvsFreeMemory(switchContext->portIdHashArray);
+OvsFreeMemoryWithTag(switchContext->portIdHashArray,
+ OVS_SWITCH_POOL_TAG);
 }
-
 if (switchContext->pidHashArray) {
-OvsFreeMemory(switchContext->pidHashArray);
+OvsFreeMemoryWithTag(switchContext->pidHashArray,
+ OVS_SWITCH_POOL_TAG);

[ovs-dev] [PATCH 10/11] datapath-windows: Added specific pool tag for user code

2015-03-25 Thread Sorin Vinturis
All memory allocations within user code have 'USVO' pool tag.

Signed-off-by: Sorin Vinturis 
Reported-by: Alin Gabriel Serdean 
Reported-at: https://github.com/openvswitch/ovs-issues/issues/56
---
 datapath-windows/ovsext/User.c | 18 ++
 datapath-windows/ovsext/Util.h |  1 +
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index d8a657e..03f0377 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -85,7 +85,7 @@ OvsPurgePacketQueue(POVS_USER_PACKET_QUEUE queue,
 LIST_FORALL_SAFE(&tmp, link, next) {
 RemoveEntryList(link);
 elem = CONTAINING_RECORD(link, OVS_PACKET_QUEUE_ELEM, link);
-OvsFreeMemory(elem);
+OvsFreeMemoryWithTag(elem, OVS_USER_POOL_TAG);
 }
 }
 
@@ -132,13 +132,13 @@ OvsCleanupPacketQueue(POVS_OPEN_INSTANCE instance)
 LIST_FORALL_SAFE(&tmp, link, next) {
 RemoveEntryList(link);
 elem = CONTAINING_RECORD(link, OVS_PACKET_QUEUE_ELEM, link);
-OvsFreeMemory(elem);
+OvsFreeMemoryWithTag(elem, OVS_USER_POOL_TAG);
 }
 if (irp) {
 OvsCompleteIrpRequest(irp, 0, STATUS_SUCCESS);
 }
 if (queue) {
-OvsFreeMemory(queue);
+OvsFreeMemoryWithTag(queue, OVS_USER_POOL_TAG);
 }
 
 /* Verify if gOvsSwitchContext exists. */
@@ -170,7 +170,8 @@ OvsSubscribeDpIoctl(PVOID instanceP,
 OvsReleasePidHashLock();
 
 } else if (instance->packetQueue == NULL && join) {
-queue = (POVS_USER_PACKET_QUEUE) OvsAllocateMemory(sizeof *queue);
+queue = (POVS_USER_PACKET_QUEUE) OvsAllocateMemoryWithTag(
+sizeof *queue, OVS_USER_POOL_TAG);
 if (queue == NULL) {
 return STATUS_NO_MEMORY;
 }
@@ -248,7 +249,7 @@ OvsReadDpIoctl(PFILE_OBJECT fileObject,
 }
 
 *replyLen = len;
-OvsFreeMemory(elem);
+OvsFreeMemoryWithTag(elem, OVS_USER_POOL_TAG);
 }
 return STATUS_SUCCESS;
 }
@@ -762,7 +763,7 @@ OvsQueuePackets(PLIST_ENTRY packetList,
 while (!IsListEmpty(&dropPackets)) {
 link = RemoveHeadList(&dropPackets);
 elem = CONTAINING_RECORD(link, OVS_PACKET_QUEUE_ELEM, link);
-OvsFreeMemory(elem);
+OvsFreeMemoryWithTag(elem, OVS_USER_POOL_TAG);
 num++;
 }
 
@@ -1060,7 +1061,8 @@ OvsCreateQueueNlPacket(PVOID userData,
 dataLen + extraLen);
 
 allocLen = sizeof (OVS_PACKET_QUEUE_ELEM) + nlMsgSize;
-elem = (POVS_PACKET_QUEUE_ELEM)OvsAllocateMemory(allocLen);
+elem = (POVS_PACKET_QUEUE_ELEM)OvsAllocateMemoryWithTag(allocLen,
+OVS_USER_POOL_TAG);
 if (elem == NULL) {
 ovsUserStats.dropDuetoResource++;
 return NULL;
@@ -1163,6 +1165,6 @@ OvsCreateQueueNlPacket(PVOID userData,
 
 return elem;
 fail:
-OvsFreeMemory(elem);
+OvsFreeMemoryWithTag(elem, OVS_USER_POOL_TAG);
 return NULL;
 }
diff --git a/datapath-windows/ovsext/Util.h b/datapath-windows/ovsext/Util.h
index 2cebe6f..a8eed91 100644
--- a/datapath-windows/ovsext/Util.h
+++ b/datapath-windows/ovsext/Util.h
@@ -31,6 +31,7 @@
 #define OVS_IPHELPER_POOL_TAG   'HSVO'
 #define OVS_OID_POOL_TAG'ASVO'
 #define OVS_SWITCH_POOL_TAG 'SSVO'
+#define OVS_USER_POOL_TAG   'USVO'
 
 VOID *OvsAllocateMemory(size_t size);
 VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag);
-- 
1.9.0.msysgit.0
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] datapath: Turn vports with dependencies into separate modules

2015-03-25 Thread Pravin Shelar
On Tue, Mar 17, 2015 at 5:00 AM, Thomas Graf  wrote:
> Upstream commit:
> The internal and netdev vport remain part of openvswitch.ko. Encap
> vports including vxlan, gre, and geneve can be built as separate
> modules and are loaded on demand. Modules can be unloaded after use.
> Datapath ports keep a reference to the vport module during their
> lifetime.
>
> Allows to remove the error prone maintenance of the global list
> vport_ops_list.
>
> Signed-off-by: Thomas Graf 
> Signed-off-by: David S. Miller 
>
> Also folds in the follow-up commit 9ba559d9ca3 to turned the non-GPL
> symbol exports to GPL exports.
>
> Exports various backwards compat functions linked into the main
> openvswitch module as GPL symbols to ensure vport modules can use them.
>
> Some fiddling with the Makefile was needed to work around the fact
> that Makefile variables can't contain '-' characters needed to define
> 'vport-xxx' module sources. Also, Kbuild complains heavily if a
> $(module)-y = $(module).o is defined which is actually backed with a .c
> file of the same name. Therefore, a new $(build_multi_modules) variable
> is defined which lists all module which consist of more than one source
> file.
>
> Upstream: 62b9c8d0372 ("ovs: Turn vports with dependencies into separate 
> modules")
> Upstream: 9ba559d9ca3 ("openvswitch: Export symbols as GPL symbols.")
> Signed-off-by: Thomas Graf 

Thanks for the patch. I saw couple of issues:-
I saw following warning due to missing symbol.
WARNING: "lockdep_ovsl_is_held"
[/home/pravin/ovs/w8/datapath/linux/vport-gre.ko] undefined!

Command to reload kernel datapath does not work anymore.
`ovs-ctl force-reload-kmod` seg faults as follows:


device br0 left promiscuous mode
general protection fault:  [#1] SMP DEBUG_PAGEALLOC
Modules linked in: openvswitch(OF) vxlan ip_tunnel libcrc32c veth
netconsole configfs autofs4 ipt_REJECT ip6t_REJECT nf_conntrack_ipv6
nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables ipv6
vhost_net macvtap macvlan vhost tun kvm_intel kvm iTCO_wdt
iTCO_vendor_support dcdbas microcode pcspkr sb_edac edac_core acpi_pad
lpc_ich mfd_core shpchp tg3 ptp pps_core ses enclosure sg wmi ext4(F)
jbd2(F) mbcache(F) usb_storage(F) sd_mod(F) crc_t10dif(F)
crct10dif_common(F) megaraid_sas(F) dm_mirror(F) dm_region_hash(F)
dm_log(F) dm_mod(F) [last unloaded: openvswitch]
CPU: 10 PID: 22434 Comm: ovs-dpctl Tainted: GF  O 3.14.30 #4
Hardware name: Dell Inc. PowerEdge T320/07C9XP, BIOS 2.1.2 01/20/2014
task: 8807e756 ti: 8807fd7e6000 task.ti: 8807fd7e6000
RIP: 0010:[]  []
ovs_vport_del+0x4a/0x70 [openvswitch]
RSP: 0018:8807fd7e7958  EFLAGS: 00010292
RAX: 6b6b6b6b6b6b6b6b RBX: 8807fef57cf0 RCX: 0006
RDX: 6990 RSI: 8807e7560c50 RDI: 8807fd7e78f8
RBP: 8807fd7e7968 R08: 0001 R09: 
R10: ea001ff96c18 R11:  R12: 
R13: 0008 R14: 81d13300 R15: a072d888
FS:  7fb4272ec860() GS:880806a0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 00408430 CR3: 0007fee86000 CR4: 001407e0
Stack:
 8807fd7e7968 8807fef57cf0 8807fd7e7988 a0718e14
  8800c79918f0 8807fd7e79b8 a07194de
 8807fd7e7a28 8807fd7e7a28 8807fc1aa1c0 8800c79918f0
Call Trace:
 [] ovs_dp_detach_port+0x44/0x60 [openvswitch]
 [] __dp_destroy+0x4e/0xc0 [openvswitch]
 [] ovs_dp_cmd_del+0x7e/0xd0 [openvswitch]
 [] genl_family_rcv_msg+0x233/0x3a0
 [] ? __lock_acquired+0x145/0x360
 [] ? genl_family_rcv_msg+0x3a0/0x3a0
 [] genl_rcv_msg+0x63/0xb0
 [] netlink_rcv_skb+0xa9/0xd0
 [] ? genl_rcv+0x1d/0x40
 [] genl_rcv+0x2c/0x40
 [] netlink_unicast+0x182/0x210
 [] netlink_sendmsg+0x2af/0x400
 [] sock_sendmsg+0x90/0xc0
 [] ? __lock_release+0x9e/0x1f0
 [] ? might_fault+0x66/0xc0
 [] ? verify_iovec+0x8d/0x110
 [] ___sys_sendmsg+0x3f6/0x410
 [] ? __do_page_fault+0x2bc/0x4d0
 [] ? __lock_acquire+0x381/0x5e0
 [] ? rcu_read_lock_held+0x45/0x50
 [] ? __fget_light+0x105/0x110
 [] __sys_sendmsg+0x49/0x90
 [] SyS_sendmsg+0x19/0x20
 [] system_call_fastpath+0x16/0x1b
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v4 4/5] ofproto-dpif: Restore metadata and registers on recirculation.

2015-03-25 Thread Ethan Jackson
Copyright year in ofproto-dpif-rid.c needs to be updated.

In compose_output_action__() it's not clear to me why we don't pass
the table_id to xlate_table_action() anymore.

Ask discussed offline, I think it would be a bit cleaner to garbage
collect the recird ids.  That said, I don't think it should block the
patch.

Also itd be nice to switch bonds to using this same framework.

Acked-by: Ethan Jackson 


On Tue, Mar 24, 2015 at 11:08 AM, Jarno Rajahalme  wrote:
> Thank you for the review. Ethan promised to review this as well, so I’ll wait 
> for his verdict before merging this.
>
>   Jarno
>
>> On Mar 24, 2015, at 9:56 AM, Ben Pfaff  wrote:
>>
>> On Thu, Mar 19, 2015 at 06:03:28PM -0700, Jarno Rajahalme wrote:
>>> xlate_actions() now considers an optional recirculation context (via
>>> 'xin') and restores OpenFlow pipeline metadata (registers, 'metadata',
>>> etc.) based on it.  The recirculation context may contain an action
>>> set and stack to be restored and further actions to be executed upon
>>> recirculation.  It also contains a table_id number to be used for rule
>>> lookup in cases where no post-recirculation actions are used.
>>>
>>> The translation context internal metadata is restored using a new
>>> internal action: UNROLL_XLATE action stores the translation context
>>> data visible to OpenFlow controllers via PACKET_IN messages.  This
>>> includes the current table number and the current rule cookie.
>>> UNROLL_XLATE actions are inserted only when the remaining actions may
>>> generate PACKET_IN messages.
>>>
>>> These changes allow the post-MPLS recirculation to properly continue
>>> with the pipeline metadata that existed at the time of recirculation.
>>>
>>> The internal table is still consulted for bonds.
>>>
>>> Signed-off-by: Jarno Rajahalme 
>>
>> I've read this a few times before and I feel like I can't properly
>> re-review it.  I did a quick scroll-through this time and nothing jumped
>> out.  If you want a thorough review, you should ask someone with fresh
>> eyes, but short of that:
>>
>> Acked-by: Ben Pfaff 
>>
>> Thanks so much for persisting with this big job!
>
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] compat: Fix RHEL7 build.

2015-03-25 Thread Pravin Shelar
On Tue, Mar 24, 2015 at 4:59 PM, Joe Stringer  wrote:
> Tested against 3.10.0-229.el7.x86_64.
>
> Signed-off-by: Joe Stringer 

looks good.
Acked-by: Pravin B Shelar 
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Mail System Error - Returned Mail

2015-03-25 Thread Bounced mail
The original message was received at Thu, 26 Mar 2015 09:17:11 +0700
from 154.87.35.105

- The following addresses had permanent fatal errors -


- Transcript of session follows -
... while talking to 134.60.247.29:
>>> MAIL FROM:"Bounced mail" 
<<< 502 Access denied

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


Re: [ovs-dev] [PATCH] netdev-dpdk: Put cuse thread into quiescent state.

2015-03-25 Thread Ben Pfaff
On Wed, Mar 25, 2015 at 05:43:06PM +, Kevin Traynor wrote:
> As ovsrcu_synchronize() is used when setting virtio_dev to NULL,
> ovsrcu_quiesce_start() must be called before destroy_device() returns.
> Otherwise there will be warnings about the thread not quiescing.
> Use of ovs_thread_create() instead of pthread_create() is optional but
> as we are now setting quiescent state, it is added.
> 
> Signed-off-by: Kevin Traynor 

Is the quiescent state permanent?  Normally ovsrcu_quiesce_start() and
ovsrcu_quiesce_end() should be paired, but this patch only seems to add
the former.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 1/2] ovs-sandbox: Initialize database before starting ovs-vswitchd.

2015-03-25 Thread Ben Pfaff
Otherwise ovs-vswitchd can't immediately start working (until some other
call to ovs-vsctl initializes the database).  This is most obvious if one
runs "ovs-vsctl list Open_vSwitch ." as the first command, because the
output will not show the changes that ovs-vswitchd will make to the
database at startup (in particular initializing datapath_types and
iface_types), which is confusing.

Signed-off-by: Ben Pfaff 
---
 tutorial/ovs-sandbox | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tutorial/ovs-sandbox b/tutorial/ovs-sandbox
index 1504ea9..9520a41 100755
--- a/tutorial/ovs-sandbox
+++ b/tutorial/ovs-sandbox
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-# Copyright (c) 2013 Nicira, Inc.
+# Copyright (c) 2013, 2015 Nicira, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -235,6 +235,9 @@ run ovsdb-tool create conf.db "$schema"
 rungdb $gdb_ovsdb ovsdb-server --detach --no-chdir --pidfile -vconsole:off 
--log-file \
 --remote=punix:"$sandbox"/db.sock
 
+# Initialize database.
+run ovs-vsctl --no-wait -- init
+
 # Start ovs-vswitchd.
 rungdb $gdb_vswitchd ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off 
--log-file \
 --enable-dummy=override -vvconn -vnetdev_dummy
-- 
2.1.3

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


[ovs-dev] [PATCH 2/2] bridge: Remove redundant call to discover_types().

2015-03-25 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 vswitchd/bridge.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 2e90ea2..be149c3 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -578,10 +578,6 @@ bridge_reconfigure(const struct ovsrec_open_vswitch 
*ovs_cfg)
 smap_get_int(&ovs_cfg->other_config, "n-handler-threads", 0),
 smap_get_int(&ovs_cfg->other_config, "n-revalidator-threads", 0));
 
-if (ovs_cfg) {
-discover_types(ovs_cfg);
-}
-
 /* Destroy "struct bridge"s, "struct port"s, and "struct iface"s according
  * to 'ovs_cfg', with only very minimal configuration otherwise.
  *
-- 
2.1.3

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


Re: [ovs-dev] [PATCH v2] vswitch.ovsschema: Add datapath_types and port_types.

2015-03-25 Thread Ben Pfaff
On Wed, Mar 25, 2015 at 12:29:56PM +, O Mahony, Billy wrote:
> I have verified the modified code works as expected when run with/without 
> --dpdk on the vswitchd command line.
> 
> I'm wondering why there is a call to 'discover_types' in two places?

I made a mistake, sorry.  Thanks for pointing it out.  I sent out a fix:
http://openvswitch.org/pipermail/dev/2015-March/052868.html

> I think it might be to do with something that I could not figure out
> when I was trying to ensure discover_types was not called more often
> that necessary.
> 
> I had initially tried to align the call to 'discover_types' with the
> 'initial_config_done' flag in 'bridge_run'. However on the first
> invocation (the first 3 in fact) 'cfg' was NULL (i.e. there was no
> record in Open_vSwitch table). 

It will be null (all the database will be empty) until the IDL manages
to retrieve the database contents from the server.  This takes a few
trips through the main loop; I guess you tended to see 3 trips, but it
can certainly vary.

> Then on the 4th invocation the idl sequence number is bumped and
> 'bridge_reconfigure' is handed an empty ' ovsrec_open_vswitch' which
> is then commited to the db before vswitchd daemonizes.

It shouldn't be empty at this point unless the database hasn't been
initialized.  There was a bug in the ovs-sandbox script that made this
likely for casual developer testing with "make sandbox"; I sent out a
fix for that:
http://openvswitch.org/pipermail/dev/2015-March/052867.html

> However, and this is what I could not get, was that handing the empty
> ' ovsrec_open_vswitch' ('null_cfg') to discover_types when doing the
> initial config did not update the Open_vSwitch table as desired - I
> was expecting discover_types to update the idl record and the the
> commit on 'daemonize_txn' to do the needful.  ( I had removed the
> separate txn create/commit from discover_types at this point).

If null_cfg gets handed to bridge_reconfigure(), that means there's no
real record to modify (none has been added to the database; the database
is empty).
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev