summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
Diffstat (limited to 'samples')
-rwxr-xr-xsamples/bpf/do_hbm_test.sh2
-rw-r--r--samples/bpf/hbm.c4
-rw-r--r--samples/bpf/tcp_cong_kern.c2
-rw-r--r--samples/bpf/tracex1.bpf.c2
-rw-r--r--samples/qmi/qmi_sample_client.c2
-rw-r--r--samples/vfio-mdev/mbochs.c71
-rw-r--r--samples/vfio-mdev/mdpy.c34
-rw-r--r--samples/vfio-mdev/mtty.c35
8 files changed, 44 insertions, 108 deletions
diff --git a/samples/bpf/do_hbm_test.sh b/samples/bpf/do_hbm_test.sh
index 38e4599350db..7f4f722787d5 100755
--- a/samples/bpf/do_hbm_test.sh
+++ b/samples/bpf/do_hbm_test.sh
@@ -112,7 +112,7 @@ function start_hbm () {
processArgs () {
for i in $args ; do
case $i in
- # Support for upcomming ingress rate limiting
+ # Support for upcoming ingress rate limiting
#in) # support for upcoming ingress rate limiting
# dir="-i"
# dir_name="in"
diff --git a/samples/bpf/hbm.c b/samples/bpf/hbm.c
index bf66277115e2..fc88d4dbdf48 100644
--- a/samples/bpf/hbm.c
+++ b/samples/bpf/hbm.c
@@ -5,7 +5,7 @@
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
- * Example program for Host Bandwidth Managment
+ * Example program for Host Bandwidth Management
*
* This program loads a cgroup skb BPF program to enforce cgroup output
* (egress) or input (ingress) bandwidth limits.
@@ -24,7 +24,7 @@
* beyond the rate limit specified while there is available
* bandwidth. Current implementation assumes there is only
* NIC (eth0), but can be extended to support multiple NICs.
- * Currrently only supported for egress.
+ * Currently only supported for egress.
* -h Print this info
* prog BPF program file name. Name defaults to hbm_out_kern.o
*/
diff --git a/samples/bpf/tcp_cong_kern.c b/samples/bpf/tcp_cong_kern.c
index 2311fc9dde85..339415eac477 100644
--- a/samples/bpf/tcp_cong_kern.c
+++ b/samples/bpf/tcp_cong_kern.c
@@ -5,7 +5,7 @@
* License as published by the Free Software Foundation.
*
* BPF program to set congestion control to dctcp when both hosts are
- * in the same datacenter (as deteremined by IPv6 prefix).
+ * in the same datacenter (as determined by IPv6 prefix).
*
* Use "bpftool cgroup attach $cg sock_ops $prog" to load this BPF program.
*/
diff --git a/samples/bpf/tracex1.bpf.c b/samples/bpf/tracex1.bpf.c
index 0ab39d76ff8f..ceedf0b1d479 100644
--- a/samples/bpf/tracex1.bpf.c
+++ b/samples/bpf/tracex1.bpf.c
@@ -20,7 +20,7 @@ SEC("kprobe.multi/__netif_receive_skb_core*")
int bpf_prog1(struct pt_regs *ctx)
{
/* attaches to kprobe __netif_receive_skb_core,
- * looks for packets on loobpack device and prints them
+ * looks for packets on loopback device and prints them
* (wildcard is used for avoiding symbol mismatch due to optimization)
*/
char devname[IFNAMSIZ];
diff --git a/samples/qmi/qmi_sample_client.c b/samples/qmi/qmi_sample_client.c
index b27d861f354f..d1814582319b 100644
--- a/samples/qmi/qmi_sample_client.c
+++ b/samples/qmi/qmi_sample_client.c
@@ -468,7 +468,7 @@ static int qmi_sample_probe(struct platform_device *pdev)
return ret;
sq = dev_get_platdata(&pdev->dev);
- ret = kernel_connect(sample->qmi.sock, (struct sockaddr *)sq,
+ ret = kernel_connect(sample->qmi.sock, (struct sockaddr_unsized *)sq,
sizeof(*sq), 0);
if (ret < 0) {
pr_err("failed to connect to remote service port\n");
diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
index 18623ba666e3..64ea19253ee3 100644
--- a/samples/vfio-mdev/mbochs.c
+++ b/samples/vfio-mdev/mbochs.c
@@ -143,11 +143,6 @@ static struct mdev_parent mbochs_parent;
static atomic_t mbochs_avail_mbytes;
static const struct vfio_device_ops mbochs_dev_ops;
-struct vfio_region_info_ext {
- struct vfio_region_info base;
- struct vfio_region_info_cap_type type;
-};
-
struct mbochs_mode {
u32 drm_format;
u32 bytepp;
@@ -1033,10 +1028,12 @@ static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf)
return 0;
}
-static int mbochs_get_region_info(struct mdev_state *mdev_state,
- struct vfio_region_info_ext *ext)
+static int mbochs_ioctl_get_region_info(struct vfio_device *vdev,
+ struct vfio_region_info *region_info,
+ struct vfio_info_cap *caps)
{
- struct vfio_region_info *region_info = &ext->base;
+ struct mdev_state *mdev_state =
+ container_of(vdev, struct mdev_state, vdev);
if (region_info->index >= MBOCHS_NUM_REGIONS)
return -EINVAL;
@@ -1061,20 +1058,23 @@ static int mbochs_get_region_info(struct mdev_state *mdev_state,
region_info->flags = (VFIO_REGION_INFO_FLAG_READ |
VFIO_REGION_INFO_FLAG_WRITE);
break;
- case MBOCHS_EDID_REGION_INDEX:
- ext->base.argsz = sizeof(*ext);
- ext->base.offset = MBOCHS_EDID_OFFSET;
- ext->base.size = MBOCHS_EDID_SIZE;
- ext->base.flags = (VFIO_REGION_INFO_FLAG_READ |
- VFIO_REGION_INFO_FLAG_WRITE |
- VFIO_REGION_INFO_FLAG_CAPS);
- ext->base.cap_offset = offsetof(typeof(*ext), type);
- ext->type.header.id = VFIO_REGION_INFO_CAP_TYPE;
- ext->type.header.version = 1;
- ext->type.header.next = 0;
- ext->type.type = VFIO_REGION_TYPE_GFX;
- ext->type.subtype = VFIO_REGION_SUBTYPE_GFX_EDID;
- break;
+ case MBOCHS_EDID_REGION_INDEX: {
+ struct vfio_region_info_cap_type cap_type = {
+ .header.id = VFIO_REGION_INFO_CAP_TYPE,
+ .header.version = 1,
+ .type = VFIO_REGION_TYPE_GFX,
+ .subtype = VFIO_REGION_SUBTYPE_GFX_EDID,
+ };
+
+ region_info->offset = MBOCHS_EDID_OFFSET;
+ region_info->size = MBOCHS_EDID_SIZE;
+ region_info->flags = (VFIO_REGION_INFO_FLAG_READ |
+ VFIO_REGION_INFO_FLAG_WRITE |
+ VFIO_REGION_INFO_FLAG_CAPS);
+
+ return vfio_info_add_capability(caps, &cap_type.header,
+ sizeof(cap_type));
+ }
default:
region_info->size = 0;
region_info->offset = 0;
@@ -1191,7 +1191,7 @@ static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd,
struct mdev_state *mdev_state =
container_of(vdev, struct mdev_state, vdev);
int ret = 0;
- unsigned long minsz, outsz;
+ unsigned long minsz;
switch (cmd) {
case VFIO_DEVICE_GET_INFO:
@@ -1215,30 +1215,6 @@ static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd,
return 0;
}
- case VFIO_DEVICE_GET_REGION_INFO:
- {
- struct vfio_region_info_ext info;
-
- minsz = offsetofend(typeof(info), base.offset);
-
- if (copy_from_user(&info, (void __user *)arg, minsz))
- return -EFAULT;
-
- outsz = info.base.argsz;
- if (outsz < minsz)
- return -EINVAL;
- if (outsz > sizeof(info))
- return -EINVAL;
-
- ret = mbochs_get_region_info(mdev_state, &info);
- if (ret)
- return ret;
-
- if (copy_to_user((void __user *)arg, &info, outsz))
- return -EFAULT;
-
- return 0;
- }
case VFIO_DEVICE_GET_IRQ_INFO:
{
@@ -1376,6 +1352,7 @@ static const struct vfio_device_ops mbochs_dev_ops = {
.read = mbochs_read,
.write = mbochs_write,
.ioctl = mbochs_ioctl,
+ .get_region_info_caps = mbochs_ioctl_get_region_info,
.mmap = mbochs_mmap,
.bind_iommufd = vfio_iommufd_emulated_bind,
.unbind_iommufd = vfio_iommufd_emulated_unbind,
diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c
index 8104831ae125..0759bd68edca 100644
--- a/samples/vfio-mdev/mdpy.c
+++ b/samples/vfio-mdev/mdpy.c
@@ -435,10 +435,13 @@ static int mdpy_mmap(struct vfio_device *vdev, struct vm_area_struct *vma)
return remap_vmalloc_range(vma, mdev_state->memblk, 0);
}
-static int mdpy_get_region_info(struct mdev_state *mdev_state,
- struct vfio_region_info *region_info,
- u16 *cap_type_id, void **cap_type)
+static int mdpy_ioctl_get_region_info(struct vfio_device *vdev,
+ struct vfio_region_info *region_info,
+ struct vfio_info_cap *caps)
{
+ struct mdev_state *mdev_state =
+ container_of(vdev, struct mdev_state, vdev);
+
if (region_info->index >= VFIO_PCI_NUM_REGIONS &&
region_info->index != MDPY_DISPLAY_REGION)
return -EINVAL;
@@ -544,30 +547,6 @@ static long mdpy_ioctl(struct vfio_device *vdev, unsigned int cmd,
return 0;
}
- case VFIO_DEVICE_GET_REGION_INFO:
- {
- struct vfio_region_info info;
- u16 cap_type_id = 0;
- void *cap_type = NULL;
-
- minsz = offsetofend(struct vfio_region_info, offset);
-
- if (copy_from_user(&info, (void __user *)arg, minsz))
- return -EFAULT;
-
- if (info.argsz < minsz)
- return -EINVAL;
-
- ret = mdpy_get_region_info(mdev_state, &info, &cap_type_id,
- &cap_type);
- if (ret)
- return ret;
-
- if (copy_to_user((void __user *)arg, &info, minsz))
- return -EFAULT;
-
- return 0;
- }
case VFIO_DEVICE_GET_IRQ_INFO:
{
@@ -665,6 +644,7 @@ static const struct vfio_device_ops mdpy_dev_ops = {
.read = mdpy_read,
.write = mdpy_write,
.ioctl = mdpy_ioctl,
+ .get_region_info_caps = mdpy_ioctl_get_region_info,
.mmap = mdpy_mmap,
.bind_iommufd = vfio_iommufd_emulated_bind,
.unbind_iommufd = vfio_iommufd_emulated_unbind,
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 59eefe2fed10..bd92c38379b8 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -624,7 +624,7 @@ static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state,
u8 lsr = 0;
mutex_lock(&mdev_state->rxtx_lock);
- /* atleast one char in FIFO */
+ /* at least one char in FIFO */
if (mdev_state->s[index].rxtx.head !=
mdev_state->s[index].rxtx.tail)
lsr |= UART_LSR_DR;
@@ -1717,10 +1717,12 @@ static int mtty_set_irqs(struct mdev_state *mdev_state, uint32_t flags,
return ret;
}
-static int mtty_get_region_info(struct mdev_state *mdev_state,
- struct vfio_region_info *region_info,
- u16 *cap_type_id, void **cap_type)
+static int mtty_ioctl_get_region_info(struct vfio_device *vdev,
+ struct vfio_region_info *region_info,
+ struct vfio_info_cap *caps)
{
+ struct mdev_state *mdev_state =
+ container_of(vdev, struct mdev_state, vdev);
unsigned int size = 0;
u32 bar_index;
@@ -1817,30 +1819,6 @@ static long mtty_ioctl(struct vfio_device *vdev, unsigned int cmd,
return 0;
}
- case VFIO_DEVICE_GET_REGION_INFO:
- {
- struct vfio_region_info info;
- u16 cap_type_id = 0;
- void *cap_type = NULL;
-
- minsz = offsetofend(struct vfio_region_info, offset);
-
- if (copy_from_user(&info, (void __user *)arg, minsz))
- return -EFAULT;
-
- if (info.argsz < minsz)
- return -EINVAL;
-
- ret = mtty_get_region_info(mdev_state, &info, &cap_type_id,
- &cap_type);
- if (ret)
- return ret;
-
- if (copy_to_user((void __user *)arg, &info, minsz))
- return -EFAULT;
-
- return 0;
- }
case VFIO_DEVICE_GET_IRQ_INFO:
{
@@ -1949,6 +1927,7 @@ static const struct vfio_device_ops mtty_dev_ops = {
.read = mtty_read,
.write = mtty_write,
.ioctl = mtty_ioctl,
+ .get_region_info_caps = mtty_ioctl_get_region_info,
.bind_iommufd = vfio_iommufd_emulated_bind,
.unbind_iommufd = vfio_iommufd_emulated_unbind,
.attach_ioas = vfio_iommufd_emulated_attach_ioas,