6 #ifndef __INCLUDE_RTE_METER_H__ 7 #define __INCLUDE_RTE_METER_H__ 73 struct rte_meter_srtcm_profile;
79 struct rte_meter_trtcm_profile;
85 struct rte_meter_trtcm_rfc4115_profile;
88 struct 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);
187 struct rte_meter_trtcm_rfc4115_profile *p);
205 struct rte_meter_srtcm_profile *p,
227 struct rte_meter_srtcm_profile *p,
248 struct rte_meter_trtcm_profile *p,
270 struct rte_meter_trtcm_profile *p,
295 struct rte_meter_trtcm_rfc4115_profile *p,
321 struct rte_meter_trtcm_rfc4115_profile *p,
330 struct rte_meter_srtcm_profile {
337 uint64_t cir_bytes_per_period;
342 struct rte_meter_srtcm {
348 struct rte_meter_trtcm_profile {
355 uint64_t cir_bytes_per_period;
359 uint64_t pir_bytes_per_period;
378 struct rte_meter_trtcm_rfc4115_profile {
385 uint64_t cir_bytes_per_period;
389 uint64_t eir_bytes_per_period;
410 struct rte_meter_srtcm_profile *p,
414 uint64_t time_diff, n_periods, tc, te;
417 time_diff = time - m->time;
418 n_periods = time_diff / p->cir_period;
419 m->time += n_periods * p->cir_period;
422 tc = m->tc + n_periods * p->cir_bytes_per_period;
433 m->tc = tc - pkt_len;
440 m->te = te - pkt_len;
451 struct rte_meter_srtcm_profile *p,
456 uint64_t time_diff, n_periods, tc, te;
459 time_diff = time - m->time;
460 n_periods = time_diff / p->cir_period;
461 m->time += n_periods * p->cir_period;
464 tc = m->tc + n_periods * p->cir_bytes_per_period;
475 m->tc = tc - pkt_len;
482 m->te = te - pkt_len;
493 struct rte_meter_trtcm_profile *p,
497 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
500 time_diff_tc = time - m->
time_tc;
501 time_diff_tp = time - m->
time_tp;
502 n_periods_tc = time_diff_tc / p->cir_period;
503 n_periods_tp = time_diff_tp / p->pir_period;
504 m->
time_tc += n_periods_tc * p->cir_period;
505 m->
time_tp += n_periods_tp * p->pir_period;
507 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
511 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
524 m->
tp = tp - pkt_len;
528 m->
tc = tc - pkt_len;
529 m->
tp = tp - pkt_len;
535 struct rte_meter_trtcm_profile *p,
540 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
543 time_diff_tc = time - m->
time_tc;
544 time_diff_tp = time - m->
time_tp;
545 n_periods_tc = time_diff_tc / p->cir_period;
546 n_periods_tp = time_diff_tp / p->pir_period;
547 m->
time_tc += n_periods_tc * p->cir_period;
548 m->
time_tp += n_periods_tp * p->pir_period;
550 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
554 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
567 m->
tp = tp - pkt_len;
571 m->
tc = tc - pkt_len;
572 m->
tp = tp - pkt_len;
579 struct rte_meter_trtcm_rfc4115_profile *p,
583 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
586 time_diff_tc = time - m->
time_tc;
587 time_diff_te = time - m->
time_te;
588 n_periods_tc = time_diff_tc / p->cir_period;
589 n_periods_te = time_diff_te / p->eir_period;
590 m->
time_tc += n_periods_tc * p->cir_period;
591 m->
time_te += n_periods_te * p->eir_period;
593 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
597 te = m->
te + n_periods_te * p->eir_bytes_per_period;
603 m->
tc = tc - pkt_len;
609 m->
te = te - pkt_len;
622 struct rte_meter_trtcm_rfc4115_profile *p,
627 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
630 time_diff_tc = time - m->
time_tc;
631 time_diff_te = time - m->
time_te;
632 n_periods_tc = time_diff_tc / p->cir_period;
633 n_periods_te = time_diff_te / p->eir_period;
634 m->
time_tc += n_periods_tc * p->cir_period;
635 m->
time_te += n_periods_te * p->eir_period;
637 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
641 te = m->
te + n_periods_te * p->eir_bytes_per_period;
647 m->
tc = tc - pkt_len;
654 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)