Skip to content

Commit

Permalink
net: sched: push cls related args into cls_common structure
Browse files Browse the repository at this point in the history
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.

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 74897ef commit 5fd9fc4
Show file tree
Hide file tree
Showing 39 changed files with 101 additions and 144 deletions.
1 change: 0 additions & 1 deletion drivers/net/ethernet/amd/xgbe/xgbe-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 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,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,
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 5 additions & 9 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down
7 changes: 3 additions & 4 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/intel/i40e/i40e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 6 additions & 11 deletions drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/mellanox/mlx4/en_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
15 changes: 5 additions & 10 deletions drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,29 +652,26 @@ 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) {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;

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:
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 9 additions & 16 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 5fd9fc4

Please sign in to comment.