]> git.baikalelectronics.ru Git - kernel.git/commitdiff
can: dev: can_get_echo_skb(): extend to return can frame length
authorMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 11 Jan 2021 14:19:28 +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_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-14-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
29 files changed:
drivers/net/can/at91_can.c
drivers/net/can/c_can/c_can.c
drivers/net/can/cc770/cc770.c
drivers/net/can/dev/skb.c
drivers/net/can/grcan.c
drivers/net/can/ifi_canfd/ifi_canfd.c
drivers/net/can/kvaser_pciefd.c
drivers/net/can/m_can/m_can.c
drivers/net/can/mscan/mscan.c
drivers/net/can/pch_can.c
drivers/net/can/peak_canfd/peak_canfd.c
drivers/net/can/rcar/rcar_can.c
drivers/net/can/rcar/rcar_canfd.c
drivers/net/can/sja1000/sja1000.c
drivers/net/can/softing/softing_main.c
drivers/net/can/spi/hi311x.c
drivers/net/can/spi/mcp251x.c
drivers/net/can/sun4i_can.c
drivers/net/can/usb/ems_usb.c
drivers/net/can/usb/esd_usb2.c
drivers/net/can/usb/gs_usb.c
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
drivers/net/can/usb/mcba_usb.c
drivers/net/can/usb/peak_usb/pcan_usb_core.c
drivers/net/can/usb/ucan.c
drivers/net/can/usb/usb_8dev.c
drivers/net/can/xilinx_can.c
include/linux/can/skb.h

index 90b223a80ed456d9fa64d112645cc87deba3c386..9ad9b39f480e79c91dc6684958adf06f05d3830d 100644 (file)
@@ -856,7 +856,7 @@ static void at91_irq_tx(struct net_device *dev, u32 reg_sr)
                if (likely(reg_msr & AT91_MSR_MRDY &&
                           ~reg_msr & AT91_MSR_MABT)) {
                        /* _NOTE_: subtract AT91_MB_TX_FIRST offset from mb! */
-                       can_get_echo_skb(dev, mb - get_mb_tx_first(priv));
+                       can_get_echo_skb(dev, mb - get_mb_tx_first(priv), NULL);
                        dev->stats.tx_packets++;
                        can_led_event(dev, CAN_LED_EVENT_TX);
                }
index 13638954a25c5114277f7e173498b51eefc0f147..ef474bae47a14912f8e689bdcc9492ca32a53d14 100644 (file)
@@ -733,7 +733,7 @@ static void c_can_do_tx(struct net_device *dev)
                pend &= ~(1 << idx);
                obj = idx + C_CAN_MSG_OBJ_TX_FIRST;
                c_can_inval_tx_object(dev, IF_RX, obj);
-               can_get_echo_skb(dev, idx);
+               can_get_echo_skb(dev, idx, NULL);
                bytes += priv->dlc[idx];
                pkts++;
        }
index e53ca338368a82918b4f01118d8682552ec5efcb..f8a130f594e2ebbc155bb6b867aa3102845d329a 100644 (file)
@@ -703,7 +703,7 @@ static void cc770_tx_interrupt(struct net_device *dev, unsigned int o)
        stats->tx_packets++;
 
        can_put_echo_skb(priv->tx_skb, dev, 0, 0);
-       can_get_echo_skb(dev, 0);
+       can_get_echo_skb(dev, 0, NULL);
        priv->tx_skb = NULL;
 
        netif_wake_queue(dev);
index c184b4dce19eba773197dfa56e6222c1de87cbe2..53683d4312f18368ace57b00c8f273ed5a078639 100644 (file)
@@ -121,12 +121,13 @@ __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr,
  * is handled in the device driver. The driver must protect
  * access to priv->echo_skb, if necessary.
  */
-unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
+unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx,
+                             unsigned int *frame_len_ptr)
 {
        struct sk_buff *skb;
        u8 len;
 
-       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 8086cdc1000052346d41610e5cd2275f9d4be319..4a8453290530921a8cb265355edfb54c3abf2905 100644 (file)
@@ -517,7 +517,7 @@ static int catch_up_echo_skb(struct net_device *dev, int budget, bool echo)
                        stats->tx_packets++;
                        stats->tx_bytes += priv->txdlc[i];
                        priv->txdlc[i] = 0;
-                       can_get_echo_skb(dev, i);
+                       can_get_echo_skb(dev, i, NULL);
                } else {
                        /* For cleanup of untransmitted messages */
                        can_free_echo_skb(dev, i);
index 56ac9e1dace7af93836099e1eceacfacf8a1b0d5..5bb957a26bc6975d04adf26762a117c6217ef0d2 100644 (file)
@@ -629,7 +629,7 @@ static irqreturn_t ifi_canfd_isr(int irq, void *dev_id)
 
        /* TX IRQ */
        if (isr & IFI_CANFD_INTERRUPT_TXFIFO_REMOVE) {
-               stats->tx_bytes += can_get_echo_skb(ndev, 0);
+               stats->tx_bytes += can_get_echo_skb(ndev, 0, NULL);
                stats->tx_packets++;
                can_led_event(ndev, CAN_LED_EVENT_TX);
        }
index 0cf82f0646a34b054c6a082a261a3a53cb4f6731..37e05010ca914261e245dd0163f5181ee803351f 100644 (file)
@@ -1467,7 +1467,7 @@ static int kvaser_pciefd_handle_eack_packet(struct kvaser_pciefd *pcie,
                                  can->reg_base + KVASER_PCIEFD_KCAN_CTRL_REG);
        } else {
                int echo_idx = p->header[0] & KVASER_PCIEFD_PACKET_SEQ_MSK;
-               int dlc = can_get_echo_skb(can->can.dev, echo_idx);
+               int dlc = can_get_echo_skb(can->can.dev, echo_idx, NULL);
                struct net_device_stats *stats = &can->can.dev->stats;
 
                stats->tx_bytes += dlc;
@@ -1533,7 +1533,7 @@ static int kvaser_pciefd_handle_ack_packet(struct kvaser_pciefd *pcie,
                netdev_dbg(can->can.dev, "Packet was flushed\n");
        } else {
                int echo_idx = p->header[0] & KVASER_PCIEFD_PACKET_SEQ_MSK;
-               int dlc = can_get_echo_skb(can->can.dev, echo_idx);
+               int dlc = can_get_echo_skb(can->can.dev, echo_idx, NULL);
                u8 count = ioread32(can->reg_base +
                                    KVASER_PCIEFD_KCAN_TX_NPACKETS_REG) & 0xff;
 
index fff7432103cb255efe00fa15628068c98d58e1d9..3752520a7d4b74a00bc47d1067300742fd02c58d 100644 (file)
@@ -930,7 +930,7 @@ static void m_can_echo_tx_event(struct net_device *dev)
                                                (fgi << TXEFA_EFAI_SHIFT)));
 
                /* update stats */
-               stats->tx_bytes += can_get_echo_skb(dev, msg_mark);
+               stats->tx_bytes += can_get_echo_skb(dev, msg_mark, NULL);
                stats->tx_packets++;
        }
 }
