netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/5] net: systemport: Turn on offloads by
@ 2018-09-27 22:36 Florian Fainelli
  2018-09-27 22:36 ` [PATCH net-next 1/5] net: systemport: Refactor bcm_sysport_set_features() Florian Fainelli
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-09-27 22:36 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

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(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next 1/5] net: systemport: Refactor bcm_sysport_set_features()
  2018-09-27 22:36 [PATCH net-next 0/5] net: systemport: Turn on offloads by Florian Fainelli
@ 2018-09-27 22:36 ` Florian Fainelli
  2018-09-27 22:36 ` [PATCH net-next 2/5] net: systemport: Utilize bcm_sysport_set_features() during resume/open Florian Fainelli
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-09-27 22:36 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

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.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 38 +++++++++-------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 147045757b10..654a07b849c4 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -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) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 2/5] net: systemport: Utilize bcm_sysport_set_features() during resume/open
  2018-09-27 22:36 [PATCH net-next 0/5] net: systemport: Turn on offloads by Florian Fainelli
  2018-09-27 22:36 ` [PATCH net-next 1/5] net: systemport: Refactor bcm_sysport_set_features() Florian Fainelli
@ 2018-09-27 22:36 ` Florian Fainelli
  2018-09-27 22:36 ` [PATCH net-next 3/5] net: systemport: Turn on offloads by default Florian Fainelli
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-09-27 22:36 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

During 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.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 654a07b849c4..3b4cb906a275 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -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);
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 3/5] net: systemport: Turn on offloads by default
  2018-09-27 22:36 [PATCH net-next 0/5] net: systemport: Turn on offloads by Florian Fainelli
  2018-09-27 22:36 ` [PATCH net-next 1/5] net: systemport: Refactor bcm_sysport_set_features() Florian Fainelli
  2018-09-27 22:36 ` [PATCH net-next 2/5] net: systemport: Utilize bcm_sysport_set_features() during resume/open Florian Fainelli
@ 2018-09-27 22:36 ` Florian Fainelli
  2018-09-27 22:36 ` [PATCH net-next 4/5] net: systemport: Be drop monitor friendly while re-allocating headroom Florian Fainelli
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-09-27 22:36 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

We 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.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 3b4cb906a275..977d9dec2fb0 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -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;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 4/5] net: systemport: Be drop monitor friendly while re-allocating headroom
  2018-09-27 22:36 [PATCH net-next 0/5] net: systemport: Turn on offloads by Florian Fainelli
                   ` (2 preceding siblings ...)
  2018-09-27 22:36 ` [PATCH net-next 3/5] net: systemport: Turn on offloads by default Florian Fainelli
@ 2018-09-27 22:36 ` Florian Fainelli
  2018-09-27 22:36 ` [PATCH net-next 5/5] net: systemport: Add software counters to track reallocations Florian Fainelli
  2018-10-02  6:12 ` [PATCH net-next 0/5] net: systemport: Turn on offloads by David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-09-27 22:36 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

During bcm_sysport_insert_tsb() make sure we differentiate a SKB
headroom re-allocation failure from the normal swap and replace path.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 977d9dec2fb0..6c40cf6090ab 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -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;
 	}
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next 5/5] net: systemport: Add software counters to track reallocations
  2018-09-27 22:36 [PATCH net-next 0/5] net: systemport: Turn on offloads by Florian Fainelli
                   ` (3 preceding siblings ...)
  2018-09-27 22:36 ` [PATCH net-next 4/5] net: systemport: Be drop monitor friendly while re-allocating headroom Florian Fainelli
@ 2018-09-27 22:36 ` Florian Fainelli
  2018-10-02  6:12 ` [PATCH net-next 0/5] net: systemport: Turn on offloads by David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-09-27 22:36 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

When 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.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 5 +++++
 drivers/net/ethernet/broadcom/bcmsysport.h | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 6c40cf6090ab..faba55fd656a 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -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));
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h
index 046c6c1d97fd..a7a230884a87 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.h
+++ b/drivers/net/ethernet/broadcom/bcmsysport.h
@@ -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 */
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next 0/5] net: systemport: Turn on offloads by
  2018-09-27 22:36 [PATCH net-next 0/5] net: systemport: Turn on offloads by Florian Fainelli
                   ` (4 preceding siblings ...)
  2018-09-27 22:36 ` [PATCH net-next 5/5] net: systemport: Add software counters to track reallocations Florian Fainelli
@ 2018-10-02  6:12 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2018-10-02  6:12 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Thu, 27 Sep 2018 15:36:09 -0700

> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-02 12:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-27 22:36 [PATCH net-next 0/5] net: systemport: Turn on offloads by Florian Fainelli
2018-09-27 22:36 ` [PATCH net-next 1/5] net: systemport: Refactor bcm_sysport_set_features() Florian Fainelli
2018-09-27 22:36 ` [PATCH net-next 2/5] net: systemport: Utilize bcm_sysport_set_features() during resume/open Florian Fainelli
2018-09-27 22:36 ` [PATCH net-next 3/5] net: systemport: Turn on offloads by default Florian Fainelli
2018-09-27 22:36 ` [PATCH net-next 4/5] net: systemport: Be drop monitor friendly while re-allocating headroom Florian Fainelli
2018-09-27 22:36 ` [PATCH net-next 5/5] net: systemport: Add software counters to track reallocations Florian Fainelli
2018-10-02  6:12 ` [PATCH net-next 0/5] net: systemport: Turn on offloads by David Miller

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).