• Vladimir Oltean's avatar
    net: enetc: split ring resource allocation from assignment · f3ce29e1
    Vladimir Oltean authored
    We have a few instances in the enetc driver where the ring resources
    (BD ring iomem, software BD ring, software TSO headers, basically
    everything except RX buffers) need to be reallocated. For example, when
    RX timestamping is enabled, the RX BD format changes to an extended one
    (twice as large).
    
    Currently, this is done using a simplistic enetc_close() -> enetc_open()
    procedure. But this is quite crude, since it also invokes phylink_stop()
    -> phylink_start(), the link is lost, and a few seconds need to pass for
    autoneg to complete again.
    
    In fact it's bad also due to the improper (yolo) error checking. In case
    we fail to allocate new resources, we've already freed the old ones, so
    the interface is more or less stuck.
    
    To avoid that, we need a system where reconfiguration is possible in a
    way in which resources are allocated upfront. This means that there will
    be a higher memory usage temporarily, but the assignment of resources to
    rings can be done when both the old and new resources are still available.
    
    Introduce a struct enetc_bdr_resource which holds the resources for a
    ring, be it RX or TX. This structure duplicates a lot of fields from
    struct enetc_bdr (and access to the same fields in the ring structure
    was left duplicated, to not change cache characteristics in the fast
    path).
    
    When enetc_alloc_tx_resources() runs, it returns an array of resource
    elements (one per TX ring), in addition to the existing priv->tx_res.
    To populate priv->tx_res with that array, one must call
    enetc_assign_tx_resources(), and this also frees the old resources.
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    f3ce29e1
enetc.c 72 KB