From patchwork Sat Mar 21 02:28:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: York Sun X-Patchwork-Id: 452877 X-Patchwork-Delegate: yorksun@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id BD12414009B for ; Sat, 21 Mar 2015 13:31:17 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 652FA4A036; Sat, 21 Mar 2015 03:30:58 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yT5ugHRcQQow; Sat, 21 Mar 2015 03:30:58 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EAFFFABD1C; Sat, 21 Mar 2015 03:29:43 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AC4994B664 for ; Sat, 21 Mar 2015 03:29:14 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CkQ-O8Hcit4F for ; Sat, 21 Mar 2015 03:29:14 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0129.outbound.protection.outlook.com [207.46.100.129]) by theia.denx.de (Postfix) with ESMTPS id 20A4D4B67B for ; Sat, 21 Mar 2015 03:28:54 +0100 (CET) Received: from DM2PR03CA0037.namprd03.prod.outlook.com (10.141.96.36) by BY2PR03MB158.namprd03.prod.outlook.com (10.242.36.15) with Microsoft SMTP Server (TLS) id 15.1.118.21; Sat, 21 Mar 2015 02:28:50 +0000 Received: from BN1AFFO11FD007.protection.gbl (2a01:111:f400:7c10::127) by DM2PR03CA0037.outlook.office365.com (2a01:111:e400:2428::36) with Microsoft SMTP Server (TLS) id 15.1.118.21 via Frontend Transport; Sat, 21 Mar 2015 02:28:49 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD007.mail.protection.outlook.com (10.58.52.67) with Microsoft SMTP Server (TLS) id 15.1.125.13 via Frontend Transport; Sat, 21 Mar 2015 02:28:48 +0000 Received: from oslab-l1.am.freescale.net ([10.214.86.234]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t2L2Sd3I021875; Fri, 20 Mar 2015 19:28:47 -0700 From: York Sun To: Date: Fri, 20 Mar 2015 19:28:15 -0700 Message-ID: <1426904912-29186-12-git-send-email-yorksun@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1426904912-29186-1-git-send-email-yorksun@freescale.com> References: <1426904912-29186-1-git-send-email-yorksun@freescale.com> X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=yorksun@freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(199003)(189002)(43544003)(48376002)(50466002)(106466001)(92566002)(6806004)(86362001)(19580405001)(87936001)(46102003)(2351001)(104016003)(229853001)(110136001)(77096005)(450100001)(62966003)(77156002)(36756003)(76176999)(33646002)(105606002)(19580395003)(50226001)(85426001)(50986999)(47776003)(2950100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB158; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB158; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006); SRVR:BY2PR03MB158; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB158; X-Forefront-PRVS: 05220145DE X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2015 02:28:48.8607 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB158 Cc: pankaj chauhan , Roy Pledge , York Sun Subject: [U-Boot] [PATCH v5 11/28] driver/ldpaa_eth: Update ldpaa ethernet driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Prabhakar Kushwaha Fix flush_dcache_range() input parameter to use start and end addresses. Change ethernet interface name to DPNI. Update entry criteria for ldpaa_eth_stop. Ethernet stack first stop the device before performing next operation. At the time of Ethernet driver registration, net_dev->state is set as ETH_STATE_INIT So take care net_dev->state as ETH_STATE_INIT in ldpaa_eth_stop. Undef CONFIG_PHYLIB temorarily because ldpaa_eth driver currently does not support PHYLIB. Instead of clearing pull descriptor one time, clear it before issuing any volatile dequeue command. Volatile command does not return frame immidiately, wait till a frame is available in DQRR. This frame can be valid or expired. Flush buffer before releasing to BMan ensure the core does not have any cachelines that the WRIOP will DMA to. Signed-off-by: Prabhakar Kushwaha Signed-off-by: pankaj chauhan Signed-off-by: Roy Pledge Signed-off-by: York Sun --- Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None drivers/net/ldpaa_eth/ldpaa_eth.c | 62 +++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c index b79942f..9015e4f 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.c +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c @@ -15,6 +15,7 @@ #include "ldpaa_eth.h" +#undef CONFIG_PHYLIB static int init_phy(struct eth_device *dev) { /*TODO for external PHY */ @@ -33,8 +34,6 @@ static void ldpaa_eth_rx(struct ldpaa_eth_priv *priv, struct qbman_release_desc releasedesc; struct qbman_swp *swp = dflt_dpio->sw_portal; - invalidate_dcache_all(); - fd_addr = ldpaa_fd_get_addr(fd); fd_offset = ldpaa_fd_get_offset(fd); fd_length = ldpaa_fd_get_len(fd); @@ -62,6 +61,7 @@ static void ldpaa_eth_rx(struct ldpaa_eth_priv *priv, NetReceive((uint8_t *)(fd_addr) + fd_offset, fd_length); error: + flush_dcache_range(fd_addr, fd_addr + LDPAA_ETH_RX_BUFFER_SIZE); qbman_release_desc_clear(&releasedesc); qbman_release_desc_set_bpid(&releasedesc, dflt_dpbp->dpbp_attr.bpid); do { @@ -76,22 +76,29 @@ static int ldpaa_eth_pull_dequeue_rx(struct eth_device *dev) struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv; const struct ldpaa_dq *dq; const struct dpaa_fd *fd; - int i = 5, err = 0, status; + int i = 5, err = 0, status, loop = 20; static struct qbman_pull_desc pulldesc; struct qbman_swp *swp = dflt_dpio->sw_portal; - qbman_pull_desc_clear(&pulldesc); - qbman_pull_desc_set_numframes(&pulldesc, 1); - qbman_pull_desc_set_fq(&pulldesc, priv->rx_dflt_fqid); - while (--i) { + qbman_pull_desc_clear(&pulldesc); + qbman_pull_desc_set_numframes(&pulldesc, 1); + qbman_pull_desc_set_fq(&pulldesc, priv->rx_dflt_fqid); + err = qbman_swp_pull(swp, &pulldesc); if (err < 0) { printf("Dequeue frames error:0x%08x\n", err); continue; } - dq = qbman_swp_dqrr_next(swp); + do { + loop--; + dq = qbman_swp_dqrr_next(swp); + + if (!loop) + break; + } while (!dq); + if (dq) { /* Check for valid frame. If not sent a consume * confirmation to QBMAN otherwise give it to NADK @@ -128,7 +135,6 @@ static void ldpaa_eth_tx_conf(struct ldpaa_eth_priv *priv, struct qbman_release_desc releasedesc; struct qbman_swp *swp = dflt_dpio->sw_portal; - invalidate_dcache_all(); fd_addr = ldpaa_fd_get_addr(fd); @@ -159,22 +165,29 @@ static int ldpaa_eth_pull_dequeue_tx_conf(struct ldpaa_eth_priv *priv) const struct ldpaa_dq *dq; const struct dpaa_fd *fd; int err = 0; - int i = 5, status; + int i = 5, status, loop = 20; static struct qbman_pull_desc pulldesc; struct qbman_swp *swp = dflt_dpio->sw_portal; - qbman_pull_desc_clear(&pulldesc); - qbman_pull_desc_set_numframes(&pulldesc, 1); - qbman_pull_desc_set_fq(&pulldesc, priv->tx_conf_fqid); - while (--i) { + qbman_pull_desc_clear(&pulldesc); + qbman_pull_desc_set_numframes(&pulldesc, 1); + qbman_pull_desc_set_fq(&pulldesc, priv->tx_conf_fqid); + err = qbman_swp_pull(swp, &pulldesc); if (err < 0) { printf("Dequeue TX conf frames error:0x%08x\n", err); continue; } - dq = qbman_swp_dqrr_next(swp); + do { + loop--; + dq = qbman_swp_dqrr_next(swp); + + if (!loop) + break; + } while (!dq); + if (dq) { /* Check for valid frame. If not sent a consume * confirmation to QBMAN otherwise give it to NADK @@ -229,7 +242,8 @@ static int ldpaa_eth_tx(struct eth_device *net_dev, void *buf, int len) memcpy(((uint8_t *)(buffer_start) + data_offset), buf, len); - flush_dcache_range(buffer_start, LDPAA_ETH_RX_BUFFER_SIZE); + flush_dcache_range(buffer_start, buffer_start + + LDPAA_ETH_RX_BUFFER_SIZE); ldpaa_fd_set_addr(&fd, (u64)buffer_start); ldpaa_fd_set_offset(&fd, (uint16_t)(data_offset)); @@ -297,10 +311,10 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) #ifdef CONFIG_PHYLIB /* TODO Check this path */ - ret = phy_startup(priv->phydev); - if (ret) { + err = phy_startup(priv->phydev); + if (err) { printf("%s: Could not initialize\n", priv->phydev->dev->name); - return ret; + return err; } #else priv->phydev->speed = SPEED_1000; @@ -361,7 +375,8 @@ static void ldpaa_eth_stop(struct eth_device *net_dev) struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv; int err = 0; - if (net_dev->state == ETH_STATE_PASSIVE) + if ((net_dev->state == ETH_STATE_PASSIVE) || + (net_dev->state == ETH_STATE_INIT)) return; /* Stop Tx and Rx traffic */ err = dpni_disable(dflt_mc_io, priv->dpni_handle); @@ -422,6 +437,8 @@ static int ldpaa_bp_add_7(uint16_t bpid) goto err_alloc; } memset(addr, 0x00, LDPAA_ETH_RX_BUFFER_SIZE); + flush_dcache_range((u64)addr, + (u64)(addr + LDPAA_ETH_RX_BUFFER_SIZE)); buf_array[i] = (uint64_t)addr; debug("Release: buffer addr =0x%p\n", addr); @@ -623,10 +640,7 @@ static int ldpaa_eth_netdev_init(struct eth_device *net_dev) int err; struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv; - if (priv->type == LDPAA_ETH_1G_E) - sprintf(net_dev->name, "DTSEC%d", priv->dpni_id); - else - sprintf(net_dev->name, "TGEC%d", priv->dpni_id); + sprintf(net_dev->name, "DPNI%d", priv->dpni_id); net_dev->iobase = 0; net_dev->init = ldpaa_eth_open;