mlxsw: Speed up transceiver module EEPROM dump
Subsystems (3)
Petr Machata
maintainercover mlxsw: Speed up transceiver module EEPROM dump
Ido Schimmel writes:
Old firmware versions could only read up to 48 bytes from a transceiver module's EEPROM in one go. Newer versions can read up to 128 bytes, resulting in fewer transactions.
Query support for the new capability during driver initialization and if supported, read up to 128 bytes in one go.
This is going to be especially useful for upcoming transceiver module firmware flashing support.
Before:
# perf stat -e devlink:devlink_hwmsg -- ethtool -m swp11 page 0x1 offset 128 length 128 i2c 0x50 [...] Performance counter stats for 'ethtool -m swp11 page 0x1 offset 128 length 128 i2c 0x50':
3 devlink:devlink_hwmsg
After:
# perf stat -e devlink:devlink_hwmsg -- ethtool -m swp11 page 0x1 offset 128 length 128 i2c 0x50 [...] Performance counter stats for 'ethtool -m swp11 page 0x1 offset 128 length 128 i2c 0x50':
1 devlink:devlink_hwmsg
Patches #1-#4 are preparations / cleanups.
Patch #5 adds support for the new read size.
Amit Cohen (2):
mlxsw: reg: Move 'mpsc' definition in 'mlxsw_reg_infos'
mlxsw: reg: Add Management Capabilities Mask Register
Ido Schimmel (3):
mlxsw: reg: Remove unused function argument
mlxsw: reg: Increase Management Cable Info Access Register length
mlxsw: core_env: Read transceiver module EEPROM in 128 bytes chunks
.../net/ethernet/mellanox/mlxsw/core_env.c | 45 ++++++--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 93 ++++++++++++++++--- 2 files changed, 112 insertions(+), 26 deletions(-)
Signature · 1 line
2.41.0
Petr Machata
maintainerPATCH 1/5 mlxsw: reg: Move 'mpsc' definition in 'mlxsw_reg_infos'
From: Amit Cohen <[email protected]>
The array 'mlxsw_reg_infos' is ordered by registers' IDs. The ID of MPSC register is 0x9080, so it should be after MCDA (register ID 0x9063) and not after MTUTC (register ID 0x9055). Note that the register's fields are defined in the correct place in the file, only the definition in 'mlxsw_reg_infos' is wrong. This issue was found while adding new register which supposed to be before mpsc.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/reg.h +1 -1
@@ -12965,10 +12965,10 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {MLXSW_REG (mcion),MLXSW_REG (mtpps),MLXSW_REG (mtutc), -MLXSW_REG (mpsc),MLXSW_REG (mcqi),MLXSW_REG (mcc),MLXSW_REG (mcda), +MLXSW_REG (mpsc),MLXSW_REG (mgpc),MLXSW_REG (mprs), MLXSW_REG(mogcr),
Signature · 1 line
2.41.0
Petr Machata
maintainerPATCH 2/5 mlxsw: reg: Add Management Capabilities Mask Register
In reply to Petr MachataFrom: Amit Cohen <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 74 +++++++++++++++++++++++ 1 file changed, 74 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +74 -0
@@ -10572,6 +10572,79 @@ static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,mlxsw_reg_mcda_data_set (payload, i, *(u32 *) &data[i *4 ]); } +/* MCAM - Management Capabilities Mask Register +* -------------------------------------------- +* Reports the device supported management features. +*/ +#define MLXSW_REG_MCAM_ID 0x907F +#define MLXSW_REG_MCAM_LEN 0x48 + +MLXSW_REG_DEFINE (mcam,MLXSW_REG_MCAM_ID ,MLXSW_REG_MCAM_LEN ); + +enum mlxsw_reg_mcam_feature_group { +/* Enhanced features. */ +MLXSW_REG_MCAM_FEATURE_GROUP_ENHANCED_FEATURES , +}; + +/* reg_mcam_feature_group +* Feature list mask index. +* Access: Index +*/ +MLXSW_ITEM32 (reg, mcam, feature_group,0x00 ,16 ,8 ); + +enum mlxsw_reg_mcam_mng_feature_cap_mask_bits { +/* If set, MCIA supports 128 bytes payloads. Otherwise, 48 bytes. */ +MLXSW_REG_MCAM_MCIA_128B =34 , +}; + +#define MLXSW_REG_BYTES_PER_DWORD 0x4 + +/* reg_mcam_mng_feature_cap_mask +* Supported port's enhanced features. +* Based on feature_group index. +* When bit is set, the feature is supported in the device. +* Access: RO +*/ +#define MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD (_dw_num, _offset) \ + MLXSW_ITEM_BIT_ARRAY(reg, mcam, mng_feature_cap_mask_dw##_dw_num, \ + _offset, MLXSW_REG_BYTES_PER_DWORD, 1) + +/* 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, the first dword contains bits +* #0-#31 and so on, so the access to the bits is simpler using bit array per +* dword. Declare each dword of 'mng_feature_cap_mask' field separately. +*/ +MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD (0 ,0x28 ); +MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD (1 ,0x2C ); +MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD (2 ,0x30 ); +MLXSW_REG_MCAM_MNG_FEATURE_CAP_MASK_DWORD (3 ,0x34 ); + +static inline void +mlxsw_reg_mcam_pack (char *payload,enum mlxsw_reg_mcam_feature_group feat_group) +{ +MLXSW_REG_ZERO (mcam, payload); +mlxsw_reg_mcam_feature_group_set (payload, feat_group); +} + +static inline void +mlxsw_reg_mcam_unpack (char *payload, +enum mlxsw_reg_mcam_mng_feature_cap_mask_bits bit, +bool *p_mng_feature_cap_val) +{ +int offset = bit % (MLXSW_REG_BYTES_PER_DWORD *BITS_PER_BYTE ); +int dword = bit / (MLXSW_REG_BYTES_PER_DWORD *BITS_PER_BYTE ); +u8 (*getters[])(const char *,u16 ) = { + mlxsw_reg_mcam_mng_feature_cap_mask_dw0_get, + mlxsw_reg_mcam_mng_feature_cap_mask_dw1_get, + mlxsw_reg_mcam_mng_feature_cap_mask_dw2_get, + mlxsw_reg_mcam_mng_feature_cap_mask_dw3_get, + }; + +if (!WARN_ON_ONCE (dword >=ARRAY_SIZE (getters))) + *p_mng_feature_cap_val = getters[dword](payload, offset); +} +/* MPSC - Monitoring Packet Sampling Configuration Register * -------------------------------------------------------- * MPSC Register is used to configure the Packet Sampling mechanism.
@@ -12968,6 +13041,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {MLXSW_REG (mcqi),MLXSW_REG (mcc),MLXSW_REG (mcda), +MLXSW_REG (mcam),MLXSW_REG (mpsc),MLXSW_REG (mgpc), MLXSW_REG(mprs),
Signature · 1 line
2.41.0
Petr Machata
maintainerPATCH 3/5 mlxsw: reg: Remove unused function argument
In reply to Petr MachataFrom: Ido Schimmel <[email protected]>
The 'lock' argument is always set to the default value of '0'. Remove it from the arguments list.
--- drivers/net/ethernet/mellanox/mlxsw/core_env.c | 10 +++++----- drivers/net/ethernet/mellanox/mlxsw/reg.h | 12 +----------- 2 files changed, 6 insertions(+), 16 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core_env.c +5 -5
@@ -111,7 +111,7 @@ mlxsw_env_validate_cable_ident(struct mlxsw_core *core, u8 slot_index, int id,if (err)return err; -mlxsw_reg_mcia_pack (mcia_pl, slot_index, id,0 , +mlxsw_reg_mcia_pack (mcia_pl, slot_index, id,MLXSW_REG_MCIA_PAGE0_LO_OFF ,0 ,1 ,MLXSW_REG_MCIA_I2C_ADDR_LOW ); err =mlxsw_reg_query (core,MLXSW_REG (mcia), mcia_pl);
@@ -188,7 +188,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, u8 slot_index, } } -mlxsw_reg_mcia_pack (mcia_pl, slot_index, module,0 , page, offset, size, +mlxsw_reg_mcia_pack (mcia_pl, slot_index, module, page, offset, size, i2c_addr); err =mlxsw_reg_query (mlxsw_core,MLXSW_REG (mcia), mcia_pl);
@@ -266,12 +266,12 @@ mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, u8 slot_index, page =MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM ; else page =MLXSW_REG_MCIA_TH_PAGE_NUM ; -mlxsw_reg_mcia_pack (mcia_pl, slot_index, module,0 , page, +mlxsw_reg_mcia_pack (mcia_pl, slot_index, module, page,MLXSW_REG_MCIA_TH_PAGE_OFF + off,MLXSW_REG_MCIA_TH_ITEM_SIZE ,MLXSW_REG_MCIA_I2C_ADDR_LOW ); }else { -mlxsw_reg_mcia_pack (mcia_pl, slot_index, module,0 , +mlxsw_reg_mcia_pack (mcia_pl, slot_index, module,MLXSW_REG_MCIA_PAGE0_LO , off,MLXSW_REG_MCIA_TH_ITEM_SIZE ,MLXSW_REG_MCIA_I2C_ADDR_HIGH );
@@ -491,7 +491,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core, size =min_t (u8, page->length - bytes_read,MLXSW_REG_MCIA_EEPROM_SIZE ); -mlxsw_reg_mcia_pack (mcia_pl, slot_index, module,0 , page->page, +mlxsw_reg_mcia_pack (mcia_pl, slot_index, module, page->page, device_addr + bytes_read, size, page->i2c_address);mlxsw_reg_mcia_bank_number_set (mcia_pl, page->bank);
drivers/net/ethernet/mellanox/mlxsw/reg.h +1 -11
@@ -9635,14 +9635,6 @@ static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind,MLXSW_REG_DEFINE (mcia,MLXSW_REG_MCIA_ID ,MLXSW_REG_MCIA_LEN ); -/* reg_mcia_l -* Lock bit. Setting this bit will lock the access to the specific -* cable. Used for updating a full page in a cable EPROM. Any access -* other then subsequence writes will fail while the port is locked. -* Access: RW -*/ -MLXSW_ITEM32 (reg, mcia, l,0x00 ,31 ,1 ); -/* reg_mcia_module * Module number. * Access: Index
@@ -9755,14 +9747,12 @@ MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE); MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1)static inline void mlxsw_reg_mcia_pack (char *payload,u8 slot_index,u8 module, -u8 lock,u8 page_number, -u16 device_addr,u8 size, +u8 page_number,u16 device_addr,u8 size,u8 i2c_device_addr) {MLXSW_REG_ZERO (mcia, payload);mlxsw_reg_mcia_slot_set (payload, slot_index);mlxsw_reg_mcia_module_set (payload, module); -mlxsw_reg_mcia_l_set (payload, lock);mlxsw_reg_mcia_page_number_set (payload, page_number);mlxsw_reg_mcia_device_address_set (payload, device_addr);mlxsw_reg_mcia_size_set (payload, size);
Signature · 1 line
2.41.0
Petr Machata
maintainerPATCH 4/5 mlxsw: reg: Increase Management Cable Info Access Register length
In reply to Petr MachataFrom: Ido Schimmel <[email protected]>
The layout of the register always supported 128 bytes payloads, but the driver defined the register with a shorter length because it uses a maximum payload size of 48 bytes. Increase the register's length in preparation for using 128 bytes payloads.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/reg.h +1 -1
@@ -9631,7 +9631,7 @@ static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind,*/ #define MLXSW_REG_MCIA_ID 0x9014 -#define MLXSW_REG_MCIA_LEN 0x40 +#define MLXSW_REG_MCIA_LEN 0x94MLXSW_REG_DEFINE (mcia,MLXSW_REG_MCIA_ID ,MLXSW_REG_MCIA_LEN );
Signature · 1 line
2.41.0
Petr Machata
maintainerPATCH 5/5 mlxsw: core_env: Read transceiver module EEPROM in 128 bytes chunks
In reply to Petr MachataFrom: Ido Schimmel <[email protected]>
Old firmware versions could only read up to 48 bytes from a transceiver module's EEPROM in one go. Newer versions can read up to 128 bytes, resulting in fewer transactions.
Query support for the new capability during driver initialization and if supported, read up to 128 bytes in one go.
This is going to be especially useful for upcoming transceiver module firmware flashing support.
Before:
# perf stat -e devlink:devlink_hwmsg -- ethtool -m swp11 page 0x1 offset 128 length 128 i2c 0x50 [...] Performance counter stats for 'ethtool -m swp11 page 0x1 offset 128 length 128 i2c 0x50':
3 devlink:devlink_hwmsg
After:
# perf stat -e devlink:devlink_hwmsg -- ethtool -m swp11 page 0x1 offset 128 length 128 i2c 0x50 [...] Performance counter stats for 'ethtool -m swp11 page 0x1 offset 128 length 128 i2c 0x50':
1 devlink:devlink_hwmsg
--- .../net/ethernet/mellanox/mlxsw/core_env.c | 35 +++++++++++++++---- drivers/net/ethernet/mellanox/mlxsw/reg.h | 3 +- 2 files changed, 30 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core_env.c +29 -6
@@ -32,6 +32,7 @@ struct mlxsw_env {const struct mlxsw_bus_info *bus_info;u8 max_module_count;/* Maximum number of modules per-slot. */ u8 num_of_slots;/* Including the main board. */ +u8 max_eeprom_len;/* Maximum module EEPROM transaction length. */ struct mutex line_cards_lock;/* Protects line cards. */ struct mlxsw_env_line_card *line_cards[]; };
@@ -146,6 +147,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, u8 slot_index, int module, u16 offset, u16 size, void *data, bool qsfp, unsigned int *p_read_size) { + struct mlxsw_env *mlxsw_env = mlxsw_core_env(mlxsw_core);char mcia_pl[MLXSW_REG_MCIA_LEN ];char *eeprom_tmp;u16 i2c_addr;
@@ -153,11 +155,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, u8 slot_index,int status;int err; -/* MCIA register accepts buffer size <= 48. Page of size 128 should be -* read by chunks of size 48, 48, 32. Align the size of the last chunk -* to avoid reading after the end of the page. -*/ - size =min_t (u16, size,MLXSW_REG_MCIA_EEPROM_SIZE ); + size =min_t (u16, size, mlxsw_env->max_eeprom_len);if (offset <MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH && offset + size >MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH )
@@ -489,7 +487,7 @@ mlxsw_env_get_module_eeprom_by_page(struct mlxsw_core *mlxsw_core,u8 size; size =min_t (u8, page->length - bytes_read, -MLXSW_REG_MCIA_EEPROM_SIZE ); + mlxsw_env->max_eeprom_len); mlxsw_reg_mcia_pack(mcia_pl, slot_index, module, page->page, device_addr + bytes_read, size,
@@ -1359,6 +1357,26 @@ static struct mlxsw_linecards_event_ops mlxsw_env_event_ops = { .got_inactive = mlxsw_env_got_inactive, }; +static int mlxsw_env_max_module_eeprom_len_query (struct mlxsw_env *mlxsw_env) +{ +char mcam_pl[MLXSW_REG_MCAM_LEN ]; +bool mcia_128b_supported; +int err; + +mlxsw_reg_mcam_pack (mcam_pl, +MLXSW_REG_MCAM_FEATURE_GROUP_ENHANCED_FEATURES ); + err =mlxsw_reg_query (mlxsw_env->core,MLXSW_REG (mcam), mcam_pl); +if (err) +return err; + +mlxsw_reg_mcam_unpack (mcam_pl,MLXSW_REG_MCAM_MCIA_128B , + &mcia_128b_supported); + + mlxsw_env->max_eeprom_len = mcia_128b_supported ?128 :48 ; + +return 0 ; +} +int mlxsw_env_init (struct mlxsw_core *mlxsw_core,const struct mlxsw_bus_info *bus_info,struct mlxsw_env **p_env)
@@ -1427,10 +1445,15 @@ int mlxsw_env_init(struct mlxsw_core *mlxsw_core,if (err) goto err_type_set; + err =mlxsw_env_max_module_eeprom_len_query (env); +if (err) + goto err_eeprom_len_query; + env->line_cards[0 ]->active = true;return 0 ; +err_eeprom_len_query: err_type_set:mlxsw_env_module_event_disable (env,0 ); err_mlxsw_env_module_event_enable:
drivers/net/ethernet/mellanox/mlxsw/reg.h +1 -2
@@ -9699,7 +9699,6 @@ MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);#define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256#define MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH 128 -#define MLXSW_REG_MCIA_EEPROM_SIZE 48#define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50#define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51#define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
@@ -9736,7 +9735,7 @@ enum mlxsw_reg_mcia_eeprom_module_info {* Bytes to read/write. * Access: RW */ -MLXSW_ITEM_BUF (reg, mcia, eeprom,0x10 ,MLXSW_REG_MCIA_EEPROM_SIZE ); +MLXSW_ITEM_BUF (reg, mcia, eeprom,0x10 ,128 );/* This is used to access the optional upper pages (1-3) in the QSFP+ * memory map. Page 1 is available on offset 256 through 383, page 2 -
Signature · 1 line
2.41.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 25 Jul 2023 14:04:00 +0200 you wrote:
Ido Schimmel writes:
Old firmware versions could only read up to 48 bytes from a transceiver module's EEPROM in one go. Newer versions can read up to 128 bytes, resulting in fewer transactions.
Query support for the new capability during driver initialization and if supported, read up to 128 bytes in one go.
[...]
Here is the summary with links:
- [net-next,1/5] mlxsw: reg: Move 'mpsc' definition in 'mlxsw_reg_infos'
https://git.kernel.org/netdev/net-next/c/68bf5100fadf - [net-next,2/5] mlxsw: reg: Add Management Capabilities Mask Register https://git.kernel.org/netdev/net-next/c/7447eda4065e - [net-next,3/5] mlxsw: reg: Remove unused function argument https://git.kernel.org/netdev/net-next/c/3930dcc5e404 - [net-next,4/5] mlxsw: reg: Increase Management Cable Info Access Register length https://git.kernel.org/netdev/net-next/c/c8dbf67883db - [net-next,5/5] mlxsw: core_env: Read transceiver module EEPROM in 128 bytes chunks https://git.kernel.org/netdev/net-next/c/1f4aea1f72da
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html