9 VPP implements Transmit queues infra to access and manage them. It provides
10 common registration functions to register or unregister interfaces’ transmit
11 queues. It also provides functions for queues placement on given thread(s).
13 The TXQ Infrastructure
14 _______________________
16 Infra registers each queue using a unique key which is formed by concatenating
17 the hardware interface index ``hw_if_index`` and unique queue identifier for
18 given interface ``queue_id``. As a result of registration of queue, infra
19 returns back a unique global ``queue_index`` which can be used by driver to
20 access that queue later.
22 Interface output node uses pre-computed ``output_node_thread_runtime`` data
23 which provides essential information related to queue placements on given
24 thread of given interface. Transmit queue infra implements an algorithm to
25 pre-compute this information. It also pre-computes scalar arguments of frame
26 ``vnet_hw_if_tx_frame_t``. It also pre-calculates a ``lookup_table`` for
27 thread if there are multiple transmit queues are placed on that thread.
28 Interface drivers call ``vnet_hw_if_update_runtime_data()`` to execute that
29 algorithm after registering the transmit queues to TXQ infra.
31 The algorithm makes the copy of existing runtime data and iterate through them
32 for each vpp main and worker thread. In each iteration, algorithm loop through
33 all the tx queues of given interface to fill the information in the frame data
34 structure ``vnet_hw_if_tx_frame_t``. Algorithm also updates the information
35 related to number of transmit queues of given interface on given vpp thread in
36 data structure ``output_node_thread_runtime``. As a consequence of any update
37 to the copy, triggers the function to update the actual working copy by taking
38 the worker barrier and free the old copy of ``output_node_thread_runtime``.
43 Interface output node uses packet flow hash using hash infra in case of multi-txq
44 on given thread. Each hardware interface class contains type of the hash required
45 for interfaces from that hardware interface class i.e. ethernet interface hardware
46 class contains type ``VNET_HASH_FN_TYPE_ETHERNET``. Though, the hash function
47 itself is contained by hardware interface data structure of given interface. Default
48 hashing function is selected upon interface creation based on priority. User can
49 configure a different hash to an interface for multi-txq use case.
51 Interface output node uses packet flow hash as an index to the pre-calculated lookup
52 table to get the queue identifier for given transmit queue. Interface output node
53 enqueues the packets to respective frame and also copies the ``vnet_hw_if_tx_frame_t``
54 to frame scalar arguments. Drivers use scalar arguments ``vnet_hw_if_tx_frame_t``
55 of the given frame to extract the information about the transmit queue to be used to
56 transmit the packets. Drivers may need to acquire a lock on given queue before
57 transmitting the packets based on the ``shared_queue`` bit status.
62 Queue information is stored in data structure ``vnet_hw_if_tx_queue_t``:
68 /* either this queue is shared among multiple threads */
70 /* hw interface index */
73 /* hardware queue identifier */
76 /* bitmap of threads which use this queue */
77 clib_bitmap_t *threads;
78 } vnet_hw_if_tx_queue_t;
81 Frame information is stored in data structure: ``vnet_hw_if_tx_frame_t``:
87 VNET_HW_IF_TX_FRAME_HINT_NOT_CHAINED = (1 << 0),
88 VNET_HW_IF_TX_FRAME_HINT_NO_GSO = (1 << 1),
89 VNET_HW_IF_TX_FRAME_HINT_NO_CKSUM_OFFLOAD = (1 << 2),
90 } vnet_hw_if_tx_frame_hint_t;
95 vnet_hw_if_tx_frame_hint_t hints : 16;
97 } vnet_hw_if_tx_frame_t;
99 Output node runtime information is stored in data structure: ``output_node_thread_runtime``:
105 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
106 vnet_hw_if_tx_frame_t *frame;
109 } vnet_hw_if_output_node_runtime_t;
115 This API message is used to place tx queue of an interface to vpp main or worker(s) thread(s).
119 autoendian autoreply define sw_interface_set_tx_placement
123 vl_api_interface_index_t sw_if_index;
126 u32 threads[array_size];
127 option vat_help = "<interface | sw_if_index <index>> queue <n> [threads <list> | mask <hex>]";
135 set interface tx-queue set interface tx-queue <interface> queue <n> [threads <list>]
136 set interface tx-hash set interface tx-hash <interface> hash-name <hash-name>
140 show hardware-interfaces
142 Name Idx Link Hardware
149 TX Hash: [name: crc32c-5tuple priority: 50 description: IPv4/IPv6 header and TCP/UDP ports]
150 queue shared thread(s)
152 Ethernet address 02:fe:27:69:5a:b5
155 RX QUEUE : Total Packets
157 TX QUEUE : Total Packets