From patchwork Tue May 8 16:02:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10386447 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 95F6E602C2 for ; Tue, 8 May 2018 16:03:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 860FD289BF for ; Tue, 8 May 2018 16:03:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AC0E28D0F; Tue, 8 May 2018 16:03:09 +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 98FF428D08 for ; Tue, 8 May 2018 16:03:08 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40gPQz0gGhzF1gW for ; Wed, 9 May 2018 02:03:07 +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="l6fiSMf8"; 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=104.47.1.77; helo=eur01-ve1-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="l6fiSMf8"; dkim-atps=neutral Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0077.outbound.protection.outlook.com [104.47.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40gPQs1Q1SzF1dk for ; Wed, 9 May 2018 02:03:01 +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=mIehE7TYt1NYIVZwK9cmCeSGc4LLw3sOy9Qp6yb+w68=; b=l6fiSMf8Urw2Ag3cmSqAiGFl54ez7ATgY7LcPAXKH6yb9iHG8bOV6AjYd7jgxW8volYXE9YW384VSHIAYDl3S67kgE3n4fQU6eD6NIBEBFSideGgyUZNDm9egSmSeMXDuN/Ati3tpKlSqxmG6g8oUoVgtWuF9nenrDzXYmDJo3c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by VI1PR05MB4189.eurprd05.prod.outlook.com (2603:10a6:803:4e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.735.17; Tue, 8 May 2018 16:02:52 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v2 4/4] mlxsw: spectrum_span: Support VLAN under mirror-to-gretap In-Reply-To: References: Message-Id: <70341445f50b3ea39f54b15516b6ae65b3217b07.1525792392.git.petrm@mellanox.com> Date: Tue, 08 May 2018 18:02:44 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [78.45.160.211] X-ClientProxiedBy: HE1PR0301CA0002.eurprd03.prod.outlook.com (2603:10a6:3:76::12) To VI1PR05MB4189.eurprd05.prod.outlook.com (2603:10a6:803:4e::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4189; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4189; 3:uK1HZA/129l67NoO+qrdrGv/PL7zSYndKmMYwC74P7guI20AYDejFaRuDsP4akN7tmyr3khnrmTI1Z8WjIWdIoauhDNfWNxCm7v5p7SCdAs5E2KWXJ1nl75KxFguS6jjP4zLBfRHc66JI/Qi2uHZvYtAVdbrpVxdgVE0QXTLQGk2IEaFLAeOztUMO5HkePDVuMVax754XOctQW15ddEtrHv/uttGoQPN5fyas7VCrd16QneO/EVCkH2EuwWkGUoK; 25:uyFNIaTHUXwPSS5Lzw2CkedrUvd68/NnI6kuTMDD12JqD/CB7MVtXCzHEynYDzNIFnm6q0LouHeQSx0AVRFiEsS/g+APh+ovvyMxgNSr3RrXZMTCJ3NHtGO23qgb4f7s/nF7kidnvtkVUg+6TxcfyFP4Xs4mwW4saVnhmrk4YmW52H87wUpQhbzri3x14s+PyS3eFA6mDBX1o9yQTGui10R90SCXIfBm6SDxgNm3i7A4n/UpMA4lJfekQDTKzShANjkl5By5qjfqhr6IY5oCGS8vBwyTyGTpK7MDF0P77SyOO1XjIqlubBRPgFSIlLGvxZbT03Y71/6PHJPZ/6PfSA==; 31:2gFhTopX0LdYDhrX4ja3u2pm7NnJbkSVlsHGk0NqE6J1pzeUfEkF7YsTPJHwt4WbVJ7hWZrICFUtkYG3dYYzGFOXDZdxB4MnlfxJ6a7KR52Un7imvNgVdACRj7kcaZP3Eit8+1MXdRcUKBmFzlLXj9LW8FOTUkQ1nUtbxGDHojtvLDG0nxpP5f+pKw5oQwH5HPanY89o1c6dhjQR3mN8WJUEzq52jg/HVmP4d4O1wKw= X-MS-TrafficTypeDiagnostic: VI1PR05MB4189: X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4189; 20:idc+Zi8phjOS72cNpOrUNyFLQDD9osB0zG30oz6EkNNrfTK0chTdhqdNi4bBzLgZIV+qLB0JeKpxhaFfBSdix6Y1H6CYJiGQjTvxPzOaoOr1IwI+uTVorTP+8V3V8nablHeYOsMBWcyr478pF+noluPeQO/JRy/CiQ98O7UkKTHT1UKVn0EpfSO8f5XlSbC3SptSOkhPLTCuY0eLTINqkeyk5qz5EhVNYluJjuxaMQGakGxWKrUswn6iuEfug80kwJPWCcpW2fUIJFUIBkxfMQtkZZWKrl5YTk97CsDL1eM9yuFxr4ZUdMPhBrBOamOAUeMdcDyjz5QFceD/d1MQnMcAt68eF18hiyd4M4akFps12/2b0MYpsluq/3lYXo8oEx6rITzdrpj44ocbFTZBE4D6ARFdSkWx7X5fRto4tu9RVxO0iBASD86EOwKVxwWtTb5ABl4Y5wXi2RHoNOxCjYdNHsqjD5Ffz6mcuSgc4HOynCbRQxZiVjM9GWMBNYpv; 4:u+XthiIDpA5Z77eEmRC+0T+KXI9CePfcUSmYJk0XthzyOUanGJ/4Z3mDREclGXf8CgRBqcFgv45BEgejbPBrRUBJiAoZssQOf27lhvAZJg6dM8xqxdi8KqdMd4XdxkrMZ6pevkwq380nxPA683CCvGS0XebOh7Z7l8LKu/64tNF1O3SJB3Cs5iLgzYG+PjL5f9nHAl6YFVtfWEuFfGjZKPWg5yiSMr+M/MaAtZOx9BOaXSp4cDC5wE2fWNR06AaAj0y3YAi+vN8oEaUmbBCwtg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:VI1PR05MB4189; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4189; X-Forefront-PRVS: 0666E15D35 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(39380400002)(346002)(376002)(199004)(189003)(48376002)(107886003)(68736007)(4326008)(50466002)(53936002)(2351001)(66066001)(47776003)(2906002)(3846002)(6116002)(36756003)(106356001)(52116002)(81166006)(105586002)(486006)(2616005)(956004)(11346002)(118296001)(446003)(476003)(8936002)(76176011)(16526019)(25786009)(26005)(6486002)(58126008)(7736002)(81156014)(305945005)(51416003)(16586007)(478600001)(8676002)(316002)(6496006)(97736004)(6666003)(5660300001)(86362001)(386003)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4189; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4189; 23:3hCzVNYogIX02nAL8eUJTmW79tupu2h0KAghx/5Nr?= =?us-ascii?Q?4RDrgdBd86ng0DkwiUrbIlaBHmcALwA3sMqMuUsZSN/q4RZ9ovUHYKQF/0tw?= =?us-ascii?Q?bRJefYb2lkS5/CMAAdgF4D1gQUynLGnQqayJx8IxFcEj3A+Yd70Xp4eHTtzS?= =?us-ascii?Q?m7Dp1iiTJ27tk0udqf8YsVl3PnKLpEldhHCXZBdqRm3IbyeeKRTfDR2ytF9L?= =?us-ascii?Q?p7jJaXfYx5AdSwBGeK8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4rhUh/cxuTvj3DNB4fofDoFeFxRqFK284vN9abFx2k/M1CJyESZHhI6iMkpMKqDs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4189; 7:UtPAVA6s5yZB+no1ZHHt3BoPa5HYxnj2ydbsGhGRg804qLLTTSlO8ENHS7/St8syy/+oUi5/pkOz/u0rQdE5deWbfc0RPig5XfXyNmp0718vs0scvKcRAdPm4CaOUL3r9EODkLCtD95ic+3WE7YmNUOFMSxOqSC55d+WxdwStLkQcJm1ptNj+vwNW7k4qjTNlNQArQVM4B6gChro8Ny85GwHtPO/e1rOUNHNUTMX2xqaW1+vkNGT+t6cnqvG9r7V X-MS-Office365-Filtering-Correlation-Id: 7e2bfd7a-72f3-4f7c-1545-08d5b4fd278b X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2018 16:02:52.1257 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e2bfd7a-72f3-4f7c-1545-08d5b4fd278b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4189 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 X-Virus-Scanned: ClamAV using ClamSMTP When mirroring to a gretap or ip6gretap device, allow the underlay packet path to include VLAN devices. The following configurations are supported in underlay: - vlan over phys - vlan-unaware bridge where the egress device is vlan over phys - vlan over vlan-aware bridge where the egress device is phys Signed-off-by: Petr Machata --- .../net/ethernet/mellanox/mlxsw/spectrum_span.c | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c index d90582e..3b77990 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c @@ -176,21 +176,23 @@ mlxsw_sp_span_entry_bridge_8021q(const struct net_device *br_dev, { struct bridge_vlan_info vinfo; struct net_device *edev; - u16 pvid; + u16 vid = *p_vid; - if (WARN_ON(br_vlan_get_pvid(br_dev, &pvid))) + if (!vid && WARN_ON(br_vlan_get_pvid(br_dev, &vid))) return NULL; - if (!pvid) + if (!vid || + br_vlan_get_info(br_dev, vid, &vinfo) || + !(vinfo.flags & BRIDGE_VLAN_INFO_BRENTRY)) return NULL; - edev = br_fdb_find_port(br_dev, dmac, pvid); + edev = br_fdb_find_port(br_dev, dmac, vid); if (!edev) return NULL; - if (br_vlan_get_info(edev, pvid, &vinfo)) + if (br_vlan_get_info(edev, vid, &vinfo)) return NULL; if (!(vinfo.flags & BRIDGE_VLAN_INFO_UNTAGGED)) - *p_vid = pvid; + *p_vid = vid; return edev; } @@ -208,13 +210,13 @@ mlxsw_sp_span_entry_bridge(const struct net_device *br_dev, { struct mlxsw_sp_bridge_port *bridge_port; enum mlxsw_reg_spms_state spms_state; + struct net_device *dev = NULL; 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 + else if (!*p_vid) dev = mlxsw_sp_span_entry_bridge_8021d(br_dev, dmac); if (!dev) return NULL; @@ -261,12 +263,21 @@ mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, if (!l3edev || mlxsw_sp_span_dmac(tbl, &gw, l3edev, dmac)) goto unoffloadable; + if (is_vlan_dev(l3edev)) + l3edev = mlxsw_sp_span_entry_vlan(l3edev, &vid); + if (netif_is_bridge_master(l3edev)) { l3edev = mlxsw_sp_span_entry_bridge(l3edev, dmac, &vid); if (!l3edev) goto unoffloadable; } + if (is_vlan_dev(l3edev)) { + if (vid || !(l3edev->flags & IFF_UP)) + goto unoffloadable; + l3edev = mlxsw_sp_span_entry_vlan(l3edev, &vid); + } + if (!mlxsw_sp_port_dev_check(l3edev)) goto unoffloadable;