From patchwork Tue Jun 7 09:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2013 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 996F33F08A for ; Tue, 7 Jun 2022 11:48:11 +0200 (CEST) Received: by mail-wr1-f72.google.com with SMTP id w8-20020adfde88000000b00213b7fa3a37sf2928066wrl.2 for ; Tue, 07 Jun 2022 02:48:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654595291; cv=pass; d=google.com; s=arc-20160816; b=WQydeajqIKtZHINyrZ3EI7NVyYOOzy+XW+mnVQ88cpTKayoJzf24/nN0fAPC2X7H2s gYoRQTUNfFJ7bhOpm/EWQrjb7QHWEYq/NCy5VJS/N4xwJ8zP41N0chwbks49zvu3Albk ozZGYRxbJH7infGEhJmqyDV9chzX4BFyh4gD+Lr1WdAHJ8OxPDNVUJKaBoUXUHEqNZRz hGXJEgOJujdqTE6jly+ki9D/AgZlnXZt+c1I5qvyDbrE1olcigSNXwU+d/l2EIwdIcrs HvnlPxLfUMvm6Ydix7wfSx9wV7wheq7VBWOjJf7o8m3TMB3x5DT6F74Lz/MI58MALn+N MLtA== 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=OZNOIeTq6ioSjLnWYIJht3DIqKd86hxF4te6cmHG2Z8=; b=V4uAnBj+ZENRC+/E7skcsqus6MR0+rTX5QmGE9ZqqXoaao7bdchoho6d38VolVaFp3 HB3irFV0nFkQQJM/gCXGTF+VbIfkyapzrFF4buZdm10DTrmN8KALfLc9tvXEYB1Qnk5k vIiHYCvjTWLdnLBH6MKC5X/Y+g4EL+E18u0SClqUcNEC787tN7aI3yM6HV9lJDsUkHgH i1oAsaWnW5DCZnZ47svKImZGtMlQIK2wATF19kFcWcAmXNoY4riVQWswPUj1Bwzt9bzD bfyXyQ/m9hl3UAK9H5/H4VtxYHIvlIc9rDQiH4h1IkVDhcRaU2n73AAysqR4J0t1g8jM bd5A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jDESy8of; 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=OZNOIeTq6ioSjLnWYIJht3DIqKd86hxF4te6cmHG2Z8=; b=qokyduRvwkyWn3jmr6GSyLHAjX4X8+lV7a0Qzy0RuLeJexOE7W6ZX0xgc0a4lWkQZ4 qiZE5QDIYjxd0cCsebyR/oL7RmMN1vXu7uzfsKG0/C5dkKloYnR2gC2W78HV48LtYyd5 75GT9YdbLq0K07nOOyvKQgk6Z5UbZFdPwhk0Q= 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=OZNOIeTq6ioSjLnWYIJht3DIqKd86hxF4te6cmHG2Z8=; b=TGxJwqE3sLXDRTttYzQPIsOHbDnuyw+lYaAD5f8Z6THhlBEN3NZPC8FZp/pJCcVHFJ 2ID7Xb4vMFMcIR4Trpe5kJm2F0+ihDxfx2jfjNCv3rftnPhv7L6l2i0ygioetNf5ALJv lGytnwsn196imFUVpt4QyLL2qryJ9bY1/F5B1YZhyreFnhWE/mhGFddAygjHDoYYpetH 788579yhbpziv32/irgtAjU5lZk991dqecl8ERpYWiCJtnxPv8vbRSaOqoqCkHGin0S0 tWrlGF4FLVcl4TwnpK43DiFNPVatFT1qEd6/5Em2OY5oQ/CWjSZupVYgbGWzd/Yxx02u M8rw== X-Gm-Message-State: AOAM533nqD+YuFiwUz7iH0UN+3Hhg4YwSS7d6SKm0Bk7l2MVFVGJqCb1 f3YlemHKuM9ZCfe3EcCTYpsCM+rA X-Google-Smtp-Source: ABdhPJy08elbYVDrGUpwSfVwLg5rQ6HEywRGSGzXqBxEA4bbvORoBgf/ygTmWnmzdZ024oY3kazl0w== X-Received: by 2002:a1c:29c3:0:b0:350:9797:b38f with SMTP id p186-20020a1c29c3000000b003509797b38fmr57383202wmp.22.1654595291064; Tue, 07 Jun 2022 02:48:11 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:1c8f:b0:397:380f:f614 with SMTP id k15-20020a05600c1c8f00b00397380ff614ls5111460wms.3.gmail; Tue, 07 Jun 2022 02:48:10 -0700 (PDT) X-Received: by 2002:a05:600c:2244:b0:39c:4060:1ec9 with SMTP id a4-20020a05600c224400b0039c40601ec9mr20832945wmm.147.1654595289954; Tue, 07 Jun 2022 02:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654595289; cv=none; d=google.com; s=arc-20160816; b=bKHPHXAFE5o3HAvF838slG6LLVso5f+qwx4If+LBGjgNAJyVK6qune7T7OP0wy8EZu NbqF/mm3TDyo0xGk8dceIJJx34ITPfaXxEXJDW2AAijm0vHGwuav09NC5qeralstqcFf Jt/gJfYKxfidE6ehsnLUtNQqk8iDin6fbazmpCoXhssTYL01c1RZDuFFNL5R4t5JINHa ezM784jMy1EYRgtBeT+PR/TmVArV7FEYS3w7/e5y5LcGNQhQmZxA8ydfjYZgqQrkT15L BJyNfH1oBVhM/kOjktVEz3rdGXg0Z0g7t8deUAKZl97rRNezhgm/GVrtVhUu5xMOsTeM uHpw== 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=59RavXyEta5t8sr+YdZ4nWyDRUr5ofB/YBoSuRW6FK4=; b=qdVyuc63MpEDaDzULG4fjjuho4EAtkP/cK0b2JY+tJSUCYGaRwuFCb/PIRUzZ0nxQY +T4cPzN49lg4a0NtepbNyj6/7uARuWOl5pc9ydI2IKERVVqqWG1FnX4mHFOfHX+XWKKb mcHjcAgMeIdreAN6sssWAVR5dJ0H/s16jLpa6hq+5Yyh3oGBv+J7Z4sr51pLIBKKifGa GL/w7K4oT33mjblZi6c0CKbfRIITyUC91tTTN6PQPSiQ3u1M8Ywoz3pTHJ1i65zsEZXe 3i4Eiyin2F+km5a97u8GcOIUvKtkhp4DEojUWwVw/jvFreCoEx1jxhLxd5lqVTQ6fV/G oqHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jDESy8of; 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 bd7-20020a05600c1f0700b0039c4a2cf724sor2126860wmb.29.2022.06.07.02.48.09 for (Google Transport Security); Tue, 07 Jun 2022 02:48:09 -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:a05:600c:2d88:b0:39c:3c07:2845 with SMTP id i8-20020a05600c2d8800b0039c3c072845mr23473258wmg.116.1654595289674; Tue, 07 Jun 2022 02:48:09 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (mob-5-90-137-51.net.vodafone.it. [5.90.137.51]) by smtp.gmail.com with ESMTPSA id o4-20020a05600c510400b0039748be12dbsm23200547wms.47.2022.06.07.02.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:48:09 -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: [RFC PATCH 00/13] can: slcan: extend supported features Date: Tue, 7 Jun 2022 11:47:39 +0200 Message-Id: <20220607094752.1029295-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" 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=jDESy8of; 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 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. 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. 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/Makefile | 2 +- drivers/net/can/slcan/Makefile | 7 + .../net/can/{slcan.c => slcan/slcan-core.c} | 464 +++++++++++++++--- drivers/net/can/slcan/slcan-ethtool.c | 65 +++ drivers/net/can/slcan/slcan.h | 18 + 5 files changed, 480 insertions(+), 76 deletions(-) create mode 100644 drivers/net/can/slcan/Makefile rename drivers/net/can/{slcan.c => slcan/slcan-core.c} (67%) create mode 100644 drivers/net/can/slcan/slcan-ethtool.c create mode 100644 drivers/net/can/slcan/slcan.h