Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3303687imm; Thu, 17 May 2018 06:46:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq3w7gXUc0qY3DqoDtsgWirLlbzNF1lJ9OY/NoIjbJZpRyierwTbR7JMvKa7NA3zPzsZzPE X-Received: by 2002:a65:4c4f:: with SMTP id l15-v6mr4188519pgr.61.1526564819360; Thu, 17 May 2018 06:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526564819; cv=none; d=google.com; s=arc-20160816; b=BVmKV/+4CxLwGVR6wYb32ISMA7ZSyu0YJfKCTXpAbSnQj4ePGOO39PkGC9vYMkPBT2 j9r4rMZuot/IjHM+ESXvJtJb5IkRXu8rUBheKwR/9STq8355LEfo4egzJy+6z650bb/1 77FZ49MBPAnR0UxrcvYBIkYRTALtEtq5mLPtm8lvgo3msvZdgDEVLzzDYgqiq5rDrUHE cT0+ez+NkePt9JBKA5C0Yeom0EsphEBt91l0Cy2yqrCXVjw9acCjS1HPRqRRQgZXDW6g AQic9jC+6/FRKyxvaX9sxD/5R8D30MQD/9cQB3b1zgyDGMe8iTFKlOtsocFzjoX/lmyj A0FQ== 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:arc-authentication-results; bh=tm8iE0r3AoRChiMZ659rLhfhGN3X2YGeaNakQ7k0+Y0=; b=vxElrWOTSLiU/ofn0UQXd5gIX99PumpF/2l3ore5LJgMC5mxh8dKFsrRMAQKbb1jmu bNDWJ6hTYLmR3m477njGDcNRRk8eW54Q7C3gMoBf9TUEIYD4y3YGSuInAD3dbnuF6Pfx IQktU6xuBOnNehMwPGrW0O96D1AEkKmvdo09dDymIfP+VPk9fJ4lNxs0n8n+QpiMd+QY g4eghMlxEnlabFwERd2jVSbO4U9GdeApIvEwUoBjfrjIcqMmjUbPKHjjsGOj9OjT+/A3 ledoJ55op6+TywuOG/weEfLEccPwLAxBNKJdYcPl3Knmd7WkUnaeiEcnj3SOedt0L6bc mMuQ== 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 w21-v6si4133277pgm.433.2018.05.17.06.46.44; Thu, 17 May 2018 06:46:59 -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 S1751999AbeEQNoc (ORCPT + 99 others); Thu, 17 May 2018 09:44:32 -0400 Received: from gofer.mess.org ([88.97.38.141]:60337 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938AbeEQNoa (ORCPT ); Thu, 17 May 2018 09:44:30 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id 2C2A260644; Thu, 17 May 2018 14:44:28 +0100 (BST) Date: Thu, 17 May 2018 14:44:28 +0100 From: Sean Young To: Quentin Monnet 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 Subject: Re: [PATCH v3 1/2] media: rc: introduce BPF_PROG_RAWIR_EVENT Message-ID: <20180517134427.bjvt2t3jfabpvbcy@gofer.mess.org> References: <92785c791057185fa5691f78cecfa4beae7fc336.1526504511.git.sean@mess.org> <592262ad-e92f-2b53-f6bb-086257c21db0@netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <592262ad-e92f-2b53-f6bb-086257c21db0@netronome.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Quentin, On Thu, May 17, 2018 at 01:10:56PM +0100, Quentin Monnet wrote: > 2018-05-16 22:04 UTC+0100 ~ Sean Young > > Add support for BPF_PROG_RAWIR_EVENT. 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 > > --- > > drivers/media/rc/Kconfig | 13 ++ > > drivers/media/rc/Makefile | 1 + > > drivers/media/rc/bpf-rawir-event.c | 363 +++++++++++++++++++++++++++++ > > drivers/media/rc/lirc_dev.c | 24 ++ > > drivers/media/rc/rc-core-priv.h | 24 ++ > > drivers/media/rc/rc-ir-raw.c | 14 +- > > include/linux/bpf_rcdev.h | 30 +++ > > include/linux/bpf_types.h | 3 + > > include/uapi/linux/bpf.h | 55 ++++- > > kernel/bpf/syscall.c | 7 + > > 10 files changed, 531 insertions(+), 3 deletions(-) > > create mode 100644 drivers/media/rc/bpf-rawir-event.c > > create mode 100644 include/linux/bpf_rcdev.h > > > > [...] > > Hi Sean, > > Please find below some nitpicks on the documentation for the two helpers. I agree with all your points. I will reword and fix this for v4. Thanks, Sean > > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > > index d94d333a8225..243e141e8a5b 100644 > > --- a/include/uapi/linux/bpf.h > > +++ b/include/uapi/linux/bpf.h > > [...] > > > @@ -1902,6 +1904,35 @@ 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, u32 scancode, u32 toggle) > > + * Description > > + * Report decoded scancode with toggle value. For use in > > + * BPF_PROG_TYPE_RAWIR_EVENT, to report a successfully > > Could you please use bold RST markup for constants and function names? > Typically for BPF_PROG_TYPE_RAWIR_EVENT here and the enum below. > > > + * decoded scancode. This is will generate a keydown event, > > s/This is will/This will/? > > > + * and a keyup event once the scancode is no longer repeated. > > + * > > + * *ctx* pointer to bpf_rawir_event, *protocol* is decoded > > + * protocol (see RC_PROTO_* enum). > > This documentation is intended to be compiled as a man page. Could you > please use a complete sentence here? > Also, this could do with additional markup as well: **struct > bpf_rawir_event**. > > > + * > > + * Some protocols include a toggle bit, in case the button > > + * was released and pressed again between consecutive scancodes, > > + * copy this bit into *toggle* if it exists, else set to 0. > > + * > > + * Return > > The "Return" lines here and in the second helper use space indent > instead as tabs (as all other lines do). Would you mind fixing it for > consistency? > > > + * Always return 0 (for now) > > Other helpers use just "0" in that case, but I do not really mind. > Out of curiosity, do you have anything specific in mind for changing the > return value here in the future? I don't expect this is to change, so I should just "0". > > > + * > > + * int bpf_rc_repeat(void *ctx) > > + * Description > > + * Repeat the last decoded scancode; some IR protocols like > > + * NEC have a special IR message for repeat last button, > > s/repeat/repeating/? > > > + * in case user is holding a button down; the scancode is > > + * not repeated. > > + * > > + * *ctx* pointer to bpf_rawir_event. > > Please use a complete sentence here as well, if you do not mind. > > > + * > > + * Return > > + * Always return 0 (for now) > > */ > Thanks, > Quentin