From patchwork Mon Oct 21 06:29:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 61522 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 E18BA29D2; Mon, 21 Oct 2019 08:45:48 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id E92CA29AC for ; Mon, 21 Oct 2019 08:45:46 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id AC7991A04E2; Mon, 21 Oct 2019 08:45:46 +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 D7F021A034E; Mon, 21 Oct 2019 08:45:44 +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 AAB86402B6; Mon, 21 Oct 2019 14:45:41 +0800 (SGT) From: Gagandeep Singh To: dev@dpdk.org, ferruh.yigit@intel.com Cc: Gagandeep Singh Date: Mon, 21 Oct 2019 11:59:50 +0530 Message-Id: <20191021062951.23562-1-g.singh@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 1/2] net/enetc: add macro for 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. 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 Mon Oct 21 06:29:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 61523 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 EA4182BCE; Mon, 21 Oct 2019 08:45:51 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id B638129AC for ; Mon, 21 Oct 2019 08:45:47 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 605E61A04E7; Mon, 21 Oct 2019 08:45:47 +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 8B42B1A04DF; Mon, 21 Oct 2019 08:45:45 +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 5F4E3402D3; Mon, 21 Oct 2019 14:45:42 +0800 (SGT) From: Gagandeep Singh To: dev@dpdk.org, ferruh.yigit@intel.com Cc: Gagandeep Singh Date: Mon, 21 Oct 2019 11:59:51 +0530 Message-Id: <20191021062951.23562-2-g.singh@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021062951.23562-1-g.singh@nxp.com> References: <20191021062951.23562-1-g.singh@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 2/2] 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/enetc_ethdev.c | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c index 4e978348c..cc8fdd051 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,21 @@ 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 ether_addr *eth_addr) +{ + char buf[ETHER_ADDR_FMT_SIZE]; + ether_format_addr(buf, 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 +149,28 @@ 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; + + ENETC_PMD_INFO("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; + *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 ether_addr *)hw->mac.addr); + } return 0; } @@ -906,5 +937,5 @@ RTE_INIT(enetc_pmd_init_log) { enetc_logtype_pmd = rte_log_register("pmd.net.enetc"); if (enetc_logtype_pmd >= 0) - rte_log_set_level(enetc_logtype_pmd, RTE_LOG_NOTICE); + rte_log_set_level(enetc_logtype_pmd, RTE_LOG_INFO); }