All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] enetc: Use generic rule to map Tx rings to interrupt vectors
@ 2021-04-09  7:16 Claudiu Manoil
  2021-04-09 10:19 ` Vladimir Oltean
  0 siblings, 1 reply; 3+ messages in thread
From: Claudiu Manoil @ 2021-04-09  7:16 UTC (permalink / raw)
  To: netdev; +Cc: Jakub Kicinski, David S . Miller, Vladimir Oltean

Even if the current mapping is correct for the 1 CPU and 2 CPU cases
(currently enetc is included in SoCs with up to 2 CPUs only), better
use a generic rule for the mapping to cover all possible cases.
The number of CPUs is the same as the number of interrupt vectors:

Per device Tx rings -
device_tx_ring[idx], where idx = 0..n_rings_total-1

Per interrupt vector Tx rings -
int_vector[i].ring[j], where i = 0..n_int_vects-1
			     j = 0..n_rings_per_v-1

Mapping rule -
n_rings_per_v = n_rings_total / n_int_vects
for i = 0..n_int_vects - 1:
	for j = 0..n_rings_per_v - 1:
		idx = n_int_vects * j + i
		int_vector[i].ring[j] <- device_tx_ring[idx]

Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
---
 drivers/net/ethernet/freescale/enetc/enetc.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 57049ae97201..1646aaa68bd1 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -2343,11 +2343,7 @@ int enetc_alloc_msix(struct enetc_ndev_priv *priv)
 			int idx;
 
 			/* default tx ring mapping policy */
-			if (priv->bdr_int_num == ENETC_MAX_BDR_INT)
-				idx = 2 * j + i; /* 2 CPUs */
-			else
-				idx = j + i * v_tx_rings; /* default */
-
+			idx = priv->bdr_int_num * j + i;
 			__set_bit(idx, &v->tx_rings_map);
 			bdr = &v->tx_ring[j];
 			bdr->index = idx;
-- 
2.25.1


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

* Re: [PATCH net-next] enetc: Use generic rule to map Tx rings to interrupt vectors
  2021-04-09  7:16 [PATCH net-next] enetc: Use generic rule to map Tx rings to interrupt vectors Claudiu Manoil
@ 2021-04-09 10:19 ` Vladimir Oltean
  2021-04-10  1:23   ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Oltean @ 2021-04-09 10:19 UTC (permalink / raw)
  To: Claudiu Manoil; +Cc: netdev, Jakub Kicinski, David S . Miller, Vladimir Oltean

On Fri, Apr 09, 2021 at 10:16:13AM +0300, Claudiu Manoil wrote:
> Even if the current mapping is correct for the 1 CPU and 2 CPU cases
> (currently enetc is included in SoCs with up to 2 CPUs only), better
> use a generic rule for the mapping to cover all possible cases.
> The number of CPUs is the same as the number of interrupt vectors:
> 
> Per device Tx rings -
> device_tx_ring[idx], where idx = 0..n_rings_total-1
> 
> Per interrupt vector Tx rings -
> int_vector[i].ring[j], where i = 0..n_int_vects-1
> 			     j = 0..n_rings_per_v-1
> 
> Mapping rule -
> n_rings_per_v = n_rings_total / n_int_vects
> for i = 0..n_int_vects - 1:
> 	for j = 0..n_rings_per_v - 1:
> 		idx = n_int_vects * j + i
> 		int_vector[i].ring[j] <- device_tx_ring[idx]
> 
> Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
> ---

Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>

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

* Re: [PATCH net-next] enetc: Use generic rule to map Tx rings to interrupt vectors
  2021-04-09 10:19 ` Vladimir Oltean
@ 2021-04-10  1:23   ` Jakub Kicinski
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2021-04-10  1:23 UTC (permalink / raw)
  To: Vladimir Oltean, Claudiu Manoil; +Cc: netdev, David S . Miller, Vladimir Oltean

On Fri, 9 Apr 2021 13:19:52 +0300 Vladimir Oltean wrote:
> On Fri, Apr 09, 2021 at 10:16:13AM +0300, Claudiu Manoil wrote:
> > Even if the current mapping is correct for the 1 CPU and 2 CPU cases
> > (currently enetc is included in SoCs with up to 2 CPUs only), better
> > use a generic rule for the mapping to cover all possible cases.
> > The number of CPUs is the same as the number of interrupt vectors:
> > 
> > Per device Tx rings -
> > device_tx_ring[idx], where idx = 0..n_rings_total-1
> > 
> > Per interrupt vector Tx rings -
> > int_vector[i].ring[j], where i = 0..n_int_vects-1
> > 			     j = 0..n_rings_per_v-1
> > 
> > Mapping rule -
> > n_rings_per_v = n_rings_total / n_int_vects
> > for i = 0..n_int_vects - 1:
> > 	for j = 0..n_rings_per_v - 1:
> > 		idx = n_int_vects * j + i
> > 		int_vector[i].ring[j] <- device_tx_ring[idx]
> > 
> > Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
> 
> Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Applied, thanks!

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

end of thread, other threads:[~2021-04-10  1:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09  7:16 [PATCH net-next] enetc: Use generic rule to map Tx rings to interrupt vectors Claudiu Manoil
2021-04-09 10:19 ` Vladimir Oltean
2021-04-10  1:23   ` Jakub Kicinski

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.