X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fmlx5%2Fmlx5_txq.c;h=1b45b4a45f6ac92a6f9733a3f4e2c5665c19a285;hb=1e3a39f72d5d088cd3038241d799dd102e50f0d2;hp=39a38c1ef87132fe28c8955d81f0d1184d14c480;hpb=43e9d9794cde875e697f29e4586b3dcab797fa4f;p=dpdk.git diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 39a38c1ef8..1b45b4a45f 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include /* Verbs header. */ /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */ @@ -168,6 +170,7 @@ txq_setup(struct txq_ctrl *tmpl, struct txq_ctrl *txq_ctrl) struct mlx5dv_obj obj; int ret = 0; + qp.comp_mask = MLX5DV_QP_MASK_UAR_MMAP_OFFSET; obj.cq.in = ibcq; obj.cq.out = &cq_info; obj.qp.in = tmpl->qp; @@ -194,6 +197,13 @@ txq_setup(struct txq_ctrl *tmpl, struct txq_ctrl *txq_ctrl) tmpl->txq.elts = (struct rte_mbuf *(*)[1 << tmpl->txq.elts_n]) ((uintptr_t)txq_ctrl + sizeof(*txq_ctrl)); + if (qp.comp_mask | MLX5DV_QP_MASK_UAR_MMAP_OFFSET) { + tmpl->uar_mmap_offset = qp.uar_mmap_offset; + } else { + ERROR("Failed to retrieve UAR info, invalid libmlx5.so version"); + return EINVAL; + } + return 0; } @@ -557,3 +567,59 @@ mlx5_tx_queue_release(void *dpdk_txq) rte_free(txq_ctrl); priv_unlock(priv); } + + +/** + * Map locally UAR used in Tx queues for BlueFlame doorbell. + * + * @param[in] priv + * Pointer to private structure. + * @param fd + * Verbs file descriptor to map UAR pages. + * + * @return + * 0 on success, errno value on failure. + */ +int +priv_tx_uar_remap(struct priv *priv, int fd) +{ + unsigned int i, j; + uintptr_t pages[priv->txqs_n]; + unsigned int pages_n = 0; + uintptr_t uar_va; + void *addr; + struct txq *txq; + struct txq_ctrl *txq_ctrl; + int already_mapped; + size_t page_size = sysconf(_SC_PAGESIZE); + + /* + * As rdma-core, UARs are mapped in size of OS page size. + * Use aligned address to avoid duplicate mmap. + * Ref to libmlx5 function: mlx5_init_context() + */ + for (i = 0; i != priv->txqs_n; ++i) { + txq = (*priv->txqs)[i]; + txq_ctrl = container_of(txq, struct txq_ctrl, txq); + uar_va = (uintptr_t)txq_ctrl->txq.bf_reg; + uar_va = RTE_ALIGN_FLOOR(uar_va, page_size); + already_mapped = 0; + for (j = 0; j != pages_n; ++j) { + if (pages[j] == uar_va) { + already_mapped = 1; + break; + } + } + if (already_mapped) + continue; + pages[pages_n++] = uar_va; + addr = mmap((void *)uar_va, page_size, + PROT_WRITE, MAP_FIXED | MAP_SHARED, fd, + txq_ctrl->uar_mmap_offset); + if (addr != (void *)uar_va) { + ERROR("call to mmap failed on UAR for txq %d\n", i); + return -1; + } + } + return 0; +}