6 #ifndef __INCLUDE_RTE_METER_H__
7 #define __INCLUDE_RTE_METER_H__
26 #include "rte_compat.h"
77 struct rte_meter_srtcm_profile;
83 struct rte_meter_trtcm_profile;
89 struct rte_meter_trtcm_rfc4115_profile;
92 struct rte_meter_srtcm;
146 struct rte_meter_trtcm_rfc4115_profile *p,
161 struct rte_meter_srtcm_profile *p);
175 struct rte_meter_trtcm_profile *p);
193 struct rte_meter_trtcm_rfc4115_profile *p);
211 struct rte_meter_srtcm_profile *p,
233 struct rte_meter_srtcm_profile *p,
254 struct rte_meter_trtcm_profile *p,
276 struct rte_meter_trtcm_profile *p,
302 struct rte_meter_trtcm_rfc4115_profile *p,
329 struct rte_meter_trtcm_rfc4115_profile *p,
339 struct rte_meter_srtcm_profile {
346 uint64_t cir_bytes_per_period;
351 struct rte_meter_srtcm {
357 struct rte_meter_trtcm_profile {
364 uint64_t cir_bytes_per_period;
368 uint64_t pir_bytes_per_period;
387 struct rte_meter_trtcm_rfc4115_profile {
394 uint64_t cir_bytes_per_period;
398 uint64_t eir_bytes_per_period;
419 struct rte_meter_srtcm_profile *p,
423 uint64_t time_diff, n_periods, tc, te;
426 time_diff = time - m->time;
427 n_periods = time_diff / p->cir_period;
428 m->time += n_periods * p->cir_period;
431 tc = m->tc + n_periods * p->cir_bytes_per_period;
442 m->tc = tc - pkt_len;
449 m->te = te - pkt_len;
460 struct rte_meter_srtcm_profile *p,
465 uint64_t time_diff, n_periods, tc, te;
468 time_diff = time - m->time;
469 n_periods = time_diff / p->cir_period;
470 m->time += n_periods * p->cir_period;
473 tc = m->tc + n_periods * p->cir_bytes_per_period;
484 m->tc = tc - pkt_len;
491 m->te = te - pkt_len;
502 struct rte_meter_trtcm_profile *p,
506 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
509 time_diff_tc = time - m->
time_tc;
510 time_diff_tp = time - m->
time_tp;
511 n_periods_tc = time_diff_tc / p->cir_period;
512 n_periods_tp = time_diff_tp / p->pir_period;
513 m->
time_tc += n_periods_tc * p->cir_period;
514 m->
time_tp += n_periods_tp * p->pir_period;
516 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
520 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
533 m->
tp = tp - pkt_len;
537 m->
tc = tc - pkt_len;
538 m->
tp = tp - pkt_len;
544 struct rte_meter_trtcm_profile *p,
549 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
552 time_diff_tc = time - m->
time_tc;
553 time_diff_tp = time - m->
time_tp;
554 n_periods_tc = time_diff_tc / p->cir_period;
555 n_periods_tp = time_diff_tp / p->pir_period;
556 m->
time_tc += n_periods_tc * p->cir_period;
557 m->
time_tp += n_periods_tp * p->pir_period;
559 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
563 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
576 m->
tp = tp - pkt_len;
580 m->
tc = tc - pkt_len;
581 m->
tp = tp - pkt_len;
589 struct rte_meter_trtcm_rfc4115_profile *p,
593 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
596 time_diff_tc = time - m->
time_tc;
597 time_diff_te = time - m->
time_te;
598 n_periods_tc = time_diff_tc / p->cir_period;
599 n_periods_te = time_diff_te / p->eir_period;
600 m->
time_tc += n_periods_tc * p->cir_period;
601 m->
time_te += n_periods_te * p->eir_period;
603 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
607 te = m->
te + n_periods_te * p->eir_bytes_per_period;
613 m->
tc = tc - pkt_len;
619 m->
te = te - pkt_len;
633 struct rte_meter_trtcm_rfc4115_profile *p,
638 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
641 time_diff_tc = time - m->
time_tc;
642 time_diff_te = time - m->
time_te;
643 n_periods_tc = time_diff_tc / p->cir_period;
644 n_periods_te = time_diff_te / p->eir_period;
645 m->
time_tc += n_periods_tc * p->cir_period;
646 m->
time_te += n_periods_te * p->eir_period;
648 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
652 te = m->
te + n_periods_te * p->eir_bytes_per_period;
658 m->
tc = tc - pkt_len;
665 m->
te = te - pkt_len;
__rte_experimental int rte_meter_trtcm_rfc4115_profile_config(struct rte_meter_trtcm_rfc4115_profile *p, struct rte_meter_trtcm_rfc4115_params *params)
static __rte_experimental enum rte_color rte_meter_trtcm_rfc4115_color_blind_check(struct rte_meter_trtcm_rfc4115 *m, struct rte_meter_trtcm_rfc4115_profile *p, uint64_t time, uint32_t pkt_len)
static enum rte_color rte_meter_srtcm_color_blind_check(struct rte_meter_srtcm *m, struct rte_meter_srtcm_profile *p, uint64_t time, uint32_t pkt_len)
int rte_meter_trtcm_profile_config(struct rte_meter_trtcm_profile *p, struct rte_meter_trtcm_params *params)
int rte_meter_srtcm_config(struct rte_meter_srtcm *m, struct rte_meter_srtcm_profile *p)
static enum rte_color rte_meter_trtcm_color_blind_check(struct rte_meter_trtcm *m, struct rte_meter_trtcm_profile *p, uint64_t time, uint32_t pkt_len)
static enum rte_color rte_meter_srtcm_color_aware_check(struct rte_meter_srtcm *m, struct rte_meter_srtcm_profile *p, uint64_t time, uint32_t pkt_len, enum rte_color pkt_color)
int rte_meter_trtcm_config(struct rte_meter_trtcm *m, struct rte_meter_trtcm_profile *p)
static enum rte_color rte_meter_trtcm_color_aware_check(struct rte_meter_trtcm *m, struct rte_meter_trtcm_profile *p, uint64_t time, uint32_t pkt_len, enum rte_color pkt_color)
__rte_experimental int rte_meter_trtcm_rfc4115_config(struct rte_meter_trtcm_rfc4115 *m, struct rte_meter_trtcm_rfc4115_profile *p)
static __rte_experimental enum rte_color rte_meter_trtcm_rfc4115_color_aware_check(struct rte_meter_trtcm_rfc4115 *m, struct rte_meter_trtcm_rfc4115_profile *p, uint64_t time, uint32_t pkt_len, enum rte_color pkt_color)
int rte_meter_srtcm_profile_config(struct rte_meter_srtcm_profile *p, struct rte_meter_srtcm_params *params)