@@ -972,7 +972,7 @@ static irqreturn_t m_can_isr(int irq, void *dev_id)
        if (cdev->version == 30) {
                if (ir & IR_TC) {
                        /* Transmission Complete Interrupt*/
-                       stats->tx_bytes += can_get_echo_skb(dev, 0);
+                       stats->tx_bytes += can_get_echo_skb(dev, 0, NULL);
                        stats->tx_packets++;
                        can_led_event(dev, CAN_LED_EVENT_TX);
                        netif_wake_queue(dev);
index a28fdaa411c659746051524c077ac05f5d2852ac..fa32e418eb296db955c34c1df62a7e9aa9f70c32 100644 (file)
@@ -448,7 +448,7 @@ static irqreturn_t mscan_isr(int irq, void *dev_id)
                        out_8(&regs->cantbsel, mask);
                        stats->tx_bytes += in_8(&regs->tx.dlr);
                        stats->tx_packets++;
-                       can_get_echo_skb(dev, entry->id);
+                       can_get_echo_skb(dev, entry->id, NULL);
                        priv->tx_active &= ~mask;
                        list_del(pos);
                }
index a4c35b48d8e97d710b0f297cf52e71ad0adb281f..92a54a5fd4c502c3238f500e9bf39b44b44582a6 100644 (file)
@@ -711,7 +711,7 @@ static void pch_can_tx_complete(struct net_device *ndev, u32 int_stat)
        struct net_device_stats *stats = &(priv->ndev->stats);
        u32 dlc;
 
-       can_get_echo_skb(ndev, int_stat - PCH_RX_OBJ_END - 1);
+       can_get_echo_skb(ndev, int_stat - PCH_RX_OBJ_END - 1, NULL);
        iowrite32(PCH_CMASK_RX_TX_GET | PCH_CMASK_CLRINTPND,
                  &priv->regs->ifregs[1].cmask);
        pch_can_rw_msg_obj(&priv->regs->ifregs[1].creq, int_stat);
index 179a8e10fbb8d1cc71d5d639f52ca41e3ff6c461..00847cbaf7b626fabbf71b38bf3630aa97bced60 100644 (file)
@@ -266,7 +266,7 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
                unsigned long flags;
 
                spin_lock_irqsave(&priv->echo_lock, flags);
-               can_get_echo_skb(priv->ndev, msg->client);
+               can_get_echo_skb(priv->ndev, msg->client, NULL);
 
                /* count bytes of the echo instead of skb */
                stats->tx_bytes += cf_len;
index 0b7e488bc4fe24837f4fcee0f69c436eea46f106..4870c4ea190a9b32bc6b2fcbd69209347f09d2c2 100644 (file)
@@ -386,7 +386,7 @@ static void rcar_can_tx_done(struct net_device *ndev)
                stats->tx_bytes += priv->tx_dlc[priv->tx_tail %
                                                RCAR_CAN_FIFO_DEPTH];
                priv->tx_dlc[priv->tx_tail % RCAR_CAN_FIFO_DEPTH] = 0;
-               can_get_echo_skb(ndev, priv->tx_tail % RCAR_CAN_FIFO_DEPTH);
+               can_get_echo_skb(ndev, priv->tx_tail % RCAR_CAN_FIFO_DEPTH, NULL);
                priv->tx_tail++;
                netif_wake_queue(ndev);
        }
index 38376f29bc561acec1e9f0b01785e62bc82c9766..d8d233e629904ddfbba5689c99a5430e8cf1b2ec 100644 (file)
@@ -1044,7 +1044,7 @@ static void rcar_canfd_tx_done(struct net_device *ndev)
                stats->tx_packets++;
                stats->tx_bytes += priv->tx_len[sent];
                priv->tx_len[sent] = 0;
-               can_get_echo_skb(ndev, sent);
+               can_get_echo_skb(ndev, sent, NULL);
 
                spin_lock_irqsave(&priv->tx_lock, flags);
                priv->tx_tail++;
index e98482c7bf3338c574e06375f51e68adf65df921..9e86488ba55f17cb674d0482be9397611c5819a4 100644 (file)
@@ -531,7 +531,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
                                stats->tx_bytes +=
                                        priv->read_reg(priv, SJA1000_FI) & 0xf;
                                stats->tx_packets++;
-                               can_get_echo_skb(dev, 0);
+                               can_get_echo_skb(dev, 0, NULL);
                        }
                        netif_wake_queue(dev);
                        can_led_event(dev, CAN_LED_EVENT_TX);
index a5314448c5ae801a73707e36f4cf9ea84025cd5c..c44f3411e5612f3529feef8f071e2321dabf3a7d 100644 (file)
@@ -284,7 +284,7 @@ static int softing_handle_1(struct softing *card)
                        skb = priv->can.echo_skb[priv->tx.echo_get];
                        if (skb)
                                skb->tstamp = ktime;
-                       can_get_echo_skb(netdev, priv->tx.echo_get);
+                       can_get_echo_skb(netdev, priv->tx.echo_get, NULL);
                        ++priv->tx.echo_get;
                        if (priv->tx.echo_get >= TX_ECHO_SKB_MAX)
                                priv->tx.echo_get = 0;
