+ return RTE_COLOR_GREEN;
+}
+
+__rte_experimental
+static inline 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)
+{
+ uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
+
+ /* Bucket update */
+ time_diff_tc = time - m->time_tc;
+ time_diff_te = time - m->time_te;
+ n_periods_tc = time_diff_tc / p->cir_period;
+ n_periods_te = time_diff_te / p->eir_period;
+ m->time_tc += n_periods_tc * p->cir_period;
+ m->time_te += n_periods_te * p->eir_period;
+
+ tc = m->tc + n_periods_tc * p->cir_bytes_per_period;
+ if (tc > p->cbs)
+ tc = p->cbs;
+
+ te = m->te + n_periods_te * p->eir_bytes_per_period;
+ if (te > p->ebs)
+ te = p->ebs;
+
+ /* Color logic */
+ if (tc >= pkt_len) {
+ m->tc = tc - pkt_len;
+ m->te = te;
+ return RTE_COLOR_GREEN;
+ }
+ if (te >= pkt_len) {
+ m->tc = tc;
+ m->te = te - pkt_len;
+ return RTE_COLOR_YELLOW;
+ }
+
+ /* If we end up here the color is RED */
+ m->tc = tc;
+ m->te = te;
+ return RTE_COLOR_RED;
+}
+
+__rte_experimental
+static inline 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)
+{
+ uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc, te;
+
+ /* Bucket update */
+ time_diff_tc = time - m->time_tc;
+ time_diff_te = time - m->time_te;
+ n_periods_tc = time_diff_tc / p->cir_period;
+ n_periods_te = time_diff_te / p->eir_period;
+ m->time_tc += n_periods_tc * p->cir_period;
+ m->time_te += n_periods_te * p->eir_period;
+
+ tc = m->tc + n_periods_tc * p->cir_bytes_per_period;
+ if (tc > p->cbs)
+ tc = p->cbs;
+
+ te = m->te + n_periods_te * p->eir_bytes_per_period;
+ if (te > p->ebs)
+ te = p->ebs;
+
+ /* Color logic */
+ if ((pkt_color == RTE_COLOR_GREEN) && (tc >= pkt_len)) {
+ m->tc = tc - pkt_len;
+ m->te = te;
+ return RTE_COLOR_GREEN;
+ }
+
+ if ((pkt_color != RTE_COLOR_RED) && (te >= pkt_len)) {
+ m->tc = tc;
+ m->te = te - pkt_len;
+ return RTE_COLOR_YELLOW;
+ }
+
+ /* If we end up here the color is RED */
+ m->tc = tc;
+ m->te = te;
+ return RTE_COLOR_RED;