Skip to content

Commit 4cd85a6

Browse files
Karicheri, Muralidharandavem330
authored andcommitted
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: Murali Karicheri <[email protected]> Signed-off-by: Sekhar Nori <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0cead3a commit 4cd85a6

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

drivers/net/ethernet/ti/netcp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ struct netcp_intf {
102102
void *rx_fdq[KNAV_DMA_FDQ_PER_CHAN];
103103
struct napi_struct rx_napi;
104104
struct napi_struct tx_napi;
105+
#define ETH_SW_CAN_REMOVE_ETH_FCS BIT(0)
106+
u32 hw_cap;
105107

106108
/* 64-bit netcp stats */
107109
struct netcp_stats stats;

drivers/net/ethernet/ti/netcp_core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,12 @@ static int netcp_process_one_rx_packet(struct netcp_intf *netcp)
739739
dev_dbg(netcp->ndev_dev, "mismatch in packet size(%d) & sum of fragments(%d)\n",
740740
pkt_sz, accum_sz);
741741

742-
/* Remove ethernet FCS from the packet */
743-
__pskb_trim(skb, skb->len - ETH_FCS_LEN);
742+
/* Newer version of the Ethernet switch can trim the Ethernet FCS
743+
* from the packet and is indicated in hw_cap. So trim it only for
744+
* older h/w
745+
*/
746+
if (!(netcp->hw_cap & ETH_SW_CAN_REMOVE_ETH_FCS))
747+
__pskb_trim(skb, skb->len - ETH_FCS_LEN);
744748

745749
/* Call each of the RX hooks */
746750
p_info.skb = skb;

drivers/net/ethernet/ti/netcp_ethss.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
#define MACSL_FULLDUPLEX BIT(0)
123123

124124
#define GBE_CTL_P0_ENABLE BIT(2)
125+
#define ETH_SW_CTL_P0_TX_CRC_REMOVE BIT(13)
125126
#define GBE13_REG_VAL_STAT_ENABLE_ALL 0xff
126127
#define XGBE_REG_VAL_STAT_ENABLE_ALL 0xf
127128
#define GBE_STATS_CD_SEL BIT(28)
@@ -2821,7 +2822,7 @@ static int gbe_open(void *intf_priv, struct net_device *ndev)
28212822
struct netcp_intf *netcp = netdev_priv(ndev);
28222823
struct gbe_slave *slave = gbe_intf->slave;
28232824
int port_num = slave->port_num;
2824-
u32 reg;
2825+
u32 reg, val;
28252826
int ret;
28262827

28272828
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)
28512852
writel(0, GBE_REG_ADDR(gbe_dev, switch_regs, ptype));
28522853

28532854
/* Control register */
2854-
writel(GBE_CTL_P0_ENABLE, GBE_REG_ADDR(gbe_dev, switch_regs, control));
2855+
val = GBE_CTL_P0_ENABLE;
2856+
if (IS_SS_ID_MU(gbe_dev)) {
2857+
val |= ETH_SW_CTL_P0_TX_CRC_REMOVE;
2858+
netcp->hw_cap = ETH_SW_CAN_REMOVE_ETH_FCS;
2859+
}
2860+
writel(val, GBE_REG_ADDR(gbe_dev, switch_regs, control));
28552861

28562862
/* All statistics enabled and STAT AB visible by default */
28572863
writel(gbe_dev->stats_en_mask, GBE_REG_ADDR(gbe_dev, switch_regs,

0 commit comments

Comments
 (0)