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 6AF1545C50; Sat, 2 Nov 2024 02:00:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 45818402B7; Sat, 2 Nov 2024 02:00:37 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2077.outbound.protection.outlook.com [40.107.237.77]) by mails.dpdk.org (Postfix) with ESMTP id 8E3D74029A for ; Sat, 2 Nov 2024 02:00:35 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jHRTckERHFZsXEcnUnlTuW0N5uuSWz+1Vx8q+rluQ7OVtLZofovsqT4AfPd6Zb0g4WcJb+fRzYTSzoMSK1/nzHzFPSAuo/LNSlKj4u3zP6SEkEMCBZdyjzkdOxzAWU+1hdA32j3IpsRSQLsy5YnKqHzkYjKxxJUamqqqLpbqq/t/8fSu+avpH5NqeEKmEt0UitiasIUtvWgVlrhHmJ1vfO6lRalN1x7ArrvhwLxLl2PWjtdtM3gglVcIWqtSWmH8nB+2IL/CXC5M7kKHv5Om42NrFguSg7VJQoZXMYeHl6LONIAdyvIiWDiG4Mysm4mceLUi/IoozATMRUYAIi2DQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jhC6tJdgn/+h0+jvCfqvYDR6j6OFwrdb2pfT91roFCg=; b=fRyWDw6cAMDor6v0LvLMbrR4lPS18glBKtz046Jca4aC4hsJSR/UMdNqlrh8jinBLTgvVL6ZhaVaOnL8DeVdEYqex1ooflu6VnCKqZZ3ab8jJM0kDS3UwKcoW2Mgr7yBA3aNknpelsNrz5U2us9JDYu9V4Vbrj9zsHZBei/lxTqM2Ua/epdJ8ovC4rK4C7gEht0e+zhh2NLzevleXXin6lYFpWcjREWNoUnt/WJchEgXH/AKNj3Y7Nt/uhFyWRTjvcXrEepfucSf5BBlICmejhaC3tSwcr0DQgIao3WSuGuVatPTxAP0hGQ587p4J3H7fL30D/YZTK4eKlxsbgOFrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jhC6tJdgn/+h0+jvCfqvYDR6j6OFwrdb2pfT91roFCg=; b=mSULPlPhbNO4yVgqzyf2Qzjf863hRYN5H+amvPo+fp4H/LYwuX0/NtQ0MWSQK5NCTLlhZFAJvlmH9jN9dTsIdArAJHWT0jHo0NbKj2oZfbh+wsuC0x3xquENiDwrci/qN4inu5Jh916lUAV0vgg1v7mgsKpH6YSAgAVVvpRN8TM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from SJ2PR12MB8830.namprd12.prod.outlook.com (2603:10b6:a03:4d0::9) by SA1PR12MB8920.namprd12.prod.outlook.com (2603:10b6:806:38e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.23; Sat, 2 Nov 2024 01:00:32 +0000 Received: from SJ2PR12MB8830.namprd12.prod.outlook.com ([fe80::c3eb:df02:eaa9:2055]) by SJ2PR12MB8830.namprd12.prod.outlook.com ([fe80::c3eb:df02:eaa9:2055%4]) with mapi id 15.20.8114.015; Sat, 2 Nov 2024 01:00:32 +0000 Message-ID: <1963a820-ad6c-4536-944f-e3da8ee8d4e0@amd.com> Date: Sat, 2 Nov 2024 01:00:26 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 4/9] net/zxdh: add msg chan and msg hwlock init To: Junlong Wang , dev@dpdk.org Cc: wang.yong19@zte.com.cn References: <20241030090124.2540776-2-wang.junlong1@zte.com.cn> <20241101062156.2637339-1-wang.junlong1@zte.com.cn> <20241101062156.2637339-5-wang.junlong1@zte.com.cn> Content-Language: en-US From: Ferruh Yigit In-Reply-To: <20241101062156.2637339-5-wang.junlong1@zte.com.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO2P265CA0413.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::17) To SN7PR12MB8818.namprd12.prod.outlook.com (2603:10b6:806:34b::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ2PR12MB8830:EE_|SA1PR12MB8920:EE_ X-MS-Office365-Filtering-Correlation-Id: 951557a5-5a69-432b-0bab-08dcfad9bfdc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?cHB4T0pmeTBJbWxjcDc3SEs2eHNKZDBsYU1MeFBUb0pZUWFoMk1HR1VzTURU?= =?utf-8?B?NGNFK2Z6TTFMTHYyL2FXaFl2N2JEZGdlMUR4QnhwY240UElHMUV2a2pwVmxJ?= =?utf-8?B?Z0JxcjZxaU5pM28zVHNXbWxESEtxWTdwQ0JtZi8wTjRnVzc2NFlvZFgxdVdN?= =?utf-8?B?Rm5BbVlTekxyOTllTnFMV283OVAyclhtcThQOCsxNXFPT2lmZHd0Z0xya1hS?= =?utf-8?B?a056bTlDZ3BhSW1iL3J3enlmL3dIbW1WS1RTUVJPTHpyR0g0Vkl2S3dVYTJK?= =?utf-8?B?QzdWaWFlWExaZ01VeWlhTkU1U1F3eEFPS0tuYXVyclF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VVvVGRwM200bkEyUXV1cFhDdmRiWEl0?= =?utf-8?B?MUxNQ3V2RE1rMkVWaUMzWDRBM0pVYXY1R3ZtRjJEZExRcjEvdEU0cWIrNTkx?= =?utf-8?B?c21nS0ZQL3hQenViWjJRNGxrY1kxcUVUQnBDY1lTcXNNM1hOVWFwMjJ4MEtR?= =?utf-8?B?ZnNDSDN5YzN5S0hHTXlGWHhIalVaWk56ZFV3eVVnZmM3Z3psdVhJZElwMG5p?= =?utf-8?B?K1FTSllVNVlaMHRjSUxDUjdJZUhWbm9Fc2VSS3BXVDFLbHROUXVxTnRLcjBa?= =?utf-8?B?UE13bmwwc0xoSTg2S1k0RDB1YXZWbnpHditlYUFDbElEUjNnWGJyQmlRQndW?= =?utf-8?B?L2diMUtvUXQrNm1qazlMWjNVNUdKTWhvZ0Y1YnVzYlZjMm5XV3RPOGdXQ2FH?= =?utf-8?B?MjMvcWpjdnowemxUR01IejhscFRBTVlETDM5RGVtSm82WjA1ZFVsV3NHQVEx?= =?utf-8?B?ZVNsNVhTZHZuc2N1RWxVUUpmSW4wV1lZOGZGcXcwNHNXWEl2UG9ZWXVQckhH?= =?utf-8?Q?eet++QhYZzCz9QNg6roXm+LCqkrf1/md65ni9Pr?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ2PR12MB8830.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d0FCdTBxU2dzNWpuVDlxbmxUSmFPTFpzM01jUnBSc3dMak1pYncyMFJWa0Jh?= =?utf-8?B?WDJKSzlBbWRHajhDZS9GSFdDbktZdThWYUEvQXV6N1lsR0hSQjBkT3Vza3I0?= =?utf-8?B?NENWYmNxelA1RGl6RVdKcy8vMXpZdGY1SGpYQU10Ylpj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WmFMWVFLYVMxMGRNeHVCdmlwZTBQbDVKVzFkTzd5cUE4R1NOSmNIMDNPUVVt?= =?utf-8?B?ZkloUnhLTWdOVzRzd2FySEZzZi9ocDJpN29pUXRldWk2cWJiYjMxQzdUSmdU?= =?utf-8?B?R0NRV0hFNlk3MkplQ3JEMmNtTmpYM21QSERJR3QzbkZuVEhkQjZHa1J2U0I3?= =?utf-8?Q?jaya+5kr2SAq5NtSGHats4uaF?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 951557a5-5a69-432b-0bab-08dcfad9bfdc X-MS-Exchange-CrossTenant-AuthSource: SN7PR12MB8818.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2024 01:00:32.8291 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uoeDxTEyV5cTb4oS7SakmztEiWfDMw+BPo339yOoM2fQ1lTsVVCKeRmTsBieV6+I X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8920 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 11/1/2024 6:21 AM, Junlong Wang wrote: > Add msg channel and hwlock init implementation. > > Signed-off-by: Junlong Wang  > <...> > @@ -83,9 +84,23 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev) >      if (ret < 0) >          goto err_zxdh_init; >   > +    ret = zxdh_msg_chan_init(); > +    if (ret != 0) { > +        PMD_INIT_LOG(ERR, "Failed to init bar msg chan"); > +        goto err_zxdh_init; > +    } > +    hw->msg_chan_init = 1; > + > +    ret = zxdh_msg_chan_hwlock_init(eth_dev); > +    if (ret != 0) { > +        PMD_INIT_LOG(ERR, "zxdh_msg_chan_hwlock_init failed ret %d", ret); > +        goto err_zxdh_init; > +    } > + >      return ret; >   >  err_zxdh_init: > +    zxdh_bar_msg_chan_exit(); > Should 'zxdh_bar_msg_chan_exit()' called during zxdh_eth_dev_uninit()? <...> > + > +struct zxdh_dev_stat { > +    bool is_mpf_scanned; > +    bool is_res_init; > +    int16_t dev_cnt; /* probe cnt */ > +}; > +struct zxdh_dev_stat g_dev_stat = {0}; > Is there a reason to not make this global variable 'static'? Please remember, when a DPDK application compiled, this will be all application and other driver and libraries, if there is really a good reason, please keep all global variables in the scope of driver. And no need to initialize global variable to 0, that is done by default. > + > +struct zxdh_seqid_item { > +    void *reps_addr; > +    uint16_t id; > +    uint16_t buffer_len; > +    uint16_t flag; > +}; > + > +struct zxdh_seqid_ring { > +    uint16_t cur_id; > +    rte_spinlock_t lock; > +    struct zxdh_seqid_item reps_info_tbl[ZXDH_BAR_SEQID_NUM_MAX]; > +}; > +struct zxdh_seqid_ring g_seqid_ring = {0}; > + ditto <...> > +/** > + * Fun: PF init hard_spinlock addr > + */ > +static int bar_chan_pf_init_spinlock(uint16_t pcie_id, uint64_t bar_base_addr) > +{ > +    int lock_id = pcie_id_to_hard_lock(pcie_id, ZXDH_MSG_CHAN_END_RISC); > + > +    zxdh_spinlock_unlock(lock_id, bar_base_addr + ZXDH_BAR0_SPINLOCK_OFFSET, > +            bar_base_addr + ZXDH_HW_LABEL_OFFSET); > +    lock_id = pcie_id_to_hard_lock(pcie_id, ZXDH_MSG_CHAN_END_VF); > +    zxdh_spinlock_unlock(lock_id, bar_base_addr + ZXDH_BAR0_SPINLOCK_OFFSET, > +            bar_base_addr + ZXDH_HW_LABEL_OFFSET); > +    return 0; > +} > + > +int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev) > +{ > +    struct zxdh_hw *hw = dev->data->dev_private; > + > +    if (!hw->is_pf) > +        return 0; > +    return bar_chan_pf_init_spinlock(hw->pcie_id, (uint64_t)(hw- >>bar_addr[ZXDH_BAR0_INDEX])); > +} > + > +static rte_spinlock_t chan_lock; > please move global variables to the top of the file, otherwise it is very easy to miss them.