Re: [PATCH v1 4/9] can: Add Nuvoton NCT6694 CAN support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > > +static netdev_tx_t nct6694_canfd_start_xmit(struct sk_buff *skb,
> > > +                                       struct net_device *ndev)
> > > +{
> > > +   struct nct6694_canfd_priv *priv = netdev_priv(ndev);
> > > +   struct nct6694 *nct6694 = priv->nct6694;
> > > +   struct canfd_frame *cf = (struct canfd_frame *)skb->data;
> > > +   struct net_device_stats *stats = &ndev->stats;
> > > +   int can_idx = priv->can_idx;
> > > +   u32 txid = 0;
> > > +   int i;
> > > +   unsigned int echo_byte;
> > > +   u8 data_buf[REQUEST_CAN_CMD10_LEN] = {0};
> > > +
> > > +   if (can_dropped_invalid_skb(ndev, skb))
> > > +           return NETDEV_TX_OK;
> > > +
> > > +   /*
> > > +    * No check for NCT66794 because the TX bit is read-clear
> > > +    * and may be read-cleared by other function
> > > +    * Just check the result of tx command.
> > > +    */
> >
> > Where do you check the result of the TX command?
> >
> > > +   /* Check if the TX buffer is full */
> >
> > Where's the check if the TX buffer is full?
> >

Sorry for the missing code. It will be checked in tx_work().
If nct6694_write_msg() for CMD10 returns an error related to CAN_Deliver,
I will add error handling in the next patch.

> > > +   netif_stop_queue(ndev);
> > > +
> > > +   if (can_idx == 0)
> > > +           data_buf[CAN_TAG_IDX] = CAN_TAG_CAN0;
> > > +   else
> > > +           data_buf[CAN_TAG_IDX] = CAN_TAG_CAN1;
> > > +
> > > +   if (cf->can_id & CAN_EFF_FLAG) {
> > > +           txid = cf->can_id & CAN_EFF_MASK;
> > > +           /*
> > > +            * In case the Extended ID frame is transmitted, the
> > > +            * standard and extended part of the ID are swapped
> > > +            * in the register, so swap them back to send the
> > > +            * correct ID.
> > > +            */
> > > +           data_buf[CAN_FLAG_IDX] |= CAN_FLAG_EFF;
> > > +   } else {
> > > +           txid = cf->can_id & CAN_SFF_MASK;
> > > +   }
> > > +
> > > +   set_buf32(&data_buf[CAN_ID_IDX], txid);
> > > +
> > > +   data_buf[CAN_DLC_IDX] = cf->len;
> > > +
> > > +   if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) && can_is_canfd_skb(skb)) {
> > > +           data_buf[CAN_FLAG_IDX] |= CAN_FLAG_FD;
> > > +           if (cf->flags & CANFD_BRS)
> > > +                   data_buf[CAN_FLAG_IDX] |= CAN_FLAG_BRS;
> > > +   }
> > > +
> > > +   if (cf->can_id & CAN_RTR_FLAG)
> > > +           data_buf[CAN_FLAG_IDX] |= CAN_FLAG_RTR;
> > > +
> > > +   /* set data to buf */
> > > +   for (i = 0; i < cf->len; i++)
> > > +           data_buf[CAN_DATA_IDX + i] = *(u8 *)(cf->data + i);
> > > +
> > > +   can_put_echo_skb(skb, ndev, 0, 0);
> > > +
> > > +   memcpy(priv->data_buf, data_buf, REQUEST_CAN_CMD10_LEN);
> > > +   queue_work(nct6694->async_workqueue, &priv->tx_work);
> > > +
> > > +   stats->tx_bytes += cf->len;
> > > +   stats->tx_packets++;
> > > +   echo_byte = can_get_echo_skb(ndev, 0, NULL);
> > > +
> > > +   netif_wake_queue(ndev);
> >
> > How do you make sure that the tx_work has finished?
> > Once you wake the queue, the xmit function can be called again. If your
> > tx_work has not finished, you'll overwrite the priv->data_buf.
>
> Do you get a CAN TX complete message/IRQ from your device?
>

I will move the code that needs to confirm the completion of TX transmission
to tx_work().

In tx_work(), CMD2 CAN_Event's TX_EVT will first confirm TX_FIFO_EMPTY,
ensuring transmission is complete.


Best regards,
Ming




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux