Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp133291iob; Tue, 17 May 2022 21:21:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7D3IxmrUVPQtiBdo78lr3fhphBG3X10gdFD0EMIOIn+W84cEFKJ8hTM75JlNNm4Osa5Yz X-Received: by 2002:a63:1c03:0:b0:3f2:75a7:b25c with SMTP id c3-20020a631c03000000b003f275a7b25cmr9891641pgc.463.1652847702999; Tue, 17 May 2022 21:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652847702; cv=none; d=google.com; s=arc-20160816; b=HZz5t5bPhk+8tZsWhFvJ3JPSAlbBjbaFS8xAPVAJB6hibLMwA810EC79nwUuuJoMQJ kfs/sH+Mya9TnNf/LJAYgTqlBbPJig6SJN5h7vJ9DHdVfMJnWx0+oRtGqnsoG1KXOXuh XunclgJirSw5F74zLaHBs/s3bkuJCSn0aJ5kyI7dTJIHxUWLCZeSeowKxP0XjpO3pCRH E8q6NspTp/fVJbrKy9L66OuHpRX1ABbj+pRKRPU6VYKp7f4ztq84U5CKMSQHZn82bL6B TmHJWRElybm7+8YjuT+aWPdcFVBWrpJuHSOblCZWakmuyDkJTXF9qSfnanHeRE45r1Wx MdjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id; bh=k2BOm4/7v+7Vw78YKlwgSymqJRHyJC/px9486qRIm6E=; b=gQD0V+k1UJ9Xn1fdF7rZ/QHQJ4VLcycnKEQL6u1BVuTl10Wg1BB4y+oQjsQoOs74t0 m0YXXAek2LTHWi1dTbTo+57m+QsNbKUs1fdEiRNkFg1+tx6oGqhlA//RMyT9nwNy7Y6W lJu5jujTDQ2hWqDKN0AWxEciEKdA2aeYQF3SHzjd9eGenJc7CbvSBY4EIi+5YDLUWZwT V3QAdjlbvAdG1QlwobU8o0wzhDCcRuKGC0hKwcdy6QxgHX+83NtOfqTgiyl73aDrlr6m SCZTub7pFJPZg/84Zh5T22gXT+Uy+DAAhdjBbfPxx5S6hhaeJ8KxxsEYTnUNItI/Axr3 qZAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i5-20020a63a845000000b003f25d48f129si1162925pgp.196.2022.05.17.21.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:21:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 786AD23163; Tue, 17 May 2022 20:46:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353145AbiEQVDt (ORCPT + 99 others); Tue, 17 May 2022 17:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235046AbiEQVDs (ORCPT ); Tue, 17 May 2022 17:03:48 -0400 Received: from smtp.smtpout.orange.fr (smtp04.smtpout.orange.fr [80.12.242.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88782532C5 for ; Tue, 17 May 2022 14:03:46 -0700 (PDT) Received: from [192.168.1.18] ([86.243.180.246]) by smtp.orange.fr with ESMTPA id r4M1nkfskEhCQr4M1ndeLA; Tue, 17 May 2022 23:03:44 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Tue, 17 May 2022 23:03:44 +0200 X-ME-IP: 86.243.180.246 Message-ID: Date: Tue, 17 May 2022 23:03:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 From: Christophe JAILLET Subject: Re: [PATCH net-next v2 1/5] net: ipqess: introduce the Qualcomm IPQESS driver To: Maxime Chevallier , davem@davemloft.net, Rob Herring Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , linux-arm-kernel@lists.infradead.org, Vladimir Oltean , Luka Perkov , Robert Marko References: <20220514150656.122108-1-maxime.chevallier@bootlin.com> <20220514150656.122108-2-maxime.chevallier@bootlin.com> X-Mozilla-News-Host: news://news.gmane.org Content-Language: fr In-Reply-To: <20220514150656.122108-2-maxime.chevallier@bootlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 14/05/2022 à 17:06, Maxime Chevallier a écrit : > The Qualcomm IPQESS controller is a simple 1G Ethernet controller found > on the IPQ4019 chip. This controller has some specificities, in that the > IPQ4019 platform that includes that controller also has an internal > switch, based on the QCA8K IP. > > It is connected to that switch through an internal link, and doesn't > expose directly any external interface, hence it only supports the > PHY_INTERFACE_MODE_INTERNAL for now. > > It has 16 RX and TX queues, with a very basic RSS fanout configured at > init time. > > Signed-off-by: Maxime Chevallier > --- > V1->V2 : > - Reworked the init sequence, following Andrew's comments > - Added clock and reset support > - Reworked the error paths > - Added extra endianness wrappers to fix sparse warnings > > MAINTAINERS | 6 + > drivers/net/ethernet/qualcomm/Kconfig | 11 + > drivers/net/ethernet/qualcomm/Makefile | 2 + > drivers/net/ethernet/qualcomm/ipqess/Makefile | 8 + > drivers/net/ethernet/qualcomm/ipqess/ipqess.c | 1269 +++++++++++++++++ > drivers/net/ethernet/qualcomm/ipqess/ipqess.h | 518 +++++++ > .../ethernet/qualcomm/ipqess/ipqess_ethtool.c | 168 +++ > 7 files changed, 1982 insertions(+) > create mode 100644 drivers/net/ethernet/qualcomm/ipqess/Makefile > create mode 100644 drivers/net/ethernet/qualcomm/ipqess/ipqess.c > create mode 100644 drivers/net/ethernet/qualcomm/ipqess/ipqess.h > create mode 100644 drivers/net/ethernet/qualcomm/ipqess/ipqess_ethtool.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 9b0480f1b153..29e6ec4f975a 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -16308,6 +16308,12 @@ L: netdev@vger.kernel.org > S: Maintained > F: drivers/net/ethernet/qualcomm/emac/ > > +QUALCOMM IPQESS ETHERNET DRIVER > +M: Maxime Chevallier > +L: netdev@vger.kernel.org > +S: Maintained > +F: drivers/net/ethernet/qualcomm/ipqess/ > + > QUALCOMM ETHQOS ETHERNET DRIVER > M: Vinod Koul > L: netdev@vger.kernel.org > diff --git a/drivers/net/ethernet/qualcomm/Kconfig b/drivers/net/ethernet/qualcomm/Kconfig > index a4434eb38950..a723ddbea248 100644 > --- a/drivers/net/ethernet/qualcomm/Kconfig > +++ b/drivers/net/ethernet/qualcomm/Kconfig > @@ -60,6 +60,17 @@ config QCOM_EMAC > low power, Receive-Side Scaling (RSS), and IEEE 1588-2008 > Precision Clock Synchronization Protocol. > > +config QCOM_IPQ4019_ESS_EDMA > + tristate "Qualcomm Atheros IPQ4019 ESS EDMA support" > + depends on OF > + select PHYLINK > + help > + This driver supports the Qualcomm Atheros IPQ40xx built-in > + ESS EDMA ethernet controller. > + > + To compile this driver as a module, choose M here: the > + module will be called ipqess. > + > source "drivers/net/ethernet/qualcomm/rmnet/Kconfig" > > endif # NET_VENDOR_QUALCOMM > diff --git a/drivers/net/ethernet/qualcomm/Makefile b/drivers/net/ethernet/qualcomm/Makefile > index 9250976dd884..db463c9ea1f9 100644 > --- a/drivers/net/ethernet/qualcomm/Makefile > +++ b/drivers/net/ethernet/qualcomm/Makefile > @@ -11,4 +11,6 @@ qcauart-objs := qca_uart.o > > obj-y += emac/ > > +obj-$(CONFIG_QCOM_IPQ4019_ESS_EDMA) += ipqess/ > + > obj-$(CONFIG_RMNET) += rmnet/ > diff --git a/drivers/net/ethernet/qualcomm/ipqess/Makefile b/drivers/net/ethernet/qualcomm/ipqess/Makefile > new file mode 100644 > index 000000000000..4f2db7283ebf > --- /dev/null > +++ b/drivers/net/ethernet/qualcomm/ipqess/Makefile > @@ -0,0 +1,8 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +# > +# Makefile for the IPQ ESS driver > +# > + > +obj-$(CONFIG_QCOM_IPQ4019_ESS_EDMA) += ipq_ess.o > + > +ipq_ess-objs := ipqess.o ipqess_ethtool.o > diff --git a/drivers/net/ethernet/qualcomm/ipqess/ipqess.c b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c > new file mode 100644 > index 000000000000..b11f11f23c11 > --- /dev/null > +++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.c > @@ -0,0 +1,1269 @@ > +// SPDX-License-Identifier: GPL-2.0 OR ISC > +/* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved. > + * Copyright (c) 2017 - 2018, John Crispin > + * Copyright (c) 2018 - 2019, Christian Lamparter > + * Copyright (c) 2020 - 2021, Gabor Juhos > + * Copyright (c) 2021 - 2022, Maxime Chevallier > + * > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "ipqess.h" > + > +#define IPQESS_RRD_SIZE 16 > +#define IPQESS_NEXT_IDX(X, Y) (((X) + 1) & ((Y) - 1)) > +#define IPQESS_TX_DMA_BUF_LEN 0x3fff > + > +static void ipqess_w32(struct ipqess *ess, u32 reg, u32 val) > +{ > + writel(val, ess->hw_addr + reg); > +} > + > +static u32 ipqess_r32(struct ipqess *ess, u16 reg) > +{ > + return readl(ess->hw_addr + reg); > +} > + > +static void ipqess_m32(struct ipqess *ess, u32 mask, u32 val, u16 reg) > +{ > + u32 _val = ipqess_r32(ess, reg); > + > + _val &= ~mask; > + _val |= val; > + > + ipqess_w32(ess, reg, _val); > +} > + > +void ipqess_update_hw_stats(struct ipqess *ess) > +{ > + u32 *p; > + u32 stat; > + int i; > + > + lockdep_assert_held(&ess->stats_lock); > + > + p = (u32 *)&ess->ipqess_stats; > + for (i = 0; i < IPQESS_MAX_TX_QUEUE; i++) { > + stat = ipqess_r32(ess, IPQESS_REG_TX_STAT_PKT_Q(i)); > + *p += stat; > + p++; > + } > + > + for (i = 0; i < IPQESS_MAX_TX_QUEUE; i++) { > + stat = ipqess_r32(ess, IPQESS_REG_TX_STAT_BYTE_Q(i)); > + *p += stat; > + p++; > + } > + > + for (i = 0; i < IPQESS_MAX_RX_QUEUE; i++) { > + stat = ipqess_r32(ess, IPQESS_REG_RX_STAT_PKT_Q(i)); > + *p += stat; > + p++; > + } > + > + for (i = 0; i < IPQESS_MAX_RX_QUEUE; i++) { > + stat = ipqess_r32(ess, IPQESS_REG_RX_STAT_BYTE_Q(i)); > + *p += stat; > + p++; > + } > +} > + > +static int ipqess_tx_ring_alloc(struct ipqess *ess) > +{ > + struct device *dev = &ess->pdev->dev; > + int i; > + > + for (i = 0; i < IPQESS_NETDEV_QUEUES; i++) { > + struct ipqess_tx_ring *tx_ring = &ess->tx_ring[i]; > + size_t size; > + u32 idx; > + > + tx_ring->ess = ess; > + tx_ring->ring_id = i; > + tx_ring->idx = i * 4; > + tx_ring->count = IPQESS_TX_RING_SIZE; > + tx_ring->nq = netdev_get_tx_queue(ess->netdev, i); > + > + size = sizeof(struct ipqess_buf) * IPQESS_TX_RING_SIZE; > + tx_ring->buf = devm_kzalloc(dev, size, GFP_KERNEL); > + if (!tx_ring->buf) { > + netdev_err(ess->netdev, "buffer alloc of tx ring failed"); > + return -ENOMEM; > + } > + > + size = sizeof(struct ipqess_tx_desc) * IPQESS_TX_RING_SIZE; > + tx_ring->hw_desc = dmam_alloc_coherent(dev, size, &tx_ring->dma, > + GFP_KERNEL | __GFP_ZERO); Hi, Nitpicking: I think that __GFP_ZERO is useless (and harmless) because dma_alloc_coherent() always zeroes the memory that is allocated. CJ