From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50040.outbound.protection.outlook.com [40.107.5.40]) by dpdk.org (Postfix) with ESMTP id 970CEAAC0 for ; Fri, 20 Apr 2018 12:34:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ZpsxBde6/c8wOX9KHOcp7OXjYIMH3ztDSm0yAhnJ7xM=; b=YCnQynIa71XstqfnT7NwoqEvlbuv04fmkN5+pj0rSE5Z7ruHOiMWQiD82mAbCzReLfo3DhWApNjKZAQUSbGJBW9NDtB3P2wmDdUI8mLt+rVoZx64RUQ/2Bqq7saXrUfMJMo7XgMP7U98+lU/de8CLmkYDHAszciOsk0GcEdemBY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=nipun.gupta@nxp.com; Received: from b27504-OptiPlex-790.ap.freescale.net (14.142.187.166) by HE1PR0401MB2427.eurprd04.prod.outlook.com (2603:10a6:3:25::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Fri, 20 Apr 2018 10:34:40 +0000 From: Nipun Gupta To: shreyansh.jain@nxp.com, thomas@monjalon.net, hemant.agrawal@nxp.com Cc: dev@dpdk.org, Nipun Gupta Date: Fri, 20 Apr 2018 16:01:02 +0530 Message-Id: <1524220264-17281-8-git-send-email-nipun.gupta@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524220264-17281-1-git-send-email-nipun.gupta@nxp.com> References: <1523114224-9852-1-git-send-email-nipun.gupta@nxp.com> <1524220264-17281-1-git-send-email-nipun.gupta@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: BM1PR01CA0102.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::18) To HE1PR0401MB2427.eurprd04.prod.outlook.com (2603:10a6:3:25::24) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(2017052603328)(7153060)(7193020); SRVR:HE1PR0401MB2427; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0401MB2427; 3:LJK+m2mo3LCahSJz5TmX7YvHFEMMrWOOp8M9IkX9U+BAwPWnrHI3YwJPL1XUyWkfNHrH4J8/BiSb7JGiMCZFb3el4wImFBIqO28JintNgw2TpukCDQmnLb0Uwy7Ar71PST/WQZ33zuDqxMDuDF2vsCWv56/zyztSkallaWnKKnsDa6FovM8SmWpJcvUNLkrmgtfsrKJ19cFOdOgGTCc4nImkoXCxSCSQin/pbKf0CW7GuNsK1eHeZnNLctsmd3wd; 25:r5CTTMUJw3qY+7KjUH5/P1FuRLGeLCrtHpjbmq0iHHTE7WE9rbSEtKGNIvcjoFk5TBgDesYjERmXJoCkNXSkEOi69fXQdJlqnxtpq/KM5ZusdLU0pQPz0jFcfUuf3P9LwMMy6EB+GDKrj1P8r3BqTT+zSFZl0CpTx62UJJrO3DpMmHw6lujkWO5c0jIblFTJZFATW+kPRNEq5A1qPRg8Gl595aY9mLoc3jWqftixUyGvX3zUpUXrUCHtZ7HHBAFB7sQ5lwed/kwcHZdISEV9GU3HL6dTzOTBIEgfyqX9dTOq2tbFIERphMRaSs/a84TaoAjT396kEMt8qxa6+F39cA==; 31:xVGIkVoSicQgae/QkJbthUROEyI77tBxEarQjwSUHKhg+n7gAS/q/6qTCt4fQkvTHbf/Lp4ySUBEJXVIYs/pT5cVtJDVRtxJlFLYj31FaQd9/Zj3T1p5PaFWpaiUbbrBY5sB/71V5HoQDPyMZZDZ/xeoQXdzzdbfHu79aO1iTZWgiSr/8eYHZQO860+rDidkPZySCLzzodh7OJCtWRG9pzbXakH25i4IcoZlnLhOLHM= X-MS-TrafficTypeDiagnostic: HE1PR0401MB2427: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0401MB2427; 20:3YndIRZ3uvJOwHgjARyTnp4sgeaSDWIBTQX3Sq4V7VM5ZL3jRKuxe+wDi/FagfKBHh4H/dgRlrSmaViKfhgB1qriKUNVLlfJ3oIAr7rvPDpnMHOPQXxPVblCfYpnmmjhmMunf0ovPku+qAQYWUf84GqgmZ8SjHPg/tzomlUt0d2q8/r8R9aJBVwL7GzWo1YbSIpqoJf1EiqQRqtMfQBnptFwmHD4Nv87Gjwh+DbF4wcTuclFKKXyeCkRAOu7B3ShLHgf3tovJZ9PfVgVEhBQA0BrZbCZbf37cyFzoEuYBBTjbrbgzeLU3pIJZces2kKYENGpn43gujOsvXZaHHqghJJPPATT1S3GS+HxDjHkp19rTdUCuNwlu/j0r7K83y5HSBs+blATYYIOgUMWoa3zwoET5k2UlnstUTtJlUaKM3iKUYx+hG9MU3hpUx6DHEmZFbmmeBYLhpihIOaoNi8NXN/n5BUEB8TH90tJCGbrCa+iHmWUpu0EimIbMSRDjqlX; 4:YhzBbCcHNF3JYXPR5WaSkYwghGYvkv2K3CZ0HwWcWdB0aPwze0lWAKW2J5ExXA/L/L5wTBm61+o1rmOECPS7X3rA6uZEwJRe2vnXtdwlfkPZBCnUQdeISF7TR9T6cS9TDQ2pmNPOx3TQI70StKTWkr6Cb2bbw+5yw7bA+I53ZfaKeRy+EZE45qaSDGCiDKE3QM0gbFZTWJjN/8qWRiIP6UbRRDMLHnVd5KNyy3yZ0wADnBbJATin0q4K+o1cMVnN8QuYPmHDTyFnWSXfBkjbDBInt/WBMLID4ylorseXqHM8nZ86DLQWlO0K5D/794c5mSm+EN9p15dJABg03Wf4IzMMZemxdLnPd1bI4ePAK4U= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231232)(944501393)(52105095)(10201501046)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:HE1PR0401MB2427; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0401MB2427; X-Forefront-PRVS: 0648FCFFA8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(366004)(39860400002)(39380400002)(4326008)(16526019)(59450400001)(6506007)(48376002)(386003)(8936002)(8676002)(81166006)(26005)(36756003)(25786009)(6116002)(3846002)(6486002)(575784001)(86362001)(956004)(11346002)(446003)(476003)(52116002)(2616005)(6666003)(76176011)(6636002)(5009440100003)(51416003)(6512007)(53936002)(2906002)(316002)(16586007)(50226002)(50466002)(305945005)(551934003)(44832011)(478600001)(7736002)(47776003)(5660300001)(66066001)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0401MB2427; H:b27504-OptiPlex-790.ap.freescale.net; FPR:; SPF:None; LANG:en; MLV:nov; PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0401MB2427; 23:YVcFoB3GW3PGzsHi7VEe+esUWBbgu26L+Ja7Zg6?= =?us-ascii?Q?dBLf3wNPknb7TqT/oB1DExMWxKkarBMncV9/WvRHtT+ctO2CggoPXxx6v40p?= =?us-ascii?Q?wLsw+ZNn88iQnBaBzXgUJpcEy2SoTkZ9zEwfQSWVQWc6JCrS70mDWaxa/78+?= =?us-ascii?Q?AZH1XWJtL1dxhfINfXZQVurUD1awPFTp5zTA0ZWVx9yB0EQ2IrlIhxtcbxuI?= =?us-ascii?Q?U/yJPTdFMl6yxqy1Im0b0qbIs44K63XQzxqWgNi4iS3aeRq+tHOZoVOfElg4?= =?us-ascii?Q?JoCYUPPB3LCG3tzliqIzVgeZB+dq55+GVp3TQ71huGHWF+I4d/qNku7b8ODY?= =?us-ascii?Q?lyVy3vbiXDhH4wMCJiut0bKq+SclxW3Z4jJAKL+V43ss4+OU27eYhHX0hpxT?= =?us-ascii?Q?bGDbEqUEGoIerHtzqKoq5wE5XoH9qcvZBNl5D4z0/OyJklVdMzKpUMD/82QT?= =?us-ascii?Q?SgSFk35XgsyuMTe2mt4Whes/OJX3lNiIVFmY7IoR4MopFKg2bMkXYBBQriyr?= =?us-ascii?Q?hxKhWBVls/2p3hXK+L9e3T1GUOwTEFNi4DRwCK5LynrgP/euPsEjvt6Dr4P0?= =?us-ascii?Q?VOHhOeWawm5AB6/O9oYw0l19WQuIml0NpCHIfa5tQqE1AMy1tfXqStoN4lE7?= =?us-ascii?Q?qyC4gKWXHlbv7v2ZRooNIIZAaEIGYAQqtd47eVhubHSQo+rnH69SHAJwL+e7?= =?us-ascii?Q?N4Aw4D1Hh/8lE4xbtojHPL5G1Es3LSVQzZ6mwvpt9hthdXEUZlXij/nTXi2m?= =?us-ascii?Q?PtOYptHhHc1Fa24N/p4bCw1Vj7IySH0STW6L21uK+34ly52tKtaGcB/LdsZy?= =?us-ascii?Q?AA7fc9Nw3ul+WeaGKttMcrp5oTZ04J7kFzVqTNfiUsGC56h8yClem6M622Uz?= =?us-ascii?Q?2WQF0MG2d964RD31OF84IRBgWYUf7PxRwPjSYva99t34wPseZ7E2pciBIHpl?= =?us-ascii?Q?hLd+LzscTfZmPcRjqFKRfl9FCwKCOAFUPdU/GuR6n+Cpb/JRdd0yFjpqsbX8?= =?us-ascii?Q?0d7lPjrU1LA/C09qgvrnxGecRC9SH0Sgyp8kZNhW9DgDp65AdmL4lqweH1OX?= =?us-ascii?Q?jAyLuz/OtELEGj3LZrrHjvfH28XbKMCAJTN/dxZAAlsfcBn0xHmeli8m9Wiz?= =?us-ascii?Q?znIWV0sPonuPMxpmQiaZQbrl6AJJTMERc6Ausio84ArwYUssRmFkRiw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Antispam-Message-Info: wGeQ7vjKN0hFASpBzVmIW2Sy8HDq+P6MYnLBmRTmEWQ2BxByNhwQ6GE+3NO2S2/bIBIY+NrwpKv0gOV1dao4ZiViv6IT8WOUheGrk4ooZUbeutwaK6agaTXacu3IHBhtRqENVv3HJZEFdxllPAW+LXtY/TuLMpDmFkd/U3x2JalkRsPrw6fZoMj8BvPCDDpj X-Microsoft-Exchange-Diagnostics: 1; HE1PR0401MB2427; 6:MurQCdLHO+mK0pTgzJEq9kWMXWXFWie8mFVNmOJjMltjsSkL09qfHcVCQoOq7ZaXqO/ljxW2yfmmufgsKRz9L2Pkrpxu8JAp1sVkb5fQgFSvh9MXPV8yIAVzEU/8n8EodY2h7RdMRJFh/VNA5hBp/3/jUC8QURhuiqz6u80yp7bHqhf+fJMXnLH8T5wszDAm4O6JXuAQ/qzlVVNxUzAqI7kPNCGjFyeoVR6prOm1q6x4biF60ZmH+kh9cGkmoh0hcmyr9XYqxCEeHO4Q35KDYAtvd3RuZD57crcb5stJi6DDm8oq29Md3K86/jw4iDDWTZve70IaBMRPlF33CD4Eo78rnLoytFiYQh3dw6qVotCQVCho+AqK9R7JZJ+vb7EHjoIJBgtLOFyU2v2C4ReowIHVlTmSXLwc/RfmMg1JPvmIF66Pue/Jn7/IMQO6RSTv8Kq1uviTiiHyBu2QzzHSag==; 5:gBWbLKUCGOwY1dfaHYrWa1LDnmDCWBx0Ls3HL8naYhYm4tlAJhVQlPBNt9hDKGi2y54YRy4cayx8EJYj7SiIiV7itcgytA+nspGl9vU6DvFmcz7CxR+KQSNqqJDzggnD3x9sYSOmrdFaC6sLfbeExUdJb/1ir+tCgsS1Ya1LHt0=; 24:F7cdn3Qyk1nUsAB+xYYd+gUxwG027FsJpNrVm6QZwfWMrj7V8HwPvhO5Xk/Dpfy570ucLqHidbqWTCGbnLXlxEr8v/QEbtF1cdu8D0Dtp9M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0401MB2427; 7:KzxXKgoEyenGV9HBfaoGYjP0Uyg+jxFJ2eylc0nhWrq1cRG+WzT/Lqv3VI8Q2CfRf9Ep18wTcNRKktfrRuCCDObd6WEH5bsk1a1HLfHcQq/FzF+r51KXClLNBuYJ9KQyOvdasFgXHuoGEVFSK/pBtdmYFcnLUnyA7cTS6p4bodcvtoU022pWRj62v7nxivrdXKRVfPYP6pkNeL+sm4n19eZDr7zwaEAxtk4i45Lew4AcaW+uyDLs6/fdmHfbLYqM X-MS-Office365-Filtering-Correlation-Id: a0eb420b-57bb-42eb-7861-08d5a6aa5398 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2018 10:34:40.7445 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0eb420b-57bb-42eb-7861-08d5a6aa5398 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0401MB2427 Subject: [dpdk-dev] [PATCH 7/9 v3] raw/dpaa2_qdma: support enq and deq operations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Apr 2018 10:34:44 -0000 Signed-off-by: Nipun Gupta --- drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 332 +++++++++++++++++++++ drivers/raw/dpaa2_qdma/dpaa2_qdma.h | 21 ++ drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h | 70 +++++ .../raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map | 4 + 4 files changed, 427 insertions(+) diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c index 2325a8d..6e3bf49 100644 --- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c +++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c @@ -344,6 +344,338 @@ return i; } +static void +dpaa2_qdma_populate_fle(struct qbman_fle *fle, + uint64_t src, uint64_t dest, + size_t len, uint32_t flags) +{ + struct qdma_sdd *sdd; + + DPAA2_QDMA_FUNC_TRACE(); + + sdd = (struct qdma_sdd *)((uint8_t *)(fle) + + (DPAA2_QDMA_MAX_FLE * sizeof(struct qbman_fle))); + + /* first frame list to source descriptor */ + DPAA2_SET_FLE_ADDR(fle, DPAA2_VADDR_TO_IOVA(sdd)); + DPAA2_SET_FLE_LEN(fle, (2 * (sizeof(struct qdma_sdd)))); + + /* source and destination descriptor */ + DPAA2_SET_SDD_RD_COHERENT(sdd); /* source descriptor CMD */ + sdd++; + DPAA2_SET_SDD_WR_COHERENT(sdd); /* dest descriptor CMD */ + + fle++; + /* source frame list to source buffer */ + if (flags & RTE_QDMA_JOB_SRC_PHY) { + DPAA2_SET_FLE_ADDR(fle, src); + DPAA2_SET_FLE_BMT(fle); + } else { + DPAA2_SET_FLE_ADDR(fle, DPAA2_VADDR_TO_IOVA(src)); + } + DPAA2_SET_FLE_LEN(fle, len); + + fle++; + /* destination frame list to destination buffer */ + if (flags & RTE_QDMA_JOB_DEST_PHY) { + DPAA2_SET_FLE_BMT(fle); + DPAA2_SET_FLE_ADDR(fle, dest); + } else { + DPAA2_SET_FLE_ADDR(fle, DPAA2_VADDR_TO_IOVA(dest)); + } + DPAA2_SET_FLE_LEN(fle, len); + + /* Final bit: 1, for last frame list */ + DPAA2_SET_FLE_FIN(fle); +} + +static int +dpdmai_dev_enqueue(struct dpaa2_dpdmai_dev *dpdmai_dev, + uint16_t txq_id, + uint16_t vq_id, + struct rte_qdma_job *job) +{ + struct qdma_io_meta *io_meta; + struct qbman_fd fd = {}; + struct dpaa2_queue *txq; + struct qbman_fle *fle; + struct qbman_eq_desc eqdesc; + struct qbman_swp *swp; + int ret; + + DPAA2_QDMA_FUNC_TRACE(); + + if (unlikely(!DPAA2_PER_LCORE_DPIO)) { + ret = dpaa2_affine_qbman_swp(); + if (ret) { + DPAA2_QDMA_ERR("Failure in affining portal"); + return 0; + } + } + swp = DPAA2_PER_LCORE_PORTAL; + + txq = &(dpdmai_dev->tx_queue[txq_id]); + + /* Prepare enqueue descriptor */ + qbman_eq_desc_clear(&eqdesc); + qbman_eq_desc_set_fq(&eqdesc, txq->fqid); + qbman_eq_desc_set_no_orp(&eqdesc, 0); + qbman_eq_desc_set_response(&eqdesc, 0, 0); + + /* + * Get an FLE/SDD from FLE pool. + * Note: IO metadata is before the FLE and SDD memory. + */ + ret = rte_mempool_get(qdma_dev.fle_pool, (void **)(&io_meta)); + if (ret) { + DPAA2_QDMA_DP_WARN("Memory alloc failed for FLE"); + return ret; + } + + /* Set the metadata */ + io_meta->cnxt = (size_t)job; + io_meta->id = vq_id; + + fle = (struct qbman_fle *)(io_meta + 1); + + /* populate Frame descriptor */ + DPAA2_SET_FD_ADDR(&fd, DPAA2_VADDR_TO_IOVA(fle)); + DPAA2_SET_FD_COMPOUND_FMT(&fd); + DPAA2_SET_FD_FRC(&fd, QDMA_SER_CTX); + + /* Populate FLE */ + memset(fle, 0, QDMA_FLE_POOL_SIZE); + dpaa2_qdma_populate_fle(fle, job->src, job->dest, job->len, job->flags); + + /* Enqueue the packet to the QBMAN */ + do { + ret = qbman_swp_enqueue_multiple(swp, &eqdesc, &fd, NULL, 1); + if (ret < 0 && ret != -EBUSY) + DPAA2_QDMA_ERR("Transmit failure with err: %d", ret); + } while (ret == -EBUSY); + + DPAA2_QDMA_DP_DEBUG("Successfully transmitted a packet"); + + return ret; +} + +int +rte_qdma_vq_enqueue_multi(uint16_t vq_id, + struct rte_qdma_job **job, + uint16_t nb_jobs) +{ + int i, ret; + + DPAA2_QDMA_FUNC_TRACE(); + + for (i = 0; i < nb_jobs; i++) { + ret = rte_qdma_vq_enqueue(vq_id, job[i]); + if (ret < 0) + break; + } + + return i; +} + +int +rte_qdma_vq_enqueue(uint16_t vq_id, + struct rte_qdma_job *job) +{ + struct qdma_virt_queue *qdma_vq = &qdma_vqs[vq_id]; + struct qdma_hw_queue *qdma_pq = qdma_vq->hw_queue; + struct dpaa2_dpdmai_dev *dpdmai_dev = qdma_pq->dpdmai_dev; + int ret; + + DPAA2_QDMA_FUNC_TRACE(); + + /* Return error in case of wrong lcore_id */ + if (rte_lcore_id() != qdma_vq->lcore_id) { + DPAA2_QDMA_ERR("QDMA enqueue for vqid %d on wrong core", + vq_id); + return -EINVAL; + } + + ret = dpdmai_dev_enqueue(dpdmai_dev, qdma_pq->queue_id, vq_id, job); + if (ret < 0) { + DPAA2_QDMA_ERR("DPDMAI device enqueue failed: %d", ret); + return ret; + } + + qdma_vq->num_enqueues++; + + return 1; +} + +/* Function to receive a QDMA job for a given device and queue*/ +static int +dpdmai_dev_dequeue(struct dpaa2_dpdmai_dev *dpdmai_dev, + uint16_t rxq_id, + uint16_t *vq_id, + struct rte_qdma_job **job) +{ + struct qdma_io_meta *io_meta; + struct dpaa2_queue *rxq; + struct qbman_result *dq_storage; + struct qbman_pull_desc pulldesc; + const struct qbman_fd *fd; + struct qbman_swp *swp; + struct qbman_fle *fle; + uint32_t fqid; + uint8_t status; + int ret; + + DPAA2_QDMA_FUNC_TRACE(); + + if (unlikely(!DPAA2_PER_LCORE_DPIO)) { + ret = dpaa2_affine_qbman_swp(); + if (ret) { + DPAA2_QDMA_ERR("Failure in affining portal"); + return 0; + } + } + swp = DPAA2_PER_LCORE_PORTAL; + + rxq = &(dpdmai_dev->rx_queue[rxq_id]); + dq_storage = rxq->q_storage->dq_storage[0]; + fqid = rxq->fqid; + + /* Prepare dequeue descriptor */ + qbman_pull_desc_clear(&pulldesc); + qbman_pull_desc_set_fq(&pulldesc, fqid); + qbman_pull_desc_set_storage(&pulldesc, dq_storage, + (uint64_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1); + qbman_pull_desc_set_numframes(&pulldesc, 1); + + while (1) { + if (qbman_swp_pull(swp, &pulldesc)) { + DPAA2_QDMA_DP_WARN("VDQ command not issued. QBMAN busy"); + continue; + } + break; + } + + /* Check if previous issued command is completed. */ + while (!qbman_check_command_complete(dq_storage)) + ; + /* Loop until dq_storage is updated with new token by QBMAN */ + while (!qbman_check_new_result(dq_storage)) + ; + + /* Check for valid frame. */ + status = qbman_result_DQ_flags(dq_storage); + if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0)) { + DPAA2_QDMA_DP_DEBUG("No frame is delivered"); + return 0; + } + + /* Get the FD */ + fd = qbman_result_DQ_fd(dq_storage); + + /* + * Fetch metadata from FLE. job and vq_id were set + * in metadata in the enqueue operation. + */ + fle = DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd)); + io_meta = (struct qdma_io_meta *)(fle) - 1; + if (vq_id) + *vq_id = io_meta->id; + + *job = (struct rte_qdma_job *)(size_t)io_meta->cnxt; + (*job)->status = DPAA2_GET_FD_ERR(fd); + + /* Free FLE to the pool */ + rte_mempool_put(qdma_dev.fle_pool, io_meta); + + DPAA2_QDMA_DP_DEBUG("packet received"); + + return 1; +} + +int +rte_qdma_vq_dequeue_multi(uint16_t vq_id, + struct rte_qdma_job **job, + uint16_t nb_jobs) +{ + int i; + + DPAA2_QDMA_FUNC_TRACE(); + + for (i = 0; i < nb_jobs; i++) { + job[i] = rte_qdma_vq_dequeue(vq_id); + if (!job[i]) + break; + } + + return i; +} + +struct rte_qdma_job * +rte_qdma_vq_dequeue(uint16_t vq_id) +{ + struct qdma_virt_queue *qdma_vq = &qdma_vqs[vq_id]; + struct qdma_hw_queue *qdma_pq = qdma_vq->hw_queue; + struct dpaa2_dpdmai_dev *dpdmai_dev = qdma_pq->dpdmai_dev; + struct rte_qdma_job *job = NULL; + struct qdma_virt_queue *temp_qdma_vq; + int dequeue_budget = QDMA_DEQUEUE_BUDGET; + int ring_count, ret, i; + uint16_t temp_vq_id; + + DPAA2_QDMA_FUNC_TRACE(); + + /* Return error in case of wrong lcore_id */ + if (rte_lcore_id() != (unsigned int)(qdma_vq->lcore_id)) { + DPAA2_QDMA_ERR("QDMA dequeue for vqid %d on wrong core", + vq_id); + return NULL; + } + + /* Only dequeue when there are pending jobs on VQ */ + if (qdma_vq->num_enqueues == qdma_vq->num_dequeues) + return NULL; + + if (qdma_vq->exclusive_hw_queue) { + /* In case of exclusive queue directly fetch from HW queue */ + ret = dpdmai_dev_dequeue(dpdmai_dev, qdma_pq->queue_id, + NULL, &job); + if (ret < 0) { + DPAA2_QDMA_ERR( + "Dequeue from DPDMAI device failed: %d", ret); + return NULL; + } + } else { + /* + * Get the QDMA completed jobs from the software ring. + * In case they are not available on the ring poke the HW + * to fetch completed jobs from corresponding HW queues + */ + ring_count = rte_ring_count(qdma_vq->status_ring); + if (ring_count == 0) { + /* TODO - How to have right budget */ + for (i = 0; i < dequeue_budget; i++) { + ret = dpdmai_dev_dequeue(dpdmai_dev, + qdma_pq->queue_id, &temp_vq_id, &job); + if (ret == 0) + break; + temp_qdma_vq = &qdma_vqs[temp_vq_id]; + rte_ring_enqueue(temp_qdma_vq->status_ring, + (void *)(job)); + ring_count = rte_ring_count( + qdma_vq->status_ring); + if (ring_count) + break; + } + } + + /* Dequeue job from the software ring to provide to the user */ + rte_ring_dequeue(qdma_vq->status_ring, (void **)&job); + if (job) + qdma_vq->num_dequeues++; + } + + return job; +} + void rte_qdma_vq_stats(uint16_t vq_id, struct rte_qdma_vq_stats *vq_status) diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.h b/drivers/raw/dpaa2_qdma/dpaa2_qdma.h index fe1da41..c6a0578 100644 --- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.h +++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.h @@ -18,10 +18,31 @@ /** FLE pool cache size */ #define QDMA_FLE_CACHE_SIZE(_num) (_num/(RTE_MAX_LCORE * 2)) +/** Notification by FQD_CTX[fqid] */ +#define QDMA_SER_CTX (1 << 8) + +/** + * Source descriptor command read transaction type for RBP=0: + * coherent copy of cacheable memory + */ +#define DPAA2_SET_SDD_RD_COHERENT(sdd) ((sdd)->cmd = (0xb << 28)) +/** + * Destination descriptor command write transaction type for RBP=0: + * coherent copy of cacheable memory + */ +#define DPAA2_SET_SDD_WR_COHERENT(sdd) ((sdd)->cmd = (0x6 << 28)) + /** Maximum possible H/W Queues on each core */ #define MAX_HW_QUEUE_PER_CORE 64 /** + * In case of Virtual Queue mode, this specifies the number of + * dequeue the 'qdma_vq_dequeue/multi' API does from the H/W Queue + * in case there is no job present on the Virtual Queue ring. + */ +#define QDMA_DEQUEUE_BUDGET 64 + +/** * Represents a QDMA device. * A single QDMA device exists which is combination of multiple DPDMAI rawdev's. */ diff --git a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h index d27fd49..5a0ee4e 100644 --- a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h +++ b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma.h @@ -175,6 +175,76 @@ struct rte_qdma_job { rte_qdma_vq_create(uint32_t lcore_id, uint32_t flags); /** + * Enqueue multiple jobs to a Virtual Queue. + * If the enqueue is successful, the H/W will perform DMA operations + * on the basis of the QDMA jobs provided. + * + * @param vq_id + * Virtual Queue ID. + * @param job + * List of QDMA Jobs containing relevant information related to DMA. + * @param nb_jobs + * Number of QDMA jobs provided by the user. + * + * @returns + * - >=0: Number of jobs successfully submitted + * - <0: Error code. + */ +int +rte_qdma_vq_enqueue_multi(uint16_t vq_id, + struct rte_qdma_job **job, + uint16_t nb_jobs); + +/** + * Enqueue a single job to a Virtual Queue. + * If the enqueue is successful, the H/W will perform DMA operations + * on the basis of the QDMA job provided. + * + * @param vq_id + * Virtual Queue ID. + * @param job + * A QDMA Job containing relevant information related to DMA. + * + * @returns + * - >=0: Number of jobs successfully submitted + * - <0: Error code. + */ +int +rte_qdma_vq_enqueue(uint16_t vq_id, + struct rte_qdma_job *job); + +/** + * Dequeue multiple completed jobs from a Virtual Queue. + * Provides the list of completed jobs capped by nb_jobs. + * + * @param vq_id + * Virtual Queue ID. + * @param job + * List of QDMA Jobs returned from the API. + * @param nb_jobs + * Number of QDMA jobs requested for dequeue by the user. + * + * @returns + * Number of jobs actually dequeued. + */ +int +rte_qdma_vq_dequeue_multi(uint16_t vq_id, + struct rte_qdma_job **job, + uint16_t nb_jobs); + +/** + * Dequeue a single completed jobs from a Virtual Queue. + * + * @param vq_id + * Virtual Queue ID. + * + * @returns + * - A completed job or NULL if no job is there. + */ +struct rte_qdma_job * +rte_qdma_vq_dequeue(uint16_t vq_id); + +/** * Get a Virtual Queue statistics. * * @param vq_id diff --git a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map index 0a0d3c5..59dd27c 100644 --- a/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map +++ b/drivers/raw/dpaa2_qdma/rte_pmd_dpaa2_qdma_version.map @@ -10,6 +10,10 @@ DPDK_18.05 { rte_qdma_stop; rte_qdma_vq_create; rte_qdma_vq_destroy; + rte_qdma_vq_dequeue; + rte_qdma_vq_dequeue_multi; + rte_qdma_vq_enqueue; + rte_qdma_vq_enqueue_multi; rte_qdma_vq_stats; local: *; -- 1.9.1