[dpdk-dev] [PATCH v5 2/5] net/mlx5: install a socket to exchange a file descriptor

Ferruh Yigit ferruh.yigit at intel.com
Fri Oct 6 20:21:00 CEST 2017


On 10/6/2017 4:45 PM, Xueming Li wrote:
> Use a unix socket to get back the communication channel with the Kernel
> driver from the primary process, this is necessary to remap those pages
> in the secondary process memory space and thus use the same Tx queues.
> 
> This is only supported from rdma-core (v15).
> 
> Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro at 6wind.com>
> Signed-off-by: Xueming Li <xuemingl at mellanox.com>

<...>

> +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) {

ICC generates following warning [1], but it looks like false positive, I
will disable this warning for this file for ICC while applying, please
double check final commit.

[1]
.../drivers/net/mlx5/mlx5_txq.c(608): error #3656: variable "pages" may
be used before its value is set
                        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;
> +}
> 



More information about the dev mailing list