Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/809165/?format=api
{ "id": 809165, "url": "http://patchwork.ozlabs.org/api/patches/809165/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170902214929.2890-12-jiri@resnulli.us/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170902214929.2890-12-jiri@resnulli.us>", "list_archive_url": null, "date": "2017-09-02T21:49:19", "name": "[net-next,v2,11/21] mlxsw: spectrum_router: Introduce loopback RIFs", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "fdd555cea8ef3b6c8c09cddf5e1e0bda4e0a29af", "submitter": { "id": 15321, "url": "http://patchwork.ozlabs.org/api/people/15321/?format=api", "name": "Jiri Pirko", "email": "jiri@resnulli.us" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/20170902214929.2890-12-jiri@resnulli.us/mbox/", "series": [ { "id": 1180, "url": "http://patchwork.ozlabs.org/api/series/1180/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=1180", "date": "2017-09-02T21:49:08", "name": "mlxsw: Offloading GRE tunnels", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/1180/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/809165/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/809165/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=resnulli-us.20150623.gappssmtp.com\n\theader.i=@resnulli-us.20150623.gappssmtp.com\n\theader.b=\"L+9uB3nK\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xl8tR0rCYz9s8J\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSun, 3 Sep 2017 07:50:39 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752840AbdIBVty (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSat, 2 Sep 2017 17:49:54 -0400", "from mail-wr0-f193.google.com ([209.85.128.193]:36654 \"EHLO\n\tmail-wr0-f193.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752776AbdIBVtu (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Sat, 2 Sep 2017 17:49:50 -0400", "by mail-wr0-f193.google.com with SMTP id 40so1620635wrv.3\n\tfor <netdev@vger.kernel.org>; Sat, 02 Sep 2017 14:49:50 -0700 (PDT)", "from localhost (jirka.pirko.cz. [84.16.102.26])\n\tby smtp.gmail.com with ESMTPSA id\n\tb196sm3207663wmd.29.2017.09.02.14.49.47\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSat, 02 Sep 2017 14:49:48 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=resnulli-us.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=WaBkxRMbOhv9+ZTk5OI2/VhBfv7nDjrE3mqY0q442q0=;\n\tb=L+9uB3nKeW1jf+yV4hidMzy7HZnD8uQujV5qW9hOz0XH6AJtCls0E9s5L0OOI08yxV\n\tPJXUv/NaldhlA83Xnb0AHSnzsScZDeZUfuqgFO8TXTp3O5QNu9tQ2iK1cA6nGs1wcR4A\n\tFQPh7yo/Bh2VuRPeEsELpgnfRHDe+nWgYpQ+22YMX41eUks+XbbKIGSUjrQTPQIjIx1N\n\tWEeV7dJ+kfXTqhVe0tiXXIPdj4m3faTKJ4tV5cECizSIz/wzcVbI2MjOQEZKhoXbLa7X\n\t7jqnjVk/t97Qnk4ZBwEChNi9LPp1egytuh3RfhggPYpndyBSJfqDGNU0fUMfCN4qigQE\n\trW7Q==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=WaBkxRMbOhv9+ZTk5OI2/VhBfv7nDjrE3mqY0q442q0=;\n\tb=qgVdhWnjG+WR0FpRlGQzBG1kfliMtc4XvsOOpLyOV7VZ7SRcO9laTWi1zj/dTYv0XK\n\tbef4HYs+Ejo/bHOYlnOQFOlS2Rs8MUa1ux/jBKroO2zLxn7SqNV/WEYFXYuajrKLGk7S\n\tHvmbCqBUBtf5DBXd+ilPXQ/OlpoH85jrwqdTMctx+E8Btrlzdovpu8B8xLpc3BdqatDk\n\tFfBdBdBHlR2hsoZandaj0l1tyLOXD80c39q+AJPVcJQn4nLm9GZxhaeApEawDQdxfFaQ\n\tqC8gCQo3tP50rf34pWfgwScgwcWBooykGv7c0ADGb/Zh8+Ow0xWPuTZmwfoqOoS8zFJJ\n\tyxVw==", "X-Gm-Message-State": "AHPjjUjwI+1tGyeNM7GeAu5ssLeazmHUD0SuR61l4UNA3G2rDTeJ+BPy\n\t80fN9T9YBh/xrP7PMOk=", "X-Google-Smtp-Source": "ADKCNb7zWH2ertaFtn8K7OVT7KWqxB8myow+pm80tETeyCjtpm8srmdCfSGaEj6riR5bkP/MqN59Vg==", "X-Received": "by 10.223.177.193 with SMTP id r1mr3439639wra.50.1504388989099; \n\tSat, 02 Sep 2017 14:49:49 -0700 (PDT)", "From": "Jiri Pirko <jiri@resnulli.us>", "To": "netdev@vger.kernel.org", "Cc": "davem@davemloft.net, petrm@mellanox.com, idosch@mellanox.com,\n\tmlxsw@mellanox.com", "Subject": "[patch net-next v2 11/21] mlxsw: spectrum_router: Introduce\n\tloopback RIFs", "Date": "Sat, 2 Sep 2017 23:49:19 +0200", "Message-Id": "<20170902214929.2890-12-jiri@resnulli.us>", "X-Mailer": "git-send-email 2.9.3", "In-Reply-To": "<20170902214929.2890-1-jiri@resnulli.us>", "References": "<20170902214929.2890-1-jiri@resnulli.us>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "From: Petr Machata <petrm@mellanox.com>\n\nWhen offloading L3 tunnels, an adjacency entry is created that loops the\npacket back into the underlay router. Loopback interfaces then hold the\ncorresponding information and are created for IP-in-IP netdevices.\n\nSigned-off-by: Petr Machata <petrm@mellanox.com>\nReviewed-by: Ido Schimmel <idosch@mellanox.com>\nSigned-off-by: Jiri Pirko <jiri@mellanox.com>\n---\n drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 +\n .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 152 ++++++++++++++++++++-\n .../net/ethernet/mellanox/mlxsw/spectrum_router.h | 13 ++\n 3 files changed, 164 insertions(+), 2 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h\nindex f8c7f7e..84ce83a 100644\n--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h\n+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h\n@@ -77,6 +77,7 @@ enum mlxsw_sp_rif_type {\n \tMLXSW_SP_RIF_TYPE_SUBPORT,\n \tMLXSW_SP_RIF_TYPE_VLAN,\n \tMLXSW_SP_RIF_TYPE_FID,\n+\tMLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */\n \tMLXSW_SP_RIF_TYPE_MAX,\n };\n \ndiff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c\nindex 38477c5..72e386b 100644\n--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c\n+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c\n@@ -1,9 +1,10 @@\n /*\n * drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c\n- * Copyright (c) 2016 Mellanox Technologies. All rights reserved.\n+ * Copyright (c) 2016-2017 Mellanox Technologies. All rights reserved.\n * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>\n * Copyright (c) 2016 Ido Schimmel <idosch@mellanox.com>\n * Copyright (c) 2016 Yotam Gigi <yotamg@mellanox.com>\n+ * Copyright (c) 2017 Petr Machata <petrm@mellanox.com>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n@@ -51,6 +52,7 @@\n #include <net/ip_fib.h>\n #include <net/ip6_fib.h>\n #include <net/fib_rules.h>\n+#include <net/ip_tunnels.h>\n #include <net/l3mdev.h>\n #include <net/addrconf.h>\n #include <net/ndisc.h>\n@@ -131,6 +133,17 @@ struct mlxsw_sp_rif_subport {\n \tbool lag;\n };\n \n+struct mlxsw_sp_rif_ipip_lb {\n+\tstruct mlxsw_sp_rif common;\n+\tstruct mlxsw_sp_rif_ipip_lb_config lb_config;\n+\tu16 ul_vr_id; /* Reserved for Spectrum-2. */\n+};\n+\n+struct mlxsw_sp_rif_params_ipip_lb {\n+\tstruct mlxsw_sp_rif_params common;\n+\tstruct mlxsw_sp_rif_ipip_lb_config lb_config;\n+};\n+\n struct mlxsw_sp_rif_ops {\n \tenum mlxsw_sp_rif_type type;\n \tsize_t rif_size;\n@@ -883,6 +896,25 @@ static void mlxsw_sp_vrs_fini(struct mlxsw_sp *mlxsw_sp)\n \tkfree(mlxsw_sp->router->vrs);\n }\n \n+static struct net_device *\n+__mlxsw_sp_ipip_netdev_ul_dev_get(const struct net_device *ol_dev)\n+{\n+\tstruct ip_tunnel *tun = netdev_priv(ol_dev);\n+\tstruct net *net = dev_net(ol_dev);\n+\n+\treturn __dev_get_by_index(net, tun->parms.link);\n+}\n+\n+static u32 mlxsw_sp_ipip_dev_ul_tb_id(const struct net_device *ol_dev)\n+{\n+\tstruct net_device *d = __mlxsw_sp_ipip_netdev_ul_dev_get(ol_dev);\n+\n+\tif (d)\n+\t\treturn l3mdev_fib_table(d) ? : RT_TABLE_MAIN;\n+\telse\n+\t\treturn l3mdev_fib_table(ol_dev) ? : RT_TABLE_MAIN;\n+}\n+\n struct mlxsw_sp_neigh_key {\n \tstruct neighbour *n;\n };\n@@ -2236,6 +2268,25 @@ static void mlxsw_sp_nexthop_neigh_fini(struct mlxsw_sp *mlxsw_sp,\n \tneigh_release(n);\n }\n \n+static bool mlxsw_sp_netdev_ipip_type(const struct mlxsw_sp *mlxsw_sp,\n+\t\t\t\t const struct net_device *dev,\n+\t\t\t\t enum mlxsw_sp_ipip_type *p_type)\n+{\n+\tstruct mlxsw_sp_router *router = mlxsw_sp->router;\n+\tconst struct mlxsw_sp_ipip_ops *ipip_ops;\n+\tenum mlxsw_sp_ipip_type ipipt;\n+\n+\tfor (ipipt = 0; ipipt < MLXSW_SP_IPIP_TYPE_MAX; ++ipipt) {\n+\t\tipip_ops = router->ipip_ops_arr[ipipt];\n+\t\tif (dev->type == ipip_ops->dev_type) {\n+\t\t\tif (p_type)\n+\t\t\t\t*p_type = ipipt;\n+\t\t\treturn true;\n+\t\t}\n+\t}\n+\treturn false;\n+}\n+\n static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp,\n \t\t\t\t struct mlxsw_sp_nexthop_group *nh_grp,\n \t\t\t\t struct mlxsw_sp_nexthop *nh,\n@@ -4374,7 +4425,10 @@ mlxsw_sp_dev_rif_type(const struct mlxsw_sp *mlxsw_sp,\n {\n \tenum mlxsw_sp_fid_type type;\n \n-\t/* RIF type is derived from the type of the underlying FID */\n+\tif (mlxsw_sp_netdev_ipip_type(mlxsw_sp, dev, NULL))\n+\t\treturn MLXSW_SP_RIF_TYPE_IPIP_LB;\n+\n+\t/* Otherwise RIF type is derived from the type of the underlying FID. */\n \tif (is_vlan_dev(dev) && netif_is_bridge_master(vlan_dev_real_dev(dev)))\n \t\ttype = MLXSW_SP_FID_TYPE_8021Q;\n \telse if (netif_is_bridge_master(dev) && br_vlan_enabled(dev))\n@@ -5164,10 +5218,104 @@ static const struct mlxsw_sp_rif_ops mlxsw_sp_rif_fid_ops = {\n \t.fid_get\t\t= mlxsw_sp_rif_fid_fid_get,\n };\n \n+static struct mlxsw_sp_rif_ipip_lb *\n+mlxsw_sp_rif_ipip_lb_rif(struct mlxsw_sp_rif *rif)\n+{\n+\treturn container_of(rif, struct mlxsw_sp_rif_ipip_lb, common);\n+}\n+\n+static void\n+mlxsw_sp_rif_ipip_lb_setup(struct mlxsw_sp_rif *rif,\n+\t\t\t const struct mlxsw_sp_rif_params *params)\n+{\n+\tstruct mlxsw_sp_rif_params_ipip_lb *params_lb;\n+\tstruct mlxsw_sp_rif_ipip_lb *rif_lb;\n+\n+\tparams_lb = container_of(params, struct mlxsw_sp_rif_params_ipip_lb,\n+\t\t\t\t common);\n+\trif_lb = mlxsw_sp_rif_ipip_lb_rif(rif);\n+\trif_lb->lb_config = params_lb->lb_config;\n+}\n+\n+static int\n+mlxsw_sp_rif_ipip_lb_op(struct mlxsw_sp_rif_ipip_lb *lb_rif,\n+\t\t\tstruct mlxsw_sp_vr *ul_vr, bool enable)\n+{\n+\tstruct mlxsw_sp_rif_ipip_lb_config lb_cf = lb_rif->lb_config;\n+\tstruct mlxsw_sp_rif *rif = &lb_rif->common;\n+\tstruct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp;\n+\tchar ritr_pl[MLXSW_REG_RITR_LEN];\n+\tu32 saddr4;\n+\n+\tswitch (lb_cf.ul_protocol) {\n+\tcase MLXSW_SP_L3_PROTO_IPV4:\n+\t\tsaddr4 = be32_to_cpu(lb_cf.saddr.addr4);\n+\t\tmlxsw_reg_ritr_pack(ritr_pl, enable, MLXSW_REG_RITR_LOOPBACK_IF,\n+\t\t\t\t rif->rif_index, rif->vr_id, rif->dev->mtu);\n+\t\tmlxsw_reg_ritr_loopback_ipip4_pack(ritr_pl, lb_cf.lb_ipipt,\n+\t\t\t MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,\n+\t\t\t ul_vr->id, saddr4, lb_cf.okey);\n+\t\tbreak;\n+\n+\tcase MLXSW_SP_L3_PROTO_IPV6:\n+\t\treturn -EAFNOSUPPORT;\n+\t}\n+\n+\treturn mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl);\n+}\n+\n+static int\n+mlxsw_sp_rif_ipip_lb_configure(struct mlxsw_sp_rif *rif)\n+{\n+\tstruct mlxsw_sp_rif_ipip_lb *lb_rif = mlxsw_sp_rif_ipip_lb_rif(rif);\n+\tu32 ul_tb_id = mlxsw_sp_ipip_dev_ul_tb_id(rif->dev);\n+\tstruct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp;\n+\tstruct mlxsw_sp_vr *ul_vr;\n+\tint err;\n+\n+\tul_vr = mlxsw_sp_vr_get(mlxsw_sp, ul_tb_id);\n+\tif (IS_ERR(ul_vr))\n+\t\treturn PTR_ERR(ul_vr);\n+\n+\terr = mlxsw_sp_rif_ipip_lb_op(lb_rif, ul_vr, true);\n+\tif (err)\n+\t\tgoto err_loopback_op;\n+\n+\tlb_rif->ul_vr_id = ul_vr->id;\n+\t++ul_vr->rif_count;\n+\treturn 0;\n+\n+err_loopback_op:\n+\tmlxsw_sp_vr_put(ul_vr);\n+\treturn err;\n+}\n+\n+static void mlxsw_sp_rif_ipip_lb_deconfigure(struct mlxsw_sp_rif *rif)\n+{\n+\tstruct mlxsw_sp_rif_ipip_lb *lb_rif = mlxsw_sp_rif_ipip_lb_rif(rif);\n+\tstruct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp;\n+\tstruct mlxsw_sp_vr *ul_vr;\n+\n+\tul_vr = &mlxsw_sp->router->vrs[lb_rif->ul_vr_id];\n+\tmlxsw_sp_rif_ipip_lb_op(lb_rif, ul_vr, false);\n+\n+\t--ul_vr->rif_count;\n+\tmlxsw_sp_vr_put(ul_vr);\n+}\n+\n+static const struct mlxsw_sp_rif_ops mlxsw_sp_rif_ipip_lb_ops = {\n+\t.type\t\t\t= MLXSW_SP_RIF_TYPE_IPIP_LB,\n+\t.rif_size\t\t= sizeof(struct mlxsw_sp_rif_ipip_lb),\n+\t.setup = mlxsw_sp_rif_ipip_lb_setup,\n+\t.configure\t\t= mlxsw_sp_rif_ipip_lb_configure,\n+\t.deconfigure\t\t= mlxsw_sp_rif_ipip_lb_deconfigure,\n+};\n+\n static const struct mlxsw_sp_rif_ops *mlxsw_sp_rif_ops_arr[] = {\n \t[MLXSW_SP_RIF_TYPE_SUBPORT]\t= &mlxsw_sp_rif_subport_ops,\n \t[MLXSW_SP_RIF_TYPE_VLAN]\t= &mlxsw_sp_rif_vlan_ops,\n \t[MLXSW_SP_RIF_TYPE_FID]\t\t= &mlxsw_sp_rif_fid_ops,\n+\t[MLXSW_SP_RIF_TYPE_IPIP_LB]\t= &mlxsw_sp_rif_ipip_lb_ops,\n };\n \n static int mlxsw_sp_rifs_init(struct mlxsw_sp *mlxsw_sp)\ndiff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h\nindex 67c6c1d..a5732aa 100644\n--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h\n+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h\n@@ -36,12 +36,25 @@\n #define _MLXSW_ROUTER_H_\n \n #include \"spectrum.h\"\n+#include \"reg.h\"\n \n enum mlxsw_sp_l3proto {\n \tMLXSW_SP_L3_PROTO_IPV4,\n \tMLXSW_SP_L3_PROTO_IPV6,\n };\n \n+union mlxsw_sp_l3addr {\n+\t__be32 addr4;\n+\tstruct in6_addr addr6;\n+};\n+\n+struct mlxsw_sp_rif_ipip_lb_config {\n+\tenum mlxsw_reg_ritr_loopback_ipip_type lb_ipipt;\n+\tu32 okey;\n+\tenum mlxsw_sp_l3proto ul_protocol; /* Underlay. */\n+\tunion mlxsw_sp_l3addr saddr;\n+};\n+\n enum mlxsw_sp_rif_counter_dir {\n \tMLXSW_SP_RIF_COUNTER_INGRESS,\n \tMLXSW_SP_RIF_COUNTER_EGRESS,\n", "prefixes": [ "net-next", "v2", "11/21" ] }