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 2F930A00C3; Tue, 16 Aug 2022 17:50:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 17C87410D3; Tue, 16 Aug 2022 17:49:58 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 8193240150 for ; Tue, 16 Aug 2022 17:49:56 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27GEBVLh003643; Tue, 16 Aug 2022 08:49:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=YOOirpylonNWBsZYSI3FbIAeXZfRo7mVsEPmB8QEiAU=; b=bQsjAowNQOPvLfkd2m8WDkB4zAByxRBNS2aL+lfWqnq3mawDiWXx+kSLsd4TJvyNRQz/ Qxu/EA5bRsuIMycAkVGnelcQGhZqnNRSCQJFTLVWPHFHd61+BczQBoc0hpoBymPB+2hu T6inxHrzHW1bR0m2TaU8gyujcokdAiOAK8gtBRgFRgjNWSH2lapTR9B3hLw6IriFRwjr RSJDx5WAkTaDs10EKaVy2EQIyXSLk1sXxQo2m3rVdgFaBeMK3eezbb2S3nJdxyHbdJET e+qCMOCzCDd3dCQj5x/Lr48GSktAaeNDx6lh96SuQZ662UKoILQi7J9aDXf5QeO+rPcj vQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3j04b9a9sa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 16 Aug 2022 08:49:55 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 16 Aug 2022 08:49:53 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 16 Aug 2022 08:49:53 -0700 Received: from MININT-80QBFE8.corp.innovium.com (unknown [10.28.161.88]) by maili.marvell.com (Postfix) with ESMTP id 73D113F7053; Tue, 16 Aug 2022 08:49:49 -0700 (PDT) From: To: , Pavan Nikhilesh , "Shijith Thotton" CC: , , , , , , , , , , Subject: [PATCH 3/3] event/cnxk: update event vector Tx routine Date: Tue, 16 Aug 2022 21:19:32 +0530 Message-ID: <20220816154932.10168-3-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220816154932.10168-1-pbhagavatula@marvell.com> References: <20220816154932.10168-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: SdHw90QSPf3T8XKi3Z9cVkwpuiC5VQj_ X-Proofpoint-ORIG-GUID: SdHw90QSPf3T8XKi3Z9cVkwpuiC5VQj_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-16_08,2022-08-16_02,2022-06-22_01 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 From: Pavan Nikhilesh Update event vector transmit routine to honor elem_offset. Use ``rte_event_vector::elem_offset`` to report partial vector transmission to the application when there is not enough space in the SQ. Signed-off-by: Pavan Nikhilesh --- drivers/event/cnxk/cn10k_worker.h | 100 +++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 29 deletions(-) diff --git a/drivers/event/cnxk/cn10k_worker.h b/drivers/event/cnxk/cn10k_worker.h index a71e076ff8..7d1fbe9c1b 100644 --- a/drivers/event/cnxk/cn10k_worker.h +++ b/drivers/event/cnxk/cn10k_worker.h @@ -516,7 +516,15 @@ cn10k_sso_txq_fc_wait(const struct cn10k_eth_txq *txq) ; } -static __rte_always_inline void +static __rte_always_inline int32_t +cn10k_sso_sq_depth(const struct cn10k_eth_txq *txq) +{ + return (txq->nb_sqb_bufs_adj - + __atomic_load_n((int16_t *)txq->fc_mem, __ATOMIC_RELAXED)) + << txq->sqes_per_sqb_log2; +} + +static __rte_always_inline uint16_t cn10k_sso_tx_one(struct cn10k_sso_hws *ws, struct rte_mbuf *m, uint64_t *cmd, uint16_t lmt_id, uintptr_t lmt_addr, uint8_t sched_type, const uint64_t *txq_data, const uint32_t flags) @@ -529,6 +537,9 @@ cn10k_sso_tx_one(struct cn10k_sso_hws *ws, struct rte_mbuf *m, uint64_t *cmd, bool sec; txq = cn10k_sso_hws_xtract_meta(m, txq_data); + if (cn10k_sso_sq_depth(txq) <= 0) + return 0; + cn10k_nix_tx_skeleton(txq, cmd, flags, 0); /* Perform header writes before barrier * for TSO @@ -566,21 +577,29 @@ cn10k_sso_tx_one(struct cn10k_sso_hws *ws, struct rte_mbuf *m, uint64_t *cmd, cn10k_sso_txq_fc_wait(txq); roc_lmt_submit_steorl(lmt_id, pa); + + if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) { + if (ref_cnt > 1) + rte_io_wmb(); + } + return 1; } -static __rte_always_inline void +static __rte_always_inline uint16_t cn10k_sso_vwqe_split_tx(struct cn10k_sso_hws *ws, struct rte_mbuf **mbufs, uint16_t nb_mbufs, uint64_t *cmd, uint16_t lmt_id, uintptr_t lmt_addr, uint8_t sched_type, const uint64_t *txq_data, const uint32_t flags) { - uint16_t port[4], queue[4]; uint16_t i, j, pkts, scalar; + uint16_t port[4], queue[4]; struct cn10k_eth_txq *txq; + uint16_t done, cnt; + int32_t space; scalar = nb_mbufs & (NIX_DESCS_PER_LOOP - 1); pkts = RTE_ALIGN_FLOOR(nb_mbufs, NIX_DESCS_PER_LOOP); - + cnt = 0; for (i = 0; i < pkts; i += NIX_DESCS_PER_LOOP) { port[0] = mbufs[i]->port; port[1] = mbufs[i + 1]->port; @@ -594,27 +613,42 @@ cn10k_sso_vwqe_split_tx(struct cn10k_sso_hws *ws, struct rte_mbuf **mbufs, if (((port[0] ^ port[1]) & (port[2] ^ port[3])) || ((queue[0] ^ queue[1]) & (queue[2] ^ queue[3]))) { - for (j = 0; j < 4; j++) - cn10k_sso_tx_one(ws, mbufs[i + j], cmd, lmt_id, - lmt_addr, sched_type, txq_data, - flags); + for (j = 0; j < 4; j++) { + done = cn10k_sso_tx_one( + ws, mbufs[i + j], cmd, lmt_id, lmt_addr, + sched_type, txq_data, flags); + if (!done) + goto fail; + rte_io_wmb(); + cnt++; + } } else { txq = (struct cn10k_eth_txq *)(txq_data[(txq_data[port[0]] >> 48) + queue[0]] & (BIT_ULL(48) - 1)); - cn10k_nix_xmit_pkts_vector(txq, (uint64_t *)ws, - &mbufs[i], 4, cmd, - flags | NIX_TX_VWQE_F); + space = cn10k_sso_sq_depth(txq); + if (space < NIX_DESCS_PER_LOOP) + goto fail; + cn10k_nix_xmit_pkts_vector( + txq, (uint64_t *)ws, &mbufs[i], + NIX_DESCS_PER_LOOP, cmd, flags | NIX_TX_VWQE_F); + cnt += NIX_DESCS_PER_LOOP; } } mbufs += i; for (i = 0; i < scalar; i++) { - cn10k_sso_tx_one(ws, mbufs[i], cmd, lmt_id, lmt_addr, - sched_type, txq_data, flags); + done = cn10k_sso_tx_one(ws, mbufs[i], cmd, lmt_id, lmt_addr, + sched_type, txq_data, flags); + if (!done) + break; + rte_io_wmb(); + cnt++; } +fail: + return cnt; } static __rte_always_inline uint16_t @@ -633,7 +667,12 @@ cn10k_sso_hws_event_tx(struct cn10k_sso_hws *ws, struct rte_event *ev, if (ev->event_type & RTE_EVENT_TYPE_VECTOR) { struct rte_mbuf **mbufs = ev->vec->mbufs; uint64_t meta = *(uint64_t *)ev->vec; + uint16_t offset, nb_pkts; + int32_t space; + nb_pkts = meta & 0xFFFF; + offset = (meta >> 16) & 0xFFF; + nb_pkts -= offset; if (meta & BIT(31)) { txq = (struct cn10k_eth_txq *)(txq_data[(txq_data[meta >> 32] >> @@ -641,29 +680,32 @@ cn10k_sso_hws_event_tx(struct cn10k_sso_hws *ws, struct rte_event *ev, (meta >> 48)] & (BIT_ULL(48) - 1)); - cn10k_nix_xmit_pkts_vector(txq, (uint64_t *)ws, mbufs, - meta & 0xFFFF, cmd, + /* Transmit based on queue depth */ + space = cn10k_sso_sq_depth(txq); + if (space <= 0) + return 0; + nb_pkts = nb_pkts < space ? nb_pkts : (uint16_t)space; + cn10k_nix_xmit_pkts_vector(txq, (uint64_t *)ws, + mbufs + offset, nb_pkts, cmd, flags | NIX_TX_VWQE_F); } else { - cn10k_sso_vwqe_split_tx( - ws, mbufs, meta & 0xFFFF, cmd, lmt_id, lmt_addr, - ev->sched_type, txq_data, flags); + nb_pkts = cn10k_sso_vwqe_split_tx( + ws, mbufs + offset, nb_pkts, cmd, lmt_id, + lmt_addr, ev->sched_type, txq_data, flags); } - rte_mempool_put(rte_mempool_from_obj(ev->vec), ev->vec); + if (!((meta & 0xFFFF) - nb_pkts - offset)) + rte_mempool_put(rte_mempool_from_obj(ev->vec), ev->vec); + else + *(uint64_t *)ev->vec = (meta & ~0xFFF0000UL) | + ((uint32_t)nb_pkts + offset) + << 16; rte_prefetch0(ws); - return 1; + return !((meta & 0xFFFF) - nb_pkts - offset); } m = ev->mbuf; - txq = cn10k_sso_hws_xtract_meta(m, txq_data); - if (((txq->nb_sqb_bufs_adj - - __atomic_load_n((int16_t *)txq->fc_mem, __ATOMIC_RELAXED)) - << txq->sqes_per_sqb_log2) <= 0) - return 0; - cn10k_sso_tx_one(ws, m, cmd, lmt_id, lmt_addr, ev->sched_type, txq_data, - flags); - - return 1; + return cn10k_sso_tx_one(ws, m, cmd, lmt_id, lmt_addr, ev->sched_type, + txq_data, flags); } #define T(name, sz, flags) \ -- 2.25.1