Commit efe31799 authored by Saeed Mahameed's avatar Saeed Mahameed

net/mlx5e: HTB, reduce visibility of htb functions

No need to expose all htb tc functions to the main driver file,
expose only the master htb tc function mlx5e_htb_setup_tc()
which selects the internal "now static" function to call.
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Signed-off-by: default avatarMoshe Tal <moshet@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Reviewed-by: default avatarMaxim Mikityanskiy <maximmi@nvidia.com>
parent 0bb7228f
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */ /* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */
#include <net/sch_generic.h> #include <net/sch_generic.h>
#include <net/pkt_cls.h>
#include "en.h" #include "en.h"
#include "params.h" #include "params.h"
#include "../qos.h" #include "../qos.h"
...@@ -482,10 +483,11 @@ static void mlx5e_qos_deactivate_all_queues(struct mlx5e_channels *chs) ...@@ -482,10 +483,11 @@ static void mlx5e_qos_deactivate_all_queues(struct mlx5e_channels *chs)
mlx5e_qos_deactivate_queues(chs->c[i]); mlx5e_qos_deactivate_queues(chs->c[i]);
} }
/* HTB API */ /* HTB TC handlers */
int mlx5e_htb_root_add(struct mlx5e_priv *priv, u16 htb_maj_id, u16 htb_defcls, static int
struct netlink_ext_ack *extack) mlx5e_htb_root_add(struct mlx5e_priv *priv, u16 htb_maj_id, u16 htb_defcls,
struct netlink_ext_ack *extack)
{ {
struct mlx5e_qos_node *root; struct mlx5e_qos_node *root;
bool opened; bool opened;
...@@ -542,7 +544,7 @@ int mlx5e_htb_root_add(struct mlx5e_priv *priv, u16 htb_maj_id, u16 htb_defcls, ...@@ -542,7 +544,7 @@ int mlx5e_htb_root_add(struct mlx5e_priv *priv, u16 htb_maj_id, u16 htb_defcls,
return err; return err;
} }
int mlx5e_htb_root_del(struct mlx5e_priv *priv) static int mlx5e_htb_root_del(struct mlx5e_priv *priv)
{ {
struct mlx5e_qos_node *root; struct mlx5e_qos_node *root;
int err; int err;
...@@ -607,9 +609,10 @@ static void mlx5e_htb_convert_ceil(struct mlx5e_priv *priv, u64 ceil, u32 *max_a ...@@ -607,9 +609,10 @@ static void mlx5e_htb_convert_ceil(struct mlx5e_priv *priv, u64 ceil, u32 *max_a
ceil, *max_average_bw); ceil, *max_average_bw);
} }
int mlx5e_htb_leaf_alloc_queue(struct mlx5e_priv *priv, u16 classid, static int
u32 parent_classid, u64 rate, u64 ceil, mlx5e_htb_leaf_alloc_queue(struct mlx5e_priv *priv, u16 classid,
struct netlink_ext_ack *extack) u32 parent_classid, u64 rate, u64 ceil,
struct netlink_ext_ack *extack)
{ {
struct mlx5e_qos_node *node, *parent; struct mlx5e_qos_node *node, *parent;
int qid; int qid;
...@@ -661,8 +664,9 @@ int mlx5e_htb_leaf_alloc_queue(struct mlx5e_priv *priv, u16 classid, ...@@ -661,8 +664,9 @@ int mlx5e_htb_leaf_alloc_queue(struct mlx5e_priv *priv, u16 classid,
return mlx5e_qid_from_qos(&priv->channels, node->qid); return mlx5e_qid_from_qos(&priv->channels, node->qid);
} }
int mlx5e_htb_leaf_to_inner(struct mlx5e_priv *priv, u16 classid, u16 child_classid, static int
u64 rate, u64 ceil, struct netlink_ext_ack *extack) mlx5e_htb_leaf_to_inner(struct mlx5e_priv *priv, u16 classid, u16 child_classid,
u64 rate, u64 ceil, struct netlink_ext_ack *extack)
{ {
struct mlx5e_qos_node *node, *child; struct mlx5e_qos_node *node, *child;
int err, tmp_err; int err, tmp_err;
...@@ -781,8 +785,8 @@ static void mlx5e_reset_qdisc(struct net_device *dev, u16 qid) ...@@ -781,8 +785,8 @@ static void mlx5e_reset_qdisc(struct net_device *dev, u16 qid)
spin_unlock_bh(qdisc_lock(qdisc)); spin_unlock_bh(qdisc_lock(qdisc));
} }
int mlx5e_htb_leaf_del(struct mlx5e_priv *priv, u16 *classid, static int mlx5e_htb_leaf_del(struct mlx5e_priv *priv, u16 *classid,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct mlx5e_qos_node *node; struct mlx5e_qos_node *node;
struct netdev_queue *txq; struct netdev_queue *txq;
...@@ -876,8 +880,9 @@ int mlx5e_htb_leaf_del(struct mlx5e_priv *priv, u16 *classid, ...@@ -876,8 +880,9 @@ int mlx5e_htb_leaf_del(struct mlx5e_priv *priv, u16 *classid,
return 0; return 0;
} }
int mlx5e_htb_leaf_del_last(struct mlx5e_priv *priv, u16 classid, bool force, static int
struct netlink_ext_ack *extack) mlx5e_htb_leaf_del_last(struct mlx5e_priv *priv, u16 classid, bool force,
struct netlink_ext_ack *extack)
{ {
struct mlx5e_qos_node *node, *parent; struct mlx5e_qos_node *node, *parent;
u32 old_hw_id, new_hw_id; u32 old_hw_id, new_hw_id;
...@@ -956,8 +961,9 @@ int mlx5e_htb_leaf_del_last(struct mlx5e_priv *priv, u16 classid, bool force, ...@@ -956,8 +961,9 @@ int mlx5e_htb_leaf_del_last(struct mlx5e_priv *priv, u16 classid, bool force,
return 0; return 0;
} }
static int mlx5e_qos_update_children(struct mlx5e_priv *priv, struct mlx5e_qos_node *node, static int
struct netlink_ext_ack *extack) mlx5e_qos_update_children(struct mlx5e_priv *priv, struct mlx5e_qos_node *node,
struct netlink_ext_ack *extack)
{ {
struct mlx5e_qos_node *child; struct mlx5e_qos_node *child;
int err = 0; int err = 0;
...@@ -988,8 +994,9 @@ static int mlx5e_qos_update_children(struct mlx5e_priv *priv, struct mlx5e_qos_n ...@@ -988,8 +994,9 @@ static int mlx5e_qos_update_children(struct mlx5e_priv *priv, struct mlx5e_qos_n
return err; return err;
} }
int mlx5e_htb_node_modify(struct mlx5e_priv *priv, u16 classid, u64 rate, u64 ceil, static int
struct netlink_ext_ack *extack) mlx5e_htb_node_modify(struct mlx5e_priv *priv, u16 classid, u64 rate, u64 ceil,
struct netlink_ext_ack *extack)
{ {
u32 bw_share, max_average_bw; u32 bw_share, max_average_bw;
struct mlx5e_qos_node *node; struct mlx5e_qos_node *node;
...@@ -1028,6 +1035,48 @@ int mlx5e_htb_node_modify(struct mlx5e_priv *priv, u16 classid, u64 rate, u64 ce ...@@ -1028,6 +1035,48 @@ int mlx5e_htb_node_modify(struct mlx5e_priv *priv, u16 classid, u64 rate, u64 ce
return err; return err;
} }
/* HTB API */
int mlx5e_htb_setup_tc(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb)
{
int res;
switch (htb->command) {
case TC_HTB_CREATE:
return mlx5e_htb_root_add(priv, htb->parent_classid, htb->classid,
htb->extack);
case TC_HTB_DESTROY:
return mlx5e_htb_root_del(priv);
case TC_HTB_LEAF_ALLOC_QUEUE:
res = mlx5e_htb_leaf_alloc_queue(priv, htb->classid, htb->parent_classid,
htb->rate, htb->ceil, htb->extack);
if (res < 0)
return res;
htb->qid = res;
return 0;
case TC_HTB_LEAF_TO_INNER:
return mlx5e_htb_leaf_to_inner(priv, htb->parent_classid, htb->classid,
htb->rate, htb->ceil, htb->extack);
case TC_HTB_LEAF_DEL:
return mlx5e_htb_leaf_del(priv, &htb->classid, htb->extack);
case TC_HTB_LEAF_DEL_LAST:
case TC_HTB_LEAF_DEL_LAST_FORCE:
return mlx5e_htb_leaf_del_last(priv, htb->classid,
htb->command == TC_HTB_LEAF_DEL_LAST_FORCE,
htb->extack);
case TC_HTB_NODE_MODIFY:
return mlx5e_htb_node_modify(priv, htb->classid, htb->rate, htb->ceil,
htb->extack);
case TC_HTB_LEAF_QUERY_QUEUE:
res = mlx5e_get_txq_by_classid(priv, htb->classid);
if (res < 0)
return res;
htb->qid = res;
return 0;
default:
return -EOPNOTSUPP;
}
}
struct mlx5e_mqprio_rl { struct mlx5e_mqprio_rl {
struct mlx5_core_dev *mdev; struct mlx5_core_dev *mdev;
u32 root_id; u32 root_id;
...@@ -1111,3 +1160,4 @@ int mlx5e_mqprio_rl_get_node_hw_id(struct mlx5e_mqprio_rl *rl, int tc, u32 *hw_i ...@@ -1111,3 +1160,4 @@ int mlx5e_mqprio_rl_get_node_hw_id(struct mlx5e_mqprio_rl *rl, int tc, u32 *hw_i
*hw_id = rl->leaves_id[tc]; *hw_id = rl->leaves_id[tc];
return 0; return 0;
} }
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
struct mlx5e_priv; struct mlx5e_priv;
struct mlx5e_channels; struct mlx5e_channels;
struct mlx5e_channel; struct mlx5e_channel;
struct tc_htb_qopt_offload;
int mlx5e_qos_bytes_rate_check(struct mlx5_core_dev *mdev, u64 nbytes); int mlx5e_qos_bytes_rate_check(struct mlx5_core_dev *mdev, u64 nbytes);
int mlx5e_qos_max_leaf_nodes(struct mlx5_core_dev *mdev); int mlx5e_qos_max_leaf_nodes(struct mlx5_core_dev *mdev);
...@@ -26,20 +27,7 @@ void mlx5e_qos_deactivate_queues(struct mlx5e_channel *c); ...@@ -26,20 +27,7 @@ void mlx5e_qos_deactivate_queues(struct mlx5e_channel *c);
void mlx5e_qos_close_queues(struct mlx5e_channel *c); void mlx5e_qos_close_queues(struct mlx5e_channel *c);
/* HTB API */ /* HTB API */
int mlx5e_htb_root_add(struct mlx5e_priv *priv, u16 htb_maj_id, u16 htb_defcls, int mlx5e_htb_setup_tc(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb);
struct netlink_ext_ack *extack);
int mlx5e_htb_root_del(struct mlx5e_priv *priv);
int mlx5e_htb_leaf_alloc_queue(struct mlx5e_priv *priv, u16 classid,
u32 parent_classid, u64 rate, u64 ceil,
struct netlink_ext_ack *extack);
int mlx5e_htb_leaf_to_inner(struct mlx5e_priv *priv, u16 classid, u16 child_classid,
u64 rate, u64 ceil, struct netlink_ext_ack *extack);
int mlx5e_htb_leaf_del(struct mlx5e_priv *priv, u16 *classid,
struct netlink_ext_ack *extack);
int mlx5e_htb_leaf_del_last(struct mlx5e_priv *priv, u16 classid, bool force,
struct netlink_ext_ack *extack);
int mlx5e_htb_node_modify(struct mlx5e_priv *priv, u16 classid, u64 rate, u64 ceil,
struct netlink_ext_ack *extack);
/* MQPRIO TX rate limit */ /* MQPRIO TX rate limit */
struct mlx5e_mqprio_rl; struct mlx5e_mqprio_rl;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
*/ */
#include <net/tc_act/tc_gact.h> #include <net/tc_act/tc_gact.h>
#include <net/pkt_cls.h>
#include <linux/mlx5/fs.h> #include <linux/mlx5/fs.h>
#include <net/vxlan.h> #include <net/vxlan.h>
#include <net/geneve.h> #include <net/geneve.h>
...@@ -3420,47 +3419,6 @@ static int mlx5e_setup_tc_mqprio(struct mlx5e_priv *priv, ...@@ -3420,47 +3419,6 @@ static int mlx5e_setup_tc_mqprio(struct mlx5e_priv *priv,
} }
} }
static int mlx5e_setup_tc_htb(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb)
{
int res;
switch (htb->command) {
case TC_HTB_CREATE:
return mlx5e_htb_root_add(priv, htb->parent_classid, htb->classid,
htb->extack);
case TC_HTB_DESTROY:
return mlx5e_htb_root_del(priv);
case TC_HTB_LEAF_ALLOC_QUEUE:
res = mlx5e_htb_leaf_alloc_queue(priv, htb->classid, htb->parent_classid,
htb->rate, htb->ceil, htb->extack);
if (res < 0)
return res;
htb->qid = res;
return 0;
case TC_HTB_LEAF_TO_INNER:
return mlx5e_htb_leaf_to_inner(priv, htb->parent_classid, htb->classid,
htb->rate, htb->ceil, htb->extack);
case TC_HTB_LEAF_DEL:
return mlx5e_htb_leaf_del(priv, &htb->classid, htb->extack);
case TC_HTB_LEAF_DEL_LAST:
case TC_HTB_LEAF_DEL_LAST_FORCE:
return mlx5e_htb_leaf_del_last(priv, htb->classid,
htb->command == TC_HTB_LEAF_DEL_LAST_FORCE,
htb->extack);
case TC_HTB_NODE_MODIFY:
return mlx5e_htb_node_modify(priv, htb->classid, htb->rate, htb->ceil,
htb->extack);
case TC_HTB_LEAF_QUERY_QUEUE:
res = mlx5e_get_txq_by_classid(priv, htb->classid);
if (res < 0)
return res;
htb->qid = res;
return 0;
default:
return -EOPNOTSUPP;
}
}
static LIST_HEAD(mlx5e_block_cb_list); static LIST_HEAD(mlx5e_block_cb_list);
static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
...@@ -3494,7 +3452,7 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, ...@@ -3494,7 +3452,7 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
return err; return err;
case TC_SETUP_QDISC_HTB: case TC_SETUP_QDISC_HTB:
mutex_lock(&priv->state_lock); mutex_lock(&priv->state_lock);
err = mlx5e_setup_tc_htb(priv, type_data); err = mlx5e_htb_setup_tc(priv, type_data);
mutex_unlock(&priv->state_lock); mutex_unlock(&priv->state_lock);
return err; return err;
default: default:
......
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