net: sched: summer cleanup part 2, ndo_setup_tc
Subsystems (22)
Jiri Pirko
maintainerv2 cover net: sched: summer cleanup part 2, ndo_setup_tc
From: Jiri Pirko <[email protected]>
This patchset focuses on ndo_setup_tc and its args. Currently there are couple of things that do not make much sense. The type is passed in struct tc_to_netdev, but as it is always required, should be arg of the ndo. Other things are passed as args but they are only relevant for cls offloads and not mqprio. Therefore, they should be pushed to struct. As the tc_to_netdev struct in the end is just a container of single pointer, we get rid of it and pass the struct according to type. So in the end, we have:ndo_setup_tc(dev, type, type_data_struct)
There are couple of cosmetics done on the way to make things smooth. Also, reported error is consolidated to eopnotsupp in case the asked offload is not supported.
v1->v2:
- added forgotten hns3pf bits
Jiri Pirko (16):
net: sched: make type an argument for ndo_setup_tc
net: sched: rename TC_SETUP_MATCHALL to TC_SETUP_CLSMATCHALL
net: sched: make egress_dev flag part of flower offload struct
cxgb4: push cls_u32 setup_tc processing into a separate function
ixgbe: push cls_u32 and mqprio setup_tc processing into separate
functions
mlx5e: push cls_flower and mqprio setup_tc processing into separate
functions
mlx5e_rep: push cls_flower setup_tc processing into a separate
function
mlxsw: spectrum: push cls_flower and cls_matchall setup_tc processing
into separate functions
mlxsw: spectrum: rename cls arg in matchall processing
dsa: push cls_matchall setup_tc processing into a separate function
nfp: change flows in apps that offload ndo_setup_tc
hns3pf: don't check handle during mqprio offload
net: sched: push cls related args into cls_common structure
net: sched: move prio into cls_common
net: sched: change return value of ndo_setup_tc for driver supporting
mqprio only
net: sched: get rid of struct tc_to_netdev
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 14 +-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 14 +-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 14 +-- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 43 +++++---- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c | 7 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.h | 6 +- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 13 +-- .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 13 +-- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 14 +-- drivers/net/ethernet/intel/i40e/i40e_main.c | 15 +-- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 65 +++++++------ drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 17 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 55 +++++------ drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 45 +++++---- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 4 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 102 ++++++++++++--------- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 2 +- .../net/ethernet/mellanox/mlxsw/spectrum_flower.c | 4 +- drivers/net/ethernet/netronome/nfp/bpf/main.c | 20 ++-- drivers/net/ethernet/netronome/nfp/flower/main.h | 4 +- .../net/ethernet/netronome/nfp/flower/offload.c | 15 ++- drivers/net/ethernet/netronome/nfp/nfp_app.h | 8 +- drivers/net/ethernet/netronome/nfp/nfp_port.c | 9 +- drivers/net/ethernet/netronome/nfp/nfp_port.h | 5 +- drivers/net/ethernet/sfc/efx.h | 4 +- drivers/net/ethernet/sfc/falcon/efx.h | 4 +- drivers/net/ethernet/sfc/falcon/tx.c | 13 +-- drivers/net/ethernet/sfc/tx.c | 13 +-- drivers/net/ethernet/ti/netcp_core.c | 13 +-- include/linux/netdevice.h | 30 ++---- include/net/pkt_cls.h | 23 ++++- net/dsa/slave.c | 39 ++++---- net/sched/cls_bpf.c | 24 ++--- net/sched/cls_flower.c | 60 +++++------- net/sched/cls_matchall.c | 31 +++---- net/sched/cls_u32.c | 95 ++++++++----------- net/sched/sch_mqprio.c | 16 ++-- 39 files changed, 438 insertions(+), 441 deletions(-)
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 1/16 net: sched: make type an argument for ndo_setup_tc
From: Jiri Pirko <[email protected]>
Since the type is always present, push it to be a separate argument to ndo_setup_tc. On the way, name the type enum and use it for arg type.
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 6 +++--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 7 ++++--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 5 +++-- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 ++++--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 7 ++++--- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 7 ++++--- .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 6 +++--- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 7 ++++--- drivers/net/ethernet/intel/i40e/i40e_main.c | 6 +++--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 9 +++++---- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 6 +++--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 8 ++++---- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 9 +++++---- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 10 +++++----- drivers/net/ethernet/netronome/nfp/bpf/main.c | 5 +++-- drivers/net/ethernet/netronome/nfp/flower/main.h | 3 ++- drivers/net/ethernet/netronome/nfp/flower/offload.c | 5 +++-- drivers/net/ethernet/netronome/nfp/nfp_app.h | 6 ++++-- drivers/net/ethernet/netronome/nfp/nfp_port.c | 7 ++++--- drivers/net/ethernet/netronome/nfp/nfp_port.h | 5 +++-- drivers/net/ethernet/sfc/efx.h | 5 +++-- drivers/net/ethernet/sfc/falcon/efx.h | 5 +++-- drivers/net/ethernet/sfc/falcon/tx.c | 7 ++++--- drivers/net/ethernet/sfc/tx.c | 7 ++++--- drivers/net/ethernet/ti/netcp_core.c | 7 ++++--- include/linux/netdevice.h | 9 +++++---- net/dsa/slave.c | 6 +++--- net/sched/cls_bpf.c | 4 ++-- net/sched/cls_flower.c | 14 ++++++-------- net/sched/cls_matchall.c | 10 ++++------ net/sched/cls_u32.c | 20 ++++++++------------ net/sched/sch_mqprio.c | 13 ++++++------- 32 files changed, 125 insertions(+), 113 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +3 -3
@@ -1918,14 +1918,14 @@ static void xgbe_poll_controller(struct net_device *netdev) }#endif /* End CONFIG_NET_POLL_CONTROLLER */ -static int xgbe_setup_tc (struct net_device *netdev,u32 handle,u32 chain_index, -__be16 proto, +static int xgbe_setup_tc (struct net_device *netdev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc_to_netdev) {struct xgbe_prv_data *pdata =netdev_priv (netdev);u8 tc; -if (tc_to_netdev->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; tc_to_netdev->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +4 -3
@@ -4284,10 +4284,11 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc)return 0 ; } -int __bnx2x_setup_tc (struct net_device *dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc) +int __bnx2x_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) { -if (tc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +3 -2
@@ -486,8 +486,9 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);/* setup_tc callback */ int bnx2x_setup_tc (struct net_device *dev,u8 num_tc); -int __bnx2x_setup_tc (struct net_device *dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc); +int __bnx2x_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc);int bnx2x_get_vf_config (struct net_device *dev,int vf,struct ifla_vf_info *ivi);
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -3
@@ -7237,10 +7237,11 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)return 0 ; } -static int bnxt_setup_tc (struct net_device *dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *ntc) +static int bnxt_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *ntc) { -if (ntc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; ntc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +4 -3
@@ -2889,8 +2889,9 @@ static int cxgb_set_tx_maxrate(struct net_device *dev, int index, u32 rate)return err; } -static int cxgb_setup_tc (struct net_device *dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc) +static int cxgb_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) {struct port_info *pi =netdev2pinfo (dev);struct adapter *adap =netdev2adap (dev);
@@ -2906,7 +2907,7 @@ static int cxgb_setup_tc(struct net_device *dev, u32 handle, u32 chain_index, }if (TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS ) && - tc->type ==TC_SETUP_CLSU32 ) { + type ==TC_SETUP_CLSU32 ) {switch (tc->cls_u32->command) {case TC_CLSU32_NEW_KNODE :case TC_CLSU32_REPLACE_KNODE :
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +4 -3
@@ -342,14 +342,15 @@ static void dpaa_get_stats64(struct net_device *net_dev, } } -static int dpaa_setup_tc (struct net_device *net_dev,u32 handle, -u32 chain_index,__be16 proto,struct tc_to_netdev *tc) +static int dpaa_setup_tc (struct net_device *net_dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) {struct dpaa_priv *priv =netdev_priv (net_dev);u8 num_tc;int i; -if (tc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +3 -3
@@ -1219,11 +1219,11 @@ static int hns3_setup_tc(struct net_device *netdev, u8 tc)return 0 ; } -static int hns3_nic_setup_tc (struct net_device *dev,u32 handle, -u32 chain_index,__be16 protocol, +static int hns3_nic_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 protocol,struct tc_to_netdev *tc) { -if (handle !=TC_H_ROOT || tc->type !=TC_SETUP_MQPRIO ) +if (handle !=TC_H_ROOT || type !=TC_SETUP_MQPRIO )return -EINVAL ;return hns3_setup_tc (dev, tc->mqprio->num_tc);
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +4 -3
@@ -1265,10 +1265,11 @@ int fm10k_setup_tc(struct net_device *dev, u8 tc)return err; } -static int __fm10k_setup_tc (struct net_device *dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc) +static int __fm10k_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) { -if (tc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -3
@@ -5656,11 +5656,11 @@ static int i40e_setup_tc(struct net_device *netdev, u8 tc)return ret; } -static int __i40e_setup_tc (struct net_device *netdev,u32 handle, -u32 chain_index,__be16 proto, +static int __i40e_setup_tc (struct net_device *netdev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) { -if (tc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +5 -4
@@ -9226,8 +9226,9 @@ static int ixgbe_configure_clsu32(struct ixgbe_adapter *adapter,return err; } -static int __ixgbe_setup_tc (struct net_device *dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc) +static int __ixgbe_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) {struct ixgbe_adapter *adapter =netdev_priv (dev);
@@ -9235,7 +9236,7 @@ static int __ixgbe_setup_tc(struct net_device *dev, u32 handle, u32 chain_index,return -EOPNOTSUPP ;if (TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS ) && - tc->type ==TC_SETUP_CLSU32 ) { + type ==TC_SETUP_CLSU32 ) {switch (tc->cls_u32->command) {case TC_CLSU32_NEW_KNODE :case TC_CLSU32_REPLACE_KNODE :
@@ -9255,7 +9256,7 @@ static int __ixgbe_setup_tc(struct net_device *dev, u32 handle, u32 chain_index, } } -if (tc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +3 -3
@@ -130,11 +130,11 @@ int mlx4_en_alloc_tx_queue_per_tc(struct net_device *dev, u8 tc)return err; } -static int __mlx4_en_setup_tc (struct net_device *dev,u32 handle, -u32 chain_index,__be16 proto, +static int __mlx4_en_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) { -if (tc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ;if (tc->mqprio->num_tc && tc->mqprio->num_tc !=MLX4_EN_NUM_UP_HIGH )
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +4 -4
@@ -3027,8 +3027,8 @@ static int mlx5e_setup_tc(struct net_device *netdev, u8 tc)return err; } -static int mlx5e_ndo_setup_tc (struct net_device *dev,u32 handle, -u32 chain_index,__be16 proto, +static int mlx5e_ndo_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {struct mlx5e_priv *priv =netdev_priv (dev);
@@ -3039,7 +3039,7 @@ static int mlx5e_ndo_setup_tc(struct net_device *dev, u32 handle,if (chain_index)return -EOPNOTSUPP ; -switch (tc->type) { +switch (type) {case TC_SETUP_CLSFLOWER :switch (tc->cls_flower->command) {case TC_CLSFLOWER_REPLACE :
@@ -3054,7 +3054,7 @@ static int mlx5e_ndo_setup_tc(struct net_device *dev, u32 handle, } mqprio: -if (tc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +5 -4
@@ -651,7 +651,8 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev,return 0 ; } -static int mlx5e_rep_ndo_setup_tc (struct net_device *dev,u32 handle, +static int mlx5e_rep_ndo_setup_tc (struct net_device *dev, +enum tc_setup_type type,u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {
@@ -664,15 +665,15 @@ static int mlx5e_rep_ndo_setup_tc(struct net_device *dev, u32 handle,struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;struct net_device *uplink_dev =mlx5_eswitch_get_uplink_netdev (esw); -return uplink_dev->netdev_ops->ndo_setup_tc (uplink_dev, handle, - chain_index, +return uplink_dev->netdev_ops->ndo_setup_tc (uplink_dev, type, + handle, chain_index, proto, tc); }if (chain_index)return -EOPNOTSUPP ; -switch (tc->type) { +switch (type) {case TC_SETUP_CLSFLOWER :switch (tc->cls_flower->command) {case TC_CLSFLOWER_REPLACE :
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +5 -5
@@ -1693,8 +1693,8 @@ static void mlxsw_sp_port_del_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port,kfree (mall_tc_entry); } -static int mlxsw_sp_setup_tc (struct net_device *dev,u32 handle, -u32 chain_index,__be16 proto, +static int mlxsw_sp_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev);
@@ -1703,7 +1703,7 @@ static int mlxsw_sp_setup_tc(struct net_device *dev, u32 handle,if (chain_index)return -EOPNOTSUPP ; -switch (tc->type) { +switch (type) {case TC_SETUP_MATCHALL :switch (tc->cls_mall->command) {case TC_CLSMATCHALL_REPLACE :
@@ -1733,9 +1733,9 @@ static int mlxsw_sp_setup_tc(struct net_device *dev, u32 handle,default :return -EOPNOTSUPP ; } +default : +return -EOPNOTSUPP ; } - -return -EOPNOTSUPP ; }static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
drivers/net/ethernet/netronome/nfp/bpf/main.c +3 -2
@@ -121,7 +121,8 @@ static void nfp_bpf_vnic_clean(struct nfp_app *app, struct nfp_net *nn) }static int nfp_bpf_setup_tc (struct nfp_app *app,struct net_device *netdev, -u32 handle,__be16 proto,struct tc_to_netdev *tc) +enum tc_setup_type type,u32 handle,__be16 proto, +struct tc_to_netdev *tc) {struct nfp_net *nn =netdev_priv (netdev);
@@ -130,7 +131,7 @@ static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev,if (proto !=htons (ETH_P_ALL ))return -EOPNOTSUPP ; -if (tc->type ==TC_SETUP_CLSBPF &&nfp_net_ebpf_capable (nn)) { +if (type ==TC_SETUP_CLSBPF &&nfp_net_ebpf_capable (nn)) {if (!nn->dp.bpf_offload_xdp)return nfp_net_bpf_offload (nn, tc->cls_bpf);else
drivers/net/ethernet/netronome/nfp/flower/main.h +2 -1
@@ -135,7 +135,8 @@ int nfp_flower_metadata_init(struct nfp_app *app);void nfp_flower_metadata_cleanup (struct nfp_app *app);int nfp_flower_setup_tc (struct nfp_app *app,struct net_device *netdev, -u32 handle,__be16 proto,struct tc_to_netdev *tc); +enum tc_setup_type type,u32 handle,__be16 proto, +struct tc_to_netdev *tc); int nfp_flower_compile_flow_match(struct tc_cls_flower_offload *flow, struct nfp_fl_key_ls *key_ls, struct net_device *netdev,
drivers/net/ethernet/netronome/nfp/flower/offload.c +3 -2
@@ -385,7 +385,8 @@ nfp_flower_repr_offload(struct nfp_app *app, struct net_device *netdev, }int nfp_flower_setup_tc (struct nfp_app *app,struct net_device *netdev, -u32 handle,__be16 proto,struct tc_to_netdev *tc) +enum tc_setup_type type,u32 handle,__be16 proto, +struct tc_to_netdev *tc) {if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ))return -EOPNOTSUPP ;
@@ -393,7 +394,7 @@ int nfp_flower_setup_tc(struct nfp_app *app, struct net_device *netdev,if (!eth_proto_is_802_3 (proto))return -EOPNOTSUPP ; -if (tc->type !=TC_SETUP_CLSFLOWER ) +if (type !=TC_SETUP_CLSFLOWER )return -EINVAL ;return nfp_flower_repr_offload (app, netdev, tc->cls_flower);
drivers/net/ethernet/netronome/nfp/nfp_app.h +4 -2
@@ -109,7 +109,8 @@ struct nfp_app_type {void (*ctrl_msg_rx)(struct nfp_app *app,struct sk_buff *skb);int (*setup_tc)(struct nfp_app *app,struct net_device *netdev, -u32 handle,__be16 proto,struct tc_to_netdev *tc); +enum tc_setup_type type,u32 handle,__be16 proto, +struct tc_to_netdev *tc);bool (*tc_busy)(struct nfp_app *app,struct nfp_net *nn);int (*xdp_offload)(struct nfp_app *app,struct nfp_net *nn,struct bpf_prog *prog);
@@ -238,12 +239,13 @@ static inline bool nfp_app_tc_busy(struct nfp_app *app, struct nfp_net *nn)static inline int nfp_app_setup_tc (struct nfp_app *app,struct net_device *netdev, +enum tc_setup_type type,u32 handle,__be16 proto,struct tc_to_netdev *tc) {if (!app || !app->type->setup_tc)return -EOPNOTSUPP ; -return app->type->setup_tc (app, netdev, handle, proto, tc); +return app->type->setup_tc (app, netdev, type, handle, proto, tc); } static inline int nfp_app_xdp_offload(struct nfp_app *app, struct nfp_net *nn,
drivers/net/ethernet/netronome/nfp/nfp_port.c +4 -3
@@ -88,8 +88,9 @@ const struct switchdev_ops nfp_port_switchdev_ops = { .switchdev_port_attr_get = nfp_port_attr_get, }; -int nfp_port_setup_tc (struct net_device *netdev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc) +int nfp_port_setup_tc (struct net_device *netdev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) {struct nfp_port *port;
@@ -100,7 +101,7 @@ int nfp_port_setup_tc(struct net_device *netdev, u32 handle, u32 chain_index,if (!port)return -EOPNOTSUPP ; -return nfp_app_setup_tc (port->app, netdev, handle, proto, tc); +return nfp_app_setup_tc (port->app, netdev, type, handle, proto, tc); } struct nfp_port *
drivers/net/ethernet/netronome/nfp/nfp_port.h +3 -2
@@ -109,8 +109,9 @@ struct nfp_port {extern const struct switchdev_ops nfp_port_switchdev_ops; -int nfp_port_setup_tc (struct net_device *netdev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc); +int nfp_port_setup_tc (struct net_device *netdev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc);struct nfp_port *nfp_port_from_netdev (struct net_device *netdev); struct nfp_port *
drivers/net/ethernet/sfc/efx.h +3 -2
@@ -32,8 +32,9 @@ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev);netdev_tx_t efx_enqueue_skb (struct efx_tx_queue *tx_queue,struct sk_buff *skb);void efx_xmit_done (struct efx_tx_queue *tx_queue,unsigned int index); -int efx_setup_tc (struct net_device *net_dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc); +int efx_setup_tc (struct net_device *net_dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc);unsigned int efx_tx_max_skb_descs (struct efx_nic *efx);extern unsigned int efx_piobuf_size;extern bool efx_separate_tx_channels;
drivers/net/ethernet/sfc/falcon/efx.h +3 -2
@@ -32,8 +32,9 @@ netdev_tx_t ef4_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev);netdev_tx_t ef4_enqueue_skb (struct ef4_tx_queue *tx_queue,struct sk_buff *skb);void ef4_xmit_done (struct ef4_tx_queue *tx_queue,unsigned int index); -int ef4_setup_tc (struct net_device *net_dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc); +int ef4_setup_tc (struct net_device *net_dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc);unsigned int ef4_tx_max_skb_descs (struct ef4_nic *efx);extern bool ef4_separate_tx_channels;
drivers/net/ethernet/sfc/falcon/tx.c +4 -3
@@ -425,8 +425,9 @@ void ef4_init_tx_queue_core_txq(struct ef4_tx_queue *tx_queue) efx->n_tx_channels : 0)); } -int ef4_setup_tc (struct net_device *net_dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *ntc) +int ef4_setup_tc (struct net_device *net_dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *ntc) {struct ef4_nic *efx =netdev_priv (net_dev);struct ef4_channel *channel;
@@ -434,7 +435,7 @@ int ef4_setup_tc(struct net_device *net_dev, u32 handle, u32 chain_index,unsigned tc, num_tc;int rc; -if (ntc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; num_tc = ntc->mqprio->num_tc;
drivers/net/ethernet/sfc/tx.c +4 -3
@@ -653,8 +653,9 @@ void efx_init_tx_queue_core_txq(struct efx_tx_queue *tx_queue) efx->n_tx_channels : 0)); } -int efx_setup_tc (struct net_device *net_dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *ntc) +int efx_setup_tc (struct net_device *net_dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *ntc) {struct efx_nic *efx =netdev_priv (net_dev);struct efx_channel *channel;
@@ -662,7 +663,7 @@ int efx_setup_tc(struct net_device *net_dev, u32 handle, u32 chain_index,unsigned tc, num_tc;int rc; -if (ntc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; num_tc = ntc->mqprio->num_tc;
drivers/net/ethernet/ti/netcp_core.c +4 -3
@@ -1877,8 +1877,9 @@ static u16 netcp_select_queue(struct net_device *dev, struct sk_buff *skb,return 0 ; } -static int netcp_setup_tc (struct net_device *dev,u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc) +static int netcp_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) {u8 num_tc;int i;
@@ -1886,7 +1887,7 @@ static int netcp_setup_tc(struct net_device *dev, u32 handle, u32 chain_index,/* setup tc must be called under rtnl lock */ ASSERT_RTNL (); -if (tc->type !=TC_SETUP_MQPRIO ) +if (type !=TC_SETUP_MQPRIO )return -EINVAL ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
include/linux/netdevice.h +5 -4
@@ -774,7 +774,7 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,/* These structures hold the attributes of qdisc and classifiers * that are being passed to the netdevice through the setup_tc op. */ -enum { +enum tc_setup_type {TC_SETUP_MQPRIO ,TC_SETUP_CLSU32 ,TC_SETUP_CLSFLOWER ,
@@ -785,7 +785,6 @@ enum {struct tc_cls_u32_offload ;struct tc_to_netdev { -unsigned int type;union {struct tc_cls_u32_offload *cls_u32;struct tc_cls_flower_offload *cls_flower;
@@ -978,8 +977,9 @@ struct xfrmdev_ops {* with PF and querying it may introduce a theoretical security risk. * int (*ndo_set_vf_rss_query_en)(struct net_device *dev, int vf, bool setting); * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); -* int (*ndo_setup_tc)(struct net_device *dev, u32 handle, u32 chain_index, -* __be16 protocol, struct tc_to_netdev *tc); +* int (*ndo_setup_tc)(struct net_device *dev, enum tc_setup_type type, +* u32 handle, u32 chain_index, __be16 protocol, +* struct tc_to_netdev *tc); * Called to setup any 'tc' scheduler, classifier or action on @dev. * This is always called from the stack with the rtnl lock held and netif * tx queues stopped. This allows the netdevice to perform queue
@@ -1227,6 +1227,7 @@ struct net_device_ops {struct net_device *dev, int vf, bool setting);int (*ndo_setup_tc)(struct net_device *dev, +enum tc_setup_type type,u32 handle,u32 chain_index,__be16 protocol,struct tc_to_netdev *tc);
net/dsa/slave.c +3 -3
@@ -863,8 +863,8 @@ static void dsa_slave_del_cls_matchall(struct net_device *dev,kfree (mall_tc_entry); } -static int dsa_slave_setup_tc (struct net_device *dev,u32 handle, -u32 chain_index,__be16 protocol, +static int dsa_slave_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 protocol,struct tc_to_netdev *tc) {bool ingress =TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS );
@@ -872,7 +872,7 @@ static int dsa_slave_setup_tc(struct net_device *dev, u32 handle,if (chain_index)return -EOPNOTSUPP ; -switch (tc->type) { +switch (type) {case TC_SETUP_MATCHALL :switch (tc->cls_mall->command) {case TC_CLSMATCHALL_REPLACE :
net/sched/cls_bpf.c +2 -2
@@ -151,7 +151,6 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,struct tc_to_netdev offload;int err; - offload.type =TC_SETUP_CLSBPF ; offload.cls_bpf = &bpf_offload; bpf_offload.command = cmd;
@@ -161,7 +160,8 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog, bpf_offload.exts_integrated = prog->exts_integrated; bpf_offload.gen_flags = prog->gen_flags; - err = dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSBPF , + tp->q->handle, tp->chain->index, tp->protocol, &offload);
net/sched/cls_flower.c +6 -8
@@ -236,11 +236,10 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, struct cls_fl_filter *f) offload.prio = tp->prio; offload.cookie = (unsigned long )f; - tc->type =TC_SETUP_CLSFLOWER ; tc->cls_flower = &offload; - dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, tp->chain->index, - tp->protocol, tc); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSFLOWER , tp->q->handle, + tp->chain->index, tp->protocol, tc); } static int fl_hw_replace_filter(struct tcf_proto *tp,
@@ -273,11 +272,11 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, offload.key = &f->mkey; offload.exts = &f->exts; - tc->type =TC_SETUP_CLSFLOWER ; tc->cls_flower = &offload; - err = dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, - tp->chain->index, tp->protocol, tc); + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSFLOWER , + tp->q->handle, tp->chain->index, + tp->protocol, tc);if (!err) f->flags |=TCA_CLS_FLAGS_IN_HW ;
@@ -300,10 +299,9 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) offload.cookie = (unsigned long )f; offload.exts = &f->exts; - tc->type =TC_SETUP_CLSFLOWER ; tc->cls_flower = &offload; - dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, + dev->netdev_ops->ndo_setup_tc (dev,TC_CLSFLOWER_STATS , tp->q->handle, tp->chain->index, tp->protocol, tc); }
net/sched/cls_matchall.c +4 -6
@@ -58,14 +58,13 @@ static int mall_replace_hw_filter(struct tcf_proto *tp,struct tc_cls_matchall_offload mall_offload = {0 };int err; - offload.type =TC_SETUP_MATCHALL ; offload.cls_mall = &mall_offload; offload.cls_mall->command =TC_CLSMATCHALL_REPLACE ; offload.cls_mall->exts = &head->exts; offload.cls_mall->cookie = cookie; - err = dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, - tp->chain->index, + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MATCHALL , + tp->q->handle, tp->chain->index, tp->protocol, &offload);if (!err) head->flags |=TCA_CLS_FLAGS_IN_HW ;
@@ -81,14 +80,13 @@ static void mall_destroy_hw_filter(struct tcf_proto *tp,struct tc_to_netdev offload;struct tc_cls_matchall_offload mall_offload = {0 }; - offload.type =TC_SETUP_MATCHALL ; offload.cls_mall = &mall_offload; offload.cls_mall->command =TC_CLSMATCHALL_DESTROY ; offload.cls_mall->exts =NULL ; offload.cls_mall->cookie = cookie; - dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, tp->chain->index, - tp->protocol, &offload); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MATCHALL , tp->q->handle, + tp->chain->index, tp->protocol, &offload); }static void mall_destroy (struct tcf_proto *tp)
net/sched/cls_u32.c +8 -12
@@ -434,15 +434,14 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle)struct tc_cls_u32_offload u32_offload = {0 };struct tc_to_netdev offload; - offload.type =TC_SETUP_CLSU32 ; offload.cls_u32 = &u32_offload;if (tc_should_offload (dev, tp,0 )) { offload.cls_u32->command =TC_CLSU32_DELETE_KNODE ; offload.cls_u32->knode.handle = handle; - dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, - tp->chain->index, tp->protocol, - &offload); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , + tp->q->handle, tp->chain->index, + tp->protocol, &offload); } }
@@ -457,7 +456,6 @@ static int u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h,if (!tc_should_offload (dev, tp, flags))return tc_skip_sw (flags) ? -EINVAL :0 ; - offload.type =TC_SETUP_CLSU32 ; offload.cls_u32 = &u32_offload; offload.cls_u32->command =TC_CLSU32_NEW_HNODE ;
@@ -465,7 +463,7 @@ static int u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h, offload.cls_u32->hnode.handle = h->handle; offload.cls_u32->hnode.prio = h->prio; - err = dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , tp->q->handle, tp->chain->index, tp->protocol, &offload);if (tc_skip_sw (flags))
@@ -480,7 +478,6 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h)struct tc_cls_u32_offload u32_offload = {0 };struct tc_to_netdev offload; - offload.type =TC_SETUP_CLSU32 ; offload.cls_u32 = &u32_offload;if (tc_should_offload (dev, tp,0 )) {
@@ -489,9 +486,9 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) offload.cls_u32->hnode.handle = h->handle; offload.cls_u32->hnode.prio = h->prio; - dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, - tp->chain->index, tp->protocol, - &offload); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , + tp->q->handle, tp->chain->index, + tp->protocol, &offload); } }
@@ -503,7 +500,6 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,struct tc_to_netdev offload;int err; - offload.type =TC_SETUP_CLSU32 ; offload.cls_u32 = &u32_offload;if (!tc_should_offload (dev, tp, flags))
@@ -524,7 +520,7 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,if (n->ht_down) offload.cls_u32->knode.link_handle = n->ht_down->handle; - err = dev->netdev_ops->ndo_setup_tc (dev, tp->q->handle, + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , tp->q->handle, tp->chain->index, tp->protocol, &offload);
net/sched/sch_mqprio.c +6 -7
@@ -40,10 +40,10 @@ static void mqprio_destroy(struct Qdisc *sch)if (priv->hw_offload && dev->netdev_ops->ndo_setup_tc) {struct tc_mqprio_qopt offload = {0 }; -struct tc_to_netdev tc = { .type =TC_SETUP_MQPRIO , - { .mqprio = &offload } }; +struct tc_to_netdev tc = { { .mqprio = &offload } }; - dev->netdev_ops->ndo_setup_tc (dev, sch->handle,0 ,0 , &tc); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , + sch->handle,0 ,0 , &tc); }else {netdev_set_num_tc (dev,0 ); }
@@ -149,11 +149,10 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)*/ if (qopt->hw) {struct tc_mqprio_qopt offload = *qopt; -struct tc_to_netdev tc = { .type =TC_SETUP_MQPRIO , - { .mqprio = &offload } }; +struct tc_to_netdev tc = { { .mqprio = &offload } }; - err = dev->netdev_ops->ndo_setup_tc (dev, sch->handle, -0 ,0 , &tc); + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , + sch->handle,0 ,0 , &tc);if (err)return err;
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 2/16 net: sched: rename TC_SETUP_MATCHALL to TC_SETUP_CLSMATCHALL
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
In order to be aligned with the rest of the types, rename TC_SETUP_MATCHALL to TC_SETUP_CLSMATCHALL.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 +- include/linux/netdevice.h | 2 +- net/dsa/slave.c | 2 +- net/sched/cls_matchall.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1 -1
@@ -1704,7 +1704,7 @@ static int mlxsw_sp_setup_tc(struct net_device *dev, enum tc_setup_type type,return -EOPNOTSUPP ;switch (type) { -case TC_SETUP_MATCHALL : +case TC_SETUP_CLSMATCHALL :switch (tc->cls_mall->command) {case TC_CLSMATCHALL_REPLACE : return mlxsw_sp_port_add_cls_matchall(mlxsw_sp_port,
include/linux/netdevice.h +1 -1
@@ -778,7 +778,7 @@ enum tc_setup_type {TC_SETUP_MQPRIO ,TC_SETUP_CLSU32 ,TC_SETUP_CLSFLOWER , -TC_SETUP_MATCHALL , +TC_SETUP_CLSMATCHALL , TC_SETUP_CLSBPF, };
net/dsa/slave.c +1 -1
@@ -873,7 +873,7 @@ static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,return -EOPNOTSUPP ;switch (type) { -case TC_SETUP_MATCHALL : +case TC_SETUP_CLSMATCHALL :switch (tc->cls_mall->command) {case TC_CLSMATCHALL_REPLACE : return dsa_slave_add_cls_matchall(dev, protocol,
net/sched/cls_matchall.c +2 -2
@@ -63,7 +63,7 @@ static int mall_replace_hw_filter(struct tcf_proto *tp, offload.cls_mall->exts = &head->exts; offload.cls_mall->cookie = cookie; - err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MATCHALL , + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSMATCHALL , tp->q->handle, tp->chain->index, tp->protocol, &offload);if (!err)
@@ -85,7 +85,7 @@ static void mall_destroy_hw_filter(struct tcf_proto *tp, offload.cls_mall->exts =NULL ; offload.cls_mall->cookie = cookie; - dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MATCHALL , tp->q->handle, + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSMATCHALL , tp->q->handle, tp->chain->index, tp->protocol, &offload); }
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 3/16 net: sched: make egress_dev flag part of flower offload struct
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Since this is specific to flower now, make it part of the flower offload struct.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +- include/linux/netdevice.h | 1 - include/net/pkt_cls.h | 1 + net/sched/cls_flower.c | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +1 -1
@@ -661,7 +661,7 @@ static int mlx5e_rep_ndo_setup_tc(struct net_device *dev,if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ))return -EOPNOTSUPP ; -if (tc->egress_dev) { +if (type ==TC_SETUP_CLSFLOWER && tc->cls_flower->egress_dev) {struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;struct net_device *uplink_dev =mlx5_eswitch_get_uplink_netdev (esw);
include/linux/netdevice.h +0 -1
@@ -792,7 +792,6 @@ struct tc_to_netdev {struct tc_cls_bpf_offload *cls_bpf;struct tc_mqprio_qopt *mqprio; }; -bool egress_dev; };/* These structures hold the attributes of xdp state that are being passed
include/net/pkt_cls.h +1 -0
@@ -504,6 +504,7 @@ struct tc_cls_flower_offload {struct fl_flow_key *mask;struct fl_flow_key *key;struct tcf_exts *exts; +bool egress_dev; };enum tc_matchall_command {
net/sched/cls_flower.c +1 -1
@@ -259,7 +259,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,return tc_skip_sw (f->flags) ? -EINVAL :0 ; } dev = f->hw_dev; - tc->egress_dev = true; + offload.egress_dev = true; }else { f->hw_dev = dev; }
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 4/16 cxgb4: push cls_u32 setup_tc processing into a separate function
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Let cxgb_setup_tc be a splitter for specific setup_tc types and push out cls_u32 specific code into a separate function.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 42 +++++++++++++++---------- 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +26 -16
@@ -2889,6 +2889,26 @@ static int cxgb_set_tx_maxrate(struct net_device *dev, int index, u32 rate)return err; } +static int cxgb_setup_tc_cls_u32 (struct net_device *dev, +enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_cls_u32_offload *cls_u32) +{ +if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || + chain_index) +return -EOPNOTSUPP ; + +switch (cls_u32->command) { +case TC_CLSU32_NEW_KNODE : +case TC_CLSU32_REPLACE_KNODE : +return cxgb4_config_knode (dev, proto, cls_u32); +case TC_CLSU32_DELETE_KNODE : +return cxgb4_delete_knode (dev, proto, cls_u32); +default : +return -EOPNOTSUPP ; + } +} +static int cxgb_setup_tc (struct net_device *dev,enum tc_setup_type type,u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc)
@@ -2896,9 +2916,6 @@ static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,struct port_info *pi =netdev2pinfo (dev);struct adapter *adap =netdev2adap (dev); -if (chain_index) -return -EOPNOTSUPP ; -if (!(adap->flags &FULL_INIT_DONE )) { dev_err(adap->pdev_dev, "Failed to setup tc on port %d. Link Down?\n",
@@ -2906,20 +2923,13 @@ static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,return -EINVAL ; } -if (TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS ) && - type ==TC_SETUP_CLSU32 ) { -switch (tc->cls_u32->command) { -case TC_CLSU32_NEW_KNODE : -case TC_CLSU32_REPLACE_KNODE : -return cxgb4_config_knode (dev, proto, tc->cls_u32); -case TC_CLSU32_DELETE_KNODE : -return cxgb4_delete_knode (dev, proto, tc->cls_u32); -default : -return -EOPNOTSUPP ; - } +switch (type) { +case TC_SETUP_CLSU32 : +return cxgb_setup_tc_cls_u32 (dev, type, handle, chain_index, + proto, tc->cls_u32); +default : +return -EOPNOTSUPP ; } - -return -EOPNOTSUPP ; } static netdev_features_t cxgb_fix_features(struct net_device *dev,
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 5/16 ixgbe: push cls_u32 and mqprio setup_tc processing into separate functions
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Let __ixgbe_setup_tc be a splitter for specific setup_tc types and push out cls_u32 and mqprio specific codes into separate functions. Also change the return values so they are the same as in the rest of the drivers.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 67 ++++++++++++++++----------- 1 file changed, 39 insertions(+), 28 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +39 -28
@@ -9226,42 +9226,53 @@ static int ixgbe_configure_clsu32(struct ixgbe_adapter *adapter,return err; } -static int __ixgbe_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto, -struct tc_to_netdev *tc) +static int ixgbe_setup_tc_cls_u32 (struct net_device *dev, +u32 handle,u32 chain_index,__be16 proto, +struct tc_cls_u32_offload *cls_u32) {struct ixgbe_adapter *adapter =netdev_priv (dev); -if (chain_index) +if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || + chain_index)return -EOPNOTSUPP ; -if (TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS ) && - type ==TC_SETUP_CLSU32 ) { -switch (tc->cls_u32->command) { -case TC_CLSU32_NEW_KNODE : -case TC_CLSU32_REPLACE_KNODE : -return ixgbe_configure_clsu32 (adapter, - proto, tc->cls_u32); -case TC_CLSU32_DELETE_KNODE : -return ixgbe_delete_clsu32 (adapter, tc->cls_u32); -case TC_CLSU32_NEW_HNODE : -case TC_CLSU32_REPLACE_HNODE : -return ixgbe_configure_clsu32_add_hnode (adapter, proto, - tc->cls_u32); -case TC_CLSU32_DELETE_HNODE : -return ixgbe_configure_clsu32_del_hnode (adapter, - tc->cls_u32); -default : -return -EINVAL ; - } +switch (cls_u32->command) { +case TC_CLSU32_NEW_KNODE : +case TC_CLSU32_REPLACE_KNODE : +return ixgbe_configure_clsu32 (adapter, proto, cls_u32); +case TC_CLSU32_DELETE_KNODE : +return ixgbe_delete_clsu32 (adapter, cls_u32); +case TC_CLSU32_NEW_HNODE : +case TC_CLSU32_REPLACE_HNODE : +return ixgbe_configure_clsu32_add_hnode (adapter, proto, + cls_u32); +case TC_CLSU32_DELETE_HNODE : +return ixgbe_configure_clsu32_del_hnode (adapter, cls_u32); +default : +return -EOPNOTSUPP ; } +} -if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; - - tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; +static int ixgbe_setup_tc_mqprio (struct net_device *dev, +struct tc_mqprio_qopt *mqprio) +{ + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; +return ixgbe_setup_tc (dev, mqprio->num_tc); +} -return ixgbe_setup_tc (dev, tc->mqprio->num_tc); +static int __ixgbe_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) +{ +switch (type) { +case TC_SETUP_CLSU32 : +return ixgbe_setup_tc_cls_u32 (dev, handle, chain_index, proto, + tc->cls_u32); +case TC_SETUP_MQPRIO : +return ixgbe_setup_tc_mqprio (dev, tc->mqprio); +default : +return -EOPNOTSUPP ; + } }#ifdef CONFIG_PCI_IOV
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 6/16 mlx5e: push cls_flower and mqprio setup_tc processing into separate functions
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Let mlx5e_setup_tc (former mlx5e_ndo_setup_tc) be a splitter for specific setup_tc types and push out cls_flower and mqprio specific codes into separate functions. Also change the return values so they are the same as in the rest of the drivers.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 56 +++++++++++++---------- 1 file changed, 31 insertions(+), 25 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +31 -25
@@ -2998,12 +2998,16 @@ static int mlx5e_modify_channels_vsd(struct mlx5e_channels *chs, bool vsd)return 0 ; } -static int mlx5e_setup_tc (struct net_device *netdev,u8 tc) +static int mlx5e_setup_tc_mqprio (struct net_device *netdev, +struct tc_mqprio_qopt *mqprio) {struct mlx5e_priv *priv =netdev_priv (netdev);struct mlx5e_channels new_channels = {}; +u8 tc = mqprio->num_tc;int err =0 ; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; +if (tc && tc !=MLX5E_MAX_NUM_TC )return -EINVAL ;
@@ -3027,39 +3031,41 @@ static int mlx5e_setup_tc(struct net_device *netdev, u8 tc)return err; } -static int mlx5e_ndo_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto, -struct tc_to_netdev *tc) +static int mlx5e_setup_tc_cls_flower (struct net_device *dev, +u32 handle,u32 chain_index,__be16 proto, +struct tc_cls_flower_offload *cls_flower) {struct mlx5e_priv *priv =netdev_priv (dev); -if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS )) - goto mqprio; +if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || + chain_index) +return -EOPNOTSUPP ; -if (chain_index) +switch (cls_flower->command) { +case TC_CLSFLOWER_REPLACE : +return mlx5e_configure_flower (priv, proto, cls_flower); +case TC_CLSFLOWER_DESTROY : +return mlx5e_delete_flower (priv, cls_flower); +case TC_CLSFLOWER_STATS : +return mlx5e_stats_flower (priv, cls_flower); +default :return -EOPNOTSUPP ; + } +} +static int mlx5e_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) +{switch (type) {case TC_SETUP_CLSFLOWER : -switch (tc->cls_flower->command) { -case TC_CLSFLOWER_REPLACE : -return mlx5e_configure_flower (priv, proto, tc->cls_flower); -case TC_CLSFLOWER_DESTROY : -return mlx5e_delete_flower (priv, tc->cls_flower); -case TC_CLSFLOWER_STATS : -return mlx5e_stats_flower (priv, tc->cls_flower); - } +return mlx5e_setup_tc_cls_flower (dev, handle, chain_index, + proto, tc->cls_flower); +case TC_SETUP_MQPRIO : +return mlx5e_setup_tc_mqprio (dev, tc->mqprio);default :return -EOPNOTSUPP ; } - -mqprio: -if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; - - tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; - -return mlx5e_setup_tc (dev, tc->mqprio->num_tc); } static void
@@ -3695,7 +3701,7 @@ static const struct net_device_ops mlx5e_netdev_ops_basic = { .ndo_open = mlx5e_open, .ndo_stop = mlx5e_close, .ndo_start_xmit = mlx5e_xmit, - .ndo_setup_tc = mlx5e_ndo_setup_tc, + .ndo_setup_tc = mlx5e_setup_tc, .ndo_select_queue = mlx5e_select_queue, .ndo_get_stats64 = mlx5e_get_stats, .ndo_set_rx_mode = mlx5e_set_rx_mode,
@@ -3720,7 +3726,7 @@ static const struct net_device_ops mlx5e_netdev_ops_sriov = { .ndo_open = mlx5e_open, .ndo_stop = mlx5e_close, .ndo_start_xmit = mlx5e_xmit, - .ndo_setup_tc = mlx5e_ndo_setup_tc, + .ndo_setup_tc = mlx5e_setup_tc, .ndo_select_queue = mlx5e_select_queue, .ndo_get_stats64 = mlx5e_get_stats, .ndo_set_rx_mode = mlx5e_set_rx_mode,
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 7/16 mlx5e_rep: push cls_flower setup_tc processing into a separate function
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Let mlx5e_rep_setup_tc (former mlx5e_rep_ndo_setup_tc) be a splitter for specific setup_tc types and push out cls_flower specific code into a separate function.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 49 ++++++++++++++---------- 1 file changed, 29 insertions(+), 20 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +29 -20
@@ -651,38 +651,47 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev,return 0 ; } -static int mlx5e_rep_ndo_setup_tc (struct net_device *dev, -enum tc_setup_type type,u32 handle, -u32 chain_index,__be16 proto, -struct tc_to_netdev *tc) +static int mlx5e_rep_setup_tc_cls_flower (struct net_device *dev, +u32 handle,u32 chain_index, +__be16 proto, +struct tc_to_netdev *tc) { +struct tc_cls_flower_offload *cls_flower = tc->cls_flower;struct mlx5e_priv *priv =netdev_priv (dev); -if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS )) +if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || + chain_index)return -EOPNOTSUPP ; -if (type ==TC_SETUP_CLSFLOWER && tc->cls_flower->egress_dev) { +if (cls_flower->egress_dev) {struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; -struct net_device *uplink_dev =mlx5_eswitch_get_uplink_netdev (esw); -return uplink_dev->netdev_ops->ndo_setup_tc (uplink_dev, type, - handle, chain_index, - proto, tc); + dev =mlx5_eswitch_get_uplink_netdev (esw); +return dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSFLOWER , + handle, chain_index, + proto, tc); } -if (chain_index) +switch (cls_flower->command) { +case TC_CLSFLOWER_REPLACE : +return mlx5e_configure_flower (priv, proto, cls_flower); +case TC_CLSFLOWER_DESTROY : +return mlx5e_delete_flower (priv, cls_flower); +case TC_CLSFLOWER_STATS : +return mlx5e_stats_flower (priv, cls_flower); +default :return -EOPNOTSUPP ; + } +} +static int mlx5e_rep_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) +{switch (type) {case TC_SETUP_CLSFLOWER : -switch (tc->cls_flower->command) { -case TC_CLSFLOWER_REPLACE : -return mlx5e_configure_flower (priv, proto, tc->cls_flower); -case TC_CLSFLOWER_DESTROY : -return mlx5e_delete_flower (priv, tc->cls_flower); -case TC_CLSFLOWER_STATS : -return mlx5e_stats_flower (priv, tc->cls_flower); - } +return mlx5e_rep_setup_tc_cls_flower (dev, handle, chain_index, + proto, tc);default :return -EOPNOTSUPP ; }
@@ -774,7 +783,7 @@ static const struct net_device_ops mlx5e_netdev_ops_rep = { .ndo_stop = mlx5e_rep_close, .ndo_start_xmit = mlx5e_xmit, .ndo_get_phys_port_name = mlx5e_rep_get_phys_port_name, - .ndo_setup_tc = mlx5e_rep_ndo_setup_tc, + .ndo_setup_tc = mlx5e_rep_setup_tc, .ndo_get_stats64 = mlx5e_rep_get_stats, .ndo_has_offload_stats = mlx5e_has_offload_stats, .ndo_get_offload_stats = mlx5e_get_offload_stats,
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 8/16 mlxsw: spectrum: push cls_flower and cls_matchall setup_tc processing into separate functions
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Let mlxsw_sp_setup_tc be a splitter for specific setup_tc types and push out cls_flower and cls_matchall specific codes into separate functions.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 81 ++++++++++++++++---------- 1 file changed, 51 insertions(+), 30 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +51 -30
@@ -1693,46 +1693,67 @@ static void mlxsw_sp_port_del_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port,kfree (mall_tc_entry); } -static int mlxsw_sp_setup_tc (struct net_device *dev,enum tc_setup_type type, +static int mlxsw_sp_setup_tc_cls_matchall (struct mlxsw_sp_port *mlxsw_sp_port, +u32 handle,u32 chain_index, +__be16 proto, +struct tc_cls_matchall_offload *f) +{ +bool ingress =TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS ); + +if (chain_index) +return -EOPNOTSUPP ; + +switch (f->command) { +case TC_CLSMATCHALL_REPLACE : +return mlxsw_sp_port_add_cls_matchall (mlxsw_sp_port, proto, f, + ingress); +case TC_CLSMATCHALL_DESTROY : +mlxsw_sp_port_del_cls_matchall (mlxsw_sp_port, f); +return 0 ; +default : +return -EOPNOTSUPP ; + } +} + +static int +mlxsw_sp_setup_tc_cls_flower (struct mlxsw_sp_port *mlxsw_sp_port,u32 handle,u32 chain_index,__be16 proto, -struct tc_to_netdev *tc) +struct tc_cls_flower_offload *f) { -struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev);bool ingress =TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS );if (chain_index)return -EOPNOTSUPP ; +switch (f->command) { +case TC_CLSFLOWER_REPLACE : +return mlxsw_sp_flower_replace (mlxsw_sp_port, ingress, + proto, f); +case TC_CLSFLOWER_DESTROY : +mlxsw_sp_flower_destroy (mlxsw_sp_port, ingress, f); +return 0 ; +case TC_CLSFLOWER_STATS : +return mlxsw_sp_flower_stats (mlxsw_sp_port, ingress, f); +default : +return -EOPNOTSUPP ; + } +} + +static int mlxsw_sp_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 proto, +struct tc_to_netdev *tc) +{ +struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev); +switch (type) {case TC_SETUP_CLSMATCHALL : -switch (tc->cls_mall->command) { -case TC_CLSMATCHALL_REPLACE : -return mlxsw_sp_port_add_cls_matchall (mlxsw_sp_port, - proto, - tc->cls_mall, - ingress); -case TC_CLSMATCHALL_DESTROY : -mlxsw_sp_port_del_cls_matchall (mlxsw_sp_port, - tc->cls_mall); -return 0 ; -default : -return -EOPNOTSUPP ; - } +return mlxsw_sp_setup_tc_cls_matchall (mlxsw_sp_port, handle, + chain_index, proto, + tc->cls_mall);case TC_SETUP_CLSFLOWER : -switch (tc->cls_flower->command) { -case TC_CLSFLOWER_REPLACE : -return mlxsw_sp_flower_replace (mlxsw_sp_port, ingress, - proto, tc->cls_flower); -case TC_CLSFLOWER_DESTROY : -mlxsw_sp_flower_destroy (mlxsw_sp_port, ingress, - tc->cls_flower); -return 0 ; -case TC_CLSFLOWER_STATS : -return mlxsw_sp_flower_stats (mlxsw_sp_port, ingress, - tc->cls_flower); -default : -return -EOPNOTSUPP ; - } +return mlxsw_sp_setup_tc_cls_flower (mlxsw_sp_port, handle, + chain_index, proto, + tc->cls_flower);default :return -EOPNOTSUPP ; }
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 9/16 mlxsw: spectrum: rename cls arg in matchall processing
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
To sync-up with the naming in the rest of the driver, rename the cls arg.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +7 -7
@@ -1618,7 +1618,7 @@ mlxsw_sp_port_del_cls_matchall_sample(struct mlxsw_sp_port *mlxsw_sp_port)static int mlxsw_sp_port_add_cls_matchall (struct mlxsw_sp_port *mlxsw_sp_port,__be16 protocol, -struct tc_cls_matchall_offload *cls, +struct tc_cls_matchall_offload *f,bool ingress) {struct mlxsw_sp_port_mall_tc_entry *mall_tc_entry;
@@ -1626,7 +1626,7 @@ static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port,LIST_HEAD (actions);int err; -if (!tcf_exts_has_one_action (cls->exts)) { +if (!tcf_exts_has_one_action (f->exts)) {netdev_err (mlxsw_sp_port->dev,"only singular actions are supported\n" );return -EOPNOTSUPP ; }
@@ -1634,9 +1634,9 @@ static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port, mall_tc_entry =kzalloc (sizeof (*mall_tc_entry),GFP_KERNEL );if (!mall_tc_entry)return -ENOMEM ; - mall_tc_entry->cookie = cls->cookie; + mall_tc_entry->cookie = f->cookie; -tcf_exts_to_list (cls->exts, &actions); +tcf_exts_to_list (f->exts, &actions); a = list_first_entry(&actions, struct tc_action, list);if (is_tcf_mirred_egress_mirror (a) && protocol ==htons (ETH_P_ALL )) {
@@ -1648,7 +1648,7 @@ static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port, mirror, a, ingress); }else if (is_tcf_sample (a) && protocol ==htons (ETH_P_ALL )) { mall_tc_entry->type =MLXSW_SP_PORT_MALL_SAMPLE ; - err =mlxsw_sp_port_add_cls_matchall_sample (mlxsw_sp_port, cls, + err =mlxsw_sp_port_add_cls_matchall_sample (mlxsw_sp_port, f, a, ingress); }else { err = -EOPNOTSUPP ;
@@ -1666,12 +1666,12 @@ static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port, }static void mlxsw_sp_port_del_cls_matchall (struct mlxsw_sp_port *mlxsw_sp_port, -struct tc_cls_matchall_offload *cls) +struct tc_cls_matchall_offload *f) {struct mlxsw_sp_port_mall_tc_entry *mall_tc_entry; mall_tc_entry =mlxsw_sp_port_mall_tc_entry_find (mlxsw_sp_port, - cls->cookie); + f->cookie);if (!mall_tc_entry) {netdev_dbg (mlxsw_sp_port->dev,"tc entry not found on port\n" );return ;
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 10/16 dsa: push cls_matchall setup_tc processing into a separate function
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Let dsa_slave_setup_tc be a splitter for specific setup_tc types and push out cls_matchall specific code into a separate function.
--- net/dsa/slave.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
net/dsa/slave.c +21 -12
@@ -863,26 +863,35 @@ static void dsa_slave_del_cls_matchall(struct net_device *dev,kfree (mall_tc_entry); } -static int dsa_slave_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 protocol, -struct tc_to_netdev *tc) +static int dsa_slave_setup_tc_cls_matchall (struct net_device *dev, +u32 handle,u32 chain_index, +__be16 protocol, +struct tc_cls_matchall_offload *cls) {bool ingress =TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS );if (chain_index)return -EOPNOTSUPP ; +switch (cls->command) { +case TC_CLSMATCHALL_REPLACE : +return dsa_slave_add_cls_matchall (dev, protocol, cls, ingress); +case TC_CLSMATCHALL_DESTROY : +dsa_slave_del_cls_matchall (dev, cls); +return 0 ; +default : +return -EOPNOTSUPP ; + } +} + +static int dsa_slave_setup_tc (struct net_device *dev,enum tc_setup_type type, +u32 handle,u32 chain_index,__be16 protocol, +struct tc_to_netdev *tc) +{switch (type) {case TC_SETUP_CLSMATCHALL : -switch (tc->cls_mall->command) { -case TC_CLSMATCHALL_REPLACE : -return dsa_slave_add_cls_matchall (dev, protocol, - tc->cls_mall, - ingress); -case TC_CLSMATCHALL_DESTROY : -dsa_slave_del_cls_matchall (dev, tc->cls_mall); -return 0 ; - } +return dsa_slave_setup_tc_cls_matchall (dev, handle, chain_index, + protocol, tc->cls_mall);default :return -EOPNOTSUPP ; }
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 11/16 nfp: change flows in apps that offload ndo_setup_tc
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Change the flows a bit in preparation of follow-up changes in ndo_setup_tc args. Also, change the error code to align with the rest of the drivers.
--- drivers/net/ethernet/netronome/nfp/bpf/main.c | 16 ++++++---------- drivers/net/ethernet/netronome/nfp/flower/offload.c | 10 +++------- 2 files changed, 9 insertions(+), 17 deletions(-)
drivers/net/ethernet/netronome/nfp/bpf/main.c +6 -10
@@ -126,19 +126,15 @@ static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev, {struct nfp_net *nn =netdev_priv (netdev); -if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS )) -return -EOPNOTSUPP ; -if (proto !=htons (ETH_P_ALL )) +if (type !=TC_SETUP_CLSBPF || !nfp_net_ebpf_capable (nn) || +TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || + proto !=htons (ETH_P_ALL ))return -EOPNOTSUPP ; -if (type ==TC_SETUP_CLSBPF &&nfp_net_ebpf_capable (nn)) { -if (!nn->dp.bpf_offload_xdp) -return nfp_net_bpf_offload (nn, tc->cls_bpf); -else -return -EBUSY ; - } +if (nn->dp.bpf_offload_xdp) +return -EBUSY ; -return -EINVAL ; +return nfp_net_bpf_offload (nn, tc->cls_bpf); }static bool nfp_bpf_tc_busy (struct nfp_app *app,struct nfp_net *nn)
drivers/net/ethernet/netronome/nfp/flower/offload.c +3 -7
@@ -388,14 +388,10 @@ int nfp_flower_setup_tc(struct nfp_app *app, struct net_device *netdev, enum tc_setup_type type, u32 handle, __be16 proto, struct tc_to_netdev *tc) { - if (TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS)) + if (type != TC_SETUP_CLSFLOWER || + TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS) || + !eth_proto_is_802_3(proto)) return -EOPNOTSUPP; -if (!eth_proto_is_802_3 (proto)) -return -EOPNOTSUPP ; - -if (type !=TC_SETUP_CLSFLOWER ) -return -EINVAL ; -return nfp_flower_repr_offload (app, netdev, tc->cls_flower); }
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 12/16 hns3pf: don't check handle during mqprio offload
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Similar to the rest offloaders of mqprio, no need to check handle.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +1 -1
@@ -1223,7 +1223,7 @@ static int hns3_nic_setup_tc(struct net_device *dev, enum tc_setup_type type, u32 handle, u32 chain_index, __be16 protocol, struct tc_to_netdev *tc) { - if (handle != TC_H_ROOT || type != TC_SETUP_MQPRIO) + if (type != TC_SETUP_MQPRIO) return -EINVAL; return hns3_setup_tc(dev, tc->mqprio->num_tc);
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 13/16 net: sched: push cls related args into cls_common structure
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
As ndo_setup_tc is generic offload op for whole tc subsystem, does not really make sense to have cls-specific args. So move them under cls_common structurure which is embedded in all cls structs.
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 1 - drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 - drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 1 - drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 - drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 14 +++++------- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c | 7 +++--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.h | 6 ++---- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 1 - .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 1 - drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 1 - drivers/net/ethernet/intel/i40e/i40e_main.c | 1 - drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 17 ++++++--------- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 1 - drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 11 ++++------ drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 15 +++++-------- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 25 ++++++++-------------- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 2 +- .../net/ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- drivers/net/ethernet/netronome/nfp/bpf/main.c | 10 +++++---- drivers/net/ethernet/netronome/nfp/flower/main.h | 3 +-- .../net/ethernet/netronome/nfp/flower/offload.c | 12 ++++++----- drivers/net/ethernet/netronome/nfp/nfp_app.h | 6 ++---- drivers/net/ethernet/netronome/nfp/nfp_port.c | 6 +----- drivers/net/ethernet/netronome/nfp/nfp_port.h | 1 - drivers/net/ethernet/sfc/efx.h | 1 - drivers/net/ethernet/sfc/falcon/efx.h | 1 - drivers/net/ethernet/sfc/falcon/tx.c | 1 - drivers/net/ethernet/sfc/tx.c | 1 - drivers/net/ethernet/ti/netcp_core.c | 1 - include/linux/netdevice.h | 3 --- include/net/pkt_cls.h | 19 ++++++++++++++++ net/dsa/slave.c | 14 +++++------- net/sched/cls_bpf.c | 7 ++---- net/sched/cls_flower.c | 13 ++++++----- net/sched/cls_matchall.c | 8 +++---- net/sched/cls_u32.c | 20 +++++++---------- net/sched/sch_mqprio.c | 6 ++---- 39 files changed, 101 insertions(+), 144 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +0 -1
@@ -1919,7 +1919,6 @@ static void xgbe_poll_controller(struct net_device *netdev)#endif /* End CONFIG_NET_POLL_CONTROLLER */ static int xgbe_setup_tc (struct net_device *netdev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc_to_netdev) {struct xgbe_prv_data *pdata =netdev_priv (netdev);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +0 -1
@@ -4285,7 +4285,6 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc) }int __bnx2x_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO )
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +0 -1
@@ -487,7 +487,6 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);/* setup_tc callback */ int bnx2x_setup_tc (struct net_device *dev,u8 num_tc);int __bnx2x_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc); int bnx2x_get_vf_config(struct net_device *dev, int vf,
drivers/net/ethernet/broadcom/bnxt/bnxt.c +0 -1
@@ -7238,7 +7238,6 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc) }static int bnxt_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *ntc) {if (type !=TC_SETUP_MQPRIO )
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +5 -9
@@ -2890,27 +2890,24 @@ static int cxgb_set_tx_maxrate(struct net_device *dev, int index, u32 rate) }static int cxgb_setup_tc_cls_u32 (struct net_device *dev, -enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_cls_u32_offload *cls_u32) { -if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || - chain_index) +if (TC_H_MAJ (cls_u32->common.handle) !=TC_H_MAJ (TC_H_INGRESS ) || + cls_u32->common.chain_index)return -EOPNOTSUPP ;switch (cls_u32->command) {case TC_CLSU32_NEW_KNODE :case TC_CLSU32_REPLACE_KNODE : -return cxgb4_config_knode (dev, proto, cls_u32); +return cxgb4_config_knode (dev, cls_u32);case TC_CLSU32_DELETE_KNODE : -return cxgb4_delete_knode (dev, proto, cls_u32); +return cxgb4_delete_knode (dev, cls_u32);default :return -EOPNOTSUPP ; } }static int cxgb_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {struct port_info *pi =netdev2pinfo (dev);
@@ -2925,8 +2922,7 @@ static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,switch (type) {case TC_SETUP_CLSU32 : -return cxgb_setup_tc_cls_u32 (dev, type, handle, chain_index, - proto, tc->cls_u32); +return cxgb_setup_tc_cls_u32 (dev, tc->cls_u32);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +3 -4
@@ -146,11 +146,11 @@ static int fill_action_fields(struct adapter *adap,return 0 ; } -int cxgb4_config_knode (struct net_device *dev,__be16 protocol, -struct tc_cls_u32_offload *cls) +int cxgb4_config_knode (struct net_device *dev,struct tc_cls_u32_offload *cls) {const struct cxgb4_match_field *start, *link_start =NULL ;struct adapter *adapter =netdev2adap (dev); +__be16 protocol = cls->common.protocol;struct ch_filter_specification fs;struct cxgb4_tc_u32_table *t;struct cxgb4_link *link;
@@ -338,8 +338,7 @@ int cxgb4_config_knode(struct net_device *dev, __be16 protocol,return ret; } -int cxgb4_delete_knode (struct net_device *dev,__be16 protocol, -struct tc_cls_u32_offload *cls) +int cxgb4_delete_knode (struct net_device *dev,struct tc_cls_u32_offload *cls) {struct adapter *adapter =netdev2adap (dev);unsigned int filter_id, max_tids, i, j;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.h +2 -4
@@ -44,10 +44,8 @@ static inline bool can_tc_u32_offload(struct net_device *dev)return (dev->features &NETIF_F_HW_TC ) && adap->tc_u32 ? true : false; } -int cxgb4_config_knode (struct net_device *dev,__be16 protocol, -struct tc_cls_u32_offload *cls); -int cxgb4_delete_knode (struct net_device *dev,__be16 protocol, -struct tc_cls_u32_offload *cls); +int cxgb4_config_knode (struct net_device *dev,struct tc_cls_u32_offload *cls); +int cxgb4_delete_knode (struct net_device *dev,struct tc_cls_u32_offload *cls);void cxgb4_cleanup_tc_u32 (struct adapter *adapter);struct cxgb4_tc_u32_table *cxgb4_init_tc_u32 (struct adapter *adap);
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +0 -1
@@ -343,7 +343,6 @@ static void dpaa_get_stats64(struct net_device *net_dev, }static int dpaa_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {struct dpaa_priv *priv =netdev_priv (net_dev);
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +0 -1
@@ -1220,7 +1220,6 @@ static int hns3_setup_tc(struct net_device *netdev, u8 tc) }static int hns3_nic_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 protocol,struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO )
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +0 -1
@@ -1266,7 +1266,6 @@ int fm10k_setup_tc(struct net_device *dev, u8 tc) }static int __fm10k_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO )
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -1
@@ -5657,7 +5657,6 @@ static int i40e_setup_tc(struct net_device *netdev, u8 tc) }static int __i40e_setup_tc (struct net_device *netdev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO )
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +6 -11
@@ -8851,7 +8851,6 @@ static int ixgbe_delete_clsu32(struct ixgbe_adapter *adapter, }static int ixgbe_configure_clsu32_add_hnode (struct ixgbe_adapter *adapter, -__be16 protocol,struct tc_cls_u32_offload *cls) {u32 uhtid =TC_U32_USERHTID (cls->hnode.handle);
@@ -9037,9 +9036,9 @@ static int ixgbe_clsu32_build_input(struct ixgbe_fdir_filter *input, }static int ixgbe_configure_clsu32 (struct ixgbe_adapter *adapter, -__be16 protocol,struct tc_cls_u32_offload *cls) { +__be16 protocol = cls->common.protocol;u32 loc = cls->knode.handle &0xfffff ;struct ixgbe_hw *hw = &adapter->hw;struct ixgbe_mat_field *field_ptr;
@@ -9227,25 +9226,23 @@ static int ixgbe_configure_clsu32(struct ixgbe_adapter *adapter, }static int ixgbe_setup_tc_cls_u32 (struct net_device *dev, -u32 handle,u32 chain_index,__be16 proto,struct tc_cls_u32_offload *cls_u32) {struct ixgbe_adapter *adapter =netdev_priv (dev); -if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || - chain_index) +if (TC_H_MAJ (cls_u32->common.handle) !=TC_H_MAJ (TC_H_INGRESS ) || + cls_u32->common.chain_index)return -EOPNOTSUPP ;switch (cls_u32->command) {case TC_CLSU32_NEW_KNODE :case TC_CLSU32_REPLACE_KNODE : -return ixgbe_configure_clsu32 (adapter, proto, cls_u32); +return ixgbe_configure_clsu32 (adapter, cls_u32);case TC_CLSU32_DELETE_KNODE :return ixgbe_delete_clsu32 (adapter, cls_u32);case TC_CLSU32_NEW_HNODE :case TC_CLSU32_REPLACE_HNODE : -return ixgbe_configure_clsu32_add_hnode (adapter, proto, - cls_u32); +return ixgbe_configure_clsu32_add_hnode (adapter, cls_u32);case TC_CLSU32_DELETE_HNODE :return ixgbe_configure_clsu32_del_hnode (adapter, cls_u32);default :
@@ -9261,13 +9258,11 @@ static int ixgbe_setup_tc_mqprio(struct net_device *dev, }static int __ixgbe_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {switch (type) {case TC_SETUP_CLSU32 : -return ixgbe_setup_tc_cls_u32 (dev, handle, chain_index, proto, - tc->cls_u32); +return ixgbe_setup_tc_cls_u32 (dev, tc->cls_u32);case TC_SETUP_MQPRIO :return ixgbe_setup_tc_mqprio (dev, tc->mqprio);default :
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 -1
@@ -131,7 +131,6 @@ int mlx4_en_alloc_tx_queue_per_tc(struct net_device *dev, u8 tc) }static int __mlx4_en_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO )
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +4 -7
@@ -3032,18 +3032,17 @@ static int mlx5e_setup_tc_mqprio(struct net_device *netdev, }static int mlx5e_setup_tc_cls_flower (struct net_device *dev, -u32 handle,u32 chain_index,__be16 proto,struct tc_cls_flower_offload *cls_flower) {struct mlx5e_priv *priv =netdev_priv (dev); -if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || - chain_index) +if (TC_H_MAJ (cls_flower->common.handle) !=TC_H_MAJ (TC_H_INGRESS ) || + cls_flower->common.chain_index)return -EOPNOTSUPP ;switch (cls_flower->command) {case TC_CLSFLOWER_REPLACE : -return mlx5e_configure_flower (priv, proto, cls_flower); +return mlx5e_configure_flower (priv, cls_flower);case TC_CLSFLOWER_DESTROY :return mlx5e_delete_flower (priv, cls_flower);case TC_CLSFLOWER_STATS :
@@ -3054,13 +3053,11 @@ static int mlx5e_setup_tc_cls_flower(struct net_device *dev, }static int mlx5e_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {switch (type) {case TC_SETUP_CLSFLOWER : -return mlx5e_setup_tc_cls_flower (dev, handle, chain_index, - proto, tc->cls_flower); +return mlx5e_setup_tc_cls_flower (dev, tc->cls_flower);case TC_SETUP_MQPRIO :return mlx5e_setup_tc_mqprio (dev, tc->mqprio);default :
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +5 -10
@@ -652,15 +652,13 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev, }static int mlx5e_rep_setup_tc_cls_flower (struct net_device *dev, -u32 handle,u32 chain_index, -__be16 proto,struct tc_to_netdev *tc) {struct tc_cls_flower_offload *cls_flower = tc->cls_flower;struct mlx5e_priv *priv =netdev_priv (dev); -if (TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || - chain_index) +if (TC_H_MAJ (cls_flower->common.handle) !=TC_H_MAJ (TC_H_INGRESS ) || + cls_flower->common.chain_index)return -EOPNOTSUPP ;if (cls_flower->egress_dev) {
@@ -668,13 +666,12 @@ static int mlx5e_rep_setup_tc_cls_flower(struct net_device *dev, dev =mlx5_eswitch_get_uplink_netdev (esw);return dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSFLOWER , - handle, chain_index, - proto, tc); + tc); }switch (cls_flower->command) {case TC_CLSFLOWER_REPLACE : -return mlx5e_configure_flower (priv, proto, cls_flower); +return mlx5e_configure_flower (priv, cls_flower);case TC_CLSFLOWER_DESTROY :return mlx5e_delete_flower (priv, cls_flower);case TC_CLSFLOWER_STATS :
@@ -685,13 +682,11 @@ static int mlx5e_rep_setup_tc_cls_flower(struct net_device *dev, }static int mlx5e_rep_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {switch (type) {case TC_SETUP_CLSFLOWER : -return mlx5e_rep_setup_tc_cls_flower (dev, handle, chain_index, - proto, tc); +return mlx5e_rep_setup_tc_cls_flower (dev, tc);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -1
@@ -1939,7 +1939,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,return err; } -int mlx5e_configure_flower (struct mlx5e_priv *priv,__be16 protocol, +int mlx5e_configure_flower (struct mlx5e_priv *priv,struct tc_cls_flower_offload *f) {struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +1 -1
@@ -38,7 +38,7 @@int mlx5e_tc_init (struct mlx5e_priv *priv);void mlx5e_tc_cleanup (struct mlx5e_priv *priv); -int mlx5e_configure_flower (struct mlx5e_priv *priv,__be16 protocol, +int mlx5e_configure_flower (struct mlx5e_priv *priv,struct tc_cls_flower_offload *f);int mlx5e_delete_flower (struct mlx5e_priv *priv,struct tc_cls_flower_offload *f);
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +9 -16
@@ -1617,11 +1617,11 @@ mlxsw_sp_port_del_cls_matchall_sample(struct mlxsw_sp_port *mlxsw_sp_port) }static int mlxsw_sp_port_add_cls_matchall (struct mlxsw_sp_port *mlxsw_sp_port, -__be16 protocol,struct tc_cls_matchall_offload *f,bool ingress) {struct mlxsw_sp_port_mall_tc_entry *mall_tc_entry; +__be16 protocol = f->common.protocol;const struct tc_action *a;LIST_HEAD (actions);int err;
@@ -1694,18 +1694,16 @@ static void mlxsw_sp_port_del_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port, }static int mlxsw_sp_setup_tc_cls_matchall (struct mlxsw_sp_port *mlxsw_sp_port, -u32 handle,u32 chain_index, -__be16 proto,struct tc_cls_matchall_offload *f) { -bool ingress =TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS ); +bool ingress =TC_H_MAJ (f->common.handle) ==TC_H_MAJ (TC_H_INGRESS ); -if (chain_index) +if (f->common.chain_index)return -EOPNOTSUPP ;switch (f->command) {case TC_CLSMATCHALL_REPLACE : -return mlxsw_sp_port_add_cls_matchall (mlxsw_sp_port, proto, f, +return mlxsw_sp_port_add_cls_matchall (mlxsw_sp_port, f, ingress);case TC_CLSMATCHALL_DESTROY :mlxsw_sp_port_del_cls_matchall (mlxsw_sp_port, f);
@@ -1717,18 +1715,16 @@ 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_port *mlxsw_sp_port, -u32 handle,u32 chain_index,__be16 proto,struct tc_cls_flower_offload *f) { -bool ingress =TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS ); +bool ingress =TC_H_MAJ (f->common.handle) ==TC_H_MAJ (TC_H_INGRESS ); -if (chain_index) +if (f->common.chain_index)return -EOPNOTSUPP ;switch (f->command) {case TC_CLSFLOWER_REPLACE : -return mlxsw_sp_flower_replace (mlxsw_sp_port, ingress, - proto, f); +return mlxsw_sp_flower_replace (mlxsw_sp_port, ingress, f);case TC_CLSFLOWER_DESTROY :mlxsw_sp_flower_destroy (mlxsw_sp_port, ingress, f);return 0 ;
@@ -1740,19 +1736,16 @@ mlxsw_sp_setup_tc_cls_flower(struct mlxsw_sp_port *mlxsw_sp_port, }static int mlxsw_sp_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev);switch (type) {case TC_SETUP_CLSMATCHALL : -return mlxsw_sp_setup_tc_cls_matchall (mlxsw_sp_port, handle, - chain_index, proto, +return mlxsw_sp_setup_tc_cls_matchall (mlxsw_sp_port, tc->cls_mall);case TC_SETUP_CLSFLOWER : -return mlxsw_sp_setup_tc_cls_flower (mlxsw_sp_port, handle, - chain_index, proto, +return mlxsw_sp_setup_tc_cls_flower (mlxsw_sp_port, tc->cls_flower);default :return -EOPNOTSUPP ;
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +1 -1
@@ -508,7 +508,7 @@ extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops;/* spectrum_flower.c */ int mlxsw_sp_flower_replace (struct mlxsw_sp_port *mlxsw_sp_port,bool ingress, -__be16 protocol,struct tc_cls_flower_offload *f); +struct tc_cls_flower_offload *f);void mlxsw_sp_flower_destroy (struct mlxsw_sp_port *mlxsw_sp_port,bool ingress,struct tc_cls_flower_offload *f); int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +1 -1
@@ -368,7 +368,7 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp, }int mlxsw_sp_flower_replace (struct mlxsw_sp_port *mlxsw_sp_port,bool ingress, -__be16 protocol,struct tc_cls_flower_offload *f) +struct tc_cls_flower_offload *f) {struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;struct net_device *dev = mlxsw_sp_port->dev;
drivers/net/ethernet/netronome/nfp/bpf/main.c +6 -4
@@ -121,20 +121,22 @@ static void nfp_bpf_vnic_clean(struct nfp_app *app, struct nfp_net *nn) }static int nfp_bpf_setup_tc (struct nfp_app *app,struct net_device *netdev, -enum tc_setup_type type,u32 handle,__be16 proto, +enum tc_setup_type type,struct tc_to_netdev *tc) { +struct tc_cls_bpf_offload *cls_bpf = tc->cls_bpf;struct nfp_net *nn =netdev_priv (netdev);if (type !=TC_SETUP_CLSBPF || !nfp_net_ebpf_capable (nn) || -TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || - proto !=htons (ETH_P_ALL )) +TC_H_MAJ (cls_bpf->common.handle) !=TC_H_MAJ (TC_H_INGRESS ) || + cls_bpf->common.protocol !=htons (ETH_P_ALL ) || + cls_bpf->common.chain_index)return -EOPNOTSUPP ;if (nn->dp.bpf_offload_xdp)return -EBUSY ; -return nfp_net_bpf_offload (nn, tc->cls_bpf); +return nfp_net_bpf_offload (nn, cls_bpf); }static bool nfp_bpf_tc_busy (struct nfp_app *app,struct nfp_net *nn)
drivers/net/ethernet/netronome/nfp/flower/main.h +1 -2
@@ -135,8 +135,7 @@ int nfp_flower_metadata_init(struct nfp_app *app);void nfp_flower_metadata_cleanup (struct nfp_app *app);int nfp_flower_setup_tc (struct nfp_app *app,struct net_device *netdev, -enum tc_setup_type type,u32 handle,__be16 proto, -struct tc_to_netdev *tc); +enum tc_setup_type type,struct tc_to_netdev *tc); int nfp_flower_compile_flow_match(struct tc_cls_flower_offload *flow, struct nfp_fl_key_ls *key_ls, struct net_device *netdev,
drivers/net/ethernet/netronome/nfp/flower/offload.c +7 -5
@@ -385,13 +385,15 @@ nfp_flower_repr_offload(struct nfp_app *app, struct net_device *netdev, }int nfp_flower_setup_tc (struct nfp_app *app,struct net_device *netdev, -enum tc_setup_type type,u32 handle,__be16 proto, -struct tc_to_netdev *tc) +enum tc_setup_type type,struct tc_to_netdev *tc) { +struct tc_cls_flower_offload *cls_flower = tc->cls_flower; +if (type !=TC_SETUP_CLSFLOWER || -TC_H_MAJ (handle) !=TC_H_MAJ (TC_H_INGRESS ) || - !eth_proto_is_802_3 (proto)) +TC_H_MAJ (cls_flower->common.handle) !=TC_H_MAJ (TC_H_INGRESS ) || + !eth_proto_is_802_3 (cls_flower->common.protocol) || + cls_flower->common.chain_index)return -EOPNOTSUPP ; -return nfp_flower_repr_offload (app, netdev, tc->cls_flower); +return nfp_flower_repr_offload (app, netdev, cls_flower); }
drivers/net/ethernet/netronome/nfp/nfp_app.h +2 -4
@@ -109,8 +109,7 @@ struct nfp_app_type {void (*ctrl_msg_rx)(struct nfp_app *app,struct sk_buff *skb);int (*setup_tc)(struct nfp_app *app,struct net_device *netdev, -enum tc_setup_type type,u32 handle,__be16 proto, -struct tc_to_netdev *tc); +enum tc_setup_type type,struct tc_to_netdev *tc);bool (*tc_busy)(struct nfp_app *app,struct nfp_net *nn);int (*xdp_offload)(struct nfp_app *app,struct nfp_net *nn,struct bpf_prog *prog);
@@ -240,12 +239,11 @@ static inline bool nfp_app_tc_busy(struct nfp_app *app, struct nfp_net *nn)static inline int nfp_app_setup_tc (struct nfp_app *app,struct net_device *netdev,enum tc_setup_type type, -u32 handle,__be16 proto,struct tc_to_netdev *tc) {if (!app || !app->type->setup_tc)return -EOPNOTSUPP ; -return app->type->setup_tc (app, netdev, type, handle, proto, tc); +return app->type->setup_tc (app, netdev, type, tc); } static inline int nfp_app_xdp_offload(struct nfp_app *app, struct nfp_net *nn,
drivers/net/ethernet/netronome/nfp/nfp_port.c +1 -5
@@ -89,19 +89,15 @@ const struct switchdev_ops nfp_port_switchdev_ops = { };int nfp_port_setup_tc (struct net_device *netdev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {struct nfp_port *port; -if (chain_index) -return -EOPNOTSUPP ; - port =nfp_port_from_netdev (netdev);if (!port)return -EOPNOTSUPP ; -return nfp_app_setup_tc (port->app, netdev, type, handle, proto, tc); +return nfp_app_setup_tc (port->app, netdev, type, tc); } struct nfp_port *
drivers/net/ethernet/netronome/nfp/nfp_port.h +0 -1
@@ -110,7 +110,6 @@ struct nfp_port {extern const struct switchdev_ops nfp_port_switchdev_ops;int nfp_port_setup_tc (struct net_device *netdev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc);struct nfp_port *nfp_port_from_netdev (struct net_device *netdev);
drivers/net/ethernet/sfc/efx.h +0 -1
@@ -33,7 +33,6 @@ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb,netdev_tx_t efx_enqueue_skb (struct efx_tx_queue *tx_queue,struct sk_buff *skb);void efx_xmit_done (struct efx_tx_queue *tx_queue,unsigned int index);int efx_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc);unsigned int efx_tx_max_skb_descs (struct efx_nic *efx);extern unsigned int efx_piobuf_size;
drivers/net/ethernet/sfc/falcon/efx.h +0 -1
@@ -33,7 +33,6 @@ netdev_tx_t ef4_hard_start_xmit(struct sk_buff *skb,netdev_tx_t ef4_enqueue_skb (struct ef4_tx_queue *tx_queue,struct sk_buff *skb);void ef4_xmit_done (struct ef4_tx_queue *tx_queue,unsigned int index);int ef4_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc);unsigned int ef4_tx_max_skb_descs (struct ef4_nic *efx);extern bool ef4_separate_tx_channels;
drivers/net/ethernet/sfc/falcon/tx.c +0 -1
@@ -426,7 +426,6 @@ void ef4_init_tx_queue_core_txq(struct ef4_tx_queue *tx_queue) }int ef4_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *ntc) {struct ef4_nic *efx =netdev_priv (net_dev);
drivers/net/ethernet/sfc/tx.c +0 -1
@@ -654,7 +654,6 @@ void efx_init_tx_queue_core_txq(struct efx_tx_queue *tx_queue) }int efx_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *ntc) {struct efx_nic *efx =netdev_priv (net_dev);
drivers/net/ethernet/ti/netcp_core.c +0 -1
@@ -1878,7 +1878,6 @@ static u16 netcp_select_queue(struct net_device *dev, struct sk_buff *skb, }static int netcp_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 proto,struct tc_to_netdev *tc) {u8 num_tc;
include/linux/netdevice.h +0 -3
@@ -977,7 +977,6 @@ struct xfrmdev_ops {* int (*ndo_set_vf_rss_query_en)(struct net_device *dev, int vf, bool setting); * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); * int (*ndo_setup_tc)(struct net_device *dev, enum tc_setup_type type, -* u32 handle, u32 chain_index, __be16 protocol, * struct tc_to_netdev *tc); * Called to setup any 'tc' scheduler, classifier or action on @dev. * This is always called from the stack with the rtnl lock held and netif
@@ -1227,8 +1226,6 @@ struct net_device_ops { int vf, bool setting);int (*ndo_setup_tc)(struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index, -__be16 protocol,struct tc_to_netdev *tc);#if IS_ENABLED (CONFIG_FCOE )int (*ndo_fcoe_enable)(struct net_device *dev);
include/net/pkt_cls.h +19 -0
@@ -405,6 +405,21 @@ tcf_match_indev(struct sk_buff *skb, int ifindex) }#endif /* CONFIG_NET_CLS_IND */ +struct tc_cls_common_offload { +u32 handle; +u32 chain_index; +__be16 protocol; +}; + +static inline void +tc_cls_common_offload_init (struct tc_cls_common_offload *cls_common, +const struct tcf_proto *tp) +{ + cls_common->handle = tp->q->handle; + cls_common->chain_index = tp->chain->index; + cls_common->protocol = tp->protocol; +} +struct tc_cls_u32_knode {struct tcf_exts *exts;struct tc_u32_sel *sel;
@@ -431,6 +446,7 @@ enum tc_clsu32_command { };struct tc_cls_u32_offload { +struct tc_cls_common_offload common;/* knode values */ enum tc_clsu32_command command;union {
@@ -497,6 +513,7 @@ enum tc_fl_command { };struct tc_cls_flower_offload { +struct tc_cls_common_offload common;enum tc_fl_command command;u32 prio;unsigned long cookie;
@@ -513,6 +530,7 @@ enum tc_matchall_command { };struct tc_cls_matchall_offload { +struct tc_cls_common_offload common;enum tc_matchall_command command;struct tcf_exts *exts;unsigned long cookie;
@@ -526,6 +544,7 @@ enum tc_clsbpf_command { };struct tc_cls_bpf_offload { +struct tc_cls_common_offload common;enum tc_clsbpf_command command;struct tcf_exts *exts;struct bpf_prog *prog;
net/dsa/slave.c +5 -9
@@ -774,12 +774,12 @@ dsa_slave_mall_tc_entry_find(struct dsa_slave_priv *p, }static int dsa_slave_add_cls_matchall (struct net_device *dev, -__be16 protocol,struct tc_cls_matchall_offload *cls,bool ingress) {struct dsa_slave_priv *p =netdev_priv (dev);struct dsa_mall_tc_entry *mall_tc_entry; +__be16 protocol = cls->common.protocol;struct dsa_switch *ds = p->dp->ds;struct net *net =dev_net (dev);struct dsa_slave_priv *to_p;
@@ -864,18 +864,16 @@ static void dsa_slave_del_cls_matchall(struct net_device *dev, }static int dsa_slave_setup_tc_cls_matchall (struct net_device *dev, -u32 handle,u32 chain_index, -__be16 protocol,struct tc_cls_matchall_offload *cls) { -bool ingress =TC_H_MAJ (handle) ==TC_H_MAJ (TC_H_INGRESS ); +bool ingress =TC_H_MAJ (cls->common.handle) ==TC_H_MAJ (TC_H_INGRESS ); -if (chain_index) +if (cls->common.chain_index)return -EOPNOTSUPP ;switch (cls->command) {case TC_CLSMATCHALL_REPLACE : -return dsa_slave_add_cls_matchall (dev, protocol, cls, ingress); +return dsa_slave_add_cls_matchall (dev, cls, ingress);case TC_CLSMATCHALL_DESTROY :dsa_slave_del_cls_matchall (dev, cls);return 0 ;
@@ -885,13 +883,11 @@ static int dsa_slave_setup_tc_cls_matchall(struct net_device *dev, }static int dsa_slave_setup_tc (struct net_device *dev,enum tc_setup_type type, -u32 handle,u32 chain_index,__be16 protocol,struct tc_to_netdev *tc) {switch (type) {case TC_SETUP_CLSMATCHALL : -return dsa_slave_setup_tc_cls_matchall (dev, handle, chain_index, - protocol, tc->cls_mall); +return dsa_slave_setup_tc_cls_matchall (dev, tc->cls_mall);default :return -EOPNOTSUPP ; }
net/sched/cls_bpf.c +2 -5
@@ -153,6 +153,7 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog, offload.cls_bpf = &bpf_offload; +tc_cls_common_offload_init (&bpf_offload.common, tp); bpf_offload.command = cmd; bpf_offload.exts = &prog->exts; bpf_offload.prog = prog->filter;
@@ -160,11 +161,7 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog, bpf_offload.exts_integrated = prog->exts_integrated; bpf_offload.gen_flags = prog->gen_flags; - err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSBPF , - tp->q->handle, - tp->chain->index, - tp->protocol, &offload); - + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSBPF , &offload);if (!err && (cmd ==TC_CLSBPF_ADD || cmd ==TC_CLSBPF_REPLACE )) prog->gen_flags |=TCA_CLS_FLAGS_IN_HW ;
net/sched/cls_flower.c +6 -7
@@ -232,14 +232,14 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, struct cls_fl_filter *f)if (!tc_can_offload (dev, tp))return ; +tc_cls_common_offload_init (&offload.common, tp); offload.command =TC_CLSFLOWER_DESTROY ; offload.prio = tp->prio; offload.cookie = (unsigned long )f; tc->cls_flower = &offload; - dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSFLOWER , tp->q->handle, - tp->chain->index, tp->protocol, tc); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSFLOWER , tc); } static int fl_hw_replace_filter(struct tcf_proto *tp,
@@ -264,6 +264,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, f->hw_dev = dev; } +tc_cls_common_offload_init (&offload.common, tp); offload.command =TC_CLSFLOWER_REPLACE ; offload.prio = tp->prio; offload.cookie = (unsigned long )f;
@@ -274,9 +275,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp, tc->cls_flower = &offload; - err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSFLOWER , - tp->q->handle, tp->chain->index, - tp->protocol, tc); + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSFLOWER , tc);if (!err) f->flags |=TCA_CLS_FLAGS_IN_HW ;
@@ -294,6 +293,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)if (!tc_can_offload (dev, tp))return ; +tc_cls_common_offload_init (&offload.common, tp); offload.command =TC_CLSFLOWER_STATS ; offload.prio = tp->prio; offload.cookie = (unsigned long )f;
@@ -301,8 +301,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) tc->cls_flower = &offload; - dev->netdev_ops->ndo_setup_tc (dev,TC_CLSFLOWER_STATS , tp->q->handle, - tp->chain->index, tp->protocol, tc); + dev->netdev_ops->ndo_setup_tc (dev,TC_CLSFLOWER_STATS , tc); }static void __fl_delete (struct tcf_proto *tp,struct cls_fl_filter *f)
net/sched/cls_matchall.c +4 -4
@@ -58,14 +58,14 @@ static int mall_replace_hw_filter(struct tcf_proto *tp,struct tc_cls_matchall_offload mall_offload = {0 };int err; +tc_cls_common_offload_init (&mall_offload.common, tp); offload.cls_mall = &mall_offload; offload.cls_mall->command =TC_CLSMATCHALL_REPLACE ; offload.cls_mall->exts = &head->exts; offload.cls_mall->cookie = cookie; err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSMATCHALL , - tp->q->handle, tp->chain->index, - tp->protocol, &offload); + &offload);if (!err) head->flags |=TCA_CLS_FLAGS_IN_HW ;
@@ -80,13 +80,13 @@ static void mall_destroy_hw_filter(struct tcf_proto *tp,struct tc_to_netdev offload;struct tc_cls_matchall_offload mall_offload = {0 }; +tc_cls_common_offload_init (&mall_offload.common, tp); offload.cls_mall = &mall_offload; offload.cls_mall->command =TC_CLSMATCHALL_DESTROY ; offload.cls_mall->exts =NULL ; offload.cls_mall->cookie = cookie; - dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSMATCHALL , tp->q->handle, - tp->chain->index, tp->protocol, &offload); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSMATCHALL , &offload); }static void mall_destroy (struct tcf_proto *tp)
net/sched/cls_u32.c +8 -12
@@ -437,11 +437,10 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle) offload.cls_u32 = &u32_offload;if (tc_should_offload (dev, tp,0 )) { +tc_cls_common_offload_init (&u32_offload.common, tp); offload.cls_u32->command =TC_CLSU32_DELETE_KNODE ; offload.cls_u32->knode.handle = handle; - dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , - tp->q->handle, tp->chain->index, - tp->protocol, &offload); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , &offload); } }
@@ -458,14 +457,13 @@ static int u32_replace_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h, offload.cls_u32 = &u32_offload; +tc_cls_common_offload_init (&u32_offload.common, tp); offload.cls_u32->command =TC_CLSU32_NEW_HNODE ; offload.cls_u32->hnode.divisor = h->divisor; offload.cls_u32->hnode.handle = h->handle; offload.cls_u32->hnode.prio = h->prio; - err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , tp->q->handle, - tp->chain->index, tp->protocol, - &offload); + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , &offload);if (tc_skip_sw (flags))return err;
@@ -481,14 +479,13 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) offload.cls_u32 = &u32_offload;if (tc_should_offload (dev, tp,0 )) { +tc_cls_common_offload_init (&u32_offload.common, tp); offload.cls_u32->command =TC_CLSU32_DELETE_HNODE ; offload.cls_u32->hnode.divisor = h->divisor; offload.cls_u32->hnode.handle = h->handle; offload.cls_u32->hnode.prio = h->prio; - dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , - tp->q->handle, tp->chain->index, - tp->protocol, &offload); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , &offload); } }
@@ -505,6 +502,7 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,if (!tc_should_offload (dev, tp, flags))return tc_skip_sw (flags) ? -EINVAL :0 ; +tc_cls_common_offload_init (&u32_offload.common, tp); offload.cls_u32->command =TC_CLSU32_REPLACE_KNODE ; offload.cls_u32->knode.handle = n->handle; offload.cls_u32->knode.fshift = n->fshift;
@@ -520,9 +518,7 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,if (n->ht_down) offload.cls_u32->knode.link_handle = n->ht_down->handle; - err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , tp->q->handle, - tp->chain->index, tp->protocol, - &offload); + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSU32 , &offload);if (!err) n->flags |=TCA_CLS_FLAGS_IN_HW ;
net/sched/sch_mqprio.c +2 -4
@@ -42,8 +42,7 @@ static void mqprio_destroy(struct Qdisc *sch)struct tc_mqprio_qopt offload = {0 };struct tc_to_netdev tc = { { .mqprio = &offload } }; - dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , - sch->handle,0 ,0 , &tc); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , &tc); }else {netdev_set_num_tc (dev,0 ); }
@@ -151,8 +150,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)struct tc_mqprio_qopt offload = *qopt;struct tc_to_netdev tc = { { .mqprio = &offload } }; - err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , - sch->handle,0 ,0 , &tc); + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , &tc);if (err)return err;
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 14/16 net: sched: move prio into cls_common
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
prio is not cls_flower specific, but it is meaningful for all classifiers. Seems that only mlxsw cares about the value. Obviously, cls offload in other drivers is broken.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- include/net/pkt_cls.h | 3 ++- net/sched/cls_flower.c | 3 --- 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +1 -1
@@ -270,7 +270,7 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,return -EOPNOTSUPP ; } -mlxsw_sp_acl_rulei_priority (rulei, f->prio); +mlxsw_sp_acl_rulei_priority (rulei, f->common.prio);if (dissector_uses_key (f->dissector,FLOW_DISSECTOR_KEY_CONTROL )) { struct flow_dissector_key_control *key =
include/net/pkt_cls.h +2 -1
@@ -409,6 +409,7 @@ struct tc_cls_common_offload {u32 handle;u32 chain_index;__be16 protocol; +u32 prio; }; static inline void
@@ -418,6 +419,7 @@ tc_cls_common_offload_init(struct tc_cls_common_offload *cls_common, cls_common->handle = tp->q->handle; cls_common->chain_index = tp->chain->index; cls_common->protocol = tp->protocol; + cls_common->prio = tp->prio; }struct tc_cls_u32_knode {
@@ -515,7 +517,6 @@ enum tc_fl_command {struct tc_cls_flower_offload {struct tc_cls_common_offload common;enum tc_fl_command command; -u32 prio;unsigned long cookie;struct flow_dissector *dissector;struct fl_flow_key *mask;
net/sched/cls_flower.c +0 -3
@@ -234,7 +234,6 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, struct cls_fl_filter *f)tc_cls_common_offload_init (&offload.common, tp); offload.command =TC_CLSFLOWER_DESTROY ; - offload.prio = tp->prio; offload.cookie = (unsigned long )f; tc->cls_flower = &offload;
@@ -266,7 +265,6 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,tc_cls_common_offload_init (&offload.common, tp); offload.command =TC_CLSFLOWER_REPLACE ; - offload.prio = tp->prio; offload.cookie = (unsigned long )f; offload.dissector = dissector; offload.mask = mask;
@@ -295,7 +293,6 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)tc_cls_common_offload_init (&offload.common, tp); offload.command =TC_CLSFLOWER_STATS ; - offload.prio = tp->prio; offload.cookie = (unsigned long )f; offload.exts = &f->exts;
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 15/16 net: sched: change return value of ndo_setup_tc for driver supporting mqprio only
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Change the return value from -EINVAL to -EOPNOTSUPP. The rest of the drivers have it like that, so be aligned.
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 2 +- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +- drivers/net/ethernet/sfc/falcon/tx.c | 2 +- drivers/net/ethernet/sfc/tx.c | 2 +- drivers/net/ethernet/ti/netcp_core.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +1 -1
@@ -1925,7 +1925,7 @@ static int xgbe_setup_tc(struct net_device *netdev, enum tc_setup_type type,u8 tc;if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ; tc_to_netdev->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; tc = tc_to_netdev->mqprio->num_tc;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -1
@@ -4288,7 +4288,7 @@ int __bnx2x_setup_tc(struct net_device *dev, enum tc_setup_type type, struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
@@ -7241,7 +7241,7 @@ static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type, struct tc_to_netdev *ntc) {if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ; ntc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +1 -1
@@ -350,7 +350,7 @@ static int dpaa_setup_tc(struct net_device *net_dev, enum tc_setup_type type,int i;if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; num_tc = tc->mqprio->num_tc;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +1 -1
@@ -1223,7 +1223,7 @@ static int hns3_nic_setup_tc(struct net_device *dev, enum tc_setup_type type, struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ;return hns3_setup_tc (dev, tc->mqprio->num_tc); }
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +1 -1
@@ -1269,7 +1269,7 @@ static int __fm10k_setup_tc(struct net_device *dev, enum tc_setup_type type, struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -5660,7 +5660,7 @@ static int __i40e_setup_tc(struct net_device *netdev, enum tc_setup_type type, struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1 -1
@@ -134,7 +134,7 @@ static int __mlx4_en_setup_tc(struct net_device *dev, enum tc_setup_type type, struct tc_to_netdev *tc) {if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ;if (tc->mqprio->num_tc && tc->mqprio->num_tc !=MLX4_EN_NUM_UP_HIGH )return -EINVAL ;
drivers/net/ethernet/sfc/falcon/tx.c +1 -1
@@ -435,7 +435,7 @@ int ef4_setup_tc(struct net_device *net_dev, enum tc_setup_type type,int rc;if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ; num_tc = ntc->mqprio->num_tc;
drivers/net/ethernet/sfc/tx.c +1 -1
@@ -663,7 +663,7 @@ int efx_setup_tc(struct net_device *net_dev, enum tc_setup_type type,int rc;if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ; num_tc = ntc->mqprio->num_tc;
drivers/net/ethernet/ti/netcp_core.c +1 -1
@@ -1887,7 +1887,7 @@ static int netcp_setup_tc(struct net_device *dev, enum tc_setup_type type,ASSERT_RTNL ();if (type !=TC_SETUP_MQPRIO ) -return -EINVAL ; +return -EOPNOTSUPP ; tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; num_tc = tc->mqprio->num_tc;
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH v2 16/16 net: sched: get rid of struct tc_to_netdev
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Get rid of struct tc_to_netdev which is now just unnecessary container and rather pass per-type structures down to drivers directly. Along with that, consolidate the naming of per-type structure variables in cls_*.
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 7 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 8 ++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 +- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 7 +- .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 6 +- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 8 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 8 ++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 10 +-- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 12 ++-- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 2 + drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 8 +-- drivers/net/ethernet/netronome/nfp/bpf/main.c | 5 +- drivers/net/ethernet/netronome/nfp/flower/main.h | 4 +- .../net/ethernet/netronome/nfp/flower/offload.c | 4 +- drivers/net/ethernet/netronome/nfp/nfp_app.h | 8 +-- drivers/net/ethernet/netronome/nfp/nfp_port.c | 4 +- drivers/net/ethernet/netronome/nfp/nfp_port.h | 3 +- drivers/net/ethernet/sfc/efx.h | 2 +- drivers/net/ethernet/sfc/falcon/efx.h | 2 +- drivers/net/ethernet/sfc/falcon/tx.c | 7 +- drivers/net/ethernet/sfc/tx.c | 7 +- drivers/net/ethernet/ti/netcp_core.c | 7 +- include/linux/netdevice.h | 19 +---- net/dsa/slave.c | 4 +- net/sched/cls_bpf.c | 21 +++--- net/sched/cls_flower.c | 54 ++++++-------- net/sched/cls_matchall.c | 27 +++---- net/sched/cls_u32.c | 83 ++++++++++------------ net/sched/sch_mqprio.c | 13 ++-- 33 files changed, 174 insertions(+), 202 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +4 -3
@@ -1919,16 +1919,17 @@ static void xgbe_poll_controller(struct net_device *netdev)#endif /* End CONFIG_NET_POLL_CONTROLLER */ static int xgbe_setup_tc (struct net_device *netdev,enum tc_setup_type type, -struct tc_to_netdev *tc_to_netdev) +void *type_data) {struct xgbe_prv_data *pdata =netdev_priv (netdev); +struct tc_mqprio_qopt *mqprio = type_data;u8 tc;if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; - tc_to_netdev->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; - tc = tc_to_netdev->mqprio->num_tc; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + tc = mqprio->num_tc;if (tc > pdata->hw_feat.tc_cnt)return -EINVAL ;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +5 -3
@@ -4285,14 +4285,16 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc) }int __bnx2x_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) { +struct tc_mqprio_qopt *mqprio = type_data; +if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; - tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; -return bnx2x_setup_tc (dev, tc->mqprio->num_tc); +return bnx2x_setup_tc (dev, mqprio->num_tc); }/* called with rtnl_lock */
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +1 -1
@@ -487,7 +487,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);/* setup_tc callback */ int bnx2x_setup_tc (struct net_device *dev,u8 num_tc);int __bnx2x_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc); +void *type_data);int bnx2x_get_vf_config (struct net_device *dev,int vf,struct ifla_vf_info *ivi);
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -3
@@ -7238,14 +7238,16 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc) }static int bnxt_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *ntc) +void *type_data) { +struct tc_mqprio_qopt *mqprio = type_data; +if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; - ntc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; -return bnxt_setup_mq_tc (dev, ntc->mqprio->num_tc); +return bnxt_setup_mq_tc (dev, mqprio->num_tc); }#ifdef CONFIG_RFS_ACCEL
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +2 -2
@@ -2908,7 +2908,7 @@ static int cxgb_setup_tc_cls_u32(struct net_device *dev, }static int cxgb_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) {struct port_info *pi =netdev2pinfo (dev);struct adapter *adap =netdev2adap (dev);
@@ -2922,7 +2922,7 @@ static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,switch (type) {case TC_SETUP_CLSU32 : -return cxgb_setup_tc_cls_u32 (dev, tc->cls_u32); +return cxgb_setup_tc_cls_u32 (dev, type_data);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +4 -3
@@ -343,17 +343,18 @@ static void dpaa_get_stats64(struct net_device *net_dev, }static int dpaa_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) {struct dpaa_priv *priv =netdev_priv (net_dev); +struct tc_mqprio_qopt *mqprio = type_data;u8 num_tc;int i;if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; - tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; - num_tc = tc->mqprio->num_tc; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + num_tc = mqprio->num_tc;if (num_tc == priv->num_tc)return 0 ;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +4 -2
@@ -1220,12 +1220,14 @@ static int hns3_setup_tc(struct net_device *netdev, u8 tc) }static int hns3_nic_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) { +struct tc_mqprio_qopt *mqprio = type_data; +if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; -return hns3_setup_tc (dev, tc->mqprio->num_tc); +return hns3_setup_tc (dev, mqprio->num_tc); } static int hns3_vlan_rx_add_vid(struct net_device *netdev,
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +5 -3
@@ -1266,14 +1266,16 @@ int fm10k_setup_tc(struct net_device *dev, u8 tc) }static int __fm10k_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) { +struct tc_mqprio_qopt *mqprio = type_data; +if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; - tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; -return fm10k_setup_tc (dev, tc->mqprio->num_tc); +return fm10k_setup_tc (dev, mqprio->num_tc); } static void fm10k_assign_l2_accel(struct fm10k_intfc *interface,
drivers/net/ethernet/intel/i40e/i40e_main.c +5 -3
@@ -5657,14 +5657,16 @@ static int i40e_setup_tc(struct net_device *netdev, u8 tc) }static int __i40e_setup_tc (struct net_device *netdev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) { +struct tc_mqprio_qopt *mqprio = type_data; +if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; - tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; -return i40e_setup_tc (netdev, tc->mqprio->num_tc); +return i40e_setup_tc (netdev, mqprio->num_tc); }/**
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +3 -3
@@ -9258,13 +9258,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, -struct tc_to_netdev *tc) +void *type_data) {switch (type) {case TC_SETUP_CLSU32 : -return ixgbe_setup_tc_cls_u32 (dev, tc->cls_u32); +return ixgbe_setup_tc_cls_u32 (dev, type_data);case TC_SETUP_MQPRIO : -return ixgbe_setup_tc_mqprio (dev, tc->mqprio); +return ixgbe_setup_tc_mqprio (dev, type_data);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +6 -4
@@ -131,17 +131,19 @@ int mlx4_en_alloc_tx_queue_per_tc(struct net_device *dev, u8 tc) }static int __mlx4_en_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) { +struct tc_mqprio_qopt *mqprio = type_data; +if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; -if (tc->mqprio->num_tc && tc->mqprio->num_tc !=MLX4_EN_NUM_UP_HIGH ) +if (mqprio->num_tc && mqprio->num_tc !=MLX4_EN_NUM_UP_HIGH )return -EINVAL ; - tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; -return mlx4_en_alloc_tx_queue_per_tc (dev, tc->mqprio->num_tc); +return mlx4_en_alloc_tx_queue_per_tc (dev, mqprio->num_tc); }#ifdef CONFIG_RFS_ACCEL
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 -3
@@ -3053,13 +3053,13 @@ static int mlx5e_setup_tc_cls_flower(struct net_device *dev, }static int mlx5e_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) {switch (type) {case TC_SETUP_CLSFLOWER : -return mlx5e_setup_tc_cls_flower (dev, tc->cls_flower); +return mlx5e_setup_tc_cls_flower (dev, type_data);case TC_SETUP_MQPRIO : -return mlx5e_setup_tc_mqprio (dev, tc->mqprio); +return mlx5e_setup_tc_mqprio (dev, type_data);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +6 -6
@@ -651,10 +651,10 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev,return 0 ; } -static int mlx5e_rep_setup_tc_cls_flower (struct net_device *dev, -struct tc_to_netdev *tc) +static int +mlx5e_rep_setup_tc_cls_flower (struct net_device *dev, +struct tc_cls_flower_offload *cls_flower) { -struct tc_cls_flower_offload *cls_flower = tc->cls_flower;struct mlx5e_priv *priv =netdev_priv (dev); if (TC_H_MAJ(cls_flower->common.handle) != TC_H_MAJ(TC_H_INGRESS) ||
@@ -666,7 +666,7 @@ static int mlx5e_rep_setup_tc_cls_flower(struct net_device *dev, dev =mlx5_eswitch_get_uplink_netdev (esw);return dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSFLOWER , - tc); + cls_flower); }switch (cls_flower->command) {
@@ -682,11 +682,11 @@ static int mlx5e_rep_setup_tc_cls_flower(struct net_device *dev, }static int mlx5e_rep_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) {switch (type) {case TC_SETUP_CLSFLOWER : -return mlx5e_rep_setup_tc_cls_flower (dev, tc); +return mlx5e_rep_setup_tc_cls_flower (dev, type_data);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +2 -0
@@ -33,6 +33,8 @@#ifndef __MLX5_EN_TC_H__#define __MLX5_EN_TC_H__ +#include <net/pkt_cls.h> +#define MLX5E_TC_FLOW_ID_MASK 0x0000ffffint mlx5e_tc_init (struct mlx5e_priv *priv);
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +3 -5
@@ -1736,17 +1736,15 @@ mlxsw_sp_setup_tc_cls_flower(struct mlxsw_sp_port *mlxsw_sp_port, }static int mlxsw_sp_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) {struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev);switch (type) {case TC_SETUP_CLSMATCHALL : -return mlxsw_sp_setup_tc_cls_matchall (mlxsw_sp_port, - tc->cls_mall); +return mlxsw_sp_setup_tc_cls_matchall (mlxsw_sp_port, type_data);case TC_SETUP_CLSFLOWER : -return mlxsw_sp_setup_tc_cls_flower (mlxsw_sp_port, - tc->cls_flower); +return mlxsw_sp_setup_tc_cls_flower (mlxsw_sp_port, type_data);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/netronome/nfp/bpf/main.c +2 -3
@@ -121,10 +121,9 @@ static void nfp_bpf_vnic_clean(struct nfp_app *app, struct nfp_net *nn) }static int nfp_bpf_setup_tc (struct nfp_app *app,struct net_device *netdev, -enum tc_setup_type type, -struct tc_to_netdev *tc) +enum tc_setup_type type,void *type_data) { -struct tc_cls_bpf_offload *cls_bpf = tc->cls_bpf; +struct tc_cls_bpf_offload *cls_bpf = type_data;struct nfp_net *nn =netdev_priv (netdev); if (type != TC_SETUP_CLSBPF || !nfp_net_ebpf_capable(nn) ||
drivers/net/ethernet/netronome/nfp/flower/main.h +2 -2
@@ -38,8 +38,8 @@#include <linux/hashtable.h> #include <linux/time64.h> #include <linux/types.h> +#include <net/pkt_cls.h> -struct tc_to_netdev ;struct net_device ;struct nfp_app ;
@@ -135,7 +135,7 @@ int nfp_flower_metadata_init(struct nfp_app *app);void nfp_flower_metadata_cleanup (struct nfp_app *app);int nfp_flower_setup_tc (struct nfp_app *app,struct net_device *netdev, -enum tc_setup_type type,struct tc_to_netdev *tc); +enum tc_setup_type type,void *type_data); int nfp_flower_compile_flow_match(struct tc_cls_flower_offload *flow, struct nfp_fl_key_ls *key_ls, struct net_device *netdev,
drivers/net/ethernet/netronome/nfp/flower/offload.c +2 -2
@@ -385,9 +385,9 @@ nfp_flower_repr_offload(struct nfp_app *app, struct net_device *netdev, }int nfp_flower_setup_tc (struct nfp_app *app,struct net_device *netdev, -enum tc_setup_type type,struct tc_to_netdev *tc) +enum tc_setup_type type,void *type_data) { -struct tc_cls_flower_offload *cls_flower = tc->cls_flower; +struct tc_cls_flower_offload *cls_flower = type_data; if (type != TC_SETUP_CLSFLOWER || TC_H_MAJ(cls_flower->common.handle) != TC_H_MAJ(TC_H_INGRESS) ||
drivers/net/ethernet/netronome/nfp/nfp_app.h +3 -5
@@ -42,7 +42,6 @@ struct bpf_prog;struct net_device ;struct pci_dev ;struct sk_buff ; -struct tc_to_netdev ;struct sk_buff ;struct nfp_app ;struct nfp_cpp ;
@@ -109,7 +108,7 @@ struct nfp_app_type {void (*ctrl_msg_rx)(struct nfp_app *app,struct sk_buff *skb);int (*setup_tc)(struct nfp_app *app,struct net_device *netdev, -enum tc_setup_type type,struct tc_to_netdev *tc); +enum tc_setup_type type,void *type_data);bool (*tc_busy)(struct nfp_app *app,struct nfp_net *nn);int (*xdp_offload)(struct nfp_app *app,struct nfp_net *nn,struct bpf_prog *prog);
@@ -238,12 +237,11 @@ static inline bool nfp_app_tc_busy(struct nfp_app *app, struct nfp_net *nn)static inline int nfp_app_setup_tc (struct nfp_app *app,struct net_device *netdev, -enum tc_setup_type type, -struct tc_to_netdev *tc) +enum tc_setup_type type,void *type_data) {if (!app || !app->type->setup_tc)return -EOPNOTSUPP ; -return app->type->setup_tc (app, netdev, type, tc); +return app->type->setup_tc (app, netdev, type, type_data); } static inline int nfp_app_xdp_offload(struct nfp_app *app, struct nfp_net *nn,
drivers/net/ethernet/netronome/nfp/nfp_port.c +2 -2
@@ -89,7 +89,7 @@ const struct switchdev_ops nfp_port_switchdev_ops = { };int nfp_port_setup_tc (struct net_device *netdev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) {struct nfp_port *port;
@@ -97,7 +97,7 @@ int nfp_port_setup_tc(struct net_device *netdev, enum tc_setup_type type,if (!port)return -EOPNOTSUPP ; -return nfp_app_setup_tc (port->app, netdev, type, tc); +return nfp_app_setup_tc (port->app, netdev, type, type_data); } struct nfp_port *
drivers/net/ethernet/netronome/nfp/nfp_port.h +1 -2
@@ -36,7 +36,6 @@#include <net/devlink.h> -struct tc_to_netdev ;struct net_device ;struct nfp_app ;struct nfp_pf ;
@@ -110,7 +109,7 @@ struct nfp_port {extern const struct switchdev_ops nfp_port_switchdev_ops;int nfp_port_setup_tc (struct net_device *netdev,enum tc_setup_type type, -struct tc_to_netdev *tc); +void *type_data);struct nfp_port *nfp_port_from_netdev (struct net_device *netdev); struct nfp_port *
drivers/net/ethernet/sfc/efx.h +1 -1
@@ -33,7 +33,7 @@ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb,netdev_tx_t efx_enqueue_skb (struct efx_tx_queue *tx_queue,struct sk_buff *skb);void efx_xmit_done (struct efx_tx_queue *tx_queue,unsigned int index);int efx_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -struct tc_to_netdev *tc); +void *type_data);unsigned int efx_tx_max_skb_descs (struct efx_nic *efx);extern unsigned int efx_piobuf_size;extern bool efx_separate_tx_channels;
drivers/net/ethernet/sfc/falcon/efx.h +1 -1
@@ -33,7 +33,7 @@ netdev_tx_t ef4_hard_start_xmit(struct sk_buff *skb,netdev_tx_t ef4_enqueue_skb (struct ef4_tx_queue *tx_queue,struct sk_buff *skb);void ef4_xmit_done (struct ef4_tx_queue *tx_queue,unsigned int index);int ef4_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -struct tc_to_netdev *tc); +void *type_data);unsigned int ef4_tx_max_skb_descs (struct ef4_nic *efx);extern bool ef4_separate_tx_channels;
drivers/net/ethernet/sfc/falcon/tx.c +4 -3
@@ -426,9 +426,10 @@ void ef4_init_tx_queue_core_txq(struct ef4_tx_queue *tx_queue) }int ef4_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -struct tc_to_netdev *ntc) +void *type_data) {struct ef4_nic *efx =netdev_priv (net_dev); +struct tc_mqprio_qopt *mqprio = type_data;struct ef4_channel *channel;struct ef4_tx_queue *tx_queue;unsigned tc, num_tc;
@@ -437,12 +438,12 @@ int ef4_setup_tc(struct net_device *net_dev, enum tc_setup_type type,if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; - num_tc = ntc->mqprio->num_tc; + num_tc = mqprio->num_tc;if (ef4_nic_rev (efx) <EF4_REV_FALCON_B0 || num_tc >EF4_MAX_TX_TC )return -EINVAL ; - ntc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;if (num_tc == net_dev->num_tc)return 0 ;
drivers/net/ethernet/sfc/tx.c +4 -3
@@ -654,9 +654,10 @@ void efx_init_tx_queue_core_txq(struct efx_tx_queue *tx_queue) }int efx_setup_tc (struct net_device *net_dev,enum tc_setup_type type, -struct tc_to_netdev *ntc) +void *type_data) {struct efx_nic *efx =netdev_priv (net_dev); +struct tc_mqprio_qopt *mqprio = type_data;struct efx_channel *channel;struct efx_tx_queue *tx_queue;unsigned tc, num_tc;
@@ -665,12 +666,12 @@ int efx_setup_tc(struct net_device *net_dev, enum tc_setup_type type,if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; - num_tc = ntc->mqprio->num_tc; + num_tc = mqprio->num_tc;if (num_tc >EFX_MAX_TX_TC )return -EINVAL ; - ntc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ;if (num_tc == net_dev->num_tc)return 0 ;
drivers/net/ethernet/ti/netcp_core.c +4 -3
@@ -1878,8 +1878,9 @@ static u16 netcp_select_queue(struct net_device *dev, struct sk_buff *skb, }static int netcp_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) { +struct tc_mqprio_qopt *mqprio = type_data;u8 num_tc;int i;
@@ -1889,8 +1890,8 @@ static int netcp_setup_tc(struct net_device *dev, enum tc_setup_type type,if (type !=TC_SETUP_MQPRIO )return -EOPNOTSUPP ; - tc->mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; - num_tc = tc->mqprio->num_tc; + mqprio->hw =TC_MQPRIO_HW_OFFLOAD_TCS ; + num_tc = mqprio->num_tc;/* Sanity-check the number of traffic classes requested */ if ((dev->real_num_tx_queues <= 1) ||
include/linux/netdevice.h +2 -17
@@ -771,9 +771,6 @@ static inline bool netdev_phys_item_id_same(struct netdev_phys_item_id *a,typedef u16 (*select_queue_fallback_t )(struct net_device *dev,struct sk_buff *skb); -/* These structures hold the attributes of qdisc and classifiers -* that are being passed to the netdevice through the setup_tc op. -*/ enum tc_setup_type {TC_SETUP_MQPRIO ,TC_SETUP_CLSU32 ,
@@ -782,18 +779,6 @@ enum tc_setup_type { TC_SETUP_CLSBPF, }; -struct tc_cls_u32_offload ; - -struct tc_to_netdev { -union { -struct tc_cls_u32_offload *cls_u32; -struct tc_cls_flower_offload *cls_flower; -struct tc_cls_matchall_offload *cls_mall; -struct tc_cls_bpf_offload *cls_bpf; -struct tc_mqprio_qopt *mqprio; - }; -}; -/* These structures hold the attributes of xdp state that are being passed * to the netdevice through the xdp op. */
@@ -977,7 +962,7 @@ struct xfrmdev_ops {* int (*ndo_set_vf_rss_query_en)(struct net_device *dev, int vf, bool setting); * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); * int (*ndo_setup_tc)(struct net_device *dev, enum tc_setup_type type, -* struct tc_to_netdev *tc); +* void *type_data); * Called to setup any 'tc' scheduler, classifier or action on @dev. * This is always called from the stack with the rtnl lock held and netif * tx queues stopped. This allows the netdevice to perform queue
@@ -1226,7 +1211,7 @@ struct net_device_ops { int vf, bool setting);int (*ndo_setup_tc)(struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc); +void *type_data);#if IS_ENABLED (CONFIG_FCOE )int (*ndo_fcoe_enable)(struct net_device *dev);int (*ndo_fcoe_disable)(struct net_device *dev);
net/dsa/slave.c +2 -2
@@ -883,11 +883,11 @@ static int dsa_slave_setup_tc_cls_matchall(struct net_device *dev, }static int dsa_slave_setup_tc (struct net_device *dev,enum tc_setup_type type, -struct tc_to_netdev *tc) +void *type_data) {switch (type) {case TC_SETUP_CLSMATCHALL : -return dsa_slave_setup_tc_cls_matchall (dev, tc->cls_mall); +return dsa_slave_setup_tc_cls_matchall (dev, type_data);default :return -EOPNOTSUPP ; }
net/sched/cls_bpf.c +9 -12
@@ -147,21 +147,18 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog, enum tc_clsbpf_command cmd) {struct net_device *dev = tp->q->dev_queue->dev; -struct tc_cls_bpf_offload bpf_offload = {}; -struct tc_to_netdev offload; +struct tc_cls_bpf_offload cls_bpf = {};int err; - offload.cls_bpf = &bpf_offload; +tc_cls_common_offload_init (&cls_bpf.common, tp); + cls_bpf.command = cmd; + cls_bpf.exts = &prog->exts; + cls_bpf.prog = prog->filter; + cls_bpf.name = prog->bpf_name; + cls_bpf.exts_integrated = prog->exts_integrated; + cls_bpf.gen_flags = prog->gen_flags; -tc_cls_common_offload_init (&bpf_offload.common, tp); - bpf_offload.command = cmd; - bpf_offload.exts = &prog->exts; - bpf_offload.prog = prog->filter; - bpf_offload.name = prog->bpf_name; - bpf_offload.exts_integrated = prog->exts_integrated; - bpf_offload.gen_flags = prog->gen_flags; - - err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSBPF , &offload); + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSBPF , &cls_bpf);if (!err && (cmd ==TC_CLSBPF_ADD || cmd ==TC_CLSBPF_REPLACE )) prog->gen_flags |=TCA_CLS_FLAGS_IN_HW ;
net/sched/cls_flower.c +23 -31
101 lines not on this page · raw message
net/sched/cls_matchall.c +11 -16
@@ -54,18 +54,16 @@ static int mall_replace_hw_filter(struct tcf_proto *tp, unsigned long cookie) {struct net_device *dev = tp->q->dev_queue->dev; -struct tc_to_netdev offload; -struct tc_cls_matchall_offload mall_offload = {0 }; +struct tc_cls_matchall_offload cls_mall = {};int err; -tc_cls_common_offload_init (&mall_offload.common, tp); - offload.cls_mall = &mall_offload; - offload.cls_mall->command =TC_CLSMATCHALL_REPLACE ; - offload.cls_mall->exts = &head->exts; - offload.cls_mall->cookie = cookie; +tc_cls_common_offload_init (&cls_mall.common, tp); + cls_mall.command =TC_CLSMATCHALL_REPLACE ; + cls_mall.exts = &head->exts; + cls_mall.cookie = cookie; err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSMATCHALL , - &offload); + &cls_mall);if (!err) head->flags |=TCA_CLS_FLAGS_IN_HW ;
@@ -77,16 +75,13 @@ static void mall_destroy_hw_filter(struct tcf_proto *tp, unsigned long cookie) {struct net_device *dev = tp->q->dev_queue->dev; -struct tc_to_netdev offload; -struct tc_cls_matchall_offload mall_offload = {0 }; +struct tc_cls_matchall_offload cls_mall = {}; -tc_cls_common_offload_init (&mall_offload.common, tp); - offload.cls_mall = &mall_offload; - offload.cls_mall->command =TC_CLSMATCHALL_DESTROY ; - offload.cls_mall->exts =NULL ; - offload.cls_mall->cookie = cookie; +tc_cls_common_offload_init (&cls_mall.common, tp); + cls_mall.command =TC_CLSMATCHALL_DESTROY ; + cls_mall.cookie = cookie; - dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSMATCHALL , &offload); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_CLSMATCHALL , &cls_mall); }static void mall_destroy (struct tcf_proto *tp)
net/sched/cls_u32.c +37 -46
128 lines not on this page · raw message
net/sched/sch_mqprio.c +6 -7
@@ -39,10 +39,9 @@ static void mqprio_destroy(struct Qdisc *sch) }if (priv->hw_offload && dev->netdev_ops->ndo_setup_tc) { -struct tc_mqprio_qopt offload = {0 }; -struct tc_to_netdev tc = { { .mqprio = &offload } }; +struct tc_mqprio_qopt mqprio = {}; - dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , &tc); + dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , &mqprio); }else {netdev_set_num_tc (dev,0 ); }
@@ -147,14 +146,14 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)* supplied and verified mapping */ if (qopt->hw) { -struct tc_mqprio_qopt offload = *qopt; -struct tc_to_netdev tc = { { .mqprio = &offload } }; +struct tc_mqprio_qopt mqprio = *qopt; - err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , &tc); + err = dev->netdev_ops->ndo_setup_tc (dev,TC_SETUP_MQPRIO , + &mqprio);if (err)return err; - priv->hw_offload = offload.hw; + priv->hw_offload = mqprio.hw; }else {netdev_set_num_tc (dev, qopt->num_tc);for (i =0 ; i < qopt->num_tc; i++)
Signature · 1 line
2.9.3
David Miller
maintainerFrom: Jiri Pirko <[email protected]>
Date: Mon, 7 Aug 2017 10:15:16 +0200
Quoted 12 lines
From: Jiri Pirko <[email protected]>
This patchset focuses on
ndo_setup_tcand its args. Currently there are couple of things that do not make much sense. The type is passed in structtc_to_netdev, but as it is always required, should be arg of the ndo. Other things are passed as args but they are only relevant for cls offloads and not mqprio. Therefore, they should be pushed to struct. As thetc_to_netdevstruct in the end is just a container of single pointer, we get rid of it and pass the struct according to type. So in the end, we have:ndo_setup_tc(dev, type, type_data_struct)
Quoted 6 lines
There are couple of cosmetics done on the way to make things smooth. Also, reported error is consolidated to eopnotsupp in case the asked offload is not supported.
v1->v2:
- added forgotten hns3pf bits
Series applied, thanks.