sched: enable SSE optimizations in config
[dpdk.git] / lib / librte_sched / rte_sched.c
index 4dcf92c..caf5f52 100644 (file)
 #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 {
@@ -635,6 +599,10 @@ rte_sched_port_config(struct rte_sched_port_params *params)
                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;
@@ -1285,35 +1253,6 @@ rte_sched_port_enqueue_qwa(struct rte_sched_port *port, uint32_t qindex, struct
        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
@@ -1476,13 +1415,7 @@ rte_sched_port_enqueue(struct rte_sched_port *port, struct rte_mbuf **pkts, uint
        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)
@@ -1615,7 +1548,6 @@ 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
 
@@ -1696,7 +1628,6 @@ grinder_credits_check(struct rte_sched_port *port, uint32_t pos)
 
 #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)
@@ -1706,11 +1637,9 @@ 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;
@@ -1735,7 +1664,7 @@ grinder_schedule(struct rte_sched_port *port, uint32_t pos)
        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)
@@ -1930,24 +1859,6 @@ grinder_next_pipe(struct rte_sched_port *port, uint32_t pos)
        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)
@@ -2013,11 +1924,6 @@ grinder_wrr(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)