Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp565655ybh; Tue, 21 Jul 2020 02:20:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFgnrtk7WUkeqtUQybyd6KIuS85xG+kOAKwlM2wHb2iQyFMoAfV8Vmx5WdnxuVOffzu9s3 X-Received: by 2002:a05:6402:1d14:: with SMTP id dg20mr25488352edb.23.1595323227540; Tue, 21 Jul 2020 02:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595323227; cv=none; d=google.com; s=arc-20160816; b=SGD4uOFBNmbCxZZJf11l+QfoE63/P/ll1dTEX4piEGkmvIdWzfh+MKcJRms5xkFRB2 1oFT7E5Alj/rCLNmh3ePIpGO0elFxQC6h3+uPFfO4tOa/FDGB3WwNZ+xSmz4MkXRlVel 1O4fXN0Pi5LAvPHast0/2jfitq87sseLw8tLwcwj9OHBfm95uAXuXJ9Ypi1ATEE1KwYK N9GLoCrMzb1BpyzSdVwWptcd6qzCBr0R+jwzj8qSRt8qsN/jX3Q56xM9wzv6Ap6o3xH0 /IlbFUQcf1oF5dTwQ2pinO2pxBeD9wvfApjMetb3KZ5aHAHfa/xux9emTlP/8zP8ABAL mQ0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ETE79uz37v2oLPcPuKJ2LaS+Pc2aiEYdqbQVS9It7SE=; b=FRwMA4fnR6KlYDdDcctVTFa3eL2QbmFgrJu2nZE80cfnZFtBG9WZ87oYF1lCwjkT9L z/iADqc7p59LfMsFO95Aj2aowcFfSuHLPmwbJlKnqaNOyAT1ATKPo2h77eHD1vU1vyfT Iw4niz8Eer/dD9MJ0MhihoIrvQhE0lIW2Kwp8pc9qhiflGFxWWe3IPvfOnSxXor4sGqk YBqx0YqN9demse466OizqIkxyLwQ+47ViN5oyEsshB9e0eJW1TK2UKpotQ2iOtLPai/E /hv58ryKY7cKeTOa5RXtAT8CYUBVy0haHnWZ9CGAcfmJu9T5HKytGDnJMRIqFDqBET0Y MeJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j28si12526485edj.142.2020.07.21.02.20.04; Tue, 21 Jul 2020 02:20:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728914AbgGUJTe (ORCPT + 99 others); Tue, 21 Jul 2020 05:19:34 -0400 Received: from inva020.nxp.com ([92.121.34.13]:34274 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbgGUJTd (ORCPT ); Tue, 21 Jul 2020 05:19:33 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id D70011A058B; Tue, 21 Jul 2020 11:19:31 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CAD0E1A05BD; Tue, 21 Jul 2020 11:19:31 +0200 (CEST) Received: from fsr-ub1864-126.ea.freescale.net (fsr-ub1864-126.ea.freescale.net [10.171.82.212]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 95E3A202A9; Tue, 21 Jul 2020 11:19:31 +0200 (CEST) From: Ioana Ciornei To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Ioana Ciornei Subject: [PATCH 2/6] staging: dpaa2-ethsw: don't allow interfaces from different DPSWs to be bridged Date: Tue, 21 Jul 2020 12:19:15 +0300 Message-Id: <20200721091919.20394-3-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200721091919.20394-1-ioana.ciornei@nxp.com> References: <20200721091919.20394-1-ioana.ciornei@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Error out when the user tries to bridge two switch interfaces that are from different DPSW instances. This is not supported by the hardware and we should reflect this into what the user is aware of. Signed-off-by: Ioana Ciornei --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 557a75115da8..530e4105375c 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1182,6 +1182,9 @@ static int port_bridge_join(struct net_device *netdev, { struct ethsw_port_priv *port_priv = netdev_priv(netdev); struct ethsw_core *ethsw = port_priv->ethsw_data; + struct ethsw_port_priv *other_port_priv; + struct net_device *other_dev; + struct list_head *iter; int i, err; for (i = 0; i < ethsw->sw_attr.num_ifs; i++) @@ -1192,6 +1195,18 @@ static int port_bridge_join(struct net_device *netdev, return -EINVAL; } + netdev_for_each_lower_dev(upper_dev, other_dev, iter) { + if (!ethsw_port_dev_check(other_dev, NULL)) + continue; + + other_port_priv = netdev_priv(other_dev); + if (other_port_priv->ethsw_data != port_priv->ethsw_data) { + netdev_err(netdev, + "Interface from a different DPSW is in the bridge already!\n"); + return -EINVAL; + } + } + /* Enable flooding */ err = ethsw_port_set_flood(port_priv, 1); if (!err) -- 2.25.1