#pragma warning(disable:2259) /* conversion may lose significant bits */
#endif
-#ifndef RTE_SCHED_OPTIMIZATIONS
-#define RTE_SCHED_OPTIMIZATIONS 0
-#endif
-
-#if RTE_SCHED_OPTIMIZATIONS
+#ifdef RTE_SCHED_VECTOR
#include <immintrin.h>
#endif
-#define RTE_SCHED_ENQUEUE 1
-
-#define RTE_SCHED_TS 1
-
-#if RTE_SCHED_TS == 0 /* Infinite credits. Traffic shaping disabled. */
-#define RTE_SCHED_TS_CREDITS_UPDATE 0
-#define RTE_SCHED_TS_CREDITS_CHECK 0
-#else /* Real Credits. Full traffic shaping implemented. */
-#define RTE_SCHED_TS_CREDITS_UPDATE 1
-#define RTE_SCHED_TS_CREDITS_CHECK 1
-#endif
-
-#ifndef RTE_SCHED_TB_RATE_CONFIG_ERR
#define RTE_SCHED_TB_RATE_CONFIG_ERR (1e-7)
-#endif
-
-#define RTE_SCHED_WRR 1
-
-#ifndef RTE_SCHED_WRR_SHIFT
#define RTE_SCHED_WRR_SHIFT 3
-#endif
-
-#ifndef RTE_SCHED_PORT_N_GRINDERS
-#define RTE_SCHED_PORT_N_GRINDERS 8
-#endif
-#if (RTE_SCHED_PORT_N_GRINDERS == 0) || (RTE_SCHED_PORT_N_GRINDERS & (RTE_SCHED_PORT_N_GRINDERS - 1))
-#error Number of grinders must be non-zero and a power of 2
-#endif
-#if (RTE_SCHED_OPTIMIZATIONS && (RTE_SCHED_PORT_N_GRINDERS != 8))
-#error Number of grinders must be 8 when RTE_SCHED_OPTIMIZATIONS is set
-#endif
-
#define RTE_SCHED_GRINDER_PCACHE_SIZE (64 / RTE_SCHED_QUEUES_PER_PIPE)
-
#define RTE_SCHED_PIPE_INVALID UINT32_MAX
-
#define RTE_SCHED_BMP_POS_INVALID UINT32_MAX
struct rte_sched_subport {
return NULL;
}
+ /* compile time checks */
+ RTE_BUILD_BUG_ON(RTE_SCHED_PORT_N_GRINDERS == 0);
+ RTE_BUILD_BUG_ON(RTE_SCHED_PORT_N_GRINDERS & (RTE_SCHED_PORT_N_GRINDERS - 1));
+
/* User parameters */
port->n_subports_per_port = params->n_subports_per_port;
port->n_pipes_per_subport = params->n_pipes_per_subport;
return 1;
}
-#if RTE_SCHED_ENQUEUE == 0
-
-int
-rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)
-{
- uint32_t result, i;
-
- result = 0;
-
- for (i = 0; i < n_pkts; i ++) {
- struct rte_mbuf *pkt;
- struct rte_mbuf **q_base;
- uint32_t subport, pipe, traffic_class, queue, qindex;
-
- pkt = pkts[i];
-
- rte_sched_port_pkt_read_tree_path(pkt, &subport, &pipe, &traffic_class, &queue);
-
- qindex = rte_sched_port_qindex(port, subport, pipe, traffic_class, queue);
-
- q_base = rte_sched_port_qbase(port, qindex);
-
- result += rte_sched_port_enqueue_qwa(port, qindex, q_base, pkt);
- }
-
- return result;
-}
-
-#else
/*
* The enqueue function implements a 4-level pipeline with each stage processing
return result;
}
-#endif /* RTE_SCHED_ENQUEUE */
-
-#if RTE_SCHED_TS_CREDITS_UPDATE == 0
-
-#define grinder_credits_update(port, pos)
-
-#elif !defined(RTE_SCHED_SUBPORT_TC_OV)
+#ifndef RTE_SCHED_SUBPORT_TC_OV
static inline void
grinder_credits_update(struct rte_sched_port *port, uint32_t pos)
#endif /* RTE_SCHED_TS_CREDITS_UPDATE, RTE_SCHED_SUBPORT_TC_OV */
-#if RTE_SCHED_TS_CREDITS_CHECK
#ifndef RTE_SCHED_SUBPORT_TC_OV
#endif /* RTE_SCHED_SUBPORT_TC_OV */
-#endif /* RTE_SCHED_TS_CREDITS_CHECK */
static inline int
grinder_schedule(struct rte_sched_port *port, uint32_t pos)
struct rte_mbuf *pkt = grinder->pkt;
uint32_t pkt_len = pkt->pkt_len + port->frame_overhead;
-#if RTE_SCHED_TS_CREDITS_CHECK
if (!grinder_credits_check(port, pos)) {
return 0;
}
-#endif
/* Advance port time */
port->time += pkt_len;
return 1;
}
-#if RTE_SCHED_OPTIMIZATIONS
+#ifdef RTE_SCHED_VECTOR
static inline int
grinder_pipe_exists(struct rte_sched_port *port, uint32_t base_pipe)
return 1;
}
-#if RTE_SCHED_WRR == 0
-
-#define grinder_wrr_load(a,b)
-
-#define grinder_wrr_store(a,b)
-
-static inline void
-grinder_wrr(struct rte_sched_port *port, uint32_t pos)
-{
- struct rte_sched_grinder *grinder = port->grinder + pos;
- uint64_t slab = grinder->qmask;
-
- if (rte_bsf64(slab, &grinder->qpos) == 0) {
- rte_panic("grinder wrr\n");
- }
-}
-
-#elif RTE_SCHED_WRR == 1
static inline void
grinder_wrr_load(struct rte_sched_port *port, uint32_t pos)
grinder->wrr_tokens[3] -= wrr_tokens_min;
}
-#else
-
-#error Invalid value for RTE_SCHED_WRR
-
-#endif /* RTE_SCHED_WRR */
#define grinder_evict(port, pos)