From patchwork Wed Jun 8 16:51:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2028 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B6E0F3F1F7 for ; Wed, 8 Jun 2022 18:51:25 +0200 (CEST) Received: by mail-ej1-f71.google.com with SMTP id gr1-20020a170906e2c100b006fefea3ec0asf9646926ejb.14 for ; Wed, 08 Jun 2022 09:51:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654707085; cv=pass; d=google.com; s=arc-20160816; b=v+OU9RUR6ki3GJClRzBY5RghpyTa8LOjPbwGd682jweHgO/U6rYCWs0fUu2x8lXCFd QXG7c5uK/p/NlwDCMyYd9qrbaD6wGsiO03rLD8yRvF7nqXBhZLDHzZVXmHwDvXHJ9Zto 4MH5Yh7cqTJptJHBuvoxAIsaDN9jMCRjHou5SjWQwpOcodM/fkZr+7x1Gp6N3WHyLFod HRATcea3mebipHF0wLWRvT6Zp/n5ObUO/Nii4xJiEpliFCtFfaCHt8kVOh8F/ZlI9IzP VrTkFlhAn70sPFFwlEs3QMSOvDbKXkBPOtxzOxO5Lschz1NmCCedKM6LLhZb57KvsIOB s+Bg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=/jvayRKHoPZamINNLC7LP5MLrYJ09ZslGihWGl0FJ+c=; b=w1SlNKJevWwjMP9UCclpHQ+O8LW6/by+9P8/a1lDdbXy8rhm5FnNTA3oS4XvtZ29jf O7q5WVzg24m1CkekU/Rd/QJuMUkqGueH+mOk5Rz9dACn/diNC5OOL6ljrfJevswjADHI hhMgYTN1mkmJGyshD+O8OtzY8K0PdLtVfc5GG57XjKVZbnPbALmDTa5ddkr035xgmGk0 dogmERs1QsgzfQt11VV/trv17Z7rBnrWeziQWYoQoiYYbtnXhg3Ak7QVDhLBKGMU8u08 eGmjnykGc86BK3BFEvdTCUpUnaMmSXvQoBIggdLvF6Typny6BEiPQy/g5HO3rXanAAhR 3F4g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cOcnVnvR; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=/jvayRKHoPZamINNLC7LP5MLrYJ09ZslGihWGl0FJ+c=; b=jlDglRWkrDx91OABCdcFyv88PQBhqYR3xBZXz9MDwjuEomS/+PXOXI5nD5SDjVQBVu 4fSo7JU5qia3cKCdsannxhNkrtwGd0drTV0B4lla616EV/fedX8oGP3GRQkWxQZOEvbt XPBEPmDvxz+61IP8AfWOzvEg66WNIDmQ1TEdo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:list-unsubscribe; bh=/jvayRKHoPZamINNLC7LP5MLrYJ09ZslGihWGl0FJ+c=; b=vtcM9t6xWtiB/mp8Wvlqu4ITrXpe0W1Z4/SrZdBniGlru6BLfCdhz0Bs36P0j1r1Nk ZPWBXbHv3aTwO6ZLG3/K6hpQUNuo+jS6a67Hsalm1knyJ4oSAJrztuwUSdZeIkUcLN2P zb4ntOSY3C/aAuyzBdikW6M1B9CCcm+lB1a47MTSuwsS0joh9y70dlH6ZD1QLq8r1Amc KJ9s9MZyYcCiu2AX3EXbmuUu+xwkhW++v8TdN+AcpUKygQsOYNLRpnYg+kOHG7QZjV1Z fbFH7AvU3IPMJUsQ/AKFgYvRl6uMt2FYwmykgEV9FAL3qF0PNKPwMd2qYpMeW6x+9rVA aFnA== X-Gm-Message-State: AOAM531F6XQw45iDMvfMgrs1sBjQnQ0BUPHobmiftSOuDJj1Zy2ajuIV zTRTfwylAOjT0TJY64LGFxxVzVOw X-Google-Smtp-Source: ABdhPJyCn6OZmiywUt+PdBL23K1oDLLYShAhnQnJklBJLVXmzTUlZwusLg3zwfYXk9G5LMXqDtFOoQ== X-Received: by 2002:a17:906:74c7:b0:711:fa45:4f88 with SMTP id z7-20020a17090674c700b00711fa454f88mr2745559ejl.347.1654707085358; Wed, 08 Jun 2022 09:51:25 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:5414:b0:431:6a31:654d with SMTP id ev20-20020a056402541400b004316a31654dls189295edb.0.gmail; Wed, 08 Jun 2022 09:51:24 -0700 (PDT) X-Received: by 2002:a05:6402:400b:b0:42d:c902:6c75 with SMTP id d11-20020a056402400b00b0042dc9026c75mr40966902eda.32.1654707084218; Wed, 08 Jun 2022 09:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654707084; cv=none; d=google.com; s=arc-20160816; b=eZdKjs/qwBihKl3KdA0aF/R1rgmm7CtVKQTp2NgvKDUv4YGbKleRnyEDFKn41bLZRx tEsJ8db3Lbu/+FHsWD1hzLyfW/VqbtU83FY1vb1EVTos1Lg41ElNZYMyt/BIXj3SZpzq NhA3D5QunsUjYTQ4LJ9ORAilx9i+yJYZCkMeBiyvSeGlqfeB4bP5uBIqdJlNFuaoOx0F rC7FiZ0qjfeScUW4Q2zjQudPFnWycbDXTU7PpCmVprfTqOIL/sfpmvXk2bABnnYKGzK0 aYApkmtWtaUvvp/IJiR44ST1dvvKs3ZMDqeXIoxInW9cji2zeUYbH1XaHNg7gO4k0/ss Zuaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=xYiKq2p8kde5xkKx+lFxNCjXxvmOUB4R02jax8DEbkQ=; b=hZV5IqJ/KKQTXFQBR0ryWZRunwhtfVt59NH4e8zrWdkkv+vxZoTy0qXD6IhCCYDgSL 6BCZPgM3gfINbFeIQylJ2UHmg6wNaqV4q0sQ9CzSnhsyQJcClSTWnVJpetgU4UDaen9U MlgTGmqwSdnyOcEO0UOcBvOzXz1pu6IHMHLYfei6ax4rXWLmS5jphqDxIisVAVsYvAgj 6v9FJgyYtP6lZwNsRIOnBqUSJaVDN66JtJMqOOhqYMzvA06JSepGycGVCj0fhUlSi6Ft MF8FLTqdhnx3Q2YxiV7LXK4JYydb+n9kT2VDdbkUzn9E+DRPhF72Yd6VsANrouaZsomG C+qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cOcnVnvR; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id t19-20020a170906269300b006fef55785d9sor9711891ejc.96.2022.06.08.09.51.24 for (Google Transport Security); Wed, 08 Jun 2022 09:51:24 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:5010:b0:711:f093:3a93 with SMTP id fw16-20020a170907501000b00711f0933a93mr5628614ejc.620.1654707083946; Wed, 08 Jun 2022 09:51:23 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id c22-20020a17090654d600b0070587f81bcfsm9569071ejp.19.2022.06.08.09.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:51:23 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Greg Kroah-Hartman , Jakub Kicinski , Jiri Slaby , Marc Kleine-Budde , Paolo Abeni , Sebastian Andrzej Siewior , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 00/13] can: slcan: extend supported features Date: Wed, 8 Jun 2022 18:51:03 +0200 Message-Id: <20220608165116.1575390-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cOcnVnvR; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This series originated as a result of CAN communication tests for an application using the USBtin adapter (https://www.fischl.de/usbtin/). The tests showed some errors but for the driver everything was ok. Also, being the first time I used the slcan driver, I was amazed that it was not possible to configure the bitrate via the ip tool. For these two reasons, I started looking at the driver code and realized that it didn't use the CAN network device driver interface. Starting from these assumptions, I tried to: - Use the CAN network device driver interface. - Set the bitrate via the ip tool. - Send the open/close command to the adapter from the driver. - Add ethtool support to reset the adapter errors. - Extend the protocol to forward the adapter CAN communication errors and the CAN state changes to the netdev upper layers. Except for the protocol extension patches (i. e. forward the adapter CAN communication errors and the CAN state changes to the netdev upper layers), the whole series has been tested under QEMU with Linux 4.19.208 using the USBtin adapter. Testing the extension protocol patches requires updating the adapter firmware. Before modifying the firmware I think it makes sense to know if these extensions can be considered useful. Before applying the series I used these commands: slcan_attach -f -s6 -o /dev/ttyACM0 slcand ttyACM0 can0 ip link set can0 up After applying the series I am using these commands: slcan_attach /dev/ttyACM0 slcand ttyACM0 can0 ip link set dev can0 down ip link set can0 type can bitrate 500000 ethtool --set-priv-flags can0 err-rst-on-open on ip link set dev can0 up Now there is a clearer separation between serial line and CAN, but above all, it is possible to use the ip and ethtool commands as it happens for any CAN device driver. The changes are backward compatible, you can continue to use the slcand and slcan_attach command options. Changes in v2: - Put the data into the allocated skb directly instead of first filling the "cf" on the stack and then doing a memcpy(). - Move CAN_SLCAN Kconfig option inside CAN_DEV scope. - Improve the commit message. - Use the CAN framework support for setting fixed bit rates. - Improve the commit message. - Improve the commit message. - Protect decoding against the case the len value is longer than the received data. - Continue error handling even if no skb can be allocated. - Continue error handling even if no skb can be allocated. Dario Binacchi (13): can: slcan: use the BIT() helper can: slcan: use netdev helpers to print out messages can: slcan: use the alloc_can_skb() helper can: slcan: use CAN network device driver API can: slcan: simplify the device de-allocation can: slcan: allow to send commands to the adapter can: slcan: set bitrate by CAN device driver API can: slcan: send the open command to the adapter can: slcan: send the close command to the adapter can: slcan: move driver into separate sub directory can: slcan: add ethtool support to reset adapter errors can: slcan: extend the protocol with error info can: slcan: extend the protocol with CAN state info drivers/net/can/Kconfig | 40 +- drivers/net/can/Makefile | 2 +- drivers/net/can/slcan/Makefile | 7 + .../net/can/{slcan.c => slcan/slcan-core.c} | 526 ++++++++++++++---- drivers/net/can/slcan/slcan-ethtool.c | 65 +++ drivers/net/can/slcan/slcan.h | 18 + 6 files changed, 539 insertions(+), 119 deletions(-) create mode 100644 drivers/net/can/slcan/Makefile rename drivers/net/can/{slcan.c => slcan/slcan-core.c} (65%) create mode 100644 drivers/net/can/slcan/slcan-ethtool.c create mode 100644 drivers/net/can/slcan/slcan.h