When configuring hairpin queues, there is an input parameter to set the number of descriptors both for TX and RX interfaces. But it is not used for mlx5 devices because of the firmware mechanism. Currently, the stride buffer is being used for every ingress packet in the firmware. PMD driver could only set the total data buffer size and the maximal number of packets. Their relationship is as below (for a single queue): total_data_size = stride_size * maximal_packet_number
And small stride size is recommended (e.g. 64B) to save the memory for small packets and get better performance. To configure the hairpin queue, either the total data buffer size or the maximal packet number could be used. When using "maximal packet number", it is not quite straightforward: 1. It doesn't mean the packets number that could be held in the same time. Because for a larger packet, more than one stride will be consumed. 2. It is not quite clear that what is the maximal length supported for a single packet. A new device parameter will be introduced for mlx5 devices to set the data buffer length - "hp_buf_log_sz". 1. It is a logarithm value, so the actual buffer length will be 2 ^^ hp_buf_log_sz. 2. If not set when probing the device, a default value will be used. 3. If jumbo frames need to be supported for the hairpin, then a larger value could be set. Or else, some smaller value will help to save the memory and fewer cache misses. 4. There is no need to care about the hairpin queue depth since no SW is involved. And firmware will be in charge of the packet descriptors number and make sure it is full enough.