Skip to content

Commit

Permalink
net: sched: get rid of struct tc_to_netdev
Browse files Browse the repository at this point in the history
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_*.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Aug 7, 2017
1 parent 38cf042 commit de4784c
Show file tree
Hide file tree
Showing 33 changed files with 174 additions and 202 deletions.
7 changes: 4 additions & 3 deletions drivers/net/ethernet/amd/xgbe/xgbe-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions drivers/net/ethernet/intel/i40e/i40e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 6 additions & 4 deletions drivers/net/ethernet/mellanox/mlx4/en_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 0x0000ffff

int mlx5e_tc_init(struct mlx5e_priv *priv);
Expand Down
8 changes: 3 additions & 5 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/netronome/nfp/bpf/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/netronome/nfp/flower/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/netronome/nfp/flower/offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
8 changes: 3 additions & 5 deletions drivers/net/ethernet/netronome/nfp/nfp_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/netronome/nfp/nfp_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ 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;

port = nfp_port_from_netdev(netdev);
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 *
Expand Down
Loading

0 comments on commit de4784c

Please sign in to comment.