Few comments below, 14/06/2022 14:01, Spike Du: > Add command line options to support host shaper configure. > - Command syntax: > mlx5 set port <port_id> host_shaper avail_thresh_triggered <0|1> rate > <rate_num> > > - Example commands: > To enable avail_thresh_triggered on port 1 and disable current host > shaper: > testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0 > > To disable avail_thresh_triggered and current host shaper on port 1: > testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0 > > The rate unit is 100Mbps. > To disable avail_thresh_triggered and configure a shaper of 5Gbps on > port 1: > testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50 > > Add sample code to handle rxq available descriptor threshold event, it > delays a while so that rxq empties, then disables host shaper and > rearms available descriptor threshold event. > > Signed-off-by: Spike Du <spi...@nvidia.com> [...] > @@ -3659,6 +3662,10 @@ struct pmd_test_command { > break; > printf("Received avail_thresh event, port:%d > rxq_id:%d\n", > port_id, rxq_id); > + > +#ifdef RTE_NET_MLX5 > + mlx5_test_avail_thresh_event_handler(port_id, rxq_id); > +#endif
This function includes a check of the driver in use for the port, so I assume it is OK to call it unconditionally here. [...] > +How to use available descriptor threshold and Host Shaper > +------------------------------ Underlining should be of same size as the title. > + > +There are sample command lines to configure available descriptor threshold > in testpmd. Simpler: There is a command to configure available descriptor threshold in testpmd. You could add a link here to the doc of the command. > +Testpmd also contains sample logic to handle available descriptor threshold > event. > +The typical workflow is: testpmd configure available descriptor threshold > for Rx queues, enable > +avail_thresh_triggered in host shaper and register a callback, when traffic > from host is > +too high and Rx queue emptiness is below available descriptor threshold, PMD > receives an event and > +firmware configures a 100Mbps shaper on host port automatically, then PMD > call > +the callback registered previously, which will delay a while to let Rx queue > +empty, then disable host shaper. > + > +Let's assume we have a simple Blue Field 2 setup: port 0 is uplink, port 1 There's no space in BlueField. > +is VF representor. Each port has 2 Rx queues. > +In order to control traffic from host to ARM, we can enable available > descriptor threshold in testpmd by: > + > +.. code-block:: console > + > + testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0 > + testpmd> set port 1 rxq 0 avail_thresh 70 > + testpmd> set port 1 rxq 1 avail_thresh 70 > + > +The first command disables current host shaper, and enables available > descriptor threshold triggered mode. > +The left commands configure available descriptor threshold to 70% of Rx > queue size for both Rx queues, left -> other > +When traffic from host is too high, you can see testpmd console prints log > +about available descriptor threshold event receiving, then host shaper is > disabled. > +The traffic rate from host is controlled and less drop happens in Rx queues. > + > +When disable available descriptor threshold and avail_thresh_triggered, we > can invoke below commands in testpmd: Reword: The threshold event and shaper can be disabled like this: > + > +.. code-block:: console > + > + testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0 > + testpmd> set port 1 rxq 0 avail_thresh 0 > + testpmd> set port 1 rxq 1 avail_thresh 0 > + > +It's recommended an application disables available descriptor threshold and > avail_thresh_triggered before exit, > +if it enables them before. > + > +We can also configure the shaper with a value, the rate unit is 100Mbps, > below > +command sets current shaper to 5Gbps and disables avail_thresh_triggered. > + > +.. code-block:: console > + > + testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50