Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp8991ybf; Wed, 26 Feb 2020 07:55:21 -0800 (PST) X-Google-Smtp-Source: APXvYqyGgd3nr+e3UAu4v2J9ZSLG/idDueweAQC8mHVppDqZQWWQVtqarVqxGvZOXjpu/yzvXiif X-Received: by 2002:a05:6830:18d4:: with SMTP id v20mr3716673ote.29.1582732521505; Wed, 26 Feb 2020 07:55:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582732521; cv=none; d=google.com; s=arc-20160816; b=AsGaY2MmUFbTRpjHDBtWja0YzB2Yw0uU9qxEv2aossmFC5eHN0YcuaW/let1zGdoyt FBbLHBXDOFfmezxO/QErADFJljPhGOD/MzHSVpK/E+EPtsl6aqZT1wbO/pTcJEPwLgMQ LWl1qZ7WMCg9I5MCtyJLa0i84woi++KBdO9iyBDYKAs8H+qeMKSPPcE6Wc+X5OYogBbL ZvTZNe0xxL/CjUot2U8snTX3YRPCVDNqGhn+WfV+/A5V/yRtc4Yq14k8swIGLuikLM3w UTbqZQYrTjgTGWizGXH+NUR6PoJM9UFh+chy3foiFkWJ7FUXgHNg/L9bqhIUYsay/ow8 3Sjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Wo0vVnrj7LlByM+obGlDBGQf7mdPxoHFFT3j3qcwsLQ=; b=tBt/KUX9DJv6Or4QceAijzjW9qdNycxxYjJ5CfhYtImxFeeYfVPEDazViiwfyNuecg ogBN4l5PLpNSrwGg8dPWr2yDJIN0DEt8EKQFpufT3oFMxAJ4L0zxll89vAeJkBKdbsHn cet4QD2do6zqry6/6iWEpDENLJrflFuubrdP2tTff1HrKZnO+6tWzCC07hGyZg8tZaMz QTr6xjCJF/PT64wCd7AWPCsY6tIuLxfLJzOpWZd6V4zuXoKHPjt2paUYSJ9fxwlVkiJX phJHZz4j2ydjxv7iBaSC4MjmUNoSbHBopKluI8M0z+HhkVWkMqEC7oMPc2INXVYG8RgF ErCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b="D2ge/CUQ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si1413417otg.309.2020.02.26.07.55.09; Wed, 26 Feb 2020 07:55:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b="D2ge/CUQ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728571AbgBZPya (ORCPT + 99 others); Wed, 26 Feb 2020 10:54:30 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39255 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728470AbgBZPy2 (ORCPT ); Wed, 26 Feb 2020 10:54:28 -0500 Received: by mail-wm1-f66.google.com with SMTP id c84so3734979wme.4 for ; Wed, 26 Feb 2020 07:54:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Wo0vVnrj7LlByM+obGlDBGQf7mdPxoHFFT3j3qcwsLQ=; b=D2ge/CUQB7iGAkEt8HFgxp9DNF+UeoHLmFY/rCVFwsAshQNIff37GWOwSPUw4j1P8B hwr1PUmCUAvOzdcVSCmpOBhHuHFiYwrwtEnoOb8baGokvQdGZ/ksIBJIq61zSoET3RHc Abvkss2EMEyMSbCNmZJbKrckbYSyZnZwwoxgvBnAHvr9gcREEGZFiS9zVOlxtQCIBOKN 3J1SISCF9952GWPd0DDuLplZQ+H3QxjGMXiAbE7dbk1MPNx9lWbL4xJ5J0q1iN+lK/UP dUoGaPvx9hayfHDVaedDlyYL0vUcGb7Dgef4C4cEqzjyeG5vnTdGGjNjy52exdTIR29e Z63w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Wo0vVnrj7LlByM+obGlDBGQf7mdPxoHFFT3j3qcwsLQ=; b=SOMf3W85etZr0W38k8637goleXeT5FQ4bMG6znyJ02AYkc+KY/3ep0WabBCXokeK7t yRq+xrEyh9nLwjGmGhz4p6jgwFDvZI+Hoid7RvyNI8nZ7zuEvBkc6EwBhugpPOO+ByaK rn/ZtM+zilrgHeFssUdjCQMQKTT51SmpVSiXt3QN0VUoSs9bNlLJ0v8QdFsFBNI2vMmE tE4J6xpu5tZON5V3GenTWjn1cp81vw2+hRdcxkv45VIQGdkDLDMCcK5wVID6E+pqWbff idlDwzdKB549knsH5YjFo3sqeHEhzycsxBOy5Ye62IzH/oiQ+t14vgksZmJkAk51SRdl /qyg== X-Gm-Message-State: APjAAAUh1s/i1YZgePBZN19oGhs4fYPzBxZhZmgQ+i+72z/zguMDHMBP BODjxhxHzzEq/yEzPU+vzGRWJqhdEu8= X-Received: by 2002:a05:600c:22c8:: with SMTP id 8mr6243279wmg.178.1582732464696; Wed, 26 Feb 2020 07:54:24 -0800 (PST) Received: from localhost (ip-89-177-130-96.net.upcbroadband.cz. [89.177.130.96]) by smtp.gmail.com with ESMTPSA id j12sm3792291wrt.35.2020.02.26.07.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2020 07:54:24 -0800 (PST) Date: Wed, 26 Feb 2020 16:54:23 +0100 From: Jiri Pirko To: Vadym Kochan Cc: "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "David S . Miller" , Oleksandr Mazur , Taras Chornyi , Serhiy Boiko , Andrii Savka , Volodymyr Mytnyk , Serhiy Pshyk Subject: Re: [RFC net-next 1/3] net: marvell: prestera: Add Switchdev driver for Prestera family ASIC device 98DX325x (AC3x) Message-ID: <20200226155423.GC26061@nanopsycho> References: <20200225163025.9430-1-vadym.kochan@plvision.eu> <20200225163025.9430-2-vadym.kochan@plvision.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200225163025.9430-2-vadym.kochan@plvision.eu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tue, Feb 25, 2020 at 05:30:54PM CET, vadym.kochan@plvision.eu wrote: >Marvell Prestera 98DX326x integrates up to 24 ports of 1GbE with 8 >ports of 10GbE uplinks or 2 ports of 40Gbps stacking for a largely >wireless SMB deployment. > >This driver implementation includes only L1 & basic L2 support. > >The core Prestera switching logic is implemented in prestera.c, there is >an intermediate hw layer between core logic and firmware. It is >implemented in prestera_hw.c, the purpose of it is to encapsulate hw >related logic, in future there is a plan to support more devices with >different HW related configurations. > >The following Switchdev features are supported: > > - VLAN-aware bridge offloading > - VLAN-unaware bridge offloading > - FDB offloading (learning, ageing) > - Switchport configuration > >Signed-off-by: Vadym Kochan >Signed-off-by: Andrii Savka >Signed-off-by: Oleksandr Mazur >Signed-off-by: Serhiy Boiko >Signed-off-by: Serhiy Pshyk >Signed-off-by: Taras Chornyi >Signed-off-by: Volodymyr Mytnyk >--- > drivers/net/ethernet/marvell/Kconfig | 1 + > drivers/net/ethernet/marvell/Makefile | 1 + > drivers/net/ethernet/marvell/prestera/Kconfig | 13 + > .../net/ethernet/marvell/prestera/Makefile | 3 + > .../net/ethernet/marvell/prestera/prestera.c | 1502 +++++++++++++++++ > .../net/ethernet/marvell/prestera/prestera.h | 244 +++ > .../marvell/prestera/prestera_drv_ver.h | 23 + > .../ethernet/marvell/prestera/prestera_hw.c | 1094 ++++++++++++ > .../ethernet/marvell/prestera/prestera_hw.h | 159 ++ > .../marvell/prestera/prestera_switchdev.c | 1217 +++++++++++++ > 10 files changed, 4257 insertions(+) > create mode 100644 drivers/net/ethernet/marvell/prestera/Kconfig > create mode 100644 drivers/net/ethernet/marvell/prestera/Makefile > create mode 100644 drivers/net/ethernet/marvell/prestera/prestera.c > create mode 100644 drivers/net/ethernet/marvell/prestera/prestera.h > create mode 100644 drivers/net/ethernet/marvell/prestera/prestera_drv_ver.h > create mode 100644 drivers/net/ethernet/marvell/prestera/prestera_hw.c > create mode 100644 drivers/net/ethernet/marvell/prestera/prestera_hw.h > create mode 100644 drivers/net/ethernet/marvell/prestera/prestera_switchdev.c > >diff --git a/drivers/net/ethernet/marvell/Kconfig b/drivers/net/ethernet/marvell/Kconfig >index 3d5caea096fb..74313d9e1fc0 100644 >--- a/drivers/net/ethernet/marvell/Kconfig >+++ b/drivers/net/ethernet/marvell/Kconfig >@@ -171,5 +171,6 @@ config SKY2_DEBUG > > > source "drivers/net/ethernet/marvell/octeontx2/Kconfig" >+source "drivers/net/ethernet/marvell/prestera/Kconfig" > > endif # NET_VENDOR_MARVELL >diff --git a/drivers/net/ethernet/marvell/Makefile b/drivers/net/ethernet/marvell/Makefile >index 89dea7284d5b..9f88fe822555 100644 >--- a/drivers/net/ethernet/marvell/Makefile >+++ b/drivers/net/ethernet/marvell/Makefile >@@ -12,3 +12,4 @@ obj-$(CONFIG_PXA168_ETH) += pxa168_eth.o > obj-$(CONFIG_SKGE) += skge.o > obj-$(CONFIG_SKY2) += sky2.o > obj-y += octeontx2/ >+obj-y += prestera/ >diff --git a/drivers/net/ethernet/marvell/prestera/Kconfig b/drivers/net/ethernet/marvell/prestera/Kconfig >new file mode 100644 >index 000000000000..d0b416dcb677 >--- /dev/null >+++ b/drivers/net/ethernet/marvell/prestera/Kconfig >@@ -0,0 +1,13 @@ >+# SPDX-License-Identifier: GPL-2.0-only >+# >+# Marvell Prestera drivers configuration >+# >+ >+config PRESTERA >+ tristate "Marvell Prestera Switch ASICs support" >+ depends on NET_SWITCHDEV && VLAN_8021Q >+ ---help--- >+ This driver supports Marvell Prestera Switch ASICs family. >+ >+ To compile this driver as a module, choose M here: the >+ module will be called prestera_sw. >diff --git a/drivers/net/ethernet/marvell/prestera/Makefile b/drivers/net/ethernet/marvell/prestera/Makefile >new file mode 100644 >index 000000000000..9446298fb7f4 >--- /dev/null >+++ b/drivers/net/ethernet/marvell/prestera/Makefile >@@ -0,0 +1,3 @@ >+# SPDX-License-Identifier: GPL-2.0 >+obj-$(CONFIG_PRESTERA) += prestera_sw.o >+prestera_sw-objs := prestera.o prestera_hw.o prestera_switchdev.o >diff --git a/drivers/net/ethernet/marvell/prestera/prestera.c b/drivers/net/ethernet/marvell/prestera/prestera.c >new file mode 100644 >index 000000000000..12d0eb590bbb >--- /dev/null >+++ b/drivers/net/ethernet/marvell/prestera/prestera.c >@@ -0,0 +1,1502 @@ >+/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 >+ * >+ * Copyright (c) 2019-2020 Marvell International Ltd. All rights reserved. >+ * >+ */ >+#include >+#include >+#include >+#include >+#include >+#include >+#include >+#include >+#include >+ >+#include "prestera.h" >+#include "prestera_hw.h" >+#include "prestera_drv_ver.h" >+ >+#define MVSW_PR_MTU_DEFAULT 1536 >+ >+#define PORT_STATS_CACHE_TIMEOUT_MS (msecs_to_jiffies(1000)) >+#define PORT_STATS_CNT (sizeof(struct mvsw_pr_port_stats) / sizeof(u64)) Keep the prefix for all defines withing the file. "PORT_STATS_CNT" looks way to generic on the first look. >+#define PORT_STATS_IDX(name) \ >+ (offsetof(struct mvsw_pr_port_stats, name) / sizeof(u64)) >+#define PORT_STATS_FIELD(name) \ >+ [PORT_STATS_IDX(name)] = __stringify(name) >+ >+static struct list_head switches_registered; >+ >+static const char mvsw_driver_kind[] = "prestera_sw"; Please be consistent. Make your prefixes, name, filenames the same. For example: prestera_driver_kind[] = "prestera"; Applied to the whole code. >+static const char mvsw_driver_name[] = "mvsw_switchdev"; Why is this different from kind? Also, don't mention "switchdev" anywhere. >+static const char mvsw_driver_version[] = PRESTERA_DRV_VER; [...] >+static void mvsw_pr_port_remote_cap_get(struct ethtool_link_ksettings *ecmd, >+ struct mvsw_pr_port *port) >+{ >+ u64 bitmap; >+ >+ if (!mvsw_pr_hw_port_remote_cap_get(port, &bitmap)) { >+ mvsw_modes_to_eth(ecmd->link_modes.lp_advertising, >+ bitmap, 0, MVSW_PORT_TYPE_NONE); >+ } Don't use {} for single statement. checkpatch.pl should warn you about this. >+} >+ >+static void mvsw_pr_port_duplex_get(struct ethtool_link_ksettings *ecmd, >+ struct mvsw_pr_port *port) >+{ >+ u8 duplex; >+ >+ if (!mvsw_pr_hw_port_duplex_get(port, &duplex)) { >+ ecmd->base.duplex = duplex == MVSW_PORT_DUPLEX_FULL ? >+ DUPLEX_FULL : DUPLEX_HALF; >+ } else { >+ ecmd->base.duplex = DUPLEX_UNKNOWN; >+ } Same here. >+} [...] >+static void __exit mvsw_pr_module_exit(void) >+{ >+ destroy_workqueue(mvsw_pr_wq); >+ >+ pr_info("Unloading Marvell Prestera Switch Driver\n"); No prints like this please. >+} >+ >+module_init(mvsw_pr_module_init); >+module_exit(mvsw_pr_module_exit); >+ >+MODULE_AUTHOR("Marvell Semi."); Does not look so :) >+MODULE_LICENSE("GPL"); >+MODULE_DESCRIPTION("Marvell Prestera switch driver"); >+MODULE_VERSION(PRESTERA_DRV_VER); [...]