[ovs-dev] [PATCH v2] ofproto: Fix Coverity false positive.

2024-04-09 Thread miterv
From: Lin Huang 

Coverity reports a false positive below:
Ofproto_class_find__() may return NULL, and dereference it to cause segfault.

This patch is made just to avoid false-positive Coverity report.

Tested-by: Zhang YuHuang 
Signed-off-by: Lin Huang 
---
 ofproto/ofproto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 122a06f30..21c6a1d82 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -800,7 +800,7 @@ ofproto_type_set_config(const char *datapath_type, const 
struct smap *cfg)
 datapath_type = ofproto_normalize_type(datapath_type);
 class = ofproto_class_find__(datapath_type);
 
-if (class->type_set_config) {
+if (class && class->type_set_config) {
 class->type_set_config(datapath_type, cfg);
 }
 }
-- 
2.39.3

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


[ovs-dev] [PATCH v1 0/1] ofproto: Fix NULL deref reported by Coverity.

2024-04-02 Thread miterv
From: miter 

ofproto: Fix NULL deref reported by Coverity.

Lin Huang (1):
  ofproto: Fix NULL deref reported by Coverity.

 ofproto/ofproto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.39.3

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


[ovs-dev] [PATCH v1 1/1] ofproto: Fix NULL deref reported by Coverity.

2024-04-02 Thread miterv
From: miter 

Ofproto_class_find__() may return NULL, and dereference it to cause
segfault.

Tested-by: Zhang YuHuang 
Signed-off-by: Lin Huang 
---
 ofproto/ofproto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 122a06f30..21c6a1d82 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -800,7 +800,7 @@ ofproto_type_set_config(const char *datapath_type, const 
struct smap *cfg)
 datapath_type = ofproto_normalize_type(datapath_type);
 class = ofproto_class_find__(datapath_type);
 
-if (class->type_set_config) {
+if (class && class->type_set_config) {
 class->type_set_config(datapath_type, cfg);
 }
 }
-- 
2.39.3

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


[ovs-dev] [PATCH v10 4/4] netdev-dpdk: Add support for ingress packet-per-second policing.

2023-08-26 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath dosen't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace ingress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maxiumim tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch reuse 'ingress_policing_kpkts_rate' and
'ingress_policing_kpkts_burst' options at interface table. Now userspace
ingress policer supports setting packet-per-second limits in addition to
the previously configurable byte rate settings.

Examples:
$ ovs-vsctl set interface dpdk0 ingress_policing_rate=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_burst=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123

Add some unit tests for ingress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  21 ++
 NEWS  |   2 +
 lib/netdev-dpdk.c |  91 +++-
 tests/system-dpdk.at  | 337 ++
 4 files changed, 443 insertions(+), 8 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index 37f482cc5..3c5d14e4c 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -120,6 +120,9 @@ Refer to ``vswitch.xml`` for more details on egress policer.
 Rate Limiting (Ingress Policing)
 
 
+Bytes Per Second Policer
+
+
 Assuming you have a :doc:`vhost-user port ` receiving traffic
 consisting of packets of size 64 bytes, the following command would limit the
 reception rate of the port to ~1,000,000 packets per second::
@@ -135,6 +138,24 @@ To clear the ingress policer configuration from the port::
 
 $ ovs-vsctl set interface vhost-user0 ingress_policing_rate=0
 
+Packets Per Second Policer
+~~
+
+Assuming you have a :doc:`vhost-user port ` receiving traffic,
+the following command would limit the reception rate of the port to ~1,000,000
+packets per second::
+
+$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=1000 \
+ingress_policing_kpkts_burst=1000`
+
+To examine the ingress policer configuration of the port::
+
+$ ovs-vsctl list interface vhost-user0
+
+To clear the ingress policer configuration from the port::
+
+$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=0
+
 Refer to ``vswitch.xml`` for more details on ingress policer.
 
 Flow Control
diff --git a/NEWS b/NEWS
index 430c3daaf..39195768a 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,8 @@ v3.2.0 - 17 Aug 2023
max sleep configuration of PMD thread cores.
  * Removed experimental tag from PMD load based sleeping.
  * Added new Qos type 'pkts-policer' to support kilo packet-per-second 
policing.
+ * Added support for ingress kilo packet-per-second policing configured by
+   ingress_policing_kpkts_rate/burst options.
- Linux TC offload:
  * Add support for offloading VXLAN tunnels with the GBP extensions.
- Python
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index c6a26dc7e..06bac720a 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -406,10 +406,17 @@ struct dpdk_tx_queue {
 );
 };
 
+enum policer_type {
+POLICER_BPS   = 1 << 0,   /* Rate value in bytes/sec. */
+POLICER_PKTPS = 1 << 1,   /* Rate value in packet/sec. */
+};
+
 struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
 struct rte_meter_srtcm_profile in_prof;
+struct token_bucket tb;
+enum policer_type type;
 rte_spinlock_t policer_lock;
 };
 
@@ -516,6 +523,9 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 
@@ -615,6 +625,14 @@ is_dpdk_class(const struct netdev_class *class)
|| class->destruct == netdev_dpdk_vhost_destruct;
 }
 
+static int
+kpkts_policer_run_single_packet(struct token_bucket *tb, struct rte_mbuf 
**pkts,
+int pkt_cnt, bool should_steal);
+
+static int
+kpkts_policer_profile_config(struct token_bucket *tb,
+ uint32_t kpkts_rate, uint32_t kpkts_burst);
+
 /* DPDK NIC drivers allocate RX buffers at a particular granularity, typically
  * aligned at 1k or less. If a declared mbuf size is not a multiple of this
  * value, insufficient buffers are allocated to accomodate the packet in its
@@ -1462,6 +1480,8 @@ 

[ovs-dev] [PATCH v10 1/4] token-bucket: Make token-bucket timestamp updated by caller.

2023-08-26 Thread miterv
From: Lin Huang 

Now, token-bucket 'last_fill' is updated by token_bucket_withdraw() itself.
Add a new function parameter 'now' to update timestamp by caller.

Signed-off-by: Lin Huang 
---
 include/openvswitch/token-bucket.h |  3 ++-
 lib/token-bucket.c |  4 ++--
 lib/vlog.c | 17 ++---
 ofproto/pinsched.c |  2 +-
 4 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/include/openvswitch/token-bucket.h 
b/include/openvswitch/token-bucket.h
index 580747f61..d1191e956 100644
--- a/include/openvswitch/token-bucket.h
+++ b/include/openvswitch/token-bucket.h
@@ -40,7 +40,8 @@ void token_bucket_init(struct token_bucket *,
unsigned int rate, unsigned int burst);
 void token_bucket_set(struct token_bucket *,
unsigned int rate, unsigned int burst);
-bool token_bucket_withdraw(struct token_bucket *, unsigned int n);
+bool token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+   long long int now);
 void token_bucket_wait_at(struct token_bucket *, unsigned int n,
   const char *where);
 #define token_bucket_wait(bucket, n)\
diff --git a/lib/token-bucket.c b/lib/token-bucket.c
index 0badeb46b..60eb26e53 100644
--- a/lib/token-bucket.c
+++ b/lib/token-bucket.c
@@ -59,10 +59,10 @@ token_bucket_set(struct token_bucket *tb,
  * if 'tb' contained fewer than 'n' tokens (and thus 'n' tokens could not be
  * removed) . */
 bool
-token_bucket_withdraw(struct token_bucket *tb, unsigned int n)
+token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+  long long int now)
 {
 if (tb->tokens < n) {
-long long int now = time_msec();
 if (now > tb->last_fill) {
 unsigned long long int elapsed_ull
 = (unsigned long long int) now - tb->last_fill;
diff --git a/lib/vlog.c b/lib/vlog.c
index b2653142f..7a46f6eb7 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -1312,6 +1312,9 @@ bool
 vlog_should_drop(const struct vlog_module *module, enum vlog_level level,
  struct vlog_rate_limit *rl)
 {
+long long int now;
+time_t now_sec;
+
 if (!module->honor_rate_limits) {
 return false;
 }
@@ -1321,12 +1324,13 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 }
 
 ovs_mutex_lock(>mutex);
-if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS)) {
-time_t now = time_now();
+now = time_msec();
+now_sec = now / 1000;
+if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS, now)) {
 if (!rl->n_dropped) {
-rl->first_dropped = now;
+rl->first_dropped = now_sec;
 }
-rl->last_dropped = now;
+rl->last_dropped = now_sec;
 rl->n_dropped++;
 ovs_mutex_unlock(>mutex);
 return true;
@@ -1335,10 +1339,9 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 if (!rl->n_dropped) {
 ovs_mutex_unlock(>mutex);
 } else {
-time_t now = time_now();
 unsigned int n_dropped = rl->n_dropped;
-unsigned int first_dropped_elapsed = now - rl->first_dropped;
-unsigned int last_dropped_elapsed = now - rl->last_dropped;
+unsigned int first_dropped_elapsed = now_sec - rl->first_dropped;
+unsigned int last_dropped_elapsed = now_sec - rl->last_dropped;
 rl->n_dropped = 0;
 ovs_mutex_unlock(>mutex);
 
diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c
index 59561f076..a39e4d2ee 100644
--- a/ofproto/pinsched.c
+++ b/ofproto/pinsched.c
@@ -184,7 +184,7 @@ get_tx_packet(struct pinsched *ps)
 static bool
 get_token(struct pinsched *ps)
 {
-return token_bucket_withdraw(>token_bucket, 1000);
+return token_bucket_withdraw(>token_bucket, 1000, time_msec());
 }
 
 void
-- 
2.39.3

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


[ovs-dev] [PATCH v10 3/4] netdev-dpdk: Add support for egress packet-per-second policing.

2023-08-26 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath doesn't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace egress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maximum tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch add a new egress Qos type called 'kpkts-policer'.
the policer police the kilo-packet per second at which the token bucket
be updated by 'kpkts_rate'. and the policer's burst size is defined by
'kpkts_burst'.

Examples:
$ovs-vsctl set port vhost-user0 qos=@newqos --
   --id=@newqos create qos type=kpkts-policer \
   other-config:kpkts_rate=123 other-config:kpkts_burst=123

Add some unit tests for egress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  21 +++
 NEWS  |   1 +
 lib/netdev-dpdk.c | 159 +++
 tests/system-dpdk.at  | 255 ++
 vswitchd/vswitch.xml  |  32 
 5 files changed, 468 insertions(+)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index a98ec672f..37f482cc5 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -36,6 +36,9 @@ QoS (Egress Policing)
 Single Queue Policer
 
 
+Bytes Per Second Policer
+
+
 Assuming you have a :doc:`vhost-user port ` transmitting traffic
 consisting of packets of size 64 bytes, the following command would limit the
 egress transmission rate of the port to ~1,000,000 packets per second::
@@ -52,6 +55,24 @@ To clear the QoS configuration from the port and ovsdb, run::
 
 $ ovs-vsctl destroy QoS vhost-user0 -- clear Port vhost-user0 qos
 
+Packets Per Second Policer
+++
+
+Assuming you have a :doc:`vhost-user port ` transmitting traffic,
+the following command would limit the egress transmission rate of the port to
+~1,000,000 packets per second::
+
+   ovs-vsctl set port vhost-user0 qos=@newqos -- \
+  --id=@newqos create qos type=kpkts-policer \
+  other-config:kpkts_rate=1000 other-config:kpkts_burst=1000
+
+To examine the QoS configuration of the port, run::
+
+$ ovs-appctl -t ovs-vswitchd qos/show vhost-user0
+
+To clear the QoS configuration from the port and ovsdb, run::
+
+$ ovs-vsctl destroy QoS vhost-user0 -- clear Port vhost-user0 qos
 
 Multi Queue Policer
 ~~~
diff --git a/NEWS b/NEWS
index b582bdbbc..430c3daaf 100644
--- a/NEWS
+++ b/NEWS
@@ -63,6 +63,7 @@ v3.2.0 - 17 Aug 2023
  * 'ovs-appctl dpif-netdev/pmd-sleep-show' command was added to get the
max sleep configuration of PMD thread cores.
  * Removed experimental tag from PMD load based sleeping.
+ * Added new Qos type 'pkts-policer' to support kilo packet-per-second 
policing.
- Linux TC offload:
  * Add support for offloading VXLAN tunnels with the GBP extensions.
- Python
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index bc8204f7e..c6a26dc7e 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -91,6 +93,8 @@ static bool per_port_memory = false; /* Status of per port 
memory support */
 #define OVS_CACHE_LINE_SIZE CACHE_LINE_SIZE
 #define OVS_VPORT_DPDK "ovs_dpdk"
 
+#define MAX_KPKTS_PARAMETER 4294967U  /* UINT32_MAX / 1000 */
+
 /*
  * need to reserve tons of extra space in the mbufs so we can align the
  * DMA addresses to 4KB.
@@ -346,6 +350,7 @@ struct dpdk_qos_ops {
 /* dpdk_qos_ops for each type of user space QoS implementation. */
 static const struct dpdk_qos_ops egress_policer_ops;
 static const struct dpdk_qos_ops trtcm_policer_ops;
+static const struct dpdk_qos_ops kpkts_policer_ops;
 
 /*
  * Array of dpdk_qos_ops, contains pointer to all supported QoS
@@ -354,6 +359,7 @@ static const struct dpdk_qos_ops trtcm_policer_ops;
 static const struct dpdk_qos_ops *const qos_confs[] = {
 _policer_ops,
 _policer_ops,
+_policer_ops,
 NULL
 };
 
@@ -5571,6 +5577,159 @@ static const struct dpdk_qos_ops trtcm_policer_ops = {
 .qos_queue_dump_state_init = trtcm_policer_qos_queue_dump_state_init
 };
 
+/* kpkts-policer details */
+struct kpkts_policer {
+struct qos_conf qos_conf;
+struct token_bucket tb;
+uint32_t kpkts_rate;
+uint32_t kpkts_burst;
+};
+
+static int

[ovs-dev] [PATCH v10 2/4] netdev-dpdk: Make srtcm_policer to free pkts by bulk.

2023-08-26 Thread miterv
From: Lin Huang 

Currently srtcm_policer free packet one by one, if packets are exceed rate 
limit.
That is a inefficient way to free memory which we have to call 
rte_pktmbuf_free()
pkt_cnt times.

To improve this, we can use rte_pktmbuf_free_bulk() function to free arrays of
mbufs instead of freeing packets one by one.

So, This patch change srtcm_policer to free pkts by bulk using 
rte_pktmbuf_free_bulk().
It gives us a slightly performance improves.

Signed-off-by: Lin Huang 
---
 lib/netdev-dpdk.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8f1361e21..bc8204f7e 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2542,13 +2542,13 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 struct rte_mbuf **pkts, int pkt_cnt,
 bool should_steal)
 {
-int i = 0;
-int cnt = 0;
-struct rte_mbuf *pkt = NULL;
+struct rte_mbuf *should_steal_batch[NETDEV_MAX_BURST];
 uint64_t current_time = rte_rdtsc();
+int i = 0, n = 0;
+int cnt = 0;
 
 for (i = 0; i < pkt_cnt; i++) {
-pkt = pkts[i];
+struct rte_mbuf *pkt = pkts[i];
 /* Handle current packet */
 if (netdev_dpdk_srtcm_policer_pkt_handle(meter, profile,
  pkt, current_time)) {
@@ -2556,13 +2556,15 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 pkts[cnt] = pkt;
 }
 cnt++;
-} else {
-if (should_steal) {
-rte_pktmbuf_free(pkt);
-}
+} else if (should_steal) {
+should_steal_batch[n++] = pkt;
 }
 }
 
+if (n) {
+rte_pktmbuf_free_bulk(should_steal_batch, n);
+}
+
 return cnt;
 }
 
-- 
2.39.3

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


[ovs-dev] [PATCH v10 0/4] netdev-dpdk: Add support for userspace port-based packet-per-second policing.

2023-08-26 Thread miterv
From: Lin Huang 

v9->v10: fix code by reviewing.

v8->v9: fix qos.rst:40:Title underline too short.

v7->v8: fix cody by reviewing.

v6->v7: split pps and bps policer.

v5->v6: fix code by reviewing.

v5->v4: police pkts bps and pps at the same time.
Get the maximum from the number of dropped packets, and drop that.

v4->v3: rewrite egress_policer_details_to_param func.
add a new pkts_policer_profile_config func.

v2->v3: police and free pkts by bulk.
fix the appropriate error code.

Lin Huang (4):
  token-bucket: Make token-bucket timestamp updated by caller.
  netdev-dpdk: Make srtcm_policer to free pkts by bulk.
  netdev-dpdk: Add support for egress packet-per-second policing.
  netdev-dpdk: Add support for ingress packet-per-second policing.

 Documentation/topics/dpdk/qos.rst  |  42 ++
 NEWS   |   3 +
 include/openvswitch/token-bucket.h |   3 +-
 lib/netdev-dpdk.c  | 268 -
 lib/token-bucket.c |   4 +-
 lib/vlog.c |  17 +-
 ofproto/pinsched.c |   2 +-
 tests/system-dpdk.at   | 592 +
 vswitchd/vswitch.xml   |  32 ++
 9 files changed, 936 insertions(+), 27 deletions(-)

-- 
2.39.3

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


[ovs-dev] [PATCH v9 3/4] netdev-dpdk: Add support for egress packet-per-second policing.

2023-08-08 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath doesn't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace egress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maximum tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch add a new egress Qos type called 'kpkts-policer'.
the policer police the kilo-packet per second at which the token bucket
be updated by 'kpkts_rate'. and the policer's burst size is defined by
'kpkts_burst'.

Examples:
$ovs-vsctl set port vhost-user0 qos=@newqos --
   --id=@newqos create qos type=kpkts-policer \
   other-config:kpkts_rate=123 other-config:kpkts_burst=123

Add some unit tests for egress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  21 +++
 NEWS  |   1 +
 lib/netdev-dpdk.c | 160 +++
 tests/system-dpdk.at  | 255 ++
 vswitchd/vswitch.xml  |  32 
 5 files changed, 469 insertions(+)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index a98ec672f..37f482cc5 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -36,6 +36,9 @@ QoS (Egress Policing)
 Single Queue Policer
 
 
+Bytes Per Second Policer
+
+
 Assuming you have a :doc:`vhost-user port ` transmitting traffic
 consisting of packets of size 64 bytes, the following command would limit the
 egress transmission rate of the port to ~1,000,000 packets per second::
@@ -52,6 +55,24 @@ To clear the QoS configuration from the port and ovsdb, run::
 
 $ ovs-vsctl destroy QoS vhost-user0 -- clear Port vhost-user0 qos
 
+Packets Per Second Policer
+++
+
+Assuming you have a :doc:`vhost-user port ` transmitting traffic,
+the following command would limit the egress transmission rate of the port to
+~1,000,000 packets per second::
+
+   ovs-vsctl set port vhost-user0 qos=@newqos -- \
+  --id=@newqos create qos type=kpkts-policer \
+  other-config:kpkts_rate=1000 other-config:kpkts_burst=1000
+
+To examine the QoS configuration of the port, run::
+
+$ ovs-appctl -t ovs-vswitchd qos/show vhost-user0
+
+To clear the QoS configuration from the port and ovsdb, run::
+
+$ ovs-vsctl destroy QoS vhost-user0 -- clear Port vhost-user0 qos
 
 Multi Queue Policer
 ~~~
diff --git a/NEWS b/NEWS
index 7a852427e..3d1ab282e 100644
--- a/NEWS
+++ b/NEWS
@@ -63,6 +63,7 @@ v3.2.0 - xx xxx 
  * 'ovs-appctl dpif-netdev/pmd-sleep-show' command was added to get the
max sleep configuration of PMD thread cores.
  * Removed experimental tag from PMD load based sleeping.
+ * Added new Qos type 'pkts-policer' to support kilo packet-per-second 
policing.
- Linux TC offload:
  * Add support for offloading VXLAN tunnels with the GBP extensions.
- Python
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 7e3020a7d..e2a84c987 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -91,6 +93,8 @@ static bool per_port_memory = false; /* Status of per port 
memory support */
 #define OVS_CACHE_LINE_SIZE CACHE_LINE_SIZE
 #define OVS_VPORT_DPDK "ovs_dpdk"
 
+#define MAX_KPKTS_PARAMETER 4294967U  /* UINT32_MAX / 1000 */
+
 /*
  * need to reserve tons of extra space in the mbufs so we can align the
  * DMA addresses to 4KB.
@@ -346,6 +350,7 @@ struct dpdk_qos_ops {
 /* dpdk_qos_ops for each type of user space QoS implementation. */
 static const struct dpdk_qos_ops egress_policer_ops;
 static const struct dpdk_qos_ops trtcm_policer_ops;
+static const struct dpdk_qos_ops kpkts_policer_ops;
 
 /*
  * Array of dpdk_qos_ops, contains pointer to all supported QoS
@@ -354,6 +359,7 @@ static const struct dpdk_qos_ops trtcm_policer_ops;
 static const struct dpdk_qos_ops *const qos_confs[] = {
 _policer_ops,
 _policer_ops,
+_policer_ops,
 NULL
 };
 
@@ -5572,6 +5578,160 @@ static const struct dpdk_qos_ops trtcm_policer_ops = {
 .qos_queue_dump_state_init = trtcm_policer_qos_queue_dump_state_init
 };
 
+/* kpkts-policer details */
+struct kpkts_policer {
+struct qos_conf qos_conf;
+struct token_bucket tb;
+uint32_t kpkts_rate;
+uint32_t kpkts_burst;
+};
+
+static int

[ovs-dev] [PATCH v9 1/4] token-bucket: Make token-bucket timestamp updated by caller.

2023-08-08 Thread miterv
From: Lin Huang 

Now, token-bucket 'last_fill' is updated by token_bucket_withdraw() itself.
Add a new function parameter 'now' to update timestamp by caller.

Signed-off-by: Lin Huang 
---
 include/openvswitch/token-bucket.h |  3 ++-
 lib/token-bucket.c |  4 ++--
 lib/vlog.c | 14 +++---
 ofproto/pinsched.c |  2 +-
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/include/openvswitch/token-bucket.h 
b/include/openvswitch/token-bucket.h
index 580747f61..d1191e956 100644
--- a/include/openvswitch/token-bucket.h
+++ b/include/openvswitch/token-bucket.h
@@ -40,7 +40,8 @@ void token_bucket_init(struct token_bucket *,
unsigned int rate, unsigned int burst);
 void token_bucket_set(struct token_bucket *,
unsigned int rate, unsigned int burst);
-bool token_bucket_withdraw(struct token_bucket *, unsigned int n);
+bool token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+   long long int now);
 void token_bucket_wait_at(struct token_bucket *, unsigned int n,
   const char *where);
 #define token_bucket_wait(bucket, n)\
diff --git a/lib/token-bucket.c b/lib/token-bucket.c
index 0badeb46b..60eb26e53 100644
--- a/lib/token-bucket.c
+++ b/lib/token-bucket.c
@@ -59,10 +59,10 @@ token_bucket_set(struct token_bucket *tb,
  * if 'tb' contained fewer than 'n' tokens (and thus 'n' tokens could not be
  * removed) . */
 bool
-token_bucket_withdraw(struct token_bucket *tb, unsigned int n)
+token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+  long long int now)
 {
 if (tb->tokens < n) {
-long long int now = time_msec();
 if (now > tb->last_fill) {
 unsigned long long int elapsed_ull
 = (unsigned long long int) now - tb->last_fill;
diff --git a/lib/vlog.c b/lib/vlog.c
index b2653142f..a025f79e5 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -1321,12 +1321,13 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 }
 
 ovs_mutex_lock(>mutex);
-if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS)) {
-time_t now = time_now();
+long long int now = time_msec();
+time_t now_sec = now / 1000;
+if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS, now)) {
 if (!rl->n_dropped) {
-rl->first_dropped = now;
+rl->first_dropped = now_sec;
 }
-rl->last_dropped = now;
+rl->last_dropped = now_sec;
 rl->n_dropped++;
 ovs_mutex_unlock(>mutex);
 return true;
@@ -1335,10 +1336,9 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 if (!rl->n_dropped) {
 ovs_mutex_unlock(>mutex);
 } else {
-time_t now = time_now();
 unsigned int n_dropped = rl->n_dropped;
-unsigned int first_dropped_elapsed = now - rl->first_dropped;
-unsigned int last_dropped_elapsed = now - rl->last_dropped;
+unsigned int first_dropped_elapsed = now_sec - rl->first_dropped;
+unsigned int last_dropped_elapsed = now_sec - rl->last_dropped;
 rl->n_dropped = 0;
 ovs_mutex_unlock(>mutex);
 
diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c
index 59561f076..a39e4d2ee 100644
--- a/ofproto/pinsched.c
+++ b/ofproto/pinsched.c
@@ -184,7 +184,7 @@ get_tx_packet(struct pinsched *ps)
 static bool
 get_token(struct pinsched *ps)
 {
-return token_bucket_withdraw(>token_bucket, 1000);
+return token_bucket_withdraw(>token_bucket, 1000, time_msec());
 }
 
 void
-- 
2.39.3

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


[ovs-dev] [PATCH v9 4/4] netdev-dpdk: Add support for ingress packet-per-second policing.

2023-08-08 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath dosen't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace ingress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maxiumim tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch reuse 'ingress_policing_kpkts_rate' and
'ingress_policing_kpkts_burst' options at interface table. Now userspace
ingress policer supports setting packet-per-second limits in addition to
the previously configurable byte rate settings.

Examples:
$ ovs-vsctl set interface dpdk0 ingress_policing_rate=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_burst=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123

Add some unit tests for ingress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  21 ++
 NEWS  |   2 +
 lib/netdev-dpdk.c |  91 +++-
 tests/system-dpdk.at  | 337 ++
 4 files changed, 443 insertions(+), 8 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index 37f482cc5..3c5d14e4c 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -120,6 +120,9 @@ Refer to ``vswitch.xml`` for more details on egress policer.
 Rate Limiting (Ingress Policing)
 
 
+Bytes Per Second Policer
+
+
 Assuming you have a :doc:`vhost-user port ` receiving traffic
 consisting of packets of size 64 bytes, the following command would limit the
 reception rate of the port to ~1,000,000 packets per second::
@@ -135,6 +138,24 @@ To clear the ingress policer configuration from the port::
 
 $ ovs-vsctl set interface vhost-user0 ingress_policing_rate=0
 
+Packets Per Second Policer
+~~
+
+Assuming you have a :doc:`vhost-user port ` receiving traffic,
+the following command would limit the reception rate of the port to ~1,000,000
+packets per second::
+
+$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=1000 \
+ingress_policing_kpkts_burst=1000`
+
+To examine the ingress policer configuration of the port::
+
+$ ovs-vsctl list interface vhost-user0
+
+To clear the ingress policer configuration from the port::
+
+$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=0
+
 Refer to ``vswitch.xml`` for more details on ingress policer.
 
 Flow Control
