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

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

 



On 24.10.2024 14:12:44, Marc Kleine-Budde wrote:
> Hello,
> 
> thanks for your contribution. It seems to me that there is no proper
> TX-flow control and I have some questions.
> 
> On 24.10.2024 16:59:17, Ming Yu wrote:
> 
> [...]
> 
> > +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?
> 
> > +	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?

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux