Commit 52be626c authored by Marc Kleine-Budde's avatar Marc Kleine-Budde
Browse files

Merge patch series "can: gs_usb: convert to NAPI"

Marc Kleine-Budde <mkl@pengutronix.de> says:

Traditionally USB drivers used netif_rx to pass the received CAN
frames/skbs to the network stack. In netif_rx() the skbs are queued to
the local CPU. If IRQs are handled in round robin, CAN frames may be
delivered out-of-order to user space.

To support devices without timestamping the TX path of the rx-offload
helper is cleaned up and extended:
- rename rx_offload_get_echo_skb() ->
  can_rx_offload_get_echo_skb_queue_timestamp()
- add can_rx_offload_get_echo_skb_queue_tail()

The last patch converts the gs_usb driver to NAPI with the rx-offload
helper.

Link: https://lore.kernel.org/all/20230718-gs_usb-rx-offload-v2-0-716e542d14d5@pengutronix.de


Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parents 412fbb84 24bc41b4
Loading
Loading
Loading
Loading
+31 −5
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2014      Protonic Holland,
 *                         David Jander
 * Copyright (C) 2014-2021 Pengutronix,
 * Copyright (C) 2014-2021, 2023 Pengutronix,
 *                         Marc Kleine-Budde <kernel@pengutronix.de>
 */

@@ -240,7 +240,8 @@ int can_rx_offload_queue_timestamp(struct can_rx_offload *offload,
}
EXPORT_SYMBOL_GPL(can_rx_offload_queue_timestamp);

unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
unsigned int
can_rx_offload_get_echo_skb_queue_timestamp(struct can_rx_offload *offload,
					    unsigned int idx, u32 timestamp,
					    unsigned int *frame_len_ptr)
{
@@ -262,7 +263,7 @@ unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,

	return len;
}
EXPORT_SYMBOL_GPL(can_rx_offload_get_echo_skb);
EXPORT_SYMBOL_GPL(can_rx_offload_get_echo_skb_queue_timestamp);

int can_rx_offload_queue_tail(struct can_rx_offload *offload,
			      struct sk_buff *skb)
@@ -279,6 +280,31 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
}
EXPORT_SYMBOL_GPL(can_rx_offload_queue_tail);

unsigned int
can_rx_offload_get_echo_skb_queue_tail(struct can_rx_offload *offload,
				       unsigned int idx,
				       unsigned int *frame_len_ptr)
{
	struct net_device *dev = offload->dev;
	struct net_device_stats *stats = &dev->stats;
	struct sk_buff *skb;
	unsigned int len;
	int err;

	skb = __can_get_echo_skb(dev, idx, &len, frame_len_ptr);
	if (!skb)
		return 0;

	err = can_rx_offload_queue_tail(offload, skb);
	if (err) {
		stats->rx_errors++;
		stats->tx_fifo_errors++;
	}

	return len;
}
EXPORT_SYMBOL_GPL(can_rx_offload_get_echo_skb_queue_tail);

void can_rx_offload_irq_finish(struct can_rx_offload *offload)
{
	unsigned long flags;
+2 −2
Original line number Diff line number Diff line
@@ -1097,7 +1097,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)

		handled = IRQ_HANDLED;
		stats->tx_bytes +=
			can_rx_offload_get_echo_skb(&priv->offload, 0,
			can_rx_offload_get_echo_skb_queue_timestamp(&priv->offload, 0,
								    reg_ctrl << 16, NULL);
		stats->tx_packets++;

+4 −4
Original line number Diff line number Diff line
@@ -1016,7 +1016,7 @@ static void m_can_tx_update_stats(struct m_can_classdev *cdev,

	if (cdev->is_peripheral)
		stats->tx_bytes +=
			can_rx_offload_get_echo_skb(&cdev->offload,
			can_rx_offload_get_echo_skb_queue_timestamp(&cdev->offload,
								    msg_mark,
								    timestamp,
								    NULL);
+3 −3
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ mcp251xfd_handle_tefif_one(struct mcp251xfd_priv *priv,
	if (skb)
		mcp251xfd_skb_set_timestamp(priv, skb, hw_tef_obj->ts);
	stats->tx_bytes +=
		can_rx_offload_get_echo_skb(&priv->offload,
		can_rx_offload_get_echo_skb_queue_timestamp(&priv->offload,
							    tef_tail, hw_tef_obj->ts,
							    frame_len_ptr);
	stats->tx_packets++;
+2 −2
Original line number Diff line number Diff line
@@ -747,7 +747,7 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
			spin_unlock_irqrestore(&priv->mbx_lock, flags);
			stamp = hecc_read_stamp(priv, mbxno);
			stats->tx_bytes +=
				can_rx_offload_get_echo_skb(&priv->offload,
				can_rx_offload_get_echo_skb_queue_timestamp(&priv->offload,
									    mbxno, stamp, NULL);
			stats->tx_packets++;
			--priv->tx_tail;
Loading