mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
eth: fbnic: Add mailbox support for PLDM updates
Add three new mailbox messages to support PLDM upgrades: * FW_START_UPGRADE - Enables driver to request starting a firmware upgrade by specifying the component to be upgraded and its size. * WRITE_CHUNK - Allows firmware to request driver to send a chunk of data at the specified offset. * FINISH_UPGRADE - Allows firmware to cancel the upgrade process and return an error. Signed-off-by: Lee Trager <lee@trager.us> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250512190109.2475614-5-lee@trager.us Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
cc083264ad
commit
2a4ada8a99
@ -766,6 +766,188 @@ void fbnic_fw_check_heartbeat(struct fbnic_dev *fbd)
|
|||||||
dev_warn(fbd->dev, "Failed to send heartbeat message\n");
|
dev_warn(fbd->dev, "Failed to send heartbeat message\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fbnic_fw_xmit_fw_start_upgrade(struct fbnic_dev *fbd,
|
||||||
|
struct fbnic_fw_completion *cmpl_data,
|
||||||
|
unsigned int id, unsigned int len)
|
||||||
|
{
|
||||||
|
struct fbnic_tlv_msg *msg;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (!fbnic_fw_present(fbd))
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
if (!len)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
msg = fbnic_tlv_msg_alloc(FBNIC_TLV_MSG_ID_FW_START_UPGRADE_REQ);
|
||||||
|
if (!msg)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
err = fbnic_tlv_attr_put_int(msg, FBNIC_FW_START_UPGRADE_SECTION, id);
|
||||||
|
if (err)
|
||||||
|
goto free_message;
|
||||||
|
|
||||||
|
err = fbnic_tlv_attr_put_int(msg, FBNIC_FW_START_UPGRADE_IMAGE_LENGTH,
|
||||||
|
len);
|
||||||
|
if (err)
|
||||||
|
goto free_message;
|
||||||
|
|
||||||
|
err = fbnic_mbx_map_req_w_cmpl(fbd, msg, cmpl_data);
|
||||||
|
if (err)
|
||||||
|
goto free_message;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
free_message:
|
||||||
|
free_page((unsigned long)msg);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct fbnic_tlv_index fbnic_fw_start_upgrade_resp_index[] = {
|
||||||
|
FBNIC_TLV_ATTR_S32(FBNIC_FW_START_UPGRADE_ERROR),
|
||||||
|
FBNIC_TLV_ATTR_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
static int fbnic_fw_parse_fw_start_upgrade_resp(void *opaque,
|
||||||
|
struct fbnic_tlv_msg **results)
|
||||||
|
{
|
||||||
|
struct fbnic_fw_completion *cmpl_data;
|
||||||
|
struct fbnic_dev *fbd = opaque;
|
||||||
|
u32 msg_type;
|
||||||
|
s32 err;
|
||||||
|
|
||||||
|
/* Verify we have a completion pointer */
|
||||||
|
msg_type = FBNIC_TLV_MSG_ID_FW_START_UPGRADE_REQ;
|
||||||
|
cmpl_data = fbnic_fw_get_cmpl_by_type(fbd, msg_type);
|
||||||
|
if (!cmpl_data)
|
||||||
|
return -ENOSPC;
|
||||||
|
|
||||||
|
/* Check for errors */
|
||||||
|
err = fta_get_sint(results, FBNIC_FW_START_UPGRADE_ERROR);
|
||||||
|
|
||||||
|
cmpl_data->result = err;
|
||||||
|
complete(&cmpl_data->done);
|
||||||
|
fbnic_fw_put_cmpl(cmpl_data);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fbnic_fw_xmit_fw_write_chunk(struct fbnic_dev *fbd,
|
||||||
|
const u8 *data, u32 offset, u16 length,
|
||||||
|
int cancel_error)
|
||||||
|
{
|
||||||
|
struct fbnic_tlv_msg *msg;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
msg = fbnic_tlv_msg_alloc(FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_RESP);
|
||||||
|
if (!msg)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
/* Report error to FW to cancel upgrade */
|
||||||
|
if (cancel_error) {
|
||||||
|
err = fbnic_tlv_attr_put_int(msg, FBNIC_FW_WRITE_CHUNK_ERROR,
|
||||||
|
cancel_error);
|
||||||
|
if (err)
|
||||||
|
goto free_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
err = fbnic_tlv_attr_put_int(msg, FBNIC_FW_WRITE_CHUNK_OFFSET,
|
||||||
|
offset);
|
||||||
|
if (err)
|
||||||
|
goto free_message;
|
||||||
|
|
||||||
|
err = fbnic_tlv_attr_put_int(msg, FBNIC_FW_WRITE_CHUNK_LENGTH,
|
||||||
|
length);
|
||||||
|
if (err)
|
||||||
|
goto free_message;
|
||||||
|
|
||||||
|
err = fbnic_tlv_attr_put_value(msg, FBNIC_FW_WRITE_CHUNK_DATA,
|
||||||
|
data + offset, length);
|
||||||
|
if (err)
|
||||||
|
goto free_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = fbnic_mbx_map_tlv_msg(fbd, msg);
|
||||||
|
if (err)
|
||||||
|
goto free_message;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
free_message:
|
||||||
|
free_page((unsigned long)msg);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct fbnic_tlv_index fbnic_fw_write_chunk_req_index[] = {
|
||||||
|
FBNIC_TLV_ATTR_U32(FBNIC_FW_WRITE_CHUNK_OFFSET),
|
||||||
|
FBNIC_TLV_ATTR_U32(FBNIC_FW_WRITE_CHUNK_LENGTH),
|
||||||
|
FBNIC_TLV_ATTR_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
static int fbnic_fw_parse_fw_write_chunk_req(void *opaque,
|
||||||
|
struct fbnic_tlv_msg **results)
|
||||||
|
{
|
||||||
|
struct fbnic_fw_completion *cmpl_data;
|
||||||
|
struct fbnic_dev *fbd = opaque;
|
||||||
|
u32 msg_type;
|
||||||
|
u32 offset;
|
||||||
|
u32 length;
|
||||||
|
|
||||||
|
/* Verify we have a completion pointer */
|
||||||
|
msg_type = FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_REQ;
|
||||||
|
cmpl_data = fbnic_fw_get_cmpl_by_type(fbd, msg_type);
|
||||||
|
if (!cmpl_data)
|
||||||
|
return -ENOSPC;
|
||||||
|
|
||||||
|
/* Pull length/offset pair and mark it as complete */
|
||||||
|
offset = fta_get_uint(results, FBNIC_FW_WRITE_CHUNK_OFFSET);
|
||||||
|
length = fta_get_uint(results, FBNIC_FW_WRITE_CHUNK_LENGTH);
|
||||||
|
cmpl_data->u.fw_update.offset = offset;
|
||||||
|
cmpl_data->u.fw_update.length = length;
|
||||||
|
|
||||||
|
complete(&cmpl_data->done);
|
||||||
|
fbnic_fw_put_cmpl(cmpl_data);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct fbnic_tlv_index fbnic_fw_finish_upgrade_req_index[] = {
|
||||||
|
FBNIC_TLV_ATTR_S32(FBNIC_FW_FINISH_UPGRADE_ERROR),
|
||||||
|
FBNIC_TLV_ATTR_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
static int fbnic_fw_parse_fw_finish_upgrade_req(void *opaque,
|
||||||
|
struct fbnic_tlv_msg **results)
|
||||||
|
{
|
||||||
|
struct fbnic_fw_completion *cmpl_data;
|
||||||
|
struct fbnic_dev *fbd = opaque;
|
||||||
|
u32 msg_type;
|
||||||
|
s32 err;
|
||||||
|
|
||||||
|
/* Verify we have a completion pointer */
|
||||||
|
msg_type = FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_REQ;
|
||||||
|
cmpl_data = fbnic_fw_get_cmpl_by_type(fbd, msg_type);
|
||||||
|
if (!cmpl_data)
|
||||||
|
return -ENOSPC;
|
||||||
|
|
||||||
|
/* Check for errors */
|
||||||
|
err = fta_get_sint(results, FBNIC_FW_FINISH_UPGRADE_ERROR);
|
||||||
|
|
||||||
|
/* Close out update by incrementing offset by length which should
|
||||||
|
* match the total size of the component. Set length to 0 since no
|
||||||
|
* new chunks will be requested.
|
||||||
|
*/
|
||||||
|
cmpl_data->u.fw_update.offset += cmpl_data->u.fw_update.length;
|
||||||
|
cmpl_data->u.fw_update.length = 0;
|
||||||
|
|
||||||
|
cmpl_data->result = err;
|
||||||
|
complete(&cmpl_data->done);
|
||||||
|
fbnic_fw_put_cmpl(cmpl_data);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fbnic_fw_xmit_tsene_read_msg - Create and transmit a sensor read request
|
* fbnic_fw_xmit_tsene_read_msg - Create and transmit a sensor read request
|
||||||
* @fbd: FBNIC device structure
|
* @fbd: FBNIC device structure
|
||||||
@ -850,6 +1032,15 @@ static const struct fbnic_tlv_parser fbnic_fw_tlv_parser[] = {
|
|||||||
fbnic_fw_parse_ownership_resp),
|
fbnic_fw_parse_ownership_resp),
|
||||||
FBNIC_TLV_PARSER(HEARTBEAT_RESP, fbnic_heartbeat_resp_index,
|
FBNIC_TLV_PARSER(HEARTBEAT_RESP, fbnic_heartbeat_resp_index,
|
||||||
fbnic_fw_parse_heartbeat_resp),
|
fbnic_fw_parse_heartbeat_resp),
|
||||||
|
FBNIC_TLV_PARSER(FW_START_UPGRADE_RESP,
|
||||||
|
fbnic_fw_start_upgrade_resp_index,
|
||||||
|
fbnic_fw_parse_fw_start_upgrade_resp),
|
||||||
|
FBNIC_TLV_PARSER(FW_WRITE_CHUNK_REQ,
|
||||||
|
fbnic_fw_write_chunk_req_index,
|
||||||
|
fbnic_fw_parse_fw_write_chunk_req),
|
||||||
|
FBNIC_TLV_PARSER(FW_FINISH_UPGRADE_REQ,
|
||||||
|
fbnic_fw_finish_upgrade_req_index,
|
||||||
|
fbnic_fw_parse_fw_finish_upgrade_req),
|
||||||
FBNIC_TLV_PARSER(TSENE_READ_RESP,
|
FBNIC_TLV_PARSER(TSENE_READ_RESP,
|
||||||
fbnic_tsene_read_resp_index,
|
fbnic_tsene_read_resp_index,
|
||||||
fbnic_fw_parse_tsene_read_resp),
|
fbnic_fw_parse_tsene_read_resp),
|
||||||
|
@ -51,6 +51,10 @@ struct fbnic_fw_completion {
|
|||||||
struct kref ref_count;
|
struct kref ref_count;
|
||||||
int result;
|
int result;
|
||||||
union {
|
union {
|
||||||
|
struct {
|
||||||
|
u32 offset;
|
||||||
|
u32 length;
|
||||||
|
} fw_update;
|
||||||
struct {
|
struct {
|
||||||
s32 millivolts;
|
s32 millivolts;
|
||||||
s32 millidegrees;
|
s32 millidegrees;
|
||||||
@ -68,6 +72,12 @@ void fbnic_mbx_flush_tx(struct fbnic_dev *fbd);
|
|||||||
int fbnic_fw_xmit_ownership_msg(struct fbnic_dev *fbd, bool take_ownership);
|
int fbnic_fw_xmit_ownership_msg(struct fbnic_dev *fbd, bool take_ownership);
|
||||||
int fbnic_fw_init_heartbeat(struct fbnic_dev *fbd, bool poll);
|
int fbnic_fw_init_heartbeat(struct fbnic_dev *fbd, bool poll);
|
||||||
void fbnic_fw_check_heartbeat(struct fbnic_dev *fbd);
|
void fbnic_fw_check_heartbeat(struct fbnic_dev *fbd);
|
||||||
|
int fbnic_fw_xmit_fw_start_upgrade(struct fbnic_dev *fbd,
|
||||||
|
struct fbnic_fw_completion *cmpl_data,
|
||||||
|
unsigned int id, unsigned int len);
|
||||||
|
int fbnic_fw_xmit_fw_write_chunk(struct fbnic_dev *fbd,
|
||||||
|
const u8 *data, u32 offset, u16 length,
|
||||||
|
int cancel_error);
|
||||||
int fbnic_fw_xmit_tsene_read_msg(struct fbnic_dev *fbd,
|
int fbnic_fw_xmit_tsene_read_msg(struct fbnic_dev *fbd,
|
||||||
struct fbnic_fw_completion *cmpl_data);
|
struct fbnic_fw_completion *cmpl_data);
|
||||||
void fbnic_fw_init_cmpl(struct fbnic_fw_completion *cmpl_data,
|
void fbnic_fw_init_cmpl(struct fbnic_fw_completion *cmpl_data,
|
||||||
@ -99,6 +109,12 @@ enum {
|
|||||||
FBNIC_TLV_MSG_ID_OWNERSHIP_RESP = 0x13,
|
FBNIC_TLV_MSG_ID_OWNERSHIP_RESP = 0x13,
|
||||||
FBNIC_TLV_MSG_ID_HEARTBEAT_REQ = 0x14,
|
FBNIC_TLV_MSG_ID_HEARTBEAT_REQ = 0x14,
|
||||||
FBNIC_TLV_MSG_ID_HEARTBEAT_RESP = 0x15,
|
FBNIC_TLV_MSG_ID_HEARTBEAT_RESP = 0x15,
|
||||||
|
FBNIC_TLV_MSG_ID_FW_START_UPGRADE_REQ = 0x22,
|
||||||
|
FBNIC_TLV_MSG_ID_FW_START_UPGRADE_RESP = 0x23,
|
||||||
|
FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_REQ = 0x24,
|
||||||
|
FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_RESP = 0x25,
|
||||||
|
FBNIC_TLV_MSG_ID_FW_FINISH_UPGRADE_REQ = 0x28,
|
||||||
|
FBNIC_TLV_MSG_ID_FW_FINISH_UPGRADE_RESP = 0x29,
|
||||||
FBNIC_TLV_MSG_ID_TSENE_READ_REQ = 0x3C,
|
FBNIC_TLV_MSG_ID_TSENE_READ_REQ = 0x3C,
|
||||||
FBNIC_TLV_MSG_ID_TSENE_READ_RESP = 0x3D,
|
FBNIC_TLV_MSG_ID_TSENE_READ_RESP = 0x3D,
|
||||||
};
|
};
|
||||||
@ -154,4 +170,25 @@ enum {
|
|||||||
FBNIC_FW_OWNERSHIP_FLAG = 0x0,
|
FBNIC_FW_OWNERSHIP_FLAG = 0x0,
|
||||||
FBNIC_FW_OWNERSHIP_MSG_MAX
|
FBNIC_FW_OWNERSHIP_MSG_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
FBNIC_FW_START_UPGRADE_ERROR = 0x0,
|
||||||
|
FBNIC_FW_START_UPGRADE_SECTION = 0x1,
|
||||||
|
FBNIC_FW_START_UPGRADE_IMAGE_LENGTH = 0x2,
|
||||||
|
FBNIC_FW_START_UPGRADE_MSG_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
FBNIC_FW_WRITE_CHUNK_OFFSET = 0x0,
|
||||||
|
FBNIC_FW_WRITE_CHUNK_LENGTH = 0x1,
|
||||||
|
FBNIC_FW_WRITE_CHUNK_DATA = 0x2,
|
||||||
|
FBNIC_FW_WRITE_CHUNK_ERROR = 0x3,
|
||||||
|
FBNIC_FW_WRITE_CHUNK_MSG_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
FBNIC_FW_FINISH_UPGRADE_ERROR = 0x0,
|
||||||
|
FBNIC_FW_FINISH_UPGRADE_MSG_MAX
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _FBNIC_FW_H_ */
|
#endif /* _FBNIC_FW_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user