net/sfc: refine order of checks on MAE action set attach
authorIvan Malov <ivan.malov@oktetlabs.ru>
Wed, 17 Nov 2021 11:44:35 +0000 (14:44 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 17 Nov 2021 13:10:08 +0000 (14:10 +0100)
The number of counters being non-zero can be detected before
the action set registry traversal, so move the check outside.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
drivers/net/sfc/sfc_mae.c

index 08e28b1..73bedf5 100644 (file)
@@ -763,13 +763,15 @@ sfc_mae_action_set_attach(struct sfc_adapter *sa,
 
        SFC_ASSERT(sfc_adapter_is_locked(sa));
 
+       /*
+        * Shared counters are not supported, hence, action
+        * sets with counters are not attachable.
+        */
+       if (n_count != 0)
+               return NULL;
+
        TAILQ_FOREACH(action_set, &mae->action_sets, entries) {
-               /*
-                * Shared counters are not supported, hence action sets with
-                * COUNT are not attachable.
-                */
                if (action_set->encap_header == encap_header &&
-                   n_count == 0 &&
                    efx_mae_action_set_specs_equal(action_set->spec, spec)) {
                        sfc_dbg(sa, "attaching to action_set=%p", action_set);
                        ++(action_set->refcnt);