From patchwork Tue Nov 19 00:23:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 179617 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3599070ilf; Mon, 18 Nov 2019 16:23:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxV0sxDElQS/SKNYftutJHziAr0lICLu/TCAWb7jBo1dYwq8hnHLkpLxsaN/wZzBoqHmQZI X-Received: by 2002:a1c:4089:: with SMTP id n131mr2432209wma.86.1574123001623; Mon, 18 Nov 2019 16:23:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574123001; cv=none; d=google.com; s=arc-20160816; b=1KNK3ksMc2OjVZmplasNuwmFGp2lTGJHQ7qaluquHrS2j2pKO8oJ8qZL/JCLQ0skLE jNiSxR1j7XL9cT6b+Mckqke/I4BeqqXqXP9dpnG+suWMPHJYRO0FVGwdFr6gXLngj3gS m+tBaEyowwwxPVwx0KRyvDJy8mAkRorccn1yAEs6A9Z6bo7ol10I36GDBIvy4wtW/YA/ 4S3/CLKMoDAApxXfUWOjOPOHcrrTEjvzgvTiDrFjZw8ivu/1AdCF430zPAJlk5isxv46 oiMn7BEiDnbMDq8yS70vkq4TzskeP/aqZe4Vyr3jd7jdL9u4pm1lMlylRKkqO9S9x490 4XXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=4llU1F6LnwHCj5QCkkDFR2utRYRS39lSfGOyGIyfVHo=; b=MAedAQZOrTM6vIv/gFUbus9CtH+mc1u7TwItTxwZGfXPNYLj5JkGzZvbvF/saMzEWu nTxPIUJftNfT35I7jm/0sltCq2BcCjCliJ0TiszQyA+J7DzdcxAUQvlQwhMz0ZvjRRAr x+J2IS/yenn29/C/Yke4wICyWH/8XRYl0WizjP7hffY2V4Fxk3xqbj6I0sHJtmR1LfLg j/2OYHZH5H3irSp4iVWeWktb90CYQjbx98MjlC4U4P21JQo2w0FzOrWZtiQiaEEQYeQM A5QzfuR6YPrH38zeeOfaR8waluEk4AzFsJpkBXIgn142KtnRKIlXLKkc5bo9Vfk6nAyU fzNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hvkhe0Hy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si15425799edc.195.2019.11.18.16.23.21; Mon, 18 Nov 2019 16:23:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hvkhe0Hy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727491AbfKSAXT (ORCPT + 26 others); Mon, 18 Nov 2019 19:23:19 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37365 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727146AbfKSAXT (ORCPT ); Mon, 18 Nov 2019 19:23:19 -0500 Received: by mail-lf1-f68.google.com with SMTP id b20so15434456lfp.4 for ; Mon, 18 Nov 2019 16:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4llU1F6LnwHCj5QCkkDFR2utRYRS39lSfGOyGIyfVHo=; b=hvkhe0HyZsyEUxKasN7CBPhArMPIxYuemst7zJgC6mwFDHbojiQUgTIES3kmaCgK7H wzEpToDBrdS32NzPxH55/yoFLKYB+TYZkHGZgbBwMSgnki3v21XSkhc5LYUanlkIKLy6 4+y75ud2n1Iv24PNKkuKgy1+Bkac1xakcVGnUm06kDcreZO+YT+BbPVVQ3yNOfH4T7Qh BScxdSlLv8rDbQYBtqSVom7DP3EZHr3Oc3aRXHI7cyCoVNOuX+5YaT+KGKJVsjIN8hkl MSOsM3+L4aDwy11MnhjP9KbgrEKTBCTVY/U4k+FWEQ2axXFPiLjFwwyf9F880YnT1iFR 7yxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4llU1F6LnwHCj5QCkkDFR2utRYRS39lSfGOyGIyfVHo=; b=Vs7smdGZdP7SckJpmwxMUuvSECwno9ZwSDCmPpv6M5r+th5KoL3FMM/wDTSFes4owf Eq5ht+sVRqnDoM8G4+5WhqAfYmw1FO6n6fXDK01awbG3/ZsexJzPj+nNckJBB6DqbSBW fh39eEJGt8nPFUcGxQ9i7wFPgjOvhsCqIcuCgaoSmlUpjxKtllniimaZY0lSqjD/DhI8 kRjLbq6uG9XlQDHcJhxB3FzXfGbq8iM1Xk0dTcIy+/QTvLxzIVDVNOYad3NObK+n0bot EZNRzoo007573CyTEny3Hv8use98YYp+uJJSimrWr4BbwpNZlfTcesKbfdH3NEcQuqv4 OCCA== X-Gm-Message-State: APjAAAWcg/qLGA0nC3FhlO5ZQHOX5tdpud6r5PTektsgjcx/73udi9Bd Qo7sX+EtBH1kcF05taNna57VyA== X-Received: by 2002:a19:6e06:: with SMTP id j6mr1468098lfc.6.1574122996442; Mon, 18 Nov 2019 16:23:16 -0800 (PST) Received: from localhost.localdomain (57-201-94-178.pool.ukrtel.net. [178.94.201.57]) by smtp.gmail.com with ESMTPSA id i6sm2633167lfo.12.2019.11.18.16.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 16:23:15 -0800 (PST) From: Ivan Khoronzhuk To: netdev@vger.kernel.org, davem@davemloft.net, vinicius.gomes@intel.com Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, linux-kernel@vger.kernel.org, olteanv@gmail.com, Ivan Khoronzhuk Subject: [net PATCH v2] taprio: don't reject same mqprio settings Date: Tue, 19 Nov 2019 02:23:12 +0200 Message-Id: <20191119002312.23811-1-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The taprio qdisc allows to set mqprio setting but only once. In case if mqprio settings are provided next time the error is returned as it's not allowed to change traffic class mapping in-flignt and that is normal. But if configuration is absolutely the same - no need to return error. It allows to provide same command couple times, changing only base time for instance, or changing only scheds maps, but leaving mqprio setting w/o modification. It more corresponds the message: "Changing the traffic mapping of a running schedule is not supported", so reject mqprio if it's really changed. Also corrected TC_BITMASK + 1 for consistency, as proposed. Fixes: a3d43c0d56f1 ("taprio: Add support adding an admin schedule") Reviewed-by: Vladimir Oltean Tested-by: Vladimir Oltean Acked-by: Vinicius Costa Gomes Signed-off-by: Ivan Khoronzhuk --- v2..v1: - rebased on net/master instead of net-next/master - added fixes tag - corrected TC_BITMASK + 1 and used <= net/sched/sch_taprio.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 7cd68628c637..c609373c8661 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -922,7 +922,7 @@ static int taprio_parse_mqprio_opt(struct net_device *dev, } /* Verify priority mapping uses valid tcs */ - for (i = 0; i < TC_BITMASK + 1; i++) { + for (i = 0; i <= TC_BITMASK; i++) { if (qopt->prio_tc_map[i] >= qopt->num_tc) { NL_SET_ERR_MSG(extack, "Invalid traffic class in priority to traffic class mapping"); return -EINVAL; @@ -1347,6 +1347,26 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, return err; } +static int taprio_mqprio_cmp(const struct net_device *dev, + const struct tc_mqprio_qopt *mqprio) +{ + int i; + + if (!mqprio || mqprio->num_tc != dev->num_tc) + return -1; + + for (i = 0; i < mqprio->num_tc; i++) + if (dev->tc_to_txq[i].count != mqprio->count[i] || + dev->tc_to_txq[i].offset != mqprio->offset[i]) + return -1; + + for (i = 0; i <= TC_BITMASK; i++) + if (dev->prio_tc_map[i] != mqprio->prio_tc_map[i]) + return -1; + + return 0; +} + static int taprio_change(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) { @@ -1398,6 +1418,10 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, admin = rcu_dereference(q->admin_sched); rcu_read_unlock(); + /* no changes - no new mqprio settings */ + if (!taprio_mqprio_cmp(dev, mqprio)) + mqprio = NULL; + if (mqprio && (oper || admin)) { NL_SET_ERR_MSG(extack, "Changing the traffic mapping of a running schedule is not supported"); err = -ENOTSUPP; @@ -1455,7 +1479,7 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, mqprio->offset[i]); /* Always use supplied priority mappings */ - for (i = 0; i < TC_BITMASK + 1; i++) + for (i = 0; i <= TC_BITMASK; i++) netdev_set_prio_tc_map(dev, i, mqprio->prio_tc_map[i]); }