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 AB59343A53; Fri, 2 Feb 2024 20:34:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F065F42ED5; Fri, 2 Feb 2024 20:33:38 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2055.outbound.protection.outlook.com [40.107.237.55]) by mails.dpdk.org (Postfix) with ESMTP id 681B542EC3 for ; Fri, 2 Feb 2024 20:33:36 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rv8fG9/a4CSuNMMVazt6ZWvkJq7Tyu59ab0xWV043ffB710ekDrKAKr9hj01pVtaN2yAoFbZ6N/ELaOVyT4lKAzGwO4HSsRPTgwD3qM5Xw+1LNWqntvV+UBMYBxIgXTft2hwYVL+HuP6q7BHenGucFUQpFlBUIYgxvbq3yHuINeQhtvAhVy4pg+ikhpb+4p3CTpVe4xYSrUjpVojf7Ec1CB/OdSrJd8wRyHH1NcmFWpfMp4uJ0zhvpPJ1cGyrF1YJ9sQ0Tw/dlcHg+jb3JqSi7IO/y1gs96DH7cjz9DmI++QtQJ51AHd63gsgOBnePLvWmXODpJyF1DaGmtKr0/V3w== 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=yTBYAikkHKtugev7OW41YS0smiQTNLHz33mk/ossyTo=; b=CmqfFBH61wdN7SGuGXv5dM4cDFmO3qX0oS4PJmZ3/SVvMKXpCcEAe3SjY8dnMYam119J2p2ljoUqA0Bbiey6WZDXMbhbTD9q/FwT6FNMExO/vYINRa/ZfkOVAGQ74wb0Pzqzzgoch7NA3kbZXexGW0xfmzphiEbWfVDK60MfMu7ke8Y8tG73s3/naJtXwELSDWcdFcMU7zKVIp2fROyeFEAM0SzuZ/qFIaaNNL8ZiJ4iwG0t7tAgnEGulrcYNBG1kKVgTVjjHu3BoHJpdnlcsZSFdBlAC7luXyOu5KKCvjn80owbaWHQwZvRJruv/ARueEdw2IjEu884VRpXEIUXMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yTBYAikkHKtugev7OW41YS0smiQTNLHz33mk/ossyTo=; b=gF6hOJwQquSpy1dbolM7l5D6ghB6D83urH4MWCRvuKEt9fW31tviA2ZD13FcL7zFyjNy5QSYGuYYkltO2gtxGikiBrgauXM5U8vH0T/oxs+Zeh7H+FVQW+ZK7Q1OtXiwBOQr0mblBqQ964Ixu9CmgL7PeGnEIro8F2Xpw+1w5Hk= Received: from DS0PR17CA0010.namprd17.prod.outlook.com (2603:10b6:8:191::26) by DM4PR12MB5118.namprd12.prod.outlook.com (2603:10b6:5:391::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34; Fri, 2 Feb 2024 19:33:34 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:8:191:cafe::71) by DS0PR17CA0010.outlook.office365.com (2603:10b6:8:191::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.30 via Frontend Transport; Fri, 2 Feb 2024 19:33:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Fri, 2 Feb 2024 19:33:33 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 2 Feb 2024 13:33:32 -0600 From: Andrew Boyer To: CC: Andrew Boyer Subject: [PATCH 13/13] net/ionic: optimize device start operation Date: Fri, 2 Feb 2024 11:32:38 -0800 Message-ID: <20240202193238.62669-14-andrew.boyer@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240202193238.62669-1-andrew.boyer@amd.com> References: <20240202193238.62669-1-andrew.boyer@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017095:EE_|DM4PR12MB5118:EE_ X-MS-Office365-Filtering-Correlation-Id: f95a4abf-2cb2-4a7e-ae0d-08dc2425d844 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SKPZI3iza04BGkouEhT4GQL3k0o3ipvfjky0ZRDo478BhM1miCaQCVeV2912uxjcpG2gvixmr+bAi9YkGUwikr32xDwx5XeUdUpUrrlvgu1U6m4nvI91/P3t6RyoiEpM3iOQC59BodlBSz6LBEoVIB+4/Nv+i+rfBSatAac2j2NRqtEHuL+EZKN3cHo39WTpoIick/9W9XFpUTxk7h+TU+DaBEPkXY59U1QOMUStx+IdfH3fnvHlBA76zpC3phiw28nFCd399t76q8SgERhHmEOQAfLTsuN73XrdWCSOcaYEMp18n3+DyVhyVpTypNWRYEVkbbAlBgJSsLdC8s300XG1iaiSHPvMcdGKks+UM74Q1sMSh+p9GUq79ZxvusMufYuFUau8lGbPwndGYNGA4wI50Qc6GOgoaFfkbHcfHQjSc+qdVLSM/AOWu+BP2wj4D7F/i3OdlgY4wvW1CHjY/Ox1rOAmbjyO3FtqzJ/BHYzpDrFd+x2R9y5uwe67AyTw4JZLrdPnMCUrHrXIbmS3mH2ebJVA3gSrQ00PIoV84MZlhiWutzKSPfZYmN8TVBODvg18b/MHMcmkjA6682LOkcQ3CYcA59Bmw4OIOcPlEZzv1R+8YbBm5LCa96Qch2VDLS3+la1uGCYzRGvQSqA3cTW4Y6+pHIgTqAry7+qsmU0IQGqj7wNCqsqLVaMue3fF+Md6yfdB7UJB9SdRo2iFhz+py3OmmIo7ABt7mM6MVZ42h1K1tJ4VKHQIXMA1AjdjMMUItN8NXF6jskdyb/NJzA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(346002)(376002)(396003)(230922051799003)(451199024)(186009)(64100799003)(82310400011)(1800799012)(36840700001)(40470700004)(46966006)(41300700001)(16526019)(1076003)(26005)(2616005)(81166007)(478600001)(356005)(6916009)(70206006)(82740400003)(4326008)(70586007)(8936002)(36860700001)(426003)(30864003)(336012)(8676002)(83380400001)(316002)(44832011)(2906002)(5660300002)(86362001)(47076005)(36756003)(40480700001)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 19:33:33.9599 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f95a4abf-2cb2-4a7e-ae0d-08dc2425d844 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5118 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 Split the queue_start operation into first-half and second-half helpers. This allows us to batch up the queue commands during dev_start(), reducing the outage window when restarting the process by about 1ms per queue. Signed-off-by: Andrew Boyer --- drivers/net/ionic/ionic_lif.c | 178 +++++++++++++++++++++------------ drivers/net/ionic/ionic_lif.h | 6 +- drivers/net/ionic/ionic_rxtx.c | 81 ++++++++++++--- drivers/net/ionic/ionic_rxtx.h | 10 ++ 4 files changed, 194 insertions(+), 81 deletions(-) diff --git a/drivers/net/ionic/ionic_lif.c b/drivers/net/ionic/ionic_lif.c index 8ffdbc4df7..1937e48d9b 100644 --- a/drivers/net/ionic/ionic_lif.c +++ b/drivers/net/ionic/ionic_lif.c @@ -1598,52 +1598,61 @@ ionic_lif_set_features(struct ionic_lif *lif) } int -ionic_lif_txq_init(struct ionic_tx_qcq *txq) +ionic_lif_txq_init_nowait(struct ionic_tx_qcq *txq) { struct ionic_qcq *qcq = &txq->qcq; struct ionic_queue *q = &qcq->q; struct ionic_lif *lif = qcq->lif; struct ionic_cq *cq = &qcq->cq; - struct ionic_admin_ctx ctx = { - .pending_work = true, - .cmd.q_init = { - .opcode = IONIC_CMD_Q_INIT, - .type = q->type, - .ver = lif->qtype_info[q->type].version, - .index = rte_cpu_to_le_32(q->index), - .flags = rte_cpu_to_le_16(IONIC_QINIT_F_ENA), - .intr_index = rte_cpu_to_le_16(IONIC_INTR_NONE), - .ring_size = rte_log2_u32(q->num_descs), - .cq_ring_base = rte_cpu_to_le_64(cq->base_pa), - .sg_ring_base = rte_cpu_to_le_64(q->sg_base_pa), - }, - }; + struct ionic_admin_ctx *ctx = &txq->admin_ctx; int err; + memset(ctx, 0, sizeof(*ctx)); + ctx->pending_work = true; + ctx->cmd.q_init.opcode = IONIC_CMD_Q_INIT; + ctx->cmd.q_init.type = q->type; + ctx->cmd.q_init.ver = lif->qtype_info[q->type].version; + ctx->cmd.q_init.index = rte_cpu_to_le_32(q->index); + ctx->cmd.q_init.flags = rte_cpu_to_le_16(IONIC_QINIT_F_ENA); + ctx->cmd.q_init.intr_index = rte_cpu_to_le_16(IONIC_INTR_NONE); + ctx->cmd.q_init.ring_size = rte_log2_u32(q->num_descs); + ctx->cmd.q_init.cq_ring_base = rte_cpu_to_le_64(cq->base_pa); + ctx->cmd.q_init.sg_ring_base = rte_cpu_to_le_64(q->sg_base_pa); + if (txq->flags & IONIC_QCQ_F_SG) - ctx.cmd.q_init.flags |= rte_cpu_to_le_16(IONIC_QINIT_F_SG); + ctx->cmd.q_init.flags |= rte_cpu_to_le_16(IONIC_QINIT_F_SG); if (txq->flags & IONIC_QCQ_F_CMB) { - ctx.cmd.q_init.flags |= rte_cpu_to_le_16(IONIC_QINIT_F_CMB); - ctx.cmd.q_init.ring_base = rte_cpu_to_le_64(q->cmb_base_pa); + ctx->cmd.q_init.flags |= rte_cpu_to_le_16(IONIC_QINIT_F_CMB); + ctx->cmd.q_init.ring_base = rte_cpu_to_le_64(q->cmb_base_pa); } else { - ctx.cmd.q_init.ring_base = rte_cpu_to_le_64(q->base_pa); + ctx->cmd.q_init.ring_base = rte_cpu_to_le_64(q->base_pa); } IONIC_PRINT(DEBUG, "txq_init.index %d", q->index); IONIC_PRINT(DEBUG, "txq_init.ring_base 0x%" PRIx64 "", q->base_pa); IONIC_PRINT(DEBUG, "txq_init.ring_size %d", - ctx.cmd.q_init.ring_size); - IONIC_PRINT(DEBUG, "txq_init.ver %u", ctx.cmd.q_init.ver); + ctx->cmd.q_init.ring_size); + IONIC_PRINT(DEBUG, "txq_init.ver %u", ctx->cmd.q_init.ver); ionic_q_reset(q); ionic_cq_reset(cq); - err = ionic_adminq_post_wait(lif, &ctx); + /* Caller responsible for calling ionic_lif_txq_init_done() */ + err = ionic_adminq_post(lif, ctx); if (err) - return err; + ctx->pending_work = false; + return err; +} - q->hw_type = ctx.comp.q_init.hw_type; - q->hw_index = rte_le_to_cpu_32(ctx.comp.q_init.hw_index); +void +ionic_lif_txq_init_done(struct ionic_tx_qcq *txq) +{ + struct ionic_lif *lif = txq->qcq.lif; + struct ionic_queue *q = &txq->qcq.q; + struct ionic_admin_ctx *ctx = &txq->admin_ctx; + + q->hw_type = ctx->comp.q_init.hw_type; + q->hw_index = rte_le_to_cpu_32(ctx->comp.q_init.hw_index); q->db = ionic_db_map(lif, q); IONIC_PRINT(DEBUG, "txq->hw_type %d", q->hw_type); @@ -1651,57 +1660,64 @@ ionic_lif_txq_init(struct ionic_tx_qcq *txq) IONIC_PRINT(DEBUG, "txq->db %p", q->db); txq->flags |= IONIC_QCQ_F_INITED; - - return 0; } int -ionic_lif_rxq_init(struct ionic_rx_qcq *rxq) +ionic_lif_rxq_init_nowait(struct ionic_rx_qcq *rxq) { struct ionic_qcq *qcq = &rxq->qcq; struct ionic_queue *q = &qcq->q; struct ionic_lif *lif = qcq->lif; struct ionic_cq *cq = &qcq->cq; - struct ionic_admin_ctx ctx = { - .pending_work = true, - .cmd.q_init = { - .opcode = IONIC_CMD_Q_INIT, - .type = q->type, - .ver = lif->qtype_info[q->type].version, - .index = rte_cpu_to_le_32(q->index), - .flags = rte_cpu_to_le_16(IONIC_QINIT_F_ENA), - .intr_index = rte_cpu_to_le_16(IONIC_INTR_NONE), - .ring_size = rte_log2_u32(q->num_descs), - .cq_ring_base = rte_cpu_to_le_64(cq->base_pa), - .sg_ring_base = rte_cpu_to_le_64(q->sg_base_pa), - }, - }; + struct ionic_admin_ctx *ctx = &rxq->admin_ctx; int err; + memset(ctx, 0, sizeof(*ctx)); + ctx->pending_work = true; + ctx->cmd.q_init.opcode = IONIC_CMD_Q_INIT; + ctx->cmd.q_init.type = q->type; + ctx->cmd.q_init.ver = lif->qtype_info[q->type].version; + ctx->cmd.q_init.index = rte_cpu_to_le_32(q->index); + ctx->cmd.q_init.flags = rte_cpu_to_le_16(IONIC_QINIT_F_ENA); + ctx->cmd.q_init.intr_index = rte_cpu_to_le_16(IONIC_INTR_NONE); + ctx->cmd.q_init.ring_size = rte_log2_u32(q->num_descs); + ctx->cmd.q_init.cq_ring_base = rte_cpu_to_le_64(cq->base_pa); + ctx->cmd.q_init.sg_ring_base = rte_cpu_to_le_64(q->sg_base_pa); + if (rxq->flags & IONIC_QCQ_F_SG) - ctx.cmd.q_init.flags |= rte_cpu_to_le_16(IONIC_QINIT_F_SG); + ctx->cmd.q_init.flags |= rte_cpu_to_le_16(IONIC_QINIT_F_SG); if (rxq->flags & IONIC_QCQ_F_CMB) { - ctx.cmd.q_init.flags |= rte_cpu_to_le_16(IONIC_QINIT_F_CMB); - ctx.cmd.q_init.ring_base = rte_cpu_to_le_64(q->cmb_base_pa); + ctx->cmd.q_init.flags |= rte_cpu_to_le_16(IONIC_QINIT_F_CMB); + ctx->cmd.q_init.ring_base = rte_cpu_to_le_64(q->cmb_base_pa); } else { - ctx.cmd.q_init.ring_base = rte_cpu_to_le_64(q->base_pa); + ctx->cmd.q_init.ring_base = rte_cpu_to_le_64(q->base_pa); } IONIC_PRINT(DEBUG, "rxq_init.index %d", q->index); IONIC_PRINT(DEBUG, "rxq_init.ring_base 0x%" PRIx64 "", q->base_pa); IONIC_PRINT(DEBUG, "rxq_init.ring_size %d", - ctx.cmd.q_init.ring_size); - IONIC_PRINT(DEBUG, "rxq_init.ver %u", ctx.cmd.q_init.ver); + ctx->cmd.q_init.ring_size); + IONIC_PRINT(DEBUG, "rxq_init.ver %u", ctx->cmd.q_init.ver); ionic_q_reset(q); ionic_cq_reset(cq); - err = ionic_adminq_post_wait(lif, &ctx); + /* Caller responsible for calling ionic_lif_rxq_init_done() */ + err = ionic_adminq_post(lif, ctx); if (err) - return err; + ctx->pending_work = false; + return err; +} - q->hw_type = ctx.comp.q_init.hw_type; - q->hw_index = rte_le_to_cpu_32(ctx.comp.q_init.hw_index); +void +ionic_lif_rxq_init_done(struct ionic_rx_qcq *rxq) +{ + struct ionic_lif *lif = rxq->qcq.lif; + struct ionic_queue *q = &rxq->qcq.q; + struct ionic_admin_ctx *ctx = &rxq->admin_ctx; + + q->hw_type = ctx->comp.q_init.hw_type; + q->hw_index = rte_le_to_cpu_32(ctx->comp.q_init.hw_index); q->db = ionic_db_map(lif, q); rxq->flags |= IONIC_QCQ_F_INITED; @@ -1709,8 +1725,6 @@ ionic_lif_rxq_init(struct ionic_rx_qcq *rxq) IONIC_PRINT(DEBUG, "rxq->hw_type %d", q->hw_type); IONIC_PRINT(DEBUG, "rxq->hw_index %d", q->hw_index); IONIC_PRINT(DEBUG, "rxq->db %p", q->db); - - return 0; } static int @@ -1959,9 +1973,11 @@ ionic_lif_configure(struct ionic_lif *lif) int ionic_lif_start(struct ionic_lif *lif) { + struct rte_eth_dev *dev = lif->eth_dev; uint32_t rx_mode; - uint32_t i; + uint32_t i, j, chunk; int err; + bool fatal = false; err = ionic_lif_rss_setup(lif); if (err) @@ -1982,25 +1998,57 @@ ionic_lif_start(struct ionic_lif *lif) "on port %u", lif->nrxqcqs, lif->ntxqcqs, lif->port_id); - for (i = 0; i < lif->nrxqcqs; i++) { - struct ionic_rx_qcq *rxq = lif->rxqcqs[i]; - if (!(rxq->flags & IONIC_QCQ_F_DEFERRED)) { - err = ionic_dev_rx_queue_start(lif->eth_dev, i); + chunk = ionic_adminq_space_avail(lif); + + for (i = 0; i < lif->nrxqcqs; i += chunk) { + if (lif->rxqcqs[0]->flags & IONIC_QCQ_F_DEFERRED) { + IONIC_PRINT(DEBUG, "Rx queue start deferred"); + break; + } + + for (j = 0; j < chunk && i + j < lif->nrxqcqs; j++) { + err = ionic_dev_rx_queue_start_firsthalf(dev, i + j); + if (err) { + fatal = true; + break; + } + } + for (j = 0; j < chunk && i + j < lif->nrxqcqs; j++) { + /* Commands that failed to post return immediately */ + err = ionic_dev_rx_queue_start_secondhalf(dev, i + j); if (err) - return err; + /* Don't break */ + fatal = true; } } + if (fatal) + return -EIO; - for (i = 0; i < lif->ntxqcqs; i++) { - struct ionic_tx_qcq *txq = lif->txqcqs[i]; - if (!(txq->flags & IONIC_QCQ_F_DEFERRED)) { - err = ionic_dev_tx_queue_start(lif->eth_dev, i); + for (i = 0; i < lif->ntxqcqs; i += chunk) { + if (lif->txqcqs[0]->flags & IONIC_QCQ_F_DEFERRED) { + IONIC_PRINT(DEBUG, "Tx queue start deferred"); + break; + } + + for (j = 0; j < chunk && i + j < lif->ntxqcqs; j++) { + err = ionic_dev_tx_queue_start_firsthalf(dev, i + j); + if (err) { + fatal = true; + break; + } + } + for (j = 0; j < chunk && i + j < lif->ntxqcqs; j++) { + /* Commands that failed to post return immediately */ + err = ionic_dev_tx_queue_start_secondhalf(dev, i + j); if (err) - return err; + /* Don't break */ + fatal = true; } } + if (fatal) + return -EIO; /* Carrier ON here */ lif->state |= IONIC_LIF_F_UP; diff --git a/drivers/net/ionic/ionic_lif.h b/drivers/net/ionic/ionic_lif.h index ee13f5b7c8..591cf1a2ff 100644 --- a/drivers/net/ionic/ionic_lif.h +++ b/drivers/net/ionic/ionic_lif.h @@ -228,11 +228,13 @@ int ionic_tx_qcq_alloc(struct ionic_lif *lif, uint32_t socket_id, struct ionic_tx_qcq **qcq_out); void ionic_qcq_free(struct ionic_qcq *qcq); -int ionic_lif_rxq_init(struct ionic_rx_qcq *rxq); +int ionic_lif_rxq_init_nowait(struct ionic_rx_qcq *rxq); +void ionic_lif_rxq_init_done(struct ionic_rx_qcq *rxq); void ionic_lif_rxq_deinit_nowait(struct ionic_rx_qcq *rxq); void ionic_lif_rxq_stats(struct ionic_rx_qcq *rxq); -int ionic_lif_txq_init(struct ionic_tx_qcq *txq); +int ionic_lif_txq_init_nowait(struct ionic_tx_qcq *txq); +void ionic_lif_txq_init_done(struct ionic_tx_qcq *txq); void ionic_lif_txq_deinit_nowait(struct ionic_tx_qcq *txq); void ionic_lif_txq_stats(struct ionic_tx_qcq *txq); diff --git a/drivers/net/ionic/ionic_rxtx.c b/drivers/net/ionic/ionic_rxtx.c index 774dc596c0..ad04e987eb 100644 --- a/drivers/net/ionic/ionic_rxtx.c +++ b/drivers/net/ionic/ionic_rxtx.c @@ -203,27 +203,54 @@ ionic_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id, * Start Transmit Units for specified queue. */ int __rte_cold -ionic_dev_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id) +ionic_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) { - uint8_t *tx_queue_state = eth_dev->data->tx_queue_state; - struct ionic_tx_qcq *txq; int err; + err = ionic_dev_tx_queue_start_firsthalf(dev, tx_queue_id); + if (err) + return err; + + return ionic_dev_tx_queue_start_secondhalf(dev, tx_queue_id); +} + +int __rte_cold +ionic_dev_tx_queue_start_firsthalf(struct rte_eth_dev *dev, + uint16_t tx_queue_id) +{ + uint8_t *tx_queue_state = dev->data->tx_queue_state; + struct ionic_tx_qcq *txq = dev->data->tx_queues[tx_queue_id]; + if (tx_queue_state[tx_queue_id] == RTE_ETH_QUEUE_STATE_STARTED) { IONIC_PRINT(DEBUG, "TX queue %u already started", tx_queue_id); return 0; } - txq = eth_dev->data->tx_queues[tx_queue_id]; - IONIC_PRINT(DEBUG, "Starting TX queue %u, %u descs", tx_queue_id, txq->qcq.q.num_descs); - err = ionic_lif_txq_init(txq); + return ionic_lif_txq_init_nowait(txq); +} + +int __rte_cold +ionic_dev_tx_queue_start_secondhalf(struct rte_eth_dev *dev, + uint16_t tx_queue_id) +{ + uint8_t *tx_queue_state = dev->data->tx_queue_state; + struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(dev); + struct ionic_tx_qcq *txq = dev->data->tx_queues[tx_queue_id]; + int err; + + if (tx_queue_state[tx_queue_id] == RTE_ETH_QUEUE_STATE_STARTED) + return 0; + + err = ionic_adminq_wait(lif, &txq->admin_ctx); if (err) return err; + ionic_lif_txq_init_done(txq); + tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; return 0; @@ -680,22 +707,31 @@ ionic_rx_init_descriptors(struct ionic_rx_qcq *rxq) * Start Receive Units for specified queue. */ int __rte_cold -ionic_dev_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) +ionic_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) { - uint8_t *rx_queue_state = eth_dev->data->rx_queue_state; - struct ionic_rx_qcq *rxq; - struct ionic_queue *q; int err; + err = ionic_dev_rx_queue_start_firsthalf(dev, rx_queue_id); + if (err) + return err; + + return ionic_dev_rx_queue_start_secondhalf(dev, rx_queue_id); +} + +int __rte_cold +ionic_dev_rx_queue_start_firsthalf(struct rte_eth_dev *dev, + uint16_t rx_queue_id) +{ + uint8_t *rx_queue_state = dev->data->rx_queue_state; + struct ionic_rx_qcq *rxq = dev->data->rx_queues[rx_queue_id]; + struct ionic_queue *q = &rxq->qcq.q; + if (rx_queue_state[rx_queue_id] == RTE_ETH_QUEUE_STATE_STARTED) { IONIC_PRINT(DEBUG, "RX queue %u already started", rx_queue_id); return 0; } - rxq = eth_dev->data->rx_queues[rx_queue_id]; - q = &rxq->qcq.q; - rxq->frame_size = rxq->qcq.lif->frame_size - RTE_ETHER_CRC_LEN; /* Recalculate segment count based on MTU */ @@ -707,10 +743,27 @@ ionic_dev_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) ionic_rx_init_descriptors(rxq); - err = ionic_lif_rxq_init(rxq); + return ionic_lif_rxq_init_nowait(rxq); +} + +int __rte_cold +ionic_dev_rx_queue_start_secondhalf(struct rte_eth_dev *dev, + uint16_t rx_queue_id) +{ + uint8_t *rx_queue_state = dev->data->rx_queue_state; + struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(dev); + struct ionic_rx_qcq *rxq = dev->data->rx_queues[rx_queue_id]; + int err; + + if (rx_queue_state[rx_queue_id] == RTE_ETH_QUEUE_STATE_STARTED) + return 0; + + err = ionic_adminq_wait(lif, &rxq->admin_ctx); if (err) return err; + ionic_lif_rxq_init_done(rxq); + /* Allocate buffers for descriptor ring */ if (rxq->flags & IONIC_QCQ_F_SG) err = ionic_rx_fill_sg(rxq); diff --git a/drivers/net/ionic/ionic_rxtx.h b/drivers/net/ionic/ionic_rxtx.h index 7ca23178cc..a342afec54 100644 --- a/drivers/net/ionic/ionic_rxtx.h +++ b/drivers/net/ionic/ionic_rxtx.h @@ -46,6 +46,16 @@ void ionic_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid); int ionic_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); int ionic_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id); +/* Helpers for optimized dev_start() */ +int ionic_dev_rx_queue_start_firsthalf(struct rte_eth_dev *dev, + uint16_t rx_queue_id); +int ionic_dev_rx_queue_start_secondhalf(struct rte_eth_dev *dev, + uint16_t rx_queue_id); +int ionic_dev_tx_queue_start_firsthalf(struct rte_eth_dev *dev, + uint16_t tx_queue_id); +int ionic_dev_tx_queue_start_secondhalf(struct rte_eth_dev *dev, + uint16_t tx_queue_id); + /* Helpers for optimized dev_stop() */ void ionic_dev_rx_queue_stop_firsthalf(struct rte_eth_dev *dev, uint16_t rx_queue_id); -- 2.17.1