From patchwork Wed Apr 26 23:38:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iyappan Subramanian X-Patchwork-Id: 9702205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 02E8F601D3 for ; Wed, 26 Apr 2017 23:38:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E724A28399 for ; Wed, 26 Apr 2017 23:38:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB86F284DB; Wed, 26 Apr 2017 23:38:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 647F428399 for ; Wed, 26 Apr 2017 23:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zrPPEBsX3Bkfcyed29fzWy7ERQQGqcTMQktvI6qdfX4=; b=fecwI1rmfeBJ97fNWe/fbiGXR5 e9p7mZgp1iu9/i4a3DPwxRt/M6BDVJ4etSZuGa5bamx5DooTZR3jkTRyhMPf8QuRVu2BaRlxRsWMh EeDbQCfz0i3G/P7WXO8NzlyEc7FTtg9oIat6sE8OKwvab5hefpbMiWLdaX1ZjsrUQwE5ZcZe2VyxU xBXNxeE32njmOTJYpyPm8jScJMSXpt/FiC15jkisxQt0ZRAMA8L7mKjCtvnx6dg8rIEjKh6H/Ab00 fryu5sRPlGASimFYVig2WMPMemRiBib8IFiMGVneGMX8WnfWthpq21kiFg9/6PWf2eOp0VOWvIcnW yo817fDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d3WVm-0005j8-Sh; Wed, 26 Apr 2017 23:38:18 +0000 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d3WUZ-0004Dv-0K for linux-arm-kernel@lists.infradead.org; Wed, 26 Apr 2017 23:37:07 +0000 Received: by mail-pf0-x232.google.com with SMTP id c198so8314369pfc.1 for ; Wed, 26 Apr 2017 16:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JSxUxHOh1t2p2nEtmnFliwlvhGRA2EANwaNdL4GqeQI=; b=TCtTGMpQyTqYh9RoyqTuGSEd74Ai+3UH0vwuXk4JzFhJS5Kx2Nw66UeacFfAGaKQ0n 2dd1mbSEeidffaZLuFaEV13SijWckLfhHxs2RMNYcy1beXUacBSBLetgY+BPzMyesqty r/5D6GnTFMJNi+JRXo2C/OBytqvgMcTQinBnI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JSxUxHOh1t2p2nEtmnFliwlvhGRA2EANwaNdL4GqeQI=; b=VFcSgJ7R2BbGEh7V5MFwZucoemMbd74W53pg2hGj4WAGFOloPfMh+4S1a0WMcGIrB7 UH846M0oprqI0JghoNKMh+kiEOmYCgk9WvqIEVr0vq9gk+yqCD7Ze+9E3Fq3+LufeUU4 L6+QEzOQKjZ0DKn34zZKNqGzX291NMbI/puzPfWgv5efJWqd1rhzMeiUe8SguDDS4Smg z5VsJEGRTZHoghT7UGBFNlqIj1QXID7nS7PYswspIAlF7uiK1kYmbNsDMneML+kzD76t s0HcaBYpfF3qRxIqw9ZepMtj4wjpeTHtA052kofMF9mt7UB48/n8soNowQ0BdAyr34Ws MbUw== X-Gm-Message-State: AN3rC/5xpTiDcGIz+MVShAT4KaEqUlbT+VcElK3LaiDF3YOFj2O9CrCm uu1l8jlvyePxNs96 X-Received: by 10.99.97.4 with SMTP id v4mr2447377pgb.171.1493249803101; Wed, 26 Apr 2017 16:36:43 -0700 (PDT) Received: from isubrama-dev.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id i30sm626700pgn.39.2017.04.26.16.36.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Apr 2017 16:36:42 -0700 (PDT) From: Iyappan Subramanian To: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH net-next 9/9] drivers: net: xgene: Workaround for HW errata 10GE_10/ENET_15 Date: Wed, 26 Apr 2017 16:38:55 -0700 Message-Id: <1493249935-30759-10-git-send-email-isubramanian@apm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493249935-30759-1-git-send-email-isubramanian@apm.com> References: <1493249935-30759-1-git-send-email-isubramanian@apm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170426_163703_188307_D4C59D61 X-CRM114-Status: GOOD ( 16.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Quan Nguyen , patches@apm.com, linux-arm-kernel@lists.infradead.org, Iyappan Subramanian MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quan Nguyen This patch adds workaround for HW errata 10GE_10 and ENET_15: "HW statistic counters value are duplicated". - RFCS duplicates RALN counter - RFLR duplicates RUND counter - TFCS duplicates TFRG counter - RALN should be intepreted as 0 in 10G mode Signed-off-by: Quan Nguyen Signed-off-by: Iyappan Subramanian --- .../net/ethernet/apm/xgene/xgene_enet_ethtool.c | 30 ++++++++++++++++++---- drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 20 ++++++++++++--- drivers/net/ethernet/apm/xgene/xgene_enet_main.h | 2 ++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c b/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c index 5e8660e..8d9ed2b 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c @@ -71,6 +71,7 @@ struct xgene_gstrings_stats { XGENE_EXTD_STAT(rx_oversize_pkt_cntr, ROVR, 16), XGENE_EXTD_STAT(rx_fragments_cntr, RFRG, 16), XGENE_EXTD_STAT(rx_jabber_cntr, RJBR, 16), + XGENE_EXTD_STAT(rx_jabber_recov_cntr, DUMP, 0), XGENE_EXTD_STAT(rx_dropped_pkt_cntr, RDRP, 16), XGENE_EXTD_STAT(rx_overrun_cntr, DUMP, 0), XGENE_EXTD_STAT(tx_multicast_pkt_cntr, TMCA, 31), @@ -96,9 +97,16 @@ struct xgene_gstrings_stats { #define XGENE_STATS_LEN ARRAY_SIZE(gstrings_stats) #define XGENE_EXTD_STATS_LEN ARRAY_SIZE(gstrings_extd_stats) +#define RFCS_IDX 7 +#define RALN_IDX 13 +#define RFLR_IDX 14 #define FALSE_RFLR_IDX 15 -#define RX_OVERRUN_IDX 23 -#define TX_UNDERRUN_IDX 42 +#define RUND_IDX 18 +#define FALSE_RJBR_IDX 22 +#define RX_OVERRUN_IDX 24 +#define TFCS_IDX 38 +#define TFRG_IDX 42 +#define TX_UNDERRUN_IDX 43 static void xgene_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *info) @@ -217,24 +225,36 @@ static int xgene_get_sset_count(struct net_device *ndev, int sset) static void xgene_get_extd_stats(struct xgene_enet_pdata *pdata) { + u32 tmp[XGENE_EXTD_STATS_LEN]; u32 rx_drop, tx_drop; - u32 tmp; int i; for (i = 0; i < XGENE_EXTD_STATS_LEN; i++) { pdata->mac_ops->read_stats(pdata, - gstrings_extd_stats[i].addr, &tmp); + gstrings_extd_stats[i].addr, &tmp[i]); if (gstrings_extd_stats[i].mask) - pdata->extd_stats[i] += tmp & + pdata->extd_stats[i] += tmp[i] & GENMASK(gstrings_extd_stats[i].mask - 1, 0); } + if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) { + /* Errata 10GE_10 - SW should intepret RALN as 0 */ + pdata->extd_stats[RALN_IDX] = 0; + } else { + /* Errata ENET_15 - Fixes RFCS, RFLR, TFCS counter */ + pdata->extd_stats[RFCS_IDX] -= tmp[RALN_IDX]; + pdata->extd_stats[RFLR_IDX] -= tmp[RUND_IDX]; + pdata->extd_stats[TFCS_IDX] -= tmp[TFRG_IDX]; + } + pdata->mac_ops->get_drop_cnt(pdata, &rx_drop, &tx_drop); pdata->extd_stats[RX_OVERRUN_IDX] += rx_drop; pdata->extd_stats[TX_UNDERRUN_IDX] += tx_drop; /* Errata 10GE_8 - Update Frame recovered from Errata 10GE_8/ENET_11 */ pdata->extd_stats[FALSE_RFLR_IDX] = pdata->false_rflr; + /* Errata ENET_15 - Jabber Frame recov'ed from Errata 10GE_10/ENET_15 */ + pdata->extd_stats[FALSE_RJBR_IDX] = pdata->vlan_rjbr; } int xgene_extd_stats_init(struct xgene_enet_pdata *pdata) diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c index c2d38da..01e389d 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c @@ -656,6 +656,18 @@ static void xgene_enet_free_pagepool(struct xgene_enet_desc_ring *buf_pool, buf_pool->head = head; } +/* Errata 10GE_10 and ENET_15 - Fix duplicated HW statistic counters */ +static bool xgene_enet_errata_10GE_10(struct sk_buff *skb, u32 len, u8 status) +{ + if (status == INGRESS_CRC && + len >= (ETHER_STD_PACKET + 1) && + len <= (ETHER_STD_PACKET + 4) && + skb->protocol == htons(ETH_P_8021Q)) + return true; + + return false; +} + /* Errata 10GE_8 and ENET_11 - allow packet with length <=64B */ static bool xgene_enet_errata_10GE_8(struct sk_buff *skb, u32 len, u8 status) { @@ -706,14 +718,16 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring, status = (GET_VAL(ELERR, le64_to_cpu(raw_desc->m0)) << LERR_LEN) | GET_VAL(LERR, le64_to_cpu(raw_desc->m0)); if (unlikely(status)) { - if (!xgene_enet_errata_10GE_8(skb, datalen, status)) { + if (xgene_enet_errata_10GE_8(skb, datalen, status)) { + pdata->false_rflr++; + } else if (xgene_enet_errata_10GE_10(skb, datalen, status)) { + pdata->vlan_rjbr++; + } else { dev_kfree_skb_any(skb); xgene_enet_free_pagepool(page_pool, raw_desc, exp_desc); xgene_enet_parse_error(rx_ring, status); rx_ring->rx_dropped++; goto out; - } else { - pdata->false_rflr++; } } diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h index 8afae57..911137f 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h @@ -42,6 +42,7 @@ #define XGENE_DRV_VERSION "v1.0" #define ETHER_MIN_PACKET 64 +#define ETHER_STD_PACKET 1518 #define XGENE_ENET_STD_MTU 1536 #define XGENE_ENET_MAX_MTU 9600 #define SKB_BUFFER_SIZE (XGENE_ENET_STD_MTU - NET_IP_ALIGN) @@ -226,6 +227,7 @@ struct xgene_enet_pdata { struct xgene_enet_cle cle; u64 *extd_stats; u64 false_rflr; + u64 vlan_rjbr; spinlock_t stats_lock; /* statistics lock */ const struct xgene_mac_ops *mac_ops; spinlock_t mac_lock; /* mac lock */