From: Ivan Malov <ivan.malov@oktetlabs.ru>
To: dev@dpdk.org
Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
Andy Moreton <amoreton@xilinx.com>, Ray Kinsella <mdr@ashroe.eu>
Subject: [dpdk-dev] [PATCH 4/5] common/sfc_efx/base: support adding dec. TTL action to a set
Date: Sat, 6 Nov 2021 00:54:08 +0300 [thread overview]
Message-ID: <20211105215409.5706-5-ivan.malov@oktetlabs.ru> (raw)
In-Reply-To: <20211105215409.5706-1-ivan.malov@oktetlabs.ru>
Affects the outermost header, taking prior action DECAP into
account. Takes care to also update IPv4 checksum accordingly.
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/common/sfc_efx/base/ef10_nic.c | 9 +++++++
drivers/common/sfc_efx/base/efx.h | 14 +++++++++++
drivers/common/sfc_efx/base/efx_impl.h | 8 ++++++
drivers/common/sfc_efx/base/efx_mae.c | 35 ++++++++++++++++++++++++++
drivers/common/sfc_efx/version.map | 1 +
5 files changed, 67 insertions(+)
diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index bbc59811ec..72d2caadb8 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1452,6 +1452,15 @@ ef10_get_datapath_caps(
encp->enc_mae_supported = B_FALSE;
encp->enc_mae_admin = B_FALSE;
}
+
+ /*
+ * Check support for MAE action set v2 features.
+ * These provide support for packet edits.
+ */
+ if (CAP_FLAGS3(req, MAE_ACTION_SET_ALLOC_V2_SUPPORTED))
+ encp->enc_mae_aset_v2_supported = B_TRUE;
+ else
+ encp->enc_mae_aset_v2_supported = B_FALSE;
#else
encp->enc_mae_supported = B_FALSE;
encp->enc_mae_admin = B_FALSE;
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 60533881c2..f08a004536 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1625,6 +1625,8 @@ typedef struct efx_nic_cfg_s {
* destination (a MAE client or network port).
*/
boolean_t enc_mae_admin;
+ /* NIC support for MAE action set v2 features. */
+ boolean_t enc_mae_aset_v2_supported;
/* Firmware support for "FLAG" and "MARK" filter actions */
boolean_t enc_filter_action_flag_supported;
boolean_t enc_filter_action_mark_supported;
@@ -4435,6 +4437,18 @@ extern __checkReturn efx_rc_t
efx_mae_action_set_populate_vlan_pop(
__in efx_mae_actions_t *spec);
+/*
+ * This always amends the outermost header. This way, for a tunnel
+ * packet, if action DECAP is not requested, this will affect the
+ * outer header; otherwise, the inner header will be updated.
+ *
+ * This will also take care to update IPv4 checksum accordingly.
+ */
+LIBEFX_API
+extern __checkReturn efx_rc_t
+efx_mae_action_set_populate_decr_ip_ttl(
+ __in efx_mae_actions_t *spec);
+
LIBEFX_API
extern __checkReturn efx_rc_t
efx_mae_action_set_populate_vlan_push(
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 5dcdb9c78d..eda41b4be0 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -1740,6 +1740,7 @@ typedef enum efx_mae_action_e {
/* These actions are strictly ordered. */
EFX_MAE_ACTION_DECAP,
EFX_MAE_ACTION_VLAN_POP,
+ EFX_MAE_ACTION_DECR_IP_TTL,
EFX_MAE_ACTION_VLAN_PUSH,
EFX_MAE_ACTION_COUNT,
EFX_MAE_ACTION_ENCAP,
@@ -1793,6 +1794,13 @@ struct efx_mae_actions_s {
* to make sure that resource IDs are not compared.
*/
efx_mae_actions_rsrc_t ema_rsrc;
+
+ /*
+ * A copy of encp->enc_mae_aset_v2_supported.
+ * It is set by efx_mae_action_set_spec_init().
+ * This value is ignored on spec comparisons.
+ */
+ boolean_t ema_v2_is_supported;
};
#endif /* EFSYS_OPT_MAE */
diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c
index 41444e1926..756c35788e 100644
--- a/drivers/common/sfc_efx/base/efx_mae.c
+++ b/drivers/common/sfc_efx/base/efx_mae.c
@@ -1376,6 +1376,7 @@ efx_mae_action_set_spec_init(
__in efx_nic_t *enp,
__out efx_mae_actions_t **specp)
{
+ const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
efx_mae_actions_t *spec;
efx_rc_t rc;
@@ -1388,6 +1389,12 @@ efx_mae_action_set_spec_init(
spec->ema_rsrc.emar_eh_id.id = EFX_MAE_RSRC_ID_INVALID;
spec->ema_rsrc.emar_counter_id.id = EFX_MAE_RSRC_ID_INVALID;
+ /*
+ * Helpers which populate v2 actions must reject them when v2 is not
+ * supported. As they have no EFX NIC argument, save v2 status here.
+ */
+ spec->ema_v2_is_supported = encp->enc_mae_aset_v2_supported;
+
*specp = spec;
return (0);
@@ -1626,6 +1633,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_DECR_IP_TTL] = {
+ .emad_add = efx_mae_action_set_no_op
+ },
[EFX_MAE_ACTION_VLAN_PUSH] = {
.emad_add = efx_mae_action_set_add_vlan_push
},
@@ -1649,6 +1659,7 @@ 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_DECAP) |
(1U << EFX_MAE_ACTION_VLAN_POP) |
+ (1U << EFX_MAE_ACTION_DECR_IP_TTL) |
(1U << EFX_MAE_ACTION_VLAN_PUSH) |
/*
* HW will conduct action COUNT after
@@ -1767,6 +1778,25 @@ efx_mae_action_set_populate_vlan_pop(
EFX_MAE_ACTION_VLAN_POP, 0, NULL));
}
+ __checkReturn efx_rc_t
+efx_mae_action_set_populate_decr_ip_ttl(
+ __in efx_mae_actions_t *spec)
+{
+ efx_rc_t rc;
+
+ if (spec->ema_v2_is_supported == B_FALSE) {
+ rc = ENOTSUP;
+ goto fail1;
+ }
+
+ return (efx_mae_action_set_spec_populate(spec,
+ EFX_MAE_ACTION_DECR_IP_TTL, 0, NULL));
+
+fail1:
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
+ return (rc);
+}
+
__checkReturn efx_rc_t
efx_mae_action_set_populate_vlan_push(
__in efx_mae_actions_t *spec,
@@ -2542,6 +2572,11 @@ 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_actions & (1U << EFX_MAE_ACTION_DECR_IP_TTL)) != 0) {
+ MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS,
+ MAE_ACTION_SET_ALLOC_IN_DO_DECR_IP_TTL, 1);
+ }
+
if (spec->ema_n_vlan_tags_to_push > 0) {
unsigned int outer_tag_idx;
diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map
index ec862200ab..765ca39332 100644
--- a/drivers/common/sfc_efx/version.map
+++ b/drivers/common/sfc_efx/version.map
@@ -95,6 +95,7 @@ INTERNAL {
efx_mae_action_set_get_nb_count;
efx_mae_action_set_populate_count;
efx_mae_action_set_populate_decap;
+ efx_mae_action_set_populate_decr_ip_ttl;
efx_mae_action_set_populate_deliver;
efx_mae_action_set_populate_drop;
efx_mae_action_set_populate_encap;
--
2.30.2
next prev parent reply other threads:[~2021-11-05 21:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-05 21:54 [dpdk-dev] [PATCH 0/5] net/sfc: support IP TTL decrement actions in transfer flows Ivan Malov
2021-11-05 21:54 ` [dpdk-dev] [PATCH 1/5] common/sfc_efx/base: refine adding encap action to a set Ivan Malov
2021-11-05 21:54 ` [dpdk-dev] [PATCH 2/5] common/sfc_efx/base: refine adding count " Ivan Malov
2021-11-05 21:54 ` [dpdk-dev] [PATCH 3/5] common/sfc_efx/base: factor out no-op helper functions Ivan Malov
2021-11-05 21:54 ` Ivan Malov [this message]
2021-11-05 21:54 ` [dpdk-dev] [PATCH 5/5] net/sfc: support decrement IP TTL actions in transfer flows Ivan Malov
2021-11-08 15:32 ` [dpdk-dev] [PATCH 0/5] net/sfc: support IP TTL decrement " Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211105215409.5706-5-ivan.malov@oktetlabs.ru \
--to=ivan.malov@oktetlabs.ru \
--cc=amoreton@xilinx.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=mdr@ashroe.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).