All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 24/45] net: mvpp2: adapt rxq distribution to PPv2.2
Date: Thu, 23 Mar 2017 17:01:50 +0100	[thread overview]
Message-ID: <20170323160211.18072-25-sr@denx.de> (raw)
In-Reply-To: <20170323160211.18072-1-sr@denx.de>

From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

In PPv2.1, we have a maximum of 8 RXQs per port, with a default of 4
RXQs per port, and we were assigning RXQs 0->3 to the first port, 4->7
to the second port, 8->11 to the third port, etc.

In PPv2.2, we have a maximum of 32 RXQs per port, and we must allocate
RXQs from the range of 32 RXQs available for each port. So port 0 must
use RXQs in the range 0->31, port 1 in the range 32->63, etc.

This commit adapts the mvpp2 to this difference between PPv2.1 and
PPv2.2:

- The constant definition MVPP2_MAX_RXQ is replaced by a new field
  'max_port_rxqs' in 'struct mvpp2', which stores the maximum number of
  RXQs per port. This field is initialized during ->probe() depending
  on the IP version.

- MVPP2_RXQ_TOTAL_NUM is removed, and instead we calculate the total
  number of RXQs by multiplying the number of ports by the maximum of
  RXQs per port. This was anyway used in only one place.

- In mvpp2_port_probe(), the calculation of port->first_rxq is adjusted
  to cope with the different allocation strategy between PPv2.1 and
  PPv2.2. Due to this change, the 'next_first_rxq' argument of this
  function is no longer needed and is removed.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Stefan Roese <sr@denx.de>
---

Changes in v2: None

 drivers/net/mvpp2.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 16a9c75cf0..c683fff53f 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -454,9 +454,6 @@ do {									\
 /* Maximum number of TXQs used by single port */
 #define MVPP2_MAX_TXQ			8
 
-/* Maximum number of RXQs used by single port */
-#define MVPP2_MAX_RXQ			8
-
 /* Default number of TXQs in use */
 #define MVPP2_DEFAULT_TXQ		1
 
@@ -464,9 +461,6 @@ do {									\
 #define MVPP2_DEFAULT_RXQ		1
 #define CONFIG_MV_ETH_RXQ		8	/* increment by 8 */
 
-/* Total number of RXQs available to all ports */
-#define MVPP2_RXQ_TOTAL_NUM		(MVPP2_MAX_PORTS * MVPP2_MAX_RXQ)
-
 /* Max number of Rx descriptors */
 #define MVPP2_MAX_RXD			16
 
@@ -772,6 +766,9 @@ struct mvpp2 {
 	/* HW version */
 	enum { MVPP21, MVPP22 } hw_version;
 
+	/* Maximum number of RXQs per port */
+	unsigned int max_port_rxqs;
+
 	struct mii_dev *bus;
 };
 
@@ -3700,7 +3697,8 @@ static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port)
 	struct mvpp2_txq_pcpu *txq_pcpu;
 	int queue, cpu, err;
 
-	if (port->first_rxq + rxq_number > MVPP2_RXQ_TOTAL_NUM)
+	if (port->first_rxq + rxq_number >
+	    MVPP2_MAX_PORTS * priv->max_port_rxqs)
 		return -EINVAL;
 
 	/* Disable port */
@@ -3808,8 +3806,7 @@ static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port)
 static int mvpp2_port_probe(struct udevice *dev,
 			    struct mvpp2_port *port,
 			    int port_node,
-			    struct mvpp2 *priv,
-			    int *next_first_rxq)
+			    struct mvpp2 *priv)
 {
 	int phy_node;
 	u32 id;
@@ -3843,7 +3840,10 @@ static int mvpp2_port_probe(struct udevice *dev,
 
 	port->priv = priv;
 	port->id = id;
-	port->first_rxq = *next_first_rxq;
+	if (priv->hw_version == MVPP21)
+		port->first_rxq = port->id * rxq_number;
+	else
+		port->first_rxq = port->id * priv->max_port_rxqs;
 	port->phy_node = phy_node;
 	port->phy_interface = phy_mode;
 	port->phyaddr = phyaddr;
@@ -3877,8 +3877,6 @@ static int mvpp2_port_probe(struct udevice *dev,
 	}
 	mvpp2_port_power_up(port);
 
-	/* Increment the first Rx queue number to be used by the next port */
-	*next_first_rxq += CONFIG_MV_ETH_RXQ;
 	priv->port_list[id] = port;
 	return 0;
 }
@@ -3995,7 +3993,8 @@ static int mvpp2_init(struct udevice *dev, struct mvpp2 *priv)
 	u32 val;
 
 	/* Checks for hardware constraints (U-Boot uses only one rxq) */
-	if ((rxq_number > MVPP2_MAX_RXQ) || (txq_number > MVPP2_MAX_TXQ)) {
+	if ((rxq_number > priv->max_port_rxqs) ||
+	    (txq_number > MVPP2_MAX_TXQ)) {
 		dev_err(&pdev->dev, "invalid queue size parameter\n");
 		return -EINVAL;
 	}
@@ -4388,8 +4387,7 @@ static int mvpp2_probe(struct udevice *dev)
 		return err;
 	}
 
-	return mvpp2_port_probe(dev, port, dev_of_offset(dev), priv,
-				&buffer_loc.first_rxq);
+	return mvpp2_port_probe(dev, port, dev_of_offset(dev), priv);
 }
 
 static const struct eth_ops mvpp2_ops = {
@@ -4477,6 +4475,11 @@ static int mvpp2_base_probe(struct udevice *dev)
 			return PTR_ERR(priv->iface_base);
 	}
 
