[v3 13/43] bus/fslmc: get MC VFIO group FD directly

Stephen Hemminger stephen at networkplumber.org
Tue Oct 15 04:27:26 CEST 2024


On Mon, 14 Oct 2024 17:30:56 +0530
vanshika.shukla at nxp.com wrote:

> +static int
> +fslmc_vfio_open_group_fd(int iommu_group_num)
> +{
> +	int vfio_group_fd;
> +	char filename[PATH_MAX];
> +	struct rte_mp_msg mp_req, *mp_rep;
> +	struct rte_mp_reply mp_reply = {0};
> +	struct timespec ts = {.tv_sec = 5, .tv_nsec = 0};
> +	struct vfio_mp_param *p = (struct vfio_mp_param *)mp_req.param;
> +
> +	/* if primary, try to open the group */
> +	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +		/* try regular group format */
> +		snprintf(filename, sizeof(filename),
> +			VFIO_GROUP_FMT, iommu_group_num);
> +		vfio_group_fd = open(filename, O_RDWR);
> +		if (vfio_group_fd <= 0) {
> +			DPAA2_BUS_ERR("Open VFIO group(%s) failed(%d)",
> +				filename, vfio_group_fd);
> +		}
> +
> +		return vfio_group_fd;
> +	}
> +	/* if we're in a secondary process, request group fd from the primary
> +	 * process via mp channel.
> +	 */
> +	p->req = SOCKET_REQ_GROUP;
> +	p->group_num = iommu_group_num;
> +	strcpy(mp_req.name, EAL_VFIO_MP);

Later versions of checkpatch complain that strcpy() should not be used.
Instead use strlcpy.



More information about the dev mailing list