From patchwork Fri Jan 26 02:26:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 866122 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kcjIbwaq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zSN7x449Zz9sNc for ; Fri, 26 Jan 2018 13:26:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751559AbeAZC0e (ORCPT ); Thu, 25 Jan 2018 21:26:34 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34168 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751542AbeAZC0c (ORCPT ); Thu, 25 Jan 2018 21:26:32 -0500 Received: by mail-pg0-f68.google.com with SMTP id r19so6330508pgn.1 for ; Thu, 25 Jan 2018 18:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x6Q6HsD5aDiKaPsEhdvBmRe2Txi4eonh2MLfUyEHgpQ=; b=kcjIbwaqDJPbKcKhbX/cRNVGMCDCV3X6xzIiLrEuRZLK6gdIY0s7bWmN15uwkTjFDo Q71Av+197ohB0VFeYXn1Fkjp0MWRIPtf67bqtemieTDyaRbsuclH/fPEPsR+wP+rioyi CGjpFa5p8NIeVOidUPNTjaKMQwTtCLwGufZ1HLTAeMRy5qRBeF++x7n4MZsZS7brE3w0 m98wMqEbxkiBXfpi/XKgg6AJw3LuhQpshAjDRxR5s1UV040OGhVOOurCh0FjPbebd5mx NTp+E8tm8vGAI9mn18bqiLT8eC5saP8pqJRLIKn4OFaaWcl2YQMhxGbTVsz1O2vJ5qn3 YaZg== 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:in-reply-to :references; bh=x6Q6HsD5aDiKaPsEhdvBmRe2Txi4eonh2MLfUyEHgpQ=; b=M7pFx2KsEchEKAtPrKM+31jPnX2mjAWyEvFKK6xgM9Ap2pAh7Wm5ZtfA46PKyf9eWt QGOCPufaDTu/CRyVu+DHLAVzZptMZFV5XUyrNAIBidga0o9Zo2JH+WXRiyn3wkoGqANK oUuWIve8s2UTnrOvI3SqPTHizLMoxXd/HL/wPCk29Q9t4HNNSTWLOIPBpEOwGe/TiNKQ ykzGqa5mSH0JIurbViJD0Ck7q/CfwzsEViKKilq19EDyP/ILDNoOQIHCmYmFtirsJQwd h9wpLzVn+ZZ1C/ZQnsy0UK9OC5+/VHMQD/nGvzyHryCkvvEYq17oJCDeb2X5cdN4f1Mk Zs3g== X-Gm-Message-State: AKwxytdBEKEGtEF1N25T+4+eZpM0PI8yzSFQXYd65wgd+Ymr3XxvuoGC Y2CCUsj79MEMlGmZKsT3NZYUPE4+ X-Google-Smtp-Source: AH8x225BRPj3lZaSmhlzUalhQnGPisltVzPXyJCj38nxfgO5QATQSmryCHoBNBmPPUP5aoD5v2qusw== X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr12876486plk.212.1516933591623; Thu, 25 Jan 2018 18:26:31 -0800 (PST) Received: from tw-172-25-30-113.office.twttr.net ([8.25.197.25]) by smtp.gmail.com with ESMTPSA id u86sm16430234pfa.102.2018.01.25.18.26.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jan 2018 18:26:30 -0800 (PST) From: Cong Wang To: netdev@vger.kernel.org Cc: john.fastabend@gmail.com, Cong Wang Subject: [Patch net-next v3 1/3] net: introduce helper dev_change_tx_queue_len() Date: Thu, 25 Jan 2018 18:26:22 -0800 Message-Id: <20180126022624.20442-2-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20180126022624.20442-1-xiyou.wangcong@gmail.com> References: <20180126022624.20442-1-xiyou.wangcong@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch promotes the local change_tx_queue_len() to a core helper function, dev_change_tx_queue_len(), so that rtnetlink and net-sysfs could share the code. This also prepares for the following patch. Note, the -EFAULT in the original code doesn't make sense, we should propagate the errno from notifiers. Cc: John Fastabend Signed-off-by: Cong Wang --- include/linux/netdevice.h | 1 + net/core/dev.c | 28 ++++++++++++++++++++++++++++ net/core/net-sysfs.c | 25 +------------------------ net/core/rtnetlink.c | 18 +++++------------- 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 24a62d590350..0804e1d38c78 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3330,6 +3330,7 @@ int dev_get_alias(const struct net_device *, char *, size_t); int dev_change_net_namespace(struct net_device *, struct net *, const char *); int __dev_set_mtu(struct net_device *, int); int dev_set_mtu(struct net_device *, int); +int dev_change_tx_queue_len(struct net_device *, unsigned long); void dev_set_group(struct net_device *, int); int dev_set_mac_address(struct net_device *, struct sockaddr *); int dev_change_carrier(struct net_device *, bool new_carrier); diff --git a/net/core/dev.c b/net/core/dev.c index 4670ccabe23a..e0b0c2784070 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -7048,6 +7048,34 @@ int dev_set_mtu(struct net_device *dev, int new_mtu) EXPORT_SYMBOL(dev_set_mtu); /** + * dev_change_tx_queue_len - Change TX queue length of a netdevice + * @dev: device + * @new_len: new tx queue length + */ +int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len) +{ + unsigned int orig_len = dev->tx_queue_len; + int res; + + if (new_len != (unsigned int)new_len) + return -ERANGE; + + if (new_len != orig_len) { + dev->tx_queue_len = new_len; + res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev); + res = notifier_to_errno(res); + if (res) { + netdev_err(dev, + "refused to change device tx_queue_len\n"); + dev->tx_queue_len = orig_len; + return res; + } + } + + return 0; +} + +/** * dev_set_group - Change group this device belongs to * @dev: device * @new_group: group this device should belong to diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index c4a28f4667b6..60a5ad2c33ee 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -346,29 +346,6 @@ static ssize_t flags_store(struct device *dev, struct device_attribute *attr, } NETDEVICE_SHOW_RW(flags, fmt_hex); -static int change_tx_queue_len(struct net_device *dev, unsigned long new_len) -{ - unsigned int orig_len = dev->tx_queue_len; - int res; - - if (new_len != (unsigned int)new_len) - return -ERANGE; - - if (new_len != orig_len) { - dev->tx_queue_len = new_len; - res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev); - res = notifier_to_errno(res); - if (res) { - netdev_err(dev, - "refused to change device tx_queue_len\n"); - dev->tx_queue_len = orig_len; - return -EFAULT; - } - } - - return 0; -} - static ssize_t tx_queue_len_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) @@ -376,7 +353,7 @@ static ssize_t tx_queue_len_store(struct device *dev, if (!capable(CAP_NET_ADMIN)) return -EPERM; - return netdev_store(dev, attr, buf, len, change_tx_queue_len); + return netdev_store(dev, attr, buf, len, dev_change_tx_queue_len); } NETDEVICE_SHOW_RW(tx_queue_len, fmt_dec); diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 97874daa1336..6fa6b9c60694 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2291,19 +2291,11 @@ static int do_setlink(const struct sk_buff *skb, if (tb[IFLA_TXQLEN]) { unsigned int value = nla_get_u32(tb[IFLA_TXQLEN]); - unsigned int orig_len = dev->tx_queue_len; - - if (dev->tx_queue_len ^ value) { - dev->tx_queue_len = value; - err = call_netdevice_notifiers( - NETDEV_CHANGE_TX_QUEUE_LEN, dev); - err = notifier_to_errno(err); - if (err) { - dev->tx_queue_len = orig_len; - goto errout; - } - status |= DO_SETLINK_MODIFIED; - } + + err = dev_change_tx_queue_len(dev, value); + if (err) + goto errout; + status |= DO_SETLINK_MODIFIED; } if (tb[IFLA_GSO_MAX_SIZE]) { From patchwork Fri Jan 26 02:26:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 866124 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="phgdvqhi"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zSN8204gWz9sNc for ; Fri, 26 Jan 2018 13:26:41 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751689AbeAZC0j (ORCPT ); Thu, 25 Jan 2018 21:26:39 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:32928 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751591AbeAZC0e (ORCPT ); Thu, 25 Jan 2018 21:26:34 -0500 Received: by mail-pg0-f65.google.com with SMTP id u1so6330497pgr.0 for ; Thu, 25 Jan 2018 18:26:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ptBetpcqJaAyq+I31hGgJwAfI8eaRI7t3REX12yAsuE=; b=phgdvqhirgUtdOqo/206RtbWW+WVGZmS0cyy56QzQxAnvNYfi7Od+rwbvdcn3hdXPd zn8cWxbKaeSQnHoS7lWWA8zmE4kjt3arizn5G+pylAa9Q8J3B9wt8Xt1CisyzJ6BMBIE 62p3U0Bph/xzUuJrmAQ2122LE6m9Etexh4gmYyaFHU2HgwBmgcNOOgSv2+SYs6mFyvRE Sg3NpChUiF6CUzQHnMNeGjlskqosYubv28sB327euF17/tLlPexbDdN6JIMCJGvsA8ga XNFH0l8w02o8Wb7Hw1HGxiexhYIPXJnZXeBhzkzXixa4sHv9LVHaOrDUu2QlLZ0nFQMa vOFA== 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:in-reply-to :references; bh=ptBetpcqJaAyq+I31hGgJwAfI8eaRI7t3REX12yAsuE=; b=qmepZGfcz2mvviaW+ohPJaBgJ9y5ci9+E5unowJX81D4yEm8CsWtaqw+NanuVu3Yer g6UZmL9GCunMXnW67tyKi1uk2AWV61c0a17pybAO0XYJr9VNFgMMb1iUcUil0MBopDS8 Y1iWwBAqrgPlbm3f2rKxfahpA/eeZxY26uWGJgIgEWpS6kvP8PbYlgCHEI3+llZALczQ 7ApSnjKPMewi8bvETGROiRh0pE98sh6f7nT4bQD/grrbsDqIZaZKpFhURkSBfEtiC6sN tCOtXvvWKr1+dqOdv1OpNBSqfDaKyqXD0hm7RvYFxdZV+JOn+YUwGf+wcBs9CXrLQsDc Q9JA== X-Gm-Message-State: AKwxytcT3z7yaUvX+7t9agU2tWvSxcu07DG7hTeBQtFIAuwLHy2mNO/r EYDW/Mo5EFtJWeAVIpfnIQISMurt X-Google-Smtp-Source: AH8x2256iv2o2ifih9jVjBitWq4NCJlv1UaBPMQnxyRXNuedhKEla4zApgQJHz1EKsX9nAG100wsDg== X-Received: by 10.98.19.137 with SMTP id 9mr17617987pft.5.1516933592902; Thu, 25 Jan 2018 18:26:32 -0800 (PST) Received: from tw-172-25-30-113.office.twttr.net ([8.25.197.25]) by smtp.gmail.com with ESMTPSA id u86sm16430234pfa.102.2018.01.25.18.26.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jan 2018 18:26:31 -0800 (PST) From: Cong Wang To: netdev@vger.kernel.org Cc: john.fastabend@gmail.com, Cong Wang Subject: [Patch net-next v3 2/3] net_sched: plug in qdisc ops change_tx_queue_len Date: Thu, 25 Jan 2018 18:26:23 -0800 Message-Id: <20180126022624.20442-3-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20180126022624.20442-1-xiyou.wangcong@gmail.com> References: <20180126022624.20442-1-xiyou.wangcong@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce a new qdisc ops ->change_tx_queue_len() so that each qdisc could decide how to implement this if it wants. Previously we simply read dev->tx_queue_len, after pfifo_fast switches to skb array, we need this API to resize the skb array when we change dev->tx_queue_len. To avoid handling race conditions with TX BH, we need to deactivate all TX queues before change the value and bring them back after we are done, this also makes implementation easier. Cc: John Fastabend Signed-off-by: Cong Wang --- include/net/sch_generic.h | 2 ++ net/core/dev.c | 1 + net/sched/sch_generic.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index eac43e8ca96d..e2ab13687fb9 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -200,6 +200,7 @@ struct Qdisc_ops { struct nlattr *arg, struct netlink_ext_ack *extack); void (*attach)(struct Qdisc *sch); + int (*change_tx_queue_len)(struct Qdisc *, unsigned int); int (*dump)(struct Qdisc *, struct sk_buff *); int (*dump_stats)(struct Qdisc *, struct gnet_dump *); @@ -489,6 +490,7 @@ void qdisc_class_hash_remove(struct Qdisc_class_hash *, void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *); void qdisc_class_hash_destroy(struct Qdisc_class_hash *); +int dev_qdisc_change_tx_queue_len(struct net_device *dev); void dev_init_scheduler(struct net_device *dev); void dev_shutdown(struct net_device *dev); void dev_activate(struct net_device *dev); diff --git a/net/core/dev.c b/net/core/dev.c index e0b0c2784070..c8443cfaa17a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -7070,6 +7070,7 @@ int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len) dev->tx_queue_len = orig_len; return res; } + return dev_qdisc_change_tx_queue_len(dev); } return 0; diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 1816bde47256..08f9fa27e06e 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -1178,6 +1178,39 @@ void dev_deactivate(struct net_device *dev) } EXPORT_SYMBOL(dev_deactivate); +static int qdisc_change_tx_queue_len(struct net_device *dev, + struct netdev_queue *dev_queue) +{ + struct Qdisc *qdisc = dev_queue->qdisc_sleeping; + const struct Qdisc_ops *ops = qdisc->ops; + + if (ops->change_tx_queue_len) + return ops->change_tx_queue_len(qdisc, dev->tx_queue_len); + return 0; +} + +int dev_qdisc_change_tx_queue_len(struct net_device *dev) +{ + bool up = dev->flags & IFF_UP; + unsigned int i; + int ret = 0; + + if (up) + dev_deactivate(dev); + + for (i = 0; i < dev->num_tx_queues; i++) { + ret = qdisc_change_tx_queue_len(dev, &dev->_tx[i]); + + /* TODO: revert changes on a partial failure */ + if (ret) + break; + } + + if (up) + dev_activate(dev); + return ret; +} + static void dev_init_scheduler_queue(struct net_device *dev, struct netdev_queue *dev_queue, void *_qdisc) From patchwork Fri Jan 26 02:26:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 866123 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="F7+en8P/"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zSN7z3Pz8z9sNc for ; Fri, 26 Jan 2018 13:26:39 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751668AbeAZC0h (ORCPT ); Thu, 25 Jan 2018 21:26:37 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:39528 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751636AbeAZC0e (ORCPT ); Thu, 25 Jan 2018 21:26:34 -0500 Received: by mail-pf0-f196.google.com with SMTP id e11so7249476pff.6 for ; Thu, 25 Jan 2018 18:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u22e9y+GOTh0VD74Q5j4WSuBzJ7AvagJ0xyBam0CrIg=; b=F7+en8P/fSxoGTcPc4FkctY1eR6LXJmaHb4JTcP6QLVc8iVS/FGPxmW0fdPHig51Ss mrbeA7tfXJ5R99HeLauZrWaWRksfbNNR0UGc+ZrRlhZsncio26XJFYz7WqOh/yZ0MDAt av8l7SPiv7WqZ5BrrZL185lXgjTq37JRjdjXwSbGQlC0amDpUykikpBC3phSIYhbsl/Q tWJHl0hnwrGgYyzhxJaLl/A3F5YeFvsfnRYL7R5pn/R2n8CF8TFkepjMDGqmml1HMQVh YxFwoEovgESJiHlpXGrCk6bOqtRcEYyxe7tg/8vF8IdBm/ntDAWUeD+fJtj4sjCHbbhp xE6w== 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:in-reply-to :references; bh=u22e9y+GOTh0VD74Q5j4WSuBzJ7AvagJ0xyBam0CrIg=; b=prCMwDE2dehOljWqjo8kYj1mK7gHkmctKzAEBTV6MtbLpGjBEhu8qAzNwG8Z/DIVfM OLBhZBQoJU3xnVqFJ8qm3SQJYPzrruMFhMuhquHaa2HJVBkCfKjX5yKqtw7Rwh0VCoWW pCJxTY8z+49T211qhS3smTrXWAEdxZ/J6WHcB5rlNGlq9ig3n4FYSTQqJPRR4B5Youzr jAli642a82G47tgOYOH1xg7+3GjLlhJRC6iX+4/RbeOjGO6OWojh44j0rADKafSuDDIK 1P5V8009LND24YNXUt6mlhG0MpkQNqeDGrM5uhuRlnAbo1Dg/LVpyiw9E6hzVYOO7eh5 5EtQ== X-Gm-Message-State: AKwxytcdnx4gEUitvT76OJgHrmm1mhDUemdd8LAy6XYIMYkPi0zKpfS3 /fHvx8vWub78skayFUb5PQKNNd1a X-Google-Smtp-Source: AH8x225OgYJjAIpXKFrhvojGyOt6WtzZ8QY8c2BO66lCPN21udoLoY1O4EVaPAVmKzPoimJn7bmZyg== X-Received: by 10.99.175.76 with SMTP id s12mr14607024pgo.240.1516933593840; Thu, 25 Jan 2018 18:26:33 -0800 (PST) Received: from tw-172-25-30-113.office.twttr.net ([8.25.197.25]) by smtp.gmail.com with ESMTPSA id u86sm16430234pfa.102.2018.01.25.18.26.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jan 2018 18:26:33 -0800 (PST) From: Cong Wang To: netdev@vger.kernel.org Cc: john.fastabend@gmail.com, Cong Wang Subject: [Patch net-next v3 3/3] net_sched: implement ->change_tx_queue_len() for pfifo_fast Date: Thu, 25 Jan 2018 18:26:24 -0800 Message-Id: <20180126022624.20442-4-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20180126022624.20442-1-xiyou.wangcong@gmail.com> References: <20180126022624.20442-1-xiyou.wangcong@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org pfifo_fast used to drop based on qdisc_dev(qdisc)->tx_queue_len, so we have to resize skb array when we change tx_queue_len. Other qdiscs which read tx_queue_len are fine because they all save it to sch->limit or somewhere else in qdisc during init. They don't have to implement this, it is nicer if they do so that users don't have to re-configure qdisc after changing tx_queue_len. Cc: John Fastabend Signed-off-by: Cong Wang --- net/sched/sch_generic.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 08f9fa27e06e..190570f21b20 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -763,6 +763,23 @@ static void pfifo_fast_destroy(struct Qdisc *sch) } } +static int pfifo_fast_change_tx_queue_len(struct Qdisc *sch, + unsigned int new_len) +{ + struct pfifo_fast_priv *priv = qdisc_priv(sch); + struct skb_array *bands[PFIFO_FAST_BANDS]; + int prio; + + for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) { + struct skb_array *q = band2list(priv, prio); + + bands[prio] = q; + } + + return skb_array_resize_multiple(bands, PFIFO_FAST_BANDS, new_len, + GFP_KERNEL); +} + struct Qdisc_ops pfifo_fast_ops __read_mostly = { .id = "pfifo_fast", .priv_size = sizeof(struct pfifo_fast_priv), @@ -773,6 +790,7 @@ struct Qdisc_ops pfifo_fast_ops __read_mostly = { .destroy = pfifo_fast_destroy, .reset = pfifo_fast_reset, .dump = pfifo_fast_dump, + .change_tx_queue_len = pfifo_fast_change_tx_queue_len, .owner = THIS_MODULE, .static_flags = TCQ_F_NOLOCK | TCQ_F_CPUSTATS, };