cxgbetool(8): Require and validate only those inputs that are applicable

to the type of rate limiter being configured.  For example, the class
WRR scheduler doesn't need any kbps limits (it just needs the weights
for each class), the channel scheduler doesn't need anything except the
aggregate kbps to limit the channel to, and so on.

MFC after:	3 days
Sponsored by:	Chelsio Communications
This commit is contained in:
np 2018-07-25 17:20:54 +00:00
parent bdff5bbe7f
commit 94f88a51a2

View File

@ -2862,15 +2862,20 @@ sched_class(int argc, const char *argv[])
warnx("sched params \"level\" parameter missing");
errs++;
}
if (op.u.params.mode < 0) {
if (op.u.params.mode < 0 &&
op.u.params.level == SCHED_CLASS_LEVEL_CL_RL) {
warnx("sched params \"mode\" parameter missing");
errs++;
}
if (op.u.params.rateunit < 0) {
if (op.u.params.rateunit < 0 &&
(op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
op.u.params.level == SCHED_CLASS_LEVEL_CH_RL)) {
warnx("sched params \"rate-unit\" parameter missing");
errs++;
}
if (op.u.params.ratemode < 0) {
if (op.u.params.ratemode < 0 &&
(op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
op.u.params.level == SCHED_CLASS_LEVEL_CH_RL)) {
warnx("sched params \"rate-mode\" parameter missing");
errs++;
}
@ -2878,7 +2883,9 @@ sched_class(int argc, const char *argv[])
warnx("sched params \"channel\" missing");
errs++;
}
if (op.u.params.cl < 0) {
if (op.u.params.cl < 0 &&
(op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
op.u.params.level == SCHED_CLASS_LEVEL_CL_WRR)) {
warnx("sched params \"class\" missing");
errs++;
}
@ -2889,15 +2896,14 @@ sched_class(int argc, const char *argv[])
"rate-limit level");
errs++;
}
if (op.u.params.weight < 0 &&
op.u.params.level == SCHED_CLASS_LEVEL_CL_WRR) {
warnx("sched params \"weight\" missing for "
"weighted-round-robin level");
if (op.u.params.level == SCHED_CLASS_LEVEL_CL_WRR &&
(op.u.params.weight < 1 || op.u.params.weight > 99)) {
warnx("sched params \"weight\" missing or invalid "
"(not 1-99) for weighted-round-robin level");
errs++;
}
if (op.u.params.pktsize < 0 &&
(op.u.params.level == SCHED_CLASS_LEVEL_CL_RL ||
op.u.params.level == SCHED_CLASS_LEVEL_CH_RL)) {
op.u.params.level == SCHED_CLASS_LEVEL_CL_RL) {
warnx("sched params \"pkt-size\" missing for "
"rate-limit level");
errs++;