docs: net: reformat driver.rst from a list to sections

driver.rst had a historical form of list of common problems.
In the age os Sphinx and rendered documentation it's better
to use the more usual title + text format.

This will allow us to render kdoc into the output more naturally.

No changes to the actual text.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2023-04-06 18:25:30 -07:00
Родитель 490fde262f
Коммит d2f5c68e3f
1 изменённых файлов: 56 добавлений и 35 удалений

Просмотреть файл

@ -4,15 +4,19 @@
Softnet Driver Issues Softnet Driver Issues
===================== =====================
Transmit path guidelines: Transmit path guidelines
========================
1) The ndo_start_xmit method must not return NETDEV_TX_BUSY under Stop queues in advance
any normal circumstances. It is considered a hard error unless ----------------------
there is no way your device can tell ahead of time when its
transmit function will become busy.
Instead it must maintain the queue properly. For example, The ndo_start_xmit method must not return NETDEV_TX_BUSY under
for a driver implementing scatter-gather this means:: any normal circumstances. It is considered a hard error unless
there is no way your device can tell ahead of time when its
transmit function will become busy.
Instead it must maintain the queue properly. For example,
for a driver implementing scatter-gather this means::
static netdev_tx_t drv_hard_start_xmit(struct sk_buff *skb, static netdev_tx_t drv_hard_start_xmit(struct sk_buff *skb,
struct net_device *dev) struct net_device *dev)
@ -42,56 +46,73 @@ Transmit path guidelines:
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
And then at the end of your TX reclamation event handling:: And then at the end of your TX reclamation event handling::
if (netif_queue_stopped(dp->dev) && if (netif_queue_stopped(dp->dev) &&
TX_BUFFS_AVAIL(dp) > (MAX_SKB_FRAGS + 1)) TX_BUFFS_AVAIL(dp) > (MAX_SKB_FRAGS + 1))
netif_wake_queue(dp->dev); netif_wake_queue(dp->dev);
For a non-scatter-gather supporting card, the three tests simply become:: For a non-scatter-gather supporting card, the three tests simply become::
/* This is a hard error log it. */ /* This is a hard error log it. */
if (TX_BUFFS_AVAIL(dp) <= 0) if (TX_BUFFS_AVAIL(dp) <= 0)
and:: and::
if (TX_BUFFS_AVAIL(dp) == 0) if (TX_BUFFS_AVAIL(dp) == 0)
and:: and::
if (netif_queue_stopped(dp->dev) && if (netif_queue_stopped(dp->dev) &&
TX_BUFFS_AVAIL(dp) > 0) TX_BUFFS_AVAIL(dp) > 0)
netif_wake_queue(dp->dev); netif_wake_queue(dp->dev);
2) An ndo_start_xmit method must not modify the shared parts of a No exclusive ownership
cloned SKB. ----------------------
3) Do not forget that once you return NETDEV_TX_OK from your An ndo_start_xmit method must not modify the shared parts of a
ndo_start_xmit method, it is your driver's responsibility to free cloned SKB.
up the SKB and in some finite amount of time.
For example, this means that it is not allowed for your TX Timely completions
mitigation scheme to let TX packets "hang out" in the TX ------------------
ring unreclaimed forever if no new TX packets are sent.
This error can deadlock sockets waiting for send buffer room
to be freed up.
If you return NETDEV_TX_BUSY from the ndo_start_xmit method, you Do not forget that once you return NETDEV_TX_OK from your
must not keep any reference to that SKB and you must not attempt ndo_start_xmit method, it is your driver's responsibility to free
to free it up. up the SKB and in some finite amount of time.
Probing guidelines: For example, this means that it is not allowed for your TX
mitigation scheme to let TX packets "hang out" in the TX
ring unreclaimed forever if no new TX packets are sent.
This error can deadlock sockets waiting for send buffer room
to be freed up.
1) Any hardware layer address you obtain for your device should If you return NETDEV_TX_BUSY from the ndo_start_xmit method, you
be verified. For example, for ethernet check it with must not keep any reference to that SKB and you must not attempt
linux/etherdevice.h:is_valid_ether_addr() to free it up.
Close/stop guidelines: Probing guidelines
==================
1) After the ndo_stop routine has been called, the hardware must Address validation
not receive or transmit any data. All in flight packets must ------------------
be aborted. If necessary, poll or wait for completion of
any reset commands.
2) The ndo_stop routine will be called by unregister_netdevice Any hardware layer address you obtain for your device should
if device is still UP. be verified. For example, for ethernet check it with
linux/etherdevice.h:is_valid_ether_addr()
Close/stop guidelines
=====================
Quiescence
----------
After the ndo_stop routine has been called, the hardware must
not receive or transmit any data. All in flight packets must
be aborted. If necessary, poll or wait for completion of
any reset commands.
Auto-close
----------
The ndo_stop routine will be called by unregister_netdevice
if device is still UP.