Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp112825pxp; Fri, 4 Mar 2022 23:12:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGqSljVExJaCDzTOu4H98iQHHYK5G7OIKadWmcoL+GVoVmGUTWu4flhzmVE4WV+Cisz9xf X-Received: by 2002:a17:902:eccf:b0:151:6a35:8498 with SMTP id a15-20020a170902eccf00b001516a358498mr2346336plh.131.1646464330990; Fri, 04 Mar 2022 23:12:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646464330; cv=none; d=google.com; s=arc-20160816; b=oS4PaWLAD4uCq4y+aOnKk7WZISNepESwnluGxODI+bsB1BwDDvd0gDbFlU/616jR9i GRULUhB3AcfvITDs5iDdMb4v9hqmBx/FfQjJZzgAC986zej/I8k28X+47C+4koYtcyKp yeBkrRkdHMLO15oJ1IffYm24UpS1Ab47bWgxT2J6bdGj+ol37yQ7wy/OJUyp8oII2MZN ETm3GoB7dp+3AR6SVt/bVg0b66dswbaYpWjgmXcp4sq02ZE56JCG50W6nV5cR1bLsQqW c6sZ/AzjjRMm2pDWldAScttDJauBb2yeaI1DYs4hC72wn0CcTzfccQ2Gs3EwLA/xzLz/ y0ZA== 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=UE8I6G1wfbrR6BPyvi06EUA8ZWwMg/puYPGng2LHoto=; b=Y8fnnVqZvoPoHo9R8RLwDMiX1sK6tHmzQBnDnSIn9SreBKorxvMNePKrvUbjQdqaP0 2nGQgtGg+mcqJZbPkVFCReQ1t7DrUiQHmAR6X4X7ASZQRnwaieMNnLZu0dd49Td1O0yQ AUqBlzIkXcA3KlKbtbjeo3iRDTQaHm0mU5fBLU+KM5SLbLuY4s7PU/Rww/FW8uvQ0Vjl sH4xrZzTbnAgqOPHwZaMXGsaxDfzyj6Ct6qbEfMVgOgr5RMmwpmaze3KnjOO8cb9qjMq S/4RdktRwmduXKnAjDrVdaLveQXTcBxjsXpCluSBz1fdhbZklo1zyKVYwP/ojxZeJDUN swsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NFihrsXc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020a63470c000000b0037425262ed6si6596818pga.358.2022.03.04.23.11.45; Fri, 04 Mar 2022 23:12:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NFihrsXc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbiCEAcP (ORCPT + 99 others); Fri, 4 Mar 2022 19:32:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229589AbiCEAcN (ORCPT ); Fri, 4 Mar 2022 19:32:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F9BECE91E; Fri, 4 Mar 2022 16:31:25 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E941C61F4A; Sat, 5 Mar 2022 00:31:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54163C340F0; Sat, 5 Mar 2022 00:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646440284; bh=awRIwbysAAAcaXhf9r6G70yV9eNUMtyfdpt6cG+WdS4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NFihrsXcizDRGkyxR3Cg8awQAmkhhYtn0duiPuoXhota0ipzzUhn0yIn1mBzEff/z lYSENiDeC1aSvAozEsWcLonBQoLmwjVnsusZmchqpphq73olCMv8xLDYP3QBOefsMZ MAbKYdMeDjdCecydm+LAf7EnOwEE2BIoIB1d7q7mZ+03q3qGfKoPAAM5YEF+URMYEu eDh9hcN5B+BgMM42Zf8YyBIekByZ7I0WQEvhF3HEU/GAONPC+qkgVlTqicNjptUXkx lnbaxgOJWuAM4jKtf5q98skl8kVSVfV/UFjSL5U6MnfPgtguZC1hA1eBwugEgEfK2a Ha+p1aGLhWxmg== Received: by mail-yb1-f182.google.com with SMTP id u10so237377ybd.9; Fri, 04 Mar 2022 16:31:24 -0800 (PST) X-Gm-Message-State: AOAM532hF4FQd+XySXHlgCbIMUMbQctUrbc0ehJa/S6UcmQyDpccTJmP aEoY6GGCmJIP9sVwG8GgCjYml/DJ6FA1RHGcCUc= X-Received: by 2002:a05:6902:1ca:b0:624:e2a1:2856 with SMTP id u10-20020a05690201ca00b00624e2a12856mr946847ybh.389.1646440283308; Fri, 04 Mar 2022 16:31:23 -0800 (PST) MIME-Version: 1.0 References: <20220304172852.274126-1-benjamin.tissoires@redhat.com> <20220304172852.274126-5-benjamin.tissoires@redhat.com> In-Reply-To: <20220304172852.274126-5-benjamin.tissoires@redhat.com> From: Song Liu Date: Fri, 4 Mar 2022 16:31:12 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 04/28] libbpf: add HID program type and API 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=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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:31 AM Benjamin Tissoires wrote: > > HID-bpf program type are needing a new SEC. > To bind a hid-bpf program, we can rely on bpf_program__attach_fd() > so export a new function to the API. > > Signed-off-by: Benjamin Tissoires Acked-by: Song Liu > > --- > > changes in v2: > - split the series by bpf/libbpf/hid/selftests and samples > --- > tools/lib/bpf/libbpf.c | 7 +++++++ > tools/lib/bpf/libbpf.h | 2 ++ > tools/lib/bpf/libbpf.map | 1 + > 3 files changed, 10 insertions(+) > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 81bf01d67671..356bbd3ad2c7 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -8680,6 +8680,7 @@ static const struct bpf_sec_def section_defs[] = { > SEC_DEF("cgroup/setsockopt", CGROUP_SOCKOPT, BPF_CGROUP_SETSOCKOPT, SEC_ATTACHABLE | SEC_SLOPPY_PFX), > SEC_DEF("struct_ops+", STRUCT_OPS, 0, SEC_NONE), > SEC_DEF("sk_lookup", SK_LOOKUP, BPF_SK_LOOKUP, SEC_ATTACHABLE | SEC_SLOPPY_PFX), > + SEC_DEF("hid/device_event", HID, BPF_HID_DEVICE_EVENT, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX), > }; > > #define MAX_TYPE_NAME_SIZE 32 > @@ -10659,6 +10660,12 @@ static struct bpf_link *attach_iter(const struct bpf_program *prog, long cookie) > return bpf_program__attach_iter(prog, NULL); > } > > +struct bpf_link * > +bpf_program__attach_hid(const struct bpf_program *prog, int hid_fd) > +{ > + return bpf_program__attach_fd(prog, hid_fd, 0, "hid"); > +} > + > struct bpf_link *bpf_program__attach(const struct bpf_program *prog) > { > if (!prog->sec_def || !prog->sec_def->attach_fn) > diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h > index c8d8daad212e..f677ac0a9ede 100644 > --- a/tools/lib/bpf/libbpf.h > +++ b/tools/lib/bpf/libbpf.h > @@ -529,6 +529,8 @@ struct bpf_iter_attach_opts { > LIBBPF_API struct bpf_link * > bpf_program__attach_iter(const struct bpf_program *prog, > const struct bpf_iter_attach_opts *opts); > +LIBBPF_API struct bpf_link * > +bpf_program__attach_hid(const struct bpf_program *prog, int hid_fd); > > /* > * Libbpf allows callers to adjust BPF programs before being loaded > diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map > index 47e70c9058d9..fdc6fa743953 100644 > --- a/tools/lib/bpf/libbpf.map > +++ b/tools/lib/bpf/libbpf.map > @@ -424,6 +424,7 @@ LIBBPF_0.6.0 { > LIBBPF_0.7.0 { > global: > bpf_btf_load; > + bpf_program__attach_hid; > bpf_program__expected_attach_type; > bpf_program__log_buf; > bpf_program__log_level; > -- > 2.35.1 >