Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933896AbcK3KKA (ORCPT ); Wed, 30 Nov 2016 05:10:00 -0500 Received: from mail-db5eur01on0075.outbound.protection.outlook.com ([104.47.2.75]:20370 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756148AbcK3KJU (ORCPT ); Wed, 30 Nov 2016 05:09:20 -0500 From: Andy Duan To: Nikita Yushchenko , "David S. Miller" , Troy Kisky , "Andrew Lunn" , Eric Nelson , Philippe Reynes , Johannes Berg , "netdev@vger.kernel.org" CC: Chris Healy , Fabio Estevam , "linux-kernel@vger.kernel.org" Subject: RE: [patch net / RFC] net: fec: increase frame size limitation to actually available buffer Thread-Topic: [patch net / RFC] net: fec: increase frame size limitation to actually available buffer Thread-Index: AQHSSm9iLT1NA30YhUiBR8NJepE5RKDwy/Ug Date: Wed, 30 Nov 2016 02:37:50 +0000 Message-ID: References: <1480444528-30054-1-git-send-email-nikita.yoush@cogentembedded.com> In-Reply-To: <1480444528-30054-1-git-send-email-nikita.yoush@cogentembedded.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=fugang.duan@nxp.com; x-originating-ip: [192.158.241.86] x-ms-office365-filtering-correlation-id: 55521f30-3f40-4f56-1066-08d418c9e0e0 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB6PR0402MB2741; x-microsoft-exchange-diagnostics: 1;DB6PR0402MB2741;7:LKtb9LHFfXHC7D95j0tA4MVwGDprySgF5h5/Nt2x669fK8YIu9tHGCOP4zzkVt7k0nLURAcaV7SaC7dOfwb2EfDbQlK6XobdC6mcI5EUoXQmRtIme9aEX3AqqUDbIoHVEBsKd7YLl9jVqBY/ZOKlHkwXKiOVZlGX2wsNpztlW3E8hFz+uLUzjABJQAFlSG7xXQJsi5EV3M8KBtN3hHyzmzM3SDvE9bWiym95wPXNhvHD15jFIVCttGntkbolyOqtmtm62vlOe+pSPxSKc1mOJ0o00fCupo75R9S2H+kK9W0y38ah96LMCtuBcQE2QC51JE66S0F+0EUlZzzbmK2MvQeYoWkYA55FIK9luXFqiQU/mb+hTpgKQLCo1oZmlWCZ9sW67ZH2xKYRzNRQEKWxbmgYNfdXDJgV6f/Fef6OvM31JBhCfmVp9sfwm6Un+yue0feJUx4B6O98E7g3zIBzvg== x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123560025)(20161123555025)(20161123564025)(6047074)(6072148);SRVR:DB6PR0402MB2741;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0402MB2741; x-forefront-prvs: 0142F22657 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(189002)(377454003)(199003)(102836003)(77096006)(2950100002)(39060400001)(229853002)(8936002)(76576001)(38730400001)(39410400001)(6116002)(4326007)(97736004)(8676002)(39450400002)(6506003)(7416002)(92566002)(2906002)(122556002)(5001770100001)(2501003)(81166006)(189998001)(3660700001)(81156014)(3280700002)(2900100001)(50986999)(105586002)(5660300001)(33656002)(106116001)(3846002)(305945005)(9686002)(7736002)(7846002)(76176999)(106356001)(74316002)(68736007)(66066001)(101416001)(54356999)(86362001)(7696004);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0402MB2741;H:AM4PR0401MB2260.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2016 02:37:50.5175 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0402MB2741 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uAUACfeG011971 Content-Length: 4315 Lines: 113 From: Nikita Yushchenko Sent: Wednesday, November 30, 2016 2:35 AM >To: David S. Miller ; Andy Duan >; Troy Kisky ; >Andrew Lunn ; Eric Nelson ; Philippe >Reynes ; Johannes Berg ; >netdev@vger.kernel.org >Cc: Chris Healy ; Fabio Estevam >; linux-kernel@vger.kernel.org; Nikita >Yushchenko >Subject: [patch net / RFC] net: fec: increase frame size limitation to actually >available buffer > >Fec driver uses Rx buffers of 2k, but programs hardware to limit incoming >frames to 1522 bytes. This raises issues when FEC device is used with DSA >(since DSA tag can make frame larger), and also disallows manual sending and >receiving larger frames. > >This patch removes the limitation, allowing Rx size up to entire buffer. >At the same time possible Tx size is increased as well, because hardware uses >the same register field to limit Rx and Tx. > >Signed-off-by: Nikita Yushchenko >--- > drivers/net/ethernet/freescale/fec_main.c | 33 +++++++++++---------------- >---- > 1 file changed, 12 insertions(+), 21 deletions(-) > >diff --git a/drivers/net/ethernet/freescale/fec_main.c >b/drivers/net/ethernet/freescale/fec_main.c >index 73ac35780611..c09789a71024 100644 >--- a/drivers/net/ethernet/freescale/fec_main.c >+++ b/drivers/net/ethernet/freescale/fec_main.c >@@ -171,30 +171,12 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet >MAC address"); #endif #endif /* CONFIG_M5272 */ > >-/* The FEC stores dest/src/type/vlan, data, and checksum for receive >packets. >- */ >-#define PKT_MAXBUF_SIZE 1522 >-#define PKT_MINBUF_SIZE 64 >-#define PKT_MAXBLR_SIZE 1536 >- > /* FEC receive acceleration */ > #define FEC_RACC_IPDIS (1 << 1) > #define FEC_RACC_PRODIS (1 << 2) > #define FEC_RACC_SHIFT16 BIT(7) > #define FEC_RACC_OPTIONS (FEC_RACC_IPDIS | FEC_RACC_PRODIS) > >-/* >- * The 5270/5271/5280/5282/532x RX control register also contains maximum >frame >- * size bits. Other FEC hardware does not, so we need to take that into >- * account when setting it. >- */ >-#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || >defined(CONFIG_M528x) || \ >- defined(CONFIG_M520x) || defined(CONFIG_M532x) || >defined(CONFIG_ARM) >-#define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16) >-#else >-#define OPT_FRAME_SIZE 0 >-#endif >- > /* FEC MII MMFR bits definition */ > #define FEC_MMFR_ST (1 << 30) > #define FEC_MMFR_OP_READ (2 << 28) >@@ -847,7 +829,8 @@ static void fec_enet_enable_ring(struct net_device >*ndev) > for (i = 0; i < fep->num_rx_queues; i++) { > rxq = fep->rx_queue[i]; > writel(rxq->bd.dma, fep->hwp + FEC_R_DES_START(i)); >- writel(PKT_MAXBLR_SIZE, fep->hwp + FEC_R_BUFF_SIZE(i)); >+ writel(FEC_ENET_RX_FRSIZE - fep->rx_align, >+ fep->hwp + FEC_R_BUFF_SIZE(i)); > > /* enable DMA1/2 */ > if (i) >@@ -895,9 +878,17 @@ fec_restart(struct net_device *ndev) > struct fec_enet_private *fep = netdev_priv(ndev); > u32 val; > u32 temp_mac[2]; >- u32 rcntl = OPT_FRAME_SIZE | 0x04; >+ u32 rcntl = 0x04; > u32 ecntl = 0x2; /* ETHEREN */ > >+ /* The 5270/5271/5280/5282/532x RX control register also contains >+ * maximum frame * size bits. Other FEC hardware does not. >+ */ >+#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || >defined(CONFIG_M528x) || \ >+ defined(CONFIG_M520x) || defined(CONFIG_M532x) || >defined(CONFIG_ARM) >+ rcntl |= (FEC_ENET_RX_FRSIZE - fep->rx_align) << 16; #endif >+ > /* Whack a reset. We should wait for this. > * For i.MX6SX SOC, enet use AXI bus, we use disable MAC > * instead of reset MAC itself. >@@ -953,7 +944,7 @@ fec_restart(struct net_device *ndev) > else > val &= ~FEC_RACC_OPTIONS; > writel(val, fep->hwp + FEC_RACC); >- writel(PKT_MAXBUF_SIZE, fep->hwp + FEC_FTRL); >+ writel(FEC_ENET_RX_FRSIZE - fep->rx_align, fep->hwp + >FEC_FTRL); By the patch itself, it seems fine except MRBRn must be evenly divisible by 64. But I think it is not necessary since the driver don't support jumbo frame. > } > #endif > >-- >2.1.4