common/sfc_efx/base: support adding VLAN push action
authorIvan Malov <ivan.malov@oktetlabs.ru>
Tue, 20 Oct 2020 09:13:07 +0000 (10:13 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:24:25 +0000 (23:24 +0100)
MAE supports pushing two tags, so this action can
be requested once or twice.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
drivers/common/sfc_efx/base/efx.h
drivers/common/sfc_efx/base/efx_impl.h
drivers/common/sfc_efx/base/efx_mae.c
drivers/common/sfc_efx/version.map

index 17bfc6f..193ffff 100644 (file)
@@ -4171,6 +4171,13 @@ extern   __checkReturn                   efx_rc_t
 efx_mae_action_set_populate_vlan_pop(
        __in                            efx_mae_actions_t *spec);
 
+LIBEFX_API
+extern __checkReturn                   efx_rc_t
+efx_mae_action_set_populate_vlan_push(
+       __in                            efx_mae_actions_t *spec,
+       __in                            uint16_t tpid_be,
+       __in                            uint16_t tci_be);
+
 LIBEFX_API
 extern __checkReturn                   efx_rc_t
 efx_mae_action_set_populate_deliver(
index 63ede90..84276dc 100644 (file)
@@ -1702,6 +1702,7 @@ struct efx_mae_match_spec_s {
 typedef enum efx_mae_action_e {
        /* These actions are strictly ordered. */
        EFX_MAE_ACTION_VLAN_POP,
+       EFX_MAE_ACTION_VLAN_PUSH,
 
        /* DELIVER is always the last action. */
        EFX_MAE_ACTION_DELIVER,
@@ -1712,11 +1713,22 @@ typedef enum efx_mae_action_e {
 /* MAE VLAN_POP action can handle 1 or 2 tags. */
 #define        EFX_MAE_VLAN_POP_MAX_NTAGS      (2)
 
+/* MAE VLAN_PUSH action can handle 1 or 2 tags. */
+#define        EFX_MAE_VLAN_PUSH_MAX_NTAGS     (2)
+
+typedef struct efx_mae_action_vlan_push_s {
+       uint16_t                        emavp_tpid_be;
+       uint16_t                        emavp_tci_be;
+} efx_mae_action_vlan_push_t;
+
 struct efx_mae_actions_s {
        /* Bitmap of actions in spec, indexed by action type */
        uint32_t                        ema_actions;
 
        unsigned int                    ema_n_vlan_tags_to_pop;
+       unsigned int                    ema_n_vlan_tags_to_push;
+       efx_mae_action_vlan_push_t      ema_vlan_push_descs[
+           EFX_MAE_VLAN_PUSH_MAX_NTAGS];
        efx_mport_sel_t                 ema_deliver_mport;
 };
 
index 644ad31..f3d7bf7 100644 (file)
@@ -677,6 +677,44 @@ fail1:
        return (rc);
 }
 
+static __checkReturn                   efx_rc_t
+efx_mae_action_set_add_vlan_push(
+       __in                            efx_mae_actions_t *spec,
+       __in                            size_t arg_size,
+       __in_bcount(arg_size)           const uint8_t *arg)
+{
+       unsigned int n_tags = spec->ema_n_vlan_tags_to_push;
+       efx_rc_t rc;
+
+       if (arg_size != sizeof (*spec->ema_vlan_push_descs)) {
+               rc = EINVAL;
+               goto fail1;
+       }
+
+       if (arg == NULL) {
+               rc = EINVAL;
+               goto fail2;
+       }
+
+       if (n_tags == EFX_MAE_VLAN_PUSH_MAX_NTAGS) {
+               rc = ENOTSUP;
+               goto fail3;
+       }
+
+       memcpy(&spec->ema_vlan_push_descs[n_tags], arg, arg_size);
+       ++(spec->ema_n_vlan_tags_to_push);
+
+       return (0);
+
+fail3:
+       EFSYS_PROBE(fail3);
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
 static __checkReturn                   efx_rc_t
 efx_mae_action_set_add_deliver(
        __in                            efx_mae_actions_t *spec,
@@ -716,6 +754,9 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = {
        [EFX_MAE_ACTION_VLAN_POP] = {
                .emad_add = efx_mae_action_set_add_vlan_pop
        },
+       [EFX_MAE_ACTION_VLAN_PUSH] = {
+               .emad_add = efx_mae_action_set_add_vlan_push
+       },
        [EFX_MAE_ACTION_DELIVER] = {
                .emad_add = efx_mae_action_set_add_deliver
        }
@@ -723,10 +764,12 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = {
 
 static const uint32_t efx_mae_action_ordered_map =
        (1U << EFX_MAE_ACTION_VLAN_POP) |
+       (1U << EFX_MAE_ACTION_VLAN_PUSH) |
        (1U << EFX_MAE_ACTION_DELIVER);
 
 static const uint32_t efx_mae_action_repeat_map =
-       (1U << EFX_MAE_ACTION_VLAN_POP);
+       (1U << EFX_MAE_ACTION_VLAN_POP) |
+       (1U << EFX_MAE_ACTION_VLAN_PUSH);
 
 /*
  * Add an action to an action set.
@@ -808,6 +851,22 @@ efx_mae_action_set_populate_vlan_pop(
            EFX_MAE_ACTION_VLAN_POP, 0, NULL));
 }
 
+       __checkReturn                   efx_rc_t
+efx_mae_action_set_populate_vlan_push(
+       __in                            efx_mae_actions_t *spec,
+       __in                            uint16_t tpid_be,
+       __in                            uint16_t tci_be)
+{
+       efx_mae_action_vlan_push_t action;
+       const uint8_t *arg = (const uint8_t *)&action;
+
+       action.emavp_tpid_be = tpid_be;
+       action.emavp_tci_be = tci_be;
+
+       return (efx_mae_action_set_spec_populate(spec,
+           EFX_MAE_ACTION_VLAN_PUSH, sizeof (action), arg));
+}
+
        __checkReturn                   efx_rc_t
 efx_mae_action_set_populate_deliver(
        __in                            efx_mae_actions_t *spec,
@@ -975,6 +1034,31 @@ efx_mae_action_set_alloc(
        MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
            MAE_ACTION_SET_ALLOC_IN_VLAN_POP, spec->ema_n_vlan_tags_to_pop);
 
+       if (spec->ema_n_vlan_tags_to_push > 0) {
+               unsigned int outer_tag_idx;
+
+               MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
+                   MAE_ACTION_SET_ALLOC_IN_VLAN_PUSH,
+                   spec->ema_n_vlan_tags_to_push);
+
+               if (spec->ema_n_vlan_tags_to_push ==
+                   EFX_MAE_VLAN_PUSH_MAX_NTAGS) {
+                       MCDI_IN_SET_WORD(req,
+                           MAE_ACTION_SET_ALLOC_IN_VLAN1_PROTO_BE,
+                           spec->ema_vlan_push_descs[0].emavp_tpid_be);
+                       MCDI_IN_SET_WORD(req,
+                           MAE_ACTION_SET_ALLOC_IN_VLAN1_TCI_BE,
+                           spec->ema_vlan_push_descs[0].emavp_tci_be);
+               }
+
+               outer_tag_idx = spec->ema_n_vlan_tags_to_push - 1;
+
+               MCDI_IN_SET_WORD(req, MAE_ACTION_SET_ALLOC_IN_VLAN0_PROTO_BE,
+                   spec->ema_vlan_push_descs[outer_tag_idx].emavp_tpid_be);
+               MCDI_IN_SET_WORD(req, MAE_ACTION_SET_ALLOC_IN_VLAN0_TCI_BE,
+                   spec->ema_vlan_push_descs[outer_tag_idx].emavp_tci_be);
+       }
+
        MCDI_IN_SET_DWORD(req,
            MAE_ACTION_SET_ALLOC_IN_DELIVER, spec->ema_deliver_mport.sel);
 
index 41c14c6..be11b6a 100644 (file)
@@ -91,6 +91,7 @@ INTERNAL {
        efx_mae_action_set_free;
        efx_mae_action_set_populate_deliver;
        efx_mae_action_set_populate_vlan_pop;
+       efx_mae_action_set_populate_vlan_push;
        efx_mae_action_set_spec_fini;
        efx_mae_action_set_spec_init;
        efx_mae_action_set_specs_equal;