Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1229318lqp; Sun, 14 Apr 2024 22:29:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWSe4CuMBmcJaxIESeoj1nBsdTc+z7BDpvEtjZlsghdHqpMpgdc7IgBWIGj3YrJDS0Id1q3jtvt1PvGNBrvrAjSKOKchbKQSR/epmCsyw== X-Google-Smtp-Source: AGHT+IFTgnJwznhPqgkIVXuoN26wmkasivk0CTdt5fCRo5cpn8mRYHVONSqTc+dc1/X6uv4Od/hi X-Received: by 2002:a05:6512:3f25:b0:518:bb48:f060 with SMTP id y37-20020a0565123f2500b00518bb48f060mr2614082lfa.19.1713158988199; Sun, 14 Apr 2024 22:29:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713158988; cv=pass; d=google.com; s=arc-20160816; b=gORazbiBTP73GpPma5UPbEcYPUrDwQSjgZT32S3eDDZj0c77TesT0V3nHf0Hh9FfMd sh9CKWjiu/T7CpnY1hi2xc2MZJ9laiz16JvYZ6F8eEKl8+roqx5P7nMfssPD42ISSj7G BU3ZmyS+0yufj36ZmSBCa0K9pUi1pqvUG4n7SkZAMOxWSbC9dft6foRpjqKfCS4C/x+8 V1862/INDn93Gp0wZveDUUAxX+wAAcECoZTZ2Oijl+VJPf0Fgwbake88zR0TMOT6q15s V7VIkp3g4gzEbE1VgSf3uUMhtSrv9nL1TUBjLB0CxuXcd3pvGscCVD1HHMBV+L5mjweE URmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=oH9+g2LiJ7hE+BmM60E94BIQlPkF9NnGngny+sqtXio=; fh=s4HdzqP+/jC3QzR2foR1kBr0BpFssXWdVsdToB0z4t8=; b=tLxc0r9fx3auTCCivyAMYsM4pMWkdheWp+bIwM9vNny7vuYFLZM9zXrZIslvAPI0lg t+lSUgoeVmLWRAvULnybJAMWdps1tvJglSs+hS0Ppd/bhq14+IWPi2G47Nof9JYJLxqt JK7YdSgqACUVD9SemWOApMha9nHCQP7TuqZVJtnp6Jiay66UYFHTLRYOUVspGRGE4b7E 8jRcVuk2oN3mL52BhT+irqd8gIPgF9OdftqpHMlGlAs3EX2/YzQ3z608iQ7SfQoznUmo 08BXho6ZHIqJscaXS/kqS41YLyd8VqB8XTgzAcJvzJsKWtbuhAwNED4TDUFEvhzyafyr IDZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=COA6bK+U; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-144543-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g15-20020a1709067c4f00b00a4e8aaa9f04si4385451ejp.518.2024.04.14.22.29.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 22:29:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144543-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=COA6bK+U; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-144543-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BD1C91F21A09 for ; Mon, 15 Apr 2024 05:29:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90EDA63C1; Mon, 15 Apr 2024 05:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="COA6bK+U" Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FF5C33C5; Mon, 15 Apr 2024 05:29:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713158975; cv=none; b=Lvr2KOsQcA5BKCzgBYZnO+laeTvVyGdeGufJWcOSWcimI1641DNfweNsj/RqMLIA9Fg8O1+G5PUfIktrhYl5xTw1M3gPjkq9UDJWKogBxVx0tQPUZACRTGvhTOhafoWgaGwyuFFPq6+fcfEKKb+akm7bIV2QrO437w20ysh8Szs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713158975; c=relaxed/simple; bh=UpCMuHkepQajdVg62XPJny0xX87yZKEpf4poRd7fJeg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=S2U8RwHGhmAD244VWTkUO1jk8ZVHpyxWC1UCNBCHQbusPvKDbxkAprzNEd88wn9VQQ16Q45xhGS/AtMpnwEdnmQ0yME92OJdbgHDVm/9+2Co0GqxEwrR+yyyddsROUT+w0MI0/yR3UDCbNaHgnrCXc5gUOH4LVqCGPKYm6WsmHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=COA6bK+U; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2a528e7f2b6so1947192a91.0; Sun, 14 Apr 2024 22:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713158973; x=1713763773; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=oH9+g2LiJ7hE+BmM60E94BIQlPkF9NnGngny+sqtXio=; b=COA6bK+Umr3eZObrZDY8r3IIZIJHD4mGWlyu6DCfV2a9YxlISwVn74BRRoJhFB0QuJ icc/nSc3uPjqs4rO6rhvE2DcovfE/WPmPt6eIoUFwz9ktoqXQ8PejQeofmZurpMtDae4 VE3SacsLC2fmRyx2mCoYGHMPQvnxLiK6R0KIMQLPFhTLlUotzseJmZQeDwC30uvlYhgr K6RPk7hj3/MGwIlHTiI1taI48hIzv3ouGcKo9zBONb4Rt0ydaMw9TYYM76t5+4tb4CKF 2FbGDTi2IOMSSRB71WaYa+k05VZ1ItZBp0w2w/UgtHLcTcya2di/eLfTJAFiRrxKEgPe /YPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713158973; x=1713763773; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oH9+g2LiJ7hE+BmM60E94BIQlPkF9NnGngny+sqtXio=; b=po6vxasDBr9aFVaitt47plxDeX1yGHKdxr2kEbLbKjHa3zXNG3SSe2edtIP6x39RIl nk/ZyYW9XOxaey81hznHMUo4ltX6DWB2xxItV7A9kNNYP7WH5o7kSwx/kpAFjBd1kX0D k45OidE3BnyJlbFyVUz6kAkonUtZXPPEvqPEgQaO3byfeFqzlvPyRf+KwC8FyImIM+w9 tk2L/kYF78klOWm7EZ+Qey9WT7+eYMkJJg2d5AGjMTumZa3mZpdwP4FnGJ6gp3rQvMhI hFREIDNRdBGfR+Pk0BpgXWiinuM4eZDiQlzL0XoWiJMOo/ULqcVo9cP81tPH3xD3liev ljkA== X-Forwarded-Encrypted: i=1; AJvYcCXrrxmf0nR5NQEwF+M7Nngd8V3EEUZS7x8w3iwR/Q8cx4d8M2vJGtqUhZYYRWP69YFFpFTlnURBVdIhJZ+S/iJNOaPDG6ScaGl6D/HhE8KIU2lfpRPJpg8G00oPdQriffnsbaXIROGMQ3He8Z9lLS9tI0A/kXVcGjMR0iEhRew6 X-Gm-Message-State: AOJu0Yyt5G7KLsVOPu/JqkwtdFEFeMNwi51jqtrQ/uAuSrc/4EaPKbfL Go8Zcq6Z5haj/ADtIiyX89ni0zFca5x4y1+io5b/a1Y+mIczaad+HyoZk57gT7xD4Sl7n0wbrkk GVC73WdljcMh4EleWXfKrJlqBW2o= X-Received: by 2002:a17:90a:c205:b0:2a5:2177:9b41 with SMTP id e5-20020a17090ac20500b002a521779b41mr6463184pjt.22.1713158973331; Sun, 14 Apr 2024 22:29:33 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240329133458.323041-2-valla.francesco@gmail.com> <20240329133458.323041-3-valla.francesco@gmail.com> <9f5ad308-f2a0-47be-85f3-d152bc98099a@hartkopp.net> <64586257-3cf6-4c10-a30b-200b1ecc5e80@hartkopp.net> In-Reply-To: <64586257-3cf6-4c10-a30b-200b1ecc5e80@hartkopp.net> From: Vincent Mailhol Date: Mon, 15 Apr 2024 14:29:21 +0900 Message-ID: Subject: Re: [PATCH v2 1/1] Documentation: networking: document ISO 15765-2:2016 To: Oliver Hartkopp Cc: Francesco Valla , Marc Kleine-Budde , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Bagas Sanjaya , fabio@redaril.me Content-Type: text/plain; charset="UTF-8" On Mon. 15 Apr. 2024 at 05:22, Oliver Hartkopp wrote: > On 14.04.24 06:03, Vincent Mailhol wrote: > > > > This doesn't remove the fact that I think that this naming convention > > is stupid because of the RAS syndrome, but I acknowledge that CAN CC > > is now the official denomination and thus, that we should adopt it in > > our documentation as well. > > > > ;-) > > > >>> Add a space between ISO and the number. Also, update the year: > >>> > >>> ISO 15765-2:2024 > >>> > >> > >> Interesting! Didn't know there's already a new version. > >> > >> Will check this out whether we really support ISO 15765-2:2024 ... > >> > >> Do you have the standard at hand right now or should we leave this as > >> ISO15765-2:2016 until we know? > > > > I have access to the newer revisions. But I never really invested time > > into reading that standard (neither the 2016 nor the 2024 versions). > > > > Regardless, here is a verbatim extract from the Foreworld section of > > ISO 15765-2:2024 > > > > This fourth edition cancels and replaces the third edition (ISO > > 15765-2:2016), which has been technically revised. > > > > The main changes are as follows: > > > > - restructured the document to achieve compatibility with OSI > > 7-layers model; > > > > - introduced T_Data abstract service primitive interface to > > achieve compatibility with ISO 14229-2; > > > > - moved all transport layer protocol-related information to Clause 9; > > > > - clarification and editorial corrections > > > > Yes, I've checked the release notes on the ISO website too. > This really looks like editorial stuff that has nothing to do with the > data protocol and its segmentation. This is also my feeling. Short story, I think it is reasonable to quote ISO 15765-2:2024 instead of ISO 15765-2:2016 in this document. > >>> > >>> Here, I would suggest the C99 designated field initialization: > >>> > >>> struct sockaddr_can addr = { > >>> .can_family = AF_CAN; > >>> .can_ifindex = if_nametoindex("can0"); > >>> .tp.tx_id = 0x18DA42F1 | CAN_EFF_FLAG; > >>> .tp.rx_id = 0x18DAF142 | CAN_EFF_FLAG; > >>> }; > > > > Typo in my previous message: the designated initializers are not > > separated by colon ";" but by comma ",". So it should have been: > > > > struct sockaddr_can addr = { > > .can_family = AF_CAN, > > .can_ifindex = if_nametoindex("can0"), > > .tp.tx_id = 0x18DA42F1 | CAN_EFF_FLAG, > > .tp.rx_id = 0x18DAF142 | CAN_EFF_FLAG, > > }; > > > >>> Well, this is just a suggestion, feel free to reject it if you do not like it. > >> > >> At least I don't like it. > >> > >> These values are usually interactively given on the command line: > >> > >> > .can_ifindex = if_nametoindex("can0"); > >> > .tp.tx_id = 0x18DA42F1 | CAN_EFF_FLAG; > >> > .tp.rx_id = 0x18DAF142 | CAN_EFF_FLAG; > >> > >> So have it in a static field initialization leads to a wrong path IMO. > > > > There is no such limitation that C99 designated initializers should > > only work with variables which have static storage duration. In my > > suggested example, nothing is static. > > > > I see this as the same thing as below example: > > > > int foo(void); > > > > int bar() > > { > > int i = foo(); > > } > > > > int baz() > > { > > int i; > > > > i = foo(); > > } > > > > In bar(), the fact that the variable i is initialized at declaration > > does not mean that it is static. In both examples, the variable i uses > > automatic storage duration. > > > > Here, my preference goes to bar(), but I recognize that baz() is also > > perfectly fine. Replace the int type by the struct sockaddr_can type > > and the scalar initialization by designated initializers and you > > should see the connection. > > Oh, sorry. Maybe I expressed myself wrong. > > IMHO your way to work with an initializer is correct from the C standpoint. > > But I think this is pretty unusual for a code example when an > application programmer starts to work with ISO-TP. > > You usually get most of these values from the command line an fill the > struct _by hand_ - and not with a static initialization. > > That was my suggestion. OK. I get your point of view, which I think is a fair argument. So let's keep it as is. Just to conclude the debate, in real life, how to write it would depend on the situation. You may for example receive the values as function parameters: static int tp_bind(const char* ifname, canid_t rx_id, canid_t tx_id) { int s; struct sockaddr_can addr = { .can_family = AF_CAN, .can_ifindex = if_nametoindex(ifname), .tp.rx_id = rx_id, .tp.tx_id = tx_id, }; int ret; s = socket(PF_CAN, SOCK_DGRAM, CAN_ISOTP); if (s < 0) exit(1); ret = bind(s, (struct sockaddr *)&addr, sizeof(addr)); if (ret < 0) exit(1); return s; } Or, if you get the values from the command line, you could have an hybrid approach: int s; struct sockaddr_can addr = { .can_family = AF_CAN, }; char ifname[IF_NAMESIZE]; canid_t rx_id, tx_id; int ret; /* Parse command line and fill ifname, rx_id and tx_id */ addr.can_ifindex = if_nametoindex(ifname); addr.tp.rx_id = rx_id; addr.tp.tx_id = tx_id; s = socket(PF_CAN, SOCK_DGRAM, CAN_ISOTP); if (s < 0) exit(1); ret = bind(s, (struct sockaddr *)&addr, sizeof(addr)); if (ret < 0) exit(1); In the end, there is not enough context to decide which one is best. And, I diverged too much. Francesco, keep the original. > > > > ** Different topic ** > > > > While replying on this, I encountered something which made me worry a bit: > > > > The type of sockaddr_can.can_ifindex is a signed int: > > > > https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/can.h#L243 > > > > But if_nametoindex() returns an unsigned int: > > > > https://man7.org/linux/man-pages/man3/if_nametoindex.3.html > > > > Shouldn't sockaddr_can.can_ifindex also be declared as an unsigned int? > > > > The if_index derives from struct netdevice.if_index > > https://elixir.bootlin.com/linux/v6.8.6/source/include/linux/netdevice.h#L2158 > > which is an int. Ack. > I don't think this would have an effect in real world to change > sockaddr_can.can_ifindex to an unsigned int. > > I wonder if it is more critical to existing user space code to change it > to unsigned int or to leave it as-is ... The only impact is the warnings if compiled with the zealous flags which warn on conversion between signed and unsigned, which would normally be a sufficient reason to change. But, I understand that this if_index is also a signed int at other locations in the kernel, so let's keep it as such in our code. > Best regards, > Oliver