Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp769205imm; Wed, 23 May 2018 05:23:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoQcQEzV2bcZ7PAh9JAbkieXw/S2qZ2oFhhzVhOqPJ53qAWJEPtCZZhSFcfDaEbtBRq0r8S X-Received: by 2002:a62:2197:: with SMTP id o23-v6mr2732738pfj.202.1527078182395; Wed, 23 May 2018 05:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527078182; cv=none; d=google.com; s=arc-20160816; b=PGiHp9UFVout3B9M7om9jeQCSmwSwT5eyQeq7z8IiILHx7/REeobmD7HOR1kcr12ac /ACfCwqsMOM91zndFWiZze5J07dJGIe1lqX1g4qNcf/u/jXQYxYXWAzcpmKVWnkN6epR a/hw77Lqn6CYoq/ZN/zX1Nszylyg9JQ5DOKHXua8Vbx0QyGePA2zzXGy21ORtiTC0VRU Uk/jxq8BAeFKHTs6z4qJGaEEi5fzM2DnXKS7quIE8s7Xpzu8G0pYAsm8HuNEGVYX8jLD FR9+w1XfmoNezfo7zrPnJpFV51+ctNmPfreufQHqnF02QJd/KjKSwhW1UYGiOOvkySMS e3IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=lQJgY4M7gPFGTtk4HFHrF0sE8O5nDhM/g1GrdSToLWY=; b=tw2D3gCY7KxT8kgJ674O0iwFj7LHFgJONwkxUUcBKkLCHrV5mmmA091c5P0wX45XYh Euan+Iy4tXStHGSEvbSmaSJ69lUkClBwR8/ssJO1EJgSKLEyTnXyEQI3qdld6sRsF8yq g1CMs5BFFDh6RrrLv9Fz65/TcFcQlx2CuIKZQTqHFON+NTEg74Ei03/WB99ENMgNuYeB JqnqnDCi9vulB6yOgZ9/cczXa05+SlFfFFz+SoSY4JyivRJGvV30qLJ7OrMl4DA2Is0K bzXbCYSH2d6E7+dLjmqoW/SN4aPe30eNh+h1PpaN+3/laTMgV9421pLqPPGHBcwSeI06 z2rw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3-v6si18785417pld.50.2018.05.23.05.22.47; Wed, 23 May 2018 05:23:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932907AbeEWMVc (ORCPT + 99 others); Wed, 23 May 2018 08:21:32 -0400 Received: from www62.your-server.de ([213.133.104.62]:46210 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932534AbeEWMVa (ORCPT ); Wed, 23 May 2018 08:21:30 -0400 Received: from [188.63.75.139] (helo=linux.home) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-SHA:256) (Exim 4.85_2) (envelope-from ) id 1fLSlk-0001NI-89; Wed, 23 May 2018 14:21:28 +0200 Subject: Re: [PATCH v4 0/3] IR decoding using BPF To: Sean Young , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Mauro Carvalho Chehab , netdev@vger.kernel.org, Matthias Reichl , Devin Heitmueller , Y Song , Quentin Monnet References: From: Daniel Borkmann Message-ID: <860cf2a8-dd2e-ba78-8b98-3d8f4330f3d0@iogearbox.net> Date: Wed, 23 May 2018 14:21:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.99.3/24595/Wed May 23 07:19:06 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/18/2018 04:07 PM, Sean Young wrote: > The kernel IR decoders (drivers/media/rc/ir-*-decoder.c) support the most > widely used IR protocols, but there are many protocols which are not > supported[1]. For example, the lirc-remotes[2] repo has over 2700 remotes, > many of which are not supported by rc-core. There is a "long tail" of > unsupported IR protocols, for which lircd is need to decode the IR . > > IR encoding is done in such a way that some simple circuit can decode it; > therefore, bpf is ideal. > > In order to support all these protocols, here we have bpf based IR decoding. > The idea is that user-space can define a decoder in bpf, attach it to > the rc device through the lirc chardev. > > Separate work is underway to extend ir-keytable to have an extensive library > of bpf-based decoders, and a much expanded library of rc keymaps. > > Another future application would be to compile IRP[3] to a IR BPF program, and > so support virtually every remote without having to write a decoder for each. > It might also be possible to support non-button devices such as analog > directional pads or air conditioning remote controls and decode the target > temperature in bpf, and pass that to an input device. Mauro, are you fine with this series going via bpf-next? How ugly would this get with regards to merge conflicts wrt drivers/media/rc/? Thanks, Daniel > Thanks, > > Sean Young > > [1] http://www.hifi-remote.com/wiki/index.php?title=DecodeIR > [2] https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/ > [3] http://www.hifi-remote.com/wiki/index.php?title=IRP_Notation > > Changes since v3: > - Implemented review comments from Quentin Monnet and Y Song (thanks!) > - More helpful and better formatted bpf helper documentation > - Changed back to bpf_prog_array rather than open-coded implementation > - scancodes can be 64 bit > - bpf gets passed values in microseconds, not nanoseconds. > microseconds is more than than enough (IR receivers support carriers upto > 70kHz, at which point a single period is already 14 microseconds). Also, > this makes it much more consistent with lirc mode2. > - Since it looks much more like lirc mode2, rename the program type to > BPF_PROG_TYPE_LIRC_MODE2. > - Rebased on bpf-next > > Changes since v2: > - Fixed locking issues > - Improved self-test to cover more cases > - Rebased on bpf-next again > > Changes since v1: > - Code review comments from Y Song and > Randy Dunlap > - Re-wrote sample bpf to be selftest > - Renamed RAWIR_DECODER -> RAWIR_EVENT (Kconfig, context, bpf prog type) > - Rebase on bpf-next > - Introduced bpf_rawir_event context structure with simpler access checking > > Sean Young (3): > bpf: bpf_prog_array_copy() should return -ENOENT if exclude_prog not > found > media: rc: introduce BPF_PROG_LIRC_MODE2 > bpf: add selftest for lirc_mode2 type program > > drivers/media/rc/Kconfig | 13 + > drivers/media/rc/Makefile | 1 + > drivers/media/rc/bpf-lirc.c | 308 ++++++++++++++++++ > drivers/media/rc/lirc_dev.c | 30 ++ > drivers/media/rc/rc-core-priv.h | 22 ++ > drivers/media/rc/rc-ir-raw.c | 12 +- > include/linux/bpf_rcdev.h | 30 ++ > include/linux/bpf_types.h | 3 + > include/uapi/linux/bpf.h | 53 ++- > kernel/bpf/core.c | 11 +- > kernel/bpf/syscall.c | 7 + > kernel/trace/bpf_trace.c | 2 + > tools/bpf/bpftool/prog.c | 1 + > tools/include/uapi/linux/bpf.h | 53 ++- > tools/include/uapi/linux/lirc.h | 217 ++++++++++++ > tools/lib/bpf/libbpf.c | 1 + > tools/testing/selftests/bpf/Makefile | 8 +- > tools/testing/selftests/bpf/bpf_helpers.h | 6 + > .../testing/selftests/bpf/test_lirc_mode2.sh | 28 ++ > .../selftests/bpf/test_lirc_mode2_kern.c | 23 ++ > .../selftests/bpf/test_lirc_mode2_user.c | 154 +++++++++ > 21 files changed, 974 insertions(+), 9 deletions(-) > create mode 100644 drivers/media/rc/bpf-lirc.c > create mode 100644 include/linux/bpf_rcdev.h > create mode 100644 tools/include/uapi/linux/lirc.h > create mode 100755 tools/testing/selftests/bpf/test_lirc_mode2.sh > create mode 100644 tools/testing/selftests/bpf/test_lirc_mode2_kern.c > create mode 100644 tools/testing/selftests/bpf/test_lirc_mode2_user.c >