From patchwork Fri Jul 16 08:35:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Kuhn X-Patchwork-Id: 95959 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 12ED9A0C50; Fri, 16 Jul 2021 10:37:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E99CA40151; Fri, 16 Jul 2021 10:37:02 +0200 (CEST) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by mails.dpdk.org (Postfix) with ESMTP id A4A964014D for ; Fri, 16 Jul 2021 10:37:01 +0200 (CEST) Received: by mail-ed1-f47.google.com with SMTP id x17so11866301edd.12 for ; Fri, 16 Jul 2021 01:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NNGijOi0BcY27rDpYn6W9ya8507NL0+lHnin/UxAuVM=; b=RybS5K2qQmCFOapnYO6cXlTzbg+wKuOeObejqCx61S3qmpZXEgA40H/MWJSglF/n99 vFZAlP9VyunLOcviuUejTRZCwnGyylVbBTppSMj1toGIgBgN3spgUhgNPpmSdXje/IuO 9ofVJV+IpzjObQI+lRSZnp90QYIrgdfEESA641cFeUH9CmyVtAertMEiPrLizwMJ1lgV EnuNatbPPhUPXRGwFfhKmm3XJ6QnhuZjtsJSIkFivJGT4hV6QBezy5upoPjrdnzroxwr 0IB6uas+SS+TZuaAoxIGzOAHmvhfY1iUduldnqKMOxDiJ+giL3EBfOZCR83CNDKQvYqf YZIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NNGijOi0BcY27rDpYn6W9ya8507NL0+lHnin/UxAuVM=; b=Egx4ggfmBDb5pesGt3an8dBJq8gzYbAFI5xJl3u2gt4WC/njg+SuOaKtjM08jGoW2x 0xnB4RxDt6zvvvQV0l6BAkFf8OLqOwMVOounxTv65oxRhHow702gZHeXDpKXbiS6nEof Qd4AAV4sfzQY5vv07R8LpybrFO/EW3CdTqkBLFiQJSvv1Dg66epHwG3YDyqZtl4ldBIY yPnmWOx38744G/JHpUuEVNHMhlYmF7NNF4YKc4U9o3X8omzUjKQCkqUuMVtgij/65cOq wQISsV3BR0diH+TrYqiZ57EOWVmpW8LO82LD9tDXEcszhRP183EHjF+Nah/Z9H6wgIiF rihQ== X-Gm-Message-State: AOAM532BK1bcXm2CmAXaEZVLHH4w+KfNfSxnyly8XE2Tch98WjinDz/7 0PDtwCKDZIufoJ5rbO/SNiAQuyZtU+Wco8w1e/6J0GkUPqL252d6qHEx3cSvMusrJg9Yx/p2wGr QBw+gVRc9hpywc1taHQ4QdY7lomwgxwlihvvpt42c0jZBJnyPkEZYmSfJaqJuoeE2 X-Google-Smtp-Source: ABdhPJzK6w28BwGKLIOpFvOI6PIQT+l+UTTOSLy7w5dsJnOxx4h/iTBQ6mGPf1MdPoJQYv8OJ0QVIw== X-Received: by 2002:a05:6402:d5a:: with SMTP id ec26mr13239935edb.4.1626424621168; Fri, 16 Jul 2021 01:37:01 -0700 (PDT) Received: from localhost.localdomain ([155.93.216.150]) by smtp.gmail.com with ESMTPSA id e6sm3371650edk.63.2021.07.16.01.36.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jul 2021 01:37:00 -0700 (PDT) From: Heinrich Kuhn To: dev@dpdk.org Cc: Heinrich Kuhn , Simon Horman Date: Fri, 16 Jul 2021 10:35:40 +0200 Message-Id: <20210716083545.34444-2-heinrich.kuhn@netronome.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210716083545.34444-1-heinrich.kuhn@netronome.com> References: <20210716082314.33865-1-heinrich.kuhn@netronome.com> <20210716083545.34444-1-heinrich.kuhn@netronome.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 1/7] net/nfp: split rxtx headers into separate file 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 Sender: "dev" This change splits out the rx/tx specific structs and defines from the main nfp_net_pmd header file and into their own header file. Signed-off-by: Heinrich Kuhn Signed-off-by: Simon Horman --- drivers/net/nfp/nfp_net.c | 1 + drivers/net/nfp/nfp_net_pmd.h | 248 ------------------------------ drivers/net/nfp/nfp_rxtx.h | 276 ++++++++++++++++++++++++++++++++++ 3 files changed, 277 insertions(+), 248 deletions(-) create mode 100644 drivers/net/nfp/nfp_rxtx.h diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index b18edd8c7b..67288abeff 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -38,6 +38,7 @@ #include "nfpcore/nfp_nsp.h" #include "nfp_net_pmd.h" +#include "nfp_rxtx.h" #include "nfp_net_logs.h" #include "nfp_net_ctrl.h" diff --git a/drivers/net/nfp/nfp_net_pmd.h b/drivers/net/nfp/nfp_net_pmd.h index 212f9ef162..a3a3ba32d6 100644 --- a/drivers/net/nfp/nfp_net_pmd.h +++ b/drivers/net/nfp/nfp_net_pmd.h @@ -23,19 +23,6 @@ /* Forward declaration */ struct nfp_net_adapter; -/* - * The maximum number of descriptors is limited by design as - * DPDK uses uint16_t variables for these values - */ -#define NFP_NET_MAX_TX_DESC (32 * 1024) -#define NFP_NET_MIN_TX_DESC 64 - -#define NFP_NET_MAX_RX_DESC (32 * 1024) -#define NFP_NET_MIN_RX_DESC 64 - -/* Descriptor alignment */ -#define NFP_ALIGN_RING_DESC 128 - #define NFP_TX_MAX_SEG UINT8_MAX #define NFP_TX_MAX_MTU_SEG 8 @@ -150,241 +137,6 @@ static inline void nn_writeq(uint64_t val, volatile void *addr) nn_writel(val, addr); } -/* TX descriptor format */ -#define PCIE_DESC_TX_EOP (1 << 7) -#define PCIE_DESC_TX_OFFSET_MASK (0x7f) - -/* Flags in the host TX descriptor */ -#define PCIE_DESC_TX_CSUM (1 << 7) -#define PCIE_DESC_TX_IP4_CSUM (1 << 6) -#define PCIE_DESC_TX_TCP_CSUM (1 << 5) -#define PCIE_DESC_TX_UDP_CSUM (1 << 4) -#define PCIE_DESC_TX_VLAN (1 << 3) -#define PCIE_DESC_TX_LSO (1 << 2) -#define PCIE_DESC_TX_ENCAP_NONE (0) -#define PCIE_DESC_TX_ENCAP_VXLAN (1 << 1) -#define PCIE_DESC_TX_ENCAP_GRE (1 << 0) - -struct nfp_net_tx_desc { - union { - struct { - uint8_t dma_addr_hi; /* High bits of host buf address */ - __le16 dma_len; /* Length to DMA for this desc */ - uint8_t offset_eop; /* Offset in buf where pkt starts + - * highest bit is eop flag. - */ - __le32 dma_addr_lo; /* Low 32bit of host buf addr */ - - __le16 mss; /* MSS to be used for LSO */ - uint8_t lso_hdrlen; /* LSO, where the data starts */ - uint8_t flags; /* TX Flags, see @PCIE_DESC_TX_* */ - - union { - struct { - /* - * L3 and L4 header offsets required - * for TSOv2 - */ - uint8_t l3_offset; - uint8_t l4_offset; - }; - __le16 vlan; /* VLAN tag to add if indicated */ - }; - __le16 data_len; /* Length of frame + meta data */ - } __rte_packed; - __le32 vals[4]; - }; -}; - -struct nfp_net_txq { - struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */ - - /* - * Queue information: @qidx is the queue index from Linux's - * perspective. @tx_qcidx is the index of the Queue - * Controller Peripheral queue relative to the TX queue BAR. - * @cnt is the size of the queue in number of - * descriptors. @qcp_q is a pointer to the base of the queue - * structure on the NFP - */ - uint8_t *qcp_q; - - /* - * Read and Write pointers. @wr_p and @rd_p are host side pointer, - * they are free running and have little relation to the QCP pointers * - * @qcp_rd_p is a local copy queue controller peripheral read pointer - */ - - uint32_t wr_p; - uint32_t rd_p; - - uint32_t tx_count; - - uint32_t tx_free_thresh; - - /* - * For each descriptor keep a reference to the mbuf and - * DMA address used until completion is signalled. - */ - struct { - struct rte_mbuf *mbuf; - } *txbufs; - - /* - * Information about the host side queue location. @txds is - * the virtual address for the queue, @dma is the DMA address - * of the queue and @size is the size in bytes for the queue - * (needed for free) - */ - struct nfp_net_tx_desc *txds; - - /* - * At this point 48 bytes have been used for all the fields in the - * TX critical path. We have room for 8 bytes and still all placed - * in a cache line. We are not using the threshold values below but - * if we need to, we can add the most used in the remaining bytes. - */ - uint32_t tx_rs_thresh; /* not used by now. Future? */ - uint32_t tx_pthresh; /* not used by now. Future? */ - uint32_t tx_hthresh; /* not used by now. Future? */ - uint32_t tx_wthresh; /* not used by now. Future? */ - uint16_t port_id; - int qidx; - int tx_qcidx; - __le64 dma; -} __rte_aligned(64); - -/* RX and freelist descriptor format */ -#define PCIE_DESC_RX_DD (1 << 7) -#define PCIE_DESC_RX_META_LEN_MASK (0x7f) - -/* Flags in the RX descriptor */ -#define PCIE_DESC_RX_RSS (1 << 15) -#define PCIE_DESC_RX_I_IP4_CSUM (1 << 14) -#define PCIE_DESC_RX_I_IP4_CSUM_OK (1 << 13) -#define PCIE_DESC_RX_I_TCP_CSUM (1 << 12) -#define PCIE_DESC_RX_I_TCP_CSUM_OK (1 << 11) -#define PCIE_DESC_RX_I_UDP_CSUM (1 << 10) -#define PCIE_DESC_RX_I_UDP_CSUM_OK (1 << 9) -#define PCIE_DESC_RX_SPARE (1 << 8) -#define PCIE_DESC_RX_EOP (1 << 7) -#define PCIE_DESC_RX_IP4_CSUM (1 << 6) -#define PCIE_DESC_RX_IP4_CSUM_OK (1 << 5) -#define PCIE_DESC_RX_TCP_CSUM (1 << 4) -#define PCIE_DESC_RX_TCP_CSUM_OK (1 << 3) -#define PCIE_DESC_RX_UDP_CSUM (1 << 2) -#define PCIE_DESC_RX_UDP_CSUM_OK (1 << 1) -#define PCIE_DESC_RX_VLAN (1 << 0) - -#define PCIE_DESC_RX_L4_CSUM_OK (PCIE_DESC_RX_TCP_CSUM_OK | \ - PCIE_DESC_RX_UDP_CSUM_OK) -struct nfp_net_rx_desc { - union { - /* Freelist descriptor */ - struct { - uint8_t dma_addr_hi; - __le16 spare; - uint8_t dd; - - __le32 dma_addr_lo; - } __rte_packed fld; - - /* RX descriptor */ - struct { - __le16 data_len; - uint8_t reserved; - uint8_t meta_len_dd; - - __le16 flags; - __le16 vlan; - } __rte_packed rxd; - - __le32 vals[2]; - }; -}; - -struct nfp_net_rx_buff { - struct rte_mbuf *mbuf; -}; - -struct nfp_net_rxq { - struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */ - - /* - * @qcp_fl and @qcp_rx are pointers to the base addresses of the - * freelist and RX queue controller peripheral queue structures on the - * NFP - */ - uint8_t *qcp_fl; - uint8_t *qcp_rx; - - /* - * Read and Write pointers. @wr_p and @rd_p are host side - * pointer, they are free running and have little relation to - * the QCP pointers. @wr_p is where the driver adds new - * freelist descriptors and @rd_p is where the driver start - * reading descriptors for newly arrive packets from. - */ - uint32_t rd_p; - - /* - * For each buffer placed on the freelist, record the - * associated SKB - */ - struct nfp_net_rx_buff *rxbufs; - - /* - * Information about the host side queue location. @rxds is - * the virtual address for the queue - */ - struct nfp_net_rx_desc *rxds; - - /* - * The mempool is created by the user specifying a mbuf size. - * We save here the reference of the mempool needed in the RX - * path and the mbuf size for checking received packets can be - * safely copied to the mbuf using the NFP_NET_RX_OFFSET - */ - struct rte_mempool *mem_pool; - uint16_t mbuf_size; - - /* - * Next two fields are used for giving more free descriptors - * to the NFP - */ - uint16_t rx_free_thresh; - uint16_t nb_rx_hold; - - /* the size of the queue in number of descriptors */ - uint16_t rx_count; - - /* - * Fields above this point fit in a single cache line and are all used - * in the RX critical path. Fields below this point are just used - * during queue configuration or not used at all (yet) - */ - - /* referencing dev->data->port_id */ - uint16_t port_id; - - uint8_t crc_len; /* Not used by now */ - uint8_t drop_en; /* Not used by now */ - - /* DMA address of the queue */ - __le64 dma; - - /* - * Queue information: @qidx is the queue index from Linux's - * perspective. @fl_qcidx is the index of the Queue - * Controller peripheral queue relative to the RX queue BAR - * used for the freelist and @rx_qcidx is the Queue Controller - * Peripheral index for the RX queue. - */ - int qidx; - int fl_qcidx; - int rx_qcidx; -} __rte_aligned(64); - struct nfp_pf_dev { /* Backpointer to associated pci device */ struct rte_pci_device *pci_dev; diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h new file mode 100644 index 0000000000..41a3a4b4e7 --- /dev/null +++ b/drivers/net/nfp/nfp_rxtx.h @@ -0,0 +1,276 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2014-2021 Netronome Systems, Inc. + * All rights reserved. + */ + +/* + * vim:shiftwidth=8:noexpandtab + * + * @file dpdk/pmd/nfp_rxtx.h + * + * Netronome NFP Rx/Tx specific header file + */ + +#ifndef _NFP_RXTX_H_ +#define _NFP_RXTX_H_ + +#include +#include + +/* + * The maximum number of descriptors is limited by design as + * DPDK uses uint16_t variables for these values + */ +#define NFP_NET_MAX_TX_DESC (32 * 1024) +#define NFP_NET_MIN_TX_DESC 64 + +#define NFP_NET_MAX_RX_DESC (32 * 1024) +#define NFP_NET_MIN_RX_DESC 64 + +/* Descriptor alignment */ +#define NFP_ALIGN_RING_DESC 128 + +/* TX descriptor format */ +#define PCIE_DESC_TX_EOP (1 << 7) +#define PCIE_DESC_TX_OFFSET_MASK (0x7f) + +/* Flags in the host TX descriptor */ +#define PCIE_DESC_TX_CSUM (1 << 7) +#define PCIE_DESC_TX_IP4_CSUM (1 << 6) +#define PCIE_DESC_TX_TCP_CSUM (1 << 5) +#define PCIE_DESC_TX_UDP_CSUM (1 << 4) +#define PCIE_DESC_TX_VLAN (1 << 3) +#define PCIE_DESC_TX_LSO (1 << 2) +#define PCIE_DESC_TX_ENCAP_NONE (0) +#define PCIE_DESC_TX_ENCAP_VXLAN (1 << 1) +#define PCIE_DESC_TX_ENCAP_GRE (1 << 0) + +struct nfp_net_tx_desc { + union { + struct { + uint8_t dma_addr_hi; /* High bits of host buf address */ + __le16 dma_len; /* Length to DMA for this desc */ + uint8_t offset_eop; /* Offset in buf where pkt starts + + * highest bit is eop flag. + */ + __le32 dma_addr_lo; /* Low 32bit of host buf addr */ + + __le16 mss; /* MSS to be used for LSO */ + uint8_t lso_hdrlen; /* LSO, where the data starts */ + uint8_t flags; /* TX Flags, see @PCIE_DESC_TX_* */ + + union { + struct { + /* + * L3 and L4 header offsets required + * for TSOv2 + */ + uint8_t l3_offset; + uint8_t l4_offset; + }; + __le16 vlan; /* VLAN tag to add if indicated */ + }; + __le16 data_len; /* Length of frame + meta data */ + } __rte_packed; + __le32 vals[4]; + }; +}; + +struct nfp_net_txq { + struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */ + + /* + * Queue information: @qidx is the queue index from Linux's + * perspective. @tx_qcidx is the index of the Queue + * Controller Peripheral queue relative to the TX queue BAR. + * @cnt is the size of the queue in number of + * descriptors. @qcp_q is a pointer to the base of the queue + * structure on the NFP + */ + uint8_t *qcp_q; + + /* + * Read and Write pointers. @wr_p and @rd_p are host side pointer, + * they are free running and have little relation to the QCP pointers * + * @qcp_rd_p is a local copy queue controller peripheral read pointer + */ + + uint32_t wr_p; + uint32_t rd_p; + + uint32_t tx_count; + + uint32_t tx_free_thresh; + + /* + * For each descriptor keep a reference to the mbuf and + * DMA address used until completion is signalled. + */ + struct { + struct rte_mbuf *mbuf; + } *txbufs; + + /* + * Information about the host side queue location. @txds is + * the virtual address for the queue, @dma is the DMA address + * of the queue and @size is the size in bytes for the queue + * (needed for free) + */ + struct nfp_net_tx_desc *txds; + + /* + * At this point 48 bytes have been used for all the fields in the + * TX critical path. We have room for 8 bytes and still all placed + * in a cache line. We are not using the threshold values below but + * if we need to, we can add the most used in the remaining bytes. + */ + uint32_t tx_rs_thresh; /* not used by now. Future? */ + uint32_t tx_pthresh; /* not used by now. Future? */ + uint32_t tx_hthresh; /* not used by now. Future? */ + uint32_t tx_wthresh; /* not used by now. Future? */ + uint16_t port_id; + int qidx; + int tx_qcidx; + __le64 dma; +} __rte_aligned(64); + +/* RX and freelist descriptor format */ +#define PCIE_DESC_RX_DD (1 << 7) +#define PCIE_DESC_RX_META_LEN_MASK (0x7f) + +/* Flags in the RX descriptor */ +#define PCIE_DESC_RX_RSS (1 << 15) +#define PCIE_DESC_RX_I_IP4_CSUM (1 << 14) +#define PCIE_DESC_RX_I_IP4_CSUM_OK (1 << 13) +#define PCIE_DESC_RX_I_TCP_CSUM (1 << 12) +#define PCIE_DESC_RX_I_TCP_CSUM_OK (1 << 11) +#define PCIE_DESC_RX_I_UDP_CSUM (1 << 10) +#define PCIE_DESC_RX_I_UDP_CSUM_OK (1 << 9) +#define PCIE_DESC_RX_SPARE (1 << 8) +#define PCIE_DESC_RX_EOP (1 << 7) +#define PCIE_DESC_RX_IP4_CSUM (1 << 6) +#define PCIE_DESC_RX_IP4_CSUM_OK (1 << 5) +#define PCIE_DESC_RX_TCP_CSUM (1 << 4) +#define PCIE_DESC_RX_TCP_CSUM_OK (1 << 3) +#define PCIE_DESC_RX_UDP_CSUM (1 << 2) +#define PCIE_DESC_RX_UDP_CSUM_OK (1 << 1) +#define PCIE_DESC_RX_VLAN (1 << 0) + +#define PCIE_DESC_RX_L4_CSUM_OK (PCIE_DESC_RX_TCP_CSUM_OK | \ + PCIE_DESC_RX_UDP_CSUM_OK) + +struct nfp_net_rx_desc { + union { + /* Freelist descriptor */ + struct { + uint8_t dma_addr_hi; + __le16 spare; + uint8_t dd; + + __le32 dma_addr_lo; + } __rte_packed fld; + + /* RX descriptor */ + struct { + __le16 data_len; + uint8_t reserved; + uint8_t meta_len_dd; + + __le16 flags; + __le16 vlan; + } __rte_packed rxd; + + __le32 vals[2]; + }; +}; + +struct nfp_net_rx_buff { + struct rte_mbuf *mbuf; +}; + +struct nfp_net_rxq { + struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */ + + /* + * @qcp_fl and @qcp_rx are pointers to the base addresses of the + * freelist and RX queue controller peripheral queue structures on the + * NFP + */ + uint8_t *qcp_fl; + uint8_t *qcp_rx; + + /* + * Read and Write pointers. @wr_p and @rd_p are host side + * pointer, they are free running and have little relation to + * the QCP pointers. @wr_p is where the driver adds new + * freelist descriptors and @rd_p is where the driver start + * reading descriptors for newly arrive packets from. + */ + uint32_t rd_p; + + /* + * For each buffer placed on the freelist, record the + * associated SKB + */ + struct nfp_net_rx_buff *rxbufs; + + /* + * Information about the host side queue location. @rxds is + * the virtual address for the queue + */ + struct nfp_net_rx_desc *rxds; + + /* + * The mempool is created by the user specifying a mbuf size. + * We save here the reference of the mempool needed in the RX + * path and the mbuf size for checking received packets can be + * safely copied to the mbuf using the NFP_NET_RX_OFFSET + */ + struct rte_mempool *mem_pool; + uint16_t mbuf_size; + + /* + * Next two fields are used for giving more free descriptors + * to the NFP + */ + uint16_t rx_free_thresh; + uint16_t nb_rx_hold; + + /* the size of the queue in number of descriptors */ + uint16_t rx_count; + + /* + * Fields above this point fit in a single cache line and are all used + * in the RX critical path. Fields below this point are just used + * during queue configuration or not used at all (yet) + */ + + /* referencing dev->data->port_id */ + uint16_t port_id; + + uint8_t crc_len; /* Not used by now */ + uint8_t drop_en; /* Not used by now */ + + /* DMA address of the queue */ + __le64 dma; + + /* + * Queue information: @qidx is the queue index from Linux's + * perspective. @fl_qcidx is the index of the Queue + * Controller peripheral queue relative to the RX queue BAR + * used for the freelist and @rx_qcidx is the Queue Controller + * Peripheral index for the RX queue. + */ + int qidx; + int fl_qcidx; + int rx_qcidx; +} __rte_aligned(64); + +#endif /* _NFP_RXTX_H_ */ +/* + * Local variables: + * c-file-style: "Linux" + * indent-tabs-mode: t + * End: + */ +