Skip to content

fby4: sd: Initial commit for yv4-sd pdr implementation#1304

Closed
BonnieLo wants to merge 1 commit into
facebook:mainfrom
Wiwynn:Peter/yv4-sd-pldm-pdr
Closed

fby4: sd: Initial commit for yv4-sd pdr implementation#1304
BonnieLo wants to merge 1 commit into
facebook:mainfrom
Wiwynn:Peter/yv4-sd-pldm-pdr

Conversation

@BonnieLo

Copy link
Copy Markdown

Description

  • Support pldm over mctp over i2c on yv4-sd.
  • Add platform code for pdr implementation.

Motivation

For implementing sensor monitoring, the BMC should get sensor information from the BIC.

Test Plan:

  • Build code: Pass
  • Add some PDR samples in BIC and BMC get pdr from BIC: Pass

Log:

Get PDR info:
pldmtool raw -m 8 -d 0x80 0x02 0x50
pldmtool: Tx: 80 02 50
pldmtool: Rx: 00 02 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 44 01 00 00 6c 00 00 00 00

Get PDR:
pldmtool platform GetPDR -m 8 -a -v
[
pldmtool: Tx: 80 02 51 00 00 00 00 00 00 00 00 01 ff ff 00 00 Success in creating the socket : RC = 4
Write to socket successful : RC = 16
Total length:123
pldmtool: Rx: 00 02 51 00 01 00 00 00 00 00 00 00 05 6c 00 00 00 00 00 01 02 00 00 60 00 00 00 00 10 20 00 01 88 00 10 00 00 00 00 05 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d 00 90 08 0a 00 00 20 0a 00 a0 0d 0a 00 b0 1b 0e 00 4d 01 0a 00 5b 00
{
"nextRecordHandle": 1,
"responseCount": 108,
"recordHandle": 0,
"PDRHeaderVersion": 1,
"PDRType": "Numeric Sensor PDR",
"recordChangeNumber": 0,
"dataLength": 96
}
,pldmtool: Tx: 81 02 51 01 00 00 00 00 00 00 00 01 ff ff 00 00 Success in creating the socket : RC = 4
Write to socket successful : RC = 16
Total length:123
pldmtool: Rx: 01 02 51 00 02 00 00 00 00 00 00 00 05 6c 00 01 00 00 00 01 02 00 00 60 00 00 00 00 10 2d 00 01 88 00 10 00 00 00 00 05 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6e 03 01 00 ca 02 01 00 80 03 01 00 89 02 01 00 02 00 02 00 04 00 00 00
{
"nextRecordHandle": 2,
"responseCount": 108,
"recordHandle": 1,
"PDRHeaderVersion": 1,
"PDRType": "Numeric Sensor PDR",
"recordChangeNumber": 0,
"dataLength": 96
}
,pldmtool: Tx: 82 02 51 02 00 00 00 00 00 00 00 01 ff ff 00 00 Success in creating the socket : RC = 4
Write to socket successful : RC = 16
Total length:123
pldmtool: Rx: 02 02 51 00 00 00 00 00 00 00 00 00 05 6c 00 02 00 00 00 01 02 00 00 60 00 00 00 00 10 01 00 01 88 00 10 00 00 00 00 02 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 96 00 00 00 00 00
{
"nextRecordHandle": 0,
"responseCount": 108,
"recordHandle": 2,
"PDRHeaderVersion": 1,
"PDRType": "Numeric Sensor PDR",
"recordChangeNumber": 0,
"dataLength": 96
}
]

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 23, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@@ -0,0 +1,326 @@
/*

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mctp code seems to be generic and better to keep it in common layer, so other platforms can also use it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a lot more complicate to put the code in common layer, since every platform is using the same common code. We need to make sure that ongoing projects won't be affected. Therefore, we plan to put this on platform like other project in this stage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PeterHo-wiwynn can you move it to common and change meta-facebook/gt-cc/src/platform/plat_mctp.c as well. I can help with testing GTT/GTI which are the only other platforms which use this.

Preferably I would like to see plat_*.c contain just configuration data structures not functions which do actions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will move it to common. However, there are still some functions which implemented differently between platforms. I will try to move the functions doing same behavior, and list the others for disscusion.

}

static void set_endpoint_resp_handler(void *args, uint8_t *buf, uint16_t len)
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API is not setting any resp_handler as suggested by name or are you going to populate this in next commit? If so, better to leave a TODO for indications.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't set device endpoint in this commit. I leaved a TODO for indication.


static void set_endpoint_resp_timeout(void *args)
{
CHECK_NULL_ARG(args);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API is not setting any timeout or are you going to populate it in next commit? If so, better to leave a TODO for indications.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't set device endpoint in this commit. I leaved a TODO for indication.

msg.timeout_cb_fn = set_endpoint_resp_timeout;
msg.timeout_cb_fn_args = p;

mctp_ctrl_send_msg(find_mctp_by_smbus(p->bus), &msg);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is mctp_ctrl_send_msg NULL safe for in_arg?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


switch (msg_type) {
case MCTP_MSG_TYPE_CTRL:
LOG_ERR("type: mctp_ctrl");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG_INFO or DEBUG rather than LOG_ERR?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it was supposed to be delete.

medium_type = MCTP_MEDIUM_TYPE_SMBUS;
break;
default:
medium_type = -1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already -1, no need to set again.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

target = I2C_BUS_BMC;
break;
default:
target = -1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already -1, no need to set again.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


uint8_t rc = mctp_set_medium_configure(p->mctp_inst, MCTP_MEDIUM_TYPE_SMBUS, p->conf);
if (rc != MCTP_SUCCESS) {
LOG_INF("mctp set medium configure failed");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be LOG_ERR?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


mctp_reg_msg_rx_func(p->mctp_inst, mctp_msg_recv);

ret = mctp_start(p->mctp_inst);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to print some error if start fails?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#define MAX_SENSOR_SIZE 60

uint8_t plat_get_pdr_size();
void load_pdr_table(void);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use consistent plat_ prefix (if possible, i.e. doesn't involve much change in other places).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@BonnieLo has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@BonnieLo has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@BonnieLo has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@BonnieLo has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Summary:
Description
- Support pldm over mctp over i2c on yv4-sd.
- Add platform code for pdr implementation.

Motivation
For implementing sensor monitoring, the BMC should get sensor information from the BIC.

Test Plan:
- Build code: Pass
- Add some PDR samples in BIC and BMC get pdr from BIC: Pass

Log:
Get PDR info:
pldmtool raw -m 8 -d 0x80 0x02 0x50
pldmtool: Tx: 80 02 50
pldmtool: Rx: 00 02 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 44 01 00 00 6c 00 00 00 00

Get PDR:
pldmtool platform GetPDR -m 8 -a -v
[
pldmtool: Tx: 80 02 51 00 00 00 00 00 00 00 00 01 ff ff 00 00
Success in creating the socket : RC = 4
Write to socket successful : RC = 16
Total length:123
pldmtool: Rx: 00 02 51 00 01 00 00 00 00 00 00 00 05 6c 00 00 00 00 00 01 02 00 00 60 00 00 00 00 10 20 00 01 88 00 10 00
00 00 00 05 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3f 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 04 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d 00 90 08 0a 00 00 20 0a 00 a0 0d 0a 00 b0 1b 0e 00 4d
01 0a 00 5b 00
{
    "nextRecordHandle": 1,
    "responseCount": 108,
    "recordHandle": 0,
    "PDRHeaderVersion": 1,
    "PDRType": "Numeric Sensor PDR",
    "recordChangeNumber": 0,
    "dataLength": 96
}
,pldmtool: Tx: 81 02 51 01 00 00 00 00 00 00 00 01 ff ff 00 00
Success in creating the socket : RC = 4
Write to socket successful : RC = 16
Total length:123
pldmtool: Rx: 01 02 51 00 02 00 00 00 00 00 00 00 05 6c 00 01 00 00 00 01 02 00 00 60 00 00 00 00 10 2d 00 01 88 00 10 00
00 00 00 05 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 04 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6e 03 01 00 ca 02 01 00 80 03 01 00 89 02 01 00 02 00 02
00 04 00 00 00
{
    "nextRecordHandle": 2,
    "responseCount": 108,
    "recordHandle": 1,
    "PDRHeaderVersion": 1,
    "PDRType": "Numeric Sensor PDR",
    "recordChangeNumber": 0,
    "dataLength": 96
}
,pldmtool: Tx: 82 02 51 02 00 00 00 00 00 00 00 01 ff ff 00 00
Success in creating the socket : RC = 4
Write to socket successful : RC = 16
Total length:123
pldmtool: Rx: 02 02 51 00 00 00 00 00 00 00 00 00 05 6c 00 02 00 00 00 01 02 00 00 60 00 00 00 00 10 01 00 01 88 00 10 00
00 00 00 02 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 04 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 96
00 00 00 00 00
{
    "nextRecordHandle": 0,
    "responseCount": 108,
    "recordHandle": 2,
    "PDRHeaderVersion": 1,
    "PDRType": "Numeric Sensor PDR",
    "recordChangeNumber": 0,
    "dataLength": 96
}
]
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@BonnieLo has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been merged in 77ab5fd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged

5 participants