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;
142 struct rte_meter_trtcm_rfc4115_profile *p,
157 struct rte_meter_srtcm_profile *p);
171 struct rte_meter_trtcm_profile *p);
185 struct rte_meter_trtcm_rfc4115_profile *p);
203 struct rte_meter_srtcm_profile *p,
225 struct rte_meter_srtcm_profile *p,
246 struct rte_meter_trtcm_profile *p,
268 struct rte_meter_trtcm_profile *p,
290 struct rte_meter_trtcm_rfc4115_profile *p,
313 struct rte_meter_trtcm_rfc4115_profile *p,
323 struct rte_meter_srtcm_profile {
330 uint64_t cir_bytes_per_period;
335 struct rte_meter_srtcm {
341 struct rte_meter_trtcm_profile {
348 uint64_t cir_bytes_per_period;
352 uint64_t pir_bytes_per_period;
371 struct rte_meter_trtcm_rfc4115_profile {
378 uint64_t cir_bytes_per_period;
382 uint64_t eir_bytes_per_period;
403 struct rte_meter_srtcm_profile *p,
407 uint64_t time_diff, n_periods, tc, te;
410 time_diff = time - m->time;
411 n_periods = time_diff / p->cir_period;
412 m->time += n_periods * p->cir_period;
415 tc = m->tc + n_periods * p->cir_bytes_per_period;
426 m->tc = tc - pkt_len;
433 m->te = te - pkt_len;
444 struct rte_meter_srtcm_profile *p,
449 uint64_t time_diff, n_periods, tc, te;
452 time_diff = time - m->time;
453 n_periods = time_diff / p->cir_period;
454 m->time += n_periods * p->cir_period;
457 tc = m->tc + n_periods * p->cir_bytes_per_period;
468 m->tc = tc - pkt_len;
475 m->te = te - pkt_len;
486 struct rte_meter_trtcm_profile *p,
490 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
493 time_diff_tc = time - m->
time_tc;
494 time_diff_tp = time - m->
time_tp;
495 n_periods_tc = time_diff_tc / p->cir_period;
496 n_periods_tp = time_diff_tp / p->pir_period;
497 m->
time_tc += n_periods_tc * p->cir_period;
498 m->
time_tp += n_periods_tp * p->pir_period;
500 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
504 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
517 m->
tp = tp - pkt_len;
521 m->
tc = tc - pkt_len;
522 m->
tp = tp - pkt_len;
528 struct rte_meter_trtcm_profile *p,
533 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
536 time_diff_tc = time - m->
time_tc;
537 time_diff_tp = time - m->
time_tp;
538 n_periods_tc = time_diff_tc / p->cir_period;
539 n_periods_tp = time_diff_tp / p->pir_period;
540 m->
time_tc += n_periods_tc * p->cir_period;
541 m->
time_tp += n_periods_tp * p->pir_period;
543 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
547 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
560 m->
tp = tp - pkt_len;
564 m->
tc = tc - pkt_len;
565 m->
tp = tp - pkt_len;
572 struct rte_meter_trtcm_rfc4115_profile *p,
576 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
579 time_diff_tc = time - m->
time_tc;
580 time_diff_te = time - m->
time_te;
581 n_periods_tc = time_diff_tc / p->cir_period;
582 n_periods_te = time_diff_te / p->eir_period;
583 m->
time_tc += n_periods_tc * p->cir_period;
584 m->
time_te += n_periods_te * p->eir_period;
586 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
590 te = m->
te + n_periods_te * p->eir_bytes_per_period;
596 m->
tc = tc - pkt_len;
602 m->
te = te - pkt_len;
615 struct rte_meter_trtcm_rfc4115_profile *p,
620 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
623 time_diff_tc = time - m->
time_tc;
624 time_diff_te = time - m->
time_te;
625 n_periods_tc = time_diff_tc / p->cir_period;
626 n_periods_te = time_diff_te / p->eir_period;
627 m->
time_tc += n_periods_tc * p->cir_period;
628 m->
time_te += n_periods_te * p->eir_period;
630 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
634 te = m->
te + n_periods_te * p->eir_bytes_per_period;
640 m->
tc = tc - pkt_len;
647 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)