index 8c83a9e5a9e48636856fbf30f6c260d52fdf9fb7..c3e020c901116634f50b50cdf29f199128686b72 100644 (file)
@@ -725,7 +725,7 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id)
                        net->stats.tx_bytes += priv->tx_len - 1;
                        can_led_event(net, CAN_LED_EVENT_TX);
                        if (priv->tx_len) {
-                               can_get_echo_skb(net, 0);
+                               can_get_echo_skb(net, 0, NULL);
                                priv->tx_len = 0;
                        }
                        netif_wake_queue(net);
index 40866754aafcac9ec04ed408313e6cd20b71d2e5..f69fb4238a654cb31c70ed2bcda663dc072abced 100644 (file)
@@ -1171,7 +1171,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
                        net->stats.tx_bytes += priv->tx_len - 1;
                        can_led_event(net, CAN_LED_EVENT_TX);
                        if (priv->tx_len) {
-                               can_get_echo_skb(net, 0);
+                               can_get_echo_skb(net, 0, NULL);
                                priv->tx_len = 0;
                        }
                        netif_wake_queue(net);
index b75175d59104f44da79ac1e188e6dc41d1b40acf..54aa7c25c4de1359e55f25363143e0b3a81a843e 100644 (file)
@@ -655,7 +655,7 @@ static irqreturn_t sun4i_can_interrupt(int irq, void *dev_id)
                            readl(priv->base +
                                  SUN4I_REG_RBUF_RBACK_START_ADDR) & 0xf;
                        stats->tx_packets++;
-                       can_get_echo_skb(dev, 0);
+                       can_get_echo_skb(dev, 0, NULL);
                        netif_wake_queue(dev);
                        can_led_event(dev, CAN_LED_EVENT_TX);
                }
index 5e5330060464e53030c061cdb534970e111b039b..18f40eb203605a55620f08f3e43f609271549fbe 100644 (file)
@@ -518,7 +518,7 @@ static void ems_usb_write_bulk_callback(struct urb *urb)
        netdev->stats.tx_packets++;
        netdev->stats.tx_bytes += context->dlc;
 
-       can_get_echo_skb(netdev, context->echo_index);
+       can_get_echo_skb(netdev, context->echo_index, NULL);
 
        /* Release context */
        context->echo_index = MAX_TX_URBS;
index 68d8a85f00c473b02a9d513e7fd14cf5b1562d82..562acbf454fd63d490963c4477a2f8476276a149 100644 (file)
@@ -357,7 +357,7 @@ static void esd_usb2_tx_done_msg(struct esd_usb2_net_priv *priv,
        if (!msg->msg.txdone.status) {
                stats->tx_packets++;
                stats->tx_bytes += context->len;
-               can_get_echo_skb(netdev, context->echo_index);
+               can_get_echo_skb(netdev, context->echo_index, NULL);
        } else {
                stats->tx_errors++;
                can_free_echo_skb(netdev, context->echo_index);
index 5ce9ba5d29d6165dc47d8f7ef656cad36f0f9324..a00dc19044151f342fa13d77f30804a6303c66ea 100644 (file)
@@ -370,7 +370,7 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
                        goto resubmit_urb;
                }
 
-               can_get_echo_skb(netdev, hf->echo_id);
+               can_get_echo_skb(netdev, hf->echo_id, NULL);
 
                gs_free_tx_context(txc);
 
index 480bd2ecb29696e6971071a5f6c27d5058200c8a..dcee8dc828ecc1dd626f31e6344be55f992079f8 100644 (file)
@@ -1151,7 +1151,7 @@ static void kvaser_usb_hydra_tx_acknowledge(const struct kvaser_usb *dev,
 
        spin_lock_irqsave(&priv->tx_contexts_lock, irq_flags);
 
-       can_get_echo_skb(priv->netdev, context->echo_index);
+       can_get_echo_skb(priv->netdev, context->echo_index, NULL);
        context->echo_index = dev->max_tx_urbs;
        --priv->active_tx_contexts;
        netif_wake_queue(priv->netdev);
index 98c016ef0607d5a125d09be08d90ccb4ea9cf966..59ba7c7beec00f4e10c19bcc03995941017c158b 100644 (file)
@@ -594,7 +594,7 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev,
 
        spin_lock_irqsave(&priv->tx_contexts_lock, flags);
 
-       can_get_echo_skb(priv->netdev, context->echo_index);
+       can_get_echo_skb(priv->netdev, context->echo_index, NULL);
        context->echo_index = dev->max_tx_urbs;
        --priv->active_tx_contexts;
        netif_wake_queue(priv->netdev);
index 5347c89992ce7237452868c673907b552d8c1d6c..4232a7126c1bd1536d2025f0fd9a6317eb661e66 100644 (file)
@@ -237,7 +237,7 @@ static void mcba_usb_write_bulk_callback(struct urb *urb)
                netdev->stats.tx_bytes += ctx->dlc;
 
                can_led_event(netdev, CAN_LED_EVENT_TX);
-               can_get_echo_skb(netdev, ctx->ndx);
+               can_get_echo_skb(netdev, ctx->ndx, NULL);
        }
 
        if (urb->status)
index 95672750419a22bd7ba2a727dbf609013e04d634..573b11559d733fc5328130fced5f910b8b81334e 100644 (file)
@@ -309,7 +309,7 @@ static void peak_usb_write_bulk_callback(struct urb *urb)
        }
 
        /* should always release echo skb and corresponding context */
