From patchwork Thu Jun 2 16:04:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1985 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 8E9883F06D for ; Thu, 2 Jun 2022 18:04:40 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id y4-20020aa7ccc4000000b0042df06d83bcsf3758857edt.22 for ; Thu, 02 Jun 2022 09:04:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185880; cv=pass; d=google.com; s=arc-20160816; b=XZvztcXrqfSH80OD3alKcxfrjdV6Xb2O50H2WVSzL24Yi5Iq3x5VpWCb4V+zxPNWT8 vevreMVREWWtrufl2dFjUtQN+gtrI+suCDKAndncXjcMvSG6u2+CGI4klHzAf+xdQFjN xx78v4mLQiZKQ9csxZOGd/2mp+Dfb1S7QrqivAkbiyNKqTI5nYIalDWEkeN23MahsYrL KjzeJ9RkZOCZmeunRm7vkmeVo8C21u8VI+jqbOwcgeBm2zUAPfG4rzgH2bWlXi0hX97A d+VA2aWhytyvg4e9XrG/dlkSLBpbrVv+urtlFTqSJDrY6DWWehfPSMFALn+ZQvb15YJn uTwA== 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=xVDDKttGuUFpBopsz2VaQbHsYnfKOiRNcis+ZWBPcpU=; b=V5bNnVkeTk2li7PLHVPzAoM7bMkJCOWE25iEE9/btPkgPhzPdogMDtCJ4dZTFnwuf/ wU04WD1l3QEMMt5LTb2/rTld/6MVGBPQr5PMp6lANsoaSIiLX2m6Nxth+5NFzo6MZS5P Wuv32o2tXYkzSZU3VvoCwo4J3VoNKHwlLBvdyVTBsdEDwMDFvZt4jmh7ellelgjTgETg w31zN2WgIg1SVLebTdgCR4R1Oub6QhmO/deS3vO2QGCFa/vJw/5A7kMPz/ixdLYJNMTS TytlmKhW/UZkOgEimJ8EyxJm2UC4FrqpoJlf7lTmqu6ka2JI3iW5PKLkKO+2GEVmMF3e vgnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=a9gX8E3T; 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=xVDDKttGuUFpBopsz2VaQbHsYnfKOiRNcis+ZWBPcpU=; b=V35mwjP+qefO11ArsYslFCTajMlhzRGl3wz0obQ9LhGRlknpG1l17Gaw3yzgNEvvCN skwiw9nv1gz5qw9OOfyJiCQSZCzHfip5M1LXvBuOVl71G2uXMkPnnuddhyx6phztKH9/ izKz41phKxyBpZ3UvxrkTUS0J7CzWEZnZr52o= 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=xVDDKttGuUFpBopsz2VaQbHsYnfKOiRNcis+ZWBPcpU=; b=OK3e44F9zsRuziU5z8AWScd+T6Hh1Oh36xeOH4Dpc3B+JTuLzVAkbrjE/ZxvQ3QIp2 r8jglFhzVzraLmwBHW88Q7IsX9TgpCCdVfyczcZ1sieq322d9e+vPqEfbAVRlMbnkjgB ubKm8e16GHr98s96wArHdNwbs9CxLA1YU+vXjPWYYQ8bvN9okxJFCPmbOeKbRBeZJX1e Z3oJwVUMTu7hHC7HbArELi/ImeOPAfX6oBhL68sA2Pkt5HlkGB0rTC+s56eU6slk63Cy o0blX15tXvtoTHKEz6FuvV1QQTshGpsv3hFS0Zx6fcuLGsclQA+7G99YrWN3nfqOIFUR H7ug== X-Gm-Message-State: AOAM531weNbbJgVRLzT4GmyaDDarcELGvdPlRp5SQSclojQ5jOlATRbl SiBWJ/U59xXE9CgNq3iUHUpY3nke X-Google-Smtp-Source: ABdhPJyEecuPNmQAUyW84hZh60BpFrul6bT/jkXRe0Ahe0L0xLKXylfxUSn+pI0PEgRgUuwl+W4xCQ== X-Received: by 2002:a05:6402:d05:b0:425:b5c8:faeb with SMTP id eb5-20020a0564020d0500b00425b5c8faebmr6232064edb.273.1654185880167; Thu, 02 Jun 2022 09:04:40 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:2ad6:b0:6fe:976a:7a5 with SMTP id m22-20020a1709062ad600b006fe976a07a5ls2947183eje.7.gmail; Thu, 02 Jun 2022 09:04:39 -0700 (PDT) X-Received: by 2002:a17:907:a426:b0:6ff:6c9f:7a3a with SMTP id sg38-20020a170907a42600b006ff6c9f7a3amr4890460ejc.316.1654185878991; Thu, 02 Jun 2022 09:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185878; cv=none; d=google.com; s=arc-20160816; b=twdmhBFM4P6mv2muW+seu73fQyoci1cRhfcf/2wZL8g4jHDAmn0wwQjeOLwOB5Rmm6 g/OYpwhUGCFISEI/5OJgd+Hac2FlR9S08nUwWRuG6OCFmbSrw2i3aulF+KQS/E0HxTtM HAMcpMWMBAU4LFOxvgpOCPSsfvXd/kpM7kfuSGW0t1SOUtriMimxxlcY97qGURyQu+IW qiT3uT4d+GnSpgaJYBRqOKwyGSBbP9lzJdijJTiYw8hfTuoIw13Lc7j9wwZPWJiWsvCD C7wDXx/Uxx8OVU6+bxQeLzgr4cU57/fe9ukTZCrzaDPuAdcuffGXkhq0Ceb2HMvXZOH4 eWyA== 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=cyCw9sXvusNqzQgXPg7y/ZOR5VM52Ch+bhMbBfl1FjM=; b=JSePNxNFXRD/SG0yg9BKqt7Y1iTTvlm2baXJ2xLpGWjUC9yXJ5lz4hwzzQNCrE7Vtx LEbfHG16Y1ZCwmjfVweKch6l9vye022F8JaOcbJkLsUj3otdP5uVrkZ4hwd4RwDMQamt 0DXqCedowesdcJdHKgi5cSMzdOmC+M25TWijvtLBRkWBgfgQRDi1UtK03/e20BVWvCca ZLk2ic7hwnWS0BLOZq4FIdjrHe4L+q0Ug92UzBatoED2PVD/B0fx59kCrqbGIE20hhrE +KmcpVR5ZcYxroC/Nw9Pl3+8t3+MpN6ZLhhkgzTUu6bzOltUk6Mc01U8LmMU2WuO+ifE L1ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=a9gX8E3T; 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 o11-20020a170906600b00b006ff8320841dsor2683624ejj.92.2022.06.02.09.04.38 for (Google Transport Security); Thu, 02 Jun 2022 09:04:38 -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:3e8b:b0:6fe:f848:f5b with SMTP id hs11-20020a1709073e8b00b006fef8480f5bmr4934032ejc.374.1654185878333; Thu, 02 Jun 2022 09:04:38 -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 f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:37 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 00/13] can: slcan: extend supported features Date: Thu, 2 Jun 2022 18:04:21 +0200 Message-Id: <20220602160434.225417-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=a9gX8E3T; 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, the whole series has been tested. 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: - Remove an useless check on bitrate. - Fix the spin_unlock() path in the slcan_exit(). 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