-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: lan966x: Add offload support for mqprio
Implement mqprio qdisc support using tc command. The HW supports 8 priority queues from highest (7) to lowest (0). Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Horatiu Vultur
authored and
David S. Miller
committed
Sep 23, 2022
1 parent
644ffce
commit 3c83431
Showing
5 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
|
||
#include "lan966x_main.h" | ||
|
||
int lan966x_mqprio_add(struct lan966x_port *port, u8 num_tc) | ||
{ | ||
u8 i; | ||
|
||
if (num_tc != NUM_PRIO_QUEUES) { | ||
netdev_err(port->dev, "Only %d tarffic classes supported\n", | ||
NUM_PRIO_QUEUES); | ||
return -EINVAL; | ||
} | ||
|
||
netdev_set_num_tc(port->dev, num_tc); | ||
|
||
for (i = 0; i < num_tc; ++i) | ||
netdev_set_tc_queue(port->dev, i, 1, i); | ||
|
||
return 0; | ||
} | ||
|
||
int lan966x_mqprio_del(struct lan966x_port *port) | ||
{ | ||
netdev_reset_tc(port->dev); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
|
||
#include <net/pkt_cls.h> | ||
|
||
#include "lan966x_main.h" | ||
|
||
static int lan966x_tc_setup_qdisc_mqprio(struct lan966x_port *port, | ||
struct tc_mqprio_qopt_offload *mqprio) | ||
{ | ||
u8 num_tc = mqprio->qopt.num_tc; | ||
|
||
mqprio->qopt.hw = TC_MQPRIO_HW_OFFLOAD_TCS; | ||
|
||
return num_tc ? lan966x_mqprio_add(port, num_tc) : | ||
lan966x_mqprio_del(port); | ||
} | ||
|
||
int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type, | ||
void *type_data) | ||
{ | ||
struct lan966x_port *port = netdev_priv(dev); | ||
|
||
switch (type) { | ||
case TC_SETUP_QDISC_MQPRIO: | ||
return lan966x_tc_setup_qdisc_mqprio(port, type_data); | ||
default: | ||
return -EOPNOTSUPP; | ||
} | ||
|
||
return 0; | ||
} |