-       can_get_echo_skb(netdev, context->echo_index);
+       can_get_echo_skb(netdev, context->echo_index, NULL);
        context->echo_index = PCAN_USB_MAX_TX_URBS;
 
        /* do wakeup tx queue in case of success only */
index 5add27614e2bcaa2d29f668f603beb67c01221b7..fa403c080871e16355fd71187b0b32f2e444dbe0 100644 (file)
@@ -672,7 +672,7 @@ static void ucan_tx_complete_msg(struct ucan_priv *up,
                        /* update statistics */
                        up->netdev->stats.tx_packets++;
                        up->netdev->stats.tx_bytes += dlc;
-                       can_get_echo_skb(up->netdev, echo_index);
+                       can_get_echo_skb(up->netdev, echo_index, NULL);
                } else {
                        up->netdev->stats.tx_dropped++;
                        can_free_echo_skb(up->netdev, echo_index);
index 2e824d9d8167e435ac9c153d21a38c50ba2ef578..e8c42430a4fcd3bc52add08c0b762db69dd113dd 100644 (file)
@@ -585,7 +585,7 @@ static void usb_8dev_write_bulk_callback(struct urb *urb)
        netdev->stats.tx_packets++;
        netdev->stats.tx_bytes += context->dlc;
 
-       can_get_echo_skb(netdev, context->echo_index);
+       can_get_echo_skb(netdev, context->echo_index, NULL);
 
        can_led_event(netdev, CAN_LED_EVENT_TX);
 
index 8d5132a3f2c9e600f8d22cf19f28ad3765f7f39c..37fa19c62d733a7e1f6cb9b678e72dc04ec27d39 100644 (file)
@@ -1292,7 +1292,7 @@ static void xcan_tx_interrupt(struct net_device *ndev, u32 isr)
 
        while (frames_sent--) {
                stats->tx_bytes += can_get_echo_skb(ndev, priv->tx_tail %
-                                                   priv->tx_max);
+                                                   priv->tx_max, NULL);
                priv->tx_tail++;
                stats->tx_packets++;
        }
index eaac4a637ae01b4e7e4e735cfff861791fba2479..685f34cfba20741d372d340fe7df1084767b2850 100644 (file)
@@ -21,7 +21,8 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
                     unsigned int idx, unsigned int frame_len);
 struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx,
                                   u8 *len_ptr, unsigned int *frame_len_ptr);
-unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
+unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx,
+                             unsigned int *frame_len_ptr);
 void can_free_echo_skb(struct net_device *dev, unsigned int idx);
 struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf);
 struct sk_buff *alloc_canfd_skb(struct net_device *dev,