[openib-general] Re: [PATCH 8 of 18] ipath - sysfs and ipathfs support for core driver

Michael S. Tsirkin mst at mellanox.co.il
Wed Mar 22 22:30:49 PST 2006


Quoting r. Bryan O'Sullivan <bos at pathscale.com>:
> Subject: [PATCH 8 of 18] ipath - sysfs and ipathfs support for core driver
> 
> The ipathfs filesystem contains files that are not appropriate for
> sysfs, because they contain binary data.  The hierarchy is simple; the
> top-level directory contains driver-wide attribute files, while numbered
> subdirectories contain per-device attribute files.
> 
> Signed-off-by: Bryan O'Sullivan <bos at pathscale.com>


.....

> +static ssize_t atomic_node_info_read(struct file *file, char __user *buf,
> +				     size_t count, loff_t *ppos)
> +{
> +	u32 nodeinfo[10];
> +	struct ipath_devdata *dd;
> +
> +	dd = file->f_dentry->d_inode->u.generic_ip;
> +
> +	nodeinfo[0] =			/* BaseVersion is SMA */
> +		/* ClassVersion is SMA */
> +		(1 << 8)		/* NodeType  */
> +		| (1 << 0);		/* NumPorts */
> +	nodeinfo[1] = (u32) (dd->ipath_guid >> 32);
> +	nodeinfo[2] = (u32) (dd->ipath_guid & 0xffffffff);
> +	/* PortGUID == SystemImageGUID for us */
> +	nodeinfo[3] = nodeinfo[1];
> +	/* PortGUID == SystemImageGUID for us */
> +	nodeinfo[4] = nodeinfo[2];
> +	/* PortGUID == NodeGUID for us */
> +	nodeinfo[5] = nodeinfo[3];
> +	/* PortGUID == NodeGUID for us */
> +	nodeinfo[6] = nodeinfo[4];
> +	nodeinfo[7] = (4 << 16) /* we support 4 pkeys */
> +		| (dd->ipath_deviceid << 0);
> +	/* our chip version as 16 bits major, 16 bits minor */
> +	nodeinfo[8] = dd->ipath_minrev | (dd->ipath_majrev << 16);
> +	nodeinfo[9] = (dd->ipath_unit << 24) | (dd->ipath_vendorid << 0);
> +
> +	return simple_read_from_buffer(buf, count, ppos, nodeinfo,
> +				       sizeof nodeinfo);

InfiniBand core already exposes these attributes to userspace, see
drivers/infiniband/core/sysfs.c

-- 
Michael S. Tsirkin
Staff Engineer, Mellanox Technologies



More information about the general mailing list