]> git.baikalelectronics.ru Git - kernel.git/commitdiff
can: dev: can_rx_offload_get_echo_skb(): extend to return can frame length
authorMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 11 Jan 2021 14:19:29 +0000 (15:19 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 14 Jan 2021 07:43:43 +0000 (08:43 +0100)
In order to implement byte queue limits (bql) in CAN drivers, the length of the
CAN frame needs to be passed into the networking stack after queueing and after
transmission completion.

To avoid to calculate this length twice, extend can_rx_offload_get_echo_skb()
to return that value. Convert all users of this function, too.

Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/r/20210111141930.693847-15-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/dev/rx-offload.c
drivers/net/can/flexcan.c
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
drivers/net/can/ti_hecc.c
include/linux/can/rx-offload.h

index 6a26b5282df1654289c3fb0add1fb27348b71f8e..ab2c1543786cff7af0af07ef3c372129edf57dd1 100644 (file)
@@ -263,7 +263,8 @@ int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
 EXPORT_SYMBOL_GPL(can_rx_offload_queue_sorted);
 
 unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
-                                        unsigned int idx, u32 timestamp)
+                                        unsigned int idx, u32 timestamp,
+                                        unsigned int *frame_len_ptr)
 {
        struct net_device *dev = offload->dev;
        struct net_device_stats *stats = &dev->stats;
@@ -271,7 +272,7 @@ unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
        u8 len;
        int err;
 
-       skb = __can_get_echo_skb(dev, idx, &len, NULL);
+       skb = __can_get_echo_skb(dev, idx, &len, frame_len_ptr);
        if (!skb)
                return 0;
 
index 202d08f8e1a40e89ba37464db90dcd4b5553c55e..5d9157c655e9a534d01669b777520db1cadf6df7 100644 (file)
@@ -1122,8 +1122,9 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
                u32 reg_ctrl = priv->read(&priv->tx_mb->can_ctrl);
 
                handled = IRQ_HANDLED;
-               stats->tx_bytes += can_rx_offload_get_echo_skb(&priv->offload,
-                                                              0, reg_ctrl << 16);
+               stats->tx_bytes +=
+                       can_rx_offload_get_echo_skb(&priv->offload, 0,
+                                                   reg_ctrl << 16, NULL);
                stats->tx_packets++;
                can_led_event(dev, CAN_LED_EVENT_TX);
 
index 95bba456a4cda8bd174b8af51ac9124c280d4768..63bbe0930e53591a53db28c090db321e3ce33533 100644 (file)
@@ -1271,7 +1271,7 @@ mcp251xfd_handle_tefif_one(struct mcp251xfd_priv *priv,
        stats->tx_bytes +=
                can_rx_offload_get_echo_skb(&priv->offload,
                                            mcp251xfd_get_tef_tail(priv),
-                                           hw_tef_obj->ts);
+                                           hw_tef_obj->ts, NULL);
        stats->tx_packets++;
        priv->tef->tail++;
 
index 485c19bc98c2914c3c4f2d8ca1d2dd3f3820b2d0..73245d8836a93019e39a6c96be8b634d3eb02252 100644 (file)
@@ -757,7 +757,7 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
                        stamp = hecc_read_stamp(priv, mbxno);
                        stats->tx_bytes +=
                                can_rx_offload_get_echo_skb(&priv->offload,
-                                                           mbxno, stamp);
+                                                           mbxno, stamp, NULL);
                        stats->tx_packets++;
                        can_led_event(ndev, CAN_LED_EVENT_TX);
                        --priv->tx_tail;
index f1b38088b7659708fb8578f9d1ce662c04c3d14f..40882df7105e89921d95dd2d3884dd9659878fcb 100644 (file)
@@ -44,7 +44,8 @@ int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload);
 int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
                                struct sk_buff *skb, u32 timestamp);
 unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
-                                        unsigned int idx, u32 timestamp);
+                                        unsigned int idx, u32 timestamp,
+                                        unsigned int *frame_len_ptr);
 int can_rx_offload_queue_tail(struct can_rx_offload *offload,
                              struct sk_buff *skb);
 void can_rx_offload_del(struct can_rx_offload *offload);