All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
	kernel@pengutronix.de,
	Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
	Jimmy Assarsson <extja@kvaser.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH net-next 08/15] can: kvaser_usb: do not increase tx statistics when sending error message frames
Date: Wed,  5 Jan 2022 15:43:55 +0100	[thread overview]
Message-ID: <20220105144402.1174191-9-mkl@pengutronix.de> (raw)
In-Reply-To: <20220105144402.1174191-1-mkl@pengutronix.de>

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

The CAN error message frames (i.e. error skb) are an interface
specific to socket CAN. The payload of the CAN error message frames
does not correspond to any actual data sent on the wire. Only an error
flag and a delimiter are transmitted when an error occurs (c.f. ISO
11898-1 section 10.4.4.2 "Error flag").

For this reason, it makes no sense to increment the tx_packets and
tx_bytes fields of struct net_device_stats when sending an error
message frame because no actual payload will be transmitted on the
wire.

N.B. Sending error message frames is a very specific feature which, at
the moment, is only supported by the Kvaser Hydra hardware. Please
refer to [1] for more details on the topic.

[1] https://lore.kernel.org/linux-can/CAMZ6RqK0rTNg3u3mBpZOoY51jLZ-et-J01tY6-+mWsM4meVw-A@mail.gmail.com/t/#u

Link: https://lore.kernel.org/all/20211207121531.42941-3-mailhol.vincent@wanadoo.fr
Co-developed-by: Jimmy Assarsson <extja@kvaser.com>
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
index 8e2ff08d1083..60e7c5f27a5f 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
@@ -296,6 +296,7 @@ struct kvaser_cmd {
 #define KVASER_USB_HYDRA_CF_FLAG_OVERRUN	BIT(1)
 #define KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME	BIT(4)
 #define KVASER_USB_HYDRA_CF_FLAG_EXTENDED_ID	BIT(5)
+#define KVASER_USB_HYDRA_CF_FLAG_TX_ACK		BIT(6)
 /* CAN frame flags. Used in ext_rx_can and ext_tx_can */
 #define KVASER_USB_HYDRA_CF_FLAG_OSM_NACK	BIT(12)
 #define KVASER_USB_HYDRA_CF_FLAG_ABL		BIT(13)
@@ -1114,6 +1115,7 @@ static void kvaser_usb_hydra_tx_acknowledge(const struct kvaser_usb *dev,
 	struct kvaser_usb_net_priv *priv;
 	unsigned long irq_flags;
 	bool one_shot_fail = false;
+	bool is_err_frame = false;
 	u16 transid = kvaser_usb_hydra_get_cmd_transid(cmd);
 
 	priv = kvaser_usb_hydra_net_priv_from_cmd(dev, cmd);
@@ -1132,10 +1134,13 @@ static void kvaser_usb_hydra_tx_acknowledge(const struct kvaser_usb *dev,
 			kvaser_usb_hydra_one_shot_fail(priv, cmd_ext);
 			one_shot_fail = true;
 		}
+
+		is_err_frame = flags & KVASER_USB_HYDRA_CF_FLAG_TX_ACK &&
+			       flags & KVASER_USB_HYDRA_CF_FLAG_ERROR_FRAME;
 	}
 
 	context = &priv->tx_contexts[transid % dev->max_tx_urbs];
-	if (!one_shot_fail) {
+	if (!one_shot_fail && !is_err_frame) {
 		struct net_device_stats *stats = &priv->netdev->stats;
 
 		stats->tx_packets++;
-- 
2.34.1



  parent reply	other threads:[~2022-01-05 14:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05 14:43 [PATCH net-next 0/15] pull-request: can-next 2022-01-05 Marc Kleine-Budde
2022-01-05 14:43 ` [PATCH net-next 01/15] can: usb_8dev: remove unused member echo_skb from struct usb_8dev_priv Marc Kleine-Budde
2022-01-05 15:10   ` patchwork-bot+netdevbpf
2022-01-05 14:43 ` [PATCH net-next 02/15] can: mcp251x: mcp251x_gpio_setup(): Get rid of duplicate of_node assignment Marc Kleine-Budde
2022-01-05 14:43 ` [PATCH net-next 03/15] can: kvaser_usb: make use of units.h in assignment of frequency Marc Kleine-Budde
2022-01-05 14:43 ` [PATCH net-next 04/15] can: ti_hecc: ti_hecc_probe(): use platform_get_irq() to get the interrupt Marc Kleine-Budde
2022-01-05 14:43 ` [PATCH net-next 05/15] can: sja1000: sp_probe(): " Marc Kleine-Budde
2022-01-05 14:43 ` [PATCH net-next 06/15] can: etas_es58x: es58x_init_netdev: populate net_device::dev_port Marc Kleine-Budde
2022-01-05 14:43 ` [PATCH net-next 07/15] can: do not increase rx statistics when generating a CAN rx error message frame Marc Kleine-Budde
2022-01-05 14:43 ` Marc Kleine-Budde [this message]
2022-01-05 14:43 ` [PATCH net-next 09/15] can: do not copy the payload of RTR frames Marc Kleine-Budde
2022-01-05 14:43 ` [PATCH net-next 10/15] can: do not increase rx_bytes statistics for " Marc Kleine-Budde
2022-01-05 14:43 ` [PATCH net-next 11/15] can: do not increase tx_bytes " Marc Kleine-Budde
2022-01-05 14:43 ` [PATCH net-next 12/15] can: dev: replace can_priv::ctrlmode_static by can_get_static_ctrlmode() Marc Kleine-Budde
2022-01-05 14:44 ` [PATCH net-next 13/15] can: dev: add sanity check in can_set_static_ctrlmode() Marc Kleine-Budde
2022-01-05 14:44 ` [PATCH net-next 14/15] can: dev: reorder struct can_priv members for better packing Marc Kleine-Budde
2022-01-05 14:44 ` [PATCH net-next 15/15] can: netlink: report the CAN controller mode supported flags Marc Kleine-Budde

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=20220105144402.1174191-9-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=extja@kvaser.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.