linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <stefanc@marvell.com>
To: <netdev@vger.kernel.org>
Cc: <thomas.petazzoni@bootlin.com>, <davem@davemloft.net>,
	<nadavh@marvell.com>, <ymarkman@marvell.com>,
	<linux-kernel@vger.kernel.org>, <stefanc@marvell.com>,
	<kuba@kernel.org>, <linux@armlinux.org.uk>, <mw@semihalf.com>,
	<andrew@lunn.ch>, <rmk+kernel@armlinux.org.uk>,
	<atenart@kernel.org>
Subject: [PATCH v2 RFC net-next 09/18] net: mvpp2: add FCA RXQ non occupied descriptor threshold
Date: Sun, 24 Jan 2021 13:43:58 +0200	[thread overview]
Message-ID: <1611488647-12478-10-git-send-email-stefanc@marvell.com> (raw)
In-Reply-To: <1611488647-12478-1-git-send-email-stefanc@marvell.com>

From: Stefan Chulski <stefanc@marvell.com>

RXQ non occupied descriptor threshold would be used by
Flow Control Firmware feature to move to the XOFF mode.
RXQ non occupied threshold would change interrupt cause
that polled by CM3 Firmware.
Actual non occupied interrupt masked and won't trigger interrupt.

Signed-off-by: Stefan Chulski <stefanc@marvell.com>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      |  3 ++
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 29 ++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h
index 0861c0b..3df8f60 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h
@@ -295,6 +295,8 @@
 #define     MVPP2_PON_CAUSE_TXP_OCCUP_DESC_ALL_MASK	0x3fc00000
 #define     MVPP2_PON_CAUSE_MISC_SUM_MASK		BIT(31)
 #define MVPP2_ISR_MISC_CAUSE_REG		0x55b0
+#define MVPP2_ISR_RX_ERR_CAUSE_REG(port)	(0x5520 + 4 * (port))
+#define	    MVPP2_ISR_RX_ERR_CAUSE_NONOCC_MASK	0x00ff
 
 /* Buffer Manager registers */
 #define MVPP2_BM_POOL_BASE_REG(pool)		(0x6000 + ((pool) * 4))
@@ -764,6 +766,7 @@
 #define MSS_SRAM_SIZE		0x800
 #define FC_QUANTA		0xFFFF
 #define FC_CLK_DIVIDER		0x140
+#define MSS_THRESHOLD_STOP    768
 
 /* RX buffer constants */
 #define MVPP2_SKB_SHINFO_SIZE \
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 9d69752..0f5069f 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -1154,6 +1154,9 @@ static void mvpp2_interrupts_mask(void *arg)
 	mvpp2_thread_write(port->priv,
 			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
 			   MVPP2_ISR_RX_TX_MASK_REG(port->id), 0);
+	mvpp2_thread_write(port->priv,
+			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
+			   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id), 0);
 }
 
 /* Unmask the current thread's Rx/Tx interrupts.
@@ -1177,6 +1180,10 @@ static void mvpp2_interrupts_unmask(void *arg)
 	mvpp2_thread_write(port->priv,
 			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
 			   MVPP2_ISR_RX_TX_MASK_REG(port->id), val);
+	mvpp2_thread_write(port->priv,
+			   mvpp2_cpu_to_thread(port->priv, smp_processor_id()),
+			   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id),
+			   MVPP2_ISR_RX_ERR_CAUSE_NONOCC_MASK);
 }
 
 static void
@@ -1201,6 +1208,9 @@ static void mvpp2_interrupts_unmask(void *arg)
 
 		mvpp2_thread_write(port->priv, v->sw_thread_id,
 				   MVPP2_ISR_RX_TX_MASK_REG(port->id), val);
+		mvpp2_thread_write(port->priv, v->sw_thread_id,
+				   MVPP2_ISR_RX_ERR_CAUSE_REG(port->id),
+				   MVPP2_ISR_RX_ERR_CAUSE_NONOCC_MASK);
 	}
 }
 
@@ -2406,6 +2416,22 @@ static void mvpp2_txp_max_tx_size_set(struct mvpp2_port *port)
 	}
 }
 
+/* Routine set the number of non-occupied descriptors threshold that change
+ * interrupt error cause polled by FW Flow Control
+ */
+static void mvpp2_set_rxq_free_tresh(struct mvpp2_port *port,
+				     struct mvpp2_rx_queue *rxq)
+{
+	u32 val;
+
+	mvpp2_write(port->priv, MVPP2_RXQ_NUM_REG, rxq->id);
+
+	val = mvpp2_read(port->priv, MVPP2_RXQ_THRESH_REG);
+	val &= ~MVPP2_RXQ_NON_OCCUPIED_MASK;
+	val |= MSS_THRESHOLD_STOP << MVPP2_RXQ_NON_OCCUPIED_OFFSET;
+	mvpp2_write(port->priv, MVPP2_RXQ_THRESH_REG, val);
+}
+
 /* Set the number of packets that will be received before Rx interrupt
  * will be generated by HW.
  */
