Commit c92342b0 authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-qdisc-refactoring'

Jiri Pirko says:

====================
mlxsw qdisc refactoring

This patchset refactors the qdisc handling in mlxsw driver in order to make
it more object oriented like.
It helps readability, laying the groundwork for the offloading of
additional qdiscs by the driver
This patchset also makes the qdiscs statistics more generic.

Patch 1 moves the qdiscs declaration to the spectrum_qdisc.c
Patches 2-3 clean the offloaded stats requests. Patch 2 changes the RED
generic stats struct to be sharable by other offloaded qdiscs. Patch 3
changes the xstats request to be like the stats. Note that these patches
are outside the driver scope.
Patches 4-5 clean the statistics related functions and structs within the
driver.
Patches 6-7 decrease the need for the same parameters to be sent to many
functions.
Patches 8-11 create a functions pointers struct, to make the qdiscs
handling more object oriented like.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents d016e13d 56202ca4
...@@ -3085,6 +3085,13 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -3085,6 +3085,13 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
goto err_port_fids_init; goto err_port_fids_init;
} }
err = mlxsw_sp_tc_qdisc_init(mlxsw_sp_port);
if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize TC qdiscs\n",
mlxsw_sp_port->local_port);
goto err_port_qdiscs_init;
}
mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_get(mlxsw_sp_port, 1); mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_get(mlxsw_sp_port, 1);
if (IS_ERR(mlxsw_sp_port_vlan)) { if (IS_ERR(mlxsw_sp_port_vlan)) {
dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to create VID 1\n", dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to create VID 1\n",
...@@ -3113,6 +3120,8 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -3113,6 +3120,8 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
mlxsw_sp_port_switchdev_fini(mlxsw_sp_port); mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
mlxsw_sp_port_vlan_put(mlxsw_sp_port_vlan); mlxsw_sp_port_vlan_put(mlxsw_sp_port_vlan);
err_port_vlan_get: err_port_vlan_get:
mlxsw_sp_tc_qdisc_fini(mlxsw_sp_port);
err_port_qdiscs_init:
mlxsw_sp_port_fids_fini(mlxsw_sp_port); mlxsw_sp_port_fids_fini(mlxsw_sp_port);
err_port_fids_init: err_port_fids_init:
mlxsw_sp_port_dcb_fini(mlxsw_sp_port); mlxsw_sp_port_dcb_fini(mlxsw_sp_port);
...@@ -3148,6 +3157,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) ...@@ -3148,6 +3157,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
mlxsw_sp->ports[local_port] = NULL; mlxsw_sp->ports[local_port] = NULL;
mlxsw_sp_port_switchdev_fini(mlxsw_sp_port); mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
mlxsw_sp_port_vlan_flush(mlxsw_sp_port); mlxsw_sp_port_vlan_flush(mlxsw_sp_port);
mlxsw_sp_tc_qdisc_fini(mlxsw_sp_port);
mlxsw_sp_port_fids_fini(mlxsw_sp_port); mlxsw_sp_port_fids_fini(mlxsw_sp_port);
mlxsw_sp_port_dcb_fini(mlxsw_sp_port); mlxsw_sp_port_dcb_fini(mlxsw_sp_port);
mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT); mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT);
......
...@@ -204,29 +204,6 @@ struct mlxsw_sp_port_vlan { ...@@ -204,29 +204,6 @@ struct mlxsw_sp_port_vlan {
struct list_head bridge_vlan_node; struct list_head bridge_vlan_node;
}; };
enum mlxsw_sp_qdisc_type {
MLXSW_SP_QDISC_NO_QDISC,
MLXSW_SP_QDISC_RED,
};
struct mlxsw_sp_qdisc {
u32 handle;
enum mlxsw_sp_qdisc_type type;
struct red_stats xstats_base;
union {
struct {
u64 tail_drop_base;
u64 ecn_base;
u64 wred_drop_base;
} red;
} xstats;
u64 tx_bytes;
u64 tx_packets;
u64 drops;
u64 overlimits;
};
/* No need an internal lock; At worse - miss a single periodic iteration */ /* No need an internal lock; At worse - miss a single periodic iteration */
struct mlxsw_sp_port_xstats { struct mlxsw_sp_port_xstats {
u64 ecn; u64 ecn;
...@@ -269,7 +246,7 @@ struct mlxsw_sp_port { ...@@ -269,7 +246,7 @@ struct mlxsw_sp_port {
} periodic_hw_stats; } periodic_hw_stats;
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;
unsigned acl_rule_count; unsigned acl_rule_count;
}; };
...@@ -584,6 +561,8 @@ int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, ...@@ -584,6 +561,8 @@ int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
struct tc_cls_flower_offload *f); struct tc_cls_flower_offload *f);
/* spectrum_qdisc.c */ /* spectrum_qdisc.c */
int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port);
void mlxsw_sp_tc_qdisc_fini(struct mlxsw_sp_port *mlxsw_sp_port);
int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port, int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
struct tc_red_qopt_offload *p); struct tc_red_qopt_offload *p);
......
...@@ -731,6 +731,11 @@ struct tc_cookie { ...@@ -731,6 +731,11 @@ struct tc_cookie {
u32 len; u32 len;
}; };
struct tc_qopt_offload_stats {
struct gnet_stats_basic_packed *bstats;
struct gnet_stats_queue *qstats;
};
enum tc_red_command { enum tc_red_command {
TC_RED_REPLACE, TC_RED_REPLACE,
TC_RED_DESTROY, TC_RED_DESTROY,
...@@ -744,10 +749,6 @@ struct tc_red_qopt_offload_params { ...@@ -744,10 +749,6 @@ struct tc_red_qopt_offload_params {
u32 probability; u32 probability;
bool is_ecn; bool is_ecn;
}; };
struct tc_red_qopt_offload_stats {
struct gnet_stats_basic_packed *bstats;
struct gnet_stats_queue *qstats;
};
struct tc_red_qopt_offload { struct tc_red_qopt_offload {
enum tc_red_command command; enum tc_red_command command;
...@@ -755,7 +756,7 @@ struct tc_red_qopt_offload { ...@@ -755,7 +756,7 @@ struct tc_red_qopt_offload {
u32 parent; u32 parent;
union { union {
struct tc_red_qopt_offload_params set; struct tc_red_qopt_offload_params set;
struct tc_red_qopt_offload_stats stats; struct tc_qopt_offload_stats stats;
struct red_stats *xstats; struct red_stats *xstats;
}; };
}; };
......
...@@ -344,32 +344,24 @@ static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d) ...@@ -344,32 +344,24 @@ static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
{ {
struct red_sched_data *q = qdisc_priv(sch); struct red_sched_data *q = qdisc_priv(sch);
struct net_device *dev = qdisc_dev(sch); struct net_device *dev = qdisc_dev(sch);
struct tc_red_xstats st = { struct tc_red_xstats st = {0};
.early = q->stats.prob_drop + q->stats.forced_drop,
.pdrop = q->stats.pdrop,
.other = q->stats.other,
.marked = q->stats.prob_mark + q->stats.forced_mark,
};
if (sch->flags & TCQ_F_OFFLOADED) { if (sch->flags & TCQ_F_OFFLOADED) {
struct red_stats hw_stats = {0};
struct tc_red_qopt_offload hw_stats_request = { struct tc_red_qopt_offload hw_stats_request = {
.command = TC_RED_XSTATS, .command = TC_RED_XSTATS,
.handle = sch->handle, .handle = sch->handle,
.parent = sch->parent, .parent = sch->parent,
{ {
.xstats = &hw_stats, .xstats = &q->stats,
}, },
}; };
if (!dev->netdev_ops->ndo_setup_tc(dev, dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_RED,
TC_SETUP_QDISC_RED, &hw_stats_request);
&hw_stats_request)) {
st.early += hw_stats.prob_drop + hw_stats.forced_drop;
st.pdrop += hw_stats.pdrop;
st.other += hw_stats.other;
st.marked += hw_stats.prob_mark + hw_stats.forced_mark;
}
} }
st.early = q->stats.prob_drop + q->stats.forced_drop;
st.pdrop = q->stats.pdrop;
st.other = q->stats.other;
st.marked = q->stats.prob_mark + q->stats.forced_mark;
return gnet_stats_copy_app(d, &st, sizeof(st)); return gnet_stats_copy_app(d, &st, sizeof(st));
} }
......
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