From nobody Tue Apr 28 05:05:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86531C433EF for ; Mon, 6 Jun 2022 13:46:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239190AbiFFNqW (ORCPT ); Mon, 6 Jun 2022 09:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239048AbiFFNqP (ORCPT ); Mon, 6 Jun 2022 09:46:15 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A76B1B1865 for ; Mon, 6 Jun 2022 06:46:14 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id n10so29082088ejk.5 for ; Mon, 06 Jun 2022 06:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hM/8L0QQElJsG/ZP5E7Xm7971VYDngZ9OkzPm4OYvuE=; b=OJs8LpvrKqi5Cd/dGV4X9s3P+/ySjRV6bVK4kcv4eoRQDVu8BWaMoFAMh81BUHldVs L3JfVc21sD/XqfokWo0cpvMxm3hbVeaFI0Jt693xfKSsG6dbpulwLsu2EYZQ/KJGHyBu Qh4dcbTDjxCnrY9P+TvPwLihtKe6DfBR+dL9o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hM/8L0QQElJsG/ZP5E7Xm7971VYDngZ9OkzPm4OYvuE=; b=pK/LRedbLg66mq9hNwz9dd3LxgpFRGIhX2QstBQwOpBTdiZtUrJXEJFZF24sGc+eJ7 RMaU/9x4QHdfqns+iF8RLaqPVlcpuzdZmcVt+/wMEe2yg7HK2HImi36BrIiP2VRo7sqf 7+q8W533UMhVBSW5WnzVBdY8oZjpvFbYea4Uutr0ACh9AEaPRg1igjLDlquJ0IbIQtJ2 NVSbdWhRUTiu1DdIcXNOypZ7obvh5ExD516EkGAxZjGDoayvj+7ZTmlNl4bxXSTQo9oO TAOeDRDa4DAJcIfsdBVXajRe8qSLzm5PKbi6Q2K862NWv5E8Qve2bYJ7SWzytCoCuH0Q lU4A== X-Gm-Message-State: AOAM530O8nI8kbg78MqvuhQ9A4TMajLjUmHwLFXBcFDaLGyt2cwR8CeH 8CmAsB95yckkOjsCcJjXsca9Kw== X-Google-Smtp-Source: ABdhPJwDtrN5NZdSXdvq60ci2ZzH2UR8lC1o4NQ/iJefcuNGMyK/r2DHNkCOrIizzW/WLbjiNyv2CA== X-Received: by 2002:a17:907:7da5:b0:711:c9cd:61e0 with SMTP id oz37-20020a1709077da500b00711c9cd61e0mr6287983ejc.443.1654523172865; Mon, 06 Jun 2022 06:46:12 -0700 (PDT) Received: from localhost.localdomain (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id a26-20020a1709062b1a00b006f3ef214db4sm5496538ejg.26.2022.06.06.06.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 06:46:12 -0700 (PDT) From: =?UTF-8?q?Alvin=20=C5=A0ipraga?= To: luizluca@gmail.com, Linus Walleij , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/5] net: dsa: realtek: rtl8365mb: rename macro RTL8367RB -> RTL8367RB_VB Date: Mon, 6 Jun 2022 15:45:49 +0200 Message-Id: <20220606134553.2919693-2-alvin@pqrs.dk> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220606134553.2919693-1-alvin@pqrs.dk> References: <20220606134553.2919693-1-alvin@pqrs.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alvin =C5=A0ipraga The official name of this switch is RTL8367RB-VB, not RTL8367RB. There is also an RTL8367RB-VC which is rather different. Change the name of the CHIP_ID/_VER macros for reasons of consistency. Signed-off-by: Alvin =C5=A0ipraga Reviewed-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/rtl8365mb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/= rtl8365mb.c index 3bb42a9f236d..0cc90e96aab7 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -108,8 +108,8 @@ #define RTL8365MB_CHIP_ID_8367S 0x6367 #define RTL8365MB_CHIP_VER_8367S 0x00A0 =20 -#define RTL8365MB_CHIP_ID_8367RB 0x6367 -#define RTL8365MB_CHIP_VER_8367RB 0x0020 +#define RTL8365MB_CHIP_ID_8367RB_VB 0x6367 +#define RTL8365MB_CHIP_VER_8367RB_VB 0x0020 =20 /* Family-specific data and limits */ #define RTL8365MB_PHYADDRMAX 7 @@ -2008,7 +2008,7 @@ static int rtl8365mb_detect(struct realtek_priv *priv) "found an RTL8365MB-VC switch (ver=3D0x%04x)\n", chip_ver); break; - case RTL8365MB_CHIP_VER_8367RB: + case RTL8365MB_CHIP_VER_8367RB_VB: dev_info(priv->dev, "found an RTL8367RB-VB switch (ver=3D0x%04x)\n", chip_ver); --=20 2.36.0 From nobody Tue Apr 28 05:05:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CCDCC433EF for ; Mon, 6 Jun 2022 13:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239203AbiFFNq1 (ORCPT ); Mon, 6 Jun 2022 09:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239054AbiFFNqP (ORCPT ); Mon, 6 Jun 2022 09:46:15 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DAA32462F7 for ; Mon, 6 Jun 2022 06:46:15 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id q1so29073256ejz.9 for ; Mon, 06 Jun 2022 06:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VYeSg1ZVJyO1wF6nKJrR5sFbD4VG+uA01p3eRJoARxI=; b=BlqD4OrH8ijJBv3g48jIRjkB144fnXNgPgxahFkUUCU2nkV1FJ0YTeVOOj6rlB/vJf 0muLJg/FvIipcuViQyVfJPAuh3IjsNCWXVCZnMFqFGgoV6hzjiRXYjmcOTCNR2FKFF9J 5FGB682nb6m9sUhEAK/HpPpQJmeLhkUYUJU48= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VYeSg1ZVJyO1wF6nKJrR5sFbD4VG+uA01p3eRJoARxI=; b=0tfeI5O96j/EwXjfAOL/mt8h61Uc/72S0JzuelMGSvwMqhdFL22LoPrCquEJnL7Wz2 sOdGAAAusyvPbAmVAfNaOOcAVJ1NZlsoNPC+VqCqt/nlyQDnWILg62p2JVxst13Qdvy2 wTRHLH3xdVWenyES1pn74zob7VHWely3asQ7T23GX+9dTsHLSSHvYu0jqCWeXu1o2MSv EZhXVoEuQT6BomAGEcVwQ5yFHrU3SBwqaWh6KS1OBQAmlBpbmgR0k79RHx4qggE1jxB/ PKthZoOIY08SQa8WNFDcSuyWzjgay8OsMwx//RTFtX2XREt7l9Di60F2WgpLLEsLxaop QGAg== X-Gm-Message-State: AOAM530N23JDXz13h1UQd5erGD0QbSn3lL+TaxlkEuK9rlh+Th0Uu0yW YujclvoE1+GD44n465J81LJbQw== X-Google-Smtp-Source: ABdhPJyfCep4n7xquLlwy7AVxmn0xa/oWVEI+ZOZvyZi6iA+YjNd0eF+CH6vK89MeOD2mZ5kkia2AA== X-Received: by 2002:a17:907:1c8d:b0:6f2:eb2:1cd6 with SMTP id nb13-20020a1709071c8d00b006f20eb21cd6mr20960665ejc.568.1654523174637; Mon, 06 Jun 2022 06:46:14 -0700 (PDT) Received: from localhost.localdomain (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id a26-20020a1709062b1a00b006f3ef214db4sm5496538ejg.26.2022.06.06.06.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 06:46:14 -0700 (PDT) From: =?UTF-8?q?Alvin=20=C5=A0ipraga?= To: luizluca@gmail.com, Linus Walleij , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/5] net: dsa: realtek: rtl8365mb: remove port_mask private data member Date: Mon, 6 Jun 2022 15:45:50 +0200 Message-Id: <20220606134553.2919693-3-alvin@pqrs.dk> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220606134553.2919693-1-alvin@pqrs.dk> References: <20220606134553.2919693-1-alvin@pqrs.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alvin =C5=A0ipraga There is no real need for this variable: the line change interrupt mask is sufficiently masked out when getting linkup_ind and linkdown_ind in the interrupt handler. Signed-off-by: Alvin =C5=A0ipraga --- drivers/net/dsa/realtek/rtl8365mb.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/= rtl8365mb.c index 0cc90e96aab7..c64219271a2b 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -564,7 +564,6 @@ struct rtl8365mb_port { * @irq: registered IRQ or zero * @chip_id: chip identifier * @chip_ver: chip silicon revision - * @port_mask: mask of all ports * @learn_limit_max: maximum number of L2 addresses the chip can learn * @cpu: CPU tagging and CPU port configuration for this chip * @mib_lock: prevent concurrent reads of MIB counters @@ -579,7 +578,6 @@ struct rtl8365mb { int irq; u32 chip_id; u32 chip_ver; - u32 port_mask; u32 learn_limit_max; struct rtl8365mb_cpu cpu; struct mutex mib_lock; @@ -1540,7 +1538,7 @@ static irqreturn_t rtl8365mb_irq(int irq, void *data) =20 linkdown_ind =3D FIELD_GET(RTL8365MB_PORT_LINKDOWN_IND_MASK, val); =20 - line_changes =3D (linkup_ind | linkdown_ind) & mb->port_mask; + line_changes =3D linkup_ind | linkdown_ind; } =20 if (!line_changes) @@ -2029,7 +2027,6 @@ static int rtl8365mb_detect(struct realtek_priv *priv) mb->priv =3D priv; mb->chip_id =3D chip_id; mb->chip_ver =3D chip_ver; - mb->port_mask =3D GENMASK(priv->num_ports - 1, 0); mb->learn_limit_max =3D RTL8365MB_LEARN_LIMIT_MAX; mb->jam_table =3D rtl8365mb_init_jam_8365mb_vc; mb->jam_size =3D ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc); --=20 2.36.0 From nobody Tue Apr 28 05:05:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3FC4C43334 for ; Mon, 6 Jun 2022 13:46:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239212AbiFFNqd (ORCPT ); Mon, 6 Jun 2022 09:46:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239180AbiFFNqS (ORCPT ); Mon, 6 Jun 2022 09:46:18 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD61728D69A for ; Mon, 6 Jun 2022 06:46:17 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id c2so18896075edf.5 for ; Mon, 06 Jun 2022 06:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BnPeSuEupDbmGQ7GCHy4it+pAl5TcIPr5v39wk3VDWY=; b=STlEAzxRwWbhrR37+QIghU6zligTbGACIocWguIbaXysVb7dqmW3Z161foAucHd9Fq WNIf8NieYkCmdcGQTS1p1cXcFVxm1KlqCanD4uHpbsnV0AbX8PW+G0J8vmPYJSKHPA6m z+Ou3/2aC6js2qQUDtJnp31U0ToUuhybLK5Qg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BnPeSuEupDbmGQ7GCHy4it+pAl5TcIPr5v39wk3VDWY=; b=vBKNtzh/ZnEIM+CPEqcbtq4ZLYRduSREVa19P73fyBqPrADcl6yLKXv6ifZ+5IWt30 bOzdy+HE17IDzSm2230p0Cgx7a0lHhOZq9QKESxQwqAWLnssf//RB05DQUxgKNkUnmuS 6ZcBvBNWEIi6h/zrhBP22rwAGL9ReD3/2059Ws4O13dxl7R+3WchkjBGPs7A5cp+gbVc 72mForkd4Dsz/hjeYCetssqXNwPsMtizFCi1OZfoK6CIVoJJsMgLPnr03eb7uc6gyRNY NaVnTQPxeVsDTf+uIy+aqlejy0Cl/5f9ixq8J5qYs/qwc6CrNJDae4f6HLKQh4A93hIN /4LQ== X-Gm-Message-State: AOAM532735TqYUaLRVMHa3fxyoHC86iTA7OaqzPt0Hwcy0QGdIYEQSbd Pa2sQmfO3j5TC2TmeRSumHyoTw== X-Google-Smtp-Source: ABdhPJzUbpoI88p20ePtUpE/Efbx+rxctOBRmEkVhIGUkdBZ5Jl3JJOTojP18Va0VLSDZe/khPlZFw== X-Received: by 2002:a05:6402:1941:b0:413:2822:9c8 with SMTP id f1-20020a056402194100b00413282209c8mr27443321edz.13.1654523176298; Mon, 06 Jun 2022 06:46:16 -0700 (PDT) Received: from localhost.localdomain (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id a26-20020a1709062b1a00b006f3ef214db4sm5496538ejg.26.2022.06.06.06.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 06:46:15 -0700 (PDT) From: =?UTF-8?q?Alvin=20=C5=A0ipraga?= To: luizluca@gmail.com, Linus Walleij , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/5] net: dsa: realtek: rtl8365mb: correct the max number of ports Date: Mon, 6 Jun 2022 15:45:51 +0200 Message-Id: <20220606134553.2919693-4-alvin@pqrs.dk> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220606134553.2919693-1-alvin@pqrs.dk> References: <20220606134553.2919693-1-alvin@pqrs.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alvin =C5=A0ipraga The maximum number of ports is actually 11, according to two observations: 1. The highest port ID used in the vendor driver is 10. Since port IDs are indexed from 0, and since DSA follows the same numbering system, this means up to 11 ports are to be presumed. 2. The registers with port mask fields always amount to a maximum port mask of 0x7FF, corresponding to a maximum 11 ports. In view of this, I also deleted the comment. Signed-off-by: Alvin =C5=A0ipraga Reviewed-by: Luiz Angelo Daros de Luca --- drivers/net/dsa/realtek/rtl8365mb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/= rtl8365mb.c index c64219271a2b..392047558656 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -115,8 +115,7 @@ #define RTL8365MB_PHYADDRMAX 7 #define RTL8365MB_NUM_PHYREGS 32 #define RTL8365MB_PHYREGMAX (RTL8365MB_NUM_PHYREGS - 1) -/* RTL8370MB and RTL8310SR, possibly suportable by this driver, have 10 po= rts */ -#define RTL8365MB_MAX_NUM_PORTS 10 +#define RTL8365MB_MAX_NUM_PORTS 11 #define RTL8365MB_LEARN_LIMIT_MAX 2112 =20 /* valid for all 6-port or less variants */ --=20 2.36.0 From nobody Tue Apr 28 05:05:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBD82CCA481 for ; Mon, 6 Jun 2022 13:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239184AbiFFNqt (ORCPT ); Mon, 6 Jun 2022 09:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239061AbiFFNqT (ORCPT ); Mon, 6 Jun 2022 09:46:19 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD9D61B9A7C for ; Mon, 6 Jun 2022 06:46:18 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id s12so21853421ejx.3 for ; Mon, 06 Jun 2022 06:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uHwQH74Q7N25Q2zdI6IdVXzOKcdi3juWfll5ugT6Tp8=; b=HYqm1kQIFYFjJDQgAJt9wjqHr/Y/X21kXW7swzLHk/yT4N57VjWHoyBsEzw0XckAYq qCqyJ3ooMy+n3Xw+Ldk31A1qJZmqEOBs7J7IKp2mOCuSjGchK+xPq//cpeKvmAhkmrH5 m0dVaugF7kY3M/AI+WOLm5+8OL8xEeDqaWV8s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uHwQH74Q7N25Q2zdI6IdVXzOKcdi3juWfll5ugT6Tp8=; b=uc2pPWvR1aQwwUH491+bFkREG9+roTHeRkREsMvBgsI04orU2I5/AwZPAZywJ8Jqwe Dl+ak03Tq8NjplEXr4p1M9WyIEQSx9nOqN+F3fUart+uGQ8vKUi7xweEEfUGxHpbOV/+ R3F41He6hLGQoT3Dzled0Zd50uae3btaqcI7aXNH+FV99QcjLUtBCCMCCO570WLJykub JM2mhtfRDRzQtvmg98XjL4xBkTNl9WHVfpFwrPZysIs5sggJPu5LPEXC81o0mZ7Ehns5 kY75DI/yE1sIvDV6xf5wM/0/A2jp8Qr/61z3c86IIarIdCSz4C8+kUB8ccoZxW1g8FJp QKNg== X-Gm-Message-State: AOAM532Gu6JYhJEYjI6aTjECOjoli0R6vWQhDCYpKTOMJqhRqleSEwjw h11tOvkdnNo6hNP/WmG3zsR7RQ== X-Google-Smtp-Source: ABdhPJxHAmaTQ7SoG4xOWZo1AxxrADEQ2354vOZDz2LunO92X2LOOVaWdpZupcrtKG2bjWHbFEFu3Q== X-Received: by 2002:a17:907:2d2a:b0:710:76a1:4d89 with SMTP id gs42-20020a1709072d2a00b0071076a14d89mr11993861ejc.307.1654523178289; Mon, 06 Jun 2022 06:46:18 -0700 (PDT) Received: from localhost.localdomain (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id a26-20020a1709062b1a00b006f3ef214db4sm5496538ejg.26.2022.06.06.06.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 06:46:17 -0700 (PDT) From: =?UTF-8?q?Alvin=20=C5=A0ipraga?= To: luizluca@gmail.com, Linus Walleij , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/5] net: dsa: realtek: rtl8365mb: remove learn_limit_max private data member Date: Mon, 6 Jun 2022 15:45:52 +0200 Message-Id: <20220606134553.2919693-5-alvin@pqrs.dk> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220606134553.2919693-1-alvin@pqrs.dk> References: <20220606134553.2919693-1-alvin@pqrs.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alvin =C5=A0ipraga The variable is just assigned the value of a macro, so it can be removed. Signed-off-by: Alvin =C5=A0ipraga --- drivers/net/dsa/realtek/rtl8365mb.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/= rtl8365mb.c index 392047558656..a3a4454f77bf 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -563,7 +563,6 @@ struct rtl8365mb_port { * @irq: registered IRQ or zero * @chip_id: chip identifier * @chip_ver: chip silicon revision - * @learn_limit_max: maximum number of L2 addresses the chip can learn * @cpu: CPU tagging and CPU port configuration for this chip * @mib_lock: prevent concurrent reads of MIB counters * @ports: per-port data @@ -577,7 +576,6 @@ struct rtl8365mb { int irq; u32 chip_id; u32 chip_ver; - u32 learn_limit_max; struct rtl8365mb_cpu cpu; struct mutex mib_lock; struct rtl8365mb_port ports[RTL8365MB_MAX_NUM_PORTS]; @@ -1108,15 +1106,13 @@ static void rtl8365mb_port_stp_state_set(struct dsa= _switch *ds, int port, static int rtl8365mb_port_set_learning(struct realtek_priv *priv, int port, bool enable) { - struct rtl8365mb *mb =3D priv->chip_data; - /* Enable/disable learning by limiting the number of L2 addresses the * port can learn. Realtek documentation states that a limit of zero * disables learning. When enabling learning, set it to the chip's * maximum. */ return regmap_write(priv->map, RTL8365MB_LUT_PORT_LEARN_LIMIT_REG(port), - enable ? mb->learn_limit_max : 0); + enable ? RTL8365MB_LEARN_LIMIT_MAX : 0); } =20 static int rtl8365mb_port_set_isolation(struct realtek_priv *priv, int por= t, @@ -2026,7 +2022,6 @@ static int rtl8365mb_detect(struct realtek_priv *priv) mb->priv =3D priv; mb->chip_id =3D chip_id; mb->chip_ver =3D chip_ver; - mb->learn_limit_max =3D RTL8365MB_LEARN_LIMIT_MAX; mb->jam_table =3D rtl8365mb_init_jam_8365mb_vc; mb->jam_size =3D ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc); =20 --=20 2.36.0 From nobody Tue Apr 28 05:05:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9936C43334 for ; Mon, 6 Jun 2022 13:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239199AbiFFNqx (ORCPT ); Mon, 6 Jun 2022 09:46:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239194AbiFFNqX (ORCPT ); Mon, 6 Jun 2022 09:46:23 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A6792B1961 for ; Mon, 6 Jun 2022 06:46:21 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id x62so18886719ede.10 for ; Mon, 06 Jun 2022 06:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqrs.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+prGQaCEIgFN71c5M9SNYfoEIfjYo8Cc5lTo+wFh6BE=; b=Vfp0ZeSY2GtdN0TOvYIz47jTO8DJxOLRf7OllZ8h5ahSlKDxh46Nla6zo3kD5kQnkh Xe3okGbcXTrr06LZKofSZIlzMUhTP9FHJnKz6aVEsUTAgPWjChcl863C4YGAORDCIl82 lW9sd+tCYou9d5VGtzutNHNpRScThOdAjewPE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+prGQaCEIgFN71c5M9SNYfoEIfjYo8Cc5lTo+wFh6BE=; b=XHsQqFwg0ljBTiJoLCUeeQaqBNoFORXFL4ddjdEjzPWp05xvA/40P7L3nAfCT9oG+w aXrqN38RqxO2hXece4HW6UNfPipjfq6WPEaZGa7I3Cef5K6vpvEtSo1/NY21IKF+uMTo Wu8J8DrHw3cGrH1PwnnbccEYR6gXwXH1UzqwEXpZDu/dCSl+FbibMP82czkg1tEX5R03 gwN+QkxIfSOWvN4Ixn50yuMUX1dkohZMusr6p2gXudYqqbpbmntfWwvc2PXZucwBmITk QXihAsADvaOCOdQJmeH2L4AhxpZr1QC1Nv/zY9p6iO8+FEn8lXFSHaAzc+O9o4HB8PJT mLtQ== X-Gm-Message-State: AOAM530Q4RiCk4Xiu4V82Qkv/maNNEffekyUnO44Te478Wvb0310uQ6+ 1Lvo1ePpFlfMwdZXIN72FG1RGQ== X-Google-Smtp-Source: ABdhPJzzbzaRw04WEzuuxy4f1/A3haCV+AzRlq9xgxB4rRr3TTwto7u6DvgWEnes+6k3QJOOb85Xgg== X-Received: by 2002:aa7:cc8f:0:b0:42d:f88c:9f63 with SMTP id p15-20020aa7cc8f000000b0042df88c9f63mr27535199edt.288.1654523180079; Mon, 06 Jun 2022 06:46:20 -0700 (PDT) Received: from localhost.localdomain (80.71.142.18.ipv4.parknet.dk. [80.71.142.18]) by smtp.gmail.com with ESMTPSA id a26-20020a1709062b1a00b006f3ef214db4sm5496538ejg.26.2022.06.06.06.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 06:46:19 -0700 (PDT) From: =?UTF-8?q?Alvin=20=C5=A0ipraga?= To: luizluca@gmail.com, Linus Walleij , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/5] net: dsa: realtek: rtl8365mb: handle PHY interface modes correctly Date: Mon, 6 Jun 2022 15:45:53 +0200 Message-Id: <20220606134553.2919693-6-alvin@pqrs.dk> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220606134553.2919693-1-alvin@pqrs.dk> References: <20220606134553.2919693-1-alvin@pqrs.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alvin =C5=A0ipraga Realtek switches in the rtl8365mb family always have at least one port with a so-called external interface, supporting PHY interface modes such as RGMII or SGMII. The purpose of this patch is to improve the driver's handling of these ports. A new struct rtl8365mb_chip_info is introduced. A static instance of this struct is added for each supported switch, which is distinguished by its chip ID and version. Embedded in each chip_info struct is an array of struct rtl8365mb_extint, describing the external interfaces available. This is more specific than the old rtl8365mb_extint_port_map, which was only valid for switches with up to 6 ports. The struct rtl8365mb_extint also contains a bitmask of supported PHY interface modes, which allows the driver to distinguish which ports support RGMII. This corrects a previous mistake in the driver whereby it was assumed that any port with an external interface supports RGMII. This is not actually the case: for example, the RTL8367S has two external interfaces, only the second of which supports RGMII. The first supports only SGMII and HSGMII. This new design will make it easier to add support for other interface modes. Finally, rtl8365mb_phylink_get_caps() is fixed up to return supported capabilities based on the external interface properties described above. This allows for ports with an external interface to be treated as DSA user ports, and for ports with an internal PHY to be treated as DSA CPU ports. Link: https://lore.kernel.org/netdev/20220510192301.5djdt3ghoavxulhl@bang-o= lufsen.dk/ Signed-off-by: Alvin =C5=A0ipraga --- drivers/net/dsa/realtek/rtl8365mb.c | 247 +++++++++++++++++++++------- 1 file changed, 183 insertions(+), 64 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/= rtl8365mb.c index a3a4454f77bf..2dc0459af5a4 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.c +++ b/drivers/net/dsa/realtek/rtl8365mb.c @@ -118,9 +118,6 @@ #define RTL8365MB_MAX_NUM_PORTS 11 #define RTL8365MB_LEARN_LIMIT_MAX 2112 =20 -/* valid for all 6-port or less variants */ -static const int rtl8365mb_extint_port_map[] =3D { -1, -1, -1, -1, -1, -1= , 1, 2, -1, -1}; - /* Chip identification registers */ #define RTL8365MB_CHIP_ID_REG 0x1300 =20 @@ -200,7 +197,7 @@ static const int rtl8365mb_extint_port_map[] =3D { -1,= -1, -1, -1, -1, -1, 1, 2, /* The PHY OCP addresses of PHY registers 0~31 start here */ #define RTL8365MB_PHY_OCP_ADDR_PHYREG_BASE 0xA400 =20 -/* EXT interface port mode values - used in DIGITAL_INTERFACE_SELECT */ +/* External interface port mode values - used in DIGITAL_INTERFACE_SELECT = */ #define RTL8365MB_EXT_PORT_MODE_DISABLE 0 #define RTL8365MB_EXT_PORT_MODE_RGMII 1 #define RTL8365MB_EXT_PORT_MODE_MII_MAC 2 @@ -216,19 +213,7 @@ static const int rtl8365mb_extint_port_map[] =3D { -1= , -1, -1, -1, -1, -1, 1, 2, #define RTL8365MB_EXT_PORT_MODE_1000X 12 #define RTL8365MB_EXT_PORT_MODE_100FX 13 =20 -/* Realtek docs and driver uses logic number as EXT_PORT0=3D16, EXT_PORT1= =3D17, - * EXT_PORT2=3D18, to interact with switch ports. That logic number is int= ernally - * converted to either a physical port number (0..9) or an external interf= ace id (0..2), - * depending on which function was called. The external interface id is ca= lculated as - * (ext_id=3Dlogic_port-15), while the logical to physical map depends on = the chip id/version. - * - * EXT_PORT0 mentioned in datasheets and rtl8367c driver is used in this d= river - * as extid=3D=3D1, EXT_PORT2, mentioned in Realtek rtl8367c driver for 10= -port switches, - * would have an ext_id of 3 (out of range for most extint macros) and ext= _id 0 does - * not seem to be used as well for this family. - */ - -/* EXT interface mode configuration registers 0~1 */ +/* External interface mode configuration registers 0~1 */ #define RTL8365MB_DIGITAL_INTERFACE_SELECT_REG0 0x1305 /* EXT1 */ #define RTL8365MB_DIGITAL_INTERFACE_SELECT_REG1 0x13C3 /* EXT2 */ #define RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(_extint) \ @@ -240,7 +225,7 @@ static const int rtl8365mb_extint_port_map[] =3D { -1,= -1, -1, -1, -1, -1, 1, 2, #define RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(_extint) \ (((_extint) % 2) * 4) =20 -/* EXT interface RGMII TX/RX delay configuration registers 0~2 */ +/* External interface RGMII TX/RX delay configuration registers 0~2 */ #define RTL8365MB_EXT_RGMXF_REG0 0x1306 /* EXT0 */ #define RTL8365MB_EXT_RGMXF_REG1 0x1307 /* EXT1 */ #define RTL8365MB_EXT_RGMXF_REG2 0x13C5 /* EXT2 */ @@ -257,7 +242,7 @@ static const int rtl8365mb_extint_port_map[] =3D { -1,= -1, -1, -1, -1, -1, 1, 2, #define RTL8365MB_PORT_SPEED_100M 1 #define RTL8365MB_PORT_SPEED_1000M 2 =20 -/* EXT interface force configuration registers 0~2 */ +/* External interface force configuration registers 0~2 */ #define RTL8365MB_DIGITAL_INTERFACE_FORCE_REG0 0x1310 /* EXT0 */ #define RTL8365MB_DIGITAL_INTERFACE_FORCE_REG1 0x1311 /* EXT1 */ #define RTL8365MB_DIGITAL_INTERFACE_FORCE_REG2 0x13C4 /* EXT2 */ @@ -489,6 +474,100 @@ static const struct rtl8365mb_jam_tbl_entry rtl8365mb= _init_jam_common[] =3D { { 0x1D32, 0x0002 }, }; =20 +enum rtl8365mb_phy_interface_mode { + RTL8365MB_PHY_INTERFACE_MODE_INVAL =3D 0, /* used as sentinel */ + RTL8365MB_PHY_INTERFACE_MODE_INTERNAL =3D BIT(0), + RTL8365MB_PHY_INTERFACE_MODE_MII =3D BIT(1), + RTL8365MB_PHY_INTERFACE_MODE_TMII =3D BIT(2), + RTL8365MB_PHY_INTERFACE_MODE_RMII =3D BIT(3), + RTL8365MB_PHY_INTERFACE_MODE_RGMII =3D BIT(4), + RTL8365MB_PHY_INTERFACE_MODE_SGMII =3D BIT(5), + RTL8365MB_PHY_INTERFACE_MODE_HSGMII =3D BIT(6), +}; + +/** + * struct rtl8365mb_extint - external interface info + * @port: the port with an external interface + * @id: the external interface ID, which is either 0, 1, or 2 + * @supported_interfaces: a bitmask of supported PHY interface modes + * + * Represents a mapping: port -> { id, supported_interfaces }. To be embed= ded + * in &struct rtl8365mb_chip_info for every port with an external interfac= e. + */ +struct rtl8365mb_extint { + int port; + int id; + unsigned int supported_interfaces; +}; + +/** + * struct rtl8365mb_chip_info - static chip-specific info + * @name: human-readable chip name + * @chip_id: chip identifier + * @chip_ver: chip silicon revision + * @jam_table: chip-specific initialization jam table + * @jam_size: size of the chip's jam table + * @extints: external interfaces, followed by a zero sentinel + * + * These data are specific to a given chip in the family of switches suppo= rted + * by this driver. When adding support for another chip in the family, a n= ew + * static struct of this type should be defined, and assigned in the + * rtl8365mb_detect() function based on chip ID/version. + */ +struct rtl8365mb_chip_info { + const char *name; + u32 chip_id; + u32 chip_ver; + const struct rtl8365mb_jam_tbl_entry *jam_table; + size_t jam_size; + const struct rtl8365mb_extint extints[]; +}; + +/* Chip info for each supported switch in the family */ +#define PHY_INTF(_mode) (RTL8365MB_PHY_INTERFACE_MODE_ ## _mode) + +static const struct rtl8365mb_chip_info rtl8365mb_chip_info_8365mb_vc =3D { + .name =3D "RTL8365MB-VC", + .chip_id =3D RTL8365MB_CHIP_ID_8365MB_VC, + .chip_ver =3D RTL8365MB_CHIP_VER_8365MB_VC, + .extints =3D { + { 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) | PHY_INTF(RMII) | + PHY_INTF(RGMII) }, + { /* sentinel */ } + }, + .jam_table =3D rtl8365mb_init_jam_8365mb_vc, + .jam_size =3D ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), +}; + +static const struct rtl8365mb_chip_info rtl8365mb_chip_info_8367s =3D { + .name =3D "RTL8367S", + .chip_id =3D RTL8365MB_CHIP_ID_8367S, + .chip_ver =3D RTL8365MB_CHIP_VER_8367S, + .extints =3D { + { 6, 1, PHY_INTF(SGMII) | PHY_INTF(HSGMII) }, + { 7, 2, PHY_INTF(MII) | PHY_INTF(TMII) | PHY_INTF(RMII) | + PHY_INTF(RGMII) }, + { /* sentinel */ } + }, + .jam_table =3D rtl8365mb_init_jam_8365mb_vc, + .jam_size =3D ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), +}; + +static const struct rtl8365mb_chip_info rtl8365mb_chip_info_8367rb_vb =3D { + .name =3D "RTL8367RB-VB", + .chip_id =3D RTL8365MB_CHIP_ID_8367RB_VB, + .chip_ver =3D RTL8365MB_CHIP_VER_8367RB_VB, + .extints =3D { + { 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) | PHY_INTF(RMII) | + PHY_INTF(RGMII) }, + { 7, 2, PHY_INTF(MII) | PHY_INTF(TMII) | PHY_INTF(RMII) | + PHY_INTF(RGMII) }, + { /* sentinel */ } + }, + .jam_table =3D rtl8365mb_init_jam_8365mb_vc, + .jam_size =3D ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), +}; + enum rtl8365mb_stp_state { RTL8365MB_STP_STATE_DISABLED =3D 0, RTL8365MB_STP_STATE_BLOCKING =3D 1, @@ -558,7 +637,7 @@ struct rtl8365mb_port { }; =20 /** - * struct rtl8365mb - private chip-specific driver data + * struct rtl8365mb - driver private data * @priv: pointer to parent realtek_priv data * @irq: registered IRQ or zero * @chip_id: chip identifier @@ -574,13 +653,10 @@ struct rtl8365mb_port { struct rtl8365mb { struct realtek_priv *priv; int irq; - u32 chip_id; - u32 chip_ver; + const struct rtl8365mb_chip_info *chip_info; struct rtl8365mb_cpu cpu; struct mutex mib_lock; struct rtl8365mb_port ports[RTL8365MB_MAX_NUM_PORTS]; - const struct rtl8365mb_jam_tbl_entry *jam_table; - size_t jam_size; }; =20 static int rtl8365mb_phy_poll_busy(struct realtek_priv *priv) @@ -775,6 +851,31 @@ static int rtl8365mb_dsa_phy_write(struct dsa_switch *= ds, int phy, int regnum, return rtl8365mb_phy_write(ds->priv, phy, regnum, val); } =20 +const struct rtl8365mb_extint * +rtl8365mb_get_port_extint(struct realtek_priv *priv, int port) +{ + struct rtl8365mb *mb =3D priv->chip_data; + const struct rtl8365mb_extint *extint; + const struct rtl8365mb_chip_info *ci; + + ci =3D mb->chip_info; + extint =3D &ci->extints[0]; + + /* Every external interface supports at least one mode, so at least one + * bit should be set in supported_interfaces. We use 0 as a sentinel, + * cf. @RTL8265MB_PHY_INTERFACE_MODE_INVAL =3D 0. + */ + while (extint->supported_interfaces !=3D + RTL8365MB_PHY_INTERFACE_MODE_INVAL) { + if (extint->port =3D=3D port) + return extint; + + extint++; + } + + return NULL; +} + static enum dsa_tag_protocol rtl8365mb_get_tag_protocol(struct dsa_switch *ds, int port, enum dsa_tag_protocol mp) @@ -795,18 +896,23 @@ rtl8365mb_get_tag_protocol(struct dsa_switch *ds, int= port, static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port, phy_interface_t interface) { + const struct rtl8365mb_extint *extint =3D + rtl8365mb_get_port_extint(priv, port); struct device_node *dn; struct dsa_port *dp; int tx_delay =3D 0; int rx_delay =3D 0; - int ext_int; u32 val; int ret; =20 - ext_int =3D rtl8365mb_extint_port_map[port]; + if (!extint) { + dev_err(priv->dev, "port %d has no external interface\n", port); + return -EINVAL; + } =20 - if (ext_int <=3D 0) { - dev_err(priv->dev, "Port %d is not an external interface port\n", port); + if (!(extint->supported_interfaces & + RTL8365MB_PHY_INTERFACE_MODE_RGMII)) { + dev_err(priv->dev, "port %d doesn't support RGMII\n", port); return -EINVAL; } =20 @@ -842,7 +948,7 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_pr= iv *priv, int port, tx_delay =3D val / 2; else dev_warn(priv->dev, - "EXT interface TX delay must be 0 or 2 ns\n"); + "RGMII TX delay must be 0 or 2 ns\n"); } =20 if (!of_property_read_u32(dn, "rx-internal-delay-ps", &val)) { @@ -852,11 +958,11 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_= priv *priv, int port, rx_delay =3D val; else dev_warn(priv->dev, - "EXT interface RX delay must be 0 to 2.1 ns\n"); + "RGMII RX delay must be 0 to 2.1 ns\n"); } =20 ret =3D regmap_update_bits( - priv->map, RTL8365MB_EXT_RGMXF_REG(ext_int), + priv->map, RTL8365MB_EXT_RGMXF_REG(extint->id), RTL8365MB_EXT_RGMXF_TXDELAY_MASK | RTL8365MB_EXT_RGMXF_RXDELAY_MASK, FIELD_PREP(RTL8365MB_EXT_RGMXF_TXDELAY_MASK, tx_delay) | @@ -865,11 +971,11 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_= priv *priv, int port, return ret; =20 ret =3D regmap_update_bits( - priv->map, RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(ext_int), - RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(ext_int), + priv->map, RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(extint->id), + RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(extint->id), RTL8365MB_EXT_PORT_MODE_RGMII << RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET( - ext_int)); + extint->id)); if (ret) return ret; =20 @@ -880,19 +986,18 @@ static int rtl8365mb_ext_config_forcemode(struct real= tek_priv *priv, int port, bool link, int speed, int duplex, bool tx_pause, bool rx_pause) { + const struct rtl8365mb_extint *extint =3D + rtl8365mb_get_port_extint(priv, port); u32 r_tx_pause; u32 r_rx_pause; u32 r_duplex; u32 r_speed; u32 r_link; - int ext_int; int val; int ret; =20 - ext_int =3D rtl8365mb_extint_port_map[port]; - - if (ext_int <=3D 0) { - dev_err(priv->dev, "Port %d is not an external interface port\n", port); + if (!extint) { + dev_err(priv->dev, "port %d has no external interface\n", port); return -EINVAL; } =20 @@ -942,7 +1047,7 @@ static int rtl8365mb_ext_config_forcemode(struct realt= ek_priv *priv, int port, r_duplex) | FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK, r_speed); ret =3D regmap_write(priv->map, - RTL8365MB_DIGITAL_INTERFACE_FORCE_REG(ext_int), + RTL8365MB_DIGITAL_INTERFACE_FORCE_REG(extint->id), val); if (ret) return ret; @@ -974,14 +1079,31 @@ static bool rtl8365mb_phy_mode_supported(struct dsa_= switch *ds, int port, static void rtl8365mb_phylink_get_caps(struct dsa_switch *ds, int port, struct phylink_config *config) { - if (dsa_is_user_port(ds, port)) - __set_bit(PHY_INTERFACE_MODE_INTERNAL, - config->supported_interfaces); - else if (dsa_is_cpu_port(ds, port)) - phy_interface_set_rgmii(config->supported_interfaces); + const struct rtl8365mb_extint *extint =3D + rtl8365mb_get_port_extint(ds->priv, port); =20 config->mac_capabilities =3D MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD; + + if (!extint) { + __set_bit(PHY_INTERFACE_MODE_INTERNAL, + config->supported_interfaces); + + /* GMII is the default interface mode for phylib, so + * we have to support it for ports with integrated PHY. + */ + __set_bit(PHY_INTERFACE_MODE_GMII, + config->supported_interfaces); + return; + } + + /* Populate according to the modes supported by _this driver_, + * not necessarily the modes supported by the hardware, some of + * which remain unimplemented. + */ + + if (extint->supported_interfaces & RTL8365MB_PHY_INTERFACE_MODE_RGMII) + phy_interface_set_rgmii(config->supported_interfaces); } =20 static void rtl8365mb_phylink_mac_config(struct dsa_switch *ds, int port, @@ -1805,14 +1927,17 @@ static int rtl8365mb_change_tag_protocol(struct dsa= _switch *ds, static int rtl8365mb_switch_init(struct realtek_priv *priv) { struct rtl8365mb *mb =3D priv->chip_data; + const struct rtl8365mb_chip_info *ci; int ret; int i; =20 + ci =3D mb->chip_info; + /* Do any chip-specific init jam before getting to the common stuff */ - if (mb->jam_table) { - for (i =3D 0; i < mb->jam_size; i++) { - ret =3D regmap_write(priv->map, mb->jam_table[i].reg, - mb->jam_table[i].val); + if (ci->jam_table) { + for (i =3D 0; i < ci->jam_size; i++) { + ret =3D regmap_write(priv->map, ci->jam_table[i].reg, + ci->jam_table[i].val); if (ret) return ret; } @@ -1997,33 +2122,27 @@ static int rtl8365mb_detect(struct realtek_priv *pr= iv) case RTL8365MB_CHIP_ID_8365MB_VC: switch (chip_ver) { case RTL8365MB_CHIP_VER_8365MB_VC: - dev_info(priv->dev, - "found an RTL8365MB-VC switch (ver=3D0x%04x)\n", - chip_ver); + mb->chip_info =3D &rtl8365mb_chip_info_8365mb_vc; break; case RTL8365MB_CHIP_VER_8367RB_VB: - dev_info(priv->dev, - "found an RTL8367RB-VB switch (ver=3D0x%04x)\n", - chip_ver); + mb->chip_info =3D &rtl8365mb_chip_info_8367rb_vb; break; case RTL8365MB_CHIP_VER_8367S: - dev_info(priv->dev, - "found an RTL8367S switch (ver=3D0x%04x)\n", - chip_ver); + mb->chip_info =3D &rtl8365mb_chip_info_8367s; break; default: - dev_err(priv->dev, "unrecognized switch version (ver=3D0x%04x)", - chip_ver); + dev_err(priv->dev, + "unrecognized switch (id=3D0x%04x, ver=3D0x%04x)", + chip_id, chip_ver); return -ENODEV; } =20 + dev_info(priv->dev, "found an %s switch\n", + mb->chip_info->name); + priv->num_ports =3D RTL8365MB_MAX_NUM_PORTS; =20 mb->priv =3D priv; - mb->chip_id =3D chip_id; - mb->chip_ver =3D chip_ver; - mb->jam_table =3D rtl8365mb_init_jam_8365mb_vc; - mb->jam_size =3D ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc); =20 mb->cpu.trap_port =3D RTL8365MB_MAX_NUM_PORTS; mb->cpu.insert =3D RTL8365MB_CPU_INSERT_TO_ALL; --=20 2.36.0