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:
Pablo Neira Ayuso
2019-07-09 22:55:39 +02:00
committed by David S. Miller
parent 2bb295f3a5
commit 4e95bc268b
17 changed files with 117 additions and 317 deletions

View File

@@ -3,6 +3,7 @@
#include <linux/kernel.h>
#include <net/flow_dissector.h>
#include <net/sch_generic.h>
struct flow_match {
struct flow_dissector *dissector;
@@ -237,4 +238,30 @@ static inline void flow_stats_update(struct flow_stats *flow_stats,
flow_stats->lastused = max_t(u64, flow_stats->lastused, lastused);
}
enum flow_block_command {
TC_BLOCK_BIND,
TC_BLOCK_UNBIND,
};
enum flow_block_binder_type {
TCF_BLOCK_BINDER_TYPE_UNSPEC,
TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS,
TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS,
};
struct tcf_block;
struct netlink_ext_ack;
struct flow_block_offload {
enum flow_block_command command;
enum flow_block_binder_type binder_type;
struct tcf_block *block;
struct list_head *driver_block_list;
struct netlink_ext_ack *extack;
};
int flow_block_cb_setup_simple(struct flow_block_offload *f,
struct list_head *driver_list, tc_setup_cb_t *cb,
void *cb_ident, void *cb_priv, bool ingress_only);
#endif /* _NET_FLOW_OFFLOAD_H */