6#ifndef __INCLUDE_RTE_METER_H__
7#define __INCLUDE_RTE_METER_H__
73struct rte_meter_srtcm_profile;
79struct rte_meter_trtcm_profile;
85struct rte_meter_trtcm_rfc4115_profile;
88struct rte_meter_srtcm;
138 struct rte_meter_trtcm_rfc4115_profile *p,
153 struct rte_meter_srtcm_profile *p);
167 struct rte_meter_trtcm_profile *p);
181 struct rte_meter_trtcm_rfc4115_profile *p);
199 struct rte_meter_srtcm_profile *p,
221 struct rte_meter_srtcm_profile *p,
242 struct rte_meter_trtcm_profile *p,
264 struct rte_meter_trtcm_profile *p,
286 struct rte_meter_trtcm_rfc4115_profile *p,
309 struct rte_meter_trtcm_rfc4115_profile *p,
318struct rte_meter_srtcm_profile {
325 uint64_t cir_bytes_per_period;
330struct rte_meter_srtcm {
336struct rte_meter_trtcm_profile {
343 uint64_t cir_bytes_per_period;
347 uint64_t pir_bytes_per_period;
366struct rte_meter_trtcm_rfc4115_profile {
373 uint64_t cir_bytes_per_period;
377 uint64_t eir_bytes_per_period;
398 struct rte_meter_srtcm_profile *p,
402 uint64_t time_diff, n_periods, tc, te;
405 time_diff = time - m->time;
406 n_periods = time_diff / p->cir_period;
407 m->time += n_periods * p->cir_period;
410 tc = m->tc + n_periods * p->cir_bytes_per_period;
421 m->tc = tc - pkt_len;
428 m->te = te - pkt_len;
439 struct rte_meter_srtcm_profile *p,
444 uint64_t time_diff, n_periods, tc, te;
447 time_diff = time - m->time;
448 n_periods = time_diff / p->cir_period;
449 m->time += n_periods * p->cir_period;
452 tc = m->tc + n_periods * p->cir_bytes_per_period;
463 m->tc = tc - pkt_len;
470 m->te = te - pkt_len;
481 struct rte_meter_trtcm_profile *p,
485 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
488 time_diff_tc = time - m->
time_tc;
489 time_diff_tp = time - m->
time_tp;
490 n_periods_tc = time_diff_tc / p->cir_period;
491 n_periods_tp = time_diff_tp / p->pir_period;
492 m->
time_tc += n_periods_tc * p->cir_period;
493 m->
time_tp += n_periods_tp * p->pir_period;
495 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
499 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
512 m->
tp = tp - pkt_len;
516 m->
tc = tc - pkt_len;
517 m->
tp = tp - pkt_len;
523 struct rte_meter_trtcm_profile *p,
528 uint64_t time_diff_tc, time_diff_tp, n_periods_tc, n_periods_tp, tc, tp;
531 time_diff_tc = time - m->
time_tc;
532 time_diff_tp = time - m->
time_tp;
533 n_periods_tc = time_diff_tc / p->cir_period;
534 n_periods_tp = time_diff_tp / p->pir_period;
535 m->
time_tc += n_periods_tc * p->cir_period;
536 m->
time_tp += n_periods_tp * p->pir_period;
538 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
542 tp = m->
tp + n_periods_tp * p->pir_bytes_per_period;
555 m->
tp = tp - pkt_len;
559 m->
tc = tc - pkt_len;
560 m->
tp = tp - pkt_len;
567 struct rte_meter_trtcm_rfc4115_profile *p,
571 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
574 time_diff_tc = time - m->
time_tc;
575 time_diff_te = time - m->
time_te;
576 n_periods_tc = time_diff_tc / p->cir_period;
577 n_periods_te = time_diff_te / p->eir_period;
578 m->
time_tc += n_periods_tc * p->cir_period;
579 m->
time_te += n_periods_te * p->eir_period;
581 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
585 te = m->
te + n_periods_te * p->eir_bytes_per_period;
591 m->
tc = tc - pkt_len;
597 m->
te = te - pkt_len;
610 struct rte_meter_trtcm_rfc4115_profile *p,
615 uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
618 time_diff_tc = time - m->
time_tc;
619 time_diff_te = time - m->
time_te;
620 n_periods_tc = time_diff_tc / p->cir_period;
621 n_periods_te = time_diff_te / p->eir_period;
622 m->
time_tc += n_periods_tc * p->cir_period;
623 m->
time_te += n_periods_te * p->eir_period;
625 tc = m->
tc + n_periods_tc * p->cir_bytes_per_period;
629 te = m->
te + n_periods_te * p->eir_bytes_per_period;
635 m->
tc = tc - pkt_len;
642 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)