From patchwork Wed Sep 10 18:30:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 387931 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CA670140143 for ; Thu, 11 Sep 2014 04:55:31 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752347AbaIJSzR (ORCPT ); Wed, 10 Sep 2014 14:55:17 -0400 Received: from mail-bn1bon0119.outbound.protection.outlook.com ([157.56.111.119]:48560 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753270AbaIJSyr (ORCPT ); Wed, 10 Sep 2014 14:54:47 -0400 Received: from BL2PR03MB484.namprd03.prod.outlook.com (10.141.92.152) by BL2PR03MB1138.namprd03.prod.outlook.com (10.141.183.21) with Microsoft SMTP Server (TLS) id 15.0.1019.16; Wed, 10 Sep 2014 18:54:44 +0000 Received: from BY2PR03CA057.namprd03.prod.outlook.com (10.141.249.30) by BL2PR03MB484.namprd03.prod.outlook.com (10.141.92.152) with Microsoft SMTP Server (TLS) id 15.0.1019.16; Wed, 10 Sep 2014 18:54:42 +0000 Received: from BN1BFFO11FD011.protection.gbl (2a01:111:f400:7c10::1:152) by BY2PR03CA057.outlook.office365.com (2a01:111:e400:2c5d::30) with Microsoft SMTP Server (TLS) id 15.0.1024.12 via Frontend Transport; Wed, 10 Sep 2014 18:54:40 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD011.mail.protection.outlook.com (10.58.144.74) with Microsoft SMTP Server (TLS) id 15.0.1019.14 via Frontend Transport; Wed, 10 Sep 2014 18:54:40 +0000 Received: from shlinux1.ap.freescale.net (shlinux1.ap.freescale.net [10.192.225.216]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s8AIscT6008980; Wed, 10 Sep 2014 11:54:38 -0700 Received: by shlinux1.ap.freescale.net (Postfix, from userid 1013) id 443621AE1EE; Thu, 11 Sep 2014 02:30:48 +0800 (CST) From: Frank Li To: , , , CC: , , , , Fugang Duan , Frank Li Subject: [Patch v3 net-next 04/12] net: fec: parser max queue number from dt file Date: Thu, 11 Sep 2014 02:30:37 +0800 Message-ID: <1410373845-5801-5-git-send-email-Frank.Li@freescale.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1410373845-5801-1-git-send-email-Frank.Li@freescale.com> References: <1410373845-5801-1-git-send-email-Frank.Li@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019019)(6009001)(428002)(199003)(189002)(21056001)(16796002)(81542001)(69596002)(74662001)(106466001)(20776003)(45336002)(87936001)(85306004)(47776003)(81156004)(92566001)(31966008)(46386002)(50226001)(105586002)(50986999)(76176999)(95666004)(88136002)(102836001)(97736003)(42186005)(48376002)(64706001)(50466002)(19580395003)(4396001)(6806004)(77096002)(101416001)(81342001)(99396002)(26826002)(89996001)(36756003)(87286001)(92726001)(46102001)(107046002)(62966002)(77156001)(2201001)(76482001)(575784001)(229853001)(77982001)(52956003)(68736004)(90102001)(79102001)(74502001)(83072002)(104166001)(19580405001)(83322001)(103686003)(84676001)(85852003)(93916002)(80022001)(44976005)(90966001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR03MB484; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; A:0; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:;UriScan:; X-Forefront-PRVS: 033054F29A Received-SPF: None (protection.outlook.com: shlinux1.ap.freescale.net does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 192.88.158.2) smtp.mailfrom=b20596@shlinux1.ap.freescale.net; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:; X-OriginatorOrg: freescale.com Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Fugang Duan By default, the tx/rx queue number is 1, user can config the queue number at DTS file like this: fsl,num-tx-queues=<3>; fsl,num-rx-queues=<3> Since i.MX6SX enet-AVB IP support multi queues, so use multi queues interface to allocate and set up an Ethernet device. Signed-off-by: Fugang Duan Signed-off-by: Frank Li --- drivers/net/ethernet/freescale/fec.h | 2 ++ drivers/net/ethernet/freescale/fec_main.c | 46 ++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index b2b91f8..72fb90f 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -356,6 +356,8 @@ struct fec_enet_private { bool ptp_clk_on; struct mutex ptp_clk_mutex; + unsigned int num_tx_queues; + unsigned int num_rx_queues; /* The saved address of a sent-in-place packet/buffer, for skfree(). */ struct fec_enet_priv_tx_q *tx_queue[FEC_ENET_MAX_TX_QS]; diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 4c0d2ee..2240df0 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2709,6 +2709,42 @@ static void fec_reset_phy(struct platform_device *pdev) } #endif /* CONFIG_OF */ +static void +fec_enet_get_queue_num(struct platform_device *pdev, int *num_tx, int *num_rx) +{ + struct device_node *np = pdev->dev.of_node; + int err; + + *num_tx = *num_rx = 1; + + if (!np || !of_device_is_available(np)) + return; + + /* parse the num of tx and rx queues */ + err = of_property_read_u32(np, "fsl,num-tx-queues", num_tx); + err |= of_property_read_u32(np, "fsl,num-rx-queues", num_rx); + if (err) { + *num_tx = 1; + *num_rx = 1; + return; + } + + if (*num_tx < 1 || *num_tx > FEC_ENET_MAX_TX_QS) { + dev_err(&pdev->dev, "Invalidate num_tx(=%d), fail back to 1\n", + *num_tx); + *num_tx = 1; + return; + } + + if (*num_rx < 1 || *num_rx > FEC_ENET_MAX_RX_QS) { + dev_err(&pdev->dev, "Invalidate num_rx(=%d), fail back to 1\n", + *num_rx); + *num_rx = 1; + return; + } + +} + static int fec_probe(struct platform_device *pdev) { @@ -2720,13 +2756,18 @@ fec_probe(struct platform_device *pdev) const struct of_device_id *of_id; static int dev_id; struct device_node *np = pdev->dev.of_node, *phy_node; + int num_tx_qs = 1; + int num_rx_qs = 1; of_id = of_match_device(fec_dt_ids, &pdev->dev); if (of_id) pdev->id_entry = of_id->data; + fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs); + /* Init network device */ - ndev = alloc_etherdev(sizeof(struct fec_enet_private)); + ndev = alloc_etherdev_mqs(sizeof(struct fec_enet_private), + num_tx_qs, num_rx_qs); if (!ndev) return -ENOMEM; @@ -2735,6 +2776,9 @@ fec_probe(struct platform_device *pdev) /* setup board info structure */ fep = netdev_priv(ndev); + fep->num_rx_queues = num_rx_qs; + fep->num_tx_queues = num_tx_qs; + #if !defined(CONFIG_M5272) /* default enable pause frame auto negotiation */ if (pdev->id_entry &&