From patchwork Mon Jan 3 11:44:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Blakey X-Patchwork-Id: 12702505 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBB3FC433EF for ; Mon, 3 Jan 2022 11:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231671AbiACLpI (ORCPT ); Mon, 3 Jan 2022 06:45:08 -0500 Received: from mail-bn7nam10on2072.outbound.protection.outlook.com ([40.107.92.72]:22401 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229788AbiACLpG (ORCPT ); Mon, 3 Jan 2022 06:45:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nsnxtebOSu7EOUNjZgZLt6yHyHVegR5B0l1RlJn2NbypbCn+D55Vfntr+2jDy0CIGKSGaMRh4jUVq4QACHNA0Xc43SjiVZ+0HNbpczV/ph3eHPC3Ll6waahDJHvHvuue4OYEVj/IhWDmr0ZCpiXLEhFRUv/SWAHkdmJYSVw7O5g6zuV237+3baXSb3uaIj5zkIcSAae6+S2GkXmHaMxBYq7SJzu8/35oFmoIG6zG8KuJk1Gnf8et7rexUyakG2WXIQqblAiHg3PpKDpShIET7egSMIcwB/nRmMBXwhXOcH9TJlmppnZD700+FyUetL+WGASqnLOYVKS2s0EeRSRkYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F3SJBsHeXDsRQmalvxRUU8i2NXM6ouqLD1RV6Y5qqcI=; b=dN+YxipHiG+kEmxkh7vpsFaqM3bKAEpvaGsvggzjTPxQSRRYU2AQjV4s9taSDlp/MoyBvmXCVUqnc2NbgD3R9MjwV6bSD20pye4mQCpw7Kkr/bSr1zQSyjhtJ6kuQPIUIIPy2A1BodX80xXidYA5VP8wT4B2xuPJpfjtvNlIkwo5LUMUBsc2dx8gHi7FVibl8wHwwqbgjpPeJwFmHhS/2aeJdEnIHuSfaslf2cPH99U20FIwevFFfTBuD7BBOzSeqQz9WQaW7Zli1LwvksRlkEieiCGRGrh1Eq3u1dZR3m/y0dC1b8+gUDBpiKjauQgGyQiuMAz4FnhC1EtQ/z55Fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=ovn.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F3SJBsHeXDsRQmalvxRUU8i2NXM6ouqLD1RV6Y5qqcI=; b=B345/7HBkrWm7ZXrFCVxHatG4HT4bowORNPgNUyUKk4UFHHB6iGPrDkms+hX3BaYznrm1JiwkwYX1HpLO2TUxNluI8v0jxlgI8n2YdVqVG1lQZqBqERLAZBOryffyLhgf5O0jwVGWfD4J8Rs26DkOZJycRL9UCroU6hLfGe/pkm4Z0Mbr6mXwRRlcANsaRvBXLmnmBeYQd4ORPis5sVWJmPlL7a3Vj2DuqEDcFSDWuY3j+6wRBR4vcwFpDhPPvA3b9vRkRzzr1uCNG3KDQRsC+PzyCcUvu5/9w00D8xe4iWL00XKlyx7Td7PFPOvMPSbpM5NsZQB+nyGenRQZNl/5Q== Received: from BN6PR16CA0025.namprd16.prod.outlook.com (2603:10b6:405:14::11) by DM6PR12MB4944.namprd12.prod.outlook.com (2603:10b6:5:1ba::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14; Mon, 3 Jan 2022 11:45:03 +0000 Received: from BN8NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:405:14:cafe::c6) by BN6PR16CA0025.outlook.office365.com (2603:10b6:405:14::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14 via Frontend Transport; Mon, 3 Jan 2022 11:45:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by BN8NAM11FT052.mail.protection.outlook.com (10.13.177.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4844.14 via Frontend Transport; Mon, 3 Jan 2022 11:45:03 +0000 Received: from HQMAIL101.nvidia.com (172.20.187.10) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 3 Jan 2022 11:45:02 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 3 Jan 2022 11:45:02 +0000 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (172.20.187.6) by mail.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 3 Jan 2022 11:44:59 +0000 From: Paul Blakey To: Paul Blakey , , , Saeed Mahameed , Cong Wang , Jamal Hadi Salim , "Pravin B Shelar" , , Jiri Pirko , Jakub Kicinski , Marcelo Ricardo Leitner CC: Oz Shlomo , Vlad Buslov , Roi Dayan Subject: [PATCH net-next 1/3] net/sched: act_ct: Fill offloading tuple iifidx Date: Mon, 3 Jan 2022 13:44:50 +0200 Message-ID: <20220103114452.406-2-paulb@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20220103114452.406-1-paulb@nvidia.com> References: <20220103114452.406-1-paulb@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a4e22a4-c504-4a0d-b4fe-08d9ceae7b36 X-MS-TrafficTypeDiagnostic: DM6PR12MB4944:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:189; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /T+SJJSbjh75QQwaJ+ERrCK3yu8GXRtrwB6fs+S+TTtwUk01kjYpTN0mLA+DLkZpjKMYHHmpYVtGScQRx/Ned2Z4TQfxGsbnmaU4hEcg206qhR+F47fY4h4PBlVBG4e4MY0p/cFjIoCG6YNFWC7svUKP/Sone+o5+QTmRVtd3FPfrH1lUSxq9Uh0//OuOIGoXAwikvxCQWdwMVKohfs1KjYPjS0ojMOKRwxHrUWH8dkuHRzs+wq5hyfHxcFzvlnCYRsSD0QrCnJFTtXz0fxttvBbU2FzVuMnJ2TwjUbqnDtmVg7DM5Ix4HIEEnHh+RZ4ZOkWkPPBaeEcPLxj83t5UaX4BZH5xvkQm8LVqsrHpc95Z8T7QjwTK0w1BWl0UYDW07WXWc0zHIuGgwFSIN5QzA5aC0TmcZzpcTh7h5NzKxSuv5O69+gU0342SiLeupujHmtLbkMgkacOnLCjHFU8wMqEL+Q8+YtSG36U7sQzc130vIRE9u4ays38gwhfZltTw9l7RGFIFvSKhxVH2d0x2AgXnp6Sjcf02Dw49gf67U6LDfc7bEoD+P8xKO6WTi6d79hMMRSf/o45zxbvdqnWeo7Oy45PwgyfnXoU3n9HYxiHSbIQFzjOufY0Q/nRS4XaJjBMqMAZ0LrfZc7V5LjIOCqXV8TKeqDggkJb9jNkcB7jFM2UgtmcC3dH4wZqJOzx/hWOY02t7c42n8rBJvg4XbTZDtak6xRnPSYt+p5gPGYhx6ES7pvRAQQ0B/rHvv/KG7WuQrey1zOatK7h2lpAWwyurokia1G/nWmDTAiRj1TfL75OhQHQUjhZJIrhzucz X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(4636009)(46966006)(40470700002)(36840700001)(26005)(186003)(70586007)(81166007)(5660300002)(8676002)(70206006)(316002)(6666004)(508600001)(4326008)(8936002)(107886003)(2616005)(54906003)(336012)(36860700001)(426003)(2906002)(110136005)(36756003)(1076003)(921005)(86362001)(83380400001)(47076005)(82310400004)(356005)(40460700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2022 11:45:03.4575 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a4e22a4-c504-4a0d-b4fe-08d9ceae7b36 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4944 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Driver offloading ct tuples can use the information of which devices received the packets that created the offloaded connections, to more efficiently offload them only to the relevant device. Add new act_ct nf conntrack extension, which is used to store the skb devices before offloading the connection, and then fill in the tuple iifindex so drivers can get the device via metadata dissector match. Signed-off-by: Oz Shlomo Signed-off-by: Paul Blakey --- include/net/netfilter/nf_conntrack_act_ct.h | 50 +++++++++++++++++++++ include/net/netfilter/nf_conntrack_extend.h | 4 ++ net/netfilter/nf_conntrack_core.c | 6 ++- net/sched/act_ct.c | 27 +++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 include/net/netfilter/nf_conntrack_act_ct.h diff --git a/include/net/netfilter/nf_conntrack_act_ct.h b/include/net/netfilter/nf_conntrack_act_ct.h new file mode 100644 index 000000000000..078d3c52c03f --- /dev/null +++ b/include/net/netfilter/nf_conntrack_act_ct.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _NF_CONNTRACK_ACT_CT_H +#define _NF_CONNTRACK_ACT_CT_H + +#include +#include +#include + +struct nf_conn_act_ct_ext { + int ifindex[IP_CT_DIR_MAX]; +}; + +static inline struct nf_conn_act_ct_ext *nf_conn_act_ct_ext_find(const struct nf_conn *ct) +{ +#if IS_ENABLED(CONFIG_NET_ACT_CT) + return nf_ct_ext_find(ct, NF_CT_EXT_ACT_CT); +#else + return NULL; +#endif +} + +static inline struct nf_conn_act_ct_ext *nf_conn_act_ct_ext_add(struct nf_conn *ct) +{ +#if IS_ENABLED(CONFIG_NET_ACT_CT) + struct nf_conn_act_ct_ext *act_ct = nf_ct_ext_find(ct, NF_CT_EXT_ACT_CT); + + if (act_ct) + return act_ct; + + act_ct = nf_ct_ext_add(ct, NF_CT_EXT_ACT_CT, GFP_ATOMIC); + return act_ct; +#else + return NULL; +#endif +} + +static inline void nf_conn_act_ct_ext_fill(struct sk_buff *skb, struct nf_conn *ct, + enum ip_conntrack_info ctinfo) +{ +#if IS_ENABLED(CONFIG_NET_ACT_CT) + struct nf_conn_act_ct_ext *act_ct_ext; + + act_ct_ext = nf_conn_act_ct_ext_find(ct); + if (dev_net(skb->dev) == &init_net && act_ct_ext) + act_ct_ext->ifindex[CTINFO2DIR(ctinfo)] = skb->dev->ifindex; +#endif +} + +#endif /* _NF_CONNTRACK_ACT_CT_H */ diff --git a/include/net/netfilter/nf_conntrack_extend.h b/include/net/netfilter/nf_conntrack_extend.h index e1e588387103..c7515d82ab06 100644 --- a/include/net/netfilter/nf_conntrack_extend.h +++ b/include/net/netfilter/nf_conntrack_extend.h @@ -27,6 +27,9 @@ enum nf_ct_ext_id { #endif #if IS_ENABLED(CONFIG_NETFILTER_SYNPROXY) NF_CT_EXT_SYNPROXY, +#endif +#if IS_ENABLED(CONFIG_NET_ACT_CT) + NF_CT_EXT_ACT_CT, #endif NF_CT_EXT_NUM, }; @@ -40,6 +43,7 @@ enum nf_ct_ext_id { #define NF_CT_EXT_TIMEOUT_TYPE struct nf_conn_timeout #define NF_CT_EXT_LABELS_TYPE struct nf_conn_labels #define NF_CT_EXT_SYNPROXY_TYPE struct nf_conn_synproxy +#define NF_CT_EXT_ACT_CT_TYPE struct nf_conn_act_ct_ext /* Extensions: optional stuff which isn't permanently in struct. */ struct nf_ct_ext { diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index d7e313548066..01d6589fba6e 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -2626,7 +2627,7 @@ int nf_conntrack_set_hashsize(const char *val, const struct kernel_param *kp) static __always_inline unsigned int total_extension_size(void) { /* remember to add new extensions below */ - BUILD_BUG_ON(NF_CT_EXT_NUM > 9); + BUILD_BUG_ON(NF_CT_EXT_NUM > 10); return sizeof(struct nf_ct_ext) + sizeof(struct nf_conn_help) @@ -2649,6 +2650,9 @@ static __always_inline unsigned int total_extension_size(void) #endif #if IS_ENABLED(CONFIG_NETFILTER_SYNPROXY) + sizeof(struct nf_conn_synproxy) +#endif +#if IS_ENABLED(CONFIG_NET_ACT_CT) + + sizeof(struct nf_conn_act_ct_ext) #endif ; }; diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index f9afb5abff21..ebdf7caf7084 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -32,6 +32,7 @@ #include #include #include +#include #include static struct workqueue_struct *act_ct_wq; @@ -56,6 +57,12 @@ static const struct rhashtable_params zones_params = { .automatic_shrinking = true, }; +static struct nf_ct_ext_type act_ct_extend __read_mostly = { + .len = sizeof(struct nf_conn_act_ct_ext), + .align = __alignof__(struct nf_conn_act_ct_ext), + .id = NF_CT_EXT_ACT_CT, +}; + static struct flow_action_entry * tcf_ct_flow_table_flow_action_get_next(struct flow_action *flow_action) { @@ -358,6 +365,7 @@ static void tcf_ct_flow_table_add(struct tcf_ct_flow_table *ct_ft, struct nf_conn *ct, bool tcp) { + struct nf_conn_act_ct_ext *act_ct_ext; struct flow_offload *entry; int err; @@ -375,6 +383,14 @@ static void tcf_ct_flow_table_add(struct tcf_ct_flow_table *ct_ft, ct->proto.tcp.seen[1].flags |= IP_CT_TCP_FLAG_BE_LIBERAL; } + act_ct_ext = nf_conn_act_ct_ext_find(ct); + if (act_ct_ext) { + entry->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.iifidx = + act_ct_ext->ifindex[IP_CT_DIR_ORIGINAL]; + entry->tuplehash[FLOW_OFFLOAD_DIR_REPLY].tuple.iifidx = + act_ct_ext->ifindex[IP_CT_DIR_REPLY]; + } + err = flow_offload_add(&ct_ft->nf_ft, entry); if (err) goto err_add; @@ -1027,6 +1043,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, if (!ct) goto out_push; nf_ct_deliver_cached_events(ct); + nf_conn_act_ct_ext_fill(skb, ct, ctinfo); err = tcf_ct_act_nat(skb, ct, ctinfo, p->ct_action, &p->range, commit); if (err != NF_ACCEPT) @@ -1036,6 +1053,9 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, tcf_ct_act_set_mark(ct, p->mark, p->mark_mask); tcf_ct_act_set_labels(ct, p->labels, p->labels_mask); + if (!nf_ct_is_confirmed(ct)) + nf_conn_act_ct_ext_add(ct); + /* This will take care of sending queued events * even if the connection is already confirmed. */ @@ -1583,10 +1603,16 @@ static int __init ct_init_module(void) if (err) goto err_register; + err = nf_ct_extend_register(&act_ct_extend); + if (err) + goto err_register_extend; + static_branch_inc(&tcf_frag_xmit_count); return 0; +err_register_extend: + tcf_unregister_action(&act_ct_ops, &ct_net_ops); err_register: tcf_ct_flow_tables_uninit(); err_tbl_init: @@ -1597,6 +1623,7 @@ static int __init ct_init_module(void) static void __exit ct_cleanup_module(void) { static_branch_dec(&tcf_frag_xmit_count); + nf_ct_extend_unregister(&act_ct_extend); tcf_unregister_action(&act_ct_ops, &ct_net_ops); tcf_ct_flow_tables_uninit(); destroy_workqueue(act_ct_wq); From patchwork Mon Jan 3 11:44:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Blakey X-Patchwork-Id: 12702506 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4D8FC433EF for ; Mon, 3 Jan 2022 11:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231327AbiACLpQ (ORCPT ); Mon, 3 Jan 2022 06:45:16 -0500 Received: from mail-dm6nam11on2083.outbound.protection.outlook.com ([40.107.223.83]:53837 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229788AbiACLpL (ORCPT ); Mon, 3 Jan 2022 06:45:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fShdu0i3HZT8x+75ItDNLt3j3YUtz0aTnWV6ukizYDu3q9nadbn7jUb14AoReIzJhaGDcPOYCXFteKQxz3G5gJYSLJ3XfmoBik0mk6LLoC/sxhvA6kOcv4Y+elfq/FO2DMFA7Ugtr/HzeQVogmqtdq7RQoZiIPF/lxPZ0zolO3/bvN4EXaq4nBfVK9Bw35Kew8kn/nQEH/kXKEaC1O5WHC0cMotQq1P+XGet76nLvtZFb2frkFWsr69N2oXVIsiahDMssl49im4RxEdlpJknSlT4emULolHkRraHqWCtY0MGlttoCthChzQgg5OsdR49a0/GuXFuTlYjrzYOf2WB0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zc/qofjYh38MvpBm306Y6CPgaY0ivumdYrENlOuFrbk=; b=MA4qGlIXuryJTtD/r4ddSwVaCjuDz433Mlsaj0htVrlEbTItxBAJIuJGpjq0Xj83nqqtwHFOrKIdV6LAsFS4BLbp+m0oUEEKADZzGtvmozngPT2lC7x+AVVMLKcOuOcque0qiRqy5mm795vqc7y/AWNSbODU5u6/xRF5PRRW+31Yo+UKBZKd6P6APFGVyUuyMCpnS+o9ODwzraqoipW526ORwRlhV3f8bWxW31L+cgE2VMhgbiF0MxeLB/lxigHOXq3r0PMZqD7CYp2pcxLUWN6HtlkmE9ckxiRmZXTqs21J1Jk2xb8hWEMwvlyANacxb4JhuZwtVUlX+yUmw+Z5hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=ovn.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zc/qofjYh38MvpBm306Y6CPgaY0ivumdYrENlOuFrbk=; b=rYKFlhGVeCq53rwpWcVV4NTsNWjbpmp+ROkJq8iM9hzQ/InWm2sTsF13IUxIT7tuig93h8YB1or9J80lJgPWQ/TNifQgAOjf4Xfb4xc2RVuqWmo/HXWUFRZn/QTVVQ2yoAxqn1C8cUeXyAPT+zLHd+W8egEd18KH5gtkW4V5Ym1B4clIOvtttY514LsC+uOslzris0cjnzPYTSMEGa7CYkqUsb8IqCxhOoZjnUCeGWl6Q/TtW0euKMftuGzGyhhU1OrEu8ppL5LTMqD52R1Qhe6rF7fz80vnKx3CtnQ9tVZxN10R7PBQLoi9h6QmRqnSS12+Tgz59oVtnUxDZfL0tw== Received: from DM3PR12CA0103.namprd12.prod.outlook.com (2603:10b6:0:55::23) by CH2PR12MB4006.namprd12.prod.outlook.com (2603:10b6:610:25::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.13; Mon, 3 Jan 2022 11:45:09 +0000 Received: from DM6NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:0:55:cafe::c5) by DM3PR12CA0103.outlook.office365.com (2603:10b6:0:55::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14 via Frontend Transport; Mon, 3 Jan 2022 11:45:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT057.mail.protection.outlook.com (10.13.172.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4844.14 via Frontend Transport; Mon, 3 Jan 2022 11:45:08 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 3 Jan 2022 11:45:06 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 3 Jan 2022 11:45:05 +0000 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (172.20.187.6) by mail.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 3 Jan 2022 11:45:02 +0000 From: Paul Blakey To: Paul Blakey , , , Saeed Mahameed , Cong Wang , Jamal Hadi Salim , "Pravin B Shelar" , , Jiri Pirko , Jakub Kicinski , Marcelo Ricardo Leitner CC: Oz Shlomo , Vlad Buslov , Roi Dayan Subject: [PATCH net-next 2/3] net: openvswitch: Fill act ct extension Date: Mon, 3 Jan 2022 13:44:51 +0200 Message-ID: <20220103114452.406-3-paulb@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20220103114452.406-1-paulb@nvidia.com> References: <20220103114452.406-1-paulb@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 60b9fefd-75db-45d1-dd5e-08d9ceae7e3f X-MS-TrafficTypeDiagnostic: CH2PR12MB4006:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:128; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u0s3RqUfrQN55Rkp3CVtV821QAS38+2R32Rn28DPMms/S7EbXgT4mItjAjj9BytYXRKNz53DhCmxSPay/u5oDC0JR2zwC0QNdydvAzOPxOa8dtuMnBw2E+Yl7RZlW6Rb5v/wcKRPzaCa0CHWyjTPRmMh8ioHh6SAbJyp3n4ABGSTvJrRdzW66GksZpBsaI9ATRIIDzR/tXbCw8qkUz297Du80RC2Gz3sAjAEXiHWqPhNYIO/ljOkIMUzFd9daWe0swNfRB+J+Qmq1igle8Xx9VJHnEy6sqpAZYj3FzL9gp8UwGoLWQqy1Sm3gwLCfxIePYgqJGXHkdJ+bW5LDpzE3BmBHwKP8IrhNOGQrjFRiJEV5/LSmFPZzkPrJEHQ+lPyP4Ypc2FNZtZA8NVm4QxDI5mMWaxToqRBBuxnzWrd6y0QzhyGghUybjA+Mhpi0UjYqIin+Au+VDzVL8EcHnVRzvynHOs/BN7eZU2l6mtdmMoP/FhLeWgUx83lgTWH/sAjio3IBGQY1JZLsrf9kuQ9KqRXzWGTG1UM+D7kQj+gNwpcBnoZMmKvFIru80+7WZnO1isd36ln3Vf2OQSft5/auQ52VC4g1YmA6W5/LPNAVAyL0my+nZWHu3JqH2md8OjH/vDyQxn8bKt3LWx4yogC9j09w+WSgKMgWpzrsJbOGz42ujw3DHMsIChBxoZUd8sPQCgcLpTSbAjk+2kJ/x1e5uH3enrvyJQrNi/D/yPJMYwQIg3fDWhvVTqNZTWokCwDQ7beI6dEbKANx+u7e4ytJELXwm+OtQaZ6/dT4p5dZuJG8IhWEBTDBN9RV8yI5yxg X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(40470700002)(2616005)(1076003)(508600001)(107886003)(54906003)(426003)(336012)(316002)(81166007)(86362001)(356005)(47076005)(186003)(26005)(36860700001)(70586007)(36756003)(8936002)(40460700001)(921005)(8676002)(2906002)(110136005)(5660300002)(82310400004)(4326008)(6666004)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2022 11:45:08.5975 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60b9fefd-75db-45d1-dd5e-08d9ceae7e3f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4006 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org To give drivers the originating device information for optimized connection tracking offload, fill in act ct extension with ifindex from skb. Signed-off-by: Paul Blakey --- net/openvswitch/conntrack.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 1b5eae57bc90..13294a55073a 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -25,6 +25,8 @@ #include #endif +#include + #include "datapath.h" #include "conntrack.h" #include "flow.h" @@ -1045,6 +1047,8 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, */ nf_ct_set_tcp_be_liberal(ct); } + + nf_conn_act_ct_ext_fill(skb, ct, ctinfo); } return 0; @@ -1245,6 +1249,8 @@ static int ovs_ct_commit(struct net *net, struct sw_flow_key *key, &info->labels.mask); if (err) return err; + + nf_conn_act_ct_ext_add(ct); } else if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) && labels_nonzero(&info->labels.mask)) { err = ovs_ct_set_labels(ct, key, &info->labels.value, From patchwork Mon Jan 3 11:44:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Blakey X-Patchwork-Id: 12702507 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B97A3C433EF for ; Mon, 3 Jan 2022 11:45:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233072AbiACLpT (ORCPT ); Mon, 3 Jan 2022 06:45:19 -0500 Received: from mail-bn7nam10on2040.outbound.protection.outlook.com ([40.107.92.40]:33120 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231809AbiACLpP (ORCPT ); Mon, 3 Jan 2022 06:45:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B7tWVof+P1X8NiQEPFK4QJXIC9APm31P8fPL3ul90UZcYPerSgo6aQSaR/1s5oJbvIT05dFiCVuGwUxPX4jQkx3aSgPeI8W0CjlMX+wpg3C83hDahEcZyFE+7NJLmXhzn5jWpc7TPJ2bhzzGvn9krCQon1baA2r+Buxt8R0EZw2vp67Qr8GTg6dAsdzDmstSrBjoV3EaktMesnDmypgYTM5MXNWMsRp7DMlCB22v470xlSk/Uy+dEjCMccWRSB/Y2NEQJq7yRnKs+ztOOf3GGmfiwQdxIK1Wi/SiloKVoiBsB47EnWaju2bMIbLl8vBm6/oAZGj0GoQqzcFzceVpQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Uz/tKL2L80XwjWxRKoTmS22LDEh498cAXW6862kQbjc=; b=JHW1S7Ry9CYShsNFd4ChDCTqCAByjBF55VYfmHbDE8KF8knpC9/xhRNGj0yvLdwVgI/gZY4GMG6e2VWPE7l7AGJM6EbBToWA5z9chiI0J87rtcPGO08XSyeuZWxluCLp8sqXR6ctrG6yBxemLJ2SYz710DByO2XaqnuOgf+eVASEODY2y2Lh6n5AYSmxnjSB3X63LAPzGJGHd9hyWNMBWLSua6eHIJPDwyFfk2Z73bay2DwDZyXMaAYZIiPxsXS1CP3YjVndPLOurfkcD5cuAoYkrLhVfHSJeKKmqp/7MXYPB9OwgmrlLZic946/CzhBlJQJsKmlaNnR91g7fu1fsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=ovn.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uz/tKL2L80XwjWxRKoTmS22LDEh498cAXW6862kQbjc=; b=jA/m0dtS+t6cLNfmzK4xVadvAmCwZy3Hf9iB0J/tMvcSHZ4yFgc9Nrhq7jiUtAMK6VnSIDdQtE76/u35VRFGxkoN9zsVP98Hjgego9E/tFQAaBCxDjZ1IcQLBShJedbs6RBl3Yi2UdugucZct4uj0EafrS6ccKy9VAje3AXsDFtdIla/qy1NUjIJjzWufQ2+QQ4gOSRwE0ywhCgtempZcejGGJosdmrcJssBw12kdyU8l2Ei7XcJeMmeBTafvECMJ8PMhR/P80Y9fJ5LH9vhfiaYqO6GbhzefhxzQ9VInh6Uv3lB5m5kmqbQO7izQxopaU0c6SDrtodG2+4BZew3/A== Received: from DM5PR17CA0050.namprd17.prod.outlook.com (2603:10b6:3:13f::12) by DM6PR12MB3628.namprd12.prod.outlook.com (2603:10b6:5:3d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Mon, 3 Jan 2022 11:45:13 +0000 Received: from DM6NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:3:13f:cafe::f) by DM5PR17CA0050.outlook.office365.com (2603:10b6:3:13f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.13 via Frontend Transport; Mon, 3 Jan 2022 11:45:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by DM6NAM11FT062.mail.protection.outlook.com (10.13.173.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4844.14 via Frontend Transport; Mon, 3 Jan 2022 11:45:11 +0000 Received: from HQMAIL111.nvidia.com (172.20.187.18) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 3 Jan 2022 11:45:09 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 3 Jan 2022 11:45:09 +0000 Received: from reg-r-vrt-019-180.mtr.labs.mlnx (172.20.187.6) by mail.nvidia.com (172.20.187.12) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 3 Jan 2022 11:45:06 +0000 From: Paul Blakey To: Paul Blakey , , , Saeed Mahameed , Cong Wang , Jamal Hadi Salim , "Pravin B Shelar" , , Jiri Pirko , Jakub Kicinski , Marcelo Ricardo Leitner CC: Oz Shlomo , Vlad Buslov , Roi Dayan Subject: [PATCH net-next 3/3] net/mlx5: CT: Set flow source hint from provided tuple device Date: Mon, 3 Jan 2022 13:44:52 +0200 Message-ID: <20220103114452.406-4-paulb@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20220103114452.406-1-paulb@nvidia.com> References: <20220103114452.406-1-paulb@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11b86af0-3f6c-475e-7321-08d9ceae803a X-MS-TrafficTypeDiagnostic: DM6PR12MB3628:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1079; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u4naH+cwjb4sKzqVzR16d0TfKFbgX1Ag0TYnYtN37vjVqoZxuHcuNKBYzCkUrkluf+3uQZUQhSi5jIHxbyunDHstQhqJoxB4FLJXl1DVOajtNNynPsKwRHfmyM6TMyMz5lW43m5R8RQNd7SAw2xj7ukG2wcfha/yBX5os/A9Ar/lLliE3B6yYLgB7nuaRTOFkmtgkfeJ2R9RNWpfwaNFNl0nvSgfC5xgDQi3lClhAMTJQJU1EJvR6qSe7iMIXDsUgAHcVsrYN5d3S0n7QX7NIk5YT1CRaMOA4yQxndBL+8LiaYcQX6pEHEYs3zNfy/Ds6RwY1bPsEY14SPLBdSNRdhA3DiA/0t4ebmGxJyMoL7A8+J11CatUncTldtmhGnWI3GHeSXww3cy8dWazcETw9HakCOT6IhhokXRd9B/cKpigWMcDydQVIo2O8Czury+HGvCXs5C3/bwQExbQcN8R2wKxhUs2HLhvGKow1kr4QkmN6M6ww6+0kGKy3suIHbk3DIpCAquRxBqkT3o2ooQotEOXjidx8yHkCx63xclm/od4iFOYNmBAYuWyQVcVpm5Ara5lldi4tn/mKCcrt29oEadPuNgVVz7bXCA9RQHvSKa1pKZ3f3UFh7BSA0lEbWaMuGgDwELz7UYoTLPMZmgS8HY0IB0Rloy0e4HwnbS1eyyr+emHHfYn8garAbTwEA5SyHudY/Ur6381JOqVjw3qPrA5Qs6cSdY9AFY7EbHp3CzHd7UzVBjwhG+cRNkbISvCWM0dwCYszE/7F8CpLwL8g6HvwX9G/l3XQVYQxTkmNVPxT5ma00U2Cw9tyOUYg3Js X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(4636009)(46966006)(40470700002)(36840700001)(40460700001)(36860700001)(356005)(1076003)(36756003)(81166007)(110136005)(47076005)(83380400001)(82310400004)(8936002)(8676002)(186003)(508600001)(4326008)(54906003)(107886003)(921005)(70206006)(6666004)(26005)(70586007)(86362001)(2906002)(426003)(336012)(2616005)(5660300002)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2022 11:45:11.9019 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11b86af0-3f6c-475e-7321-08d9ceae803a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3628 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Get originating device from tuple offload metadata match ingress_ifindex, and set flow_source hint to either LOCAL for vf/sf reps, UPLINK for uplink/wire/tunnel devices/bond, or ANY (as before this patch) for all others. This allows lower layer (software steering or firmware) to insert the tuple rule only in one table (either rx or tx) instead of two (rx and tx). Signed-off-by: Paul Blakey --- drivers/net/ethernet/mellanox/mlx5/core/dev.c | 2 +- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 51 +++++++++++++++++-- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 1 + 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c index a8b84d53dfb0..ba6dad97e308 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c @@ -538,7 +538,7 @@ int mlx5_rescan_drivers_locked(struct mlx5_core_dev *dev) return add_drivers(dev); } -static bool mlx5_same_hw_devs(struct mlx5_core_dev *dev, struct mlx5_core_dev *peer_dev) +bool mlx5_same_hw_devs(struct mlx5_core_dev *dev, struct mlx5_core_dev *peer_dev) { u64 fsystem_guid, psystem_guid; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c index 9f33729e7fc4..4a0d38d219ed 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "lib/fs_chains.h" #include "en/tc_ct.h" @@ -326,7 +327,33 @@ mlx5_tc_ct_rule_to_tuple_nat(struct mlx5_ct_tuple *tuple, } static int -mlx5_tc_ct_set_tuple_match(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec, +mlx5_tc_ct_get_flow_source_match(struct mlx5_tc_ct_priv *ct_priv, + struct net_device *ndev) +{ + struct mlx5e_priv *other_priv = netdev_priv(ndev); + struct mlx5_core_dev *mdev = ct_priv->dev; + bool vf_rep, uplink_rep; + + vf_rep = mlx5e_eswitch_vf_rep(ndev) && mlx5_same_hw_devs(mdev, other_priv->mdev); + uplink_rep = mlx5e_eswitch_uplink_rep(ndev) && mlx5_same_hw_devs(mdev, other_priv->mdev); + + if (vf_rep) + return MLX5_FLOW_CONTEXT_FLOW_SOURCE_LOCAL_VPORT; + if (uplink_rep) + return MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; + if (is_vlan_dev(ndev)) + return mlx5_tc_ct_get_flow_source_match(ct_priv, vlan_dev_real_dev(ndev)); + if (netif_is_macvlan(ndev)) + return mlx5_tc_ct_get_flow_source_match(ct_priv, macvlan_dev_real_dev(ndev)); + if (mlx5e_get_tc_tun(ndev) || netif_is_lag_master(ndev)) + return MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; + + return MLX5_FLOW_CONTEXT_FLOW_SOURCE_ANY_VPORT; +} + +static int +mlx5_tc_ct_set_tuple_match(struct mlx5_tc_ct_priv *ct_priv, + struct mlx5_flow_spec *spec, struct flow_rule *rule) { void *headers_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria, @@ -341,8 +368,7 @@ mlx5_tc_ct_set_tuple_match(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec, flow_rule_match_basic(rule, &match); - mlx5e_tc_set_ethertype(priv->mdev, &match, true, headers_c, - headers_v); + mlx5e_tc_set_ethertype(ct_priv->dev, &match, true, headers_c, headers_v); MLX5_SET(fte_match_set_lyr_2_4, headers_c, ip_protocol, match.mask->ip_proto); MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_protocol, @@ -438,6 +464,23 @@ mlx5_tc_ct_set_tuple_match(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec, ntohs(match.key->flags)); } + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_META)) { + struct flow_match_meta match; + + flow_rule_match_meta(rule, &match); + + if (match.key->ingress_ifindex & match.mask->ingress_ifindex) { + struct net_device *dev; + + dev = dev_get_by_index(&init_net, match.key->ingress_ifindex); + if (dev && MLX5_CAP_ESW_FLOWTABLE(ct_priv->dev, flow_source)) + spec->flow_context.flow_source = + mlx5_tc_ct_get_flow_source_match(ct_priv, dev); + + dev_put(dev); + } + } + return 0; } @@ -770,7 +813,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv, if (ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB) attr->esw_attr->in_mdev = priv->mdev; - mlx5_tc_ct_set_tuple_match(netdev_priv(ct_priv->netdev), spec, flow_rule); + mlx5_tc_ct_set_tuple_match(ct_priv, spec, flow_rule); mlx5e_tc_match_to_reg_match(spec, ZONE_TO_REG, entry->tuple.zone, MLX5_CT_ZONE_MASK); zone_rule->rule = mlx5_tc_rule_insert(priv, spec, attr); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index bb677329ea08..6f8baa0f2a73 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -305,5 +305,6 @@ static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev) bool mlx5_eth_supported(struct mlx5_core_dev *dev); bool mlx5_rdma_supported(struct mlx5_core_dev *dev); bool mlx5_vnet_supported(struct mlx5_core_dev *dev); +bool mlx5_same_hw_devs(struct mlx5_core_dev *dev, struct mlx5_core_dev *peer_dev); #endif /* __MLX5_CORE_H__ */