]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx5: support modifying ECN field
authorSean Zhang <xiazhang@nvidia.com>
Tue, 7 Jun 2022 11:18:59 +0000 (14:18 +0300)
committerRaslan Darawsheh <rasland@nvidia.com>
Thu, 23 Jun 2022 15:23:25 +0000 (17:23 +0200)
This patch is to support modify ECN field in IPv4/IPv6 header.

Signed-off-by: Sean Zhang <xiazhang@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
doc/guides/nics/mlx5.rst
doc/guides/rel_notes/release_22_07.rst
drivers/net/mlx5/mlx5_flow_dv.c

index 1e13a9327f074970c40dbcb99bc30b8c6a4b21a6..7693c134001befeb2f257955f640318370ba57d3 100644 (file)
@@ -82,6 +82,7 @@ Features
 - Matching on GTP extension header with raw encap/decap action.
 - Matching on Geneve TLV option header with raw encap/decap action.
 - Matching on ESP header SPI field.
+- Modify IPv4/IPv6 ECN field.
 - RSS support in sample action.
 - E-Switch mirroring and jump.
 - E-Switch mirroring and modify.
index 2162439786b844fcd41ec3563ddedaecf3f38a07..a94cd3a298098b0cb7c1bf246ed9031be70d00c1 100644 (file)
@@ -169,6 +169,7 @@ New Features
   * Added support for MTU on Windows.
   * Added matching and RSS on IPsec ESP.
   * Added matching on represented port.
+  * Added support for modifying ECN field of IPv4/IPv6.
 
 * **Updated Netronome nfp driver.**
 
index ee0a4bdcfcb0b9cca39bb25d6d45d0f090569b0d..2b94f7156ecc9ba72d42fcd895d7a22bb9a73997 100644 (file)
@@ -1450,6 +1450,9 @@ mlx5_flow_item_field_width(struct rte_eth_dev *dev,
        case RTE_FLOW_FIELD_POINTER:
        case RTE_FLOW_FIELD_VALUE:
                return inherit < 0 ? 0 : inherit;
+       case RTE_FLOW_FIELD_IPV4_ECN:
+       case RTE_FLOW_FIELD_IPV6_ECN:
+               return 2;
        default:
                MLX5_ASSERT(false);
        }
@@ -1827,6 +1830,13 @@ mlx5_flow_field_id_to_modify_info
                                        (meta_count - width)) & meta_mask);
                }
                break;
+       case RTE_FLOW_FIELD_IPV4_ECN:
+       case RTE_FLOW_FIELD_IPV6_ECN:
+               info[idx] = (struct field_modify_info){1, 0,
+                                       MLX5_MODI_OUT_IP_ECN};
+               if (mask)
+                       mask[idx] = 0x3 >> (2 - width);
+               break;
        case RTE_FLOW_FIELD_POINTER:
        case RTE_FLOW_FIELD_VALUE:
        default:
@@ -4900,6 +4910,7 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,
        int ret = 0;
        struct mlx5_priv *priv = dev->data->dev_private;
        struct mlx5_sh_config *config = &priv->sh->config;
+       struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr;
        const struct rte_flow_action_modify_field *action_modify_field =
                action->conf;
        uint32_t dst_width = mlx5_flow_item_field_width(dev,
@@ -5027,6 +5038,15 @@ flow_dv_validate_action_modify_field(struct rte_eth_dev *dev,
                                RTE_FLOW_ERROR_TYPE_ACTION, action,
                                "add and sub operations"
                                " are not supported");
+       if (action_modify_field->dst.field == RTE_FLOW_FIELD_IPV4_ECN ||
+           action_modify_field->src.field == RTE_FLOW_FIELD_IPV4_ECN ||
+           action_modify_field->dst.field == RTE_FLOW_FIELD_IPV6_ECN ||
+           action_modify_field->src.field == RTE_FLOW_FIELD_IPV6_ECN)
+               if (!hca_attr->modify_outer_ip_ecn &&
+                   !attr->transfer && !attr->group)
+                       return rte_flow_error_set(error, ENOTSUP,
+                               RTE_FLOW_ERROR_TYPE_ACTION, action,
+                               "modifications of the ECN for current firmware is not supported");
        return (action_modify_field->width / 32) +
               !!(action_modify_field->width % 32);
 }