[PATCH v17 07/11] common/sxe2: add ioctl interface for DMA map and unmap

Stephen Hemminger stephen at networkplumber.org
Tue May 19 19:41:42 CEST 2026


On Tue, 19 May 2026 11:01:28 +0800
liujie5 at linkdatatechnology.com wrote:

> +RTE_EXPORT_INTERNAL_SYMBOL(sxe2_drv_dev_dma_unmap)
> +int32_t
> +sxe2_drv_dev_dma_unmap(struct sxe2_common_device *cdev, uint64_t iova)
> +{
> +	int32_t ret = 0;
> +	int32_t cmd_fd = 0;
> +	struct sxe2_ioctl_iommu_dma_unmap cmd_params;
> +
> +	if (cdev->config.kernel_reset) {
> +		ret = -EPERM;
> +		PMD_LOG_WARN(COM, "kernel reset, need restart app.");
> +		goto l_end;
> +	}
> +
> +	if (!cdev->config.support_iommu)
> +		goto l_end;
> +
> +	cmd_fd = SXE2_CDEV_TO_CMD_FD(cdev);
> +	if (cmd_fd < 0) {
> +		ret = -EBADF;
> +		PMD_LOG_ERR(COM, "Failed to exec cmd, fd=%d", cmd_fd);
> +		goto l_end;
> +	}
> +
> +	PMD_LOG_DEBUG(COM, "fd %d dma unmap iova=0x%"PRIX64"",
> +		cmd_fd, iova);
> +
> +	memset(&cmd_params, 0, sizeof(struct sxe2_ioctl_iommu_dma_unmap));
> +	cmd_params.iova = iova;
> +
> +	(void)pthread_mutex_lock(&cdev->config.lock);
> +	ret = ioctl(cmd_fd, SXE2_COM_CMD_DMA_UNMAP, &cmd_params);
> +	if (ret < 0) {
> +		PMD_LOG_INFO(COM, "Failed to dma unmap, fd=%d, ret=%d, err:%s",
> +				cmd_fd, ret, strerror(errno));
> +		ret = -EIO;
> +		(void)pthread_mutex_unlock(&cdev->config.lock);
> +		goto l_end;
> +	}
> +	(void)pthread_mutex_unlock(&cdev->config.lock);
> +
> +l_end:
> +	return ret;
> +}
> +

You shouldn't need the cast void cast around pthread_mutex_lock/unlock;
other drivers don't do that.

Also, git complains about this when doing merge.
Applying: common/sxe2: add ioctl interface for DMA map and unmap
/home/shemminger/DPDK/main/.git/worktrees/sxe2/rebase-apply/patch:192: new blank line at EOF.
+



More information about the dev mailing list