diff --git a/NEWS b/NEWS
index 3d1ab282e..47330e644 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,8 @@ v3.2.0 - xx xxx 
max sleep configuration of PMD thread cores.
  * Removed experimental tag from PMD load based sleeping.
  * Added new Qos type 'pkts-policer' to support kilo packet-per-second 
policing.
+ * Added support for ingress kilo packet-per-second policing configured by
+   ingress_policing_kpkts_rate/burst options.
- Linux TC offload:
  * Add support for offloading VXLAN tunnels with the GBP extensions.
- Python
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e2a84c987..f36feedf8 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -406,10 +406,17 @@ struct dpdk_tx_queue {
 );
 };
 
+enum policer_type {
+POLICER_BPS   = 1 << 0,   /* Rate value in bytes/sec. */
+POLICER_PKTPS = 1 << 1,   /* Rate value in packet/sec. */
+};
+
 struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
 struct rte_meter_srtcm_profile in_prof;
+struct token_bucket tb;
+enum policer_type type;
 rte_spinlock_t policer_lock;
 };
 
@@ -516,6 +523,9 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 
@@ -615,6 +625,14 @@ is_dpdk_class(const struct netdev_class *class)
|| class->destruct == netdev_dpdk_vhost_destruct;
 }
 
+static int
+kpkts_policer_run_single_packet(struct token_bucket *tb, struct rte_mbuf 
**pkts,
+int pkt_cnt, bool should_steal);
+
+static int
+kpkts_policer_profile_config(struct token_bucket *tb,
+ uint32_t kpkts_rate, uint32_t kpkts_burst);
+
 /* DPDK NIC drivers allocate RX buffers at a particular granularity, typically
  * aligned at 1k or less. If a declared mbuf size is not a multiple of this
  * value, insufficient buffers are allocated to accomodate the packet in its
@@ -1462,6 +1480,8 @@ 

[ovs-dev] [PATCH v9 0/4] netdev-dpdk: Add support for userspace port-based packet-per-second policing.

2023-08-08 Thread miterv
From: Lin Huang 

v8->v9: fix qos.rst:40:Title underline too short.

v7->v8: fix cody by reviewing.

v6->v7: split pps and bps policer.

v5->v6: fix code by reviewing.

v5->v4: police pkts bps and pps at the same time.
Get the maximum from the number of dropped packets, and drop that.

v4->v3: rewrite egress_policer_details_to_param func.
add a new pkts_policer_profile_config func.

v2->v3: police and free pkts by bulk.
fix the appropriate error code.


Lin Huang (4):
  token-bucket: Make token-bucket timestamp updated by caller.
  netdev-dpdk: Make srtcm_policer to free pkts by bulk.
  netdev-dpdk: Add support for egress packet-per-second policing.
  netdev-dpdk: Add support for ingress packet-per-second policing.

 Documentation/topics/dpdk/qos.rst  |  42 ++
 NEWS   |   3 +
 include/openvswitch/token-bucket.h |   3 +-
 lib/netdev-dpdk.c  | 262 -
 lib/token-bucket.c |   4 +-
 lib/vlog.c |  14 +-
 ofproto/pinsched.c |   2 +-
 tests/system-dpdk.at   | 592 +
 vswitchd/vswitch.xml   |  32 ++
 9 files changed, 931 insertions(+), 23 deletions(-)

-- 
2.39.3

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


[ovs-dev] [PATCH v9 2/4] netdev-dpdk: Make srtcm_policer to free pkts by bulk.

2023-08-08 Thread miterv
From: Lin Huang 

Currently srtcm_policer free packet one by one, if packets are exceed rate 
limit.
This patch change srtcm_policer to free pkts by bulk using 
rte_pktmbuf_free_bulk().

Signed-off-by: Lin Huang 
---
 lib/netdev-dpdk.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8f1361e21..7e3020a7d 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2542,10 +2542,11 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 struct rte_mbuf **pkts, int pkt_cnt,
 bool should_steal)
 {
-int i = 0;
 int cnt = 0;
+int i = 0, n = 0;
 struct rte_mbuf *pkt = NULL;
 uint64_t current_time = rte_rdtsc();
+struct rte_mbuf *batch[NETDEV_MAX_BURST] = {0};
 
 for (i = 0; i < pkt_cnt; i++) {
 pkt = pkts[i];
@@ -2557,12 +2558,14 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 }
 cnt++;
 } else {
-if (should_steal) {
-rte_pktmbuf_free(pkt);
-}
+batch[n++] = pkt;
 }
 }
 
+if (should_steal && n) {
+rte_pktmbuf_free_bulk(batch, n);
+}
+
 return cnt;
 }
 
-- 
2.39.3

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


[ovs-dev] [PATCH v8 4/4] netdev-dpdk: Add support for ingress packet-per-second policing.

2023-08-04 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath dosen't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace ingress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maxiumim tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch reuse 'ingress_policing_kpkts_rate' and
'ingress_policing_kpkts_burst' options at interface table. Now userspace
ingress policer supports setting packet-per-second limits in addition to
the previously configurable byte rate settings.

Examples:
$ ovs-vsctl set interface dpdk0 ingress_policing_rate=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_burst=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123

Add some unit tests for ingress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  21 ++
 NEWS  |   2 +
 lib/netdev-dpdk.c |  91 +++-
 tests/system-dpdk.at  | 337 ++
 4 files changed, 443 insertions(+), 8 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index 6a4408127..db66dcecf 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -120,6 +120,9 @@ Refer to ``vswitch.xml`` for more details on egress policer.
 Rate Limiting (Ingress Policing)
 
 
+Bytes Per Second Policer
+
+
 Assuming you have a :doc:`vhost-user port ` receiving traffic
 consisting of packets of size 64 bytes, the following command would limit the
 reception rate of the port to ~1,000,000 packets per second::
@@ -135,6 +138,24 @@ To clear the ingress policer configuration from the port::
 
 $ ovs-vsctl set interface vhost-user0 ingress_policing_rate=0
 
+Packets Per Second Policer
+
+
+Assuming you have a :doc:`vhost-user port ` receiving traffic,
+the following command would limit the reception rate of the port to ~1,000,000
+packets per second::
+
+$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=1000 \
+ingress_policing_kpkts_burst=1000`
+
+To examine the ingress policer configuration of the port::
+
+$ ovs-vsctl list interface vhost-user0
+
+To clear the ingress policer configuration from the port::
+
+$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=0
+
 Refer to ``vswitch.xml`` for more details on ingress policer.
 
 Flow Control
diff --git a/NEWS b/NEWS
index 3d1ab282e..47330e644 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,8 @@ v3.2.0 - xx xxx 
max sleep configuration of PMD thread cores.
  * Removed experimental tag from PMD load based sleeping.
  * Added new Qos type 'pkts-policer' to support kilo packet-per-second 
policing.
+ * Added support for ingress kilo packet-per-second policing configured by
+   ingress_policing_kpkts_rate/burst options.
- Linux TC offload:
  * Add support for offloading VXLAN tunnels with the GBP extensions.
- Python
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e2a84c987..f36feedf8 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -406,10 +406,17 @@ struct dpdk_tx_queue {
 );
 };
 
+enum policer_type {
+POLICER_BPS   = 1 << 0,   /* Rate value in bytes/sec. */
+POLICER_PKTPS = 1 << 1,   /* Rate value in packet/sec. */
+};
+
 struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
 struct rte_meter_srtcm_profile in_prof;
+struct token_bucket tb;
+enum policer_type type;
 rte_spinlock_t policer_lock;
 };
 
@@ -516,6 +523,9 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 
@@ -615,6 +625,14 @@ is_dpdk_class(const struct netdev_class *class)
|| class->destruct == netdev_dpdk_vhost_destruct;
 }
 
+static int
+kpkts_policer_run_single_packet(struct token_bucket *tb, struct rte_mbuf 
**pkts,
+int pkt_cnt, bool should_steal);
+
+static int
+kpkts_policer_profile_config(struct token_bucket *tb,
+ uint32_t kpkts_rate, uint32_t kpkts_burst);
+
 /* DPDK NIC drivers allocate RX buffers at a particular granularity, typically
  * aligned at 1k or less. If a declared mbuf size is not a multiple of this
  * value, insufficient buffers are allocated to accomodate the packet in its
@@ -1462,6 +1480,8 @@ common_construct(struct 

[ovs-dev] [PATCH v8 3/4] netdev-dpdk: Add support for egress packet-per-second policing.

2023-08-04 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath doesn't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace egress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maximum tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch add a new egress Qos type called 'kpkts-policer'.
the policer police the kilo-packet per second at which the token bucket
be updated by 'kpkts_rate'. and the policer's burst size is defined by
'kpkts_burst'.

Examples:
$ovs-vsctl set port vhost-user0 qos=@newqos --
   --id=@newqos create qos type=kpkts-policer \
   other-config:kpkts_rate=123 other-config:kpkts_burst=123

Add some unit tests for egress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  21 +++
 NEWS  |   1 +
 lib/netdev-dpdk.c | 160 +++
 tests/system-dpdk.at  | 255 ++
 vswitchd/vswitch.xml  |  32 
 5 files changed, 469 insertions(+)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index a98ec672f..6a4408127 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -36,6 +36,9 @@ QoS (Egress Policing)
 Single Queue Policer
 
 
+Bytes Per Second Policer

+
 Assuming you have a :doc:`vhost-user port ` transmitting traffic
 consisting of packets of size 64 bytes, the following command would limit the
 egress transmission rate of the port to ~1,000,000 packets per second::
@@ -52,6 +55,24 @@ To clear the QoS configuration from the port and ovsdb, run::
 
 $ ovs-vsctl destroy QoS vhost-user0 -- clear Port vhost-user0 qos
 
+Packets Per Second Policer

+
+Assuming you have a :doc:`vhost-user port ` transmitting traffic,
+the following command would limit the egress transmission rate of the port to
+~1,000,000 packets per second::
+
+   ovs-vsctl set port vhost-user0 qos=@newqos -- \
+  --id=@newqos create qos type=kpkts-policer \
+  other-config:kpkts_rate=1000 other-config:kpkts_burst=1000
+
+To examine the QoS configuration of the port, run::
+
+$ ovs-appctl -t ovs-vswitchd qos/show vhost-user0
+
+To clear the QoS configuration from the port and ovsdb, run::
+
+$ ovs-vsctl destroy QoS vhost-user0 -- clear Port vhost-user0 qos
 
 Multi Queue Policer
 ~~~
diff --git a/NEWS b/NEWS
index 7a852427e..3d1ab282e 100644
--- a/NEWS
+++ b/NEWS
@@ -63,6 +63,7 @@ v3.2.0 - xx xxx 
  * 'ovs-appctl dpif-netdev/pmd-sleep-show' command was added to get the
max sleep configuration of PMD thread cores.
  * Removed experimental tag from PMD load based sleeping.
+ * Added new Qos type 'pkts-policer' to support kilo packet-per-second 
policing.
- Linux TC offload:
  * Add support for offloading VXLAN tunnels with the GBP extensions.
- Python
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 7e3020a7d..e2a84c987 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -91,6 +93,8 @@ static bool per_port_memory = false; /* Status of per port 
memory support */
 #define OVS_CACHE_LINE_SIZE CACHE_LINE_SIZE
 #define OVS_VPORT_DPDK "ovs_dpdk"
 
+#define MAX_KPKTS_PARAMETER 4294967U  /* UINT32_MAX / 1000 */
+
 /*
  * need to reserve tons of extra space in the mbufs so we can align the
  * DMA addresses to 4KB.
@@ -346,6 +350,7 @@ struct dpdk_qos_ops {
 /* dpdk_qos_ops for each type of user space QoS implementation. */
 static const struct dpdk_qos_ops egress_policer_ops;
 static const struct dpdk_qos_ops trtcm_policer_ops;
+static const struct dpdk_qos_ops kpkts_policer_ops;
 
 /*
  * Array of dpdk_qos_ops, contains pointer to all supported QoS
@@ -354,6 +359,7 @@ static const struct dpdk_qos_ops trtcm_policer_ops;
 static const struct dpdk_qos_ops *const qos_confs[] = {
 _policer_ops,
 _policer_ops,
+_policer_ops,
 NULL
 };
 
@@ -5572,6 +5578,160 @@ static const struct dpdk_qos_ops trtcm_policer_ops = {
 .qos_queue_dump_state_init = trtcm_policer_qos_queue_dump_state_init
 };
 
+/* kpkts-policer details */
+struct kpkts_policer {
+struct qos_conf qos_conf;
+struct token_bucket tb;
+uint32_t kpkts_rate;
+uint32_t kpkts_burst;
+};
+
+static int
+kpkts_policer_run_single_packet(struct 

[ovs-dev] [PATCH v8 2/4] netdev-dpdk: Make srtcm_policer to free pkts by bulk.

2023-08-04 Thread miterv
From: Lin Huang 

Currently srtcm_policer free packet one by one, if packets are exceed rate 
limit.
This patch change srtcm_policer to free pkts by bulk using 
rte_pktmbuf_free_bulk().

Signed-off-by: Lin Huang 
---
 lib/netdev-dpdk.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8f1361e21..7e3020a7d 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2542,10 +2542,11 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 struct rte_mbuf **pkts, int pkt_cnt,
 bool should_steal)
 {
-int i = 0;
 int cnt = 0;
+int i = 0, n = 0;
 struct rte_mbuf *pkt = NULL;
 uint64_t current_time = rte_rdtsc();
+struct rte_mbuf *batch[NETDEV_MAX_BURST] = {0};
 
 for (i = 0; i < pkt_cnt; i++) {
 pkt = pkts[i];
@@ -2557,12 +2558,14 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 }
 cnt++;
 } else {
-if (should_steal) {
-rte_pktmbuf_free(pkt);
-}
+batch[n++] = pkt;
 }
 }
 
+if (should_steal && n) {
+rte_pktmbuf_free_bulk(batch, n);
+}
+
 return cnt;
 }
 
-- 
2.39.3

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


[ovs-dev] [PATCH v8 1/4] token-bucket: Make token-bucket timestamp updated by caller.

2023-08-04 Thread miterv
From: Lin Huang 

Now, token-bucket 'last_fill' is updated by token_bucket_withdraw() itself.
Add a new function parameter 'now' to update timestamp by caller.

Signed-off-by: Lin Huang 
---
 include/openvswitch/token-bucket.h |  3 ++-
 lib/token-bucket.c |  4 ++--
 lib/vlog.c | 14 +++---
 ofproto/pinsched.c |  2 +-
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/include/openvswitch/token-bucket.h 
b/include/openvswitch/token-bucket.h
index 580747f61..d1191e956 100644
--- a/include/openvswitch/token-bucket.h
+++ b/include/openvswitch/token-bucket.h
@@ -40,7 +40,8 @@ void token_bucket_init(struct token_bucket *,
unsigned int rate, unsigned int burst);
 void token_bucket_set(struct token_bucket *,
unsigned int rate, unsigned int burst);
-bool token_bucket_withdraw(struct token_bucket *, unsigned int n);
+bool token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+   long long int now);
 void token_bucket_wait_at(struct token_bucket *, unsigned int n,
   const char *where);
 #define token_bucket_wait(bucket, n)\
