netfilter: add hardware offload infrastructure
Subsystems (18)
Pablo Neira Ayuso
maintainerv4 cover netfilter: add hardware offload infrastructure
Hi,
This patchset adds support for Netfilter hardware offloads.
This patchset reuses the existing block infrastructure, the netdev_ops->ndo_setup_tc() interface, TC_SETUP_CLSFLOWER classifier and the flow rule API.
Patch #1 adds flow_block_cb_setup_simple(), most drivers do the same thing
to set up flow blocks, to reduce the number of changes, consolidate codebase. Use _simple() postfix as requested by Jakub Kicinski. This new function resides in net/core/flow_offload.c
Patch #2 renames TC_BLOCK_{UN}BIND to FLOW_BLOCK_{UN}BIND.
Patch #3 renames TCF_BLOCK_BINDER_TYPE_* to FLOW_BLOCK_BINDER_TYPE_*.
Patch #4 adds flow_block_cb_alloc() and flow_block_cb_free() helper
functions, this is the first patch of the flow block API.
Patch #5 adds the helper to deal with list operations in the flow block API.
This includes flow_block_cb_lookup(), flow_block_cb_add() and flow_block_cb_remove().
Patch #6 adds flow_block_cb_priv(), flow_block_cb_incref() and
flow_block_cb_decref() which completes the flow block API.
Patch #7 updates the cls_api to use the flow block API from the new
tcf_block_setup(). This infrastructure transports these objects via list (through the tc_block_offload object) back to the core for registration.
CLS_API DRIVER
TC_SETUP_BLOCK ----------> setup flow_block_cb object &
it adds object to flow_block_offload->cb_list
|
CLS_API <-----------------------'
registers list with flow blocks
flow_block_cb & travels back to
calls ->reoffload the core for registration
drivers allocate and sets up (configure the blocks), then registration happens from the core (cls_api and netfilter).
Patch #8 updates drivers to use the flow block API.
Patch #9 removes the tcf block callback API, which is replaced by the
flow block API.
Patch #10 adds the flow_block_cb_is_busy() helper to check if the block
is already used by a subsystem. This helper is invoked from drivers. Once drivers are updated to support for multiple subsystems, they can remove this check.
Patch #11 rename tc structure and definitions for the block bind/unbind
path.
Patch #12 introduces basic netfilter hardware offload infrastructure
for the ingress chain. This includes 5-tuple exact matching
and accept / drop rule actions. Only basechains are supported
at this stage, no .reoffload callback is implemented either.
Default policy to "accept" is only supported for now.
table netdev filter {
chain ingress {
type filter hook ingress device eth0 priority 0; flags offload;
ip daddr 192.168.0.10 tcp dport 22 drop
}
}This patchset reuses the existing tcf block callback API and it places it in the flow block callback API in net/core/flow_offload.c.
This series aims to address Jakub and Jiri's feedback, please see specific patches in this batch for changelog in this v4.
Please, apply. Thank you very much.
P.S: yes, Phil, I still believe there is a chance.
Pablo Neira Ayuso (12):
net: flow_offload: add flow_block_cb_setup_simple()
net: flow_offload: rename TC_BLOCK_{UN}BIND to FLOW_BLOCK_{UN}BIND
net: flow_offload: rename TCF_BLOCK_BINDER_TYPE_* to FLOW_BLOCK_BINDER_TYPE_*
net: flow_offload: add flow_block_cb_alloc() and flow_block_cb_free()
net: flow_offload: add list handling functions
net: flow_offload: add flow_block_cb_{priv,incref,decref}()
net: sched: use flow block API
drivers: net: use flow block API
net: sched: remove tcf block API
net: flow_offload: add flow_block_cb_is_busy() and use it
net: flow_offload: rename tc_cls_flower_offload to flow_cls_offload
netfilter: nf_tables: add hardware offload support
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 27 +-- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 18 +- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 29 +-- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 35 +-- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 22 +- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h | 6 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 49 ++-- drivers/net/ethernet/intel/iavf/iavf_main.c | 58 ++--- drivers/net/ethernet/intel/igb/igb_main.c | 43 ++-- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 30 +-- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 6 +- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.h | 8 +- .../ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c | 18 +- .../ethernet/mellanox/mlx5/core/en/tc_tun_gre.c | 4 +- .../ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c | 10 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 38 +-- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 94 ++++---- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 34 +-- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 6 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 116 +++++---- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 10 +- .../net/ethernet/mellanox/mlxsw/spectrum_flower.c | 34 +-- drivers/net/ethernet/mscc/ocelot_ace.h | 4 +- drivers/net/ethernet/mscc/ocelot_flower.c | 70 +++--- drivers/net/ethernet/mscc/ocelot_tc.c | 47 ++-- drivers/net/ethernet/netronome/nfp/abm/cls.c | 22 +- drivers/net/ethernet/netronome/nfp/abm/main.h | 2 +- drivers/net/ethernet/netronome/nfp/bpf/main.c | 30 +-- drivers/net/ethernet/netronome/nfp/flower/action.c | 14 +- drivers/net/ethernet/netronome/nfp/flower/main.h | 6 +- drivers/net/ethernet/netronome/nfp/flower/match.c | 44 ++-- .../net/ethernet/netronome/nfp/flower/metadata.c | 2 +- .../net/ethernet/netronome/nfp/flower/offload.c | 116 +++++---- drivers/net/ethernet/qlogic/qede/qede.h | 2 +- drivers/net/ethernet/qlogic/qede/qede_filter.c | 2 +- drivers/net/ethernet/qlogic/qede/qede_main.c | 32 +-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 23 +- drivers/net/netdevsim/netdev.c | 29 +-- include/net/flow_offload.h | 96 ++++++++ include/net/netfilter/nf_tables.h | 14 ++ include/net/netfilter/nf_tables_offload.h | 76 ++++++ include/net/pkt_cls.h | 129 +--------- include/uapi/linux/netfilter/nf_tables.h | 2 + net/core/flow_offload.c | 118 +++++++++ net/dsa/slave.c | 33 ++- net/netfilter/Makefile | 2 +- net/netfilter/nf_tables_api.c | 39 ++- net/netfilter/nf_tables_offload.c | 267 +++++++++++++++++++++ net/netfilter/nft_cmp.c | 53 ++++ net/netfilter/nft_immediate.c | 31 +++ net/netfilter/nft_meta.c | 27 +++ net/netfilter/nft_payload.c | 187 +++++++++++++++ net/sched/cls_api.c | 211 ++++++++-------- net/sched/cls_flower.c | 24 +- net/sched/sch_ingress.c | 6 +- 56 files changed, 1579 insertions(+), 880 deletions(-) create mode 100644 include/net/netfilter/nf_tables_offload.h create mode 100644 net/netfilter/nf_tables_offload.c
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v4 1/12 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.
---
v4: no changes.
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 ++++------------- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 28 ++++-------------- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 26 ++++------------- drivers/net/ethernet/intel/i40e/i40e_main.c | 26 ++++------------- drivers/net/ethernet/intel/iavf/iavf_main.c | 35 ++++------------------- drivers/net/ethernet/intel/igb/igb_main.c | 24 +++------------- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 27 ++++------------- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 27 ++++------------- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 26 ++++------------- drivers/net/ethernet/netronome/nfp/abm/cls.c | 17 ++--------- drivers/net/ethernet/netronome/nfp/bpf/main.c | 29 ++++--------------- drivers/net/ethernet/qlogic/qede/qede_main.c | 23 ++------------- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 22 ++------------ drivers/net/netdevsim/netdev.c | 26 ++++------------- include/net/flow_offload.h | 27 +++++++++++++++++ include/net/pkt_cls.h | 20 ++----------- net/core/flow_offload.c | 25 ++++++++++++++++ 17 files changed, 117 insertions(+), 317 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -21
@@ -9847,32 +9847,16 @@ static int bnxt_setup_tc_block_cb(enum tc_setup_type type, void *type_data, } } -static int bnxt_setup_tc_block (struct net_device *dev, -struct tc_block_offload *f) -{ -struct bnxt *bp =netdev_priv (dev); - -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, bnxt_setup_tc_block_cb, - bp, bp, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, bnxt_setup_tc_block_cb, bp); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int bnxt_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) { +struct bnxt *bp =netdev_priv (dev); +switch (type) {case TC_SETUP_BLOCK : -return bnxt_setup_tc_block (dev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + bnxt_setup_tc_block_cb, + bp, bp, true);case TC_SETUP_QDISC_MQPRIO : {struct tc_mqprio_qopt *mqprio = type_data;
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +5 -23
@@ -161,34 +161,16 @@ static int bnxt_vf_rep_setup_tc_block_cb(enum tc_setup_type type, } } -static int bnxt_vf_rep_setup_tc_block (struct net_device *dev, -struct tc_block_offload *f) -{ -struct bnxt_vf_rep *vf_rep =netdev_priv (dev); - -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, - bnxt_vf_rep_setup_tc_block_cb, - vf_rep, vf_rep, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, - bnxt_vf_rep_setup_tc_block_cb, vf_rep); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int bnxt_vf_rep_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) { +struct bnxt_vf_rep *vf_rep =netdev_priv (dev); +switch (type) {case TC_SETUP_BLOCK : -return bnxt_vf_rep_setup_tc_block (dev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + bnxt_vf_rep_setup_tc_block_cb, + vf_rep, vf_rep, true);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +5 -21
@@ -3190,32 +3190,16 @@ static int cxgb_setup_tc_block_cb(enum tc_setup_type type, void *type_data, } } -static int cxgb_setup_tc_block (struct net_device *dev, -struct tc_block_offload *f) -{ -struct port_info *pi =netdev2pinfo (dev); - -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, cxgb_setup_tc_block_cb, - pi, dev, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, cxgb_setup_tc_block_cb, pi); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int cxgb_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) { +struct port_info *pi =netdev2pinfo (dev); +switch (type) {case TC_SETUP_BLOCK : -return cxgb_setup_tc_block (dev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + cxgb_setup_tc_block_cb, + pi, dev, true);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/intel/i40e/i40e_main.c +5 -21
@@ -8177,34 +8177,18 @@ static int i40e_setup_tc_block_cb(enum tc_setup_type type, void *type_data, } } -static int i40e_setup_tc_block (struct net_device *dev, -struct tc_block_offload *f) -{ -struct i40e_netdev_priv *np =netdev_priv (dev); - -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, i40e_setup_tc_block_cb, - np, np, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, i40e_setup_tc_block_cb, np); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int __i40e_setup_tc (struct net_device *netdev,enum tc_setup_type type,void *type_data) { +struct i40e_netdev_priv *np =netdev_priv (netdev); +switch (type) {case TC_SETUP_QDISC_MQPRIO :return i40e_setup_tc (netdev, type_data);case TC_SETUP_BLOCK : -return i40e_setup_tc_block (netdev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + i40e_setup_tc_block_cb, + np, np, true);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/intel/iavf/iavf_main.c +5 -30
@@ -3114,35 +3114,6 @@ static int iavf_setup_tc_block_cb(enum tc_setup_type type, void *type_data, }/** -* iavf_setup_tc_block - register callbacks for tc -* @netdev: network interface device structure -* @f: tc offload data -* -* This function registers block callbacks for tc -* offloads -**/ -static int iavf_setup_tc_block (struct net_device *dev, -struct tc_block_offload *f) -{ -struct iavf_adapter *adapter =netdev_priv (dev); - -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, iavf_setup_tc_block_cb, - adapter, adapter, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, iavf_setup_tc_block_cb, - adapter); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} - -/** * iavf_setup_tc - configure multiple traffic classes * @netdev: network interface device structure * @type: type of offload
@@ -3156,11 +3127,15 @@ static int iavf_setup_tc_block(struct net_device *dev,static int iavf_setup_tc (struct net_device *netdev,enum tc_setup_type type,void *type_data) { +struct iavf_adapter *adapter =netdev_priv (netdev); +switch (type) {case TC_SETUP_QDISC_MQPRIO :return __iavf_setup_tc (netdev, type_data);case TC_SETUP_BLOCK : -return iavf_setup_tc_block (netdev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + iavf_setup_tc_block_cb, + adapter, adapter, true);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/intel/igb/igb_main.c +4 -20
@@ -2783,25 +2783,6 @@ static int igb_setup_tc_block_cb(enum tc_setup_type type, void *type_data, } } -static int igb_setup_tc_block (struct igb_adapter *adapter, -struct tc_block_offload *f) -{ -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, igb_setup_tc_block_cb, - adapter, adapter, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, igb_setup_tc_block_cb, - adapter); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int igb_offload_txtime (struct igb_adapter *adapter,struct tc_etf_qopt_offload *qopt) {
@@ -2834,7 +2815,10 @@ static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type,case TC_SETUP_QDISC_CBS :return igb_offload_cbs (adapter, type_data);case TC_SETUP_BLOCK : -return igb_setup_tc_block (adapter, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + igb_setup_tc_block_cb, + adapter, adapter, true); +case TC_SETUP_QDISC_ETF :return igb_offload_txtime (adapter, type_data);
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +5 -22
@@ -9607,27 +9607,6 @@ static int ixgbe_setup_tc_block_cb(enum tc_setup_type type, void *type_data, } } -static int ixgbe_setup_tc_block (struct net_device *dev, -struct tc_block_offload *f) -{ -struct ixgbe_adapter *adapter =netdev_priv (dev); - -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, ixgbe_setup_tc_block_cb, - adapter, adapter, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, ixgbe_setup_tc_block_cb, - adapter); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int ixgbe_setup_tc_mqprio (struct net_device *dev,struct tc_mqprio_qopt *mqprio) {
@@ -9638,9 +9617,13 @@ static int ixgbe_setup_tc_mqprio(struct net_device *dev,static int __ixgbe_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) { +struct ixgbe_adapter *adapter =netdev_priv (dev); +switch (type) {case TC_SETUP_BLOCK : -return ixgbe_setup_tc_block (dev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + ixgbe_setup_tc_block_cb, + adapter, adapter, true);case TC_SETUP_QDISC_MQPRIO :return ixgbe_setup_tc_mqprio (dev, type_data);default :
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +5 -22
@@ -3457,36 +3457,19 @@ static int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data, return -EOPNOTSUPP; } } - -static int mlx5e_setup_tc_block (struct net_device *dev, -struct tc_block_offload *f) -{ -struct mlx5e_priv *priv =netdev_priv (dev); - -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, mlx5e_setup_tc_block_cb, - priv, priv, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, mlx5e_setup_tc_block_cb, - priv); -return 0 ; -default : -return -EOPNOTSUPP ; - } -}#endif static int mlx5e_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) { +struct mlx5e_priv *priv =netdev_priv (dev); +switch (type) {#ifdef CONFIG_MLX5_ESWITCH case TC_SETUP_BLOCK : -return mlx5e_setup_tc_block (dev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + mlx5e_setup_tc_block_cb, + priv, priv, true);#endif case TC_SETUP_QDISC_MQPRIO :return mlx5e_setup_tc_mqprio (dev, type_data);
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +5 -21
@@ -1178,32 +1178,16 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data, } } -static int mlx5e_rep_setup_tc_block (struct net_device *dev, -struct tc_block_offload *f) -{ -struct mlx5e_priv *priv =netdev_priv (dev); - -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, mlx5e_rep_setup_tc_cb, - priv, priv, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, mlx5e_rep_setup_tc_cb, priv); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int mlx5e_rep_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) { +struct mlx5e_priv *priv =netdev_priv (dev); +switch (type) {case TC_SETUP_BLOCK : -return mlx5e_rep_setup_tc_block (dev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + mlx5e_rep_setup_tc_cb, + priv, priv, true);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/netronome/nfp/abm/cls.c +2 -15
@@ -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); }
drivers/net/ethernet/netronome/nfp/bpf/main.c +5 -24
@@ -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 ; }
drivers/net/ethernet/qlogic/qede/qede_main.c +3 -20
@@ -579,25 +579,6 @@ static int qede_setup_tc_block_cb(enum tc_setup_type type, void *type_data, } } -static int qede_setup_tc_block (struct qede_dev *edev, -struct tc_block_offload *f) -{ -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, - qede_setup_tc_block_cb, - edev, edev, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, qede_setup_tc_block_cb, edev); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int qede_setup_tc_offload (struct net_device *dev,enum tc_setup_type type,void *type_data)
@@ -607,7 +588,9 @@ qede_setup_tc_offload(struct net_device *dev, enum tc_setup_type type,switch (type) {case TC_SETUP_BLOCK : -return qede_setup_tc_block (edev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + qede_setup_tc_block_cb, + edev, edev, true);case TC_SETUP_QDISC_MQPRIO : mqprio = type_data;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -19
@@ -3853,24 +3853,6 @@ static int stmmac_setup_tc_block_cb(enum tc_setup_type type, void *type_data,return ret; } -static int stmmac_setup_tc_block (struct stmmac_priv *priv, -struct tc_block_offload *f) -{ -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, stmmac_setup_tc_block_cb, - priv, priv, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, stmmac_setup_tc_block_cb, priv); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int stmmac_setup_tc (struct net_device *ndev,enum tc_setup_type type,void *type_data) {
@@ -3878,7 +3860,9 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type,switch (type) {case TC_SETUP_BLOCK : -return stmmac_setup_tc_block (priv, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + stmmac_setup_tc_block_cb, + priv, priv, true);case TC_SETUP_QDISC_CBS :return stmmac_tc_setup_cbs (priv, priv, type_data);default :
drivers/net/netdevsim/netdev.c +5 -21
@@ -78,26 +78,6 @@ nsim_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv)return nsim_bpf_setup_tc_block_cb (type, type_data, cb_priv); } -static int -nsim_setup_tc_block (struct net_device *dev,struct tc_block_offload *f) -{ -struct netdevsim *ns =netdev_priv (dev); - -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, nsim_setup_tc_block_cb, - ns, ns, f->extack); -case TC_BLOCK_UNBIND : -tcf_block_cb_unregister (f->block, nsim_setup_tc_block_cb, ns); -return 0 ; -default : -return -EOPNOTSUPP ; - } -} -static int nsim_set_vf_mac (struct net_device *dev,int vf,u8 *mac) {struct netdevsim *ns =netdev_priv (dev);
@@ -226,9 +206,13 @@ static int nsim_set_vf_link_state(struct net_device *dev, int vf, int state)static int nsim_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) { +struct netdevsim *ns =netdev_priv (dev); +switch (type) {case TC_SETUP_BLOCK : -return nsim_setup_tc_block (dev, type_data); +return flow_block_cb_setup_simple (type_data,NULL , + nsim_setup_tc_block_cb, + ns, ns, true);default :return -EOPNOTSUPP ; }
include/net/flow_offload.h +27 -0
@@ -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;
@@ -232,4 +233,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 */
include/net/pkt_cls.h +3 -17
@@ -26,11 +26,9 @@ struct tcf_walker {int register_tcf_proto_ops (struct tcf_proto_ops *ops);int unregister_tcf_proto_ops (struct tcf_proto_ops *ops); -enum tcf_block_binder_type { -TCF_BLOCK_BINDER_TYPE_UNSPEC , -TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS , -TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS , -}; +#define tc_block_offload flow_block_offload +#define tc_block_command flow_block_command +#define tcf_block_binder_type flow_block_binder_typestruct tcf_block_ext_info {enum tcf_block_binder_type binder_type;
@@ -610,18 +608,6 @@ int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, void *type_data, bool err_stop);unsigned int tcf_exts_num_actions (struct tcf_exts *exts); -enum tc_block_command { -TC_BLOCK_BIND , -TC_BLOCK_UNBIND , -}; - -struct tc_block_offload { -enum tc_block_command command; -enum tcf_block_binder_type binder_type; -struct tcf_block *block; -struct netlink_ext_ack *extack; -}; -struct tc_cls_common_offload {u32 chain_index;__be16 protocol;
net/core/flow_offload.c +25 -0
@@ -2,6 +2,7 @@#include <linux/kernel.h> #include <linux/slab.h> #include <net/flow_offload.h> +#include <net/pkt_cls.h> struct flow_rule *flow_rule_alloc (unsigned int num_actions) {
@@ -164,3 +165,27 @@ void flow_rule_match_enc_opts(const struct flow_rule *rule,FLOW_DISSECTOR_MATCH (rule,FLOW_DISSECTOR_KEY_ENC_OPTS , out); }EXPORT_SYMBOL (flow_rule_match_enc_opts); + +int flow_block_cb_setup_simple (struct flow_block_offload *f, +struct list_head *driver_block_list, +tc_setup_cb_t *cb,void *cb_ident,void *cb_priv, +bool ingress_only) +{ +if (ingress_only && + f->binder_type !=TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) +return -EOPNOTSUPP ; + + f->driver_block_list = driver_block_list; + +switch (f->command) { +case TC_BLOCK_BIND : +return tcf_block_cb_register (f->block, cb, cb_ident, cb_priv, + f->extack); +case TC_BLOCK_UNBIND : +tcf_block_cb_unregister (f->block, cb, cb_ident); +return 0 ; +default : +return -EOPNOTSUPP ; + } +} +EXPORT_SYMBOL (flow_block_cb_setup_simple);
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v4 2/12 net: flow_offload: rename TC_BLOCK_{UN}BIND to FLOW_BLOCK_{UN}BIND
In reply to Pablo Neira AyusoRename from TC_BLOCK_{UN}BIND to FLOW_BLOCK_{UN}BIND and remove temporary tc_block_command alias.
---
v4: no changes.
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 4 ++-- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 ++-- drivers/net/ethernet/mscc/ocelot_tc.c | 4 ++-- .../net/ethernet/netronome/nfp/flower/offload.c | 8 ++++---- include/net/flow_offload.h | 4 ++-- include/net/pkt_cls.h | 1 - net/core/flow_offload.c | 4 ++-- net/dsa/slave.c | 4 ++-- net/sched/cls_api.c | 22 +++++++++++----------- 9 files changed, 27 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -2
@@ -704,7 +704,7 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,return -EOPNOTSUPP ;switch (f->command) { -case TC_BLOCK_BIND : +case FLOW_BLOCK_BIND : indr_priv =mlx5e_rep_indr_block_priv_lookup (rpriv, netdev);if (indr_priv)return -EEXIST ;
@@ -727,7 +727,7 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev, }return err; -case TC_BLOCK_UNBIND : +case FLOW_BLOCK_UNBIND : indr_priv =mlx5e_rep_indr_block_priv_lookup (rpriv, netdev);if (!indr_priv)return -ENOENT ;
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2 -2
@@ -1679,7 +1679,7 @@ static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port, }switch (f->command) { -case TC_BLOCK_BIND : +case FLOW_BLOCK_BIND : err =tcf_block_cb_register (f->block, cb, mlxsw_sp_port, mlxsw_sp_port, f->extack);if (err)
@@ -1692,7 +1692,7 @@ static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,return err; }return 0 ; -case TC_BLOCK_UNBIND : +case FLOW_BLOCK_UNBIND :mlxsw_sp_setup_tc_block_flower_unbind (mlxsw_sp_port, f->block, ingress);tcf_block_cb_unregister (f->block, cb, mlxsw_sp_port);
drivers/net/ethernet/mscc/ocelot_tc.c +2 -2
@@ -147,14 +147,14 @@ static int ocelot_setup_tc_block(struct ocelot_port *port, }switch (f->command) { -case TC_BLOCK_BIND : +case FLOW_BLOCK_BIND : ret =tcf_block_cb_register (f->block, cb, port, port, f->extack);if (ret)return ret;return ocelot_setup_tc_block_flower_bind (port, f); -case TC_BLOCK_UNBIND : +case FLOW_BLOCK_UNBIND :ocelot_setup_tc_block_flower_unbind (port, f);tcf_block_cb_unregister (f->block, cb, port);return 0 ;
drivers/net/ethernet/netronome/nfp/flower/offload.c +4 -4
@@ -1315,11 +1315,11 @@ static int nfp_flower_setup_tc_block(struct net_device *netdev, repr_priv->block_shared =tcf_block_shared (f->block);switch (f->command) { -case TC_BLOCK_BIND : +case FLOW_BLOCK_BIND :return tcf_block_cb_register (f->block, nfp_flower_setup_tc_block_cb, repr, repr, f->extack); -case TC_BLOCK_UNBIND : +case FLOW_BLOCK_UNBIND :tcf_block_cb_unregister (f->block, nfp_flower_setup_tc_block_cb, repr);
@@ -1395,7 +1395,7 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app,return -EOPNOTSUPP ;switch (f->command) { -case TC_BLOCK_BIND : +case FLOW_BLOCK_BIND : cb_priv =kmalloc (sizeof (*cb_priv),GFP_KERNEL );if (!cb_priv)return -ENOMEM ;
@@ -1413,7 +1413,7 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app, }return err; -case TC_BLOCK_UNBIND : +case FLOW_BLOCK_UNBIND : cb_priv =nfp_flower_indr_block_cb_priv_lookup (app, netdev);if (!cb_priv)return -ENOENT ;
include/net/flow_offload.h +2 -2
@@ -234,8 +234,8 @@ static inline void flow_stats_update(struct flow_stats *flow_stats, }enum flow_block_command { -TC_BLOCK_BIND , -TC_BLOCK_UNBIND , +FLOW_BLOCK_BIND , +FLOW_BLOCK_UNBIND , };enum flow_block_binder_type {
include/net/pkt_cls.h +0 -1
@@ -27,7 +27,6 @@ int register_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 -#define tc_block_command flow_block_command#define tcf_block_binder_type flow_block_binder_typestruct tcf_block_ext_info {
net/core/flow_offload.c +2 -2
@@ -178,10 +178,10 @@ int flow_block_cb_setup_simple(struct flow_block_offload *f, f->driver_block_list = driver_block_list;switch (f->command) { -case TC_BLOCK_BIND : +case FLOW_BLOCK_BIND :return tcf_block_cb_register (f->block, cb, cb_ident, cb_priv, f->extack); -case TC_BLOCK_UNBIND : +case FLOW_BLOCK_UNBIND :tcf_block_cb_unregister (f->block, cb, cb_ident);return 0 ;default :
net/dsa/slave.c +2 -2
@@ -955,9 +955,9 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,return -EOPNOTSUPP ;switch (f->command) { -case TC_BLOCK_BIND : +case FLOW_BLOCK_BIND :return tcf_block_cb_register (f->block, cb, dev, dev, f->extack); -case TC_BLOCK_UNBIND : +case FLOW_BLOCK_UNBIND :tcf_block_cb_unregister (f->block, cb, dev);return 0 ;default :
net/sched/cls_api.c +11 -11
@@ -674,7 +674,7 @@ static void tc_indr_block_cb_del(struct tc_indr_block_cb *indr_block_cb)static void tc_indr_block_ing_cmd (struct tc_indr_block_dev *indr_dev,struct tc_indr_block_cb *indr_block_cb, -enum tc_block_command command) +enum flow_block_command command) {struct tc_block_offload bo = { .command = command,
@@ -705,7 +705,7 @@ int __tc_indr_block_cb_register(struct net_device *dev, void *cb_priv,if (err) goto err_dev_put; -tc_indr_block_ing_cmd (indr_dev, indr_block_cb,TC_BLOCK_BIND ); +tc_indr_block_ing_cmd (indr_dev, indr_block_cb,FLOW_BLOCK_BIND );return 0 ; err_dev_put:
@@ -742,7 +742,7 @@ void __tc_indr_block_cb_unregister(struct net_device *dev,return ;/* Send unbind message if required to free any block cbs. */ -tc_indr_block_ing_cmd (indr_dev, indr_block_cb,TC_BLOCK_UNBIND ); +tc_indr_block_ing_cmd (indr_dev, indr_block_cb,FLOW_BLOCK_UNBIND );tc_indr_block_cb_del (indr_block_cb);tc_indr_block_dev_put (indr_dev); }
@@ -759,7 +759,7 @@ EXPORT_SYMBOL_GPL(tc_indr_block_cb_unregister);static void tc_indr_block_call (struct tcf_block *block,struct net_device *dev,struct tcf_block_ext_info *ei, -enum tc_block_command command, +enum flow_block_command command,struct netlink_ext_ack *extack) {struct tc_indr_block_cb *indr_block_cb;
@@ -775,7 +775,7 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,if (!indr_dev)return ; - indr_dev->block = command ==TC_BLOCK_BIND ? block :NULL ; + indr_dev->block = command ==FLOW_BLOCK_BIND ? block :NULL ;list_for_each_entry (indr_block_cb, &indr_dev->cb_list, list) indr_block_cb->cb(dev, indr_block_cb->cb_priv, TC_SETUP_BLOCK,
@@ -790,7 +790,7 @@ static bool tcf_block_offload_in_use(struct tcf_block *block)static int tcf_block_offload_cmd (struct tcf_block *block,struct net_device *dev,struct tcf_block_ext_info *ei, -enum tc_block_command command, +enum flow_block_command command,struct netlink_ext_ack *extack) {struct tc_block_offload bo = {};
@@ -820,20 +820,20 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,return -EOPNOTSUPP ; } - err =tcf_block_offload_cmd (block, dev, ei,TC_BLOCK_BIND , extack); + err =tcf_block_offload_cmd (block, dev, ei,FLOW_BLOCK_BIND , extack);if (err == -EOPNOTSUPP ) goto no_offload_dev_inc;if (err)return err; -tc_indr_block_call (block, dev, ei,TC_BLOCK_BIND , extack); +tc_indr_block_call (block, dev, ei,FLOW_BLOCK_BIND , extack);return 0 ; no_offload_dev_inc:if (tcf_block_offload_in_use (block))return -EOPNOTSUPP ; block->nooffloaddevcnt++; -tc_indr_block_call (block, dev, ei,TC_BLOCK_BIND , extack); +tc_indr_block_call (block, dev, ei,FLOW_BLOCK_BIND , extack);return 0 ; }
@@ -843,11 +843,11 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,struct net_device *dev = q->dev_queue->dev;int err; -tc_indr_block_call (block, dev, ei,TC_BLOCK_UNBIND ,NULL ); +tc_indr_block_call (block, dev, ei,FLOW_BLOCK_UNBIND ,NULL );if (!dev->netdev_ops->ndo_setup_tc) goto no_offload_dev_dec; - err =tcf_block_offload_cmd (block, dev, ei,TC_BLOCK_UNBIND ,NULL ); + err =tcf_block_offload_cmd (block, dev, ei,FLOW_BLOCK_UNBIND ,NULL );if (err == -EOPNOTSUPP ) goto no_offload_dev_dec;return ;
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v4 3/12 net: flow_offload: rename TCF_BLOCK_BINDER_TYPE_* to FLOW_BLOCK_BINDER_TYPE_*
In reply to Pablo Neira AyusoRename from TCF_BLOCK_BINDER_TYPE_* to FLOW_BLOCK_BINDER_TYPE_* and remove temporary tcf_block_binder_type alias.
---
v4: no changes.
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 ++-- drivers/net/ethernet/mscc/ocelot_flower.c | 2 +- drivers/net/ethernet/mscc/ocelot_tc.c | 4 ++-- drivers/net/ethernet/netronome/nfp/flower/offload.c | 6 +++--- include/net/flow_offload.h | 6 +++--- include/net/pkt_cls.h | 3 +-- net/core/flow_offload.c | 2 +- net/dsa/slave.c | 4 ++-- net/sched/cls_api.c | 14 +++++++------- net/sched/sch_ingress.c | 6 +++--- 11 files changed, 26 insertions(+), 27 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -1
@@ -700,7 +700,7 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,struct mlx5e_rep_indr_block_priv *indr_priv;int err =0 ; -if (f->binder_type !=TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) +if (f->binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS )return -EOPNOTSUPP ;switch (f->command) {
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2 -2
@@ -1668,10 +1668,10 @@ static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,bool ingress;int err; -if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) { +if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) { cb = mlxsw_sp_setup_tc_block_cb_matchall_ig; ingress = true; - }else if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) { + }else if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) { cb = mlxsw_sp_setup_tc_block_cb_matchall_eg; ingress = false; }else {
drivers/net/ethernet/mscc/ocelot_flower.c +1 -1
@@ -306,7 +306,7 @@ int ocelot_setup_tc_block_flower_bind(struct ocelot_port *port,struct tcf_block_cb *block_cb;int ret; -if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) +if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS )return -EOPNOTSUPP ; block_cb = tcf_block_cb_lookup(f->block,
drivers/net/ethernet/mscc/ocelot_tc.c +2 -2
@@ -137,10 +137,10 @@ static int ocelot_setup_tc_block(struct ocelot_port *port,netdev_dbg (port->dev,"tc_block command %d, binder_type %d\n" , f->command, f->binder_type); -if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) { +if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) { cb = ocelot_setup_tc_block_cb_ig; port->tc.block_shared =tcf_block_shared (f->block); - }else if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) { + }else if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) { cb = ocelot_setup_tc_block_cb_eg; }else {return -EOPNOTSUPP ;
drivers/net/ethernet/netronome/nfp/flower/offload.c +3 -3
@@ -1308,7 +1308,7 @@ static int nfp_flower_setup_tc_block(struct net_device *netdev,struct nfp_repr *repr =netdev_priv (netdev);struct nfp_flower_repr_priv *repr_priv; -if (f->binder_type !=TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) +if (f->binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS )return -EOPNOTSUPP ; repr_priv = repr->app_priv;
@@ -1389,8 +1389,8 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app,struct nfp_flower_priv *priv = app->priv;int err; -if (f->binder_type !=TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS && - !(f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS && +if (f->binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS && + !(f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS &&nfp_flower_internal_port_can_offload (app, netdev)))return -EOPNOTSUPP ;
include/net/flow_offload.h +3 -3
@@ -239,9 +239,9 @@ enum flow_block_command { };enum flow_block_binder_type { -TCF_BLOCK_BINDER_TYPE_UNSPEC , -TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS , -TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS , +FLOW_BLOCK_BINDER_TYPE_UNSPEC , +FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS , +FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS , };struct tcf_block ;
include/net/pkt_cls.h +1 -2
@@ -27,10 +27,9 @@ int register_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 -#define tcf_block_binder_type flow_block_binder_typestruct tcf_block_ext_info { -enum tcf_block_binder_type binder_type; +enum flow_block_binder_type binder_type;tcf_chain_head_change_t *chain_head_change;void *chain_head_change_priv;u32 block_index;
net/core/flow_offload.c +1 -1
@@ -172,7 +172,7 @@ int flow_block_cb_setup_simple(struct flow_block_offload *f, bool ingress_only) {if (ingress_only && - f->binder_type !=TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) + f->binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS )return -EOPNOTSUPP ; f->driver_block_list = driver_block_list;
net/dsa/slave.c +2 -2
@@ -947,9 +947,9 @@ static int dsa_slave_setup_tc_block(struct net_device *dev, {tc_setup_cb_t *cb; -if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) +if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) cb = dsa_slave_setup_tc_block_cb_ig; -else if (f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) +else if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) cb = dsa_slave_setup_tc_block_cb_eg;else return -EOPNOTSUPP ;
net/sched/cls_api.c +7 -7
@@ -678,7 +678,7 @@ static void tc_indr_block_ing_cmd(struct tc_indr_block_dev *indr_dev, {struct tc_block_offload bo = { .command = command, - .binder_type =TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS , + .binder_type =FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS , .block = indr_dev->block, };
@@ -1340,17 +1340,17 @@ static void tcf_block_release(struct Qdisc *q, struct tcf_block *block,struct tcf_block_owner_item {struct list_head list;struct Qdisc *q; -enum tcf_block_binder_type binder_type; +enum flow_block_binder_type binder_type; };static void tcf_block_owner_netif_keep_dst (struct tcf_block *block,struct Qdisc *q, -enum tcf_block_binder_type binder_type) +enum flow_block_binder_type binder_type) {if (block->keep_dst && - binder_type !=TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS && - binder_type !=TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) + binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS && + binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS )netif_keep_dst (qdisc_dev (q)); }
@@ -1367,7 +1367,7 @@ EXPORT_SYMBOL(tcf_block_netif_keep_dst);static int tcf_block_owner_add (struct tcf_block *block,struct Qdisc *q, -enum tcf_block_binder_type binder_type) +enum flow_block_binder_type binder_type) {struct tcf_block_owner_item *item;
@@ -1382,7 +1382,7 @@ static int tcf_block_owner_add(struct tcf_block *block,static void tcf_block_owner_del (struct tcf_block *block,struct Qdisc *q, -enum tcf_block_binder_type binder_type) +enum flow_block_binder_type binder_type) {struct tcf_block_owner_item *item;
net/sched/sch_ingress.c +3 -3
@@ -83,7 +83,7 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt,mini_qdisc_pair_init (&q->miniqp, sch, &dev->miniq_ingress); - q->block_info.binder_type =TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ; + q->block_info.binder_type =FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ; q->block_info.chain_head_change = clsact_chain_head_change; q->block_info.chain_head_change_priv = &q->miniqp;
@@ -217,7 +217,7 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,mini_qdisc_pair_init (&q->miniqp_ingress, sch, &dev->miniq_ingress); - q->ingress_block_info.binder_type =TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ; + q->ingress_block_info.binder_type =FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ; q->ingress_block_info.chain_head_change = clsact_chain_head_change; q->ingress_block_info.chain_head_change_priv = &q->miniqp_ingress;
@@ -228,7 +228,7 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,mini_qdisc_pair_init (&q->miniqp_egress, sch, &dev->miniq_egress); - q->egress_block_info.binder_type =TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS ; + q->egress_block_info.binder_type =FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS ; q->egress_block_info.chain_head_change = clsact_chain_head_change; q->egress_block_info.chain_head_change_priv = &q->miniqp_egress;
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v4 4/12 net: flow_offload: add flow_block_cb_alloc() and flow_block_cb_free()
In reply to Pablo Neira AyusoAdd a new helper function to allocate flow_block_cb objects.
---
v4: no changes.
include/net/flow_offload.h | 14 ++++++++++++++ net/core/flow_offload.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)
include/net/flow_offload.h +14 -0
@@ -255,6 +255,20 @@ struct flow_block_offload {struct netlink_ext_ack *extack; }; +struct flow_block_cb { +struct list_head list; +tc_setup_cb_t *cb; +void *cb_ident; +void *cb_priv; +void (*release)(void *cb_priv); +unsigned int refcnt; +}; + +struct flow_block_cb *flow_block_cb_alloc (struct net *net,tc_setup_cb_t *cb, +void *cb_ident,void *cb_priv, +void (*release)(void *cb_priv)); +void flow_block_cb_free (struct flow_block_cb *block_cb); +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);
net/core/flow_offload.c +28 -0
@@ -166,6 +166,34 @@ void flow_rule_match_enc_opts(const struct flow_rule *rule, }EXPORT_SYMBOL (flow_rule_match_enc_opts); +struct flow_block_cb *flow_block_cb_alloc (struct net *net,tc_setup_cb_t *cb, +void *cb_ident,void *cb_priv, +void (*release)(void *cb_priv)) +{ +struct flow_block_cb *block_cb; + + block_cb =kzalloc (sizeof (*block_cb),GFP_KERNEL ); +if (!block_cb) +return ERR_PTR (-ENOMEM ); + + block_cb->cb = cb; + block_cb->cb_ident = cb_ident; + block_cb->cb_priv = cb_priv; + block_cb->release = release; + +return block_cb; +} +EXPORT_SYMBOL (flow_block_cb_alloc); + +void flow_block_cb_free (struct flow_block_cb *block_cb) +{ +if (block_cb->release) + block_cb->release (block_cb->cb_priv); + +kfree (block_cb); +} +EXPORT_SYMBOL (flow_block_cb_free); + int flow_block_cb_setup_simple(struct flow_block_offload *f, struct list_head *driver_block_list, tc_setup_cb_t *cb, void *cb_ident, void *cb_priv,
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v4 5/12 net: flow_offload: add list handling functions
In reply to Pablo Neira AyusoThis patch adds the list handling functions for the flow block API:
* flow_block_cb_lookup() allows drivers to look up for existing flow blocks.
* flow_block_cb_add() adds a flow block to the per driver list to be registered by the core.
* flow_block_cb_remove() to remove a flow block from the list of existing flow blocks per driver and to request the core to unregister this.
The flow block API also annotates the netns this flow block belongs to.
---
v4: missing "per driver" reference in flow_block_cb_add() description - Jiri Pirko.
Move per-driver list to struct flow_block_offload - Jiri Pirko.
include/net/flow_offload.h | 19 +++++++++++++++++++ net/core/flow_offload.c | 17 +++++++++++++++++ net/sched/cls_api.c | 3 +++ 3 files changed, 39 insertions(+)
include/net/flow_offload.h +19 -0
@@ -251,12 +251,16 @@ struct flow_block_offload {enum flow_block_command command;enum flow_block_binder_type binder_type;struct tcf_block *block; +struct net *net; +struct list_head cb_list;struct list_head *driver_block_list;struct netlink_ext_ack *extack; };struct flow_block_cb { +struct list_head driver_list;struct list_head list; +struct net *net;tc_setup_cb_t *cb;void *cb_ident;void *cb_priv;
@@ -269,6 +273,21 @@ struct flow_block_cb *flow_block_cb_alloc(struct net *net, tc_setup_cb_t *cb, void (*release)(void *cb_priv));void flow_block_cb_free (struct flow_block_cb *block_cb); +struct flow_block_cb *flow_block_cb_lookup (struct flow_block_offload *offload, +tc_setup_cb_t *cb,void *cb_ident); + +static inline void flow_block_cb_add (struct flow_block_cb *block_cb, +struct flow_block_offload *offload) +{ +list_add_tail (&block_cb->list, &offload->cb_list); +} + +static inline void flow_block_cb_remove (struct flow_block_cb *block_cb, +struct flow_block_offload *offload) +{ +list_move (&block_cb->list, &offload->cb_list); +} +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);
net/core/flow_offload.c +17 -0
@@ -176,6 +176,7 @@ struct flow_block_cb *flow_block_cb_alloc(struct net *net, tc_setup_cb_t *cb,if (!block_cb)return ERR_PTR (-ENOMEM ); + block_cb->net = net; block_cb->cb = cb; block_cb->cb_ident = cb_ident; block_cb->cb_priv = cb_priv;
@@ -194,6 +195,22 @@ void flow_block_cb_free(struct flow_block_cb *block_cb) }EXPORT_SYMBOL (flow_block_cb_free); +struct flow_block_cb *flow_block_cb_lookup (struct flow_block_offload *f, +tc_setup_cb_t *cb,void *cb_ident) +{ +struct flow_block_cb *block_cb; + +list_for_each_entry (block_cb, f->driver_block_list, driver_list) { +if (block_cb->net == f->net && + block_cb->cb == cb && + block_cb->cb_ident == cb_ident) +return block_cb; + } + +return NULL ; +} +EXPORT_SYMBOL (flow_block_cb_lookup); + int flow_block_cb_setup_simple(struct flow_block_offload *f, struct list_head *driver_block_list, tc_setup_cb_t *cb, void *cb_ident, void *cb_priv,
net/sched/cls_api.c +3 -0
@@ -679,6 +679,7 @@ static void tc_indr_block_ing_cmd(struct tc_indr_block_dev *indr_dev,struct tc_block_offload bo = { .command = command, .binder_type =FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS , + .net =dev_net (indr_dev->dev), .block = indr_dev->block, };
@@ -767,6 +768,7 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,struct tc_block_offload bo = { .command = command, .binder_type = ei->binder_type, + .net =dev_net (dev), .block = block, .extack = extack, };
@@ -795,6 +797,7 @@ static int tcf_block_offload_cmd(struct tcf_block *block, {struct tc_block_offload bo = {}; + bo.net =dev_net (dev); bo.command = command; bo.binder_type = ei->binder_type; bo.block = block;
Signature · 1 line
2.11.0
Jiri Pirko
maintainerRe: [PATCH net-next,v4 05/12] net: flow_offload: add list handling functions
Tue, Jul 09, 2019 at 10:55:43PM CEST, [email protected] wrote:
[...]
Quoted 9 lines
net/core/flow_offload.c +1
-0@@ -176,6 +176,7 @@ struct flow_block_cb *flow_block_cb_alloc(struct net *net, tc_setup_cb_t *cb,if (!block_cb)return ERR_PTR (-ENOMEM ); + block_cb->net = net; block_cb->cb = cb; block_cb->cb_ident = cb_ident; block_cb->cb_priv = cb_priv;
net/core/flow_offload.c void flow_block_cb_free(struct flow_block_cb *block_cb) · line 204
Quoted 10 lines
net/core/flow_offload.c +7
-0@@ -194,6 +195,22 @@ void flow_block_cb_free(struct flow_block_cb *block_cb) }EXPORT_SYMBOL (flow_block_cb_free); +struct flow_block_cb *flow_block_cb_lookup (struct flow_block_offload *f, +tc_setup_cb_t *cb,void *cb_ident) +{ +struct flow_block_cb *block_cb; + +list_for_each_entry (block_cb, f->driver_block_list, driver_list) { + if (block_cb->net == f->net &&
I don't understand why you need net for this. You should have a list of cbs per subsystem (tc/nft) go over it here.
The clash of 2 suybsytems is prevented later on by flow_block_cb_is_busy().
Am I missing something?
If not, could you please remove use of net from flow_block_cb_alloc() and from here and replace it by some shared flow structure holding the cb list that would be used by both tc and nft?
Quoted 9 lines
net/core/flow_offload.c +9
-0+ block_cb->cb == cb && + block_cb->cb_ident == cb_ident) +return block_cb; + } + +return NULL ; +} +EXPORT_SYMBOL (flow_block_cb_lookup); +
[...]
Jiri Pirko
maintainerRe: [PATCH net-next,v4 05/12] net: flow_offload: add list handling functions
Quoted 17 lines · Wed, Jul 10, 2019 at 09:36:52AM CEST, [email protected] wrote:
Tue, Jul 09, 2019 at 10:55:43PM CEST, [email protected] wrote:
[...]
Quoted 12 lines
net/core/flow_offload.c +1
-0@@ -176,6 +176,7 @@ struct flow_block_cb *flow_block_cb_alloc(struct net *net, tc_setup_cb_t *cb,if (!block_cb)return ERR_PTR (-ENOMEM ); + block_cb->net = net; block_cb->cb = cb; block_cb->cb_ident = cb_ident; block_cb->cb_priv = cb_priv;@@ -194,6 +195,22 @@ void flow_block_cb_free(struct flow_block_cb *block_cb) }EXPORT_SYMBOL (flow_block_cb_free);
Quoted 7 lines
net/core/flow_offload.c void flow_block_cb_free(struct flow_block_cb *block_cb) · line 204
Quoted 7 lines
net/core/flow_offload.c +7
-0+struct flow_block_cb *flow_block_cb_lookup (struct flow_block_offload *f, +tc_setup_cb_t *cb,void *cb_ident) +{ +struct flow_block_cb *block_cb; + +list_for_each_entry (block_cb, f->driver_block_list, driver_list) { + if (block_cb->net == f->net &&
Looking at this a bit more, this is wrong. This breaks block sharing concept. The original lookup look up the block_cb in certain block - the block to be shared. With this, you broke the block sharing feature for mlxsw.
We need to maintain the existing block concept (changed to flow_block).
Quoted 25 lines
I don't understand why you need net for this. You should have a list of cbs per subsystem (tc/nft) go over it here.
The clash of 2 suybsytems is prevented later on by
flow_block_cb_is_busy().Am I missing something?
If not, could you please remove use of net fromflow_block_cb_alloc()and from here and replace it by some shared flow structure holding the cb list that would be used by both tc and nft?Quoted 9 lines
net/core/flow_offload.c +9
-0+ block_cb->cb == cb && + block_cb->cb_ident == cb_ident) +return block_cb; + } + +return NULL ; +} +EXPORT_SYMBOL (flow_block_cb_lookup); +[...]
Pablo Neira Ayuso
maintainerPATCH v4 6/12 net: flow_offload: add flow_block_cb_{priv,incref,decref}()
In reply to Pablo Neira AyusoThis patch completes the flow block API to introduce:
* flow_block_cb_priv() to access callback private data.
* flow_block_cb_incref() to bump reference counter on this flow block.
* flow_block_cb_decref() to decrement the reference counter.
These functions are taken from the existing tcf_block_cb_priv(), tcf_block_cb_incref() and tcf_block_cb_decref().
---
v6: fix typo in commit message - Jiri Pirko.
include/net/flow_offload.h | 4 ++++ net/core/flow_offload.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+)
include/net/flow_offload.h +4 -0
@@ -276,6 +276,10 @@ void flow_block_cb_free(struct flow_block_cb *block_cb);struct flow_block_cb *flow_block_cb_lookup (struct flow_block_offload *offload,tc_setup_cb_t *cb,void *cb_ident); +void *flow_block_cb_priv (struct flow_block_cb *block_cb); +void flow_block_cb_incref (struct flow_block_cb *block_cb); +unsigned int flow_block_cb_decref (struct flow_block_cb *block_cb); +static inline void flow_block_cb_add (struct flow_block_cb *block_cb,struct flow_block_offload *offload) {
net/core/flow_offload.c +18 -0
@@ -211,6 +211,24 @@ struct flow_block_cb *flow_block_cb_lookup(struct flow_block_offload *f, }EXPORT_SYMBOL (flow_block_cb_lookup); +void *flow_block_cb_priv (struct flow_block_cb *block_cb) +{ +return block_cb->cb_priv; +} +EXPORT_SYMBOL (flow_block_cb_priv); + +void flow_block_cb_incref (struct flow_block_cb *block_cb) +{ + block_cb->refcnt++; +} +EXPORT_SYMBOL (flow_block_cb_incref); + +unsigned int flow_block_cb_decref (struct flow_block_cb *block_cb) +{ +return --block_cb->refcnt; +} +EXPORT_SYMBOL (flow_block_cb_decref); + int flow_block_cb_setup_simple(struct flow_block_offload *f, struct list_head *driver_block_list, tc_setup_cb_t *cb, void *cb_ident, void *cb_priv,
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v4 7/12 net: sched: use flow block API
In reply to Pablo Neira AyusoThis patch adds tcf_block_setup() which uses the flow block API.
This infrastructure takes the flow block callbacks coming from the driver and register/unregister to/from the cls_api core.
---
v4: Remove driver_list handling from the core - Jiri Pirko.
net/sched/cls_api.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-)
net/sched/cls_api.c +87 -1
@@ -672,6 +672,9 @@ static void tc_indr_block_cb_del(struct tc_indr_block_cb *indr_block_cb)kfree (indr_block_cb); } +static int tcf_block_setup (struct tcf_block *block, +struct flow_block_offload *bo); +static void tc_indr_block_ing_cmd (struct tc_indr_block_dev *indr_dev,struct tc_indr_block_cb *indr_block_cb,enum flow_block_command command)
@@ -682,12 +685,14 @@ static void tc_indr_block_ing_cmd(struct tc_indr_block_dev *indr_dev, .net = dev_net(indr_dev->dev), .block = indr_dev->block, }; +INIT_LIST_HEAD (&bo.cb_list);if (!indr_dev->block)return ; indr_block_cb->cb (indr_dev->dev, indr_block_cb->cb_priv,TC_SETUP_BLOCK , &bo); +tcf_block_setup (indr_dev->block, &bo); } int __tc_indr_block_cb_register(struct net_device *dev, void *cb_priv,
@@ -772,6 +777,7 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev, .block = block, .extack = extack, }; +INIT_LIST_HEAD (&bo.cb_list); indr_dev =tc_indr_block_dev_lookup (dev);if (!indr_dev)
@@ -782,6 +788,8 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,list_for_each_entry (indr_block_cb, &indr_dev->cb_list, list) indr_block_cb->cb (dev, indr_block_cb->cb_priv,TC_SETUP_BLOCK , &bo); + +tcf_block_setup (block, &bo); }static bool tcf_block_offload_in_use (struct tcf_block *block)
@@ -796,13 +804,20 @@ static int tcf_block_offload_cmd(struct tcf_block *block, struct netlink_ext_ack *extack) {struct tc_block_offload bo = {}; +int err; bo.net =dev_net (dev); bo.command = command; bo.binder_type = ei->binder_type; bo.block = block; bo.extack = extack; -return dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_BLOCK , &bo); +INIT_LIST_HEAD (&bo.cb_list); + + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_BLOCK , &bo); +if (err <0 ) +return err; + +return tcf_block_setup (block, &bo); } static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,
@@ -1636,6 +1651,77 @@ void tcf_block_cb_unregister(struct tcf_block *block, }EXPORT_SYMBOL (tcf_block_cb_unregister); +static int tcf_block_bind (struct tcf_block *block, +struct flow_block_offload *bo) +{ +struct flow_block_cb *block_cb, *next; +int err, i =0 ; + +list_for_each_entry (block_cb, &bo->cb_list, list) { + err =tcf_block_playback_offloads (block, block_cb->cb, + block_cb->cb_priv, true, +tcf_block_offload_in_use (block), + bo->extack); +if (err) + goto err_unroll; + + i++; + } +list_splice (&bo->cb_list, &block->cb_list); + +return 0 ; + +err_unroll: +list_for_each_entry_safe (block_cb, next, &bo->cb_list, list) { +if (i-- >0 ) { +list_del (&block_cb->list); +tcf_block_playback_offloads (block, block_cb->cb, + block_cb->cb_priv, false, +tcf_block_offload_in_use (block), +NULL ); + } +flow_block_cb_free (block_cb); + } + +return err; +} + +static void tcf_block_unbind (struct tcf_block *block, +struct flow_block_offload *bo) +{ +struct flow_block_cb *block_cb, *next; + +list_for_each_entry_safe (block_cb, next, &bo->cb_list, list) { +tcf_block_playback_offloads (block, block_cb->cb, + block_cb->cb_priv, false, +tcf_block_offload_in_use (block), +NULL ); +list_del (&block_cb->list); +flow_block_cb_free (block_cb); + } +} + +static int tcf_block_setup (struct tcf_block *block, +struct flow_block_offload *bo) +{ +int err; + +switch (bo->command) { +case FLOW_BLOCK_BIND : + err =tcf_block_bind (block, bo); +break ; +case FLOW_BLOCK_UNBIND : + err =0 ; +tcf_block_unbind (block, bo); +break ; +default : +WARN_ON_ONCE (1 ); + err = -EOPNOTSUPP ; + } + +return err; +} +/* Main classifier routine: scans classifier chain attached * to this qdisc, (optionally) tests for protocol and asks * specific classifiers.
Signature · 1 line
2.11.0
Re: [PATCH net-next,v4 07/12] net: sched: use flow block API
Quoted 58 lines · Pablo Neira Ayuso
This patch adds
tcf_block_setup()which uses the flow block API.This infrastructure takes the flow block callbacks coming from the driver and register/unregister to/from the
cls_apicore.Signed-off-by Pablo Neira Ayuso <[email protected]>---
<snip>net/sched/cls_api.c +32
-1@@ -796,13 +804,20 @@ static int tcf_block_offload_cmd(struct tcf_block *block, struct netlink_ext_ack *extack) {struct tc_block_offload bo = {}; +int err; bo.net =dev_net (dev); bo.command = command; bo.binder_type = ei->binder_type; bo.block = block; bo.extack = extack; -return dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_BLOCK , &bo); +INIT_LIST_HEAD (&bo.cb_list); + + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_BLOCK , &bo); +if (err <0 ) +return err; + +return tcf_block_setup (block, &bo); } static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,@@ -1636,6 +1651,77 @@ void tcf_block_cb_unregister(struct tcf_block *block, }EXPORT_SYMBOL (tcf_block_cb_unregister); +static int tcf_block_bind (struct tcf_block *block, +struct flow_block_offload *bo) +{ +struct flow_block_cb *block_cb, *next; +int err, i =0 ; + +list_for_each_entry (block_cb, &bo->cb_list, list) { + err =tcf_block_playback_offloads (block, block_cb->cb, + block_cb->cb_priv, true, +tcf_block_offload_in_use (block), + bo->extack); +if (err) + goto err_unroll; + + i++; + } +list_splice (&bo->cb_list, &block->cb_list); + +return 0 ; + +err_unroll: +list_for_each_entry_safe (block_cb, next, &bo->cb_list, list) { +if (i-- >0 ) { +list_del (&block_cb->list);
net/sched/cls_api.c void tcf_block_cb_unregister(struct tcf_block *block, · line 1687
Quoted 10 lines
net/sched/cls_api.c +10
-0+tcf_block_playback_offloads (block, block_cb->cb, + block_cb->cb_priv, false, +tcf_block_offload_in_use (block), +NULL ); + } +flow_block_cb_free (block_cb); + } + +return err; +}
Why has the replay been moved from the function called by the driver (__tcf_block_cb_register()) to work done by the driver's caller based on what the driver has left on this flow_block_offload.cb_list? This makes it impossible for the driver to (say) unregister a block outside of an explicit request from ndo_setup_tc().
In my under-development driver, I have a teardown path called on PCI remove, which calls tcf_block_cb_unregister() on all my block bindings (of which the driver keeps track), to ensure that no flow rules are still in place when unregister_netdev() is called; this is needed because some of the driver's state for certain rules involves taking a reference on the netdevice (dev_hold()). Your structural changes here make that impossible; is there any reason why they're necessary?
-Ed
Pablo Neira Ayuso
maintainerRe: [PATCH net-next,v4 07/12] net: sched: use flow block API
Quoted 71 lines · Edward Cree
Quoted 59 lines · Pablo Neira Ayuso
This patch adds
tcf_block_setup()which uses the flow block API.This infrastructure takes the flow block callbacks coming from the driver and register/unregister to/from the
cls_apicore.Signed-off-by Pablo Neira Ayuso <[email protected]>---
<snip>net/sched/cls_api.c +33
-1@@ -796,13 +804,20 @@ static int tcf_block_offload_cmd(struct tcf_block *block, struct netlink_ext_ack *extack) {struct tc_block_offload bo = {}; +int err; bo.net =dev_net (dev); bo.command = command; bo.binder_type = ei->binder_type; bo.block = block; bo.extack = extack; -return dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_BLOCK , &bo); +INIT_LIST_HEAD (&bo.cb_list); + + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_BLOCK , &bo); +if (err <0 ) +return err; + +return tcf_block_setup (block, &bo); } static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,@@ -1636,6 +1651,77 @@ void tcf_block_cb_unregister(struct tcf_block *block, }EXPORT_SYMBOL (tcf_block_cb_unregister); +static int tcf_block_bind (struct tcf_block *block, +struct flow_block_offload *bo) +{ +struct flow_block_cb *block_cb, *next; +int err, i =0 ; + +list_for_each_entry (block_cb, &bo->cb_list, list) { + err =tcf_block_playback_offloads (block, block_cb->cb, + block_cb->cb_priv, true, +tcf_block_offload_in_use (block), + bo->extack); +if (err) + goto err_unroll; + + i++; + } +list_splice (&bo->cb_list, &block->cb_list); + +return 0 ; + +err_unroll: +list_for_each_entry_safe (block_cb, next, &bo->cb_list, list) { +if (i-- >0 ) { +list_del (&block_cb->list); + tcf_block_playback_offloads(block, block_cb->cb,net/sched/cls_api.c void tcf_block_cb_unregister(struct tcf_block *block, · line 1688
Quoted 10 lines
net/sched/cls_api.c +9
-0+ block_cb->cb_priv, false, +tcf_block_offload_in_use (block), + NULL); + } +flow_block_cb_free (block_cb); + } + +return err; +}Why has the replay been moved from the function called by the driver
Quoted 8 lines
(__tcf_block_cb_register()) to work done by the driver's caller based on what the driver has left on this flow_block_offload.cb_list? This makes it impossible for the driver to (say) unregister a block outside of an explicit request from
ndo_setup_tc().
In my under-development driver, I have a teardown path called on PCI remove, which callstcf_block_cb_unregister()on all my block bindings (of which the driver keeps track), to ensure that no flow rules are still in place whenunregister_netdev()is called;
It's the subsystem that has to release resources when unregister_netdev() event happens. At least in netfilter, when the device is going away, the filtering policy is removed, hence the FLOW_BLOCK_UNBIND is called to release the blocks and, hence, the offload resources. I remember tc ingress qdisc works like this too.
Quoted 4 lines
this is needed because some of the driver's state for certain rules involves taking a reference on the netdevice (
dev_hold()). Your structural changes here make that impossible; is there any reason why they're necessary?
May I have access to your driver code?
This would make it easier for me to understand your requirements, and to discuss changes with you.
Pablo Neira Ayuso
maintainerPATCH v4 8/12 drivers: net: use flow block API
In reply to Pablo Neira AyusoThis 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.
---
v4: fix typo in list in nfp driver - Jakub Kicinski.
Move driver_list handling to the driver code, this list is transitional, until drivers are updated to support multiple subsystems. No more driver_list handling from core.
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 5 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 5 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 5 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 5 +- drivers/net/ethernet/intel/igb/igb_main.c | 5 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 5 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 42 +++++++--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 92 ++++++++++++++-------- drivers/net/ethernet/mscc/ocelot_ace.h | 4 +- drivers/net/ethernet/mscc/ocelot_flower.c | 46 ++++++----- drivers/net/ethernet/mscc/ocelot_tc.c | 34 +++++--- drivers/net/ethernet/netronome/nfp/abm/cls.c | 7 +- drivers/net/ethernet/netronome/nfp/abm/main.h | 2 +- drivers/net/ethernet/netronome/nfp/bpf/main.c | 5 +- .../net/ethernet/netronome/nfp/flower/offload.c | 68 +++++++++++----- drivers/net/ethernet/qlogic/qede/qede_main.c | 5 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +- drivers/net/netdevsim/netdev.c | 5 +- include/net/flow_offload.h | 3 +- include/net/pkt_cls.h | 2 - net/core/flow_offload.c | 20 ++++- net/dsa/slave.c | 22 +++++- net/sched/cls_api.c | 14 ++-- 25 files changed, 286 insertions(+), 130 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -1
@@ -9847,6 +9847,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,void *type_data) {
@@ -9854,7 +9856,8 @@ static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,switch (type) {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, bp, bp, true);case TC_SETUP_QDISC_MQPRIO : {
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +4 -1
@@ -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,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) {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, vf_rep, vf_rep, true);default :
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +4 -1
@@ -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,void *type_data) {
@@ -3197,7 +3199,8 @@ static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,switch (type) {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, pi, dev, true);default :
drivers/net/ethernet/intel/i40e/i40e_main.c +4 -1
@@ -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,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 :return i40e_setup_tc (netdev, type_data);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, np, np, true);default :
drivers/net/ethernet/intel/iavf/iavf_main.c +4 -1
@@ -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 * @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 :return __iavf_setup_tc (netdev, type_data);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, adapter, adapter, true);default :
drivers/net/ethernet/intel/igb/igb_main.c +4 -1
@@ -2806,6 +2806,8 @@ static int igb_offload_txtime(struct igb_adapter *adapter,return 0 ; } +static LIST_HEAD (igb_block_cb_list); +static int igb_setup_tc (struct net_device *dev,enum tc_setup_type type,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 :return igb_offload_cbs (adapter, type_data);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, adapter, adapter, true);
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +4 -1
@@ -9614,6 +9614,8 @@ static int ixgbe_setup_tc_mqprio(struct net_device *dev,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,void *type_data) {
@@ -9621,7 +9623,8 @@ static int __ixgbe_setup_tc(struct net_device *dev, enum tc_setup_type type,switch (type) {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, adapter, adapter, true);case TC_SETUP_QDISC_MQPRIO :
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +4 -1
@@ -3459,6 +3459,8 @@ static int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data, }#endif +static LIST_HEAD (mlx5e_block_cb_list); +static int mlx5e_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) {
@@ -3467,7 +3469,8 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,switch (type) {#ifdef CONFIG_MLX5_ESWITCH 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, priv, priv, true);#endif
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +30 -12
73 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +58 -34
161 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_ace.h +2 -2
@@ -225,8 +225,8 @@ int ocelot_ace_init(struct ocelot *ocelot);void ocelot_ace_deinit (void );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, -struct tc_block_offload *f); +struct flow_block_offload *f);#endif /* _MSCC_OCELOT_ACE_H_ */
drivers/net/ethernet/mscc/ocelot_flower.c +26 -20
82 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_tc.c +25 -9
@@ -128,35 +128,51 @@ static int ocelot_setup_tc_block_cb_eg(enum tc_setup_type type, cb_priv, false); } +static LIST_HEAD (ocelot_block_cb_list); +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; -int ret; +int err;netdev_dbg (port->dev,"tc_block command %d, binder_type %d\n" , f->command, f->binder_type);if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) { 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 ) { cb = ocelot_setup_tc_block_cb_eg; }else {return -EOPNOTSUPP ; } + f->driver_block_list = &ocelot_block_cb_list; +switch (f->command) {case FLOW_BLOCK_BIND : - ret =tcf_block_cb_register (f->block, cb, port, - port, f->extack); -if (ret) -return ret; + block_cb =flow_block_cb_alloc (f->net, cb, port, port,NULL ); +if (IS_ERR (block_cb)) +return PTR_ERR (block_cb); -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 : + block_cb =flow_block_cb_lookup (f, cb, port); +if (!block_cb) +return -ENOENT ; +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 ;default :return -EOPNOTSUPP ;
drivers/net/ethernet/netronome/nfp/abm/cls.c +5 -2
@@ -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, -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); }
drivers/net/ethernet/netronome/nfp/abm/main.h +1 -1
@@ -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,struct tc_gred_qopt_offload *opt);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_find_addrs (struct nfp_abm *abm);
drivers/net/ethernet/netronome/nfp/bpf/main.c +4 -1
@@ -160,6 +160,8 @@ static int nfp_bpf_setup_tc_block_cb(enum tc_setup_type type,return 0 ; } +static LIST_HEAD (nfp_bpf_block_cb_list); +static int nfp_bpf_setup_tc (struct nfp_app *app,struct net_device *netdev,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) {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, nn, nn, true);default :
drivers/net/ethernet/netronome/nfp/flower/offload.c +48 -20
114 lines not on this page · raw message
drivers/net/ethernet/qlogic/qede/qede_main.c +4 -1
@@ -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 qede_setup_tc_offload (struct net_device *dev,enum tc_setup_type type,void *type_data)
@@ -588,7 +590,8 @@ qede_setup_tc_offload(struct net_device *dev, enum tc_setup_type type,switch (type) {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, edev, edev, true);case TC_SETUP_QDISC_MQPRIO :
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -1
@@ -3853,6 +3853,8 @@ static int stmmac_setup_tc_block_cb(enum tc_setup_type type, void *type_data,return ret; } +static LIST_HEAD (stmmac_block_cb_list); +static int stmmac_setup_tc (struct net_device *ndev,enum tc_setup_type type,void *type_data) {
@@ -3860,7 +3862,8 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type,switch (type) {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, priv, priv, true);case TC_SETUP_QDISC_CBS :
drivers/net/netdevsim/netdev.c +4 -1
@@ -203,6 +203,8 @@ static int nsim_set_vf_link_state(struct net_device *dev, int vf, int state)return 0 ; } +static LIST_HEAD (nsim_block_cb_list); +static int 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) {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, ns, ns, true);default :
include/net/flow_offload.h +1 -2
@@ -244,13 +244,12 @@ enum flow_block_binder_type { FLOW_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; +bool block_shared;struct net *net;struct list_head cb_list;struct list_head *driver_block_list;
include/net/pkt_cls.h +0 -2
@@ -26,8 +26,6 @@ struct tcf_walker {int register_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 {enum flow_block_binder_type binder_type;tcf_chain_head_change_t *chain_head_change;
net/core/flow_offload.c +16 -4
@@ -2,7 +2,6 @@#include <linux/kernel.h> #include <linux/slab.h> #include <net/flow_offload.h> -#include <net/pkt_cls.h> 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, bool ingress_only) { +struct flow_block_cb *block_cb; +if (ingress_only && f->binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS )return -EOPNOTSUPP ;
@@ -242,10 +243,21 @@ int flow_block_cb_setup_simple(struct flow_block_offload *f,switch (f->command) {case FLOW_BLOCK_BIND : -return tcf_block_cb_register (f->block, cb, cb_ident, cb_priv, - f->extack); + block_cb =flow_block_cb_alloc (f->net, cb, cb_ident, + 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 : -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 ;default :return -EOPNOTSUPP ;
net/dsa/slave.c +19 -3
@@ -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); } +static LIST_HEAD (dsa_slave_block_cb_list); +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;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 return -EOPNOTSUPP ; + f->driver_block_list = &dsa_slave_block_cb_list; +switch (f->command) {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 : -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 ;default :return -EOPNOTSUPP ;
net/sched/cls_api.c +7 -7
@@ -679,11 +679,11 @@ static void tc_indr_block_ing_cmd(struct tc_indr_block_dev *indr_dev,struct tc_indr_block_cb *indr_block_cb, enum flow_block_command command) { - struct tc_block_offload bo = { + struct flow_block_offload bo = { .command = command, .binder_type =FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS , .net =dev_net (indr_dev->dev), - .block = indr_dev->block, + .block_shared =tcf_block_shared (indr_dev->block), };INIT_LIST_HEAD (&bo.cb_list);
@@ -770,11 +770,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_dev *indr_dev; -struct tc_block_offload bo = { +struct flow_block_offload bo = { .command = command, .binder_type = ei->binder_type, .net =dev_net (dev), - .block = block, + .block_shared =tcf_block_shared (block), .extack = extack, };INIT_LIST_HEAD (&bo.cb_list);
@@ -803,13 +803,13 @@ static int tcf_block_offload_cmd(struct tcf_block *block,enum flow_block_command command, struct netlink_ext_ack *extack) { - struct tc_block_offload bo = {}; + struct flow_block_offload bo = {};int err; bo.net =dev_net (dev); bo.command = command; bo.binder_type = ei->binder_type; - bo.block = block; + bo.block_shared =tcf_block_shared (block); bo.extack = extack;INIT_LIST_HEAD (&bo.cb_list);
@@ -3244,7 +3244,7 @@ EXPORT_SYMBOL(tcf_exts_dump_stats);int tc_setup_cb_call (struct tcf_block *block,enum tc_setup_type type,void *type_data,bool err_stop) { -struct tcf_block_cb *block_cb; +struct flow_block_cb *block_cb;int ok_count =0 ;int err;
Signature · 1 line
2.11.0
Jiri Pirko
maintainerRe: [PATCH net-next,v4 08/12] drivers: net: use flow block API
Tue, Jul 09, 2019 at 10:55:46PM CEST, [email protected] wrote:
[...]
Quoted 45 lines
static int
mlxsw_sp_setup_tc_block_flower_bind(structmlxsw_sp_port*mlxsw_sp_port,drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1
-2- struct tcf_block *block, bool ingress, - struct netlink_ext_ack *extack) + struct flow_block_offload *f, bool ingress){ struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; struct mlxsw_sp_acl_block *acl_block;drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2
-1-struct tcf_block_cb *block_cb; +struct flow_block_cb *block_cb; +bool register_block = false;int err;drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2
-2- block_cb =tcf_block_cb_lookup (block, mlxsw_sp_setup_tc_block_cb_flower, - mlxsw_sp); + block_cb =flow_block_cb_lookup (f, mlxsw_sp_setup_tc_block_cb_flower, + mlxsw_sp);if (!block_cb) {drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1
-1- 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) return -ENOMEM;drivers/net/ethernet/mellanox/mlxsw/spectrum.c +4
-3- block_cb =__tcf_block_cb_register (block, - mlxsw_sp_setup_tc_block_cb_flower, - mlxsw_sp, acl_block, extack); + block_cb =flow_block_cb_alloc (f->net, + mlxsw_sp_setup_tc_block_cb_flower, + mlxsw_sp, acl_block, + mlxsw_sp_tc_block_flower_release);if (IS_ERR(block_cb)) {(quoted diff) +1
-0+ mlxsw_sp_acl_block_destroy(acl_block);err = PTR_ERR(block_cb); goto err_cb_register; }drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1
-0+ register_block = true;} else {(quoted diff) +1
-1- acl_block = tcf_block_cb_priv(block_cb); + acl_block = flow_block_cb_priv(block_cb);}(quoted diff) +1
-1- tcf_block_cb_incref(block_cb); + flow_block_cb_incref(block_cb);err = mlxsw_sp_acl_block_bind(mlxsw_sp, acl_block, mlxsw_sp_port, ingress); if (err)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c mlxsw_sp_setup_tc_block_flower_bind(struct mlxsw_sp_port *mlxsw_sp_port, · line 1640
Quoted 7 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +4
-0@@ -1622,28 +1634,31 @@ mlxsw_sp_setup_tc_block_flower_bind(struct mlxsw_sp_port *mlxsw_sp_port,else 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); + }
What prevents you from doing these 2 above right after flow_block_cb_alloc?
More than that, what prevents you do maintain the same flow as was there originally? You just need struct flow_block as a replacement of struct tcf_block and have it contained in both struct nft_base_chain and struct tcf_block.
And you would push pointer to struct flow_block down to drivers in struct flow_block_offload.
[...]
Re: [PATCH net-next,v4 08/12] drivers: net: use flow block API
In reply to Pablo Neira AyusoQuoted 6 lines · Pablo Neira Ayuso
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.
Quoted 8 lines
Remove
tc_block_offloadalias.Signed-off-by Pablo Neira Ayuso <[email protected]>---
v4: fix typo in list in nfp driver - Jakub Kicinski.
Movedriver_listhandling to the driver code, this list is transitional, until drivers are updated to support multiple subsystems. No moredriver_listhandling from core.
Pablo, can you explain (because this commit message doesn't) why these per- driver lists are needed, and what the information/state is that has module (rather than, say, netdevice) scope?
AFAICT none of these drivers otherwise interacts with TC at a module level (every block binding, callback etc. is associated with a single netdevice, usually through a cb_priv = netdev_priv(net_dev)), so this looks very out of place.
(More questions likely to follow as I work my way through trying to re- target my in-development driver to this new API. Also if you have any kind of design document explaining how it all fits together, that'd be nice, because currently trying to figure it out is giving me a headache.)
-Ed
Pablo Neira Ayuso
maintainerRe: [PATCH net-next,v4 08/12] drivers: net: use flow block API
Quoted 16 lines · Edward Cree
Quoted 6 lines · Pablo Neira Ayuso
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.
Quoted 8 lines
Remove
tc_block_offloadalias.Signed-off-by Pablo Neira Ayuso <[email protected]>---
v4: fix typo in list in nfp driver - Jakub Kicinski.
Movedriver_listhandling to the driver code, this list is transitional, until drivers are updated to support multiple subsystems. No moredriver_listhandling from core.
Quoted 3 lines
Pablo, can you explain (because this commit message doesn't) why these per- driver lists are needed, and what the information/state is that has module (rather than, say, netdevice) scope?
The idea is to update drivers to support one flow_block per subsystem, one for ethtool, one for tc, and so on. So far, existing drivers only allow for binding one single flow_block to one of the existing subsystems. So this limitation applies at driver level.
Re: [PATCH net-next,v4 08/12] drivers: net: use flow block API
Quoted 8 lines · Pablo Neira Ayuso
Quoted 3 lines · Edward Cree
Pablo, can you explain (because this commit message doesn't) why these per- driver lists are needed, and what the information/state is that has module (rather than, say, netdevice) scope?
The idea is to update drivers to support one
flow_blockper subsystem, one for ethtool, one for tc, and so on. So far, existing drivers only allow for binding one singleflow_blockto one of the existing subsystems. So this limitation applies at driver level.
That argues for per-driver _code_, not for per-driver _state_. For instance, each driver could (more logically) store this information in the netdev private data, rather than a static global. Or even, since each driver instance has a unique cb_ident = netdev_priv(net_dev), this doesn't need to be local to the driver at all and could just belong to the device owning the flow_block (which isn't necessarily the device doing the offload, per indirect blocks).
TBH I'm still not clear why you need a flow_block per subsystem, rather than just having multiple subsystems feed their offload requests through the same flow_block but with different enum tc_setup_type or enum tc_fl_command or some other indication that this is "netfilter" rather than "tc" asking for a tc_cls_flower_offload.
I'd also like to concur with what Jakub said on v2: "this series is really hard to follow... the number of things called some combination of block cb and list makes my head hurt :/".
This really needs a design document explaining what all the bits are, how they fit together, and why they need to be like that.
Pablo Neira Ayuso
maintainerRe: [PATCH net-next,v4 08/12] drivers: net: use flow block API
Quoted 11 lines · Edward Cree
Quoted 9 lines · Pablo Neira Ayuso
Quoted 3 lines · Edward Cree
Pablo, can you explain (because this commit message doesn't) why these per- driver lists are needed, and what the information/state is that has module (rather than, say, netdevice) scope?
The idea is to update drivers to support one
flow_blockper subsystem, one for ethtool, one for tc, and so on. So far, existing drivers only allow for binding one singleflow_blockto one of the existing subsystems. So this limitation applies at driver level.
Quoted 7 lines
That argues for per-driver _code_, not for per-driver _state_. For instance, each driver could (more logically) store this information in the netdev private data, rather than a static global. Or even, since each driver instance has a unique
cb_ident=netdev_priv(net_dev), this doesn't need to be local to the driver at all and could just belong to the device owning theflow_block(which isn't necessarily the device doing the offload, per indirect blocks).
This list could be placed in netdev_priv() area, yes.
Quoted 5 lines
TBH I'm still not clear why you need a
flow_blockper subsystem, rather than just having multiple subsystems feed their offload requests through the sameflow_blockbut with different enumtc_setup_typeor enumtc_fl_commandor some other indication that this is "netfilter" rather than "tc" asking for atc_cls_flower_offload.
In tc, the flow_block is set up by when the ingress qdisc is registered. The usual scenario for most drivers is to have one single flow_block per registered ingress qdisc, this makes a 1:1 mapping between ingress qdisc and flow_block.
Still, you can register two or more ingress qdiscs to make them share the same policy via 'tc block'. In that case all those qdiscs use one single flow_block. This makes a N:1 mapping between these qdisc ingress and the flow_block. This policy applies to all ingress qdiscs that are part of the same tc block. By 'tc block', I'm refering to the tcf_block structure.
In netfilter, there are ingress basechains that are registered per device. Each basechain gets a flow_block by when the basechain is registered. Shared blocks as in tcf_block are not yet supported, but it should not be hard to extend it to make this work.
To reuse the same flow_block as entry point for all subsystems as your propose - assuming offloads for two or more subsystems are in place - then all of them would need to have the same block sharing configuration, which might not be the case, ie. tc ingress might have a eth0 and eth1 use the same policy via flow_block, while netfilter might have one basechain for eth0 and another for eth1 (no policy sharing).
[...]
Quoted 2 lines
This really needs a design document explaining what all the bits are, how they fit together, and why they need to be like that.
I did not design this flow_block abstraction, this concept was already in place under a different name and extend it so the ethtool/netfilter subsystems to avoid driver code duplication for offloads. Having said this, I agree documentation is good to have.
Re: [PATCH net-next,v4 08/12] drivers: net: use flow block API
Quoted 23 lines · Pablo Neira Ayuso
Quoted 5 lines · Edward Cree
TBH I'm still not clear why you need a
flow_blockper subsystem, rather than just having multiple subsystems feed their offload requests through the sameflow_blockbut with different enumtc_setup_typeor enumtc_fl_commandor some other indication that this is "netfilter" rather than "tc" asking for atc_cls_flower_offload.In tc, the
flow_blockis set up by when the ingress qdisc is registered. The usual scenario for most drivers is to have one singleflow_blockper registered ingress qdisc, this makes a 1:1 mapping between ingress qdisc andflow_block.Still, you can register two or more ingress qdiscs to make them share the same policy via 'tc block'. In that case all those qdiscs use one single
flow_block. This makes a N:1 mapping between these qdisc ingress and theflow_block. This policy applies to all ingress qdiscs that are part of the same tc block. By 'tc block', I'm refering to thetcf_blockstructure.In netfilter, there are ingress basechains that are registered per device. Each basechain gets a
flow_blockby when the basechain is registered. Shared blocks as intcf_blockare not yet supported, but it should not be hard to extend it to make this work.
Quoted 7 lines
To reuse the same
flow_blockas entry point for all subsystems as your propose - assuming offloads for two or more subsystems are in place - then all of them would need to have the same block sharing configuration, which might not be the case, ie. tc ingress might have a eth0 and eth1 use the same policy viaflow_block, while netfilter might have one basechain for eth0 and another for eth1 (no policy sharing).
Thank you, that's very helpful.
Quoted 5 lines
Quoted 2 lines
This really needs a design document explaining what all the bits are, how they fit together, and why they need to be like that.
I did not design this
flow_blockabstraction, this concept was already in place under a different name and extend it so the ethtool/netfilter subsystems to avoid driver code duplication for offloads.
It's more the new implementation that you've created as part of this extension that I was asking about, although I agree that the abstraction that already existed is in need of documentation too.
Pablo Neira Ayuso
maintainerPATCH v4 9/12 net: sched: remove tcf block API
In reply to Pablo Neira AyusoUnused, now replaced by flow block API.
---
v4: no changes.
include/net/pkt_cls.h | 69 ------------------------------------ net/sched/cls_api.c | 98 --------------------------------------------------- 2 files changed, 167 deletions(-)
include/net/pkt_cls.h +0 -69
@@ -66,22 +66,6 @@ static inline struct Qdisc *tcf_block_q(struct tcf_block *block)return block->q; } -void *tcf_block_cb_priv (struct tcf_block_cb *block_cb); -struct tcf_block_cb *tcf_block_cb_lookup (struct tcf_block *block, -tc_setup_cb_t *cb,void *cb_ident); -void tcf_block_cb_incref (struct tcf_block_cb *block_cb); -unsigned int tcf_block_cb_decref (struct tcf_block_cb *block_cb); -struct tcf_block_cb *__tcf_block_cb_register (struct tcf_block *block, -tc_setup_cb_t *cb,void *cb_ident, -void *cb_priv, -struct netlink_ext_ack *extack); -int tcf_block_cb_register (struct tcf_block *block, -tc_setup_cb_t *cb,void *cb_ident, -void *cb_priv,struct netlink_ext_ack *extack); -void __tcf_block_cb_unregister (struct tcf_block *block, -struct tcf_block_cb *block_cb); -void tcf_block_cb_unregister (struct tcf_block *block, -tc_setup_cb_t *cb,void *cb_ident);int __tc_indr_block_cb_register (struct net_device *dev,void *cb_priv,tc_indr_block_bind_cb_t *cb,void *cb_ident); int tc_indr_block_cb_register(struct net_device *dev, void *cb_priv,
@@ -145,59 +129,6 @@ void tc_setup_cb_block_unregister(struct tcf_block *block, tc_setup_cb_t *cb, }static inline -void *tcf_block_cb_priv (struct tcf_block_cb *block_cb) -{ -return NULL ; -} - -static inline -struct tcf_block_cb *tcf_block_cb_lookup (struct tcf_block *block, -tc_setup_cb_t *cb,void *cb_ident) -{ -return NULL ; -} - -static inline -void tcf_block_cb_incref (struct tcf_block_cb *block_cb) -{ -} - -static inline -unsigned int tcf_block_cb_decref (struct tcf_block_cb *block_cb) -{ -return 0 ; -} - -static inline -struct tcf_block_cb *__tcf_block_cb_register (struct tcf_block *block, -tc_setup_cb_t *cb,void *cb_ident, -void *cb_priv, -struct netlink_ext_ack *extack) -{ -return NULL ; -} - -static inline -int tcf_block_cb_register (struct tcf_block *block, -tc_setup_cb_t *cb,void *cb_ident, -void *cb_priv,struct netlink_ext_ack *extack) -{ -return 0 ; -} - -static inline -void __tcf_block_cb_unregister (struct tcf_block *block, -struct tcf_block_cb *block_cb) -{ -} - -static inline -void tcf_block_cb_unregister (struct tcf_block *block, -tc_setup_cb_t *cb,void *cb_ident) -{ -} - -static inline int __tc_indr_block_cb_register (struct net_device *dev,void *cb_priv,tc_indr_block_bind_cb_t *cb,void *cb_ident) {
net/sched/cls_api.c +0 -98
110 lines not on this page · raw message
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v4 10/12 net: flow_offload: add flow_block_cb_is_busy() and use it
In reply to Pablo Neira AyusoThis patch adds a function to check if flow block callback is already in use. Call this new function from flow_block_cb_setup_simple() and from drivers.
---
v4: no changes.
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 4 ++++ drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 ++++ drivers/net/ethernet/mscc/ocelot_tc.c | 3 +++ drivers/net/ethernet/netronome/nfp/flower/offload.c | 4 ++++ include/net/flow_offload.h | 3 +++ net/core/flow_offload.c | 18 ++++++++++++++++++ net/dsa/slave.c | 3 +++ 7 files changed, 39 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +4 -0
@@ -721,6 +721,10 @@ mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,if (indr_priv)return -EEXIST ; +if (flow_block_cb_is_busy (mlx5e_rep_indr_setup_block_cb, + indr_priv, &mlx5e_block_cb_list)) +return -EBUSY ; + indr_priv =kmalloc (sizeof (*indr_priv),GFP_KERNEL );if (!indr_priv)return -ENOMEM ;
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +4 -0
@@ -1698,6 +1698,10 @@ static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,switch (f->command) {case FLOW_BLOCK_BIND : +if (flow_block_cb_is_busy (cb, mlxsw_sp_port, + &mlxsw_sp_block_cb_list)) +return -EBUSY ; + block_cb =flow_block_cb_alloc (f->net, cb, mlxsw_sp_port, mlxsw_sp_port,NULL );if (IS_ERR (block_cb))
drivers/net/ethernet/mscc/ocelot_tc.c +3 -0
@@ -153,6 +153,9 @@ static int ocelot_setup_tc_block(struct ocelot_port *port,switch (f->command) {case FLOW_BLOCK_BIND : +if (flow_block_cb_is_busy (cb, port, &ocelot_block_cb_list)) +return -EBUSY ; + block_cb =flow_block_cb_alloc (f->net, cb, port, port,NULL );if (IS_ERR (block_cb))return PTR_ERR (block_cb);
drivers/net/ethernet/netronome/nfp/flower/offload.c +4 -0
@@ -1320,6 +1320,10 @@ static int nfp_flower_setup_tc_block(struct net_device *netdev,switch (f->command) {case FLOW_BLOCK_BIND : +if (flow_block_cb_is_busy (nfp_flower_setup_tc_block_cb, repr, + &nfp_block_cb_list)) +return -EBUSY ; + block_cb =flow_block_cb_alloc (f->net, nfp_flower_setup_tc_block_cb, repr, repr,NULL );
include/net/flow_offload.h +3 -0
@@ -291,6 +291,9 @@ static inline void flow_block_cb_remove(struct flow_block_cb *block_cb,list_move (&block_cb->list, &offload->cb_list); } +bool flow_block_cb_is_busy (tc_setup_cb_t *cb,void *cb_ident, +struct list_head *driver_block_list); +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);
net/core/flow_offload.c +18 -0
@@ -228,6 +228,21 @@ unsigned int flow_block_cb_decref(struct flow_block_cb *block_cb) }EXPORT_SYMBOL (flow_block_cb_decref); +bool flow_block_cb_is_busy (tc_setup_cb_t *cb,void *cb_ident, +struct list_head *driver_block_list) +{ +struct flow_block_cb *block_cb; + +list_for_each_entry (block_cb, driver_block_list, driver_list) { +if (block_cb->cb == cb && + block_cb->cb_ident == cb_ident) +return true; + } + +return false; +} +EXPORT_SYMBOL (flow_block_cb_is_busy); + int flow_block_cb_setup_simple(struct flow_block_offload *f, struct list_head *driver_block_list, tc_setup_cb_t *cb, void *cb_ident, void *cb_priv,
@@ -243,6 +258,9 @@ int flow_block_cb_setup_simple(struct flow_block_offload *f,switch (f->command) {case FLOW_BLOCK_BIND : +if (flow_block_cb_is_busy (cb, cb_ident, driver_block_list)) +return -EBUSY ; + block_cb =flow_block_cb_alloc (f->net, cb, cb_ident, cb_priv,NULL );if (IS_ERR (block_cb))
net/dsa/slave.c +3 -0
@@ -961,6 +961,9 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,switch (f->command) {case FLOW_BLOCK_BIND : +if (flow_block_cb_is_busy (cb, dev, &dsa_slave_block_cb_list)) +return -EBUSY ; + block_cb =flow_block_cb_alloc (f->net, cb, dev, dev,NULL );if (IS_ERR (block_cb))return PTR_ERR (block_cb);
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v4 11/12 net: flow_offload: rename tc_cls_flower_offload to flow_cls_offload
In reply to Pablo Neira AyusoAnd any other existing fields in this structure that refer to tc. Specifically:
* tc_cls_flower_offload_flow_rule() to flow_cls_offload_flow_rule().
* TC_CLSFLOWER_* to FLOW_CLS_*.
* tc_cls_common_offload to tc_cls_common_offload.
---
v4: new patch, rename tc definitions and structures - Jakub Kicinski and Jiri Pirko.
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 18 ++++----- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h | 4 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 8 ++-- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 22 +++++------ .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h | 6 +-- drivers/net/ethernet/intel/i40e/i40e_main.c | 22 +++++------ drivers/net/ethernet/intel/iavf/iavf_main.c | 22 +++++------ drivers/net/ethernet/intel/igb/igb_main.c | 16 ++++---- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 6 +-- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.h | 8 ++-- .../ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c | 18 ++++----- .../ethernet/mellanox/mlx5/core/en/tc_tun_gre.c | 4 +- .../ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c | 10 ++--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 8 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 16 ++++---- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 34 ++++++++--------- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 6 +-- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 12 +++--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 10 ++--- .../net/ethernet/mellanox/mlxsw/spectrum_flower.c | 34 ++++++++--------- drivers/net/ethernet/mscc/ocelot_flower.c | 22 +++++------ drivers/net/ethernet/netronome/nfp/flower/action.c | 14 +++---- drivers/net/ethernet/netronome/nfp/flower/main.h | 6 +-- drivers/net/ethernet/netronome/nfp/flower/match.c | 44 +++++++++++----------- .../net/ethernet/netronome/nfp/flower/metadata.c | 2 +- .../net/ethernet/netronome/nfp/flower/offload.c | 30 +++++++-------- drivers/net/ethernet/qlogic/qede/qede.h | 2 +- drivers/net/ethernet/qlogic/qede/qede_filter.c | 2 +- drivers/net/ethernet/qlogic/qede/qede_main.c | 8 ++-- include/net/flow_offload.h | 30 +++++++++++++++ include/net/pkt_cls.h | 40 +++----------------- net/sched/cls_flower.c | 24 ++++++------ 32 files changed, 254 insertions(+), 254 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +9 -9
@@ -170,10 +170,10 @@ static int bnxt_tc_parse_actions(struct bnxt *bp, }static int bnxt_tc_parse_flow (struct bnxt *bp, -struct tc_cls_flower_offload *tc_flow_cmd, +struct flow_cls_offload *tc_flow_cmd,struct bnxt_tc_flow *flow) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (tc_flow_cmd); +struct flow_rule *rule =flow_cls_offload_flow_rule (tc_flow_cmd);struct flow_dissector *dissector = rule->match.dissector;/* KEY_CONTROL and KEY_BASIC are needed for forming a meaningful key */
@@ -1262,7 +1262,7 @@ static void bnxt_tc_set_src_fid(struct bnxt *bp, struct bnxt_tc_flow *flow,* The hash-tables are already protected by the rhashtable API. */ static int bnxt_tc_add_flow (struct bnxt *bp,u16 src_fid, -struct tc_cls_flower_offload *tc_flow_cmd) +struct flow_cls_offload *tc_flow_cmd) {struct bnxt_tc_flow_node *new_node, *old_node;struct bnxt_tc_info *tc_info = bp->tc_info;
@@ -1348,7 +1348,7 @@ static int bnxt_tc_add_flow(struct bnxt *bp, u16 src_fid, }static int bnxt_tc_del_flow (struct bnxt *bp, -struct tc_cls_flower_offload *tc_flow_cmd) +struct flow_cls_offload *tc_flow_cmd) {struct bnxt_tc_info *tc_info = bp->tc_info;struct bnxt_tc_flow_node *flow_node;
@@ -1363,7 +1363,7 @@ static int bnxt_tc_del_flow(struct bnxt *bp, }static int bnxt_tc_get_flow_stats (struct bnxt *bp, -struct tc_cls_flower_offload *tc_flow_cmd) +struct flow_cls_offload *tc_flow_cmd) {struct bnxt_tc_flow_stats stats, *curr_stats, *prev_stats;struct bnxt_tc_info *tc_info = bp->tc_info;
@@ -1585,14 +1585,14 @@ void bnxt_tc_flow_stats_work(struct bnxt *bp) }int bnxt_tc_setup_flower (struct bnxt *bp,u16 src_fid, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {switch (cls_flower->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return bnxt_tc_add_flow (bp, src_fid, cls_flower); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return bnxt_tc_del_flow (bp, cls_flower); -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return bnxt_tc_get_flow_stats (bp, cls_flower);default :return -EOPNOTSUPP ;
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.h +2 -2
@@ -196,7 +196,7 @@ struct bnxt_tc_flow_node { };int bnxt_tc_setup_flower (struct bnxt *bp,u16 src_fid, -struct tc_cls_flower_offload *cls_flower); +struct flow_cls_offload *cls_flower);int bnxt_init_tc (struct bnxt *bp);void bnxt_shutdown_tc (struct bnxt *bp);void bnxt_tc_flow_stats_work (struct bnxt *bp);
@@ -209,7 +209,7 @@ static inline bool bnxt_tc_flower_enabled(struct bnxt *bp)#else /* CONFIG_BNXT_FLOWER_OFFLOAD */ static inline int bnxt_tc_setup_flower (struct bnxt *bp,u16 src_fid, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {return -EOPNOTSUPP ; }
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +4 -4
@@ -3135,14 +3135,14 @@ static int cxgb_set_tx_maxrate(struct net_device *dev, int index, u32 rate) }static int cxgb_setup_tc_flower (struct net_device *dev, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {switch (cls_flower->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return cxgb4_tc_flower_replace (dev, cls_flower); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return cxgb4_tc_flower_destroy (dev, cls_flower); -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return cxgb4_tc_flower_stats (dev, cls_flower);default :return -EOPNOTSUPP ;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +11 -11
@@ -80,10 +80,10 @@ static struct ch_tc_flower_entry *ch_flower_lookup(struct adapter *adap, }static void cxgb4_process_flow_match (struct net_device *dev, -struct tc_cls_flower_offload *cls, +struct flow_cls_offload *cls,struct ch_filter_specification *fs) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (cls); +struct flow_rule *rule =flow_cls_offload_flow_rule (cls);u16 addr_type =0 ;if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_CONTROL )) {
@@ -223,9 +223,9 @@ static void cxgb4_process_flow_match(struct net_device *dev, }static int cxgb4_validate_flow_match (struct net_device *dev, -struct tc_cls_flower_offload *cls) +struct flow_cls_offload *cls) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (cls); +struct flow_rule *rule =flow_cls_offload_flow_rule (cls);struct flow_dissector *dissector = rule->match.dissector;u16 ethtype_mask =0 ;u16 ethtype_key =0 ;
@@ -378,10 +378,10 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val, }static void cxgb4_process_flow_actions (struct net_device *in, -struct tc_cls_flower_offload *cls, +struct flow_cls_offload *cls,struct ch_filter_specification *fs) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (cls); +struct flow_rule *rule =flow_cls_offload_flow_rule (cls);struct flow_action_entry *act;int i;
@@ -544,9 +544,9 @@ static bool valid_pedit_action(struct net_device *dev, }static int cxgb4_validate_flow_actions (struct net_device *dev, -struct tc_cls_flower_offload *cls) +struct flow_cls_offload *cls) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (cls); +struct flow_rule *rule =flow_cls_offload_flow_rule (cls);struct flow_action_entry *act;bool act_redir = false;bool act_pedit = false;
@@ -633,7 +633,7 @@ static int cxgb4_validate_flow_actions(struct net_device *dev, }int cxgb4_tc_flower_replace (struct net_device *dev, -struct tc_cls_flower_offload *cls) +struct flow_cls_offload *cls) {struct adapter *adap =netdev2adap (dev);struct ch_tc_flower_entry *ch_flower;
@@ -709,7 +709,7 @@ int cxgb4_tc_flower_replace(struct net_device *dev, }int cxgb4_tc_flower_destroy (struct net_device *dev, -struct tc_cls_flower_offload *cls) +struct flow_cls_offload *cls) {struct adapter *adap =netdev2adap (dev);struct ch_tc_flower_entry *ch_flower;
@@ -783,7 +783,7 @@ static void ch_flower_stats_cb(struct timer_list *t) }int cxgb4_tc_flower_stats (struct net_device *dev, -struct tc_cls_flower_offload *cls) +struct flow_cls_offload *cls) {struct adapter *adap =netdev2adap (dev);struct ch_tc_flower_stats *ofld_stats;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h +3 -3
@@ -109,11 +109,11 @@ struct ch_tc_pedit_fields {#define PEDIT_UDP_SPORT_DPORT 0x0int cxgb4_tc_flower_replace (struct net_device *dev, -struct tc_cls_flower_offload *cls); +struct flow_cls_offload *cls);int cxgb4_tc_flower_destroy (struct net_device *dev, -struct tc_cls_flower_offload *cls); +struct flow_cls_offload *cls);int cxgb4_tc_flower_stats (struct net_device *dev, -struct tc_cls_flower_offload *cls); +struct flow_cls_offload *cls);int cxgb4_init_tc_flower (struct adapter *adap);void cxgb4_cleanup_tc_flower (struct adapter *adap);
drivers/net/ethernet/intel/i40e/i40e_main.c +11 -11
@@ -7759,15 +7759,15 @@ int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,/** * i40e_parse_cls_flower - Parse tc flower filters provided by kernel * @vsi: Pointer to VSI -* @cls_flower: Pointer to struct tc_cls_flower_offload +* @cls_flower: Pointer to struct flow_cls_offload * @filter: Pointer to cloud filter structure * **/ static int i40e_parse_cls_flower (struct i40e_vsi *vsi, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,struct i40e_cloud_filter *filter) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_dissector *dissector = rule->match.dissector;u16 n_proto_mask =0 , n_proto_key =0 , addr_type =0 ;struct i40e_pf *pf = vsi->back;
@@ -8001,11 +8001,11 @@ static int i40e_handle_tclass(struct i40e_vsi *vsi, u32 tc,/** * i40e_configure_clsflower - Configure tc flower filters * @vsi: Pointer to VSI -* @cls_flower: Pointer to struct tc_cls_flower_offload +* @cls_flower: Pointer to struct flow_cls_offload * **/ static int i40e_configure_clsflower (struct i40e_vsi *vsi, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {int tc =tc_classid_to_hwtc (vsi->netdev, cls_flower->classid);struct i40e_cloud_filter *filter =NULL ;
@@ -8097,11 +8097,11 @@ static struct i40e_cloud_filter *i40e_find_cloud_filter(struct i40e_vsi *vsi,/** * i40e_delete_clsflower - Remove tc flower filters * @vsi: Pointer to VSI -* @cls_flower: Pointer to struct tc_cls_flower_offload +* @cls_flower: Pointer to struct flow_cls_offload * **/ static int i40e_delete_clsflower (struct i40e_vsi *vsi, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {struct i40e_cloud_filter *filter =NULL ;struct i40e_pf *pf = vsi->back;
@@ -8144,16 +8144,16 @@ static int i40e_delete_clsflower(struct i40e_vsi *vsi,* @type_data: offload data **/ static int i40e_setup_tc_cls_flower (struct i40e_netdev_priv *np, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {struct i40e_vsi *vsi = np->vsi;switch (cls_flower->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return i40e_configure_clsflower (vsi, cls_flower); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return i40e_delete_clsflower (vsi, cls_flower); -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return -EOPNOTSUPP ;default :return -EOPNOTSUPP ;
drivers/net/ethernet/intel/iavf/iavf_main.c +11 -11
@@ -2699,14 +2699,14 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)/** * iavf_parse_cls_flower - Parse tc flower filters provided by kernel * @adapter: board private structure -* @cls_flower: pointer to struct tc_cls_flower_offload +* @cls_flower: pointer to struct flow_cls_offload * @filter: pointer to cloud filter structure */ static int iavf_parse_cls_flower (struct iavf_adapter *adapter, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,struct iavf_cloud_filter *filter) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_dissector *dissector = rule->match.dissector;u16 n_proto_mask =0 ;u16 n_proto_key =0 ;
@@ -2971,10 +2971,10 @@ static int iavf_handle_tclass(struct iavf_adapter *adapter, u32 tc,/** * iavf_configure_clsflower - Add tc flower filters * @adapter: board private structure -* @cls_flower: Pointer to struct tc_cls_flower_offload +* @cls_flower: Pointer to struct flow_cls_offload */ static int iavf_configure_clsflower (struct iavf_adapter *adapter, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {int tc =tc_classid_to_hwtc (adapter->netdev, cls_flower->classid);struct iavf_cloud_filter *filter =NULL ;
@@ -3050,10 +3050,10 @@ static struct iavf_cloud_filter *iavf_find_cf(struct iavf_adapter *adapter,/** * iavf_delete_clsflower - Remove tc flower filters * @adapter: board private structure -* @cls_flower: Pointer to struct tc_cls_flower_offload +* @cls_flower: Pointer to struct flow_cls_offload */ static int iavf_delete_clsflower (struct iavf_adapter *adapter, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {struct iavf_cloud_filter *filter =NULL ;int err =0 ;
@@ -3077,17 +3077,17 @@ static int iavf_delete_clsflower(struct iavf_adapter *adapter,* @type_data: offload data */ static int iavf_setup_tc_cls_flower (struct iavf_adapter *adapter, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {if (cls_flower->common.chain_index)return -EOPNOTSUPP ;switch (cls_flower->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return iavf_configure_clsflower (adapter, cls_flower); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return iavf_delete_clsflower (adapter, cls_flower); -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return -EOPNOTSUPP ;default :return -EOPNOTSUPP ;
drivers/net/ethernet/intel/igb/igb_main.c +8 -8
@@ -2578,11 +2578,11 @@ static int igb_offload_cbs(struct igb_adapter *adapter,#define VLAN_PRIO_FULL_MASK (0x07)static int igb_parse_cls_flower (struct igb_adapter *adapter, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,int traffic_class,struct igb_nfc_filter *input) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_dissector *dissector = rule->match.dissector;struct netlink_ext_ack *extack = f->common.extack;
@@ -2660,7 +2660,7 @@ static int igb_parse_cls_flower(struct igb_adapter *adapter, }static int igb_configure_clsflower (struct igb_adapter *adapter, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {struct netlink_ext_ack *extack = cls_flower->common.extack;struct igb_nfc_filter *filter, *f;
@@ -2722,7 +2722,7 @@ static int igb_configure_clsflower(struct igb_adapter *adapter, }static int igb_delete_clsflower (struct igb_adapter *adapter, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {struct igb_nfc_filter *filter;int err;
@@ -2752,14 +2752,14 @@ static int igb_delete_clsflower(struct igb_adapter *adapter, }static int igb_setup_tc_cls_flower (struct igb_adapter *adapter, -struct tc_cls_flower_offload *cls_flower) +struct flow_cls_offload *cls_flower) {switch (cls_flower->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return igb_configure_clsflower (adapter, cls_flower); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return igb_delete_clsflower (adapter, cls_flower); -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return -EOPNOTSUPP ;default :return -EOPNOTSUPP ;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +3 -3
@@ -452,7 +452,7 @@ int mlx5e_tc_tun_init_encap_attr(struct net_device *tunnel_dev,int mlx5e_tc_tun_parse (struct net_device *filter_dev,struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v,u8 *match_level) {
@@ -489,11 +489,11 @@ int mlx5e_tc_tun_parse(struct net_device *filter_dev,int mlx5e_tc_tun_parse_udp_ports (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct netlink_ext_ack *extack = f->common.extack;struct flow_match_ports enc_ports;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h +4 -4
@@ -33,12 +33,12 @@ struct mlx5e_tc_tunnel { struct mlx5e_encap_entry *e);int (*parse_udp_ports)(struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v);int (*parse_tunnel)(struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v); };
@@ -68,13 +68,13 @@ bool mlx5e_tc_tun_device_to_offload(struct mlx5e_priv *priv,int mlx5e_tc_tun_parse (struct net_device *filter_dev,struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v,u8 *match_level);int mlx5e_tc_tun_parse_udp_ports (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v);
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c +9 -9
@@ -20,9 +20,9 @@ static int mlx5e_tc_tun_calc_hlen_geneve(struct mlx5e_encap_entry *e) }static int mlx5e_tc_tun_check_udp_dport_geneve (struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct netlink_ext_ack *extack = f->common.extack;struct flow_match_ports enc_ports;
@@ -48,7 +48,7 @@ static int mlx5e_tc_tun_check_udp_dport_geneve(struct mlx5e_priv *priv,static int mlx5e_tc_tun_parse_udp_ports_geneve (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v) {
@@ -122,9 +122,9 @@ static int mlx5e_gen_ip_tunnel_header_geneve(char buf[],static int mlx5e_tc_tun_parse_geneve_vni (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct netlink_ext_ack *extack = f->common.extack;struct flow_match_enc_keyid enc_keyid;void *misc_c, *misc_v;
@@ -154,11 +154,11 @@ static int mlx5e_tc_tun_parse_geneve_vni(struct mlx5e_priv *priv,static int mlx5e_tc_tun_parse_geneve_options (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {u8 max_tlv_option_data_len =MLX5_CAP_GEN (priv->mdev, max_geneve_tlv_option_data_len);u8 max_tlv_options =MLX5_CAP_GEN (priv->mdev, max_geneve_tlv_options); -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct netlink_ext_ack *extack = f->common.extack;void *misc_c, *misc_v, *misc_3_c, *misc_3_v;struct geneve_opt *option_key, *option_mask;
@@ -277,7 +277,7 @@ static int mlx5e_tc_tun_parse_geneve_options(struct mlx5e_priv *priv,static int mlx5e_tc_tun_parse_geneve_params (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {void *misc_c =MLX5_ADDR_OF (fte_match_param, spec->match_criteria, misc_parameters);void *misc_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters);
@@ -306,7 +306,7 @@ static int mlx5e_tc_tun_parse_geneve_params(struct mlx5e_priv *priv,static int mlx5e_tc_tun_parse_geneve (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v) {
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_gre.c +2 -2
@@ -54,13 +54,13 @@ static int mlx5e_gen_ip_tunnel_header_gretap(char buf[],static int mlx5e_tc_tun_parse_gretap (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v) {void *misc_c =MLX5_ADDR_OF (fte_match_param, spec->match_criteria, misc_parameters);void *misc_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters); -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);MLX5_SET_TO_ONES (fte_match_set_lyr_2_4, headers_c, ip_protocol);MLX5_SET (fte_match_set_lyr_2_4, headers_v, ip_protocol,IPPROTO_GRE );
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c +5 -5
@@ -16,9 +16,9 @@ static int mlx5e_tc_tun_calc_hlen_vxlan(struct mlx5e_encap_entry *e) }static int mlx5e_tc_tun_check_udp_dport_vxlan (struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct netlink_ext_ack *extack = f->common.extack;struct flow_match_ports enc_ports;
@@ -44,7 +44,7 @@ static int mlx5e_tc_tun_check_udp_dport_vxlan(struct mlx5e_priv *priv,static int mlx5e_tc_tun_parse_udp_ports_vxlan (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v) {
@@ -100,11 +100,11 @@ static int mlx5e_gen_ip_tunnel_header_vxlan(char buf[],static int mlx5e_tc_tun_parse_vxlan (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,void *headers_c,void *headers_v) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct netlink_ext_ack *extack = f->common.extack;struct flow_match_enc_keyid enc_keyid;void *misc_c, *misc_v;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +4 -4
@@ -3426,17 +3426,17 @@ static int mlx5e_setup_tc_mqprio(struct net_device *netdev,#ifdef CONFIG_MLX5_ESWITCH static int mlx5e_setup_tc_cls_flower (struct mlx5e_priv *priv, -struct tc_cls_flower_offload *cls_flower, +struct flow_cls_offload *cls_flower,int flags) {switch (cls_flower->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return mlx5e_configure_flower (priv->netdev, priv, cls_flower, flags); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return mlx5e_delete_flower (priv->netdev, priv, cls_flower, flags); -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return mlx5e_stats_flower (priv->netdev, priv, cls_flower, flags);default :
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +8 -8
@@ -655,7 +655,7 @@ static void mlx5e_rep_indr_clean_block_privs(struct mlx5e_rep_priv *rpriv)static int mlx5e_rep_indr_offload (struct net_device *netdev, -struct tc_cls_flower_offload *flower, +struct flow_cls_offload *flower,struct mlx5e_rep_indr_block_priv *indr_priv) {struct mlx5e_priv *priv =netdev_priv (indr_priv->rpriv->netdev);
@@ -663,13 +663,13 @@ mlx5e_rep_indr_offload(struct net_device *netdev,int err =0 ;switch (flower->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE : err =mlx5e_configure_flower (netdev, priv, flower, flags);break ; -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY : err =mlx5e_delete_flower (netdev, priv, flower, flags);break ; -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS : err =mlx5e_stats_flower (netdev, priv, flower, flags);break ;default :
@@ -1169,16 +1169,16 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev,static int mlx5e_rep_setup_tc_cls_flower (struct mlx5e_priv *priv, -struct tc_cls_flower_offload *cls_flower,int flags) +struct flow_cls_offload *cls_flower,int flags) {switch (cls_flower->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return mlx5e_configure_flower (priv->netdev, priv, cls_flower, flags); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return mlx5e_delete_flower (priv->netdev, priv, cls_flower, flags); -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return mlx5e_stats_flower (priv->netdev, priv, cls_flower, flags);default :
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +17 -17
@@ -1350,7 +1350,7 @@ static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,static int parse_tunnel_attr (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,struct net_device *filter_dev,u8 *match_level) {struct netlink_ext_ack *extack = f->common.extack;
@@ -1358,7 +1358,7 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv, outer_headers);void *headers_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, outer_headers); -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);int err; err = mlx5e_tc_tun_parse(filter_dev, priv, spec, f,
@@ -1478,7 +1478,7 @@ static void *get_match_headers_value(u32 flags,static int __parse_cls_flower (struct mlx5e_priv *priv,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,struct net_device *filter_dev,u8 *match_level,u8 *tunnel_match_level) {
@@ -1491,7 +1491,7 @@ static int __parse_cls_flower(struct mlx5e_priv *priv, misc_parameters);void *misc_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters); -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_dissector *dissector = rule->match.dissector;u16 addr_type =0 ;u8 ip_proto =0 ;
@@ -1831,7 +1831,7 @@ static int __parse_cls_flower(struct mlx5e_priv *priv,static int parse_cls_flower (struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow,struct mlx5_flow_spec *spec, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,struct net_device *filter_dev) {struct netlink_ext_ack *extack = f->common.extack;
@@ -3115,7 +3115,7 @@ static bool is_peer_flow_needed(struct mlx5e_tc_flow *flow)static int mlx5e_alloc_flow (struct mlx5e_priv *priv,int attr_size, -struct tc_cls_flower_offload *f,u16 flow_flags, +struct flow_cls_offload *f,u16 flow_flags,struct mlx5e_tc_flow_parse_attr **__parse_attr,struct mlx5e_tc_flow **__flow) {
@@ -3149,7 +3149,7 @@ static void mlx5e_flow_esw_attr_init(struct mlx5_esw_flow_attr *esw_attr, struct mlx5e_priv *priv, struct mlx5e_tc_flow_parse_attr *parse_attr, - struct tc_cls_flower_offload *f, + struct flow_cls_offload *f, struct mlx5_eswitch_rep *in_rep, struct mlx5_core_dev *in_mdev) {
@@ -3171,13 +3171,13 @@ mlx5e_flow_esw_attr_init(struct mlx5_esw_flow_attr *esw_attr,static struct mlx5e_tc_flow *__mlx5e_add_fdb_flow (struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,u16 flow_flags,struct net_device *filter_dev,struct mlx5_eswitch_rep *in_rep,struct mlx5_core_dev *in_mdev) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct netlink_ext_ack *extack = f->common.extack;struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5e_tc_flow *flow;
@@ -3221,7 +3221,7 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,return ERR_PTR (err); } -static int mlx5e_tc_add_fdb_peer_flow (struct tc_cls_flower_offload *f, +static int mlx5e_tc_add_fdb_peer_flow (struct flow_cls_offload *f,struct mlx5e_tc_flow *flow,u16 flow_flags) {
@@ -3273,7 +3273,7 @@ static int mlx5e_tc_add_fdb_peer_flow(struct tc_cls_flower_offload *f,static int mlx5e_add_fdb_flow (struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,u16 flow_flags,struct net_device *filter_dev,struct mlx5e_tc_flow **__flow)
@@ -3307,12 +3307,12 @@ mlx5e_add_fdb_flow(struct mlx5e_priv *priv,static int mlx5e_add_nic_flow (struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,u16 flow_flags,struct net_device *filter_dev,struct mlx5e_tc_flow **__flow) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct netlink_ext_ack *extack = f->common.extack;struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5e_tc_flow *flow;
@@ -3358,7 +3358,7 @@ mlx5e_add_nic_flow(struct mlx5e_priv *priv,static int mlx5e_tc_add_flow (struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,int flags,struct net_device *filter_dev,struct mlx5e_tc_flow **flow)
@@ -3383,7 +3383,7 @@ mlx5e_tc_add_flow(struct mlx5e_priv *priv, }int mlx5e_configure_flower (struct net_device *dev,struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f,int flags) +struct flow_cls_offload *f,int flags) {struct netlink_ext_ack *extack = f->common.extack;struct rhashtable *tc_ht =get_tc_ht (priv, flags);
@@ -3430,7 +3430,7 @@ static bool same_flow_direction(struct mlx5e_tc_flow *flow, int flags) }int mlx5e_delete_flower (struct net_device *dev,struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f,int flags) +struct flow_cls_offload *f,int flags) {struct rhashtable *tc_ht =get_tc_ht (priv, flags);struct mlx5e_tc_flow *flow;
@@ -3449,7 +3449,7 @@ int mlx5e_delete_flower(struct net_device *dev, struct mlx5e_priv *priv, }int mlx5e_stats_flower (struct net_device *dev,struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f,int flags) +struct flow_cls_offload *f,int flags) {struct mlx5_devcom *devcom = priv->mdev->priv.devcom;struct rhashtable *tc_ht =get_tc_ht (priv, flags);
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +3 -3
@@ -54,12 +54,12 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht);void mlx5e_tc_esw_cleanup (struct rhashtable *tc_ht);int mlx5e_configure_flower (struct net_device *dev,struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f,int flags); +struct flow_cls_offload *f,int flags);int mlx5e_delete_flower (struct net_device *dev,struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f,int flags); +struct flow_cls_offload *f,int flags);int mlx5e_stats_flower (struct net_device *dev,struct mlx5e_priv *priv, -struct tc_cls_flower_offload *f,int flags); +struct flow_cls_offload *f,int flags);struct mlx5e_encap_entry ; void mlx5e_tc_encap_flows_add(struct mlx5e_priv *priv,
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +6 -6
@@ -1508,21 +1508,21 @@ static int mlxsw_sp_setup_tc_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port,static int mlxsw_sp_setup_tc_cls_flower (struct mlxsw_sp_acl_block *acl_block, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {struct mlxsw_sp *mlxsw_sp =mlxsw_sp_acl_block_mlxsw_sp (acl_block);switch (f->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return mlxsw_sp_flower_replace (mlxsw_sp, acl_block, f); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :mlxsw_sp_flower_destroy (mlxsw_sp, acl_block, f);return 0 ; -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return mlxsw_sp_flower_stats (mlxsw_sp, acl_block, f); -case TC_CLSFLOWER_TMPLT_CREATE : +case FLOW_CLS_TMPLT_CREATE :return mlxsw_sp_flower_tmplt_create (mlxsw_sp, acl_block, f); -case TC_CLSFLOWER_TMPLT_DESTROY : +case FLOW_CLS_TMPLT_DESTROY :mlxsw_sp_flower_tmplt_destroy (mlxsw_sp, acl_block, f);return 0 ;default :
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +5 -5
@@ -807,19 +807,19 @@ extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops;/* spectrum_flower.c */ int mlxsw_sp_flower_replace (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f); +struct flow_cls_offload *f);void mlxsw_sp_flower_destroy (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f); +struct flow_cls_offload *f);int mlxsw_sp_flower_stats (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f); +struct flow_cls_offload *f);int mlxsw_sp_flower_tmplt_create (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f); +struct flow_cls_offload *f);void mlxsw_sp_flower_tmplt_destroy (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f); +struct flow_cls_offload *f);/* spectrum_qdisc.c */ int mlxsw_sp_tc_qdisc_init (struct mlxsw_sp_port *mlxsw_sp_port);
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +17 -17
@@ -121,10 +121,10 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, }static int mlxsw_sp_flower_parse_meta (struct mlxsw_sp_acl_rule_info *rulei, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,struct mlxsw_sp_acl_block *block) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct mlxsw_sp_port *mlxsw_sp_port;struct net_device *ingress_dev;struct flow_match_meta match;
@@ -164,7 +164,7 @@ static int mlxsw_sp_flower_parse_meta(struct mlxsw_sp_acl_rule_info *rulei, }static void mlxsw_sp_flower_parse_ipv4 (struct mlxsw_sp_acl_rule_info *rulei, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {struct flow_match_ipv4_addrs match;
@@ -179,7 +179,7 @@ static void mlxsw_sp_flower_parse_ipv4(struct mlxsw_sp_acl_rule_info *rulei, }static void mlxsw_sp_flower_parse_ipv6 (struct mlxsw_sp_acl_rule_info *rulei, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {struct flow_match_ipv6_addrs match;
@@ -213,10 +213,10 @@ static void mlxsw_sp_flower_parse_ipv6(struct mlxsw_sp_acl_rule_info *rulei,static int mlxsw_sp_flower_parse_ports (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_rule_info *rulei, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,u8 ip_proto) { -const struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +const struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_match_ports match;if (!flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_PORTS ))
@@ -240,10 +240,10 @@ static int mlxsw_sp_flower_parse_ports(struct mlxsw_sp *mlxsw_sp,static int mlxsw_sp_flower_parse_tcp (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_rule_info *rulei, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,u8 ip_proto) { -const struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +const struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_match_tcp match;if (!flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_TCP ))
@@ -265,10 +265,10 @@ static int mlxsw_sp_flower_parse_tcp(struct mlxsw_sp *mlxsw_sp,static int mlxsw_sp_flower_parse_ip (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_rule_info *rulei, -struct tc_cls_flower_offload *f, +struct flow_cls_offload *f,u16 n_proto) { -const struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +const struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_match_ip match;if (!flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_IP ))
@@ -299,9 +299,9 @@ static int mlxsw_sp_flower_parse_ip(struct mlxsw_sp *mlxsw_sp,static int mlxsw_sp_flower_parse (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block,struct mlxsw_sp_acl_rule_info *rulei, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_dissector *dissector = rule->match.dissector;u16 n_proto_mask =0 ;u16 n_proto_key =0 ;
@@ -426,7 +426,7 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,int mlxsw_sp_flower_replace (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {struct mlxsw_sp_acl_rule_info *rulei;struct mlxsw_sp_acl_ruleset *ruleset;
@@ -473,7 +473,7 @@ int mlxsw_sp_flower_replace(struct mlxsw_sp *mlxsw_sp,void mlxsw_sp_flower_destroy (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {struct mlxsw_sp_acl_ruleset *ruleset;struct mlxsw_sp_acl_rule *rule;
@@ -495,7 +495,7 @@ void mlxsw_sp_flower_destroy(struct mlxsw_sp *mlxsw_sp,int mlxsw_sp_flower_stats (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {struct mlxsw_sp_acl_ruleset *ruleset;struct mlxsw_sp_acl_rule *rule;
@@ -531,7 +531,7 @@ int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,int mlxsw_sp_flower_tmplt_create (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {struct mlxsw_sp_acl_ruleset *ruleset;struct mlxsw_sp_acl_rule_info rulei;
@@ -552,7 +552,7 @@ int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp,void mlxsw_sp_flower_tmplt_destroy (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_acl_block *block, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {struct mlxsw_sp_acl_ruleset *ruleset;
drivers/net/ethernet/mscc/ocelot_flower.c +11 -11
@@ -19,7 +19,7 @@ static u16 get_prio(u32 prio)return prio >>16 ; } -static int ocelot_flower_parse_action (struct tc_cls_flower_offload *f, +static int ocelot_flower_parse_action (struct flow_cls_offload *f,struct ocelot_ace_rule *rule) {const struct flow_action_entry *a;
@@ -44,10 +44,10 @@ static int ocelot_flower_parse_action(struct tc_cls_flower_offload *f,return 0 ; } -static int ocelot_flower_parse (struct tc_cls_flower_offload *f, +static int ocelot_flower_parse (struct flow_cls_offload *f,struct ocelot_ace_rule *ocelot_rule) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);struct flow_dissector *dissector = rule->match.dissector; if (dissector->used_keys &
@@ -174,7 +174,7 @@ static int ocelot_flower_parse(struct tc_cls_flower_offload *f, }static -struct ocelot_ace_rule *ocelot_ace_rule_create (struct tc_cls_flower_offload *f, +struct ocelot_ace_rule *ocelot_ace_rule_create (struct flow_cls_offload *f,struct ocelot_port_block *block) {struct ocelot_ace_rule *rule;
@@ -188,7 +188,7 @@ struct ocelot_ace_rule *ocelot_ace_rule_create(struct tc_cls_flower_offload *f,return rule; } -static int ocelot_flower_replace (struct tc_cls_flower_offload *f, +static int ocelot_flower_replace (struct flow_cls_offload *f,struct ocelot_port_block *port_block) {struct ocelot_ace_rule *rule;
@@ -212,7 +212,7 @@ static int ocelot_flower_replace(struct tc_cls_flower_offload *f,return 0 ; } -static int ocelot_flower_destroy (struct tc_cls_flower_offload *f, +static int ocelot_flower_destroy (struct flow_cls_offload *f,struct ocelot_port_block *port_block) {struct ocelot_ace_rule rule;
@@ -230,7 +230,7 @@ static int ocelot_flower_destroy(struct tc_cls_flower_offload *f,return 0 ; } -static int ocelot_flower_stats_update (struct tc_cls_flower_offload *f, +static int ocelot_flower_stats_update (struct flow_cls_offload *f,struct ocelot_port_block *port_block) {struct ocelot_ace_rule rule;
@@ -247,15 +247,15 @@ static int ocelot_flower_stats_update(struct tc_cls_flower_offload *f,return 0 ; } -static int ocelot_setup_tc_cls_flower (struct tc_cls_flower_offload *f, +static int ocelot_setup_tc_cls_flower (struct flow_cls_offload *f,struct ocelot_port_block *port_block) {switch (f->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return ocelot_flower_replace (f, port_block); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return ocelot_flower_destroy (f, port_block); -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return ocelot_flower_stats_update (f, port_block);default :return -EOPNOTSUPP ;
drivers/net/ethernet/netronome/nfp/flower/action.c +7 -7
@@ -171,7 +171,7 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output, }static bool -nfp_flower_tun_is_gre (struct tc_cls_flower_offload *flow,int start_idx) +nfp_flower_tun_is_gre (struct flow_cls_offload *flow,int start_idx) {struct flow_action_entry *act = flow->rule->action.entries;int num_act = flow->rule->action.num_entries;
@@ -188,7 +188,7 @@ nfp_flower_tun_is_gre(struct tc_cls_flower_offload *flow, int start_idx)static enum nfp_flower_tun_type nfp_fl_get_tun_from_act (struct nfp_app *app, -struct tc_cls_flower_offload *flow, +struct flow_cls_offload *flow,const struct flow_action_entry *act,int act_idx) {const struct ip_tunnel_info *tun = act->tunnel;
@@ -669,11 +669,11 @@ struct nfp_flower_pedit_acts { };static int -nfp_fl_commit_mangle (struct tc_cls_flower_offload *flow,char *nfp_action, +nfp_fl_commit_mangle (struct flow_cls_offload *flow,char *nfp_action,int *a_len,struct nfp_flower_pedit_acts *set_act,u32 *csum_updated) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (flow); +struct flow_rule *rule =flow_cls_offload_flow_rule (flow);size_t act_size =0 ;u8 ip_proto =0 ;
@@ -771,7 +771,7 @@ nfp_fl_commit_mangle(struct tc_cls_flower_offload *flow, char *nfp_action,static int nfp_fl_pedit (const struct flow_action_entry *act, -struct tc_cls_flower_offload *flow,char *nfp_action,int *a_len, +struct flow_cls_offload *flow,char *nfp_action,int *a_len,u32 *csum_updated,struct nfp_flower_pedit_acts *set_act,struct netlink_ext_ack *extack) {
@@ -858,7 +858,7 @@ nfp_flower_output_action(struct nfp_app *app, static int nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, - struct tc_cls_flower_offload *flow, + struct flow_cls_offload *flow, struct nfp_fl_payload *nfp_fl, int *a_len, struct net_device *netdev, enum nfp_flower_tun_type *tun_type, int *tun_out_cnt,
@@ -1021,7 +1021,7 @@ static bool nfp_fl_check_mangle_end(struct flow_action *flow_act, }int nfp_flower_compile_action (struct nfp_app *app, -struct tc_cls_flower_offload *flow, +struct flow_cls_offload *flow,struct net_device *netdev,struct nfp_fl_payload *nfp_flow,struct netlink_ext_ack *extack)
drivers/net/ethernet/netronome/nfp/flower/main.h +3 -3
@@ -343,19 +343,19 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app,struct nfp_fl_payload *sub_flow1, struct nfp_fl_payload *sub_flow2);int nfp_flower_compile_flow_match (struct nfp_app *app, -struct tc_cls_flower_offload *flow, +struct flow_cls_offload *flow,struct nfp_fl_key_ls *key_ls,struct net_device *netdev,struct nfp_fl_payload *nfp_flow,enum nfp_flower_tun_type tun_type,struct netlink_ext_ack *extack);int nfp_flower_compile_action (struct nfp_app *app, -struct tc_cls_flower_offload *flow, +struct flow_cls_offload *flow,struct net_device *netdev,struct nfp_fl_payload *nfp_flow,struct netlink_ext_ack *extack);int nfp_compile_flow_metadata (struct nfp_app *app, -struct tc_cls_flower_offload *flow, +struct flow_cls_offload *flow,struct nfp_fl_payload *nfp_flow,struct net_device *netdev,struct netlink_ext_ack *extack);
drivers/net/ethernet/netronome/nfp/flower/match.c +22 -22
126 lines not on this page · raw message
drivers/net/ethernet/netronome/nfp/flower/metadata.c +1 -1
@@ -290,7 +290,7 @@ nfp_check_mask_remove(struct nfp_app *app, char *mask_data, u32 mask_len, }int nfp_compile_flow_metadata (struct nfp_app *app, -struct tc_cls_flower_offload *flow, +struct flow_cls_offload *flow,struct nfp_fl_payload *nfp_flow,struct net_device *netdev,struct netlink_ext_ack *extack)
drivers/net/ethernet/netronome/nfp/flower/offload.c +15 -15
@@ -121,9 +121,9 @@ nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow,return 0 ; } -static bool nfp_flower_check_higher_than_mac (struct tc_cls_flower_offload *f) +static bool nfp_flower_check_higher_than_mac (struct flow_cls_offload *f) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);return flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_IPV4_ADDRS ) || flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS) ||
@@ -131,9 +131,9 @@ static bool nfp_flower_check_higher_than_mac(struct tc_cls_flower_offload *f)flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ICMP ); } -static bool nfp_flower_check_higher_than_l3 (struct tc_cls_flower_offload *f) +static bool nfp_flower_check_higher_than_l3 (struct flow_cls_offload *f) { -struct flow_rule *rule =tc_cls_flower_offload_flow_rule (f); +struct flow_rule *rule =flow_cls_offload_flow_rule (f);return flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_PORTS ) ||flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ICMP );
@@ -212,11 +212,11 @@ static int nfp_flower_calculate_key_layers(struct nfp_app *app, struct net_device *netdev, struct nfp_fl_key_ls *ret_key_ls, - struct tc_cls_flower_offload *flow, + struct flow_cls_offload *flow, enum nfp_flower_tun_type *tun_type, struct netlink_ext_ack *extack) { - struct flow_rule *rule = tc_cls_flower_offload_flow_rule(flow); + struct flow_rule *rule = flow_cls_offload_flow_rule(flow);struct flow_dissector *dissector = rule->match.dissector;struct flow_match_basic basic = {NULL ,NULL };struct nfp_flower_priv *priv = app->priv;
@@ -866,7 +866,7 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app,struct nfp_fl_payload *sub_flow1, struct nfp_fl_payload *sub_flow2) { - struct tc_cls_flower_offload merge_tc_off; + struct flow_cls_offload merge_tc_off;struct nfp_flower_priv *priv = app->priv;struct netlink_ext_ack *extack =NULL ;struct nfp_fl_payload *merge_flow;
@@ -962,7 +962,7 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app,*/ static int nfp_flower_add_offload (struct nfp_app *app,struct net_device *netdev, -struct tc_cls_flower_offload *flow) +struct flow_cls_offload *flow) {enum nfp_flower_tun_type tun_type =NFP_FL_TUNNEL_NONE ;struct nfp_flower_priv *priv = app->priv;
@@ -1125,7 +1125,7 @@ nfp_flower_del_linked_merge_flows(struct nfp_app *app,*/ static int nfp_flower_del_offload (struct nfp_app *app,struct net_device *netdev, -struct tc_cls_flower_offload *flow) +struct flow_cls_offload *flow) {struct nfp_flower_priv *priv = app->priv;struct netlink_ext_ack *extack =NULL ;
@@ -1232,7 +1232,7 @@ nfp_flower_update_merge_stats(struct nfp_app *app,*/ static int nfp_flower_get_stats (struct nfp_app *app,struct net_device *netdev, -struct tc_cls_flower_offload *flow) +struct flow_cls_offload *flow) {struct nfp_flower_priv *priv = app->priv;struct netlink_ext_ack *extack =NULL ;
@@ -1265,17 +1265,17 @@ nfp_flower_get_stats(struct nfp_app *app, struct net_device *netdev,static int nfp_flower_repr_offload (struct nfp_app *app,struct net_device *netdev, -struct tc_cls_flower_offload *flower) +struct flow_cls_offload *flower) {if (!eth_proto_is_802_3 (flower->common.protocol))return -EOPNOTSUPP ;switch (flower->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return nfp_flower_add_offload (app, netdev, flower); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return nfp_flower_del_offload (app, netdev, flower); -case TC_CLSFLOWER_STATS : +case FLOW_CLS_STATS :return nfp_flower_get_stats (app, netdev, flower);default :return -EOPNOTSUPP ;
@@ -1385,7 +1385,7 @@ static int nfp_flower_setup_indr_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) { struct nfp_flower_indr_block_cb_priv *priv = cb_priv; -struct tc_cls_flower_offload *flower = type_data; +struct flow_cls_offload *flower = type_data;if (flower->common.chain_index)return -EOPNOTSUPP ;
drivers/net/ethernet/qlogic/qede/qede.h +1 -1
@@ -551,7 +551,7 @@ int qede_txq_has_work(struct qede_tx_queue *txq);void qede_recycle_rx_bd_ring (struct qede_rx_queue *rxq,u8 count);void qede_update_rx_prod (struct qede_dev *edev,struct qede_rx_queue *rxq);int qede_add_tc_flower_fltr (struct qede_dev *edev,__be16 proto, -struct tc_cls_flower_offload *f); +struct flow_cls_offload *f);#define RX_RING_SIZE_POW 13#define RX_RING_SIZE ((u16)BIT(RX_RING_SIZE_POW))
drivers/net/ethernet/qlogic/qede/qede_filter.c +1 -1
@@ -1943,7 +1943,7 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto, }int qede_add_tc_flower_fltr (struct qede_dev *edev,__be16 proto, -struct tc_cls_flower_offload *f) +struct flow_cls_offload *f) {struct qede_arfs_fltr_node *n;int min_hlen, rc = -EINVAL ;
drivers/net/ethernet/qlogic/qede/qede_main.c +4 -4
@@ -548,13 +548,13 @@ static int qede_setup_tc(struct net_device *ndev, u8 num_tc) }static int -qede_set_flower (struct qede_dev *edev,struct tc_cls_flower_offload *f, +qede_set_flower (struct qede_dev *edev,struct flow_cls_offload *f,__be16 proto) {switch (f->command) { -case TC_CLSFLOWER_REPLACE : +case FLOW_CLS_REPLACE :return qede_add_tc_flower_fltr (edev, proto, f); -case TC_CLSFLOWER_DESTROY : +case FLOW_CLS_DESTROY :return qede_delete_flow_filter (edev, f->cookie);default :return -EOPNOTSUPP ;
@@ -564,7 +564,7 @@ qede_set_flower(struct qede_dev *edev, struct tc_cls_flower_offload *f,static int qede_setup_tc_block_cb (enum tc_setup_type type,void *type_data,void *cb_priv) { -struct tc_cls_flower_offload *f; +struct flow_cls_offload *f;struct qede_dev *edev = cb_priv;if (!tc_cls_can_offload_and_chain0 (edev->ndev, type_data))
include/net/flow_offload.h +30 -0
@@ -298,4 +298,34 @@ 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); +enum flow_cls_command { +FLOW_CLS_REPLACE , +FLOW_CLS_DESTROY , +FLOW_CLS_STATS , +FLOW_CLS_TMPLT_CREATE , +FLOW_CLS_TMPLT_DESTROY , +}; + +struct flow_cls_common_offload { +u32 chain_index; +__be16 protocol; +u32 prio; +struct netlink_ext_ack *extack; +}; + +struct flow_cls_offload { +struct flow_cls_common_offload common; +enum flow_cls_command command; +unsigned long cookie; +struct flow_rule *rule; +struct flow_stats stats; +u32 classid; +}; + +static inline struct flow_rule * +flow_cls_offload_flow_rule (struct flow_cls_offload *flow_cmd) +{ +return flow_cmd->rule; +} +#endif /* _NET_FLOW_OFFLOAD_H */
include/net/pkt_cls.h +5 -35
@@ -535,13 +535,6 @@ int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, void *type_data, bool err_stop);unsigned int tcf_exts_num_actions (struct tcf_exts *exts); -struct tc_cls_common_offload { -u32 chain_index; -__be16 protocol; -u32 prio; -struct netlink_ext_ack *extack; -}; -struct tc_cls_u32_knode {struct tcf_exts *exts;struct tcf_result *res;
@@ -569,7 +562,7 @@ enum tc_clsu32_command { };struct tc_cls_u32_offload { -struct tc_cls_common_offload common; +struct flow_cls_common_offload common;/* knode values */ enum tc_clsu32_command command;union {
@@ -596,7 +589,7 @@ static inline bool tc_can_offload_extack(const struct net_device *dev,static inline bool tc_cls_can_offload_and_chain0 (const struct net_device *dev, -struct tc_cls_common_offload *common) +struct flow_cls_common_offload *common) {if (!tc_can_offload_extack (dev, common->extack))return false;
@@ -638,7 +631,7 @@ static inline bool tc_in_hw(u32 flags) }static inline void -tc_cls_common_offload_init (struct tc_cls_common_offload *cls_common, +tc_cls_common_offload_init (struct flow_cls_common_offload *cls_common,const struct tcf_proto *tp,u32 flags,struct netlink_ext_ack *extack) {
@@ -649,29 +642,6 @@ tc_cls_common_offload_init(struct tc_cls_common_offload *cls_common, cls_common->extack = extack; } -enum tc_fl_command { -TC_CLSFLOWER_REPLACE , -TC_CLSFLOWER_DESTROY , -TC_CLSFLOWER_STATS , -TC_CLSFLOWER_TMPLT_CREATE , -TC_CLSFLOWER_TMPLT_DESTROY , -}; - -struct tc_cls_flower_offload { -struct tc_cls_common_offload common; -enum tc_fl_command command; -unsigned long cookie; -struct flow_rule *rule; -struct flow_stats stats; -u32 classid; -}; - -static inline struct flow_rule * -tc_cls_flower_offload_flow_rule (struct tc_cls_flower_offload *tc_flow_cmd) -{ -return tc_flow_cmd->rule; -} -enum tc_matchall_command {TC_CLSMATCHALL_REPLACE ,TC_CLSMATCHALL_DESTROY ,
@@ -679,7 +649,7 @@ enum tc_matchall_command { };struct tc_cls_matchall_offload { -struct tc_cls_common_offload common; +struct flow_cls_common_offload common;enum tc_matchall_command command;struct flow_rule *rule;struct flow_stats stats;
@@ -692,7 +662,7 @@ enum tc_clsbpf_command { };struct tc_cls_bpf_offload { -struct tc_cls_common_offload common; +struct flow_cls_common_offload common;enum tc_clsbpf_command command;struct tcf_exts *exts;struct bpf_prog *prog;
net/sched/cls_flower.c +12 -12
@@ -390,14 +390,14 @@ static void fl_destroy_filter_work(struct work_struct *work)static void fl_hw_destroy_filter (struct tcf_proto *tp,struct cls_fl_filter *f,bool rtnl_held,struct netlink_ext_ack *extack) { -struct tc_cls_flower_offload cls_flower = {};struct tcf_block *block = tp->chain->block; +struct flow_cls_offload cls_flower = {};if (!rtnl_held)rtnl_lock ();tc_cls_common_offload_init (&cls_flower.common, tp, f->flags, extack); - cls_flower.command =TC_CLSFLOWER_DESTROY ; + cls_flower.command =FLOW_CLS_DESTROY ; cls_flower.cookie = (unsigned long ) f;tc_setup_cb_call (block,TC_SETUP_CLSFLOWER , &cls_flower, false);
@@ -415,8 +415,8 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, struct netlink_ext_ack *extack) {struct cls_fl_head *head =fl_head_dereference (tp); -struct tc_cls_flower_offload cls_flower = {};struct tcf_block *block = tp->chain->block; +struct flow_cls_offload cls_flower = {};bool skip_sw =tc_skip_sw (f->flags);int err =0 ;
@@ -430,7 +430,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, }tc_cls_common_offload_init (&cls_flower.common, tp, f->flags, extack); - cls_flower.command =TC_CLSFLOWER_REPLACE ; + cls_flower.command =FLOW_CLS_REPLACE ; cls_flower.cookie = (unsigned long ) f; cls_flower.rule->match.dissector = &f->mask->dissector; cls_flower.rule->match.mask = &f->mask->key;
@@ -479,14 +479,14 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,static void fl_hw_update_stats (struct tcf_proto *tp,struct cls_fl_filter *f,bool rtnl_held) { -struct tc_cls_flower_offload cls_flower = {};struct tcf_block *block = tp->chain->block; +struct flow_cls_offload cls_flower = {};if (!rtnl_held)rtnl_lock ();tc_cls_common_offload_init (&cls_flower.common, tp, f->flags,NULL ); - cls_flower.command =TC_CLSFLOWER_STATS ; + cls_flower.command =FLOW_CLS_STATS ; cls_flower.cookie = (unsigned long ) f; cls_flower.classid = f->res.classid;
@@ -1736,8 +1736,8 @@ fl_get_next_hw_filter(struct tcf_proto *tp, struct cls_fl_filter *f, bool add)static int fl_reoffload (struct tcf_proto *tp,bool add,tc_setup_cb_t *cb,void *cb_priv,struct netlink_ext_ack *extack) { -struct tc_cls_flower_offload cls_flower = {};struct tcf_block *block = tp->chain->block; +struct flow_cls_offload cls_flower = {};struct cls_fl_filter *f =NULL ;int err;
@@ -1758,7 +1758,7 @@ static int fl_reoffload(struct tcf_proto *tp, bool add, tc_setup_cb_t *cb,tc_cls_common_offload_init (&cls_flower.common, tp, f->flags, extack); cls_flower.command = add ? -TC_CLSFLOWER_REPLACE :TC_CLSFLOWER_DESTROY ; +FLOW_CLS_REPLACE :FLOW_CLS_DESTROY ; cls_flower.cookie = (unsigned long )f; cls_flower.rule->match.dissector = &f->mask->dissector; cls_flower.rule->match.mask = &f->mask->key;
@@ -1802,7 +1802,7 @@ static int fl_reoffload(struct tcf_proto *tp, bool add, tc_setup_cb_t *cb,static int fl_hw_create_tmplt (struct tcf_chain *chain,struct fl_flow_tmplt *tmplt) { -struct tc_cls_flower_offload cls_flower = {}; +struct flow_cls_offload cls_flower = {};struct tcf_block *block = chain->block; cls_flower.rule =flow_rule_alloc (0 );
@@ -1810,7 +1810,7 @@ static int fl_hw_create_tmplt(struct tcf_chain *chain,return -ENOMEM ; cls_flower.common.chain_index = chain->index; - cls_flower.command =TC_CLSFLOWER_TMPLT_CREATE ; + cls_flower.command =FLOW_CLS_TMPLT_CREATE ; cls_flower.cookie = (unsigned long ) tmplt; cls_flower.rule->match.dissector = &tmplt->dissector; cls_flower.rule->match.mask = &tmplt->mask;
@@ -1828,11 +1828,11 @@ static int fl_hw_create_tmplt(struct tcf_chain *chain,static void fl_hw_destroy_tmplt (struct tcf_chain *chain,struct fl_flow_tmplt *tmplt) { -struct tc_cls_flower_offload cls_flower = {}; +struct flow_cls_offload cls_flower = {};struct tcf_block *block = chain->block; cls_flower.common.chain_index = chain->index; - cls_flower.command =TC_CLSFLOWER_TMPLT_DESTROY ; + cls_flower.command =FLOW_CLS_TMPLT_DESTROY ; cls_flower.cookie = (unsigned long ) tmplt;tc_setup_cb_call (block,TC_SETUP_CLSFLOWER , &cls_flower, false);
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH v4 12/12 netfilter: nf_tables: add hardware offload support
In reply to Pablo Neira AyusoThis patch adds hardware offload support for nftables through the existing netdev_ops->ndo_setup_tc() interface, the TC_SETUP_CLSFLOWER classifier and the flow rule API. This hardware offload support is available for the NFPROTO_NETDEV family and the ingress hook.
Each nftables expression has a new ->offload interface, that is used to populate the flow rule object that is attached to the transaction object.
There is a new per-table NFT_TABLE_F_HW flag, that is set on to offload an entire table, including all of its chains.
This patch supports for basic metadata (layer 3 and 4 protocol numbers), 5-tuple payload matching and the accept/drop actions; this also includes basechain hardware offload only.
---
v4: "we want the per-device offload enable flags" - Jakub Kicinski.
This patch enables offload flag per base chain (ie. per-device), see example in cover letter, no need for ethtool -k knob.
include/net/netfilter/nf_tables.h | 14 ++ include/net/netfilter/nf_tables_offload.h | 76 +++++++++ include/uapi/linux/netfilter/nf_tables.h | 2 + net/netfilter/Makefile | 2 +- net/netfilter/nf_tables_api.c | 39 ++++- net/netfilter/nf_tables_offload.c | 267 ++++++++++++++++++++++++++++++ net/netfilter/nft_cmp.c | 53 ++++++ net/netfilter/nft_immediate.c | 31 ++++ net/netfilter/nft_meta.c | 27 +++ net/netfilter/nft_payload.c | 187 +++++++++++++++++++++ 10 files changed, 691 insertions(+), 7 deletions(-) create mode 100644 include/net/netfilter/nf_tables_offload.h create mode 100644 net/netfilter/nf_tables_offload.c
include/net/netfilter/nf_tables.h +14 -0
@@ -161,6 +161,7 @@ struct nft_ctx {const struct nlattr *const *nla;u32 portid;u32 seq; +u16 flags;u8 family;u8 level;bool report;
@@ -735,6 +736,9 @@ enum nft_trans_phase { NFT_TRANS_RELEASE }; +struct nft_flow_rule ; +struct nft_offload_ctx ; +/** * struct nft_expr_ops - nf_tables expression operations *
@@ -777,6 +781,10 @@ struct nft_expr_ops { const struct nft_data **data);bool (*gc)(struct net *net,const struct nft_expr *expr); +int (*offload)(struct nft_offload_ctx *ctx, +struct nft_flow_rule *flow, +const struct nft_expr *expr); +u32 offload_flags;const struct nft_expr_type *type;void *data; };
@@ -859,6 +867,7 @@ static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule)enum nft_chain_flags {NFT_BASE_CHAIN =0x1 , +NFT_CHAIN_HW_OFFLOAD =0x2 , };/**
@@ -942,6 +951,7 @@ struct nft_stats {* @stats: per-cpu chain stats * @chain: the chain * @dev_name: device name that this base chain is attached to (if any) +* @cb_list: list of flow block callbacks (for hardware offload) */ struct nft_base_chain {struct nf_hook_ops ops;
@@ -951,6 +961,7 @@ struct nft_base_chain {struct nft_stats __percpu *stats;struct nft_chain chain;char dev_name[IFNAMSIZ ]; +struct list_head cb_list; };static inline struct nft_base_chain *nft_base_chain (const struct nft_chain *chain)
@@ -1322,11 +1333,14 @@ struct nft_trans {struct nft_trans_rule {struct nft_rule *rule; +struct nft_flow_rule *flow;u32 rule_id; };#define nft_trans_rule (trans) \ (((struct nft_trans_rule *)trans->data)->rule) +#define nft_trans_flow_rule (trans) \ + (((struct nft_trans_rule *)trans->data)->flow)#define nft_trans_rule_id (trans) \ (((struct nft_trans_rule *)trans->data)->rule_id)
include/net/netfilter/nf_tables_offload.h new file +76 -0
76 lines not on this page · raw message
include/uapi/linux/netfilter/nf_tables.h +2 -0
@@ -192,6 +192,7 @@ enum nft_table_attributes {* @NFTA_CHAIN_USE: number of references to this chain (NLA_U32) * @NFTA_CHAIN_TYPE: type name of the string (NLA_NUL_STRING) * @NFTA_CHAIN_COUNTERS: counter specification of the chain (NLA_NESTED: nft_counter_attributes) +* @NFTA_CHAIN_FLAGS: chain flags */ enum nft_chain_attributes {NFTA_CHAIN_UNSPEC ,
@@ -204,6 +205,7 @@ enum nft_chain_attributes {NFTA_CHAIN_TYPE ,NFTA_CHAIN_COUNTERS ,NFTA_CHAIN_PAD , +NFTA_CHAIN_FLAGS , __NFTA_CHAIN_MAX };#define NFTA_CHAIN_MAX (__NFTA_CHAIN_MAX - 1)
net/netfilter/Makefile +1 -1
@@ -78,7 +78,7 @@ nf_tables-objs := nf_tables_core.o nf_tables_api.o nft_chain_filter.o \ nf_tables_trace.o nft_immediate.o nft_cmp.o nft_range.o \ nft_bitwise.o nft_byteorder.o nft_payload.o nft_lookup.o \ nft_dynset.o nft_meta.o nft_rt.o nft_exthdr.o \ - nft_chain_route.o + nft_chain_route.o nf_tables_offload.o nf_tables_set-objs := nf_tables_set_core.o \ nft_set_hash.o nft_set_bitmap.o nft_set_rbtree.o
net/netfilter/nf_tables_api.c +33 -6
@@ -18,6 +18,7 @@#include <net/netfilter/nf_flow_table.h> #include <net/netfilter/nf_tables_core.h> #include <net/netfilter/nf_tables.h> +#include <net/netfilter/nf_tables_offload.h> #include <net/net_namespace.h> #include <net/sock.h>
@@ -97,6 +98,7 @@ static void nft_ctx_init(struct nft_ctx *ctx, ctx->nla = nla; ctx->portid =NETLINK_CB (skb).portid; ctx->report =nlmsg_report (nlh); + ctx->flags = nlh->nlmsg_flags; ctx->seq = nlh->nlmsg_seq; }
@@ -1169,6 +1171,7 @@ static const struct nla_policy nft_chain_policy[NFTA_CHAIN_MAX + 1] = { [NFTA_CHAIN_POLICY] = { .type = NLA_U32 }, [NFTA_CHAIN_TYPE] = { .type = NLA_STRING }, [NFTA_CHAIN_COUNTERS] = { .type = NLA_NESTED }, + [NFTA_CHAIN_FLAGS] = { .type = NLA_U32 }, };static const struct nla_policy nft_hook_policy[NFTA_HOOK_MAX +1 ] = {
@@ -1603,7 +1606,7 @@ static struct nft_rule **nf_tables_chain_alloc_rules(const struct nft_chain *cha }static int nf_tables_addchain (struct nft_ctx *ctx,u8 family,u8 genmask, -u8 policy) +u8 policy,u32 flags) {const struct nlattr *const *nla = ctx->nla;struct nft_table *table = ctx->table;
@@ -1657,8 +1660,9 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask, ops->hook = hook.type->hooks[ops->hooknum]; ops->dev = hook.dev; - chain->flags |=NFT_BASE_CHAIN ; + chain->flags |=NFT_BASE_CHAIN | flags; basechain->policy =NF_ACCEPT ; +INIT_LIST_HEAD (&basechain->cb_list); }else { chain =kzalloc (sizeof (*chain),GFP_KERNEL );if (chain ==NULL )
@@ -1718,7 +1722,8 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,return err; } -static int nf_tables_updchain (struct nft_ctx *ctx,u8 genmask,u8 policy) +static int nf_tables_updchain (struct nft_ctx *ctx,u8 genmask,u8 policy, +u32 flags) {const struct nlattr *const *nla = ctx->nla;struct nft_table *table = ctx->table;
@@ -1730,6 +1735,9 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy)struct nft_trans *trans;int err; +if (chain->flags ^ flags) +return -EOPNOTSUPP ; +if (nla[NFTA_CHAIN_HOOK ]) {if (!nft_is_base_chain (chain))return -EBUSY ;
@@ -1835,6 +1843,7 @@ static int nf_tables_newchain(struct net *net, struct sock *nlsk,u8 policy =NF_ACCEPT ;struct nft_ctx ctx;u64 handle =0 ; +u32 flags =0 ;lockdep_assert_held (&net->nft.commit_mutex);
@@ -1889,6 +1898,9 @@ static int nf_tables_newchain(struct net *net, struct sock *nlsk, } } +if (nla[NFTA_CHAIN_FLAGS ]) + flags =ntohl (nla_get_be32 (nla[NFTA_CHAIN_FLAGS ])); +nft_ctx_init (&ctx, net, skb, nlh, family, table, chain, nla);if (chain !=NULL ) {
@@ -1899,10 +1911,10 @@ static int nf_tables_newchain(struct net *net, struct sock *nlsk,if (nlh->nlmsg_flags &NLM_F_REPLACE )return -EOPNOTSUPP ; -return nf_tables_updchain (&ctx, genmask, policy); +return nf_tables_updchain (&ctx, genmask, policy, flags); } -return nf_tables_addchain (&ctx, family, genmask, policy); +return nf_tables_addchain (&ctx, family, genmask, policy, flags); } static int nf_tables_delchain(struct net *net, struct sock *nlsk,
@@ -2638,6 +2650,7 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,u8 genmask =nft_genmask_next (net);struct nft_expr_info *info =NULL ;int family = nfmsg->nfgen_family; +struct nft_flow_rule *flow;struct nft_table *table;struct nft_chain *chain;struct nft_rule *rule, *old_rule =NULL ;
@@ -2784,7 +2797,8 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,list_add_tail_rcu (&rule->list, &old_rule->list); }else { -if (nft_trans_rule_add (&ctx,NFT_MSG_NEWRULE , rule) ==NULL ) { + trans =nft_trans_rule_add (&ctx,NFT_MSG_NEWRULE , rule); +if (!trans) { err = -ENOMEM ; goto err2; }
@@ -2807,6 +2821,14 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,if (net->nft.validate_state ==NFT_VALIDATE_DO )return nft_table_validate (net, table); +if (chain->flags &NFT_CHAIN_HW_OFFLOAD ) { + flow =nft_flow_rule_create (rule); +if (IS_ERR (flow)) +return PTR_ERR (flow); + +nft_trans_flow_rule (trans) = flow; + } +return 0 ; err2:nf_tables_rule_release (&ctx, rule);
@@ -6604,6 +6626,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)struct nft_trans_elem *te;struct nft_chain *chain;struct nft_table *table; +int err;if (list_empty (&net->nft.commit_list)) {mutex_unlock (&net->nft.commit_mutex);
@@ -6614,6 +6637,10 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)if (nf_tables_validate (net) <0 )return -EAGAIN ; + err =nft_flow_rule_offload_commit (net); +if (err <0 ) +return err; +/* 1. Allocate space for next generation rules_gen_X[] */ list_for_each_entry_safe (trans, next, &net->nft.commit_list, list) {int ret;
net/netfilter/nf_tables_offload.c new file +267 -0
267 lines not on this page · raw message
net/netfilter/nft_cmp.c +53 -0
83 lines not on this page · raw message
net/netfilter/nft_immediate.c +31 -0
@@ -13,6 +13,7 @@#include <linux/netfilter/nf_tables.h> #include <net/netfilter/nf_tables_core.h> #include <net/netfilter/nf_tables.h> +#include <net/netfilter/nf_tables_offload.h> void nft_immediate_eval(const struct nft_expr *expr, struct nft_regs *regs,
@@ -124,6 +125,34 @@ static int nft_immediate_validate(const struct nft_ctx *ctx,return 0 ; } +static int nft_immediate_offload (struct nft_offload_ctx *ctx, +struct nft_flow_rule *flow, +const struct nft_expr *expr) +{ +const struct nft_immediate_expr *priv =nft_expr_priv (expr); +struct flow_action_entry *entry; +const struct nft_data *data; + +if (priv->dreg !=NFT_REG_VERDICT ) +return -EOPNOTSUPP ; + + entry = &flow->rule->action.entries[ctx->num_actions++]; + + data = &priv->data; +switch (data->verdict.code) { +case NF_ACCEPT : + entry->id =FLOW_ACTION_ACCEPT ; +break ; +case NF_DROP : + entry->id =FLOW_ACTION_DROP ; +break ; +default : +return -EOPNOTSUPP ; + } + +return 0 ; +} +static const struct nft_expr_ops nft_imm_ops = { .type = &nft_imm_type, .size =NFT_EXPR_SIZE (sizeof (struct nft_immediate_expr )),
@@ -133,6 +162,8 @@ static const struct nft_expr_ops nft_imm_ops = { .deactivate = nft_immediate_deactivate, .dump = nft_immediate_dump, .validate = nft_immediate_validate, + .offload = nft_immediate_offload, + .offload_flags = NFT_OFFLOAD_F_ACTION, };struct nft_expr_type nft_imm_type__read_mostly = {
net/netfilter/nft_meta.c +27 -0
@@ -21,6 +21,7 @@#include <net/tcp_states.h> /* for TCP_TIME_WAIT */ #include <net/netfilter/nf_tables.h> #include <net/netfilter/nf_tables_core.h> +#include <net/netfilter/nf_tables_offload.h> #include <uapi/linux/netfilter_bridge.h> /* NF_BR_PRE_ROUTING */
@@ -515,6 +516,31 @@ static void nft_meta_set_destroy(const struct nft_ctx *ctx,static_branch_dec (&nft_trace_enabled); } +static int nft_meta_get_offload (struct nft_offload_ctx *ctx, +struct nft_flow_rule *flow, +const struct nft_expr *expr) +{ +const struct nft_meta *priv =nft_expr_priv (expr); +struct nft_offload_reg *reg = &ctx->regs[priv->dreg]; + +switch (priv->key) { +case NFT_META_PROTOCOL : +NFT_OFFLOAD_MATCH (FLOW_DISSECTOR_KEY_BASIC , basic, n_proto, +sizeof (__u16), reg); +nft_offload_set_dependency (ctx,NFT_OFFLOAD_DEP_NETWORK ); +break ; +case NFT_META_L4PROTO : +NFT_OFFLOAD_MATCH (FLOW_DISSECTOR_KEY_BASIC , basic, ip_proto, +sizeof (__u8), reg); +nft_offload_set_dependency (ctx,NFT_OFFLOAD_DEP_TRANSPORT ); +break ; +default : +return -EOPNOTSUPP ; + } + +return 0 ; +} +static const struct nft_expr_ops nft_meta_get_ops = { .type = &nft_meta_type, .size =NFT_EXPR_SIZE (sizeof (struct nft_meta )),
@@ -522,6 +548,7 @@ static const struct nft_expr_ops nft_meta_get_ops = { .init = nft_meta_get_init, .dump = nft_meta_get_dump, .validate = nft_meta_get_validate, + .offload = nft_meta_get_offload, };static const struct nft_expr_ops nft_meta_set_ops = {
net/netfilter/nft_payload.c +187 -0
215 lines not on this page · raw message
Signature · 1 line
2.11.0
Jiri Pirko
maintainerRe: [PATCH net-next,v4 12/12] netfilter: nf_tables: add hardware offload support
Tue, Jul 09, 2019 at 10:55:50PM CEST, [email protected] wrote:
[...]
net/netfilter/nf_tables_offload.c line 191
Quoted 1 line
net/netfilter/nf_tables_offload.c new file +1
-0+if (!dev || !dev->netdev_ops->ndo_setup_tc)
Why didn't you rename ndo_setup_tc? I put a comment about it in the previous version thread. I expect that you can at least write why it is a wrong idea.
[...]
Pablo Neira Ayuso
maintainerRe: [PATCH net-next,v4 12/12] netfilter: nf_tables: add hardware offload support
Quoted 9 lines · Jiri Pirko
Tue, Jul 09, 2019 at 10:55:50PM CEST, [email protected] wrote:
[...]
net/netfilter/nf_tables_offload.c line 191
Quoted 1 line
net/netfilter/nf_tables_offload.c new file +1
-0+if (!dev || !dev->netdev_ops->ndo_setup_tc)Why didn't you rename
ndo_setup_tc? I put a comment about it in the previous version thread. I expect that you can at least write why it is a wrong idea.
This is a good idea. It happened that I read this email by when my new patch series was ready. I will follow up with a patch to address this rename as soon as the bug fixes are sorted out.
Thanks.
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Tue, 9 Jul 2019 22:55:38 +0200
Quoted 1 line
This patchset adds support for Netfilter hardware offloads.
Series applied with v5 of patch #12.
Please follow-up to any other feedback as necessary, thank you.