From: Peng Zhang <[email protected]> Add the meter algorithms. DPDK meter support three algorithms, and OVS also can support these algorithms.
Signed-off-by: Peng Zhang <[email protected]> Signed-off-by: Jin Liu <[email protected]> Signed-off-by: Simon Horman <[email protected]> --- lib/netdev-dpdk.c | 58 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index cc2d0762226f..2ce95aed2455 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -5331,6 +5331,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, @@ -5338,16 +5382,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; } -- 2.30.2 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
