Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions common/service/pldm/pldm_firmware_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
return comp_id;
}

__weak uint8_t plat_pldm_pass_component_table_check(uint16_t num_of_comp,
const uint8_t *comp_image_version_str,
uint8_t comp_image_version_str_len)
{
return PLDM_SUCCESS;
}

int get_descriptor_type_length(uint16_t type)
{
switch (type) {
Expand Down Expand Up @@ -645,7 +652,7 @@
}
}

static void pldm_status_reset()
void pldm_status_reset()
{
state_update(STATE_IDLE);
cur_aux_state = STATE_AUX_NOT_IN_UPDATE;
Expand All @@ -658,7 +665,7 @@

static void exit_update_mode()
{
printk("PLDM update mode timeout, exiting update mode...\n");
LOG_WRN("PLDM update mode timeout, exiting update mode...");
pldm_status_reset();
}

Expand All @@ -672,7 +679,7 @@
CHECK_NULL_ARG_WITH_RETURN(ext_params, 0);

pldm_msg msg = { 0 };
mctp_ext_params *extra_data = (mctp_ext_params *)ext_params;

Check failure on line 682 in common/service/pldm/pldm_firmware_update.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Variable 'extra_data' can be declared as pointer to const Raw Output: common/service/pldm/pldm_firmware_update.c:682:19:Variable 'extra_data' can be declared as pointer to const

msg.ext_params = *extra_data;

Expand Down Expand Up @@ -1069,6 +1076,14 @@
LOG_HEXDUMP_INF(buf + sizeof(struct pldm_pass_component_table_req), req_p->comp_ver_str_len,
"");

uint8_t check_result = plat_pldm_pass_component_table_check(
req_p->comp_identifier, buf + sizeof(struct pldm_pass_component_table_req),
req_p->comp_ver_str_len);
if (check_result != PLDM_SUCCESS) {

Check failure on line 1082 in common/service/pldm/pldm_firmware_update.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Condition 'check_result!=PLDM_SUCCESS' is always false Raw Output: common/service/pldm/pldm_firmware_update.c:1082:19:Condition 'check_result!=PLDM_SUCCESS' is always false
resp_p->completion_code = check_result;
goto exit;
}

if (current_state != STATE_LEARN_COMP) {
LOG_ERR("Firmware update failed because current state %d is not %d", current_state,
STATE_LEARN_COMP);
Expand Down Expand Up @@ -1240,7 +1255,7 @@
CHECK_NULL_ARG_WITH_RETURN(resp_len, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(ext_params, PLDM_ERROR);

struct pldm_activate_firmware_req *req_p = (struct pldm_activate_firmware_req *)buf;

Check failure on line 1258 in common/service/pldm/pldm_firmware_update.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Variable 'req_p' can be declared as pointer to const Raw Output: common/service/pldm/pldm_firmware_update.c:1258:37:Variable 'req_p' can be declared as pointer to const
struct pldm_activate_firmware_resp *resp_p = (struct pldm_activate_firmware_resp *)resp;

*resp_len = 1;
Expand Down Expand Up @@ -1717,7 +1732,7 @@
descriptor_count -= type_length;

for (index = 0; index < type_length; ++index) {
strncpy(data, &descriptor->descriptor_data[index * 2], 2);

Check failure on line 1735 in common/service/pldm/pldm_firmware_update.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 The buffer 'data' may not be null-terminated after the call to strncpy(). Raw Output: common/service/pldm/pldm_firmware_update.c:1735:4:The buffer 'data' may not be null-terminated after the call to strncpy().
val = strtol(data, NULL, 16);
tlv_ptr->descriptor_data[index] = val;
}
Expand Down
4 changes: 4 additions & 0 deletions common/service/pldm/pldm_firmware_update.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,10 @@ uint8_t fill_descriptor_into_buf(struct pldm_descriptor_string *descriptor, uint
uint8_t *fill_length, uint16_t current_length);
bool is_update_state_download_phase();
bool is_update_state_idle();
void pldm_status_reset();
uint8_t plat_pldm_pass_component_table_check(uint16_t num_of_comp,
const uint8_t *comp_image_version_str,
uint8_t comp_image_version_str_len);

#ifdef __cplusplus
}
Expand Down
38 changes: 38 additions & 0 deletions common/service/pldm/pldm_oem.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,42 @@
void *ext_params);
#endif

__weak uint8_t force_update_flag_set_cmd(void *mctp_inst, uint8_t *buf, uint16_t len,
uint8_t instance_id, uint8_t *resp, uint16_t *resp_len,
void *ext_params)
{
CHECK_NULL_ARG_WITH_RETURN(mctp_inst, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(buf, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(resp, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(resp_len, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(ext_params, PLDM_ERROR);

uint8_t *completion_code_p = resp;

*completion_code_p = PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
*resp_len = 1;

return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
}

__weak uint8_t force_update_flag_get_cmd(void *mctp_inst, uint8_t *buf, uint16_t len,
uint8_t instance_id, uint8_t *resp, uint16_t *resp_len,
void *ext_params)
{
CHECK_NULL_ARG_WITH_RETURN(mctp_inst, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(buf, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(resp, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(resp_len, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(ext_params, PLDM_ERROR);

uint8_t *completion_code_p = resp;

*completion_code_p = PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
*resp_len = 1;

return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
}

__weak uint8_t sensor_polling_cmd(void *mctp_inst, uint8_t *buf, uint16_t len, uint8_t instance_id,
uint8_t *resp, uint16_t *resp_len, void *ext_params)
{
Expand Down Expand Up @@ -91,7 +127,7 @@
CHECK_NULL_ARG_WITH_RETURN(resp_len, PLDM_ERROR);
CHECK_NULL_ARG_WITH_RETURN(ext_params, PLDM_ERROR);

struct _cmd_echo_req *req_p = (struct _cmd_echo_req *)buf;

Check failure on line 130 in common/service/pldm/pldm_oem.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Variable 'req_p' can be declared as pointer to const Raw Output: common/service/pldm/pldm_oem.c:130:24:Variable 'req_p' can be declared as pointer to const
struct _cmd_echo_resp *resp_p = (struct _cmd_echo_resp *)resp;

if (check_iana(req_p->iana) == PLDM_ERROR) {
Expand Down Expand Up @@ -184,7 +220,7 @@

#ifdef ENABLE_PLDM
#ifdef ENABLE_EVENT_TO_BMC
uint8_t send_event_log_to_bmc(struct pldm_addsel_data sel_msg)

Check failure on line 223 in common/service/pldm/pldm_oem.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Function 'send_event_log_to_bmc' argument 1 names different: declaration 'msg' definition 'sel_msg'. Raw Output: common/service/pldm/pldm_oem.c:223:55:Function 'send_event_log_to_bmc' argument 1 names different: declaration 'msg' definition 'sel_msg'.
{
pldm_msg msg = { 0 };
uint8_t bmc_bus = I2C_BUS_BMC;
Expand Down Expand Up @@ -251,6 +287,8 @@
#ifdef ENABLE_VISTARA
{ PLDM_OEM_WF_READ_SPD_CHUNK, oem_wf_read_spd_chunk },
#endif
{ PLDM_OEM_FORCE_UPDATE_SETTING_CMD, force_update_flag_set_cmd },
{ PLDM_OEM_FORCE_UPDATE_GETTING_CMD, force_update_flag_get_cmd },
};

uint8_t pldm_oem_handler_query(uint8_t code, void **ret_fn)
Expand Down Expand Up @@ -295,7 +333,7 @@
return PLDM_SUCCESS;
}

uint8_t *iana = &buf[0];

Check failure on line 336 in common/service/pldm/pldm_oem.c

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 Variable 'iana' can be declared as pointer to const Raw Output: common/service/pldm/pldm_oem.c:336:11:Variable 'iana' can be declared as pointer to const
uint8_t cxl_id = buf[3];
uint8_t dimm_idx = buf[4];
uint16_t offset = (uint16_t)buf[5] | ((uint16_t)buf[6] << 8);
Expand Down
23 changes: 23 additions & 0 deletions common/service/pldm/pldm_oem.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ extern "C" {
#define PLDM_OEM_READ_FILE_IO 0x03
#define PLDM_OEM_SENSOR_POLLING_CMD 0x04
#define PLDM_OEM_WF_READ_SPD_CHUNK 0x05
#define PLDM_OEM_FORCE_UPDATE_SETTING_CMD 0x06
#define PLDM_OEM_FORCE_UPDATE_GETTING_CMD 0x07

#define POWER_CONTROL_LEN 0x01

Expand Down Expand Up @@ -286,6 +288,27 @@ struct _sensor_polling_cmd_resp {
uint8_t set_value;
} __attribute__((packed));

struct _force_update_flag_set_cmd_req {
uint8_t iana[IANA_LEN];
uint8_t set_value;
} __attribute__((packed));

struct _force_update_flag_set_cmd_resp {
uint8_t completion_code;
uint8_t iana[IANA_LEN];
uint8_t set_value;
} __attribute__((packed));

struct _force_update_flag_get_cmd_req {
uint8_t iana[IANA_LEN];
} __attribute__((packed));

struct _force_update_flag_get_cmd_resp {
uint8_t completion_code;
uint8_t iana[IANA_LEN];
uint8_t get_value;
} __attribute__((packed));

uint8_t check_iana(const uint8_t *iana);
uint8_t set_iana(uint8_t *buf, uint8_t buf_len);
uint8_t send_event_log_to_bmc(struct pldm_addsel_data msg);
Expand Down
3 changes: 2 additions & 1 deletion meta-facebook/minerva-ag/boards/npcm400f_evb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ CONFIG_I2C_NPCM4XX=y
CONFIG_I3C_NPCM4XX=y
CONFIG_ADC_NPCM4XX=y
CONFIG_USB_DC_NPCM4XX=y
CONFIG_JTAG_NPCM4XX=y
CONFIG_JTAG_NPCM4XX=y
CONFIG_LOG_STRDUP_BUF_COUNT=16
Loading
Loading