Re: [PATCH v12 06/10] net: ti: icssg-prueth: Add ICSSG ethernet driver

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

 



Hi Jakub,

On 29/07/23 5:54 am, Jakub Kicinski wrote:
> On Thu, 27 Jul 2023 16:58:23 +0530 MD Danish Anwar wrote:
>> +static int emac_tx_complete_packets(struct prueth_emac *emac, int chn,
>> +				    int budget)
>> +{
>> +	struct net_device *ndev = emac->ndev;
>> +	struct cppi5_host_desc_t *desc_tx;
>> +	struct netdev_queue *netif_txq;
>> +	struct prueth_tx_chn *tx_chn;
>> +	unsigned int total_bytes = 0;
>> +	struct sk_buff *skb;
>> +	dma_addr_t desc_dma;
>> +	int res, num_tx = 0;
>> +	void **swdata;
>> +
>> +	tx_chn = &emac->tx_chns[chn];
>> +
>> +	while (budget) {
>> +		res = k3_udma_glue_pop_tx_chn(tx_chn->tx_chn, &desc_dma);
>> +		if (res == -ENODATA)
>> +			break;
> 
> You shouldn't limit the number of serviced packets to budget for Tx
> NAPI.
> 
> https://docs.kernel.org/next/networking/napi.html#driver-api

Sure, I will remove budget from here, instead will service packets in
while(true) {} loop.
> 
>> +	skb->dev = ndev;
>> +	if (!netif_running(skb->dev)) {
>> +		dev_kfree_skb_any(skb);
>> +		return 0;
>> +	}
> 
> why do you check if the interface is running?
> If a packet arrives, it means the interface is running..
> 
>> +drop_free_descs:
>> +	prueth_xmit_free(tx_chn, first_desc);
>> +drop_stop_q:
>> +	netif_tx_stop_queue(netif_txq);
> 
> Do not stop the queue on DMA errors. If the queue is empty nothing
> will wake it up. Queue should only be stopped based on occupancy.

There are five error handling cases in xmit().

1. DMA Mapping the linear buffer -- If we fail to map dma, we will return
NETDEV_TX_OK and goto drop_free_skb which will free the skb and drop the packet.

2. Allocating descriptor for linear buffer -- If we fail to allocate descriptor
this means it is a occupancy issue and we will goto drop_stop_q_busy which will
stop queue and return NETDEV_TX_BUSY.

3. Allocating descriptor when skb is fragmented. -- If we fail to allocate
descriptor when skb is fragmented, we will goto drop_stop_q which will stop the
queue, free the descriptor, free the skb, drop the packet and return NETDEV_TX_OK.

4. DMA mapping for fragment. -- If DMA mapping for fragment fails, we will go
to drop_free_descs which will free the descriptor, free the skb, drop the
packet and return NETDEV_TX_OK.

5. Tx push failed. -- If tx push fails we will goto drop_free_descs which will
free the descriptor, free the skb, drop the packet and return.

We will only stop queue in case 2 and 3 where we failed to allocate descriptor.
In case 1, 4 and 5 we are encountering dma mapping error, so for these cases we
will not stop the queue.

Below will be my goto labels.

drop_stop_q:
	netif_tx_stop_queue(netif_txq);

drop_free_descs:
	prueth_xmit_free(tx_chn, first_desc);

drop_free_skb:
	dev_kfree_skb_any(skb);

	/* error */
	ndev->stats.tx_dropped++;
	netdev_err(ndev, "tx: error: %d\n", ret);

	return ret;

drop_stop_q_busy:
	netif_tx_stop_queue(netif_txq);
	return NETDEV_TX_BUSY;

Please let me know if this looks OK or if you have any comment on this.

> 
>> +	dev_kfree_skb_any(skb);
>> +
>> +	/* error */
>> +	ndev->stats.tx_dropped++;
>> +	netdev_err(ndev, "tx: error: %d\n", ret);
>> +
>> +	return ret;

-- 
Thanks and Regards,
Danish.



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux