net: sched: pass extack pointer to block binds and cb registration
authorJohn Hurley <john.hurley@netronome.com>
Mon, 25 Jun 2018 21:30:04 +0000 (14:30 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Jun 2018 14:21:32 +0000 (23:21 +0900)
Pass the extact struct from a tc qdisc add to the block bind function and,
in turn, to the setup_tc ndo of binding device via the tc_block_offload
struct. Pass this back to any block callback registrations to allow
netlink logging of fails in the bind process.

Signed-off-by: John Hurley <john.hurley@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 files changed:
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/i40evf/i40evf_main.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/netronome/nfp/bpf/main.c
drivers/net/ethernet/netronome/nfp/flower/offload.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/netdevsim/netdev.c
include/net/pkt_cls.h
net/dsa/slave.c
net/sched/cls_api.c

index 176fc9f..b5fc641 100644 (file)
@@ -7984,7 +7984,7 @@ static int bnxt_setup_tc_block(struct net_device *dev,
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, bnxt_setup_tc_block_cb,
-                                            bp, bp);
+                                            bp, bp, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, bnxt_setup_tc_block_cb, bp);
                return 0;
index 05d4059..0745f2d 100644 (file)
@@ -173,7 +173,7 @@ static int bnxt_vf_rep_setup_tc_block(struct net_device *dev,
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block,
                                             bnxt_vf_rep_setup_tc_block_cb,
-                                            vf_rep, vf_rep);
+                                            vf_rep, vf_rep, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block,
                                        bnxt_vf_rep_setup_tc_block_cb, vf_rep);
index bc03c17..96bc177 100644 (file)
@@ -3016,7 +3016,7 @@ static int cxgb_setup_tc_block(struct net_device *dev,
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, cxgb_setup_tc_block_cb,
-                                            pi, dev);
+                                            pi, dev, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, cxgb_setup_tc_block_cb, pi);
                return 0;
index 7ad2b1b..426b0cc 100644 (file)
@@ -7554,7 +7554,7 @@ static int i40e_setup_tc_block(struct net_device *dev,
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, i40e_setup_tc_block_cb,
-                                            np, np);
+                                            np, np, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, i40e_setup_tc_block_cb, np);
                return 0;
index dc56a86..5906c1c 100644 (file)
@@ -2926,7 +2926,7 @@ static int i40evf_setup_tc_block(struct net_device *dev,
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, i40evf_setup_tc_block_cb,
-                                            adapter, adapter);
+                                            adapter, adapter, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, i40evf_setup_tc_block_cb,
                                        adapter);
index 6a78d82..f1e3397 100644 (file)
@@ -2728,7 +2728,7 @@ static int igb_setup_tc_block(struct igb_adapter *adapter,
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, igb_setup_tc_block_cb,
-                                            adapter, adapter);
+                                            adapter, adapter, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, igb_setup_tc_block_cb,
                                        adapter);
index 3e87dbb..d29bd8f 100644 (file)
@@ -9325,7 +9325,7 @@ static int ixgbe_setup_tc_block(struct net_device *dev,
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, ixgbe_setup_tc_block_cb,
-                                            adapter, adapter);
+                                            adapter, adapter, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, ixgbe_setup_tc_block_cb,
                                        adapter);
index 56c1b6f..134f20a 100644 (file)
@@ -3371,7 +3371,7 @@ static int mlx5e_setup_tc_block(struct net_device *dev,
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, mlx5e_setup_tc_block_cb,
-                                            priv, priv);
+                                            priv, priv, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, mlx5e_setup_tc_block_cb,
                                        priv);
index 57987f6..3f2fe95 100644 (file)
@@ -797,7 +797,7 @@ static int mlx5e_rep_setup_tc_block(struct net_device *dev,
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, mlx5e_rep_setup_tc_cb,
-                                            priv, priv);
+                                            priv, priv, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, mlx5e_rep_setup_tc_cb, priv);
                return 0;
index 968b88a..d2bc335 100644 (file)
@@ -1503,7 +1503,8 @@ static int mlxsw_sp_setup_tc_block_cb_flower(enum tc_setup_type type,
 
 static int
 mlxsw_sp_setup_tc_block_flower_bind(struct mlxsw_sp_port *mlxsw_sp_port,
-                                   struct tcf_block *block, bool ingress)
+                                   struct tcf_block *block, bool ingress,
+                                   struct netlink_ext_ack *extack)
 {
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
        struct mlxsw_sp_acl_block *acl_block;
@@ -1518,7 +1519,7 @@ mlxsw_sp_setup_tc_block_flower_bind(struct mlxsw_sp_port *mlxsw_sp_port,
                        return -ENOMEM;
                block_cb = __tcf_block_cb_register(block,
                                                   mlxsw_sp_setup_tc_block_cb_flower,
-                                                  mlxsw_sp, acl_block);
+                                                  mlxsw_sp, acl_block, extack);
                if (IS_ERR(block_cb)) {
                        err = PTR_ERR(block_cb);
                        goto err_cb_register;
@@ -1596,11 +1597,12 @@ static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,
        switch (f->command) {
        case TC_BLOCK_BIND:
                err = tcf_block_cb_register(f->block, cb, mlxsw_sp_port,
-                                           mlxsw_sp_port);
+                                           mlxsw_sp_port, f->extack);
                if (err)
                        return err;
                err = mlxsw_sp_setup_tc_block_flower_bind(mlxsw_sp_port,
-                                                         f->block, ingress);
+                                                         f->block, ingress,
+                                                         f->extack);
                if (err) {
                        tcf_block_cb_unregister(f->block, cb, mlxsw_sp_port);
                        return err;
index fcdfb8e..bf46f7b 100644 (file)
@@ -206,7 +206,7 @@ static int nfp_bpf_setup_tc_block(struct net_device *netdev,
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block,
                                             nfp_bpf_setup_tc_block_cb,
-                                            nn, nn);
+                                            nn, nn, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block,
                                        nfp_bpf_setup_tc_block_cb,
index c0e74aa..a427dab 100644 (file)
@@ -627,7 +627,7 @@ static int nfp_flower_setup_tc_block(struct net_device *netdev,
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block,
                                             nfp_flower_setup_tc_block_cb,
-                                            repr, repr);
+                                            repr, repr, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block,
                                        nfp_flower_setup_tc_block_cb,
index cba46b6..2354e30 100644 (file)
@@ -3776,7 +3776,7 @@ static int stmmac_setup_tc_block(struct stmmac_priv *priv,
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, stmmac_setup_tc_block_cb,
-                               priv, priv);
+                               priv, priv, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, stmmac_setup_tc_block_cb, priv);
                return 0;
index ec68f38..c9dacc6 100644 (file)
@@ -260,7 +260,7 @@ nsim_setup_tc_block(struct net_device *dev, struct tc_block_offload *f)
        switch (f->command) {
        case TC_BLOCK_BIND:
                return tcf_block_cb_register(f->block, nsim_setup_tc_block_cb,
-                                            ns, ns);
+                                            ns, ns, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, nsim_setup_tc_block_cb, ns);
                return 0;
index a3c1a2c..a2c6d35 100644 (file)
@@ -73,10 +73,11 @@ void tcf_block_cb_incref(struct tcf_block_cb *block_cb);
 unsigned int tcf_block_cb_decref(struct tcf_block_cb *block_cb);
 struct tcf_block_cb *__tcf_block_cb_register(struct tcf_block *block,
                                             tc_setup_cb_t *cb, void *cb_ident,
-                                            void *cb_priv);
+                                            void *cb_priv,
+                                            struct netlink_ext_ack *extack);
 int tcf_block_cb_register(struct tcf_block *block,
                          tc_setup_cb_t *cb, void *cb_ident,
-                         void *cb_priv);
+                         void *cb_priv, struct netlink_ext_ack *extack);
 void __tcf_block_cb_unregister(struct tcf_block_cb *block_cb);
 void tcf_block_cb_unregister(struct tcf_block *block,
                             tc_setup_cb_t *cb, void *cb_ident);
@@ -161,7 +162,8 @@ unsigned int tcf_block_cb_decref(struct tcf_block_cb *block_cb)
 static inline
 struct tcf_block_cb *__tcf_block_cb_register(struct tcf_block *block,
                                             tc_setup_cb_t *cb, void *cb_ident,
-                                            void *cb_priv)
+                                            void *cb_priv,
+                                            struct netlink_ext_ack *extack)
 {
        return NULL;
 }
@@ -169,7 +171,7 @@ struct tcf_block_cb *__tcf_block_cb_register(struct tcf_block *block,
 static inline
 int tcf_block_cb_register(struct tcf_block *block,
                          tc_setup_cb_t *cb, void *cb_ident,
-                         void *cb_priv)
+                         void *cb_priv, struct netlink_ext_ack *extack)
 {
        return 0;
 }
