Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3298375imm; Mon, 6 Aug 2018 02:08:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcOrWJP0+2h4lk0AkY1aVAWccpqOodO0gfaW1qb2yamJGTqOaxs8PFCn9XnHBXZ3vpYrO16 X-Received: by 2002:a17:902:7688:: with SMTP id m8-v6mr13015055pll.338.1533546528972; Mon, 06 Aug 2018 02:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533546528; cv=none; d=google.com; s=arc-20160816; b=RpJTuqhxdiH+uzZ3Mdt640WqnL9V9sr2wgrOHttVQsQhiyksnCfYDGJNfSE94lYalF RiULGHv9gMoPVLfbGIrXN3Rw+MQ/H5X7jP34yABddV9JWY12/zOBKQ+FT80hpDkB28qj UP8GknoYI9MIA6r/cpSdi1XfeD8aiipyscwcFkny70ABsjY6K2BVG1sR3YX/8b6jgIzu 7juh8opg0b2yweAj+k+Oevhf5tK9FzRf6YJMEf9hiJXuAG2C7giCaz2oN8e+ZOvsUi7w VpkWcd+8MbZPRi5dhpzLE+SFkOUPERE0UeAlTnz1kLI+GZMyYWJgK76VawQlWuOKcC6W Z4pw== 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:cc:to:subject:arc-authentication-results; bh=LygnqGtxG02dvM5X+OJUK8+cIuXpxqs6gtfSBFhBxIU=; b=nCJAXEKR7pLq/1m+LMPkh/irFEyIFGBViiqqLJyL9y1NqWi+oQPvqLevbv2PSplCvL HaG/ecZH/hpjR3gkLyt8ieBKRvWzzED9CW59XR6Uizw6QfGL3cQhZG8lom0TnubjWyp5 bqVVr1zuZ8vEAb09dw+kdKOcWqb/f9GE8JZj0MOCDQUFGnTBd71bdM+mOj3aJwni8ZcS nJd++/Jb2dMWbRD7l2hAdAE3y4zqkBcwYPGuyBZHsPMB+hpbwjHsJHVPE3j8JKdO2hfG kRr+EaSEzkE9gzS++E5d+5DUEDMmRe5ahC53TkVHtYfuMh6UUafbU/fzgTedAl8SZIwQ W6zQ== 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 o21-v6si7872453pgk.337.2018.08.06.02.08.33; Mon, 06 Aug 2018 02:08:48 -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 S1727730AbeHFLPu (ORCPT + 99 others); Mon, 6 Aug 2018 07:15:50 -0400 Received: from proxima.lasnet.de ([78.47.171.185]:44913 "EHLO proxima.lasnet.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbeHFLPu (ORCPT ); Mon, 6 Aug 2018 07:15:50 -0400 Received: from [IPv6:2003:e9:d706:d44e:3252:cbff:fe54:190f] (p200300E9D706D44E3252CBFFFE54190F.dip0.t-ipconnect.de [IPv6:2003:e9:d706:d44e:3252:cbff:fe54:190f]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: stefan@datenfreihafen.org) by proxima.lasnet.de (Postfix) with ESMTPSA id 04AD7C75AE; Mon, 6 Aug 2018 11:07:40 +0200 (CEST) Subject: Re: [PATCH] ieee802154: add rx LQI from userspace To: =?UTF-8?B?Q2zDqW1lbnQgUMOpcm9u?= , Romuald Cari , linux-wpan@vger.kernel.org Cc: Alexander Aring , Stefan Schmidt , "David S . Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Cl=c3=a9ment_Peron?= References: <20180607140802.22666-1-peron.clem@gmail.com> From: Stefan Schmidt Message-ID: <35c6ef3e-7f7b-2a2d-d73b-201efbc4594c@datenfreihafen.org> Date: Mon, 6 Aug 2018 11:07:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180607140802.22666-1-peron.clem@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On 06/07/2018 04:08 PM, Clément Péron wrote: > From: Romuald CARI > > The Link Quality Indication data exposed by drivers could not be accessed from > userspace. Since this data is per-datagram received, it makes sense to make it > available to userspace application through the ancillary data mechanism in > recvmsg rather than through ioctls. This can be activated using the socket > option WPAN_WANTLQI under SOL_IEEE802154 protocol. > > This LQI data is available in the ancillary data buffer under the SOL_IEEE802154 > level as the type WPAN_LQI. The value is an unsigned byte indicating the link > quality with values ranging 0-255. > > Signed-off-by: Romuald Cari > Signed-off-by: Clément Peron > --- > include/net/af_ieee802154.h | 1 + > net/ieee802154/socket.c | 17 +++++++++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/include/net/af_ieee802154.h b/include/net/af_ieee802154.h > index a5563d27a3eb..8003a9f6eb43 100644 > --- a/include/net/af_ieee802154.h > +++ b/include/net/af_ieee802154.h > @@ -56,6 +56,7 @@ struct sockaddr_ieee802154 { > #define WPAN_WANTACK 0 > #define WPAN_SECURITY 1 > #define WPAN_SECURITY_LEVEL 2 > +#define WPAN_WANTLQI 3 > > #define WPAN_SECURITY_DEFAULT 0 > #define WPAN_SECURITY_OFF 1 > diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c > index a60658c85a9a..bc6b912603f1 100644 > --- a/net/ieee802154/socket.c > +++ b/net/ieee802154/socket.c > @@ -25,6 +25,7 @@ > #include /* For TIOCOUTQ/INQ */ > #include > #include > +#include > #include > #include > #include > @@ -452,6 +453,7 @@ struct dgram_sock { > unsigned int bound:1; > unsigned int connected:1; > unsigned int want_ack:1; > + unsigned int want_lqi:1; > unsigned int secen:1; > unsigned int secen_override:1; > unsigned int seclevel:3; > @@ -486,6 +488,7 @@ static int dgram_init(struct sock *sk) > struct dgram_sock *ro = dgram_sk(sk); > > ro->want_ack = 1; > + ro->want_lqi = 0; > return 0; > } > > @@ -713,6 +716,7 @@ static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, > size_t copied = 0; > int err = -EOPNOTSUPP; > struct sk_buff *skb; > + struct dgram_sock *ro = dgram_sk(sk); > DECLARE_SOCKADDR(struct sockaddr_ieee802154 *, saddr, msg->msg_name); > > skb = skb_recv_datagram(sk, flags, noblock, &err); > @@ -744,6 +748,13 @@ static int dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, > *addr_len = sizeof(*saddr); > } > > + if (ro->want_lqi) { > + err = put_cmsg(msg, SOL_IEEE802154, WPAN_WANTLQI, > + sizeof(uint8_t), &(mac_cb(skb)->lqi)); > + if (err) > + goto done; > + } > + > if (flags & MSG_TRUNC) > copied = skb->len; > done: > @@ -847,6 +858,9 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname, > case WPAN_WANTACK: > val = ro->want_ack; > break; > + case WPAN_WANTLQI: > + val = ro->want_lqi; > + break; > case WPAN_SECURITY: > if (!ro->secen_override) > val = WPAN_SECURITY_DEFAULT; > @@ -892,6 +906,9 @@ static int dgram_setsockopt(struct sock *sk, int level, int optname, > case WPAN_WANTACK: > ro->want_ack = !!val; > break; > + case WPAN_WANTLQI: > + ro->want_lqi = !!val; > + break; > case WPAN_SECURITY: > if (!ns_capable(net->user_ns, CAP_NET_ADMIN) && > !ns_capable(net->user_ns, CAP_NET_RAW)) { > This patch has been applied to the wpan-next tree and will be part of the next pull request to net-next. Thanks! regards Stefan Schmidt