1. 29 6月, 2022 2 次提交
    • A
      mlxsw: spectrum_switchdev: Rename MID structure · eede53a4
      Amit Cohen 提交于
      Currently the structure which represents MDB entry is called
      'struct mlxsw_sp_mid'. This name is not accurate as a MID entry stores a
      bitmap of ports to which a packet needs to be replicated and a MDB entry
      stores the mapping from {MAC, FID} to PGT index (MID).
      
      Rename the structure to 'struct mlxsw_sp_mdb_entry'. The structure
      'mlxsw_sp_mid' is defined as part of spectrum.h. The only file which
      uses it is spectrum_switchdev.c, so there is no reason to expose it to
      other files. Move the definition to spectrum_switchdev.c.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      eede53a4
    • A
      mlxsw: Align PGT index to legacy bridge model · 4abaa5cc
      Amit Cohen 提交于
      FID code reserves about 15K entries in PGT table for flooding. These
      entries are just allocated and are not used yet because the code that uses
      them is skipped now.
      
      The next patches will convert MDB code to use PGT APIs. The allocation of
      indexes for multicast is done after FID code reserves 15K entries.
      Currently, legacy bridge model is used and firmware manages PGT table. That
      means that the indexes which are allocated using PGT API are too high when
      legacy bridge model is used. To not exceed firmware limitation for MDB
      entries, add an API that returns the correct 'mid_index', based on bridge
      model. For legacy model, subtract the number of flood entries from PGT
      index. Use it to write the correct MID to SMID register. This API will be
      used also from MDB code in the next patches.
      
      PGT should not be aware of MDB and FID different usage, this API is
      temporary and will be removed once unified bridge model will be used.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4abaa5cc
  2. 28 6月, 2022 5 次提交
    • A
      mlxsw: Extend PGT APIs to support maintaining list of ports per entry · a3a7992b
      Amit Cohen 提交于
      Add an API to associate a PGT entry with SMPE index and add or remove a
      port. This API will be used by FID code and MDB code, to add/remove port
      from specific PGT entry.
      
      When the first port is added to PGT entry, allocate the entry in the given
      MID index, when the last port is removed from PGT entry, free it.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      a3a7992b
    • A
      mlxsw: Add a dedicated structure for bitmap of ports · d7a7b697
      Amit Cohen 提交于
      Currently when bitmap of ports is needed, 'unsigned long *' type is
      used. The functions which use the bitmap assume its length according to
      its name, i.e., each function which gets a bitmap of ports queries the
      maximum number of ports and uses it as the size.
      
      As preparation for the next patch which will use bitmap of ports, add a
      dedicated structure for it. Refactor the existing code to use the new
      structure.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      d7a7b697
    • A
      mlxsw: Add an indication of SMPE index validity for PGT table · a1697d11
      Amit Cohen 提交于
      In Spectrum-1, the index into the MPE table - called switch multicast to
      port egress VID (SMPE) - is derived from the PGT entry, whereas in
      Spectrum-2 and later ASICs it is derived from the FID.
      
      Therefore, in Spectrum-1, the SMPE index needs to be programmed as part of
      the PGT entry via SMID register, while it is reserved for Spectrum-2 and
      later ASICs.
      
      Add 'pgt_smpe_index_valid' boolean as part of 'struct mlxsw_sp' and set
      it to true for Spectrum-1 and to false for the later ASICs. Add
      'smpe_index_valid' as part of 'struct mlxsw_sp_pgt' and set it according
      to the value in 'struct mlxsw_sp' as part of PGT initialization.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Reviewed-by: NPetr Machata <petrm@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      a1697d11
    • A
      mlxsw: Add an initial PGT table support · d8782ec5
      Amit Cohen 提交于
      The PGT (Port Group Table) table maps an index to a bitmap of local ports
      to which a packet needs to be replicated. This table is used for layer 2
      multicast and flooding.
      
      In the legacy model, software did not interact with this table directly.
      Instead, it was accessed by firmware in response to registers such as
      SFTR and SMID. In the new model, the SFTR register is deprecated and
      software has full control over the PGT table using the SMID register.
      
      The entire state of the PGT table needs to be maintained in software
      because member ports in a PGT entry needs to be reference counted to avoid
      releasing entries which are still in use.
      
      Add the following APIs:
      1. mlxsw_sp_pgt_{init, fini}() - allocate/free the PGT table.
      2. mlxsw_sp_pgt_mid_alloc_range() - allocate a range of MID indexes in PGT.
         To be used by FID code during initialization to reserve specific PGT
         indexes for flooding entries.
      3. mlxsw_sp_pgt_mid_free_range() - free indexes in a given range.
      4. mlxsw_sp_pgt_mid_alloc() - allocate one MID index in the PGT at a
         non-specific range, just search for free index. To be used by MDB code.
      5. mlxsw_sp_pgt_mid_free() - free the given index.
      
      Note that alloc() functions do not allocate the entries in software, just
      allocate IDs using 'idr'.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Reviewed-by: NPetr Machata <petrm@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      d8782ec5
    • A
      mlxsw: spectrum: Add a temporary variable to indicate bridge model · d6d90266
      Amit Cohen 提交于
      As part of transition to unified bridge model, many different firmware
      configurations are done.
      
      Some of the configuration that needs to be done for the unified bridge
      model is not valid under the legacy model, and would be rejected by the
      firmware. At the same time, the driver cannot switch to the unified bridge
      model until all of the code has been converted.
      
      To allow breaking the change into patches, and to not break driver
      behavior during the transition, add a boolean variable to indicate bridge
      model. Then, forbidden configurations will be skipped using the check -
      "if (!mlxsw_sp->ubridge)".
      
      The new variable is temporary for several sets, it will be removed when
      firmware will be configured to work with unified bridge model.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Reviewed-by: NPetr Machata <petrm@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      d6d90266
  3. 24 6月, 2022 2 次提交
    • A
      mlxsw: spectrum: Rename MLXSW_SP_RIF_TYPE_VLAN · 027c92e0
      Amit Cohen 提交于
      Currently, the driver emulates 802.1Q FIDs using 802.1D FIDs. As such,
      the RIFs configured on top of these FIDs are FID RIFs and not VLAN RIFs.
      
      As part of converting the driver to the unified bridge model, 802.1Q
      FIDs and VLAN RIFs will be used.
      
      As a preparation for this change, rename the emulated VLAN RIFs from
      'MLXSW_SP_RIF_TYPE_VLAN' to 'MLXSW_SP_RIF_TYPE_VLAN_EMU'. After the
      conversion the emulated VLAN RIFs will be removed.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      027c92e0
    • A
      mlxsw: spectrum: Use different arrays of FID families per-ASIC type · 04e85970
      Amit Cohen 提交于
      Egress VID for layer 2 multicast is determined from two tables, the MPE
      and PGT tables. The MPE table is a two dimensional table indexed by local
      port and SMPE index, which should be thought of as a FID index.
      
      In Spectrum-1 the SMPE index is derived from the PGT entry, whereas in
      Spectrum-2 and newer ASICs the SMPE index is a FID attribute configured
      via the SFMR register.
      
      The validity of the SMPE index in SFMR is influenced from two factors:
      1. FID family. SMPE index is reserved for rFIDs, as their flooding is
         handled by firmware.
      2. ASIC generation. SMPE index is always reserved for Spectrum-1.
      
      As such, the validity of the SMPE index should be an attribute of the FID
      family and have different arrays of FID families per-ASIC type.
      
      As a preparation for SMPE index configuration, create separate arrays of
      FID families for different ASICs.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      04e85970
  4. 22 6月, 2022 1 次提交
  5. 17 6月, 2022 1 次提交
  6. 08 5月, 2022 3 次提交
  7. 18 4月, 2022 3 次提交
  8. 07 2月, 2022 1 次提交
  9. 28 1月, 2022 1 次提交
    • A
      mlxsw: spectrum: Guard against invalid local ports · bcdfd615
      Amit Cohen 提交于
      When processing events generated by the device's firmware, the driver
      protects itself from events reported for non-existent local ports, but
      not for the CPU port (local port 0), which exists, but does not have all
      the fields as any local port.
      
      This can result in a NULL pointer dereference when trying access
      'struct mlxsw_sp_port' fields which are not initialized for CPU port.
      
      Commit 63b08b1f ("mlxsw: spectrum: Protect driver from buggy firmware")
      already handled such issue by bailing early when processing a PUDE event
      reported for the CPU port.
      
      Generalize the approach by moving the check to a common function and
      making use of it in all relevant places.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      bcdfd615
  10. 07 1月, 2022 3 次提交
    • A
      mlxsw: spectrum_acl_bloom_filter: Add support for Spectrum-4 calculation · 852ee419
      Amit Cohen 提交于
      Spectrum-4 will calculate hash function for bloom filter differently
      from the existing ASICs.
      
      First, two hash functions will be used to calculate 16 bits result.
      The final result will be combination of the two results - 6 bits which
      are result of CRC-6 will be used as MSB and 10 bits which are result of
      CRC-10 will be used as LSB.
      
      Second, while in Spectrum{2,3}, there is a padding in each chunk, so the
      chunks use a sequence of whole bytes, in Spectrum-4 there is no padding,
      so each chunk use 20 bytes minus 2 bits, so it is necessary to align the
      chunks to be without holes.
      
      Add dedicated 'mlxsw_sp_acl_bf_ops' for Spectrum-4 and add the required
      tables for CRC calculations.
      
      All the details are documented as part of the code for future use.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Reviewed-by: NPetr Machata <petrm@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      852ee419
    • A
      mlxsw: Add operations structure for bloom filter calculation · 58723d2f
      Amit Cohen 提交于
      Spectrum-4 will calculate hash function for bloom filter differently from
      the existing ASICs.
      
      There are two changes:
      1. Instead of using one hash function to calculate 16 bits output (CRC-16),
         two functions will be used.
      2. The chunks will be built differently, without padding.
      
      As preparation for support of Spectrum-4 bloom filter, add 'ops'
      structure to allow handling different calculation for different ASICs.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Reviewed-by: NPetr Machata <petrm@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      58723d2f
    • A
      mlxsw: Introduce flex key elements for Spectrum-4 · 07ff1359
      Amit Cohen 提交于
      Spectrum-4 ASIC will support more virtual routers and local ports
      compared to the existing ASICs. Therefore, the virtual router and local
      port ACL key elements need to be increased.
      
      Introduce new key elements for Spectrum-4 to be aligned with the elements
      used already for other Spectrum ASICs.
      
      The key blocks layout is the same for Spectrum-4, so use the existing
      code for encode_block() and clear_block(), just create separate blocks.
      
      Note that size of `VIRT_ROUTER_MSB` is 4 bits in Spectrum-4,
      therefore declare it using `MLXSW_AFK_ELEMENT_INST_U32()`, in order to
      be able to set `.avoid_size_check` to true.
      Otherwise, `mlxsw_afk_blocks_check()` will fail and warn.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      07ff1359
  11. 15 12月, 2021 2 次提交
  12. 01 12月, 2021 1 次提交
  13. 26 10月, 2021 1 次提交
  14. 14 10月, 2021 1 次提交
    • P
      mlxsw: spectrum_qdisc: Introduce per-TC ECN counters · 15be36b8
      Petr Machata 提交于
      The Qdisc code in mlxsw used to report a number of packets ECN-marked on a
      port. Because reporting a per-port value as a per-TC value was misleading,
      this was removed in commit 8a29581e ("mlxsw: spectrum: Move the
      ECN-marked packet counter to ethtool").
      
      On Spectrum-3, a per-TC number of ECN-marked packets is available in per-TC
      congestion counter group. Add a new array for the ECN counter, fetch the
      values from the per-TC congestion group, and pick the value indicated by
      tclass_num as appropriate.
      
      On Spectrum-1 and Spectrum-2, this per-TC value is not available, and
      zeroes will be reported, as they currently are.
      Signed-off-by: NPetr Machata <petrm@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      15be36b8
  15. 12 10月, 2021 1 次提交
  16. 24 9月, 2021 1 次提交
  17. 14 9月, 2021 1 次提交
  18. 23 8月, 2021 1 次提交
    • A
      mlxsw: spectrum: Add infrastructure for parsing configuration · 2d91f080
      Amit Cohen 提交于
      Spectrum ASICs have a configurable limit on how deep into the packet
      they parse. By default, the limit is 96 bytes.
      
      There are several cases where this parsing depth is not enough and there
      is a need to increase it. Currently, increasing parsing depth is
      maintained as part of VxLAN module, because the MPRS register which
      configures parsing depth also configures UDP destination port number
      used for VxLAN encapsulation and decapsulation.
      
      Add an API for increasing parsing depth as part of spectrum.c code, so
      that it will be possible to use it from other modules. In addition, add
      an API for setting UDP destination port and protect it using a dedicated
      lock for saving parsing configurations. The lock is needed as not all
      the callers hold RTNL lock.
      
      Maintain a counter for increased parsing depth consumers. For first
      consumer subscription, increase the parsing depth and for last consumer
      unsubscription, set parsing depth to default value.
      Signed-off-by: NAmit Cohen <amcohen@nvidia.com>
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2d91f080
  19. 30 3月, 2021 1 次提交
    • I
      mlxsw: spectrum: Fix ECN marking in tunnel decapsulation · 66167c31
      Ido Schimmel 提交于
      Cited commit changed the behavior of the software data path with regards
      to the ECN marking of decapsulated packets. However, the commit did not
      change other callers of __INET_ECN_decapsulate(), namely mlxsw. The
      driver is using the function in order to ensure that the hardware and
      software data paths act the same with regards to the ECN marking of
      decapsulated packets.
      
      The discrepancy was uncovered by commit 5aa3c334 ("selftests:
      forwarding: vxlan_bridge_1d: Fix vxlan ecn decapsulate value") that
      aligned the selftest to the new behavior. Without this patch the
      selftest passes when used with veth pairs, but fails when used with
      mlxsw netdevs.
      
      Fix this by instructing the device to propagate the ECT(1) mark from the
      outer header to the inner header when the inner header is ECT(0), for
      both NVE and IP-in-IP tunnels.
      
      A helper is added in order not to duplicate the code between both tunnel
      types.
      
      Fixes: b7237487 ("tunnel: Propagate ECT(1) when decapsulating as recommended by RFC6040")
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: NPetr Machata <petrm@nvidia.com>
      Acked-by: NToke Høiland-Jørgensen <toke@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      66167c31
  20. 23 3月, 2021 1 次提交
  21. 18 3月, 2021 2 次提交
  22. 17 3月, 2021 5 次提交