+int
+rte_sched_subport_pipe_profile_add(struct rte_sched_port *port,
+ uint32_t subport_id,
+ struct rte_sched_pipe_params *params,
+ uint32_t *pipe_profile_id)
+{
+ struct rte_sched_subport *s;
+ struct rte_sched_pipe_profile *pp;
+ uint32_t i;
+ int status;
+
+ /* Port */
+ if (port == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter port\n", __func__);
+ return -EINVAL;
+ }
+
+ /* Subport id not exceeds the max limit */
+ if (subport_id > port->n_subports_per_port) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for subport id\n", __func__);
+ return -EINVAL;
+ }
+
+ s = port->subports[subport_id];
+
+ /* Pipe profiles exceeds the max limit */
+ if (s->n_pipe_profiles >= s->n_max_pipe_profiles) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Number of pipe profiles exceeds the max limit\n", __func__);
+ return -EINVAL;
+ }
+
+ /* Pipe params */
+ status = pipe_profile_check(params, port->rate, &s->qsize[0]);
+ if (status != 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Pipe profile check failed(%d)\n", __func__, status);
+ return -EINVAL;
+ }
+
+ pp = &s->pipe_profiles[s->n_pipe_profiles];
+ rte_sched_pipe_profile_convert(s, params, pp, port->rate);
+
+ /* Pipe profile should not exists */
+ for (i = 0; i < s->n_pipe_profiles; i++)
+ if (memcmp(s->pipe_profiles + i, pp, sizeof(*pp)) == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Pipe profile exists\n", __func__);
+ return -EINVAL;
+ }
+
+ /* Pipe profile commit */
+ *pipe_profile_id = s->n_pipe_profiles;
+ s->n_pipe_profiles++;
+
+ if (s->pipe_tc_be_rate_max < params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE])
+ s->pipe_tc_be_rate_max = params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
+
+ rte_sched_port_log_pipe_profile(s, *pipe_profile_id);
+
+ return 0;
+}
+
+int
+rte_sched_port_subport_profile_add(struct rte_sched_port *port,
+ struct rte_sched_subport_profile_params *params,
+ uint32_t *subport_profile_id)
+{
+ int status;
+ uint32_t i;
+ struct rte_sched_subport_profile *dst;
+
+ /* Port */
+ if (port == NULL) {
+ RTE_LOG(ERR, SCHED, "%s: "
+ "Incorrect value for parameter port\n", __func__);
+ return -EINVAL;
+ }
+
+ if (params == NULL) {
+ RTE_LOG(ERR, SCHED, "%s: "
+ "Incorrect value for parameter profile\n", __func__);
+ return -EINVAL;
+ }
+
+ if (subport_profile_id == NULL) {
+ RTE_LOG(ERR, SCHED, "%s: "
+ "Incorrect value for parameter subport_profile_id\n",
+ __func__);
+ return -EINVAL;
+ }
+
+ dst = port->subport_profiles + port->n_subport_profiles;
+
+ /* Subport profiles exceeds the max limit */
+ if (port->n_subport_profiles >= port->n_max_subport_profiles) {
+ RTE_LOG(ERR, SCHED, "%s: "
+ "Number of subport profiles exceeds the max limit\n",
+ __func__);
+ return -EINVAL;
+ }
+
+ status = subport_profile_check(params, port->rate);
+ if (status != 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: subport profile check failed(%d)\n", __func__, status);
+ return -EINVAL;
+ }
+
+ rte_sched_subport_profile_convert(params, dst, port->rate);
+
+ /* Subport profile should not exists */
+ for (i = 0; i < port->n_subport_profiles; i++)
+ if (memcmp(port->subport_profiles + i,
+ dst, sizeof(*dst)) == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: subport profile exists\n", __func__);
+ return -EINVAL;
+ }
+
+ /* Subport profile commit */
+ *subport_profile_id = port->n_subport_profiles;
+ port->n_subport_profiles++;
+
+ rte_sched_port_log_subport_profile(port, *subport_profile_id);
+
+ return 0;
+}
+
+static inline uint32_t
+rte_sched_port_qindex(struct rte_sched_port *port,
+ uint32_t subport,
+ uint32_t pipe,
+ uint32_t traffic_class,
+ uint32_t queue)