diff --git a/lib/token-bucket.c b/lib/token-bucket.c
index 0badeb46b..60eb26e53 100644
--- a/lib/token-bucket.c
+++ b/lib/token-bucket.c
@@ -59,10 +59,10 @@ token_bucket_set(struct token_bucket *tb,
  * if 'tb' contained fewer than 'n' tokens (and thus 'n' tokens could not be
  * removed) . */
 bool
-token_bucket_withdraw(struct token_bucket *tb, unsigned int n)
+token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+  long long int now)
 {
 if (tb->tokens < n) {
-long long int now = time_msec();
 if (now > tb->last_fill) {
 unsigned long long int elapsed_ull
 = (unsigned long long int) now - tb->last_fill;
diff --git a/lib/vlog.c b/lib/vlog.c
index b2653142f..a025f79e5 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -1321,12 +1321,13 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 }
 
 ovs_mutex_lock(>mutex);
-if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS)) {
-time_t now = time_now();
+long long int now = time_msec();
+time_t now_sec = now / 1000;
+if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS, now)) {
 if (!rl->n_dropped) {
-rl->first_dropped = now;
+rl->first_dropped = now_sec;
 }
-rl->last_dropped = now;
+rl->last_dropped = now_sec;
 rl->n_dropped++;
 ovs_mutex_unlock(>mutex);
 return true;
@@ -1335,10 +1336,9 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 if (!rl->n_dropped) {
 ovs_mutex_unlock(>mutex);
 } else {
-time_t now = time_now();
 unsigned int n_dropped = rl->n_dropped;
-unsigned int first_dropped_elapsed = now - rl->first_dropped;
-unsigned int last_dropped_elapsed = now - rl->last_dropped;
+unsigned int first_dropped_elapsed = now_sec - rl->first_dropped;
+unsigned int last_dropped_elapsed = now_sec - rl->last_dropped;
 rl->n_dropped = 0;
 ovs_mutex_unlock(>mutex);
 
diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c
index 59561f076..a39e4d2ee 100644
--- a/ofproto/pinsched.c
+++ b/ofproto/pinsched.c
@@ -184,7 +184,7 @@ get_tx_packet(struct pinsched *ps)
 static bool
 get_token(struct pinsched *ps)
 {
-return token_bucket_withdraw(>token_bucket, 1000);
+return token_bucket_withdraw(>token_bucket, 1000, time_msec());
 }
 
 void
-- 
2.39.3

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


[ovs-dev] [PATCH v8 0/4] netdev-dpdk: Add support for userspace port-based packet-per-second policing.

2023-08-04 Thread miterv
From: Lin Huang 

v7->v8: fix cody by reviewing.

v6->v7: split pps and bps policer.

v5->v6: fix code by reviewing.

v5->v4: police pkts bps and pps at the same time.
Get the maximum from the number of dropped packets, and drop that.

v4->v3: rewrite egress_policer_details_to_param func.
add a new pkts_policer_profile_config func.

v2->v3: police and free pkts by bulk.
fix the appropriate error code.

v1->v2: delete duplicated code.

Lin Huang (4):
  token-bucket: Make token-bucket timestamp updated by caller.
  netdev-dpdk: Make srtcm_policer to free pkts by bulk.
  netdev-dpdk: Add support for egress packet-per-second policing.
  netdev-dpdk: Add support for ingress packet-per-second policing.

 Documentation/topics/dpdk/qos.rst  |  42 ++
 NEWS   |   3 +
 include/openvswitch/token-bucket.h |   3 +-
 lib/netdev-dpdk.c  | 262 -
 lib/token-bucket.c |   4 +-
 lib/vlog.c |  14 +-
 ofproto/pinsched.c |   2 +-
 tests/system-dpdk.at   | 592 +
 vswitchd/vswitch.xml   |  32 ++
 9 files changed, 931 insertions(+), 23 deletions(-)

-- 
2.39.3

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


[ovs-dev] [PATCH v7 4/4] netdev-dpdk: Add support for ingress packet-per-second policing.

2023-07-29 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath dosen't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace ingress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maxiumim tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch reuse 'ingress_policing_kpkts_rate' and
'ingress_policing_kpkts_burst' options at interface table. Now userspace
ingress policer supports setting packet-per-second limits in addition to
the previously configurable byte rate settings.

Examples:
$ ovs-vsctl set interface dpdk0 ingress_policing_rate=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_burst=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123

Add some unit tests for ingress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  21 ++
 NEWS  |   2 +
 lib/netdev-dpdk.c |  91 +++-
 tests/system-dpdk.at  | 339 ++
 4 files changed, 445 insertions(+), 8 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index 6a4408127..db66dcecf 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -120,6 +120,9 @@ Refer to ``vswitch.xml`` for more details on egress policer.
 Rate Limiting (Ingress Policing)
 
 
+Bytes Per Second Policer
+
+
 Assuming you have a :doc:`vhost-user port ` receiving traffic
 consisting of packets of size 64 bytes, the following command would limit the
 reception rate of the port to ~1,000,000 packets per second::
@@ -135,6 +138,24 @@ To clear the ingress policer configuration from the port::
 
 $ ovs-vsctl set interface vhost-user0 ingress_policing_rate=0
 
+Packets Per Second Policer
+
+
+Assuming you have a :doc:`vhost-user port ` receiving traffic,
+the following command would limit the reception rate of the port to ~1,000,000
+packets per second::
+
+$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=1000 \
+ingress_policing_kpkts_burst=1000`
+
+To examine the ingress policer configuration of the port::
+
+$ ovs-vsctl list interface vhost-user0
+
+To clear the ingress policer configuration from the port::
+
+$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=0
+
 Refer to ``vswitch.xml`` for more details on ingress policer.
 
 Flow Control
diff --git a/NEWS b/NEWS
index 3d1ab282e..47330e644 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,8 @@ v3.2.0 - xx xxx 
max sleep configuration of PMD thread cores.
  * Removed experimental tag from PMD load based sleeping.
  * Added new Qos type 'pkts-policer' to support kilo packet-per-second 
policing.
+ * Added support for ingress kilo packet-per-second policing configured by
+   ingress_policing_kpkts_rate/burst options.
- Linux TC offload:
  * Add support for offloading VXLAN tunnels with the GBP extensions.
- Python
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e6b8922aa..8c252022a 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -406,10 +406,17 @@ struct dpdk_tx_queue {
 );
 };
 
+enum policer_type {
+POLICER_BPS   = 1 << 0,   /* Rate value in bytes/sec. */
+POLICER_PKTPS = 1 << 1,   /* Rate value in packet/sec. */
+};
+
 struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
 struct rte_meter_srtcm_profile in_prof;
+struct token_bucket tb;
+enum policer_type type;
 rte_spinlock_t policer_lock;
 };
 
@@ -516,6 +523,9 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 
@@ -615,6 +625,14 @@ is_dpdk_class(const struct netdev_class *class)
|| class->destruct == netdev_dpdk_vhost_destruct;
 }
 
+static int
+kpkts_policer_run_single_packet(struct token_bucket *tb, struct rte_mbuf 
**pkts,
+int pkt_cnt, bool should_steal);
+
+static int
+kpkts_policer_profile_config(struct token_bucket *tb,
+ uint32_t kpkts_rate, uint32_t kpkts_burst);
+
 /* DPDK NIC drivers allocate RX buffers at a particular granularity, typically
  * aligned at 1k or less. If a declared mbuf size is not a multiple of this
  * value, insufficient buffers are allocated to accomodate the packet in its
@@ -1462,6 +1480,8 @@ common_construct(struct 

[ovs-dev] [PATCH v7 2/4] netdev-dpdk: Make srtcm_policer to free pkts by bulk.

2023-07-29 Thread miterv
From: Lin Huang 

Currently srtcm_policer free packet one by one, if packets are exceed rate 
limit.
This patch change srtcm_policer to free pkts by bulk using 
rte_pktmbuf_free_bulk().

Signed-off-by: Lin Huang 
---
 lib/netdev-dpdk.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8f1361e21..7e3020a7d 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2542,10 +2542,11 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 struct rte_mbuf **pkts, int pkt_cnt,
 bool should_steal)
 {
-int i = 0;
 int cnt = 0;
+int i = 0, n = 0;
 struct rte_mbuf *pkt = NULL;
 uint64_t current_time = rte_rdtsc();
+struct rte_mbuf *batch[NETDEV_MAX_BURST] = {0};
 
 for (i = 0; i < pkt_cnt; i++) {
 pkt = pkts[i];
@@ -2557,12 +2558,14 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 }
 cnt++;
 } else {
-if (should_steal) {
-rte_pktmbuf_free(pkt);
-}
+batch[n++] = pkt;
 }
 }
 
+if (should_steal && n) {
+rte_pktmbuf_free_bulk(batch, n);
+}
+
 return cnt;
 }
 
-- 
2.39.3

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


[ovs-dev] [PATCH v7 3/4] netdev-dpdk: Add support for egress packet-per-second policing.

2023-07-29 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath doesn't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace egress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maximum tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch add a new egress Qos type called 'kpkts-policer'.
the policer police the kilo-packet per second at which the token bucket
be updated by 'kpkts_rate'. and the policer's burst size is defined by
'kpkts_burst'.

Examples:
$ovs-vsctl set port vhost-user0 qos=@newqos --
   --id=@newqos create qos type=kpkts-policer \
   other-config:kpkts_rate=123 other-config:kpkts_burst=123

Add some unit tests for egress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  21 +++
 NEWS  |   1 +
 lib/netdev-dpdk.c | 159 +++
 tests/system-dpdk.at  | 255 ++
 vswitchd/vswitch.xml  |  32 
 5 files changed, 468 insertions(+)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index a98ec672f..6a4408127 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -36,6 +36,9 @@ QoS (Egress Policing)
 Single Queue Policer
 
 
+Bytes Per Second Policer

+
 Assuming you have a :doc:`vhost-user port ` transmitting traffic
 consisting of packets of size 64 bytes, the following command would limit the
 egress transmission rate of the port to ~1,000,000 packets per second::
@@ -52,6 +55,24 @@ To clear the QoS configuration from the port and ovsdb, run::
 
 $ ovs-vsctl destroy QoS vhost-user0 -- clear Port vhost-user0 qos
 
+Packets Per Second Policer

+
+Assuming you have a :doc:`vhost-user port ` transmitting traffic,
+the following command would limit the egress transmission rate of the port to
+~1,000,000 packets per second::
+
+   ovs-vsctl set port vhost-user0 qos=@newqos -- \
+  --id=@newqos create qos type=kpkts-policer \
+  other-config:kpkts_rate=1000 other-config:kpkts_burst=1000
+
+To examine the QoS configuration of the port, run::
+
+$ ovs-appctl -t ovs-vswitchd qos/show vhost-user0
+
+To clear the QoS configuration from the port and ovsdb, run::
+
+$ ovs-vsctl destroy QoS vhost-user0 -- clear Port vhost-user0 qos
 
 Multi Queue Policer
 ~~~
diff --git a/NEWS b/NEWS
index 7a852427e..3d1ab282e 100644
--- a/NEWS
+++ b/NEWS
@@ -63,6 +63,7 @@ v3.2.0 - xx xxx 
  * 'ovs-appctl dpif-netdev/pmd-sleep-show' command was added to get the
max sleep configuration of PMD thread cores.
  * Removed experimental tag from PMD load based sleeping.
+ * Added new Qos type 'pkts-policer' to support kilo packet-per-second 
policing.
- Linux TC offload:
  * Add support for offloading VXLAN tunnels with the GBP extensions.
- Python
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 7e3020a7d..e6b8922aa 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -91,6 +93,8 @@ static bool per_port_memory = false; /* Status of per port 
memory support */
 #define OVS_CACHE_LINE_SIZE CACHE_LINE_SIZE
 #define OVS_VPORT_DPDK "ovs_dpdk"
 
+#define MAX_KPKTS_PARAMETER 4294967U  /* UINT32_MAX / 1000 */
+
 /*
  * need to reserve tons of extra space in the mbufs so we can align the
  * DMA addresses to 4KB.
@@ -346,6 +350,7 @@ struct dpdk_qos_ops {
 /* dpdk_qos_ops for each type of user space QoS implementation. */
 static const struct dpdk_qos_ops egress_policer_ops;
 static const struct dpdk_qos_ops trtcm_policer_ops;
+static const struct dpdk_qos_ops kpkts_policer_ops;
 
 /*
  * Array of dpdk_qos_ops, contains pointer to all supported QoS
@@ -354,6 +359,7 @@ static const struct dpdk_qos_ops trtcm_policer_ops;
 static const struct dpdk_qos_ops *const qos_confs[] = {
 _policer_ops,
 _policer_ops,
+_policer_ops,
 NULL
 };
 
@@ -5572,6 +5578,159 @@ static const struct dpdk_qos_ops trtcm_policer_ops = {
 .qos_queue_dump_state_init = trtcm_policer_qos_queue_dump_state_init
 };
 
+/* kpkts-policer details */
+struct kpkts_policer {
+struct qos_conf qos_conf;
+struct token_bucket tb;
+uint32_t kpkts_rate;
+uint32_t kpkts_burst;
+};
+
+static int
+kpkts_policer_run_single_packet(struct 

[ovs-dev] [PATCH v7 1/4] token-bucket: Make token-bucket timestamp updated by caller.

2023-07-29 Thread miterv
From: Lin Huang 

Now, token-bucket 'last_fill' is updated by token_bucket_withdraw() itself.
Add a new function parameter 'now' to update timestamp by caller.

Signed-off-by: Lin Huang 
---
 include/openvswitch/token-bucket.h |  3 ++-
 lib/token-bucket.c |  4 ++--
 lib/vlog.c | 14 +++---
 ofproto/pinsched.c |  2 +-
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/include/openvswitch/token-bucket.h 
b/include/openvswitch/token-bucket.h
index 580747f61..d1191e956 100644
--- a/include/openvswitch/token-bucket.h
+++ b/include/openvswitch/token-bucket.h
@@ -40,7 +40,8 @@ void token_bucket_init(struct token_bucket *,
unsigned int rate, unsigned int burst);
 void token_bucket_set(struct token_bucket *,
unsigned int rate, unsigned int burst);
-bool token_bucket_withdraw(struct token_bucket *, unsigned int n);
+bool token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+   long long int now);
 void token_bucket_wait_at(struct token_bucket *, unsigned int n,
   const char *where);
 #define token_bucket_wait(bucket, n)\
diff --git a/lib/token-bucket.c b/lib/token-bucket.c
index 0badeb46b..60eb26e53 100644
--- a/lib/token-bucket.c
+++ b/lib/token-bucket.c
@@ -59,10 +59,10 @@ token_bucket_set(struct token_bucket *tb,
  * if 'tb' contained fewer than 'n' tokens (and thus 'n' tokens could not be
  * removed) . */
 bool
-token_bucket_withdraw(struct token_bucket *tb, unsigned int n)
+token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+  long long int now)
 {
 if (tb->tokens < n) {
-long long int now = time_msec();
 if (now > tb->last_fill) {
 unsigned long long int elapsed_ull
 = (unsigned long long int) now - tb->last_fill;
diff --git a/lib/vlog.c b/lib/vlog.c
index b2653142f..a025f79e5 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -1321,12 +1321,13 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 }
 
 ovs_mutex_lock(>mutex);
-if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS)) {
-time_t now = time_now();
+long long int now = time_msec();
+time_t now_sec = now / 1000;
+if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS, now)) {
 if (!rl->n_dropped) {
-rl->first_dropped = now;
+rl->first_dropped = now_sec;
 }
-rl->last_dropped = now;
+rl->last_dropped = now_sec;
 rl->n_dropped++;
 ovs_mutex_unlock(>mutex);
 return true;
@@ -1335,10 +1336,9 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 if (!rl->n_dropped) {
 ovs_mutex_unlock(>mutex);
 } else {
-time_t now = time_now();
 unsigned int n_dropped = rl->n_dropped;
-unsigned int first_dropped_elapsed = now - rl->first_dropped;
-unsigned int last_dropped_elapsed = now - rl->last_dropped;
+unsigned int first_dropped_elapsed = now_sec - rl->first_dropped;
+unsigned int last_dropped_elapsed = now_sec - rl->last_dropped;
 rl->n_dropped = 0;
 ovs_mutex_unlock(>mutex);
 
diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c
index 59561f076..a39e4d2ee 100644
--- a/ofproto/pinsched.c
+++ b/ofproto/pinsched.c
@@ -184,7 +184,7 @@ get_tx_packet(struct pinsched *ps)
 static bool
 get_token(struct pinsched *ps)
 {
-return token_bucket_withdraw(>token_bucket, 1000);
+return token_bucket_withdraw(>token_bucket, 1000, time_msec());
 }
 
 void
-- 
2.39.3

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


[ovs-dev] [PATCH v7 0/4] netdev-dpdk: Add support for userspace port-based packet-per-second policing.

2023-07-29 Thread miterv
From: Lin Huang 

v6->v7: split pps and bps policer.

v5->v6: fix code by reviewing.

v5->v4: police pkts bps and pps at the same time.
Get the maximum from the number of dropped packets, and drop that.

v4->v3: rewrite egress_policer_details_to_param func.
add a new pkts_policer_profile_config func.

v2->v3: police and free pkts by bulk.
fix the appropriate error code.

v1->v2: delete duplicated code.

Lin Huang (4):
  token-bucket: Make token-bucket timestamp updated by caller.
  netdev-dpdk: Make srtcm_policer to free pkts by bulk.
  netdev-dpdk: Add support for egress packet-per-second policing.
  netdev-dpdk: Add support for ingress packet-per-second policing.

 Documentation/topics/dpdk/qos.rst  |  42 ++
 NEWS   |   3 +
 include/openvswitch/token-bucket.h |   3 +-
 lib/netdev-dpdk.c  | 261 -
 lib/token-bucket.c |   4 +-
 lib/vlog.c |  14 +-
 ofproto/pinsched.c |   2 +-
 tests/system-dpdk.at   | 594 +
 vswitchd/vswitch.xml   |  32 ++
 9 files changed, 932 insertions(+), 23 deletions(-)

-- 
2.39.3

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


[ovs-dev] [PATCH v6 4/4] netdev-dpdk: Add support for ingress packet-per-second policing.

2023-07-01 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath dosen't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace ingress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maxiumim tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch reuse 'ingress_policing_kpkts_rate' and
'ingress_policing_kpkts_burst' options at interface table. Now userspace
ingress policer supports setting packet-per-second limits in addition to
the previously configurable byte rate settings.

Examples:
$ ovs-vsctl set interface dpdk0 ingress_policing_rate=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_burst=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123

Add some unit tests for ingress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  14 +-
 NEWS  |   2 +
 lib/netdev-dpdk.c |  71 --
 tests/system-dpdk.at  | 218 ++
 4 files changed, 288 insertions(+), 17 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index 5f0b1469a..4812ed37c 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -106,13 +106,19 @@ Refer to ``vswitch.xml`` for more details on egress 
policer.
 Rate Limiting (Ingress Policing)
 
 
-Assuming you have a :doc:`vhost-user port ` receiving traffic
-consisting of packets of size 64 bytes, the following command would limit the
-reception rate of the port to ~1,000,000 packets per second::
+Assuming you have a :doc:`vhost-user port ` receiving traffic,
+the following command would limit the reception rate of the port to
+~1,000,000 bits per second::
 
-$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=368000 \
+$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=1000 \
 ingress_policing_burst=1000`
 
+or, the following command would limit the reception rate of the port to
+~1,000,000 packets per second::
+
+$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=1000 \
+ingress_policing_kpkts_burst=1000`
+
 To examine the ingress policer configuration of the port::
 
 $ ovs-vsctl list interface vhost-user0
diff --git a/NEWS b/NEWS
index d88f490b1..91f62a0e4 100644
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,8 @@ Post-v3.1.0
table to check the status.
  * Added new configuration options 'kpkts_rate' and 'kpkts_burst' for
   'egress-policer' to support kilo packet-per-second policing.
+ * Added support for ingress kilo packet-per-second policing configured by
+   ingress_policing_kpkts_rate/burst options.
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f97153665..b6efa70a4 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -413,6 +413,8 @@ struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
 struct rte_meter_srtcm_profile in_prof;
+struct token_bucket tb;
+enum policer_type type;
 rte_spinlock_t policer_lock;
 };
 
@@ -499,6 +501,9 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 );
@@ -1377,6 +1382,8 @@ common_construct(struct netdev *netdev, dpdk_port_t 
port_no,
 ovsrcu_init(>ingress_policer, NULL);
 dev->policer_rate = 0;
 dev->policer_burst = 0;
+dev->policer_kpkts_rate = 0;
+dev->policer_kpkts_burst = 0;
 
 netdev->n_rxq = 0;
 netdev->n_txq = 0;
@@ -2471,14 +2478,22 @@ static int
 ingress_policer_run(struct ingress_policer *policer, struct rte_mbuf **pkts,
 int pkt_cnt, bool should_steal)
 {
+int bps_drop = 0, pps_drop = 0;
 int cnt = 0;
 
 rte_spinlock_lock(>policer_lock);
-cnt = srtcm_policer_run_single_packet(>in_policer,
-  >in_prof,
-  pkts, pkt_cnt);
+if (policer->type & POLICER_BPS) {
+bps_drop = srtcm_policer_run_single_packet(>in_policer,
+   >in_prof,
+   pkts, pkt_cnt);
+}
+
+if (policer->type & POLICER_PKTPS) {
+pps_drop = pkts_policer_run_single_packet(>tb, pkt_cnt);
+}
 rte_spinlock_unlock(>policer_lock);
 
+cnt = MAX(bps_drop, pps_drop);
 if (should_steal && 

[ovs-dev] [PATCH v6 3/4] netdev-dpdk: Add support for egress packet-per-second policing.

2023-07-01 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath doesn't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace egress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maximum tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch add new configuration option 'kpkts_rate' and 'kpkts_burst'
for egress-policer QoS type which now supports setting packet-per-second
limits in addition to the previously configurable byte rate settings.

Examples:
$ovs-vsctl set port vhost-user0 qos=@newqos --
   --id=@newqos create qos type=egress-policer \
   other-config:cir=123000 other-config:cbs=123000
   other-config:kpkts_rate=123 other-config:kpkts_burst=123

Add some unit tests for egress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  15 ++-
 NEWS  |   2 +
 lib/netdev-dpdk.c | 132 
 tests/system-dpdk.at  | 194 +-
 vswitchd/vswitch.xml  |  10 ++
 5 files changed, 327 insertions(+), 26 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index a98ec672f..5f0b1469a 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -36,14 +36,21 @@ QoS (Egress Policing)
 Single Queue Policer
 
 
-Assuming you have a :doc:`vhost-user port ` transmitting traffic
-consisting of packets of size 64 bytes, the following command would limit the
-egress transmission rate of the port to ~1,000,000 packets per second::
+Assuming you have a :doc:`vhost-user port ` transmitting traffic,
+the following command would limit the egress transmission rate of the port to
+~1,000,000 bytes per second:
 
 $ ovs-vsctl set port vhost-user0 qos=@newqos -- \
---id=@newqos create qos type=egress-policer other-config:cir=4600 \
+--id=@newqos create qos type=egress-policer other-config:cir=100 \
 other-config:cbs=2048`
 
+or, the following command would limit the egress transmission rate of the port
+to ~1,000,000 packets per second:
+
+   ovs-vsctl set port vhost-user0 qos=@newqos -- \
+  --id=@newqos create qos type=egress-policer \
+  other-config:kpkts_rate=1000 other-config:kpkts_burst=1000
+
 To examine the QoS configuration of the port, run::
 
 $ ovs-appctl -t ovs-vswitchd qos/show vhost-user0
diff --git a/NEWS b/NEWS
index 0b5dc3db1..d88f490b1 100644
--- a/NEWS
+++ b/NEWS
@@ -44,6 +44,8 @@ Post-v3.1.0
  * IP and L4 checksum offload support is now enabled by default for
interfaces that support it.  See the 'status' column in the 'interface'
table to check the status.
+ * Added new configuration options 'kpkts_rate' and 'kpkts_burst' for
+  'egress-policer' to support kilo packet-per-second policing.
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 2f7f74395..f97153665 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -91,6 +93,8 @@ static bool per_port_memory = false; /* Status of per port 
memory support */
 #define OVS_CACHE_LINE_SIZE CACHE_LINE_SIZE
 #define OVS_VPORT_DPDK "ovs_dpdk"
 
+#define MAX_KPKTS_PARAMETER 4294967U  /* UINT32_MAX / 1000 */
+
 /*
  * need to reserve tons of extra space in the mbufs so we can align the
  * DMA addresses to 4KB.
@@ -400,6 +404,11 @@ struct dpdk_tx_queue {
 );
 };
 
+enum policer_type {
+POLICER_BPS   = 1 << 0,   /* Rate value in bytes/sec. */
+POLICER_PKTPS = 1 << 1,   /* Rate value in packet/sec. */
+};
+
 struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
@@ -2418,6 +2427,46 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 return cnt;
 }
 
