From patchwork Wed Sep 3 20:38:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 385643 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 37E1D14018E for ; Thu, 4 Sep 2014 07:00:03 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755840AbaICU76 (ORCPT ); Wed, 3 Sep 2014 16:59:58 -0400 Received: from mail-bn1blp0181.outbound.protection.outlook.com ([207.46.163.181]:27474 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750939AbaICU75 (ORCPT ); Wed, 3 Sep 2014 16:59:57 -0400 Received: from BN3PR0301CA0068.namprd03.prod.outlook.com (25.160.152.164) by BL2PR03MB370.namprd03.prod.outlook.com (10.141.89.13) with Microsoft SMTP Server (TLS) id 15.0.1019.16; Wed, 3 Sep 2014 20:59:55 +0000 Received: from BN1AFFO11FD057.protection.gbl (2a01:111:f400:7c10::170) by BN3PR0301CA0068.outlook.office365.com (2a01:111:e400:401e::36) with Microsoft SMTP Server (TLS) id 15.0.1019.16 via Frontend Transport; Wed, 3 Sep 2014 20:59:54 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD057.mail.protection.outlook.com (10.58.53.72) with Microsoft SMTP Server (TLS) id 15.0.1010.11 via Frontend Transport; Wed, 3 Sep 2014 20:59:54 +0000 Received: from shlinux1.ap.freescale.net (shlinux1.ap.freescale.net [10.192.225.216]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s83KxnGB030270; Wed, 3 Sep 2014 13:59:53 -0700 Received: by shlinux1.ap.freescale.net (Postfix, from userid 1013) id 525221AE1F4; Thu, 4 Sep 2014 04:38:19 +0800 (CST) From: Frank Li To: , , , CC: , , , Fugang Duan , Frank Li Subject: [Patch net-next 03/11] net:fec: use multiqueue interface to allocate Ethernet device Date: Thu, 4 Sep 2014 04:38:09 +0800 Message-ID: <1409776697-1536-4-git-send-email-Frank.Li@freescale.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1409776697-1536-1-git-send-email-Frank.Li@freescale.com> References: <1409776697-1536-1-git-send-email-Frank.Li@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(428002)(189002)(199003)(80022001)(50466002)(81342001)(42186005)(64706001)(20776003)(47776003)(89996001)(62966002)(79102001)(77982001)(76482001)(87286001)(46102001)(84676001)(77096002)(88136002)(74502001)(85852003)(77156001)(103686003)(2201001)(87936001)(36756003)(83072002)(44976005)(229853001)(68736004)(90102001)(19580395003)(83322001)(19580405001)(6806004)(93916002)(16796002)(104166001)(92726001)(105586002)(31966008)(92566001)(102836001)(48376002)(99396002)(50986999)(107046002)(46386002)(85306004)(4396001)(50226001)(21056001)(76176999)(45336002)(74662001)(95666004)(97736001)(101416001)(52956003)(81542001)(106466001)(26826002)(90966001); DIR:OUT; SFP:; SCL:1; SRVR:BL2PR03MB370; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; A:0; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 032334F434 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.168.50) smtp.mailfrom=b20596@shlinux1.ap.freescale.net; X-OriginatorOrg: freescale.com Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Fugang Duan 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 | 9 ++++++ drivers/net/ethernet/freescale/fec_main.c | 49 ++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index 635772b..f77ed6f 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -233,6 +233,13 @@ struct bufdesc_ex { /* This device has up to three irqs on some platforms */ #define FEC_IRQ_NUM 3 +/* Maximum number of queues supported + * ENET with AVB IP can support up to 3 independent tx queues and rx queues. + * User can point the queue number that is less than or equal to 3. + */ +#define FEC_ENET_MAX_TX_QS 3 +#define FEC_ENET_MAX_RX_QS 3 + /* The number of Tx and Rx buffers. These are allocated from the page * pool. The code may assume these are power of two, so it it best * to keep them that size. @@ -278,6 +285,8 @@ struct fec_enet_private { bool ptp_clk_on; struct mutex ptp_clk_mutex; + int num_tx_queues; + int num_rx_queues; /* The saved address of a sent-in-place packet/buffer, for skfree(). */ unsigned char *tx_bounce[TX_RING_SIZE]; diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index ee9f04f..00fcadd 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2573,6 +2573,39 @@ static void fec_reset_phy(struct platform_device *pdev) #endif /* CONFIG_OF */ static int +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; + + if (!np || !of_device_is_available(np)) + return -ENODEV; + + /* 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 0; + } + + if (*num_tx < 1 || *num_tx > FEC_ENET_MAX_TX_QS) { + dev_err(&pdev->dev, "num_tx(=%d) greater than MAX_TX_QS(=%d)\n", + *num_tx, FEC_ENET_MAX_TX_QS); + return -EINVAL; + } + + if (*num_rx < 1 || *num_rx > FEC_ENET_MAX_RX_QS) { + dev_err(&pdev->dev, "num_rx(=%d) greater than MAX_RX_QS(=%d)\n", + *num_rx, FEC_ENET_MAX_RX_QS); + return -EINVAL; + } + + return 0; +} + +static int fec_probe(struct platform_device *pdev) { struct fec_enet_private *fep; @@ -2583,13 +2616,23 @@ 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; + if (pdev->id_entry && + (pdev->id_entry->driver_data & FEC_QUIRK_HAS_AVB)) { + ret = fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs); + if (ret) + return ret; + } + /* 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; @@ -2598,6 +2641,10 @@ 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; + netif_set_real_num_rx_queues(ndev, num_rx_qs); + #if !defined(CONFIG_M5272) /* default enable pause frame auto negotiation */ if (pdev->id_entry &&