Skip to content

Commit 7447eda

Browse files
Amit Cohenkuba-moo
authored andcommitted
mlxsw: reg: Add Management Capabilities Mask Register
MCAM register reports the device supported management features. Querying this register exposes if features are supported with the current firmware version in the current ASIC. Then, the driver can separate between different implementations dynamically. MCAM register supports querying whether the MCIA register supports 128 bytes payloads or only 48 bytes. Add support for the register as preparation for allowing larger MCIA transactions. Note that the access to the bits in the field 'mng_feature_cap_mask' is not same to other mask fields in other registers. In most of the cases bit #0 is the first one in the last dword, in MCAM register, bits #0-#31 are in the first dword and so on. Declare the mask field using bits arrays per dword to simplify the access. Signed-off-by: Amit Cohen <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Petr Machata <[email protected]> Signed-off-by: Petr Machata <[email protected]> Link: https://lore.kernel.org/r/1427a3f57ba93db1c5dd4f982bfb31dd5c82356e.1690281940.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 68bf510 commit 7447eda

File tree

1 file changed

+74
-0
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+74
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/reg.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10581,6 +10581,79 @@ static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
1058110581
mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
1058210582
}
1058310583

10584+
/* MCAM - Management Capabilities Mask Register
10585+
* --------------------------------------------
10586+
* Reports the device supported management features.
10587+
*/
10588+
#define MLXSW_REG_MCAM_ID 0x907F
10589+
#define MLXSW_REG_MCAM_LEN 0x48
10590+
10591+
MLXSW_REG_DEFINE(mcam, MLXSW_REG_MCAM_ID, MLXSW_REG_MCAM_LEN);
10592+
10593+
enum mlxsw_reg_mcam_feature_group {
10594+
/* Enhanced features. */
10595+
MLXSW_REG_MCAM_FEATURE_GROUP_ENHANCED_FEATURES,
10596+
};
10597+
10598+
/* reg_mcam_feature_group
10599+
* Feature list mask index.
10600+
* Access: Index
10601+
*/
10602+
MLXSW_ITEM32(reg, mcam, feature_group, 0x00, 16, 8);
10603+
10604+
enum mlxsw_reg_mcam_mng_feature_cap_mask_bits {
10605+
/* If set, MCIA supports 128 bytes payloads. Otherwise, 48 bytes. */
10606+
MLXSW_REG_MCAM_MCIA_128B = 34,
10607+
};
10608+
10609+
#define MLXSW_REG_BYTES_PER_DWORD 0x4
10610+
10611+
/* reg_mcam_mng_feature_cap_mask
10612+
* Supported port's enhanced features.
10613+
* Based on feature_group index.
10614+
* When bit is set, the feature is supported in the device.
10615+
* Access: RO
10616+
*/
10617+
#define MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(_dw_num, _offset) \
10618+
MLXSW_ITEM_BIT_ARRAY(reg, mcam, mng_feature_cap_mask_dw##_dw_num, \
10619+
_offset, MLXSW_REG_BYTES_PER_DWORD, 1)
10620+
10621+
/* The access to the bits in the field 'mng_feature_cap_mask' is not same to
10622+
* other mask fields in other registers. In most of the cases bit #0 is the
10623+
* first one in the last dword. In MCAM register, the first dword contains bits
10624+
* #0-#31 and so on, so the access to the bits is simpler using bit array per
10625+
* dword. Declare each dword of 'mng_feature_cap_mask' field separately.
10626+
*/
10627+
MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(0, 0x28);
10628+
MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(1, 0x2C);
10629+
MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(2, 0x30);
10630+
MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD(3, 0x34);
10631+
10632+
static inline void
10633+
mlxsw_reg_mcam_pack(char *payload, enum mlxsw_reg_mcam_feature_group feat_group)
10634+
{
10635+
MLXSW_REG_ZERO(mcam, payload);
10636+
mlxsw_reg_mcam_feature_group_set(payload, feat_group);
10637+
}
10638+
10639+
static inline void
10640+
mlxsw_reg_mcam_unpack(char *payload,
10641+
enum mlxsw_reg_mcam_mng_feature_cap_mask_bits bit,
10642+
bool *p_mng_feature_cap_val)
10643+
{
10644+
int offset = bit % (MLXSW_REG_BYTES_PER_DWORD * BITS_PER_BYTE);
10645+
int dword = bit / (MLXSW_REG_BYTES_PER_DWORD * BITS_PER_BYTE);
10646+
u8 (*getters[])(const char *, u16) = {
10647+
mlxsw_reg_mcam_mng_feature_cap_mask_dw0_get,
10648+
mlxsw_reg_mcam_mng_feature_cap_mask_dw1_get,
10649+
mlxsw_reg_mcam_mng_feature_cap_mask_dw2_get,
10650+
mlxsw_reg_mcam_mng_feature_cap_mask_dw3_get,
10651+
};
10652+
10653+
if (!WARN_ON_ONCE(dword >= ARRAY_SIZE(getters)))
10654+
*p_mng_feature_cap_val = getters[dword](payload, offset);
10655+
}
10656+
1058410657
/* MPSC - Monitoring Packet Sampling Configuration Register
1058510658
* --------------------------------------------------------
1058610659
* MPSC Register is used to configure the Packet Sampling mechanism.
@@ -12977,6 +13050,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
1297713050
MLXSW_REG(mcqi),
1297813051
MLXSW_REG(mcc),
1297913052
MLXSW_REG(mcda),
13053+
MLXSW_REG(mcam),
1298013054
MLXSW_REG(mpsc),
1298113055
MLXSW_REG(mgpc),
1298213056
MLXSW_REG(mprs),

0 commit comments

Comments
 (0)