From: Shahaf Shuler <shahafs@mellanox.com>
To: Slava Ovsiienko <viacheslavo@mellanox.com>,
"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 1/4] net/mlx5: add DV/DR flow data alloc/free routines
Date: Tue, 2 Apr 2019 19:09:45 +0000 [thread overview]
Message-ID: <AM0PR0502MB3795CF84222D0D35C438E2F7C3560@AM0PR0502MB3795.eurprd05.prod.outlook.com> (raw)
Message-ID: <20190402190945.3sPqQLd4AIwzqPv3bjr3wzLHRkpanXXE3nLsF3LB_4M@z> (raw)
In-Reply-To: <1554186157-29455-2-git-send-email-viacheslavo@mellanox.com>
Tuesday, April 2, 2019 9:23 AM, Viacheslav Ovsiienko:
> Subject: [PATCH 1/4] net/mlx5: add DV/DR flow data alloc/free routines
DV and DR are acronyms which are Mellanox specific. The title should be written in a way that even non-Mellanox developer will easily understand it.
>
> 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 <viacheslavo@mellanox.com>
> ---
> 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
Function prototypes should not be under ifdef. Ifdef should be used in the function body.
It much simplify the code readability of the function which calls them.
> +/**
> + * Initialize DV/DR related data within private structure.
> + * This is preparation step for the data sharing.
Per my understanding below those are only direct rule objects.
> + *
> + * @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
Have the ifdef inside the shared_dv and remove it from here.
> + 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
next prev parent reply other threads:[~2019-04-02 19:09 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 6:22 [dpdk-dev] [PATCH 0/4] support DR/DV flows over shared IB context Viacheslav Ovsiienko
2019-04-02 6:22 ` Viacheslav Ovsiienko
2019-04-02 6:22 ` [dpdk-dev] [PATCH 1/4] net/mlx5: add DV/DR flow data alloc/free routines Viacheslav Ovsiienko
2019-04-02 6:22 ` Viacheslav Ovsiienko
2019-04-02 19:09 ` Shahaf Shuler [this message]
2019-04-02 19:09 ` Shahaf Shuler
2019-04-02 6:22 ` [dpdk-dev] [PATCH 2/4] net/mlx5: add reference counter for DV/DR structures Viacheslav Ovsiienko
2019-04-02 6:22 ` Viacheslav Ovsiienko
2019-04-02 19:09 ` Shahaf Shuler
2019-04-02 19:09 ` Shahaf Shuler
2019-04-03 13:27 ` Slava Ovsiienko
2019-04-03 13:27 ` Slava Ovsiienko
2019-04-02 6:22 ` [dpdk-dev] [PATCH 3/4] net/mlx5: share DV/DR flow related structures Viacheslav Ovsiienko
2019-04-02 6:22 ` Viacheslav Ovsiienko
2019-04-02 19:09 ` Shahaf Shuler
2019-04-02 19:09 ` Shahaf Shuler
2019-04-02 6:22 ` [dpdk-dev] [PATCH 4/4] net/mlx5: add mutex for shared DV/DR structures Viacheslav Ovsiienko
2019-04-02 6:22 ` Viacheslav Ovsiienko
2019-04-02 19:09 ` Shahaf Shuler
2019-04-02 19:09 ` Shahaf Shuler
2019-04-04 13:04 ` [dpdk-dev] [PATCH v2 0/2] support Direct Rules flows over shared IB context Viacheslav Ovsiienko
2019-04-04 13:04 ` Viacheslav Ovsiienko
2019-04-04 13:04 ` [dpdk-dev] [PATCH v2 1/2] net/mlx5: add Direct Rules flow data alloc/free routines Viacheslav Ovsiienko
2019-04-04 13:04 ` Viacheslav Ovsiienko
2019-04-04 13:04 ` [dpdk-dev] [PATCH v2 2/2] net/mlx5: share Direct Rules/Verbs flow related structures Viacheslav Ovsiienko
2019-04-04 13:04 ` Viacheslav Ovsiienko
2019-04-04 18:57 ` [dpdk-dev] [PATCH v2 0/2] support Direct Rules flows over shared IB context Shahaf Shuler
2019-04-04 18:57 ` Shahaf Shuler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM0PR0502MB3795CF84222D0D35C438E2F7C3560@AM0PR0502MB3795.eurprd05.prod.outlook.com \
--to=shahafs@mellanox.com \
--cc=dev@dpdk.org \
--cc=viacheslavo@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).