From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4E1AAA0548 for ; Tue, 18 May 2021 06:15:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 697A34003E; Tue, 18 May 2021 06:15:05 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2044.outbound.protection.outlook.com [40.107.93.44]) by mails.dpdk.org (Postfix) with ESMTP id 606B64003E for ; Tue, 18 May 2021 06:15:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pp3eVaW+YasWWwc9rzk6SIG+JnxX+WbeqG82kif6AVxVECULziLV7SvUAbFjeIF/F7ZCUflRM9XO2y3HGIJJS7VJYRHxXofFEVrAWzdFZG+MVmmk8kxsDa6JuNcw4vU7rD28hTSazlcejLG3MR+qwD6AJi1R8Q0LDfzAL5OgePTTo6Q46ppjHNULjMwARrYC2tsGQo7WTNycETC/L0qbqW+vMnsSDcOZoT+FUG7FTDzeTkIfJt9ifLbU8udQLthiOkSqGvY3uJu3TKcLzGLvsUYQOR1gqIxX5EoR69XIxjz91dil+jGmdSTaoiUv8uWQC/g26M7hdwlHUTTb/089bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hgveNJKZjN0ygb7FQbmDoVLgunRk+SDsWKBINIsWgOE=; b=LC2JXXEZRFyHZ39aQi4Qg1+8nt5+l6D3MXrS3LR5nVkjk9HLOHXaI6E/HS3YXdLoSN/NdT2+3VcKjBfPA5iF+eVBtbC+n8pxGzWpsZPK0JF6oN6jeVBqjPb4j0mE6BCy/ZUdoqSJyu+TuTC0Z4HsSxE5GM44w5zL3HiQES+U8ffu0xcR3QtSwj+b7RLttLK0aacvB97LkByfeGi5o+yNpoywr6vN8dGCxwpqukqn26+7n09ZorNC3qVOf0PBf/veugd2l1gj+NyTXizvS6WakVTmONk8nBjXKUlPREkaa0Q/faQUBFZlFLyG7waNJ0ss6JTQ7xndmQr62GybdbnFbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hgveNJKZjN0ygb7FQbmDoVLgunRk+SDsWKBINIsWgOE=; b=k5SoyYO45Y5b7yeWHNe/wmCkiQJhDUqmVndvWps/5LcnpqkpDpayxdi8cXfGORWE+hLGsCxr9h66qVkY/gOTDKWzMR20Q+dvVwSDl0GPB4yybG80hNr6J8EFNwRpWDohLn3hQyuVGUP3qZ0AaiM5Rq4rh6uBDCSKxZMQ1EFmV+Ztjn8yI+mcxL3CAIWWu5Cz842vCFn6V7dImaHR3O7UDbnUws29F3f20J3QSSksnzOaXN3vvzo750Uzkr74HBjBegLRY1ldNaUBvccMyr+WQBUJqqZSz2WQOD64XtVeOCazszduK3zcS0YXWKvoyxrii5B2FSed3hsOzb/QEWMNUg== Received: from BY5PR12MB4324.namprd12.prod.outlook.com (2603:10b6:a03:209::10) by BY5PR12MB4904.namprd12.prod.outlook.com (2603:10b6:a03:1d3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.30; Tue, 18 May 2021 04:15:02 +0000 Received: from BY5PR12MB4324.namprd12.prod.outlook.com ([fe80::b919:53f4:6757:331c]) by BY5PR12MB4324.namprd12.prod.outlook.com ([fe80::b919:53f4:6757:331c%6]) with mapi id 15.20.4129.032; Tue, 18 May 2021 04:15:02 +0000 From: "Xueming(Steven) Li" To: "Min Hu (Connor)" , "stable@dpdk.org" CC: "ferruh.yigit@intel.com" Thread-Topic: [PATCH 20.11 2/4] net/hns3: fix VF handling LSC event in secondary process Thread-Index: AQHXSyOn7YiPjZeAHUy+vsS92uNAraroonDQ Date: Tue, 18 May 2021 04:15:01 +0000 Message-ID: References: <1621259445-5182-1-git-send-email-humin29@huawei.com> <1621259445-5182-2-git-send-email-humin29@huawei.com> In-Reply-To: <1621259445-5182-2-git-send-email-humin29@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=nvidia.com; x-originating-ip: [180.174.128.225] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 728c31b4-7d6d-405b-a095-08d919b38216 x-ms-traffictypediagnostic: BY5PR12MB4904: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4125; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: UFA9+x5d6vCQoRfYS1njO4TwphFEKKipYI26T/roxnrxpvo59BWagn0Cxzrb7DVjxtHCR0C8hCuvxDeiZM2KRxlQdiTyWPfhj3eF5qmzHnEUWpzboauxZXDZsgfKWkUuPnxMc+/GdLAUP/2wzxYsSG3C4ZC3l7omUBzTy0RhjwpynhLqjc9iXfVB/ZJDZK384tMXnZZFyx4mlUQtkW3keoGJlXPHi4nwFBwRzoZZdELxmA1bMFlUkZwZoVuANvTBSUu7beGb+p1OqjkMFvMwzaxT1SNzSo5NX50QWHgSaBdw7kB7oK+NaPoZ7ypy6VEVtpiezoBd3Z+7VePpZVZ4l6zkPjIEfdW/dMkwdgbO0BWKoyx/rMG89KlOYAzgpdNvHCFj1bLvbOpfQ7WgmVedggwWsZor3xFRycdZP5nC8ECWR/3sekb9cf7f7/VCdwA3/vAlZmEg86BuP5fhLPlKSNTtLiW/xJ+qHpQHNCZzPD+EJB6GvYqYHIK/M5teJ5ePgTQf1w5XvtM46GyO3ed4Us/ApV/ORDHBA5NqyiRINGnvxVG+2cu9+ybM1d9RLSsNOTSWxkLWRol4pKsZOppIKLSvRWGmSTi+zV/ceHOoiO8= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR12MB4324.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(396003)(376002)(136003)(346002)(122000001)(38100700002)(4326008)(7696005)(5660300002)(33656002)(186003)(52536014)(8936002)(8676002)(83380400001)(53546011)(316002)(71200400001)(86362001)(76116006)(66946007)(2906002)(66476007)(26005)(64756008)(55016002)(110136005)(66446008)(478600001)(9686003)(6506007)(66556008); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?PFYB+i15J/dk3I7VeXgHNCpoV/id3XBp2W8/ILxL4EftZzXtkm+SbMio3Wu5?= =?us-ascii?Q?3oGFsZl3n3tYe6IlXs2C6YKniopEZGNyVhHCLVC+wSuYX+EmZXkqXOkSTp61?= =?us-ascii?Q?SaBToVXoHCC3SVb0P3w4FYET6cUChJmrxutbNzyPhZnNtfzfh1B+LqdXTzlq?= =?us-ascii?Q?Mq+8AhSKPKa6t3Pth5q52eNaMKsRBq2iNilvJJacARSrsnE0e8WWR1/noDD9?= =?us-ascii?Q?esSS7tLaHiXP45JiGYIeNGJTGH1oayS/HM0vXBIUenAVWkn2olNQME6lDVtd?= =?us-ascii?Q?rprjuWIXMoMQnMjpsptC5rbgNj9ZZC9b7Ma0hUteljqXJTUbwIo/iSbUbCuT?= =?us-ascii?Q?eelPw/wGvXGlOKVDoMzc9E7TpA0sIb0CUNFTixX4tht/FcjBFVVPJZ64lqjY?= =?us-ascii?Q?Fesuxsl2dQUBpD/ER6mJq4U0M8tlAmaE7Qoghb86uuk7c/Os2pisGW6Cg81r?= =?us-ascii?Q?ihcFWNXpGxeLh+Sbn7eth+2HeXosgEq9kSJY1jPT3fN6rX9Kd4fezMA8RhVK?= =?us-ascii?Q?vnmaaV7a/Z8MvNVDgrxI1bl67cpU+7dQP+I4OtKHin9Iiaahfhp1Mol6XRt2?= =?us-ascii?Q?czjejZzd8hwn7VEV13qb0EDdk4dUNdtedFHiUhD5q9wIZJfPBPq61IB5lAyM?= =?us-ascii?Q?Um0JfyVNR0Qu7cy4jNRUOOLgZSkKaVZHGT3/SYOh6vvxymILrnCtx79paAUW?= =?us-ascii?Q?+C1jtBfqHHx2F2VWV76fxD1MDGcHTyGLTv8Aj3sAYK8BJE9fNWkwKqgU9MV8?= =?us-ascii?Q?QlnXQ2/p27dVxf6sGonNOIAvo+D6m6a6YDTcaAE4uCtpQZySvTG8N8wUyDVO?= =?us-ascii?Q?HnUlaSySZT/YIxF4MjK/4leCV4iWRXDQ03F+6t563lC65fEEBa4WLfu+pSbM?= =?us-ascii?Q?b2yRZtwXiiRQk+RPI+fRzxTO2lQVCL/vUo5sZG6Zqhalc7Bfj9LeUWARD6j8?= =?us-ascii?Q?N/QJv/hTdWN3Pqd4ZphPyItgcgFmO9tC39+krfBuvg2KW4iGcEnIQgawzBmu?= =?us-ascii?Q?DanYR9p4kUkWJnH9TwPgwj2ODLSRUWmUGhVZQdpbg0j6J8IqciEl2HYsMeQD?= =?us-ascii?Q?nvZysR6K6MeWwt4EpqBms/5/52IGFS0iCboG1gPGTz55PjYWscf56ZSmIEr3?= =?us-ascii?Q?IrwQTmQBclAj0PZhhuDWQQGOguCHLHGLZmrp8xFuGOv2NcmtbH8A3VbkK+1H?= =?us-ascii?Q?gBvx2vYQkLyV95ZpNZzDvhQHN1kCb6XMkwlhZnQSBX40O/bpfP3xuajnci/B?= =?us-ascii?Q?Oc/vwmJjTjVujd+p92leYxVfNZsJ7diNa9dO8RQdsRqkK72kXndBXFCSJ+7c?= =?us-ascii?Q?AgbxGrISfEYBlmxV9brirTMP?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4324.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 728c31b4-7d6d-405b-a095-08d919b38216 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 May 2021 04:15:01.9936 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VFYWLyepipq0DmHVPfICZWmtZeOcbTwarz7VhpMXjYwoAowwHK8prg3TWSiunVKzMeYRSI2JmIozNoNUy2VDew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4904 Subject: Re: [dpdk-stable] [PATCH 20.11 2/4] net/hns3: fix VF handling LSC event in secondary process X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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" Thanks, merged > -----Original Message----- > From: Min Hu (Connor) > Sent: Monday, May 17, 2021 9:51 PM > To: stable@dpdk.org > Cc: ferruh.yigit@intel.com; Xueming(Steven) Li > Subject: [PATCH 20.11 2/4] net/hns3: fix VF handling LSC event in seconda= ry process >=20 > From: Chengwen Feng >=20 > [ upstream commit dbbbad23e380773b37872df2195c4529fd93ca6f ] >=20 > VF will build two queues (csq: command send queue, crq: command receive > queue) with firmware, the crq may contain the following messages: > 1) mailbox response message which was the ack of mailbox sync request. > 2) PF's link status change message which may send by PF at anytime; >=20 > Currently, any threads in the primary and secondary processes could send = mailbox sync request, so it will need to process the crq > messages in there own thread context. >=20 > If the crq hold two messages: a) PF's link status change message, b) mail= box response message when secondary process deals with > the crq messages, it will lead to report lsc event in secondary process b= ecause it uses the policy of processing all pending messages at > once. >=20 > We use the following scheme to solve it: > 1) threads in secondary process could only process specifics messages > (eg. mailbox response message) in crq, if the message processed, its > opcode will rewrite with zero, then the intr thread in primary > process will not process again. > 2) threads other than intr thread in the primary process use the same > processing logic as the threads in secondary process. > 3) intr thread in the primary process could process all messages. >=20 > Fixes: 76a3836b98c4 ("net/hns3: fix setting default MAC address in bondin= g of VF") > Fixes: 463e748964f5 ("net/hns3: support mailbox") > Cc: stable@dpdk.org >=20 > Signed-off-by: Chengwen Feng > Signed-off-by: Min Hu (Connor) > --- > drivers/net/hns3/hns3_mbx.c | 68 +++++++++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 68 insertions(+) >=20 > diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c in= dex 79ac16a..11e5235 100644 > --- a/drivers/net/hns3/hns3_mbx.c > +++ b/drivers/net/hns3/hns3_mbx.c > @@ -407,6 +407,44 @@ hns3_handle_promisc_info(struct hns3_hw *hw, uint16_= t promisc_en) > } > } >=20 > +static void > +hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw) { > + struct hns3_cmq_ring *crq =3D &hw->cmq.crq; > + struct hns3_mbx_pf_to_vf_cmd *req; > + struct hns3_cmd_desc *desc; > + uint32_t tail, next_to_use; > + uint8_t opcode; > + uint16_t flag; > + > + tail =3D hns3_read_dev(hw, HNS3_CMDQ_RX_TAIL_REG); > + next_to_use =3D crq->next_to_use; > + while (next_to_use !=3D tail) { > + desc =3D &crq->desc[next_to_use]; > + req =3D (struct hns3_mbx_pf_to_vf_cmd *)desc->data; > + opcode =3D req->msg[0] & 0xff; > + > + flag =3D rte_le_to_cpu_16(crq->desc[next_to_use].flag); > + if (!hns3_get_bit(flag, HNS3_CMDQ_RX_OUTVLD_B)) > + goto scan_next; > + > + if (crq->desc[next_to_use].opcode =3D=3D 0) > + goto scan_next; > + > + if (opcode =3D=3D HNS3_MBX_PF_VF_RESP) { > + hns3_handle_mbx_response(hw, req); > + /* > + * Clear opcode to inform intr thread don't process > + * again. > + */ > + crq->desc[crq->next_to_use].opcode =3D 0; > + } > + > +scan_next: > + next_to_use =3D (next_to_use + 1) % hw->cmq.crq.desc_num; > + } > +} > + > void > hns3_dev_handle_mbx_msg(struct hns3_hw *hw) { @@ -418,6 +456,29 @@ hns3= _dev_handle_mbx_msg(struct hns3_hw *hw) > uint16_t flag; > rte_spinlock_lock(&hw->cmq.crq.lock); >=20 > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY || > + !rte_thread_is_intr()) { > + /* > + * Currently, any threads in the primary and secondary processes > + * could send mailbox sync request, so it will need to process > + * the crq message (which is the HNS3_MBX_PF_VF_RESP) in there > + * own thread context. It may also process other messages > + * because it uses the policy of processing all pending messages > + * at once. > + * But some messages such as HNS3_MBX_PUSH_LINK_STATUS could > + * only process within the intr thread in primary process, > + * otherwise it may lead to report lsc event in secondary > + * process. > + * So the threads other than intr thread in primary process > + * could only process HNS3_MBX_PF_VF_RESP message, if the > + * message processed, its opcode will rewrite with zero, then > + * the intr thread in primary process will not process again. > + */ > + hns3_handle_mbx_msg_out_intr(hw); > + rte_spinlock_unlock(&hw->cmq.crq.lock); > + return; > + } > + > while (!hns3_cmd_crq_empty(hw)) { > if (rte_atomic16_read(&hw->reset.disable_cmd)) > rte_spinlock_unlock(&hw->cmq.crq.lock); > @@ -439,6 +500,13 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) > continue; > } >=20 > + if (desc->opcode =3D=3D 0) { > + /* Message already processed by other thread */ > + crq->desc[crq->next_to_use].flag =3D 0; > + hns3_mbx_ring_ptr_move_crq(crq); > + continue; > + } > + > switch (opcode) { > case HNS3_MBX_PF_VF_RESP: > hns3_handle_mbx_response(hw, req); > -- > 2.7.4