From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 33E98A04DB for ; Tue, 17 Nov 2020 12:15:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 28309F3E; Tue, 17 Nov 2020 12:15:49 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 4294BF3E for ; Tue, 17 Nov 2020 12:15:48 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id r17so22794953wrw.1 for ; Tue, 17 Nov 2020 03:15:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cI1pGjV2uG/eyqOrcgyWRCE/9CaoP8uJLvJkoCtRGd0=; b=mTEAOfCuLWe3Ve92OoVMaFYtaQuC0kx7KlQlxljdny0r+2sJu7eAEGo8jmMcD7ORg8 WNnG01mqtPkw3lV3PdYO94a9j0nixX4f4932Wn433R3HrBsng9a6th9P3zbfhNqet1zR f6PkvW8qqv49TnOIYTWP6EBwDT7T3J/gnibeaa3GiomSLUYqVdJ+wabEjrqR/1Czb1fG +UGINtoa2UFDIKYjvfDRhedLsmx5LIzRU+HLsrtW8mbdczwf6Jx6o3qVf8Fd5BVn88zB qcLEJ7Cc6F5yZo4qqctro5fPDID0ywRWdiTzPFi8deY+DeRdCGHUE5+kS4onhSiMhROP eAwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cI1pGjV2uG/eyqOrcgyWRCE/9CaoP8uJLvJkoCtRGd0=; b=Ycvw6qcmwqD7uq/7PZnqUY1l8CAVCUl/MHJxoYRNQb6sdbTPQCeXriQXytqWZ2IXBs 69riKeT7+/wT+bEEdeZAln2VGpWvALZJoSL8LhB0ZDAYjMeoSXrbEzC58qdiicuG8BYL AdgFUY8/Ho3QpIphEV39/m6cazb3EVwano8Y0agMbOf96tVCTg36IKe7W1KNqRwaB+Qs zGRn9/rllKzGhVNsB0q2vB+8c8IaCSEQeBZXi3G4bre3QS2/hNveWUmqhCrb1nTGWDyK SXlJoU4/QC7iubHctYwZCCGhZXxy2ENzqG+gqT/krSgoU/SyS+J5U1ELDXLOT2fU9guT ai9A== X-Gm-Message-State: AOAM531VJ/pO9A9CtEQHuyXYw8U3gX3htqQjqFbZpX7isgLulhi83WCn cnVN7kuEidKzV0t21LgN+iI12oW+hadoYIzc X-Google-Smtp-Source: ABdhPJxMZ0Z+iPXawIKDbO1Wasbi8UuJDGx0r3KaZT6SCSrRpyy/mDsB/mGPS8QBEJr5IdTS2eMElA== X-Received: by 2002:a5d:474f:: with SMTP id o15mr23596727wrs.377.1605611747020; Tue, 17 Nov 2020 03:15:47 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id c62sm3094149wme.22.2020.11.17.03.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 03:15:46 -0800 (PST) From: luca.boccassi@gmail.com To: Guoyang Zhou Cc: dpdk stable Date: Tue, 17 Nov 2020 11:14:00 +0000 Message-Id: <20201117111416.1961049-26-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201117111416.1961049-1-luca.boccassi@gmail.com> References: <20201109185030.3478760-2-luca.boccassi@gmail.com> <20201117111416.1961049-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/hinic/base: add message check for command channel' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/19/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/c76a71e256f83dc23d6544efcb640fe4cb5b1c14 Thanks. Luca Boccassi --- >From c76a71e256f83dc23d6544efcb640fe4cb5b1c14 Mon Sep 17 00:00:00 2001 From: Guoyang Zhou Date: Wed, 11 Nov 2020 14:33:37 +0800 Subject: [PATCH] net/hinic/base: add message check for command channel [ upstream commit cb99500de915040339f294b6ad2fc8edb4085b19 ] 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") Signed-off-by: Guoyang Zhou --- 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 ab99cfb5ad..fb7d16dc6a 100644 --- a/drivers/net/hinic/base/hinic_pmd_mbox.c +++ b/drivers/net/hinic/base/hinic_pmd_mbox.c @@ -241,20 +241,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; @@ -478,16 +480,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; } @@ -497,7 +507,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 dc08b99f47..b17f0df1db 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 8bff353da8..d5fd16f235 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 fail, " - "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 0f32865106..5099a3a8d6 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 -- 2.27.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-11-17 11:13:14.079125476 +0000 +++ 0026-net-hinic-base-add-message-check-for-command-channel.patch 2020-11-17 11:13:12.925116690 +0000 @@ -1 +1 @@ -From cb99500de915040339f294b6ad2fc8edb4085b19 Mon Sep 17 00:00:00 2001 +From c76a71e256f83dc23d6544efcb640fe4cb5b1c14 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit cb99500de915040339f294b6ad2fc8edb4085b19 ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ -index ff44c25a85..92a7cc1a11 100644 +index ab99cfb5ad..fb7d16dc6a 100644 @@ -25 +26 @@ -@@ -240,20 +240,22 @@ static void recv_func_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, +@@ -241,20 +241,22 @@ static void recv_func_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, @@ -53 +54 @@ -@@ -477,16 +479,24 @@ static int recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, +@@ -478,16 +480,24 @@ static int recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, @@ -81 +82 @@ -@@ -496,7 +506,7 @@ static int recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, +@@ -497,7 +507,7 @@ static int recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func, @@ -104 +105 @@ -index fb31bc8581..9b399502de 100644 +index 8bff353da8..d5fd16f235 100644 @@ -149 +150 @@ - "Mgmt msg sequence and segment check failed, " + "Mgmt msg sequence and segment check fail, "