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 1729C42910; Mon, 10 Apr 2023 13:02:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BAF8942D4A; Mon, 10 Apr 2023 13:01:20 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2098.outbound.protection.outlook.com [40.107.93.98]) by mails.dpdk.org (Postfix) with ESMTP id 255E742D4A for ; Mon, 10 Apr 2023 13:01:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AdLycGT9cuaMhISXjisTmBsNo9tWMGjbhfD47TKcNMzlau7Emt1d2Qh/1e3J0LWKKW9qiqRAKjJzaUVDr06OAveDB/c6njHk1ndipicAb3+UPMw6YN3/fxmxLLxRdFxRW8fujZ2o3DWCRy1SbybeNPROH8ePha9Rk/bXOfHlOLp3tG7PdlSO/9tZzgYRBG18MYtQLOyToh6xImop9vB5gZP05sNpnQ8sW5Lfx+d9pIt1OAcBwQ7OFeNSvm/fi+ZqUjfvrKaOS26oXEkJLqMe+vr7s0+LjJdz/IXMiIL4aeuZ+6JRxiYRN350NMb3UrzKzo32m8uoNj1y5INQtKQEtA== 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=ltqszPpFf0oufpdWbz7BG+dh3Q40NNw2CdjjjTCmRN4=; b=ndzk7g49Ngphrn3R2Q0JGcDI+x1mWPF20W0Gr+4rLmIVSG6doiT+jW0RKlMbCdi/BqOyRzQNO/F6fNhvDryFg4sBgaA4279NWKAMVfVcRzzy4qz7rIbmfW2dZR/PCpYxtxhC2g5LfW9Rj/k5wNnxdWfwsG8SbThFyq04uEjeLU5zY3GUkfujdhsCRjWC0mSclE8X1+jz6eMMFO7jeObmhMVmSb+quXbHheLSbr6KHebRUCnLmwF5OhrXF6+TMw+K54ddkbMNOjSUfuGiDXqu2Bfi9Zba/IbVVuY51MX4js5+m1c1lkyybdWzm/e/CnF8CrU94rcOHzrO0vdIjsRZPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ltqszPpFf0oufpdWbz7BG+dh3Q40NNw2CdjjjTCmRN4=; b=GAwQktBksTsnkFxd3QwFOonJInJekjjy3w+8vx0Y5KVKnOTK78RHNw9VSSW4dWRCkigPG1f5c5W3NRYvBjgt/g785+YraTiQx9SEnqyFKvfGADBvHtW+qSgWWijlvR7hPwKf/axgWREcamXZPO+9cD69FYzLCQuKbIaMj+79Sfo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by MW4PR13MB5436.namprd13.prod.outlook.com (2603:10b6:303:183::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Mon, 10 Apr 2023 11:01:15 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::baa6:b49:d2f4:c60e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::baa6:b49:d2f4:c60e%4]) with mapi id 15.20.6277.036; Mon, 10 Apr 2023 11:01:15 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 13/13] net/nfp: modify the logic of some NFDk function Date: Mon, 10 Apr 2023 19:00:15 +0800 Message-Id: <20230410110015.2973660-14-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230410110015.2973660-1-chaoyong.he@corigine.com> References: <20230410110015.2973660-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR01CA0040.apcprd01.prod.exchangelabs.com (2603:1096:4:193::14) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW4PR13MB5436:EE_ X-MS-Office365-Filtering-Correlation-Id: bcc95475-a789-4d03-01ad-08db39b2e754 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 65he+mi6QP0uwvBK9pEJq+5HRB4f+onGrnTDyiRN70xAMhldOwqJOnTFfhpfT1X0Zd7nG2va9vYMMLIPA91fs3MMG3mcuwKI1QaYB8XlCd3uEVX4Hcx4lJ3ZQvrdPYZLMIH0AuRUwqDHZrimf9OkFfoqJyTzHasv2TS4yqBNrbUQGu6iGy2wqF4NSkaJco5jW6sv8Q+RtVKlE5maRSLp8/h54fTEKV2/Tgx8R1LXY7MdYhMrwj9zsOP9fbVMr760UaKtVsFm7wY8VNIHQPybjQjWQ7PKVmXLXY1yfUV+AE0untNhLrZvsbol941NIaebdT55KvC3k1DWQmwECU7zzx8FlBqxvY25okxE8ggvabHJpab/sB9SZXsAaPvbammoa6ANkDtZJwt4aR0HYlXlULpItG3Ym6Bo1Dq46VIXZR9E4wZfmSwfOTWtJpB3S5eR+1SWGaeGJekq3m5Wij3Tr3hbuACmJIZoR0WBpUzL2OwoG4U/7/OcnhIJmU19ylPptVa7/kDVGl464IWBbC6di+ngFC5UwGGYnaw7Vv4MpCGDHWbNINp/aYiGvh00ESBT6HzTYaonaAN2jVW7cTF5L58Tw959CNL2Dn+WaN9+fpOVv3f0avycGVd71nAS8NvAfYPMbH24gJ4dorWchcVHUiL6DAJOB3ccm5HX0pGrjxw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(136003)(376002)(396003)(346002)(366004)(39840400004)(451199021)(478600001)(52116002)(316002)(6512007)(1076003)(6506007)(26005)(44832011)(186003)(6486002)(2906002)(5660300002)(4326008)(66946007)(41300700001)(8936002)(8676002)(6916009)(66476007)(107886003)(66556008)(38100700002)(38350700002)(86362001)(66574015)(36756003)(83380400001)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Uzl0MkFDblU5SHE4QWNPUU83T2gxbFpxV0kzQk55b2IwZVRGNWJ5a1RoUkMr?= =?utf-8?B?L1hHUVdiSXJzaHhiT1pXOXVsMzdjNGlZeGdiOHRuS1d2bHRNbEp0dktBb20r?= =?utf-8?B?a2tQQU1ja1Znd0ZVQm1mUGg0TlNjM2tHRzc1VDI5S0hIZ3dCemlkUGJaK052?= =?utf-8?B?RmpKM0VqVWtFVmhPTXNveTBSRkd3UW5PdDlKUW9rS3d1SVlRd1MzYTF0OGRN?= =?utf-8?B?aWNpSUIrQlZWRi9WTHZQYWVCTTVVVEFZd3NWT0FMSVdHVTR1RmdUZWlESkU2?= =?utf-8?B?OTVoSlZnbGpjTGcxT000eXVqNStvWVdPTUdNNmhscHYwRElyR0JLR3pWZ0FP?= =?utf-8?B?Nk5zT3grM2JlcUxjNEo1a2hQYlVtS1BXMG45ejVhNDV2bkd2T1JwK2hrW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X-MS-Exchange-CrossTenant-Network-Message-Id: bcc95475-a789-4d03-01ad-08db39b2e754 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2023 11:01:15.4258 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Tv5/JMl7RhTJ3pb01lTyv+PHjM3wlq95zAFwXB/94Dafhs9cbr54+tdt3F3H8+423UrUKIka5gBjOwwQNmLlVV0eDCKe5NBWiLcuXIFaid4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR13MB5436 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 one function into two functions and change the data type of parameter and return value. Also add some comment message to help understand. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfdk/nfp_nfdk.h | 75 ++++++++++++++++++++++++++++-- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 48 ++++++++++++------- 2 files changed, 101 insertions(+), 22 deletions(-) diff --git a/drivers/net/nfp/nfdk/nfp_nfdk.h b/drivers/net/nfp/nfdk/nfp_nfdk.h index 9af9176eb7..c39501990a 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk.h +++ b/drivers/net/nfp/nfdk/nfp_nfdk.h @@ -9,22 +9,27 @@ #define NFDK_TX_DESC_PER_SIMPLE_PKT 2 #define NFDK_TX_DESC_GATHER_MAX 17 -#define NFDK_TX_MAX_DATA_PER_HEAD 0x00001000 -#define NFDK_TX_MAX_DATA_PER_DESC 0x00004000 -#define NFDK_TX_MAX_DATA_PER_BLOCK 0x00010000 +#define NFDK_TX_MAX_DATA_PER_HEAD 0x00001000 /* 4K */ +#define NFDK_TX_MAX_DATA_PER_DESC 0x00004000 /* 16K */ +#define NFDK_TX_MAX_DATA_PER_BLOCK 0x00010000 /* 64K */ +/* The mask of 'dma_len_xx' of address descriptor */ #define NFDK_DESC_TX_DMA_LEN_HEAD 0x0FFF /* [0,11] */ #define NFDK_DESC_TX_DMA_LEN 0x3FFF /* [0,13] */ #define NFDK_DESC_TX_TYPE_HEAD 0xF000 /* [12,15] */ +/* The mask of upper 4 bit of first address descriptor */ +#define NFDK_DESC_TX_TYPE_HEAD 0xF000 /* [12,15] */ + +/* The value of upper 4 bit of first address descriptor */ #define NFDK_DESC_TX_TYPE_GATHER 1 #define NFDK_DESC_TX_TYPE_TSO 2 #define NFDK_DESC_TX_TYPE_SIMPLE 8 -/* TX descriptor format */ +/* The 'end of chain' flag of address descriptor */ #define NFDK_DESC_TX_EOP RTE_BIT32(14) -/* Flags in the host TX descriptor */ +/* Flags in the host metadata descriptor */ #define NFDK_DESC_TX_CHAIN_META RTE_BIT32(3) #define NFDK_DESC_TX_ENCAP RTE_BIT32(2) #define NFDK_DESC_TX_L4_CSUM RTE_BIT32(1) @@ -40,14 +45,73 @@ /* Convenience macro for wrapping descriptor index on ring size */ #define D_IDX(ring, idx) ((idx) & ((ring)->tx_count - 1)) +/* + * A full TX descriptor consists of one or more address descriptors, + * followed by a TX metadata descriptor, and finally a TSO descriptor for + * TSO packets. + * + * --> Header address descriptor: + * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * Word +-+-+---+-----------------------+-------------------------------+ + * 0 |S|E| TP| dma_len_12 | dma_addr_hi | + * +-+-+---+-----------------------+-------------------------------+ + * 1 | dma_addr_lo | + * +---------------------------------------------------------------+ + * + * --> Subsequent address descriptor(s): + * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * Word +-+-+---------------------------+-------------------------------+ + * 0 |S|E| dma_len_14 | dma_addr_hi | + * +-+-+---------------------------+-------------------------------+ + * 1 | dma_addr_lo | + * +---------------------------------------------------------------+ + * + * S - Simple Packet descriptor + * TP - Type of descriptor + * E - End of chain + * dma_len - length of the host memory in bytes -1 + * dma_addr_hi - bits [47:32] of host memory address + * dma_addr_lo - bits [31:0] of host memory address + * + * --> metadata descriptor + * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * Word +-------+-----------------------+---------------------+---+-----+ + *  0 | ZERO | Rsvd (64b support) | TBD meta | MT| CSUM| + * +-------+-----------------------+---------------------+---+-----+ + * 1 | TBD meta | + * +---------------------------------------------------------------+ + * + * --> TSO descriptor + * The following is only present if TP above indicates LSO: + * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * Word +---------------+---------------+---+---------------------------+ + * 0 | total_segments| header_len |sp0| mss | + * +---------------+---------------+---+---------------------------+ + * 1 | sp1 | L4 | L3 | + * +---------------------------------------------------------------+ + * + * total_segments - LSO: Total number of segments + * header_len - LSO: length of the LSO header in bytes + * sp0 - Spare Bits (ZERO) + * mss - LSO: TCP MSS, maximum segment size of TCP payload + * sp1 - Spare Bits (ZERO) + * L4 - Layer 4 data + * L3 - Layer 3 data + */ struct nfp_net_nfdk_tx_desc { union { + /* Address descriptor */ struct { uint16_t dma_addr_hi; /* High bits of host buf address */ uint16_t dma_len_type; /* Length to DMA for this desc */ uint32_t dma_addr_lo; /* Low 32bit of host buf addr */ }; + /* TSO descriptor */ struct { uint16_t mss; /* MSS to be used for LSO */ uint8_t lso_hdrlen; /* LSO, TCP payload offset */ @@ -57,6 +121,7 @@ struct nfp_net_nfdk_tx_desc { uint16_t lso_meta_res; /* Rsvd bits in TSO metadata */ }; + /* Metadata descriptor */ struct { uint8_t flags; /* TX Flags, see @NFDK_DESC_TX_* */ uint8_t reserved[7]; /* meta byte placeholder */ diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c index 013f369b55..12233393fc 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c +++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c @@ -14,25 +14,46 @@ #include "../nfpcore/nfp_rtsym.h" #include "nfp_nfdk.h" -static inline int -nfp_net_nfdk_headlen_to_segs(unsigned int headlen) +static inline uint16_t +nfp_net_nfdk_headlen_to_segs(uint16_t headlen) { + /* First descriptor fits less data, so adjust for that */ return DIV_ROUND_UP(headlen + NFDK_TX_MAX_DATA_PER_DESC - NFDK_TX_MAX_DATA_PER_HEAD, NFDK_TX_MAX_DATA_PER_DESC); } +static inline void +nfp_net_nfdk_tx_close_block(struct nfp_net_txq *txq, + uint32_t nop_slots) +{ + uint32_t i; + uint32_t wr_p; + + wr_p = txq->wr_p; + memset(&txq->ktxds[wr_p], 0, nop_slots * sizeof(struct nfp_net_nfdk_tx_desc)); + + for (i = wr_p; i < nop_slots + wr_p; i++) { + if (txq->txbufs[i].mbuf != NULL) { + rte_pktmbuf_free_seg(txq->txbufs[i].mbuf); + txq->txbufs[i].mbuf = NULL; + } + } + + txq->data_pending = 0; + txq->wr_p = D_IDX(txq, wr_p + nop_slots); +} + static int nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq, struct rte_mbuf *pkt) { - uint32_t i; - uint32_t wr_p; uint16_t n_descs; uint32_t nop_slots; struct rte_mbuf *pkt_temp; + /* Count address descriptor */ pkt_temp = pkt; n_descs = nfp_net_nfdk_headlen_to_segs(pkt_temp->data_len); while (pkt_temp->next != NULL) { @@ -43,9 +64,12 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq, if (unlikely(n_descs > NFDK_TX_DESC_GATHER_MAX)) return -EINVAL; - if ((pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) + /* Count TSO descriptor */ + if ((txq->hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 && + (pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) n_descs++; + /* Don't count metadata descriptor, for the round down to work out */ if (round_down(txq->wr_p, NFDK_TX_DESC_BLOCK_CNT) != round_down(txq->wr_p + n_descs, NFDK_TX_DESC_BLOCK_CNT)) goto close_block; @@ -56,18 +80,8 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq, return 0; close_block: - wr_p = txq->wr_p; - nop_slots = D_BLOCK_CPL(wr_p); - - memset(&txq->ktxds[wr_p], 0, nop_slots * sizeof(struct nfp_net_nfdk_tx_desc)); - for (i = wr_p; i < nop_slots + wr_p; i++) { - if (txq->txbufs[i].mbuf) { - rte_pktmbuf_free_seg(txq->txbufs[i].mbuf); - txq->txbufs[i].mbuf = NULL; - } - } - txq->data_pending = 0; - txq->wr_p = D_IDX(txq, txq->wr_p + nop_slots); + nop_slots = D_BLOCK_CPL(txq->wr_p); + nfp_net_nfdk_tx_close_block(txq, nop_slots); return nop_slots; } -- 2.39.1