diff mbox series

[ovs-dev,dpdk-latest,v4,4/5] netdev-dpdk: Add meter algorithms

Message ID 20230426140510.949421-5-simon.horman@corigine.com
State Changes Requested
Headers show
Series Add support for DPDK meter HW offload | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Simon Horman April 26, 2023, 2:05 p.m. UTC
From: Peng Zhang <peng.zhang@corigine.com>

Add the meter algorithms. DPDK meter support three algorithms,
and OVS also can support these algorithms.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Signed-off-by: Jin Liu <jin.liu@corigine.com>
Co-authored-by: Jin Liu <jin.liu@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
 lib/netdev-dpdk.c | 58 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 51 insertions(+), 7 deletions(-)

Comments

0-day Robot April 26, 2023, 2:16 p.m. UTC | #1
References:  <20230426140510.949421-5-simon.horman@corigine.com>
 

Bleep bloop.  Greetings Simon Horman, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


Patch skipped due to previous failure.

Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index c2f527a1456f..47c4091d49eb 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -5342,6 +5342,50 @@  netdev_dpdk_rte_flow_query_count(struct netdev *netdev,
     return ret;
 }
 
+/* RTE_MTR_TRTCM_RFC2697 meter profile */
+static void
+netdev_dpdk_meter_profile_rfc2697_init(struct rte_mtr_meter_profile *profile,
+                                       const uint64_t rate,
+                                       const uint64_t burst,
+                                       const int flag)
+{
+       profile->alg = RTE_MTR_SRTCM_RFC2697;
+       profile->packet_mode = flag;
+       profile->srtcm_rfc2697.cir = rate;
+       profile->srtcm_rfc2697.cbs = burst;
+       profile->srtcm_rfc2697.ebs = burst;
+}
+
+/* RTE_MTR_TRTCM_RFC2698 meter profile */
+static void
+netdev_dpdk_meter_profile_rfc2698_init(struct rte_mtr_meter_profile *profile,
+                                       const uint64_t rate,
+                                       const uint64_t burst,
+                                       const int flag)
+{
+       profile->alg = RTE_MTR_TRTCM_RFC2698;
+       profile->packet_mode = flag;
+       profile->trtcm_rfc2698.cir = rate;
+       profile->trtcm_rfc2698.cbs = burst;
+       profile->trtcm_rfc2698.pir = rate;
+       profile->trtcm_rfc2698.pbs = burst;
+}
+
+/* RTE_MTR_TRTCM_RFC2698 meter profile */
+static void
+netdev_dpdk_meter_profile_rfc4115_init(struct rte_mtr_meter_profile *profile,
+                                       const uint64_t rate,
+                                       const uint64_t burst,
+                                       const int flag)
+{
+       profile->alg = RTE_MTR_TRTCM_RFC4115;
+       profile->packet_mode = flag;
+       profile->trtcm_rfc4115.cir = rate;
+       profile->trtcm_rfc4115.cbs = burst;
+       profile->trtcm_rfc4115.eir = rate;
+       profile->trtcm_rfc4115.ebs = burst;
+}
+
 static int OVS_UNUSED
 netdev_dpdk_meter_profile_init(struct rte_mtr_meter_profile *profile,
                                struct rte_mtr_capabilities *cap,
@@ -5349,16 +5393,16 @@  netdev_dpdk_meter_profile_init(struct rte_mtr_meter_profile *profile,
                                const uint64_t burst,
                                const int flag)
 {
-    if (!cap->meter_srtcm_rfc2697_n_max) {
+    if (cap->meter_srtcm_rfc2697_n_max) {
+        netdev_dpdk_meter_profile_rfc2697_init(profile, rate, burst, flag);
+    } else if (cap->meter_trtcm_rfc2698_n_max) {
+        netdev_dpdk_meter_profile_rfc2698_init(profile, rate, burst, flag);
+    } else if (cap->meter_trtcm_rfc4115_n_max) {
+        netdev_dpdk_meter_profile_rfc4115_init(profile, rate, burst, flag);
+    } else {
         return EOPNOTSUPP;
     }
 
-    profile->alg = RTE_MTR_SRTCM_RFC2697;
-    profile->packet_mode = flag;
-    profile->srtcm_rfc2697.cir = rate;
-    profile->srtcm_rfc2697.cbs = burst;
-    profile->srtcm_rfc2697.ebs = burst;
-
     return 0;
 }