net: systemport: Turn on offloads by
Subsystems (3)
cover net: systemport: Turn on offloads by
Hi David,
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.
Florian Fainelli (5):
net: systemport: Refactor bcm_sysport_set_features()
net: systemport: Utilize bcm_sysport_set_features() during resume/open
net: systemport: Turn on offloads by default
net: systemport: Be drop monitor friendly while re-allocating headroom
net: systemport: Add software counters to track reallocations
drivers/net/ethernet/broadcom/bcmsysport.c | 67 +++++++++++----------- drivers/net/ethernet/broadcom/bcmsysport.h | 2 + 2 files changed, 35 insertions(+), 34 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/5 net: systemport: Refactor bcm_sysport_set_features()
In preparation for unconditionally enabling TX and RX checksum offloads, refactor bcm_sysport_set_features() a bit such that __netdev_update_features() during register_netdev() can make sure that features are correctly programmed during network device registration.
Since we can now be called during register_netdev() with clocks gated, we need to temporarily turn them on/off in order to have a successful register programming.
We also move the CRC forward setting read into bcm_sysport_set_features() since priv->crc_fwd matters while turning on RX checksum offload, that way we are guaranteed they are in sync in case we ever add support for NETIF_F_RXFCS at some point in the future.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 38 +++++++++------------- 1 file changed, 15 insertions(+), 23 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +15 -23
@@ -126,8 +126,8 @@ static inline void tdma_port_write_desc_addr(struct bcm_sysport_priv *priv, }/* Ethtool operations */ -static int bcm_sysport_set_rx_csum (struct net_device *dev, -netdev_features_t wanted) +static void bcm_sysport_set_rx_csum (struct net_device *dev, +netdev_features_t wanted) {struct bcm_sysport_priv *priv =netdev_priv (dev);u32 reg;
@@ -157,12 +157,10 @@ static int bcm_sysport_set_rx_csum(struct net_device *dev, reg &= ~RXCHK_BRCM_TAG_EN ;rxchk_writel (priv, reg,RXCHK_CONTROL ); - -return 0 ; } -static int bcm_sysport_set_tx_csum (struct net_device *dev, -netdev_features_t wanted) +static void bcm_sysport_set_tx_csum (struct net_device *dev, +netdev_features_t wanted) {struct bcm_sysport_priv *priv =netdev_priv (dev);u32 reg;
@@ -177,23 +175,24 @@ static int bcm_sysport_set_tx_csum(struct net_device *dev,else reg &= ~tdma_control_bit (priv,TSB_EN );tdma_writel (priv, reg,TDMA_CONTROL ); - -return 0 ; }static int bcm_sysport_set_features (struct net_device *dev,netdev_features_t features) { -netdev_features_t changed = features ^ dev->features; -netdev_features_t wanted = dev->wanted_features; -int ret =0 ; +struct bcm_sysport_priv *priv =netdev_priv (dev); + +/* 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 ); -if (changed &NETIF_F_RXCSUM ) - ret =bcm_sysport_set_rx_csum (dev, wanted); -if (changed & (NETIF_F_IP_CSUM |NETIF_F_IPV6_CSUM )) - ret =bcm_sysport_set_tx_csum (dev, wanted); +bcm_sysport_set_rx_csum (dev, features); +bcm_sysport_set_tx_csum (dev, features); -return ret; +return 0 ; }/* Hardware counters must be kept in sync because the order/offset
@@ -1976,13 +1975,6 @@ static int bcm_sysport_open(struct net_device *dev)/* Set MAC address */ 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,0 , priv->phy_interface);if (!phydev) {
Signature · 1 line
2.17.1
PATCH 2/5 net: systemport: Utilize bcm_sysport_set_features() during resume/open
In reply to Florian FainelliDuring driver resume and open, the HW may have lost its context/state, utilize bcm_sysport_set_features() to make sure we do restore the correct set of features that were previously configured.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +7 -7
@@ -1972,6 +1972,11 @@ static int bcm_sysport_open(struct net_device *dev)else 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 */ umac_set_hw_addr (priv, dev->dev_addr);
@@ -2708,7 +2713,6 @@ static int __maybe_unused bcm_sysport_resume(struct device *d)struct net_device *dev =dev_get_drvdata (d);struct bcm_sysport_priv *priv =netdev_priv (dev);unsigned int i; -u32 reg;int ret;if (!netif_running (dev))
@@ -2752,12 +2756,8 @@ static int __maybe_unused bcm_sysport_resume(struct device *d) goto out_free_rx_ring; } -/* Enable rxhck */ -if (priv->rx_chk_en) { - reg =rxchk_readl (priv,RXCHK_CONTROL ); - reg |=RXCHK_EN ; -rxchk_writel (priv, reg,RXCHK_CONTROL ); - } +/* Restore enabled features */ +bcm_sysport_set_features (dev, dev->features);rbuf_init (priv);
Signature · 1 line
2.17.1
PATCH 3/5 net: systemport: Turn on offloads by default
In reply to Florian FainelliWe can turn on the RX/TX checksum offloads by default and make sure that those are properly reflected back to e.g: stacked devices such as VLAN or DSA.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +4 -3
@@ -2508,9 +2508,10 @@ static int bcm_sysport_probe(struct platform_device *pdev) dev->netdev_ops = &bcm_sysport_netdev_ops;netif_napi_add (dev, &priv->napi, bcm_sysport_poll,64 ); -/* HW supported features, none enabled by default */ - dev->hw_features |=NETIF_F_RXCSUM |NETIF_F_HIGHDMA | -NETIF_F_IP_CSUM |NETIF_F_IPV6_CSUM ; + dev->features |=NETIF_F_RXCSUM |NETIF_F_HIGHDMA | +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 */ priv->wol_irq_disabled =1 ;
Signature · 1 line
2.17.1
PATCH 4/5 net: systemport: Be drop monitor friendly while re-allocating headroom
In reply to Florian FainelliDuring bcm_sysport_insert_tsb() make sure we differentiate a SKB headroom re-allocation failure from the normal swap and replace path.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bcmsysport.c +2 -1
@@ -1230,12 +1230,13 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb,/* Re-allocate SKB if needed */ if (unlikely (skb_headroom (skb) <sizeof (*tsb))) { nskb =skb_realloc_headroom (skb,sizeof (*tsb)); -dev_kfree_skb (skb);if (!nskb) { +dev_kfree_skb_any (skb); dev->stats.tx_errors++; dev->stats.tx_dropped++;return NULL ; } +dev_consume_skb_any (skb); skb = nskb; }
Signature · 1 line
2.17.1
PATCH 5/5 net: systemport: Add software counters to track reallocations
In reply to Florian FainelliWhen inserting the TSB, keep track of how many times we had to do it and if there was a failure in doing so, this helps profile the driver for possibly incorrect headroom settings.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 5 +++++ drivers/net/ethernet/broadcom/bcmsysport.h | 2 ++ 2 files changed, 7 insertions(+)
drivers/net/ethernet/broadcom/bcmsysport.c +5 -0
@@ -284,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 ("rx_dma_failed" , mib.rx_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 */ };
@@ -1220,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,struct net_device *dev) { +struct bcm_sysport_priv *priv =netdev_priv (dev);struct sk_buff *nskb;struct bcm_tsb *tsb;u32 csum_info;
@@ -1232,12 +1235,14 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb, nskb =skb_realloc_headroom (skb,sizeof (*tsb));if (!nskb) {dev_kfree_skb_any (skb); + priv->mib.tx_realloc_tsb_failed++; dev->stats.tx_errors++; dev->stats.tx_dropped++;return NULL ; }dev_consume_skb_any (skb); skb = nskb; + priv->mib.tx_realloc_tsb++; } tsb =skb_push (skb,sizeof (*tsb));
drivers/net/ethernet/broadcom/bcmsysport.h +2 -0
@@ -607,6 +607,8 @@ struct bcm_sysport_mib {u32 alloc_rx_buff_failed;u32 rx_dma_failed;u32 tx_dma_failed; +u32 tx_realloc_tsb; +u32 tx_realloc_tsb_failed; };/* HW maintains a large list of counters */
Signature · 1 line
2.17.1
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Thu, 27 Sep 2018 15:36:09 -0700
Quoted 4 lines
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.
Series applied.