+static int
+pkts_policer_run_single_packet(struct token_bucket *tb, int pkt_cnt)
+{
+int cnt = 0;
+long long int now = time_msec();
+
+for (int i = 0; i < pkt_cnt; i++) {
+/* Handle current packet. */
+if (!token_bucket_withdraw(tb, 1, now)) {
+/* Count dropped packets. */
+cnt++;
+}
+}
+
+return cnt;
+}
+
+static int
+pkts_policer_profile_config(struct token_bucket *tb,
+uint32_t kpkts_rate, uint32_t kpkts_burst)
+{
+if (kpkts_rate > 

[ovs-dev] [PATCH v6 2/4] netdev-dpdk: Make srtcm_policer not to free pkts.

2023-07-01 Thread miterv
From: Lin Huang 

Now srtcm_policer will free pkts, if packets are exceed rate limit.
This patch change srtcm_policer not to free pkts, just count dropped packets.

Signed-off-by: Lin Huang 
---
 lib/netdev-dpdk.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 63dac689e..2f7f74395 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2399,8 +2399,7 @@ netdev_dpdk_srtcm_policer_pkt_handle(struct 
rte_meter_srtcm *meter,
 static int
 srtcm_policer_run_single_packet(struct rte_meter_srtcm *meter,
 struct rte_meter_srtcm_profile *profile,
-struct rte_mbuf **pkts, int pkt_cnt,
-bool should_steal)
+struct rte_mbuf **pkts, int pkt_cnt)
 {
 int i = 0;
 int cnt = 0;
@@ -2410,16 +2409,9 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 for (i = 0; i < pkt_cnt; i++) {
 pkt = pkts[i];
 /* Handle current packet */
-if (netdev_dpdk_srtcm_policer_pkt_handle(meter, profile,
- pkt, current_time)) {
-if (cnt != i) {
-pkts[cnt] = pkt;
-}
+if (!netdev_dpdk_srtcm_policer_pkt_handle(meter, profile,
+  pkt, current_time)) {
 cnt++;
-} else {
-if (should_steal) {
-rte_pktmbuf_free(pkt);
-}
 }
 }
 
@@ -2435,10 +2427,14 @@ ingress_policer_run(struct ingress_policer *policer, 
struct rte_mbuf **pkts,
 rte_spinlock_lock(>policer_lock);
 cnt = srtcm_policer_run_single_packet(>in_policer,
   >in_prof,
-  pkts, pkt_cnt, should_steal);
+  pkts, pkt_cnt);
 rte_spinlock_unlock(>policer_lock);
 
-return cnt;
+if (should_steal && cnt) {
+rte_pktmbuf_free_bulk([pkt_cnt - cnt], cnt);
+}
+
+return pkt_cnt - cnt;
 }
 
 static bool
@@ -4976,9 +4972,13 @@ egress_policer_run(struct qos_conf *conf, struct 
rte_mbuf **pkts, int pkt_cnt,
 
 cnt = srtcm_policer_run_single_packet(>egress_meter,
   >egress_prof, pkts,
-  pkt_cnt, should_steal);
+  pkt_cnt);
 
-return cnt;
+if (should_steal && cnt) {
+rte_pktmbuf_free_bulk([pkt_cnt - cnt], cnt);
+}
+
+return pkt_cnt - cnt;
 }
 
 static const struct dpdk_qos_ops egress_policer_ops = {
-- 
2.39.1

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


[ovs-dev] [PATCH v6 1/4] token-bucket: Make token-bucket timestamp updated by caller.

2023-07-01 Thread miterv
From: Lin Huang 

Now, token-bucket 'last_fill' is updated by token_bucket_withdraw() itself.
Add a new function parameter 'now' to update timestamp by caller.

Signed-off-by: Lin Huang 
---
 include/openvswitch/token-bucket.h | 3 ++-
 lib/token-bucket.c | 4 ++--
 lib/vlog.c | 3 ++-
 ofproto/pinsched.c | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/openvswitch/token-bucket.h 
b/include/openvswitch/token-bucket.h
index 580747f61..d1191e956 100644
--- a/include/openvswitch/token-bucket.h
+++ b/include/openvswitch/token-bucket.h
@@ -40,7 +40,8 @@ void token_bucket_init(struct token_bucket *,
unsigned int rate, unsigned int burst);
 void token_bucket_set(struct token_bucket *,
unsigned int rate, unsigned int burst);
-bool token_bucket_withdraw(struct token_bucket *, unsigned int n);
+bool token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+   long long int now);
 void token_bucket_wait_at(struct token_bucket *, unsigned int n,
   const char *where);
 #define token_bucket_wait(bucket, n)\
diff --git a/lib/token-bucket.c b/lib/token-bucket.c
index 0badeb46b..60eb26e53 100644
--- a/lib/token-bucket.c
+++ b/lib/token-bucket.c
@@ -59,10 +59,10 @@ token_bucket_set(struct token_bucket *tb,
  * if 'tb' contained fewer than 'n' tokens (and thus 'n' tokens could not be
  * removed) . */
 bool
-token_bucket_withdraw(struct token_bucket *tb, unsigned int n)
+token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+  long long int now)
 {
 if (tb->tokens < n) {
-long long int now = time_msec();
 if (now > tb->last_fill) {
 unsigned long long int elapsed_ull
 = (unsigned long long int) now - tb->last_fill;
diff --git a/lib/vlog.c b/lib/vlog.c
index b2653142f..380dcd479 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -1321,7 +1321,8 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 }
 
 ovs_mutex_lock(>mutex);
-if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS)) {
+if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS,
+   time_msec())) {
 time_t now = time_now();
 if (!rl->n_dropped) {
 rl->first_dropped = now;
diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c
index 59561f076..a39e4d2ee 100644
--- a/ofproto/pinsched.c
+++ b/ofproto/pinsched.c
@@ -184,7 +184,7 @@ get_tx_packet(struct pinsched *ps)
 static bool
 get_token(struct pinsched *ps)
 {
-return token_bucket_withdraw(>token_bucket, 1000);
+return token_bucket_withdraw(>token_bucket, 1000, time_msec());
 }
 
 void
-- 
2.39.1

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


[ovs-dev] [PATCH v6 0/4] netdev-dpdk: Add support for userspace port-based packet-per-second policing.

2023-07-01 Thread miterv
From: Lin Huang 

v5->v6: fix code by reviewing.

v5->v4: police pkts bps and pps at the same time.
Get the maximum from the number of dropped packets, and drop that.

v4->v3: rewrite egress_policer_details_to_param func.
add a new pkts_policer_profile_config func.

v2->v3: police and free pkts by bulk.
fix the appropriate error code.

v1->v2: delete duplicated code.

Lin Huang (4):
  token-bucket: Make token-bucket timestamp updated by caller.
  netdev-dpdk: Make srtcm_policer not to free pkts.
  netdev-dpdk: Add support for egress packet-per-second policing.
  netdev-dpdk: Add support for ingress packet-per-second policing.

 Documentation/topics/dpdk/qos.rst  |  29 +-
 NEWS   |   4 +
 include/openvswitch/token-bucket.h |   3 +-
 lib/netdev-dpdk.c  | 229 
 lib/token-bucket.c |   4 +-
 lib/vlog.c |   3 +-
 ofproto/pinsched.c |   2 +-
 tests/system-dpdk.at   | 412 -
 vswitchd/vswitch.xml   |  10 +
 9 files changed, 635 insertions(+), 61 deletions(-)

-- 
2.39.1

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


[ovs-dev] [PATCH v5 4/4] netdev-dpdk: Add support for ingress packet-per-second policing.

2023-06-18 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath dosen't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace ingress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maxiumim tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch reuse 'ingress_policing_kpkts_rate' and
'ingress_policing_kpkts_burst' options at interface table. Now userspace
ingress policer supports setting packet-per-second limits in addition to
the previously configurable byte rate settings.

Examples:
$ ovs-vsctl set interface dpdk0 ingress_policing_rate=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_burst=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123

Add some unit tests for ingress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  14 +-
 NEWS  |   2 +
 lib/netdev-dpdk.c |  77 +--
 tests/system-dpdk.at  | 218 ++
 4 files changed, 293 insertions(+), 18 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index 5f0b1469a..e7cc3d2a7 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -106,11 +106,17 @@ Refer to ``vswitch.xml`` for more details on egress 
policer.
 Rate Limiting (Ingress Policing)
 
 
-Assuming you have a :doc:`vhost-user port ` receiving traffic
-consisting of packets of size 64 bytes, the following command would limit the
-reception rate of the port to ~1,000,000 packets per second::
+Assuming you have a :doc:`vhost-user port ` receiving traffic,
+the following command would limit the reception rate of the port to
+~1,000,000 bits per second::
 
-$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=368000 \
+$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=1000 \
+ingress_policing_burst=1000`
+
+or, the following command would limit the reception rate of the port to
+~1,000,000 packets per second::
+
+$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=1000 \
 ingress_policing_burst=1000`
 
 To examine the ingress policer configuration of the port::
diff --git a/NEWS b/NEWS
index 3c33acbbf..cf4ae1b13 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,8 @@ Post-v3.1.0
- Userspace datapath:
  * Added new configuration options 'kpkts_rate' and 'kpkts_burst' for
   'egress-policer' to support packet-per-second policing.
+ * Added support for ingress packet-per-second policing configured by
+   ingress_policing_kpkts_rate/burst options.
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index ee5d557b0..9a4543b0e 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -413,6 +413,8 @@ struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
 struct rte_meter_srtcm_profile in_prof;
+struct token_bucket tb;
+enum policer_type type;
 rte_spinlock_t policer_lock;
 };
 
@@ -496,6 +498,9 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 );
@@ -1315,6 +1320,8 @@ common_construct(struct netdev *netdev, dpdk_port_t 
port_no,
 ovsrcu_init(>ingress_policer, NULL);
 dev->policer_rate = 0;
 dev->policer_burst = 0;
+dev->policer_kpkts_rate = 0;
+dev->policer_kpkts_burst = 0;
 
 netdev->n_rxq = 0;
 netdev->n_txq = 0;
@@ -2418,14 +2425,27 @@ ingress_policer_run(struct ingress_policer *policer, 
struct rte_mbuf **pkts,
 int pkt_cnt, bool should_steal)
 {
 int cnt = 0;
+int bps_drop = 0;
+int pps_drop = 0;
 
 rte_spinlock_lock(>policer_lock);
-cnt = srtcm_policer_run_single_packet(>in_policer,
-  >in_prof,
-  pkts, pkt_cnt);
+if (policer->type & POLICER_BPS) {
+bps_drop = srtcm_policer_run_single_packet(>in_policer,
+   >in_prof,
+   pkts, pkt_cnt);
+}
+
+if (policer->type & POLICER_PKTPS) {
+pps_drop = pkts_policer_run_single_packet(>tb, pkts, pkt_cnt);
+}
 rte_spinlock_unlock(>policer_lock);
 
-return cnt;
+cnt = MAX(bps_drop, pps_drop);
+if (should_steal && cnt) {
+rte_pktmbuf_free_bulk([pkt_cnt - 

[ovs-dev] [PATCH v5 1/4] token-bucket: Make token-bucket timestamp updated by caller.

2023-06-18 Thread miterv
From: Lin Huang 

Now, token-bucket 'last_fill' is updated by token_bucket_withdraw() itself.
Add a new function parameter 'now' to update timestamp by caller.

Signed-off-by: Lin Huang 
---
 include/openvswitch/token-bucket.h | 3 ++-
 lib/token-bucket.c | 4 ++--
 lib/vlog.c | 3 ++-
 ofproto/pinsched.c | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/openvswitch/token-bucket.h 
b/include/openvswitch/token-bucket.h
index 580747f61..d1191e956 100644
--- a/include/openvswitch/token-bucket.h
+++ b/include/openvswitch/token-bucket.h
@@ -40,7 +40,8 @@ void token_bucket_init(struct token_bucket *,
unsigned int rate, unsigned int burst);
 void token_bucket_set(struct token_bucket *,
unsigned int rate, unsigned int burst);
-bool token_bucket_withdraw(struct token_bucket *, unsigned int n);
+bool token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+   long long int now);
 void token_bucket_wait_at(struct token_bucket *, unsigned int n,
   const char *where);
 #define token_bucket_wait(bucket, n)\
diff --git a/lib/token-bucket.c b/lib/token-bucket.c
index 0badeb46b..60eb26e53 100644
--- a/lib/token-bucket.c
+++ b/lib/token-bucket.c
@@ -59,10 +59,10 @@ token_bucket_set(struct token_bucket *tb,
  * if 'tb' contained fewer than 'n' tokens (and thus 'n' tokens could not be
  * removed) . */
 bool
-token_bucket_withdraw(struct token_bucket *tb, unsigned int n)
+token_bucket_withdraw(struct token_bucket *tb, unsigned int n,
+  long long int now)
 {
 if (tb->tokens < n) {
-long long int now = time_msec();
 if (now > tb->last_fill) {
 unsigned long long int elapsed_ull
 = (unsigned long long int) now - tb->last_fill;
diff --git a/lib/vlog.c b/lib/vlog.c
index b2653142f..380dcd479 100644
--- a/lib/vlog.c
+++ b/lib/vlog.c
@@ -1321,7 +1321,8 @@ vlog_should_drop(const struct vlog_module *module, enum 
vlog_level level,
 }
 
 ovs_mutex_lock(>mutex);
-if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS)) {
+if (!token_bucket_withdraw(>token_bucket, VLOG_MSG_TOKENS,
+   time_msec())) {
 time_t now = time_now();
 if (!rl->n_dropped) {
 rl->first_dropped = now;
diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c
index 59561f076..a39e4d2ee 100644
--- a/ofproto/pinsched.c
+++ b/ofproto/pinsched.c
@@ -184,7 +184,7 @@ get_tx_packet(struct pinsched *ps)
 static bool
 get_token(struct pinsched *ps)
 {
-return token_bucket_withdraw(>token_bucket, 1000);
+return token_bucket_withdraw(>token_bucket, 1000, time_msec());
 }
 
 void
-- 
2.39.1

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


[ovs-dev] [PATCH v5 3/4] netdev-dpdk: Add support for egress packet-per-second policing.

2023-06-18 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath doesn't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace egress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maximum tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch add new configuration option 'kpkts_rate' and 'kpkts_burst'
for egress-policer QoS type which now supports setting packet-per-second
limits in addition to the previously configurable byte rate settings.

Examples:
$ovs-vsctl set port vhost-user0 qos=@newqos --
   --id=@newqos create qos type=egress-policer \
   other-config:cir=123000 other-config:cbs=123000
   other-config:kpkts_rate=123 other-config:kpkts_burst=123

Add some unit tests for egress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  15 ++-
 NEWS  |   3 +
 lib/netdev-dpdk.c | 141 ++
 tests/system-dpdk.at  | 194 +-
 vswitchd/vswitch.xml  |  10 ++
 5 files changed, 337 insertions(+), 26 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index a98ec672f..5f0b1469a 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -36,14 +36,21 @@ QoS (Egress Policing)
 Single Queue Policer
 
 
-Assuming you have a :doc:`vhost-user port ` transmitting traffic
-consisting of packets of size 64 bytes, the following command would limit the
-egress transmission rate of the port to ~1,000,000 packets per second::
+Assuming you have a :doc:`vhost-user port ` transmitting traffic,
+the following command would limit the egress transmission rate of the port to
+~1,000,000 bytes per second:
 
 $ ovs-vsctl set port vhost-user0 qos=@newqos -- \
---id=@newqos create qos type=egress-policer other-config:cir=4600 \
+--id=@newqos create qos type=egress-policer other-config:cir=100 \
 other-config:cbs=2048`
 
+or, the following command would limit the egress transmission rate of the port
+to ~1,000,000 packets per second:
+
+   ovs-vsctl set port vhost-user0 qos=@newqos -- \
+  --id=@newqos create qos type=egress-policer \
+  other-config:kpkts_rate=1000 other-config:kpkts_burst=1000
+
 To examine the QoS configuration of the port, run::
 
 $ ovs-appctl -t ovs-vswitchd qos/show vhost-user0
diff --git a/NEWS b/NEWS
index cfd43..3c33acbbf 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,9 @@ Post-v3.1.0
process extra privileges when mapping physical interconnect memory.
- SRv6 Tunnel Protocol
  * Added support for userspace datapath (only).
+   - Userspace datapath:
+ * Added new configuration options 'kpkts_rate' and 'kpkts_burst' for
+  'egress-policer' to support packet-per-second policing.
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 707f622f3..ee5d557b0 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -91,6 +93,8 @@ static bool per_port_memory = false; /* Status of per port 
memory support */
 #define OVS_CACHE_LINE_SIZE CACHE_LINE_SIZE
 #define OVS_VPORT_DPDK "ovs_dpdk"
 
+#define MAX_KPKTS_PARAMETER 4294967U  /* UINT32_MAX / 1000 */
+
 /*
  * need to reserve tons of extra space in the mbufs so we can align the
  * DMA addresses to 4KB.
@@ -400,6 +404,11 @@ struct dpdk_tx_queue {
 );
 };
 
+enum policer_type {
+POLICER_BPS   = 1 << 0,   /* Rate value in bytes/sec. */
+POLICER_PKTPS = 1 << 1,   /* Rate value in packet/sec. */
+};
+
 struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
@@ -2360,6 +2369,50 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 return cnt;
 }
 
+static int
+pkts_policer_run_single_packet(struct token_bucket *tb, struct rte_mbuf **pkts,
+   int pkt_cnt)
+{
+int cnt = 0;
+struct rte_mbuf *pkt = NULL;
+long long int now = time_msec();
+
+for (int i = 0; i < pkt_cnt; i++) {
+pkt = pkts[i];
+/* Handle current packet. */
+if (!token_bucket_withdraw(tb, 1, now)) {
+/* Count dropped packets. */
+cnt++;
+}
+}
+
+/* Count dropped packets */
+return cnt;
+}
+
+static int

[ovs-dev] [PATCH v5 2/4] netdev-dpdk: make srtcm_policer not to free pkts.

2023-06-18 Thread miterv
From: Lin Huang 

Now srtcm_policer will free pkts, if packets are exceed rate limit.
This patch change srtcm_policer not to free pkts, just count dropped packets.

Signed-off-by: Lin Huang 
---
 lib/netdev-dpdk.c | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8cb1a7703..707f622f3 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2340,8 +2340,7 @@ netdev_dpdk_srtcm_policer_pkt_handle(struct 
rte_meter_srtcm *meter,
 static int
 srtcm_policer_run_single_packet(struct rte_meter_srtcm *meter,
 struct rte_meter_srtcm_profile *profile,
-struct rte_mbuf **pkts, int pkt_cnt,
-bool should_steal)
+struct rte_mbuf **pkts, int pkt_cnt)
 {
 int i = 0;
 int cnt = 0;
@@ -2351,19 +2350,13 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 for (i = 0; i < pkt_cnt; i++) {
 pkt = pkts[i];
 /* Handle current packet */
-if (netdev_dpdk_srtcm_policer_pkt_handle(meter, profile,
- pkt, current_time)) {
-if (cnt != i) {
-pkts[cnt] = pkt;
-}
-cnt++;
-} else {
-if (should_steal) {
-rte_pktmbuf_free(pkt);
-}
+if (!netdev_dpdk_srtcm_policer_pkt_handle(meter, profile,
+  pkt, current_time)) {
+ cnt++;
 }
 }
 
+/* Count dropped packets */
 return cnt;
 }
 
@@ -2376,7 +2369,7 @@ ingress_policer_run(struct ingress_policer *policer, 
struct rte_mbuf **pkts,
 rte_spinlock_lock(>policer_lock);
 cnt = srtcm_policer_run_single_packet(>in_policer,
   >in_prof,
-  pkts, pkt_cnt, should_steal);
+  pkts, pkt_cnt);
 rte_spinlock_unlock(>policer_lock);
 
 return cnt;
@@ -4876,7 +4869,7 @@ egress_policer_run(struct qos_conf *conf, struct rte_mbuf 
**pkts, int pkt_cnt,
 
 cnt = srtcm_policer_run_single_packet(>egress_meter,
   >egress_prof, pkts,
-  pkt_cnt, should_steal);
+  pkt_cnt);
 
 return cnt;
 }
-- 
2.39.1

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


[ovs-dev] [PATCH v5 0/4] netdev-dpdk: Add support for userspace port-based packet-per-second policing.

2023-06-18 Thread miterv
From: Lin Huang 

v5->v4: police pkts bps and pps at the same time.
Get the maximum from the number of dropped packets, and drop that.

v4->v3: rewrite egress_policer_details_to_param func.
add a new pkts_policer_profile_config func.

v2->v3: police and free pkts by bulk.
fix the appropriate error code.

v1->v2: delete duplicated code.

Lin Huang (4):
  token-bucket: Make token-bucket timestamp updated by caller.
  netdev-dpdk: make srtcm_policer not to free pkts.
  netdev-dpdk: Add support for egress packet-per-second policing.
  netdev-dpdk: Add support for ingress packet-per-second policing.

 Documentation/topics/dpdk/qos.rst  |  29 +-
 NEWS   |   5 +
 include/openvswitch/token-bucket.h |   3 +-
 lib/netdev-dpdk.c  | 233 
 lib/token-bucket.c |   4 +-
 lib/vlog.c |   3 +-
 ofproto/pinsched.c |   2 +-
 tests/system-dpdk.at   | 412 -
 vswitchd/vswitch.xml   |  10 +
 9 files changed, 641 insertions(+), 60 deletions(-)

-- 
2.39.1

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


[ovs-dev] [PATCH v1] dpif-netdev: Update meter timestamp when dp_netdev_run_meter been called.

2023-05-31 Thread miterv
From: Lin Huang 

Currently, a meter's timestamp 'now' is set by 'pmd->ctx.now' which updated
by pmd_thread_ctx_time_update().

Before processing of the new packet batch:
- dpif_netdev_execute()
- dp_netdev_process_rxq_port()

There is a problem when user want to police the rate to a low pps by meter.
For example, When the traffic is more than 3Mpps, policing the traffic to
1M pps, the real rate will be 3Mpps not 1Mpps.

The key point is that a meter's timestamp isn't update in real time.
For example, PMD thread A and B are polled at the same time (t1).
Thread A starts to run meter to police traffic. At the same time, thread B
pause at 'ovs_mutex_lock(>lock)' to wait thread A release the meter
lock. This elapsed a lot of time, especially we have more than 10 PMD threads.

After thread A release the meter lock, thread B start to count the time diff.
- long_delta_t = now - meter->used' --> long_delta_t = t1 - t1 = 0.
- band->bucket += (uint64_t) delta_t * band->rate --> band->bucket = 0.
- band_exceeded_pkt = band->bucket / 1000; --> band_exceeded_pkt = 0.

Fix this problem by update the meter timestamp every time.

Test-by: Zhang Yuhuang 
Signed-off-by: Lin Huang 
---
 lib/dpif-netdev.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 70b953ae6..dbb275cf8 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -7169,12 +7169,13 @@ dpif_netdev_meter_get_features(const struct dpif * dpif 
OVS_UNUSED,
  * that exceed a band are dropped in-place. */
 static void
 dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
-uint32_t meter_id, long long int now)
+uint32_t meter_id)
 {
 struct dp_meter *meter;
 struct dp_meter_band *band;
 struct dp_packet *packet;
 long long int long_delta_t; /* msec */
+long long int now;
 uint32_t delta_t; /* msec */
 const size_t cnt = dp_packet_batch_size(packets_);
 uint32_t bytes, volume;
@@ -7197,8 +7198,12 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct 
dp_packet_batch *packets_,
 memset(exceeded_rate, 0, cnt * sizeof *exceeded_rate);
 
 ovs_mutex_lock(>lock);
+
+/* Update now */
+now = time_msec();
+
 /* All packets will hit the meter at the same time. */
-long_delta_t = now / 1000 - meter->used / 1000; /* msec */
+long_delta_t = now  - meter->used; /* msec */
 
 if (long_delta_t < 0) {
 /* This condition means that we have several threads fighting for a
@@ -9170,8 +9175,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch 
*packets_,
 }
 
 case OVS_ACTION_ATTR_METER:
-dp_netdev_run_meter(pmd->dp, packets_, nl_attr_get_u32(a),
-pmd->ctx.now);
+dp_netdev_run_meter(pmd->dp, packets_, nl_attr_get_u32(a));
 break;
 
 case OVS_ACTION_ATTR_PUSH_VLAN:
-- 
2.39.1

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


[ovs-dev] [PATCH v4 2/2] netdev-dpdk: Add support for ingress packet-per-second policing.

2023-05-16 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath dosen't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace ingress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maxiumim tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch reuse 'ingress_policing_kpkts_rate' and
'ingress_policing_kpkts_burst' options at interface table. Now userspace
ingress policer supports setting packet-per-second limits in addition to
the previously configurable byte rate settings.

Examples:
$ ovs-vsctl set interface dpdk0 ingress_policing_rate=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_burst=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123

Add some unit tests for ingress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  14 +-
 NEWS  |   2 +
 lib/netdev-dpdk.c |  73 +++---
 tests/system-dpdk.at  | 218 ++
 4 files changed, 287 insertions(+), 20 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index 5f0b1469a..e7cc3d2a7 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -106,11 +106,17 @@ Refer to ``vswitch.xml`` for more details on egress 
policer.
 Rate Limiting (Ingress Policing)
 
 
-Assuming you have a :doc:`vhost-user port ` receiving traffic
-consisting of packets of size 64 bytes, the following command would limit the
-reception rate of the port to ~1,000,000 packets per second::
+Assuming you have a :doc:`vhost-user port ` receiving traffic,
+the following command would limit the reception rate of the port to
+~1,000,000 bits per second::
 
-$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=368000 \
+$ ovs-vsctl set interface vhost-user0 ingress_policing_rate=1000 \
+ingress_policing_burst=1000`
+
+or, the following command would limit the reception rate of the port to
+~1,000,000 packets per second::
+
+$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=1000 \
 ingress_policing_burst=1000`
 
 To examine the ingress policer configuration of the port::
diff --git a/NEWS b/NEWS
index 3c33acbbf..36661ff30 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,8 @@ Post-v3.1.0
- Userspace datapath:
  * Added new configuration options 'kpkts_rate' and 'kpkts_burst' for
   'egress-policer' to support packet-per-second policing.
+ * Added support for ingress packet-per-second policing,configured by
+   ingress_policing_kpkts_rate/burst options.
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 518267414..55ab8c3f7 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -413,6 +413,8 @@ struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
 struct rte_meter_srtcm_profile in_prof;
+struct token_bucket tb;
+enum policer_type type;
 rte_spinlock_t policer_lock;
 };
 
@@ -496,6 +498,9 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 );
@@ -1315,6 +1320,8 @@ common_construct(struct netdev *netdev, dpdk_port_t 
port_no,
 ovsrcu_init(>ingress_policer, NULL);
 dev->policer_rate = 0;
 dev->policer_burst = 0;
+dev->policer_kpkts_rate = 0;
+dev->policer_kpkts_burst = 0;
 
 netdev->n_rxq = 0;
 netdev->n_txq = 0;
@@ -2387,15 +2394,20 @@ static int
 ingress_policer_run(struct ingress_policer *policer, struct rte_mbuf **pkts,
 int pkt_cnt, bool should_steal)
 {
-int cnt = 0;
-
 rte_spinlock_lock(>policer_lock);
-cnt = srtcm_policer_run_single_packet(>in_policer,
-  >in_prof,
-  pkts, pkt_cnt, should_steal);
+if (policer->type & POLICER_BPS) {
+pkt_cnt = srtcm_policer_run_single_packet(>in_policer,
+  >in_prof,
+  pkts, pkt_cnt, should_steal);
+}
+
+if (policer->type & POLICER_PKTPS) {
+pkt_cnt = pkts_policer_run_single_packet(>tb, pkts, pkt_cnt,
+ should_steal);
+}
 rte_spinlock_unlock(>policer_lock);
 
-return cnt;
+return pkt_cnt;
 }
 
 static bool
@@ -3554,7 +3566,8 

[ovs-dev] [PATCH v4 0/2] netdev-dpdk: Add support for userspace port-based packet-per-second policing.

2023-05-16 Thread miterv
From: Lin Huang 

v4->v3: rewrite egress_policer_details_to_param func.
add a new pkts_policer_profile_config func.

v2->v3: police and free pkts by bulk.
fix the appropriate error code.

v1->v2: delete duplicated code.

Lin Huang (2):
  netdev-dpdk: Add support for egress packet-per-second policing.
  netdev-dpdk: Add support for ingress packet-per-second policing.

 Documentation/topics/dpdk/qos.rst |  29 ++-
 NEWS  |   5 +
 lib/netdev-dpdk.c | 203 ---
 tests/system-dpdk.at  | 412 +-
 vswitchd/vswitch.xml  |  10 +
 5 files changed, 612 insertions(+), 47 deletions(-)

-- 
2.39.1

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


[ovs-dev] [PATCH v4 1/2] netdev-dpdk: Add support for egress packet-per-second policing.

2023-05-16 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath doesn't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace egress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maximum tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch add new configuration option 'kpkts_rate' and 'kpkts_burst'
for egress-policer QoS type which now supports setting packet-per-second
limits in addition to the previously configurable byte rate settings.

Examples:
$ovs-vsctl set port vhost-user0 qos=@newqos --
   --id=@newqos create qos type=egress-policer \
   other-config:cir=123000 other-config:cbs=123000
   other-config:kpkts_rate=123 other-config:kpkts_burst=123

Add some unit tests for egress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 Documentation/topics/dpdk/qos.rst |  15 ++-
 NEWS  |   3 +
 lib/netdev-dpdk.c | 130 
 tests/system-dpdk.at  | 194 +-
 vswitchd/vswitch.xml  |  10 ++
 5 files changed, 325 insertions(+), 27 deletions(-)

diff --git a/Documentation/topics/dpdk/qos.rst 
b/Documentation/topics/dpdk/qos.rst
index a98ec672f..5f0b1469a 100644
--- a/Documentation/topics/dpdk/qos.rst
+++ b/Documentation/topics/dpdk/qos.rst
@@ -36,14 +36,21 @@ QoS (Egress Policing)
 Single Queue Policer
 
 
-Assuming you have a :doc:`vhost-user port ` transmitting traffic
-consisting of packets of size 64 bytes, the following command would limit the
-egress transmission rate of the port to ~1,000,000 packets per second::
+Assuming you have a :doc:`vhost-user port ` transmitting traffic,
+the following command would limit the egress transmission rate of the port to
+~1,000,000 bytes per second:
 
 $ ovs-vsctl set port vhost-user0 qos=@newqos -- \
---id=@newqos create qos type=egress-policer other-config:cir=4600 \
+--id=@newqos create qos type=egress-policer other-config:cir=100 \
 other-config:cbs=2048`
 
+or, the following command would limit the egress transmission rate of the port
+to ~1,000,000 packets per second:
+
+   ovs-vsctl set port vhost-user0 qos=@newqos -- \
+  --id=@newqos create qos type=egress-policer \
+  other-config:kpkts_rate=1000 other-config:kpkts_burst=1000
+
 To examine the QoS configuration of the port, run::
 
 $ ovs-appctl -t ovs-vswitchd qos/show vhost-user0
diff --git a/NEWS b/NEWS
index cfd43..3c33acbbf 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,9 @@ Post-v3.1.0
process extra privileges when mapping physical interconnect memory.
- SRv6 Tunnel Protocol
  * Added support for userspace datapath (only).
+   - Userspace datapath:
+ * Added new configuration options 'kpkts_rate' and 'kpkts_burst' for
+  'egress-policer' to support packet-per-second policing.
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index fb0dd43f7..518267414 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -91,6 +93,8 @@ static bool per_port_memory = false; /* Status of per port 
memory support */
 #define OVS_CACHE_LINE_SIZE CACHE_LINE_SIZE
 #define OVS_VPORT_DPDK "ovs_dpdk"
 
+#define MAX_KPKTS_PARAMETER 4294967U  /* UINT32_MAX / 1000 */
+
 /*
  * need to reserve tons of extra space in the mbufs so we can align the
  * DMA addresses to 4KB.
@@ -400,6 +404,11 @@ struct dpdk_tx_queue {
 );
 };
 
+enum policer_type {
+POLICER_BPS   = 1 << 0,   /* Rate value in bytes/sec. */
+POLICER_PKTPS = 1 << 1,   /* Rate value in packet/sec. */
+};
+
 struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
@@ -2335,6 +2344,45 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 return cnt;
 }
 
+static int
+pkts_policer_run_single_packet(struct token_bucket *tb, struct rte_mbuf **pkts,
+   unsigned int pkt_cnt, bool should_steal)
+{
+int cnt = 0;
+
+if (token_bucket_withdraw(tb, pkt_cnt)) {
+/* Handle packet by batch. */
+cnt = pkt_cnt;
+} else if (should_steal) {
+rte_pktmbuf_free_bulk(pkts, pkt_cnt);
+}
+
+return cnt;
+}
+
+static int
+pkts_policer_profile_config(struct token_bucket *tb,
+uint32_t kpkts_rate, uint32_t kpkts_burst)
+{

[ovs-dev] [PATCH v3 2/2] netdev-dpdk: Add support for userspace port-based ingress packet-per-second policing.

2023-05-01 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath dosen't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace ingress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maxiumim tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch reuse 'ingress_policing_kpkts_rate' and
'ingress_policing_kpkts_burst' options at interface table. Now userspace
ingress policer supports setting packet-per-second limits in addition to
the previously configurable byte rate settings.

Examples:
$ ovs-vsctl set interface dpdk0 ingress_policing_rate=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_burst=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123

Add some unit tests for ingress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 NEWS |   4 +
 lib/netdev-dpdk.c|  78 +---
 tests/system-dpdk.at | 216 ++-
 3 files changed, 285 insertions(+), 13 deletions(-)

diff --git a/NEWS b/NEWS
index c41c6adf6..53adbed82 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,10 @@ Post-v3.1.0
ovs-vsctl set port vhost-user0 qos=@newqos -- \
   --id=@newqos create qos type=egress-policer \
   other-config:kpkts_rate=123 other-config:kpkts_burst=123
+ * Added support for ingress packet-per-second policing.
+   Examples:
+   $ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
+   $ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index bcd13c116..a717edc5e 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -413,6 +413,8 @@ struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
 struct rte_meter_srtcm_profile in_prof;
+struct token_bucket tb;
+enum policer_type type;
 rte_spinlock_t policer_lock;
 };
 
@@ -496,6 +498,9 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 );
@@ -1315,6 +1320,8 @@ common_construct(struct netdev *netdev, dpdk_port_t 
port_no,
 ovsrcu_init(>ingress_policer, NULL);
 dev->policer_rate = 0;
 dev->policer_burst = 0;
+dev->policer_kpkts_rate = 0;
+dev->policer_kpkts_burst = 0;
 
 netdev->n_rxq = 0;
 netdev->n_txq = 0;
@@ -2367,9 +2374,16 @@ ingress_policer_run(struct ingress_policer *policer, 
struct rte_mbuf **pkts,
 int cnt = 0;
 
 rte_spinlock_lock(>policer_lock);
-cnt = srtcm_policer_run_single_packet(>in_policer,
-  >in_prof,
-  pkts, pkt_cnt, should_steal);
+if (policer->type & POLICER_BPS) {
+cnt = srtcm_policer_run_single_packet(>in_policer,
+  >in_prof,
+  pkts, pkt_cnt, should_steal);
+}
+
+if (policer->type & POLICER_PKTPS) {
+cnt = pkts_policer_run_single_packet(>tb, pkts, pkt_cnt,
+ should_steal);
+}
 rte_spinlock_unlock(>policer_lock);
 
 return cnt;
@@ -3531,7 +3545,8 @@ netdev_dpdk_get_features(const struct netdev *netdev,
 }
 
 static struct ingress_policer *
-netdev_dpdk_policer_construct(uint32_t rate, uint32_t burst)
+netdev_dpdk_policer_construct(uint32_t rate, uint32_t burst,
+  uint32_t kpkts_rate, uint32_t kpkts_burst)
 {
 struct ingress_policer *policer = NULL;
 uint64_t rate_bytes;
@@ -3539,6 +3554,9 @@ netdev_dpdk_policer_construct(uint32_t rate, uint32_t 
burst)
 int err = 0;
 
 policer = xmalloc(sizeof *policer);
+if (!policer) {
+return NULL;
+}
 rte_spinlock_init(>policer_lock);
 
 /* rte_meter requires bytes so convert kbits rate and burst to bytes. */
@@ -3556,8 +3574,29 @@ netdev_dpdk_policer_construct(uint32_t rate, uint32_t 
burst)
 }
 if (err) {
 VLOG_ERR("Could not create rte meter for ingress policer");
+} else {
+policer->type |= POLICER_BPS;
+}
+
+if (kpkts_rate > MAX_KPKTS_PARAMETER || kpkts_burst > MAX_KPKTS_PARAMETER
+|| kpkts_rate == 0 || kpkts_burst == 0) {
+/* Paramters between (1 ~ MAX_KPKTS_PARAMETER). */
+/* Zero means not to police the flow. */
+VLOG_ERR("Could not create tocken bucket for ingress policer");
+} else {
+/*
+  

[ovs-dev] [PATCH v3 1/2] netdev-dpdk: Add support for userspace port-based egress packet-per-second policing.

2023-05-01 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress
and egress side in kernel datapath. But the userspace datapath dosen't
support for ingress and egress packet-per-second policing now.

So, this patch add support for userspace egress pps policing by using
native ovs token bucket library. Token bucket is accumulated by 'rate'
tokens per millisecond and store maxiumim tokens at 'burst' bucket size.
One token in the bucket means one packet (1 kpkts * millisecond) which
will drop or pass by policer.

This patch add new configuration option 'kpkts_rate' and 'kpkts_burst'
for egress-policer QoS type which now supports setting packet-per-second
limits in addition to the previously configurable byte rate settings.

Examples:
$ovs-vsctl set port vhost-user0 qos=@newqos --
   --id=@newqos create qos type=egress-policer \
   other-config:cir=123000 other-config:cbs=123000
   other-config:kpkts_rate=123 other-config:kpkts_burst=123

Add some unit tests for egress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 NEWS |   7 ++
 lib/netdev-dpdk.c|  96 +++---
 tests/system-dpdk.at | 186 ++-
 vswitchd/vswitch.xml |  10 +++
 4 files changed, 285 insertions(+), 14 deletions(-)

diff --git a/NEWS b/NEWS
index b6418c36e..c41c6adf6 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,13 @@ Post-v3.1.0
process extra privileges when mapping physical interconnect memory.
- SRv6 Tunnel Protocol
  * Added support for userspace datapath (only).
+   - Userspace datapath:
+ * Added new configuration options 'kpkts_rate' and 'kpkts_burst' for
+  'egress-policer' to support packet-per-second policing.
+   Examples:
+   ovs-vsctl set port vhost-user0 qos=@newqos -- \
+  --id=@newqos create qos type=egress-policer \
+  other-config:kpkts_rate=123 other-config:kpkts_burst=123
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index fb0dd43f7..bcd13c116 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -91,6 +93,8 @@ static bool per_port_memory = false; /* Status of per port 
memory support */
 #define OVS_CACHE_LINE_SIZE CACHE_LINE_SIZE
 #define OVS_VPORT_DPDK "ovs_dpdk"
 
+#define MAX_KPKTS_PARAMETER 4294967U  /* UINT32_MAX / 1000 */
+
 /*
  * need to reserve tons of extra space in the mbufs so we can align the
  * DMA addresses to 4KB.
@@ -400,6 +404,11 @@ struct dpdk_tx_queue {
 );
 };
 
+enum policer_type {
+POLICER_BPS   = 1 << 0,   /* Rate value in bytes/sec. */
+POLICER_PKTPS = 1 << 1,   /* Rate value in packet/sec. */
+};
+
 struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
@@ -2335,6 +2344,22 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 return cnt;
 }
 
+static int
+pkts_policer_run_single_packet(struct token_bucket *tb, struct rte_mbuf **pkts,
+   int pkt_cnt, bool should_steal)
+{
+int cnt = 0;
+
+if (token_bucket_withdraw(tb, pkt_cnt)) {
+/* Handle packet by batch. */
+cnt = pkt_cnt;
+} else if (should_steal) {
+rte_pktmbuf_free_bulk(pkts, pkt_cnt);
+}
+
+return cnt;
+}
+
 static int
 ingress_policer_run(struct ingress_policer *policer, struct rte_mbuf **pkts,
 int pkt_cnt, bool should_steal)
@@ -4757,6 +4782,10 @@ netdev_dpdk_queue_dump_done(const struct netdev *netdev 
OVS_UNUSED,
 
 struct egress_policer {
 struct qos_conf qos_conf;
+enum policer_type type;
+uint32_t kpkts_rate;
+uint32_t kpkts_burst;
+struct token_bucket egress_tb;
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm egress_meter;
 struct rte_meter_srtcm_profile egress_prof;
@@ -4776,26 +4805,53 @@ static int
 egress_policer_qos_construct(const struct smap *details,
  struct qos_conf **conf)
 {
+uint32_t kpkts_burst, kpkts_rate;
 struct egress_policer *policer;
 int err = 0;
 
-policer = xmalloc(sizeof *policer);
+policer = xzalloc(sizeof *policer);
+if (!policer) {
+return ENOMEM;
+}
+
 qos_conf_init(>qos_conf, _policer_ops);
 egress_policer_details_to_param(details, >app_srtcm_params);
 err = rte_meter_srtcm_profile_config(>egress_prof,
- >app_srtcm_params);
+>app_srtcm_params);
 if (!err) {
 err = rte_meter_srtcm_config(>egress_meter,
- >egress_prof);
+   

[ovs-dev] [PATCH v3 0/2] netdev-dpdk: Add support for userspace port-based packet-per-second policing.

2023-05-01 Thread miterv
From: Lin Huang 

v2->v3: police and free pkts by bulk.
fix the appropriate error code.

v1->v2: delete duplicated code.

Lin Huang (2):
  netdev-dpdk: Add support for userspace port-based egress
packet-per-second policing.
  netdev-dpdk: Add support for userspace port-based ingress
packet-per-second policing.

 NEWS |  11 ++
 lib/netdev-dpdk.c| 174 ---
 tests/system-dpdk.at | 402 ++-
 vswitchd/vswitch.xml |  10 ++
 4 files changed, 570 insertions(+), 27 deletions(-)

-- 
2.31.1

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


[ovs-dev] [PATCH v2 1/2] * netdev-dpdk: Add support for userspace port-based egress packet-per-second policing.

2023-04-09 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress and 
egress
side in kernel datapath. But the userspace datapath dosen't support for ingress 
and
egress packet-per-second policing now.

So, this patch add support for userspace egress pps policing by using native ovs
token bucket library. Token bucket is accumulated by 'rate' tokens per 
millisecond
and store maxiumim tokens at 'burst' bucket size. One token in the bucket means
one packet (1 kpkts * millisecond) which will drop or pass by policer.

This patch add new configuration option 'kpkts_rate' and 'kpkts_burst' for
egress-policer QoS type which now supports setting packet-per-second limits in
addition to the previously configurable byte rate settings.

Examples:
$ovs-vsctl set port vhost-user0 qos=@newqos --
   --id=@newqos create qos type=egress-policer \
   other-config:cir=123000 other-config:cbs=123000
   other-config:kpkts_rate=123 other-config:kpkts_burst=123

Add some unit tests for egress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 NEWS |   7 +++
 lib/netdev-dpdk.c|  90 +
 tests/system-dpdk.at | 134 +++
 vswitchd/vswitch.xml |  10 
 4 files changed, 229 insertions(+), 12 deletions(-)

diff --git a/NEWS b/NEWS
index b6418c36e..c41c6adf6 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,13 @@ Post-v3.1.0
process extra privileges when mapping physical interconnect memory.
- SRv6 Tunnel Protocol
  * Added support for userspace datapath (only).
+   - Userspace datapath:
+ * Added new configuration options 'kpkts_rate' and 'kpkts_burst' for
+  'egress-policer' to support packet-per-second policing.
+   Examples:
+   ovs-vsctl set port vhost-user0 qos=@newqos -- \
+  --id=@newqos create qos type=egress-policer \
+  other-config:kpkts_rate=123 other-config:kpkts_burst=123
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index fb0dd43f7..2fd8bc68d 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -400,6 +402,11 @@ struct dpdk_tx_queue {
 );
 };
 
+enum policer_type {
+POLICER_BPS   = 1 << 0,   /* Rate value in bytes/sec. */
+POLICER_PKTPS = 1 << 1,   /* Rate value in packet/sec. */
+};
+
 struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
@@ -2335,6 +2342,29 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 return cnt;
 }
 
+static int
+pkts_policer_run_single_packet(struct token_bucket *tb, struct rte_mbuf **pkts,
+   int pkt_cnt, bool should_steal)
+{
+struct rte_mbuf *pkt;
+int cnt = 0;
+
+for (int i = 0; i < pkt_cnt; i++) {
+pkt = pkts[i];
+/* Handle current packet. */
+if (token_bucket_withdraw(tb, 1)) {
+if (cnt != i) {
+pkts[cnt] = pkt;
+}
+cnt++;
+} else if (should_steal) {
+rte_pktmbuf_free(pkt);
+}
+}
+
+return cnt;
+}
+
 static int
 ingress_policer_run(struct ingress_policer *policer, struct rte_mbuf **pkts,
 int pkt_cnt, bool should_steal)
@@ -4757,6 +4787,10 @@ netdev_dpdk_queue_dump_done(const struct netdev *netdev 
OVS_UNUSED,
 
 struct egress_policer {
 struct qos_conf qos_conf;
+enum policer_type type;
+uint32_t kpkts_rate;
+uint32_t kpkts_burst;
+struct token_bucket egress_tb;
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm egress_meter;
 struct rte_meter_srtcm_profile egress_prof;
@@ -4776,10 +4810,11 @@ static int
 egress_policer_qos_construct(const struct smap *details,
  struct qos_conf **conf)
 {
+uint32_t kpkts_burst, kpkts_rate;
 struct egress_policer *policer;
 int err = 0;
 
-policer = xmalloc(sizeof *policer);
+policer = xcalloc(1, sizeof *policer);
 qos_conf_init(>qos_conf, _policer_ops);
 egress_policer_details_to_param(details, >app_srtcm_params);
 err = rte_meter_srtcm_profile_config(>egress_prof,
@@ -4787,15 +4822,32 @@ egress_policer_qos_construct(const struct smap *details,
 if (!err) {
 err = rte_meter_srtcm_config(>egress_meter,
  >egress_prof);
+if (!err) {
+policer->type |= POLICER_BPS;
+} else {
+VLOG_ERR("Could not create rte meter for egress policer");
+}
 }
 
-if (!err) {
-*conf = >qos_conf;
-} else {
-VLOG_ERR("Could not create rte meter for 

[ovs-dev] [PATCH v2 2/2] * netdev-dpdk: Add support for userspace port-based ingress packet-per-second policing.

2023-04-09 Thread miterv
From: Lin Huang 

OvS has supported packet-per-second policer which can be set at ingress and 
egress
side in kernel datapath. But the userspace datapath dosen't support for ingress 
and
egress packet-per-second policing now.

So, this patch add support for userspace ingress pps policing by using native 
ovs
token bucket library. Token bucket is accumulated by 'rate' tokens per 
millisecond
and store maxiumim tokens at 'burst' bucket size. One token in the bucket means
one packet (1 kpkts * millisecond) which will drop or pass by policer.

This patch reuse 'ingress_policing_kpkts_rate' and 
'ingress_policing_kpkts_burst'
options at interface table. Now userspace ingress policer supports setting
packet-per-second limits in addition to the previously configurable byte rate
settings.

Examples:
$ ovs-vsctl set interface dpdk0 ingress_policing_rate=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_burst=12300
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
$ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123

Add some unit tests for ingress packet-per-second policing.

Signed-off-by: Lin Huang 
---
 NEWS |   4 ++
 lib/netdev-dpdk.c|  99 +---
 tests/system-dpdk.at | 152 +++
 3 files changed, 230 insertions(+), 25 deletions(-)

diff --git a/NEWS b/NEWS
index c41c6adf6..53adbed82 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,10 @@ Post-v3.1.0
ovs-vsctl set port vhost-user0 qos=@newqos -- \
   --id=@newqos create qos type=egress-policer \
   other-config:kpkts_rate=123 other-config:kpkts_burst=123
+ * Added support for ingress packet-per-second policing.
+   Examples:
+   $ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_rate=123
+   $ ovs-vsctl set interface dpdk0 ingress_policing_kpkts_burst=123
 
 
 v3.1.0 - 16 Feb 2023
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 2fd8bc68d..ca0f22287 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -411,6 +411,8 @@ struct ingress_policer {
 struct rte_meter_srtcm_params app_srtcm_params;
 struct rte_meter_srtcm in_policer;
 struct rte_meter_srtcm_profile in_prof;
+struct token_bucket tb;
+enum policer_type type;
 rte_spinlock_t policer_lock;
 };
 
@@ -494,6 +496,9 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 );
@@ -1313,6 +1318,8 @@ common_construct(struct netdev *netdev, dpdk_port_t 
port_no,
 ovsrcu_init(>ingress_policer, NULL);
 dev->policer_rate = 0;
 dev->policer_burst = 0;
+dev->policer_kpkts_rate = 0;
+dev->policer_kpkts_burst = 0;
 
 netdev->n_rxq = 0;
 netdev->n_txq = 0;
@@ -2372,9 +2379,15 @@ ingress_policer_run(struct ingress_policer *policer, 
struct rte_mbuf **pkts,
 int cnt = 0;
 
 rte_spinlock_lock(>policer_lock);
-cnt = srtcm_policer_run_single_packet(>in_policer,
-  >in_prof,
-  pkts, pkt_cnt, should_steal);
+if (policer->type & POLICER_BPS) {
+cnt = srtcm_policer_run_single_packet(>in_policer,
+  >in_prof,
+  pkts, pkt_cnt, should_steal);
+}
+if (policer->type & POLICER_PKTPS) {
+cnt = pkts_policer_run_single_packet(>tb, pkts, pkt_cnt,
+ should_steal);
+}
 rte_spinlock_unlock(>policer_lock);
 
 return cnt;
@@ -3536,7 +3549,8 @@ netdev_dpdk_get_features(const struct netdev *netdev,
 }
 
 static struct ingress_policer *
-netdev_dpdk_policer_construct(uint32_t rate, uint32_t burst)
+netdev_dpdk_policer_construct(uint32_t rate, uint32_t burst,
+  uint32_t kpkts_rate, uint32_t kpkts_burst)
 {
 struct ingress_policer *policer = NULL;
 uint64_t rate_bytes;
@@ -3546,23 +3560,43 @@ netdev_dpdk_policer_construct(uint32_t rate, uint32_t 
burst)
 policer = xmalloc(sizeof *policer);
 rte_spinlock_init(>policer_lock);
 
-/* rte_meter requires bytes so convert kbits rate and burst to bytes. */
-rate_bytes = rate * 1000ULL / 8;
-burst_bytes = burst * 1000ULL / 8;
+if (rate) {
+/* rte_meter requires bytes so convert kbits rate and burst to bytes. 
*/
+rate_bytes = rate * 1000ULL / 8;
+burst_bytes = burst * 1000ULL / 8;
 
-policer->app_srtcm_params.cir = rate_bytes;
-policer->app_srtcm_params.cbs = burst_bytes;
-policer->app_srtcm_params.ebs = 0;
-err = rte_meter_srtcm_profile_config(>in_prof,
- >app_srtcm_params);
-if (!err) {
-err = rte_meter_srtcm_config(>in_policer,
- 

[ovs-dev] [PATCH v2 0/2] netdev-dpdk: Add support for userspace port-based packet-per-second policing.

2023-04-09 Thread miterv
From: Lin Huang 

v1->v2: delete duplicated code.

Lin Huang (2):
  * netdev-dpdk: Add support for userspace port-based egress
packet-per-second policing.
  * netdev-dpdk: Add support for userspace port-based ingress
packet-per-second policing.

 NEWS |  11 ++
 lib/netdev-dpdk.c| 189 ++--
 tests/system-dpdk.at | 286 +++
 vswitchd/vswitch.xml |  10 ++
 4 files changed, 459 insertions(+), 37 deletions(-)

-- 
2.31.1

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


[ovs-dev] [PATCH v1 2/2] netdev-dpdk: add netdev-dpdk ingress pkts policer.

2023-04-02 Thread miterv
From: Lin Huang 

add netdev-dpdk ingress pkts policer.

Signed-off-by: Lin Huang 
---
 lib/netdev-dpdk.c | 115 --
 1 file changed, 111 insertions(+), 4 deletions(-)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 6709c459c..b645b3907 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -411,6 +411,11 @@ struct ingress_policer {
 rte_spinlock_t policer_lock;
 };
 
+struct ingress_pkts_policer {
+struct token_bucket tb;
+rte_spinlock_t policer_lock;
+};
+
 enum dpdk_hw_ol_features {
 NETDEV_RX_CHECKSUM_OFFLOAD = 1 << 0,
 NETDEV_RX_HW_CRC_STRIP = 1 << 1,
@@ -491,6 +496,11 @@ struct netdev_dpdk {
 uint32_t policer_rate;
 uint32_t policer_burst;
 
+/* Ingress Pkts Policer */
+OVSRCU_TYPE(struct ingress_pkts_policer *) ingress_pkts_policer;
+uint32_t policer_kpkts_rate;
+uint32_t policer_kpkts_burst;
+
 /* Array of vhost rxq states, see vring_state_changed. */
 bool *vhost_rxq_enabled;
 );
@@ -567,6 +577,9 @@ int netdev_dpdk_get_vid(const struct netdev_dpdk *dev);
 struct ingress_policer *
 netdev_dpdk_get_ingress_policer(const struct netdev_dpdk *dev);
 
+struct ingress_pkts_policer *
+netdev_dpdk_get_ingress_pkts_policer(const struct netdev_dpdk *dev);
+
 static bool
 is_dpdk_class(const struct netdev_class *class)
 {
@@ -1308,8 +1321,11 @@ common_construct(struct netdev *netdev, dpdk_port_t 
port_no,
 ovsrcu_init(>qos_conf, NULL);
 
 ovsrcu_init(>ingress_policer, NULL);
+ovsrcu_init(>ingress_pkts_policer, NULL);
 dev->policer_rate = 0;
 dev->policer_burst = 0;
+dev->policer_kpkts_rate = 0;
+dev->policer_kpkts_burst = 0;
 
 netdev->n_rxq = 0;
 netdev->n_txq = 0;
@@ -1487,6 +1503,8 @@ common_destruct(struct netdev_dpdk *dev)
 ovs_list_remove(>list_node);
 free(ovsrcu_get_protected(struct ingress_policer *,
   >ingress_policer));
+free(ovsrcu_get_protected(struct ingress_pkts_policer *,
+  >ingress_pkts_policer));
 free(dev->sw_stats);
 ovs_mutex_destroy(>mutex);
 }
@@ -2377,6 +2395,20 @@ ingress_policer_run(struct ingress_policer *policer, 
struct rte_mbuf **pkts,
 return cnt;
 }
 
+static int
+ingress_pkts_policer_run(struct ingress_pkts_policer *policer,
+ struct rte_mbuf **pkts, int pkt_cnt, bool 
should_steal)
+{
+int cnt = 0;
+
+rte_spinlock_lock(>policer_lock);
+cnt = pkts_policer_run_single_packet(>tb, pkts, pkt_cnt,
+ should_steal);
+rte_spinlock_unlock(>policer_lock);
+
+return cnt;
+}
+
 static bool
 is_vhost_running(struct netdev_dpdk *dev)
 {
@@ -2392,6 +2424,8 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
 {
 struct netdev_dpdk *dev = netdev_dpdk_cast(rxq->netdev);
 struct ingress_policer *policer = netdev_dpdk_get_ingress_policer(dev);
+struct ingress_pkts_policer *pkts_policer =
+netdev_dpdk_get_ingress_pkts_policer(dev);
 uint16_t nb_rx = 0;
 uint16_t qos_drops = 0;
 int qid = rxq->queue_id * VIRTIO_QNUM + VIRTIO_TXQ;
@@ -2427,6 +2461,14 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq,
 qos_drops -= nb_rx;
 }
 
+if (pkts_policer) {
+qos_drops = nb_rx;
+nb_rx = ingress_pkts_policer_run(pkts_policer,
+ (struct rte_mbuf **) batch->packets,
+ nb_rx, true);
+qos_drops -= nb_rx;
+}
+
 if (OVS_UNLIKELY(qos_drops)) {
 rte_spinlock_lock(>stats_lock);
 dev->stats.rx_dropped += qos_drops;
@@ -2455,6 +2497,8 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct 
dp_packet_batch *batch,
 struct netdev_rxq_dpdk *rx = netdev_rxq_dpdk_cast(rxq);
 struct netdev_dpdk *dev = netdev_dpdk_cast(rxq->netdev);
 struct ingress_policer *policer = netdev_dpdk_get_ingress_policer(dev);
+struct ingress_pkts_policer *pkts_policer =
+netdev_dpdk_get_ingress_pkts_policer(dev);
 int nb_rx;
 int dropped = 0;
 
@@ -2477,6 +2521,14 @@ netdev_dpdk_rxq_recv(struct netdev_rxq *rxq, struct 
dp_packet_batch *batch,
 dropped -= nb_rx;
 }
 
+if (pkts_policer) {
+dropped = nb_rx;
+nb_rx = ingress_pkts_policer_run(pkts_policer,
+ (struct rte_mbuf **) batch->packets,
+ nb_rx, true);
+dropped -= nb_rx;
+}
+
 /* Update stats to reflect dropped packets */
 if (OVS_UNLIKELY(dropped)) {
 rte_spinlock_lock(>stats_lock);
@@ -3565,14 +3617,28 @@ netdev_dpdk_policer_construct(uint32_t rate, uint32_t 
burst)
 return policer;
 }
 
+static struct ingress_pkts_policer *
+netdev_dpdk_pkts_policer_construct(uint32_t kpkts_rate, uint32_t kpkts_burst)
+{
+struct ingress_pkts_policer *pkts_policer;

[ovs-dev] [PATCH v1 1/2] netdev-dpdk: add netdev-dpdk egress pkts policer.

2023-04-02 Thread miterv
From: Lin Huang 

add netdev-dpdk egress pkts policer.

Signed-off-by: Lin Huang 
---
 lib/netdev-dpdk.c| 118 +++
 vswitchd/vswitch.xml |  32 
 2 files changed, 150 insertions(+)

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index fb0dd43f7..6709c459c 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -59,6 +60,7 @@
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/shash.h"
+#include "openvswitch/token-bucket.h"
 #include "openvswitch/vlog.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
@@ -345,6 +347,7 @@ struct dpdk_qos_ops {
 
 /* dpdk_qos_ops for each type of user space QoS implementation. */
 static const struct dpdk_qos_ops egress_policer_ops;
+static const struct dpdk_qos_ops egress_pkts_policer_ops;
 static const struct dpdk_qos_ops trtcm_policer_ops;
 
 /*
@@ -353,6 +356,7 @@ static const struct dpdk_qos_ops trtcm_policer_ops;
  */
 static const struct dpdk_qos_ops *const qos_confs[] = {
 _policer_ops,
+_pkts_policer_ops,
 _policer_ops,
 NULL
 };
@@ -2335,6 +2339,29 @@ srtcm_policer_run_single_packet(struct rte_meter_srtcm 
*meter,
 return cnt;
 }
 
+static int
+pkts_policer_run_single_packet(struct token_bucket *tb, struct rte_mbuf **pkts,
+   int pkt_cnt, bool should_steal)
+{
+int cnt = 0;
+struct rte_mbuf *pkt;
+
+for (int i = 0; i < pkt_cnt; i++) {
+pkt = pkts[i];
+/* Handle current packet */
+if (token_bucket_withdraw(tb, 1000)) {
+if (cnt != i) {
+pkts[cnt] = pkt;
+}
+cnt++;
+} else if (should_steal) {
+rte_pktmbuf_free(pkt);
+}
+}
+
+return cnt;
+}
+
 static int
 ingress_policer_run(struct ingress_policer *policer, struct rte_mbuf **pkts,
 int pkt_cnt, bool should_steal)
@@ -4858,6 +4885,97 @@ static const struct dpdk_qos_ops egress_policer_ops = {
 .qos_run = egress_policer_run
 };
 
+/* egress-pkts-policer details */
+
+struct egress_pkts_policer {
+struct qos_conf qos_conf;
+struct token_bucket tb;
+};
+
+static int
+egress_pkts_policer_qos_construct(const struct smap *details,
+  struct qos_conf **conf)
+{
+uint32_t rate, burst;
+struct egress_pkts_policer *policer;
+
+policer = xmalloc(sizeof *policer);
+rate  = smap_get_uint(details, "pkts_rate", 0);
+burst = smap_get_uint(details, "pkts_burst", 0);
+
+/*
+ * Force to 0 if no rate specified,
+ * default to rate if burst is 0,
+ * else stick with user-specified value.
+ */
+burst = (!rate ? 0 : !burst ? rate : burst);
+
+qos_conf_init(>qos_conf, _pkts_policer_ops);
+token_bucket_init(>tb, rate, burst * 1000);
+
+*conf = >qos_conf;
+
+return 0;
+}
+
+static void
+egress_pkts_policer_qos_destruct(struct qos_conf *conf)
+{
+struct egress_pkts_policer *policer =
+CONTAINER_OF(conf, struct egress_pkts_policer, qos_conf);
+
+free(policer);
+}
+
+static int
+egress_pkts_policer_qos_get(const struct qos_conf *conf, struct smap *details)
+{
+struct egress_pkts_policer *policer =
+CONTAINER_OF(conf, struct egress_pkts_policer, qos_conf);
+
+smap_add_format(details, "pkts_rate", "%"PRIu32, policer->tb.rate);
+smap_add_format(details, "pkts_burst", "%"PRIu32, policer->tb.burst);
+
+return 0;
+}
+
+static bool
+egress_pkts_policer_qos_is_equal(const struct qos_conf *conf,
+ const struct smap *details)
+{
+uint32_t rate, burst;
+struct egress_pkts_policer *policer =
+CONTAINER_OF(conf, struct egress_pkts_policer, qos_conf);
+
+rate  = smap_get_uint(details, "pkts_rate", 0);
+burst = smap_get_uint(details, "pkts_burst", 0);
+
+return (policer->tb.rate == rate && policer->tb.burst == burst);
+}
+
+static int
+egress_pkts_policer_run(struct qos_conf *conf, struct rte_mbuf **pkts,
+int pkt_cnt, bool should_steal)
+{
+int cnt = 0;
+struct egress_pkts_policer *policer =
+CONTAINER_OF(conf, struct egress_pkts_policer, qos_conf);
+
+cnt = pkts_policer_run_single_packet(>tb, pkts, pkt_cnt,
+ should_steal);
+
+return cnt;
+}
+
+static const struct dpdk_qos_ops egress_pkts_policer_ops = {
+.qos_name = "egress-pkts-policer",
+.qos_construct = egress_pkts_policer_qos_construct,
+.qos_destruct = egress_pkts_policer_qos_destruct,
+.qos_get = egress_pkts_policer_qos_get,
+.qos_is_equal = egress_pkts_policer_qos_is_equal,
+.qos_run = egress_pkts_policer_run
+};
+
 /* trtcm-policer details */
 
 struct trtcm_policer {
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index edb5eafa0..94bfe54eb 100644
--- a/vswitchd/vswitch.xml
+++ 

[ovs-dev] [PATCH v1 0/2] Add netdev-dpdk support for ingress and egress pkts policer.

2023-04-02 Thread miterv
From: Lin Huang 

This series patch set adds ingress and egress pkts policer support for 
netdev-dpdk
device.

Lin Huang (2):
  netdev-dpdk: add netdev-dpdk egress pkts policer.
  netdev-dpdk: add netdev-dpdk ingress pkts policer.

 lib/netdev-dpdk.c| 233 ++-
 vswitchd/vswitch.xml |  32 ++
 2 files changed, 261 insertions(+), 4 deletions(-)

-- 
2.37.1.windows.1

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


[ovs-dev] [PATCH v2] conntrack-tp: Fix clang warning.

2023-03-30 Thread miterv
From: Lin Huang 

Declaration of 'struct conn' will not be visible outside of this function.
Declaration of 'struct conntrack' will not be visible outside of this function.
Declaration of 'struct timeout_policy' will not be visible outside of this 
function.
---
 lib/conntrack-tp.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/lib/conntrack-tp.h b/lib/conntrack-tp.h
index 4d411d19f..7ece2eae2 100644
--- a/lib/conntrack-tp.h
+++ b/lib/conntrack-tp.h
@@ -17,8 +17,15 @@
 #ifndef CONNTRACK_TP_H
 #define CONNTRACK_TP_H 1
 
+#include 
+
 #define CT_DPIF_NETDEV_TP_MIN 30
+
 enum ct_timeout;
+struct conn;
+struct conntrack;
+struct timeout_policy;
+
 void timeout_policy_init(struct conntrack *ct);
 int timeout_policy_update(struct conntrack *ct, struct timeout_policy *tp);
 int timeout_policy_delete(struct conntrack *ct, uint32_t tp_id);
-- 
2.32.0.windows.2

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


[ovs-dev] [PATCH] conntrack-tp: Fix clang warning.

2023-03-30 Thread miterv
From: Lin Huang 

Declaration of 'struct conn' will not be visible outside of this function.
Declaration of 'struct conntrack' will not be visible outside of this function.
Declaration of 'struct timeout_policy' will not be visible outside of this 
function.

Signed-off-by: Lin Huang 
---
 lib/conntrack-tp.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lib/conntrack-tp.h b/lib/conntrack-tp.h
index 4d411d19f..2227f6fa5 100644
--- a/lib/conntrack-tp.h
+++ b/lib/conntrack-tp.h
@@ -17,8 +17,13 @@
 #ifndef CONNTRACK_TP_H
 #define CONNTRACK_TP_H 1
 
+#include 
+
 #define CT_DPIF_NETDEV_TP_MIN 30
 enum ct_timeout;
+struct conn;
+struct conntrack;
+struct timeout_policy;
 void timeout_policy_init(struct conntrack *ct);
 int timeout_policy_update(struct conntrack *ct, struct timeout_policy *tp);
 int timeout_policy_delete(struct conntrack *ct, uint32_t tp_id);
-- 
2.37.1.windows.1

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


[ovs-dev] [PATCH v2 1/1] mac-learning: Fix learned fdb entries not age out issue.

2022-10-22 Thread miterv
From: Lin Huang 

After user add a static fdb entry, the get_lru() function will always return
the static fdb entry. That's normal fdb entries will not age out through 
mac_learning_run().

Fix the issue by modify the get_lru() function to check the entry->expires 
field and
not return the entry which entry->expires is MAC_ENTRY_AGE_STATIC_ENTRY.

Adding a unit test for this.

Fixes: ccc24fc88d59 ("ofproto-dpif: APIs and CLI option to add/delete static 
fdb entry.")
Tested-by: Zhang Yuhuang 
Signed-off-by: Lin Huang 
---
 lib/mac-learning.c| 37 ++---
 tests/ofproto-dpif.at | 23 +++
 2 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/lib/mac-learning.c b/lib/mac-learning.c
index a60794fb2..5932e2709 100644
--- a/lib/mac-learning.c
+++ b/lib/mac-learning.c
@@ -176,12 +176,18 @@ get_lru(struct mac_learning *ml, struct mac_entry **e)
 OVS_REQ_RDLOCK(ml->rwlock)
 {
 if (!ovs_list_is_empty(>lrus)) {
-*e = mac_entry_from_lru_node(ml->lrus.next);
-return true;
-} else {
-*e = NULL;
-return false;
+struct mac_entry *entry;
+
+LIST_FOR_EACH (entry, lru_node, >lrus) {
+if (entry->expires != MAC_ENTRY_AGE_STATIC_ENTRY) {
+*e = entry;
+return true;
+}
+}
 }
+
+*e = NULL;
+return false;
 }
 
 static unsigned int
@@ -618,25 +624,10 @@ mac_learning_expire(struct mac_learning *ml, struct 
mac_entry *e)
 void
 mac_learning_flush(struct mac_learning *ml)
 {
-struct mac_entry *e, *first_static_mac = NULL;
-
-while (get_lru(ml, ) && (e != first_static_mac)) {
-
-/* Static mac should not be evicted. */
-if (MAC_ENTRY_AGE_STATIC_ENTRY == e->expires) {
-
-/* Make note of first static-mac encountered, so that this while
- * loop will break on visting this mac again via get_lru(). */
-if (!first_static_mac) {
-first_static_mac = e;
-}
+struct mac_entry *e;
 
-/* Remove from lru head and append it to tail. */
-ovs_list_remove(>lru_node);
-ovs_list_push_back(>lrus, >lru_node);
-} else {
-mac_learning_expire(ml, e);
-}
+while (get_lru(ml, )) {
+mac_learning_expire(ml, e);
 }
 hmap_shrink(>table);
 }
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index 8e993c585..eb4cd1896 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -7287,6 +7287,29 @@ AT_CHECK([ovs-appctl coverage/read-counter 
mac_learning_static_none_move], [0],
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([ofproto-dpif - static-mac learned mac age out])
+OVS_VSWITCHD_START([set bridge br0 fail-mode=standalone -- set bridge br0 
other_config:mac-aging-time=5])
+add_of_ports br0 1 2
+
+dnl Add some static mac entries.
+AT_CHECK([ovs-appctl fdb/add br0 p1 0 50:54:00:00:01:01])
+AT_CHECK([ovs-appctl fdb/add br0 p2 0 50:54:00:00:02:02])
+
+dnl Generate some dynamic fdb entries on some ports.
+OFPROTO_TRACE([ovs-dummy], [in_port(1),eth(src=60:54:00:00:00:01)], 
[-generate], [100,2])
+OFPROTO_TRACE([ovs-dummy], [in_port(2),eth(src=60:54:00:00:00:02)], 
[-generate], [100,1])
+
+dnl Waiting for aging out.
+ovs-appctl time/warp 2
+
+dnl Count number of static entries remaining.
+AT_CHECK_UNQUOTED([ovs-appctl fdb/stats-show br0 | grep expired], [0], [dnl
+  Total number of expired MAC entries : 2
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
 AT_SETUP([ofproto-dpif - basic truncate action])
 OVS_VSWITCHD_START
 add_of_ports br0 1 2 3 4 5
-- 
2.37.1

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


[ovs-dev] [PATCH v2 0/1] mac-learning: Fix learned fdb entries not age out issue.

2022-10-22 Thread miterv
From: Lin Huang 

Changes since v1:
1. Revised according to the suggestions and comments of the reviewers


Lin Huang (1):
  mac-learning: Fix learned fdb entries not age out issue.

 lib/mac-learning.c| 37 ++---
 tests/ofproto-dpif.at | 23 +++
 2 files changed, 37 insertions(+), 23 deletions(-)

-- 
2.37.1

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


[ovs-dev] [PATCH] mac-learning: Fix learned fdb entries not age out issue.

2022-10-20 Thread miterv
From: Lin Huang 

After user add a static fdb entry, the get_lru() function will always return
the static fdb entry. That's normal fdb entries will not age out through 
mac_learning_run().

Fix the issue by modify the get_lru() function to check the entry->expires 
field and
not return the entry which entry->expires is MAC_ENTRY_AGE_STATIC_ENTRY.

Adding a unit test for this.

Fixes: ccc24fc88d59 ("ofproto-dpif: APIs and CLI option to add/delete static 
fdb entry.")
Tested-by: Zhang Yuhuang 
Signed-off-by: Lin Huang 
---
 lib/mac-learning.c| 36 +---
 tests/ofproto-dpif.at | 23 +++
 2 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/lib/mac-learning.c b/lib/mac-learning.c
index a60794fb2..e8ead51af 100644
--- a/lib/mac-learning.c
+++ b/lib/mac-learning.c
@@ -176,12 +176,17 @@ get_lru(struct mac_learning *ml, struct mac_entry **e)
 OVS_REQ_RDLOCK(ml->rwlock)
 {
 if (!ovs_list_is_empty(>lrus)) {
-*e = mac_entry_from_lru_node(ml->lrus.next);
-return true;
-} else {
-*e = NULL;
-return false;
+struct mac_entry *entry;
+LIST_FOR_EACH (entry, lru_node, >lrus) {
+if (entry->expires != MAC_ENTRY_AGE_STATIC_ENTRY) {
+*e = entry;
+return true;
+}
+}
 }
+
+*e = NULL;
+return false;
 }
 
 static unsigned int
@@ -618,25 +623,10 @@ mac_learning_expire(struct mac_learning *ml, struct 
mac_entry *e)
 void
 mac_learning_flush(struct mac_learning *ml)
 {
-struct mac_entry *e, *first_static_mac = NULL;
-
-while (get_lru(ml, ) && (e != first_static_mac)) {
-
-/* Static mac should not be evicted. */
-if (MAC_ENTRY_AGE_STATIC_ENTRY == e->expires) {
-
-/* Make note of first static-mac encountered, so that this while
- * loop will break on visting this mac again via get_lru(). */
-if (!first_static_mac) {
-first_static_mac = e;
-}
+struct mac_entry *e;
 
-/* Remove from lru head and append it to tail. */
-ovs_list_remove(>lru_node);
-ovs_list_push_back(>lrus, >lru_node);
-} else {
-mac_learning_expire(ml, e);
-}
+while (get_lru(ml, )) {
+mac_learning_expire(ml, e);
 }
 hmap_shrink(>table);
 }
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index 8e993c585..eb4cd1896 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -7287,6 +7287,29 @@ AT_CHECK([ovs-appctl coverage/read-counter 
mac_learning_static_none_move], [0],
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([ofproto-dpif - static-mac learned mac age out])
+OVS_VSWITCHD_START([set bridge br0 fail-mode=standalone -- set bridge br0 
other_config:mac-aging-time=5])
+add_of_ports br0 1 2
+
+dnl Add some static mac entries.
+AT_CHECK([ovs-appctl fdb/add br0 p1 0 50:54:00:00:01:01])
+AT_CHECK([ovs-appctl fdb/add br0 p2 0 50:54:00:00:02:02])
+
+dnl Generate some dynamic fdb entries on some ports.
+OFPROTO_TRACE([ovs-dummy], [in_port(1),eth(src=60:54:00:00:00:01)], 
[-generate], [100,2])
+OFPROTO_TRACE([ovs-dummy], [in_port(2),eth(src=60:54:00:00:00:02)], 
[-generate], [100,1])
+
+dnl Waiting for aging out.
+ovs-appctl time/warp 2
+
+dnl Count number of static entries remaining.
+AT_CHECK_UNQUOTED([ovs-appctl fdb/stats-show br0 | grep expired], [0], [dnl
+  Total number of expired MAC entries : 2
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
 AT_SETUP([ofproto-dpif - basic truncate action])
 OVS_VSWITCHD_START
 add_of_ports br0 1 2 3 4 5
-- 
2.27.0

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


[ovs-dev] [PATCH v1] ovs-tcpdump: Fix bond port unable to capture jumbo frames.

2022-10-06 Thread miterv
From: Lin Huang 

Currently the ovs-tcpdump utility creates a tap port to capture the
frames of a bond port.

If a user want to capture the packets from the bond port which member
interface's mtu is more than 1500. By default the utility creates a
tap port which mtu is 1500, regardless the member interface's mtu config.
So that user cann't get the bond port frames which mtu is lager than 1500.

This patch fix this issiue by checking the member interface's mtu and
set maximal mtu value to the tap port.

Signed-off-by: Lin Huang 
---
 utilities/ovs-tcpdump.in | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in
index 7fd26e405..e12bab889 100755
--- a/utilities/ovs-tcpdump.in
+++ b/utilities/ovs-tcpdump.in
@@ -225,6 +225,13 @@ class OVSDB(object):
 def interface_mtu(self, intf_name):
 try:
 intf = self._find_row_by_name('Interface', intf_name)
+if intf is None:
+mtu = 1500
+port = self._find_row_by_name('Port', intf_name)
+for intf in port.interfaces:
+if mtu < intf.mtu[0]:
+mtu = intf.mtu[0]
+return mtu
 return intf.mtu[0]
 except Exception:
 return None
-- 
2.37.1.windows.1

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


[ovs-dev] [PATCH] ovs-tcpdump: Fix bond port unable to capture jumbo frames.

2022-10-05 Thread miterv
From: Lin Huang 

Currently the ovs-tcpdump utility creates a tap port to capture the
frames of a bond port.

If a user want to capture the packets from the bond port which member
interface's mtu is more than 1500. By default the utility creates a
tap port which mtu is 1500, regardless the member interface's mtu config.
So that user cann't get the bond port frames which mtu is lager than 1500.

This patch fix this issiue by checking the member interface's mtu and
set minimal mtu value to the tap port.

Signed-off-by: Lin Huang 
---
 utilities/ovs-tcpdump.in | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in
index 7fd26e405..d2b86d586 100755
--- a/utilities/ovs-tcpdump.in
+++ b/utilities/ovs-tcpdump.in
@@ -225,6 +225,13 @@ class OVSDB(object):
 def interface_mtu(self, intf_name):
 try:
 intf = self._find_row_by_name('Interface', intf_name)
+if intf is None:
+mtu = 1500
+port = self._find_row_by_name('Port', intf_name)
+for intf in port.interfaces:
+if mtu > intf.mtu[0]:
+mtu = intf.mtu[0]
+return mtu
 return intf.mtu[0]
 except Exception:
 return None
-- 
2.37.1.windows.1

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


[ovs-dev] [PATCH] mac-learning: Fix learned fdb entries are not age out issue.

2022-07-29 Thread miterv
From: Lin Huang 

After user add a static fdb entry, the get_lru() function will always return the
static fdb entry. That's normal fdb entries will not age out through 
mac_learning_run().

Fix the issue by modify the get_lru() function to check the entry->expires 
field and
not return the entry which entry->expires is MAC_ENTRY_AGE_STATIC_ENTRY.

Adding a unit test for this.

Fixes: ccc24fc88d59 ("ofproto-dpif: APIs and CLI option to add/delete static 
fdb entry.")
Tested-by: Zhang Yuhuang 
Signed-off-by: Lin Huang 
---
 lib/mac-learning.c| 37 ++---
 tests/ofproto-dpif.at | 23 +++
 2 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/lib/mac-learning.c b/lib/mac-learning.c
index a60794fb2..713f81e63 100644
--- a/lib/mac-learning.c
+++ b/lib/mac-learning.c
@@ -175,13 +175,19 @@ static bool
 get_lru(struct mac_learning *ml, struct mac_entry **e)
 OVS_REQ_RDLOCK(ml->rwlock)
 {
+struct mac_entry *entry;
+
 if (!ovs_list_is_empty(>lrus)) {
-*e = mac_entry_from_lru_node(ml->lrus.next);
-return true;
-} else {
-*e = NULL;
-return false;
+LIST_FOR_EACH (entry, lru_node, >lrus) {
+if (entry->expires != MAC_ENTRY_AGE_STATIC_ENTRY) {
+*e = entry;
+return true;
+}
+}
 }
+
+*e = NULL;
+return false;
 }
 
 static unsigned int
@@ -618,25 +624,10 @@ mac_learning_expire(struct mac_learning *ml, struct 
mac_entry *e)
 void
 mac_learning_flush(struct mac_learning *ml)
 {
-struct mac_entry *e, *first_static_mac = NULL;
-
-while (get_lru(ml, ) && (e != first_static_mac)) {
-
-/* Static mac should not be evicted. */
-if (MAC_ENTRY_AGE_STATIC_ENTRY == e->expires) {
-
-/* Make note of first static-mac encountered, so that this while
- * loop will break on visting this mac again via get_lru(). */
-if (!first_static_mac) {
-first_static_mac = e;
-}
+struct mac_entry *e;
 
-/* Remove from lru head and append it to tail. */
-ovs_list_remove(>lru_node);
-ovs_list_push_back(>lrus, >lru_node);
-} else {
-mac_learning_expire(ml, e);
-}
+while (get_lru(ml, )) {
+mac_learning_expire(ml, e);
 }
 hmap_shrink(>table);
 }
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index 2e91ae1a1..4b455315d 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -7195,6 +7195,29 @@ AT_CHECK([ovs-appctl coverage/read-counter 
mac_learning_static_none_move], [0],
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([ofproto-dpif - static-mac learned mac age out])
+OVS_VSWITCHD_START([set bridge br0 fail-mode=standalone -- set bridge br0 
other_config:mac-aging-time=5])
+add_of_ports br0 1 2
+
+dnl Add some static mac entries.
+AT_CHECK([ovs-appctl fdb/add br0 p1 0 50:54:00:00:01:01])
+AT_CHECK([ovs-appctl fdb/add br0 p2 0 50:54:00:00:02:02])
+
+dnl Generate some dynamic fdb entries on some ports.
+OFPROTO_TRACE([ovs-dummy], [in_port(1),eth(src=50:54:00:00:00:01)], 
[-generate], [100,2])
+OFPROTO_TRACE([ovs-dummy], [in_port(2),eth(src=50:54:00:00:00:02)], 
[-generate], [100,1])
+
+dnl Waiting for aging out.
+sleep 16
+
+dnl Count number of static entries remaining.
+AT_CHECK_UNQUOTED([ovs-appctl fdb/stats-show br0 | grep expired], [0], [dnl
+  Total number of expired MAC entries : 2
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP
+
 AT_SETUP([ofproto-dpif - basic truncate action])
 OVS_VSWITCHD_START
 add_of_ports br0 1 2 3 4 5
-- 
2.32.0.windows.2

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


[ovs-dev] [PATCH 2/2] dpif-netdev: Fix ALB 'rebalance_intvl' max hard limit.

2022-05-24 Thread miterv
From: Lin Huang 

Currently the pmd-auto-lb-rebal-interval's value was not been
checked properly.

It maybe a negative, or too big value (>2 weeks between rebalances),
which will be lead to a big unsigned value. So reset it to default
if the value exceeds the max permitted as described in vswitchd.xml.

Fixes: 5bf84282482a ("Adding support for PMD auto load balancing")
Signed-off-by: Lin Huang 
---
 lib/dpif-netdev.c |  6 +-
 tests/alb.at  | 20 +++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 95b154185..a69b570f6 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -93,7 +93,8 @@ VLOG_DEFINE_THIS_MODULE(dpif_netdev);
 /* Auto Load Balancing Defaults */
 #define ALB_IMPROVEMENT_THRESHOLD25
 #define ALB_LOAD_THRESHOLD   95
-#define ALB_REBALANCE_INTERVAL   1 /* 1 Min */
+#define ALB_REBALANCE_INTERVAL   1 /* 1 Min */
+#define MAX_ALB_REBALANCE_INTERVAL   2 /* 2 Min */
 #define MIN_TO_MSEC  6
 
 #define FLOW_DUMP_MAX_BATCH 50
@@ -4883,6 +4884,9 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 rebalance_intvl = smap_get_ullong(other_config,
   "pmd-auto-lb-rebal-interval",
   ALB_REBALANCE_INTERVAL);
+if (rebalance_intvl > MAX_ALB_REBALANCE_INTERVAL) {
+rebalance_intvl = ALB_REBALANCE_INTERVAL;
+}
 
 /* Input is in min, convert it to msec. */
 rebalance_intvl =
diff --git a/tests/alb.at b/tests/alb.at
index 0036bd1f2..922185d61 100644
--- a/tests/alb.at
+++ b/tests/alb.at
@@ -243,7 +243,25 @@ get_log_next_line_num
 AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="0"])
 CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
 
-# No check for above max as it is only a documented max value and not a hard 
limit
+# Set new value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="100"])
+CHECK_ALB_PARAM([interval], [100 mins], [+$LINENUM])
+
+# Set above max value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="20001"])
+CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
+
+# Set new value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="1000"])
+CHECK_ALB_PARAM([interval], [1000 mins], [+$LINENUM])
+
+# Set Negative value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="-1"])
+CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
-- 
2.36.1

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


[ovs-dev] [PATCH 1/2] dpif-netdev: Fix ALB parameters type mismatch.

2022-05-24 Thread miterv
From: Lin Huang 

The ALB parameters should never be negative.
So it's to use unsigned smap_get versions to get it properly, and
update VLOG formatting.

Fixes: 5bf84282482a ("Adding support for PMD auto load balancing")
Signed-off-by: Lin Huang 
---
 lib/dpif-netdev.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 21277b236..95b154185 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -4778,8 +4778,8 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 uint32_t insert_min, cur_min;
 uint32_t tx_flush_interval, cur_tx_flush_interval;
 uint64_t rebalance_intvl;
-uint8_t rebalance_load, cur_rebalance_load;
-uint8_t rebalance_improve;
+uint8_t cur_rebalance_load;
+uint32_t rebalance_load, rebalance_improve;
 bool log_autolb = false;
 enum sched_assignment_type pmd_rxq_assign_type;
 
@@ -4880,8 +4880,9 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 
 struct pmd_auto_lb *pmd_alb = >pmd_alb;
 
-rebalance_intvl = smap_get_int(other_config, "pmd-auto-lb-rebal-interval",
-   ALB_REBALANCE_INTERVAL);
+rebalance_intvl = smap_get_ullong(other_config,
+  "pmd-auto-lb-rebal-interval",
+  ALB_REBALANCE_INTERVAL);
 
 /* Input is in min, convert it to msec. */
 rebalance_intvl =
@@ -4894,21 +4895,21 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 log_autolb = true;
 }
 
-rebalance_improve = smap_get_int(other_config,
- "pmd-auto-lb-improvement-threshold",
- ALB_IMPROVEMENT_THRESHOLD);
+rebalance_improve = smap_get_uint(other_config,
+  "pmd-auto-lb-improvement-threshold",
+  ALB_IMPROVEMENT_THRESHOLD);
 if (rebalance_improve > 100) {
 rebalance_improve = ALB_IMPROVEMENT_THRESHOLD;
 }
 if (rebalance_improve != pmd_alb->rebalance_improve_thresh) {
 pmd_alb->rebalance_improve_thresh = rebalance_improve;
 VLOG_INFO("PMD auto load balance improvement threshold set to "
-  "%"PRIu8"%%", rebalance_improve);
+  "%"PRIu32"%%", rebalance_improve);
 log_autolb = true;
 }
 
-rebalance_load = smap_get_int(other_config, "pmd-auto-lb-load-threshold",
-  ALB_LOAD_THRESHOLD);
+rebalance_load = smap_get_uint(other_config, "pmd-auto-lb-load-threshold",
+   ALB_LOAD_THRESHOLD);
 if (rebalance_load > 100) {
 rebalance_load = ALB_LOAD_THRESHOLD;
 }
@@ -4916,7 +4917,7 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 if (rebalance_load != cur_rebalance_load) {
 atomic_store_relaxed(_alb->rebalance_load_thresh,
  rebalance_load);
-VLOG_INFO("PMD auto load balance load threshold set to %"PRIu8"%%",
+VLOG_INFO("PMD auto load balance load threshold set to %"PRIu32"%%",
   rebalance_load);
 log_autolb = true;
 }
-- 
2.36.1

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


[ovs-dev] [PATCH v5 0/2] Fix ALB parameters type and value mismatch.

2022-05-24 Thread miterv
From: Lin Huang 

This series fix ALB parameters type mismatch and set a hard limit
to rebalance_intvl.

It also includes some self-tests.

Changes since v3:
1. Fix CI warnings

Changes since v2:
   1. Fix type mismatch int dpif-netdev.c.

Changes since v1:
1. Fix the commit message and formatting.
2. Fix typo in unit tests.

Lin Huang (2):
  dpif-netdev: Fix ALB parameters type mismatch.
  dpif-netdev: Fix ALB 'rebalance_intvl' max hard limit.

 lib/dpif-netdev.c | 29 +
 tests/alb.at  | 20 +++-
 2 files changed, 36 insertions(+), 13 deletions(-)

-- 
2.36.1

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


[ovs-dev] [PATCH] ofp-msgs: Fix comment typo.

2022-05-24 Thread miterv
From: Lin Huang 

Fix comment typo.

Signed-off-by: Lin Huang 
---
 lib/ofp-msgs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c
index 93aa81297..fdb898064 100644
--- a/lib/ofp-msgs.c
+++ b/lib/ofp-msgs.c
@@ -148,7 +148,7 @@ struct raw_instance {
 /* Information about a particular 'enum ofpraw'. */
 struct raw_info {
 /* All possible instantiations of this OFPRAW_* into OpenFlow headers. */
-struct raw_instance *instances; /* min_version - max_version + 1 elems. */
+struct raw_instance *instances; /* max_version - min_version + 1 elems. */
 uint8_t min_version;
 uint8_t max_version;
 
-- 
2.27.0

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


[ovs-dev] [PATCH v4 1/2] dpif-netdev : Fix ALB parameters type mismatch.

2022-05-18 Thread miterv
From: Lin Huang 

The ALB parameters should never be negative.
So it's to use smap_get_ulonglong() or smap_get_uint() to get it properly.

Fixes: 5bf84282482a ("Adding support for PMD auto load balancing")
Signed-off-by: Lin Huang 
---
 lib/dpif-netdev.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 21277b236..3597d7e40 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -4880,8 +4880,9 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 
 struct pmd_auto_lb *pmd_alb = >pmd_alb;
 
-rebalance_intvl = smap_get_int(other_config, "pmd-auto-lb-rebal-interval",
-   ALB_REBALANCE_INTERVAL);
+rebalance_intvl = smap_get_ullong(other_config,
+  "pmd-auto-lb-rebal-interval",
+  ALB_REBALANCE_INTERVAL);
 
 /* Input is in min, convert it to msec. */
 rebalance_intvl =
@@ -4894,9 +4895,9 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 log_autolb = true;
 }
 
-rebalance_improve = smap_get_int(other_config,
- "pmd-auto-lb-improvement-threshold",
- ALB_IMPROVEMENT_THRESHOLD);
+rebalance_improve = smap_get_uint(other_config,
+  "pmd-auto-lb-improvement-threshold",
+  ALB_IMPROVEMENT_THRESHOLD);
 if (rebalance_improve > 100) {
 rebalance_improve = ALB_IMPROVEMENT_THRESHOLD;
 }
@@ -4907,8 +4908,8 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 log_autolb = true;
 }
 
-rebalance_load = smap_get_int(other_config, "pmd-auto-lb-load-threshold",
-  ALB_LOAD_THRESHOLD);
+rebalance_load = smap_get_uint(other_config, "pmd-auto-lb-load-threshold",
+   ALB_LOAD_THRESHOLD);
 if (rebalance_load > 100) {
 rebalance_load = ALB_LOAD_THRESHOLD;
 }
-- 
2.36.1

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


[ovs-dev] [PATCH v4 2/2] dpif-netdev : Fix ALB 'rebalance_intvl' max hard limit.

2022-05-18 Thread miterv
From: Lin Huang 

Currently the pmd-auto-lb-rebal-interval's value was not been
checked properly.
It maybe a negative, or too big value (>2 weeks between rebalances),
which will be lead to a big unsigned value. So reset it to default
if the value exceeds the max permitted as described in vswitchd.xml.

Fixes: 5bf84282482a ("Adding support for PMD auto load balancing")
Signed-off-by: Lin Huang 
---
 lib/dpif-netdev.c |  6 +-
 tests/alb.at  | 20 +++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 3597d7e40..33fb8ad81 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -93,7 +93,8 @@ VLOG_DEFINE_THIS_MODULE(dpif_netdev);
 /* Auto Load Balancing Defaults */
 #define ALB_IMPROVEMENT_THRESHOLD25
 #define ALB_LOAD_THRESHOLD   95
-#define ALB_REBALANCE_INTERVAL   1 /* 1 Min */
+#define ALB_REBALANCE_INTERVAL   1 /* 1 Min */
+#define MAX_ALB_REBALANCE_INTERVAL   2 /* 2 Min */
 #define MIN_TO_MSEC  6
 
 #define FLOW_DUMP_MAX_BATCH 50
@@ -4883,6 +4884,9 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 rebalance_intvl = smap_get_ullong(other_config,
   "pmd-auto-lb-rebal-interval",
   ALB_REBALANCE_INTERVAL);
+if (rebalance_intvl > MAX_ALB_REBALANCE_INTERVAL) {
+rebalance_intvl = ALB_REBALANCE_INTERVAL;
+}
 
 /* Input is in min, convert it to msec. */
 rebalance_intvl =
diff --git a/tests/alb.at b/tests/alb.at
index 0036bd1f2..922185d61 100644
--- a/tests/alb.at
+++ b/tests/alb.at
@@ -243,7 +243,25 @@ get_log_next_line_num
 AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="0"])
 CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
 
-# No check for above max as it is only a documented max value and not a hard 
limit
+# Set new value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="100"])
+CHECK_ALB_PARAM([interval], [100 mins], [+$LINENUM])
+
+# Set above max value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="20001"])
+CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
+
+# Set new value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="1000"])
+CHECK_ALB_PARAM([interval], [1000 mins], [+$LINENUM])
+
+# Set Negative value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="-1"])
+CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
-- 
2.36.1

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


[ovs-dev] [PATCH v4 0/2] Fix ALB parameters type and value mismatch.

2022-05-18 Thread miterv
From: Lin Huang 

This series fix ALB parameters type mismatch and set a hard limit
to rebalance_intvl.

It also includes some self-tests.

Changes since v3:
1. Fix CI warnings

Changes since v2:
   1. Fix type mismatch int dpif-netdev.c.

Changes since v1:
1. Fix the commit message and formatting.
2. Fix typo in unit tests.

Lin Huang (2):
  dpif-netdev : Fix ALB parameters type mismatch.
  dpif-netdev : Fix ALB 'rebalance_intvl' max hard limit.

 lib/dpif-netdev.c | 21 +
 tests/alb.at  | 20 +++-
 2 files changed, 32 insertions(+), 9 deletions(-)

-- 
2.36.1

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


[ovs-dev] [PATCH v3 2/2] dpif-netdev : Fix ALB 'rebalance_intvl' max hard limit.

2022-05-15 Thread miterv
From: linhuang 

Currently the pmd-auto-lb-rebal-interval's value was not been
checked properly.
It maybe a negative, or too big value (>2 weeks between rebalances),
which will be lead to a big unsigned value. So reset it to default
if the value exceeds the max permitted as described in vswitchd.xml.

Fixes: 5bf84282482a ("Adding support for PMD auto load balancing")
Signed-off-by: Lin Huang linhu...@ruijie.com.cn
---
 lib/dpif-netdev.c |  6 +-
 tests/alb.at  | 20 +++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 904f4ec92..503539841 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -93,7 +93,8 @@ VLOG_DEFINE_THIS_MODULE(dpif_netdev);
 /* Auto Load Balancing Defaults */
 #define ALB_IMPROVEMENT_THRESHOLD25
 #define ALB_LOAD_THRESHOLD   95
-#define ALB_REBALANCE_INTERVAL   1 /* 1 Min */
+#define ALB_REBALANCE_INTERVAL   1 /* 1 Min */
+#define MAX_ALB_REBALANCE_INTERVAL   2 /* 2 Min */
 #define MIN_TO_MSEC  6
 
 #define FLOW_DUMP_MAX_BATCH 50
@@ -4881,6 +4882,9 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 
 rebalance_intvl = smap_get_ullong(other_config, 
"pmd-auto-lb-rebal-interval",
   ALB_REBALANCE_INTERVAL);
+if (rebalance_intvl > MAX_ALB_REBALANCE_INTERVAL) {
+rebalance_intvl = ALB_REBALANCE_INTERVAL;
+}
 
 /* Input is in min, convert it to msec. */
 rebalance_intvl =
diff --git a/tests/alb.at b/tests/alb.at
index 0036bd1f2..922185d61 100644
--- a/tests/alb.at
+++ b/tests/alb.at
@@ -243,7 +243,25 @@ get_log_next_line_num
 AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="0"])
 CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
 
-# No check for above max as it is only a documented max value and not a hard 
limit
+# Set new value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="100"])
+CHECK_ALB_PARAM([interval], [100 mins], [+$LINENUM])
+
+# Set above max value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="20001"])
+CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
+
+# Set new value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="1000"])
+CHECK_ALB_PARAM([interval], [1000 mins], [+$LINENUM])
+
+# Set Negative value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="-1"])
+CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
-- 
2.36.0

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


[ovs-dev] [PATCH v3 1/2] dpif-netdev: Fix ALB parameters type mismatch.

2022-05-15 Thread miterv
From: linhuang 

The ALB parameters should never be negative.
So it's to use unsigned smap_get versions to get it properly, and
update VLOG formatting.

Fixes: 5bf84282482a ("Adding support for PMD auto load balancing")
Signed-off-by: Lin Huang 
---
 lib/dpif-netdev.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 61929049c..904f4ec92 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -4777,8 +4777,8 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 uint32_t insert_min, cur_min;
 uint32_t tx_flush_interval, cur_tx_flush_interval;
 uint64_t rebalance_intvl;
-uint8_t rebalance_load, cur_rebalance_load;
-uint8_t rebalance_improve;
+uint8_t cur_rebalance_load;
+uint32_t rebalance_load, rebalance_improve;
 bool log_autolb = false;
 enum sched_assignment_type pmd_rxq_assign_type;
 
@@ -4879,8 +4879,8 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 
 struct pmd_auto_lb *pmd_alb = >pmd_alb;
 
-rebalance_intvl = smap_get_int(other_config, "pmd-auto-lb-rebal-interval",
-   ALB_REBALANCE_INTERVAL);
+rebalance_intvl = smap_get_ullong(other_config, 
"pmd-auto-lb-rebal-interval",
+  ALB_REBALANCE_INTERVAL);
 
 /* Input is in min, convert it to msec. */
 rebalance_intvl =
@@ -4893,21 +4893,21 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 log_autolb = true;
 }
 
-rebalance_improve = smap_get_int(other_config,
- "pmd-auto-lb-improvement-threshold",
- ALB_IMPROVEMENT_THRESHOLD);
+rebalance_improve = smap_get_uint(other_config,
+  "pmd-auto-lb-improvement-threshold",
+  ALB_IMPROVEMENT_THRESHOLD);
 if (rebalance_improve > 100) {
 rebalance_improve = ALB_IMPROVEMENT_THRESHOLD;
 }
 if (rebalance_improve != pmd_alb->rebalance_improve_thresh) {
 pmd_alb->rebalance_improve_thresh = rebalance_improve;
 VLOG_INFO("PMD auto load balance improvement threshold set to "
-  "%"PRIu8"%%", rebalance_improve);
+  "%"PRIu32"%%", rebalance_improve);
 log_autolb = true;
 }
 
-rebalance_load = smap_get_int(other_config, "pmd-auto-lb-load-threshold",
-  ALB_LOAD_THRESHOLD);
+rebalance_load = smap_get_uint(other_config, "pmd-auto-lb-load-threshold",
+   ALB_LOAD_THRESHOLD);
 if (rebalance_load > 100) {
 rebalance_load = ALB_LOAD_THRESHOLD;
 }
@@ -4915,7 +4915,7 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 if (rebalance_load != cur_rebalance_load) {
 atomic_store_relaxed(_alb->rebalance_load_thresh,
  rebalance_load);
-VLOG_INFO("PMD auto load balance load threshold set to %"PRIu8"%%",
+VLOG_INFO("PMD auto load balance load threshold set to %"PRIu32"%%",
   rebalance_load);
 log_autolb = true;
 }
-- 
2.36.0

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


[ovs-dev] [PATCH v3 0/2] Fix ALB parameters type and value mismatch.

2022-05-15 Thread miterv
From: Lin Huang 

This series fix ALB parameters type mismatch and set a hard limit
to rebalance_intvl.

It also includes some self-tests.

Changes since v2:
  1. Fix type mismatch int dpif-netdev.c.

Changes since v1:
  1. Fix the commit message and formatting.
  2. Fix typo in unit tests.

Lin Huang (2):
  dpif-netdev: Fix ALB parameters type mismatch.
  dpif-netdev : Fix ALB 'rebalance_intvl' max hard limit.

 lib/dpif-netdev.c | 28 
 tests/alb.at  | 20 +++-
 2 files changed, 35 insertions(+), 13 deletions(-)

-- 
2.36.0

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


[ovs-dev] [PATCH v2 2/2] dpif-netdev: Fix ALB 'rebalance_intvl' max hard limit.

2022-05-11 Thread miterv
From: linhuang 

Currently the pmd-auto-lb-rebal-interval's value was not been
checked properly.
It maybe a negative, or too big value (>2 weeks between rebalances),
which will be lead to a big unsigned value. So reset it to default
if the value exceeds the max permitted as described in vswitchd.xml.

Fixes: 5bf84282482a ("Adding support for PMD auto load balancing")
Signed-off-by: Lin Huang 
---
 lib/dpif-netdev.c |  6 +-
 tests/alb.at  | 20 +++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 23ceccf3a..4a5af0182 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -93,7 +93,8 @@ VLOG_DEFINE_THIS_MODULE(dpif_netdev);
 /* Auto Load Balancing Defaults */
 #define ALB_IMPROVEMENT_THRESHOLD25
 #define ALB_LOAD_THRESHOLD   95
-#define ALB_REBALANCE_INTERVAL   1 /* 1 Min */
+#define ALB_REBALANCE_INTERVAL   1 /* 1 Min */
+#define MAX_ALB_REBALANCE_INTERVAL   2 /* 2 Min */
 #define MIN_TO_MSEC  6
 
 #define FLOW_DUMP_MAX_BATCH 50
@@ -4881,6 +4882,9 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 
 rebalance_intvl = smap_get_ullong(other_config, 
"pmd-auto-lb-rebal-interval",
   ALB_REBALANCE_INTERVAL);
+if (rebalance_intvl > MAX_ALB_REBALANCE_INTERVAL) {
+rebalance_intvl = ALB_REBALANCE_INTERVAL;
+}
 
 /* Input is in min, convert it to msec. */
 rebalance_intvl =
diff --git a/tests/alb.at b/tests/alb.at
index 0036bd1f2..922185d61 100644
--- a/tests/alb.at
+++ b/tests/alb.at
@@ -243,7 +243,25 @@ get_log_next_line_num
 AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="0"])
 CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
 
-# No check for above max as it is only a documented max value and not a hard 
limit
+# Set new value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="100"])
+CHECK_ALB_PARAM([interval], [100 mins], [+$LINENUM])
+
+# Set above max value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="20001"])
+CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
+
+# Set new value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="1000"])
+CHECK_ALB_PARAM([interval], [1000 mins], [+$LINENUM])
+
+# Set Negative value
+get_log_next_line_num
+AT_CHECK([ovs-vsctl set open_vswitch . 
other_config:pmd-auto-lb-rebal-interval="-1"])
+CHECK_ALB_PARAM([interval], [1 mins], [+$LINENUM])
 
 OVS_VSWITCHD_STOP
 AT_CLEANUP
-- 
2.36.0.windows.1

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


[ovs-dev] [PATCH v2 1/2] dpif-netdev: Fix ALB parameters type mismatch.

2022-05-11 Thread miterv
From: linhuang 

The ALB parameters should never be negative.
So it's to use unsigned smap_get versions to get it properly.

Fixes: 5bf84282482a ("Adding support for PMD auto load balancing")
Signed-off-by: Lin Huang 
---
 lib/dpif-netdev.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 61929049c..23ceccf3a 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -4879,8 +4879,8 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 
 struct pmd_auto_lb *pmd_alb = >pmd_alb;
 
-rebalance_intvl = smap_get_int(other_config, "pmd-auto-lb-rebal-interval",
-   ALB_REBALANCE_INTERVAL);
+rebalance_intvl = smap_get_ullong(other_config, 
"pmd-auto-lb-rebal-interval",
+  ALB_REBALANCE_INTERVAL);
 
 /* Input is in min, convert it to msec. */
 rebalance_intvl =
@@ -4893,9 +4893,9 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 log_autolb = true;
 }
 
-rebalance_improve = smap_get_int(other_config,
- "pmd-auto-lb-improvement-threshold",
- ALB_IMPROVEMENT_THRESHOLD);
+rebalance_improve = smap_get_uint(other_config,
+  "pmd-auto-lb-improvement-threshold",
+  ALB_IMPROVEMENT_THRESHOLD);
 if (rebalance_improve > 100) {
 rebalance_improve = ALB_IMPROVEMENT_THRESHOLD;
 }
@@ -4906,8 +4906,8 @@ dpif_netdev_set_config(struct dpif *dpif, const struct 
smap *other_config)
 log_autolb = true;
 }
 
-rebalance_load = smap_get_int(other_config, "pmd-auto-lb-load-threshold",
-  ALB_LOAD_THRESHOLD);
+rebalance_load = smap_get_uint(other_config, "pmd-auto-lb-load-threshold",
+   ALB_LOAD_THRESHOLD);
 if (rebalance_load > 100) {
 rebalance_load = ALB_LOAD_THRESHOLD;
 }
-- 
2.36.0.windows.1

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


[ovs-dev] [PATCH v2 0/2] Fix ALB parameters type and value mismatch.

2022-05-11 Thread miterv
From: Lin Huang 

Changes since v1:
  1. Fix the commit message and formatting.
  2. Fix typo in unit tests.

Lin Huang (2):
  dpif-netdev: Fix ALB parameters type mismatch.
  dpif-netdev: Fix ALB 'rebalance_intvl' max hard limit.

 lib/dpif-netdev.c | 20 
 tests/alb.at  | 20 +++-
 2 files changed, 31 insertions(+), 9 deletions(-)

-- 
2.36.0

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