From patchwork Tue Feb 28 09:44:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yen ChunChao X-Patchwork-Id: 658408 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F36CC64ED6 for ; Tue, 28 Feb 2023 09:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231244AbjB1Jpq (ORCPT ); Tue, 28 Feb 2023 04:45:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231225AbjB1Jpp (ORCPT ); Tue, 28 Feb 2023 04:45:45 -0500 Received: from AUS01-SY4-obe.outbound.protection.outlook.com (mail-sy4aus01olkn2144.outbound.protection.outlook.com [40.92.62.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28C6D2E0EC for ; Tue, 28 Feb 2023 01:45:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jz0DC4JwFUnYKWSyn2sgo3qJycdM3g9qgK60ZPRIzpHVf3k5SeFbxUaZWIqSuiRyzl1lhNB66jer9Y4HNFc5lqsE6FoJ8cH5JYvssh5fqkfY1zPNvpmzc4veICbsuTUX1QdYNj+K9adFzyFp8aqe3qOwIw1czSZdwQDetqx4VYYLQAmmafkTJCzU3ATptA7w6xTzVZZenEiZdSFds5nuo8l7iJze+YMaZ/J6e+RvzyPruHQv6nP/AQ0OCdQzRInwuhTlm3oLtI8wCrkhYhWe3pdHN2RzOz+YDc9bZZP6o2y77eYSMF1ttYsRphITBirCo9kCTkS0LvkEAiKRQxShxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vUeMcUDi3HeH9B8x3lZjXb2MttUodq7rT2sTfNw6a4s=; b=gOZ+upcVbkO+eMFh1lSmw03aI4M6Msjv6Ini05CEpvOAqodOhjA6Ipv2lWNhJ3HjvFJZmIhUykXGWSIewBAkFsZWbMc1ijQLFjDlFAePASLu4zzKQQVduB15DW+zA84+MpvowKt1YiT+I1OEOa39nxc7WmVnaJfzvNY+fKq+lMU2Va8G1MWu0WMdJfUc1Rndt1SZZSOtvXrCq36CoN9s6pZiRqLCk5bh7XgqULczjUU3UdIUa3zpZz1F/gw4p+IFvcsR0YtjQGLcLwsxuuOQ9i9fp8hemn0/TCPDKOcR4d7ZS+Xk7wzOOTJMOB4s/n8b/lhbp7Vv+f6KD8cYSr6WCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vUeMcUDi3HeH9B8x3lZjXb2MttUodq7rT2sTfNw6a4s=; b=OPMCMzyNdC1bPhcKdISSiU/6QTm8JdKTaxMiR+4XmHmD13DNVAr9Jk/XaI2S0TDXiSxe+i+5mcntJurzvTodI+ZUqsW8lULLdoPuXrbNmsiWnGwr0BOevalH92BpB/IwhRfmDMj+wXNSnXLcfoqd1TEn1LrE+HAuMXU2q0pech0mJSfMfpUJiPQjI0le/bzoSxB+elbrUkcRLukkyG5Cs4wB+j+ikoV0nW4LpMaTmKhKQyb4yWhsLP+NdiTZGNbttlciPWwNofb6vwExMQxWnpluMUK9Xgxk04+n0wTgX8P4k8MBHEJzZ4S/RIbyh3w6xjlWBN4ZzMJFk/tg0W9nqw== Received: from ME3P282MB2827.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:13c::13) by ME3P282MB0884.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:86::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30; Tue, 28 Feb 2023 09:44:52 +0000 Received: from ME3P282MB2827.AUSP282.PROD.OUTLOOK.COM ([fe80::50ae:cb9:fc65:57f4]) by ME3P282MB2827.AUSP282.PROD.OUTLOOK.COM ([fe80::50ae:cb9:fc65:57f4%5]) with mapi id 15.20.6134.029; Tue, 28 Feb 2023 09:44:52 +0000 From: Yen ChunChao To: "davem@davemloft.net" CC: "pabeni@redhat.com" , "linux-usb@vger.kernel.org" Subject: [PATCH 2/3 RFC] net: usb: ax88179_178a: Enable AX_RX_CTL_IPE only when NET_IP_ALIGN != 0 Thread-Topic: [PATCH 2/3 RFC] net: usb: ax88179_178a: Enable AX_RX_CTL_IPE only when NET_IP_ALIGN != 0 Thread-Index: AQHZS1lO02yRow6F0ES3ZlBD2LvbCA== Date: Tue, 28 Feb 2023 09:44:52 +0000 Message-ID: References: <20221007142038.2814378-1-nothingstopsme@hotmail.com> In-Reply-To: Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [sbTylhdqrwOqq3p9u8F6El1gcMUD5LPj] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: ME3P282MB2827:EE_|ME3P282MB0884:EE_ x-ms-office365-filtering-correlation-id: 4aedc242-9e1d-4d4b-b7ef-08db197070b3 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BUoxWYaIEWD1izyRXH1qmiCJl3vrrZoOcUhlBOFQ6wc4ZuC7vGzW4WZ+gxDMwhE2/cVhVcih4lRqGp53YBmYzKqckbJT2aosiQZ8mrUhzIvuJRaAJkW7HkegRyRPLfuNJGnUSi7sg0W2kS8/P1CexQIa3tN6vTKDcBdXXclPnqChmHeCUHhsPyCkuMghi7tF4YoZ3ymI0Az+bws/dYFGdLyW1OHXVXS8NYUoJqXyPXxBH45H0YqrzGbVqMqLmoqkn0o74HEpMngjMC5678JYF+6rrL5Wj9SoqzPSJ2wKbVzJWOSfaVj0KaknUhgZcEfPZZgUPIQq6azzyzbdsdg7D4K9soJGGSobLQXgrOe2f2XdncxqbqmY3njMgxBoxUeW3ik6npiKxCncgpwZ16MRWXpODHy3st5XHLe9WRzBz8Goafx7L42FwoLu8aGRj9nlFcAq/pZxo8mxMVKdGHj6ga8EDG8VJNrqrRAC3yLSL8UoK69DKnUThnnyMWUxtkIHxWdFZRZbi5DSbZ2dhq463534ybjzFB4BrZcL48DiApz/bzBAtcMTVS4No0QNjCeoZTQbYLkZpduMg84jA0zVwg== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?8AlOEVoofYvuHjtQodoWGQJ?= =?iso-8859-1?q?4dT/Wac3jVMrFXQJc0B6sli3jzhafVtPEoEncw06G5H+AnJQ4UJySSNeV0U6?= =?iso-8859-1?q?Gh+4ubXkepP9vdwwmrqmV6ZRq1Thc+GUvUe5kJSZQvI7MbL4FvKd0S4FuxRj?= =?iso-8859-1?q?X+tXBQilQmfVb9gXbyzZAz1Ni23um3IiqdzEPMmjtVThyDnq6qdH2AB2ST1x?= =?iso-8859-1?q?jbX6qj2zT76vJmSmmuXvKXH60zMIlmXpTAIOkch6KSczJkFY9qyQ+kXw0RaW?= =?iso-8859-1?q?OKGBZ02Bn0vUUY2z36G0oHGQzmDzda1QajTFxWYDqGRGd9VYnIcstgxjKS3l?= =?iso-8859-1?q?KRI1R3hgcdjTOMRrjeETTSc6mtFwV6V3ScqAIICutFzRj28ZQp/EbnLWZq3/?= =?iso-8859-1?q?CbabAMR7dReaQcVs02ydG1QMGrhllT2x7FGVpBp/Oym/LTe7OT2DS5CfOmBz?= =?iso-8859-1?q?FnAuanfNfQF/+TS2nPRcLo4iBHGfRl0QXif2pdsxmU0EgVIcTzhzdJNi0eAv?= =?iso-8859-1?q?tmFUJwoONYhUnpiBogRWnQfzOf4cVXoS/mJQ3U0mmQnSn93wFhFcXEwAjFGU?= =?iso-8859-1?q?KjW9pfitn71ymojK3V8144HGOpVX/NqFYi8uapkC8z4/2nSh/y+qdhxa/mKl?= =?iso-8859-1?q?Y8gOJIrqqg5CSDRXA6wp+owlap5032dEkqo2RMQNjIl1xiJIiRfTKhZy5O/H?= =?iso-8859-1?q?xGq8NCnf3Wd9Z3gP4yzLtAQu7ypijKqtU92E7s7lMsU2BuYdm5KGpsSCuoo+?= =?iso-8859-1?q?kX29Ah4zBnUOXbLJmfeVg27s1nJa7invBdt7uuCDBZ3FvvV8B07PXN0tLte1?= =?iso-8859-1?q?S7YFVYvFRIVJEzyO+QdhiBBJPwWj7VhxQg6ifRERL4Rh9YnkFWnoLIVUWpie?= =?iso-8859-1?q?HJEhgGZaBAt5OmLt+pg3b+02K8zcSG0IBdCzQizlJ+miMiHcgBFzyyTGw96/?= =?iso-8859-1?q?yAgO20d/Op3H6KrCRrUnloGRNFrNJCQCS2p4XqsuzOSksbRAnrwpuFxBJKzy?= =?iso-8859-1?q?mi3Ym42BBbsimfAXGrgiXd0FUyQJMe2dpgI65Q74abts7cavhn6xCb6mPsvR?= =?iso-8859-1?q?w9bw01dl/XflRTUEAG+9nj/yv6JU5idMpyOd43/LOhNkn61FBA8v+YPICwAT?= =?iso-8859-1?q?SSR0uebKDM3rCbm60K6oAl6NZe944HjQAcv+ySap4fxXPlVU3/eVcYZ65FUO?= =?iso-8859-1?q?Ely3N1SOMxU+qPIjn/etwjD64WxZuC+xgTMf0Tqx0F9IwLjiDvNDGsQJKEuS?= =?iso-8859-1?q?AqKapHFmzwTlkyEVNx1q8SgBZZBYg4Ch8BwBLtWWNqqi37gDZ9wXuATeBF34?= =?iso-8859-1?q?6muZSJJs4nT+TNp314w=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-746f3.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: ME3P282MB2827.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 4aedc242-9e1d-4d4b-b7ef-08db197070b3 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2023 09:44:52.0758 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: ME3P282MB0884 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Problem Description: According to the comments in the hardware vendor's outdated source code [1], AX_RX_CTL_IPE signals the hardware to do 32-bit(4-byte) IP header alignment; such alignment is equivalent to the concept of NET_IP_ALIGN = 2 (an extra 2-byte "pesudo header" at the beginning of each etherner frame), as described in skbuff.h. In the current implementation, however, AX_RX_CTL_IPE is always enabled regardless of the value of NET_IP_ALIGN; this can introduce waste in many aspects, such as 1. hardware internal resource 2. USB bandwidth 3. host memory 4. cpu cycles (for updating frame start pointers and frame size variables) when alignment is completely unnecessary, i.e. NET_IP_ALIGN = 0. Solution: Enable AX_RX_CTL_IPE and process pesudo headers only when NET_IP_ALIGN != 0. Verification: Only tested on a platform where NET_IP_ALIGN = 0, with this device: 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet References: [1] https://www.asix.com.tw/en/support/download/file/120 (AX88179 USB3.0 to 10/100/1000M Gigabit Ethernet Controller, version 1.20.0) Signed-off-by: Chun-Chao Yen --- This is the same patch as https://rb.gy/ieil2d sent in Oct. 2022. I just would like to know the current state of this patch. Has it been rejected or still under review? Thanks  drivers/net/usb/ax88179_178a.c | 20 +++++++++++++++-----  1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index b50748b3776c..96ede3a131d4 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c @@ -858,7 +858,10 @@ static void ax88179_set_multicast(struct net_device *net)          struct ax88179_data *data = dev->driver_priv;          u8 *m_filter = ((u8 *)dev->data);   -       data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE); +       data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB); + +       if (NET_IP_ALIGN) +               data->rxctl |= AX_RX_CTL_IPE;            if (net->flags & IFF_PROMISC) {                  data->rxctl |= AX_RX_CTL_PRO; @@ -1424,7 +1427,7 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb)                    /* Check CRC or runt packet */                  if ((*pkt_hdr & (AX_RXHDR_CRC_ERR | AX_RXHDR_DROP_ERR)) || -                   pkt_len < 2 + ETH_HLEN) { +                   pkt_len < (NET_IP_ALIGN ? 2 : 0) + ETH_HLEN) {                          dev->net->stats.rx_errors++;                          goto advance_data_ptr;                  } @@ -1438,8 +1441,13 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb)                  }                  skb_trim(ax_skb, pkt_len);   -               /* Skip IP alignment pseudo header */ -               skb_pull(ax_skb, 2); +               if (NET_IP_ALIGN) { +                       /* Skip the pseudo header, 2 bytes at the start of each +                        * ethernet frame, resulting from hardware 4-byte +                        * IP header alignment (triggered by AX_RX_CTL_IPE) +                        */ +                       skb_pull(ax_skb, 2); +               }                    ax_skb->truesize = SKB_TRUESIZE(pkt_len);                  ax88179_rx_checksum(ax_skb, pkt_hdr); @@ -1609,8 +1617,10 @@ static int ax88179_reset(struct usbnet *dev)          ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp);            /* Configure RX control register => start operation */ -       *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | +       *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START |                   AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; +       if (NET_IP_ALIGN) +               *tmp16 |= AX_RX_CTL_IPE;          ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16);            *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL |