netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next 2/4] net: bcmgenet: add support for ethtool tx-frames
Date: Mon, 21 Apr 2014 08:45:22 -0700	[thread overview]
Message-ID: <1398095124-5411-3-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1398095124-5411-1-git-send-email-f.fainelli@gmail.com>

Configuring the ethtool tx-frames property, which translates into N
packets before a TX interrupt is the simplest configuration scheme
because it requires no locking neither at the softare nor hardware
level, and is completely indepedent from the link speed. Since ethtool
does not allow per-tx queue coalescing parameters, we apply the same
setting to any transmit queue.

We can no longer enable the BDONE/PDONE interrupts as those would fire
for each packet/buffer received, which would defeat the MBDONE interrupt
purpose. The MBDONE interrupt is guaranteed to correspond to a
PDONE/BDONE interrupt when the threshold is set to 1.

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

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index b093a48c427f..f1b3969de10b 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -78,11 +78,10 @@
 #define GENET_RDMA_REG_OFF	(priv->hw_params->rdma_offset + \
 				TOTAL_DESC * DMA_DESC_SIZE)
 
-/* Tx/Rx DMA done masks: packet, buffer and multiple buffer done */
-#define UMAC_TXDMA_DONE_MASK	(UMAC_IRQ_TXDMA_BDONE | \
-				 UMAC_IRQ_TXDMA_PDONE | \
-				 UMAC_IRQ_TXDMA_MBDONE)
+/* TX DMA done mask: multiple buffer done */
+#define UMAC_TXDMA_DONE_MASK	(UMAC_IRQ_TXDMA_MBDONE)
 
+/* Rx DMA done masks: packet, buffer and multiple buffer done */
 #define UMAC_RXDMA_DONE_MASK	(UMAC_IRQ_RXDMA_BDONE | \
 				 UMAC_IRQ_RXDMA_PDONE | \
 				 UMAC_IRQ_RXDMA_MBDONE)
@@ -495,6 +494,38 @@ static void bcmgenet_set_msglevel(struct net_device *dev, u32 level)
 	priv->msg_enable = level;
 }
 
+static int bcmgenet_get_coalesce(struct net_device *dev,
+				 struct ethtool_coalesce *ec)
+{
+	struct bcmgenet_priv *priv = netdev_priv(dev);
+
+	ec->tx_max_coalesced_frames = bcmgenet_tdma_ring_readl(priv,
+			DESC_INDEX, DMA_MBUF_DONE_THRESH);
+
+	return 0;
+}
+
+static int bcmgenet_set_coalesce(struct net_device *dev,
+				 struct ethtool_coalesce *ec)
+{
+	struct bcmgenet_priv *priv = netdev_priv(dev);
+	unsigned int i;
+
+	if (ec->tx_max_coalesced_frames > 255)
+		return -EINVAL;
+
+	/* Program all TX queues with the same values, as there is no
+	 * ethtool knob to do coalescing on a per-queue basis
+	 */
+	for (i = 0; i < priv->hw_params->tx_queues; i++)
+		bcmgenet_tdma_ring_writel(priv, i,
+			ec->tx_max_coalesced_frames, DMA_MBUF_DONE_THRESH);
+	bcmgenet_tdma_ring_writel(priv, DESC_INDEX,
+			ec->tx_max_coalesced_frames, DMA_MBUF_DONE_THRESH);
+
+	return 0;
+}
+
 /* standard ethtool support functions. */
 enum bcmgenet_stat_type {
 	BCMGENET_STAT_NETDEV = -1,
@@ -739,6 +770,8 @@ static struct ethtool_ops bcmgenet_ethtool_ops = {
 	.get_link		= ethtool_op_get_link,
 	.get_msglevel		= bcmgenet_get_msglevel,
 	.set_msglevel		= bcmgenet_set_msglevel,
+	.get_coalesce		= bcmgenet_get_coalesce,
+	.set_coalesce		= bcmgenet_set_coalesce,
 };
 
 /* Power down the unimac, based on mode. */
@@ -856,7 +889,7 @@ static inline void bcmgenet_tx_ring16_int_disable(struct bcmgenet_priv *priv,
 static inline void bcmgenet_tx_ring16_int_enable(struct bcmgenet_priv *priv,
 						 struct bcmgenet_tx_ring *ring)
 {
-	bcmgenet_intrl2_0_writel(priv, UMAC_TXDMA_DONE_MASK
+	bcmgenet_intrl2_0_writel(priv, UMAC_TXDMA_DONE_MASK,
 			INTRL2_CPU_MASK_CLEAR);
 }
 
-- 
1.9.1

  parent reply	other threads:[~2014-04-21 15:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-21 15:45 [PATCH net-next 0/4] net: bcmgenet: interrupt coalescing support Florian Fainelli
2014-04-21 15:45 ` [PATCH net-next 1/4] net: bcmgenet: prepare for MBDONE interrupts support Florian Fainelli
2014-04-21 15:45 ` Florian Fainelli [this message]
2014-04-21 19:17   ` [PATCH net-next 2/4] net: bcmgenet: add support for ethtool tx-frames David Miller
2014-04-21 19:55     ` Florian Fainelli
2014-04-21 19:59       ` David Miller
2014-04-21 15:45 ` [PATCH net-next 3/4] net: bcmgenet: add support for ethtool rx-frames Florian Fainelli
2014-04-21 15:45 ` [PATCH net-next 4/4] net: bcmgenet: do not set RX buffer length Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1398095124-5411-3-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).