netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francesco Valla <francesco@valla.it>
To: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
	Paolo Abeni <pabeni@redhat.com>,
	Harald Mommer <harald.mommer@opensynergy.com>,
	Mikhail Golubev-Ciuchea <Mikhail.Golubev-Ciuchea@opensynergy.com>,
	Wolfgang Grandegger <wg@grandegger.com>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
	Damir Shaikhutdinov <Damir.Shaikhutdinov@opensynergy.com>,
	linux-kernel@vger.kernel.org, linux-can@vger.kernel.org,
	netdev@vger.kernel.org, virtualization@lists.linux.dev,
	development@redaril.me
Subject: Re: [PATCH v5] can: virtio: Initial virtio CAN driver.
Date: Tue, 14 Oct 2025 18:01:07 +0200	[thread overview]
Message-ID: <1997333.7Z3S40VBb9@fedora.fritz.box> (raw)
In-Reply-To: <aO4isIfRbgKuCvRX@fedora>

On Tuesday, 14 October 2025 at 12:15:12 Matias Ezequiel Vara Larsen <mvaralar@redhat.com> wrote:
> On Thu, Sep 11, 2025 at 10:59:40PM +0200, Francesco Valla wrote:
> > Hello Mikhail, Harald,
> > 
> > hoping there will be a v6 of this patch soon, a few comments:
> > 
> > On Monday, 8 January 2024 at 14:10:35 Mikhail Golubev-Ciuchea <Mikhail.Golubev-Ciuchea@opensynergy.com> wrote:
> > 
> > [...]
> > > +
> > > +/* Compare with m_can.c/m_can_echo_tx_event() */
> > > +static int virtio_can_read_tx_queue(struct virtqueue *vq)
> > > +{
> > > +	struct virtio_can_priv *can_priv = vq->vdev->priv;
> > > +	struct net_device *dev = can_priv->dev;
> > > +	struct virtio_can_tx *can_tx_msg;
> > > +	struct net_device_stats *stats;
> > > +	unsigned long flags;
> > > +	unsigned int len;
> > > +	u8 result;
> > > +
> > > +	stats = &dev->stats;
> > > +
> > > +	/* Protect list and virtio queue operations */
> > > +	spin_lock_irqsave(&can_priv->tx_lock, flags);
> > > +
> > > +	can_tx_msg = virtqueue_get_buf(vq, &len);
> > > +	if (!can_tx_msg) {
> > > +		spin_unlock_irqrestore(&can_priv->tx_lock, flags);
> > > +		return 0; /* No more data */
> > > +	}
> > > +
> > > +	if (unlikely(len < sizeof(struct virtio_can_tx_in))) {
> > > +		netdev_err(dev, "TX ACK: Device sent no result code\n");
> > > +		result = VIRTIO_CAN_RESULT_NOT_OK; /* Keep things going */
> > > +	} else {
> > > +		result = can_tx_msg->tx_in.result;
> > > +	}
> > > +
> > > +	if (can_priv->can.state < CAN_STATE_BUS_OFF) {
> > > +		/* Here also frames with result != VIRTIO_CAN_RESULT_OK are
> > > +		 * echoed. Intentional to bring a waiting process in an upper
> > > +		 * layer to an end.
> > > +		 * TODO: Any better means to indicate a problem here?
> > > +		 */
> > > +		if (result != VIRTIO_CAN_RESULT_OK)
> > > +			netdev_warn(dev, "TX ACK: Result = %u\n", result);
> > 
> > Maybe an error frame reporting CAN_ERR_CRTL_UNSPEC would be better?
> > 
> I am not sure. In xilinx_can.c, CAN_ERR_CRTL_UNSPEC is indicated during
> a problem in the rx path and this is the tx path. I think the comment
> refers to improving the way the driver informs this error to the user
> but I may be wrong.
> 

Since we have no detail of what went wrong here, I suggested
CAN_ERR_CRTL_UNSPEC as it is "unspecified error", to be coupled with a
controller error with id CAN_ERR_CRTL; however, a different error might be
more appropriate.

For sure, at least in my experience, having a warn printed to kmsg is *not*
enough, as the application sending the message(s) would not be able to detect
the error.


> > For sure, counting the known errors as valid tx_packets and tx_bytes
> > is misleading.
> > 
> 
> I'll remove the counters below.
> 

We don't really know what's wrong here - the packet might have been sent and
and then not ACK'ed, as well as any other error condition (as it happens in the
reference implementation from the original authors [1]). Echoing the packet
only "to bring a waiting process in an upper layer to an end" and incrementing
counters feels wrong, but maybe someone more expert than me can advise better
here.


[1] https://github.com/OpenSynergy/qemu/commit/115540168f92ba5351a20b9c62552782ea1e3e04


Regards,
Francesco




  reply	other threads:[~2025-10-14 16:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-08 13:10 [PATCH v5] can: virtio: Initial virtio CAN driver Mikhail Golubev-Ciuchea
2024-01-08 19:34 ` Christophe JAILLET
2024-02-01 18:57   ` Harald Mommer
2025-03-12 10:31     ` Matias Ezequiel Vara Larsen
2025-03-12 10:41       ` Marc Kleine-Budde
2025-03-12 13:28         ` Matias Ezequiel Vara Larsen
2025-03-12 13:36           ` Marc Kleine-Budde
2025-03-12 15:11             ` Matias Ezequiel Vara Larsen
2025-03-13  0:26             ` Jason Wang
2025-03-13 18:48     ` Matias Ezequiel Vara Larsen
2025-09-11 20:59 ` Francesco Valla
2025-10-01 15:23   ` Matias Ezequiel Vara Larsen
2025-10-10 15:46   ` Matias Ezequiel Vara Larsen
2025-10-10 21:20     ` Francesco Valla
2025-10-13  9:52       ` Matias Ezequiel Vara Larsen
2025-10-13 16:29         ` Francesco Valla
2025-10-13 18:07           ` Matias Ezequiel Vara Larsen
2025-10-13 14:15       ` Matias Ezequiel Vara Larsen
2025-10-13 16:35   ` Matias Ezequiel Vara Larsen
2025-10-14  6:54     ` Francesco Valla
2025-10-14 10:42       ` Matias Ezequiel Vara Larsen
2025-10-14 10:15   ` Matias Ezequiel Vara Larsen
2025-10-14 16:01     ` Francesco Valla [this message]
2025-10-20 14:56       ` Matias Ezequiel Vara Larsen
2025-10-20 21:24         ` Francesco Valla
2025-10-21  9:40           ` Matias Ezequiel Vara Larsen
2025-10-21 12:08             ` Francesco Valla
2025-10-21 13:15               ` Matias Ezequiel Vara Larsen
2025-10-31 12:21                 ` Matias Ezequiel Vara Larsen
2025-10-14 10:25   ` Matias Ezequiel Vara Larsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1997333.7Z3S40VBb9@fedora.fritz.box \
    --to=francesco@valla.it \
    --cc=Damir.Shaikhutdinov@opensynergy.com \
    --cc=Mikhail.Golubev-Ciuchea@opensynergy.com \
    --cc=development@redaril.me \
    --cc=edumazet@google.com \
    --cc=harald.mommer@opensynergy.com \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=mst@redhat.com \
    --cc=mvaralar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=wg@grandegger.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).