* [dpdk-stable] [PATCH v1 1/1] net/hinic/base: add message check for command channel [not found] <cover.1605015133.git.zhouguoyang@huawei.com> @ 2020-11-11 6:24 ` Guoyang Zhou 2020-11-11 6:33 ` Guoyang Zhou 2020-11-12 13:03 ` Ferruh Yigit 0 siblings, 2 replies; 3+ messages in thread From: Guoyang Zhou @ 2020-11-11 6:24 UTC (permalink / raw) To: luojiachen; +Cc: zhouguoyang, stable In the command channel, a message may has several fragments, and the several fragments should have same message id. To prevent problems, this check is added. Fixes: 1e4593db1d58 ("net/hinic/base: fix log info for PF command channel") Cc: stable@dpdk.org Signed-off-by: Guoyang Zhou <zhouguoyang@huawei.com> --- drivers/net/hinic/base/hinic_pmd_mbox.c | 28 +++++++++++++++++++--------- drivers/net/hinic/base/hinic_pmd_mbox.h | 2 +- drivers/net/hinic/base/hinic_pmd_mgmt.c | 23 ++++++++++++++--------- drivers/net/hinic/base/hinic_pmd_mgmt.h | 2 +- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/drivers/net/hinic/base/hinic_pmd_mbox.c b/drivers/net/hinic/base/hinic_pmd_mbox.c index ff44c25..92a7cc1 100644 --- a/drivers/net/hinic/base/hinic_pmd_mbox.c +++ b/drivers/net/hinic/base/hinic_pmd_mbox.c @@ -240,20 +240,22 @@ static void recv_func_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, } static bool check_mbox_seq_id_and_seg_len(struct hinic_recv_mbox *recv_mbox, - u8 seq_id, u8 seg_len) + u8 seq_id, u8 seg_len, u8 msg_id) { if (seq_id > HINIC_SEQ_ID_MAX_VAL || seg_len > HINIC_MSG_SEG_LEN) return false; if (seq_id == 0) { - recv_mbox->sed_id = seq_id; + recv_mbox->seq_id = seq_id; + recv_mbox->msg_info.msg_id = msg_id; } else { - if (seq_id != recv_mbox->sed_id + 1) { - recv_mbox->sed_id = 0; + if ((seq_id != recv_mbox->seq_id + 1) || + msg_id != recv_mbox->msg_info.msg_id) { + recv_mbox->seq_id = 0; return false; } - recv_mbox->sed_id = seq_id; + recv_mbox->seq_id = seq_id; } return true; @@ -477,16 +479,24 @@ static int recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, u16 src_func_idx; enum hinic_hwif_direction_type direction; u8 seq_id, seg_len; + u8 msg_id; + u8 front_id; seq_id = HINIC_MBOX_HEADER_GET(mbox_header, SEQID); seg_len = HINIC_MBOX_HEADER_GET(mbox_header, SEG_LEN); direction = HINIC_MBOX_HEADER_GET(mbox_header, DIRECTION); src_func_idx = HINIC_MBOX_HEADER_GET(mbox_header, SRC_GLB_FUNC_IDX); + msg_id = HINIC_MBOX_HEADER_GET(mbox_header, MSG_ID); + front_id = recv_mbox->seq_id; - if (!check_mbox_seq_id_and_seg_len(recv_mbox, seq_id, seg_len)) { + if (!check_mbox_seq_id_and_seg_len(recv_mbox, seq_id, seg_len, + msg_id)) { PMD_DRV_LOG(ERR, - "Mailbox sequence and segment check failed, src func id: 0x%x, front id: 0x%x, current id: 0x%x, seg len: 0x%x\n", - src_func_idx, recv_mbox->sed_id, seq_id, seg_len); + "Mailbox sequence and segment check failed, src func id: 0x%x, " + "front id: 0x%x, current id: 0x%x, seg len: 0x%x " + "front msg_id: %d, cur msg_id: %d", + src_func_idx, front_id, seq_id, seg_len, + recv_mbox->msg_info.msg_id, msg_id); return HINIC_ERROR; } @@ -496,7 +506,7 @@ static int recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, if (!HINIC_MBOX_HEADER_GET(mbox_header, LAST)) return HINIC_ERROR; - recv_mbox->sed_id = 0; + recv_mbox->seq_id = 0; recv_mbox->cmd = HINIC_MBOX_HEADER_GET(mbox_header, CMD); recv_mbox->mod = HINIC_MBOX_HEADER_GET(mbox_header, MODULE); recv_mbox->mbox_len = HINIC_MBOX_HEADER_GET(mbox_header, MSG_LEN); diff --git a/drivers/net/hinic/base/hinic_pmd_mbox.h b/drivers/net/hinic/base/hinic_pmd_mbox.h index dc08b99..b17f0df 100644 --- a/drivers/net/hinic/base/hinic_pmd_mbox.h +++ b/drivers/net/hinic/base/hinic_pmd_mbox.h @@ -39,7 +39,7 @@ struct hinic_recv_mbox { void *buf_out; enum hinic_mbox_ack_type ack_type; struct mbox_msg_info msg_info; - u8 sed_id; + u8 seq_id; }; struct hinic_send_mbox { diff --git a/drivers/net/hinic/base/hinic_pmd_mgmt.c b/drivers/net/hinic/base/hinic_pmd_mgmt.c index fb31bc8..9b39950 100644 --- a/drivers/net/hinic/base/hinic_pmd_mgmt.c +++ b/drivers/net/hinic/base/hinic_pmd_mgmt.c @@ -529,19 +529,21 @@ int hinic_msg_to_mgmt_no_ack(void *hwdev, enum hinic_mod_type mod, u8 cmd, } static bool check_mgmt_seq_id_and_seg_len(struct hinic_recv_msg *recv_msg, - u8 seq_id, u8 seg_len) + u8 seq_id, u8 seg_len, u16 msg_id) { if (seq_id > HINIC_SEQ_ID_MAX_VAL || seg_len > HINIC_MSG_SEG_LEN) return false; if (seq_id == 0) { - recv_msg->sed_id = seq_id; + recv_msg->seq_id = seq_id; + recv_msg->msg_id = msg_id; } else { - if (seq_id != recv_msg->sed_id + 1) { - recv_msg->sed_id = 0; + if ((seq_id != recv_msg->seq_id + 1) || + msg_id != recv_msg->msg_id) { + recv_msg->seq_id = 0; return false; } - recv_msg->sed_id = seq_id; + recv_msg->seq_id = seq_id; } return true; @@ -615,17 +617,20 @@ static int recv_mgmt_msg_handler(struct hinic_msg_pf_to_mgmt *pf_to_mgmt, u8 seq_id, seq_len; u32 msg_buf_max = MAX_PF_MGMT_BUF_SIZE; u8 front_id; + u16 msg_id; seq_id = HINIC_MSG_HEADER_GET(msg_header, SEQID); seq_len = HINIC_MSG_HEADER_GET(msg_header, SEG_LEN); - front_id = recv_msg->sed_id; + front_id = recv_msg->seq_id; + msg_id = HINIC_MSG_HEADER_GET(msg_header, MSG_ID); - if (!check_mgmt_seq_id_and_seg_len(recv_msg, seq_id, seq_len)) { + if (!check_mgmt_seq_id_and_seg_len(recv_msg, seq_id, seq_len, msg_id)) { PMD_DRV_LOG(ERR, "Mgmt msg sequence and segment check failed, " - "func id: 0x%x, front id: 0x%x, current id: 0x%x, seg len: 0x%x", + "func id: 0x%x, front id: 0x%x, current id: 0x%x, seg len: 0x%x " + "front msg_id: %d, cur msg_id: %d", hinic_global_func_id(pf_to_mgmt->hwdev), - front_id, seq_id, seq_len); + front_id, seq_id, seq_len, recv_msg->msg_id, msg_id); return HINIC_ERROR; } diff --git a/drivers/net/hinic/base/hinic_pmd_mgmt.h b/drivers/net/hinic/base/hinic_pmd_mgmt.h index 0f32865..5099a3a 100644 --- a/drivers/net/hinic/base/hinic_pmd_mgmt.h +++ b/drivers/net/hinic/base/hinic_pmd_mgmt.h @@ -69,7 +69,7 @@ struct hinic_recv_msg { u8 cmd; u16 msg_id; int async_mgmt_to_pf; - u8 sed_id; + u8 seq_id; }; #define HINIC_COMM_SELF_CMD_MAX 8 -- 1.8.3.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [dpdk-stable] [PATCH v1 1/1] net/hinic/base: add message check for command channel 2020-11-11 6:24 ` [dpdk-stable] [PATCH v1 1/1] net/hinic/base: add message check for command channel Guoyang Zhou @ 2020-11-11 6:33 ` Guoyang Zhou 2020-11-12 13:03 ` Ferruh Yigit 1 sibling, 0 replies; 3+ messages in thread From: Guoyang Zhou @ 2020-11-11 6:33 UTC (permalink / raw) To: dev Cc: ferruh.yigit, bluca, cloud.wangxiaoyun, luoxianjun, yin.yinshi, luojiachen, zhouguoyang, chenlizhong, zhaohui8, chenchanghu, stable In the command channel, a message may has several fragments, and the several fragments should have same message id. To prevent problems, this check is added. Fixes: 1e4593db1d58 ("net/hinic/base: fix log info for PF command channel") Cc: stable@dpdk.org Signed-off-by: Guoyang Zhou <zhouguoyang@huawei.com> --- drivers/net/hinic/base/hinic_pmd_mbox.c | 28 +++++++++++++++++++--------- drivers/net/hinic/base/hinic_pmd_mbox.h | 2 +- drivers/net/hinic/base/hinic_pmd_mgmt.c | 23 ++++++++++++++--------- drivers/net/hinic/base/hinic_pmd_mgmt.h | 2 +- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/drivers/net/hinic/base/hinic_pmd_mbox.c b/drivers/net/hinic/base/hinic_pmd_mbox.c index ff44c25..92a7cc1 100644 --- a/drivers/net/hinic/base/hinic_pmd_mbox.c +++ b/drivers/net/hinic/base/hinic_pmd_mbox.c @@ -240,20 +240,22 @@ static void recv_func_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, } static bool check_mbox_seq_id_and_seg_len(struct hinic_recv_mbox *recv_mbox, - u8 seq_id, u8 seg_len) + u8 seq_id, u8 seg_len, u8 msg_id) { if (seq_id > HINIC_SEQ_ID_MAX_VAL || seg_len > HINIC_MSG_SEG_LEN) return false; if (seq_id == 0) { - recv_mbox->sed_id = seq_id; + recv_mbox->seq_id = seq_id; + recv_mbox->msg_info.msg_id = msg_id; } else { - if (seq_id != recv_mbox->sed_id + 1) { - recv_mbox->sed_id = 0; + if ((seq_id != recv_mbox->seq_id + 1) || + msg_id != recv_mbox->msg_info.msg_id) { + recv_mbox->seq_id = 0; return false; } - recv_mbox->sed_id = seq_id; + recv_mbox->seq_id = seq_id; } return true; @@ -477,16 +479,24 @@ static int recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, u16 src_func_idx; enum hinic_hwif_direction_type direction; u8 seq_id, seg_len; + u8 msg_id; + u8 front_id; seq_id = HINIC_MBOX_HEADER_GET(mbox_header, SEQID); seg_len = HINIC_MBOX_HEADER_GET(mbox_header, SEG_LEN); direction = HINIC_MBOX_HEADER_GET(mbox_header, DIRECTION); src_func_idx = HINIC_MBOX_HEADER_GET(mbox_header, SRC_GLB_FUNC_IDX); + msg_id = HINIC_MBOX_HEADER_GET(mbox_header, MSG_ID); + front_id = recv_mbox->seq_id; - if (!check_mbox_seq_id_and_seg_len(recv_mbox, seq_id, seg_len)) { + if (!check_mbox_seq_id_and_seg_len(recv_mbox, seq_id, seg_len, + msg_id)) { PMD_DRV_LOG(ERR, - "Mailbox sequence and segment check failed, src func id: 0x%x, front id: 0x%x, current id: 0x%x, seg len: 0x%x\n", - src_func_idx, recv_mbox->sed_id, seq_id, seg_len); + "Mailbox sequence and segment check failed, src func id: 0x%x, " + "front id: 0x%x, current id: 0x%x, seg len: 0x%x " + "front msg_id: %d, cur msg_id: %d", + src_func_idx, front_id, seq_id, seg_len, + recv_mbox->msg_info.msg_id, msg_id); return HINIC_ERROR; } @@ -496,7 +506,7 @@ static int recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, if (!HINIC_MBOX_HEADER_GET(mbox_header, LAST)) return HINIC_ERROR; - recv_mbox->sed_id = 0; + recv_mbox->seq_id = 0; recv_mbox->cmd = HINIC_MBOX_HEADER_GET(mbox_header, CMD); recv_mbox->mod = HINIC_MBOX_HEADER_GET(mbox_header, MODULE); recv_mbox->mbox_len = HINIC_MBOX_HEADER_GET(mbox_header, MSG_LEN); diff --git a/drivers/net/hinic/base/hinic_pmd_mbox.h b/drivers/net/hinic/base/hinic_pmd_mbox.h index dc08b99..b17f0df 100644 --- a/drivers/net/hinic/base/hinic_pmd_mbox.h +++ b/drivers/net/hinic/base/hinic_pmd_mbox.h @@ -39,7 +39,7 @@ struct hinic_recv_mbox { void *buf_out; enum hinic_mbox_ack_type ack_type; struct mbox_msg_info msg_info; - u8 sed_id; + u8 seq_id; }; struct hinic_send_mbox { diff --git a/drivers/net/hinic/base/hinic_pmd_mgmt.c b/drivers/net/hinic/base/hinic_pmd_mgmt.c index fb31bc8..9b39950 100644 --- a/drivers/net/hinic/base/hinic_pmd_mgmt.c +++ b/drivers/net/hinic/base/hinic_pmd_mgmt.c @@ -529,19 +529,21 @@ int hinic_msg_to_mgmt_no_ack(void *hwdev, enum hinic_mod_type mod, u8 cmd, } static bool check_mgmt_seq_id_and_seg_len(struct hinic_recv_msg *recv_msg, - u8 seq_id, u8 seg_len) + u8 seq_id, u8 seg_len, u16 msg_id) { if (seq_id > HINIC_SEQ_ID_MAX_VAL || seg_len > HINIC_MSG_SEG_LEN) return false; if (seq_id == 0) { - recv_msg->sed_id = seq_id; + recv_msg->seq_id = seq_id; + recv_msg->msg_id = msg_id; } else { - if (seq_id != recv_msg->sed_id + 1) { - recv_msg->sed_id = 0; + if ((seq_id != recv_msg->seq_id + 1) || + msg_id != recv_msg->msg_id) { + recv_msg->seq_id = 0; return false; } - recv_msg->sed_id = seq_id; + recv_msg->seq_id = seq_id; } return true; @@ -615,17 +617,20 @@ static int recv_mgmt_msg_handler(struct hinic_msg_pf_to_mgmt *pf_to_mgmt, u8 seq_id, seq_len; u32 msg_buf_max = MAX_PF_MGMT_BUF_SIZE; u8 front_id; + u16 msg_id; seq_id = HINIC_MSG_HEADER_GET(msg_header, SEQID); seq_len = HINIC_MSG_HEADER_GET(msg_header, SEG_LEN); - front_id = recv_msg->sed_id; + front_id = recv_msg->seq_id; + msg_id = HINIC_MSG_HEADER_GET(msg_header, MSG_ID); - if (!check_mgmt_seq_id_and_seg_len(recv_msg, seq_id, seq_len)) { + if (!check_mgmt_seq_id_and_seg_len(recv_msg, seq_id, seq_len, msg_id)) { PMD_DRV_LOG(ERR, "Mgmt msg sequence and segment check failed, " - "func id: 0x%x, front id: 0x%x, current id: 0x%x, seg len: 0x%x", + "func id: 0x%x, front id: 0x%x, current id: 0x%x, seg len: 0x%x " + "front msg_id: %d, cur msg_id: %d", hinic_global_func_id(pf_to_mgmt->hwdev), - front_id, seq_id, seq_len); + front_id, seq_id, seq_len, recv_msg->msg_id, msg_id); return HINIC_ERROR; } diff --git a/drivers/net/hinic/base/hinic_pmd_mgmt.h b/drivers/net/hinic/base/hinic_pmd_mgmt.h index 0f32865..5099a3a 100644 --- a/drivers/net/hinic/base/hinic_pmd_mgmt.h +++ b/drivers/net/hinic/base/hinic_pmd_mgmt.h @@ -69,7 +69,7 @@ struct hinic_recv_msg { u8 cmd; u16 msg_id; int async_mgmt_to_pf; - u8 sed_id; + u8 seq_id; }; #define HINIC_COMM_SELF_CMD_MAX 8 -- 1.8.3.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-stable] [PATCH v1 1/1] net/hinic/base: add message check for command channel 2020-11-11 6:24 ` [dpdk-stable] [PATCH v1 1/1] net/hinic/base: add message check for command channel Guoyang Zhou 2020-11-11 6:33 ` Guoyang Zhou @ 2020-11-12 13:03 ` Ferruh Yigit 1 sibling, 0 replies; 3+ messages in thread From: Ferruh Yigit @ 2020-11-12 13:03 UTC (permalink / raw) To: Guoyang Zhou, dev Cc: bluca, cloud.wangxiaoyun, luoxianjun, yin.yinshi, luojiachen, chenlizhong, zhaohui8, chenchanghu, stable On 11/11/2020 6:33 AM, Guoyang Zhou wrote: > In the command channel, a message may has several fragments, > and the several fragments should have same message id. To > prevent problems, this check is added. > > Fixes: 1e4593db1d58 ("net/hinic/base: fix log info for PF command channel") > Cc: stable@dpdk.org > Signed-off-by: Guoyang Zhou <zhouguoyang@huawei.com> Applied to dpdk-next-net/main, thanks. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-12 13:03 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <cover.1605015133.git.zhouguoyang@huawei.com> 2020-11-11 6:24 ` [dpdk-stable] [PATCH v1 1/1] net/hinic/base: add message check for command channel Guoyang Zhou 2020-11-11 6:33 ` Guoyang Zhou 2020-11-12 13:03 ` Ferruh Yigit
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).