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 28359A0548; Fri, 12 Feb 2021 12:04:07 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9736D22A24C; Fri, 12 Feb 2021 12:04:06 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id EBE0B22A233 for ; Fri, 12 Feb 2021 12:04:04 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11CB0Hov010428; Fri, 12 Feb 2021 03:04:04 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0220; bh=B7ZyMGBwatAV/18Xe5jZNrLmEe5vN79rMZBYl2gFTh4=; b=XdEgP7LcPAbDyDcHybe5XXiV1pwooGNvS7NHV+A/KXoUKQzBTZSNJ5W+wibdhIg9yHhQ 1RRhar1BsCLTu9XFPF/focjeE9kSdxhCvtfsEoeOFJpVc5AtIAm5uOkiLGyABkdLgUzd l7WIlXLEqoO2uEVpuJs0wHJntmNmC8cbYsVbKgFRVXKh/Ah1VTNCo1RQKN28JFW308xk p2YUXItaTbl54ZJedGtuYsIEijJtH/FVqDSDiiALvCgSMJNV69gntNa2F47bOVO63nnA 9fjBukFGq1JeGprNxg/r4dvT+uv9CkqQNlajFrVcK2wSJK/IAhlC26alUnSsXoWVd301 6w== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 36hsbrtdw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 12 Feb 2021 03:04:03 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 12 Feb 2021 03:04:02 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 12 Feb 2021 03:04:01 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.102) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 12 Feb 2021 03:04:01 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=do52GTBJv6TUzPIEE8DOavtk2WhKwPyIaocTmk/nYZxkmKMCe9zuI6np4Gn8m1kHXd7enIxcJD5pPWopPMsCKNngQYOtdxWG3AnXnrjHGRd2V2Jp5rBcXs9GlSSQaV9oxcM9ITDfI1sxXar2UufsgD2oqi9Itq5ZXR6GjAreATBHQ7fr76QYWqjeCP3b7De2JLE+9BHu6FZM6CBfCL8ni2N78UO4QFN75zYnGs/rCtL6C9OrBtHKLco1F3IYybo6V/Ody4AHSq4XWE786V63DTw5rj5V4y0rgc/FBK7jsIO2kfpOM99H93thWG3QHADKLXDKRybzb5pHYgUrQa+V2g== 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=B7ZyMGBwatAV/18Xe5jZNrLmEe5vN79rMZBYl2gFTh4=; b=LI4QLL3sAIjdi1hG0KDLRk7Z9xAvltX5MtFNuvMc7oGHgarhw/aIs7oR2x1mY/hfur4jBWdNsftWg/zUocyXAkLflhmwaRxdx0R+P6fdI5MWQTf79yQfeZJi3FIWcz7EsstGlBZXh/B9LjhPZqO6w5Xs44t/VovGjauaTPlbDS2FmkKwtKUUrxxDr87MoVhHP+v6CtJ3N69vlUsoOc6YjZgnJcDa6fBAybHPumVlVFVFGlDxnBYf/XWQG4sNRMEelKfxI18YWepSmHEHLj4UgUC5DzFwia9qXtGdRvf7Ah6ks76K4LKIyO+Cl9AJYP7bNTW31oPxGSjr2mDslo2Erg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B7ZyMGBwatAV/18Xe5jZNrLmEe5vN79rMZBYl2gFTh4=; b=gSSRxxLtZKTTNJy0cgWlX2MsUgGNCk5lAfWvGxqSZR1ClvBHw03HyGWGQetmia87CChVTD/7H5F5q4z9gWx2dvoaD46k3UQdKsCd2VdBFcA3Nil8s2aCoOsGvo91jgz+Gutg7+hGhba1gFmvGIlLWPysKaq5mdyqvfHdiG2+bHo= Received: from CO6PR18MB3828.namprd18.prod.outlook.com (2603:10b6:5:346::20) by MW3PR18MB3561.namprd18.prod.outlook.com (2603:10b6:303:2e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Fri, 12 Feb 2021 11:04:00 +0000 Received: from CO6PR18MB3828.namprd18.prod.outlook.com ([fe80::5c2c:a13a:4f3d:94df]) by CO6PR18MB3828.namprd18.prod.outlook.com ([fe80::5c2c:a13a:4f3d:94df%5]) with mapi id 15.20.3846.031; Fri, 12 Feb 2021 11:04:00 +0000 From: Pavan Nikhilesh Bhagavatula To: Shijith Thotton , Erik Gabriel Carrillo CC: Shijith Thotton , Jerin Jacob Kollanukkaran , "dev@dpdk.org" Thread-Topic: [RFC PATCH] eventdev: use shared memory to store timer adapter Thread-Index: AQHXASfFsJAXE9c5xUu7DKVns9EE16pUVssQ Date: Fri, 12 Feb 2021 11:03:59 +0000 Message-ID: References: <20210212101343.689792-1-sthotton@marvell.com> In-Reply-To: <20210212101343.689792-1-sthotton@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2405:201:d009:380f:4d89:c26a:c6e6:7be2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 723426be-5463-494d-f725-08d8cf45e6a3 x-ms-traffictypediagnostic: MW3PR18MB3561: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Dtb4EZK/Wfmv+/J8wjO18PkVuh+EfUGlmxgLfBSI19bV/CGDntVz8dqwkzli+vEm6lgWOsfzjnN9G47jt+MG9o7PYG04K0e06MLLJddfSN7nI8GQYIN6XY4VV13reSSGbu8CQrcx0nqAXqnEUBjeIFoR8YU4hCFQYseYzaqZhj3MBim7fXn+lYN3diAWN1fxQzIv8VvMhJVIi0tGVqmuWN7UgUJUiM+EPtquYYHRwObnLV1Q4CwdUP1UCRcskP/fk53m9ZiouV6aXrGs50v7pipTSGplkUZMfGdTCkMwKhTQ5YajmAFoc/bxacc7skRJ+gJASS7pfJjhdXrIrNqeXo5uO6iLXvl0DBfiSiWtOR0GMWMXJTTOfim2ScW6creoLZrs8oEcCCwD5QN1/wQFCk1DOUGBLNiajU1NnKa4IvQLwvtp2q0WHSCywmC8pRMRoMUyrJ+5VKqW4BnA41ov5EAKbKmYXhAmTF+RP+VRz9dRWI2FesVNYdMsv1YIIXTRV0wgWV6OY0Wkojtpc87VtQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR18MB3828.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39850400004)(136003)(396003)(376002)(366004)(346002)(9686003)(55016002)(8936002)(7696005)(186003)(6506007)(316002)(66556008)(64756008)(66446008)(5660300002)(66476007)(83380400001)(52536014)(478600001)(86362001)(54906003)(66946007)(4326008)(2906002)(110136005)(33656002)(8676002)(71200400001)(76116006)(30864003)(579004); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?OBMa0f2pG9sbra71SV4Y1Op3KDrJVkjypK92Kc76SBTPwhnfzR3OP1M79OSQ?= =?us-ascii?Q?fS82ksACg9ujTaxAZNUpycR3uAvCKGJRTAp1lu6fFpJ3wPPNpZSNjav9Qp+W?= =?us-ascii?Q?5pw6ZhRCSha7j+hN/n6RFedf740CtAmXtjrJv7d6Lk1XX99P6Tc4pD7O5zJG?= =?us-ascii?Q?gWvOy+N9OfNreiTjCZbFXvMJB3IVUgNcD9sO7/iQRuWMdD7IRHsjgJraIm7e?= =?us-ascii?Q?CSm1J8sa94Gm00SykWNYHQevXtU5F3fvgVJqQLVlDu10XFpB0vrHPeDb4B0u?= =?us-ascii?Q?eEzwfLSv9XzS3afGUMjVWWvBIwyYHC9Sb2z1VuBytrn/Rml4CJfKZivN8Aiv?= =?us-ascii?Q?YNRxAvmngvhHfArk9dzroq4pxydES1zr7sA2Fz5q1H/Pl7bG6yiHMN+kkx18?= =?us-ascii?Q?+uMMJoUZJs9lkbHYj/PPihJMOezi7+3ezuwTTiIRko/yfqHo1fR91z9HTz72?= =?us-ascii?Q?VKf8mnSz+EPiRmDoJ3VzHrVOVBvkLBCKJ+HU8TyKJ0fjnf9+LYzdGpezrZJ/?= =?us-ascii?Q?9TkVRbMH3orDV7Wt5v0ws4pDnFgjcuSZ3nhOSmGhD+Kk/F640mbwnvRc8Nvc?= =?us-ascii?Q?o3/3iipO3fEoC9mluI2hZrJy6ZrCWb3TUnEpsUZsG/iODaz4JXNkWb09HV/O?= =?us-ascii?Q?6qnXLFj5ZKPyc4ylupsyj+e2NhOY6BjEzlhP6iGgdFleb+5/H85vBowKSgYf?= =?us-ascii?Q?50svxxIs0XE1QoAh5CZ8oBDAk+rhpHfUl4nHVp+bdryyDz7j+EZCJbq2k2Lz?= =?us-ascii?Q?Gonu8DN/cyxllR3icu85bQjIo12XKX/b892DAfPEirM+XHBKD0pZOl5fxh5Y?= =?us-ascii?Q?SfnSDxvIQ3zqg/fu4SBfqKOmgaYwDLwpFmy0TTpb0IWAiOShF6pYAxcRj0Fk?= =?us-ascii?Q?G2DeZXsKrpxXx/zgwGoNaJWb4p1CSkwXVSq4YMzdA3YofB5b+bndos5w5d2D?= =?us-ascii?Q?dGLvGkUnTft/Zl/SdgY2kOQ4J7Z38EL1N1yB8kT1IPuplowjHFd/uYvaUq+N?= =?us-ascii?Q?QNJbHFWNzWU2YBN4t7oOTa2Hq5fq373kIOwYSQXBt3UPaSOpCXKILhekuvlv?= =?us-ascii?Q?diUyveKj8fMlkVq3UDwI/L4AxYg65+kx89w579kOHy9ym7Ke8/qkFREFCebm?= =?us-ascii?Q?Fjyk3+3kaocWUfqFeHf58qeFbu+NP38C2u6d30EUs60g+azrDeNqoGk3vsH1?= =?us-ascii?Q?N1W/Y3iBGJ0dRrmnPaWmiJ6QCgU5HZI1MgsKYt8iBVoyrVNRwgENkZ6YMkFg?= =?us-ascii?Q?IFg7F4cJx03fIesiwS25QmN2Jb9XOkssLnhQGVDaloqzdeLBnodWe9Um2REP?= =?us-ascii?Q?6ASVePBXEdKzjf0Tiu2SNR0X1M+oW1EZtBXQAodfj9PXI8+9kcIghc9Zeib7?= =?us-ascii?Q?sJpe205MKj6cG+tpAhrvzgm43ApY?= 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: CO6PR18MB3828.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 723426be-5463-494d-f725-08d8cf45e6a3 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Feb 2021 11:03:59.9903 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 75v/+X00lq6l1msOQEdOb2yR4ROxn3tfERnhxp0lXPmk4nUFWkTOjmaGBtQZaG54CawZJvXt0zExa8cOFaV4EEgXy8QRRD7z+HxdyopAtDc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR18MB3561 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.737 definitions=2021-02-12_04:2021-02-12, 2021-02-12 signatures=0 Subject: Re: [dpdk-dev] [RFC PATCH] eventdev: use shared memory to store timer adapter 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 Sender: "dev" >-----Original Message----- >From: Shijith Thotton >Sent: Friday, February 12, 2021 3:44 PM >To: Erik Gabriel Carrillo >Cc: Shijith Thotton ; Pavan Nikhilesh >Bhagavatula ; Jerin Jacob Kollanukkaran >; dev@dpdk.org >Subject: [RFC PATCH] eventdev: use shared memory to store timer >adapter > >It is not possible for secondary process to arm timer as timer adapter >is not stored in shared memory. Using shared memory allows the >secondary >to lookup adapters and arm them. > >Signed-off-by: Shijith Thotton >--- > drivers/event/octeontx/timvf_evdev.c | 20 +- > drivers/event/octeontx/timvf_worker.c | 12 +- > drivers/event/octeontx2/otx2_tim_evdev.c | 28 +-- > drivers/event/octeontx2/otx2_tim_worker.c | 4 +- > lib/librte_eventdev/rte_event_timer_adapter.c | 193 ++++++++++------ >-- > lib/librte_eventdev/rte_event_timer_adapter.h | 58 ++++-- > .../rte_event_timer_adapter_pmd.h | 31 --- > 7 files changed, 186 insertions(+), 160 deletions(-) > >diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c >b/lib/librte_eventdev/rte_event_timer_adapter.c >index dd7b83087..682b1c3c2 100644 >--- a/lib/librte_eventdev/rte_event_timer_adapter.c >+++ b/lib/librte_eventdev/rte_event_timer_adapter.c >@@ -26,14 +26,14 @@ > #include "rte_event_timer_adapter.h" > #include "rte_event_timer_adapter_pmd.h" > >-#define DATA_MZ_NAME_MAX_LEN 64 >-#define DATA_MZ_NAME_FORMAT >"rte_event_timer_adapter_data_%d" >+#define EVTIM_MZ_NAME_MAX_LEN 64 >+#define EVTIM_MZ_NAME_FORMAT "rte_event_timer_adapter_%d" > > RTE_LOG_REGISTER(evtim_logtype, lib.eventdev.adapter.timer, >NOTICE); > RTE_LOG_REGISTER(evtim_buffer_logtype, lib.eventdev.adapter.timer, >NOTICE); > RTE_LOG_REGISTER(evtim_svc_logtype, >lib.eventdev.adapter.timer.svc, NOTICE); > >-static struct rte_event_timer_adapter >adapters[RTE_EVENT_TIMER_ADAPTER_NUM_MAX]; >+static struct rte_event_timer_adapter **adapters; > > static const struct rte_event_timer_adapter_ops swtim_ops; > >@@ -72,8 +72,8 @@ default_port_conf_cb(uint16_t id, uint8_t >event_dev_id, uint8_t *event_port_id, > > RTE_SET_USED(event_dev_id); > >- adapter =3D &adapters[id]; >- dev =3D &rte_eventdevs[adapter->data->event_dev_id]; >+ adapter =3D adapters[id]; >+ dev =3D &rte_eventdevs[adapter->data.event_dev_id]; > dev_id =3D dev->data->dev_id; > dev_conf =3D dev->data->dev_conf; > >@@ -118,6 +118,31 @@ default_port_conf_cb(uint16_t id, uint8_t >event_dev_id, uint8_t *event_port_id, > return ret; > } > >+static int >+rte_event_timer_adapter_init(void) >+{ >+ const char *name =3D "rte_event_timer_adapter_array"; >+ const struct rte_memzone *mz; >+ unsigned int sz; >+ >+ sz =3D sizeof(*adapters) * >RTE_EVENT_TIMER_ADAPTER_NUM_MAX; >+ sz =3D RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE); >+ >+ mz =3D rte_memzone_lookup(name); >+ if (mz =3D=3D NULL) { >+ mz =3D rte_memzone_reserve_aligned(name, sz, >rte_socket_id(), 0, >+ >RTE_CACHE_LINE_SIZE); >+ if (mz =3D=3D NULL) { >+ EVTIM_LOG_ERR("failed to reserve memzone >err =3D %" >+ PRId32, rte_errno); >+ return -rte_errno; >+ } >+ } >+ >+ adapters =3D mz->addr; Moving adapter array to shared memory wouldn't work as adapter->ops would a= lso be on shared mem=20 and secondary processes would just replace the ops function pointers to its= text section resulting in=20 undefined behavior on primary and other secondaries. The Programming model should be one process should create the timer adapter= and other primary/secondaries Should do a rte_event_timer_adapter_lookup before using the adapter_id to a= rm/cancel timers. The fixup/sync between primary and secondary is done in `rte_event_timer_ad= apter_lookup`. Maybe we should update the documentation regarding this. Regards, Pavan. >+ return 0; >+} >+ > struct rte_event_timer_adapter * > rte_event_timer_adapter_create(const struct >rte_event_timer_adapter_conf *conf) > { >@@ -134,7 +159,7 @@ rte_event_timer_adapter_create_ext( > uint16_t adapter_id; > struct rte_event_timer_adapter *adapter; > const struct rte_memzone *mz; >- char mz_name[DATA_MZ_NAME_MAX_LEN]; >+ char mz_name[EVTIM_MZ_NAME_MAX_LEN]; > int n, ret; > struct rte_eventdev *dev; > >@@ -143,6 +168,11 @@ rte_event_timer_adapter_create_ext( > return NULL; > } > >+ if (adapters =3D=3D NULL) { >+ if (rte_event_timer_adapter_init()) >+ return NULL; >+ } >+ > /* Check eventdev ID */ > if (!rte_event_pmd_is_valid_dev(conf->event_dev_id)) { > rte_errno =3D EINVAL; >@@ -159,49 +189,51 @@ rte_event_timer_adapter_create_ext( > } > > /* Check adapter ID not already allocated */ >- adapter =3D &adapters[adapter_id]; >- if (adapter->allocated) { >+ adapter =3D adapters[adapter_id]; >+ if (adapter) { >+ EVTIM_LOG_ERR("Timer adapter id %u already exists", >adapter_id); > rte_errno =3D EEXIST; > return NULL; > } > >- /* Create shared data area. */ >- n =3D snprintf(mz_name, sizeof(mz_name), >DATA_MZ_NAME_FORMAT, adapter_id); >+ /* Reserve timer adapter memory. */ >+ n =3D snprintf(mz_name, sizeof(mz_name), >EVTIM_MZ_NAME_FORMAT, >+ adapter_id); > if (n >=3D (int)sizeof(mz_name)) { > rte_errno =3D EINVAL; > return NULL; > } > mz =3D rte_memzone_reserve(mz_name, >- sizeof(struct >rte_event_timer_adapter_data), >+ sizeof(struct rte_event_timer_adapter), > conf->socket_id, 0); > if (mz =3D=3D NULL) > /* rte_errno set by rte_memzone_reserve */ > return NULL; > >- adapter->data =3D mz->addr; >- memset(adapter->data, 0, sizeof(struct >rte_event_timer_adapter_data)); >+ adapter =3D mz->addr; >+ memset(adapter, 0, sizeof(struct rte_event_timer_adapter)); > >- adapter->data->mz =3D mz; >- adapter->data->event_dev_id =3D conf->event_dev_id; >- adapter->data->id =3D adapter_id; >- adapter->data->socket_id =3D conf->socket_id; >- adapter->data->conf =3D *conf; /* copy conf structure */ >+ adapter->mz =3D mz; >+ adapter->data.event_dev_id =3D conf->event_dev_id; >+ adapter->data.id =3D adapter_id; >+ adapter->data.socket_id =3D conf->socket_id; >+ adapter->data.conf =3D *conf; /* copy conf structure */ > > /* Query eventdev PMD for timer adapter capabilities and ops >*/ > ret =3D dev->dev_ops->timer_adapter_caps_get(dev, >- adapter->data- >>conf.flags, >- &adapter->data- >>caps, >+ adapter- >>data.conf.flags, >+ &adapter->data.caps, > &adapter->ops); > if (ret < 0) { > rte_errno =3D -ret; > goto free_memzone; > } > >- if (!(adapter->data->caps & >+ if (!(adapter->data.caps & > RTE_EVENT_TIMER_ADAPTER_CAP_INTERNAL_PORT)) { > FUNC_PTR_OR_NULL_RET_WITH_ERRNO(conf_cb, >EINVAL); >- ret =3D conf_cb(adapter->data->id, adapter->data- >>event_dev_id, >- &adapter->data->event_port_id, conf_arg); >+ ret =3D conf_cb(adapter->data.id, adapter- >>data.event_dev_id, >+ &adapter->data.event_port_id, conf_arg); > if (ret < 0) { > rte_errno =3D -ret; > goto free_memzone; >@@ -227,14 +259,14 @@ rte_event_timer_adapter_create_ext( > adapter->arm_tmo_tick_burst =3D adapter->ops- >>arm_tmo_tick_burst; > adapter->cancel_burst =3D adapter->ops->cancel_burst; > >- adapter->allocated =3D 1; >+ adapters[adapter_id] =3D adapter; > > rte_eventdev_trace_timer_adapter_create(adapter_id, >adapter, conf, > conf_cb); > return adapter; > > free_memzone: >- rte_memzone_free(adapter->data->mz); >+ rte_memzone_free(adapter->mz); > return NULL; > } > >@@ -249,24 +281,24 @@ rte_event_timer_adapter_get_info(const >struct rte_event_timer_adapter *adapter, > adapter->ops->get_info(adapter, adapter_info); > > /* Set common values */ >- adapter_info->conf =3D adapter->data->conf; >- adapter_info->event_dev_port_id =3D adapter->data- >>event_port_id; >- adapter_info->caps =3D adapter->data->caps; >+ adapter_info->conf =3D adapter->data.conf; >+ adapter_info->event_dev_port_id =3D adapter- >>data.event_port_id; >+ adapter_info->caps =3D adapter->data.caps; > > return 0; > } > > int >-rte_event_timer_adapter_start(const struct rte_event_timer_adapter >*adapter) >+rte_event_timer_adapter_start(struct rte_event_timer_adapter >*adapter) > { > int ret; > > ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL); > FUNC_PTR_OR_ERR_RET(adapter->ops->start, -EINVAL); > >- if (adapter->data->started) { >+ if (adapter->data.started) { > EVTIM_LOG_ERR("event timer adapter %"PRIu8" >already started", >- adapter->data->id); >+ adapter->data.id); > return -EALREADY; > } > >@@ -274,22 +306,22 @@ rte_event_timer_adapter_start(const struct >rte_event_timer_adapter *adapter) > if (ret < 0) > return ret; > >- adapter->data->started =3D 1; >+ adapter->data.started =3D 1; > rte_eventdev_trace_timer_adapter_start(adapter); > return 0; > } > > int >-rte_event_timer_adapter_stop(const struct rte_event_timer_adapter >*adapter) >+rte_event_timer_adapter_stop(struct rte_event_timer_adapter >*adapter) > { > int ret; > > ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL); > FUNC_PTR_OR_ERR_RET(adapter->ops->stop, -EINVAL); > >- if (adapter->data->started =3D=3D 0) { >+ if (adapter->data.started =3D=3D 0) { > EVTIM_LOG_ERR("event timer adapter %"PRIu8" >already stopped", >- adapter->data->id); >+ adapter->data.id); > return 0; > } > >@@ -297,7 +329,7 @@ rte_event_timer_adapter_stop(const struct >rte_event_timer_adapter *adapter) > if (ret < 0) > return ret; > >- adapter->data->started =3D 0; >+ adapter->data.started =3D 0; > rte_eventdev_trace_timer_adapter_stop(adapter); > return 0; > } >@@ -305,34 +337,26 @@ rte_event_timer_adapter_stop(const struct >rte_event_timer_adapter *adapter) > struct rte_event_timer_adapter * > rte_event_timer_adapter_lookup(uint16_t adapter_id) > { >- char name[DATA_MZ_NAME_MAX_LEN]; >- const struct rte_memzone *mz; >- struct rte_event_timer_adapter_data *data; > struct rte_event_timer_adapter *adapter; >- int ret; >+ char name[EVTIM_MZ_NAME_MAX_LEN]; >+ const struct rte_memzone *mz; > struct rte_eventdev *dev; >+ int ret; > >- if (adapters[adapter_id].allocated) >- return &adapters[adapter_id]; /* Adapter is already >loaded */ >- >- snprintf(name, DATA_MZ_NAME_MAX_LEN, >DATA_MZ_NAME_FORMAT, adapter_id); >+ snprintf(name, EVTIM_MZ_NAME_MAX_LEN, >EVTIM_MZ_NAME_FORMAT, adapter_id); > mz =3D rte_memzone_lookup(name); > if (mz =3D=3D NULL) { > rte_errno =3D ENOENT; > return NULL; > } > >- data =3D mz->addr; >- >- adapter =3D &adapters[data->id]; >- adapter->data =3D data; >- >- dev =3D &rte_eventdevs[adapter->data->event_dev_id]; >+ adapter =3D mz->addr; >+ dev =3D &rte_eventdevs[adapter->data.event_dev_id]; > > /* Query eventdev PMD for timer adapter capabilities and ops >*/ > ret =3D dev->dev_ops->timer_adapter_caps_get(dev, >- adapter->data- >>conf.flags, >- &adapter->data- >>caps, >+ adapter- >>data.conf.flags, >+ &adapter->data.caps, > &adapter->ops); > if (ret < 0) { > rte_errno =3D EINVAL; >@@ -350,37 +374,36 @@ rte_event_timer_adapter_lookup(uint16_t >adapter_id) > adapter->arm_tmo_tick_burst =3D adapter->ops- >>arm_tmo_tick_burst; > adapter->cancel_burst =3D adapter->ops->cancel_burst; > >- adapter->allocated =3D 1; >- > return adapter; > } > > int > rte_event_timer_adapter_free(struct rte_event_timer_adapter >*adapter) > { >+ uint8_t adapter_id; > int ret; > > ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL); > FUNC_PTR_OR_ERR_RET(adapter->ops->uninit, -EINVAL); > >- if (adapter->data->started =3D=3D 1) { >+ if (adapter->data.started =3D=3D 1) { > EVTIM_LOG_ERR("event timer adapter %"PRIu8" must >be stopped " >- "before freeing", adapter->data->id); >+ "before freeing", adapter->data.id); > return -EBUSY; > } > >+ adapter_id =3D adapter->data.id; > /* free impl priv data */ > ret =3D adapter->ops->uninit(adapter); > if (ret < 0) > return ret; > >- /* free shared data area */ >- ret =3D rte_memzone_free(adapter->data->mz); >+ /* free shared adapter memory */ >+ ret =3D rte_memzone_free(adapter->mz); > if (ret < 0) > return ret; > >- adapter->data =3D NULL; >- adapter->allocated =3D 0; >+ adapters[adapter_id] =3D NULL; > > rte_eventdev_trace_timer_adapter_free(adapter); > return 0; >@@ -392,10 +415,10 @@ >rte_event_timer_adapter_service_id_get(struct >rte_event_timer_adapter *adapter, > { > ADAPTER_VALID_OR_ERR_RET(adapter, -EINVAL); > >- if (adapter->data->service_inited && service_id !=3D NULL) >- *service_id =3D adapter->data->service_id; >+ if (adapter->data.service_inited && service_id !=3D NULL) >+ *service_id =3D adapter->data.service_id; > >- return adapter->data->service_inited ? 0 : -ESRCH; >+ return adapter->data.service_inited ? 0 : -ESRCH; > } > > int >@@ -569,7 +592,7 @@ struct swtim { > static inline struct swtim * > swtim_pmd_priv(const struct rte_event_timer_adapter *adapter) > { >- return adapter->data->adapter_priv; >+ return adapter->data.adapter_priv; > } > > static void >@@ -635,8 +658,8 @@ swtim_callback(struct rte_timer *tim) > > if (event_buffer_batch_ready(&sw->buffer)) { > event_buffer_flush(&sw->buffer, >- adapter->data->event_dev_id, >- adapter->data->event_port_id, >+ adapter->data.event_dev_id, >+ adapter->data.event_port_id, > &nb_evs_flushed, > &nb_evs_invalid); > >@@ -712,7 +735,7 @@ check_destination_event_queue(struct >rte_event_timer *evtim, > int ret; > uint32_t sched_type; > >- ret =3D rte_event_queue_attr_get(adapter->data->event_dev_id, >+ ret =3D rte_event_queue_attr_get(adapter->data.event_dev_id, > evtim->ev.queue_id, > >RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE, > &sched_type); >@@ -744,8 +767,8 @@ swtim_service_func(void *arg) > sw->n_expired_timers =3D 0; > > event_buffer_flush(&sw->buffer, >- adapter->data->event_dev_id, >- adapter->data->event_port_id, >+ adapter->data.event_dev_id, >+ adapter->data.event_port_id, > &nb_evs_flushed, > &nb_evs_invalid); > >@@ -799,9 +822,9 @@ swtim_init(struct rte_event_timer_adapter >*adapter) > #define SWTIM_NAMESIZE 32 > char swtim_name[SWTIM_NAMESIZE]; > snprintf(swtim_name, SWTIM_NAMESIZE, "swtim_%"PRIu8, >- adapter->data->id); >+ adapter->data.id); > sw =3D rte_zmalloc_socket(swtim_name, sizeof(*sw), >RTE_CACHE_LINE_SIZE, >- adapter->data->socket_id); >+ adapter->data.socket_id); > if (sw =3D=3D NULL) { > EVTIM_LOG_ERR("failed to allocate space for private >data"); > rte_errno =3D ENOMEM; >@@ -809,25 +832,25 @@ swtim_init(struct rte_event_timer_adapter >*adapter) > } > > /* Connect storage to adapter instance */ >- adapter->data->adapter_priv =3D sw; >+ adapter->data.adapter_priv =3D sw; > sw->adapter =3D adapter; > >- sw->timer_tick_ns =3D adapter->data->conf.timer_tick_ns; >- sw->max_tmo_ns =3D adapter->data->conf.max_tmo_ns; >+ sw->timer_tick_ns =3D adapter->data.conf.timer_tick_ns; >+ sw->max_tmo_ns =3D adapter->data.conf.max_tmo_ns; > > /* Create a timer pool */ > char pool_name[SWTIM_NAMESIZE]; > snprintf(pool_name, SWTIM_NAMESIZE, >"swtim_pool_%"PRIu8, >- adapter->data->id); >+ adapter->data.id); > /* Optimal mempool size is a power of 2 minus one */ >- uint64_t nb_timers =3D rte_align64pow2(adapter->data- >>conf.nb_timers); >+ uint64_t nb_timers =3D rte_align64pow2(adapter- >>data.conf.nb_timers); > int pool_size =3D nb_timers - 1; > int cache_size =3D compute_msg_mempool_cache_size( >- adapter->data->conf.nb_timers, >nb_timers); >+ adapter->data.conf.nb_timers, >nb_timers); > flags =3D 0; /* pool is multi-producer, multi-consumer */ > sw->tim_pool =3D rte_mempool_create(pool_name, pool_size, > sizeof(struct rte_timer), cache_size, 0, NULL, >NULL, >- NULL, NULL, adapter->data->socket_id, flags); >+ NULL, NULL, adapter->data.socket_id, flags); > if (sw->tim_pool =3D=3D NULL) { > EVTIM_LOG_ERR("failed to create timer object >mempool"); > rte_errno =3D ENOMEM; >@@ -863,8 +886,8 @@ swtim_init(struct rte_event_timer_adapter >*adapter) > /* Register a service component to run adapter logic */ > memset(&service, 0, sizeof(service)); > snprintf(service.name, RTE_SERVICE_NAME_MAX, >- "swtim_svc_%"PRIu8, adapter->data->id); >- service.socket_id =3D adapter->data->socket_id; >+ "swtim_svc_%"PRIu8, adapter->data.id); >+ service.socket_id =3D adapter->data.socket_id; > service.callback =3D swtim_service_func; > service.callback_userdata =3D adapter; > service.capabilities &=3D ~(RTE_SERVICE_CAP_MT_SAFE); >@@ -881,8 +904,8 @@ swtim_init(struct rte_event_timer_adapter >*adapter) > EVTIM_LOG_DBG("registered service %s with id %"PRIu32, >service.name, > sw->service_id); > >- adapter->data->service_id =3D sw->service_id; >- adapter->data->service_inited =3D 1; >+ adapter->data.service_id =3D sw->service_id; >+ adapter->data.service_inited =3D 1; > > return 0; > free_mempool: >@@ -924,7 +947,7 @@ swtim_uninit(struct rte_event_timer_adapter >*adapter) > > rte_mempool_free(sw->tim_pool); > rte_free(sw); >- adapter->data->adapter_priv =3D NULL; >+ adapter->data.adapter_priv =3D NULL; > > return 0; > } >@@ -1025,7 +1048,7 @@ __swtim_arm_burst(const struct >rte_event_timer_adapter *adapter, > > #ifdef RTE_LIBRTE_EVENTDEV_DEBUG > /* Check that the service is running. */ >- if (rte_service_runstate_get(adapter->data->service_id) !=3D 1) { >+ if (rte_service_runstate_get(adapter->data.service_id) !=3D 1) { > rte_errno =3D EINVAL; > return 0; > } >@@ -1149,7 +1172,7 @@ swtim_cancel_burst(const struct >rte_event_timer_adapter *adapter, > > #ifdef RTE_LIBRTE_EVENTDEV_DEBUG > /* Check that the service is running. */ >- if (rte_service_runstate_get(adapter->data->service_id) !=3D 1) { >+ if (rte_service_runstate_get(adapter->data.service_id) !=3D 1) { > rte_errno =3D EINVAL; > return 0; > } >diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h >b/lib/librte_eventdev/rte_event_timer_adapter.h >index d2ebcb090..af9541736 100644 >--- a/lib/librte_eventdev/rte_event_timer_adapter.h >+++ b/lib/librte_eventdev/rte_event_timer_adapter.h >@@ -320,8 +320,7 @@ rte_event_timer_adapter_get_info( > * be started before calling rte_event_timer_adapter_start(). > */ > int >-rte_event_timer_adapter_start( >- const struct rte_event_timer_adapter *adapter); >+rte_event_timer_adapter_start(struct rte_event_timer_adapter >*adapter); > > /** > * Stop an event timer adapter. >@@ -338,7 +337,7 @@ rte_event_timer_adapter_start( > * - -EINVAL if adapter identifier invalid > */ > int >-rte_event_timer_adapter_stop(const struct rte_event_timer_adapter >*adapter); >+rte_event_timer_adapter_stop(struct rte_event_timer_adapter >*adapter); > > /** > * Lookup an event timer adapter using its identifier. >@@ -503,6 +502,34 @@ typedef uint16_t >(*rte_event_timer_cancel_burst_t)( > uint16_t nb_tims); > /**< @internal Prevent event timers from enqueuing timer events */ > >+/** >+ * @internal Adapter data. >+ */ >+struct rte_event_timer_adapter_data { >+ uint8_t id; >+ /**< Event timer adapter ID */ >+ uint8_t event_dev_id; >+ /**< Event device ID */ >+ uint32_t socket_id; >+ /**< Socket ID where memory is allocated */ >+ uint8_t event_port_id; >+ /**< Optional: event port ID used when the inbuilt port is >absent */ >+ struct rte_event_timer_adapter_conf conf; >+ /**< Configuration used to configure the adapter. */ >+ uint32_t caps; >+ /**< Adapter capabilities */ >+ void *adapter_priv; >+ /**< Timer adapter private data*/ >+ uint8_t service_inited; >+ /**< Service initialization state */ >+ uint32_t service_id; >+ /**< Service ID*/ >+ >+ RTE_STD_C11 >+ uint8_t started : 1; >+ /**< Flag to indicate adapter started. */ >+} __rte_cache_aligned; >+ > /** > * @internal Data structure associated with each event timer adapter. > */ >@@ -513,19 +540,26 @@ struct rte_event_timer_adapter { > /**< Pointer to driver arm_tmo_tick_burst function. */ > rte_event_timer_cancel_burst_t cancel_burst; > /**< Pointer to driver cancel function. */ >- struct rte_event_timer_adapter_data *data; >- /**< Pointer to shared adapter data */ >+ struct rte_event_timer_adapter_data data; >+ /**< Event timer adapter data. */ > const struct rte_event_timer_adapter_ops *ops; > /**< Functions exported by adapter driver */ >- >- RTE_STD_C11 >- uint8_t allocated : 1; >- /**< Flag to indicate that this adapter has been allocated */ >+ const struct rte_memzone *mz; >+ /**< Event timer adapter memzone pointer */ > } __rte_cache_aligned; > >-#define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { > \ >- if (adapter =3D=3D NULL || !adapter->allocated) \ >- return retval; \ >+#define ADAPTER_VALID_OR_ERR_RET(adapter, retval) do { > \ >+ if (adapter =3D=3D NULL) { > \ >+ return retval; > \ >+ } else { \ >+ int i; > \ >+ for (i =3D 0; i < RTE_EVENT_TIMER_ADAPTER_NUM_MAX; >i++) { \ >+ if (adapters[i] =3D=3D adapter) > \ >+ break; > \ >+ } > \ >+ if (i =3D=3D RTE_EVENT_TIMER_ADAPTER_NUM_MAX) > \ >+ return retval; > \ >+ } > \ > } while (0) > > #define FUNC_PTR_OR_ERR_RET(func, errval) do { > \ >diff --git a/lib/librte_eventdev/rte_event_timer_adapter_pmd.h >b/lib/librte_eventdev/rte_event_timer_adapter_pmd.h >index cf3509dc6..0766b336e 100644 >--- a/lib/librte_eventdev/rte_event_timer_adapter_pmd.h >+++ b/lib/librte_eventdev/rte_event_timer_adapter_pmd.h >@@ -76,37 +76,6 @@ struct rte_event_timer_adapter_ops { > /**< Cancel one or more event timers */ > }; > >-/** >- * @internal Adapter data; structure to be placed in shared memory to >be >- * accessible by various processes in a multi-process configuration. >- */ >-struct rte_event_timer_adapter_data { >- uint8_t id; >- /**< Event timer adapter ID */ >- uint8_t event_dev_id; >- /**< Event device ID */ >- uint32_t socket_id; >- /**< Socket ID where memory is allocated */ >- uint8_t event_port_id; >- /**< Optional: event port ID used when the inbuilt port is >absent */ >- const struct rte_memzone *mz; >- /**< Event timer adapter memzone pointer */ >- struct rte_event_timer_adapter_conf conf; >- /**< Configuration used to configure the adapter. */ >- uint32_t caps; >- /**< Adapter capabilities */ >- void *adapter_priv; >- /**< Timer adapter private data*/ >- uint8_t service_inited; >- /**< Service initialization state */ >- uint32_t service_id; >- /**< Service ID*/ >- >- RTE_STD_C11 >- uint8_t started : 1; >- /**< Flag to indicate adapter started. */ >-} __rte_cache_aligned; >- > #ifdef __cplusplus > } > #endif >-- >2.25.1