Commit 30bbb983 authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-mq-red-offload'

Jiri Pirko says:

====================
mlxsw: Offload multi-queue RED support

Nogah says:

Support a two level hierarchy of offloaded qdiscs in mlxsw, with sch_prio
being the root qdisc and sch_red as the children.

                +----------+
                | sch_prio |
                +----+-----+
                     |
                     |
    +----------------------------------+
    |                |                 |
    |                |                 |
    |                |                 |
+---v---+       +----v---+       +-----v--+
|sch_red|       |sch_red |       |sch_red |
+-------+       +--------+       +--------+

When setting sch_prio as the root qdisc on a physical port, mlxsw will
offload it. When adding it with sch_red as a child qdisc, it will offload
it as well.
Relocating child qdisc or connecting them to more then one child will
result in unoffloading them. Relocating child qdisc more then once is
highly unrecommended and might cause a miss match between the kernel
configuration and the offloaded one. The offloaded configuration will be
aligned with the one shown in the show command.
Changing the priomap parameter of sch_prio might cause a band that its
configuration was changed and it has offloaded sch_red set on it, to lose
some stats data as if sch_red was unoffloaded and offloaded again. However,
it won't affect the data on this band that will have sch_red continuously.

Patch 1 adds support for setting RED as the child of root qdisc.
Patches 2-4 add support for RED bstasts for offloaded child qdiscs.
Patches 5-6 handle backlog related changes for offloaded child qdiscs.
Patches 7-8 update PRIO in mlxsw to be able to have RED as child on its
bands.
Patch 9 adds offload handles for PRIO graft operations. In mlxsw it will
cause the driver to stop offloading the child in question.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 56beda3d 32dc5efc
...@@ -1040,6 +1040,16 @@ mlxsw_sp_port_get_hw_xstats(struct net_device *dev, ...@@ -1040,6 +1040,16 @@ mlxsw_sp_port_get_hw_xstats(struct net_device *dev,
xstats->tail_drop[i] = xstats->tail_drop[i] =
mlxsw_reg_ppcnt_tc_no_buffer_discard_uc_get(ppcnt_pl); mlxsw_reg_ppcnt_tc_no_buffer_discard_uc_get(ppcnt_pl);
} }
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
err = mlxsw_sp_port_get_stats_raw(dev, MLXSW_REG_PPCNT_PRIO_CNT,
i, ppcnt_pl);
if (err)
continue;
xstats->tx_packets[i] = mlxsw_reg_ppcnt_tx_frames_get(ppcnt_pl);
xstats->tx_bytes[i] = mlxsw_reg_ppcnt_tx_octets_get(ppcnt_pl);
}
} }
static void update_stats_cache(struct work_struct *work) static void update_stats_cache(struct work_struct *work)
......
...@@ -210,6 +210,8 @@ struct mlxsw_sp_port_xstats { ...@@ -210,6 +210,8 @@ struct mlxsw_sp_port_xstats {
u64 wred_drop[TC_MAX_QUEUE]; u64 wred_drop[TC_MAX_QUEUE];
u64 tail_drop[TC_MAX_QUEUE]; u64 tail_drop[TC_MAX_QUEUE];
u64 backlog[TC_MAX_QUEUE]; u64 backlog[TC_MAX_QUEUE];
u64 tx_bytes[IEEE_8021QAZ_MAX_TCS];
u64 tx_packets[IEEE_8021QAZ_MAX_TCS];
}; };
struct mlxsw_sp_port { struct mlxsw_sp_port {
...@@ -247,6 +249,7 @@ struct mlxsw_sp_port { ...@@ -247,6 +249,7 @@ struct mlxsw_sp_port {
struct mlxsw_sp_port_sample *sample; struct mlxsw_sp_port_sample *sample;
struct list_head vlans_list; struct list_head vlans_list;
struct mlxsw_sp_qdisc *root_qdisc; struct mlxsw_sp_qdisc *root_qdisc;
struct mlxsw_sp_qdisc *tclass_qdiscs;
unsigned acl_rule_count; unsigned acl_rule_count;
struct mlxsw_sp_acl_block *ing_acl_block; struct mlxsw_sp_acl_block *ing_acl_block;
struct mlxsw_sp_acl_block *eg_acl_block; struct mlxsw_sp_acl_block *eg_acl_block;
......
...@@ -806,6 +806,7 @@ enum tc_prio_command { ...@@ -806,6 +806,7 @@ enum tc_prio_command {
TC_PRIO_REPLACE, TC_PRIO_REPLACE,
TC_PRIO_DESTROY, TC_PRIO_DESTROY,
TC_PRIO_STATS, TC_PRIO_STATS,
TC_PRIO_GRAFT,
}; };
struct tc_prio_qopt_offload_params { struct tc_prio_qopt_offload_params {
...@@ -818,6 +819,11 @@ struct tc_prio_qopt_offload_params { ...@@ -818,6 +819,11 @@ struct tc_prio_qopt_offload_params {
struct gnet_stats_queue *qstats; struct gnet_stats_queue *qstats;
}; };
struct tc_prio_qopt_offload_graft_params {
u8 band;
u32 child_handle;
};
struct tc_prio_qopt_offload { struct tc_prio_qopt_offload {
enum tc_prio_command command; enum tc_prio_command command;
u32 handle; u32 handle;
...@@ -825,6 +831,8 @@ struct tc_prio_qopt_offload { ...@@ -825,6 +831,8 @@ struct tc_prio_qopt_offload {
union { union {
struct tc_prio_qopt_offload_params replace_params; struct tc_prio_qopt_offload_params replace_params;
struct tc_qopt_offload_stats stats; struct tc_qopt_offload_stats stats;
struct tc_prio_qopt_offload_graft_params graft_params;
}; };
}; };
#endif #endif
...@@ -739,6 +739,7 @@ static u32 qdisc_alloc_handle(struct net_device *dev) ...@@ -739,6 +739,7 @@ static u32 qdisc_alloc_handle(struct net_device *dev)
void qdisc_tree_reduce_backlog(struct Qdisc *sch, unsigned int n, void qdisc_tree_reduce_backlog(struct Qdisc *sch, unsigned int n,
unsigned int len) unsigned int len)
{ {
bool qdisc_is_offloaded = sch->flags & TCQ_F_OFFLOADED;
const struct Qdisc_class_ops *cops; const struct Qdisc_class_ops *cops;
unsigned long cl; unsigned long cl;
u32 parentid; u32 parentid;
...@@ -760,8 +761,12 @@ void qdisc_tree_reduce_backlog(struct Qdisc *sch, unsigned int n, ...@@ -760,8 +761,12 @@ void qdisc_tree_reduce_backlog(struct Qdisc *sch, unsigned int n,
* If child was empty even before update then backlog * If child was empty even before update then backlog
* counter is screwed and we skip notification because * counter is screwed and we skip notification because
* parent class is already passive. * parent class is already passive.
*
* If the original child was offloaded then it is allowed
* to be seem as empty, so the parent is notified anyway.
*/ */
notify = !sch->q.qlen && !WARN_ON_ONCE(!n); notify = !sch->q.qlen && !WARN_ON_ONCE(!n &&
!qdisc_is_offloaded);
/* TODO: perform the search on a per txq basis */ /* TODO: perform the search on a per txq basis */
sch = qdisc_lookup(qdisc_dev(sch), TC_H_MAJ(parentid)); sch = qdisc_lookup(qdisc_dev(sch), TC_H_MAJ(parentid));
if (sch == NULL) { if (sch == NULL) {
......
...@@ -142,9 +142,8 @@ prio_reset(struct Qdisc *sch) ...@@ -142,9 +142,8 @@ prio_reset(struct Qdisc *sch)
sch->q.qlen = 0; sch->q.qlen = 0;
} }
static int prio_offload(struct Qdisc *sch, bool enable) static int prio_offload(struct Qdisc *sch, struct tc_prio_qopt *qopt)
{ {
struct prio_sched_data *q = qdisc_priv(sch);
struct net_device *dev = qdisc_dev(sch); struct net_device *dev = qdisc_dev(sch);
struct tc_prio_qopt_offload opt = { struct tc_prio_qopt_offload opt = {
.handle = sch->handle, .handle = sch->handle,
...@@ -154,10 +153,10 @@ static int prio_offload(struct Qdisc *sch, bool enable) ...@@ -154,10 +153,10 @@ static int prio_offload(struct Qdisc *sch, bool enable)
if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc) if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (enable) { if (qopt) {
opt.command = TC_PRIO_REPLACE; opt.command = TC_PRIO_REPLACE;
opt.replace_params.bands = q->bands; opt.replace_params.bands = qopt->bands;
memcpy(&opt.replace_params.priomap, q->prio2band, memcpy(&opt.replace_params.priomap, qopt->priomap,
TC_PRIO_MAX + 1); TC_PRIO_MAX + 1);
opt.replace_params.qstats = &sch->qstats; opt.replace_params.qstats = &sch->qstats;
} else { } else {
...@@ -174,7 +173,7 @@ prio_destroy(struct Qdisc *sch) ...@@ -174,7 +173,7 @@ prio_destroy(struct Qdisc *sch)
struct prio_sched_data *q = qdisc_priv(sch); struct prio_sched_data *q = qdisc_priv(sch);
tcf_block_put(q->block); tcf_block_put(q->block);
prio_offload(sch, false); prio_offload(sch, NULL);
for (prio = 0; prio < q->bands; prio++) for (prio = 0; prio < q->bands; prio++)
qdisc_destroy(q->queues[prio]); qdisc_destroy(q->queues[prio]);
} }
...@@ -211,6 +210,7 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt, ...@@ -211,6 +210,7 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt,
} }
} }
prio_offload(sch, qopt);
sch_tree_lock(sch); sch_tree_lock(sch);
q->bands = qopt->bands; q->bands = qopt->bands;
memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1); memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1);
...@@ -230,7 +230,6 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt, ...@@ -230,7 +230,6 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt,
} }
sch_tree_unlock(sch); sch_tree_unlock(sch);
prio_offload(sch, true);
return 0; return 0;
} }
...@@ -309,12 +308,44 @@ static int prio_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, ...@@ -309,12 +308,44 @@ static int prio_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
struct Qdisc **old, struct netlink_ext_ack *extack) struct Qdisc **old, struct netlink_ext_ack *extack)
{ {
struct prio_sched_data *q = qdisc_priv(sch); struct prio_sched_data *q = qdisc_priv(sch);
struct tc_prio_qopt_offload graft_offload;
struct net_device *dev = qdisc_dev(sch);
unsigned long band = arg - 1; unsigned long band = arg - 1;
bool any_qdisc_is_offloaded;
int err;
if (new == NULL) if (new == NULL)
new = &noop_qdisc; new = &noop_qdisc;
*old = qdisc_replace(sch, new, &q->queues[band]); *old = qdisc_replace(sch, new, &q->queues[band]);
if (!tc_can_offload(dev))
return 0;
graft_offload.handle = sch->handle;
graft_offload.parent = sch->parent;
graft_offload.graft_params.band = band;
graft_offload.graft_params.child_handle = new->handle;
graft_offload.command = TC_PRIO_GRAFT;
err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_PRIO,
&graft_offload);
/* Don't report error if the graft is part of destroy operation. */
if (err && new != &noop_qdisc) {
/* Don't report error if the parent, the old child and the new
* one are not offloaded.
*/
any_qdisc_is_offloaded = sch->flags & TCQ_F_OFFLOADED;
any_qdisc_is_offloaded |= new->flags & TCQ_F_OFFLOADED;
if (*old)
any_qdisc_is_offloaded |= (*old)->flags &
TCQ_F_OFFLOADED;
if (any_qdisc_is_offloaded)
NL_SET_ERR_MSG(extack, "Offloading graft operation failed.");
}
return 0; return 0;
} }
......
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