Skip to content

Commit

Permalink
net/mlx5: implement tunnel offload
Browse files Browse the repository at this point in the history
Tunnel Offload API provides hardware independent, unified model
to offload tunneled traffic. Key model elements are:
 - apply matches to both outer and inner packet headers
   during entire offload procedure;
 - restore outer header of partially offloaded packet;
 - model is implemented as a set of helper functions.

Implementation details:
* tunnel_offload PMD parameter must be set to 1 to enable the feature.
* application cannot use MARK and META flow actions with tunnel.
* offload JUMP action is restricted to steering tunnel rule only.

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  • Loading branch information
getelson-at-mellanox authored and Ferruh Yigit committed Nov 3, 2020
1 parent d2046c0 commit 4ec6360
Show file tree
Hide file tree
Showing 8 changed files with 1,084 additions and 54 deletions.
3 changes: 3 additions & 0 deletions doc/guides/nics/mlx5.rst
Expand Up @@ -787,6 +787,9 @@ Driver options
24 bits. The actual supported width can be retrieved in runtime by
series of rte_flow_validate() trials.

- 3, this engages tunnel offload mode. In E-Switch configuration, that
mode implicitly activates ``dv_xmeta_en=1``.

+------+-----------+-----------+-------------+-------------+
| Mode | ``MARK`` | ``META`` | ``META`` Tx | FDB/Through |
+======+===========+===========+=============+=============+
Expand Down
18 changes: 18 additions & 0 deletions drivers/net/mlx5/linux/mlx5_os.c
Expand Up @@ -291,6 +291,12 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
sh->esw_drop_action = mlx5_glue->dr_create_flow_action_drop();
}
#endif
if (!sh->tunnel_hub)
err = mlx5_alloc_tunnel_hub(sh);
if (err) {
DRV_LOG(ERR, "mlx5_alloc_tunnel_hub failed err=%d", err);
goto error;
}
if (priv->config.reclaim_mode == MLX5_RCM_AGGR) {
mlx5_glue->dr_reclaim_domain_memory(sh->rx_domain, 1);
mlx5_glue->dr_reclaim_domain_memory(sh->tx_domain, 1);
Expand Down Expand Up @@ -335,6 +341,10 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
mlx5_hlist_destroy(sh->tag_table, NULL, NULL);
sh->tag_table = NULL;
}
if (sh->tunnel_hub) {
mlx5_release_tunnel_hub(sh, priv->dev_port);
sh->tunnel_hub = NULL;
}
mlx5_free_table_hash_list(priv);
return err;
}
Expand Down Expand Up @@ -391,6 +401,10 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
mlx5_hlist_destroy(sh->tag_table, NULL, NULL);
sh->tag_table = NULL;
}
if (sh->tunnel_hub) {
mlx5_release_tunnel_hub(sh, priv->dev_port);
sh->tunnel_hub = NULL;
}
mlx5_free_table_hash_list(priv);
}

Expand Down Expand Up @@ -733,6 +747,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
strerror(rte_errno));
goto error;
}
if (config->dv_miss_info) {
if (switch_info->master || switch_info->representor)
config->dv_xmeta_en = MLX5_XMETA_MODE_META16;
}
mlx5_malloc_mem_select(config->sys_mem_en);
sh = mlx5_alloc_shared_dev_ctx(spawn, config);
if (!sh)
Expand Down
8 changes: 6 additions & 2 deletions drivers/net/mlx5/mlx5.c
Expand Up @@ -1619,13 +1619,17 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
} else if (strcmp(MLX5_DV_XMETA_EN, key) == 0) {
if (tmp != MLX5_XMETA_MODE_LEGACY &&
tmp != MLX5_XMETA_MODE_META16 &&
tmp != MLX5_XMETA_MODE_META32) {
tmp != MLX5_XMETA_MODE_META32 &&
tmp != MLX5_XMETA_MODE_MISS_INFO) {
DRV_LOG(ERR, "invalid extensive "
"metadata parameter");
rte_errno = EINVAL;
return -rte_errno;
}
config->dv_xmeta_en = tmp;
if (tmp != MLX5_XMETA_MODE_MISS_INFO)
config->dv_xmeta_en = tmp;
else
config->dv_miss_info = 1;
} else if (strcmp(MLX5_LACP_BY_USER, key) == 0) {
config->lacp_by_user = !!tmp;
} else if (strcmp(MLX5_MR_EXT_MEMSEG_EN, key) == 0) {
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/mlx5/mlx5.h
Expand Up @@ -208,6 +208,7 @@ struct mlx5_dev_config {
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. */
unsigned int dv_miss_info:1; /* restore packet after partial hw miss */
struct {
unsigned int enabled:1; /* Whether MPRQ is enabled. */
unsigned int stride_num_n; /* Number of strides. */
Expand Down Expand Up @@ -644,6 +645,7 @@ struct mlx5_dev_ctx_shared {
/* UAR same-page access control required in 32bit implementations. */
#endif
struct mlx5_hlist *flow_tbls;
struct mlx5_flow_tunnel_hub *tunnel_hub;
/* Direct Rules tables for FDB, NIC TX+RX */
void *esw_drop_action; /* Pointer to DR E-Switch drop action. */
void *pop_vlan_action; /* Pointer to DR pop VLAN action. */
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/mlx5/mlx5_defs.h
Expand Up @@ -165,6 +165,8 @@
#define MLX5_XMETA_MODE_LEGACY 0
#define MLX5_XMETA_MODE_META16 1
#define MLX5_XMETA_MODE_META32 2
/* Provide info on patrial hw miss. Implies MLX5_XMETA_MODE_META16 */
#define MLX5_XMETA_MODE_MISS_INFO 3

/* MLX5_TX_DB_NC supported values. */
#define MLX5_TXDB_CACHED 0
Expand Down

0 comments on commit 4ec6360

Please sign in to comment.