Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/809093/?format=api
{ "id": 809093, "url": "http://patchwork.ozlabs.org/api/patches/809093/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170902152126.17286-11-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": "<20170902152126.17286-11-jiri@resnulli.us>", "list_archive_url": null, "date": "2017-09-02T15:21:15", "name": "[net-next,10/21] mlxsw: spectrum_router: Introduce loopback RIFs", "commit_ref": null, "pull_url": null, "state": "superseded", "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/20170902152126.17286-11-jiri@resnulli.us/mbox/", "series": [ { "id": 1159, "url": "http://patchwork.ozlabs.org/api/series/1159/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=1159", "date": "2017-09-02T15:21:05", "name": "mlxsw: Offloading GRE tunnels", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1159/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/809093/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/809093/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=\"sxH6WzMi\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xl0Gp6SGmz9sRY\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSun, 3 Sep 2017 01:22:42 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752828AbdIBPWg (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSat, 2 Sep 2017 11:22:36 -0400", "from mail-wr0-f195.google.com ([209.85.128.195]:38527 \"EHLO\n\tmail-wr0-f195.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752741AbdIBPVq (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Sat, 2 Sep 2017 11:21:46 -0400", "by mail-wr0-f195.google.com with SMTP id j3so1342069wrb.5\n\tfor <netdev@vger.kernel.org>; Sat, 02 Sep 2017 08:21:45 -0700 (PDT)", "from localhost (jirka.pirko.cz. [84.16.102.26])\n\tby smtp.gmail.com with ESMTPSA id\n\tc56sm5387332wrc.1.2017.09.02.08.21.43\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSat, 02 Sep 2017 08:21:43 -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=sxH6WzMi+3jQGSPwqo7sr+av6kbAr8nl0gjnfYikF8jag4CBe+ieEI6pcOIna2mF10\n\tGYuzbrWMj+GZdJzCJ/Ee/5iDVl3iXuNyW7OE0HNayxpmzoNcjwG6DvcfZHIeJdivCbZI\n\tNmGxfHOB8sAbxH5FHF1zemcabwwiIjRCP99YT1pZwcjZJbUJXo75OHYfBwboDm9x/SiL\n\tneYF6qJiMZjCsosz8SMsIun7LBu4ACCdfxpvgHlR7O3jfJvcWFiyiepge3a/8PQLXuYd\n\tZpMm7Mt42unJ8Z08xv4dOtK/eURtp2Htx3VWfQGeBJfeY36QAwGkGMd9fB4Cd429mU9x\n\tmLbQ==", "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=pm0QQt0ELTOokLJVPF7TrfcA28eoIhc6mTjb/hmkr2ybpYJ8HOGX6E2wHwkZwTcct9\n\tMQZefT+iSnWJmPcl7THx2HvVcXCJluHPUGd9m27Z3javx99Qvcuchx6B7368KlbXqNMP\n\tkuYMft2qqX55hPRSbGINLJRUYV/TJhyhJZXWGWoqOCqikSJ3jBzl2JoX2mUnq26rNmeI\n\tbotIIDe7XGY5Sf8nYIfw3vU8QsfL5ibLw4pL/21RyDHCjYXD8uo5z3PNmQN4ZLz5aqP0\n\tF85OWbmk0sL9OTeGKrQh5BMd2jyaR1f7pUV5Yw49UX2V6xzzEzvrJn5l9jZfChr0bVT2\n\tKz6g==", "X-Gm-Message-State": "AHPjjUg+L4taYVqUzxkchgRDVNAvsbYf47KJuLypKfDjPSoiyAIY3j7U\n\teK9guMXrEKOn+R17oos=", "X-Google-Smtp-Source": "ADKCNb57JZh4zd5bFESCBVNNzeFj09KF8zo1BFBNBZQpW2bJHztncxXfsZAq81pLml5EF69V9lR0rA==", "X-Received": "by 10.223.167.7 with SMTP id c7mr3353638wrd.300.1504365704289;\n\tSat, 02 Sep 2017 08:21:44 -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 10/21] mlxsw: spectrum_router: Introduce loopback\n\tRIFs", "Date": "Sat, 2 Sep 2017 17:21:15 +0200", "Message-Id": "<20170902152126.17286-11-jiri@resnulli.us>", "X-Mailer": "git-send-email 2.9.3", "In-Reply-To": "<20170902152126.17286-1-jiri@resnulli.us>", "References": "<20170902152126.17286-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", "10/21" ] }