[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW6Jd_A7J8QQTqDZt9hwcy_Cnqm=9-+9qQ6-KTkLRT8NAA@mail.gmail.com>
Date: Thu, 10 Mar 2022 16:50:07 -0800
From: Song Liu <song@...nel.org>
To: Benjamin Tissoires <benjamin.tissoires@...hat.com>
Cc: Greg KH <gregkh@...uxfoundation.org>,
Jiri Kosina <jikos@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Shuah Khan <shuah@...nel.org>,
Dave Marchevsky <davemarchevsky@...com>,
Joe Stringer <joe@...ium.io>,
Tero Kristo <tero.kristo@...ux.intel.com>,
open list <linux-kernel@...r.kernel.org>,
"open list:HID CORE LAYER" <linux-input@...r.kernel.org>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
linux-kselftest@...r.kernel.org
Subject: Re: [PATCH bpf-next v2 19/28] bpf/hid: add bpf_hid_raw_request helper function
On Fri, Mar 4, 2022 at 9:35 AM Benjamin Tissoires
<benjamin.tissoires@...hat.com> wrote:
>
> When we are in a user_event context, we can talk to the device to fetch
> or set features/outputs/inputs reports.
> Add a bpf helper to do so. This helper is thus only available to
> user_events, because calling this function while in IRQ context (any
> other BPF type) is forbidden.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@...hat.com>
>
> ---
>
> changes in v2:
> - split the series by bpf/libbpf/hid/selftests and samples
> ---
> include/linux/bpf-hid.h | 2 ++
> include/uapi/linux/bpf.h | 8 ++++++++
> kernel/bpf/hid.c | 26 ++++++++++++++++++++++++++
> tools/include/uapi/linux/bpf.h | 8 ++++++++
> 4 files changed, 44 insertions(+)
>
> diff --git a/include/linux/bpf-hid.h b/include/linux/bpf-hid.h
> index 4cf2e99109fe..bd548f6a4a26 100644
> --- a/include/linux/bpf-hid.h
> +++ b/include/linux/bpf-hid.h
> @@ -100,6 +100,8 @@ struct bpf_hid_hooks {
> u64 offset, u32 n, u8 *data, u64 data_size);
> int (*hid_set_data)(struct hid_device *hdev, u8 *buf, size_t buf_size,
> u64 offset, u32 n, u8 *data, u64 data_size);
> + int (*hid_raw_request)(struct hid_device *hdev, u8 *buf, size_t size,
> + u8 rtype, u8 reqtype);
> };
>
> #ifdef CONFIG_BPF
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index b3063384d380..417cf1c31579 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -5121,6 +5121,13 @@ union bpf_attr {
> * Return
> * The length of data copied into ctx->event.data. On error, a negative
> * value is returned.
> + *
> + * int bpf_hid_raw_request(void *ctx, void *buf, u64 size, u8 rtype, u8 reqtype)
> + * Description
> + * communicate with the HID device
I think we need more description here, e.g. what are rtype and reqtype here?
> + * Return
> + * 0 on success.
> + * negative value on error.
> */
> #define __BPF_FUNC_MAPPER(FN) \
> FN(unspec), \
> @@ -5317,6 +5324,7 @@ union bpf_attr {
> FN(copy_from_user_task), \
> FN(hid_get_data), \
> FN(hid_set_data), \
> + FN(hid_raw_request), \
> /* */
[...]
Powered by blists - more mailing lists