]> git.baikalelectronics.ru Git - kernel.git/commitdiff
can: dev: can_put_echo_skb(): extend to handle frame_len
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>
Mon, 11 Jan 2021 14:19:27 +0000 (15:19 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 14 Jan 2021 07:43:43 +0000 (08:43 +0100)
Add a frame_len argument to can_put_echo_skb() which is used to save length of
the CAN frame into field frame_len of struct can_skb_priv so that it can be
later used after transmission completion. Convert all users of this function,
too.

Drivers which implement BQL call can_put_echo_skb() with the output of
can_skb_get_frame_len(skb) and drivers which do not simply pass zero as an
input (in the same way that NULL would be given to can_get_echo_skb()). This
way, we have a nice symmetry between the two echo functions.

Link: https://lore.kernel.org/r/20210111061335.39983-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/r/20210111141930.693847-13-mkl@pengutronix.de
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
31 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/flexcan.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/spi/mcp251xfd/mcp251xfd-core.c
drivers/net/can/sun4i_can.c
drivers/net/can/ti_hecc.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_core.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 5284f0ab3b06978e98932dd224daf4b60e04b8e6..90b223a80ed456d9fa64d112645cc87deba3c386 100644 (file)
@@ -484,7 +484,7 @@ static netdev_tx_t at91_start_xmit(struct sk_buff *skb, struct net_device *dev)
        stats->tx_bytes += cf->len;
 
        /* _NOTE_: subtract AT91_MB_TX_FIRST offset from mb! */
-       can_put_echo_skb(skb, dev, mb - get_mb_tx_first(priv));
+       can_put_echo_skb(skb, dev, mb - get_mb_tx_first(priv), 0);
 
        /*
         * we have to stop the queue and deliver all messages in case
index 63f48b016ecd8a860453671a776bbcf479b7f227..13638954a25c5114277f7e173498b51eefc0f147 100644 (file)
@@ -476,7 +476,7 @@ static netdev_tx_t c_can_start_xmit(struct sk_buff *skb,
         */
        c_can_setup_tx_object(dev, IF_TX, frame, idx);
        priv->dlc[idx] = frame->len;
-       can_put_echo_skb(skb, dev, idx);
+       can_put_echo_skb(skb, dev, idx, 0);
 
        /* Update the active bits */
        atomic_add((1 << idx), &priv->tx_active);
index 8d9f332c35e0c52a552b24116dd5a3f26ecb479d..e53ca338368a82918b4f01118d8682552ec5efcb 100644 (file)
@@ -702,7 +702,7 @@ static void cc770_tx_interrupt(struct net_device *dev, unsigned int o)
        stats->tx_bytes += cf->len;
        stats->tx_packets++;
 
-       can_put_echo_skb(priv->tx_skb, dev, 0);
+       can_put_echo_skb(priv->tx_skb, dev, 0, 0);
        can_get_echo_skb(dev, 0);
        priv->tx_skb = NULL;
 
index 24f782a234093740d7f694e7ff17a6d20701fcbe..c184b4dce19eba773197dfa56e6222c1de87cbe2 100644 (file)
@@ -38,7 +38,7 @@ void can_flush_echo_skb(struct net_device *dev)
  * priv->echo_skb, if necessary.
  */
 int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
-                    unsigned int idx)
+                    unsigned int idx, unsigned int frame_len)
 {
        struct can_priv *priv = netdev_priv(dev);
 
@@ -62,6 +62,9 @@ int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
                skb->ip_summed = CHECKSUM_UNNECESSARY;
                skb->dev = dev;
 
+               /* save frame_len to reuse it when transmission is completed */
+               can_skb_prv(skb)->frame_len = frame_len;
+
                /* save this skb for tx interrupt echo handling */
                priv->echo_skb[idx] = skb;
        } else {
index 7ab20a6b0d1dbbcb11e64161d2835645daad87bf..202d08f8e1a40e89ba37464db90dcd4b5553c55e 100644 (file)
@@ -815,7 +815,7 @@ static netdev_tx_t flexcan_start_xmit(struct sk_buff *skb, struct net_device *de
                priv->write(data, &priv->tx_mb->data[i / sizeof(u32)]);
        }
 
-       can_put_echo_skb(skb, dev, 0);
+       can_put_echo_skb(skb, dev, 0, 0);
 
        priv->write(can_id, &priv->tx_mb->can_id);
        priv->write(ctrl, &priv->tx_mb->can_ctrl);
index f5d94a6925767ac8e2ebdf2ff41811e32c575d6c..8086cdc1000052346d41610e5cd2275f9d4be319 100644 (file)
@@ -1448,7 +1448,7 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *skb,
         * taken.
         */
        priv->txdlc[slotindex] = cf->len; /* Store dlc for statistics */
-       can_put_echo_skb(skb, dev, slotindex);
+       can_put_echo_skb(skb, dev, slotindex, 0);
 
        /* Make sure everything is written before allowing hardware to
         * read from the memory
index 86b0e1406a215cff0b5d019651721fd028366533..56ac9e1dace7af93836099e1eceacfacf8a1b0d5 100644 (file)
@@ -922,7 +922,7 @@ static netdev_tx_t ifi_canfd_start_xmit(struct sk_buff *skb,
        writel(0, priv->base + IFI_CANFD_TXFIFO_REPEATCOUNT);
        writel(0, priv->base + IFI_CANFD_TXFIFO_SUSPEND_US);
 
-       can_put_echo_skb(skb, ndev, 0);
+       can_put_echo_skb(skb, ndev, 0, 0);
 
        /* Start the transmission */
        writel(IFI_CANFD_TXSTCMD_ADD_MSG, priv->base + IFI_CANFD_TXSTCMD);
index 969cedb9b0b6044588c2703c95225fbe482b6b86..0cf82f0646a34b054c6a082a261a3a53cb4f6731 100644 (file)
@@ -778,7 +778,7 @@ static netdev_tx_t kvaser_pciefd_start_xmit(struct sk_buff *skb,
        spin_lock_irqsave(&can->echo_lock, irq_flags);
 
        /* Prepare and save echo skb in internal slot */
-       can_put_echo_skb(skb, netdev, can->echo_idx);
+       can_put_echo_skb(skb, netdev, can->echo_idx, 0);
 
        /* Move echo index to the next slot */
        can->echo_idx = (can->echo_idx + 1) % can->can.echo_skb_max;
index da551fd0f5026426170589f030bb686abdd879a8..fff7432103cb255efe00fa15628068c98d58e1d9 100644 (file)
@@ -1483,7 +1483,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
                                         M_CAN_FIFO_DATA(i / 4),
                                         *(u32 *)(cf->data + i));
 
-               can_put_echo_skb(skb, dev, 0);
+               can_put_echo_skb(skb, dev, 0, 0);
 
                if (cdev->can.ctrlmode & CAN_CTRLMODE_FD) {
                        cccr = m_can_read(cdev, M_CAN_CCCR);
@@ -1554,7 +1554,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
                /* Push loopback echo.
                 * Will be looped back on TX interrupt based on message marker
                 */
-               can_put_echo_skb(skb, dev, putidx);
+               can_put_echo_skb(skb, dev, putidx, 0);
 
                /* Enable TX FIFO element to start transfer  */
                m_can_write(cdev, M_CAN_TXBAR, (1 << putidx));
index 5ed00a1558e1d20501800ddc08c6ebf949800c46..a28fdaa411c659746051524c077ac05f5d2852ac 100644 (file)
@@ -270,7 +270,7 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        list_add_tail(&priv->tx_queue[buf_id].list, &priv->tx_head);
 
-       can_put_echo_skb(skb, dev, buf_id);
+       can_put_echo_skb(skb, dev, buf_id, 0);
 
        /* Enable interrupt. */
        priv->tx_active |= 1 << buf_id;
index 4f9e7ec192aa83e3e0d9a01934064640c0128c83..a4c35b48d8e97d710b0f297cf52e71ad0adb281f 100644 (file)
@@ -924,7 +924,7 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev)
                          &priv->regs->ifregs[1].data[i / 2]);
        }
 
