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 4B74B42B94; Thu, 25 May 2023 05:58:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D358340DDB; Thu, 25 May 2023 05:58:54 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 86E6B40A82 for ; Thu, 25 May 2023 05:58:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684987132; x=1716523132; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=buV56FlmaJpTlwKP69uWgBkkvCVuR7eN2hVVuR7+pjo=; b=gJuqpGwYIKa8kSQ3DzAoTMEYEsAJYIlnNWSxpD6gMiwLFArcuGtybtez SuL4NcvvHD9soIRP0xcMRl2t6kW5kTAAEg05xuiKCXw2o/6GwjKn0nHhi CZRuXaog4Ve1bx+6YAA04wRush72hBzXWFJ82WnLak7OJBZhTib2+L+B1 Dv8jstsxRsfisBFzL3K96bRY+tzfmpqU7dM5XDwJnlPkNWRojmEOyr8zG rDAXsVszJqIOfArWnsyHzZwpHqE2X9eV4V8elnrD5+7AEUyXqRP6QeVEW pweJXWIiowv/+Q5NcOzyln1uMhpYaCLD5+0oWmsBU3K4vvfEdhJNIIaH0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="417237609" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="417237609" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 20:58:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="774504074" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="774504074" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga004.fm.intel.com with ESMTP; 24 May 2023 20:58:51 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 24 May 2023 20:58:50 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Wed, 24 May 2023 20:58:50 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.43) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Wed, 24 May 2023 20:58:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h0KzG9RZi7M5AKM39jUplMtNzsZXSvRoqDGUcAbt9kX6ENKJdUBp4Qu0wONseQCmG13ojXVvV2duIuWet21LJn33x3ejoRzx3BoVDlY4q7kzCinNGPkiWdH9PLzfdLE63E2yO+Uy5P0nRLbH2JAfCmGDhxOTqtLi2OgZXIVkl5ywD2bGws2fKBove9saLLTM93x5KvRbziFwugLiFZEh3GoZZ7el9GUHAOzKwq6AzDSHwZa/P1VQf1lQbKqiRPaR1hybKKUL+sD2VFXAHZJNCf/sg0RA/p/68kAKTE3nnaxEIbFrUiagebfkphwCsPUiniAUlV2upuZQ4FbURraUYg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xr7yYexCKYFp4wQZIL18X0k9fi340BXJbEoTby4hBfE=; b=IgSz8OSfrQYlu17VlncuO691Q3Hd/ewvZijX4x6Ujd4kNgG4v78IwDKQ3CEk9WnFUmkJolicrpno3QCu3yaToDE0ZJGCOSMXUeB4gRpppVPmcFgnoG9La3+4sBOor1qhDOXRMD5OtwIVkaO9Vqbocs1awyUYyXJ8oYiFpoZBa/+XyFTkOCsBn7oLR3HG7XQs1oy/iBmxEEF6anBHhfDVsVE/pV80Vo0MwC5lL/smYaWA2Cr+zotiqI2NxRYgfyvgmh1OPCyZg3bND8xCn+BT/J4Dg0fDSKgwDEkexsnQJ4cyrG2HhImb36R4/VRdqfvt5+7h4Zgxvt5ejeVtoVHG6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MW3PR11MB4587.namprd11.prod.outlook.com (2603:10b6:303:58::7) by SA0PR11MB4733.namprd11.prod.outlook.com (2603:10b6:806:9a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.15; Thu, 25 May 2023 03:58:49 +0000 Received: from MW3PR11MB4587.namprd11.prod.outlook.com ([fe80::5666:142:4f22:1a30]) by MW3PR11MB4587.namprd11.prod.outlook.com ([fe80::5666:142:4f22:1a30%7]) with mapi id 15.20.6433.015; Thu, 25 May 2023 03:58:48 +0000 From: "Wu, Jingjing" To: "Xing, Beilei" CC: "dev@dpdk.org" , "Liu, Mingxia" , "Wang, Xiao W" Subject: RE: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and release Thread-Topic: [PATCH v3 05/10] net/cpfl: support hairpin queue setup and release Thread-Index: AQHZiidMYmr0EZo5j0iDh6wNj3qKK69qYgMg Date: Thu, 25 May 2023 03:58:48 +0000 Message-ID: References: <20230519051055.106893-1-beilei.xing@intel.com> <20230519073116.56749-1-beilei.xing@intel.com> <20230519073116.56749-6-beilei.xing@intel.com> In-Reply-To: <20230519073116.56749-6-beilei.xing@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW3PR11MB4587:EE_|SA0PR11MB4733:EE_ x-ms-office365-filtering-correlation-id: 5ce2ea6a-5e25-4213-46ac-08db5cd45869 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9vvfrGKNGbBddSs8BhMVhTDk7O9pZ2UdUEqNE1hhROmJ+JD+5y7n+TttdannWH+XYVtHk4sfxkvDmQild/chSGMPfkPNLD07Sds8gzLm26KfLhuVlKMIqrVthd2L0job2vDxFJDNnU7GYuvf7zBZ69/X56uYC39lqlXyx+JcSrni1zk0Y83XwoIztp0orXujD63iuWFflzjjNM98DBph0WPPlEs9NvkmgE6IXRc1jxlABwmS5e4LQi+Wr8+7HrCAgk3BmizpNU66mgl6ZJyRVSCSGRK3nhVpobpIPBSd78zYlJUp4w6ZpkQYcxn0z7B82cT+X3u0PMIj6KF/SxyueJWX9LvTpPCBSoMzOH4phg/Omf39nUUOziGoploLakRGTqfq3/uPvQDemh4/OBEtal8LluY9R72L190zIvcW6lRyFxRWTUlhs0hljHie/DGunSge5avZDMWW114mUdf8fV0T9BKZSdQZ/9FhmLHa7+uW22UrhxvJtKWv+7374xASpuz114yi2NcG63jS9WR9Llxy1eJ7v1fZZdy1eQFdrRHeSLrjRAvmbFN+f0eJRBjzzqX+d0HzR6CAW0dRrqXVKznZ0atZUXyX/4tAwETey9pzadVzIypjVEgyHg03Sbwb x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW3PR11MB4587.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(366004)(346002)(376002)(396003)(39860400002)(136003)(451199021)(8676002)(6862004)(8936002)(52536014)(5660300002)(186003)(107886003)(6506007)(38100700002)(9686003)(86362001)(122000001)(82960400001)(38070700005)(6636002)(41300700001)(76116006)(55016003)(7696005)(33656002)(71200400001)(64756008)(66446008)(66476007)(66556008)(4326008)(316002)(66946007)(478600001)(54906003)(2906002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?LqdL3jVEF6WyWwu7dkn/CY9vQBV8TBdjPNIeaJQxzDI93AbLiSGZt5WpDQtU?= =?us-ascii?Q?pzg6u9AWQVMk6sjDoFSi9VYjHU4ZSFJjji/ZDuXadvKo/YDMDeryzXja5wu4?= =?us-ascii?Q?uxX0ONA/ok7CVHTCW16gMrvfqYKpCC43LEIBoHzoHseNOAnenOW278ZzU0fN?= =?us-ascii?Q?Eb+Bjt+gmd8x0PGvVVBZIynByNkJNtjPH+ypNL4ZQfoAjiUzLGdhVvNeLR2M?= =?us-ascii?Q?bNcG46CHoDe1VnSQ/Ic74yINyARx6F1jj6n68ZmcxaCYcetiCPTaX82Q/vkP?= =?us-ascii?Q?8seTCYACUW1rusEHRP75Pl6u1gPJIP2aHZIvr3mr1ayruTUha4tUZaSChK/E?= =?us-ascii?Q?LF5Y4WzPAzcVux4R5TUzHHaRDjUaZo4bIDLgfa0vDkwPqpf/l6r07GHzrVPA?= =?us-ascii?Q?AzZg4wcqWmERXdGC+rbSmPuQEBHg/5IWwaXnWooUlD9jg7YTtOOTqOHk/93v?= =?us-ascii?Q?vAAXhgssVqKfkeTyOrr/jR9hobIQC5S3fzR21qjVF0dYLUfYEYM59CWOJ53U?= =?us-ascii?Q?+1gegWFcLRPKLF4pIh+fEvHmG0h36WJBUGxFJuCr3r+AAbFf722pk/ry3qjv?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xKA4yrLZa2N2cXMgNsGiww7dsAGaay7Ld?= =?us-ascii?Q?tbMFDQgD4goNDwVmduiWRiA8DBAkJJVCIQpz1F4jv9nOEOV4b0n5R/q7ORoa?= =?us-ascii?Q?WN1MoI66rf4yHGLBqlDaU+kRGEdMuacTgaUaqNStKi8OnT5y68Tig231om+s?= =?us-ascii?Q?CjQ1ShEio34e4PCeGwngoPrBwJiyEVC/+QU7Thpqe1+X?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4587.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ce2ea6a-5e25-4213-46ac-08db5cd45869 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 May 2023 03:58:48.8571 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: KJanm+l/uh4qBptqSjfal+chlaAu8P8goSew06MSMjiN/rUx5AQiGH9ICNyB14W2WavhCeI+oDmezYx+T+mmEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4733 X-OriginatorOrg: intel.com 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 >=20 > +static int > +cpfl_rx_hairpin_bufq_setup(struct rte_eth_dev *dev, struct idpf_rx_queue= *bufq, > + uint16_t logic_qid, uint16_t nb_desc) > +{ > + struct cpfl_vport *cpfl_vport =3D > + (struct cpfl_vport *)dev->data->dev_private; > + struct idpf_vport *vport =3D &cpfl_vport->base; > + struct idpf_adapter *adapter =3D vport->adapter; > + struct rte_mempool *mp; > + char pool_name[RTE_MEMPOOL_NAMESIZE]; > + > + mp =3D cpfl_vport->p2p_mp; > + if (!mp) { > + snprintf(pool_name, RTE_MEMPOOL_NAMESIZE, "p2p_mb_pool_%u", > + dev->data->port_id); > + mp =3D rte_pktmbuf_pool_create(pool_name, CPFL_P2P_NB_MBUF, > CPFL_P2P_CACHE_SIZE, > + 0, CPFL_P2P_MBUF_SIZE, dev->device- > >numa_node); > + if (!mp) { > + PMD_INIT_LOG(ERR, "Failed to allocate mbuf pool for p2p"); > + return -ENOMEM; > + } > + cpfl_vport->p2p_mp =3D mp; > + } > + > + bufq->mp =3D mp; > + bufq->nb_rx_desc =3D nb_desc; > + bufq->queue_id =3D cpfl_hw_qid_get(cpfl_vport- > >p2p_q_chunks_info.rx_buf_start_qid, logic_qid); > + bufq->port_id =3D dev->data->port_id; > + bufq->adapter =3D adapter; > + bufq->rx_buf_len =3D CPFL_P2P_MBUF_SIZE - RTE_PKTMBUF_HEADROOM; > + > + bufq->sw_ring =3D rte_zmalloc("sw ring", > + sizeof(struct rte_mbuf *) * nb_desc, > + RTE_CACHE_LINE_SIZE); Is sw_ring required in p2p case? It has been never used right? Please also check the sw_ring in tx queue. > + if (!bufq->sw_ring) { > + PMD_INIT_LOG(ERR, "Failed to allocate memory for SW ring"); > + return -ENOMEM; > + } > + > + bufq->q_set =3D true; > + bufq->ops =3D &def_rxq_ops; > + > + return 0; > +} > + > +int > +cpfl_rx_hairpin_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, > + uint16_t nb_desc, > + const struct rte_eth_hairpin_conf *conf) > +{ > + struct cpfl_vport *cpfl_vport =3D (struct cpfl_vport *)dev->data->dev_p= rivate; > + struct idpf_vport *vport =3D &cpfl_vport->base; > + struct idpf_adapter *adapter_base =3D vport->adapter; > + uint16_t logic_qid =3D cpfl_vport->nb_p2p_rxq; > + struct cpfl_rxq_hairpin_info *hairpin_info; > + struct cpfl_rx_queue *cpfl_rxq; > + struct idpf_rx_queue *bufq1 =3D NULL; > + struct idpf_rx_queue *rxq; > + uint16_t peer_port, peer_q; > + uint16_t qid; > + int ret; > + > + if (vport->rxq_model =3D=3D VIRTCHNL2_QUEUE_MODEL_SINGLE) { > + PMD_INIT_LOG(ERR, "Only spilt queue model supports hairpin queue."); > + return -EINVAL; > + } > + > + if (conf->peer_count !=3D 1) { > + PMD_INIT_LOG(ERR, "Can't support Rx hairpin queue peer count %d", > conf->peer_count); > + return -EINVAL; > + } > + > + peer_port =3D conf->peers[0].port; > + peer_q =3D conf->peers[0].queue; > + > + if (nb_desc % CPFL_ALIGN_RING_DESC !=3D 0 || > + nb_desc > CPFL_MAX_RING_DESC || > + nb_desc < CPFL_MIN_RING_DESC) { > + PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors is invalid", > nb_desc); > + return -EINVAL; > + } > + > + /* Free memory if needed */ > + if (dev->data->rx_queues[queue_idx]) { > + cpfl_rx_queue_release(dev->data->rx_queues[queue_idx]); > + dev->data->rx_queues[queue_idx] =3D NULL; > + } > + > + /* Setup Rx description queue */ > + cpfl_rxq =3D rte_zmalloc_socket("cpfl hairpin rxq", > + sizeof(struct cpfl_rx_queue), > + RTE_CACHE_LINE_SIZE, > + SOCKET_ID_ANY); > + if (!cpfl_rxq) { > + PMD_INIT_LOG(ERR, "Failed to allocate memory for rx queue data > structure"); > + return -ENOMEM; > + } > + > + rxq =3D &cpfl_rxq->base; > + hairpin_info =3D &cpfl_rxq->hairpin_info; > + rxq->nb_rx_desc =3D nb_desc * 2; > + rxq->queue_id =3D cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info.rx_star= t_qid, > logic_qid); > + rxq->port_id =3D dev->data->port_id; > + rxq->adapter =3D adapter_base; > + rxq->rx_buf_len =3D CPFL_P2P_MBUF_SIZE - RTE_PKTMBUF_HEADROOM; > + hairpin_info->hairpin_q =3D true; > + hairpin_info->peer_txp =3D peer_port; > + hairpin_info->peer_txq_id =3D peer_q; > + > + if (conf->manual_bind !=3D 0) > + cpfl_vport->p2p_manual_bind =3D true; > + else > + cpfl_vport->p2p_manual_bind =3D false; > + > + /* setup 1 Rx buffer queue for the 1st hairpin rxq */ > + if (logic_qid =3D=3D 0) { > + bufq1 =3D rte_zmalloc_socket("hairpin rx bufq1", > + sizeof(struct idpf_rx_queue), > + RTE_CACHE_LINE_SIZE, > + SOCKET_ID_ANY); > + if (!bufq1) { > + PMD_INIT_LOG(ERR, "Failed to allocate memory for hairpin Rx > buffer queue 1."); > + ret =3D -ENOMEM; > + goto err_alloc_bufq1; > + } > + qid =3D 2 * logic_qid; Inside the brace ( if (logic_qid=3D0) {} ), the logic_qid should be zero, r= ight? What is the purpose of doing qid =3D 2* logic_qid? > + ret =3D cpfl_rx_hairpin_bufq_setup(dev, bufq1, qid, nb_desc); > + if (ret) { > + PMD_INIT_LOG(ERR, "Failed to setup hairpin Rx buffer queue 1"); > + ret =3D -EINVAL; > + goto err_setup_bufq1; > + } > + cpfl_vport->p2p_rx_bufq =3D bufq1; > + } > + > + rxq->bufq1 =3D cpfl_vport->p2p_rx_bufq; > + rxq->bufq2 =3D NULL; > + cpfl_vport->p2p_rx_bufq is allocated in this function. But haven't seen whe= re it will be released. And in cpfl_rx_hairpin_bufq_reset the rxq->bufq1 will be assigned to NULL. = Will queue release miss this? > + cpfl_vport->nb_p2p_rxq++; > + rxq->q_set =3D true; > + dev->data->rx_queues[queue_idx] =3D cpfl_rxq; > + > + return 0; > + > +err_setup_bufq1: > + rte_free(bufq1); > +err_alloc_bufq1: > + rte_free(rxq); > + > + return ret; > +} > +