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 55B8DA0093; Wed, 27 Apr 2022 20:38:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E641640E78; Wed, 27 Apr 2022 20:38:13 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 4D85440691 for ; Wed, 27 Apr 2022 20:38:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651084690; x=1682620690; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=BUWzM2vK39b7WCr2Y/8UuGw+WoBC0ofyOhSEGp9yas8=; b=ALMZVbhL1Fo7hCSaB+4WZ56hzxie0ekmWDFGKQVMuHatIoesjDwNF8b8 vfTZv3PRRMdiiS7rJXGedJTYzfS16g4Hejl0KlDMGpXGOpQIeiNhsWMul TkWzHRFDzKPIQczfLwymdowoxFNxhUjuUrVoKg9vghsUNWEgXGthrY6Z4 g8WSyI3btQU4AGRRBYXLt0CbZquU7xJACK3biOyLQqcLXn/n7TL5aTXva pttQ0Wb1L3JNvEQOl7Gc6tbgODTUByMNe68AR1rnyZjwqHiSao2vy6gli XQ7c2bOQBSkGvuWrHFoIJ13dgXfVgTXWCavHteZvaHIcOmE+MwTUO46Bk g==; X-IronPort-AV: E=McAfee;i="6400,9594,10330"; a="245953308" X-IronPort-AV: E=Sophos;i="5.90,293,1643702400"; d="scan'208";a="245953308" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2022 11:38:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,293,1643702400"; d="scan'208";a="650848401" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by FMSMGA003.fm.intel.com with ESMTP; 27 Apr 2022 11:38:07 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 27 Apr 2022 11:38:07 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Wed, 27 Apr 2022 11:38:07 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.176) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Wed, 27 Apr 2022 11:38:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TQIXyPHlN/vn4hm5ynzTFyOvtJlWVonGlpNdQuhrsorZT0/m7XFjo8hM38iQPT83n8O5uaQ2Udw4zAfJcDzVnJLh7lobWYG2HF02JtZuI8atsXigwg6aTLVRZDZCGCYh2qD3XSkGAuv8wgKD4kX+hp/CWIsHte4usBZQ4J3ia+gCkHmYYtng4WJz2xtmFxHzPiA9X6o3vNUGEmcf/YaU8J+bLZz0eK4xgIs5PuvItPuFUsI4KaC99hPip5oeA3TPYVoBU9ISBQ8HiP+O8l0CiZi0+tZaV3cUXlLtfYOWUpiYb6WWYf/ciZTWDrAWWmum8ooBMTWB9OTPaBsu+SqP9A== 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=iLygWJxcSjngvr7ULcxqMsVTOnivxHV4i/XcScXtW8c=; b=fp132i2bizOL7razL66/GCcChn1cZrL+PqQ6ae8ZC05BCsL4KGmRKIG5zUNLxmbVCfj2+m8KTh2+I4VW0zhfH4mO7zfIvGLg1mqlxIXpcBea67XHvlz76tSvA/RwfJPyroZv268Pdqndn9ghBUvYqRFQiHjhsKnGFF26s4AGxyccRQY15WDCxrWPVoZ4XzI6pMJGa7ZNmlf1SYdWzPlQsvrkC4mrnGwCQRqRGrdYSIcUr8nHpVrMJkgRC06Q4xOzowNcwozLcdW8EC7jQHSGV+GXqDAUNJ8ZVa2RWliLa6fflbDVrEXVzIZ2KVioCvmDJNyyStNUR89kxh3VfbZtKA== 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 BY5PR11MB4451.namprd11.prod.outlook.com (2603:10b6:a03:1cb::30) by DM6PR11MB2730.namprd11.prod.outlook.com (2603:10b6:5:c7::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.18; Wed, 27 Apr 2022 18:38:03 +0000 Received: from BY5PR11MB4451.namprd11.prod.outlook.com ([fe80::354b:3b12:be2c:1b6e]) by BY5PR11MB4451.namprd11.prod.outlook.com ([fe80::354b:3b12:be2c:1b6e%5]) with mapi id 15.20.5206.013; Wed, 27 Apr 2022 18:38:03 +0000 From: "Chautru, Nicolas" To: John Miller , "dev@dpdk.org" CC: "ferruh.yigit@xilinx.com" , "ed.czeck@atomicrules.com" Subject: RE: [PATCH 05/10] baseband/ark: add ark baseband device Thread-Topic: [PATCH 05/10] baseband/ark: add ark baseband device Thread-Index: AQHYVZOP28fc23XZIkWjDe6BdrZpqK0EH2eQ Date: Wed, 27 Apr 2022 18:38:03 +0000 Message-ID: References: <20220421151900.703467-1-john.miller@atomicrules.com> <20220421151900.703467-5-john.miller@atomicrules.com> In-Reply-To: <20220421151900.703467-5-john.miller@atomicrules.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.401.20 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bd549a71-6df4-466a-9464-08da287d105c x-ms-traffictypediagnostic: DM6PR11MB2730:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BDqL40ODhrgA+tdfoFRxF4LVUCdopF5YlwJEuxEv3BvkzQfZwJxowwme5k0BERWOxkQijJPIB/Eeq7lk2a+iPCHVkTRtThQenxtSgKrE3GNfWi/8rdaRIgE94bC+w8F2BFP+nK5JfWpt5x+UnK1GbrcKwTOzw7aN/DQEwYEdJj1F+D9M9Ude+c2zw8FKto/tz8cCrrdvgR9if3qdfxkzr5+wFKQEVp8MAHPrsxh3h80cxSdcvag8mwt6ww3pJnwkOSCAfnnO1X1XAXYgt+DOEXIYyGzDmKXO5MJS82kIbbM3hpcsbIVZnzFPhZ6IbIr+wuYulaTApLZpSQyMuuipu30jK+NOeIPZWBLeEyDULcRx739k+LDQ0g2a/VdwHc4ZU1S1yPe7cECH3aIr13PiXaCZ55BXjUo4R4FV0ExQJmU0ZIx6i5M6/8SJHPXdsgLd8C2dThEBUPHq4NFoc55CakAa/QDBUdW6tpTcwYJjCatNbYzlgYTnGPTF4T7m1/QeFLHW/xqWVdgv/eSamWNRY+GI68U3UwqUA8hFxg4wpMGwHs/4jyuZx1geS7e6ah3rGtz8fY1ul2NIGYzn9Lf42Ayd6Z+0h9aJANvlzzQijZXLdUL8nR4mhKimIQdzetW0DGRa8Z7VaHXzkOslNt+u9UBlwfNy/IL3v0bpJf128e/xkN5Q3ATr/IpP204YhXHk8HJxZrd9RM/5vcumX6TVCg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR11MB4451.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(83380400001)(86362001)(55016003)(5660300002)(82960400001)(38100700002)(38070700005)(122000001)(7696005)(53546011)(9686003)(71200400001)(6506007)(316002)(26005)(54906003)(508600001)(110136005)(186003)(52536014)(30864003)(8936002)(2906002)(64756008)(4326008)(8676002)(66946007)(66476007)(76116006)(66556008)(66446008)(33656002)(579004)(559001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?FtBZ8Myo7/g63mCTyYq3flVorcDtc8y1AQ7NysWKlHy0Oaod7JUdDVtKmoL8?= =?us-ascii?Q?vt3qPvPAF9y0sd0i4Ok46GOm/KRswHjmR5OHZ2+YJoP9cqsIU7ifJyztf7gB?= =?us-ascii?Q?IP87qcTlhtKUv/v644CvDIZmr/7ecaOslQx/KTlYTFkqlMskIr+bcAad183x?= =?us-ascii?Q?OfyC5xpFPWY7Ve6XTlBSQ/pWFtNMbOYimV2O/Li/jjrGO3iFMewvQpRWspJr?= =?us-ascii?Q?tvLWqptTYHYoZKDiNgNSB1mzHaj9Wd6ZYLZRFuZaDBL0ABaaNZRUdAwEvpgT?= =?us-ascii?Q?GJbuvcpsBNYeXjqXH0JvP3bV/5okx+xAWjaVw5qL/FF9VFMO5fK4Md/OjB4K?= =?us-ascii?Q?rznqLOs+Q6sL4clPrq14DPwTtASbDA587btTi/l/7QQHGHn/AAJiRFxaVVg1?= =?us-ascii?Q?zv9VTmWjCgwdEqM5R0lkJow9qEqp2BDMOJPNj4Pm9Men0zjaRWA2W6nqcqix?= =?us-ascii?Q?aTPBa9ow4J85BXQww2QAW8p9NXNXsACwzcG3Y5Ndtfay9074mOe/W2JJS6sx?= =?us-ascii?Q?Y6M0Aze7NQRtdDPLltUibGxSHXsGfb4GUJvr99adtsYS3yUlm6olxwYYNGGT?= =?us-ascii?Q?JkuXlznKFhR0+vg3xC3Y6Pdhx/yzNaPI8MQ3qUWa80PRY/0l1DH4qYQddchy?= =?us-ascii?Q?+S22jEvE2XkehTG5QNwZsUOWfDg+GVI/Tq7kWX0R00JarI5lPF1AEqo1fYvy?= =?us-ascii?Q?ksYbSZWXz8QjanpEbb9r8/Xr9Uz52Nqgfikj6Ie4CiJrimO2Bq/57K22v7Sr?= =?us-ascii?Q?AdQ7nNzMI12UArM/cL61sr3vtHMjJD4ym4xvEqy1uOWfG/5buEdwdGL2Fp37?= =?us-ascii?Q?o1auxnzfqOi4Sx6M/jI8Q3OxgH+PL9V/x3tsaGKT1ARYLnAXeZrHRmCHxrgC?= =?us-ascii?Q?hPUkUWVRwDy7G5iANykMIykp+W9vq1vosNUR4wpYDOf9EgxuhhwJJaC093mG?= =?us-ascii?Q?eiRLh1rGRXkePMHuXuvQZtteysfcU8k4x108wDe2x/c9YooBroJ2RjNRM6XM?= =?us-ascii?Q?h0irqSxgIFeh4JW0cF2V4bGRf50lX6fjL26bVGy5lF22WlXV8KageLUlogVL?= =?us-ascii?Q?X8OEl+PhUFQ8S5b1pwGV3gHmdGDkfmyPvPo6FeylYlnJch5j12ZZihAgzQQa?= =?us-ascii?Q?QqhC7oQVzOd/ggwkKbS8mN39M6xBB3JM/6wkVsMbKPtvo86LKiT2PFq8FV9a?= =?us-ascii?Q?/awEMiaIhbkBY3o8ZRPiRuTXpxe789nnFXHF4Sj2nAXDtjzC3f8IwJBFQCgV?= =?us-ascii?Q?LvHPmc0WJYbMf6YGnCQXGzWx1T470aiLLgK6Xlc+tU+kyjN0q63nSo8BYDda?= =?us-ascii?Q?otDr/7rDhHDDC8DAEM6XOXcMD7kTWy1Bdn3/A0BRQPC22YkMqqon8PXlYsMA?= =?us-ascii?Q?vrFT2woorvx1IC4yM8Fg2I7pdJmLuhuiQSn9eEuyh8URgT5E9hDTBydQ2QIf?= =?us-ascii?Q?emk1a/hZmbJoz52L22cC/kDtL4EpMe55QvF0f/OJxESCXiHUSz/3HI7SGBt7?= =?us-ascii?Q?7Ro24u60AARUP0A3eezkbmeYEJqrzCa+Fl+oZlUpmHz3qzb7N7IjoGVgLF0j?= =?us-ascii?Q?rEGy3YayKMFmWP6qTuPu2a84mjhub8kEbCoKkUHxD2/uKZOCH7oEZisI34ae?= =?us-ascii?Q?P08K7SFZdGiYYFbI47goLwa4E0qn6//YqJpTzmWaLP5OX5waoA92H/1FU43M?= =?us-ascii?Q?Y+643e5XEAmVnCd/5DEBdb/hidOgYDGC0ZlTdUPfi7+hUp4VAIQ/Vn79ca4z?= =?us-ascii?Q?1sO1aCWbGcw0JMemBiGpyxYIjd7OQfY=3D?= 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: BY5PR11MB4451.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd549a71-6df4-466a-9464-08da287d105c X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Apr 2022 18:38:03.6403 (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: u/TpUMFSf6ki3LdSEaWlRp3LTvRfOr8ajkmqxi4bODrexciDw5E4Qmr7opI2wGM6SEEoqk4W4UzCTYFBQ7iH0nSxtSLTxsEtrp+MAq6bJtw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2730 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 Hi John,=20 Do you think this one can be split into a few incremental commits? There are a few TODOs, is that v1 ready for review? Also you are targeting = 22.11 right? Thanks Nic > -----Original Message----- > From: John Miller > Sent: Thursday, April 21, 2022 8:19 AM > To: dev@dpdk.org > Cc: ferruh.yigit@xilinx.com; ed.czeck@atomicrules.com; John Miller > > Subject: [PATCH 05/10] baseband/ark: add ark baseband device >=20 > Add new ark baseband device. >=20 > Signed-off-by: John Miller > --- > drivers/baseband/ark/ark_bbdev.c | 1064 +++++++++++++++++++++++ > drivers/baseband/ark/ark_bbdev_common.c | 125 +++ > drivers/baseband/ark/ark_bbdev_common.h | 92 ++ > drivers/baseband/ark/ark_bbdev_custom.c | 201 +++++ > drivers/baseband/ark/ark_bbdev_custom.h | 30 + > drivers/baseband/ark/meson.build | 11 + > drivers/baseband/ark/version.map | 3 + > 7 files changed, 1526 insertions(+) > create mode 100644 drivers/baseband/ark/ark_bbdev.c create mode > 100644 drivers/baseband/ark/ark_bbdev_common.c > create mode 100644 drivers/baseband/ark/ark_bbdev_common.h > create mode 100644 drivers/baseband/ark/ark_bbdev_custom.c > create mode 100644 drivers/baseband/ark/ark_bbdev_custom.h > create mode 100644 drivers/baseband/ark/meson.build create mode > 100644 drivers/baseband/ark/version.map >=20 > diff --git a/drivers/baseband/ark/ark_bbdev.c > b/drivers/baseband/ark/ark_bbdev.c > new file mode 100644 > index 0000000000..b23bbd44d1 > --- /dev/null > +++ b/drivers/baseband/ark/ark_bbdev.c > @@ -0,0 +1,1064 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2016-2021 Atomic Rules LLC */ > + > +#include "ark_common.h" > +#include "ark_bbdev_common.h" > +#include "ark_bbdev_custom.h" > +#include "ark_ddm.h" > +#include "ark_mpu.h" > +#include "ark_rqp.h" > +#include "ark_udm.h" > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#define DRIVER_NAME baseband_ark > + > +RTE_LOG_REGISTER_DEFAULT(ark_bbdev_logtype, DEBUG); > + > +#define ARK_SYSCTRL_BASE 0x0 > +#define ARK_PKTGEN_BASE 0x10000 > +#define ARK_MPU_RX_BASE 0x20000 > +#define ARK_UDM_BASE 0x30000 > +#define ARK_MPU_TX_BASE 0x40000 > +#define ARK_DDM_BASE 0x60000 > +#define ARK_PKTDIR_BASE 0xa0000 > +#define ARK_PKTCHKR_BASE 0x90000 > +#define ARK_RCPACING_BASE 0xb0000 > +#define ARK_MPU_QOFFSET 0x00100 > + > +#define BB_ARK_TX_Q_FACTOR 4 > + > +/* TODO move to UDM, verify configuration */ #define ARK_RX_META_SIZE > +32 #define ARK_RX_META_OFFSET (RTE_PKTMBUF_HEADROOM - > ARK_RX_META_SIZE) > +#define ARK_RX_MAX_NOCHAIN (RTE_MBUF_DEFAULT_DATAROOM) > + > +static_assert(sizeof(struct ark_rx_meta) =3D=3D ARK_RX_META_SIZE, > +"Unexpected struct size ark_rx_meta"); static_assert(sizeof(union > +ark_tx_meta) =3D=3D 8, "Unexpected struct size ark_tx_meta"); > + > +static struct rte_pci_id pci_id_ark[] =3D { > + {RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1015)}, > + {RTE_PCI_DEVICE(AR_VENDOR_ID, 0x1016)}, > + {.device_id =3D 0}, > +}; > + > +static const struct ark_dev_caps > +ark_device_caps[] =3D { > + SET_DEV_CAPS(0x1015, true), > + SET_DEV_CAPS(0x1016, true), > + {.device_id =3D 0,} > +}; > + > + > +/* Forward declarations */ > +static const struct rte_bbdev_ops ark_bbdev_pmd_ops; > + > + > +/* queue */ > +struct ark_bbdev_queue { > + struct rte_ring *active_ops; /* Ring for processed packets */ > + > + /* RX components */ > + /* array of physical addresses of the mbuf data pointer */ > + rte_iova_t *rx_paddress_q; > + struct ark_udm_t *udm; > + struct ark_mpu_t *rx_mpu; > + > + /* TX components */ > + union ark_tx_meta *tx_meta_q; > + struct ark_mpu_t *tx_mpu; > + struct ark_ddm_t *ddm; > + > + /* */ > + uint32_t tx_queue_mask; > + uint32_t rx_queue_mask; > + > + int32_t rx_seed_index; /* step 1 set with empty mbuf */ > + int32_t rx_cons_index; /* step 3 consumed by driver */ > + > + /* 3 indexes to the paired data rings. */ > + int32_t tx_prod_index; /* where to put the next one */ > + int32_t tx_free_index; /* local copy of tx_cons_index */ > + > + /* separate cache line -- written by FPGA -- RX announce */ > + RTE_MARKER cacheline1 __rte_cache_min_aligned; > + volatile int32_t rx_prod_index; /* step 2 filled by FPGA */ > + > + /* Separate cache line -- written by FPGA -- RX completion */ > + RTE_MARKER cacheline2 __rte_cache_min_aligned; > + volatile int32_t tx_cons_index; /* hw is done, can be freed */ } > +__rte_cache_aligned; > + > +static int > +ark_bb_hw_q_setup(struct rte_bbdev *bbdev, uint16_t q_id, uint16_t > +queue_size) { > + struct ark_bbdev_queue *q =3D bbdev->data- > >queues[q_id].queue_private; > + > + rte_iova_t queue_base; > + rte_iova_t phys_addr_q_base; > + rte_iova_t phys_addr_prod_index; > + rte_iova_t phys_addr_cons_index; > + > + uint32_t write_interval_ns =3D 500; /* TODO this seems big */ > + > + if (ark_mpu_verify(q->rx_mpu, sizeof(rte_iova_t))) { > + ARK_BBDEV_LOG(ERR, "Illegal hw/sw configuration RX > queue"); > + return -1; > + } > + ARK_BBDEV_LOG(DEBUG, "ark_bb_q setup %u:%u", > + bbdev->data->dev_id, q_id); > + > + /* RX MPU */ > + phys_addr_q_base =3D rte_malloc_virt2iova(q->rx_paddress_q); > + /* Force TX mode on MPU to match bbdev behavior */ > + ark_mpu_configure(q->rx_mpu, phys_addr_q_base, queue_size, 1); > + ark_mpu_reset_stats(q->rx_mpu); > + ark_mpu_start(q->rx_mpu); > + > + /* UDM */ > + queue_base =3D rte_malloc_virt2iova(q); > + phys_addr_prod_index =3D queue_base + > + offsetof(struct ark_bbdev_queue, rx_prod_index); > + ark_udm_write_addr(q->udm, phys_addr_prod_index); > + ark_udm_queue_enable(q->udm, 1); > + > + /* TX MPU */ > + phys_addr_q_base =3D rte_malloc_virt2iova(q->tx_meta_q); > + ark_mpu_configure(q->tx_mpu, phys_addr_q_base, > + BB_ARK_TX_Q_FACTOR * queue_size, 1); > + ark_mpu_start(q->tx_mpu); > + > + /* DDM */ > + phys_addr_cons_index =3D queue_base + > + offsetof(struct ark_bbdev_queue, tx_cons_index); > + ark_ddm_setup(q->ddm, phys_addr_cons_index, write_interval_ns); > + > + return 0; > +} > + > +/* Setup a queue */ > +static int > +ark_bb_q_setup(struct rte_bbdev *bbdev, uint16_t q_id, > + const struct rte_bbdev_queue_conf *queue_conf) { > + struct ark_bbdev_queue *q; > + struct ark_bbdevice *ark_bb =3D bbdev->data->dev_private; > + > + const uint32_t queue_size =3D queue_conf->queue_size; > + const int socket_id =3D queue_conf->socket; > + const uint64_t pg_sz =3D sysconf(_SC_PAGESIZE); > + char ring_name[RTE_RING_NAMESIZE]; > + > + /* Configuration checks */ > + if (!rte_is_power_of_2(queue_size)) { > + ARK_BBDEV_LOG(ERR, > + "Configuration queue size" > + " must be power of two %u", > + queue_size); > + return -EINVAL; > + } > + > + if (RTE_PKTMBUF_HEADROOM < ARK_RX_META_SIZE) { > + ARK_BBDEV_LOG(ERR, > + "Error: Ark bbdev requires head room > %d bytes > (%s)", > + ARK_RX_META_SIZE, __func__); > + return -EINVAL; > + } > + > + /* Allocate the queue data structure. */ > + q =3D rte_zmalloc_socket(RTE_STR(DRIVER_NAME), sizeof(*q), > + RTE_CACHE_LINE_SIZE, queue_conf->socket); > + if (q =3D=3D NULL) { > + ARK_BBDEV_LOG(ERR, "Failed to allocate queue memory"); > + return -ENOMEM; > + } > + bbdev->data->queues[q_id].queue_private =3D q; > + > + /* RING */ > + snprintf(ring_name, RTE_RING_NAMESIZE, RTE_STR(DRIVER_NAME) > "%u:%u", > + bbdev->data->dev_id, q_id); > + q->active_ops =3D rte_ring_create(ring_name, > + queue_size, > + queue_conf->socket, > + RING_F_SP_ENQ | RING_F_SC_DEQ); > + if (q->active_ops =3D=3D NULL) { > + ARK_BBDEV_LOG(ERR, "Failed to create ring"); > + goto free_all; > + } > + > + q->rx_queue_mask =3D queue_size - 1; > + q->tx_queue_mask =3D (BB_ARK_TX_Q_FACTOR * queue_size) - 1; > + > + /* Each mbuf requires 2 to 4 objects, factor by > BB_ARK_TX_Q_FACTOR */ > + q->tx_meta_q =3D > + rte_zmalloc_socket("Ark_bb_txqueue meta", > + queue_size * BB_ARK_TX_Q_FACTOR * > + sizeof(union ark_tx_meta), > + pg_sz, > + socket_id); > + > + if (q->tx_meta_q =3D=3D 0) { > + ARK_BBDEV_LOG(ERR, "Failed to allocate " > + "queue memory in %s", __func__); > + goto free_all; > + } > + > + q->ddm =3D RTE_PTR_ADD(ark_bb->ddm.v, q_id * > ARK_DDM_QOFFSET); > + q->tx_mpu =3D RTE_PTR_ADD(ark_bb->mputx.v, q_id * > ARK_MPU_QOFFSET); > + > + q->rx_paddress_q =3D > + rte_zmalloc_socket("ark_bb_rx_paddress_q", > + queue_size * sizeof(rte_iova_t), > + pg_sz, > + socket_id); > + > + if (q->rx_paddress_q =3D=3D 0) { > + ARK_BBDEV_LOG(ERR, > + "Failed to allocate queue memory in %s", > + __func__); > + goto free_all; > + } > + q->udm =3D RTE_PTR_ADD(ark_bb->udm.v, q_id * > ARK_UDM_QOFFSET); > + q->rx_mpu =3D RTE_PTR_ADD(ark_bb->mpurx.v, q_id * > ARK_MPU_QOFFSET); > + > + /* Structure have been configured, set the hardware */ > + return ark_bb_hw_q_setup(bbdev, q_id, queue_size); > + > +free_all: > + rte_free(q->tx_meta_q); > + rte_free(q->rx_paddress_q); > + rte_free(q); > + return -EFAULT; > +} > + > +/* Release queue */ > +static int > +ark_bb_q_release(struct rte_bbdev *bbdev, uint16_t q_id) { > + struct ark_bbdev_queue *q =3D bbdev->data- > >queues[q_id].queue_private; > + > + /* TODO Wait for ddm to send out all packets in flight, > + * Is this only called after q stop? > + */ > + > + ark_mpu_dump(q->rx_mpu, "rx_MPU release", q_id); > + ark_mpu_dump(q->tx_mpu, "tx_MPU release", q_id); > + > + rte_ring_free(q->active_ops); > + rte_free(q->tx_meta_q); > + rte_free(q->rx_paddress_q); > + rte_free(q); > + bbdev->data->queues[q_id].queue_private =3D NULL; > + > + ARK_BBDEV_LOG(DEBUG, "released device queue %u:%u", > + bbdev->data->dev_id, q_id); > + return 0; > +} > + > +static int > +ark_bbdev_start(struct rte_bbdev *bbdev) { > + struct ark_bbdevice *ark_bb =3D bbdev->data->dev_private; > + > + ARK_BBDEV_LOG(DEBUG, "Starting device %u", bbdev->data- > >dev_id); > + if (ark_bb->started) > + return 0; > + > + /* start UDM */ > + ark_udm_start(ark_bb->udm.v); > + > + /* start DDM */ > + ark_ddm_start(ark_bb->ddm.v); > + > + ark_bb->started =3D 1; > + > + if (ark_bb->start_pg) > + ark_pktchkr_run(ark_bb->pc); > + > + if (ark_bb->start_pg) { > + pthread_t thread; > + > + /* Delay packet generator start allow the hardware to be > ready > + * This is only used for sanity checking with internal generator > + */ > + if (pthread_create(&thread, NULL, > + ark_pktgen_delay_start, ark_bb->pg)) { > + ARK_BBDEV_LOG(ERR, "Could not create pktgen " > + "starter thread"); > + return -1; > + } > + } > + > + return 0; > +} > + > +static void > +ark_bbdev_stop(struct rte_bbdev *bbdev) { > + struct ark_bbdevice *ark_bb =3D bbdev->data->dev_private; > + struct ark_mpu_t *mpu; > + unsigned int i; > + int status; > + > + ARK_BBDEV_LOG(DEBUG, "Stopping device %u", bbdev->data- > >dev_id); > + > + if (!ark_bb->started) > + return; > + > + /* Stop the packet generator */ > + if (ark_bb->start_pg) > + ark_pktgen_pause(ark_bb->pg); > + > + /* Stop DDM */ > + /* Wait up to 0.1 second. each stop is up to 1000 * 10 useconds */ > + for (i =3D 0; i < 10; i++) { > + status =3D ark_ddm_stop(ark_bb->ddm.v, 1); > + if (status =3D=3D 0) > + break; > + } > + if (status || i !=3D 0) { > + ARK_BBDEV_LOG(ERR, "DDM stop anomaly. status:" > + " %d iter: %u. (%s)", > + status, > + i, > + __func__); > + ark_ddm_dump(ark_bb->ddm.v, "Stop anomaly"); > + > + mpu =3D ark_bb->mputx.v; > + for (i =3D 0; i < ark_bb->max_nb_queues; i++) { > + ark_mpu_dump(mpu, "DDM failure dump", i); > + mpu =3D RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET); > + } > + } > + ark_ddm_dump_stats(ark_bb->ddm.v, "bbdev stop"); > + > + /* STOP RX Side */ > + /* Stop UDM multiple tries attempted */ > + for (i =3D 0; i < 10; i++) { > + status =3D ark_udm_stop(ark_bb->udm.v, 1); > + if (status =3D=3D 0) > + break; > + } > + if (status || i !=3D 0) { > + ARK_BBDEV_LOG(WARNING, "UDM stop anomaly. status %d > iter: %u. (%s)", > + status, i, __func__); > + ark_udm_dump(ark_bb->udm.v, "Stop anomaly"); > + > + mpu =3D ark_bb->mpurx.v; > + for (i =3D 0; i < ark_bb->max_nb_queues; i++) { > + ark_mpu_dump(mpu, "UDM Stop anomaly", i); > + mpu =3D RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET); > + } > + } > + > + ark_udm_dump_stats(ark_bb->udm.v, "Post stop"); > + ark_udm_dump_perf(ark_bb->udm.v, "Post stop"); > + > + /* Stop the packet checker if it is running */ > + if (ark_bb->start_pg) { > + ark_pktchkr_dump_stats(ark_bb->pc); > + ark_pktchkr_stop(ark_bb->pc); > + } > +} > + > +static int > +ark_bb_q_start(struct rte_bbdev *bbdev, uint16_t q_id) { > + struct ark_bbdev_queue *q =3D bbdev->data- > >queues[q_id].queue_private; > + ARK_BBDEV_LOG(DEBUG, "ark_bb_q start %u:%u", bbdev->data- > >dev_id, q_id); > + ark_mpu_start(q->tx_mpu); > + ark_mpu_start(q->rx_mpu); > + return 0; > +} > +static int > +ark_bb_q_stop(struct rte_bbdev *bbdev, uint16_t q_id) { > + struct ark_bbdev_queue *q =3D bbdev->data- > >queues[q_id].queue_private; > + ARK_BBDEV_LOG(DEBUG, "ark_bb_q stop %u:%u", bbdev->data- > >dev_id, q_id); > + ark_mpu_stop(q->tx_mpu); > + ark_mpu_stop(q->rx_mpu); > + return 0; > +} > + > +/* > +**************************************************************** > ******* > +** */ > +/* Common function for all enqueue and dequeue ops */ static inline > +void ark_bb_enqueue_desc_fill(struct ark_bbdev_queue *q, > + struct rte_mbuf *mbuf, > + uint16_t offset, /* Extra offset */ > + uint8_t flags, > + uint32_t *meta, > + uint8_t meta_cnt /* 0, 1 or 2 */ > + ) > +{ > + union ark_tx_meta *tx_meta; > + int32_t tx_idx; > + uint8_t m; > + > + /* Header */ > + tx_idx =3D q->tx_prod_index & q->tx_queue_mask; > + tx_meta =3D &q->tx_meta_q[tx_idx]; > + tx_meta->data_len =3D rte_pktmbuf_data_len(mbuf) - offset; > + tx_meta->flags =3D flags; > + tx_meta->meta_cnt =3D meta_cnt; > + tx_meta->user1 =3D *meta++; > + q->tx_prod_index++; > + > + for (m =3D 0; m < meta_cnt; m++) { > + tx_idx =3D q->tx_prod_index & q->tx_queue_mask; > + tx_meta =3D &q->tx_meta_q[tx_idx]; > + tx_meta->usermeta0 =3D *meta++; > + tx_meta->usermeta1 =3D *meta++; > + q->tx_prod_index++; > + } > + > + tx_idx =3D q->tx_prod_index & q->tx_queue_mask; > + tx_meta =3D &q->tx_meta_q[tx_idx]; > + tx_meta->physaddr =3D rte_mbuf_data_iova(mbuf) + offset; > + q->tx_prod_index++; > +} > + > +static inline void > +ark_bb_enqueue_segmented_pkt(struct ark_bbdev_queue *q, > + struct rte_mbuf *mbuf, > + uint16_t offset, > + uint32_t *meta, uint8_t meta_cnt) { > + struct rte_mbuf *next; > + uint8_t flags =3D ARK_DDM_SOP; > + > + while (mbuf !=3D NULL) { > + next =3D mbuf->next; > + flags |=3D (next =3D=3D NULL) ? ARK_DDM_EOP : 0; > + > + ark_bb_enqueue_desc_fill(q, mbuf, offset, flags, > + meta, meta_cnt); > + > + flags &=3D ~ARK_DDM_SOP; /* drop SOP flags */ > + meta_cnt =3D 0; > + offset =3D 0; > + > + mbuf =3D next; > + } > +} > + > +static inline int > +ark_bb_enqueue_common(struct ark_bbdev_queue *q, > + struct rte_mbuf *m_in, struct rte_mbuf *m_out, > + uint16_t offset, > + uint32_t *meta, uint8_t meta_cnt) { > + int32_t free_queue_space; > + int32_t rx_idx; > + > + /* TX side limit */ > + free_queue_space =3D q->tx_queue_mask - > + (q->tx_prod_index - q->tx_free_index); > + if (unlikely(free_queue_space < (2 + (2 * m_in->nb_segs)))) > + return 1; > + > + /* RX side limit */ > + free_queue_space =3D q->rx_queue_mask - > + (q->rx_seed_index - q->rx_cons_index); > + if (unlikely(free_queue_space < m_out->nb_segs)) > + return 1; > + > + if (unlikely(m_in->nb_segs > 1)) > + ark_bb_enqueue_segmented_pkt(q, m_in, offset, meta, > meta_cnt); > + else > + ark_bb_enqueue_desc_fill(q, m_in, offset, > + ARK_DDM_SOP | ARK_DDM_EOP, > + meta, meta_cnt); > + > + /* We assume that the return mubf has exactly enough segments for > + * return data, which is 2048 bytes per segment. > + */ > + do { > + rx_idx =3D q->rx_seed_index & q->rx_queue_mask; > + q->rx_paddress_q[rx_idx] =3D m_out->buf_iova; > + q->rx_seed_index++; > + m_out =3D m_out->next; > + } while (m_out); > + > + return 0; > +} > + > +static inline void > +ark_bb_enqueue_finalize(struct rte_bbdev_queue_data *q_data, > + struct ark_bbdev_queue *q, > + void **ops, > + uint16_t nb_ops, uint16_t nb) > +{ > + /* BBDEV global stats */ > + /* These are not really errors, not sure why bbdev counts these. */ > + q_data->queue_stats.enqueue_err_count +=3D nb_ops - nb; > + q_data->queue_stats.enqueued_count +=3D nb; > + > + /* Notify HW that */ > + if (unlikely(nb =3D=3D 0)) > + return; > + > + ark_mpu_set_producer(q->tx_mpu, q->tx_prod_index); > + ark_mpu_set_producer(q->rx_mpu, q->rx_seed_index); > + > + /* Queue info for dequeue-side processing */ > + rte_ring_enqueue_burst(q->active_ops, > + (void **)ops, nb, NULL); > +} > + > +static int > +ark_bb_dequeue_segmented(struct rte_mbuf *mbuf0, > + int32_t *prx_cons_index, > + uint16_t pkt_len > + ) > +{ > + struct rte_mbuf *mbuf; > + uint16_t data_len; > + uint16_t remaining; > + uint16_t segments =3D 1; > + > + data_len =3D RTE_MIN(pkt_len, RTE_MBUF_DEFAULT_DATAROOM); > + remaining =3D pkt_len - data_len; > + > + mbuf =3D mbuf0; > + mbuf0->data_len =3D data_len; > + while (remaining) { > + segments +=3D 1; > + mbuf =3D mbuf->next; > + if (unlikely(mbuf =3D=3D 0)) { > + ARK_BBDEV_LOG(CRIT, "Expected chained mbuf with > " > + "at least %d segments for dequeue " > + "of packet length %d", > + segments, pkt_len); > + return 1; > + } > + > + data_len =3D RTE_MIN(remaining, > + RTE_MBUF_DEFAULT_DATAROOM); > + remaining -=3D data_len; > + > + mbuf->data_len =3D data_len; > + *prx_cons_index +=3D 1; > + } > + > + if (mbuf->next !=3D 0) { > + ARK_BBDEV_LOG(CRIT, "Expected chained mbuf with " > + "at exactly %d segments for dequeue " > + "of packet length %d. Found %d " > + "segments", > + segments, pkt_len, mbuf0->nb_segs); > + return 1; > + } > + return 0; > +} > + > +/* > +**************************************************************** > ******* > +** */ > +/* LDPC Decode ops */ > +static int16_t > +ark_bb_enqueue_ldpc_dec_one_op(struct ark_bbdev_queue *q, > + struct rte_bbdev_dec_op *this_op) { > + struct rte_bbdev_op_ldpc_dec *ldpc_dec_op =3D &this_op->ldpc_dec; > + struct rte_mbuf *m_in =3D ldpc_dec_op->input.data; > + struct rte_mbuf *m_out =3D ldpc_dec_op->hard_output.data; > + uint16_t offset =3D ldpc_dec_op->input.offset; > + uint32_t meta[5] =3D {0}; > + uint8_t meta_cnt =3D 0; > + > + /* User's meta move from bbdev op to Arkville HW */ > + if (ark_bb_user_enqueue_ldpc_dec(this_op, meta, &meta_cnt)) { > + ARK_BBDEV_LOG(ERR, "%s failed", __func__); > + return 1; > + } > + > + return ark_bb_enqueue_common(q, m_in, m_out, offset, meta, > meta_cnt); > +} > + > +/* Enqueue LDPC Decode -- burst */ > +static uint16_t > +ark_bb_enqueue_ldpc_dec_ops(struct rte_bbdev_queue_data *q_data, > + struct rte_bbdev_dec_op **ops, uint16_t nb_ops) { > + struct ark_bbdev_queue *q =3D q_data->queue_private; > + unsigned int max_enq; > + uint16_t nb; > + > + max_enq =3D rte_ring_free_count(q->active_ops); > + max_enq =3D RTE_MIN(max_enq, nb_ops); > + for (nb =3D 0; nb < max_enq; nb++) { > + if (ark_bb_enqueue_ldpc_dec_one_op(q, ops[nb])) > + break; > + } > + > + ark_bb_enqueue_finalize(q_data, q, (void **)ops, nb_ops, nb); > + return nb; > +} > + > +/* > +**************************************************************** > ******* > +** */ > +/* Dequeue LDPC Decode -- burst */ > +static uint16_t > +ark_bb_dequeue_ldpc_dec_ops(struct rte_bbdev_queue_data *q_data, > + struct rte_bbdev_dec_op **ops, uint16_t nb_ops) { > + struct ark_bbdev_queue *q =3D q_data->queue_private; > + struct rte_mbuf *mbuf; > + struct rte_bbdev_dec_op *this_op; > + struct ark_rx_meta *meta; > + uint32_t *usermeta; > + > + uint16_t nb =3D 0; > + int32_t prod_index =3D q->rx_prod_index; > + int32_t cons_index =3D q->rx_cons_index; > + > + q->tx_free_index =3D q->tx_cons_index; > + > + while ((prod_index - cons_index) > 0) { > + if (rte_ring_dequeue(q->active_ops, (void **)&this_op)) { > + ARK_BBDEV_LOG(ERR, "%s data ready but no op!", > + __func__); > + q_data->queue_stats.dequeue_err_count +=3D 1; > + break; > + } > + ops[nb] =3D this_op; > + > + mbuf =3D this_op->ldpc_dec.hard_output.data; > + > + /* META DATA embedded in headroom */ > + meta =3D RTE_PTR_ADD(mbuf->buf_addr, > ARK_RX_META_OFFSET); > + > + mbuf->pkt_len =3D meta->pkt_len; > + mbuf->data_len =3D meta->pkt_len; > + > + if (unlikely(meta->pkt_len > ARK_RX_MAX_NOCHAIN)) { > + if (ark_bb_dequeue_segmented(mbuf, &cons_index, > + meta->pkt_len)) > + q_data->queue_stats.dequeue_err_count +=3D > 1; > + } else if (mbuf->next !=3D 0) { > + ARK_BBDEV_LOG(CRIT, "Expected mbuf with " > + "at exactly 1 segments for dequeue " > + "of packet length %d. Found %d " > + "segments", > + meta->pkt_len, mbuf->nb_segs); > + q_data->queue_stats.dequeue_err_count +=3D 1; > + } > + > + usermeta =3D meta->user_meta; > + /* User's meta move from Arkville HW to bbdev OP */ > + ark_bb_user_dequeue_ldpc_dec(this_op, usermeta); > + nb++; > + cons_index++; > + if (nb >=3D nb_ops) > + break; > + } > + > + q->rx_cons_index =3D cons_index; > + > + /* BBdev stats */ > + q_data->queue_stats.dequeued_count +=3D nb; > + > + return nb; > +} > + > +/*************************************************************** > ******* > +****/ > +/* Enqueue LDPC Encode */ > +static int16_t > +ark_bb_enqueue_ldpc_enc_one_op(struct ark_bbdev_queue *q, > + struct rte_bbdev_enc_op *this_op) { > + struct rte_bbdev_op_ldpc_enc *ldpc_enc_op =3D &this_op->ldpc_enc; > + struct rte_mbuf *m_in =3D ldpc_enc_op->input.data; > + struct rte_mbuf *m_out =3D ldpc_enc_op->output.data; > + uint16_t offset =3D ldpc_enc_op->input.offset; > + uint32_t meta[5] =3D {0}; > + uint8_t meta_cnt =3D 0; > + > + /* User's meta move from bbdev op to Arkville HW */ > + if (ark_bb_user_enqueue_ldpc_enc(this_op, meta, &meta_cnt)) { > + ARK_BBDEV_LOG(ERR, "%s failed", __func__); > + return 1; > + } > + > + return ark_bb_enqueue_common(q, m_in, m_out, offset, meta, > meta_cnt); > +} > + > +/* Enqueue LDPC Encode -- burst */ > +static uint16_t > +ark_bb_enqueue_ldpc_enc_ops(struct rte_bbdev_queue_data *q_data, > + struct rte_bbdev_enc_op **ops, uint16_t nb_ops) { > + struct ark_bbdev_queue *q =3D q_data->queue_private; > + unsigned int max_enq; > + uint16_t nb; > + > + max_enq =3D rte_ring_free_count(q->active_ops); > + max_enq =3D RTE_MIN(max_enq, nb_ops); > + for (nb =3D 0; nb < max_enq; nb++) { > + if (ark_bb_enqueue_ldpc_enc_one_op(q, ops[nb])) > + break; > + } > + > + ark_bb_enqueue_finalize(q_data, q, (void **)ops, nb_ops, nb); > + return nb; > +} > + > +/* Dequeue LDPC Encode -- burst */ > +static uint16_t > +ark_bb_dequeue_ldpc_enc_ops(struct rte_bbdev_queue_data *q_data, > + struct rte_bbdev_enc_op **ops, uint16_t nb_ops) { > + struct ark_bbdev_queue *q =3D q_data->queue_private; > + struct rte_mbuf *mbuf; > + struct rte_bbdev_enc_op *this_op; > + struct ark_rx_meta *meta; > + uint32_t *usermeta; > + > + uint16_t nb =3D 0; > + int32_t prod_index =3D q->rx_prod_index; > + int32_t cons_index =3D q->rx_cons_index; > + > + q->tx_free_index =3D q->tx_cons_index; > + > + while ((prod_index - cons_index) > 0) { > + if (rte_ring_dequeue(q->active_ops, (void **)&this_op)) { > + ARK_BBDEV_LOG(ERR, "%s data ready but no op!", > + __func__); > + q_data->queue_stats.dequeue_err_count +=3D 1; > + break; > + } > + ops[nb] =3D this_op; > + > + mbuf =3D this_op->ldpc_enc.output.data; > + > + /* META DATA embedded in headroom */ > + meta =3D RTE_PTR_ADD(mbuf->buf_addr, > ARK_RX_META_OFFSET); > + > + mbuf->pkt_len =3D meta->pkt_len; > + mbuf->data_len =3D meta->pkt_len; > + usermeta =3D meta->user_meta; > + > + if (unlikely(meta->pkt_len > ARK_RX_MAX_NOCHAIN)) { > + if (ark_bb_dequeue_segmented(mbuf, &cons_index, > + meta->pkt_len)) > + q_data->queue_stats.dequeue_err_count +=3D > 1; > + } else if (mbuf->next !=3D 0) { > + ARK_BBDEV_LOG(CRIT, "Expected mbuf with " > + "at exactly 1 segments for dequeue " > + "of packet length %d. Found %d " > + "segments", > + meta->pkt_len, mbuf->nb_segs); > + q_data->queue_stats.dequeue_err_count +=3D 1; > + } > + > + /* User's meta move from Arkville HW to bbdev OP */ > + ark_bb_user_dequeue_ldpc_enc(this_op, usermeta); > + nb++; > + cons_index++; > + if (nb >=3D nb_ops) > + break; > + } > + > + q->rx_cons_index =3D cons_index; > + > + /* BBdev stats */ > + q_data->queue_stats.dequeued_count +=3D nb; > + > + return nb; > +} > + > +/*************************************************************** > ******* > +****/ > +/* > + *Initial device hardware configuration when device is opened > + * setup the DDM, and UDM; called once per PCIE device */ static int > +ark_bb_config_device(struct ark_bbdevice *ark_bb) { > + uint16_t num_q, i; > + struct ark_mpu_t *mpu; > + > + /* > + * Make sure that the packet director, generator and checker are in a > + * known state > + */ > + ark_bb->start_pg =3D 0; > + ark_bb->pg =3D ark_pktgen_init(ark_bb->pktgen.v, 0, 1); > + if (ark_bb->pg =3D=3D NULL) > + return -1; > + ark_pktgen_reset(ark_bb->pg); > + ark_bb->pc =3D ark_pktchkr_init(ark_bb->pktchkr.v, 0, 1); > + if (ark_bb->pc =3D=3D NULL) > + return -1; > + ark_pktchkr_stop(ark_bb->pc); > + ark_bb->pd =3D ark_pktdir_init(ark_bb->pktdir.v); > + if (ark_bb->pd =3D=3D NULL) > + return -1; > + > + /* Verify HW */ > + if (ark_udm_verify(ark_bb->udm.v)) > + return -1; > + if (ark_ddm_verify(ark_bb->ddm.v)) > + return -1; > + > + /* UDM */ > + if (ark_udm_reset(ark_bb->udm.v)) { > + ARK_BBDEV_LOG(ERR, "Unable to stop and reset UDM"); > + return -1; > + } > + /* Keep in reset until the MPU are cleared */ > + > + /* MPU reset */ > + mpu =3D ark_bb->mpurx.v; > + num_q =3D ark_api_num_queues(mpu); > + ark_bb->max_nb_queues =3D num_q; > + > + for (i =3D 0; i < num_q; i++) { > + ark_mpu_reset(mpu); > + mpu =3D RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET); > + } > + > + /* Only 1 queue supported in the udm */ > + ark_udm_stop(ark_bb->udm.v, 0); > + ark_udm_configure(ark_bb->udm.v, > + RTE_PKTMBUF_HEADROOM, > + bbdev->data->queues[q_id]->dataroom, > + ARK_RX_WRITE_TIME_NS); > + > + > + ark_udm_stats_reset(ark_bb->udm.v); > + ark_udm_stop(ark_bb->udm.v, 0); > + > + /* TX -- DDM */ > + if (ark_ddm_stop(ark_bb->ddm.v, 1)) > + ARK_BBDEV_LOG(ERR, "Unable to stop DDM"); > + > + mpu =3D ark_bb->mputx.v; > + num_q =3D ark_api_num_queues(mpu); > + for (i =3D 0; i < num_q; i++) { > + ark_mpu_reset(mpu); > + mpu =3D RTE_PTR_ADD(mpu, ARK_MPU_QOFFSET); > + } > + > + ark_ddm_reset(ark_bb->ddm.v); > + ark_ddm_stats_reset(ark_bb->ddm.v); > + > + ark_ddm_stop(ark_bb->ddm.v, 0); > + if (ark_bb->rqpacing) > + ark_rqp_stats_reset(ark_bb->rqpacing); > + > + ARK_BBDEV_LOG(INFO, "packet director set to 0x%x", ark_bb- > >pkt_dir_v); > + ark_pktdir_setup(ark_bb->pd, ark_bb->pkt_dir_v); > + > + if (ark_bb->pkt_gen_args[0]) { > + ARK_BBDEV_LOG(INFO, "Setting up the packet generator"); > + ark_pktgen_parse(ark_bb->pkt_gen_args); > + ark_pktgen_reset(ark_bb->pg); > + ark_pktgen_setup(ark_bb->pg); > + ark_bb->start_pg =3D 1; > + } > + > + return 0; > +} > + > +static int > +ark_bbdev_init(struct rte_bbdev *bbdev, struct rte_pci_driver *pci_drv) > +{ > + struct ark_bbdevice *ark_bb =3D bbdev->data->dev_private; > + struct rte_pci_device *pci_dev =3D RTE_DEV_TO_PCI(bbdev->device); > + bool rqpacing =3D false; > + int p; > + > + RTE_SET_USED(pci_drv); > + > + ark_bb->bar0 =3D (uint8_t *)pci_dev->mem_resource[0].addr; > + ark_bb->a_bar =3D (uint8_t *)pci_dev->mem_resource[2].addr; > + > + ark_bb->sysctrl.v =3D (void *)&ark_bb->bar0[ARK_SYSCTRL_BASE]; > + ark_bb->mpurx.v =3D (void *)&ark_bb->bar0[ARK_MPU_RX_BASE]; > + ark_bb->udm.v =3D (void *)&ark_bb->bar0[ARK_UDM_BASE]; > + ark_bb->mputx.v =3D (void *)&ark_bb->bar0[ARK_MPU_TX_BASE]; > + ark_bb->ddm.v =3D (void *)&ark_bb->bar0[ARK_DDM_BASE]; > + ark_bb->pktdir.v =3D (void *)&ark_bb->bar0[ARK_PKTDIR_BASE]; > + ark_bb->pktgen.v =3D (void *)&ark_bb->bar0[ARK_PKTGEN_BASE]; > + ark_bb->pktchkr.v =3D (void *)&ark_bb->bar0[ARK_PKTCHKR_BASE]; > + > + p =3D 0; > + while (ark_device_caps[p].device_id !=3D 0) { > + if (pci_dev->id.device_id =3D=3D ark_device_caps[p].device_id) { > + rqpacing =3D ark_device_caps[p].caps.rqpacing; > + break; > + } > + p++; > + } > + > + if (rqpacing) > + ark_bb->rqpacing =3D > + (struct ark_rqpace_t *)(ark_bb->bar0 + > ARK_RCPACING_BASE); > + else > + ark_bb->rqpacing =3D NULL; > + > + ark_bb->started =3D 0; > + > + ARK_BBDEV_LOG(INFO, "Sys Ctrl Const =3D 0x%x HW Commit_ID: > %08x", > + ark_bb->sysctrl.t32[4], > + rte_be_to_cpu_32(ark_bb->sysctrl.t32[0x20 / 4])); > + ARK_BBDEV_LOG(INFO, "Arkville HW Commit_ID: %08x", > + rte_be_to_cpu_32(ark_bb->sysctrl.t32[0x20 / 4])); > + > + /* If HW sanity test fails, return an error */ > + if (ark_bb->sysctrl.t32[4] !=3D 0xcafef00d) { > + ARK_BBDEV_LOG(ERR, > + "HW Sanity test has failed, expected constant" > + " 0x%x, read 0x%x (%s)", > + 0xcafef00d, > + ark_bb->sysctrl.t32[4], __func__); > + return -1; > + } > + > + return ark_bb_config_device(ark_bb); > +} > + > +static int > +ark_bbdev_uninit(struct rte_bbdev *bbdev) { > + struct ark_bbdevice *ark_bb =3D bbdev->data->dev_private; > + > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) > + return 0; > + > + ark_pktgen_uninit(ark_bb->pg); > + ark_pktchkr_uninit(ark_bb->pc); > + > + return 0; > +} > + > +static int > +ark_bbdev_probe(struct rte_pci_driver *pci_drv, > + struct rte_pci_device *pci_dev) > +{ > + struct rte_bbdev *bbdev =3D NULL; > + char dev_name[RTE_BBDEV_NAME_MAX_LEN]; > + struct ark_bbdevice *ark_bb; > + > + if (pci_dev =3D=3D NULL) > + return -EINVAL; > + > + rte_pci_device_name(&pci_dev->addr, dev_name, sizeof(dev_name)); > + > + /* Allocate memory to be used privately by drivers */ > + bbdev =3D rte_bbdev_allocate(pci_dev->device.name); > + if (bbdev =3D=3D NULL) > + return -ENODEV; > + > + /* allocate device private memory */ > + bbdev->data->dev_private =3D rte_zmalloc_socket(dev_name, > + sizeof(struct ark_bbdevice), > + RTE_CACHE_LINE_SIZE, > + pci_dev->device.numa_node); > + > + if (bbdev->data->dev_private =3D=3D NULL) { > + ARK_BBDEV_LOG(CRIT, > + "Allocate of %zu bytes for device \"%s\" > failed", > + sizeof(struct ark_bbdevice), dev_name); > + rte_bbdev_release(bbdev); > + return -ENOMEM; > + } > + ark_bb =3D bbdev->data->dev_private; > + /* Initialize ark_bb */ > + ark_bb->pkt_dir_v =3D 0x00110110; > + > + /* Fill HW specific part of device structure */ > + bbdev->device =3D &pci_dev->device; > + bbdev->intr_handle =3D NULL; > + bbdev->data->socket_id =3D pci_dev->device.numa_node; > + bbdev->dev_ops =3D &ark_bbdev_pmd_ops; > + if (pci_dev->device.devargs) > + parse_ark_bbdev_params(pci_dev->device.devargs->args, > ark_bb); > + > + > + /* Device specific initialization */ > + if (ark_bbdev_init(bbdev, pci_drv)) > + return -EIO; > + if (ark_bbdev_start(bbdev)) > + return -EIO; > + > + /* Core operations LDPC encode amd decode */ > + bbdev->enqueue_ldpc_enc_ops =3D ark_bb_enqueue_ldpc_enc_ops; > + bbdev->dequeue_ldpc_enc_ops =3D ark_bb_dequeue_ldpc_enc_ops; > + bbdev->enqueue_ldpc_dec_ops =3D ark_bb_enqueue_ldpc_dec_ops; > + bbdev->dequeue_ldpc_dec_ops =3D ark_bb_dequeue_ldpc_dec_ops; > + > + ARK_BBDEV_LOG(DEBUG, "bbdev id =3D %u [%s]", > + bbdev->data->dev_id, dev_name); > + > + return 0; > +} > + > +/* Uninitialize device */ > +static int > +ark_bbdev_remove(struct rte_pci_device *pci_dev) { > + struct rte_bbdev *bbdev; > + int ret; > + > + if (pci_dev =3D=3D NULL) > + return -EINVAL; > + > + /* Find device */ > + bbdev =3D rte_bbdev_get_named_dev(pci_dev->device.name); > + if (bbdev =3D=3D NULL) { > + ARK_BBDEV_LOG(CRIT, > + "Couldn't find HW dev \"%s\" to Uninitialize > it", > + pci_dev->device.name); > + return -ENODEV; > + } > + > + /* Arkville device close */ > + ark_bbdev_uninit(bbdev); > + rte_free(bbdev->data->dev_private); > + > + /* Close device */ > + ret =3D rte_bbdev_close(bbdev->data->dev_id); > + if (ret < 0) > + ARK_BBDEV_LOG(ERR, > + "Device %i failed to close during remove: %i", > + bbdev->data->dev_id, ret); > + > + return rte_bbdev_release(bbdev); > +} > + > +/* Operation for the PMD */ > +static const struct rte_bbdev_ops ark_bbdev_pmd_ops =3D { > + .info_get =3D ark_bbdev_info_get, > + .start =3D ark_bbdev_start, > + .stop =3D ark_bbdev_stop, > + .queue_setup =3D ark_bb_q_setup, > + .queue_release =3D ark_bb_q_release, > + .queue_start =3D ark_bb_q_start, > + .queue_stop =3D ark_bb_q_stop, > +}; > + > + > + > +static struct rte_pci_driver ark_bbdev_pmd_drv =3D { > + .probe =3D ark_bbdev_probe, > + .remove =3D ark_bbdev_remove, > + .id_table =3D pci_id_ark, > + .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING > +}; > + > +RTE_PMD_REGISTER_PCI(DRIVER_NAME, ark_bbdev_pmd_drv); > +RTE_PMD_REGISTER_PCI_TABLE(DRIVER_NAME, pci_id_ark); > +RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME, > + ARK_BBDEV_PKTGEN_ARG "=3D " > + ARK_BBDEV_PKTCHKR_ARG "=3D " > + ARK_BBDEV_PKTDIR_ARG "=3D" > + ); > diff --git a/drivers/baseband/ark/ark_bbdev_common.c > b/drivers/baseband/ark/ark_bbdev_common.c > new file mode 100644 > index 0000000000..6ef0f43654 > --- /dev/null > +++ b/drivers/baseband/ark/ark_bbdev_common.c > @@ -0,0 +1,125 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2016-2021 Atomic Rules LLC */ > + > +#include > + > +#include > +#include > + > +#include "ark_bbdev_common.h" > + > +static const char * const ark_bbdev_valid_params[] =3D { > + ARK_BBDEV_PKTDIR_ARG, > + ARK_BBDEV_PKTGEN_ARG, > + ARK_BBDEV_PKTCHKR_ARG, > + NULL > +}; > + > +/* Parse 16-bit integer from string argument */ static inline int > +parse_u16_arg(const char *key, const char *value, void *extra_args) { > + uint16_t *u16 =3D extra_args; > + unsigned int long result; > + > + if ((value =3D=3D NULL) || (extra_args =3D=3D NULL)) > + return -EINVAL; > + errno =3D 0; > + result =3D strtoul(value, NULL, 0); > + if ((result >=3D (1 << 16)) || (errno !=3D 0)) { > + ARK_BBDEV_LOG(ERR, "Invalid value %" PRIu64 " for %s", > result, key); > + return -ERANGE; > + } > + *u16 =3D (uint16_t)result; > + return 0; > +} > + > +static inline int > +process_pktdir_arg(const char *key, const char *value, > + void *extra_args) > +{ > + uint32_t *u32 =3D extra_args; > + ARK_BBDEV_LOG(DEBUG, "key =3D %s, value =3D %s", key, value); > + > + *u32 =3D strtol(value, NULL, 0); > + ARK_BBDEV_LOG(DEBUG, "pkt_dir_v =3D 0x%x", *u32); > + return 0; > +} > + > +static inline int > +process_file_args(const char *key, const char *value, void *extra_args) > +{ > + char *args =3D (char *)extra_args; > + ARK_BBDEV_LOG(DEBUG, "key =3D %s, value =3D %s", key, value); > + > + /* Open the configuration file */ > + FILE *file =3D fopen(value, "r"); > + char line[ARK_MAX_ARG_LEN]; > + int size =3D 0; > + int first =3D 1; > + > + if (file =3D=3D NULL) { > + ARK_BBDEV_LOG(ERR, "Unable to open config file %s", > + value); > + return -1; > + } > + > + while (fgets(line, sizeof(line), file)) { > + size +=3D strlen(line); > + if (size >=3D ARK_MAX_ARG_LEN) { > + ARK_BBDEV_LOG(ERR, "Unable to parse file %s args, > " > + "parameter list is too long", value); > + fclose(file); > + return -1; > + } > + if (first) { > + strncpy(args, line, ARK_MAX_ARG_LEN); > + first =3D 0; > + } else { > + strncat(args, line, ARK_MAX_ARG_LEN); > + } > + } > + ARK_BBDEV_LOG(DEBUG, "file =3D %s", args); > + fclose(file); > + return 0; > +} > + > + > +/* Parse parameters used to create device */ int > +parse_ark_bbdev_params(const char *input_args, > + struct ark_bbdevice *ark_bb) > +{ > + struct rte_kvargs *kvlist =3D NULL; > + int ret =3D 0; > + > + if (ark_bb =3D=3D NULL) > + return -EINVAL; > + if (input_args =3D=3D NULL) > + return ret; > + > + kvlist =3D rte_kvargs_parse(input_args, ark_bbdev_valid_params); > + if (kvlist =3D=3D NULL) > + return -EFAULT; > + > + ret =3D rte_kvargs_process(kvlist, ARK_BBDEV_PKTDIR_ARG, > + &process_pktdir_arg, &ark_bb->pkt_dir_v); > + if (ret < 0) > + goto exit; > + > + ret =3D rte_kvargs_process(kvlist, ARK_BBDEV_PKTGEN_ARG, > + &process_file_args, &ark_bb- > >pkt_gen_args); > + if (ret < 0) > + goto exit; > + > + ret =3D rte_kvargs_process(kvlist, ARK_BBDEV_PKTCHKR_ARG, > + &process_file_args, &ark_bb- > >pkt_chkr_args); > + if (ret < 0) > + goto exit; > + > + exit: > + if (kvlist) > + rte_kvargs_free(kvlist); > + return ret; > +} > diff --git a/drivers/baseband/ark/ark_bbdev_common.h > b/drivers/baseband/ark/ark_bbdev_common.h > new file mode 100644 > index 0000000000..670e7e86d6 > --- /dev/null > +++ b/drivers/baseband/ark/ark_bbdev_common.h > @@ -0,0 +1,92 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2016-2021 Atomic Rules LLC */ > + > +#ifndef _ARK_BBDEV_COMMON_H_ > +#define _ARK_BBDEV_COMMON_H_ > + > +#include "ark_pktchkr.h" > +#include "ark_pktdir.h" > +#include "ark_pktgen.h" > + > +#define ARK_MAX_ARG_LEN 256 > + > +/* Acceptable params for ark BBDEV devices */ > +/* > + * The packet generator is a functional block used to generate packet > + * patterns for testing. It is not intended for nominal use. > + */ > +#define ARK_BBDEV_PKTGEN_ARG "Pkt_gen" > + > +/* > + * The packet checker is a functional block used to verify packet > + * patterns for testing. It is not intended for nominal use. > + */ > +#define ARK_BBDEV_PKTCHKR_ARG "Pkt_chkr" > + > +/* > + * The packet director is used to select the internal ingress and > + * egress packets paths during testing. It is not intended for > + * nominal use. > + */ > +#define ARK_BBDEV_PKTDIR_ARG "Pkt_dir" > + > + > +#define def_ptr(type, name) \ > + union type { \ > + uint64_t *t64; \ > + uint32_t *t32; \ > + uint16_t *t16; \ > + uint8_t *t8; \ > + void *v; \ > + } name > + > +/* > + * Structure to store private data for each PF/VF instance. > + */ > +struct ark_bbdevice { > + /* Our Bar 0 */ > + uint8_t *bar0; > + > + /* Application Bar needed for extensions */ > + uint8_t *a_bar; > + > + /* Arkville hardware block offsets */ > + def_ptr(sys_ctrl, sysctrl); > + def_ptr(pkt_gen, pktgen); > + def_ptr(mpu_rx, mpurx); > + def_ptr(UDM, udm); > + def_ptr(mpu_tx, mputx); > + def_ptr(DDM, ddm); > + def_ptr(pkt_dir, pktdir); > + def_ptr(pkt_chkr, pktchkr); > + struct ark_rqpace_t *rqpacing; > + > + /* Pointers to packet generator and checker */ > + int start_pg; > + ark_pkt_gen_t pg; > + ark_pkt_chkr_t pc; > + ark_pkt_dir_t pd; > + > + /* Packet generator/checker args */ > + char pkt_gen_args[ARK_MAX_ARG_LEN]; > + char pkt_chkr_args[ARK_MAX_ARG_LEN]; > + uint32_t pkt_dir_v; > + > + int started; > + unsigned int max_nb_queues; /**< Max number of queues */ > + > +}; > + > + > +/* Log message for PMD */ > +extern int ark_bbdev_logtype; > + > +/* Helper macro for logging */ > +#define ARK_BBDEV_LOG(level, fmt, ...) \ > + rte_log(RTE_LOG_ ## level, ark_bbdev_logtype, \ > + "ARK_BBD: " fmt "\n", ##__VA_ARGS__) > + > +int parse_ark_bbdev_params(const char *argv, struct ark_bbdevice *dev); > + > +#endif > diff --git a/drivers/baseband/ark/ark_bbdev_custom.c > b/drivers/baseband/ark/ark_bbdev_custom.c > new file mode 100644 > index 0000000000..6b1553abe1 > --- /dev/null > +++ b/drivers/baseband/ark/ark_bbdev_custom.c > @@ -0,0 +1,201 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2016-2021 Atomic Rules LLC */ > + > +#include > +#include > + > +#include > +#include /* For debug */ > + > + > +#include "ark_bbdev_common.h" > +#include "ark_bbdev_custom.h" > + > +/* It is expected that functions in this file will be modified based on > + * specifics of the FPGA hardware beyond the core Arkville > + * components. > + */ > + > +/* bytyes must be range of 0 to 20 */ > +static inline > +uint8_t ark_bb_cvt_bytes_meta_cnt(size_t bytes) { > + return (bytes + 3) / 8; > +} > + > +void > +ark_bbdev_info_get(struct rte_bbdev *dev, > + struct rte_bbdev_driver_info *dev_info) { > + struct ark_bbdevice *ark_bb =3D dev->data->dev_private; > + > + static const struct rte_bbdev_op_cap bbdev_capabilities[] =3D { > + { > + .type =3D RTE_BBDEV_OP_LDPC_DEC, > + .cap.ldpc_dec =3D { > + .capability_flags =3D > + RTE_BBDEV_LDPC_CRC_24B_ATTACH > | > + RTE_BBDEV_LDPC_RATE_MATCH, > + .num_buffers_src =3D > + > RTE_BBDEV_LDPC_MAX_CODE_BLOCKS, > + .num_buffers_hard_out =3D > + > RTE_BBDEV_LDPC_MAX_CODE_BLOCKS > + } > + }, > + { > + .type =3D RTE_BBDEV_OP_LDPC_ENC, > + .cap.ldpc_enc =3D { > + .capability_flags =3D > + RTE_BBDEV_LDPC_CRC_24B_ATTACH > | > + RTE_BBDEV_LDPC_RATE_MATCH, > + .num_buffers_src =3D > + > RTE_BBDEV_LDPC_MAX_CODE_BLOCKS, > + .num_buffers_dst =3D > + > RTE_BBDEV_LDPC_MAX_CODE_BLOCKS > + } > + }, > + RTE_BBDEV_END_OF_CAPABILITIES_LIST(), > + }; > + > + static struct rte_bbdev_queue_conf default_queue_conf =3D { > + .queue_size =3D RTE_BBDEV_QUEUE_SIZE_LIMIT, > + }; > + > + default_queue_conf.socket =3D dev->data->socket_id; > + > + dev_info->driver_name =3D RTE_STR(DRIVER_NAME); > + dev_info->max_num_queues =3D ark_bb->max_nb_queues; > + dev_info->queue_size_lim =3D RTE_BBDEV_QUEUE_SIZE_LIMIT; > + dev_info->hardware_accelerated =3D true; > + dev_info->max_dl_queue_priority =3D 0; > + dev_info->max_ul_queue_priority =3D 0; > + dev_info->default_queue_conf =3D default_queue_conf; > + dev_info->capabilities =3D bbdev_capabilities; > + dev_info->cpu_flag_reqs =3D NULL; > + dev_info->min_alignment =3D 4; > + > +} > + > +/* Structure defining layout of the ldpc command struct */ struct > +ark_bb_ldpc_enc_meta { > + uint16_t header; > + uint8_t rv_index:2, > + basegraph:1, > + code_block_mode:1, > + rfu_71_68:4; > + > + uint8_t q_m; > + uint32_t e_ea; > + uint32_t eb; > + uint8_t c; > + uint8_t cab; > + uint16_t n_cb; > + uint16_t pad; > + uint16_t trailer; > +} __rte_packed; > + > +/* The size must be less then 20 Bytes */ static_assert(sizeof(struct > +ark_bb_ldpc_enc_meta) <=3D 20, "struct size"); > + > +/* Custom operation on equeue ldpc operation */ > +/* Do these function need queue number? */ > +/* Maximum of 20 bytes */ > +int > +ark_bb_user_enqueue_ldpc_enc(struct rte_bbdev_enc_op *enc_op, > + uint32_t *meta, uint8_t *meta_cnt) { > + struct rte_bbdev_op_ldpc_enc *ldpc_enc_op =3D &enc_op->ldpc_enc; > + struct ark_bb_ldpc_enc_meta *src =3D (struct ark_bb_ldpc_enc_meta > +*)meta; > + > + src->header =3D 0x4321; /* For testings */ > + src->trailer =3D 0xFEDC; > + > + src->rv_index =3D ldpc_enc_op->rv_index; > + src->basegraph =3D ldpc_enc_op->basegraph; > + src->code_block_mode =3D ldpc_enc_op->code_block_mode; > + > + src->q_m =3D ldpc_enc_op->q_m; > + src->e_ea =3D 0xABCD; > + src->eb =3D ldpc_enc_op->tb_params.eb; > + src->c =3D ldpc_enc_op->tb_params.c; > + src->cab =3D ldpc_enc_op->tb_params.cab; > + > + src->n_cb =3D 0; > + > + meta[0] =3D 0x11111110; > + meta[1] =3D 0x22222220; > + meta[2] =3D 0x33333330; > + meta[3] =3D 0x44444440; > + meta[4] =3D 0x55555550; > + > + *meta_cnt =3D ark_bb_cvt_bytes_meta_cnt( > + sizeof(struct ark_bb_ldpc_enc_meta)); > + return 0; > +} > + > +/* Custom operation on dequeue ldpc operation */ int > +ark_bb_user_dequeue_ldpc_enc(struct rte_bbdev_enc_op *enc_op, > + const uint32_t *usermeta) > +{ > + static int dump; /* =3D 0 */ > + /* Just compare with what was sent? */ > + uint32_t meta_in[5] =3D {0}; > + uint8_t meta_cnt; > + > + ark_bb_user_enqueue_ldpc_enc(enc_op, meta_in, &meta_cnt); > + if (memcmp(usermeta, meta_in, 3 + (meta_cnt * 8))) { > + fprintf(stderr, > + "------------------------------------------\n"); > + rte_hexdump(stdout, "meta difference for lpdc_enc IN", > + meta_in, 20); > + rte_hexdump(stdout, "meta difference for lpdc_enc OUT", > + usermeta, 20); > + } else if (dump) { > + rte_hexdump(stdout, "DUMP lpdc_enc IN", usermeta, 20); > + dump--; > + } > + > + return 0; > +} > + > + > +/* Turbo op call backs for user meta data */ int > +ark_bb_user_enqueue_ldpc_dec(struct rte_bbdev_dec_op *enc_op, > + uint32_t *meta, uint8_t *meta_cnt) { > + RTE_SET_USED(enc_op); > + meta[0] =3D 0xF1111110; > + meta[1] =3D 0xF2222220; > + meta[2] =3D 0xF3333330; > + meta[3] =3D 0xF4444440; > + meta[4] =3D 0xF5555550; > + > + *meta_cnt =3D ark_bb_cvt_bytes_meta_cnt(20); > + return 0; > +} > + > +int ark_bb_user_dequeue_ldpc_dec(struct rte_bbdev_dec_op *enc_op, > + const uint32_t *usermeta) > +{ > + RTE_SET_USED(enc_op); > + static int dump; /* =3D 0 */ > + /* Just compare with what was sent? */ > + uint32_t meta_in[5] =3D {0}; > + uint8_t meta_cnt; > + > + ark_bb_user_enqueue_ldpc_dec(enc_op, meta_in, &meta_cnt); > + if (memcmp(usermeta, meta_in, 3 + (meta_cnt * 8))) { > + fprintf(stderr, > + "------------------------------------------\n"); > + rte_hexdump(stdout, "meta difference for lpdc_enc IN", > + meta_in, 20); > + rte_hexdump(stdout, "meta difference for lpdc_enc OUT", > + usermeta, 20); > + } else if (dump) { > + rte_hexdump(stdout, "DUMP lpdc_enc IN", usermeta, 20); > + dump--; > + } > + return 0; > +} > diff --git a/drivers/baseband/ark/ark_bbdev_custom.h > b/drivers/baseband/ark/ark_bbdev_custom.h > new file mode 100644 > index 0000000000..32a2ef6bb6 > --- /dev/null > +++ b/drivers/baseband/ark/ark_bbdev_custom.h > @@ -0,0 +1,30 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2016-2021 Atomic Rules LLC */ > + > +#ifndef _ARK_BBDEV_CUSTOM_H_ > +#define _ARK_BBDEV_CUSTOM_H_ > + > +#include > + > +/* Forward declarations */ > +struct rte_bbdev; > +struct rte_bbdev_driver_info; > +struct rte_bbdev_enc_op; > +struct rte_bbdev_dec_op; > +struct rte_mbuf; > + > +void ark_bbdev_info_get(struct rte_bbdev *dev, > + struct rte_bbdev_driver_info *dev_info); > + > +int ark_bb_user_enqueue_ldpc_dec(struct rte_bbdev_dec_op *enc_op, > + uint32_t *meta, uint8_t *meta_cnt); int > +ark_bb_user_dequeue_ldpc_dec(struct rte_bbdev_dec_op *enc_op, > + const uint32_t *usermeta); > + > +int ark_bb_user_enqueue_ldpc_enc(struct rte_bbdev_enc_op *enc_op, > + uint32_t *meta, uint8_t *meta_cnt); int > +ark_bb_user_dequeue_ldpc_enc(struct rte_bbdev_enc_op *enc_op, > + const uint32_t *usermeta); > + > +#endif > diff --git a/drivers/baseband/ark/meson.build > b/drivers/baseband/ark/meson.build > new file mode 100644 > index 0000000000..b876f05c6e > --- /dev/null > +++ b/drivers/baseband/ark/meson.build > @@ -0,0 +1,11 @@ > +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Luca > +Boccassi > + > +deps +=3D ['common_ark', 'bbdev', 'bus_pci', 'pci', 'ring'] sources =3D > +files( > + 'ark_bbdev.c', > + 'ark_bbdev_common.c', > + 'ark_bbdev_custom.c' > + ) > + > +includes +=3D include_directories('../../common/ark') > diff --git a/drivers/baseband/ark/version.map > b/drivers/baseband/ark/version.map > new file mode 100644 > index 0000000000..4a76d1d52d > --- /dev/null > +++ b/drivers/baseband/ark/version.map > @@ -0,0 +1,3 @@ > +DPDK_21 { > + local: *; > +}; > -- > 2.25.1