Skip to content

Commit 5bade5a

Browse files
Jiri Pirkodavem330
Jiri Pirko
authored andcommitted
mlxsw: reg: Add Management Binary Code Transfer Register
The MBCT register allows to transfer binary INI codes from the host to the management FW by transferring it by chunks of maximum 1KB. Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5290a8f commit 5bade5a

File tree

1 file changed

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

1 file changed

+122
-0
lines changed

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

+122
Original file line numberDiff line numberDiff line change
@@ -11492,6 +11492,127 @@ mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
1149211492
*num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
1149311493
}
1149411494

11495+
/* MBCT - Management Binary Code Transfer Register
11496+
* -----------------------------------------------
11497+
* This register allows to transfer binary codes from the host to
11498+
* the management FW by transferring it by chunks of maximum 1KB.
11499+
*/
11500+
#define MLXSW_REG_MBCT_ID 0x9120
11501+
#define MLXSW_REG_MBCT_LEN 0x420
11502+
11503+
MLXSW_REG_DEFINE(mbct, MLXSW_REG_MBCT_ID, MLXSW_REG_MBCT_LEN);
11504+
11505+
/* reg_mbct_slot_index
11506+
* Slot index. 0 is reserved.
11507+
* Access: Index
11508+
*/
11509+
MLXSW_ITEM32(reg, mbct, slot_index, 0x00, 0, 4);
11510+
11511+
/* reg_mbct_data_size
11512+
* Actual data field size in bytes for the current data transfer.
11513+
* Access: WO
11514+
*/
11515+
MLXSW_ITEM32(reg, mbct, data_size, 0x04, 0, 11);
11516+
11517+
enum mlxsw_reg_mbct_op {
11518+
MLXSW_REG_MBCT_OP_ERASE_INI_IMAGE = 1,
11519+
MLXSW_REG_MBCT_OP_DATA_TRANSFER, /* Download */
11520+
MLXSW_REG_MBCT_OP_ACTIVATE,
11521+
MLXSW_REG_MBCT_OP_CLEAR_ERRORS = 6,
11522+
MLXSW_REG_MBCT_OP_QUERY_STATUS,
11523+
};
11524+
11525+
/* reg_mbct_op
11526+
* Access: WO
11527+
*/
11528+
MLXSW_ITEM32(reg, mbct, op, 0x08, 28, 4);
11529+
11530+
/* reg_mbct_last
11531+
* Indicates that the current data field is the last chunk of the INI.
11532+
* Access: WO
11533+
*/
11534+
MLXSW_ITEM32(reg, mbct, last, 0x08, 26, 1);
11535+
11536+
/* reg_mbct_oee
11537+
* Opcode Event Enable. When set a BCTOE event will be sent once the opcode
11538+
* was executed and the fsm_state has changed.
11539+
* Access: WO
11540+
*/
11541+
MLXSW_ITEM32(reg, mbct, oee, 0x08, 25, 1);
11542+
11543+
enum mlxsw_reg_mbct_status {
11544+
/* Partial data transfer completed successfully and ready for next
11545+
* data transfer.
11546+
*/
11547+
MLXSW_REG_MBCT_STATUS_PART_DATA = 2,
11548+
MLXSW_REG_MBCT_STATUS_LAST_DATA,
11549+
MLXSW_REG_MBCT_STATUS_ERASE_COMPLETE,
11550+
/* Error - trying to erase INI while it being used. */
11551+
MLXSW_REG_MBCT_STATUS_ERROR_INI_IN_USE,
11552+
/* Last data transfer completed, applying magic pattern. */
11553+
MLXSW_REG_MBCT_STATUS_ERASE_FAILED = 7,
11554+
MLXSW_REG_MBCT_STATUS_INI_ERROR,
11555+
MLXSW_REG_MBCT_STATUS_ACTIVATION_FAILED,
11556+
MLXSW_REG_MBCT_STATUS_ILLEGAL_OPERATION = 11,
11557+
};
11558+
11559+
/* reg_mbct_status
11560+
* Status.
11561+
* Access: RO
11562+
*/
11563+
MLXSW_ITEM32(reg, mbct, status, 0x0C, 24, 5);
11564+
11565+
enum mlxsw_reg_mbct_fsm_state {
11566+
MLXSW_REG_MBCT_FSM_STATE_INI_IN_USE = 5,
11567+
MLXSW_REG_MBCT_FSM_STATE_ERROR,
11568+
};
11569+
11570+
/* reg_mbct_fsm_state
11571+
* FSM state.
11572+
* Access: RO
11573+
*/
11574+
MLXSW_ITEM32(reg, mbct, fsm_state, 0x0C, 16, 4);
11575+
11576+
#define MLXSW_REG_MBCT_DATA_LEN 1024
11577+
11578+
/* reg_mbct_data
11579+
* Up to 1KB of data.
11580+
* Access: WO
11581+
*/
11582+
MLXSW_ITEM_BUF(reg, mbct, data, 0x20, MLXSW_REG_MBCT_DATA_LEN);
11583+
11584+
static inline void mlxsw_reg_mbct_pack(char *payload, u8 slot_index,
11585+
enum mlxsw_reg_mbct_op op, bool oee)
11586+
{
11587+
MLXSW_REG_ZERO(mbct, payload);
11588+
mlxsw_reg_mbct_slot_index_set(payload, slot_index);
11589+
mlxsw_reg_mbct_op_set(payload, op);
11590+
mlxsw_reg_mbct_oee_set(payload, oee);
11591+
}
11592+
11593+
static inline void mlxsw_reg_mbct_dt_pack(char *payload,
11594+
u16 data_size, bool last,
11595+
const char *data)
11596+
{
11597+
if (WARN_ON(data_size > MLXSW_REG_MBCT_DATA_LEN))
11598+
return;
11599+
mlxsw_reg_mbct_data_size_set(payload, data_size);
11600+
mlxsw_reg_mbct_last_set(payload, last);
11601+
mlxsw_reg_mbct_data_memcpy_to(payload, data);
11602+
}
11603+
11604+
static inline void
11605+
mlxsw_reg_mbct_unpack(const char *payload, u8 *p_slot_index,
11606+
enum mlxsw_reg_mbct_status *p_status,
11607+
enum mlxsw_reg_mbct_fsm_state *p_fsm_state)
11608+
{
11609+
if (p_slot_index)
11610+
*p_slot_index = mlxsw_reg_mbct_slot_index_get(payload);
11611+
*p_status = mlxsw_reg_mbct_status_get(payload);
11612+
if (p_fsm_state)
11613+
*p_fsm_state = mlxsw_reg_mbct_fsm_state_get(payload);
11614+
}
11615+
1149511616
/* MDDQ - Management DownStream Device Query Register
1149611617
* --------------------------------------------------
1149711618
* This register allows to query the DownStream device properties. The desired
@@ -12990,6 +13111,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
1299013111
MLXSW_REG(mtptpt),
1299113112
MLXSW_REG(mfgd),
1299213113
MLXSW_REG(mgpir),
13114+
MLXSW_REG(mbct),
1299313115
MLXSW_REG(mddq),
1299413116
MLXSW_REG(mddc),
1299513117
MLXSW_REG(mfde),

0 commit comments

Comments
 (0)