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 CAEA2A0548 for ; Mon, 17 May 2021 08:58:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 972384003C; Mon, 17 May 2021 08:58:52 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2043.outbound.protection.outlook.com [40.107.93.43]) by mails.dpdk.org (Postfix) with ESMTP id F3D504003C for ; Mon, 17 May 2021 08:58:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I+9fNQpUB2pCiyryZPdSPTkIAWsRdnWOaYkN147OH/gili/sD41tMUNDYw/kThEmrdR58lhP3xm8PKwOu542SnWbpd/kFSOv8lhl+pTyjNZlNb3RaXz4fv2EBTaDF6Hy+4MxUyCUcOqvUOCbMaru1IcjStQ90hnbRtMQf0hA132EXE8EcQAlBrGhvIUULYRNGMtw7PZotl9wVPwuPkCm9Z99JdjxkVLvXcgbRMaybQIROECdcd1sF4OemChxdcRzBcq0aXjw0iVmV0rFYGVKVpaIEHR/hzg7Ji4AIujay+cqltEDDG4pxrCccdooBFp4gWRfmGCtjWJXb3RO5jNFJw== 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=0huopYLygIT/oUjek4huPOii/v+Mn45Gbj82Tli/OTc=; b=M1rWsoD/bYDlr2Q7jqWHoMyyfwWjD0lFY5j0nTeTJCF++dAQSxL9kIMhGoFhdACMzAE3G+/7Da1TBiEx3T3ogHja2vFuAYWzS+igUQ+hr+/X0pkVZOmi6gobG7fMRY/cmZnUl9HttPedThMCvxk3YK0vuSGc8G1BKBlk4p1/So1/+BeTlBC2Or2jfRtU1DoIdca17oWRzFPzNOooNRQqpc8gEz9CGch+hEvwauVCdSCYDWznKra+eU3pWXSg4vpAyycse6OdzQAgmv0ipFc1LFgaLx5iNUI2Yl2nKTgrkSDSJqX5F1oIQjtHSYjVv7/BOrwrXUEi1Z0nmhtPt/VtNA== 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=0huopYLygIT/oUjek4huPOii/v+Mn45Gbj82Tli/OTc=; b=lN3svzy2CiKWWIsmZL2x9lf4BDj8dVqMptb47BweZ+7MO2AWyJYpZHdkWdAcOirjjDkRiH8AJR0bFZqsMCSsiX/CKDzGCY/7Z21D2EKQm6EnvCkfIE/oJpyPrJJ+1uRxIQ02ok7Irr5Emz4q/ukYV9F4hLsBim1sAwEuOqg8NZM+Jg9rdYA9H8Hp48ijVT7MFrF7GLDMa2BL36P/X1SJneY9Amg1qLGCFePbr8ToqyBILGGXtw8Pywu5Y0S+O0sJE0vo3Idviuwo5UnQnb6YWswvyBYS1Nxa5S642RRzMynSrEAzoeGEwRC6ePUjofdlJR0CSz+RlqYQJipFBXyS9g== Received: from BY5PR12MB4324.namprd12.prod.outlook.com (2603:10b6:a03:209::10) by BY5PR12MB4068.namprd12.prod.outlook.com (2603:10b6:a03:203::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Mon, 17 May 2021 06:58:49 +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.031; Mon, 17 May 2021 06:58:49 +0000 From: "Xueming(Steven) Li" To: "Min Hu (Connor)" , "stable@dpdk.org" CC: "ferruh.yigit@intel.com" Thread-Topic: [PATCH 20.11] net/hns3: fix setting default MAC address in bonding of VF Thread-Index: AQHXSWnLaT98JEl9NUe+7ftRqIdpHKrnQM5Q Date: Mon, 17 May 2021 06:58:49 +0000 Message-ID: References: <1621069664-39500-1-git-send-email-humin29@huawei.com> In-Reply-To: <1621069664-39500-1-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: ca8de34a-0bb7-42a2-642c-08d919013936 x-ms-traffictypediagnostic: BY5PR12MB4068: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:431; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ir5NnhDkFX1I3IxqwV6ZtPKQb1KewBC+jFsfbz4leuH8peSmJ3QGheqal+1I6nB4eR4036+Ft2MTgTSCnha9PFnljQQomOsvv1sK+pJHBAvON1VqjV829oPzCxvD0h9IzjoVWd9JiCqoXGI8Yt1Yjt6VEp45PReddd2k+hgNzZVxsgUBTmLDxR6I3D4dY8aPJhjLPyUrmVmOC1vJVBXsCThk11OYwd8G2cp/3DeLEylctn9sJ7xoEzfOUQUoOqyWoHNVZAF6jcv8o3avG7wyOtRtPpY1Xw/RCQI66v4UXMGeuXF0wIrOw03Fl+0S5+nC3k/xsmkZ4HCzC5kN2qcz4zcChva6W46CyNkazJPoyMZMOzFfbCWHivi/gxtE28faIx0C4yDX9qO6CA9FfeM+uWX10ZUcRpywxdNcg1NlRc6P58csHjxa0V/Y8eeOzm9tc1Ag0ShCVluna+PxE0ypd1hzhZdQYfEnQBrSzlbGd4dTRzgdOvS+MzLTH//XNxGp7xgTBL9zQsJn728QgUhSfFFCa7gbLItxYbVEiO44UlYPYX5rf8pRP6rdjvj5H9vtJCmdwY+snO73UyzOjfaOtcY+ArGVCPN6vL7ob74dK7E= 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)(136003)(396003)(346002)(366004)(376002)(38100700002)(9686003)(2906002)(8676002)(76116006)(26005)(71200400001)(6506007)(110136005)(66476007)(122000001)(64756008)(186003)(83380400001)(478600001)(4326008)(53546011)(55016002)(33656002)(5660300002)(7696005)(66946007)(8936002)(86362001)(52536014)(66446008)(66556008)(316002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?o3jP4fq1x8hC5ajdGk4t5z0XYx4FyfI42/Qc3BNa4kulxbrylbvqs6pnv1Qb?= =?us-ascii?Q?izlvrH78AbNt4uiDGiGAVc0usORLsJkHgLUy3egIvE8Qk0KQ+W1TP+ALXwh3?= =?us-ascii?Q?RCZr0g/3bmADjLz0q7DTpksLpLyIdfp9LgOKFzbq8UuPFyZ9VRPCfOO1sHIU?= =?us-ascii?Q?2DETz8rStCdw0d/BIlXOpsassTRIu2qNocsO/Mi5LBqwkFV4M9BjiymUXRj0?= =?us-ascii?Q?uy8YhN0tAq96r6bQvqaMLQB1a2NtPLVKShbJMBQG6lMbuQvk5mexbhNLhY2C?= =?us-ascii?Q?Q9HXCPHOXCGHVby/Blyuswbziqc9g0o89O35GaVmPnQcLPNQFDf23iClIGNl?= =?us-ascii?Q?WmuY1GzPbGFn+qmatx7riii9NmkgzbES4QulzrHd4y2qyo8dyKtmAW1SwyAs?= =?us-ascii?Q?Oh2S1QuRANcmErbb6tuu2TLP+WkIrHi4Kg8mDpX7Xy8XqRp8+/VZ0sgA+u0o?= =?us-ascii?Q?pjUd+fwuqhEV5r1hj38+0rR4DTs76eZq9RQQ56dQ6G/WklGNdHCtAczgEKfo?= =?us-ascii?Q?RMdDRtdn1M3s6/Dygy3bil5st9jaIlhLq3m/Zi5ZZfkwZ4WGozF0duxVULzE?= =?us-ascii?Q?2AuHgTaHX2hdrT4HEWYTHuV2GzmpOuG6p+ZZ49+6mVA6JRW2zlB9K9RcTiSJ?= =?us-ascii?Q?d0htFRHoSBoLXRMjRjhT6ldpCCVlDpazTVP6yWTYohy7499le3VLV5KPWBPY?= =?us-ascii?Q?Pm4EUVG8SKGZurkpbJkQf1xfXlICaZmBmReve2Fc//VxgUDzEElzjCMTajG8?= =?us-ascii?Q?0bPXWb8yYJXwHWcghKL7GiIYO+DwJEDvu87uhTgF4AloyqI2Xe4q2HsftrCF?= =?us-ascii?Q?sjK2LlBYwzg61cbKTtypHXjGImHNHoGKRA2Te8Ko5RbEJFfg5ht6NbWxYcpX?= =?us-ascii?Q?J1Ckc9iscWFQRwsSzjdUOTlC6y85zUdFjFAUlZf5uV+ZLUakS36NqCfYi46r?= =?us-ascii?Q?zIJAiYoX1WJpnkbnlqbL+rmoryEoAzg6Bb892xC2q7AZjFIkocYoECKFXskM?= =?us-ascii?Q?TC1ehDqbQs6hQ/Z0opI/x9B87kbAh0IoqCwIT2nYH9VMJFV4bZjlNcwSeTHB?= =?us-ascii?Q?CQ8/6bhyhH8WLnQa2tHa9uGIIrm7u1ZQXG8FWKET+XCHjh+FfnxX4Z/yAgiP?= =?us-ascii?Q?r6mAE2JwUpNc91ABAktS58J+ZRS8O7Ml/TsyjHW7jgpMV1U+OXswr1TBeXfv?= =?us-ascii?Q?yLq0+XyGXJ3kYxOLpNzjWN1MpghfBGoIOQAk7m4MNRg+fUk/N+cwWrTiIL1R?= =?us-ascii?Q?7ADBA7r0qiAOKRDlXMFD2R9mbqQ9A6fc1j/Lha2uYQ8o164DYxol0mZTPuJx?= =?us-ascii?Q?Xbm+X9R/LUjGVsqvh6aEmOca?= 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: ca8de34a-0bb7-42a2-642c-08d919013936 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 May 2021 06:58:49.3341 (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: hSe1oXjl8DqzWRQsa6FBcvKTjxq2BJrJHkZj5ykuS3VRdDmLVvGqd8jBdlSyhfQgKMgQCzbVhlM/oNwAEaBERA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4068 Subject: Re: [dpdk-stable] [PATCH 20.11] net/hns3: fix setting default MAC address in bonding of VF 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" Hi Min, > -----Original Message----- > From: Min Hu (Connor) > Sent: Saturday, May 15, 2021 5:08 PM > To: stable@dpdk.org > Cc: ferruh.yigit@intel.com; Xueming(Steven) Li > Subject: [PATCH 20.11] net/hns3: fix setting default MAC address in bondi= ng of VF >=20 > From: Chengwen Feng >=20 > [ upstream commit 76a3836b98c4af6b9aaeaaa50907fe6143d31c55 ] >=20 > When start testpmd with two hns3 VFs(0000:bd:01.0, 0000:bd:01.7), and the= n execute the following commands: > testpmd> create bonded device 1 0 > testpmd> set bonding mac_addr 2 3c:12:34:56:78:9a > testpmd> add bonding slave 0 2 > testpmd> add bonding slave 1 2 > testpmd> set portmask 0x4 > testpmd> port start 2 >=20 > It will occurs the following error in a low probability: > 0000:bd:01.0 hns3_get_mbx_resp(): VF could not get mbx(3,0) > head(16) tail(15) lost(1) from PF in_irq:0 > 0000:bd:01.0 hns3vf_set_default_mac_addr(): Failed to set mac > addr(3C:**:**:**:78:9A) for vf: -62 > mac_address_slaves_update(1541) - Failed to update port Id 0 > MAC address >=20 > The problem replay: > 1. The 'port start 2' command will start slave ports and then set slave > mac address, the function call flow: bond_ethdev_start -> > mac_address_slaves_update. > 2. There are also a monitor task which running in intr thread will check > slave ports link status and update slave ports mac address, the > function call flow: bond_ethdev_slave_link_status_change_monitor -> > bond_ethdev_lsc_event_callback -> mac_address_slaves_update. > 3. Because the above step1&2 running on different threads, they may both > call drivers ops mac_addr_set which is hns3vf_set_default_mac_addr. > 4. hns3vf_set_default_mac_addr will first acquire hw.lock and then send > mailbox to PF and wait PF's response message. Note: the PF's > response is an independent message which will received in hw.cmq.crq, > the receiving operation can only performed in intr thread. > 5. So if the step1 operation hold the hw.lock and try get response > message, and step2 operation try acquire the hw.lock and so it can't > process the response message, this will lead to step1 fail. >=20 > The solution: > 1. make all threads could process the mailbox response message, which > protected by the hw.cmq.crq.lock. > 2. use the following rules to avoid deadlock: > 2.1. ensure use the correct locking sequence: hw.lock > > hw.mbx_resp.lock > hw.cmq.crq.lock. > 2.2. make sure don't acquire such as hw.lock & hw.mbx_resp.lock again > when process mailbox response message. >=20 > 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_ethdev.h | 1 - > drivers/net/hns3/hns3_ethdev_vf.c | 3 --- > drivers/net/hns3/hns3_mbx.c | 47 +++++++++------------------------= ------ > 3 files changed, 11 insertions(+), 40 deletions(-) >=20 > diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethde= v.h index 4c40df1..2065592 100644 > --- a/drivers/net/hns3/hns3_ethdev.h > +++ b/drivers/net/hns3/hns3_ethdev.h > @@ -424,7 +424,6 @@ struct hns3_hw { > struct hns3_cmq cmq; > struct hns3_mbx_resp_status mbx_resp; /* mailbox response */ > struct hns3_mbx_arq_ring arq; /* mailbox async rx queue */ > - pthread_t irq_thread_id; > struct hns3_mac mac; > unsigned int secondary_cnt; /* Number of secondary processes init'd. */ > struct hns3_tqp_stats tqp_stats; > diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_et= hdev_vf.c > index 52ad825..99275f1 100644 > --- a/drivers/net/hns3/hns3_ethdev_vf.c > +++ b/drivers/net/hns3/hns3_ethdev_vf.c > @@ -1112,9 +1112,6 @@ hns3vf_interrupt_handler(void *param) > enum hns3vf_evt_cause event_cause; > uint32_t clearval; >=20 > - if (hw->irq_thread_id =3D=3D 0) > - hw->irq_thread_id =3D pthread_self(); > - > /* Disable interrupt */ > hns3vf_disable_irq0(hw); >=20 > diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c in= dex d2a5db8..975a60b 100644 > --- a/drivers/net/hns3/hns3_mbx.c > +++ b/drivers/net/hns3/hns3_mbx.c > @@ -40,36 +40,14 @@ hns3_resp_to_errno(uint16_t resp_code) > return -EIO; > } >=20 > -static void > -hns3_poll_all_sync_msg(void) > -{ > - struct rte_eth_dev *eth_dev; > - struct hns3_adapter *adapter; > - const char *name; > - uint16_t port_id; > - > - RTE_ETH_FOREACH_DEV(port_id) { > - eth_dev =3D &rte_eth_devices[port_id]; > - name =3D eth_dev->device->driver->name; > - if (strcmp(name, "net_hns3") && strcmp(name, "net_hns3_vf")) > - continue; > - adapter =3D eth_dev->data->dev_private; > - if (!adapter || adapter->hw.adapter_state =3D=3D HNS3_NIC_CLOSED) > - continue; > - /* Synchronous msg, the mbx_resp.req_msg_data is non-zero */ > - if (adapter->hw.mbx_resp.req_msg_data) > - hns3_dev_handle_mbx_msg(&adapter->hw); > - } > -} > - > static int > hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, > uint8_t *resp_data, uint16_t resp_len) { > #define HNS3_MAX_RETRY_MS 500 > +#define HNS3_WAIT_RESP_US 100 > struct hns3_adapter *hns =3D HNS3_DEV_HW_TO_ADAPTER(hw); > struct hns3_mbx_resp_status *mbx_resp; > - bool in_irq =3D false; > uint64_t now; > uint64_t end; >=20 > @@ -96,26 +74,19 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0,= uint16_t code1, > return -EIO; > } >=20 > - /* > - * The mbox response is running on the interrupt thread. > - * Sending mbox in the interrupt thread cannot wait for the > - * response, so polling the mbox response on the irq thread. > - */ > - if (pthread_equal(hw->irq_thread_id, pthread_self())) { > - in_irq =3D true; > - hns3_poll_all_sync_msg(); > - } else { > - rte_delay_ms(HNS3_POLL_RESPONE_MS); > - } > + hns3_dev_handle_mbx_msg(hw); > + rte_delay_us(HNS3_WAIT_RESP_US); > + > now =3D get_timeofday_ms(); > } > hw->mbx_resp.req_msg_data =3D 0; > if (now >=3D end) { > hw->mbx_resp.lost++; > hns3_err(hw, > - "VF could not get mbx(%u,%u) head(%u) tail(%u) lost(%u) from PF in_i= rq:%d", > + "VF could not get mbx(%u,%u) head(%u) tail(%u) " > + "lost(%u) from PF", > code0, code1, hw->mbx_resp.head, hw->mbx_resp.tail, > - hw->mbx_resp.lost, in_irq); > + hw->mbx_resp.lost); > return -ETIME; > } > rte_io_rmb(); > @@ -365,9 +336,11 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) > uint16_t flag; > uint8_t *temp; > int i; > + rte_spinlock_lock(&hw->cmq.crq.lock); >=20 > while (!hns3_cmd_crq_empty(hw)) { > if (rte_atomic16_read(&hw->reset.disable_cmd)) > + rte_spinlock_unlock(&hw->cmq.crq.lock); > return; Seems "{ }" needed around if block, added during merge, thanks. >=20 > desc =3D &crq->desc[crq->next_to_use]; > @@ -439,4 +412,6 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) >=20 > /* Write back CMDQ_RQ header pointer, IMP need this pointer */ > hns3_write_dev(hw, HNS3_CMDQ_RX_HEAD_REG, crq->next_to_use); > + > + rte_spinlock_unlock(&hw->cmq.crq.lock); > } > -- > 2.7.4