Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3013363pxb; Fri, 8 Oct 2021 22:39:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmLQh8wyFt+oqQTabnei2biaWMP5oU40rYuo2ZJ/FtbOaQ15xzGSog+/tNZ10xqf1FN3Ov X-Received: by 2002:a17:907:3e05:: with SMTP id hp5mr9459374ejc.527.1633757983455; Fri, 08 Oct 2021 22:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633757983; cv=none; d=google.com; s=arc-20160816; b=KDZBSR47v6xbySDjInnA+bvmgMLVX8YXSWd5jwr40v8aDhKa+Iby31ZE0Addt8Tlls KSE8ClFzrBBYa1lCzCPuRD8S1kcnDJiPmKQEQokBfKABI9llf7FjjzQkhlYHO/8oWtZc bjfvavHKn944wyT9q4D8Q2If9Kqt/92JNaCOSNkX2IRSvsU7Usbm/Ciwaqhumfp+0mvq VXIfXzY/agtVZMgQ0L6wNK/GvzcXKeRPGIC3r+zZatLwSgWkblsQW7B4Tda/5T/WAitB TqFuq4/Hz0b0N2nHXYyEM2NqfUoox4ReuuQQ9PiK/bodN+uGMXoIVWEPpYaTf8XLUO0j +4Iw== 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; bh=aIghcbJ60FBCmsTSZcidGZHdsZIgJ4C2Kwndg3+KdLc=; b=EH0rAWt/+rHl66odELmxdn5p39PXjpbNxJtgJRzOsbEX+C+YU4XoLq9nRpfs8SaP8k tJoHk6hs3afVPmG8uPC33yhWcg1zpMMn3iYI6n3Qpp7j6uUdV3yRGbxqFcwMj5fmZQqa ihiLRGKIpyoFld7m+/NjAPi9qZn+ypQ11aXUMSQnz1TMQ9e4ltQHrnp5v/9D++seMTgm 1y8A64ALsdXA3o+/XAzEzkCQOieNqcn1at/JjuCSBPd9USnByxCxjj/JioOzXZuE9COV Kq7iTN9+ZNGR0lP6S7abJLvrLFAh26ostfkywjy/Qe0fp78cWp/25A1puvgjRBa/kz3q 5/vA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n14si2201223eda.482.2021.10.08.22.39.19; Fri, 08 Oct 2021 22:39:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244279AbhJIFjP (ORCPT + 99 others); Sat, 9 Oct 2021 01:39:15 -0400 Received: from mail-yb1-f175.google.com ([209.85.219.175]:44782 "EHLO mail-yb1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbhJIFjO (ORCPT ); Sat, 9 Oct 2021 01:39:14 -0400 Received: by mail-yb1-f175.google.com with SMTP id s64so25518242yba.11; Fri, 08 Oct 2021 22:37:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aIghcbJ60FBCmsTSZcidGZHdsZIgJ4C2Kwndg3+KdLc=; b=GSRQ1Iaf1jcG6jkjDcE0B8hBNwjtTQ4mbDh4TEU1M0ryezASe86tpYTv9qBlFiPagV 0mOzC2xtjSIGX/LLi4BHeLJy0yDZkYncrVPdPuUleydzjo0GGcOF1zXVENu9wwUi8mr0 QFCfJwknKg16eYQ19JaarW9giEtkdoIJCNn36fsdUT6BKWgRP17/fRIVV4SlgUaKA1iN f6QEw1wJP0XwSwpMn3LNUnUHrE0XkFp0zJlCWyNAgQdRU10qXhL40FqSD0ZyQsIfhHPv DuUS9Dk8SJi5XuhcFayv/JGNevgGZcnQrqeZdjcyIx3jgzOfj1ylaI0wQ6d7cP5FAUaZ Pdeg== X-Gm-Message-State: AOAM532jXNoziPEEQG1Xma1tenb3tIzCE3M5Toi64XQfIIcIviqsRT9d HI1KThQXJpoZ2J45OshLZ4NdIbJiw/XNgA0vSsajTDd22nk= X-Received: by 2002:a25:4146:: with SMTP id o67mr8514459yba.113.1633757837390; Fri, 08 Oct 2021 22:37:17 -0700 (PDT) MIME-Version: 1.0 References: <20211003044049.568441-1-mailhol.vincent@wanadoo.fr> In-Reply-To: <20211003044049.568441-1-mailhol.vincent@wanadoo.fr> From: Vincent MAILHOL Date: Sat, 9 Oct 2021 14:37:06 +0900 Message-ID: Subject: Re: [PATCH v1] can: netlink: report the CAN controller mode supported flags To: Marc Kleine-Budde , linux-can Cc: netdev , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun. 3 Oct 2021 at 13:40, Vincent Mailhol wrote: > This patch introduces a method for the user to check both the > supported and the static capabilities. > > Currently, the CAN netlink interface provides no easy ways to check > the capabilities of a given controller. The only method from the > command line is to try each CAN_CTRLMODE_ individually to check > whether the netlink interface returns an -EOPNOTSUPP error or not > (alternatively, one may find it easier to directly check the source > code of the driver instead...) > > It appears that, currently, the struct can_ctrlmode::mask field is > only used in one direction: from the userland to the kernel. So we can > just reuse this field in the other direction (from the kernel to > userland). But, because the semantic is different, we use a union to > give this field a proper name: supported. > > Below table explains how the two fields can_ctrlmode::supported and > can_ctrlmode::flags, when masked with any of the CAN_CTRLMODE_* bit > flags, allow us to identify both the supported and the static > capabilities: > > supported & flags & Controller capabilities > CAN_CTRLMODE_* CAN_CTRLMODE_* > ------------------------------------------------------------------------ > false false Feature not supported (always disabled) > false true Static feature (always enabled) > true false Feature supported but disabled > true true Feature supported and enabled > > N.B.: This patch relies on the fact that a given CAN_CTRLMODE_* > feature can not be set for both can_priv::ctrlmode_supported and > can_priv::ctrlmode_static at the same time. c.f. comments in struct > can_priv [1]. Else, there would be no way to distinguish which > features were statically enabled. Actually, can_priv::ctrlmode_static can be derived from the other ctrlmode fields. I will send a v2 in which I will add a patch to replace that field with an inline function. Yours sincerely, Vincent Mailhol