6#ifndef __INCLUDE_RTE_METER_H__
7#define __INCLUDE_RTE_METER_H__
76struct rte_meter_srtcm_profile;
82struct rte_meter_trtcm_profile;
88struct rte_meter_trtcm_rfc4115_profile;
91struct rte_meter_srtcm;
141 struct rte_meter_trtcm_rfc4115_profile *p,
156 struct rte_meter_srtcm_profile *p);
170 struct rte_meter_trtcm_profile *p);
184 struct rte_meter_trtcm_rfc4115_profile *p);
202 struct rte_meter_srtcm_profile *p,
224 struct rte_meter_srtcm_profile *p,
245 struct rte_meter_trtcm_profile *p,
267 struct rte_meter_trtcm_profile *p,
289 struct rte_meter_trtcm_rfc4115_profile *p,
312 struct rte_meter_trtcm_rfc4115_profile *p,
322struct rte_meter_srtcm_profile {
329 uint64_t cir_bytes_per_period;
334struct rte_meter_srtcm {
340struct rte_meter_trtcm_profile {
347 uint64_t cir_bytes_per_period;
351 uint64_t pir_bytes_per_period;
370struct rte_meter_trtcm_rfc4115_profile {
377 uint64_t cir_bytes_per_period;
381 uint64_t eir_bytes_per_period;
402 struct rte_meter_srtcm_profile *p,
406 uint64_t time_diff, n_periods, tc, te;
409 time_diff = time - m->time;
410 n_periods = time_diff / p->cir_period;
411 m->time += n_periods * p->cir_period;
414 tc = m->tc + n_periods * p->cir_bytes_per_period;
425 m->tc = tc - pkt_len;
432 m->te = te - pkt_len;
443 struct rte_meter_srtcm_profile *p,
448 uint64_t time_diff, n_periods, tc, te;
451 time_diff = time - m->time;
452 n_periods = time_diff / p->cir_period;
453 m->time += n_periods * p->cir_period;
456 tc = m->tc + n_periods * p->cir_bytes_per_period;
467 m->tc = tc - pkt_len;
474 m->te = te - pkt_len;
485 struct rte_meter_trtcm_profile *p,
489 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
492 time_diff_tc = time - m->
time_tc;
493 time_diff_tp = time - m->
time_tp;
494 n_periods_tc = time_diff_tc / p->cir_period;
495 n_periods_tp = time_diff_tp / p->pir_period;
496 m->
time_tc += n_periods_tc * p->cir_period;
497 m->
time_tp += n_periods_tp * p->pir_period;
499 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
503 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
516 m->
tp = tp - pkt_len;
520 m->
tc = tc - pkt_len;
521 m->
tp = tp - pkt_len;
527 struct rte_meter_trtcm_profile *p,
532 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
535 time_diff_tc = time - m->
time_tc;
536 time_diff_tp = time - m->
time_tp;
537 n_periods_tc = time_diff_tc / p->cir_period;
538 n_periods_tp = time_diff_tp / p->pir_period;
539 m->
time_tc += n_periods_tc * p->cir_period;
540 m->
time_tp += n_periods_tp * p->pir_period;
542 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
546 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
559 m->
tp = tp - pkt_len;
563 m->
tc = tc - pkt_len;
564 m->
tp = tp - pkt_len;
571 struct rte_meter_trtcm_rfc4115_profile *p,
575 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
578 time_diff_tc = time - m->
time_tc;
579 time_diff_te = time - m->
time_te;
580 n_periods_tc = time_diff_tc / p->cir_period;
581 n_periods_te = time_diff_te / p->eir_period;
582 m->
time_tc += n_periods_tc * p->cir_period;
583 m->
time_te += n_periods_te * p->eir_period;
585 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
589 te = m->
te + n_periods_te * p->eir_bytes_per_period;
595 m->
tc = tc - pkt_len;
601 m->
te = te - pkt_len;
614 struct rte_meter_trtcm_rfc4115_profile *p,
619 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
622 time_diff_tc = time - m->
time_tc;
623 time_diff_te = time - m->
time_te;
624 n_periods_tc = time_diff_tc / p->cir_period;
625 n_periods_te = time_diff_te / p->eir_period;
626 m->
time_tc += n_periods_tc * p->cir_period;
627 m->
time_te += n_periods_te * p->eir_period;
629 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
633 te = m->
te + n_periods_te * p->eir_bytes_per_period;
639 m->
tc = tc - pkt_len;
646 m->
te = te - pkt_len;
static 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_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)
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_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)
int rte_meter_trtcm_rfc4115_profile_config(struct rte_meter_trtcm_rfc4115_profile *p, struct rte_meter_trtcm_rfc4115_params *params)
int rte_meter_srtcm_profile_config(struct rte_meter_srtcm_profile *p, struct rte_meter_srtcm_params *params)
int rte_meter_srtcm_config(struct rte_meter_srtcm *m, struct rte_meter_srtcm_profile *p)
int rte_meter_trtcm_rfc4115_config(struct rte_meter_trtcm_rfc4115 *m, struct rte_meter_trtcm_rfc4115_profile *p)
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)
int rte_meter_trtcm_profile_config(struct rte_meter_trtcm_profile *p, struct rte_meter_trtcm_params *params)
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)