multiqueue.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===========================================
  3. HOWTO for multiqueue network device support
  4. ===========================================
  5. Section 1: Base driver requirements for implementing multiqueue support
  6. =======================================================================
  7. Intro: Kernel support for multiqueue devices
  8. ---------------------------------------------------------
  9. Kernel support for multiqueue devices is always present.
  10. Base drivers are required to use the new alloc_etherdev_mq() or
  11. alloc_netdev_mq() functions to allocate the subqueues for the device. The
  12. underlying kernel API will take care of the allocation and deallocation of
  13. the subqueue memory, as well as netdev configuration of where the queues
  14. exist in memory.
  15. The base driver will also need to manage the queues as it does the global
  16. netdev->queue_lock today. Therefore base drivers should use the
  17. netif_{start|stop|wake}_subqueue() functions to manage each queue while the
  18. device is still operational. netdev->queue_lock is still used when the device
  19. comes online or when it's completely shut down (unregister_netdev(), etc.).
  20. Section 2: Qdisc support for multiqueue devices
  21. ===============================================
  22. Currently two qdiscs are optimized for multiqueue devices. The first is the
  23. default pfifo_fast qdisc. This qdisc supports one qdisc per hardware queue.
  24. A new round-robin qdisc, sch_multiq also supports multiple hardware queues. The
  25. qdisc is responsible for classifying the skb's and then directing the skb's to
  26. bands and queues based on the value in skb->queue_mapping. Use this field in
  27. the base driver to determine which queue to send the skb to.
  28. sch_multiq has been added for hardware that wishes to avoid head-of-line
  29. blocking. It will cycle though the bands and verify that the hardware queue
  30. associated with the band is not stopped prior to dequeuing a packet.
  31. On qdisc load, the number of bands is based on the number of queues on the
  32. hardware. Once the association is made, any skb with skb->queue_mapping set,
  33. will be queued to the band associated with the hardware queue.
  34. Section 3: Brief howto using MULTIQ for multiqueue devices
  35. ==========================================================
  36. The userspace command 'tc,' part of the iproute2 package, is used to configure
  37. qdiscs. To add the MULTIQ qdisc to your network device, assuming the device
  38. is called eth0, run the following command::
  39. # tc qdisc add dev eth0 root handle 1: multiq
  40. The qdisc will allocate the number of bands to equal the number of queues that
  41. the device reports, and bring the qdisc online. Assuming eth0 has 4 Tx
  42. queues, the band mapping would look like::
  43. band 0 => queue 0
  44. band 1 => queue 1
  45. band 2 => queue 2
  46. band 3 => queue 3
  47. Traffic will begin flowing through each queue based on either the simple_tx_hash
  48. function or based on netdev->select_queue() if you have it defined.
  49. The behavior of tc filters remains the same. However a new tc action,
  50. skbedit, has been added. Assuming you wanted to route all traffic to a
  51. specific host, for example 192.168.0.3, through a specific queue you could use
  52. this action and establish a filter such as::
  53. tc filter add dev eth0 parent 1: protocol ip prio 1 u32 \
  54. match ip dst 192.168.0.3 \
  55. action skbedit queue_mapping 3
  56. :Author: Alexander Duyck <alexander.h.duyck@intel.com>
  57. :Original Author: Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>