提交 c9f14470 编写于 作者: V Vlad Buslov 提交者: David S. Miller

net: sched: add API for registering unlocked offload block callbacks

Extend struct flow_block_offload with "unlocked_driver_cb" flag to allow
registering and unregistering block hardware offload callbacks that do not
require caller to hold rtnl lock. Extend tcf_block with additional
lockeddevcnt counter that is incremented for each non-unlocked driver
callback attached to device. This counter is necessary to conditionally
obtain rtnl lock before calling hardware callbacks in following patches.

Register mlx5 tc block offload callbacks as "unlocked".
Signed-off-by: NVlad Buslov <vladbu@mellanox.com>
Acked-by: NJiri Pirko <jiri@mellanox.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a449a3e7
...@@ -3470,10 +3470,12 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, ...@@ -3470,10 +3470,12 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
void *type_data) void *type_data)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct flow_block_offload *f = type_data;
switch (type) { switch (type) {
#ifdef CONFIG_MLX5_ESWITCH #ifdef CONFIG_MLX5_ESWITCH
case TC_SETUP_BLOCK: case TC_SETUP_BLOCK:
f->unlocked_driver_cb = true;
return flow_block_cb_setup_simple(type_data, return flow_block_cb_setup_simple(type_data,
&mlx5e_block_cb_list, &mlx5e_block_cb_list,
mlx5e_setup_tc_block_cb, mlx5e_setup_tc_block_cb,
......
...@@ -763,6 +763,7 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev, ...@@ -763,6 +763,7 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,
if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
return -EOPNOTSUPP; return -EOPNOTSUPP;
f->unlocked_driver_cb = true;
f->driver_block_list = &mlx5e_block_cb_list; f->driver_block_list = &mlx5e_block_cb_list;
switch (f->command) { switch (f->command) {
...@@ -1245,9 +1246,11 @@ static int mlx5e_rep_setup_tc(struct net_device *dev, enum tc_setup_type type, ...@@ -1245,9 +1246,11 @@ static int mlx5e_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
void *type_data) void *type_data)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct flow_block_offload *f = type_data;
switch (type) { switch (type) {
case TC_SETUP_BLOCK: case TC_SETUP_BLOCK:
f->unlocked_driver_cb = true;
return flow_block_cb_setup_simple(type_data, return flow_block_cb_setup_simple(type_data,
&mlx5e_rep_block_cb_list, &mlx5e_rep_block_cb_list,
mlx5e_rep_setup_tc_cb, mlx5e_rep_setup_tc_cb,
......
...@@ -284,6 +284,7 @@ struct flow_block_offload { ...@@ -284,6 +284,7 @@ struct flow_block_offload {
enum flow_block_command command; enum flow_block_command command;
enum flow_block_binder_type binder_type; enum flow_block_binder_type binder_type;
bool block_shared; bool block_shared;
bool unlocked_driver_cb;
struct net *net; struct net *net;
struct flow_block *block; struct flow_block *block;
struct list_head cb_list; struct list_head cb_list;
......
...@@ -408,6 +408,7 @@ struct tcf_block { ...@@ -408,6 +408,7 @@ struct tcf_block {
bool keep_dst; bool keep_dst;
atomic_t offloadcnt; /* Number of oddloaded filters */ atomic_t offloadcnt; /* Number of oddloaded filters */
unsigned int nooffloaddevcnt; /* Number of devs unable to do offload */ unsigned int nooffloaddevcnt; /* Number of devs unable to do offload */
unsigned int lockeddevcnt; /* Number of devs that require rtnl lock. */
struct { struct {
struct tcf_chain *chain; struct tcf_chain *chain;
struct list_head filter_chain_list; struct list_head filter_chain_list;
......
...@@ -1418,6 +1418,8 @@ static int tcf_block_bind(struct tcf_block *block, ...@@ -1418,6 +1418,8 @@ static int tcf_block_bind(struct tcf_block *block,
bo->extack); bo->extack);
if (err) if (err)
goto err_unroll; goto err_unroll;
if (!bo->unlocked_driver_cb)
block->lockeddevcnt++;
i++; i++;
} }
...@@ -1433,6 +1435,8 @@ static int tcf_block_bind(struct tcf_block *block, ...@@ -1433,6 +1435,8 @@ static int tcf_block_bind(struct tcf_block *block,
block_cb->cb_priv, false, block_cb->cb_priv, false,
tcf_block_offload_in_use(block), tcf_block_offload_in_use(block),
NULL); NULL);
if (!bo->unlocked_driver_cb)
block->lockeddevcnt--;
} }
flow_block_cb_free(block_cb); flow_block_cb_free(block_cb);
} }
...@@ -1454,6 +1458,8 @@ static void tcf_block_unbind(struct tcf_block *block, ...@@ -1454,6 +1458,8 @@ static void tcf_block_unbind(struct tcf_block *block,
NULL); NULL);
list_del(&block_cb->list); list_del(&block_cb->list);
flow_block_cb_free(block_cb); flow_block_cb_free(block_cb);
if (!bo->unlocked_driver_cb)
block->lockeddevcnt--;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册