+static inline uint16_t
+rte_sched_port_pipe_queue(struct rte_sched_port *port, uint32_t traffic_class)
+{
+ uint16_t pipe_queue = port->pipe_queue[traffic_class];
+
+ return pipe_queue;
+}
+
+static inline uint8_t
+rte_sched_port_pipe_tc(struct rte_sched_port *port, uint32_t qindex)
+{
+ uint8_t pipe_tc = port->pipe_tc[qindex & (RTE_SCHED_QUEUES_PER_PIPE - 1)];
+
+ return pipe_tc;
+}
+
+static inline uint8_t
+rte_sched_port_tc_queue(struct rte_sched_port *port, uint32_t qindex)
+{
+ uint8_t tc_queue = port->tc_queue[qindex & (RTE_SCHED_QUEUES_PER_PIPE - 1)];
+
+ return tc_queue;
+}
+
+static int
+pipe_profile_check(struct rte_sched_pipe_params *params,
+ uint32_t rate, uint16_t *qsize)
+{
+ uint32_t i;
+
+ /* Pipe parameters */
+ if (params == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter params\n", __func__);
+ return -EINVAL;
+ }
+
+ /* TB rate: non-zero, not greater than port rate */
+ if (params->tb_rate == 0 ||
+ params->tb_rate > rate) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tb rate\n", __func__);
+ return -EINVAL;
+ }
+
+ /* TB size: non-zero */
+ if (params->tb_size == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tb size\n", __func__);
+ return -EINVAL;
+ }
+
+ /* TC rate: non-zero if qsize non-zero, less than pipe rate */
+ for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
+ if ((qsize[i] == 0 && params->tc_rate[i] != 0) ||
+ (qsize[i] != 0 && (params->tc_rate[i] == 0 ||
+ params->tc_rate[i] > params->tb_rate))) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for qsize or tc_rate\n", __func__);
+ return -EINVAL;
+ }
+ }
+
+ if (params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0 ||
+ qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for be traffic class rate\n", __func__);
+ return -EINVAL;
+ }
+
+ /* TC period: non-zero */
+ if (params->tc_period == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tc period\n", __func__);
+ return -EINVAL;
+ }
+
+ /* Best effort tc oversubscription weight: non-zero */
+ if (params->tc_ov_weight == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tc ov weight\n", __func__);
+ return -EINVAL;
+ }
+
+ /* Queue WRR weights: non-zero */
+ for (i = 0; i < RTE_SCHED_BE_QUEUES_PER_PIPE; i++) {
+ if (params->wrr_weights[i] == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for wrr weight\n", __func__);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+