From patchwork Mon Feb 2 09:25:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chen, Jing D" X-Patchwork-Id: 2911 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id CE3E9376D; Mon, 2 Feb 2015 10:27:32 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 412472A61 for ; Mon, 2 Feb 2015 10:27:30 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 02 Feb 2015 01:20:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,505,1418112000"; d="scan'208";a="646058497" Received: from kmsmsx152.gar.corp.intel.com ([172.21.73.87]) by orsmga001.jf.intel.com with ESMTP; 02 Feb 2015 01:25:52 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by KMSMSX152.gar.corp.intel.com (172.21.73.87) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 2 Feb 2015 17:25:50 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.129]) with mapi id 14.03.0195.001; Mon, 2 Feb 2015 17:25:50 +0800 From: "Chen, Jing D" To: David Marchand Thread-Topic: [dpdk-dev] [PATCH 03/18] fm10k: Add empty fm10k files Thread-Index: AQHQPErIuHHy5Tg05UC3lptn6sYToJzbP66AgAHbefA= Date: Mon, 2 Feb 2015 09:25:48 +0000 Message-ID: <4341B239C0EFF9468EE453F9E9F4604D016632DD@shsmsx102.ccr.corp.intel.com> References: <1422594454-11045-1-git-send-email-jing.d.chen@intel.com> <1422594454-11045-4-git-send-email-jing.d.chen@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 03/18] fm10k: Add empty fm10k files X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi David, From: David Marchand [mailto:david.marchand@6wind.com] Sent: Sunday, February 01, 2015 9:01 PM To: Chen, Jing D Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 03/18] fm10k: Add empty fm10k files On Fri, Jan 30, 2015 at 6:07 AM, Chen Jing D(Mark) wrote: From: Jeff Shaw Define macros and basic data structure. Define rte_log wrapper functions. This comment applies to the logs macro (and the rest of the patchset). - don't use a build option for logs to be displayed, especially if these are init messages or error messages that prevent the pmd from working - you can remove this "Use RTE_LOG directly to make sure this error is seen." in fm10k_rx_queue_setup if you use a "init" macro that is not under a build option - don't use \n in logs, only one is enough Please, check the cleanup work that has been done in other Intel pmd (for example, ixgbe). I would really prefer we have consistent logs across dpdk. [Mark] Thanks for your comments. I'll check it. -- David Marchand   Signed-off-by: Jeff Shaw Signed-off-by: Chen Jing D(Mark) ---  lib/librte_pmd_fm10k/Makefile     |   96 ++++++++++++++++  lib/librte_pmd_fm10k/fm10k.h      |  224 +++++++++++++++++++++++++++++++++++++  lib/librte_pmd_fm10k/fm10k_logs.h |   66 +++++++++++  3 files changed, 386 insertions(+), 0 deletions(-)  create mode 100644 lib/librte_pmd_fm10k/Makefile  create mode 100644 lib/librte_pmd_fm10k/fm10k.h  create mode 100644 lib/librte_pmd_fm10k/fm10k_ethdev.c  create mode 100644 lib/librte_pmd_fm10k/fm10k_logs.h  create mode 100644 lib/librte_pmd_fm10k/fm10k_rxtx.c diff --git a/lib/librte_pmd_fm10k/fm10k_rxtx.c b/lib/librte_pmd_fm10k/fm10k_rxtx.c new file mode 100644 index 0000000..e69de29 -- 1.7.7.6 diff --git a/lib/librte_pmd_fm10k/Makefile b/lib/librte_pmd_fm10k/Makefile new file mode 100644 index 0000000..3d76387 --- /dev/null +++ b/lib/librte_pmd_fm10k/Makefile @@ -0,0 +1,96 @@ +#   BSD LICENSE +# +#   Copyright(c) 2013-2014 Intel Corporation. All rights reserved. +#   All rights reserved. +# +#   Redistribution and use in source and binary forms, with or without +#   modification, are permitted provided that the following conditions +#   are met: +# +#     * Redistributions of source code must retain the above copyright +#       notice, this list of conditions and the following disclaimer. +#     * Redistributions in binary form must reproduce the above copyright +#       notice, this list of conditions and the following disclaimer in +#       the documentation and/or other materials provided with the +#       distribution. +#     * Neither the name of Intel Corporation nor the names of its +#       contributors may be used to endorse or promote products derived +#       from this software without specific prior written permission. +# +#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_pmd_fm10k.a + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) + +ifeq ($(CC), icc) +# +# CFLAGS for icc +# +CFLAGS_BASE_DRIVER = -wd174 -wd593 -wd869 -wd981 -wd2259 + +else ifeq ($(CC), clang) +# +## CFLAGS for clang +# +CFLAGS_BASE_DRIVER = -Wno-unused-parameter -Wno-unused-value +CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args +CFLAGS_BASE_DRIVER += -Wno-unused-variable -Wno-unused-but-set-variable +CFLAGS_BASE_DRIVER += -Wno-missing-field-initializers + +else +# +# CFLAGS for gcc +# +ifneq ($(shell test $(GCC_MAJOR_VERSION) -le 4 -a $(GCC_MINOR_VERSION) -le 3 && echo 1), 1) +CFLAGS     += -Wno-deprecated +endif +CFLAGS_BASE_DRIVER = -Wno-unused-parameter -Wno-unused-value +CFLAGS_BASE_DRIVER += -Wno-strict-aliasing -Wno-format-extra-args +CFLAGS_BASE_DRIVER += -Wno-unused-variable -Wno-unused-but-set-variable +CFLAGS_BASE_DRIVER += -Wno-missing-field-initializers +endif + +# +# Add extra flags for base driver source files to disable warnings in them +# +BASE_DRIVER_OBJS=$(patsubst %.c,%.o,$(notdir $(wildcard $(RTE_SDK)/lib/librte_pmd_fm10k/SHARED/*.c))) +$(foreach obj, $(BASE_DRIVER_OBJS), $(eval CFLAGS_$(obj)+=$(CFLAGS_BASE_DRIVER))) + +VPATH += $(RTE_SDK)/lib/librte_pmd_fm10k/SHARED + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_rxtx.c + +SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_pf.c +SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_tlv.c +SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_common.c +SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_mbx.c +SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_vf.c +SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_api.c + +# this lib depends upon: +DEPDIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += lib/librte_eal lib/librte_ether +DEPDIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += lib/librte_mempool lib/librte_mbuf +DEPDIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += lib/librte_net lib/librte_malloc + +include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_pmd_fm10k/fm10k.h b/lib/librte_pmd_fm10k/fm10k.h new file mode 100644 index 0000000..9b2d3da --- /dev/null +++ b/lib/librte_pmd_fm10k/fm10k.h @@ -0,0 +1,224 @@ +/*- + *   BSD LICENSE + * + *   Copyright(c) 2013-2014 Intel Corporation. All rights reserved. + *   All rights reserved. + * + *   Redistribution and use in source and binary forms, with or without + *   modification, are permitted provided that the following conditions + *   are met: + * + *     * Redistributions of source code must retain the above copyright + *       notice, this list of conditions and the following disclaimer. + *     * Redistributions in binary form must reproduce the above copyright + *       notice, this list of conditions and the following disclaimer in + *       the documentation and/or other materials provided with the + *       distribution. + *     * Neither the name of Intel Corporation nor the names of its + *       contributors may be used to endorse or promote products derived + *       from this software without specific prior written permission. + * + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _FM10K_H_ +#define _FM10K_H_ + +#include +#include +#include +#include +#include +#include "fm10k_logs.h" +#include "SHARED/fm10k_type.h" + +/* descriptor ring base addresses must be aligned to the following */ +#define FM10K_ALIGN_RX_DESC  128 +#define FM10K_ALIGN_TX_DESC  128 + +/* The maximum packet size that FM10K supports */ +#define FM10K_MAX_PKT_SIZE  (15 * 1024) + +/* Minimum size of RX buffer FM10K supported */ +#define FM10K_MIN_RX_BUF_SIZE  256 + +/* The maximum of SRIOV VFs per port supported */ +#define FM10K_MAX_VF_NUM    64 + +/* number of descriptors must be a multiple of the following */ +#define FM10K_MULT_RX_DESC  FM10K_REQ_RX_DESCRIPTOR_MULTIPLE +#define FM10K_MULT_TX_DESC  FM10K_REQ_TX_DESCRIPTOR_MULTIPLE + +/* maximum size of descriptor rings */ +#define FM10K_MAX_RX_RING_SZ  (512 * 1024) +#define FM10K_MAX_TX_RING_SZ  (512 * 1024) + +/* minimum and maximum number of descriptors in a ring */ +#define FM10K_MIN_RX_DESC  32 +#define FM10K_MIN_TX_DESC  32 +#define FM10K_MAX_RX_DESC  (FM10K_MAX_RX_RING_SZ / sizeof(union fm10k_rx_desc)) +#define FM10K_MAX_TX_DESC  (FM10K_MAX_TX_RING_SZ / sizeof(struct fm10k_tx_desc)) + +/* + * byte aligment for HW RX data buffer + * Datasheet requires RX buffer addresses shall either be 512-byte aligned or + * be 8-byte aligned but without crossing host memory pages (4KB alignment + * boundaries). Satisfy first option. + */ +#define FM10K_RX_DATABUF_ALIGN 512 + +/* + * threshold default, min, max, and divisor constraints + * the configured values must satisfy the following: + *   MIN <= value <= MAX + *   DIV % value == 0 + */ +#define FM10K_RX_FREE_THRESH_DEFAULT(rxq)  32 +#define FM10K_RX_FREE_THRESH_MIN(rxq)      1 +#define FM10K_RX_FREE_THRESH_MAX(rxq)      ((rxq)->nb_desc - 1) +#define FM10K_RX_FREE_THRESH_DIV(rxq)      ((rxq)->nb_desc) + +#define FM10K_TX_FREE_THRESH_DEFAULT(txq)  32 +#define FM10K_TX_FREE_THRESH_MIN(txq)      1 +#define FM10K_TX_FREE_THRESH_MAX(txq)      ((txq)->nb_desc - 3) +#define FM10K_TX_FREE_THRESH_DIV(txq)      0 + +#define FM10K_DEFAULT_RX_PTHRESH      8 +#define FM10K_DEFAULT_RX_HTHRESH      8 +#define FM10K_DEFAULT_RX_WTHRESH      0 + +#define FM10K_DEFAULT_TX_PTHRESH      32 +#define FM10K_DEFAULT_TX_HTHRESH      0 +#define FM10K_DEFAULT_TX_WTHRESH      0 + +#define FM10K_TX_RS_THRESH_DEFAULT(txq)    32 +#define FM10K_TX_RS_THRESH_MIN(txq)        1 +#define FM10K_TX_RS_THRESH_MAX(txq)        \ +       RTE_MIN(((txq)->nb_desc - 2), (txq)->free_thresh) +#define FM10K_TX_RS_THRESH_DIV(txq)        ((txq)->nb_desc) + +#define FM10K_VLAN_TAG_SIZE 4 + +struct fm10k_dev_info { +       volatile uint32_t enable; +       volatile uint32_t glort; +       /* Protect the mailbox to avoid race condition */ +       rte_spinlock_t    mbx_lock; +}; + +/* + * Structure to store private data for each driver instance. + */ +struct fm10k_adapter { +       struct fm10k_hw             hw; +       struct fm10k_hw_stats       stats; +       struct fm10k_dev_info       info; +}; + +#define FM10K_DEV_PRIVATE_TO_HW(adapter) \ +       (&((struct fm10k_adapter *)adapter)->hw) + +#define FM10K_DEV_PRIVATE_TO_STATS(adapter) \ +       (&((struct fm10k_adapter *)adapter)->stats) + +#define FM10K_DEV_PRIVATE_TO_INFO(adapter) \ +       (&((struct fm10k_adapter *)adapter)->info) + +#define FM10K_DEV_PRIVATE_TO_MBXLOCK(adapter) \ +       (&(((struct fm10k_adapter *)adapter)->info.mbx_lock)) + +struct fm10k_rx_queue { +       struct rte_mempool *mp; +       struct rte_mbuf **sw_ring; +       volatile union fm10k_rx_desc *hw_ring; +       struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */ +       struct rte_mbuf *pkt_last_seg;  /**< Last segment of current packet. */ +       uint64_t hw_ring_phys_addr; +       uint16_t next_dd; +       uint16_t next_alloc; +       uint16_t next_trigger; +       uint16_t alloc_thresh; +       volatile uint32_t *tail_ptr; +       uint16_t nb_desc; +       uint16_t queue_id; +       uint8_t port_id; +       uint8_t drop_en; +       uint8_t rx_deferred_start; /** < don't start this queue in dev start. */ +}; + +/* + * a FIFO is used to track which descriptors have their RS bit set for Tx + * queues which are configured to allow multiple descriptors per packet + */ +struct fifo { +       uint16_t *list; +       uint16_t *head; +       uint16_t *tail; +       uint16_t *endp; +}; + +struct fm10k_tx_queue { +       struct rte_mbuf **sw_ring; +       struct fm10k_tx_desc *hw_ring; +       uint64_t hw_ring_phys_addr; +       struct fifo rs_tracker; +       uint16_t last_free; +       uint16_t next_free; +       uint16_t nb_free; +       uint16_t nb_used; +       uint16_t free_trigger; +       uint16_t free_thresh; +       uint16_t rs_thresh; +       volatile uint32_t *tail_ptr; +       uint16_t nb_desc; +       uint8_t port_id; +       uint8_t tx_deferred_start; /** < don't start this queue in dev start. */ +       uint16_t queue_id; +}; + +#define MBUF_DMA_ADDR(mb) \ +       ((uint64_t) ((mb)->buf_physaddr + (mb)->data_off)) + +/* enforce 512B alignment on default Rx DMA addresses */ +#define MBUF_DMA_ADDR_DEFAULT(mb) \ +       ((uint64_t) RTE_ALIGN(((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM), 512)) + +static inline void fifo_reset(struct fifo *fifo, uint32_t len) +{ +       fifo->head = fifo->tail = fifo->list; +       fifo->endp = fifo->list + len; +} + +static inline void fifo_insert(struct fifo *fifo, uint16_t val) +{ +       *fifo->head = val; +       if (++fifo->head == fifo->endp) +               fifo->head = fifo->list; +} + +/* do not worry about list being empty since we only check it once we know + * we have used enough descriptors to set the RS bit at least once */ +static inline uint16_t fifo_peek(struct fifo *fifo) +{ +       return *fifo->tail; +} + +static inline uint16_t fifo_remove(struct fifo *fifo) +{ +       uint16_t val; +       val = *fifo->tail; +       if (++fifo->tail == fifo->endp) +               fifo->tail = fifo->list; +       return val; +} +#endif diff --git a/lib/librte_pmd_fm10k/fm10k_ethdev.c b/lib/librte_pmd_fm10k/fm10k_ethdev.c new file mode 100644 index 0000000..e69de29 diff --git a/lib/librte_pmd_fm10k/fm10k_logs.h b/lib/librte_pmd_fm10k/fm10k_logs.h new file mode 100644 index 0000000..0b4cd24 --- /dev/null +++ b/lib/librte_pmd_fm10k/fm10k_logs.h @@ -0,0 +1,66 @@ +/*- + *   BSD LICENSE + * + *   Copyright(c) 2013-2014 Intel Corporation. All rights reserved. + *   All rights reserved. + * + *   Redistribution and use in source and binary forms, with or without + *   modification, are permitted provided that the following conditions + *   are met: + * + *     * Redistributions of source code must retain the above copyright + *       notice, this list of conditions and the following disclaimer. + *     * Redistributions in binary form must reproduce the above copyright + *       notice, this list of conditions and the following disclaimer in + *       the documentation and/or other materials provided with the + *       distribution. + *     * Neither the name of Intel Corporation nor the names of its + *       contributors may be used to endorse or promote products derived + *       from this software without specific prior written permission. + * + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _FM10K_LOGS_H_ +#define _FM10K_LOGS_H_ + +#include + +#ifdef RTE_LIBRTE_FM10K_DEBUG +#define PMD_LOG(level, fmt, args...) \ +       RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) +#define PMD_FUNC_TRACE() PMD_LOG(DEBUG, " >>") +#else +#define PMD_LOG(level, fmt, args...) do { } while (0) +#define PMD_FUNC_TRACE() do { } while (0) +#endif + +#ifdef RTE_LIBRTE_FM10K_DEBUG_RX +#define PMD_LOG_RX(level, fmt, args...) \ +       RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) +#define PMD_FUNC_TRACE_RX() PMD_LOG_RX(DEBUG, " >>") +#else +#define PMD_LOG_RX(level, fmt, args...) do { } while (0) +#define PMD_FUNC_TRACE_RX() do { } while (0) +#endif + +#ifdef RTE_LIBRTE_FM10K_DEBUG_TX +#define PMD_LOG_TX(level, fmt, args...) \ +       RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args) +#define PMD_FUNC_TRACE_TX() PMD_LOG_TX(DEBUG, " >>") +#else +#define PMD_LOG_TX(level, fmt, args...) do { } while (0) +#define PMD_FUNC_TRACE_TX() do { } while (0) +#endif + +#endif /* _FM10K_LOGS_H_ */