Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1274003rwe; Sat, 27 Aug 2022 04:51:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR7x9O2mZMUDksMfsxYHJPzmEVzpOfLHUSvfmwxGfMltkRYTyakpLpCzGK/z2MuhHSZmh8Cl X-Received: by 2002:a17:902:f681:b0:172:f8ee:b1f7 with SMTP id l1-20020a170902f68100b00172f8eeb1f7mr7758544plg.19.1661601107915; Sat, 27 Aug 2022 04:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661601107; cv=none; d=google.com; s=arc-20160816; b=ZPv7cY75EiNU6yrz/zKKCna+ym4hNvwMt1+IvnSNNAo3tZvYUy4r/oLcpyFpLTWUpF uR0SIwhLsQ81rZZAx2MpaXyCb6kgv7zrAWest4l+BpKCzb5UdfCgE4KP82AD0RQJBIHn TCLA153RB5Qdb2HoGhNcZNk1IoIietihJAy/6/RPq4BmvtpJ1yq5+d7JR8fJmx1cj/Ub 147u+UcIhBOx96Q4J+g0f6Yb3aguZnNvwM/+gbApFbiCYnZKWYx4KPiQXtfANmDJYBEa wxeZSTML3f5NK4W42MgKKUE/bhZ6hX1s+E4qT9S8JvkN4xIZuOuZVU+vawqxsMncZTDm z8hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=VaJk7sINEIae+TNpvJ5IvFGcM4VJpS4JY8vRgYaAwNo=; b=I1ToJLosXqR/zyWnL4EDknOVix/2e+MBxu+LI5OTZzMk94Zn9g7RxcRv0UO1WSykhA G7N/LvQhSi3Kmu/UQYF9+gq+jCpR+6+GnnLHbAXRmUEMeeTANyOfn/cd1+AvjFs7OXql i0lDGPza9fFFMBVXWOtAYTpJLnG10SFd+BIYnk2UfxOwpq46nhN7NhCaMUAQIiWanGIZ lRzL0fx+UDchBTY5JAPOWOUDv/PxuajWFhPAjIilEzISL/QHnCUl11RJAlZdoXAM9P0W CpSXFiajUgi+zTVe0407I5zfyJbXUiCduw2xKAGrCPkJe3sZLhP5R5eLdJsOV9QEu+3H wBHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hartkopp.net header.s=strato-dkim-0002 header.b="B2xS/I0g"; 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=REJECT sp=REJECT dis=NONE) header.from=hartkopp.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a631b08000000b0042ba464cc6fsi1072279pgb.373.2022.08.27.04.51.35; Sat, 27 Aug 2022 04:51:47 -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=@hartkopp.net header.s=strato-dkim-0002 header.b="B2xS/I0g"; 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=REJECT sp=REJECT dis=NONE) header.from=hartkopp.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234499AbiH0LMq (ORCPT + 99 others); Sat, 27 Aug 2022 07:12:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbiH0LMn (ORCPT ); Sat, 27 Aug 2022 07:12:43 -0400 Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [81.169.146.166]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F11954C99; Sat, 27 Aug 2022 04:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1661598744; s=strato-dkim-0002; d=hartkopp.net; h=In-Reply-To:From:References:Cc:To:Subject:Date:Message-ID:Cc:Date: From:Subject:Sender; bh=VaJk7sINEIae+TNpvJ5IvFGcM4VJpS4JY8vRgYaAwNo=; b=B2xS/I0gWOpeNipmsYABfVSUN4RhWuEBF0eWc1yd0Qds8tdmY8YN0ZUKtdY4EN7Eno 72jNfgxe8AOs84207oWUp6zr8pQetJfVceqPiV9t8CZ4Gf2DnxXUzwuFCFonX7L2Zf/1 2whgR4oUgVALbgv1PAn2FvCv7RSddA70MF01/GT98RRfO5DMEkOHNF4noKBZHaLCgkg0 ds2DkcE7F5iErMj/hTUY8V8vPZZh4BMIaeW6GLeo8+F8dID2A+3rDh/H3O67Qz5AyoOr Kx/VSTHLHuwW/sl0dnGb7+J5GRsxDdKP82wqkVY38k3g4b3hmQHzAR3iCF3Sx9wYPhfa 2Img== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P2MHfkW8eP4Mre39l357AZT/I7AY/7nT2yrDxb8mjG14FZxedJy6qgO1qCHSa1GLptZHusx3hdIrpKytISr6jamATg==" X-RZG-CLASS-ID: mo00 Received: from [IPV6:2a00:6020:1cfd:d104::1e4] by smtp.strato.de (RZmta 47.47.0 AUTH) with ESMTPSA id Icb1b0y7RBCNIdT (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Sat, 27 Aug 2022 13:12:23 +0200 (CEST) Message-ID: <33cab5f4-8391-a59f-0873-b359c9c13917@hartkopp.net> Date: Sat, 27 Aug 2022 13:12:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [RFC PATCH 1/1] can: virtio: Initial virtio CAN driver. To: Marc Kleine-Budde , Harald Mommer Cc: virtio-dev@lists.oasis-open.org, linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Wolfgang Grandegger , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Dariusz Stojaczyk , Harald Mommer References: <20220825134449.18803-1-harald.mommer@opensynergy.com> <20220827093909.ag3zi7k525k4zuqq@pengutronix.de> Content-Language: en-US From: Oliver Hartkopp In-Reply-To: <20220827093909.ag3zi7k525k4zuqq@pengutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 8/27/22 11:39, Marc Kleine-Budde wrote: > On 25.08.2022 15:44:49, Harald Mommer wrote: >> - CAN Control >> >> - "ip link set up can0" starts the virtual CAN controller, >> - "ip link set up can0" stops the virtual CAN controller >> >> - CAN RX >> >> Receive CAN frames. CAN frames can be standard or extended, classic or >> CAN FD. Classic CAN RTR frames are supported. >> >> - CAN TX >> >> Send CAN frames. CAN frames can be standard or extended, classic or >> CAN FD. Classic CAN RTR frames are supported. >> >> - CAN Event indication (BusOff) >> >> The bus off handling is considered code complete but until now bus off >> handling is largely untested. > > Is there an Open Source implementation of the host side of this > interface? > > Please fix these checkpatch warnings: > > | WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? > | #65: > | new file mode 100644 > | > | WARNING: Use #include instead of > | #105: FILE: drivers/net/can/virtio_can/virtio_can.c:7: > | +#include > | > | WARNING: __always_unused or __maybe_unused is preferred over __attribute__((__unused__)) > | #186: FILE: drivers/net/can/virtio_can/virtio_can.c:88: > | +static void __attribute__((unused)) > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #263: FILE: drivers/net/can/virtio_can/virtio_can.c:165: > | + BUG_ON(prio != 0); /* Currently only 1 priority */ > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #264: FILE: drivers/net/can/virtio_can/virtio_can.c:166: > | + BUG_ON(atomic_read(&priv->tx_inflight[0]) >= priv->can.echo_skb_max); > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #279: FILE: drivers/net/can/virtio_can/virtio_can.c:181: > | + BUG_ON(prio >= VIRTIO_CAN_PRIO_COUNT); > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #280: FILE: drivers/net/can/virtio_can/virtio_can.c:182: > | + BUG_ON(idx >= priv->can.echo_skb_max); > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #281: FILE: drivers/net/can/virtio_can/virtio_can.c:183: > | + BUG_ON(atomic_read(&priv->tx_inflight[prio]) == 0); > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #288: FILE: drivers/net/can/virtio_can/virtio_can.c:190: > | +/* > | + * Create a scatter-gather list representing our input buffer and put > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #309: FILE: drivers/net/can/virtio_can/virtio_can.c:211: > | +/* > | + * Send a control message with message type either > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #332: FILE: drivers/net/can/virtio_can/virtio_can.c:234: > | + /* > | + * The function may be serialized by rtnl lock. Not sure. > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #382: FILE: drivers/net/can/virtio_can/virtio_can.c:284: > | +/* > | + * See also m_can.c/m_can_set_mode() > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #408: FILE: drivers/net/can/virtio_can/virtio_can.c:310: > | +/* > | + * Called by issuing "ip link set up can0" > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #443: FILE: drivers/net/can/virtio_can/virtio_can.c:345: > | + /* > | + * Keep RX napi active to allow dropping of pending RX CAN messages, > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #481: FILE: drivers/net/can/virtio_can/virtio_can.c:383: > | + /* > | + * No local check for CAN_RTR_FLAG or FD frame against negotiated > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #521: FILE: drivers/net/can/virtio_can/virtio_can.c:423: > | + /* > | + * May happen if > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #533: FILE: drivers/net/can/virtio_can/virtio_can.c:435: > | + BUG_ON(can_tx_msg->putidx < 0); > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #613: FILE: drivers/net/can/virtio_can/virtio_can.c:515: > | + /* > | + * Here also frames with result != VIRTIO_CAN_RESULT_OK are > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #646: FILE: drivers/net/can/virtio_can/virtio_can.c:548: > | +/* > | + * Poll TX used queue for sent CAN messages > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #675: FILE: drivers/net/can/virtio_can/virtio_can.c:577: > | +/* > | + * This function is the NAPI RX poll function and NAPI guarantees that this > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #698: FILE: drivers/net/can/virtio_can/virtio_can.c:600: > | + BUG_ON(len < header_size); > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #813: FILE: drivers/net/can/virtio_can/virtio_can.c:715: > | +/* > | + * See m_can_poll() / m_can_handle_state_errors() m_can_handle_state_change(). > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #855: FILE: drivers/net/can/virtio_can/virtio_can.c:757: > | +/* > | + * Poll RX used queue for received CAN messages > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #897: FILE: drivers/net/can/virtio_can/virtio_can.c:799: > | + /* > | + * The interrupt function is not assumed to be interrupted by > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #904: FILE: drivers/net/can/virtio_can/virtio_can.c:806: > | + BUG_ON(len < sizeof(struct virtio_can_event_ind)); > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #966: FILE: drivers/net/can/virtio_can/virtio_can.c:868: > | + /* > | + * The order of RX and TX is exactly the opposite as in console and > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #976: FILE: drivers/net/can/virtio_can/virtio_can.c:878: > | + BUG_ON(!priv); > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #977: FILE: drivers/net/can/virtio_can/virtio_can.c:879: > | + BUG_ON(!priv->vdev); > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #1004: FILE: drivers/net/can/virtio_can/virtio_can.c:906: > | + /* > | + * From here we have dead silence from the device side so no locks > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #1025: FILE: drivers/net/can/virtio_can/virtio_can.c:927: > | + /* > | + * Is keeping track of allocated elements by an own linked list > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #1060: FILE: drivers/net/can/virtio_can/virtio_can.c:962: > | + BUG_ON(!vdev); > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #1063: FILE: drivers/net/can/virtio_can/virtio_can.c:965: > | + /* > | + * CAN needs always access to the config space. > | > | WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() > | #1090: FILE: drivers/net/can/virtio_can/virtio_can.c:992: > | + BUG_ON(!vdev); > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #1144: FILE: drivers/net/can/virtio_can/virtio_can.c:1046: > | + /* > | + * It is possible to consider the number of TX queue places to > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #1185: FILE: drivers/net/can/virtio_can/virtio_can.c:1087: > | +/* > | + * Compare with m_can.c/m_can_suspend(), virtio_net.c/virtnet_freeze() and > | > | WARNING: networking block comments don't use an empty /* line, use /* Comment... > | #1210: FILE: drivers/net/can/virtio_can/virtio_can.c:1112: > | +/* > | + * Compare with m_can.c/m_can_resume(), virtio_net.c/virtnet_restore() and > | > | WARNING: Prefer "GPL" over "GPL v2" - see commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity") > | #1273: FILE: drivers/net/can/virtio_can/virtio_can.c:1175: > | +MODULE_LICENSE("GPL v2"); Btw. @Harald: When you want to express your code to be GPLv2 why is your code GPL-2.0+ then? diff --git a/drivers/net/can/virtio_can/virtio_can.c b/drivers/net/can/virtio_can/virtio_can.c new file mode 100644 index 000000000000..dafbe5a36511 --- /dev/null +++ b/drivers/net/can/virtio_can/virtio_can.c @@ -0,0 +1,1176 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * CAN bus driver for the Virtio CAN controller + * Copyright (C) 2021 OpenSynergy GmbH + */ Best regards, Oliver > | > | WARNING: From:/Signed-off-by: email address mismatch: 'From: Harald Mommer ' != 'Signed-off-by: Harald Mommer ' > | > | total: 0 errors, 38 warnings, 1275 lines checked > > regards, > Marc >