@@ -596,6 +598,7 @@ struct tc_block_offload {
        enum tc_block_command command;
        enum tcf_block_binder_type binder_type;
        struct tcf_block *block;
+       struct netlink_ext_ack *extack;
 };
 
 struct tc_cls_common_offload {
index 1e3b6a6..71536c4 100644 (file)
@@ -900,7 +900,7 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,
 
        switch (f->command) {
        case TC_BLOCK_BIND:
-               return tcf_block_cb_register(f->block, cb, dev, dev);
+               return tcf_block_cb_register(f->block, cb, dev, dev, f->extack);
        case TC_BLOCK_UNBIND:
                tcf_block_cb_unregister(f->block, cb, dev);
                return 0;
index cdc3c87..8c9fb4b 100644 (file)
@@ -277,18 +277,21 @@ static bool tcf_block_offload_in_use(struct tcf_block *block)
 static int tcf_block_offload_cmd(struct tcf_block *block,
                                 struct net_device *dev,
                                 struct tcf_block_ext_info *ei,
-                                enum tc_block_command command)
+                                enum tc_block_command command,
+                                struct netlink_ext_ack *extack)
 {
        struct tc_block_offload bo = {};
 
        bo.command = command;
        bo.binder_type = ei->binder_type;
        bo.block = block;
+       bo.extack = extack;
        return dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_BLOCK, &bo);
 }
 
 static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,
-                                 struct tcf_block_ext_info *ei)
+                                 struct tcf_block_ext_info *ei,
+                                 struct netlink_ext_ack *extack)
 {
        struct net_device *dev = q->dev_queue->dev;
        int err;
@@ -299,10 +302,12 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,
        /* If tc offload feature is disabled and the block we try to bind
         * to already has some offloaded filters, forbid to bind.
         */
-       if (!tc_can_offload(dev) && tcf_block_offload_in_use(block))
+       if (!tc_can_offload(dev) && tcf_block_offload_in_use(block)) {
+               NL_SET_ERR_MSG(extack, "Bind to offloaded block failed as dev has offload disabled");
                return -EOPNOTSUPP;
+       }
 
-       err = tcf_block_offload_cmd(block, dev, ei, TC_BLOCK_BIND);
+       err = tcf_block_offload_cmd(block, dev, ei, TC_BLOCK_BIND, extack);
        if (err == -EOPNOTSUPP)
                goto no_offload_dev_inc;
        return err;
@@ -322,7 +327,7 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
 
        if (!dev->netdev_ops->ndo_setup_tc)
                goto no_offload_dev_dec;
-       err = tcf_block_offload_cmd(block, dev, ei, TC_BLOCK_UNBIND);
+       err = tcf_block_offload_cmd(block, dev, ei, TC_BLOCK_UNBIND, NULL);
        if (err == -EOPNOTSUPP)
                goto no_offload_dev_dec;
        return;
@@ -612,7 +617,7 @@ int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
        if (err)
                goto err_chain_head_change_cb_add;
 
-       err = tcf_block_offload_bind(block, q, ei);
+       err = tcf_block_offload_bind(block, q, ei, extack);
        if (err)
                goto err_block_offload_bind;
 
@@ -748,7 +753,8 @@ EXPORT_SYMBOL(tcf_block_cb_decref);
 
 struct tcf_block_cb *__tcf_block_cb_register(struct tcf_block *block,
                                             tc_setup_cb_t *cb, void *cb_ident,
-                                            void *cb_priv)
+                                            void *cb_priv,
+                                            struct netlink_ext_ack *extack)
 {
        struct tcf_block_cb *block_cb;
 
@@ -772,11 +778,12 @@ EXPORT_SYMBOL(__tcf_block_cb_register);
 
 int tcf_block_cb_register(struct tcf_block *block,
                          tc_setup_cb_t *cb, void *cb_ident,
-                         void *cb_priv)
+                         void *cb_priv, struct netlink_ext_ack *extack)
 {
        struct tcf_block_cb *block_cb;
 
-       block_cb = __tcf_block_cb_register(block, cb, cb_ident, cb_priv);
+       block_cb = __tcf_block_cb_register(block, cb, cb_ident, cb_priv,
+                                          extack);
        return IS_ERR(block_cb) ? PTR_ERR(block_cb) : 0;
 }
 EXPORT_SYMBOL(tcf_block_cb_register);