Skip to content

Commit

Permalink
net/mlx5: fix Direct Rules API
Browse files Browse the repository at this point in the history
The RDMA-CORE Direct Rules API was changed in latest upstream code

This commit update the API accordingly.

Fixes: 4f84a19 ("net/mlx5: add Direct Rules API")

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
  • Loading branch information
orikam authored and Ferruh Yigit committed May 3, 2019
1 parent 9cc42c5 commit d1e64fb
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 100 deletions.
4 changes: 2 additions & 2 deletions drivers/net/mlx5/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
$Q sh -- '$<' '$@' \
HAVE_MLX5DV_DR \
infiniband/mlx5dv.h \
enum MLX5DV_DR_NS_TYPE_TERMINATING \
enum MLX5DV_DR_DOMAIN_TYPE_NIC_RX \
$(AUTOCONF_OUTPUT)
$Q sh -- '$<' '$@' \
HAVE_MLX5DV_DR_ESWITCH \
infiniband/mlx5dv.h \
enum MLX5DV_DR_NS_DOMAIN_FDB_BYPASS \
enum MLX5DV_DR_DOMAIN_TYPE_FDB \
$(AUTOCONF_OUTPUT)
$Q sh -- '$<' '$@' \
HAVE_IBV_DEVX_OBJ \
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/mlx5/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ if build
[ 'HAVE_IBV_FLOW_DEVX_COUNTERS', 'infiniband/mlx5dv.h',
'MLX5DV_FLOW_ACTION_COUNTERS_DEVX' ],
[ 'HAVE_MLX5DV_DR', 'infiniband/mlx5dv.h',
'MLX5DV_DR_NS_TYPE_TERMINATING' ],
'MLX5DV_DR_DOMAIN_TYPE_NIC_RX' ],
[ 'HAVE_MLX5DV_DR_ESWITCH', 'infiniband/mlx5dv.h',
'MLX5DV_DR_NS_DOMAIN_FDB_BYPASS' ],
'MLX5DV_DR_DOMAIN_TYPE_FDB' ],
[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
'SUPPORTED_40000baseKR4_Full' ],
[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
Expand Down
68 changes: 34 additions & 34 deletions drivers/net/mlx5/mlx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
#ifdef HAVE_MLX5DV_DR
struct mlx5_ibv_shared *sh = priv->sh;
int err = 0;
void *ns;
void *domain;

assert(sh);
if (sh->dv_refcnt) {
Expand All @@ -352,33 +352,33 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)
return 0;
}
/* Reference counter is zero, we should initialize structures. */
ns = mlx5_glue->dr_create_ns(sh->ctx,
MLX5DV_DR_NS_DOMAIN_INGRESS_BYPASS);
if (!ns) {
DRV_LOG(ERR, "ingress mlx5dv_dr_create_ns failed");
domain = mlx5_glue->dr_create_domain(sh->ctx,
MLX5DV_DR_DOMAIN_TYPE_NIC_RX);
if (!domain) {
DRV_LOG(ERR, "ingress mlx5dv_dr_create_domain failed");
err = errno;
goto error;
}
sh->rx_ns = ns;
ns = mlx5_glue->dr_create_ns(sh->ctx,
MLX5DV_DR_NS_DOMAIN_EGRESS_BYPASS);
if (!ns) {
DRV_LOG(ERR, "egress mlx5dv_dr_create_ns failed");
sh->rx_domain = domain;
domain = mlx5_glue->dr_create_domain(sh->ctx,
MLX5DV_DR_DOMAIN_TYPE_NIC_TX);
if (!domain) {
DRV_LOG(ERR, "egress mlx5dv_dr_create_domain failed");
err = errno;
goto error;
}
pthread_mutex_init(&sh->dv_mutex, NULL);
sh->tx_ns = ns;
sh->tx_domain = domain;
#ifdef HAVE_MLX5DV_DR_ESWITCH
if (priv->config.dv_esw_en) {
ns = mlx5_glue->dr_create_ns(sh->ctx,
MLX5DV_DR_NS_DOMAIN_FDB_BYPASS);
if (!ns) {
DRV_LOG(ERR, "FDB mlx5dv_dr_create_ns failed");
domain = mlx5_glue->dr_create_domain
(sh->ctx, MLX5DV_DR_DOMAIN_TYPE_FDB);
if (!domain) {
DRV_LOG(ERR, "FDB mlx5dv_dr_create_domain failed");
err = errno;
goto error;
}
sh->fdb_ns = ns;
sh->fdb_domain = domain;
sh->esw_drop_action = mlx5_glue->dr_create_flow_action_drop();
}
#endif
Expand All @@ -388,17 +388,17 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv)

error:
/* Rollback the created objects. */
if (sh->rx_ns) {
mlx5_glue->dr_destroy_ns(sh->rx_ns);
sh->rx_ns = NULL;
if (sh->rx_domain) {
mlx5_glue->dr_destroy_domain(sh->rx_domain);
sh->rx_domain = NULL;
}
if (sh->tx_ns) {
mlx5_glue->dr_destroy_ns(sh->tx_ns);
sh->tx_ns = NULL;
if (sh->tx_domain) {
mlx5_glue->dr_destroy_domain(sh->tx_domain);
sh->tx_domain = NULL;
}
if (sh->fdb_ns) {
mlx5_glue->dr_destroy_ns(sh->fdb_ns);
sh->fdb_ns = NULL;
if (sh->fdb_domain) {
mlx5_glue->dr_destroy_domain(sh->fdb_domain);
sh->fdb_domain = NULL;
}
if (sh->esw_drop_action) {
mlx5_glue->destroy_flow_action(sh->esw_drop_action);
Expand Down Expand Up @@ -431,18 +431,18 @@ mlx5_free_shared_dr(struct mlx5_priv *priv)
assert(sh->dv_refcnt);
if (sh->dv_refcnt && --sh->dv_refcnt)
return;
if (sh->rx_ns) {
mlx5_glue->dr_destroy_ns(sh->rx_ns);
sh->rx_ns = NULL;
if (sh->rx_domain) {
mlx5_glue->dr_destroy_domain(sh->rx_domain);
sh->rx_domain = NULL;
}
if (sh->tx_ns) {
mlx5_glue->dr_destroy_ns(sh->tx_ns);
sh->tx_ns = NULL;
if (sh->tx_domain) {
mlx5_glue->dr_destroy_domain(sh->tx_domain);
sh->tx_domain = NULL;
}
#ifdef HAVE_MLX5DV_DR_ESWITCH
if (sh->fdb_ns) {
mlx5_glue->dr_destroy_ns(sh->fdb_ns);
sh->fdb_ns = NULL;
if (sh->fdb_domain) {
mlx5_glue->dr_destroy_domain(sh->fdb_domain);
sh->fdb_domain = NULL;
}
if (sh->esw_drop_action) {
mlx5_glue->destroy_flow_action(sh->esw_drop_action);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/mlx5/mlx5.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,13 @@ struct mlx5_ibv_shared {
/* Shared DV/DR flow data section. */
pthread_mutex_t dv_mutex; /* DV context mutex. */
uint32_t dv_refcnt; /* DV/DR data reference counter. */
void *fdb_ns; /* FDB Direct Rules name space handle. */
void *fdb_domain; /* FDB Direct Rules name space handle. */
struct mlx5_flow_tbl_resource fdb_tbl[MLX5_MAX_TABLES_FDB];
/* FDB Direct Rules tables. */
void *rx_ns; /* RX Direct Rules name space handle. */
void *rx_domain; /* RX Direct Rules name space handle. */
struct mlx5_flow_tbl_resource rx_tbl[MLX5_MAX_TABLES];
/* RX Direct Rules tables. */
void *tx_ns; /* TX Direct Rules name space handle. */
void *tx_domain; /* TX Direct Rules name space handle. */
struct mlx5_flow_tbl_resource tx_tbl[MLX5_MAX_TABLES];
void *esw_drop_action; /* Pointer to DR E-Switch drop action. */
/* TX Direct Rules tables/ */
Expand Down
30 changes: 16 additions & 14 deletions drivers/net/mlx5/mlx5_flow_dv.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
#endif

#ifndef HAVE_MLX5DV_DR_ESWITCH
#ifndef MLX5DV_FLOW_TABLE_TYPE_FDB
#define MLX5DV_FLOW_TABLE_TYPE_FDB 0
#endif
#endif

#ifndef HAVE_MLX5DV_DR
#define MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL 1
Expand Down Expand Up @@ -943,15 +945,15 @@ flow_dv_encap_decap_resource_register
struct mlx5_ibv_shared *sh = priv->sh;
struct mlx5_flow_dv_encap_decap_resource *cache_resource;
struct rte_flow *flow = dev_flow->flow;
struct mlx5dv_dr_ns *ns;
struct mlx5dv_dr_domain *domain;

resource->flags = flow->group ? 0 : 1;
if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB)
ns = sh->fdb_ns;
domain = sh->fdb_domain;
else if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_NIC_RX)
ns = sh->rx_ns;
domain = sh->rx_domain;
else
ns = sh->tx_ns;
domain = sh->tx_domain;

/* Lookup a matching resource from cache. */
LIST_FOREACH(cache_resource, &sh->encaps_decaps, next) {
Expand Down Expand Up @@ -980,7 +982,7 @@ flow_dv_encap_decap_resource_register
cache_resource->verbs_action =
mlx5_glue->dv_create_flow_action_packet_reformat
(sh->ctx, cache_resource->reformat_type,
cache_resource->ft_type, ns, cache_resource->flags,
cache_resource->ft_type, domain, cache_resource->flags,
cache_resource->size,
(cache_resource->size ? cache_resource->buf : NULL));
if (!cache_resource->verbs_action) {
Expand Down Expand Up @@ -1108,8 +1110,8 @@ flow_dv_port_id_action_resource_register
"cannot allocate resource memory");
*cache_resource = *resource;
cache_resource->action =
mlx5_glue->dr_create_flow_action_dest_vport(priv->sh->fdb_ns,
resource->port_id);
mlx5_glue->dr_create_flow_action_dest_vport
(priv->sh->fdb_domain, resource->port_id);
if (!cache_resource->action) {
rte_free(cache_resource);
return rte_flow_error_set(error, ENOMEM,
Expand Down Expand Up @@ -1826,14 +1828,14 @@ flow_dv_modify_hdr_resource_register
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_ibv_shared *sh = priv->sh;
struct mlx5_flow_dv_modify_hdr_resource *cache_resource;
struct mlx5dv_dr_ns *ns;
struct mlx5dv_dr_domain *ns;

if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB)
ns = sh->fdb_ns;
ns = sh->fdb_domain;
else if (resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_NIC_TX)
ns = sh->tx_ns;
ns = sh->tx_domain;
else
ns = sh->rx_ns;
ns = sh->rx_domain;
resource->flags =
dev_flow->flow->group ? 0 : MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL;
/* Lookup a matching resource from cache. */
Expand Down Expand Up @@ -3305,17 +3307,17 @@ flow_dv_tbl_resource_get(struct rte_eth_dev *dev,
tbl = &sh->fdb_tbl[table_id];
if (!tbl->obj)
tbl->obj = mlx5_glue->dr_create_flow_tbl
(sh->fdb_ns, table_id);
(sh->fdb_domain, table_id);
} else if (egress) {
tbl = &sh->tx_tbl[table_id];
if (!tbl->obj)
tbl->obj = mlx5_glue->dr_create_flow_tbl
(sh->tx_ns, table_id);
(sh->tx_domain, table_id);
} else {
tbl = &sh->rx_tbl[table_id];
if (!tbl->obj)
tbl->obj = mlx5_glue->dr_create_flow_tbl
(sh->rx_ns, table_id);
(sh->rx_domain, table_id);
}
if (!tbl->obj) {
rte_flow_error_set(error, ENOMEM,
Expand Down
Loading

0 comments on commit d1e64fb

Please sign in to comment.