Skip to content

Commit 2ea08f8

Browse files
camelia-groza-NXPmadalinbucur
authored andcommitted
dpaa_eth: enable multiple Tx traffic classes
Implement the setup_tc ndo to configure prioritised Tx traffic classes. Priorities range from 0 (lowest) to 3 (highest). The driver assigns NR_CPUS queues to each traffic class. Signed-off-by: Camelia Groza <camelia.groza@nxp.com> Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
1 parent c44efa1 commit 2ea08f8

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

drivers/net/ethernet/freescale/dpaa/dpaa_eth.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,41 @@ static void dpaa_get_stats64(struct net_device *net_dev,
342342
}
343343
}
344344

345+
static int dpaa_setup_tc(struct net_device *net_dev, u32 handle, __be16 proto,
346+
struct tc_to_netdev *tc)
347+
{
348+
struct dpaa_priv *priv = netdev_priv(net_dev);
349+
int i;
350+
351+
if (tc->type != TC_SETUP_MQPRIO)
352+
return -EINVAL;
353+
354+
if (tc->tc == priv->num_tc)
355+
return 0;
356+
357+
if (!tc->tc) {
358+
netdev_reset_tc(net_dev);
359+
goto out;
360+
}
361+
362+
if (tc->tc > DPAA_TC_NUM) {
363+
netdev_err(net_dev, "Too many traffic classes: max %d supported.\n",
364+
DPAA_TC_NUM);
365+
return -EINVAL;
366+
}
367+
368+
netdev_set_num_tc(net_dev, tc->tc);
369+
370+
for (i = 0; i < tc->tc; i++)
371+
netdev_set_tc_queue(net_dev, i, DPAA_TC_TXQ_NUM,
372+
i * DPAA_TC_TXQ_NUM);
373+
374+
out:
375+
priv->num_tc = tc->tc ? tc->tc : 1;
376+
netif_set_real_num_tx_queues(net_dev, priv->num_tc * DPAA_TC_TXQ_NUM);
377+
return 0;
378+
}
379+
345380
static struct mac_device *dpaa_mac_dev_get(struct platform_device *pdev)
346381
{
347382
struct platform_device *of_dev;
@@ -2417,6 +2452,7 @@ static const struct net_device_ops dpaa_ops = {
24172452
.ndo_validate_addr = eth_validate_addr,
24182453
.ndo_set_rx_mode = dpaa_set_rx_mode,
24192454
.ndo_do_ioctl = dpaa_ioctl,
2455+
.ndo_setup_tc = dpaa_setup_tc,
24202456
};
24212457

24222458
static int dpaa_napi_add(struct net_device *net_dev)

0 commit comments

Comments
 (0)