net/mlx5: create relaxed ordering memory regions
authorShiri Kuzin <shirik@mellanox.com>
Tue, 24 Mar 2020 11:39:39 +0000 (13:39 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:05 +0000 (13:57 +0200)
In the current state, when preforming read/write
transactions we must wait for a completion in order
to run the next transaction, and all transactions are
performed by order.

Relaxed Ordering is a PCI optimization which by enabling it
we allow the system to perform read/writes in a different
order without having to wait for completion and improve
the performance in that matter.

This commit introduces the creation of relaxed ordering
memory regions in mlx5.
As relaxed ordering is an optimization, drivers that
do not support it can simply ignore it and therefore
it is enabled by default.

Signed-off-by: Shiri Kuzin <shirik@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
doc/guides/rel_notes/release_20_05.rst
drivers/common/mlx5/mlx5_devx_cmds.c
drivers/common/mlx5/mlx5_devx_cmds.h
drivers/common/mlx5/mlx5_glue.h
drivers/common/mlx5/mlx5_prm.h
drivers/net/mlx5/mlx5_flow_dv.c
drivers/net/mlx5/mlx5_mr.c
drivers/vdpa/mlx5/mlx5_vdpa_lm.c
drivers/vdpa/mlx5/mlx5_vdpa_mem.c

index cd7d15c..8c39625 100644 (file)
@@ -93,6 +93,7 @@ New Features
   Updated Mellanox mlx5 driver with new features and improvements, including:
 
   * Added support for matching on IPv4 Time To Live and IPv6 Hop Limit.
+  * Added support for creating Relaxed Ordering Memory Regions.
 
 * **Updated the AESNI MB crypto PMD.**
 
index d960bc9..1157a44 100644 (file)
@@ -196,6 +196,10 @@ mlx5_devx_cmd_mkey_create(struct ibv_context *ctx,
        MLX5_SET(mkc, mkc, pd, attr->pd);
        MLX5_SET(mkc, mkc, mkey_7_0, attr->umem_id & 0xFF);
        MLX5_SET(mkc, mkc, translations_octword_size, translation_size);
+       if (attr->relaxed_ordering == 1) {
+               MLX5_SET(mkc, mkc, relaxed_ordering_write, 0x1);
+               MLX5_SET(mkc, mkc, relaxed_ordering_read, 0x1);
+       }
        MLX5_SET64(mkc, mkc, start_addr, attr->addr);
        MLX5_SET64(mkc, mkc, len, attr->size);
        mkey->obj = mlx5_glue->devx_obj_create(ctx, in, in_size_dw * 4, out,
index 6912dc6..20bb294 100644 (file)
@@ -33,6 +33,7 @@ struct mlx5_devx_mkey_attr {
        uint32_t pd;
        uint32_t log_entity_size;
        uint32_t pg_access:1;
+       uint32_t relaxed_ordering:1;
        struct mlx5_klm *klm_array;
        int klm_num;
 };
index 6238b43..cd1136f 100644 (file)
@@ -98,6 +98,10 @@ struct mlx5dv_var { uint32_t page_id; uint32_t length; off_t mmap_off;
                        uint64_t comp_mask; };
 #endif
 
+#ifndef IBV_ACCESS_RELAXED_ORDERING
+#define IBV_ACCESS_RELAXED_ORDERING 0
+#endif
+
 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
 struct mlx5_glue {
        const char *version;
index eee3a4b..00fd7c1 100644 (file)
@@ -882,7 +882,9 @@ struct mlx5_ifc_mkc_bits {
 
        u8         translations_octword_size[0x20];
 
-       u8         reserved_at_1c0[0x1b];
+       u8         reserved_at_1c0[0x19];
+       u8                 relaxed_ordering_read[0x1];
+       u8                 reserved_at_1da[0x1];
        u8         log_page_size[0x5];
 
        u8         reserved_at_1e0[0x20];
index 2090631..809833b 100644 (file)
@@ -3962,6 +3962,7 @@ flow_dv_create_counter_stat_mem_mng(struct rte_eth_dev *dev, int raws_n)
        mkey_attr.pg_access = 0;
        mkey_attr.klm_array = NULL;
        mkey_attr.klm_num = 0;
+       mkey_attr.relaxed_ordering = 1;
        mem_mng->dm = mlx5_devx_cmd_mkey_create(sh->ctx, &mkey_attr);
        if (!mem_mng->dm) {
                mlx5_glue->devx_umem_dereg(mem_mng->umem);
index 6aa5786..a8f185a 100644 (file)
@@ -768,7 +768,8 @@ alloc_resources:
         * through mlx5_alloc_verbs_buf().
         */
        mr->ibv_mr = mlx5_glue->reg_mr(sh->pd, (void *)data.start, len,
-                                      IBV_ACCESS_LOCAL_WRITE);
+                                      IBV_ACCESS_LOCAL_WRITE |
+                                          IBV_ACCESS_RELAXED_ORDERING);
        if (mr->ibv_mr == NULL) {
                DEBUG("port %u fail to create a verbs MR for address (%p)",
                      dev->data->port_id, (void *)addr);
@@ -1217,7 +1218,8 @@ mlx5_create_mr_ext(struct rte_eth_dev *dev, uintptr_t addr, size_t len,
        if (mr == NULL)
                return NULL;
        mr->ibv_mr = mlx5_glue->reg_mr(priv->sh->pd, (void *)addr, len,
-                                      IBV_ACCESS_LOCAL_WRITE);
+                                      IBV_ACCESS_LOCAL_WRITE |
+                                          IBV_ACCESS_RELAXED_ORDERING);
        if (mr->ibv_mr == NULL) {
                DRV_LOG(WARNING,
                        "port %u fail to create a verbs MR for address (%p)",
index 3358704..4457760 100644 (file)
@@ -39,6 +39,7 @@ mlx5_vdpa_dirty_bitmap_set(struct mlx5_vdpa_priv *priv, uint64_t log_base,
                        .pg_access = 1,
                        .klm_array = NULL,
                        .klm_num = 0,
+                       .relaxed_ordering = 0,
        };
        struct mlx5_devx_virtq_attr attr = {
                .type = MLX5_VIRTQ_MODIFY_TYPE_DIRTY_BITMAP_PARAMS,
index 398ca35..da31b47 100644 (file)
@@ -263,6 +263,7 @@ mlx5_vdpa_mem_register(struct mlx5_vdpa_priv *priv)
                mkey_attr.pg_access = 1;
                mkey_attr.klm_array = NULL;
                mkey_attr.klm_num = 0;
+               mkey_attr.relaxed_ordering = 0;
                entry->mkey = mlx5_devx_cmd_mkey_create(priv->ctx, &mkey_attr);
                if (!entry->mkey) {
                        DRV_LOG(ERR, "Failed to create direct Mkey.");