Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1435661iof; Tue, 7 Jun 2022 05:41:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEesLIYuTqV95s397pPu2qk8p+ZWWRXHRwyrIEudpF6do7IEAw4BC2OzvQw4OZ3faoDHwH X-Received: by 2002:a17:906:7308:b0:710:dad0:f56d with SMTP id di8-20020a170906730800b00710dad0f56dmr14983768ejc.691.1654605705329; Tue, 07 Jun 2022 05:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654605705; cv=none; d=google.com; s=arc-20160816; b=nioLeZxuRdI9+dFnTiIgNjSKbg0SS/HYuvitNVdKxS2bvcT5Ss58rdCpDx46GB1qr4 c2wOexk8QTUgAWAmmsPvhaiO/M0KK7dwUew80z8BDSNxiT6h0FAOn3VvLmwn9XWC3ZB7 yFvl2ijoIPw7C9asCTM4Z3F5a6HNlG/Zpi0XGN8x3rAcNJFGGIYZ/vMdlKn+OjMYxJu1 UAD7uUlltjzHVUdSNu5H/6UhfK5sz7AjRlwmQo8d6QmRxbqJ8MOshKE5p91Ob5kgscna ZECf3xWqntycmHY3J1745WfMdUjbDn9PrvFS9VHM4e4EtskLqq8UYE3FvcguJNqo8wq7 twkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=59RavXyEta5t8sr+YdZ4nWyDRUr5ofB/YBoSuRW6FK4=; b=Q/nIQMpQ3viFiFINoCKiokp1L62Fxt1NKHrUBZUSv2Cz13udpB7lqAe9RIE8mTivS6 a7UULZKzkFblW8VTaob96NwizFoE+SjO4eoJkQvz0Lv9qPPCblQhz/e6LGsdplOWetTI UNW8wyuee57FSjc+eN06vn0/pcaMzbS2OQP842kuSPEqLw1dFh+aYTrDaoX0tnfEOQ4+ 0Z6rah+Mlfshyi+Mm1AUcO7m9glwdzEdyIiKtLKpicgR24h5L1sw2XbdAzerXbR5amRF O4s125E2cFclG7xx1pjM5TBTIfbpzTOIWeOcd/vLaCr+v3XPAv7wWBKiHUQvCZWUXQN7 fj5w== 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 linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a05640235c500b0042fbc23bfd3si9187787edc.562.2022.06.07.05.41.16; Tue, 07 Jun 2022 05:41:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jDESy8of; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239944AbiFGJsX (ORCPT + 99 others); Tue, 7 Jun 2022 05:48:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239975AbiFGJsO (ORCPT ); Tue, 7 Jun 2022 05:48:14 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D7DE52B4 for ; Tue, 7 Jun 2022 02:48:11 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id m39-20020a05600c3b2700b0039c511ebbacso2381904wms.3 for ; Tue, 07 Jun 2022 02:48:11 -0700 (PDT) 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 :content-transfer-encoding; bh=59RavXyEta5t8sr+YdZ4nWyDRUr5ofB/YBoSuRW6FK4=; b=jDESy8ofDeN1851pfvFKhws3saitHU8Qf68t0qnmzaOWDoMfXKcOHnQzvzjczJEKKZ Fk7VYNrCPa+zwFreDrShre8wL5TOeeGxZx7Jgjhi/tkgETCzZR6wY9pwOJ0Cvn21Oi0r J0DPDK9FV0VujnSZqhbB0rE7xysGVImHmw1XA= 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 :content-transfer-encoding; bh=59RavXyEta5t8sr+YdZ4nWyDRUr5ofB/YBoSuRW6FK4=; b=kxcWYMeRoTbwdOahmDyUNWNVRssAZhJnTHayMlcg4PGD3ONh58sm13VoqamQUQGKxO yXmnxq+Il+SO/dG5G+NH8PWa7AshI2blDV1uV4mfQFRGfyhnIcUy6HCtk2v0YcVIRYSY e07nDB98VI+qf1owYUYHstvmnH4DM/VYOYxOQEjyKMWXVQecGysZlnDwGQM8mhCX1hwo u7290MxyheGahHMSvy1gS/y36XVYjADX9n/pUQvDDRExbHGZS3i3ixjrxC9F4YZ7dfXY ZHZcyE/BUXrbmB9S0K0D/Wozi9JApR30xLsUdYNfMcpU6jlZXTglx6zptRIU3jF7H62L J7+g== X-Gm-Message-State: AOAM532Bx/FbuU2++PTl8ZlPbsNSfFt8BT+k/9vQS2NCOVZl9BbbxlaF poYKfkxTuNMNRpSv6uo/ELjs7EG8qWuR1A== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.32.0