From: Murali Karicheri <m-karicheri2@ti.com>
To: <netdev@vger.kernel.org>, <linux-omap@vger.kernel.org>,
<grygorii.strashko@ti.com>, <mugunthanvnm@ti.com>,
<linux-kernel@vger.kernel.org>, <arnd@arndb.de>,
<davem@davemloft.net>, <devicetree@vger.kernel.org>,
<mark.rutland@arm.com>, <robh+dt@kernel.org>
Subject: [PATCH net-next 07/10] net: netcp: use hw capability to remove FCS word from rx packets
Date: Tue, 20 Dec 2016 17:09:50 -0500 [thread overview]
Message-ID: <1482271793-7671-8-git-send-email-m-karicheri2@ti.com> (raw)
In-Reply-To: <1482271793-7671-1-git-send-email-m-karicheri2@ti.com>
Some of the newer Ethernet switch hw (such as that on k2e/l/g) can
strip the Etherenet FCS from packet at the port 0 egress of the switch.
So use this capability instead of doing it in software.
Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
---
drivers/net/ethernet/ti/netcp.h | 2 ++
drivers/net/ethernet/ti/netcp_core.c | 8 ++++++--
drivers/net/ethernet/ti/netcp_ethss.c | 10 ++++++++--
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/ti/netcp.h b/drivers/net/ethernet/ti/netcp.h
index d243c5d..8900a6f 100644
--- a/drivers/net/ethernet/ti/netcp.h
+++ b/drivers/net/ethernet/ti/netcp.h
@@ -102,6 +102,8 @@ struct netcp_intf {
void *rx_fdq[KNAV_DMA_FDQ_PER_CHAN];
struct napi_struct rx_napi;
struct napi_struct tx_napi;
+#define ETH_SW_CAN_REMOVE_ETH_FCS BIT(0)
+ u32 hw_cap;
/* 64-bit netcp stats */
struct netcp_stats stats;
diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
index b077ed4..68a75cc 100644
--- a/drivers/net/ethernet/ti/netcp_core.c
+++ b/drivers/net/ethernet/ti/netcp_core.c
@@ -739,8 +739,12 @@ static int netcp_process_one_rx_packet(struct netcp_intf *netcp)
dev_dbg(netcp->ndev_dev, "mismatch in packet size(%d) & sum of fragments(%d)\n",
pkt_sz, accum_sz);
- /* Remove ethernet FCS from the packet */
- __pskb_trim(skb, skb->len - ETH_FCS_LEN);
+ /* Newer version of the Ethernet switch can trim the Ethernet FCS
+ * from the packet and is indicated in hw_cap. So trim it only for
+ * older h/w
+ */
+ if (!(netcp->hw_cap & ETH_SW_CAN_REMOVE_ETH_FCS))
+ __pskb_trim(skb, skb->len - ETH_FCS_LEN);
/* Call each of the RX hooks */
p_info.skb = skb;
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 9266961..4b2a911 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -133,6 +133,7 @@
#define MACSL_FULLDUPLEX BIT(0)
#define GBE_CTL_P0_ENABLE BIT(2)
+#define ETH_SW_CTL_P0_TX_CRC_REMOVE BIT(13)
#define GBE13_REG_VAL_STAT_ENABLE_ALL 0xff
#define XGBE_REG_VAL_STAT_ENABLE_ALL 0xf
#define GBE_STATS_CD_SEL BIT(28)
@@ -2847,7 +2848,7 @@ static int gbe_open(void *intf_priv, struct net_device *ndev)
struct netcp_intf *netcp = netdev_priv(ndev);
struct gbe_slave *slave = gbe_intf->slave;
int port_num = slave->port_num;
- u32 reg;
+ u32 reg, val;
int ret;
reg = readl(GBE_REG_ADDR(gbe_dev, switch_regs, id_ver));
@@ -2877,7 +2878,12 @@ static int gbe_open(void *intf_priv, struct net_device *ndev)
writel(0, GBE_REG_ADDR(gbe_dev, switch_regs, ptype));
/* Control register */
- writel(GBE_CTL_P0_ENABLE, GBE_REG_ADDR(gbe_dev, switch_regs, control));
+ val = GBE_CTL_P0_ENABLE;
+ if (IS_SS_ID_MU(gbe_dev)) {
+ val |= ETH_SW_CTL_P0_TX_CRC_REMOVE;
+ netcp->hw_cap = ETH_SW_CAN_REMOVE_ETH_FCS;
+ }
+ writel(val, GBE_REG_ADDR(gbe_dev, switch_regs, control));
/* All statistics enabled and STAT AB visible by default */
writel(gbe_dev->stats_en_mask, GBE_REG_ADDR(gbe_dev, switch_regs,
--
1.9.1
next prev parent reply other threads:[~2016-12-20 22:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-20 22:09 [PATCH net-next 00/10] netcp: enhancements and minor fixes Murali Karicheri
2016-12-20 22:09 ` [PATCH net-next 01/10] net: netcp: ethss: add support of subsystem register region regmap Murali Karicheri
2016-12-22 21:24 ` Rob Herring
2017-01-05 20:42 ` Murali Karicheri
2017-01-05 22:08 ` Murali Karicheri
2016-12-20 22:09 ` [PATCH net-next 02/10] net: netcp: ethss: add support of 10gbe pcsr link status Murali Karicheri
2016-12-22 22:30 ` Rob Herring
2016-12-20 22:09 ` [PATCH net-next 03/10] net: netcp: extract eflag from desc for rx_hook handling Murali Karicheri
2016-12-20 22:09 ` [PATCH net-next 04/10] net: netcp: remove the redundant memmov() Murali Karicheri
2016-12-20 22:09 ` [PATCH net-next 05/10] net: netcp: store network statistics in 64 bits Murali Karicheri
2016-12-20 22:09 ` [PATCH net-next 06/10] net: netcp: ethss: get phy-handle only if link interface is MAC-to-PHY Murali Karicheri
2016-12-20 22:09 ` Murali Karicheri [this message]
2016-12-20 22:09 ` [PATCH net-next 08/10] net: netcp: ale: update to support unknown vlan controls for NU switch Murali Karicheri
2016-12-20 22:09 ` [PATCH net-next 09/10] net: netcp: ale: use ale_status to size the ale table Murali Karicheri
2016-12-20 22:09 ` [PATCH net-next 10/10] net: netcp: ale: add proper ale entry mask bits for netcp switch ALE Murali Karicheri
2016-12-21 0:03 ` [PATCH net-next 00/10] netcp: enhancements and minor fixes David Miller
2016-12-21 23:50 ` Murali Karicheri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1482271793-7671-8-git-send-email-m-karicheri2@ti.com \
--to=m-karicheri2@ti.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=grygorii.strashko@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mugunthanvnm@ti.com \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).