1. Jun 25, 2023
  2. Jun 24, 2023
    • Jakub Kicinski's avatar
      Merge branch 'mlxsw-maintain-candidate-rifs' · d1d29a42
      Jakub Kicinski authored
      Petr Machata says:
      
      ====================
      mlxsw: Maintain candidate RIFs
      
      The mlxsw driver currently makes the assumption that the user applies
      configuration in a bottom-up manner. Thus netdevices need to be added to
      the bridge before IP addresses are configured on that bridge or SVI added
      on top of it. Enslaving a netdevice to another netdevice that already has
      uppers is in fact forbidden by mlxsw for this reason. Despite this safety,
      it is rather easy to get into situations where the offloaded configuration
      is just plain wrong.
      
      As an example, take a front panel port, configure an IP address: it gets a
      RIF. Now enslave the port to the bridge, and the RIF is gone. Remove the
      port from the bridge again, but the RIF never comes back. There is a number
      of similar situations, where changing the configuration there and back
      utterly breaks the offload.
      
      The situation is going to be made better by implementing a range of replays
      and post-hoc offloads.
      
      This patch set lays the ground for replay of next hops. The particular
      issue that it deals with is that currently, driver-specific bookkeeping for
      next hops is hooked off RIF objects, which come and go across the lifetime
      of a netdevice. We would rather keep these objects at an entity that
      mirrors the lifetime of the netdevice itself. That way they are at hand and
      can be offloaded when a RIF is eventually created.
      
      To that end, with this patchset, mlxsw keeps a hash table of CRIFs:
      candidate RIFs, persistent handles for netdevices that mlxsw deems
      potentially interesting. The lifetime of a CRIF matches that of the
      underlying netdevice, and thus a RIF can always assume a CRIF exists. A
      CRIF is where next hops are kept, and when RIF is created, these next hops
      can be easily offloaded. (Previously only the next hops created after the
      RIF was created were offloaded.)
      
      - Patches #1 and #2 are minor adjustments.
      - In patches #3 and #4, add CRIF bookkeeping.
      - In patch #5, link CRIFs to RIFs such that given a netdevice-backed RIF,
        the corresponding CRIF is easy to look up.
      - Patch #6 is a clean-up allowed by the previous patches
      - Patches #7 and #8 move next hop tracking to CRIFs
      
      No observable effects are intended as of yet. This will be useful once
      there is support for RIF creation for netdevices that become mlxsw uppers,
      which will come in following patch sets.
      ====================
      
      Link: https://lore.kernel.org/r/cover.1687438411.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      d1d29a42
    • Petr Machata's avatar
      mlxsw: spectrum_router: Track next hops at CRIFs · 9464a3d6
      Petr Machata authored
      
      
      Move the list of next hops from struct mlxsw_sp_rif to mlxsw_sp_crif. The
      reason is that eventually, next hops for mlxsw uppers should be offloaded
      and unoffloaded on demand as a netdevice becomes an upper, or stops being
      one. Currently, next hops are tracked at RIFs, but RIFs do not exist when a
      netdevice is not an mlxsw uppers. CRIFs are kept track of throughout the
      netdevice lifetime.
      
      Correspondingly, track at each next hop not its RIF, but its CRIF (from
      which a RIF can always be deduced).
      
      Note that now that next hops are tracked at a CRIF, it is not necessary to
      move each over to a new RIF when it is necessary to edit a RIF. Therefore
      drop mlxsw_sp_nexthop_rif_migrate() and have mlxsw_sp_rif_migrate_destroy()
      call mlxsw_sp_nexthop_rif_update() directly.
      
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Link: https://lore.kernel.org/r/e7c1c0a7dd13883b0f09aeda12c4fcf4d63a70e3.1687438411.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      9464a3d6
    • Petr Machata's avatar
      mlxsw: spectrum_router: Split nexthop finalization to two stages · a285d664
      Petr Machata authored
      
      
      Nexthop finalization consists of two steps: the part where the offload is
      removed, because the backing RIF is now gone; and the part where the
      association to the RIF is severed.
      
      Extract from mlxsw_sp_nexthop_type_fini() a helper that covers the
      unoffloading part, mlxsw_sp_nexthop_type_rif_gone(), so that it can later
      be called independently.
      
      Note that this swaps around the ordering of mlxsw_sp_nexthop_ipip_fini()
      vs. mlxsw_sp_nexthop_rif_fini(). The current ordering is more of a
      historical happenstance than a conscious decision. The two cleanups do not
      depend on each other, and this change should have no observable effects.
      
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Link: https://lore.kernel.org/r/7134559534c5f5c4807c3a1569fae56f8887e763.1687438411.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      a285d664
    • Petr Machata's avatar
      mlxsw: spectrum_router: Use router.lb_crif instead of .lb_rif_index · bdc0b78e
      Petr Machata authored
      
      
      A previous patch added a pointer to loopback CRIF to the router data
      structure. That makes the loopback RIF index redundant, as everything
      necessary can be derived from the CRIF. Drop the field and adjust the code
      accordingly.
      
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Link: https://lore.kernel.org/r/8637bf959bc5b6c9d5184b9bd8a0cd53c5132835.1687438411.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      bdc0b78e
    • Petr Machata's avatar
      mlxsw: spectrum_router: Link CRIFs to RIFs · aa21242b
      Petr Machata authored
      
      
      When a RIF is about to be created, the registration of the netdevice that
      it should be associated with must have been seen in the past, and a CRIF
      created. Therefore make this a hard requirement by looking up the CRIF
      during RIF creation, and complaining loudly when there isn't one.
      
      This then allows to keep a link between a RIF and its corresponding
      CRIF (and back, as the relationship is one-to-at-most-one), which do.
      
      The CRIF will later be useful as the objects tracked there will be
      offloaded lazily as a result of RIF creation.
      
      CRIFs are created when an "interesting" netdevice is registered, and
      destroyed after such device is unregistered. CRIFs are supposed to already
      exist when a RIF creation request arises, and exist at least as long as
      that RIF exists. This makes for a simple invariant: it is always safe to
      dereference CRIF pointer from "its" RIF.
      
      To guarantee this, CRIFs cannot be removed immediately when the UNREGISTER
      event is delivered. The reason is that if a RIF's netdevices has an IPv6
      address, removal of this address is notified in an atomic block. To remove
      the RIF, the IPv6 removal handler schedules a work item. It must be safe
      for this work item to access the associated CRIF as well.
      
      Thus when a netdevice that backs the CRIF is removed, if it still has a
      RIF, do not actually free the CRIF, only toggle its can_destroy flag, which
      this patch adds. Later on, mlxsw_sp_rif_destroy() collects the CRIF.
      
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Link: https://lore.kernel.org/r/68c8e33afa6b8c03c431b435e1685ffdff752e63.1687438411.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      aa21242b