From: Suanming Mou Date: Wed, 15 Jul 2020 13:10:21 +0000 (+0800) Subject: net/mlx5: add option to configure FCS or decapsulation X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=50f95b23c9ba8237a7f376e2e90d4bfa04a3bab6 net/mlx5: add option to configure FCS or decapsulation There are some limitations on some NICs (at least on ConnectX-6 Dx and BlueField 2) with supporting FCS (frame checksum) scattering for the tunnel decapsulated packets. For the case only one of the features can be supported in the same time, and the new devarg "decap_en" is introduced to provide the choice to the users. If FCS scattering feature is not supposed to be engaged by application, this new devarg should be specified as "decap_en=0", forcing the FCS feature enable and rejecting tunnel decap actions in the rte_flow engine. If FCS scatter is not needed and application supposes to use tunnel decapsulation in rte_flow, the devarg can be omitted or set to non-zero value (this is default settings). Signed-off-by: Suanming Mou Acked-by: Viacheslav Ovsiienko --- diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index efb9cd57bf..90202c0bbb 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -929,6 +929,15 @@ Driver options By default, the PMD will set this value to 0. +- ``decap_en`` parameter [int] + + Some devices do not support FCS (frame checksum) scattering for + tunnel-decapsulated packets. + If set to 0, this option forces the FCS feature and rejects tunnel + decapsulation in the flow engine for such devices. + + By default, the PMD will set this value to 1. + .. _mlx5_firmware_config: Firmware configuration diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 742e2fba49..42f45ec403 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -776,8 +776,6 @@ err_secondary: (config.hw_vlan_strip ? "" : "not ")); config.hw_fcs_strip = !!(sh->device_attr.raw_packet_caps & IBV_RAW_PACKET_CAP_SCATTER_FCS); - DRV_LOG(DEBUG, "FCS stripping configuration is %ssupported", - (config.hw_fcs_strip ? "" : "not ")); #if defined(HAVE_IBV_WQ_FLAG_RX_END_PADDING) hw_padding = !!sh->device_attr.rx_pad_end_addr_align; #elif defined(HAVE_IBV_WQ_FLAGS_PCI_WRITE_END_PADDING) @@ -959,6 +957,15 @@ err_secondary: config.rt_timestamp = 1; } } + /* + * If HW has bug working with tunnel packet decapsulation and + * scatter FCS, and decapsulation is needed, clear the hw_fcs_strip + * bit. Then DEV_RX_OFFLOAD_KEEP_CRC bit will not be set anymore. + */ + if (config.hca_attr.scatter_fcs_w_decap_disable && config.decap_en) + config.hw_fcs_strip = 0; + DRV_LOG(DEBUG, "FCS stripping configuration is %ssupported", + (config.hw_fcs_strip ? "" : "not ")); if (config.mprq.enabled && mprq) { if (config.mprq.stride_num_n && (config.mprq.stride_num_n > mprq_max_stride_num_n || @@ -1732,6 +1739,7 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, }, .dv_esw_en = 1, .dv_flow_en = 1, + .decap_en = 1, .log_hp_size = MLX5_ARG_UNSET, }; /* Device specific configuration. */ diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 98b17c71fe..3af7c1c967 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -183,6 +183,8 @@ /* The default memory allocator used in PMD. */ #define MLX5_SYS_MEM_EN "sys_mem_en" +/* Decap will be used or not. */ +#define MLX5_DECAP_EN "decap_en" static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data"; @@ -1544,6 +1546,8 @@ mlx5_args_check(const char *key, const char *val, void *opaque) config->reclaim_mode = tmp; } else if (strcmp(MLX5_SYS_MEM_EN, key) == 0) { config->sys_mem_en = !!tmp; + } else if (strcmp(MLX5_DECAP_EN, key) == 0) { + config->decap_en = !!tmp; } else { DRV_LOG(WARNING, "%s: unknown parameter", key); rte_errno = EINVAL; @@ -1603,6 +1607,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs) MLX5_HP_BUF_SIZE, MLX5_RECLAIM_MEM, MLX5_SYS_MEM_EN, + MLX5_DECAP_EN, NULL, }; struct rte_kvargs *kvlist; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 4d90a19c42..1a21ce65c7 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -218,6 +218,7 @@ struct mlx5_dev_config { unsigned int reclaim_mode:2; /* Memory reclaim mode. */ unsigned int rt_timestamp:1; /* realtime timestamp format. */ unsigned int sys_mem_en:1; /* The default memory allocator. */ + unsigned int decap_en:1; /* Whether decap will be used or not. */ struct { unsigned int enabled:1; /* Whether MPRQ is enabled. */ unsigned int stride_num_n; /* Number of strides. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index ff182edd24..73beaf9afa 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -2429,6 +2429,11 @@ flow_dv_validate_action_decap(struct rte_eth_dev *dev, { const struct mlx5_priv *priv = dev->data->dev_private; + if (priv->config.hca_attr.scatter_fcs_w_decap_disable && + !priv->config.decap_en) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "decap is not enabled"); if (action_flags & MLX5_FLOW_XCAP_ACTIONS) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL,