From: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
To: dev@dpdk.org
Cc: shahafs@mellanox.com
Subject: [dpdk-dev] [PATCH 2/4] net/mlx5: add reference counter for DV/DR structures
Date: Tue, 2 Apr 2019 06:22:35 +0000 [thread overview]
Message-ID: <1554186157-29455-3-git-send-email-viacheslavo@mellanox.com> (raw)
Message-ID: <20190402062235.Zt3XbVPEK9PzSfwwyEKqOnEcvDy0gYaE0GhaX4UBgag@z> (raw)
In-Reply-To: <1554186157-29455-1-git-send-email-viacheslavo@mellanox.com>
This patch introduces the reference counter for DV/DR
flow engine structure, which we are going to share
between master and representors in E-Switch configurations
over multiport Infiniband device.
Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
drivers/net/mlx5/mlx5.c | 26 ++++++++++++++++++++++++--
drivers/net/mlx5/mlx5.h | 4 ++++
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 9de122d..79e0c17 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -299,7 +299,8 @@ struct mlx5_dev_spawn_data {
#ifdef HAVE_MLX5DV_DR
/**
* Initialize DV/DR related data within private structure.
- * This is preparation step for the data sharing.
+ * Routine checks the reference counter and does actual
+ * resources creation/iniialization only if counter is zero.
*
* @param[in] priv
* Pointer to the private device data structure.
@@ -314,6 +315,14 @@ struct mlx5_dev_spawn_data {
int err = 0;
void *ns;
+ assert(sh);
+ if (sh->dv_refcnt) {
+ /* Shared DV/DR structures is already initialized. */
+ sh->dv_refcnt++;
+ priv->dv_shared = 1;
+ return 0;
+ }
+ /* Reference counter is zero, we should initialize structures. */
ns = mlx5dv_dr_create_ns(sh->ctx, MLX5DV_DR_NS_DOMAIN_INGRESS_BYPASS);
if (!ns) {
DRV_LOG(ERR, "ingress mlx5dv_dr_create_ns failed");
@@ -328,6 +337,8 @@ struct mlx5_dev_spawn_data {
goto error;
}
priv->tx_ns = ns;
+ sh->dv_refcnt++;
+ priv->dv_shared = 1;
return 0;
error:
@@ -352,6 +363,16 @@ struct mlx5_dev_spawn_data {
static void
mlx5_free_shared_dv(struct mlx5_priv *priv)
{
+ struct mlx5_ibv_shared *sh;
+
+ if (!priv->dv_shared)
+ return;
+ priv->dv_shared = 0;
+ sh = priv->sh;
+ assert(sh);
+ assert(sh->dv_refcnt);
+ if (sh->dv_refcnt && --sh->dv_refcnt)
+ return;
if (priv->rx_ns) {
mlx5dv_dr_destroy_ns(priv->rx_ns);
priv->rx_ns = NULL;
@@ -1491,7 +1512,8 @@ struct mlx5_dev_spawn_data {
error:
if (priv) {
#ifdef HAVE_MLX5DV_DR
- mlx5_free_shared_dv(priv);
+ if (priv->sh)
+ mlx5_free_shared_dv(priv);
#endif
if (priv->nl_socket_route >= 0)
close(priv->nl_socket_route);
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index a3d5f8e..56a2c61 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -213,6 +213,9 @@ struct mlx5_ibv_shared {
char ibdev_name[IBV_SYSFS_NAME_MAX]; /* IB device name. */
char ibdev_path[IBV_SYSFS_PATH_MAX]; /* IB device path for secondary */
struct ibv_device_attr_ex device_attr; /* Device properties. */
+ /* Shared DV/DR flow data section. */
+ uint32_t dv_refcnt; /* DV/DR data reference counter. */
+ /* Shared interrupt handler section. */
pthread_mutex_t intr_mutex; /* Interrupt config mutex. */
uint32_t intr_cnt; /* Interrupt handler reference counter. */
struct rte_intr_handle intr_handle; /* Interrupt handler for device. */
@@ -244,6 +247,7 @@ struct mlx5_priv {
unsigned int isolated:1; /* Whether isolated mode is enabled. */
unsigned int representor:1; /* Device is a port representor. */
unsigned int master:1; /* Device is a E-Switch master. */
+ unsigned int dv_shared:1; /* DV/DR data is shared. */
uint16_t domain_id; /* Switch domain identifier. */
uint16_t vport_id; /* Associated VF vport index (if any). */
int32_t representor_id; /* Port representor identifier. */
--
1.8.3.1
next prev parent reply other threads:[~2019-04-02 6:23 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
2019-04-02 19:09 ` Shahaf Shuler
2019-04-02 6:22 ` Viacheslav Ovsiienko [this message]
2019-04-02 6:22 ` [dpdk-dev] [PATCH 2/4] net/mlx5: add reference counter for DV/DR structures 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=1554186157-29455-3-git-send-email-viacheslavo@mellanox.com \
--to=viacheslavo@mellanox.com \
--cc=dev@dpdk.org \
--cc=shahafs@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).