From patchwork Wed Apr 25 14:08:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10363289 X-Patchwork-Delegate: idosch@idosch.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1DC49601D3 for ; Wed, 25 Apr 2018 14:08:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EC47289E3 for ; Wed, 25 Apr 2018 14:08:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 035B2289F5; Wed, 25 Apr 2018 14:08:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0636E289E3 for ; Wed, 25 Apr 2018 14:08:32 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40WMVk2dZlzF24R for ; Thu, 26 Apr 2018 00:08:30 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="U1qILBxB"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=40.107.3.88; helo=eur03-am5-obe.outbound.protection.outlook.com; envelope-from=petrm@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="U1qILBxB"; dkim-atps=neutral Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30088.outbound.protection.outlook.com [40.107.3.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40WMVX47ZXzF24d for ; Thu, 26 Apr 2018 00:08:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=u+JqEMLVHEnjwQ6uVnLoIOo+I2ibt3OJnrx0RIebDlM=; b=U1qILBxBtjFUIUqJwaFkkTZjN8f4yFX862iNiHQYi0KWfNbJw3Cj0TerF0/Cq400cmjF5Ox6kwPl5pjB+0CnAVAB8CC6eRMIh3vPKWVYxnXIhJfLRzaNh3NGXAgav6UkWJcnQnXrzFzUtf6nV71mNuPUu95Nqk6ZNMK0L2BUfDw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.177.127.115) by AM6PR05MB4184.eurprd05.prod.outlook.com (2603:10a6:209:40::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Wed, 25 Apr 2018 14:08:13 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v3 6/6] mlxsw: spectrum_span: Allow bridge for gretap mirror In-Reply-To: References: Message-Id: <0d61bf71c86c05b632355b7a78245d2235992018.1524654206.git.petrm@mellanox.com> Date: Wed, 25 Apr 2018 16:08:09 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.177.127.115] X-ClientProxiedBy: DB6PR0202CA0010.eurprd02.prod.outlook.com (2603:10a6:4:29::20) To AM6PR05MB4184.eurprd05.prod.outlook.com (2603:10a6:209:40::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(2017052603328)(7153060)(7193020); SRVR:AM6PR05MB4184; X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4184; 3:/8XfMLlGccNof5/lEEuNM0AubNYYn7BIvL6xdDq9AO3jTN1dSY93kxxwWwczq9ZbUAQjcCzMFdJqX0pRbXqiW3qFslD1pSVakyUA99m+3p5454Xc13j0sa2MAkuHidzEVYVobr9IM1brkNQi+MIidnDbQBXYBnwTzOU3rLBUYRCB2Ex18SafFGuREpRrnfTnAHjDkuVqpP9AGYjDEjhGb0jhCItL462tLkUFuS+2JBvMs1LNVilEJdd8R+s+qRdL; 25:QVAWv140Kph9mkLa8iQoX4vhQpV6wlx8wllWLF2XXVZChDDXtvbeiIumy3ph1k++m30Mh84oSkE9PGHAMeelzI6CH8PSzIk8u4RkqIgG2/z/5XEm1AYYwx2gA1pmOS6QoQIGmnLpl9y2xw650jZGmrMhen3bCDd2pYe5rh5rYV8NrBlMMnSJFjDlfFC84uTBcFSz4xkjHC4qDR3Kwf0DQr2laX1DJ5WRGYWt2eldH4zcV7eRDDfYUofoAZxg+BJ5n5tKH7Eq+mpOfVyjqErSWii+FaIdCe6w6GOYSd9ICEDbORaRuAto66BRUwPymvFFbb2q1CRgUk3fFuhaZWHwbQ==; 31:bdWIvskJyAXlETC1dNhYr+pDBmSOm0p6kKJpllkT2F2iMIWuj03LGmLkAe+ydzABJOsVmucALWKEI7KhWK5AG5U7Sw2kVfoACVCdLb1ygXmxqmDs8HIcsvaPl4F0JvKfHVnyJHz0DJyXRRNv0plN5X3LHlTDht5darplYSsvMCKmqew8821AZSICpGvqyVaK/w9syIfmhjFhxZewUmHP0y0lOpJ2jYX4wfXjVj4UdQM= X-MS-TrafficTypeDiagnostic: AM6PR05MB4184: X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4184; 20:QppK0JIZLFtTeE21WoaGu7bo8tvGDeQ08CfRjE6n9bt+2WEau9n8oMtBTDIqtdQq8Q+DCQh3wfaOPV20QK5ueQPRQAuGGgT3AKQSyKLCatcVoJof562mq4XmQVRaLSrDRx2U1VtvseBENHxYO26kcNqNsbaOf34awQipkxQHk5KuXLelIjzZP0JLn3q7FF0PgI+Wwr3KGd95qLcPBPcv8V+YEZ2kiVsn9bA6HHcAPBG3f1X37xapX3JwwIif2k/ddOffnCq77i2lvOH6Q3yOEqNfxCQOfEDPkqGzRP4xJGjkMVR/XWdsNRboTE46eyfsd0DUTT61ZBySu2R3gLfx/VwqOWe9GBDkMJjANwplwSxcDPnxqB765zMatyIxrW6mWTZXQJwF0sCf9AfPJoFuL5rKU+GBhVy1VZS5Akv53sScVteDyYhBtKfUSSHMqYcY8W/yuGXcwTDhTCVZpiQCbWvvZmSwLaTE3Fr1L1IFYnRFBS5bG0VPifVsXCr74UDi; 4:N2M+aURbXrubOKAB9/7aSIlkNtqqxhPcHfYM4IvQi6mBjTM+xACX+uv0w2zTYJySz0IHg9lsatqj+BWJeIHIr+oq0gvlGs5o209cz5Km4rEs599uAtfeW3AVPBGM8I4huzxzoARDD10CHNrk1Ba/IBMaPeObN5tTMRANstLyh7E790xhJ2hugYGzAmWhFniUF1HLW404lnHmLklZyOjjR6ZdeVUj6wscZ5dQaU1nOfPzHpe2LHYgdujnFbd6jOQNM52r8+L/krhJbqouJGVUEQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231232)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:AM6PR05MB4184; BCL:0; PCL:0; RULEID:; SRVR:AM6PR05MB4184; X-Forefront-PRVS: 06530126A4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(346002)(366004)(39860400002)(39380400002)(396003)(189003)(199004)(106356001)(118296001)(478600001)(6116002)(5660300001)(7736002)(66066001)(2351001)(68736007)(486006)(53936002)(25786009)(36756003)(305945005)(2616005)(476003)(956004)(107886003)(2906002)(58126008)(3846002)(50466002)(86362001)(76176011)(52116002)(446003)(105586002)(316002)(8936002)(6916009)(11346002)(16586007)(26005)(6496006)(16526019)(6486002)(48376002)(4326008)(47776003)(6666003)(97736004)(386003)(81166006)(51416003)(8676002)(81156014)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4184; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM6PR05MB4184; 23:c0cXvfbzPMlKymxl7im8QVr7VCoPsb1GHIL5hvrXd?= =?us-ascii?Q?azF9QhZNV71cM5tYf7oXUR/rEy+PWJ49zpQY/ROm8iHaFUB6LS2vY9IzmYIN?= =?us-ascii?Q?hMxfODFZVBV5+ycjuAnprQZ5S//LC2vILRIsFnyPJIMWf3d6+YGJnZyr6h1E?= =?us-ascii?Q?CYad1Rkas+N4xsCKM+cRSN2UzSsUpVGxO+OVn3XUGQUkXyf1Z0dxd574xruB?= =?us-ascii?Q?MXxbjEIpLyMvdGkOoIMsXfY+htBqnNSGviyeLIfu3mMtkQcy+psEp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8zUpKPbeC2Rr6JN+/7CNedj3Yixm1dq9+anAPbjLiMu0gZ5QRwEHk7WbmslBpO47zrCiDfmkb0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4184; 7:WZSit6octrZWPg7QLzu8j9obGpbp9CS2lY0trwcT+kI0af2+y+BZs930Sb91Eix3uNmCqPO4gtGQBkNpewEau7QGHME41Y4KzrbIZRE3PpubyOmbuEfykeqIB3zuciMlmYt9Fx+SqTItBvFbgzJv5ejvI7RzXWznQKz52oc7QoFbJVCRLPW+9Y5XYHIDJPsowFCX2JZ7S8GggjpVpq7v0fTabxheQAqr6yt1G9NCk/kLN7nv9jMKB1JbWA40hdcr X-MS-Office365-Filtering-Correlation-Id: 47cfc12b-faf9-40cf-3abf-08d5aab5fc29 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2018 14:08:13.5718 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47cfc12b-faf9-40cf-3abf-08d5aab5fc29 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4184 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-internal@mellanox.com Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org Sender: "Linux-mlxsw" X-Virus-Scanned: ClamAV using ClamSMTP When handling mirroring to a gretap or ip6gretap netdevice in mlxsw, the underlay address (i.e. the remote address of the tunnel) may be routed to a bridge. In that case, look up the resolved neighbor Ethernet address in that bridge's FDB. Then configure the offload to direct the mirrored traffic to that port, possibly with tagging. Signed-off-by: Petr Machata --- Notes: Changes from v1 to v2: - Don't offload if there's no PVID set for the bridge. - Constify br_dev parameter of mlxsw_sp_span_entry_bridge{,_8021d,_8021q,_lookup_dev}(), - s/vidp/p_vid/g .../net/ethernet/mellanox/mlxsw/spectrum_span.c | 102 +++++++++++++++++++-- .../net/ethernet/mellanox/mlxsw/spectrum_span.h | 1 + 2 files changed, 97 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c index 65a7770..92fb818 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c @@ -32,6 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -39,8 +40,9 @@ #include #include "spectrum.h" -#include "spectrum_span.h" #include "spectrum_ipip.h" +#include "spectrum_span.h" +#include "spectrum_switchdev.h" int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp) { @@ -167,6 +169,79 @@ mlxsw_sp_span_entry_unoffloadable(struct mlxsw_sp_span_parms *sparmsp) return 0; } +static struct net_device * +mlxsw_sp_span_entry_bridge_8021q(const struct net_device *br_dev, + unsigned char *dmac, + u16 *p_vid) +{ + struct net_bridge_vlan_group *vg = br_vlan_group_rtnl(br_dev); + u16 pvid = br_vlan_group_pvid(vg); + struct net_device *edev = NULL; + struct net_bridge_vlan *v; + + if (pvid) + edev = br_fdb_find_port_hold(br_dev, dmac, pvid); + if (!edev) + return NULL; + + /* RTNL prevents edev from being removed. */ + dev_put(edev); + + vg = br_port_vlan_group_rtnl(edev); + v = br_vlan_find(vg, pvid); + if (!v) + return NULL; + if (!(br_vlan_flags(v) & BRIDGE_VLAN_INFO_UNTAGGED)) + *p_vid = pvid; + return edev; +} + +static struct net_device * +mlxsw_sp_span_entry_bridge_8021d(const struct net_device *br_dev, + unsigned char *dmac) +{ + struct net_device *edev = br_fdb_find_port_hold(br_dev, dmac, 0); + + /* RTNL prevents edev from being removed. */ + dev_put(edev); + + return edev; +} + +static struct net_device * +mlxsw_sp_span_entry_bridge(const struct net_device *br_dev, + unsigned char dmac[ETH_ALEN], + u16 *p_vid) +{ + struct mlxsw_sp_bridge_port *bridge_port; + enum mlxsw_reg_spms_state spms_state; + struct mlxsw_sp_port *port; + struct net_device *dev; + u8 stp_state; + + if (br_vlan_enabled(br_dev)) + dev = mlxsw_sp_span_entry_bridge_8021q(br_dev, dmac, p_vid); + else + dev = mlxsw_sp_span_entry_bridge_8021d(br_dev, dmac); + if (!dev) + return NULL; + + port = mlxsw_sp_port_dev_lower_find(dev); + if (!port) + return NULL; + + bridge_port = mlxsw_sp_bridge_port_find(port->mlxsw_sp->bridge, dev); + if (!bridge_port) + return NULL; + + stp_state = mlxsw_sp_bridge_port_stp_state(bridge_port); + spms_state = mlxsw_sp_stp_spms_state(stp_state); + if (spms_state != MLXSW_REG_SPMS_STATE_FORWARDING) + return NULL; + + return dev; +} + static __maybe_unused int mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, union mlxsw_sp_l3addr saddr, @@ -177,13 +252,22 @@ mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, struct mlxsw_sp_span_parms *sparmsp) { unsigned char dmac[ETH_ALEN]; + u16 vid = 0; if (mlxsw_sp_l3addr_is_zero(gw)) gw = daddr; - if (!l3edev || !mlxsw_sp_port_dev_check(l3edev) || - mlxsw_sp_span_dmac(tbl, &gw, l3edev, dmac)) - return mlxsw_sp_span_entry_unoffloadable(sparmsp); + if (!l3edev || mlxsw_sp_span_dmac(tbl, &gw, l3edev, dmac)) + goto unoffloadable; + + if (netif_is_bridge_master(l3edev)) { + l3edev = mlxsw_sp_span_entry_bridge(l3edev, dmac, &vid); + if (!l3edev) + goto unoffloadable; + } + + if (!mlxsw_sp_port_dev_check(l3edev)) + goto unoffloadable; sparmsp->dest_port = netdev_priv(l3edev); sparmsp->ttl = ttl; @@ -191,7 +275,11 @@ mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, memcpy(sparmsp->smac, l3edev->dev_addr, ETH_ALEN); sparmsp->saddr = saddr; sparmsp->daddr = daddr; + sparmsp->vid = vid; return 0; + +unoffloadable: + return mlxsw_sp_span_entry_unoffloadable(sparmsp); } #if IS_ENABLED(CONFIG_NET_IPGRE) @@ -268,9 +356,10 @@ mlxsw_sp_span_entry_gretap4_configure(struct mlxsw_sp_span_entry *span_entry, /* Create a new port analayzer entry for local_port. */ mlxsw_reg_mpat_pack(mpat_pl, pa_id, local_port, true, MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3); + mlxsw_reg_mpat_eth_rspan_pack(mpat_pl, sparms.vid); mlxsw_reg_mpat_eth_rspan_l2_pack(mpat_pl, MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER, - sparms.dmac, false); + sparms.dmac, !!sparms.vid); mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(mpat_pl, sparms.ttl, sparms.smac, be32_to_cpu(sparms.saddr.addr4), @@ -368,9 +457,10 @@ mlxsw_sp_span_entry_gretap6_configure(struct mlxsw_sp_span_entry *span_entry, /* Create a new port analayzer entry for local_port. */ mlxsw_reg_mpat_pack(mpat_pl, pa_id, local_port, true, MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3); + mlxsw_reg_mpat_eth_rspan_pack(mpat_pl, sparms.vid); mlxsw_reg_mpat_eth_rspan_l2_pack(mpat_pl, MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER, - sparms.dmac, false); + sparms.dmac, !!sparms.vid); mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(mpat_pl, sparms.ttl, sparms.smac, sparms.saddr.addr6, sparms.daddr.addr6); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h index 4b87ec2..14a6de9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h @@ -63,6 +63,7 @@ struct mlxsw_sp_span_parms { unsigned char smac[ETH_ALEN]; union mlxsw_sp_l3addr daddr; union mlxsw_sp_l3addr saddr; + u16 vid; }; struct mlxsw_sp_span_entry_ops;