• Eli Cohen's avatar
    vdpa: Add support for querying vendor statistics · 13b00b13
    Eli Cohen authored
    Allows to read vendor statistics of a vdpa device. The specific
    statistics data are received from the upstream driver in the form of an
    (attribute name, attribute value) pairs.
    
    An example of statistics for mlx5_vdpa device are:
    
    received_desc - number of descriptors received by the virtqueue
    completed_desc - number of descriptors completed by the virtqueue
    
    A descriptor using indirect buffers is still counted as 1. In addition,
    N chained descriptors are counted correctly N times as one would expect.
    
    A new callback was added to vdpa_config_ops which provides the means for
    the vdpa driver to return statistics results.
    
    The interface allows for reading all the supported virtqueues, including
    the control virtqueue if it exists.
    
    Below are some examples taken from mlx5_vdpa which are introduced in the
    following patch:
    
    1. Read statistics for the virtqueue at index 1
    
    $ vdpa dev vstats show vdpa-a qidx 1
    vdpa-a:
    queue_type tx queue_index 1 received_desc 3844836 completed_desc 3844836
    
    2. Read statistics for the virtqueue at index 32
    $ vdpa dev vstats show vdpa-a qidx 32
    vdpa-a:
    queue_type control_vq queue_index 32 received_desc 62 completed_desc 62
    
    3. Read statisitics for the virtqueue at index 0 with json output
    $ vdpa -j dev vstats show vdpa-a qidx 0
    {"vstats":{"vdpa-a":{
    "queue_type":"rx","queue_index":0,"name":"received_desc","value":417776,\
     "name":"completed_desc","value":417548}}}
    
    4. Read statistics for the virtqueue at index 0 with preety json output
    $ vdpa -jp dev vstats show vdpa-a qidx 0
    {
        "vstats": {
            "vdpa-a": {
    
                "queue_type": "rx",
                "queue_index": 0,
                "name": "received_desc",
                "value": 417776,
                "name": "completed_desc",
                "value": 417548
            }
        }
    }
    Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
    Message-Id: <20220518133804.1075129-3-elic@nvidia.com>
    Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    13b00b13
vdpa.c 30.3 KB