From patchwork Mon Jan 28 23:28:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1032951 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="htV3KcAS"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43pvYF2jcCz9sBZ for ; Wed, 30 Jan 2019 05:05:21 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728751AbfA2SFU (ORCPT ); Tue, 29 Jan 2019 13:05:20 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42396 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727907AbfA2SFT (ORCPT ); Tue, 29 Jan 2019 13:05:19 -0500 Received: by mail-pf1-f193.google.com with SMTP id 64so10008847pfr.9 for ; Tue, 29 Jan 2019 10:05:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=r2V46+GOCWU8y6KKCzf3heZHYZVbmMjvLyAi1Jt4FKc=; b=htV3KcASQIltQZE8wmfZaA1tvXgH2yqKUztYO+pxm7VWblIqpXhXVC6+cKYX5pB1fz Z147fH3JCP4m5fNFObLQ41hYXCRwHiwLdxRtzvJ5JzAUT7RiYY1GG5wqncnSKEQ02J7w Dl+ihKZSb71Ty7qFX/ocH00lDnNEL0fbE6Ry11FTaHaHQPWdLI8RSxm4SY2Rv8Xr8KBJ f8FkS0yQ7O08//hm/JbuYPRvQ5oAYc+xweGrfI3ALaN4/kI6/Erz1wP5hAPNArBqTaJu y0u5/CMWep2LLEJUhPMgKdXblJCZJqZRc6eY0uvYcGPp2BOLAp9XCOGS/zIqhdy8XX3R bS5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=r2V46+GOCWU8y6KKCzf3heZHYZVbmMjvLyAi1Jt4FKc=; b=ROnhsD1ABJqaNAQ47Kk+M17+PAmIXgBo/4MEt3jiGjfwmbNHHcsB8vbcZydScVBzep lsmNJ14U3jJcr1i2K7qdzQoSOotK7lpPa9BAlNLigc6kQXypf59H1+TVdgBZy1iNTAOs L+wFgYaqfxOfipN3Wns6+QYh6sTqRq06ky2me1dC10D3ihOQcMX6S90OKB+9BIBRog1V udz7wSH2HDk1gpzO2ddLiNorY+IUspR354obk2hUgAkzbcuAvEzd6ah63cOf7bCxPoWh JesTs80dt2KBpPzGbfQcFjcFBk2ZlE4l5cr7OmPooaSvnin+RycPG6tRMSvT+uvyPmJ2 rtPA== X-Gm-Message-State: AJcUukfV00dO7ACJOGhOpzWz8MbShCvTyOzBQEJMBChzourECZREdMlY wmPfCCvx9MCzgIq6zqxCrJI= X-Google-Smtp-Source: ALg8bN452g+777RDQHBlfEjStuNliKLEPeYCyQCxEgYd8vQpMH/Nn+sXVOyd0WwQbzgBtzGSG6YKBA== X-Received: by 2002:a63:d655:: with SMTP id d21mr24605348pgj.280.1548785119266; Tue, 29 Jan 2019 10:05:19 -0800 (PST) Received: from local.opencloud.tech.localdomain ([106.120.33.223]) by smtp.gmail.com with ESMTPSA id b2sm65284351pfm.3.2019.01.29.10.05.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 10:05:18 -0800 (PST) From: xiangxia.m.yue@gmail.com To: saeedm@mellanox.com, gerlitz.or@gmail.com, davem@davemloft.net Cc: netdev@vger.kernel.org, Tonghao Zhang , Hadar Hen Zion Subject: [PATCH net v5 1/2] net/mlx5e: Update hw flows when encap source mac changed Date: Mon, 28 Jan 2019 15:28:05 -0800 Message-Id: <1548718086-20924-1-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tonghao Zhang When we offload tc filters to hardware, hardware flows can be updated when mac of encap destination ip is changed. But we ignore one case, that the mac of local encap ip can be changed too, so we should also update them. To fix it, add route_dev in mlx5e_encap_entry struct to save the local encap netdevice, and when mac changed, kernel will flush all the neighbour on the netdevice and send NETEVENT_NEIGH_UPDATE event. The mlx5 driver will delete the flows and add them when neighbour available again. Fixes: 232c001398ae ("net/mlx5e: Add support to neighbour update flow") Cc: Hadar Hen Zion Signed-off-by: Tonghao Zhang Reviewed-by: Or Gerlitz Acked-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 4 ++++ drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 1 + 3 files changed, 7 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c index 046948e..114e0a2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c @@ -256,6 +256,7 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, e->m_neigh.family = n->ops->family; memcpy(&e->m_neigh.dst_ip, n->primary_key, n->tbl->key_len); e->out_dev = out_dev; + e->route_dev = route_dev; /* It's important to add the neigh to the hash table before checking * the neigh validity state. So if we'll get a notification, in case the @@ -369,6 +370,7 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, e->m_neigh.family = n->ops->family; memcpy(&e->m_neigh.dst_ip, n->primary_key, n->tbl->key_len); e->out_dev = out_dev; + e->route_dev = route_dev; /* It's importent to add the neigh to the hash table before checking * the neigh validity state. So if we'll get a notification, in case the diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c index 96cc0c6..c4b9073 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c @@ -594,6 +594,10 @@ static void mlx5e_rep_update_flows(struct mlx5e_priv *priv, if (neigh_connected && !(e->flags & MLX5_ENCAP_ENTRY_VALID)) { ether_addr_copy(e->h_dest, ha); ether_addr_copy(eth->h_dest, ha); + /* Update the encap source mac, in case that we delete + * the flows when encap source mac changed. + */ + ether_addr_copy(eth->h_source, e->route_dev->dev_addr); mlx5e_tc_encap_flows_add(priv, e); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h index edd7228..36eafc8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h @@ -148,6 +148,7 @@ struct mlx5e_encap_entry { unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ struct net_device *out_dev; + struct net_device *route_dev; int tunnel_type; int tunnel_hlen; int reformat_type; From patchwork Mon Jan 28 23:28:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1032952 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TvF1CoIl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43pvYW4NGcz9sBZ for ; Wed, 30 Jan 2019 05:05:35 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728914AbfA2SFe (ORCPT ); Tue, 29 Jan 2019 13:05:34 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42406 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727607AbfA2SFd (ORCPT ); Tue, 29 Jan 2019 13:05:33 -0500 Received: by mail-pg1-f194.google.com with SMTP id d72so9061778pga.9 for ; Tue, 29 Jan 2019 10:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MRjewqtNEtrdL1DtjkL8Iii7l5DOc3mub9TOYy9HG3o=; b=TvF1CoIl7G0Q+HyTiXq8Fl3LwGJ21EAX3tlSTHKB5mYuqqj/sdwH2TB+wu7l1EnwCM S+4euShQFPvDutLodQR628QlylFebZabjaqfKsLKdHWMBpkOHI/1zjkDI510buJFc/wc ugOxGCxvnl1A6K8GL4Ll8v5O1SaoaRmGVIOmvrCmTZoVk4ckSinJraEREXKSvng+hT9P 32SAw0+WY7qpBIVtPEgjOKDUFNhAHqsukufSgO3LqkjChNtHwWaOjPuFIQsUDK1PNvYj NColvrkw0Au6RC7B0clazLfCz+/PrWV0f/Dukl7nhLDAy2ex7yqwymyZzb0HzlRKdmcU L1Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MRjewqtNEtrdL1DtjkL8Iii7l5DOc3mub9TOYy9HG3o=; b=KF+gN5gMcXE3V6rnZGTF19TDysCnl8DJrgpc+5pCqI5Ew7YMB6wbF8JWvQjtRSBT0O C8STZQMJqqhJu18xWqZIl8+o6mtG90gBtHH7H0yePf74bXtWWdCb+NhiE+vOi/Gujooh KSyKvmwoYUVZkhL+71VknxZ88iIY3k7NpdgeXeHgfJy/6STcP9WUF5WT62FzBnlIVDu/ nVtowcFeKVX1cGOV2KFAssjSsP6nJpz4m3W5/hr8pCCr1oVHYoZGEi3jSoJshzXwIJS4 B+cGxQtMLp2W1gPJ4MKR1Opw7tqBFnIxG0uKf4Iz2uD6AjCzgueRVJpHASArifKbzL6d tyaw== X-Gm-Message-State: AJcUukdC//yzl6dzv6epJFjnRQEyI16i09w+wMebW+JLfGbIE2MzLm4n BErqxWUUOz1qBAUY/zy469E= X-Google-Smtp-Source: ALg8bN6oyqaEt7bm3yBRsZR12CJ4M1fICxh1+brGKCeDownc0iM9cGzbtpOyBgqabscv14jVALWqhQ== X-Received: by 2002:a63:374e:: with SMTP id g14mr25112828pgn.59.1548785132923; Tue, 29 Jan 2019 10:05:32 -0800 (PST) Received: from local.opencloud.tech.localdomain ([106.120.33.223]) by smtp.gmail.com with ESMTPSA id b2sm65284351pfm.3.2019.01.29.10.05.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 10:05:32 -0800 (PST) From: xiangxia.m.yue@gmail.com To: saeedm@mellanox.com, gerlitz.or@gmail.com, davem@davemloft.net Cc: netdev@vger.kernel.org, Tonghao Zhang , Or Gerlitz Subject: [PATCH net v5 2/2] net/mlx5e: Don't overwrite pedit action when multiple pedit used Date: Mon, 28 Jan 2019 15:28:06 -0800 Message-Id: <1548718086-20924-2-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1548718086-20924-1-git-send-email-xiangxia.m.yue@gmail.com> References: <1548718086-20924-1-git-send-email-xiangxia.m.yue@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Tonghao Zhang In some case, we may use multiple pedit actions to modify packets. The command shown as below: the last pedit action is effective. $ tc filter add dev netdev_rep parent ffff: protocol ip prio 1 \ flower skip_sw ip_proto icmp dst_ip 3.3.3.3 \ action pedit ex munge ip dst set 192.168.1.100 pipe \ action pedit ex munge eth src set 00:00:00:00:00:01 pipe \ action pedit ex munge eth dst set 00:00:00:00:00:02 pipe \ action csum ip pipe \ action tunnel_key set src_ip 1.1.1.100 dst_ip 1.1.1.200 dst_port 4789 id 100 \ action mirred egress redirect dev vxlan0 To fix it, we add max_mod_hdr_actions to mlx5e_tc_flow_parse_attr struction, max_mod_hdr_actions will store the max pedit action number we support and num_mod_hdr_actions indicates how many pedit action we used, and store all pedit action to mod_hdr_actions. Fixes: d79b6df6b10a ("net/mlx5e: Add parsing of TC pedit actions to HW format") Cc: Or Gerlitz Signed-off-by: Tonghao Zhang Reviewed-by: Or Gerlitz Acked-by: Saeed Mahameed --- v3: Remove the unnecessary init. v2: Fix comment message and change tag from net-next to net. --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index cae6c6d..a21724d0 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -128,6 +128,7 @@ struct mlx5e_tc_flow_parse_attr { struct net_device *filter_dev; struct mlx5_flow_spec spec; int num_mod_hdr_actions; + int max_mod_hdr_actions; void *mod_hdr_actions; int mirred_ifindex[MLX5_MAX_FLOW_FWD_VPORTS]; }; @@ -1934,9 +1935,9 @@ struct mlx5_fields { OFFLOAD(UDP_DPORT, 2, udp.dest, 0), }; -/* On input attr->num_mod_hdr_actions tells how many HW actions can be parsed at - * max from the SW pedit action. On success, it says how many HW actions were - * actually parsed. +/* On input attr->max_mod_hdr_actions tells how many HW actions can be parsed at + * max from the SW pedit action. On success, attr->num_mod_hdr_actions + * says how many HW actions were actually parsed. */ static int offload_pedit_fields(struct pedit_headers *masks, struct pedit_headers *vals, @@ -1960,9 +1961,11 @@ static int offload_pedit_fields(struct pedit_headers *masks, add_vals = &vals[TCA_PEDIT_KEY_EX_CMD_ADD]; action_size = MLX5_UN_SZ_BYTES(set_action_in_add_action_in_auto); - action = parse_attr->mod_hdr_actions; - max_actions = parse_attr->num_mod_hdr_actions; - nactions = 0; + action = parse_attr->mod_hdr_actions + + parse_attr->num_mod_hdr_actions * action_size; + + max_actions = parse_attr->max_mod_hdr_actions; + nactions = parse_attr->num_mod_hdr_actions; for (i = 0; i < ARRAY_SIZE(fields); i++) { f = &fields[i]; @@ -2073,7 +2076,7 @@ static int alloc_mod_hdr_actions(struct mlx5e_priv *priv, if (!parse_attr->mod_hdr_actions) return -ENOMEM; - parse_attr->num_mod_hdr_actions = max_actions; + parse_attr->max_mod_hdr_actions = max_actions; return 0; } @@ -2119,9 +2122,11 @@ static int parse_tc_pedit_action(struct mlx5e_priv *priv, goto out_err; } - err = alloc_mod_hdr_actions(priv, a, namespace, parse_attr); - if (err) - goto out_err; + if (!parse_attr->mod_hdr_actions) { + err = alloc_mod_hdr_actions(priv, a, namespace, parse_attr); + if (err) + goto out_err; + } err = offload_pedit_fields(masks, vals, parse_attr, extack); if (err < 0)