-       can_put_echo_skb(skb, ndev, tx_obj_no - PCH_RX_OBJ_END - 1);
+       can_put_echo_skb(skb, ndev, tx_obj_no - PCH_RX_OBJ_END - 1, 0);
 
        /* Set the size of the data. Update if2_mcont */
        iowrite32(cf->len | PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_TXRQXT |
index c5334b0c3038f937e8cc70726af55dd49ebaec26..179a8e10fbb8d1cc71d5d639f52ca41e3ff6c461 100644 (file)
@@ -716,7 +716,7 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb,
        spin_lock_irqsave(&priv->echo_lock, flags);
 
        /* prepare and save echo skb in internal slot */
-       can_put_echo_skb(skb, ndev, priv->echo_idx);
+       can_put_echo_skb(skb, ndev, priv->echo_idx, 0);
 
        /* move echo index to the next slot */
        priv->echo_idx = (priv->echo_idx + 1) % priv->can.echo_skb_max;
index c803327f8f79d79ae6d7b238973b0c393f31093f..0b7e488bc4fe24837f4fcee0f69c436eea46f106 100644 (file)
@@ -617,7 +617,7 @@ static netdev_tx_t rcar_can_start_xmit(struct sk_buff *skb,
        writeb(cf->len, &priv->regs->mb[RCAR_CAN_TX_FIFO_MBX].dlc);
 
        priv->tx_dlc[priv->tx_head % RCAR_CAN_FIFO_DEPTH] = cf->len;
-       can_put_echo_skb(skb, ndev, priv->tx_head % RCAR_CAN_FIFO_DEPTH);
+       can_put_echo_skb(skb, ndev, priv->tx_head % RCAR_CAN_FIFO_DEPTH, 0);
        priv->tx_head++;
        /* Start Tx: write 0xff to the TFPCR register to increment
         * the CPU-side pointer for the transmit FIFO to the next
index 2778ed5c61d181c68612bfe42d66f3c42debac3e..38376f29bc561acec1e9f0b01785e62bc82c9766 100644 (file)
@@ -1390,7 +1390,7 @@ static netdev_tx_t rcar_canfd_start_xmit(struct sk_buff *skb,
        }
 
        priv->tx_len[priv->tx_head % RCANFD_FIFO_DEPTH] = cf->len;
-       can_put_echo_skb(skb, ndev, priv->tx_head % RCANFD_FIFO_DEPTH);
+       can_put_echo_skb(skb, ndev, priv->tx_head % RCANFD_FIFO_DEPTH, 0);
 
        spin_lock_irqsave(&priv->tx_lock, flags);
        priv->tx_head++;
index b6a7003c51d263f6b5df17734bbc91fbe4d9521a..e98482c7bf3338c574e06375f51e68adf65df921 100644 (file)
@@ -318,7 +318,7 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
        for (i = 0; i < cf->len; i++)
                priv->write_reg(priv, dreg++, cf->data[i]);
 
-       can_put_echo_skb(skb, dev, 0);
+       can_put_echo_skb(skb, dev, 0, 0);
 
        if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
                cmd_reg_val |= CMD_AT;
index 40070c930202b2601ab8550fdef52e32ecf9185c..a5314448c5ae801a73707e36f4cf9ea84025cd5c 100644 (file)
@@ -104,7 +104,7 @@ static netdev_tx_t softing_netdev_start_xmit(struct sk_buff *skb,
        card->tx.last_bus = priv->index;
        ++card->tx.pending;
        ++priv->tx.pending;
-       can_put_echo_skb(skb, dev, priv->tx.echo_put);
+       can_put_echo_skb(skb, dev, priv->tx.echo_put, 0);
        ++priv->tx.echo_put;
        if (priv->tx.echo_put >= TX_ECHO_SKB_MAX)
                priv->tx.echo_put = 0;
index f9455de94786ec066ce8deca9c59d3bd9978fa7c..8c83a9e5a9e48636856fbf30f6c260d52fdf9fb7 100644 (file)
@@ -586,7 +586,7 @@ static void hi3110_tx_work_handler(struct work_struct *ws)
                        frame = (struct can_frame *)priv->tx_skb->data;
                        hi3110_hw_tx(spi, frame);
                        priv->tx_len = 1 + frame->len;
-                       can_put_echo_skb(priv->tx_skb, net, 0);
+                       can_put_echo_skb(priv->tx_skb, net, 0, 0);
                        priv->tx_skb = NULL;
                }
        }
index 25859d16d06f82479774bc66e6c4e20d654eaaa9..40866754aafcac9ec04ed408313e6cd20b71d2e5 100644 (file)
@@ -1002,7 +1002,7 @@ static void mcp251x_tx_work_handler(struct work_struct *ws)
                                frame->len = CAN_FRAME_MAX_DATA_LEN;
                        mcp251x_hw_tx(spi, frame, 0);
                        priv->tx_len = 1 + frame->len;
-                       can_put_echo_skb(priv->tx_skb, net, 0);
+                       can_put_echo_skb(priv->tx_skb, net, 0, 0);
                        priv->tx_skb = NULL;
                }
        }
index 36235afb0bc6628db8398d8b87451aba4611d5dd..95bba456a4cda8bd174b8af51ac9124c280d4768 100644 (file)
@@ -2436,7 +2436,7 @@ static netdev_tx_t mcp251xfd_start_xmit(struct sk_buff *skb,
        if (tx_ring->head - tx_ring->tail >= tx_ring->obj_num)
                netif_stop_queue(ndev);
 
-       can_put_echo_skb(skb, ndev, tx_head);
+       can_put_echo_skb(skb, ndev, tx_head, 0);
 
        err = mcp251xfd_tx_obj_write(priv, tx_obj);
        if (err)
index 783b63218b7b7ccab61eb83297062078de85d977..b75175d59104f44da79ac1e188e6dc41d1b40acf 100644 (file)
@@ -448,7 +448,7 @@ static netdev_tx_t sun4ican_start_xmit(struct sk_buff *skb, struct net_device *d
 
        writel(msg_flag_n, priv->base + SUN4I_REG_BUF0_ADDR);
 
-       can_put_echo_skb(skb, dev, 0);
+       can_put_echo_skb(skb, dev, 0, 0);
 
        if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
                sun4i_can_write_cmdreg(priv, SUN4I_CMD_SELF_RCV_REQ);
index a6850ff0b55b6f83b19ee28b6d16a5cd771233b4..485c19bc98c2914c3c4f2d8ca1d2dd3f3820b2d0 100644 (file)
@@ -513,7 +513,7 @@ static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev)
                               be32_to_cpu(*(__be32 *)(cf->data + 4)));
        else
                *(u32 *)(cf->data + 4) = 0;
-       can_put_echo_skb(skb, ndev, mbxno);
+       can_put_echo_skb(skb, ndev, mbxno, 0);
 
        spin_lock_irqsave(&priv->mbx_lock, flags);
        --priv->tx_head;
index 25eee4466364a29053ff983e1f07662ce1b9eb9d..5e5330060464e53030c061cdb534970e111b039b 100644 (file)
@@ -801,7 +801,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
        urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
        usb_anchor_urb(urb, &dev->tx_submitted);
 
-       can_put_echo_skb(skb, netdev, context->echo_index);
+       can_put_echo_skb(skb, netdev, context->echo_index, 0);
 
        atomic_inc(&dev->active_tx_urbs);
 
index 9eed75a4b678b086fffa3a2636ee1dd94a406067..68d8a85f00c473b02a9d513e7fd14cf5b1562d82 100644 (file)
@@ -783,7 +783,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
 
        usb_anchor_urb(urb, &priv->tx_submitted);
 
-       can_put_echo_skb(skb, netdev, context->echo_index);
+       can_put_echo_skb(skb, netdev, context->echo_index, 0);
 
        atomic_inc(&priv->active_tx_jobs);
 
index 0487095e1fd0468b205ae09f113f84b292d0d91e..5ce9ba5d29d6165dc47d8f7ef656cad36f0f9324 100644 (file)
@@ -525,7 +525,7 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
        urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
        usb_anchor_urb(urb, &dev->tx_submitted);
 
-       can_put_echo_skb(skb, netdev, idx);
+       can_put_echo_skb(skb, netdev, idx, 0);
 
        atomic_inc(&dev->active_tx_urbs);
 
index e2d58846c40ca89f63e2ad456d2c161e2d25c629..2b7efd296758d7cdd5ec83b7bd55ce527886289c 100644 (file)
@@ -578,7 +578,7 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
 
        context->priv = priv;
 
-       can_put_echo_skb(skb, netdev, context->echo_index);
+       can_put_echo_skb(skb, netdev, context->echo_index, 0);
 
        usb_fill_bulk_urb(urb, dev->udev,
                          usb_sndbulkpipe(dev->udev,
index df54eb7d4b36bf3cc96cc70f84fec60f262eb4cf..5347c89992ce7237452868c673907b552d8c1d6c 100644 (file)
@@ -355,7 +355,7 @@ static netdev_tx_t mcba_usb_start_xmit(struct sk_buff *skb,
        if (cf->can_id & CAN_RTR_FLAG)
                usb_msg.dlc |= MCBA_DLC_RTR_MASK;
 
-       can_put_echo_skb(skb, priv->netdev, ctx->ndx);
+       can_put_echo_skb(skb, priv->netdev, ctx->ndx, 0);
 
        err = mcba_usb_xmit(priv, (struct mcba_usb_msg *)&usb_msg, ctx);
        if (err)
index 251835ea15aa739af53962c98cbe3c7e73f20284..95672750419a22bd7ba2a727dbf609013e04d634 100644 (file)
@@ -365,7 +365,7 @@ static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff *skb,
 
        usb_anchor_urb(urb, &dev->tx_submitted);
 
-       can_put_echo_skb(skb, netdev, context->echo_index);
+       can_put_echo_skb(skb, netdev, context->echo_index, 0);
 
        atomic_inc(&dev->active_tx_urbs);
 
index 7d92da8954fe976f1df345c5915513257c2c9a00..5add27614e2bcaa2d29f668f603beb67c01221b7 100644 (file)
@@ -1137,7 +1137,7 @@ static netdev_tx_t ucan_start_xmit(struct sk_buff *skb,
 
        /* put the skb on can loopback stack */
        spin_lock_irqsave(&up->echo_skb_lock, flags);
-       can_put_echo_skb(skb, up->netdev, echo_index);
+       can_put_echo_skb(skb, up->netdev, echo_index, 0);
        spin_unlock_irqrestore(&up->echo_skb_lock, flags);
 
        /* transmit it */
index 44478304ff469c68479a4c68e619e382ac18b3c9..2e824d9d8167e435ac9c153d21a38c50ba2ef578 100644 (file)
@@ -664,7 +664,7 @@ static netdev_tx_t usb_8dev_start_xmit(struct sk_buff *skb,
        urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
        usb_anchor_urb(urb, &priv->tx_submitted);
 
-       can_put_echo_skb(skb, netdev, context->echo_index);
+       can_put_echo_skb(skb, netdev, context->echo_index, 0);
 
        atomic_inc(&priv->active_tx_urbs);
 
index 3f54edee92ebf20bba63342c9c71a372d518cfe5..8d5132a3f2c9e600f8d22cf19f28ad3765f7f39c 100644 (file)
@@ -592,9 +592,9 @@ static void xcan_write_frame(struct net_device *ndev, struct sk_buff *skb,
 
        if (!(priv->devtype.flags & XCAN_FLAG_TX_MAILBOXES) &&
            (priv->devtype.flags & XCAN_FLAG_TXFEMP))
-               can_put_echo_skb(skb, ndev, priv->tx_head % priv->tx_max);
+               can_put_echo_skb(skb, ndev, priv->tx_head % priv->tx_max, 0);
        else
-               can_put_echo_skb(skb, ndev, 0);
+               can_put_echo_skb(skb, ndev, 0, 0);
 
        priv->tx_head++;
 
index 5db9da30843c26e52c2b50c1cc04d0f011d3f916..eaac4a637ae01b4e7e4e735cfff861791fba2479 100644 (file)
@@ -18,7 +18,7 @@
 
 void can_flush_echo_skb(struct net_device *dev);
 int can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
-                    unsigned int idx);
+                    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);