+	if (priv->hw_version == MVPP21)
+		priv->max_port_rxqs = 8;
+	else
+		priv->max_port_rxqs = 32;
+
 	/* Finally create and register the MDIO bus driver */
 	bus = mdio_alloc();
 	if (!bus) {
-- 
2.12.1

  parent reply	other threads:[~2017-03-23 16:01 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-23 16:01 [U-Boot] [PATCH v2 00/45] Add PPv2.2 support to the mvpp2 ethernet driver and enable it for A7k/8k Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 01/45] bitops.h: Include bitsperlong.h as needed for GENMASK_ULL Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 02/45] net: mvpp2: Round up top tx buffer boundaries for dcache ops Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 03/45] net: mvpp2: simplify mvpp2_bm_bufs_add() Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 04/45] net: mvpp2: remove unused register definitions Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 05/45] net: mvpp2: fix indentation of MVPP2_EXT_GLOBAL_CTRL_DEFAULT Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 06/45] net: mvpp2: simplify MVPP2_PRS_RI_* definitions Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 07/45] net: mvpp2: enable building on 64-bit platforms Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 08/45] net: mvpp2: enable building on 64-bit platforms (more U-Boot specific) Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 09/45] net: mvpp2: use "dma" instead of "phys" where appropriate Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 10/45] net: mvpp2: remove support for buffer header Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 11/45] net: mvpp2: store physical address of buffer in rx_desc->buf_cookie Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 12/45] net: mvpp2: add and use accessors for TX/RX descriptors Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 13/45] net: mvpp2: add hw_version field in "struct mvpp2" Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 14/45] net: mvpp2: introduce an intermediate union for the TX/RX descriptors Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 15/45] net: mvpp2: introduce PPv2.2 HW descriptors and adapt accessors Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 16/45] net: mvpp2: adjust the allocation/free of BM pools for PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 17/45] net: mvpp2: adapt the mvpp2_rxq_*_pool_set functions to PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 18/45] net: mvpp2: adapt mvpp2_defaults_set() " Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 19/45] net: mvpp2: adjust mvpp2_{rxq, txq}_init for PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 20/45] net: mvpp2: handle register mapping and access " Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 21/45] net: mvpp2: handle misc PPv2.1/PPv2.2 differences Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 22/45] net: mvpp2: add AXI bridge initialization for PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 23/45] net: mvpp2: rework RXQ interrupt group " Stefan Roese
2017-03-23 16:01 ` Stefan Roese [this message]
2017-03-25 21:24   ` [U-Boot] [PATCH v2 24/45] net: mvpp2: adapt rxq distribution to PPv2.2 Joe Hershberger
2017-03-23 16:01 ` [U-Boot] [PATCH v2 25/45] net: mvpp2: finally add the PPv2.2 compatible string Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 26/45] net: mvpp2: Add MDIO support for PPv2.2 Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 27/45] net: mvpp2: Move probe function from MISC to ETH DM driver Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 28/45] net: mvpp2.c: Clear all buffer / descriptor areas before usage Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 29/45] net: mvpp2: Enable compilation for Armada 7K/8K platforms Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 30/45] arm64: marvell: dts: add PPv2.2 description to Armada 7K/8K Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 31/45] arm64: mvebu: armada-7k/8k: Enable MVPP2 ethernet driver Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 32/45] net: mvpp2: Handle eth device naming in multi-CP case correctly Stefan Roese
2017-03-23 16:01 ` [U-Boot] [PATCH v2 33/45] net: mvpp2: Add remove function that is called before the OS is started Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 34/45] net: mvpp2: Add RX and TX FIFO configuration for PPv2.2 Stefan Roese
2017-03-25 20:32   ` Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 35/45] net: include/phy.h: Add new PHY interface modes Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 36/45] net: mvpp2: Restructure probe / init functions Stefan Roese
2017-03-25 21:30   ` Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 37/45] net: mvpp2: Read phy-speed from DT to select between 1GB and 2.5GB SGMII Stefan Roese
2017-03-25 21:31   ` Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 38/45] net: mvpp2: Add GoP and NetC support for ports 2 & 3 (RGMII & SGMII) Stefan Roese
2017-03-25 20:05   ` Joe Hershberger
2017-03-27 11:17     ` Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 39/45] net: mvpp2: Add GoP and NetC support for port 0 (SFI) Stefan Roese
2017-03-25 20:16   ` Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 40/45] net: mvpp2: Add missing PHY_INTERFACE_MODE_RGMII_ID Stefan Roese
2017-03-25 21:34   ` Joe Hershberger
2017-03-23 16:02 ` [U-Boot] [PATCH v2 41/45] net: mvpp2: Enable PHY polling mode on PPv2.2 Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 42/45] net: mvpp2: Configure SMI PHY address needed for PHY polling Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 43/45] net: mvpp2: Remove unreferenced in_use_thresh from struct mvpp2_bm_pool Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 44/45] arm64: mvebu: armada-7040-db.dts: Change eth1 speed from 2.5G to 1G Stefan Roese
2017-03-23 16:02 ` [U-Boot] [PATCH v2 45/45] arm64: mvebu: Enable CONFIG_PHY_MARVELL in Armada7k/8k-DB defconfig Stefan Roese
2017-03-25 21:42 ` [U-Boot] [PATCH v2 00/45] Add PPv2.2 support to the mvpp2 ethernet driver and enable it for A7k/8k Joe Hershberger
2017-03-27 12:02   ` Stefan Roese
2017-03-29  9:24 ` Stefan Roese

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=20170323160211.18072-25-sr@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.