Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) Softnet Driver Issues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) Transmit path guidelines:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 1) The ndo_start_xmit method must not return NETDEV_TX_BUSY under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)    any normal circumstances.  It is considered a hard error unless
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)    there is no way your device can tell ahead of time when it's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)    transmit function will become busy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)    Instead it must maintain the queue properly.  For example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)    for a driver implementing scatter-gather this means::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	static netdev_tx_t drv_hard_start_xmit(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 					       struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		struct drv *dp = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		lock_tx(dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		/* This is a hard error log it. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		if (TX_BUFFS_AVAIL(dp) <= (skb_shinfo(skb)->nr_frags + 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 			netif_stop_queue(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 			unlock_tx(dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 			printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 			       dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 			return NETDEV_TX_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		... queue packet to card ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		... update tx consumer index ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		if (TX_BUFFS_AVAIL(dp) <= (MAX_SKB_FRAGS + 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 			netif_stop_queue(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		unlock_tx(dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		return NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)    And then at the end of your TX reclamation event handling::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	if (netif_queue_stopped(dp->dev) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	    TX_BUFFS_AVAIL(dp) > (MAX_SKB_FRAGS + 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		netif_wake_queue(dp->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)    For a non-scatter-gather supporting card, the three tests simply become::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		/* This is a hard error log it. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		if (TX_BUFFS_AVAIL(dp) <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)    and::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		if (TX_BUFFS_AVAIL(dp) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)    and::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	if (netif_queue_stopped(dp->dev) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	    TX_BUFFS_AVAIL(dp) > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 		netif_wake_queue(dp->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 2) An ndo_start_xmit method must not modify the shared parts of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)    cloned SKB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 3) Do not forget that once you return NETDEV_TX_OK from your
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)    ndo_start_xmit method, it is your driver's responsibility to free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)    up the SKB and in some finite amount of time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)    For example, this means that it is not allowed for your TX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)    mitigation scheme to let TX packets "hang out" in the TX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)    ring unreclaimed forever if no new TX packets are sent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)    This error can deadlock sockets waiting for send buffer room
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)    to be freed up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)    If you return NETDEV_TX_BUSY from the ndo_start_xmit method, you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)    must not keep any reference to that SKB and you must not attempt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)    to free it up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) Probing guidelines:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 1) Any hardware layer address you obtain for your device should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)    be verified.  For example, for ethernet check it with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)    linux/etherdevice.h:is_valid_ether_addr()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) Close/stop guidelines:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 1) After the ndo_stop routine has been called, the hardware must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)    not receive or transmit any data.  All in flight packets must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)    be aborted. If necessary, poll or wait for completion of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)    any reset commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) 2) The ndo_stop routine will be called by unregister_netdevice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)    if device is still UP.