From patchwork Wed Sep 10 18:30:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yes@shlinux1.ap.freescale.net X-Patchwork-Id: 387922 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 B43E4140143 for ; Thu, 11 Sep 2014 04:54:29 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbaIJSyZ (ORCPT ); Wed, 10 Sep 2014 14:54:25 -0400 Received: from mail-bn1bn0100.outbound.protection.outlook.com ([157.56.110.100]:20633 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753043AbaIJSyX (ORCPT ); Wed, 10 Sep 2014 14:54:23 -0400 Received: from BY2PR03CA071.namprd03.prod.outlook.com (10.141.249.44) by DM2PR03MB365.namprd03.prod.outlook.com (10.141.55.12) with Microsoft SMTP Server (TLS) id 15.0.1024.12; Wed, 10 Sep 2014 18:54:07 +0000 Received: from BL2FFO11FD019.protection.gbl (2a01:111:f400:7c09::126) by BY2PR03CA071.outlook.office365.com (2a01:111:e400:2c5d::44) with Microsoft SMTP Server (TLS) id 15.0.1024.12 via Frontend Transport; Wed, 10 Sep 2014 18:54:06 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD019.mail.protection.outlook.com (10.173.161.37) with Microsoft SMTP Server (TLS) id 15.0.1019.14 via Frontend Transport; Wed, 10 Sep 2014 18:54:05 +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 s8AIs233008920; Wed, 10 Sep 2014 11:54:03 -0700 Received: by shlinux1.ap.freescale.net (Postfix, from userid 1013) id 6C3291AE1F5; Thu, 11 Sep 2014 02:30:15 +0800 (CST) From: 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:05 +0800 Message-ID: <1410373813-5731-5-git-send-email-yes> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1410373813-5731-1-git-send-email-yes> References: <1410373813-5731-1-git-send-email-yes> X-EOPAttributedMessage: 0 X-Matching-Connectors: 130548488459618812; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009019)(6009001)(428002)(199003)(189002)(80022001)(81156004)(4396001)(81342001)(105586002)(77096002)(44976005)(81542001)(69596002)(45336002)(68736004)(50466002)(50226001)(101416001)(107046002)(90102001)(229853001)(85306004)(87286001)(50986999)(76176999)(103686003)(106466001)(19580395003)(99396002)(83322001)(21056001)(89996001)(92566001)(47776003)(93916002)(52956003)(2201001)(104166001)(85852003)(84676001)(92726001)(83072002)(88136002)(31966008)(74502001)(16796002)(64706001)(42186005)(74662001)(86152002)(20776003)(575784001)(95666004)(79102001)(306002)(46386002)(6806004)(87936001)(48376002)(19580405001)(77156001)(11926002)(77982001)(97736003)(62966002)(102836001)(76482001)(46102001)(26826002)(90966001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR03MB365; 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:; 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; 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 &&