Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp38923imm; Fri, 25 May 2018 13:47:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpbBjtJCN0qpq0gMEheM52K928dVvhh/d3kqFXrMKvi+RvBd4yx8vpxzqF4i6Nt2FEMP7db X-Received: by 2002:a62:62c2:: with SMTP id w185-v6mr4047699pfb.78.1527281251563; Fri, 25 May 2018 13:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527281251; cv=none; d=google.com; s=arc-20160816; b=yjSvYdPtFixPll2INKn8r90ohIUOAL0a+BvF4p0xJDu1GrN4F7cT4Ogo2tOr0t2o2g mmH5ZYGkNbnWLyinTfgSdds7/pBUEfXbgkdTBGvQPI0hyxGBoOmYBluofYgh2sisMD2J 6HwZu4BQ+r3gPnhDEClMHGs8XY5DPctq39YV7B7tMCfkYeO+GmhpSZEcJv6p/3N/qX2C B0RAs9GIaWZBXBwZ9uwsrpyfRUONgFzCAFUJfCt0VV+GEGmTwPEbw5uE+hhaUW+YH+l5 tapKa++LhYGC8Lav9Bo5HWF1acQHNHmWQiSyEqH3DfxGvy1oqNhZaS1dFq0a6+fReDCv 3W/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=0OZYXn53lOgajTEBfkOnS/g8rYNgmXBEWWGuiWUcVeU=; b=NdZ8WSf0LgFzyY4bp+rVC3SsFLMhGhzD18pgEtKajT2uV0hgluEqu3/wJi7Vo39tXb GBOq+FnwgZ7sU5EEsLL3KQvYA/PqV6InvTf9QILt+xZiknYd1Oqsv99w8vhN55L4LPnb X6rd6fWDV1FirVuF6cy8mIE/hIp8NiQl79EJqnfqMCAtrgSw4kvpHzy8PPPBr22xQD9X O3d6zTLyp5v4wa9jV3zTm7N5r4YnmkfOdkHgx6FnXQ80LMp65cf0vHtnBrIofkB+WQJ1 kPlE6utPx3r4AP+OBg5kk8QdrYyWmubleL/mmpiI1hbuEapEBP1N5NJtykpf/9qIiYGe 69UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HBrLJQtU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10-v6si1648982pla.53.2018.05.25.13.47.17; Fri, 25 May 2018 13:47:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HBrLJQtU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968466AbeEYUpS (ORCPT + 99 others); Fri, 25 May 2018 16:45:18 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:40796 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968275AbeEYUpP (ORCPT ); Fri, 25 May 2018 16:45:15 -0400 Received: by mail-pl0-f66.google.com with SMTP id t12-v6so3778206plo.7; Fri, 25 May 2018 13:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=0OZYXn53lOgajTEBfkOnS/g8rYNgmXBEWWGuiWUcVeU=; b=HBrLJQtUWk5LFg5XaDClKjT8YY4x6MwyMswhqI96NG0PgKq1Kp7DesVUA0UozJBdz1 qx75seRfo2ziLhe17oNHbYnmEGPcrjSP+NvS8jclGQP+rEOtvR20nYoQ3j32wJxiLA8Y sW6SQ2tzhxpADOFmTNhH8mWnIAZDLESK3aaPAaFDffFilweic691gbohNRsZaBu3wlgx qixtUaseQj2fl9idyYIVVVKQQBn4zUbb/KVu3l/Hv1fwHtlNGazawpjpT9WJH+JY0shj KpinPePdE9rkeWvG4crUvauMe0SrVspJlHyF9dsKK6cj2tw6ZMLpy81uFIfMXSZyOvCL rqgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=0OZYXn53lOgajTEBfkOnS/g8rYNgmXBEWWGuiWUcVeU=; b=N+3loyE6kOBJsYtJqVSeeaIHNno+mE6S9isg//Ec4AGDS7ZUiEh4yRRsNvIs5Qn0Ca hg9WGPSDQIyYmv39yDCzVSPBj67OyIuJ4nEGZroW+rIk6ULxgfSEdj9KHEezQrUt9h3J 6qOHRNmhdjBFkgQ6W5sM8HAM17z4moexPHZMcpkl4K8p8wEaPWmbebFo5iBmqNvJbSwb sfojayF64k1mlcHzP2WDUcQTnz18d+WjsyV92zjsNTIGmQhS7POPMfdHYWlW1BTB2DyT IjqEMCU41Zf4vySlndcP0xLp0RH5Hf7Egmlu3MnsWzsgMTN9HGZUbbcJdUqKZ5Nj4Ldl HoBg== X-Gm-Message-State: ALKqPwc4MzWntxGWwnQ/1/k6qZ9st8NUTjBLmE9ndrht2xPLiM7gpd3r h952pyvXZ1+3a8JOJBnzjesIpeAW X-Received: by 2002:a17:902:b216:: with SMTP id t22-v6mr365851plr.199.1527281114723; Fri, 25 May 2018 13:45:14 -0700 (PDT) Received: from ast-mbp ([2620:10d:c090:180::1:a20f]) by smtp.gmail.com with ESMTPSA id d71-v6sm40329781pfd.48.2018.05.25.13.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 13:45:13 -0700 (PDT) Date: Fri, 25 May 2018 13:45:11 -0700 From: Alexei Starovoitov To: Sean Young Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Mauro Carvalho Chehab , Daniel Borkmann , netdev@vger.kernel.org, Matthias Reichl , Devin Heitmueller , Y Song , Quentin Monnet Subject: Re: [PATCH v4 2/3] media: rc: introduce BPF_PROG_LIRC_MODE2 Message-ID: <20180525204509.7jsnnk2qzws3bmyd@ast-mbp> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 18, 2018 at 03:07:29PM +0100, Sean Young wrote: > Add support for BPF_PROG_LIRC_MODE2. This type of BPF program can call > rc_keydown() to reported decoded IR scancodes, or rc_repeat() to report > that the last key should be repeated. > > The bpf program can be attached to using the bpf(BPF_PROG_ATTACH) syscall; > the target_fd must be the /dev/lircN device. > > Signed-off-by: Sean Young ... > enum bpf_attach_type { > @@ -158,6 +159,7 @@ enum bpf_attach_type { > BPF_CGROUP_INET6_CONNECT, > BPF_CGROUP_INET4_POST_BIND, > BPF_CGROUP_INET6_POST_BIND, > + BPF_LIRC_MODE2, > __MAX_BPF_ATTACH_TYPE > }; > > @@ -1902,6 +1904,53 @@ union bpf_attr { > * egress otherwise). This is the only flag supported for now. > * Return > * **SK_PASS** on success, or **SK_DROP** on error. > + * > + * int bpf_rc_keydown(void *ctx, u32 protocol, u64 scancode, u32 toggle) > + * Description > + * This helper is used in programs implementing IR decoding, to > + * report a successfully decoded key press with *scancode*, > + * *toggle* value in the given *protocol*. The scancode will be > + * translated to a keycode using the rc keymap, and reported as > + * an input key down event. After a period a key up event is > + * generated. This period can be extended by calling either > + * **bpf_rc_keydown** () with the same values, or calling > + * **bpf_rc_repeat** (). > + * > + * Some protocols include a toggle bit, in case the button > + * was released and pressed again between consecutive scancodes > + * > + * The *ctx* should point to the lirc sample as passed into > + * the program. > + * > + * The *protocol* is the decoded protocol number (see > + * **enum rc_proto** for some predefined values). > + * > + * This helper is only available is the kernel was compiled with > + * the **CONFIG_BPF_LIRC_MODE2** configuration option set to > + * "**y**". > + * > + * Return > + * 0 > + * > + * int bpf_rc_repeat(void *ctx) > + * Description > + * This helper is used in programs implementing IR decoding, to > + * report a successfully decoded repeat key message. This delays > + * the generation of a key up event for previously generated > + * key down event. > + * > + * Some IR protocols like NEC have a special IR message for > + * repeating last button, for when a button is held down. > + * > + * The *ctx* should point to the lirc sample as passed into > + * the program. > + * > + * This helper is only available is the kernel was compiled with > + * the **CONFIG_BPF_LIRC_MODE2** configuration option set to > + * "**y**". Hi Sean, thank you for working on this. The patch set looks good to me. I'd only ask to change above two helper names to something more specific. Since BPF_PROG_TYPE_LIRC_MODE2 is the name of new prog type and kconfig. May be bpf_lirc2_keydown() and bpf_lirc2_repeat() ? > @@ -1576,6 +1577,8 @@ static int bpf_prog_attach(const union bpf_attr *attr) > case BPF_SK_SKB_STREAM_PARSER: > case BPF_SK_SKB_STREAM_VERDICT: > return sockmap_get_from_fd(attr, BPF_PROG_TYPE_SK_SKB, true); > + case BPF_LIRC_MODE2: > + return rc_dev_prog_attach(attr); ... > + case BPF_LIRC_MODE2: > + return rc_dev_prog_detach(attr); and similar rename for internal function names that go into bpf core. Please add accumulated acks when you respin. Thanks