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;
145 struct rte_meter_trtcm_rfc4115_profile *p,
160 struct rte_meter_srtcm_profile *p);
174 struct rte_meter_trtcm_profile *p);
191 struct rte_meter_trtcm_rfc4115_profile *p);
209 struct rte_meter_srtcm_profile *p,
231 struct rte_meter_srtcm_profile *p,
252 struct rte_meter_trtcm_profile *p,
274 struct rte_meter_trtcm_profile *p,
299 struct rte_meter_trtcm_rfc4115_profile *p,
325 struct rte_meter_trtcm_rfc4115_profile *p,
335 struct rte_meter_srtcm_profile {
342 uint64_t cir_bytes_per_period;
347 struct rte_meter_srtcm {
353 struct rte_meter_trtcm_profile {
360 uint64_t cir_bytes_per_period;
364 uint64_t pir_bytes_per_period;
383 struct rte_meter_trtcm_rfc4115_profile {
390 uint64_t cir_bytes_per_period;
394 uint64_t eir_bytes_per_period;
415 struct rte_meter_srtcm_profile *p,
419 uint64_t time_diff, n_periods, tc, te;
422 time_diff = time - m->time;
423 n_periods = time_diff / p->cir_period;
424 m->time += n_periods * p->cir_period;
427 tc = m->tc + n_periods * p->cir_bytes_per_period;
438 m->tc = tc - pkt_len;
445 m->te = te - pkt_len;
456 struct rte_meter_srtcm_profile *p,
461 uint64_t time_diff, n_periods, tc, te;
464 time_diff = time - m->time;
465 n_periods = time_diff / p->cir_period;
466 m->time += n_periods * p->cir_period;
469 tc = m->tc + n_periods * p->cir_bytes_per_period;
480 m->tc = tc - pkt_len;
487 m->te = te - pkt_len;
498 struct rte_meter_trtcm_profile *p,
502 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
505 time_diff_tc = time - m->
time_tc;
506 time_diff_tp = time - m->
time_tp;
507 n_periods_tc = time_diff_tc / p->cir_period;
508 n_periods_tp = time_diff_tp / p->pir_period;
509 m->
time_tc += n_periods_tc * p->cir_period;
510 m->
time_tp += n_periods_tp * p->pir_period;
512 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
516 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
529 m->
tp = tp - pkt_len;
533 m->
tc = tc - pkt_len;
534 m->
tp = tp - pkt_len;
540 struct rte_meter_trtcm_profile *p,
545 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
548 time_diff_tc = time - m->
time_tc;
549 time_diff_tp = time - m->
time_tp;
550 n_periods_tc = time_diff_tc / p->cir_period;
551 n_periods_tp = time_diff_tp / p->pir_period;
552 m->
time_tc += n_periods_tc * p->cir_period;
553 m->
time_tp += n_periods_tp * p->pir_period;
555 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
559 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
572 m->
tp = tp - pkt_len;
576 m->
tc = tc - pkt_len;
577 m->
tp = tp - pkt_len;
584 struct rte_meter_trtcm_rfc4115_profile *p,
588 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
591 time_diff_tc = time - m->
time_tc;
592 time_diff_te = time - m->
time_te;
593 n_periods_tc = time_diff_tc / p->cir_period;
594 n_periods_te = time_diff_te / p->eir_period;
595 m->
time_tc += n_periods_tc * p->cir_period;
596 m->
time_te += n_periods_te * p->eir_period;
598 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
602 te = m->
te + n_periods_te * p->eir_bytes_per_period;
608 m->
tc = tc - pkt_len;
614 m->
te = te - pkt_len;
627 struct rte_meter_trtcm_rfc4115_profile *p,
632 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
635 time_diff_tc = time - m->
time_tc;
636 time_diff_te = time - m->
time_te;
637 n_periods_tc = time_diff_tc / p->cir_period;
638 n_periods_te = time_diff_te / p->eir_period;
639 m->
time_tc += n_periods_tc * p->cir_period;
640 m->
time_te += n_periods_te * p->eir_period;
642 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
646 te = m->
te + n_periods_te * p->eir_bytes_per_period;
652 m->
tc = tc - pkt_len;
659 m->
te = te - 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)
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)
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)
int rte_meter_trtcm_rfc4115_config(struct rte_meter_trtcm_rfc4115 *m, struct rte_meter_trtcm_rfc4115_profile *p)
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)
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)