Commit 4cd85a61 authored by Karicheri, Muralidharan's avatar Karicheri, Muralidharan Committed by David S. Miller

net: netcp: use hw capability to remove FCS word from rx packets

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: default avatarMurali Karicheri <m-karicheri2@ti.com>
Signed-off-by: default avatarSekhar Nori <nsekhar@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0cead3a6
...@@ -102,6 +102,8 @@ struct netcp_intf { ...@@ -102,6 +102,8 @@ struct netcp_intf {
void *rx_fdq[KNAV_DMA_FDQ_PER_CHAN]; void *rx_fdq[KNAV_DMA_FDQ_PER_CHAN];
struct napi_struct rx_napi; struct napi_struct rx_napi;
struct napi_struct tx_napi; struct napi_struct tx_napi;
#define ETH_SW_CAN_REMOVE_ETH_FCS BIT(0)
u32 hw_cap;
/* 64-bit netcp stats */ /* 64-bit netcp stats */
struct netcp_stats stats; struct netcp_stats stats;
......
...@@ -739,8 +739,12 @@ static int netcp_process_one_rx_packet(struct netcp_intf *netcp) ...@@ -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", dev_dbg(netcp->ndev_dev, "mismatch in packet size(%d) & sum of fragments(%d)\n",
pkt_sz, accum_sz); pkt_sz, accum_sz);
/* Remove ethernet FCS from the packet */ /* Newer version of the Ethernet switch can trim the Ethernet FCS
__pskb_trim(skb, skb->len - ETH_FCS_LEN); * 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 */ /* Call each of the RX hooks */
p_info.skb = skb; p_info.skb = skb;
......
...@@ -122,6 +122,7 @@ ...@@ -122,6 +122,7 @@
#define MACSL_FULLDUPLEX BIT(0) #define MACSL_FULLDUPLEX BIT(0)
#define GBE_CTL_P0_ENABLE BIT(2) #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 GBE13_REG_VAL_STAT_ENABLE_ALL 0xff
#define XGBE_REG_VAL_STAT_ENABLE_ALL 0xf #define XGBE_REG_VAL_STAT_ENABLE_ALL 0xf
#define GBE_STATS_CD_SEL BIT(28) #define GBE_STATS_CD_SEL BIT(28)
...@@ -2821,7 +2822,7 @@ static int gbe_open(void *intf_priv, struct net_device *ndev) ...@@ -2821,7 +2822,7 @@ static int gbe_open(void *intf_priv, struct net_device *ndev)
struct netcp_intf *netcp = netdev_priv(ndev); struct netcp_intf *netcp = netdev_priv(ndev);
struct gbe_slave *slave = gbe_intf->slave; struct gbe_slave *slave = gbe_intf->slave;
int port_num = slave->port_num; int port_num = slave->port_num;
u32 reg; u32 reg, val;
int ret; int ret;
reg = readl(GBE_REG_ADDR(gbe_dev, switch_regs, id_ver)); reg = readl(GBE_REG_ADDR(gbe_dev, switch_regs, id_ver));
...@@ -2851,7 +2852,12 @@ static int gbe_open(void *intf_priv, struct net_device *ndev) ...@@ -2851,7 +2852,12 @@ static int gbe_open(void *intf_priv, struct net_device *ndev)
writel(0, GBE_REG_ADDR(gbe_dev, switch_regs, ptype)); writel(0, GBE_REG_ADDR(gbe_dev, switch_regs, ptype));
/* Control register */ /* 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 */ /* All statistics enabled and STAT AB visible by default */
writel(gbe_dev->stats_en_mask, GBE_REG_ADDR(gbe_dev, switch_regs, writel(gbe_dev->stats_en_mask, GBE_REG_ADDR(gbe_dev, switch_regs,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment