From patchwork Wed Nov 18 16:51:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 11915423 X-Patchwork-Delegate: kuba@kernel.org 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=-13.7 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,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 595C5C6369E for ; Wed, 18 Nov 2020 16:52:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD9FA2485D for ; Wed, 18 Nov 2020 16:52:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="SM8fZCN6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728021AbgKRQv5 (ORCPT ); Wed, 18 Nov 2020 11:51:57 -0500 Received: from mout.gmx.net ([212.227.15.19]:56939 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727522AbgKRQv4 (ORCPT ); Wed, 18 Nov 2020 11:51:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1605718305; bh=9PdZgdrJapiK1z1oJaC3HBy6vk5e/Yz7ao2IblRp2Dc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=SM8fZCN6twvwNW4XnkUmYqOiVBtKnPTBWOLGAZ7zwCwQYt9ggEpNmmak17idIegfS fTfRnGuWawZVetdeF8N8RNk5SYAmU+LTPBHhGm3q8/eOwy/l7kr7DfUS+lmP4BA/mG NPHQyacsBkaPLA1GnPs5EpNnXSbqGpSLgN4hUjYA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from MX-Linux-Intel.fritz.box ([79.242.191.181]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MV63g-1kneQZ2wIo-00S7Kl; Wed, 18 Nov 2020 17:51:45 +0100 From: Armin Wolf To: kuba@kernel.org Cc: netdev@vger.kernel.org, davem@davemloft.net, f.fainelli@gmail.com, joe@perches.com Subject: [PATCH net-next v2 1/2] lib8390: Use eth_skb_pad() Date: Wed, 18 Nov 2020 17:51:06 +0100 Message-Id: <20201118165107.12419-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201118165107.12419-1-W_Armin@gmx.de> References: <20201118165107.12419-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:UI0q0o1fkVoauqLNrWKc/F6agW3V0iV2UuMi/0LMCCTB26wksUb ZRDTkiyNS6S9NF4iEzTBMRZlT9omszEml8qNgUstMu+QSQXh0lPmBM4LFSix0X6NKbESsYz R7gwjvmcaZ15xqLXPvY6WQl7Jyfj9SZPfB58FrCXkHmBtV5gDHHhrWFFvMs1p7wsSRYL/f1 5smzQ4Flt6uNq0BGNxzmw== X-UI-Out-Filterresults: notjunk:1;V03:K0:Tfm6nAiZ7U8=:y+zhPLvstETBIfcDzByDWr aQZVzq6lgFmwEPZmLUACuGY2GRN/dc5Ggu6VY+Y+PHG4t4W+w06XNGMeSnK/wlT+Q15H8TC54 tGrRpawESKkXcmk6ArATBpGzCvJ19SLAChHw/dgS6SZ+hxyvK9FbyCe0pE7q3MmqzQlbSVvtr PLFWKGKOSiy7kO7+4LDpxFEZXPHp4GZkuTyv7TCYi8GDa2JzqhZWNNV6WHOkwLUd3p4TSQIXw D2taH4ElmCRa0fIZFFku8T1CR6GfkpiIKntqcCI8JFJ+5tZ2kByct1L299ZRZdLEcDe+v78w1 KeXEcUavPiPr4AnE+4V4ELIi+WV2puKNxcc3sUh28eTez2rO/B7F5gqUbOOO6h5ZC7CZdAatW s4a4hq4i5t6BHka+EgbLsgJGKB3BXGhSBF19EUkd1d95u6vSJ2GB1wMmYx6IeCnCTQi0upkBp fJxn6HRiWqOvdnosFoKNQ0pbTq9NGBlsLxt5ynzACoQ7TItJikS5aeZ4HxB47Y93ASS46/CXu x2f9Vc0h4fqxLb448vQ7c99TBQbuxtOiTuuLJaXQZP81IKPN6kdMUR6tuqTvHbypMQ7ITt9Mm q0OwvAwGwf0sqm+qsnQlVg4TTOJzgG0oDtfL+oaVAmKjfsQYDE/oIif9NWiHN3/Id9kYPwmIj ApmkGTjh+HifZGTk+S8JyF5A1H0MjQW/bpZ5uI3B7X3ZQihfsTKfFEL8JSoOpqQlY1SWvgPAF jNFf/T8/9yiT7DB5hp7G9/HSNk7jzkdnU2HYhc8ClkrInTPyvtAwU+Wfmg4mVDQB+Wd0r1vEi 5Ez2jbvqI8FLeY7kZNw7U+wMD0heQWHAr6a9OGsh0y2bdIOytjyC5qQ0lNp/a4IhUYtcgtY16 UAnFZwEMyIBxi0/NFSEw== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org According to Joe Perches, this bit seems less than optimal because it overwrites already zeroed content. But instead of fixing the custom padding solution, replace them entirely with generic eth_skb_pad(). Signed-off-by: Armin Wolf --- drivers/net/ethernet/8390/lib8390.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/8390/lib8390.c b/drivers/net/ethernet/8390/lib8390.c index e84021282edf..b3499714f7e0 100644 --- a/drivers/net/ethernet/8390/lib8390.c +++ b/drivers/net/ethernet/8390/lib8390.c @@ -305,17 +305,17 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb, { unsigned long e8390_base = dev->base_addr; struct ei_device *ei_local = netdev_priv(dev); - int send_length = skb->len, output_page; + int send_length, output_page; unsigned long flags; - char buf[ETH_ZLEN]; - char *data = skb->data; - - if (skb->len < ETH_ZLEN) { - memset(buf, 0, ETH_ZLEN); /* more efficient than doing just the needed bits */ - memcpy(buf, data, skb->len); - send_length = ETH_ZLEN; - data = buf; + char *data; + + /* The Hardware does not pad undersized frames */ + if (eth_skb_pad(skb)) { + dev->stats.tx_dropped++; + return NETDEV_TX_OK; } + data = skb->data; + send_length = skb->len; /* Mask interrupts from the ethercard. SMP: We have to grab the lock here otherwise the IRQ handler From patchwork Wed Nov 18 16:51:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 11915421 X-Patchwork-Delegate: kuba@kernel.org 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=-13.7 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,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 1D604C63777 for ; Wed, 18 Nov 2020 16:52:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B1962485B for ; Wed, 18 Nov 2020 16:52:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=gmx.net header.i=@gmx.net header.b="dr94ghwW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728017AbgKRQv5 (ORCPT ); Wed, 18 Nov 2020 11:51:57 -0500 Received: from mout.gmx.net ([212.227.15.18]:37347 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728011AbgKRQv4 (ORCPT ); Wed, 18 Nov 2020 11:51:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1605718306; bh=er5T1TaopyHwQjYumtcOzRR5jgOSxSy7MPppmgo5t+4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=dr94ghwWCKEgFMwYdPetBUh6+VLDjLphvJ/Q6UWsaU9albqjcjZbxsD7kPDPKjq5s oGQkpbX8jGBX9DXDfyeGfFpo0Pd3UKGCYlmsZOAQA1o9hesQIj5SL6T9Zh90SbfChQ atKYILUom+j8U0cJwy8uu6KWeGAmRsseaBbWNtAM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from MX-Linux-Intel.fritz.box ([79.242.191.181]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mof5H-1jv7VL2N5t-00p8qU; Wed, 18 Nov 2020 17:51:46 +0100 From: Armin Wolf To: kuba@kernel.org Cc: netdev@vger.kernel.org, davem@davemloft.net, f.fainelli@gmail.com, joe@perches.com Subject: [PATCH net-next v2 2/2] lib8390: Cleanup variables Date: Wed, 18 Nov 2020 17:51:07 +0100 Message-Id: <20201118165107.12419-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201118165107.12419-1-W_Armin@gmx.de> References: <20201118165107.12419-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:wMCtpzEJDJTu45T0paQDAUfIOZC8SIplxIiYqFTwCznJDkEbCEi vuj7je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NC7zxWuQN3/2E4DCW66aDqpJ4+x/QJKbER+aVMTtppcZ5W YsLt1+vddbG0jSZcVpdg== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Replace variables associated with the former padding solution with skb->* expressions. They are not needed anymore. Signed-off-by: Armin Wolf --- drivers/net/ethernet/8390/lib8390.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 2.20.1 diff --git a/drivers/net/ethernet/8390/lib8390.c b/drivers/net/ethernet/8390/lib8390.c index b3499714f7e0..47e2962eff56 100644 --- a/drivers/net/ethernet/8390/lib8390.c +++ b/drivers/net/ethernet/8390/lib8390.c @@ -305,17 +305,14 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb, { unsigned long e8390_base = dev->base_addr; struct ei_device *ei_local = netdev_priv(dev); - int send_length, output_page; + int output_page; unsigned long flags; - char *data; /* The Hardware does not pad undersized frames */ if (eth_skb_pad(skb)) { dev->stats.tx_dropped++; return NETDEV_TX_OK; } - data = skb->data; - send_length = skb->len; /* Mask interrupts from the ethercard. SMP: We have to grab the lock here otherwise the IRQ handler @@ -347,7 +344,7 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb, if (ei_local->tx1 == 0) { output_page = ei_local->tx_start_page; - ei_local->tx1 = send_length; + ei_local->tx1 = skb->len; if ((netif_msg_tx_queued(ei_local)) && ei_local->tx2 > 0) netdev_dbg(dev, @@ -355,7 +352,7 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb, ei_local->tx2, ei_local->lasttx, ei_local->txing); } else if (ei_local->tx2 == 0) { output_page = ei_local->tx_start_page + TX_PAGES/2; - ei_local->tx2 = send_length; + ei_local->tx2 = skb->len; if ((netif_msg_tx_queued(ei_local)) && ei_local->tx1 > 0) netdev_dbg(dev, @@ -380,11 +377,11 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb, * trigger the send later, upon receiving a Tx done interrupt. */ - ei_block_output(dev, send_length, data, output_page); + ei_block_output(dev, skb->len, skb->data, output_page); if (!ei_local->txing) { ei_local->txing = 1; - NS8390_trigger_send(dev, send_length, output_page); + NS8390_trigger_send(dev, skb->len, output_page); if (output_page == ei_local->tx_start_page) { ei_local->tx1 = -1; ei_local->lasttx = -1; @@ -407,8 +404,8 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb, spin_unlock(&ei_local->page_lock); enable_irq_lockdep_irqrestore(dev->irq, &flags); skb_tx_timestamp(skb); + dev->stats.tx_bytes += skb->len; dev_consume_skb_any(skb); - dev->stats.tx_bytes += send_length; return NETDEV_TX_OK; }