From patchwork Wed Apr 21 12:04:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12216039 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54F76C43460 for ; Wed, 21 Apr 2021 12:05:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14CA16144D for ; Wed, 21 Apr 2021 12:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239381AbhDUMFh (ORCPT ); Wed, 21 Apr 2021 08:05:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235020AbhDUMFf (ORCPT ); Wed, 21 Apr 2021 08:05:35 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF0BDC06174A for ; Wed, 21 Apr 2021 05:05:01 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 12so66274856lfq.13 for ; Wed, 21 Apr 2021 05:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=8N6/NNytP3vCaFcVwG1TesVxRYfAjS3ibaup22OjGQE=; b=W2DlYRSImRI24rgrHcRva2xjn7mkykUYXBJEghev3VlQiwhF9b2EclHI4WN/W2sPdZ nkCC5/yfWj+2mHFD/ZjuGlbCRW5gW4frx5ZMtHN+WDRHXHpda1Hohl8E/MOf4rXlBt9X pXbuGStQFDd2d6JVMepQiLv0zEVzs36yCf1zij9CL528KqSBNq0MqLUIOm3XMt5oMwjK mIH+zMnVO7mX9mwGJ34INQUQDQdz+fliMd0HNxHIuEf6QiFyIWDczHFp5GROf5ywgNrW V0n3ckbnxrcQFEqPUZ7TV1cDWBFo/l012EXSkCfo1irF7AZVL8afRhCPVLGVfLJb0rKr xKoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=8N6/NNytP3vCaFcVwG1TesVxRYfAjS3ibaup22OjGQE=; b=BwvHPENzCyBQTMDMNTFtcVV0VOeKiUkmnOx5+w8jeVWI+grfNgDBL5txK4IfDH6e83 GDk98CpNabbDsgflBYGFS/I0QetuD+rmsKWJZbWIv1Urcx0c4ol1d2y27Iv0L8D7Z3+k fJgMo6vtvdatD76TxJCIYUse8ccajdYPfu9nCdV6pjuhYrKc3gf6jMhYtTev/JEPFMle 5WAlQHc608/ibhkbUnYAwYXFVl4edfDcPyiKLeU7i/slvW64QstCj4NeiE+z/mdI6GrB ay7FvfEZdOY8YolFi7e/nFXTuPIP8V5cw1CIp3dy1pXbePpvizSJeMfvnhiqt4lzW6bl UmzQ== X-Gm-Message-State: AOAM532iu8BkE8mtphm1cR+OitCPoWvhU/VClgogYmU6qoEXdi1Y0ruj 5OFmWK3x9IOM7yYXHH5rmTwINKcD07M/5w== X-Google-Smtp-Source: ABdhPJwDOF3DmvM8jQwRAT4EZkAzVV3CSY1TKuu7erNYnK3j6zsKQNrChj1qOoOrCI4LPBI5H1Zrrg== X-Received: by 2002:ac2:560b:: with SMTP id v11mr15128960lfd.254.1619006700439; Wed, 21 Apr 2021 05:05:00 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id r71sm193430lff.12.2021.04.21.05.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 05:05:00 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH net-next 1/3] net: dsa: mv88e6xxx: Correct spelling of define "ADRR" -> "ADDR" Date: Wed, 21 Apr 2021 14:04:52 +0200 Message-Id: <20210421120454.1541240-2-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210421120454.1541240-1-tobias@waldekranz.com> References: <20210421120454.1541240-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Because ADRR is not a thing. Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- drivers/net/dsa/mv88e6xxx/global2.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 9ff1a10993b1..eca285aaf72f 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1440,7 +1440,7 @@ static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port) * the special "LAG device" in the PVT, using * the LAG ID as the port number. */ - dev = MV88E6XXX_G2_PVT_ADRR_DEV_TRUNK; + dev = MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK; port = dsa_lag_id(dst, dp->lag_dev); } } diff --git a/drivers/net/dsa/mv88e6xxx/global2.h b/drivers/net/dsa/mv88e6xxx/global2.h index c78769cdbb59..8f85c23ec9c7 100644 --- a/drivers/net/dsa/mv88e6xxx/global2.h +++ b/drivers/net/dsa/mv88e6xxx/global2.h @@ -109,7 +109,7 @@ #define MV88E6XXX_G2_PVT_ADDR_OP_WRITE_PVLAN 0x3000 #define MV88E6XXX_G2_PVT_ADDR_OP_READ 0x4000 #define MV88E6XXX_G2_PVT_ADDR_PTR_MASK 0x01ff -#define MV88E6XXX_G2_PVT_ADRR_DEV_TRUNK 0x1f +#define MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK 0x1f /* Offset 0x0C: Cross-chip Port VLAN Data Register */ #define MV88E6XXX_G2_PVT_DATA 0x0c From patchwork Wed Apr 21 12:04:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12216041 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1FE7C433ED for ; Wed, 21 Apr 2021 12:05:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9990E6144D for ; Wed, 21 Apr 2021 12:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239515AbhDUMFj (ORCPT ); Wed, 21 Apr 2021 08:05:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239238AbhDUMFg (ORCPT ); Wed, 21 Apr 2021 08:05:36 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 817BDC06138A for ; Wed, 21 Apr 2021 05:05:02 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id q22so4039993lfu.8 for ; Wed, 21 Apr 2021 05:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=ik62DtIT8mcYynVtSQf4YeYw+4lWsIEkMOvdGt8/XTY=; b=1UIq0mbcl1M0eMo7YuTg4Oe72z/XQcLFeFU2EAUlVMmIIwvb/A17fdRs9DnEUtkMCC 5PEvX4xTcPCZMFVd97xSlXC2lwGCdBsAAz6ztqhteRcps79P3eJp1MjmezS3G2syianS IGPdWFXD7ZuCyL/r0rItGGcIMbUX5TXhSL509Kfhjpaw1MwVzwzSc4Ihu4M9i1plmcOt 0iZRLFqMlKqcsvcgjETkwIQa1DEnGMIXHbQ0v2Cn+xaJrfWtM/CM8xbH2oRzeTcvm7im Jee07+pVKovoC09xCfaZLmuNcGtY2cIAEHIDvXmxQmDf+MGLAo36bA3DzMLUM7DJw3S/ MwFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=ik62DtIT8mcYynVtSQf4YeYw+4lWsIEkMOvdGt8/XTY=; b=SlrTvbxL4gjY2rMH6alKZqGg7YoX0hHbhSLbOKhdhrW+4LH9HrGcmR1S6vHfxZe/F3 W403Hl3G3naTPMH26EQWSjPgHUWR0lMgLKnAs5qB2VSQ/aRARdAH//9aoGzlrFGHfoK3 cL3wGypPIQ2FTcci1nq0btgJ/iexE+JQxKNxWrzPTRTrTwVEcTc6QG2Wt6Va7TaxYlKX V8CsJOn2zUEEVl8LRD94NZnxUbpbbfNLsSuhh5toUAuxfZM6/I5jI++fxz7/oY9dwhAO HOFoiOU7h3qP50jpY+5aN6afFbSG7+8QKzxXgGxSOBddGnS2XQNTbROGqmARZQwpPM3Z wYmA== X-Gm-Message-State: AOAM533U0CqF3GK71ESNRJqhWvBxUczsUBqj5+BD993V61jcqf75lIwq KvhhJhXCFRpoo7VX3JVfo9PB6A== X-Google-Smtp-Source: ABdhPJw5/GuZo3AiRldOMagzCzoItDD15X8tCxfStkKIivl4fXCbBV9LoUOY08X85EnIMIWN+5M3WA== X-Received: by 2002:ac2:5f75:: with SMTP id c21mr16655848lfc.600.1619006701070; Wed, 21 Apr 2021 05:05:01 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id r71sm193430lff.12.2021.04.21.05.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 05:05:00 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH net-next 2/3] net: dsa: mv88e6xxx: Fix off-by-one in VTU devlink region size Date: Wed, 21 Apr 2021 14:04:53 +0200 Message-Id: <20210421120454.1541240-3-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210421120454.1541240-1-tobias@waldekranz.com> References: <20210421120454.1541240-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In the unlikely event of the VTU being loaded to the brim with 4k entries, the last one was placed in the buffer, but the size reported to devlink was off-by-one. Make sure that the final entry is available to the caller. Fixes: ca4d632aef03 ("net: dsa: mv88e6xxx: Export VTU as devlink region") Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c index 21953d6d484c..ada7a38d4d31 100644 --- a/drivers/net/dsa/mv88e6xxx/devlink.c +++ b/drivers/net/dsa/mv88e6xxx/devlink.c @@ -678,7 +678,7 @@ static int mv88e6xxx_setup_devlink_regions_global(struct dsa_switch *ds, sizeof(struct mv88e6xxx_devlink_atu_entry); break; case MV88E6XXX_REGION_VTU: - size = mv88e6xxx_max_vid(chip) * + size = (mv88e6xxx_max_vid(chip) + 1) * sizeof(struct mv88e6xxx_devlink_vtu_entry); break; } From patchwork Wed Apr 21 12:04:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12216043 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50862C433B4 for ; Wed, 21 Apr 2021 12:05:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B7E861450 for ; Wed, 21 Apr 2021 12:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239508AbhDUMFl (ORCPT ); Wed, 21 Apr 2021 08:05:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239269AbhDUMFg (ORCPT ); Wed, 21 Apr 2021 08:05:36 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A34DC06138B for ; Wed, 21 Apr 2021 05:05:03 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id a25so34122289ljm.11 for ; Wed, 21 Apr 2021 05:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=ivrc+ZgIINCZVu5SYzSGx7/ZivSN1yJOovHUdxjfUKs=; b=KGjuHf70HVouJ9HWfSUBB86L/54Bu0cw27SefM4yGEeyYPoXREIPaq8hR8IYjffv8V GJBKDJzrL+xOcA0oQefXMP7/Hv6ZAavH7/ouDV3CiUZFz/aMIZk3NctIz5BPS2liQA4k qe+u99tYNUogq5IivZtCJy+M93Mn17qvqK1nprWnlRAgGp6MJtmic/3olH/Fw9fjxATX Zpc6Db2E8q35o6/UylJQPU+UDmpve9o4EPBlThgAywYkv5RCxyl/TONw3qfyoUtPwSr3 B1vowmM1/8XrH9clBQvSan0fCIWAhARNy6ZF0oarzV+eNZySQTh0zo4gtFL6Oy0QDaBl Knpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=ivrc+ZgIINCZVu5SYzSGx7/ZivSN1yJOovHUdxjfUKs=; b=U/iJhf/Ob9dLiVE69auWAKKAmndYPtjaACdMhj8y60eH5kVKCpvtN08apDuiDDOeQs xE1yKT8NePPJ3iT2MQcGcNixOzAEO8HxlrixnlyHLl1Hs3l7dOBNVwOI36yUml7Oh0Gx w+FEMW2p1ARe7qH+RojqR+NeZohUrTMLCPfhshtMo3/70zkGLnEc27saA67ww5/dpFxQ Il29Q4amlGiqvn+owPZTVMol6+0OTprDx0PoWyOHi6mCNLl7S7AhaAPHsN1muWoaezyK JCeTTkPnZWC+B8KPNLv4EODA32L+BK9WkWZpntnutOpNKEZw7zaiSXX+aGVAgIRmwsJr hFfw== X-Gm-Message-State: AOAM533Hr63nEPfpxw0vxA7O1wU67JCryDdpkvkN6sBAe6YPci4MBVqx SkLAz0lBWIlkyUcFChcqYmTnrA== X-Google-Smtp-Source: ABdhPJyyhiU91MgLoDy2jg9dMoNIuZo0EN1VGDNBercJXdQMoMiyp8Sr/LKNGUnhgTL75QLrhFcD3w== X-Received: by 2002:a2e:165d:: with SMTP id 29mr16825392ljw.359.1619006701705; Wed, 21 Apr 2021 05:05:01 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id r71sm193430lff.12.2021.04.21.05.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 05:05:01 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH net-next 3/3] net: dsa: mv88e6xxx: Export cross-chip PVT as devlink region Date: Wed, 21 Apr 2021 14:04:54 +0200 Message-Id: <20210421120454.1541240-4-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210421120454.1541240-1-tobias@waldekranz.com> References: <20210421120454.1541240-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Export the raw PVT data in a devlink region so that it can be inspected from userspace and compared to the current bridge configuration. Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/chip.h | 3 ++ drivers/net/dsa/mv88e6xxx/devlink.c | 56 +++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/global2.c | 17 +++++++++ drivers/net/dsa/mv88e6xxx/global2.h | 2 ++ 4 files changed, 78 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h index 4f116f73a74b..675b1f3e43b7 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -23,6 +23,8 @@ /* PVT limits for 4-bit port and 5-bit switch */ #define MV88E6XXX_MAX_PVT_SWITCHES 32 #define MV88E6XXX_MAX_PVT_PORTS 16 +#define MV88E6XXX_MAX_PVT_ENTRIES \ + (MV88E6XXX_MAX_PVT_SWITCHES * MV88E6XXX_MAX_PVT_PORTS) #define MV88E6XXX_MAX_GPIO 16 @@ -266,6 +268,7 @@ enum mv88e6xxx_region_id { MV88E6XXX_REGION_GLOBAL2, MV88E6XXX_REGION_ATU, MV88E6XXX_REGION_VTU, + MV88E6XXX_REGION_PVT, _MV88E6XXX_REGION_MAX, }; diff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c index ada7a38d4d31..0c0f5ea6680c 100644 --- a/drivers/net/dsa/mv88e6xxx/devlink.c +++ b/drivers/net/dsa/mv88e6xxx/devlink.c @@ -503,6 +503,44 @@ static int mv88e6xxx_region_vtu_snapshot(struct devlink *dl, return 0; } +static int mv88e6xxx_region_pvt_snapshot(struct devlink *dl, + const struct devlink_region_ops *ops, + struct netlink_ext_ack *extack, + u8 **data) +{ + struct dsa_switch *ds = dsa_devlink_to_ds(dl); + struct mv88e6xxx_chip *chip = ds->priv; + int dev, port, err; + u16 *pvt, *cur; + + pvt = kcalloc(MV88E6XXX_MAX_PVT_ENTRIES, sizeof(*pvt), GFP_KERNEL); + if (!pvt) + return -ENOMEM; + + mv88e6xxx_reg_lock(chip); + + cur = pvt; + for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; dev++) { + for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; port++) { + err = mv88e6xxx_g2_pvt_read(chip, dev, port, cur); + if (err) + break; + + cur++; + } + } + + mv88e6xxx_reg_unlock(chip); + + if (err) { + kfree(pvt); + return err; + } + + *data = (u8 *)pvt; + return 0; +} + static int mv88e6xxx_region_port_snapshot(struct devlink_port *devlink_port, const struct devlink_port_region_ops *ops, struct netlink_ext_ack *extack, @@ -567,6 +605,12 @@ static struct devlink_region_ops mv88e6xxx_region_vtu_ops = { .destructor = kfree, }; +static struct devlink_region_ops mv88e6xxx_region_pvt_ops = { + .name = "pvt", + .snapshot = mv88e6xxx_region_pvt_snapshot, + .destructor = kfree, +}; + static const struct devlink_port_region_ops mv88e6xxx_region_port_ops = { .name = "port", .snapshot = mv88e6xxx_region_port_snapshot, @@ -576,6 +620,8 @@ static const struct devlink_port_region_ops mv88e6xxx_region_port_ops = { struct mv88e6xxx_region { struct devlink_region_ops *ops; u64 size; + + bool (*cond)(struct mv88e6xxx_chip *chip); }; static struct mv88e6xxx_region mv88e6xxx_regions[] = { @@ -594,6 +640,11 @@ static struct mv88e6xxx_region mv88e6xxx_regions[] = { .ops = &mv88e6xxx_region_vtu_ops /* calculated at runtime */ }, + [MV88E6XXX_REGION_PVT] = { + .ops = &mv88e6xxx_region_pvt_ops, + .size = MV88E6XXX_MAX_PVT_ENTRIES * sizeof(u16), + .cond = mv88e6xxx_has_pvt, + }, }; static void @@ -663,6 +714,7 @@ static int mv88e6xxx_setup_devlink_regions_ports(struct dsa_switch *ds, static int mv88e6xxx_setup_devlink_regions_global(struct dsa_switch *ds, struct mv88e6xxx_chip *chip) { + bool (*cond)(struct mv88e6xxx_chip *chip); struct devlink_region_ops *ops; struct devlink_region *region; u64 size; @@ -671,6 +723,10 @@ static int mv88e6xxx_setup_devlink_regions_global(struct dsa_switch *ds, for (i = 0; i < ARRAY_SIZE(mv88e6xxx_regions); i++) { ops = mv88e6xxx_regions[i].ops; size = mv88e6xxx_regions[i].size; + cond = mv88e6xxx_regions[i].cond; + + if (cond && !cond(chip)) + continue; switch (i) { case MV88E6XXX_REGION_ATU: diff --git a/drivers/net/dsa/mv88e6xxx/global2.c b/drivers/net/dsa/mv88e6xxx/global2.c index da8bac8813e1..fa65ecd9cb85 100644 --- a/drivers/net/dsa/mv88e6xxx/global2.c +++ b/drivers/net/dsa/mv88e6xxx/global2.c @@ -239,6 +239,23 @@ static int mv88e6xxx_g2_pvt_op(struct mv88e6xxx_chip *chip, int src_dev, return mv88e6xxx_g2_pvt_op_wait(chip); } +int mv88e6xxx_g2_pvt_read(struct mv88e6xxx_chip *chip, int src_dev, + int src_port, u16 *data) +{ + int err; + + err = mv88e6xxx_g2_pvt_op_wait(chip); + if (err) + return err; + + err = mv88e6xxx_g2_pvt_op(chip, src_dev, src_port, + MV88E6XXX_G2_PVT_ADDR_OP_READ); + if (err) + return err; + + return mv88e6xxx_g2_read(chip, MV88E6XXX_G2_PVT_DATA, data); +} + int mv88e6xxx_g2_pvt_write(struct mv88e6xxx_chip *chip, int src_dev, int src_port, u16 data) { diff --git a/drivers/net/dsa/mv88e6xxx/global2.h b/drivers/net/dsa/mv88e6xxx/global2.h index 8f85c23ec9c7..f3e27573a386 100644 --- a/drivers/net/dsa/mv88e6xxx/global2.h +++ b/drivers/net/dsa/mv88e6xxx/global2.h @@ -330,6 +330,8 @@ int mv88e6xxx_g2_get_eeprom16(struct mv88e6xxx_chip *chip, int mv88e6xxx_g2_set_eeprom16(struct mv88e6xxx_chip *chip, struct ethtool_eeprom *eeprom, u8 *data); +int mv88e6xxx_g2_pvt_read(struct mv88e6xxx_chip *chip, int src_dev, + int src_port, u16 *data); int mv88e6xxx_g2_pvt_write(struct mv88e6xxx_chip *chip, int src_dev, int src_port, u16 data); int mv88e6xxx_g2_misc_4_bit_port(struct mv88e6xxx_chip *chip);