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 EADECA0C50; Fri, 16 Jul 2021 10:23:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D850041330; Fri, 16 Jul 2021 10:23:56 +0200 (CEST) Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by mails.dpdk.org (Postfix) with ESMTP id 30BC34014D for ; Fri, 16 Jul 2021 10:23:55 +0200 (CEST) Received: by mail-ed1-f48.google.com with SMTP id l1so11813325edr.11 for ; Fri, 16 Jul 2021 01:23:55 -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=6we0oN5yQh6Ti30iZ0xgdwXeBsOAJV9G7XJkAhAk7YA=; b=SSJDWsLtFL8zAu+dg/Lmc/nBi5wl8bDBaAMslxi4WdxlLEACwL48sT1Ry34+BzXzxj eVhqUNDhPhW+xw7rhxam7SV34+kJHObHBV+pKd9oUBcdFH/ITySHwAXuCQ1smafMuvMz mvb/jRNho//iUT68LO6+rmYtaOE+tw07AQF7trFO0Ra4h1Fl/W2XBMkIkjqYMNIrwPQc eVUHLSPUWfq6pGr2pAIiyK1THU/fjpO0x/bInmUA14FC4gS3y6GbvRi4lag+tnByoPGa NEmOtDDNk4PiUYmqkiOyCCIcSWKhSuUf6QILOCWbgPfgDtWCtQWa7XZclF3GVpkS6UZi SZ+w== 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=6we0oN5yQh6Ti30iZ0xgdwXeBsOAJV9G7XJkAhAk7YA=; b=TmKCej3PNr4vw/IsDoR6o85nJ1hp1EAkir7QYIlyh7MXtRDIpKFdbQaZRzXoyNt1Q3 AWrWP6OhQyxPG1VuZVaywKPVBWIAteKGxPpwBN5Vlathy1q68SuAoCdN/cv5NUzIGCZY 2WdvjRLgCALHUCiTi+VXEMMeHQnORUAPwTApF7qv7GddG1K4kqdplJcEK8L2cj7pt3Nj kNrxFANRCZlDlINfo8C7OJqk35ZupeiAeezUgzgH+zVS5wi+GI+P0G6RlusEGsohZGBI ZsdYsTGERflcT9Y9ymDyuIgDkYlZrUdMO8uiE9OK8hh5cP1ZwmUgxqmvEuX5zOk8m+/h 16tw== X-Gm-Message-State: AOAM530qxnDQi/cQqcWpjhA5/k/bcX6k3iBHCzxHPzHe+qhyo5PORAE8 T6/r3vjU6WQYkkqxDrk3AG1XUrq7VPWmzKiRMTbWO5aTHOecRpdDNM9QUN5wUTVAAWj5hShFzNe Shk1Kx9pRZIZSim/VUP6y+1E3AlbfE1hu+Y9U5sZ70RlPbz8hVrM0MJD0ufbsyFD8 X-Google-Smtp-Source: ABdhPJwDXfD//4FceL0bVClo1Gs6kwCTmjJTXEOpNhePISMdRo3U9w2zOUWPqtIBg0bB/ejDvD5fyA== X-Received: by 2002:a05:6402:b4e:: with SMTP id bx14mr12984776edb.158.1626423834702; Fri, 16 Jul 2021 01:23:54 -0700 (PDT) Received: from localhost.localdomain ([155.93.216.150]) by smtp.gmail.com with ESMTPSA id q9sm2636777ejf.70.2021.07.16.01.23.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jul 2021 01:23:54 -0700 (PDT) From: Heinrich Kuhn To: dev@dpdk.org Cc: heinrich.kuhn@corigine.com, Heinrich Kuhn Date: Fri, 16 Jul 2021 10:23:08 +0200 Message-Id: <20210716082314.33865-2-heinrich.kuhn@netronome.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210716082314.33865-1-heinrich.kuhn@netronome.com> References: <20210716082314.33865-1-heinrich.kuhn@netronome.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 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 --- 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: + */ + -- 2.30.1 (Apple Git-130)