• Jacob Keller's avatar
    ice: refactor devlink_port to be per-VSI · 48d40025
    Jacob Keller authored
    Currently, the devlink_port structure is stored within the ice_pf. This
    made sense because we create a single devlink_port for each PF. This
    setup does not mesh with the abstractions in the driver very well, and
    led to a flow where we accidentally call devlink_port_unregister twice
    during error cleanup.
    
    In particular, if devlink_port_register or devlink_port_unregister are
    called twice, this leads to a kernel panic. This appears to occur during
    some possible flows while cleaning up from a failure during driver
    probe.
    
    If register_netdev fails, then we will call devlink_port_unregister in
    ice_cfg_netdev as it cleans up. Later, we again call
    devlink_port_unregister since we assume that we must cleanup the port
    that is associated with the PF structure.
    
    This occurs because we cleanup the devlink_port for the main PF even
    though it was not allocated. We allocated the port within a per-VSI
    function for managing the main netdev, but did not release the port when
    cleaning up that VSI, the allocation and destruction are not aligned.
    
    Instead of attempting to manage the devlink_port as part of the PF
    structure, manage it as part of the PF VSI. Doing this has advantages,
    as we can match the de-allocation of the devlink_port with the
    unregister_netdev associated with the main PF VSI.
    
    Moving the port to the VSI is preferable as it paves the way for
    handling devlink ports allocated for other purposes such as SR-IOV VFs.
    
    Since we're changing up how we allocate the devlink_port, also change
    the indexing. Originally, we indexed the port using the PF id number.
    This came from an old goal of sharing a devlink for each physical
    function. Managing devlink instances across multiple function drivers is
    not workable. Instead, lets set the port number to the logical port
    number returned by firmware and set the index using the VSI index
    (sometimes referred to as VSI handle).
    Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
    Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
    Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    48d40025
ice_devlink.h 516 Bytes