forked from Minki/linux
drivers: net: use flow block API
This patch updates flow_block_cb_setup_simple() to use the flow block API. Several drivers are also adjusted to use it. This patch introduces the per-driver list of flow blocks to account for blocks that are already in use. Remove tc_block_offload alias. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
59094b1e50
commit
955bcb6ea0
@ -9907,6 +9907,8 @@ static int bnxt_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(bnxt_block_cb_list);
|
||||||
|
|
||||||
static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
||||||
void *type_data)
|
void *type_data)
|
||||||
{
|
{
|
||||||
@ -9914,7 +9916,8 @@ static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&bnxt_block_cb_list,
|
||||||
bnxt_setup_tc_block_cb,
|
bnxt_setup_tc_block_cb,
|
||||||
bp, bp, true);
|
bp, bp, true);
|
||||||
case TC_SETUP_QDISC_MQPRIO: {
|
case TC_SETUP_QDISC_MQPRIO: {
|
||||||
|
@ -161,6 +161,8 @@ static int bnxt_vf_rep_setup_tc_block_cb(enum tc_setup_type type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(bnxt_vf_block_cb_list);
|
||||||
|
|
||||||
static int bnxt_vf_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
static int bnxt_vf_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
||||||
void *type_data)
|
void *type_data)
|
||||||
{
|
{
|
||||||
@ -168,7 +170,8 @@ static int bnxt_vf_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&bnxt_vf_block_cb_list,
|
||||||
bnxt_vf_rep_setup_tc_block_cb,
|
bnxt_vf_rep_setup_tc_block_cb,
|
||||||
vf_rep, vf_rep, true);
|
vf_rep, vf_rep, true);
|
||||||
default:
|
default:
|
||||||
|
@ -3190,6 +3190,8 @@ static int cxgb_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(cxgb_block_cb_list);
|
||||||
|
|
||||||
static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
||||||
void *type_data)
|
void *type_data)
|
||||||
{
|
{
|
||||||
@ -3197,7 +3199,8 @@ static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&cxgb_block_cb_list,
|
||||||
cxgb_setup_tc_block_cb,
|
cxgb_setup_tc_block_cb,
|
||||||
pi, dev, true);
|
pi, dev, true);
|
||||||
default:
|
default:
|
||||||
|
@ -8177,6 +8177,8 @@ static int i40e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(i40e_block_cb_list);
|
||||||
|
|
||||||
static int __i40e_setup_tc(struct net_device *netdev, enum tc_setup_type type,
|
static int __i40e_setup_tc(struct net_device *netdev, enum tc_setup_type type,
|
||||||
void *type_data)
|
void *type_data)
|
||||||
{
|
{
|
||||||
@ -8186,7 +8188,8 @@ static int __i40e_setup_tc(struct net_device *netdev, enum tc_setup_type type,
|
|||||||
case TC_SETUP_QDISC_MQPRIO:
|
case TC_SETUP_QDISC_MQPRIO:
|
||||||
return i40e_setup_tc(netdev, type_data);
|
return i40e_setup_tc(netdev, type_data);
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&i40e_block_cb_list,
|
||||||
i40e_setup_tc_block_cb,
|
i40e_setup_tc_block_cb,
|
||||||
np, np, true);
|
np, np, true);
|
||||||
default:
|
default:
|
||||||
|
@ -3113,6 +3113,8 @@ static int iavf_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(iavf_block_cb_list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* iavf_setup_tc - configure multiple traffic classes
|
* iavf_setup_tc - configure multiple traffic classes
|
||||||
* @netdev: network interface device structure
|
* @netdev: network interface device structure
|
||||||
@ -3133,7 +3135,8 @@ static int iavf_setup_tc(struct net_device *netdev, enum tc_setup_type type,
|
|||||||
case TC_SETUP_QDISC_MQPRIO:
|
case TC_SETUP_QDISC_MQPRIO:
|
||||||
return __iavf_setup_tc(netdev, type_data);
|
return __iavf_setup_tc(netdev, type_data);
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&iavf_block_cb_list,
|
||||||
iavf_setup_tc_block_cb,
|
iavf_setup_tc_block_cb,
|
||||||
adapter, adapter, true);
|
adapter, adapter, true);
|
||||||
default:
|
default:
|
||||||
|
@ -2806,6 +2806,8 @@ static int igb_offload_txtime(struct igb_adapter *adapter,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(igb_block_cb_list);
|
||||||
|
|
||||||
static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
||||||
void *type_data)
|
void *type_data)
|
||||||
{
|
{
|
||||||
@ -2815,7 +2817,8 @@ static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
|||||||
case TC_SETUP_QDISC_CBS:
|
case TC_SETUP_QDISC_CBS:
|
||||||
return igb_offload_cbs(adapter, type_data);
|
return igb_offload_cbs(adapter, type_data);
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&igb_block_cb_list,
|
||||||
igb_setup_tc_block_cb,
|
igb_setup_tc_block_cb,
|
||||||
adapter, adapter, true);
|
adapter, adapter, true);
|
||||||
|
|
||||||
|
@ -9614,6 +9614,8 @@ static int ixgbe_setup_tc_mqprio(struct net_device *dev,
|
|||||||
return ixgbe_setup_tc(dev, mqprio->num_tc);
|
return ixgbe_setup_tc(dev, mqprio->num_tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(ixgbe_block_cb_list);
|
||||||
|
|
||||||
static int __ixgbe_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
static int __ixgbe_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
||||||
void *type_data)
|
void *type_data)
|
||||||
{
|
{
|
||||||
@ -9621,7 +9623,8 @@ static int __ixgbe_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&ixgbe_block_cb_list,
|
||||||
ixgbe_setup_tc_block_cb,
|
ixgbe_setup_tc_block_cb,
|
||||||
adapter, adapter, true);
|
adapter, adapter, true);
|
||||||
case TC_SETUP_QDISC_MQPRIO:
|
case TC_SETUP_QDISC_MQPRIO:
|
||||||
|
@ -3459,6 +3459,8 @@ static int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
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,
|
||||||
void *type_data)
|
void *type_data)
|
||||||
{
|
{
|
||||||
@ -3467,7 +3469,8 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
#ifdef CONFIG_MLX5_ESWITCH
|
#ifdef CONFIG_MLX5_ESWITCH
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&mlx5e_block_cb_list,
|
||||||
mlx5e_setup_tc_block_cb,
|
mlx5e_setup_tc_block_cb,
|
||||||
priv, priv, true);
|
priv, priv, true);
|
||||||
#endif
|
#endif
|
||||||
|
@ -693,17 +693,29 @@ static int mlx5e_rep_indr_setup_block_cb(enum tc_setup_type type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mlx5e_rep_indr_tc_block_unbind(void *cb_priv)
|
||||||
|
{
|
||||||
|
struct mlx5e_rep_indr_block_priv *indr_priv = cb_priv;
|
||||||
|
|
||||||
|
list_del(&indr_priv->list);
|
||||||
|
kfree(indr_priv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(mlx5e_block_cb_list);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,
|
mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,
|
||||||
struct mlx5e_rep_priv *rpriv,
|
struct mlx5e_rep_priv *rpriv,
|
||||||
struct tc_block_offload *f)
|
struct flow_block_offload *f)
|
||||||
{
|
{
|
||||||
struct mlx5e_rep_indr_block_priv *indr_priv;
|
struct mlx5e_rep_indr_block_priv *indr_priv;
|
||||||
int err = 0;
|
struct flow_block_cb *block_cb;
|
||||||
|
|
||||||
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->driver_block_list = &mlx5e_block_cb_list;
|
||||||
|
|
||||||
switch (f->command) {
|
switch (f->command) {
|
||||||
case FLOW_BLOCK_BIND:
|
case FLOW_BLOCK_BIND:
|
||||||
indr_priv = mlx5e_rep_indr_block_priv_lookup(rpriv, netdev);
|
indr_priv = mlx5e_rep_indr_block_priv_lookup(rpriv, netdev);
|
||||||
@ -719,26 +731,32 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,
|
|||||||
list_add(&indr_priv->list,
|
list_add(&indr_priv->list,
|
||||||
&rpriv->uplink_priv.tc_indr_block_priv_list);
|
&rpriv->uplink_priv.tc_indr_block_priv_list);
|
||||||
|
|
||||||
err = tcf_block_cb_register(f->block,
|
block_cb = flow_block_cb_alloc(f->net,
|
||||||
mlx5e_rep_indr_setup_block_cb,
|
mlx5e_rep_indr_setup_block_cb,
|
||||||
indr_priv, indr_priv, f->extack);
|
indr_priv, indr_priv,
|
||||||
if (err) {
|
mlx5e_rep_indr_tc_block_unbind);
|
||||||
|
if (IS_ERR(block_cb)) {
|
||||||
list_del(&indr_priv->list);
|
list_del(&indr_priv->list);
|
||||||
kfree(indr_priv);
|
kfree(indr_priv);
|
||||||
|
return PTR_ERR(block_cb);
|
||||||
}
|
}
|
||||||
|
flow_block_cb_add(block_cb, f);
|
||||||
|
list_add_tail(&block_cb->driver_list, &mlx5e_block_cb_list);
|
||||||
|
|
||||||
return err;
|
return 0;
|
||||||
case FLOW_BLOCK_UNBIND:
|
case FLOW_BLOCK_UNBIND:
|
||||||
indr_priv = mlx5e_rep_indr_block_priv_lookup(rpriv, netdev);
|
indr_priv = mlx5e_rep_indr_block_priv_lookup(rpriv, netdev);
|
||||||
if (!indr_priv)
|
if (!indr_priv)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
tcf_block_cb_unregister(f->block,
|
block_cb = flow_block_cb_lookup(f,
|
||||||
mlx5e_rep_indr_setup_block_cb,
|
mlx5e_rep_indr_setup_block_cb,
|
||||||
indr_priv);
|
indr_priv);
|
||||||
list_del(&indr_priv->list);
|
if (!block_cb)
|
||||||
kfree(indr_priv);
|
return -ENOENT;
|
||||||
|
|
||||||
|
flow_block_cb_remove(block_cb, f);
|
||||||
|
list_del(&block_cb->driver_list);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
@ -1585,33 +1585,45 @@ static int mlxsw_sp_setup_tc_block_cb_flower(enum tc_setup_type type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mlxsw_sp_tc_block_flower_release(void *cb_priv)
|
||||||
|
{
|
||||||
|
struct mlxsw_sp_acl_block *acl_block = cb_priv;
|
||||||
|
|
||||||
|
mlxsw_sp_acl_block_destroy(acl_block);
|
||||||
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(mlxsw_sp_block_cb_list);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mlxsw_sp_setup_tc_block_flower_bind(struct mlxsw_sp_port *mlxsw_sp_port,
|
mlxsw_sp_setup_tc_block_flower_bind(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||||
struct tcf_block *block, bool ingress,
|
struct flow_block_offload *f, bool ingress)
|
||||||
struct netlink_ext_ack *extack)
|
|
||||||
{
|
{
|
||||||
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
|
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
|
||||||
struct mlxsw_sp_acl_block *acl_block;
|
struct mlxsw_sp_acl_block *acl_block;
|
||||||
struct tcf_block_cb *block_cb;
|
struct flow_block_cb *block_cb;
|
||||||
|
bool register_block = false;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
block_cb = tcf_block_cb_lookup(block, mlxsw_sp_setup_tc_block_cb_flower,
|
block_cb = flow_block_cb_lookup(f, mlxsw_sp_setup_tc_block_cb_flower,
|
||||||
mlxsw_sp);
|
mlxsw_sp);
|
||||||
if (!block_cb) {
|
if (!block_cb) {
|
||||||
acl_block = mlxsw_sp_acl_block_create(mlxsw_sp, block->net);
|
acl_block = mlxsw_sp_acl_block_create(mlxsw_sp, f->net);
|
||||||
if (!acl_block)
|
if (!acl_block)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
block_cb = __tcf_block_cb_register(block,
|
block_cb = flow_block_cb_alloc(f->net,
|
||||||
mlxsw_sp_setup_tc_block_cb_flower,
|
mlxsw_sp_setup_tc_block_cb_flower,
|
||||||
mlxsw_sp, acl_block, extack);
|
mlxsw_sp, acl_block,
|
||||||
|
mlxsw_sp_tc_block_flower_release);
|
||||||
if (IS_ERR(block_cb)) {
|
if (IS_ERR(block_cb)) {
|
||||||
|
mlxsw_sp_acl_block_destroy(acl_block);
|
||||||
err = PTR_ERR(block_cb);
|
err = PTR_ERR(block_cb);
|
||||||
goto err_cb_register;
|
goto err_cb_register;
|
||||||
}
|
}
|
||||||
|
register_block = true;
|
||||||
} else {
|
} else {
|
||||||
acl_block = tcf_block_cb_priv(block_cb);
|
acl_block = flow_block_cb_priv(block_cb);
|
||||||
}
|
}
|
||||||
tcf_block_cb_incref(block_cb);
|
flow_block_cb_incref(block_cb);
|
||||||
err = mlxsw_sp_acl_block_bind(mlxsw_sp, acl_block,
|
err = mlxsw_sp_acl_block_bind(mlxsw_sp, acl_block,
|
||||||
mlxsw_sp_port, ingress);
|
mlxsw_sp_port, ingress);
|
||||||
if (err)
|
if (err)
|
||||||
@ -1622,28 +1634,31 @@ mlxsw_sp_setup_tc_block_flower_bind(struct mlxsw_sp_port *mlxsw_sp_port,
|
|||||||
else
|
else
|
||||||
mlxsw_sp_port->eg_acl_block = acl_block;
|
mlxsw_sp_port->eg_acl_block = acl_block;
|
||||||
|
|
||||||
|
if (register_block) {
|
||||||
|
flow_block_cb_add(block_cb, f);
|
||||||
|
list_add_tail(&block_cb->driver_list, &mlxsw_sp_block_cb_list);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_block_bind:
|
err_block_bind:
|
||||||
if (!tcf_block_cb_decref(block_cb)) {
|
if (!flow_block_cb_decref(block_cb))
|
||||||
__tcf_block_cb_unregister(block, block_cb);
|
flow_block_cb_free(block_cb);
|
||||||
err_cb_register:
|
err_cb_register:
|
||||||
mlxsw_sp_acl_block_destroy(acl_block);
|
|
||||||
}
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mlxsw_sp_setup_tc_block_flower_unbind(struct mlxsw_sp_port *mlxsw_sp_port,
|
mlxsw_sp_setup_tc_block_flower_unbind(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||||
struct tcf_block *block, bool ingress)
|
struct flow_block_offload *f, bool ingress)
|
||||||
{
|
{
|
||||||
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
|
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
|
||||||
struct mlxsw_sp_acl_block *acl_block;
|
struct mlxsw_sp_acl_block *acl_block;
|
||||||
struct tcf_block_cb *block_cb;
|
struct flow_block_cb *block_cb;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
block_cb = tcf_block_cb_lookup(block, mlxsw_sp_setup_tc_block_cb_flower,
|
block_cb = flow_block_cb_lookup(f, mlxsw_sp_setup_tc_block_cb_flower,
|
||||||
mlxsw_sp);
|
mlxsw_sp);
|
||||||
if (!block_cb)
|
if (!block_cb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1652,18 +1667,19 @@ mlxsw_sp_setup_tc_block_flower_unbind(struct mlxsw_sp_port *mlxsw_sp_port,
|
|||||||
else
|
else
|
||||||
mlxsw_sp_port->eg_acl_block = NULL;
|
mlxsw_sp_port->eg_acl_block = NULL;
|
||||||
|
|
||||||
acl_block = tcf_block_cb_priv(block_cb);
|
acl_block = flow_block_cb_priv(block_cb);
|
||||||
err = mlxsw_sp_acl_block_unbind(mlxsw_sp, acl_block,
|
err = mlxsw_sp_acl_block_unbind(mlxsw_sp, acl_block,
|
||||||
mlxsw_sp_port, ingress);
|
mlxsw_sp_port, ingress);
|
||||||
if (!err && !tcf_block_cb_decref(block_cb)) {
|
if (!err && !flow_block_cb_decref(block_cb)) {
|
||||||
__tcf_block_cb_unregister(block, block_cb);
|
flow_block_cb_remove(block_cb, f);
|
||||||
mlxsw_sp_acl_block_destroy(acl_block);
|
list_del(&block_cb->driver_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,
|
static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||||
struct tc_block_offload *f)
|
struct flow_block_offload *f)
|
||||||
{
|
{
|
||||||
|
struct flow_block_cb *block_cb;
|
||||||
tc_setup_cb_t *cb;
|
tc_setup_cb_t *cb;
|
||||||
bool ingress;
|
bool ingress;
|
||||||
int err;
|
int err;
|
||||||
@ -1678,24 +1694,32 @@ static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f->driver_block_list = &mlxsw_sp_block_cb_list;
|
||||||
|
|
||||||
switch (f->command) {
|
switch (f->command) {
|
||||||
case FLOW_BLOCK_BIND:
|
case FLOW_BLOCK_BIND:
|
||||||
err = tcf_block_cb_register(f->block, cb, mlxsw_sp_port,
|
block_cb = flow_block_cb_alloc(f->net, cb, mlxsw_sp_port,
|
||||||
mlxsw_sp_port, f->extack);
|
mlxsw_sp_port, NULL);
|
||||||
if (err)
|
if (IS_ERR(block_cb))
|
||||||
return err;
|
return PTR_ERR(block_cb);
|
||||||
err = mlxsw_sp_setup_tc_block_flower_bind(mlxsw_sp_port,
|
err = mlxsw_sp_setup_tc_block_flower_bind(mlxsw_sp_port, f,
|
||||||
f->block, ingress,
|
ingress);
|
||||||
f->extack);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
tcf_block_cb_unregister(f->block, cb, mlxsw_sp_port);
|
flow_block_cb_free(block_cb);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
flow_block_cb_add(block_cb, f);
|
||||||
|
list_add_tail(&block_cb->driver_list, &mlxsw_sp_block_cb_list);
|
||||||
return 0;
|
return 0;
|
||||||
case FLOW_BLOCK_UNBIND:
|
case FLOW_BLOCK_UNBIND:
|
||||||
mlxsw_sp_setup_tc_block_flower_unbind(mlxsw_sp_port,
|
mlxsw_sp_setup_tc_block_flower_unbind(mlxsw_sp_port,
|
||||||
f->block, ingress);
|
f, ingress);
|
||||||
tcf_block_cb_unregister(f->block, cb, mlxsw_sp_port);
|
block_cb = flow_block_cb_lookup(f, cb, mlxsw_sp_port);
|
||||||
|
if (!block_cb)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
flow_block_cb_remove(block_cb, f);
|
||||||
|
list_del(&block_cb->driver_list);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
@ -225,8 +225,8 @@ int ocelot_ace_init(struct ocelot *ocelot);
|
|||||||
void ocelot_ace_deinit(void);
|
void ocelot_ace_deinit(void);
|
||||||
|
|
||||||
int ocelot_setup_tc_block_flower_bind(struct ocelot_port *port,
|
int ocelot_setup_tc_block_flower_bind(struct ocelot_port *port,
|
||||||
struct tc_block_offload *f);
|
struct flow_block_offload *f);
|
||||||
void ocelot_setup_tc_block_flower_unbind(struct ocelot_port *port,
|
void ocelot_setup_tc_block_flower_unbind(struct ocelot_port *port,
|
||||||
struct tc_block_offload *f);
|
struct flow_block_offload *f);
|
||||||
|
|
||||||
#endif /* _MSCC_OCELOT_ACE_H_ */
|
#endif /* _MSCC_OCELOT_ACE_H_ */
|
||||||
|
@ -299,36 +299,45 @@ static void ocelot_port_block_destroy(struct ocelot_port_block *block)
|
|||||||
kfree(block);
|
kfree(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ocelot_tc_block_unbind(void *cb_priv)
|
||||||
|
{
|
||||||
|
struct ocelot_port_block *port_block = cb_priv;
|
||||||
|
|
||||||
|
ocelot_port_block_destroy(port_block);
|
||||||
|
}
|
||||||
|
|
||||||
int ocelot_setup_tc_block_flower_bind(struct ocelot_port *port,
|
int ocelot_setup_tc_block_flower_bind(struct ocelot_port *port,
|
||||||
struct tc_block_offload *f)
|
struct flow_block_offload *f)
|
||||||
{
|
{
|
||||||
struct ocelot_port_block *port_block;
|
struct ocelot_port_block *port_block;
|
||||||
struct tcf_block_cb *block_cb;
|
struct flow_block_cb *block_cb;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS)
|
if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
block_cb = tcf_block_cb_lookup(f->block,
|
block_cb = flow_block_cb_lookup(f, ocelot_setup_tc_block_cb_flower,
|
||||||
ocelot_setup_tc_block_cb_flower, port);
|
port);
|
||||||
if (!block_cb) {
|
if (!block_cb) {
|
||||||
port_block = ocelot_port_block_create(port);
|
port_block = ocelot_port_block_create(port);
|
||||||
if (!port_block)
|
if (!port_block)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
block_cb =
|
block_cb = flow_block_cb_alloc(f->net,
|
||||||
__tcf_block_cb_register(f->block,
|
ocelot_setup_tc_block_cb_flower,
|
||||||
ocelot_setup_tc_block_cb_flower,
|
port, port_block,
|
||||||
port, port_block, f->extack);
|
ocelot_tc_block_unbind);
|
||||||
if (IS_ERR(block_cb)) {
|
if (IS_ERR(block_cb)) {
|
||||||
ret = PTR_ERR(block_cb);
|
ret = PTR_ERR(block_cb);
|
||||||
goto err_cb_register;
|
goto err_cb_register;
|
||||||
}
|
}
|
||||||
|
flow_block_cb_add(block_cb, f);
|
||||||
|
list_add_tail(&block_cb->driver_list, f->driver_block_list);
|
||||||
} else {
|
} else {
|
||||||
port_block = tcf_block_cb_priv(block_cb);
|
port_block = flow_block_cb_priv(block_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
tcf_block_cb_incref(block_cb);
|
flow_block_cb_incref(block_cb);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_cb_register:
|
err_cb_register:
|
||||||
@ -338,20 +347,17 @@ err_cb_register:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ocelot_setup_tc_block_flower_unbind(struct ocelot_port *port,
|
void ocelot_setup_tc_block_flower_unbind(struct ocelot_port *port,
|
||||||
struct tc_block_offload *f)
|
struct flow_block_offload *f)
|
||||||
{
|
{
|
||||||
struct ocelot_port_block *port_block;
|
struct flow_block_cb *block_cb;
|
||||||
struct tcf_block_cb *block_cb;
|
|
||||||
|
|
||||||
block_cb = tcf_block_cb_lookup(f->block,
|
block_cb = flow_block_cb_lookup(f, ocelot_setup_tc_block_cb_flower,
|
||||||
ocelot_setup_tc_block_cb_flower, port);
|
port);
|
||||||
if (!block_cb)
|
if (!block_cb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
port_block = tcf_block_cb_priv(block_cb);
|
if (!flow_block_cb_decref(block_cb)) {
|
||||||
if (!tcf_block_cb_decref(block_cb)) {
|
flow_block_cb_remove(block_cb, f);
|
||||||
tcf_block_cb_unregister(f->block,
|
list_del(&block_cb->driver_list);
|
||||||
ocelot_setup_tc_block_cb_flower, port);
|
|
||||||
ocelot_port_block_destroy(port_block);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,35 +128,51 @@ static int ocelot_setup_tc_block_cb_eg(enum tc_setup_type type,
|
|||||||
cb_priv, false);
|
cb_priv, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(ocelot_block_cb_list);
|
||||||
|
|
||||||
static int ocelot_setup_tc_block(struct ocelot_port *port,
|
static int ocelot_setup_tc_block(struct ocelot_port *port,
|
||||||
struct tc_block_offload *f)
|
struct flow_block_offload *f)
|
||||||
{
|
{
|
||||||
|
struct flow_block_cb *block_cb;
|
||||||
tc_setup_cb_t *cb;
|
tc_setup_cb_t *cb;
|
||||||
int ret;
|
int err;
|
||||||
|
|
||||||
netdev_dbg(port->dev, "tc_block command %d, binder_type %d\n",
|
netdev_dbg(port->dev, "tc_block command %d, binder_type %d\n",
|
||||||
f->command, f->binder_type);
|
f->command, f->binder_type);
|
||||||
|
|
||||||
if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) {
|
if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) {
|
||||||
cb = ocelot_setup_tc_block_cb_ig;
|
cb = ocelot_setup_tc_block_cb_ig;
|
||||||
port->tc.block_shared = tcf_block_shared(f->block);
|
port->tc.block_shared = f->block_shared;
|
||||||
} else if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS) {
|
} else if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS) {
|
||||||
cb = ocelot_setup_tc_block_cb_eg;
|
cb = ocelot_setup_tc_block_cb_eg;
|
||||||
} else {
|
} else {
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f->driver_block_list = &ocelot_block_cb_list;
|
||||||
|
|
||||||
switch (f->command) {
|
switch (f->command) {
|
||||||
case FLOW_BLOCK_BIND:
|
case FLOW_BLOCK_BIND:
|
||||||
ret = tcf_block_cb_register(f->block, cb, port,
|
block_cb = flow_block_cb_alloc(f->net, cb, port, port, NULL);
|
||||||
port, f->extack);
|
if (IS_ERR(block_cb))
|
||||||
if (ret)
|
return PTR_ERR(block_cb);
|
||||||
return ret;
|
|
||||||
|
|
||||||
return ocelot_setup_tc_block_flower_bind(port, f);
|
err = ocelot_setup_tc_block_flower_bind(port, f);
|
||||||
|
if (err < 0) {
|
||||||
|
flow_block_cb_free(block_cb);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
flow_block_cb_add(block_cb, f);
|
||||||
|
list_add_tail(&block_cb->driver_list, f->driver_block_list);
|
||||||
|
return 0;
|
||||||
case FLOW_BLOCK_UNBIND:
|
case FLOW_BLOCK_UNBIND:
|
||||||
|
block_cb = flow_block_cb_lookup(f, cb, port);
|
||||||
|
if (!block_cb)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
ocelot_setup_tc_block_flower_unbind(port, f);
|
ocelot_setup_tc_block_flower_unbind(port, f);
|
||||||
tcf_block_cb_unregister(f->block, cb, port);
|
flow_block_cb_remove(block_cb, f);
|
||||||
|
list_del(&block_cb->driver_list);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
@ -262,9 +262,12 @@ static int nfp_abm_setup_tc_block_cb(enum tc_setup_type type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(nfp_abm_block_cb_list);
|
||||||
|
|
||||||
int nfp_abm_setup_cls_block(struct net_device *netdev, struct nfp_repr *repr,
|
int nfp_abm_setup_cls_block(struct net_device *netdev, struct nfp_repr *repr,
|
||||||
struct tc_block_offload *f)
|
struct flow_block_offload *f)
|
||||||
{
|
{
|
||||||
return flow_block_cb_setup_simple(f, NULL, nfp_abm_setup_tc_block_cb,
|
return flow_block_cb_setup_simple(f, &nfp_abm_block_cb_list,
|
||||||
|
nfp_abm_setup_tc_block_cb,
|
||||||
repr, repr, true);
|
repr, repr, true);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ int nfp_abm_setup_tc_mq(struct net_device *netdev, struct nfp_abm_link *alink,
|
|||||||
int nfp_abm_setup_tc_gred(struct net_device *netdev, struct nfp_abm_link *alink,
|
int nfp_abm_setup_tc_gred(struct net_device *netdev, struct nfp_abm_link *alink,
|
||||||
struct tc_gred_qopt_offload *opt);
|
struct tc_gred_qopt_offload *opt);
|
||||||
int nfp_abm_setup_cls_block(struct net_device *netdev, struct nfp_repr *repr,
|
int nfp_abm_setup_cls_block(struct net_device *netdev, struct nfp_repr *repr,
|
||||||
struct tc_block_offload *opt);
|
struct flow_block_offload *opt);
|
||||||
|
|
||||||
int nfp_abm_ctrl_read_params(struct nfp_abm_link *alink);
|
int nfp_abm_ctrl_read_params(struct nfp_abm_link *alink);
|
||||||
int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm);
|
int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm);
|
||||||
|
@ -160,6 +160,8 @@ static int nfp_bpf_setup_tc_block_cb(enum tc_setup_type type,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(nfp_bpf_block_cb_list);
|
||||||
|
|
||||||
static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev,
|
static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev,
|
||||||
enum tc_setup_type type, void *type_data)
|
enum tc_setup_type type, void *type_data)
|
||||||
{
|
{
|
||||||
@ -167,7 +169,8 @@ static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev,
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&nfp_bpf_block_cb_list,
|
||||||
nfp_bpf_setup_tc_block_cb,
|
nfp_bpf_setup_tc_block_cb,
|
||||||
nn, nn, true);
|
nn, nn, true);
|
||||||
default:
|
default:
|
||||||
|
@ -1302,27 +1302,41 @@ static int nfp_flower_setup_tc_block_cb(enum tc_setup_type type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(nfp_block_cb_list);
|
||||||
|
|
||||||
static int nfp_flower_setup_tc_block(struct net_device *netdev,
|
static int nfp_flower_setup_tc_block(struct net_device *netdev,
|
||||||
struct tc_block_offload *f)
|
struct flow_block_offload *f)
|
||||||
{
|
{
|
||||||
struct nfp_repr *repr = netdev_priv(netdev);
|
struct nfp_repr *repr = netdev_priv(netdev);
|
||||||
struct nfp_flower_repr_priv *repr_priv;
|
struct nfp_flower_repr_priv *repr_priv;
|
||||||
|
struct flow_block_cb *block_cb;
|
||||||
|
|
||||||
if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
|
if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
repr_priv = repr->app_priv;
|
repr_priv = repr->app_priv;
|
||||||
repr_priv->block_shared = tcf_block_shared(f->block);
|
repr_priv->block_shared = f->block_shared;
|
||||||
|
f->driver_block_list = &nfp_block_cb_list;
|
||||||
|
|
||||||
switch (f->command) {
|
switch (f->command) {
|
||||||
case FLOW_BLOCK_BIND:
|
case FLOW_BLOCK_BIND:
|
||||||
return tcf_block_cb_register(f->block,
|
block_cb = flow_block_cb_alloc(f->net,
|
||||||
nfp_flower_setup_tc_block_cb,
|
nfp_flower_setup_tc_block_cb,
|
||||||
repr, repr, f->extack);
|
repr, repr, NULL);
|
||||||
|
if (IS_ERR(block_cb))
|
||||||
|
return PTR_ERR(block_cb);
|
||||||
|
|
||||||
|
flow_block_cb_add(block_cb, f);
|
||||||
|
list_add_tail(&block_cb->driver_list, &nfp_block_cb_list);
|
||||||
|
return 0;
|
||||||
case FLOW_BLOCK_UNBIND:
|
case FLOW_BLOCK_UNBIND:
|
||||||
tcf_block_cb_unregister(f->block,
|
block_cb = flow_block_cb_lookup(f, nfp_flower_setup_tc_block_cb,
|
||||||
nfp_flower_setup_tc_block_cb,
|
repr);
|
||||||
repr);
|
if (!block_cb)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
flow_block_cb_remove(block_cb, f);
|
||||||
|
list_del(&block_cb->driver_list);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -1381,13 +1395,21 @@ static int nfp_flower_setup_indr_block_cb(enum tc_setup_type type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nfp_flower_setup_indr_tc_release(void *cb_priv)
|
||||||
|
{
|
||||||
|
struct nfp_flower_indr_block_cb_priv *priv = cb_priv;
|
||||||
|
|
||||||
|
list_del(&priv->list);
|
||||||
|
kfree(priv);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app,
|
nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app,
|
||||||
struct tc_block_offload *f)
|
struct flow_block_offload *f)
|
||||||
{
|
{
|
||||||
struct nfp_flower_indr_block_cb_priv *cb_priv;
|
struct nfp_flower_indr_block_cb_priv *cb_priv;
|
||||||
struct nfp_flower_priv *priv = app->priv;
|
struct nfp_flower_priv *priv = app->priv;
|
||||||
int err;
|
struct flow_block_cb *block_cb;
|
||||||
|
|
||||||
if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS &&
|
if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS &&
|
||||||
!(f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS &&
|
!(f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS &&
|
||||||
@ -1404,26 +1426,32 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app,
|
|||||||
cb_priv->app = app;
|
cb_priv->app = app;
|
||||||
list_add(&cb_priv->list, &priv->indr_block_cb_priv);
|
list_add(&cb_priv->list, &priv->indr_block_cb_priv);
|
||||||
|
|
||||||
err = tcf_block_cb_register(f->block,
|
block_cb = flow_block_cb_alloc(f->net,
|
||||||
nfp_flower_setup_indr_block_cb,
|
nfp_flower_setup_indr_block_cb,
|
||||||
cb_priv, cb_priv, f->extack);
|
cb_priv, cb_priv,
|
||||||
if (err) {
|
nfp_flower_setup_indr_tc_release);
|
||||||
|
if (IS_ERR(block_cb)) {
|
||||||
list_del(&cb_priv->list);
|
list_del(&cb_priv->list);
|
||||||
kfree(cb_priv);
|
kfree(cb_priv);
|
||||||
|
return PTR_ERR(block_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
flow_block_cb_add(block_cb, f);
|
||||||
|
list_add_tail(&block_cb->driver_list, &nfp_block_cb_list);
|
||||||
|
return 0;
|
||||||
case FLOW_BLOCK_UNBIND:
|
case FLOW_BLOCK_UNBIND:
|
||||||
cb_priv = nfp_flower_indr_block_cb_priv_lookup(app, netdev);
|
cb_priv = nfp_flower_indr_block_cb_priv_lookup(app, netdev);
|
||||||
if (!cb_priv)
|
if (!cb_priv)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
tcf_block_cb_unregister(f->block,
|
block_cb = flow_block_cb_lookup(f,
|
||||||
nfp_flower_setup_indr_block_cb,
|
nfp_flower_setup_indr_block_cb,
|
||||||
cb_priv);
|
cb_priv);
|
||||||
list_del(&cb_priv->list);
|
if (!block_cb)
|
||||||
kfree(cb_priv);
|
return -ENOENT;
|
||||||
|
|
||||||
|
flow_block_cb_remove(block_cb, f);
|
||||||
|
list_del(&block_cb->driver_list);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
@ -579,6 +579,8 @@ static int qede_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(qede_block_cb_list);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qede_setup_tc_offload(struct net_device *dev, enum tc_setup_type type,
|
qede_setup_tc_offload(struct net_device *dev, enum tc_setup_type type,
|
||||||
void *type_data)
|
void *type_data)
|
||||||
@ -588,7 +590,8 @@ qede_setup_tc_offload(struct net_device *dev, enum tc_setup_type type,
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&qede_block_cb_list,
|
||||||
qede_setup_tc_block_cb,
|
qede_setup_tc_block_cb,
|
||||||
edev, edev, true);
|
edev, edev, true);
|
||||||
case TC_SETUP_QDISC_MQPRIO:
|
case TC_SETUP_QDISC_MQPRIO:
|
||||||
|
@ -3769,6 +3769,8 @@ static int stmmac_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(stmmac_block_cb_list);
|
||||||
|
|
||||||
static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type,
|
static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type,
|
||||||
void *type_data)
|
void *type_data)
|
||||||
{
|
{
|
||||||
@ -3776,7 +3778,8 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type,
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&stmmac_block_cb_list,
|
||||||
stmmac_setup_tc_block_cb,
|
stmmac_setup_tc_block_cb,
|
||||||
priv, priv, true);
|
priv, priv, true);
|
||||||
case TC_SETUP_QDISC_CBS:
|
case TC_SETUP_QDISC_CBS:
|
||||||
|
@ -203,6 +203,8 @@ static int nsim_set_vf_link_state(struct net_device *dev, int vf, int state)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(nsim_block_cb_list);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data)
|
nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data)
|
||||||
{
|
{
|
||||||
@ -210,7 +212,8 @@ nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data)
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TC_SETUP_BLOCK:
|
case TC_SETUP_BLOCK:
|
||||||
return flow_block_cb_setup_simple(type_data, NULL,
|
return flow_block_cb_setup_simple(type_data,
|
||||||
|
&nsim_block_cb_list,
|
||||||
nsim_setup_tc_block_cb,
|
nsim_setup_tc_block_cb,
|
||||||
ns, ns, true);
|
ns, ns, true);
|
||||||
default:
|
default:
|
||||||
|
@ -249,13 +249,12 @@ enum flow_block_binder_type {
|
|||||||
FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS,
|
FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tcf_block;
|
|
||||||
struct netlink_ext_ack;
|
struct netlink_ext_ack;
|
||||||
|
|
||||||
struct flow_block_offload {
|
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;
|
||||||
struct tcf_block *block;
|
bool block_shared;
|
||||||
struct net *net;
|
struct net *net;
|
||||||
struct list_head cb_list;
|
struct list_head cb_list;
|
||||||
struct list_head *driver_block_list;
|
struct list_head *driver_block_list;
|
||||||
|
@ -26,8 +26,6 @@ struct tcf_walker {
|
|||||||
int register_tcf_proto_ops(struct tcf_proto_ops *ops);
|
int register_tcf_proto_ops(struct tcf_proto_ops *ops);
|
||||||
int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
|
int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
|
||||||
|
|
||||||
#define tc_block_offload flow_block_offload
|
|
||||||
|
|
||||||
struct tcf_block_ext_info {
|
struct tcf_block_ext_info {
|
||||||
enum flow_block_binder_type binder_type;
|
enum flow_block_binder_type binder_type;
|
||||||
tcf_chain_head_change_t *chain_head_change;
|
tcf_chain_head_change_t *chain_head_change;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <net/flow_offload.h>
|
#include <net/flow_offload.h>
|
||||||
#include <net/pkt_cls.h>
|
|
||||||
|
|
||||||
struct flow_rule *flow_rule_alloc(unsigned int num_actions)
|
struct flow_rule *flow_rule_alloc(unsigned int num_actions)
|
||||||
{
|
{
|
||||||
@ -234,6 +233,8 @@ int flow_block_cb_setup_simple(struct flow_block_offload *f,
|
|||||||
tc_setup_cb_t *cb, void *cb_ident, void *cb_priv,
|
tc_setup_cb_t *cb, void *cb_ident, void *cb_priv,
|
||||||
bool ingress_only)
|
bool ingress_only)
|
||||||
{
|
{
|
||||||
|
struct flow_block_cb *block_cb;
|
||||||
|
|
||||||
if (ingress_only &&
|
if (ingress_only &&
|
||||||
f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
|
f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@ -242,10 +243,21 @@ int flow_block_cb_setup_simple(struct flow_block_offload *f,
|
|||||||
|
|
||||||
switch (f->command) {
|
switch (f->command) {
|
||||||
case FLOW_BLOCK_BIND:
|
case FLOW_BLOCK_BIND:
|
||||||
return tcf_block_cb_register(f->block, cb, cb_ident, cb_priv,
|
block_cb = flow_block_cb_alloc(f->net, cb, cb_ident,
|
||||||
f->extack);
|
cb_priv, NULL);
|
||||||
|
if (IS_ERR(block_cb))
|
||||||
|
return PTR_ERR(block_cb);
|
||||||
|
|
||||||
|
flow_block_cb_add(block_cb, f);
|
||||||
|
list_add_tail(&block_cb->driver_list, driver_block_list);
|
||||||
|
return 0;
|
||||||
case FLOW_BLOCK_UNBIND:
|
case FLOW_BLOCK_UNBIND:
|
||||||
tcf_block_cb_unregister(f->block, cb, cb_ident);
|
block_cb = flow_block_cb_lookup(f, cb, cb_ident);
|
||||||
|
if (!block_cb)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
flow_block_cb_remove(block_cb, f);
|
||||||
|
list_del(&block_cb->driver_list);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
@ -942,9 +942,12 @@ static int dsa_slave_setup_tc_block_cb_eg(enum tc_setup_type type,
|
|||||||
return dsa_slave_setup_tc_block_cb(type, type_data, cb_priv, false);
|
return dsa_slave_setup_tc_block_cb(type, type_data, cb_priv, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LIST_HEAD(dsa_slave_block_cb_list);
|
||||||
|
|
||||||
static int dsa_slave_setup_tc_block(struct net_device *dev,
|
static int dsa_slave_setup_tc_block(struct net_device *dev,
|
||||||
struct tc_block_offload *f)
|
struct flow_block_offload *f)
|
||||||
{
|
{
|
||||||
|
struct flow_block_cb *block_cb;
|
||||||
tc_setup_cb_t *cb;
|
tc_setup_cb_t *cb;
|
||||||
|
|
||||||
if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
|
if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
|
||||||
@ -954,11 +957,24 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,
|
|||||||
else
|
else
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
f->driver_block_list = &dsa_slave_block_cb_list;
|
||||||
|
|
||||||
switch (f->command) {
|
switch (f->command) {
|
||||||
case FLOW_BLOCK_BIND:
|
case FLOW_BLOCK_BIND:
|
||||||
return tcf_block_cb_register(f->block, cb, dev, dev, f->extack);
|
block_cb = flow_block_cb_alloc(f->net, cb, dev, dev, NULL);
|
||||||
|
if (IS_ERR(block_cb))
|
||||||
|
return PTR_ERR(block_cb);
|
||||||
|
|
||||||
|
flow_block_cb_add(block_cb, f);
|
||||||
|
list_add_tail(&block_cb->driver_list, &dsa_slave_block_cb_list);
|
||||||
|
return 0;
|
||||||
case FLOW_BLOCK_UNBIND:
|
case FLOW_BLOCK_UNBIND:
|
||||||
tcf_block_cb_unregister(f->block, cb, dev);
|
block_cb = flow_block_cb_lookup(f, cb, dev);
|
||||||
|
if (!block_cb)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
flow_block_cb_remove(block_cb, f);
|
||||||
|
list_del(&block_cb->driver_list);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
@ -680,11 +680,11 @@ static void tc_indr_block_ing_cmd(struct tc_indr_block_dev *indr_dev,
|
|||||||
struct tc_indr_block_cb *indr_block_cb,
|
struct tc_indr_block_cb *indr_block_cb,
|
||||||
enum flow_block_command command)
|
enum flow_block_command command)
|
||||||
{
|
{
|
||||||
struct tc_block_offload bo = {
|
struct flow_block_offload bo = {
|
||||||
.command = command,
|
.command = command,
|
||||||
.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS,
|
.binder_type = FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS,
|
||||||
.net = dev_net(indr_dev->dev),
|
.net = dev_net(indr_dev->dev),
|
||||||
.block = indr_dev->block,
|
.block_shared = tcf_block_shared(indr_dev->block),
|
||||||
};
|
};
|
||||||
INIT_LIST_HEAD(&bo.cb_list);
|
INIT_LIST_HEAD(&bo.cb_list);
|
||||||
|
|
||||||
@ -771,11 +771,11 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
|
|||||||
{
|
{
|
||||||
struct tc_indr_block_cb *indr_block_cb;
|
struct tc_indr_block_cb *indr_block_cb;
|
||||||
struct tc_indr_block_dev *indr_dev;
|
struct tc_indr_block_dev *indr_dev;
|
||||||
struct tc_block_offload bo = {
|
struct flow_block_offload bo = {
|
||||||
.command = command,
|
.command = command,
|
||||||
.binder_type = ei->binder_type,
|
.binder_type = ei->binder_type,
|
||||||
.net = dev_net(dev),
|
.net = dev_net(dev),
|
||||||
.block = block,
|
.block_shared = tcf_block_shared(block),
|
||||||
.extack = extack,
|
.extack = extack,
|
||||||
};
|
};
|
||||||
INIT_LIST_HEAD(&bo.cb_list);
|
INIT_LIST_HEAD(&bo.cb_list);
|
||||||
@ -804,13 +804,13 @@ static int tcf_block_offload_cmd(struct tcf_block *block,
|
|||||||
enum flow_block_command command,
|
enum flow_block_command command,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
struct tc_block_offload bo = {};
|
struct flow_block_offload bo = {};
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
bo.net = dev_net(dev);
|
bo.net = dev_net(dev);
|
||||||
bo.command = command;
|
bo.command = command;
|
||||||
bo.binder_type = ei->binder_type;
|
bo.binder_type = ei->binder_type;
|
||||||
bo.block = block;
|
bo.block_shared = tcf_block_shared(block);
|
||||||
bo.extack = extack;
|
bo.extack = extack;
|
||||||
INIT_LIST_HEAD(&bo.cb_list);
|
INIT_LIST_HEAD(&bo.cb_list);
|
||||||
|
|
||||||
@ -3245,7 +3245,7 @@ EXPORT_SYMBOL(tcf_exts_dump_stats);
|
|||||||
int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,
|
int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,
|
||||||
void *type_data, bool err_stop)
|
void *type_data, bool err_stop)
|
||||||
{
|
{
|
||||||
struct tcf_block_cb *block_cb;
|
struct flow_block_cb *block_cb;
|
||||||
int ok_count = 0;
|
int ok_count = 0;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user