From patchwork Wed Oct 23 06:05:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 61702 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5DB921BF89; Wed, 23 Oct 2019 08:22:04 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 4F9F81BF83; Wed, 23 Oct 2019 08:22:00 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 1116C2000AD; Wed, 23 Oct 2019 08:22:00 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D76B220081E; Wed, 23 Oct 2019 08:21:57 +0200 (CEST) Received: from GDB1.ap.freescale.net (GDB1.ap.freescale.net [10.232.132.179]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id A0646402D3; Wed, 23 Oct 2019 14:21:54 +0800 (SGT) From: Gagandeep Singh To: dev@dpdk.org, ferruh.yigit@intel.com Cc: Gagandeep Singh , stable@dpdk.org Date: Wed, 23 Oct 2019 11:35:59 +0530 Message-Id: <20191023060602.32456-2-g.singh@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023060602.32456-1-g.singh@nxp.com> References: <20191021105027.14792-1-g.singh@nxp.com> <20191023060602.32456-1-g.singh@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v5 1/4] net/enetc: fix BD ring alignment X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" enetc BD rings should be aligned to 128 instead of RTE_CACHE_LINE_SIZE. Fixes: 469c6111a7 ("net/enetc: enable Rx and Tx") Cc: stable@dpdk.org Signed-off-by: Gagandeep Singh --- drivers/net/enetc/base/enetc_hw.h | 3 +++ drivers/net/enetc/enetc_ethdev.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/enetc/base/enetc_hw.h b/drivers/net/enetc/base/enetc_hw.h index fd71155ee..2fe7ccb5b 100644 --- a/drivers/net/enetc/base/enetc_hw.h +++ b/drivers/net/enetc/base/enetc_hw.h @@ -12,6 +12,9 @@ #define ENETC_DEV_ID_VF 0xef00 #define ENETC_DEV_ID 0xe100 +/* BD RING ALIGNMENT */ +#define ENETC_BD_RING_ALIGN 128 + /* ENETC register block BAR */ #define ENETC_BAR_REGS 0x0 diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index dc05c00ff..4e978348c 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -178,12 +178,12 @@ enetc_alloc_txbdr(struct enetc_bdr *txr, uint16_t nb_desc) int size; size = nb_desc * sizeof(struct enetc_swbd); - txr->q_swbd = rte_malloc(NULL, size, RTE_CACHE_LINE_SIZE); + txr->q_swbd = rte_malloc(NULL, size, ENETC_BD_RING_ALIGN); if (txr->q_swbd == NULL) return -ENOMEM; size = nb_desc * sizeof(struct enetc_tx_bd); - txr->bd_base = rte_malloc(NULL, size, RTE_CACHE_LINE_SIZE); + txr->bd_base = rte_malloc(NULL, size, ENETC_BD_RING_ALIGN); if (txr->bd_base == NULL) { rte_free(txr->q_swbd); txr->q_swbd = NULL; @@ -325,12 +325,12 @@ enetc_alloc_rxbdr(struct enetc_bdr *rxr, int size; size = nb_rx_desc * sizeof(struct enetc_swbd); - rxr->q_swbd = rte_malloc(NULL, size, RTE_CACHE_LINE_SIZE); + rxr->q_swbd = rte_malloc(NULL, size, ENETC_BD_RING_ALIGN); if (rxr->q_swbd == NULL) return -ENOMEM; size = nb_rx_desc * sizeof(union enetc_rx_bd); - rxr->bd_base = rte_malloc(NULL, size, RTE_CACHE_LINE_SIZE); + rxr->bd_base = rte_malloc(NULL, size, ENETC_BD_RING_ALIGN); if (rxr->bd_base == NULL) { rte_free(rxr->q_swbd); rxr->q_swbd = NULL; From patchwork Wed Oct 23 06:06:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 61703 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 044731BF97; Wed, 23 Oct 2019 08:22:07 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 929221BF87 for ; Wed, 23 Oct 2019 08:22:00 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 58C1F20081E; Wed, 23 Oct 2019 08:22:00 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 8A1DB200054; Wed, 23 Oct 2019 08:21:58 +0200 (CEST) Received: from GDB1.ap.freescale.net (GDB1.ap.freescale.net [10.232.132.179]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 68D10402F3; Wed, 23 Oct 2019 14:21:55 +0800 (SGT) From: Gagandeep Singh To: dev@dpdk.org, ferruh.yigit@intel.com Cc: Gagandeep Singh Date: Wed, 23 Oct 2019 11:36:00 +0530 Message-Id: <20191023060602.32456-3-g.singh@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023060602.32456-1-g.singh@nxp.com> References: <20191021105027.14792-1-g.singh@nxp.com> <20191023060602.32456-1-g.singh@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v5 2/4] net/enetc: set random MAC in case no MAC for SI X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" for SGMII interfaces, there can be 0 value written on MAC registers. This patch set the random MAC address for those interfaces. Signed-off-by: Gagandeep Singh --- drivers/net/enetc/Makefile | 2 +- drivers/net/enetc/enetc_ethdev.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/net/enetc/Makefile b/drivers/net/enetc/Makefile index 9895501db..312b37245 100644 --- a/drivers/net/enetc/Makefile +++ b/drivers/net/enetc/Makefile @@ -17,7 +17,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ENETC_PMD) += enetc_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_ENETC_PMD) += enetc_rxtx.c LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -LDLIBS += -lrte_ethdev +LDLIBS += -lrte_ethdev -lrte_net LDLIBS += -lrte_bus_pci include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index 4e978348c..d07e61c3f 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -4,6 +4,7 @@ #include #include +#include #include "enetc_logs.h" #include "enetc.h" @@ -123,11 +124,22 @@ enetc_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) return rte_eth_linkstatus_set(dev, &link); } +static void +print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr) +{ + char buf[RTE_ETHER_ADDR_FMT_SIZE]; + + rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr); + ENETC_PMD_INFO("%s%s\n", name, buf); +} + static int enetc_hardware_init(struct enetc_eth_hw *hw) { struct enetc_hw *enetc_hw = &hw->hw; uint32_t *mac = (uint32_t *)hw->mac.addr; + uint32_t high_mac = 0; + uint16_t low_mac = 0; PMD_INIT_FUNC_TRACE(); /* Calculating and storing the base HW addresses */ @@ -138,8 +150,27 @@ enetc_hardware_init(struct enetc_eth_hw *hw) enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN); *mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0)); + high_mac = (uint32_t)*mac; mac++; *mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0)); + low_mac = (uint16_t)*mac; + + if ((high_mac | low_mac) == 0) { + char *first_byte; + + mac = (uint32_t *)hw->mac.addr; + *mac = (uint32_t)rte_rand(); + first_byte = (char *)mac; + *first_byte &= 0xfe; /* clear multicast bit */ + *first_byte |= 0x02; /* set local assignment bit (IEEE802) */ + + enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), *mac); + mac++; + *mac = (uint16_t)rte_rand(); + enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), *mac); + print_ethaddr("New address: ", + (const struct rte_ether_addr *)hw->mac.addr); + } return 0; } From patchwork Wed Oct 23 06:06:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 61704 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 52F921BF9B; Wed, 23 Oct 2019 08:22:09 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 158DC1BF83 for ; Wed, 23 Oct 2019 08:22:01 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id A07F21A0324; Wed, 23 Oct 2019 08:22:00 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id D27DA1A06C9; Wed, 23 Oct 2019 08:21:58 +0200 (CEST) Received: from GDB1.ap.freescale.net (GDB1.ap.freescale.net [10.232.132.179]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 1C1214030B; Wed, 23 Oct 2019 14:21:56 +0800 (SGT) From: Gagandeep Singh To: dev@dpdk.org, ferruh.yigit@intel.com Cc: Gagandeep Singh Date: Wed, 23 Oct 2019 11:36:01 +0530 Message-Id: <20191023060602.32456-4-g.singh@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023060602.32456-1-g.singh@nxp.com> References: <20191021105027.14792-1-g.singh@nxp.com> <20191023060602.32456-1-g.singh@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v5 3/4] net/enetc: add log level notice X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" To display random MAC address as notice, a log level NOTICE is added. Signed-off-by: Gagandeep Singh --- drivers/net/enetc/enetc_ethdev.c | 4 +++- drivers/net/enetc/enetc_logs.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index d07e61c3f..c6099714e 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -130,7 +130,7 @@ print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr) char buf[RTE_ETHER_ADDR_FMT_SIZE]; rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr); - ENETC_PMD_INFO("%s%s\n", name, buf); + ENETC_PMD_NOTICE("%s%s\n", name, buf); } static int @@ -158,6 +158,8 @@ enetc_hardware_init(struct enetc_eth_hw *hw) if ((high_mac | low_mac) == 0) { char *first_byte; + ENETC_PMD_NOTICE("MAC is not available for this SI, " + "set random MAC\n"); mac = (uint32_t *)hw->mac.addr; *mac = (uint32_t)rte_rand(); first_byte = (char *)mac; diff --git a/drivers/net/enetc/enetc_logs.h b/drivers/net/enetc/enetc_logs.h index c8a6c0cf3..0976d42de 100644 --- a/drivers/net/enetc/enetc_logs.h +++ b/drivers/net/enetc/enetc_logs.h @@ -21,6 +21,8 @@ extern int enetc_logtype_pmd; ENETC_PMD_LOG(CRIT, fmt, ## args) #define ENETC_PMD_INFO(fmt, args...) \ ENETC_PMD_LOG(INFO, fmt, ## args) +#define ENETC_PMD_NOTICE(fmt, args...) \ + ENETC_PMD_LOG(NOTICE, fmt, ## args) #define ENETC_PMD_ERR(fmt, args...) \ ENETC_PMD_LOG(ERR, fmt, ## args) #define ENETC_PMD_WARN(fmt, args...) \ From patchwork Wed Oct 23 06:06:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 61705 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8D9581BFA5; Wed, 23 Oct 2019 08:22:11 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 7A26A1BF87 for ; Wed, 23 Oct 2019 08:22:01 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 529A11A00B2; Wed, 23 Oct 2019 08:22:01 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 845071A0362; Wed, 23 Oct 2019 08:21:59 +0200 (CEST) Received: from GDB1.ap.freescale.net (GDB1.ap.freescale.net [10.232.132.179]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id C32D6402E5; Wed, 23 Oct 2019 14:21:56 +0800 (SGT) From: Gagandeep Singh To: dev@dpdk.org, ferruh.yigit@intel.com Cc: Gagandeep Singh Date: Wed, 23 Oct 2019 11:36:02 +0530 Message-Id: <20191023060602.32456-5-g.singh@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023060602.32456-1-g.singh@nxp.com> References: <20191021105027.14792-1-g.singh@nxp.com> <20191023060602.32456-1-g.singh@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v5 4/4] net/enetc: enable dpaax library X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" dpaaX is used to maintain a local copy of PA->VA translations. Using the rte_mem_virt2iova or rte_mem_virt2phy is expensive. This library is an attempt to reduce the overall cost associated with this translation. This patch enables this dpaaX library by populating a dpaaX's table for PA to VA translation. This change will also help the caam JR driver in PA to VA translation when used with enetc driver over enetc supported SoCs. Signed-off-by: Gagandeep Singh --- drivers/net/enetc/Makefile | 2 ++ drivers/net/enetc/enetc_ethdev.c | 8 ++++++++ drivers/net/enetc/meson.build | 1 + 3 files changed, 11 insertions(+) diff --git a/drivers/net/enetc/Makefile b/drivers/net/enetc/Makefile index 312b37245..4498bc51f 100644 --- a/drivers/net/enetc/Makefile +++ b/drivers/net/enetc/Makefile @@ -10,6 +10,7 @@ LIB = librte_pmd_enetc.a CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/drivers/common/dpaax EXPORT_MAP := rte_pmd_enetc_version.map LIBABIVER := 1 @@ -19,5 +20,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_ENETC_PMD) += enetc_rxtx.c LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool LDLIBS += -lrte_ethdev -lrte_net LDLIBS += -lrte_bus_pci +LDLIBS += -lrte_common_dpaax include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index c6099714e..20b77c006 100644 --- a/drivers/net/enetc/enetc_ethdev.c +++ b/drivers/net/enetc/enetc_ethdev.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "enetc_logs.h" #include "enetc.h" @@ -896,6 +897,9 @@ enetc_dev_init(struct rte_eth_dev *eth_dev) eth_dev->data->mtu = RTE_ETHER_MAX_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN; + if (rte_eal_iova_mode() == RTE_IOVA_PA) + dpaax_iova_table_populate(); + ENETC_PMD_DEBUG("port_id %d vendorID=0x%x deviceID=0x%x", eth_dev->data->port_id, pci_dev->id.vendor_id, pci_dev->id.device_id); @@ -906,6 +910,10 @@ static int enetc_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused) { PMD_INIT_FUNC_TRACE(); + + if (rte_eal_iova_mode() == RTE_IOVA_PA) + dpaax_iova_table_depopulate(); + return 0; } diff --git a/drivers/net/enetc/meson.build b/drivers/net/enetc/meson.build index 3bc069844..bea54bea8 100644 --- a/drivers/net/enetc/meson.build +++ b/drivers/net/enetc/meson.build @@ -6,6 +6,7 @@ if not is_linux reason = 'only supported on linux' endif +deps += ['common_dpaax'] sources = files('enetc_ethdev.c', 'enetc_rxtx.c')