src/dpdk/drivers/bus/vmbus/linux/vmbus_bus.c
int
rte_vmbus_map_device(struct rte_vmbus_device *dev)
{
	char uioname[PATH_MAX], filename[PATH_MAX];
	char dirname[PATH_MAX], mapname[64];
	int i;

	dev->uio_num = vmbus_get_uio_dev(dev, uioname, sizeof(uioname));
	if (dev->uio_num < 0) {
		VMBUS_LOG(DEBUG, "Not managed by UIO driver, skipped");
		return 1;
	}

	/* Extract resource value */
	for (i = 0; i < VMBUS_MAX_RESOURCE; i++) {
		struct rte_mem_resource *res = &dev->resource[i];
		unsigned long len, gpad = 0;
		char *cp;

		snprintf(dirname, sizeof(dirname),
			 "%s/maps/map%d", uioname, i);

		snprintf(filename, sizeof(filename),
			 "%s/name", dirname);

		if (get_sysfs_string(filename, mapname, sizeof(mapname)) < 0) {
			VMBUS_LOG(ERR, "could not read %s", filename);
			return -1;
		}

		if (strncmp(map_names[i], mapname, strlen(map_names[i])) != 0) {
			VMBUS_LOG(ERR,
				"unexpected resource %s (expected %s)",
				mapname, map_names[i]);
			return -1;
		}

		snprintf(filename, sizeof(filename),
			 "%s/size", dirname);
		if (eal_parse_sysfs_value(filename, &len) < 0) {
			VMBUS_LOG(ERR,
				"could not read %s", filename);
			return -1;
		}
		res->len = len;

		/* both send and receive buffers have gpad in name */
		cp = memchr(mapname, ':', sizeof(mapname));
		if (cp)
			gpad = strtoul(cp+1, NULL, 0);

		/* put the GPAD value in physical address */
		res->phys_addr = gpad;
	}

	return vmbus_uio_map_resource(dev);
}
/* map the resources of a vmbus device in virtual memory */
map the resources of a vmbus device in virtual memory
map the resources of a vmbus device in virtual memory
int
rte_vmbus_map_device(struct rte_vmbus_device *dev)
{
	char uioname[PATH_MAX], filename[PATH_MAX];
	char dirname[PATH_MAX], mapname[64];
	int i;
	dev->uio_num = vmbus_get_uio_dev(dev, uioname, sizeof(uioname));
	if (dev->uio_num < 0) {
		VMBUS_LOG(DEBUG, "Not managed by UIO driver, skipped");
		return 1;
	}
	for (i = 0; i < VMBUS_MAX_RESOURCE; i++) {
		struct rte_mem_resource *res = &dev->resource[i];
		unsigned long len, gpad = 0;
		char *cp;
		snprintf(dirname, sizeof(dirname),
			 "%s/maps/map%d", uioname, i);
		snprintf(filename, sizeof(filename),
			 "%s/name", dirname);
		if (get_sysfs_string(filename, mapname, sizeof(mapname)) < 0) {
			VMBUS_LOG(ERR, "could not read %s", filename);
			return -1;
		}
		if (strncmp(map_names[i], mapname, strlen(map_names[i])) != 0) {
			VMBUS_LOG(ERR,
				"unexpected resource %s (expected %s)",
				mapname, map_names[i]);
			return -1;
		}
		snprintf(filename, sizeof(filename),
			 "%s/size", dirname);
		if (eal_parse_sysfs_value(filename, &len) < 0) {
			VMBUS_LOG(ERR,
				"could not read %s", filename);
			return -1;
		}
		res->len = len;
		cp = memchr(mapname, ':', sizeof(mapname));
		if (cp)
			gpad = strtoul(cp+1, NULL, 0);
		res->phys_addr = gpad;
	}
	return vmbus_uio_map_resource(dev);
}
int rte_vmbus_map_device ( struct rte_vmbus_device * dev ) { char uioname [ PATH_MAX ] , filename [ PATH_MAX ] ; char dirname [ PATH_MAX ] , mapname [ 64 ] ; int i ; dev -> uio_num = vmbus_get_uio_dev ( dev , uioname , sizeof ( uioname ) ) ; if ( dev -> uio_num < 0 ) { VMBUS_LOG ( DEBUG , " " ) ; return 1 ; } for ( i = 0 ; i < VMBUS_MAX_RESOURCE ; i ++ ) { struct rte_mem_resource * res = & dev -> resource [ i ] ; unsigned long len , gpad = 0 ; char * cp ; snprintf ( dirname , sizeof ( dirname ) , " " , uioname , i ) ; snprintf ( filename , sizeof ( filename ) , " " , dirname ) ; if ( get_sysfs_string ( filename , mapname , sizeof ( mapname ) ) < 0 ) { VMBUS_LOG ( ERR , " " , filename ) ; return -1 ; } if ( strncmp ( map_names [ i ] , mapname , strlen ( map_names [ i ] ) ) != 0 ) { VMBUS_LOG ( ERR , " " , mapname , map_names [ i ] ) ; return -1 ; } snprintf ( filename , sizeof ( filename ) , " " , dirname ) ; if ( eal_parse_sysfs_value ( filename , & len ) < 0 ) { VMBUS_LOG ( ERR , " " , filename ) ; return -1 ; } res -> len = len ; cp = memchr ( mapname , ' ' , sizeof ( mapname ) ) ; if ( cp ) gpad = strtoul ( cp + 1 , NULL , 0 ) ; res -> phys_addr = gpad ; } return vmbus_uio_map_resource ( dev ) ; }
map the resources of a vmbus device in virtual memory
map the resources of a vmbus device in virtual memory
/* Extract resource value */ /* both send and receive buffers have gpad in name */ /* put the GPAD value in physical address */