@@ -2661,6 +2687,9 @@ static int mvpp2_rxq_init(struct mvpp2_port *port,
 	mvpp2_rx_pkts_coal_set(port, rxq);
 	mvpp2_rx_time_coal_set(port, rxq);
 
+	/* Set the number of non occupied descriptors threshold */
+	mvpp2_set_rxq_free_tresh(port, rxq);
+
 	/* Add number of descriptors ready for receiving packets */
 	mvpp2_rxq_status_update(port, rxq->id, 0, rxq->size);
 
-- 
1.9.1


  parent reply	other threads:[~2021-01-24 11:49 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-24 11:43 [PATCH v2 RFC net-next 00/18] net: mvpp2: Add TX Flow Control support stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 01/18] doc: marvell: add cm3-mem device tree bindings description stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 02/18] dts: marvell: add CM3 SRAM memory to cp115 ethernet device tree stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 03/18] net: mvpp2: add CM3 SRAM memory map stefanc
2021-01-24 12:28   ` Russell King - ARM Linux admin
2021-01-24 12:44   ` Russell King - ARM Linux admin
2021-01-24 18:51     ` Andrew Lunn
2021-01-24 18:46   ` Andrew Lunn
2021-01-25  7:16     ` [EXT] " Stefan Chulski
2021-01-24 11:43 ` [PATCH v2 RFC net-next 04/18] net: mvpp2: add PPv23 version definition stefanc
2021-01-24 13:18   ` Russell King - ARM Linux admin
2021-01-24 13:55     ` [EXT] " Stefan Chulski
2021-01-24 19:03       ` Andrew Lunn
2021-01-25  7:12         ` Stefan Chulski
2021-01-24 11:43 ` [PATCH v2 RFC net-next 05/18] net: mvpp2: always compare hw-version vs MVPP21 stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 06/18] net: mvpp2: increase BM pool size to 2048 buffers stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 07/18] net: mvpp2: increase RXQ size to 1024 descriptors stefanc
2021-01-24 11:43 ` [PATCH v2 RFC net-next 08/18] net: mvpp2: add FCA periodic timer configurations stefanc
2021-01-24 12:14   ` Russell King - ARM Linux admin
2021-01-24 14:43     ` [EXT] " Stefan Chulski
2021-01-24 19:11       ` Andrew Lunn
2021-01-25  7:15         ` Stefan Chulski
2021-01-24 11:43 ` stefanc [this message]
2021-01-24 13:01   ` [PATCH v2 RFC net-next 09/18] net: mvpp2: add FCA RXQ non occupied descriptor threshold Russell King - ARM Linux admin
2021-01-24 13:24     ` [EXT] " Stefan Chulski
2021-01-24 11:43 ` [PATCH v2 RFC net-next 10/18] net: mvpp2: add spinlock for FW FCA configuration path stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 11/18] net: mvpp2: enable global flow control stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 12/18] net: mvpp2: add RXQ flow control configurations stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 13/18] net: mvpp2: add ethtool flow control configuration support stefanc
2021-01-24 12:35   ` Russell King - ARM Linux admin
2021-01-24 12:39     ` [EXT] " Stefan Chulski
2021-01-24 11:44 ` [PATCH v2 RFC net-next 14/18] net: mvpp2: add BM protection underrun feature support stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 15/18] net: mvpp2: add PPv23 RX FIFO flow control stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 16/18] net: mvpp2: set 802.3x GoP Flow Control mode stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 17/18] net: mvpp2: limit minimum ring size to 1024 descriptors stefanc
2021-01-24 11:44 ` [PATCH v2 RFC net-next 18/18] net: mvpp2: add TX FC firmware check stefanc

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=1611488647-12478-10-git-send-email-stefanc@marvell.com \
    --to=stefanc@marvell.com \
    --cc=andrew@lunn.ch \
    --cc=atenart@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mw@semihalf.com \
    --cc=nadavh@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=ymarkman@marvell.com \
    /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).