-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vfio-ccw: Introduce a new schib region
The schib region can be used by userspace to get the subchannel- information block (SCHIB) for the passthrough subchannel. This can be useful to get information such as channel path information via the SCHIB.PMCW fields. Signed-off-by: Farhan Ali <alifm@linux.ibm.com> Signed-off-by: Eric Farman <farman@linux.ibm.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <20200505122745.53208-5-farman@linux.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
- Loading branch information
Farhan Ali
authored and
Cornelia Huck
committed
Jun 2, 2020
1 parent
600279b
commit 24c9867
Showing
8 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Channel path related status regions for vfio_ccw | ||
* | ||
* Copyright IBM Corp. 2020 | ||
* | ||
* Author(s): Farhan Ali <alifm@linux.ibm.com> | ||
* Eric Farman <farman@linux.ibm.com> | ||
*/ | ||
|
||
#include <linux/vfio.h> | ||
#include "vfio_ccw_private.h" | ||
|
||
static ssize_t vfio_ccw_schib_region_read(struct vfio_ccw_private *private, | ||
char __user *buf, size_t count, | ||
loff_t *ppos) | ||
{ | ||
unsigned int i = VFIO_CCW_OFFSET_TO_INDEX(*ppos) - VFIO_CCW_NUM_REGIONS; | ||
loff_t pos = *ppos & VFIO_CCW_OFFSET_MASK; | ||
struct ccw_schib_region *region; | ||
int ret; | ||
|
||
if (pos + count > sizeof(*region)) | ||
return -EINVAL; | ||
|
||
mutex_lock(&private->io_mutex); | ||
region = private->region[i].data; | ||
|
||
if (cio_update_schib(private->sch)) { | ||
ret = -ENODEV; | ||
goto out; | ||
} | ||
|
||
memcpy(region, &private->sch->schib, sizeof(*region)); | ||
|
||
if (copy_to_user(buf, (void *)region + pos, count)) { | ||
ret = -EFAULT; | ||
goto out; | ||
} | ||
|
||
ret = count; | ||
|
||
out: | ||
mutex_unlock(&private->io_mutex); | ||
return ret; | ||
} | ||
|
||
static ssize_t vfio_ccw_schib_region_write(struct vfio_ccw_private *private, | ||
const char __user *buf, size_t count, | ||
loff_t *ppos) | ||
{ | ||
return -EINVAL; | ||
} | ||
|
||
|
||
static void vfio_ccw_schib_region_release(struct vfio_ccw_private *private, | ||
struct vfio_ccw_region *region) | ||
{ | ||
|
||
} | ||
|
||
const struct vfio_ccw_regops vfio_ccw_schib_region_ops = { | ||
.read = vfio_ccw_schib_region_read, | ||
.write = vfio_ccw_schib_region_write, | ||
.release = vfio_ccw_schib_region_release, | ||
}; | ||
|
||
int vfio_ccw_register_schib_dev_regions(struct vfio_ccw_private *private) | ||
{ | ||
return vfio_ccw_register_dev_region(private, | ||
VFIO_REGION_SUBTYPE_CCW_SCHIB, | ||
&vfio_ccw_schib_region_ops, | ||
sizeof(struct ccw_schib_region), | ||
VFIO_REGION_INFO_FLAG_READ, | ||
private->schib_region); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters