Commit 83364625 authored by Jakub Kicinski's avatar Jakub Kicinski

docs: net: use C syntax highlight in driver.rst

Use syntax highlight, comment out the "..." since they are
not valid C.
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent da4f0f82
...@@ -43,7 +43,9 @@ there is no way your device can tell ahead of time when its ...@@ -43,7 +43,9 @@ there is no way your device can tell ahead of time when its
transmit function will become busy. transmit function will become busy.
Instead it must maintain the queue properly. For example, Instead it must maintain the queue properly. For example,
for a driver implementing scatter-gather this means:: for a driver implementing scatter-gather this means:
.. code-block:: c
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)
...@@ -51,7 +53,7 @@ for a driver implementing scatter-gather this means:: ...@@ -51,7 +53,7 @@ for a driver implementing scatter-gather this means::
struct drv *dp = netdev_priv(dev); struct drv *dp = netdev_priv(dev);
lock_tx(dp); lock_tx(dp);
... //...
/* This is a hard error log it. */ /* This is a hard error log it. */
if (TX_BUFFS_AVAIL(dp) <= (skb_shinfo(skb)->nr_frags + 1)) { if (TX_BUFFS_AVAIL(dp) <= (skb_shinfo(skb)->nr_frags + 1)) {
netif_stop_queue(dev); netif_stop_queue(dev);
...@@ -61,34 +63,42 @@ for a driver implementing scatter-gather this means:: ...@@ -61,34 +63,42 @@ for a driver implementing scatter-gather this means::
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
... queue packet to card ... //... queue packet to card ...
... update tx consumer index ... //... update tx consumer index ...
if (TX_BUFFS_AVAIL(dp) <= (MAX_SKB_FRAGS + 1)) if (TX_BUFFS_AVAIL(dp) <= (MAX_SKB_FRAGS + 1))
netif_stop_queue(dev); netif_stop_queue(dev);
... //...
unlock_tx(dp); unlock_tx(dp);
... //...
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:
.. code-block:: c
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:
.. code-block:: c
/* 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:
.. code-block:: c
if (TX_BUFFS_AVAIL(dp) == 0) if (TX_BUFFS_AVAIL(dp) == 0)
and:: and:
.. code-block:: c
if (netif_queue_stopped(dp->dev) && if (netif_queue_stopped(dp->dev) &&
TX_BUFFS_AVAIL(dp) > 0) TX_BUFFS_AVAIL(dp) > 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment