From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 0552CA0679 for ; Tue, 2 Apr 2019 08:22:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CD0FE3798; Tue, 2 Apr 2019 08:22:49 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id E0DE15A for ; Tue, 2 Apr 2019 08:22:44 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Apr 2019 09:22:41 +0300 Received: from pegasus12.mtr.labs.mlnx. (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x326MfmU024769; Tue, 2 Apr 2019 09:22:41 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: shahafs@mellanox.com Date: Tue, 2 Apr 2019 06:22:34 +0000 Message-Id: <1554186157-29455-2-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1554186157-29455-1-git-send-email-viacheslavo@mellanox.com> References: <1554186157-29455-1-git-send-email-viacheslavo@mellanox.com> Subject: [dpdk-dev] [PATCH 1/4] net/mlx5: add DV/DR flow data alloc/free routines X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190402062234.7mrQwXor7TDevrhsIPHIVPVOw6kMid2auHfelCnq_B0@z> We are going to share the DR/DV flow device data structures between master and representors in the E-Switch configurations over multiport IB device. The code of initializing and destroying these data is moved to dedicated routines, this is just a preparation step for actual data sharing. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.c | 90 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 13 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index b59fc58..9de122d 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -296,6 +296,73 @@ struct mlx5_dev_spawn_data { pthread_mutex_unlock(&mlx5_ibv_list_mutex); } +#ifdef HAVE_MLX5DV_DR +/** + * Initialize DV/DR related data within private structure. + * This is preparation step for the data sharing. + * + * @param[in] priv + * Pointer to the private device data structure. + * + * @return + * Zero on success, positive error code otherwise. + */ +static int +mlx5_alloc_shared_dv(struct mlx5_priv *priv) +{ + struct mlx5_ibv_shared *sh = priv->sh; + int err = 0; + void *ns; + + ns = mlx5dv_dr_create_ns(sh->ctx, MLX5DV_DR_NS_DOMAIN_INGRESS_BYPASS); + if (!ns) { + DRV_LOG(ERR, "ingress mlx5dv_dr_create_ns failed"); + err = errno; + goto error; + } + priv->rx_ns = ns; + ns = mlx5dv_dr_create_ns(sh->ctx, MLX5DV_DR_NS_DOMAIN_EGRESS_BYPASS); + if (!ns) { + DRV_LOG(ERR, "egress mlx5dv_dr_create_ns failed"); + err = errno; + goto error; + } + priv->tx_ns = ns; + return 0; + +error: + /* Rollback the created objects. */ + if (priv->rx_ns) { + mlx5dv_dr_destroy_ns(priv->rx_ns); + priv->rx_ns = NULL; + } + if (priv->tx_ns) { + mlx5dv_dr_destroy_ns(priv->tx_ns); + priv->tx_ns = NULL; + } + return err; +} + +/** + * Destroy DV/DR related structures within private structure. + * + * @param[in] priv + * Pointer to the private device data structure. + */ +static void +mlx5_free_shared_dv(struct mlx5_priv *priv) +{ + if (priv->rx_ns) { + mlx5dv_dr_destroy_ns(priv->rx_ns); + priv->rx_ns = NULL; + } + if (priv->tx_ns) { + mlx5dv_dr_destroy_ns(priv->tx_ns); + priv->tx_ns = NULL; + } +} +#endif + /** * Prepare shared data between primary and secondary process. */ @@ -446,6 +513,9 @@ struct mlx5_dev_spawn_data { mlx5_mprq_free_mp(dev); mlx5_mr_release(dev); assert(priv->sh); +#ifdef HAVE_MLX5DV_DR + mlx5_free_shared_dv(priv); +#endif if (priv->sh) mlx5_free_shared_ibctx(priv->sh); priv->sh = NULL; @@ -1363,20 +1433,11 @@ struct mlx5_dev_spawn_data { } } #ifdef HAVE_MLX5DV_DR - priv->rx_ns = mlx5dv_dr_create_ns - (sh->ctx, MLX5DV_DR_NS_DOMAIN_INGRESS_BYPASS); - if (priv->rx_ns == NULL) { - DRV_LOG(ERR, "mlx5dv_dr_create_ns failed"); - err = errno; - goto error; - } - priv->tx_ns = mlx5dv_dr_create_ns(sh->ctx, - MLX5DV_DR_NS_DOMAIN_EGRESS_BYPASS); - if (priv->tx_ns == NULL) { - DRV_LOG(ERR, "mlx5dv_dr_create_ns failed"); - err = errno; + if (config.dv_flow_en) { + err = mlx5_alloc_shared_dv(priv); + if (err) goto error; - } + } #endif TAILQ_INIT(&priv->flows); TAILQ_INIT(&priv->ctrl_flows); @@ -1429,6 +1490,9 @@ struct mlx5_dev_spawn_data { return eth_dev; error: if (priv) { +#ifdef HAVE_MLX5DV_DR + mlx5_free_shared_dv(priv); +#endif if (priv->nl_socket_route >= 0) close(priv->nl_socket_route); if (priv->nl_socket_rdma >= 0) -- 1.8.3.1