6 #ifndef __INCLUDE_RTE_METER_H__ 7 #define __INCLUDE_RTE_METER_H__ 76 struct rte_meter_srtcm_profile;
82 struct rte_meter_trtcm_profile;
88 struct rte_meter_trtcm_rfc4115_profile;
91 struct rte_meter_srtcm;
144 struct rte_meter_trtcm_rfc4115_profile *p,
159 struct rte_meter_srtcm_profile *p);
173 struct rte_meter_trtcm_profile *p);
190 struct rte_meter_trtcm_rfc4115_profile *p);
208 struct rte_meter_srtcm_profile *p,
230 struct rte_meter_srtcm_profile *p,
251 struct rte_meter_trtcm_profile *p,
273 struct rte_meter_trtcm_profile *p,
298 struct rte_meter_trtcm_rfc4115_profile *p,
324 struct rte_meter_trtcm_rfc4115_profile *p,
334 struct rte_meter_srtcm_profile {
341 uint64_t cir_bytes_per_period;
346 struct rte_meter_srtcm {
352 struct rte_meter_trtcm_profile {
359 uint64_t cir_bytes_per_period;
363 uint64_t pir_bytes_per_period;
382 struct rte_meter_trtcm_rfc4115_profile {
389 uint64_t cir_bytes_per_period;
393 uint64_t eir_bytes_per_period;
414 struct rte_meter_srtcm_profile *p,
418 uint64_t time_diff, n_periods, tc, te;
421 time_diff = time - m->time;
422 n_periods = time_diff / p->cir_period;
423 m->time += n_periods * p->cir_period;
426 tc = m->tc + n_periods * p->cir_bytes_per_period;
437 m->tc = tc - pkt_len;
444 m->te = te - pkt_len;
455 struct rte_meter_srtcm_profile *p,
460 uint64_t time_diff, n_periods, tc, te;
463 time_diff = time - m->time;
464 n_periods = time_diff / p->cir_period;
465 m->time += n_periods * p->cir_period;
468 tc = m->tc + n_periods * p->cir_bytes_per_period;
479 m->tc = tc - pkt_len;
486 m->te = te - pkt_len;
497 struct rte_meter_trtcm_profile *p,
501 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
504 time_diff_tc = time - m->
time_tc;
505 time_diff_tp = time - m->
time_tp;
506 n_periods_tc = time_diff_tc / p->cir_period;
507 n_periods_tp = time_diff_tp / p->pir_period;
508 m->
time_tc += n_periods_tc * p->cir_period;
509 m->
time_tp += n_periods_tp * p->pir_period;
511 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
515 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
528 m->
tp = tp - pkt_len;
532 m->
tc = tc - pkt_len;
533 m->
tp = tp - pkt_len;
539 struct rte_meter_trtcm_profile *p,
544 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
547 time_diff_tc = time - m->
time_tc;
548 time_diff_tp = time - m->
time_tp;
549 n_periods_tc = time_diff_tc / p->cir_period;
550 n_periods_tp = time_diff_tp / p->pir_period;
551 m->
time_tc += n_periods_tc * p->cir_period;
552 m->
time_tp += n_periods_tp * p->pir_period;
554 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
558 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
571 m->
tp = tp - pkt_len;
575 m->
tc = tc - pkt_len;
576 m->
tp = tp - pkt_len;
583 struct rte_meter_trtcm_rfc4115_profile *p,
587 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
590 time_diff_tc = time - m->
time_tc;
591 time_diff_te = time - m->
time_te;
592 n_periods_tc = time_diff_tc / p->cir_period;
593 n_periods_te = time_diff_te / p->eir_period;
594 m->
time_tc += n_periods_tc * p->cir_period;
595 m->
time_te += n_periods_te * p->eir_period;
597 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
601 te = m->
te + n_periods_te * p->eir_bytes_per_period;
607 m->
tc = tc - pkt_len;
613 m->
te = te - pkt_len;
626 struct rte_meter_trtcm_rfc4115_profile *p,
631 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
634 time_diff_tc = time - m->
time_tc;
635 time_diff_te = time - m->
time_te;
636 n_periods_tc = time_diff_tc / p->cir_period;
637 n_periods_te = time_diff_te / p->eir_period;
638 m->
time_tc += n_periods_tc * p->cir_period;
639 m->
time_te += n_periods_te * p->eir_period;
641 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
645 te = m->
te + n_periods_te * p->eir_bytes_per_period;
651 m->
tc = tc - pkt_len;
658 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)