Commit a0651d8e authored by David S. Miller's avatar David S. Miller

Merge branch 'net-systemport-Turn-on-offloads-by-default'

Florian Fainelli says:

====================
net: systemport: Turn on offloads by default

Up until now, we had added all the code necessary to turn on RX/TX
checksum offloads at runtime, but there is no reason why they have to be
disabled by default given that this gives a slight performance
improvement.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 460b3601 a5d78ce7
...@@ -126,7 +126,7 @@ static inline void tdma_port_write_desc_addr(struct bcm_sysport_priv *priv, ...@@ -126,7 +126,7 @@ static inline void tdma_port_write_desc_addr(struct bcm_sysport_priv *priv,
} }
/* Ethtool operations */ /* Ethtool operations */
static int bcm_sysport_set_rx_csum(struct net_device *dev, static void bcm_sysport_set_rx_csum(struct net_device *dev,
netdev_features_t wanted) netdev_features_t wanted)
{ {
struct bcm_sysport_priv *priv = netdev_priv(dev); struct bcm_sysport_priv *priv = netdev_priv(dev);
...@@ -157,11 +157,9 @@ static int bcm_sysport_set_rx_csum(struct net_device *dev, ...@@ -157,11 +157,9 @@ static int bcm_sysport_set_rx_csum(struct net_device *dev,
reg &= ~RXCHK_BRCM_TAG_EN; reg &= ~RXCHK_BRCM_TAG_EN;
rxchk_writel(priv, reg, RXCHK_CONTROL); rxchk_writel(priv, reg, RXCHK_CONTROL);
return 0;
} }
static int bcm_sysport_set_tx_csum(struct net_device *dev, static void bcm_sysport_set_tx_csum(struct net_device *dev,
netdev_features_t wanted) netdev_features_t wanted)
{ {
struct bcm_sysport_priv *priv = netdev_priv(dev); struct bcm_sysport_priv *priv = netdev_priv(dev);
...@@ -177,23 +175,24 @@ static int bcm_sysport_set_tx_csum(struct net_device *dev, ...@@ -177,23 +175,24 @@ static int bcm_sysport_set_tx_csum(struct net_device *dev,
else else
reg &= ~tdma_control_bit(priv, TSB_EN); reg &= ~tdma_control_bit(priv, TSB_EN);
tdma_writel(priv, reg, TDMA_CONTROL); tdma_writel(priv, reg, TDMA_CONTROL);
return 0;
} }
static int bcm_sysport_set_features(struct net_device *dev, static int bcm_sysport_set_features(struct net_device *dev,
netdev_features_t features) netdev_features_t features)
{ {
netdev_features_t changed = features ^ dev->features; struct bcm_sysport_priv *priv = netdev_priv(dev);
netdev_features_t wanted = dev->wanted_features;
int ret = 0;
if (changed & NETIF_F_RXCSUM) /* Read CRC forward */
ret = bcm_sysport_set_rx_csum(dev, wanted); if (!priv->is_lite)
if (changed & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) priv->crc_fwd = !!(umac_readl(priv, UMAC_CMD) & CMD_CRC_FWD);
ret = bcm_sysport_set_tx_csum(dev, wanted); else
priv->crc_fwd = !((gib_readl(priv, GIB_CONTROL) &
GIB_FCS_STRIP) >> GIB_FCS_STRIP_SHIFT);
return ret; bcm_sysport_set_rx_csum(dev, features);
bcm_sysport_set_tx_csum(dev, features);
return 0;
} }
/* Hardware counters must be kept in sync because the order/offset /* Hardware counters must be kept in sync because the order/offset
...@@ -285,6 +284,8 @@ static const struct bcm_sysport_stats bcm_sysport_gstrings_stats[] = { ...@@ -285,6 +284,8 @@ static const struct bcm_sysport_stats bcm_sysport_gstrings_stats[] = {
STAT_MIB_SOFT("alloc_rx_buff_failed", mib.alloc_rx_buff_failed), STAT_MIB_SOFT("alloc_rx_buff_failed", mib.alloc_rx_buff_failed),
STAT_MIB_SOFT("rx_dma_failed", mib.rx_dma_failed), STAT_MIB_SOFT("rx_dma_failed", mib.rx_dma_failed),
STAT_MIB_SOFT("tx_dma_failed", mib.tx_dma_failed), STAT_MIB_SOFT("tx_dma_failed", mib.tx_dma_failed),
STAT_MIB_SOFT("tx_realloc_tsb", mib.tx_realloc_tsb),
STAT_MIB_SOFT("tx_realloc_tsb_failed", mib.tx_realloc_tsb_failed),
/* Per TX-queue statistics are dynamically appended */ /* Per TX-queue statistics are dynamically appended */
}; };
...@@ -1221,6 +1222,7 @@ static void bcm_sysport_poll_controller(struct net_device *dev) ...@@ -1221,6 +1222,7 @@ static void bcm_sysport_poll_controller(struct net_device *dev)
static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb, static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb,
struct net_device *dev) struct net_device *dev)
{ {
struct bcm_sysport_priv *priv = netdev_priv(dev);
struct sk_buff *nskb; struct sk_buff *nskb;
struct bcm_tsb *tsb; struct bcm_tsb *tsb;
u32 csum_info; u32 csum_info;
...@@ -1231,13 +1233,16 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb, ...@@ -1231,13 +1233,16 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb,
/* Re-allocate SKB if needed */ /* Re-allocate SKB if needed */
if (unlikely(skb_headroom(skb) < sizeof(*tsb))) { if (unlikely(skb_headroom(skb) < sizeof(*tsb))) {
nskb = skb_realloc_headroom(skb, sizeof(*tsb)); nskb = skb_realloc_headroom(skb, sizeof(*tsb));
dev_kfree_skb(skb);
if (!nskb) { if (!nskb) {
dev_kfree_skb_any(skb);
priv->mib.tx_realloc_tsb_failed++;
dev->stats.tx_errors++; dev->stats.tx_errors++;
dev->stats.tx_dropped++; dev->stats.tx_dropped++;
return NULL; return NULL;
} }
dev_consume_skb_any(skb);
skb = nskb; skb = nskb;
priv->mib.tx_realloc_tsb++;
} }
tsb = skb_push(skb, sizeof(*tsb)); tsb = skb_push(skb, sizeof(*tsb));
...@@ -1973,16 +1978,14 @@ static int bcm_sysport_open(struct net_device *dev) ...@@ -1973,16 +1978,14 @@ static int bcm_sysport_open(struct net_device *dev)
else else
gib_set_pad_extension(priv); gib_set_pad_extension(priv);
/* Apply features again in case we changed them while interface was
* down
*/
bcm_sysport_set_features(dev, dev->features);
/* Set MAC address */ /* Set MAC address */
umac_set_hw_addr(priv, dev->dev_addr); umac_set_hw_addr(priv, dev->dev_addr);
/* Read CRC forward */
if (!priv->is_lite)
priv->crc_fwd = !!(umac_readl(priv, UMAC_CMD) & CMD_CRC_FWD);
else
priv->crc_fwd = !((gib_readl(priv, GIB_CONTROL) &
GIB_FCS_STRIP) >> GIB_FCS_STRIP_SHIFT);
phydev = of_phy_connect(dev, priv->phy_dn, bcm_sysport_adj_link, phydev = of_phy_connect(dev, priv->phy_dn, bcm_sysport_adj_link,
0, priv->phy_interface); 0, priv->phy_interface);
if (!phydev) { if (!phydev) {
...@@ -2511,9 +2514,10 @@ static int bcm_sysport_probe(struct platform_device *pdev) ...@@ -2511,9 +2514,10 @@ static int bcm_sysport_probe(struct platform_device *pdev)
dev->netdev_ops = &bcm_sysport_netdev_ops; dev->netdev_ops = &bcm_sysport_netdev_ops;
netif_napi_add(dev, &priv->napi, bcm_sysport_poll, 64); netif_napi_add(dev, &priv->napi, bcm_sysport_poll, 64);
/* HW supported features, none enabled by default */ dev->features |= NETIF_F_RXCSUM | NETIF_F_HIGHDMA |
dev->hw_features |= NETIF_F_RXCSUM | NETIF_F_HIGHDMA |
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
dev->hw_features |= dev->features;
dev->vlan_features |= dev->features;
/* Request the WOL interrupt and advertise suspend if available */ /* Request the WOL interrupt and advertise suspend if available */
priv->wol_irq_disabled = 1; priv->wol_irq_disabled = 1;
...@@ -2716,7 +2720,6 @@ static int __maybe_unused bcm_sysport_resume(struct device *d) ...@@ -2716,7 +2720,6 @@ static int __maybe_unused bcm_sysport_resume(struct device *d)
struct net_device *dev = dev_get_drvdata(d); struct net_device *dev = dev_get_drvdata(d);
struct bcm_sysport_priv *priv = netdev_priv(dev); struct bcm_sysport_priv *priv = netdev_priv(dev);
unsigned int i; unsigned int i;
u32 reg;
int ret; int ret;
if (!netif_running(dev)) if (!netif_running(dev))
...@@ -2760,12 +2763,8 @@ static int __maybe_unused bcm_sysport_resume(struct device *d) ...@@ -2760,12 +2763,8 @@ static int __maybe_unused bcm_sysport_resume(struct device *d)
goto out_free_rx_ring; goto out_free_rx_ring;
} }
/* Enable rxhck */ /* Restore enabled features */
if (priv->rx_chk_en) { bcm_sysport_set_features(dev, dev->features);
reg = rxchk_readl(priv, RXCHK_CONTROL);
reg |= RXCHK_EN;
rxchk_writel(priv, reg, RXCHK_CONTROL);
}
rbuf_init(priv); rbuf_init(priv);
......
...@@ -607,6 +607,8 @@ struct bcm_sysport_mib { ...@@ -607,6 +607,8 @@ struct bcm_sysport_mib {
u32 alloc_rx_buff_failed; u32 alloc_rx_buff_failed;
u32 rx_dma_failed; u32 rx_dma_failed;
u32 tx_dma_failed; u32 tx_dma_failed;
u32 tx_realloc_tsb;
u32 tx_realloc_tsb_failed;
}; };
/* HW maintains a large list of counters */ /* HW maintains a large list of counters */
......
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