From patchwork Wed Jul 21 21:56:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 483704 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B977FC6377B for ; Wed, 21 Jul 2021 23:56:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95F9060E0C for ; Wed, 21 Jul 2021 23:56:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbhGUXPc (ORCPT ); Wed, 21 Jul 2021 19:15:32 -0400 Received: from mout.gmx.net ([212.227.17.22]:48009 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbhGUXP1 (ORCPT ); Wed, 21 Jul 2021 19:15:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1626911757; bh=8zeB9SdYIGad3GftpPhXNeuDOVvPqv+DJPqmbH0vpUQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=QiGRi6Jh6eLwK2syCOZSMxr/vMGhbW0PcxujKeJiLdENYtFHJWxW1GlKwaX+k7zs8 daDUVIDIWJKUpqc7Zm9QLtlJ9ywdhhFAZD75vV19gOOpQIzF0PE2K7Y6lrCPSBNoIO /3r9IdZy3IrsfJgFpRWN5x8TP6ThBHTge97YHClQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([149.172.237.67]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MfpSb-1lQdo20hKL-00gIod; Wed, 21 Jul 2021 23:56:51 +0200 From: Lino Sanfilippo To: woojung.huh@microchip.com, olteanv@gmail.com Cc: UNGLinuxDriver@microchip.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lino Sanfilippo Subject: [PATCH v2 1/2] net: dsa: ensure linearized SKBs in case of tail taggers Date: Wed, 21 Jul 2021 23:56:41 +0200 Message-Id: <20210721215642.19866-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210721215642.19866-1-LinoSanfilippo@gmx.de> References: <20210721215642.19866-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:mUIOwjeXZDD68etj9mBr6MrnFG4lg1jEYtOkP3DA14joz2fY37k 1zgYb4+R0rj65ECSE3yX1R7l8ydwDDZsFEE/om+kwVbBW1iwDH/iK7qaqCe8/127jpdqp/9 2i7XiJSX5N3neJyaM6wUWAVTgxASajUarjFiwRpGG2VEAdmAGq3W3lUu+QvPe0T9KMjC2xS rUlm6+0F/PZnud5mT8zjw== X-UI-Out-Filterresults: notjunk:1; V03:K0:vDn73y4plaM=:+5o4aSgaIj/zyUSbyjJhFb MEG6LF2GXoh00HXel2z0Mb8jtmhNbNE4FIqfFN1Fa3w7IZ0eGpSSY2g0lE//srUa196jzceGo T8JuJ8J7UPTccSGLwJ8uUM37FyVK206USKCKe4aLjlf7qVXNJay8BVh6hCqwXbUtUlMtk5Jr7 lLN26DchTNxw78Db0MSmLpdG9DCg9EE/Vh67BuNixdLZIjhvxXWWkBvKYqklRKSTdEzf2vC2P zJ4JraMAC79EjKXR9/joziu4c0DFXOBR/mM7SxnRCCGg/jFShZBQZ8SaXFgRhGYWm23cspVmE dIRixll1VjJUlJ1GMjE01ml4UIIK1bRAzly8xJOqV+rpZ7jio0qk0WAnlsWPtpYIaIK5ckByr IK9H7OO8s0u//7aODOZUzlfXC+28hdpMo6nxWVYP4r2ybT64QctPxB/BD0s3VQN3w4LR1v2w3 TYHrq+2Co1+MtQf92944i0nhZIh9bnenuCbpIZF4+IZIbukLj2vqCeSuuFsLBQfw+VxyU8Dia BJtsWz17UWDHF3DLwnCzBo+SmGuoeOF8EfZv8/19kKlpyzZQQH547shWq727HJdCGPt30+U1v YjOQ9V91hf/79OeF42upEsJu1749oBmofJDqY2BIMAAl7JA16aNpTWnZGF+kVBNXtQN7V7WyV 28YIEKlhgA0EncssHwMOoZDmer7v4sbdncYJNFCDvHl/U5pYrfbpNj4+paw4s6UMK/JzotQGf vjEY1IUevtpSRDyXj8lCz1Obs8x/lVqzLxnpBUwfHNi3kP1yUkVzSMhdzMLEkFydvPYeBU1Ng b6HS6GR/HZYj9D2BPLxAD1UJtvOS6v9kjhG9HZn5Lz5N29bMzg+bDIQRmY6TgAu0AAt07LE5g HvBcvMNX9Ljau5acsi2U+/ZOJDH7ZCQVz4EBh6QSyymMYwpd7Nj2h5cpICuYFUxRrdcw5jFnl up6p6xM3GCY9eRtPkNp3WYFXPiBON/kRDQCeRBWNddImU6tkzHcwKeliOG0fdxYkSVMCBSvfY SG7QYz4NAn/0COIYPdre2wkYrJ+fPH0z5/83GJ1XUt+J0I5rDSV3AMRAJeYvVvRomhov+8EUg qCDcqaifgfC9xqUnvODdSr90nmVjPrQ9dw8CMlPPkP190qBTDr1nShoEg== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The function skb_put() that is used by tail taggers to make room for the DSA tag must only be called for linearized SKBS. However in case that the slave device inherited features like NETIF_F_HW_SG or NETIF_F_FRAGLIST the SKB passed to the slaves transmit function may not be linearized. Avoid those SKBs by clearing the NETIF_F_HW_SG and NETIF_F_FRAGLIST flags for tail taggers. Furthermore since the tagging protocol can be changed at runtime move the code for setting up the slaves features into dsa_slave_setup_tagger(). Suggested-by: Vladimir Oltean Signed-off-by: Lino Sanfilippo Reviewed-by: Florian Fainelli --- net/dsa/slave.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 22ce11cd770e..ae2a648ed9be 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1808,6 +1808,7 @@ void dsa_slave_setup_tagger(struct net_device *slave) struct dsa_slave_priv *p = netdev_priv(slave); const struct dsa_port *cpu_dp = dp->cpu_dp; struct net_device *master = cpu_dp->master; + const struct dsa_switch *ds = dp->ds; slave->needed_headroom = cpu_dp->tag_ops->needed_headroom; slave->needed_tailroom = cpu_dp->tag_ops->needed_tailroom; @@ -1819,6 +1820,14 @@ void dsa_slave_setup_tagger(struct net_device *slave) slave->needed_tailroom += master->needed_tailroom; p->xmit = cpu_dp->tag_ops->xmit; + + slave->features = master->vlan_features | NETIF_F_HW_TC; + if (ds->ops->port_vlan_add && ds->ops->port_vlan_del) + slave->features |= NETIF_F_HW_VLAN_CTAG_FILTER; + slave->hw_features |= NETIF_F_HW_TC; + slave->features |= NETIF_F_LLTX; + if (slave->needed_tailroom) + slave->features &= ~(NETIF_F_SG | NETIF_F_FRAGLIST); } static struct lock_class_key dsa_slave_netdev_xmit_lock_key; @@ -1881,11 +1890,6 @@ int dsa_slave_create(struct dsa_port *port) if (slave_dev == NULL) return -ENOMEM; - slave_dev->features = master->vlan_features | NETIF_F_HW_TC; - if (ds->ops->port_vlan_add && ds->ops->port_vlan_del) - slave_dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; - slave_dev->hw_features |= NETIF_F_HW_TC; - slave_dev->features |= NETIF_F_LLTX; slave_dev->ethtool_ops = &dsa_slave_ethtool_ops; if (!is_zero_ether_addr(port->mac)) ether_addr_copy(slave_dev->dev_addr, port->mac);