Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp698969pxp; Fri, 11 Mar 2022 12:42:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwomQO1oAdQzXjo70mFf/z6ldlWk9nzCQAcncB5mfedcFcrM054erklBEhewXY3YXQ5JCnc X-Received: by 2002:a05:6a00:16d6:b0:4e0:ed6a:cf82 with SMTP id l22-20020a056a0016d600b004e0ed6acf82mr11795736pfc.9.1647031372654; Fri, 11 Mar 2022 12:42:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647031372; cv=none; d=google.com; s=arc-20160816; b=jcXQX4yI6w4TXkDIQrbOvF8Cx86stJBmaJKtjmQCcVxQ6kuFYe9ieDLUwqhwk8KTCU vOc29mEr1ZcihD9S5r74RuZcce5yPgBBPhiuDNeVz3L6eSPRnXYlGVDmwSytzbmAdkkv 0/Fr0DYqL/U/yDsR4lsH/q8JgU+ALvO+GVHxknsoMh5tB8lhlz6PqDcpTPUvPctGwo+X n8wslHnUgor19HuEqG0HLwzFI8Mubbi7xQl9rnJq2yIJmUsCHMxLfsMp9e//EE/hH7CD jyjbU1TPWgNRGZNmGsXYPQIWrU2VlqqQGI4sLttftpKuQPITcSQHmY8O+D1Pv8Z99Bz/ Q5Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=51hVhO0ua5q/6tYldbvzr8zpARPuG1zFVMo4yCGRPsg=; b=cfZJ65QN8GeaMe50h7Hwhd1aysq3DL56rMG4MGa567OvlkuqGvFEASBx0LVseWILrA kFGSoAmQmyg01AgrHQkawtNQYyrqT5NGhENhsModMC8FJsynlId9NKMTFnydqo8JvdYM KvvGII7hP3f4/rixz2lxcZe3JGe9iEkaEcSQKwVF9CRduVZUuldLzZ5u3yo5c9gsey0n TGHLI5H2ld2TZWGyAuA7x856qwiQBoUebdeR4bpREyv9MEI3PQowDemzsaT6qCfV04qH +O0xz1cTZIbRdBRUqMsYFbFAg2JrpeEkYo5Qc4fn1JPFzkSg7bWjLF6PJoGdc0YSYI23 Xfew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WyhnZrW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h63-20020a638342000000b00380bc91e048si8123917pge.711.2022.03.11.12.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 12:42:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WyhnZrW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4FBAE1D982A; Fri, 11 Mar 2022 12:39:52 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344734AbiCKAv0 (ORCPT + 99 others); Thu, 10 Mar 2022 19:51:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235560AbiCKAvY (ORCPT ); Thu, 10 Mar 2022 19:51:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1FE12627; Thu, 10 Mar 2022 16:50:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 50EB5B829A1; Fri, 11 Mar 2022 00:50:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0BD5C340EC; Fri, 11 Mar 2022 00:50:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646959820; bh=IO8rAexqJOVECI+Go6BBgSARYGGCV+CVeaztQWwxRWs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=WyhnZrW4xMPh7AwOByOMM+BFl4aXfTzLqB1YRjo3juB+vJ2k0nsTR+azxWVU7tWFP R5d/R1PfsI0ypQg8RsUa5S7X58+Q4tGqnFYjDzJLAdgWcfUnpgw9JzNDObQdjY3e0u tyM8XFJT7sltSIoLtm44tGez9MYaI3UuRQRmdu36FUwmJH4K7aUh5Mw+45TDQDSXg+ h9fK60U45QlYvW5TXmbUh8tAYLnN/MuJMWJ4k9s2/ibSVz79ejwiO+NTYRe/hYYSSw 6kqcrxLV/D4pm5BCec7v6PDXaj833bN7NeZHRqBJdzVR4Xh2F6elhbSbBTedMNhoEB 8LeeZ0VgGTNKA== Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-2dc348dab52so77794617b3.6; Thu, 10 Mar 2022 16:50:19 -0800 (PST) X-Gm-Message-State: AOAM530vjtoHg0d4EG0Hh9DDd0FyJFd7D7tU4dLKnqs5qllkG58wuAt0 6rq5XiY9yZoX2eDrNZk7+TCSqa8gLdbygdpEui4= X-Received: by 2002:a0d:fb45:0:b0:2d0:d09a:576c with SMTP id l66-20020a0dfb45000000b002d0d09a576cmr6515180ywf.447.1646959819038; Thu, 10 Mar 2022 16:50:19 -0800 (PST) MIME-Version: 1.0 References: <20220304172852.274126-1-benjamin.tissoires@redhat.com> <20220304172852.274126-20-benjamin.tissoires@redhat.com> In-Reply-To: <20220304172852.274126-20-benjamin.tissoires@redhat.com> From: Song Liu Date: Thu, 10 Mar 2022 16:50:07 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 19/28] bpf/hid: add bpf_hid_raw_request helper function To: Benjamin Tissoires Cc: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer , Tero Kristo , open list , "open list:HID CORE LAYER" , Networking , bpf , linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 4, 2022 at 9:35 AM Benjamin Tissoires 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 > > --- > > 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), \ > /* */ [...]