uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE];
uint32_t n_pipe_profiles;
uint32_t n_max_pipe_profiles;
- uint32_t pipe_tc3_rate_max;
+ uint32_t pipe_tc_be_rate_max;
#ifdef RTE_SCHED_RED
struct rte_red_config red_config[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE][RTE_COLORS];
#endif
uint32_t i;
/* Pipe parameters */
- if (params == NULL)
- return -10;
+ 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)
- return -11;
+ 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)
- return -12;
+ 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)))
- return -13;
+ 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)
- return -13;
+ 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)
- return -14;
+ if (params->tc_period == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tc period\n", __func__);
+ return -EINVAL;
+ }
- /* TC3 oversubscription weight: non-zero */
- if (params->tc_ov_weight == 0)
- return -15;
+ /* 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)
- return -16;
+ if (params->wrr_weights[i] == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for wrr weight\n", __func__);
+ return -EINVAL;
+ }
}
return 0;
{
uint32_t i;
- if (params == NULL)
- return -1;
+ if (params == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter params\n", __func__);
+ return -EINVAL;
+ }
/* socket */
- if (params->socket < 0)
- return -3;
+ if (params->socket < 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for socket id\n", __func__);
+ return -EINVAL;
+ }
/* rate */
- if (params->rate == 0)
- return -4;
+ if (params->rate == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for rate\n", __func__);
+ return -EINVAL;
+ }
/* mtu */
- if (params->mtu == 0)
- return -5;
+ if (params->mtu == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for mtu\n", __func__);
+ return -EINVAL;
+ }
/* n_subports_per_port: non-zero, limited to 16 bits, power of 2 */
if (params->n_subports_per_port == 0 ||
params->n_subports_per_port > 1u << 16 ||
- !rte_is_power_of_2(params->n_subports_per_port))
- return -6;
+ !rte_is_power_of_2(params->n_subports_per_port)) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for number of subports\n", __func__);
+ return -EINVAL;
+ }
/* n_pipes_per_subport: non-zero, power of 2 */
if (params->n_pipes_per_subport == 0 ||
- !rte_is_power_of_2(params->n_pipes_per_subport))
- return -7;
+ !rte_is_power_of_2(params->n_pipes_per_subport)) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for pipes number\n", __func__);
+ return -EINVAL;
+ }
- /* qsize: non-zero, power of 2,
+ /* qsize: if 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];
if ((qsize != 0 && !rte_is_power_of_2(qsize)) ||
- ((i == RTE_SCHED_TRAFFIC_CLASS_BE) && (qsize == 0)))
- return -8;
+ ((i == RTE_SCHED_TRAFFIC_CLASS_BE) && (qsize == 0))) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tc rate\n", __func__);
+ return -EINVAL;
+ }
}
/* pipe_profiles and n_pipe_profiles */
if (params->pipe_profiles == NULL ||
params->n_pipe_profiles == 0 ||
- params->n_pipe_profiles > params->n_max_pipe_profiles)
- return -9;
+ params->n_pipe_profiles > params->n_max_pipe_profiles) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for number of pipe profiles\n", __func__);
+ return -EINVAL;
+ }
for (i = 0; i < params->n_pipe_profiles; i++) {
struct rte_sched_pipe_params *p = params->pipe_profiles + i;
int status;
status = pipe_profile_check(p, params->rate, ¶ms->qsize[0]);
- if (status != 0)
- return status;
+ if (status != 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Pipe profile check failed(%d)\n", __func__, status);
+ return -EINVAL;
+ }
}
return 0;
p->tc_credits_per_period[11],
p->tc_credits_per_period[12],
- /* Traffic class 3 oversubscription */
+ /* Best-effort traffic class oversubscription */
p->tc_ov_weight,
/* WRR */
rte_sched_port_log_pipe_profile(port, i);
}
- port->pipe_tc3_rate_max = 0;
+ port->pipe_tc_be_rate_max = 0;
for (i = 0; i < port->n_pipe_profiles; i++) {
struct rte_sched_pipe_params *src = params->pipe_profiles + i;
- uint32_t pipe_tc3_rate = src->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
+ uint32_t pipe_tc_be_rate = src->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
- if (port->pipe_tc3_rate_max < pipe_tc3_rate)
- port->pipe_tc3_rate_max = pipe_tc3_rate;
+ if (port->pipe_tc_be_rate_max < pipe_tc_be_rate)
+ port->pipe_tc_be_rate_max = pipe_tc_be_rate;
}
}
s->tc_credits_per_period[11],
s->tc_credits_per_period[12],
- /* Traffic class 3 oversubscription */
+ /* Best effort traffic class oversubscription */
s->tc_ov_wm_min,
s->tc_ov_wm_max);
}
uint32_t i;
/* Check user parameters */
- if (port == NULL ||
- subport_id >= port->n_subports_per_port ||
- params == NULL)
- return -1;
+ if (port == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter port\n", __func__);
+ return -EINVAL;
+ }
- if (params->tb_rate == 0 || params->tb_rate > port->rate)
- return -2;
+ if (subport_id >= port->n_subports_per_port) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for subport id\n", __func__);
+ return -EINVAL;
+ }
- if (params->tb_size == 0)
- return -3;
+ if (params == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter params\n", __func__);
+ return -EINVAL;
+ }
+
+ if (params->tb_rate == 0 || params->tb_rate > port->rate) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tb rate\n", __func__);
+ return -EINVAL;
+ }
+
+ if (params->tb_size == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tb size\n", __func__);
+ return -EINVAL;
+ }
for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
uint32_t tc_rate = params->tc_rate[i];
if ((qsize == 0 && tc_rate != 0) ||
(qsize != 0 && tc_rate == 0) ||
- (tc_rate > params->tb_rate))
- return -4;
+ (tc_rate > params->tb_rate)) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tc rate\n", __func__);
+ return -EINVAL;
+ }
}
if (port->qsize[RTE_SCHED_TRAFFIC_CLASS_BE] == 0 ||
- params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0)
- return -4;
+ params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE] == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tc rate(best effort)\n", __func__);
+ return -EINVAL;
+ }
- if (params->tc_period == 0)
- return -5;
+ if (params->tc_period == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tc period\n", __func__);
+ return -EINVAL;
+ }
s = port->subport + subport_id;
/* TC oversubscription */
s->tc_ov_wm_min = port->mtu;
s->tc_ov_wm_max = rte_sched_time_ms_to_bytes(params->tc_period,
- port->pipe_tc3_rate_max);
+ port->pipe_tc_be_rate_max);
s->tc_ov_wm = s->tc_ov_wm_max;
s->tc_ov_period_id = 0;
s->tc_ov = 0;
profile = (uint32_t) pipe_profile;
deactivate = (pipe_profile < 0);
- if (port == NULL ||
- subport_id >= port->n_subports_per_port ||
- pipe_id >= port->n_pipes_per_subport ||
- (!deactivate && profile >= port->n_pipe_profiles))
- return -1;
+ if (port == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter port\n", __func__);
+ return -EINVAL;
+ }
+
+ if (subport_id >= port->n_subports_per_port) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter subport id\n", __func__);
+ return -EINVAL;
+ }
+ if (pipe_id >= port->n_pipes_per_subport) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter pipe id\n", __func__);
+ return -EINVAL;
+ }
+
+ if (!deactivate && profile >= port->n_pipe_profiles) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter pipe profile\n", __func__);
+ return -EINVAL;
+ }
/* Check that subport configuration is valid */
s = port->subport + subport_id;
- if (s->tb_period == 0)
- return -2;
+ if (s->tb_period == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Subport configuration invalid\n", __func__);
+ return -EINVAL;
+ }
p = port->pipe + (subport_id * port->n_pipes_per_subport + pipe_id);
if (p->tb_time) {
params = port->pipe_profiles + p->profile;
- double subport_tc3_rate =
+ double subport_tc_be_rate =
(double) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
/ (double) s->tc_period;
- double pipe_tc3_rate =
+ double pipe_tc_be_rate =
(double) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
/ (double) params->tc_period;
- uint32_t tc3_ov = s->tc_ov;
+ uint32_t tc_be_ov = s->tc_ov;
/* Unplug pipe from its subport */
s->tc_ov_n -= params->tc_ov_weight;
- s->tc_ov_rate -= pipe_tc3_rate;
- s->tc_ov = s->tc_ov_rate > subport_tc3_rate;
+ s->tc_ov_rate -= pipe_tc_be_rate;
+ s->tc_ov = s->tc_ov_rate > subport_tc_be_rate;
- if (s->tc_ov != tc3_ov) {
+ if (s->tc_ov != tc_be_ov) {
RTE_LOG(DEBUG, SCHED,
- "Subport %u TC3 oversubscription is OFF (%.4lf >= %.4lf)\n",
- subport_id, subport_tc3_rate, s->tc_ov_rate);
+ "Subport %u Best-effort TC oversubscription is OFF (%.4lf >= %.4lf)\n",
+ subport_id, subport_tc_be_rate, s->tc_ov_rate);
}
/* Reset the pipe */
p->tc_credits[i] = params->tc_credits_per_period[i];
{
- /* Subport TC3 oversubscription */
- double subport_tc3_rate =
+ /* Subport best effort tc oversubscription */
+ double subport_tc_be_rate =
(double) s->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
/ (double) s->tc_period;
- double pipe_tc3_rate =
+ double pipe_tc_be_rate =
(double) params->tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASS_BE]
/ (double) params->tc_period;
- uint32_t tc3_ov = s->tc_ov;
+ uint32_t tc_be_ov = s->tc_ov;
s->tc_ov_n += params->tc_ov_weight;
- s->tc_ov_rate += pipe_tc3_rate;
- s->tc_ov = s->tc_ov_rate > subport_tc3_rate;
+ s->tc_ov_rate += pipe_tc_be_rate;
+ s->tc_ov = s->tc_ov_rate > subport_tc_be_rate;
- if (s->tc_ov != tc3_ov) {
+ if (s->tc_ov != tc_be_ov) {
RTE_LOG(DEBUG, SCHED,
- "Subport %u TC3 oversubscription is ON (%.4lf < %.4lf)\n",
- subport_id, subport_tc3_rate, s->tc_ov_rate);
+ "Subport %u Best effort TC oversubscription is ON (%.4lf < %.4lf)\n",
+ subport_id, subport_tc_be_rate, s->tc_ov_rate);
}
p->tc_ov_period_id = s->tc_ov_period_id;
p->tc_ov_credits = s->tc_ov_wm;
int status;
/* Port */
- if (port == NULL)
- return -1;
+ if (port == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter port\n", __func__);
+ return -EINVAL;
+ }
/* Pipe profiles not exceeds the max limit */
- if (port->n_pipe_profiles >= port->n_max_pipe_profiles)
- return -2;
+ if (port->n_pipe_profiles >= port->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, &port->qsize[0]);
- if (status != 0)
- return status;
+ if (status != 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Pipe profile check failed(%d)\n", __func__, status);
+ return -EINVAL;
+ }
pp = &port->pipe_profiles[port->n_pipe_profiles];
rte_sched_pipe_profile_convert(port, params, pp, port->rate);
/* Pipe profile not exists */
for (i = 0; i < port->n_pipe_profiles; i++)
- if (memcmp(port->pipe_profiles + i, pp, sizeof(*pp)) == 0)
- return -3;
+ if (memcmp(port->pipe_profiles + i, pp, sizeof(*pp)) == 0) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Pipe profile doesn't exist\n", __func__);
+ return -EINVAL;
+ }
/* Pipe profile commit */
*pipe_profile_id = port->n_pipe_profiles;
port->n_pipe_profiles++;
- if (port->pipe_tc3_rate_max < params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE])
- port->pipe_tc3_rate_max = params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
+ if (port->pipe_tc_be_rate_max < params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE])
+ port->pipe_tc_be_rate_max = params->tc_rate[RTE_SCHED_TRAFFIC_CLASS_BE];
rte_sched_port_log_pipe_profile(port, *pipe_profile_id);
struct rte_sched_subport *s;
/* Check user parameters */
- if (port == NULL || subport_id >= port->n_subports_per_port ||
- stats == NULL || tc_ov == NULL)
- return -1;
+ if (port == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter port\n", __func__);
+ return -EINVAL;
+ }
+
+ if (subport_id >= port->n_subports_per_port) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for subport id\n", __func__);
+ return -EINVAL;
+ }
+
+ if (stats == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter stats\n", __func__);
+ return -EINVAL;
+ }
+
+ if (tc_ov == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for tc_ov\n", __func__);
+ return -EINVAL;
+ }
s = port->subport + subport_id;
struct rte_sched_queue_extra *qe;
/* Check user parameters */
- if ((port == NULL) ||
- (queue_id >= rte_sched_port_queues_per_port(port)) ||
- (stats == NULL) ||
- (qlen == NULL)) {
- return -1;
+ if (port == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter port\n", __func__);
+ return -EINVAL;
+ }
+
+ if (queue_id >= rte_sched_port_queues_per_port(port)) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for queue id\n", __func__);
+ return -EINVAL;
+ }
+
+ if (stats == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter stats\n", __func__);
+ return -EINVAL;
+ }
+
+ if (qlen == NULL) {
+ RTE_LOG(ERR, SCHED,
+ "%s: Incorrect value for parameter qlen\n", __func__);
+ return -EINVAL;
}
q = port->queue + queue_id;
qe = port->queue_extra + queue_id;