net: flow_offload: add flow_block_cb_setup_simple()
Most drivers do the same thing to set up the flow block callbacks, this patch adds a helper function to do this. This preparation patch reduces the number of changes to adapt the existing drivers to use the flow block callback API. This new helper function takes a flow block list per-driver, which is set to NULL until this driver list is used. This patch also introduces the flow_block_command and flow_block_binder_type enumerations, which are renamed to use FLOW_BLOCK_* in follow up patches. There are three definitions (aliases) in order to reduce the number of updates in this patch, which go away once drivers are fully adapted to use this flow block API. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
2bb295f3a5
commit
4e95bc268b
@@ -265,19 +265,6 @@ static int nfp_abm_setup_tc_block_cb(enum tc_setup_type type,
|
||||
int nfp_abm_setup_cls_block(struct net_device *netdev, struct nfp_repr *repr,
|
||||
struct tc_block_offload *f)
|
||||
{
|
||||
if (f->binder_type != TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
switch (f->command) {
|
||||
case TC_BLOCK_BIND:
|
||||
return tcf_block_cb_register(f->block,
|
||||
nfp_abm_setup_tc_block_cb,
|
||||
repr, repr, f->extack);
|
||||
case TC_BLOCK_UNBIND:
|
||||
tcf_block_cb_unregister(f->block, nfp_abm_setup_tc_block_cb,
|
||||
repr);
|
||||
return 0;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
return flow_block_cb_setup_simple(f, NULL, nfp_abm_setup_tc_block_cb,
|
||||
repr, repr, true);
|
||||
}
|
||||
|
@@ -160,35 +160,16 @@ static int nfp_bpf_setup_tc_block_cb(enum tc_setup_type type,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nfp_bpf_setup_tc_block(struct net_device *netdev,
|
||||
struct tc_block_offload *f)
|
||||
{
|
||||
struct nfp_net *nn = netdev_priv(netdev);
|
||||
|
||||
if (f->binder_type != TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
switch (f->command) {
|
||||
case TC_BLOCK_BIND:
|
||||
return tcf_block_cb_register(f->block,
|
||||
nfp_bpf_setup_tc_block_cb,
|
||||
nn, nn, f->extack);
|
||||
case TC_BLOCK_UNBIND:
|
||||
tcf_block_cb_unregister(f->block,
|
||||
nfp_bpf_setup_tc_block_cb,
|
||||
nn);
|
||||
return 0;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
|
||||
static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev,
|
||||
enum tc_setup_type type, void *type_data)
|
||||
{
|
||||
struct nfp_net *nn = netdev_priv(netdev);
|
||||
|
||||
switch (type) {
|
||||
case TC_SETUP_BLOCK:
|
||||
return nfp_bpf_setup_tc_block(netdev, type_data);
|
||||
return flow_block_cb_setup_simple(type_data, NULL,
|
||||
nfp_bpf_setup_tc_block_cb,
|
||||
nn, nn, true);
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
Reference in New Issue
Block a user