Comment 12 for bug 1962844

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/ussuri)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/832765
Committed: https://opendev.org/openstack/neutron/commit/98fe52e15eb7c05ff3337e6235435ffc9e1be4d7
Submitter: "Zuul (22348)"
Branch: stable/ussuri

commit 98fe52e15eb7c05ff3337e6235435ffc9e1be4d7
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Thu Mar 3 02:57:07 2022 +0000

    [SR-IOV] Fix QoS extension to set min/max values

    "ip link" commands allow to define VF rates independently.
    That means, first "rate" (max BW) can be set and in a second
    command "min" (min BW) (check LP bug description).

    However Pyroute2 command to set the VF rates requires to set both.
    If one value is missing ("min_tx_rate", "max_tx_rate"), the library
    sets this value to 0; in other words, the value is deleted.

    The Pyroute2 structures are built depending on the parameter names.
    In this case, {'vf': {'rate': ...}} will create a "vf_rate" [1]
    nla structure, that requires "min_tx_rate" and "max_tx_rate".
    This is part of the full structure passed to the "iproute" library
    [2].

    This is an example of code that only sets the "max_tx_rate" for
    the 15th VF of "enp196s0f0":
      $ from neutron.plugins.ml2.drivers.mech_sriov.agent import pci_lib
        pci = pci_lib.PciDeviceIPWrapper("enp196s0f0")
        pci.set_vf_rate(15, {'max_tx_rate': 10})

    The "msg" [3] (structure passed to "iproute" library) is this:
    https://paste.opendev.org/show/b2FZBOebGOCHMrYhPr6X/. The
    "min_tx_rate" is set to the default value 0.

    This patch reads first the existing rates ("min_tx_rate",
    "max_tx_rate") and populates the command parameters accordingly.

    [1]https://github.com/svinota/pyroute2/blob/a9564dff8e53659f761d71bbee0dd68dd0db6ce8/pyroute2.core/pr2modules/netlink/rtnl/ifinfmsg/__init__.py#L712-L717
    [2]https://github.com/shemminger/iproute2/blob/c8d9d92544668922dc5aa06d2491f42b837b9361/ip/ipaddress.c#L454-L470
    [3]https://github.com/svinota/pyroute2/blob/a9564dff8e53659f761d71bbee0dd68dd0db6ce8/pyroute2.core/pr2modules/iproute/linux.py#L1499

    Conflicts:
        neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py

    Closes-Bug: #1962844
    Change-Id: Ibbb6d938355440c42850812e368224b76b1fce19
    (cherry picked from commit cdff281f642511ea3d0e077dbe885ec955208a7a)
    (cherry picked from commit 1cadfc84a5650758153385bb52dea7be713c4184)