• Amit Cohen's avatar
    mlxsw: pci: Initialize dummy net devices for NAPI · 5d01ed2e
    Amit Cohen authored
    mlxsw will use NAPI for event processing in a next patch. As preparation,
    add two dummy net devices and initialize them.
    
    NAPI instance should be attached to net device. Usually each queue is used
    by a single net device in network drivers, so the mapping between net
    device to NAPI instance is intuitive. In our case, Rx queues are not per
    port, they are per trap-group. Tx queues are mapped to net devices, but we
    do not have a separate queue for each local port, several ports share the
    same queue.
    
    Use init_dummy_netdev() to initialize dummy net devices for NAPI.
    
    To run NAPI poll method in a kernel thread, the net device which NAPI
    instance is attached to should be marked as 'threaded'. It is
    recommended to handle Tx packets in softIRQ context, as usually this is
    a short task - just free the Tx packet which has been transmitted.
    Rx packets handling is more complicated task, so drivers can use a
    dedicated kernel thread to process them. It allows processing packets from
    different Rx queues in parallel. We would like to handle only Rx packets in
    kernel threads, which means that we will use two dummy net devices
    (one for Rx and one for Tx). Set only one of them with 'threaded' as it
    will be used for Rx processing. Do not fail in case that setting 'threaded'
    fails, as it is better to use regular softIRQ NAPI rather than preventing
    the driver from loading.
    
    Note that the net devices are initialized with init_dummy_netdev(), so
    they are not registered, which means that they will not be visible to user.
    It will not be possible to change 'threaded' configuration from user
    space, but it is reasonable in our case, as there is no another
    configuration which makes sense, considering that user has no influence
    on the usage of each queue.
    Signed-off-by: default avatarAmit Cohen <amcohen@nvidia.com>
    Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
    Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    5d01ed2e
pci.c 60.1 KB