From patchwork Tue Dec 13 17:46:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Schultz X-Patchwork-Id: 32904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp270226wrn; Tue, 13 Dec 2022 09:52:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf5SLpdGI6EiaiIZHrvMesXPnlOTqGKE5tH3I8myKCXUYrjdK1XP4EqPZ6cInxHUcmiHdjEo X-Received: by 2002:a17:90a:ba01:b0:218:8263:4aac with SMTP id s1-20020a17090aba0100b0021882634aacmr22055002pjr.17.1670953930478; Tue, 13 Dec 2022 09:52:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670953930; cv=none; d=google.com; s=arc-20160816; b=mt08h3JHoQbpBBSpgTx7XtARG+Ct+lzr6770tA64MMW6gWSyp75TjEcVgJyi+cHx2x KUSxSkQ0LS9Dugi2QGofbIJxWNX5dAl5aIwvaxI59TKAppllD+nh8v9GDpRZkozva4FC EhapccahkSN1wsb0Ejr76UqHqC1uyZ6x0K62lUuOlqC+CN6mnCGBknsYHEDebGykRCnN pgLbNPnrTL6V4v0PxrYDSi3qhQPf/OUHJ7IgwYP7qfh3ywOJvl3OScpmhEX8UKY4eFK4 xNYk6JDnEjgSuDVKK+KuzmJzXiNinoB/gCsg9O17FNEjxECz71WddDey38in34NNmcej nzPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=ugNcPMPFqJbl7gg9/gO1OK/MP2MmCPVKoAMXT6jWmmQ=; b=1FALggnj9QrNWE+A2C4+EASCJ+2OxFFoA0qlVgXf8vOmEqxt10RNRYRO82P8ngL/Vm bMNaAl+GfZNZmFY9PQJgf39gL+Kc+xuDmKzkYdtiS05AmRKFvJYdooGrFiQ4CcbN10ss YFtm/JnFwvVN3ON0FmadNS3eZc/OwqKaHB6kojkfiR0lLXZlFiC5nJ5tH6gAXCJRH2Qz e4UPLYy0ij2sjlpilbVJRrD/tMiuYzEQs3y8qyOt+dodonoVozQiybGDDz1lzmX82Y9/ UlLsunyMclDIQjm+aFGWGUIz6R6W3gMYdMdTeDZhBzm+AJAI93b0AIdV/AR6GWGM9HRN J5hQ== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a17090ae50b00b00219b9479155si12213761pjy.187.2022.12.13.09.51.56; Tue, 13 Dec 2022 09:52:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235645AbiLMRsX (ORCPT + 99 others); Tue, 13 Dec 2022 12:48:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235907AbiLMRsL (ORCPT ); Tue, 13 Dec 2022 12:48:11 -0500 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1007C3898; Tue, 13 Dec 2022 09:48:08 -0800 (PST) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id A28FF18839AD; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id 8C7B02500015; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 1000) id 84C3C9EC0027; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) X-Screener-Id: 413d8c6ce5bf6eab4824d0abaab02863e8e3f662 Received: from fujitsu.vestervang (2-104-116-184-cable.dk.customer.tdc.net [2.104.116.184]) by smtp.gigahost.dk (Postfix) with ESMTPSA id 3A73491201E4; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) From: "Hans J. Schultz" To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, "Hans J. Schultz" , Andrew Lunn , Florian Fainelli , Vladimir Oltean , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 net-next 1/3] net: dsa: mv88e6xxx: change default return of mv88e6xxx_port_bridge_flags Date: Tue, 13 Dec 2022 18:46:48 +0100 Message-Id: <20221213174650.670767-2-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213174650.670767-1-netdev@kapio-technology.com> References: <20221213174650.670767-1-netdev@kapio-technology.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752122188834832414?= X-GMAIL-MSGID: =?utf-8?q?1752122188834832414?= The default return value -EOPNOTSUPP of mv88e6xxx_port_bridge_flags() came from the return value of the DSA method port_egress_floods() in commit 4f85901f0063 ("net: dsa: mv88e6xxx: add support for bridge flags"), but the DSA API was changed in commit a8b659e7ff75 ("net: dsa: act as passthrough for bridge port flags"), resulting in the return value -EOPNOTSUPP not being valid anymore, and sections for new flags will not need to set the return value to zero on success, as with the new mab flag added in a following patch. Signed-off-by: Hans J. Schultz Reviewed-by: Alexander Duyck --- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index ba4fff8690aa..d5930b287db4 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -6546,7 +6546,7 @@ static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack) { struct mv88e6xxx_chip *chip = ds->priv; - int err = -EOPNOTSUPP; + int err = 0; mv88e6xxx_reg_lock(chip); From patchwork Tue Dec 13 17:46:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Schultz X-Patchwork-Id: 32903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp269585wrn; Tue, 13 Dec 2022 09:50:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf7q3pw2xHOOrMRVpDz0GCnZ/VOpCoSKymvEtXB+6ROawBHGcRNStyhrIt0REZvdFepNN63y X-Received: by 2002:a17:90a:514f:b0:219:c8f8:dbee with SMTP id k15-20020a17090a514f00b00219c8f8dbeemr21886765pjm.29.1670953859342; Tue, 13 Dec 2022 09:50:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670953859; cv=none; d=google.com; s=arc-20160816; b=yvMZPiEYDBOQfveJ1+f22ui7/1LmIb/mmjEomYi+eateZCGHtlsw4RcShW27YXw6JV vpmZEhJ0ZLjzg018sbF6prlQo8VBEJcA4PtnwYKeBU1oXGsOepnpbE603FawRO368gv/ NPpXuKmAuZ/jzsmXLZkEy+6XME3uwWVRGjuCJ+YuIGHUvjPzQRYcQq9QFlffSlYTmR5+ Lws1VDsaNltaMxHVciF/BOeQyct3zMD6+IJV0bxEmxKBC+VcBbpQH0lSzxhp5AwiOjDS gcCMlN5eIFLDxwpGRFt2Njq7IRfU5ELH4qS2XC7a8xTO4VqX5ko9Osiogr/2OBRtOsDb H1cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=h51pJH6cHzodeoqh2MviDY7bEHKSym5zwv8IArnirvs=; b=RfkEDVA27NF3OJricJCO3eum3+iTVzq/mQIKoLnlDX23Ug4YKqfyTAHn7QwjCf75S3 3eI69Zsw+CG+v4yStLST0E9/aSpL1zQ0pjJaMCxUYohORH8TXNFgGp4xlALNtkDNcqG/ Y/0G98Lgad8yKfrc9DRjZKuZFhatC8GRJoyh6JWsY4Ja3vy4U+nMDz+h0P9GAVrim9wt tJTOVZ5Fjk+5s+ib8v0JAJ/ek8ERdywH/ydHo/n64kp1DSmNZbuAG6KErT3Mf2SPbP6E 6qOdUHJuZa8elm9Hp6c8ZDxtF6qS9/W6SJkI6wAIZ1nTqrBF2o8nRk9c7ZKgPe39FyLn pW4Q== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ls4-20020a17090b350400b0020d2286c30csi13689248pjb.134.2022.12.13.09.50.45; Tue, 13 Dec 2022 09:50:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236378AbiLMRsP (ORCPT + 99 others); Tue, 13 Dec 2022 12:48:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236366AbiLMRsL (ORCPT ); Tue, 13 Dec 2022 12:48:11 -0500 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1705F11A0F; Tue, 13 Dec 2022 09:48:08 -0800 (PST) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id E6C3F18839C0; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id D6BA72500015; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 1000) id CAB329EC0027; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) X-Screener-Id: 413d8c6ce5bf6eab4824d0abaab02863e8e3f662 Received: from fujitsu.vestervang (2-104-116-184-cable.dk.customer.tdc.net [2.104.116.184]) by smtp.gigahost.dk (Postfix) with ESMTPSA id 7E8F891201E3; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) From: "Hans J. Schultz" To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, "Hans J. Schultz" , Andrew Lunn , Florian Fainelli , Vladimir Oltean , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 net-next 2/3] net: dsa: mv88e6xxx: disable hold of chip lock for handling Date: Tue, 13 Dec 2022 18:46:49 +0100 Message-Id: <20221213174650.670767-3-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213174650.670767-1-netdev@kapio-technology.com> References: <20221213174650.670767-1-netdev@kapio-technology.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752122114129026753?= X-GMAIL-MSGID: =?utf-8?q?1752122114129026753?= As functions called under the interrupt handler will need to take the netlink lock, we need to release the chip lock before calling those functions as otherwise double lock deadlocks will occur as userspace calls towards the driver often take the netlink lock and then the chip lock. The deadlock would look like: Interrupt handler: chip lock taken, but cannot take netlink lock as userspace config call has netlink lock. Userspace config: netlink lock taken, but cannot take chip lock as the interrupt handler has the chip lock. Signed-off-by: Hans J. Schultz Reviewed-by: Alexander Duyck --- drivers/net/dsa/mv88e6xxx/global1_atu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/global1_atu.c b/drivers/net/dsa/mv88e6xxx/global1_atu.c index 61ae2d61e25c..34203e112eef 100644 --- a/drivers/net/dsa/mv88e6xxx/global1_atu.c +++ b/drivers/net/dsa/mv88e6xxx/global1_atu.c @@ -409,11 +409,11 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id) err = mv88e6xxx_g1_read_atu_violation(chip); if (err) - goto out; + goto out_unlock; err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_OP, &val); if (err) - goto out; + goto out_unlock; err = mv88e6xxx_g1_atu_fid_read(chip, &fid); if (err) @@ -421,11 +421,13 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id) err = mv88e6xxx_g1_atu_data_read(chip, &entry); if (err) - goto out; + goto out_unlock; err = mv88e6xxx_g1_atu_mac_read(chip, &entry); if (err) - goto out; + goto out_unlock; + + mv88e6xxx_reg_unlock(chip); spid = entry.state; @@ -449,13 +451,13 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id) fid); chip->ports[spid].atu_full_violation++; } - mv88e6xxx_reg_unlock(chip); return IRQ_HANDLED; -out: +out_unlock: mv88e6xxx_reg_unlock(chip); +out: dev_err(chip->dev, "ATU problem: error %d while handling interrupt\n", err); return IRQ_HANDLED; From patchwork Tue Dec 13 17:46:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Schultz X-Patchwork-Id: 32905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp271362wrn; Tue, 13 Dec 2022 09:54:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf50DlUi9e/fcuNRnTPz1wmnVL7SaReSmCepjR9qtfyCuuFgPNv2JlJruFIwrHRaspK7uasF X-Received: by 2002:a05:6a21:1788:b0:aa:5c2d:6e59 with SMTP id nx8-20020a056a21178800b000aa5c2d6e59mr24301094pzb.7.1670954080407; Tue, 13 Dec 2022 09:54:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670954080; cv=none; d=google.com; s=arc-20160816; b=TiX8SOgu6dm31WZ1DKBEaQaDrGNC4BKZso/d3zxMYARalDCVNUfu+AAYQMki0rGVrb kSbSJkWWAlaKGzCGBdhiMqZ7gCiEbJAqjrlg6YEmh71qV6+XzP1wUKtk6yj8b/iREreI MRjftRltgzegHD0TUoygtrCyNBPvAo4xgd5EiU2sa3kRV0EbHReLlwXdddpqoRADH+f5 EBGsUgnk62MCbjGfS0n7c+juZPb/6IH8MOVrgD+Re6EHw/zna3cM7IlXx8OfyLOoJe9O fCzU/Hidb7bXZpccIWnkfWIyMTbmxviaTL5+VrUfrNC1CvweQTQDRs/CkcT/hId/axR6 EtlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=6qIDfgQR+xGxIh/I0A9fFouy0SJ70toBcIWRVRn/VPA=; b=ewxuwRSPwYEyZcUGGCkXuv4QvGEg0qnroFrEf1HEHwSJXfZK+oYYYD95exhWLBolVk HprtEdzeBuD0P6guuV/pqcEpL2ymLp7ZFOZ18DW7I5QXfCH9fWM+dk8emDL/M0pgs35y 47+/xD2DC6bBa2PwWIjYIqtkq7eWkM5eBXzgt55Y6OLW5hDWFqLBs+TW0PTjPCNTvyRR Njox/hVQoryHYAbp7+yvJGFcRwG1bwn3IDja4n3i+Es8YBLqMhwkCDD17v62gqsuMbd9 C3UufhSDjcuuH5MYrWlSMY6egmiR0nQOaa/CXWzsVV6K11ecUEA9qJtttJZKUb6NE3dT g/5A== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a71-20020a63904a000000b00478ca0483casi13086757pge.17.2022.12.13.09.54.26; Tue, 13 Dec 2022 09:54:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236292AbiLMRs1 (ORCPT + 99 others); Tue, 13 Dec 2022 12:48:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236367AbiLMRsL (ORCPT ); Tue, 13 Dec 2022 12:48:11 -0500 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2287813F07; Tue, 13 Dec 2022 09:48:08 -0800 (PST) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id 4F4E618839C2; Tue, 13 Dec 2022 17:48:07 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id 354A82500015; Tue, 13 Dec 2022 17:48:07 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 1000) id 204B791201E3; Tue, 13 Dec 2022 17:48:07 +0000 (UTC) X-Screener-Id: 413d8c6ce5bf6eab4824d0abaab02863e8e3f662 Received: from fujitsu.vestervang (2-104-116-184-cable.dk.customer.tdc.net [2.104.116.184]) by smtp.gigahost.dk (Postfix) with ESMTPSA id C697091201E4; Tue, 13 Dec 2022 17:48:06 +0000 (UTC) From: "Hans J. Schultz" To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, "Hans J. Schultz" , Andrew Lunn , Florian Fainelli , Vladimir Oltean , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 net-next 3/3] net: dsa: mv88e6xxx: mac-auth/MAB implementation Date: Tue, 13 Dec 2022 18:46:50 +0100 Message-Id: <20221213174650.670767-4-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213174650.670767-1-netdev@kapio-technology.com> References: <20221213174650.670767-1-netdev@kapio-technology.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752122345668251828?= X-GMAIL-MSGID: =?utf-8?q?1752122345668251828?= This implementation for the Marvell mv88e6xxx chip series, is based on handling ATU miss violations occurring when packets ingress on a port that is locked with learning on. This will trigger a SWITCHDEV_FDB_ADD_TO_BRIDGE event, which will result in the bridge module adding a locked FDB entry. This bridge FDB entry will not age out as it has the extern_learn flag set. Userspace daemons can listen to these events and either accept or deny access for the host, by either replacing the locked FDB entry with a simple entry or leave the locked entry. If the host MAC address is already present on another port, a ATU member violation will occur, but to no real effect, and the packet will be dropped in hardware. Statistics on these violations can be shown with the command and example output of interest: ethtool -S ethX NIC statistics: ... atu_member_violation: 5 atu_miss_violation: 23 ... Where ethX is the interface of the MAB enabled port. Furthermore, as added vlan interfaces where the vid is not added to the VTU will cause ATU miss violations reporting the FID as MV88E6XXX_FID_STANDALONE, we need to check and skip the miss violations handling in this case. Signed-off-by: Hans J. Schultz Reviewed-by: Alexander Duyck --- drivers/net/dsa/mv88e6xxx/Makefile | 1 + drivers/net/dsa/mv88e6xxx/chip.c | 18 ++++-- drivers/net/dsa/mv88e6xxx/chip.h | 15 +++++ drivers/net/dsa/mv88e6xxx/global1_atu.c | 8 +++ drivers/net/dsa/mv88e6xxx/switchdev.c | 83 +++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/switchdev.h | 19 ++++++ 6 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 drivers/net/dsa/mv88e6xxx/switchdev.c create mode 100644 drivers/net/dsa/mv88e6xxx/switchdev.h diff --git a/drivers/net/dsa/mv88e6xxx/Makefile b/drivers/net/dsa/mv88e6xxx/Makefile index 49bf358b9c4f..1409e691ab77 100644 --- a/drivers/net/dsa/mv88e6xxx/Makefile +++ b/drivers/net/dsa/mv88e6xxx/Makefile @@ -15,6 +15,7 @@ mv88e6xxx-objs += port_hidden.o mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += ptp.o mv88e6xxx-objs += serdes.o mv88e6xxx-objs += smi.o +mv88e6xxx-objs += switchdev.o mv88e6xxx-objs += trace.o # for tracing framework to find trace.h diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index d5930b287db4..2682c2b29346 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1729,11 +1729,11 @@ static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid, return err; } -static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, - int (*cb)(struct mv88e6xxx_chip *chip, - const struct mv88e6xxx_vtu_entry *entry, - void *priv), - void *priv) +int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, + int (*cb)(struct mv88e6xxx_chip *chip, + const struct mv88e6xxx_vtu_entry *entry, + void *priv), + void *priv) { struct mv88e6xxx_vtu_entry entry = { .vid = mv88e6xxx_max_vid(chip), @@ -6527,7 +6527,7 @@ static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port, const struct mv88e6xxx_ops *ops; if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | - BR_BCAST_FLOOD | BR_PORT_LOCKED)) + BR_BCAST_FLOOD | BR_PORT_LOCKED | BR_PORT_MAB)) return -EINVAL; ops = chip->info->ops; @@ -6585,6 +6585,12 @@ static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, goto out; } + if (flags.mask & BR_PORT_MAB) { + bool mab = !!(flags.val & BR_PORT_MAB); + + mv88e6xxx_port_set_mab(chip, port, mab); + } + if (flags.mask & BR_PORT_LOCKED) { bool locked = !!(flags.val & BR_PORT_LOCKED); diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h index e693154cf803..f635a5bb47ce 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -280,6 +280,9 @@ struct mv88e6xxx_port { unsigned int serdes_irq; char serdes_irq_name[64]; struct devlink_region *region; + + /* MacAuth Bypass control flag */ + bool mab; }; enum mv88e6xxx_region_id { @@ -784,6 +787,12 @@ static inline bool mv88e6xxx_is_invalid_port(struct mv88e6xxx_chip *chip, int po return (chip->info->invalid_port_mask & BIT(port)) != 0; } +static inline void mv88e6xxx_port_set_mab(struct mv88e6xxx_chip *chip, + int port, bool mab) +{ + chip->ports[port].mab = mab; +} + int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val); int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val); int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg, @@ -802,6 +811,12 @@ static inline void mv88e6xxx_reg_unlock(struct mv88e6xxx_chip *chip) mutex_unlock(&chip->reg_lock); } +int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, + int (*cb)(struct mv88e6xxx_chip *chip, + const struct mv88e6xxx_vtu_entry *entry, + void *priv), + void *priv); + int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *bitmap); #endif /* _MV88E6XXX_CHIP_H */ diff --git a/drivers/net/dsa/mv88e6xxx/global1_atu.c b/drivers/net/dsa/mv88e6xxx/global1_atu.c index 34203e112eef..fc020161b7cf 100644 --- a/drivers/net/dsa/mv88e6xxx/global1_atu.c +++ b/drivers/net/dsa/mv88e6xxx/global1_atu.c @@ -12,6 +12,7 @@ #include "chip.h" #include "global1.h" +#include "switchdev.h" #include "trace.h" /* Offset 0x01: ATU FID Register */ @@ -443,6 +444,13 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id) entry.portvec, entry.mac, fid); chip->ports[spid].atu_miss_violation++; + + if (fid != MV88E6XXX_FID_STANDALONE && chip->ports[spid].mab) { + err = mv88e6xxx_handle_miss_violation(chip, spid, + &entry, fid); + if (err) + goto out; + } } if (val & MV88E6XXX_G1_ATU_OP_FULL_VIOLATION) { diff --git a/drivers/net/dsa/mv88e6xxx/switchdev.c b/drivers/net/dsa/mv88e6xxx/switchdev.c new file mode 100644 index 000000000000..4c346a884fb2 --- /dev/null +++ b/drivers/net/dsa/mv88e6xxx/switchdev.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * switchdev.c + * + * Authors: + * Hans J. Schultz + * + */ + +#include +#include "chip.h" +#include "global1.h" +#include "switchdev.h" + +struct mv88e6xxx_fid_search_ctx { + u16 fid_search; + u16 vid_found; +}; + +static int __mv88e6xxx_find_vid(struct mv88e6xxx_chip *chip, + const struct mv88e6xxx_vtu_entry *entry, + void *priv) +{ + struct mv88e6xxx_fid_search_ctx *ctx = priv; + + if (ctx->fid_search == entry->fid) { + ctx->vid_found = entry->vid; + return 1; + } + + return 0; +} + +static int mv88e6xxx_find_vid(struct mv88e6xxx_chip *chip, u16 fid, u16 *vid) +{ + struct mv88e6xxx_fid_search_ctx ctx; + int err; + + ctx.fid_search = fid; + mv88e6xxx_reg_lock(chip); + err = mv88e6xxx_vtu_walk(chip, __mv88e6xxx_find_vid, &ctx); + mv88e6xxx_reg_unlock(chip); + if (err < 0) + return err; + if (err == 1) + *vid = ctx.vid_found; + else + return -ENOENT; + + return 0; +} + +int mv88e6xxx_handle_miss_violation(struct mv88e6xxx_chip *chip, int port, + struct mv88e6xxx_atu_entry *entry, u16 fid) +{ + struct switchdev_notifier_fdb_info info = { + .addr = entry->mac, + .locked = true, + }; + struct net_device *brport; + struct dsa_port *dp; + u16 vid; + int err; + + err = mv88e6xxx_find_vid(chip, fid, &vid); + if (err) + return err; + + info.vid = vid; + dp = dsa_to_port(chip->ds, port); + + rtnl_lock(); + brport = dsa_port_to_bridge_port(dp); + if (!brport) { + rtnl_unlock(); + return -ENODEV; + } + err = call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_BRIDGE, + brport, &info.info, NULL); + rtnl_unlock(); + + return err; +} diff --git a/drivers/net/dsa/mv88e6xxx/switchdev.h b/drivers/net/dsa/mv88e6xxx/switchdev.h new file mode 100644 index 000000000000..62214f9d62b0 --- /dev/null +++ b/drivers/net/dsa/mv88e6xxx/switchdev.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * switchdev.h + * + * Authors: + * Hans J. Schultz + * + */ + +#ifndef _MV88E6XXX_SWITCHDEV_H_ +#define _MV88E6XXX_SWITCHDEV_H_ + +#include "chip.h" + +int mv88e6xxx_handle_miss_violation(struct mv88e6xxx_chip *chip, int port, + struct mv88e6xxx_atu_entry *entry, + u16 fid); + +#endif /* _MV88E6XXX_SWITCHDEV_H_ */