#pragma warning(disable:2259) /* conversion may lose significant bits */
#endif
-#ifndef RTE_SCHED_DEBUG
-#define RTE_SCHED_DEBUG 0
-#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 {
e_GRINDER_READ_MBUF
};
+/*
+ * Path through the scheduler hierarchy used by the scheduler enqueue
+ * operation to identify the destination queue for the current
+ * packet. Stored in the field pkt.hash.sched of struct rte_mbuf of
+ * each packet, typically written by the classification stage and read
+ * by scheduler enqueue.
+ */
+struct rte_sched_port_hierarchy {
+ uint32_t queue:2; /**< Queue ID (0 .. 3) */
+ uint32_t traffic_class:2; /**< Traffic class ID (0 .. 3)*/
+ uint32_t pipe:20; /**< Pipe ID */
+ uint32_t subport:6; /**< Subport ID */
+ uint32_t color:2; /**< Color */
+};
+
struct rte_sched_grinder {
/* Pipe cache */
uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE];
return -7;
}
- /* qsize: non-zero, power of 2, no bigger than 32K (due to 16-bit read/write pointers) */
+ /* qsize: non-zero, power of 2,
+ * no bigger than 32K (due to 16-bit read/write pointers) */
for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i ++) {
uint16_t qsize = params->qsize[i];
status = rte_sched_port_check_params(params);
if (status != 0) {
- RTE_LOG(INFO, SCHED, "Port scheduler params check failed (%d)\n", status);
+ RTE_LOG(NOTICE, SCHED,
+ "Port scheduler params check failed (%d)\n", status);
return 0;
}
{
struct rte_sched_pipe_profile *p = port->pipe_profiles + i;
- RTE_LOG(INFO, SCHED, "Low level config for pipe profile %u:\n"
+ RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
" Token bucket: period = %u, credits per period = %u, size = %u\n"
" Traffic classes: period = %u, credits per period = [%u, %u, %u, %u]\n"
" Traffic class 3 oversubscription: weight = %hhu\n"
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;
bmp_mem_size = rte_bitmap_get_memory_footprint(n_queues_per_port);
port->bmp = rte_bitmap_init(n_queues_per_port, port->bmp_array, bmp_mem_size);
if (port->bmp == NULL) {
- RTE_LOG(INFO, SCHED, "Bitmap init error\n");
+ RTE_LOG(ERR, SCHED, "Bitmap init error\n");
return NULL;
}
for (i = 0; i < RTE_SCHED_PORT_N_GRINDERS; i ++) {
{
struct rte_sched_subport *s = port->subport + i;
- RTE_LOG(INFO, SCHED, "Low level config for subport %u:\n"
+ RTE_LOG(DEBUG, SCHED, "Low level config for subport %u:\n"
" Token bucket: period = %u, credits per period = %u, size = %u\n"
" Traffic classes: period = %u, credits per period = [%u, %u, %u, %u]\n"
" Traffic class 3 oversubscription: wm min = %u, wm max = %u\n",
s->tc_ov = s->tc_ov_rate > subport_tc3_rate;
if (s->tc_ov != tc3_ov) {
- RTE_LOG(INFO, SCHED, "Subport %u TC3 oversubscription is OFF (%.4lf >= %.4lf)\n",
+ RTE_LOG(DEBUG, SCHED,
+ "Subport %u TC3 oversubscription is OFF (%.4lf >= %.4lf)\n",
subport_id, subport_tc3_rate, s->tc_ov_rate);
}
#endif
s->tc_ov = s->tc_ov_rate > subport_tc3_rate;
if (s->tc_ov != tc3_ov) {
- RTE_LOG(INFO, SCHED, "Subport %u TC3 oversubscription is ON (%.4lf < %.4lf)\n",
+ RTE_LOG(DEBUG, SCHED,
+ "Subport %u TC3 oversubscription is ON (%.4lf < %.4lf)\n",
subport_id, subport_tc3_rate, s->tc_ov_rate);
}
p->tc_ov_period_id = s->tc_ov_period_id;
return 0;
}
+void
+rte_sched_port_pkt_write(struct rte_mbuf *pkt,
+ uint32_t subport, uint32_t pipe, uint32_t traffic_class,
+ uint32_t queue, enum rte_meter_color color)
+{
+ struct rte_sched_port_hierarchy *sched
+ = (struct rte_sched_port_hierarchy *) &pkt->hash.sched;
+
+ sched->color = (uint32_t) color;
+ sched->subport = subport;
+ sched->pipe = pipe;
+ sched->traffic_class = traffic_class;
+ sched->queue = queue;
+}
+
+void
+rte_sched_port_pkt_read_tree_path(const struct rte_mbuf *pkt,
+ uint32_t *subport, uint32_t *pipe,
+ uint32_t *traffic_class, uint32_t *queue)
+{
+ const struct rte_sched_port_hierarchy *sched
+ = (const struct rte_sched_port_hierarchy *) &pkt->hash.sched;
+
+ *subport = sched->subport;
+ *pipe = sched->pipe;
+ *traffic_class = sched->traffic_class;
+ *queue = sched->queue;
+}
+
+
+enum rte_meter_color
+rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt)
+{
+ const struct rte_sched_port_hierarchy *sched
+ = (const struct rte_sched_port_hierarchy *) &pkt->hash.sched;
+
+ return (enum rte_meter_color) sched->color;
+}
+
int
rte_sched_subport_read_stats(struct rte_sched_port *port,
uint32_t subport_id,
return port->qsize[tc];
}
-#if RTE_SCHED_DEBUG
+#ifdef RTE_SCHED_DEBUG
static inline int
rte_sched_port_queue_is_empty(struct rte_sched_port *port, uint32_t qindex)
#endif /* RTE_SCHED_RED */
-#if RTE_SCHED_DEBUG
+#ifdef RTE_SCHED_DEBUG
static inline int
debug_pipe_is_empty(struct rte_sched_port *port, uint32_t pindex)
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
+/*
+ * The enqueue function implements a 4-level pipeline with each stage processing
* two different packets. The purpose of using a pipeline is to hide the latency
* of prefetching the data structures. The naming convention is presented in the
* diagram below:
* ----->|_______|----->|_______|----->|_______|----->|_______|----->
* p01 p11 p21 p31
*
- ***/
+ */
int
rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint32_t n_pkts)
{
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 0;
}
-#if RTE_SCHED_DEBUG
+#ifdef RTE_SCHED_DEBUG
debug_check_queue_slab(port, bmp_pos, bmp_slab);
#endif
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)