Commit 3f136849 authored by Antoine Tenart's avatar Antoine Tenart Committed by David S. Miller

net: mvpp2: fix the computation of the RXQs

The patch fixes the computation of RXQs being used by the PPv2 driver,
which is set depending on the PPv2 engine version and the queue mode
used. There are three cases:

- PPv2.1: 1 RXQ per CPU.
- PPV2.2 with MVPP2_QDIST_MULTI_MODE: 1 RXQ per CPU.
- PPv2.2 with MVPP2_QDIST_SINGLE_MODE: 1 RXQ is shared between the CPUs.

The PPv2 engine supports a maximum of 32 queues per port. This patch
adds a check so that we do not overstep this maximum.

It appeared the calculation was broken for PPv2.1 engines since
f8c6ba84, as PPv2.1 ports ended up with a single RXQ while they
needed 4. This patch fixes it.

Fixes: f8c6ba84 ("net: mvpp2: use only one rx queue per port per CPU")
Signed-off-by: default avatarAntoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8b318f30
...@@ -549,8 +549,8 @@ ...@@ -549,8 +549,8 @@
#define MVPP2_MAX_TSO_SEGS 300 #define MVPP2_MAX_TSO_SEGS 300
#define MVPP2_MAX_SKB_DESCS (MVPP2_MAX_TSO_SEGS * 2 + MAX_SKB_FRAGS) #define MVPP2_MAX_SKB_DESCS (MVPP2_MAX_TSO_SEGS * 2 + MAX_SKB_FRAGS)
/* Default number of RXQs in use */ /* Max number of RXQs per port */
#define MVPP2_DEFAULT_RXQ 1 #define MVPP2_PORT_MAX_RXQ 32
/* Max number of Rx descriptors */ /* Max number of Rx descriptors */
#define MVPP2_MAX_RXD_MAX 1024 #define MVPP2_MAX_RXD_MAX 1024
......
...@@ -4061,8 +4061,8 @@ static int mvpp2_multi_queue_vectors_init(struct mvpp2_port *port, ...@@ -4061,8 +4061,8 @@ static int mvpp2_multi_queue_vectors_init(struct mvpp2_port *port,
snprintf(irqname, sizeof(irqname), "hif%d", i); snprintf(irqname, sizeof(irqname), "hif%d", i);
if (queue_mode == MVPP2_QDIST_MULTI_MODE) { if (queue_mode == MVPP2_QDIST_MULTI_MODE) {
v->first_rxq = i * MVPP2_DEFAULT_RXQ; v->first_rxq = i;
v->nrxqs = MVPP2_DEFAULT_RXQ; v->nrxqs = 1;
} else if (queue_mode == MVPP2_QDIST_SINGLE_MODE && } else if (queue_mode == MVPP2_QDIST_SINGLE_MODE &&
i == (port->nqvecs - 1)) { i == (port->nqvecs - 1)) {
v->first_rxq = 0; v->first_rxq = 0;
...@@ -4155,8 +4155,7 @@ static int mvpp2_port_init(struct mvpp2_port *port) ...@@ -4155,8 +4155,7 @@ static int mvpp2_port_init(struct mvpp2_port *port)
MVPP2_MAX_PORTS * priv->max_port_rxqs) MVPP2_MAX_PORTS * priv->max_port_rxqs)
return -EINVAL; return -EINVAL;
if (port->nrxqs % MVPP2_DEFAULT_RXQ || if (port->nrxqs > priv->max_port_rxqs || port->ntxqs > MVPP2_MAX_TXQ)
port->nrxqs > priv->max_port_rxqs || port->ntxqs > MVPP2_MAX_TXQ)
return -EINVAL; return -EINVAL;
/* Disable port */ /* Disable port */
...@@ -4777,10 +4776,18 @@ static int mvpp2_port_probe(struct platform_device *pdev, ...@@ -4777,10 +4776,18 @@ static int mvpp2_port_probe(struct platform_device *pdev,
} }
ntxqs = MVPP2_MAX_TXQ; ntxqs = MVPP2_MAX_TXQ;
if (priv->hw_version == MVPP22 && queue_mode == MVPP2_QDIST_MULTI_MODE) if (priv->hw_version == MVPP22 && queue_mode == MVPP2_QDIST_SINGLE_MODE) {
nrxqs = MVPP2_DEFAULT_RXQ * num_possible_cpus(); nrxqs = 1;
else } else {
nrxqs = MVPP2_DEFAULT_RXQ; /* According to the PPv2.2 datasheet and our experiments on
* PPv2.1, RX queues have an allocation granularity of 4 (when
* more than a single one on PPv2.2).
* Round up to nearest multiple of 4.
*/
nrxqs = (num_possible_cpus() + 3) & ~0x3;
if (nrxqs > MVPP2_PORT_MAX_RXQ)
nrxqs = MVPP2_PORT_MAX_RXQ;
}
dev = alloc_etherdev_mqs(sizeof(*port), ntxqs, nrxqs); dev = alloc_etherdev_mqs(sizeof(*port), ntxqs, nrxqs);
if (!dev) if (!dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment