net: sched: move the can_offload check from binding phase to rule insertion phase

This restores the original behaviour before the block callbacks were
introduced. Allow the drivers to do binding of block always, no matter
if the NETIF_F_HW_TC feature is on or off. Move the check to the block
callback which is called for rule insertion.

Reported-by: Alexander Duyck <alexander.duyck@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko 2017-11-01 11:47:39 +01:00 committed by David S. Miller
parent 0b5a89caee
commit 44ae12a768
11 changed files with 27 additions and 3 deletions

View File

@ -7347,7 +7347,7 @@ static int bnxt_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
{ {
struct bnxt *bp = cb_priv; struct bnxt *bp = cb_priv;
if (!bnxt_tc_flower_enabled(bp)) if (!bnxt_tc_flower_enabled(bp) || !tc_can_offload(bp->dev))
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch (type) { switch (type) {

View File

@ -124,7 +124,7 @@ static int bnxt_vf_rep_setup_tc_block_cb(enum tc_setup_type type,
struct bnxt *bp = vf_rep->bp; struct bnxt *bp = vf_rep->bp;
int vf_fid = bp->pf.vf[vf_rep->vf_idx].fw_fid; int vf_fid = bp->pf.vf[vf_rep->vf_idx].fw_fid;
if (!bnxt_tc_flower_enabled(vf_rep->bp)) if (!bnxt_tc_flower_enabled(vf_rep->bp) || !tc_can_offload(bp->dev))
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch (type) { switch (type) {

View File

@ -2943,6 +2943,9 @@ static int cxgb_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
return -EINVAL; return -EINVAL;
} }
if (!tc_can_offload(dev))
return -EOPNOTSUPP;
switch (type) { switch (type) {
case TC_SETUP_CLSU32: case TC_SETUP_CLSU32:
return cxgb_setup_tc_cls_u32(dev, type_data); return cxgb_setup_tc_cls_u32(dev, type_data);

View File

@ -9386,6 +9386,9 @@ static int ixgbe_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
{ {
struct ixgbe_adapter *adapter = cb_priv; struct ixgbe_adapter *adapter = cb_priv;
if (!tc_can_offload(adapter->netdev))
return -EOPNOTSUPP;
switch (type) { switch (type) {
case TC_SETUP_CLSU32: case TC_SETUP_CLSU32:
return ixgbe_setup_tc_cls_u32(adapter, type_data); return ixgbe_setup_tc_cls_u32(adapter, type_data);

View File

@ -3106,6 +3106,9 @@ int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
{ {
struct mlx5e_priv *priv = cb_priv; struct mlx5e_priv *priv = cb_priv;
if (!tc_can_offload(priv->netdev))
return -EOPNOTSUPP;
switch (type) { switch (type) {
case TC_SETUP_CLSFLOWER: case TC_SETUP_CLSFLOWER:
return mlx5e_setup_tc_cls_flower(priv, type_data); return mlx5e_setup_tc_cls_flower(priv, type_data);

View File

@ -682,6 +682,9 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
{ {
struct mlx5e_priv *priv = cb_priv; struct mlx5e_priv *priv = cb_priv;
if (!tc_can_offload(priv->netdev))
return -EOPNOTSUPP;
switch (type) { switch (type) {
case TC_SETUP_CLSFLOWER: case TC_SETUP_CLSFLOWER:
return mlx5e_rep_setup_tc_cls_flower(priv, type_data); return mlx5e_rep_setup_tc_cls_flower(priv, type_data);

View File

@ -1738,6 +1738,9 @@ static int mlxsw_sp_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
{ {
struct mlxsw_sp_port *mlxsw_sp_port = cb_priv; struct mlxsw_sp_port *mlxsw_sp_port = cb_priv;
if (!tc_can_offload(mlxsw_sp_port->dev))
return -EOPNOTSUPP;
switch (type) { switch (type) {
case TC_SETUP_CLSMATCHALL: case TC_SETUP_CLSMATCHALL:
return mlxsw_sp_setup_tc_cls_matchall(mlxsw_sp_port, type_data, return mlxsw_sp_setup_tc_cls_matchall(mlxsw_sp_port, type_data,

View File

@ -121,6 +121,9 @@ static int nfp_bpf_setup_tc_block_cb(enum tc_setup_type type,
struct tc_cls_bpf_offload *cls_bpf = type_data; struct tc_cls_bpf_offload *cls_bpf = type_data;
struct nfp_net *nn = cb_priv; struct nfp_net *nn = cb_priv;
if (!tc_can_offload(nn->dp.netdev))
return -EOPNOTSUPP;
switch (type) { switch (type) {
case TC_SETUP_CLSBPF: case TC_SETUP_CLSBPF:
if (!nfp_net_ebpf_capable(nn) || if (!nfp_net_ebpf_capable(nn) ||

View File

@ -470,6 +470,9 @@ static int nfp_flower_setup_tc_block_cb(enum tc_setup_type type,
{ {
struct nfp_net *nn = cb_priv; struct nfp_net *nn = cb_priv;
if (!tc_can_offload(nn->dp.netdev))
return -EOPNOTSUPP;
switch (type) { switch (type) {
case TC_SETUP_CLSFLOWER: case TC_SETUP_CLSFLOWER:
return nfp_flower_repr_offload(nn->app, nn->port->netdev, return nfp_flower_repr_offload(nn->app, nn->port->netdev,

View File

@ -799,6 +799,9 @@ static int dsa_slave_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
{ {
struct net_device *dev = cb_priv; struct net_device *dev = cb_priv;
if (!tc_can_offload(dev))
return -EOPNOTSUPP;
switch (type) { switch (type) {
case TC_SETUP_CLSMATCHALL: case TC_SETUP_CLSMATCHALL:
return dsa_slave_setup_tc_cls_matchall(dev, type_data, ingress); return dsa_slave_setup_tc_cls_matchall(dev, type_data, ingress);

View File

@ -256,7 +256,7 @@ static void tcf_block_offload_cmd(struct tcf_block *block, struct Qdisc *q,
struct net_device *dev = q->dev_queue->dev; struct net_device *dev = q->dev_queue->dev;
struct tc_block_offload bo = {}; struct tc_block_offload bo = {};
if (!tc_can_offload(dev)) if (!dev->netdev_ops->ndo_setup_tc)
return; return;
bo.command = command; bo.command = command;
bo.binder_type = ei->binder_type; bo.binder_type = ei->binder_type;