From patchwork Thu Jul 22 07:58:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 485121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E87CDC6379A for ; Thu, 22 Jul 2021 07:58:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C148460FDA for ; Thu, 22 Jul 2021 07:58:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231230AbhGVHSA (ORCPT ); Thu, 22 Jul 2021 03:18:00 -0400 Received: from mail-bn8nam11on2102.outbound.protection.outlook.com ([40.107.236.102]:43163 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231187AbhGVHR4 (ORCPT ); Thu, 22 Jul 2021 03:17:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UugwKY5u7K2tNwKYGnIzxryNfmwaGPbucAFrQAeqwVIyNZewLK7ASpZ46yCqH2GXcC2y1DSMu139Ch1g8ZkLh7NOIpIcW6AuR+qhdLJxQNpTBzvgB451vbdKXPVDriWgVLw3cchiOkw3YZPms5OH392fTEdlfPMxVSvacfTdszZLK2BFcCNKWTBn5ZRnGyyUPmFGHJxN/Dm7AJ7wa/lGOE55bnyzoyiY6kz+CDX0UDjMDsXs38Rqx7jZioCx5xcxjg5XcWXIu960RtdM9UNEzSBCmKPi0/daogGw/Z/x61i6imjKPwDuadGxmoFCkt5a41wDbsDGSDlq1q9j7VOGTw== 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-SenderADCheck; bh=1F09HQD/uo9guJONJpyHbOLwoPF0MMqoKnTh+EW2lSU=; b=h9huoPx2NEtMHMj9ylQHwgFSqcYp2jdU5Culo633exM4uWlXXVV+I71nUKQkJRtFV94SlrRPou2jRSijFcslBWgEfD202odPSL/wSuvpeXbilVQ3Lm4xG/LwNlzqQHikruBcScG3uOusGnJzo6xFllx/x3axkysfLDPJ332sLxG5Y22v9tNzvRlWJCx7YUvThc/uZh7RsGarDh4xhVVpCMSt8oOjM5/IMxrWdky1C0qtyYk7080w67yWhgvDq98aq0/HuURPXAxU2Idu4GQFlSoAc7N71DxrhhQ1WbzH4/ORncwhaQl8rDAFc5sMnw4H6dWbj1780UYeIhKHLrJQ4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1F09HQD/uo9guJONJpyHbOLwoPF0MMqoKnTh+EW2lSU=; b=gvpb6ASKoET2ai4Veg7cgw+jH30iDGvggmW2JeFIRhmuhgoch/T9ku9QBMer3G+rQ+V4+NN732DpfMJHN0YjF+cigM4ZDNu5GD2F/jITnF76iR6I2amqLIZCFVya/AgRT5rtfa9ATN62yTLkkBFWr6WzxH7UxBBeiah208N0j48= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4892.namprd13.prod.outlook.com (2603:10b6:510:74::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.11; Thu, 22 Jul 2021 07:58:30 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3%7]) with mapi id 15.20.4352.024; Thu, 22 Jul 2021 07:58:30 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Yinjun Zhang , Louis Peens , Simon Horman Subject: [PATCH net-next 1/9] nfp: flower: make the match compilation functions reusable Date: Thu, 22 Jul 2021 09:58:00 +0200 Message-Id: <20210722075808.10095-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722075808.10095-1-simon.horman@corigine.com> References: <20210722075808.10095-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Thu, 22 Jul 2021 07:58:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1c8f88e-ec3c-489f-aa61-08d94ce67e6d X-MS-TrafficTypeDiagnostic: PH0PR13MB4892: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7vyNnAvbTmczPqTToNOWZTvp1DQiJTGmPeoPGObV2TNUwv3HG7ZPucyErQvjTsg55NUrIvYjmCszdoGFIz4OYEtfw/06XRHKWwppUtayOcSCMccFxPa2ys4Relfy6n3ZSfXh67J20KvMz5QGtbZGdwWbn7e8ySfAYr5khL7Z4F47D0+Dti/PsHOtnJsdsoBAJ2YghzKCFrhddFvIPzjRNlwJtH8Jv2xQ6mcp/4HcpeVqDcHJLTYbJ4rDJlMo0lEmmmiYUzhw2K0jui5iwPmuG8B/pP+DYajOFhPHeVqFwDzU/r/9xyZSOTEAbemRrAeZCNVxRCOOtqL/gr62HVOeNU/i4YapvqP5zKbqB0ol4bS/obL2hbibr42aRUFE2QENWvnFtPewR2xwDfdIbw7sJqkCvqmjEwneqLduMxyw1PrDG2oRqyuSg8olaG5+0lS9N/pmkXhuv2+alGkGzU+CVoLvjdTudvm3Upw4MDkmrdIF4RnRQzk4jAAKdXal9MmRlEvwe4C+z6oWLPskDOv7BmQktC0Y1Y4rWBTGy+tpzRHbgPm3/SeKeacx8soCULqJKqErWJTU7pa9RoNQGeqgOqq0v7bD9LZnK++dEep4YUFEIQMdXO2YeALvOm1GrWu+bgk/yTezBl62v3i7jkNxJw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(376002)(39830400003)(396003)(136003)(346002)(52116002)(4326008)(6666004)(316002)(6506007)(1076003)(8936002)(5660300002)(30864003)(8676002)(6486002)(186003)(107886003)(6512007)(110136005)(478600001)(2906002)(54906003)(36756003)(86362001)(44832011)(83380400001)(38100700002)(2616005)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cQAUxl+KjtKmY6PPl6kuanGPu7f2ej5hnrlBWBw6APQlKdira6h2d4/IhKd7e3c5F+WJYij1+uutdlCzWFiE8SxmZK1eis8zshQVshq8iie1UPbnzVozi8colkTupdDgELwalmB51R7wydWSfiIRU9Ke+2YUmT/ascEFX9pTdIoVW4urrWV2ffk3ijYysmoMwQsFWsDuyBlDjzu/otDi6z1cflNhw7S1Jlei/pz8AD8deNDo6XT6me+iFkD3hQ99O8YWdWV1QAON5A0d+RCf3bgv5Q+CkrMw2YxepuykvkZHEjcIppVXLRlLEAWC2cuPjoHMJ0Gc9c9ePg6/YrmVH1VRBf88tC9QUBgI55T3rh0bBlpLnvcU6ecpsY3UOT9na7zIwHcvBDKbRM7tmWvmb0AjdbcNpjBrwJNY5BCVXrijvOD/KGsjK1MJyT+CNwVWZaT/AQyHumx1/JSIWoLVbmNGWUFfLcIa5pBsSY9mqEVUpxGAJG/V3GhMk+5eeYisycWRFtJh91ZF7oLSWTHeCPGdJ/tbTMKTM7ava4j0dptI6Cbtfy2lnRgc3M7gZR8Izr/3sMT8v9o0YYusCaBTAfETeiOzVJT8YiXEnli8njFpxkkp1D+pJWIFm+1uT/pfeGQKZ592nfNXMB/rVtL1Dx9w87UnkCRnL/PK9Xyu3t8u4+KLKJQKzFudAfaN7gcKCeFVhN0RuYhfAclG2XnIvYK6sAZ72poXfjmen8OwdwVAeBsE0y9Fv7ipTwMvjW9tEJ/m1xvu5wP8QD6eGKT3Lc7TwaUuXtsWVOGmAbcbe0Agoxp1ZoR0YgBvkfezdOxNqHyvT4eZgAMEACG2ImI+tVnGvHWAsf0mM3uvhWQ6XzIvs6XaSdx5Aqovz2MzfsU/h0pPTU1TV1DRC6KRl7Y5Y8BfpTQtKNAOfj4Kq4BsEgj/rXvMH7h7C2UJgg2KVZ58DYlKfa7w1V+X1sePpPCkefxT1MkRszY8g/qSkoc1495FjgUgKtBA9cekv7Upw5UlJG2XPqlcaUG6VCL7C+i3OEipl1gpaPrLjFX1fuYnGogbRBadoA+JJyFymVh6KZSLCllhg5vwXkKPZca8M+7iBplG/tW9Mby64wd3J+ngK4MZ4c4htL1BNp0fy+Xx/EIfhYtdc289vRg4tOAdmXWu0RlorB0eSI3Npf+4IsMdQuke2+0BTakvhgMDT/Y+PRSnqHG5raj6UPRFcAUwTZo3T+EhOlW3KY0LblF/qqLox5yL3K/cAdmf6CAGcaWTSBQaCJrPzrHsHyUgJ8Mr5OFGPYgLFV1svt1ESrfxMI2OTfKNvMNAMHx0gryinV0MfMXW/8UJeCnpD+xJgX01jE9C4aXV9y8uZZ05F2YcLDL4AquKhL3D1U8BqumKcyVvOecS X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1c8f88e-ec3c-489f-aa61-08d94ce67e6d X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:58:29.9181 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8nwLqgBjfzOSxfFX5oZiu9Tjf4MPK5LnP+Cz87dcVXT4bThaL7f66bpdZuZNqzL/WhqL0LFbuzRJK6/T0uGPQnleO3BaXhCaWcQLmt1u7ZA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4892 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yinjun Zhang Expose and refactor the match compilation functions so that they can be invoked externally. Also update the functions so they can be called multiple times with the results OR'd together. This is applicable for the flows-merging scenario, in which there could be overlapped and non-conflicting match fields. This will be used in upcoming conntrack patches. This is safe to do in the in the single call case as well since both unmasked_data and mask_data gets initialised to 0. Signed-off-by: Yinjun Zhang Signed-off-by: Louis Peens Signed-off-by: Simon Horman --- .../net/ethernet/netronome/nfp/flower/main.h | 54 +++ .../net/ethernet/netronome/nfp/flower/match.c | 330 ++++++++++-------- 2 files changed, 239 insertions(+), 145 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 0fbd682ccf72..beb19deaeb56 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -413,6 +413,60 @@ int nfp_flower_setup_tc(struct nfp_app *app, struct net_device *netdev, int nfp_flower_merge_offloaded_flows(struct nfp_app *app, struct nfp_fl_payload *sub_flow1, struct nfp_fl_payload *sub_flow2); +void +nfp_flower_compile_meta(struct nfp_flower_meta_tci *ext, + struct nfp_flower_meta_tci *msk, u8 key_type); +void +nfp_flower_compile_tci(struct nfp_flower_meta_tci *ext, + struct nfp_flower_meta_tci *msk, + struct flow_rule *rule); +void +nfp_flower_compile_ext_meta(struct nfp_flower_ext_meta *frame, u32 key_ext); +int +nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port, + bool mask_version, enum nfp_flower_tun_type tun_type, + struct netlink_ext_ack *extack); +void +nfp_flower_compile_mac(struct nfp_flower_mac_mpls *ext, + struct nfp_flower_mac_mpls *msk, + struct flow_rule *rule); +int +nfp_flower_compile_mpls(struct nfp_flower_mac_mpls *ext, + struct nfp_flower_mac_mpls *msk, + struct flow_rule *rule, + struct netlink_ext_ack *extack); +void +nfp_flower_compile_tport(struct nfp_flower_tp_ports *ext, + struct nfp_flower_tp_ports *msk, + struct flow_rule *rule); +void +nfp_flower_compile_vlan(struct nfp_flower_vlan *ext, + struct nfp_flower_vlan *msk, + struct flow_rule *rule); +void +nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *ext, + struct nfp_flower_ipv4 *msk, struct flow_rule *rule); +void +nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *ext, + struct nfp_flower_ipv6 *msk, struct flow_rule *rule); +void +nfp_flower_compile_geneve_opt(u8 *ext, u8 *msk, struct flow_rule *rule); +void +nfp_flower_compile_ipv4_gre_tun(struct nfp_flower_ipv4_gre_tun *ext, + struct nfp_flower_ipv4_gre_tun *msk, + struct flow_rule *rule); +void +nfp_flower_compile_ipv4_udp_tun(struct nfp_flower_ipv4_udp_tun *ext, + struct nfp_flower_ipv4_udp_tun *msk, + struct flow_rule *rule); +void +nfp_flower_compile_ipv6_udp_tun(struct nfp_flower_ipv6_udp_tun *ext, + struct nfp_flower_ipv6_udp_tun *msk, + struct flow_rule *rule); +void +nfp_flower_compile_ipv6_gre_tun(struct nfp_flower_ipv6_gre_tun *ext, + struct nfp_flower_ipv6_gre_tun *msk, + struct flow_rule *rule); int nfp_flower_compile_flow_match(struct nfp_app *app, struct flow_cls_offload *flow, struct nfp_fl_key_ls *key_ls, diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c index 255a4dff6288..9af1bd90d6c4 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/match.c +++ b/drivers/net/ethernet/netronome/nfp/flower/match.c @@ -7,51 +7,68 @@ #include "cmsg.h" #include "main.h" -static void -nfp_flower_compile_meta_tci(struct nfp_flower_meta_tci *ext, - struct nfp_flower_meta_tci *msk, - struct flow_rule *rule, u8 key_type, bool qinq_sup) +void +nfp_flower_compile_meta(struct nfp_flower_meta_tci *ext, + struct nfp_flower_meta_tci *msk, u8 key_type) { - u16 tmp_tci; - - memset(ext, 0, sizeof(struct nfp_flower_meta_tci)); - memset(msk, 0, sizeof(struct nfp_flower_meta_tci)); - /* Populate the metadata frame. */ ext->nfp_flow_key_layer = key_type; ext->mask_id = ~0; msk->nfp_flow_key_layer = key_type; msk->mask_id = ~0; +} - if (!qinq_sup && flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) { +void +nfp_flower_compile_tci(struct nfp_flower_meta_tci *ext, + struct nfp_flower_meta_tci *msk, + struct flow_rule *rule) +{ + u16 msk_tci, key_tci; + + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) { struct flow_match_vlan match; flow_rule_match_vlan(rule, &match); /* Populate the tci field. */ - tmp_tci = NFP_FLOWER_MASK_VLAN_PRESENT; - tmp_tci |= FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, + key_tci = NFP_FLOWER_MASK_VLAN_PRESENT; + key_tci |= FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, match.key->vlan_priority) | FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, match.key->vlan_id); - ext->tci = cpu_to_be16(tmp_tci); - tmp_tci = NFP_FLOWER_MASK_VLAN_PRESENT; - tmp_tci |= FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, + msk_tci = NFP_FLOWER_MASK_VLAN_PRESENT; + msk_tci |= FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, match.mask->vlan_priority) | FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, match.mask->vlan_id); - msk->tci = cpu_to_be16(tmp_tci); + + ext->tci |= cpu_to_be16((key_tci & msk_tci)); + msk->tci |= cpu_to_be16(msk_tci); } } static void +nfp_flower_compile_meta_tci(struct nfp_flower_meta_tci *ext, + struct nfp_flower_meta_tci *msk, + struct flow_rule *rule, u8 key_type, bool qinq_sup) +{ + memset(ext, 0, sizeof(struct nfp_flower_meta_tci)); + memset(msk, 0, sizeof(struct nfp_flower_meta_tci)); + + nfp_flower_compile_meta(ext, msk, key_type); + + if (!qinq_sup) + nfp_flower_compile_tci(ext, msk, rule); +} + +void nfp_flower_compile_ext_meta(struct nfp_flower_ext_meta *frame, u32 key_ext) { frame->nfp_flow_key_layer2 = cpu_to_be32(key_ext); } -static int +int nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port, bool mask_version, enum nfp_flower_tun_type tun_type, struct netlink_ext_ack *extack) @@ -74,28 +91,37 @@ nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port, return 0; } -static int +void nfp_flower_compile_mac(struct nfp_flower_mac_mpls *ext, - struct nfp_flower_mac_mpls *msk, struct flow_rule *rule, - struct netlink_ext_ack *extack) + struct nfp_flower_mac_mpls *msk, + struct flow_rule *rule) { - memset(ext, 0, sizeof(struct nfp_flower_mac_mpls)); - memset(msk, 0, sizeof(struct nfp_flower_mac_mpls)); - if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) { struct flow_match_eth_addrs match; + int i; flow_rule_match_eth_addrs(rule, &match); /* Populate mac frame. */ - ether_addr_copy(ext->mac_dst, &match.key->dst[0]); - ether_addr_copy(ext->mac_src, &match.key->src[0]); - ether_addr_copy(msk->mac_dst, &match.mask->dst[0]); - ether_addr_copy(msk->mac_src, &match.mask->src[0]); + for (i = 0; i < ETH_ALEN; i++) { + ext->mac_dst[i] |= match.key->dst[i] & + match.mask->dst[i]; + msk->mac_dst[i] |= match.mask->dst[i]; + ext->mac_src[i] |= match.key->src[i] & + match.mask->src[i]; + msk->mac_src[i] |= match.mask->src[i]; + } } +} +int +nfp_flower_compile_mpls(struct nfp_flower_mac_mpls *ext, + struct nfp_flower_mac_mpls *msk, + struct flow_rule *rule, + struct netlink_ext_ack *extack) +{ if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_MPLS)) { struct flow_match_mpls match; - u32 t_mpls; + u32 key_mpls, msk_mpls; flow_rule_match_mpls(rule, &match); @@ -106,22 +132,24 @@ nfp_flower_compile_mac(struct nfp_flower_mac_mpls *ext, return -EOPNOTSUPP; } - t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, - match.key->ls[0].mpls_label) | - FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, - match.key->ls[0].mpls_tc) | - FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, - match.key->ls[0].mpls_bos) | - NFP_FLOWER_MASK_MPLS_Q; - ext->mpls_lse = cpu_to_be32(t_mpls); - t_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, - match.mask->ls[0].mpls_label) | - FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, - match.mask->ls[0].mpls_tc) | - FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, - match.mask->ls[0].mpls_bos) | - NFP_FLOWER_MASK_MPLS_Q; - msk->mpls_lse = cpu_to_be32(t_mpls); + key_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, + match.key->ls[0].mpls_label) | + FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, + match.key->ls[0].mpls_tc) | + FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, + match.key->ls[0].mpls_bos) | + NFP_FLOWER_MASK_MPLS_Q; + + msk_mpls = FIELD_PREP(NFP_FLOWER_MASK_MPLS_LB, + match.mask->ls[0].mpls_label) | + FIELD_PREP(NFP_FLOWER_MASK_MPLS_TC, + match.mask->ls[0].mpls_tc) | + FIELD_PREP(NFP_FLOWER_MASK_MPLS_BOS, + match.mask->ls[0].mpls_bos) | + NFP_FLOWER_MASK_MPLS_Q; + + ext->mpls_lse |= cpu_to_be32((key_mpls & msk_mpls)); + msk->mpls_lse |= cpu_to_be32(msk_mpls); } else if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) { /* Check for mpls ether type and set NFP_FLOWER_MASK_MPLS_Q * bit, which indicates an mpls ether type but without any @@ -132,30 +160,41 @@ nfp_flower_compile_mac(struct nfp_flower_mac_mpls *ext, flow_rule_match_basic(rule, &match); if (match.key->n_proto == cpu_to_be16(ETH_P_MPLS_UC) || match.key->n_proto == cpu_to_be16(ETH_P_MPLS_MC)) { - ext->mpls_lse = cpu_to_be32(NFP_FLOWER_MASK_MPLS_Q); - msk->mpls_lse = cpu_to_be32(NFP_FLOWER_MASK_MPLS_Q); + ext->mpls_lse |= cpu_to_be32(NFP_FLOWER_MASK_MPLS_Q); + msk->mpls_lse |= cpu_to_be32(NFP_FLOWER_MASK_MPLS_Q); } } return 0; } -static void +static int +nfp_flower_compile_mac_mpls(struct nfp_flower_mac_mpls *ext, + struct nfp_flower_mac_mpls *msk, + struct flow_rule *rule, + struct netlink_ext_ack *extack) +{ + memset(ext, 0, sizeof(struct nfp_flower_mac_mpls)); + memset(msk, 0, sizeof(struct nfp_flower_mac_mpls)); + + nfp_flower_compile_mac(ext, msk, rule); + + return nfp_flower_compile_mpls(ext, msk, rule, extack); +} + +void nfp_flower_compile_tport(struct nfp_flower_tp_ports *ext, struct nfp_flower_tp_ports *msk, struct flow_rule *rule) { - memset(ext, 0, sizeof(struct nfp_flower_tp_ports)); - memset(msk, 0, sizeof(struct nfp_flower_tp_ports)); - if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) { struct flow_match_ports match; flow_rule_match_ports(rule, &match); - ext->port_src = match.key->src; - ext->port_dst = match.key->dst; - msk->port_src = match.mask->src; - msk->port_dst = match.mask->dst; + ext->port_src |= match.key->src & match.mask->src; + ext->port_dst |= match.key->dst & match.mask->dst; + msk->port_src |= match.mask->src; + msk->port_dst |= match.mask->dst; } } @@ -167,18 +206,18 @@ nfp_flower_compile_ip_ext(struct nfp_flower_ip_ext *ext, struct flow_match_basic match; flow_rule_match_basic(rule, &match); - ext->proto = match.key->ip_proto; - msk->proto = match.mask->ip_proto; + ext->proto |= match.key->ip_proto & match.mask->ip_proto; + msk->proto |= match.mask->ip_proto; } if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IP)) { struct flow_match_ip match; flow_rule_match_ip(rule, &match); - ext->tos = match.key->tos; - ext->ttl = match.key->ttl; - msk->tos = match.mask->tos; - msk->ttl = match.mask->ttl; + ext->tos |= match.key->tos & match.mask->tos; + ext->ttl |= match.key->ttl & match.mask->ttl; + msk->tos |= match.mask->tos; + msk->ttl |= match.mask->ttl; } if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_TCP)) { @@ -231,99 +270,108 @@ nfp_flower_compile_ip_ext(struct nfp_flower_ip_ext *ext, } static void -nfp_flower_fill_vlan(struct flow_dissector_key_vlan *key, - struct nfp_flower_vlan *frame, - bool outer_vlan) +nfp_flower_fill_vlan(struct flow_match_vlan *match, + struct nfp_flower_vlan *ext, + struct nfp_flower_vlan *msk, bool outer_vlan) { - u16 tci; - - tci = NFP_FLOWER_MASK_VLAN_PRESENT; - tci |= FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, - key->vlan_priority) | - FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, - key->vlan_id); + struct flow_dissector_key_vlan *mask = match->mask; + struct flow_dissector_key_vlan *key = match->key; + u16 msk_tci, key_tci; + + key_tci = NFP_FLOWER_MASK_VLAN_PRESENT; + key_tci |= FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, + key->vlan_priority) | + FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, + key->vlan_id); + msk_tci = NFP_FLOWER_MASK_VLAN_PRESENT; + msk_tci |= FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, + mask->vlan_priority) | + FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, + mask->vlan_id); if (outer_vlan) { - frame->outer_tci = cpu_to_be16(tci); - frame->outer_tpid = key->vlan_tpid; + ext->outer_tci |= cpu_to_be16((key_tci & msk_tci)); + ext->outer_tpid |= key->vlan_tpid & mask->vlan_tpid; + msk->outer_tci |= cpu_to_be16(msk_tci); + msk->outer_tpid |= mask->vlan_tpid; } else { - frame->inner_tci = cpu_to_be16(tci); - frame->inner_tpid = key->vlan_tpid; + ext->inner_tci |= cpu_to_be16((key_tci & msk_tci)); + ext->inner_tpid |= key->vlan_tpid & mask->vlan_tpid; + msk->inner_tci |= cpu_to_be16(msk_tci); + msk->inner_tpid |= mask->vlan_tpid; } } -static void +void nfp_flower_compile_vlan(struct nfp_flower_vlan *ext, struct nfp_flower_vlan *msk, struct flow_rule *rule) { struct flow_match_vlan match; - memset(ext, 0, sizeof(struct nfp_flower_vlan)); - memset(msk, 0, sizeof(struct nfp_flower_vlan)); - if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) { flow_rule_match_vlan(rule, &match); - nfp_flower_fill_vlan(match.key, ext, true); - nfp_flower_fill_vlan(match.mask, msk, true); + nfp_flower_fill_vlan(&match, ext, msk, true); } if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN)) { flow_rule_match_cvlan(rule, &match); - nfp_flower_fill_vlan(match.key, ext, false); - nfp_flower_fill_vlan(match.mask, msk, false); + nfp_flower_fill_vlan(&match, ext, msk, false); } } -static void +void nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *ext, struct nfp_flower_ipv4 *msk, struct flow_rule *rule) { - struct flow_match_ipv4_addrs match; - - memset(ext, 0, sizeof(struct nfp_flower_ipv4)); - memset(msk, 0, sizeof(struct nfp_flower_ipv4)); - if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) { + struct flow_match_ipv4_addrs match; + flow_rule_match_ipv4_addrs(rule, &match); - ext->ipv4_src = match.key->src; - ext->ipv4_dst = match.key->dst; - msk->ipv4_src = match.mask->src; - msk->ipv4_dst = match.mask->dst; + ext->ipv4_src |= match.key->src & match.mask->src; + ext->ipv4_dst |= match.key->dst & match.mask->dst; + msk->ipv4_src |= match.mask->src; + msk->ipv4_dst |= match.mask->dst; } nfp_flower_compile_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); } -static void +void nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *ext, struct nfp_flower_ipv6 *msk, struct flow_rule *rule) { - memset(ext, 0, sizeof(struct nfp_flower_ipv6)); - memset(msk, 0, sizeof(struct nfp_flower_ipv6)); - if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS)) { struct flow_match_ipv6_addrs match; + int i; flow_rule_match_ipv6_addrs(rule, &match); - ext->ipv6_src = match.key->src; - ext->ipv6_dst = match.key->dst; - msk->ipv6_src = match.mask->src; - msk->ipv6_dst = match.mask->dst; + for (i = 0; i < sizeof(ext->ipv6_src); i++) { + ext->ipv6_src.s6_addr[i] |= match.key->src.s6_addr[i] & + match.mask->src.s6_addr[i]; + ext->ipv6_dst.s6_addr[i] |= match.key->dst.s6_addr[i] & + match.mask->dst.s6_addr[i]; + msk->ipv6_src.s6_addr[i] |= match.mask->src.s6_addr[i]; + msk->ipv6_dst.s6_addr[i] |= match.mask->dst.s6_addr[i]; + } } nfp_flower_compile_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); } -static int -nfp_flower_compile_geneve_opt(void *ext, void *msk, struct flow_rule *rule) +void +nfp_flower_compile_geneve_opt(u8 *ext, u8 *msk, struct flow_rule *rule) { struct flow_match_enc_opts match; + int i; - flow_rule_match_enc_opts(rule, &match); - memcpy(ext, match.key->data, match.key->len); - memcpy(msk, match.mask->data, match.mask->len); + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_OPTS)) { + flow_rule_match_enc_opts(rule, &match); - return 0; + for (i = 0; i < match.mask->len; i++) { + ext[i] |= match.key->data[i] & match.mask->data[i]; + msk[i] |= match.mask->data[i]; + } + } } static void @@ -335,10 +383,10 @@ nfp_flower_compile_tun_ipv4_addrs(struct nfp_flower_tun_ipv4 *ext, struct flow_match_ipv4_addrs match; flow_rule_match_enc_ipv4_addrs(rule, &match); - ext->src = match.key->src; - ext->dst = match.key->dst; - msk->src = match.mask->src; - msk->dst = match.mask->dst; + ext->src |= match.key->src & match.mask->src; + ext->dst |= match.key->dst & match.mask->dst; + msk->src |= match.mask->src; + msk->dst |= match.mask->dst; } } @@ -349,12 +397,17 @@ nfp_flower_compile_tun_ipv6_addrs(struct nfp_flower_tun_ipv6 *ext, { if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS)) { struct flow_match_ipv6_addrs match; + int i; flow_rule_match_enc_ipv6_addrs(rule, &match); - ext->src = match.key->src; - ext->dst = match.key->dst; - msk->src = match.mask->src; - msk->dst = match.mask->dst; + for (i = 0; i < sizeof(ext->src); i++) { + ext->src.s6_addr[i] |= match.key->src.s6_addr[i] & + match.mask->src.s6_addr[i]; + ext->dst.s6_addr[i] |= match.key->dst.s6_addr[i] & + match.mask->dst.s6_addr[i]; + msk->src.s6_addr[i] |= match.mask->src.s6_addr[i]; + msk->dst.s6_addr[i] |= match.mask->dst.s6_addr[i]; + } } } @@ -367,10 +420,10 @@ nfp_flower_compile_tun_ip_ext(struct nfp_flower_tun_ip_ext *ext, struct flow_match_ip match; flow_rule_match_enc_ip(rule, &match); - ext->tos = match.key->tos; - ext->ttl = match.key->ttl; - msk->tos = match.mask->tos; - msk->ttl = match.mask->ttl; + ext->tos |= match.key->tos & match.mask->tos; + ext->ttl |= match.key->ttl & match.mask->ttl; + msk->tos |= match.mask->tos; + msk->ttl |= match.mask->ttl; } } @@ -383,10 +436,11 @@ nfp_flower_compile_tun_udp_key(__be32 *key, __be32 *key_msk, u32 vni; flow_rule_match_enc_keyid(rule, &match); - vni = be32_to_cpu(match.key->keyid) << NFP_FL_TUN_VNI_OFFSET; - *key = cpu_to_be32(vni); + vni = be32_to_cpu((match.key->keyid & match.mask->keyid)) << + NFP_FL_TUN_VNI_OFFSET; + *key |= cpu_to_be32(vni); vni = be32_to_cpu(match.mask->keyid) << NFP_FL_TUN_VNI_OFFSET; - *key_msk = cpu_to_be32(vni); + *key_msk |= cpu_to_be32(vni); } } @@ -398,22 +452,19 @@ nfp_flower_compile_tun_gre_key(__be32 *key, __be32 *key_msk, __be16 *flags, struct flow_match_enc_keyid match; flow_rule_match_enc_keyid(rule, &match); - *key = match.key->keyid; - *key_msk = match.mask->keyid; + *key |= match.key->keyid & match.mask->keyid; + *key_msk |= match.mask->keyid; *flags = cpu_to_be16(NFP_FL_GRE_FLAG_KEY); *flags_msk = cpu_to_be16(NFP_FL_GRE_FLAG_KEY); } } -static void +void nfp_flower_compile_ipv4_gre_tun(struct nfp_flower_ipv4_gre_tun *ext, struct nfp_flower_ipv4_gre_tun *msk, struct flow_rule *rule) { - memset(ext, 0, sizeof(struct nfp_flower_ipv4_gre_tun)); - memset(msk, 0, sizeof(struct nfp_flower_ipv4_gre_tun)); - /* NVGRE is the only supported GRE tunnel type */ ext->ethertype = cpu_to_be16(ETH_P_TEB); msk->ethertype = cpu_to_be16(~0); @@ -424,40 +475,31 @@ nfp_flower_compile_ipv4_gre_tun(struct nfp_flower_ipv4_gre_tun *ext, &ext->tun_flags, &msk->tun_flags, rule); } -static void +void nfp_flower_compile_ipv4_udp_tun(struct nfp_flower_ipv4_udp_tun *ext, struct nfp_flower_ipv4_udp_tun *msk, struct flow_rule *rule) { - memset(ext, 0, sizeof(struct nfp_flower_ipv4_udp_tun)); - memset(msk, 0, sizeof(struct nfp_flower_ipv4_udp_tun)); - nfp_flower_compile_tun_ipv4_addrs(&ext->ipv4, &msk->ipv4, rule); nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); nfp_flower_compile_tun_udp_key(&ext->tun_id, &msk->tun_id, rule); } -static void +void nfp_flower_compile_ipv6_udp_tun(struct nfp_flower_ipv6_udp_tun *ext, struct nfp_flower_ipv6_udp_tun *msk, struct flow_rule *rule) { - memset(ext, 0, sizeof(struct nfp_flower_ipv6_udp_tun)); - memset(msk, 0, sizeof(struct nfp_flower_ipv6_udp_tun)); - nfp_flower_compile_tun_ipv6_addrs(&ext->ipv6, &msk->ipv6, rule); nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); nfp_flower_compile_tun_udp_key(&ext->tun_id, &msk->tun_id, rule); } -static void +void nfp_flower_compile_ipv6_gre_tun(struct nfp_flower_ipv6_gre_tun *ext, struct nfp_flower_ipv6_gre_tun *msk, struct flow_rule *rule) { - memset(ext, 0, sizeof(struct nfp_flower_ipv6_gre_tun)); - memset(msk, 0, sizeof(struct nfp_flower_ipv6_gre_tun)); - /* NVGRE is the only supported GRE tunnel type */ ext->ethertype = cpu_to_be16(ETH_P_TEB); msk->ethertype = cpu_to_be16(~0); @@ -527,9 +569,9 @@ int nfp_flower_compile_flow_match(struct nfp_app *app, msk += sizeof(struct nfp_flower_in_port); if (NFP_FLOWER_LAYER_MAC & key_ls->key_layer) { - err = nfp_flower_compile_mac((struct nfp_flower_mac_mpls *)ext, - (struct nfp_flower_mac_mpls *)msk, - rule, extack); + err = nfp_flower_compile_mac_mpls((struct nfp_flower_mac_mpls *)ext, + (struct nfp_flower_mac_mpls *)msk, + rule, extack); if (err) return err; @@ -640,9 +682,7 @@ int nfp_flower_compile_flow_match(struct nfp_app *app, } if (key_ls->key_layer_two & NFP_FLOWER_LAYER2_GENEVE_OP) { - err = nfp_flower_compile_geneve_opt(ext, msk, rule); - if (err) - return err; + nfp_flower_compile_geneve_opt(ext, msk, rule); } } From patchwork Thu Jul 22 07:58:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 484334 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41D22C63793 for ; Thu, 22 Jul 2021 07:58:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FD5261279 for ; Thu, 22 Jul 2021 07:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231233AbhGVHSB (ORCPT ); Thu, 22 Jul 2021 03:18:01 -0400 Received: from mail-bn8nam11on2102.outbound.protection.outlook.com ([40.107.236.102]:43163 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230200AbhGVHR6 (ORCPT ); Thu, 22 Jul 2021 03:17:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wwdd+cOlrk3idiieOqTam5+Ozig7Gyu5H2In+vP3zHc0NYapEbVrpwUL989UXaBMo8wsfrnuImhufCmGBZgo7I9d687oBzFa57tHhAIIFBlato4cMqReZq2RGaKOgfEW+xsrMCa0tpTwsd7jy1Yd2cRySLVEt6zPS9nHzQtxL0Krif6OeEIKS4N44BQyTHm4FeIsas1nlRV0kqqsS0OVSvc/R5VlBJH0c0QyA78rg32SFxnmnZOaGhhgMAkD05ICpKwjbiKQR6RHqQ8+UUiV665f85q6Dl1jDLJ6Tu6BfzPftx56UmEOukKbOCg8iuNwmsLBncvpoLUjVxBdnm7Clw== 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-SenderADCheck; bh=bjjzREvIELlxvZych8gAfGrSz1hDGePZRnh8mLuUf+0=; b=kWKx8xOf6tCdf6+FXLKNxpCeC3hAS+2oeyoCngMGGYCvqKmo/gx8UiVUMIsddiCjSTxQnEdfc5SlIFiyAEP8SUbgWS5F65gZqVMxz+n4qOeD9S9AZKr4c7DER91D6Txqgw5jDERC/YeECx+qHXd2YeNPYqPUmsDU1TsWvOCyMM9lDk2w5MAFgmwkSy6nQ3UrHAuzDPjcLC9XA7zn1fDDrlI+nccLPC6qB1RmRxhr5FmA4Nfvxgl/HTs0MWZQMPWygVXyUCHxe2yjqgv/EcljWaoc3aE3UxROsuhiL29a3Zad2h0lzaRx0gYgNjF8DfHoqI4j63XWWN0qHRaOwLJ94A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bjjzREvIELlxvZych8gAfGrSz1hDGePZRnh8mLuUf+0=; b=DWLOZUdb5N0JoaOyY6kuUlnZNNvjE7+ilMSKwttinaPyIQCP3Rq12NvW32gr4PhtMaFGIMsHVE3clUpeG3rnXI34zauxEjGo9jbT1sRxf16NRXQYkEOsHY/8SJwtCQvxWuBm0XMSmEBrcBAFuXiIf92d1hfH4m5QycUq8r2lAa0= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4892.namprd13.prod.outlook.com (2603:10b6:510:74::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.11; Thu, 22 Jul 2021 07:58:31 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3%7]) with mapi id 15.20.4352.024; Thu, 22 Jul 2021 07:58:31 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Yinjun Zhang , Louis Peens , Simon Horman Subject: [PATCH net-next 2/9] nfp: flower: refactor match functions to take flow_rule as input Date: Thu, 22 Jul 2021 09:58:01 +0200 Message-Id: <20210722075808.10095-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722075808.10095-1-simon.horman@corigine.com> References: <20210722075808.10095-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Thu, 22 Jul 2021 07:58:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ed64f5b-daee-4c62-c7ec-08d94ce67f7b X-MS-TrafficTypeDiagnostic: PH0PR13MB4892: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SfKIuyMJc3wfYWs6y9Qatdq8K7pWnb+4APy3YluLdwIr78kZfFjxU0UasMJa+P96eiKgrKGhKlXwxQyxS/xb/rr0t2ftHVs40KmSdGzeDHjYEe1m/CA3juUMET+iCsoNrK5o97RleeEZYgc77sYZ/LDWbX8L8jpyo4H8vpgls4nXPAQTvMVEpVDNsiFq38m/n0Hc90umqSs6E/G/twrmAp1YA7qZx3IEmsUpmzQRkm3S1UPAL+DSz8TJ0285ZPopmy1XrfaAhlmHkspPjM4QkXccXtt1BZY4HTXJOvJEqPIzEYNE6xckv6+C3IW+ckS7/1uxinfxxTkpytCWBr2LNgWvXSAZjNXNi9GirbonDizZZ4uQLZVu5I/3ywdZ2os7vxNZetyIPgPSSlQ4KL6SlsYx82Mz33ZQhwrkhYPJXMmSUNZyBVTtQSaJrUl7QJ1gFUsl87EtnCbvXE/Rv9fPGStI+YWTfRaLewZxyaito4SAREuIKyDBiVPh8J6Uj9fkVyKOeEdROc7ugRksY9b+ciB5ETOtfhZsqqwY53oAtWcb1+L6jj3HghKBSI4x3JBxqkS9be2aLlT4h7Dgcl8y+swWugKB/ISeDrSGqxeEvxdrRCqzwxuP4F6ND0crRtFYair+YGIZ/R3dNW2h58FCJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(376002)(39830400003)(396003)(136003)(346002)(52116002)(4326008)(6666004)(316002)(6506007)(1076003)(8936002)(5660300002)(8676002)(6486002)(186003)(107886003)(6512007)(110136005)(478600001)(2906002)(54906003)(36756003)(86362001)(44832011)(83380400001)(38100700002)(2616005)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p7FsweKF3ma9iV7dF8AlHOaqQwtPMf+nJZvYiHLbOkmxZIJTM+Ux4pF0JZVVetw+PLNckJOqD9/Mt0ZjQ6mKFnlFkaABeYMeMo8UuZkaYyVAJRpaElffKbq0IDLtztns89foO8/24X3t1FJE3vuA7CblB/i9HJN5hCXKeI86fw/jVKaqd9O5XCg7x3huQ0S5Gfb2H9axlhB19tvxuGZeoavSG9efC8JDRTCe/MSFjmW6fhqgrij53l5eNSDX6TNlfiB8WoVjO7v4aOyf6RiDYroAHl7SNmw6U/G1sg7NtxHUmQXzCL1CAiZZf3MLQA9jYT2BSqlFyTxtnZrVxRklU/xXiwIBR8NRLdW75Wi3j/+3QaXCCFsS8+lcvkI7m74mca/esaRFJLFxdpfsvC7Po8sf0RO76Ff8+ePBdMByRgWFffxX//Za3KhmnYL+JKHZwklF5uLUNr9q190eydWZKjccmyK3zfD7f2f/jYbQDIwDzFB9/xfm2JfwI/5EzB5FcZcqdi8+QNjmNVHWbPU7Co7L06tcpp9r0BUwwpmyOfpvynGXJy9SplLRsRCU/jKEptAinkyNLJomJ4aS4qbQ98Xc4qt9Iux4BWWT0LLv7oAa0Xq+c4OrSxsoyYWwWq1Hy6x0VXM7CVk+2H1HhT6Qm0HPuBL9XonpLxffoyEakpMd7yji1oJouOxL6QnSZGHWzbvCJp9t2gAg+jEQJw6MvqjGk1MBvUmB/7aNcZrVrS4hy5OeZ/hWkMc14VkoEklP3zRloYymLHtaD61sDQ4zk2tymVAaAnj3qmpU1mt6z2btd/CvgVnyIZJJNTZaeSU5/243jFuTvFEmxKQQWf3zjyr3LX9AD3GcVJEx4XnYpF6czStHh972WB6RcCM+hv25XEkGshEVLjq+QCrUzeZk34avLrd7WnWr1hNyUaVmZyBswRCNGNPmBJ6ZlC3Kl7kCmk/faCEpaY2e+UENQrdK6o9HCBcgoJCfiDv1YLlumIil7LunAl3N1K7ETd6aOztkU49oFK6SL2qSQtUiUXBM9yGQ1uRgeO4ABE/vBxi1m423S31cTH6ka19JM8tOw/qjur2LcMcdqbxXFNg/DU8JgTrWDEPvyFYM2VdoKcgZHFyhyytHaZ9+qzEjU2qmTODpdjH3Oq7wcHlI1PHHyx4hPSt5GOELCIfYzC2YtsYRDw6Wp+5+7gwr1gub34wd+CS+LuqGk/3sHWSrIvXVbXREFwp99xgvzTQhfgbKluq9wX+vihDZaOXYgZy9rFSqMP+SZdsDG0ZcGNsNdhFbrxmxR7WBrX8jgwbeuIBKFKt9JN+9BjW3ebKeZidd6IR6VG9kWrJHrg88/CVBHcc2vVYkhfUOijiLhbKOZInSKgiUI0pqeqycJNmBVzIYYBZBfC6l X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ed64f5b-daee-4c62-c7ec-08d94ce67f7b X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:58:31.5828 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gamsJGqim8VJr7kDt/JR23fuXw7hXxnjCtWROqb7y45VgzV74tAFaofr7CAzPw+tfWRQxBIzUrq02vc7YbNRbiXQaE6wZKyaDa8e2DAcYZY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4892 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens This is a small cleanup to pass in flow->rule to some of the compile functions instead of extracting it every time. This is will also be useful for conntrack patches later. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../net/ethernet/netronome/nfp/flower/main.h | 5 ++-- .../net/ethernet/netronome/nfp/flower/match.c | 3 +- .../ethernet/netronome/nfp/flower/metadata.c | 7 ++--- .../ethernet/netronome/nfp/flower/offload.c | 30 +++++++------------ 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index beb19deaeb56..004665567b5a 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -468,7 +468,7 @@ nfp_flower_compile_ipv6_gre_tun(struct nfp_flower_ipv6_gre_tun *ext, struct nfp_flower_ipv6_gre_tun *msk, struct flow_rule *rule); int nfp_flower_compile_flow_match(struct nfp_app *app, - struct flow_cls_offload *flow, + struct flow_rule *rule, struct nfp_fl_key_ls *key_ls, struct net_device *netdev, struct nfp_fl_payload *nfp_flow, @@ -479,8 +479,7 @@ int nfp_flower_compile_action(struct nfp_app *app, struct net_device *netdev, struct nfp_fl_payload *nfp_flow, struct netlink_ext_ack *extack); -int nfp_compile_flow_metadata(struct nfp_app *app, - struct flow_cls_offload *flow, +int nfp_compile_flow_metadata(struct nfp_app *app, u32 cookie, struct nfp_fl_payload *nfp_flow, struct net_device *netdev, struct netlink_ext_ack *extack); diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c index 9af1bd90d6c4..9d86eea4dc16 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/match.c +++ b/drivers/net/ethernet/netronome/nfp/flower/match.c @@ -511,14 +511,13 @@ nfp_flower_compile_ipv6_gre_tun(struct nfp_flower_ipv6_gre_tun *ext, } int nfp_flower_compile_flow_match(struct nfp_app *app, - struct flow_cls_offload *flow, + struct flow_rule *rule, struct nfp_fl_key_ls *key_ls, struct net_device *netdev, struct nfp_fl_payload *nfp_flow, enum nfp_flower_tun_type tun_type, struct netlink_ext_ack *extack) { - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); struct nfp_flower_priv *priv = app->priv; bool qinq_sup; u32 port_id; diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 621113650a9b..2af9faee96c5 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c @@ -290,8 +290,7 @@ nfp_check_mask_remove(struct nfp_app *app, char *mask_data, u32 mask_len, return true; } -int nfp_compile_flow_metadata(struct nfp_app *app, - struct flow_cls_offload *flow, +int nfp_compile_flow_metadata(struct nfp_app *app, u32 cookie, struct nfp_fl_payload *nfp_flow, struct net_device *netdev, struct netlink_ext_ack *extack) @@ -310,7 +309,7 @@ int nfp_compile_flow_metadata(struct nfp_app *app, } nfp_flow->meta.host_ctx_id = cpu_to_be32(stats_cxt); - nfp_flow->meta.host_cookie = cpu_to_be64(flow->cookie); + nfp_flow->meta.host_cookie = cpu_to_be64(cookie); nfp_flow->ingress_dev = netdev; ctx_entry = kzalloc(sizeof(*ctx_entry), GFP_KERNEL); @@ -357,7 +356,7 @@ int nfp_compile_flow_metadata(struct nfp_app *app, priv->stats[stats_cxt].bytes = 0; priv->stats[stats_cxt].used = jiffies; - check_entry = nfp_flower_search_fl_table(app, flow->cookie, netdev); + check_entry = nfp_flower_search_fl_table(app, cookie, netdev); if (check_entry) { NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot offload duplicate flow entry"); if (nfp_release_stats_entry(app, stats_cxt)) { diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 2406d33356ad..46bd5da89bfd 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -134,20 +134,16 @@ nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow, return 0; } -static bool nfp_flower_check_higher_than_mac(struct flow_cls_offload *f) +static bool nfp_flower_check_higher_than_mac(struct flow_rule *rule) { - struct flow_rule *rule = flow_cls_offload_flow_rule(f); - return flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS) || flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS) || flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS) || flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ICMP); } -static bool nfp_flower_check_higher_than_l3(struct flow_cls_offload *f) +static bool nfp_flower_check_higher_than_l3(struct flow_rule *rule) { - struct flow_rule *rule = flow_cls_offload_flow_rule(f); - return flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS) || flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ICMP); } @@ -240,11 +236,10 @@ static int nfp_flower_calculate_key_layers(struct nfp_app *app, struct net_device *netdev, struct nfp_fl_key_ls *ret_key_ls, - struct flow_cls_offload *flow, + struct flow_rule *rule, enum nfp_flower_tun_type *tun_type, struct netlink_ext_ack *extack) { - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); struct flow_dissector *dissector = rule->match.dissector; struct flow_match_basic basic = { NULL, NULL}; struct nfp_flower_priv *priv = app->priv; @@ -452,7 +447,7 @@ nfp_flower_calculate_key_layers(struct nfp_app *app, NL_SET_ERR_MSG_MOD(extack, "unsupported offload: match on given EtherType is not supported"); return -EOPNOTSUPP; } - } else if (nfp_flower_check_higher_than_mac(flow)) { + } else if (nfp_flower_check_higher_than_mac(rule)) { NL_SET_ERR_MSG_MOD(extack, "unsupported offload: cannot match above L2 without specified EtherType"); return -EOPNOTSUPP; } @@ -471,7 +466,7 @@ nfp_flower_calculate_key_layers(struct nfp_app *app, } if (!(key_layer & NFP_FLOWER_LAYER_TP) && - nfp_flower_check_higher_than_l3(flow)) { + nfp_flower_check_higher_than_l3(rule)) { NL_SET_ERR_MSG_MOD(extack, "unsupported offload: cannot match on L4 information without specified IP protocol type"); return -EOPNOTSUPP; } @@ -1005,9 +1000,7 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app, struct nfp_fl_payload *sub_flow1, struct nfp_fl_payload *sub_flow2) { - struct flow_cls_offload merge_tc_off; struct nfp_flower_priv *priv = app->priv; - struct netlink_ext_ack *extack = NULL; struct nfp_fl_payload *merge_flow; struct nfp_fl_key_ls merge_key_ls; struct nfp_merge_info *merge_info; @@ -1016,7 +1009,6 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app, ASSERT_RTNL(); - extack = merge_tc_off.common.extack; if (sub_flow1 == sub_flow2 || nfp_flower_is_merge_flow(sub_flow1) || nfp_flower_is_merge_flow(sub_flow2)) @@ -1061,9 +1053,8 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app, if (err) goto err_unlink_sub_flow1; - merge_tc_off.cookie = merge_flow->tc_flower_cookie; - err = nfp_compile_flow_metadata(app, &merge_tc_off, merge_flow, - merge_flow->ingress_dev, extack); + err = nfp_compile_flow_metadata(app, merge_flow->tc_flower_cookie, merge_flow, + merge_flow->ingress_dev, NULL); if (err) goto err_unlink_sub_flow2; @@ -1305,6 +1296,7 @@ static int nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, struct flow_cls_offload *flow) { + struct flow_rule *rule = flow_cls_offload_flow_rule(flow); enum nfp_flower_tun_type tun_type = NFP_FL_TUNNEL_NONE; struct nfp_flower_priv *priv = app->priv; struct netlink_ext_ack *extack = NULL; @@ -1330,7 +1322,7 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, if (!key_layer) return -ENOMEM; - err = nfp_flower_calculate_key_layers(app, netdev, key_layer, flow, + err = nfp_flower_calculate_key_layers(app, netdev, key_layer, rule, &tun_type, extack); if (err) goto err_free_key_ls; @@ -1341,7 +1333,7 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, goto err_free_key_ls; } - err = nfp_flower_compile_flow_match(app, flow, key_layer, netdev, + err = nfp_flower_compile_flow_match(app, rule, key_layer, netdev, flow_pay, tun_type, extack); if (err) goto err_destroy_flow; @@ -1356,7 +1348,7 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, goto err_destroy_flow; } - err = nfp_compile_flow_metadata(app, flow, flow_pay, netdev, extack); + err = nfp_compile_flow_metadata(app, flow->cookie, flow_pay, netdev, extack); if (err) goto err_destroy_flow; From patchwork Thu Jul 22 07:58:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 485120 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E511C63793 for ; Thu, 22 Jul 2021 07:58:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29AA860FDA for ; Thu, 22 Jul 2021 07:58:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231258AbhGVHSF (ORCPT ); Thu, 22 Jul 2021 03:18:05 -0400 Received: from mail-bn8nam11on2102.outbound.protection.outlook.com ([40.107.236.102]:43163 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231219AbhGVHSA (ORCPT ); Thu, 22 Jul 2021 03:18:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HuSdVeD17VzjPjq6euDAx4+vRkOOqUg9Cxl/KwRg/ujylapbfBkqVEP/5YQC5du1+aTF94mDuLTWjJZwkwxPDqs26bxGcY3nooOYR5qFJW7hcBBvf3hjEkmxL9nEoNYYuyGCzkB3ZHG4PcotJ+tg/efTWpnFF/6ZBPfEuf6k4qQJfVyL8gYMD7hWFrW/0M09xkbwUvahdNs4TxlkrAb8W4IU77jRJ3hbxF/r8kMAcbuGBhhl6kbt35uVI20UF2RKzCJo5PRFkNw0rH4AzdStMJDtVZQXQ/qmKewp55cjOSVYOFB41TqL2gSQCa9Q19DNFe+6Kl6Wgx7bo4oAaYbEWg== 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-SenderADCheck; bh=exMRxsHVpg1lAcVliXsuus0Uv8cROtl/IERjGNBR/H4=; b=R7WLIBK1JET1BL3DoMLHnvaknb/1Yb7nJn8SGy/u8WLlH3uuSE36axTqa8r/mVesbrrtDH3SF1Xm++gBRnld5X+fBJ1Bk7U6z+hpkPjfVRjgk67pS9SMBU+HOCnYGhKQBPWPnxvwAitGT6qBtoSCI1VM3qcgtTlbRoOeGVxvPzKH1a7ZqJdRWVyOxZF6bXzhgKwuZVTg4fQIWxC6Z7f0wsndiY+WSXVGT/CwX3vvtdVMtq2m1wxN/f5johWezv9cWTweNkfReDZukfxyArYu/oUQYfVlwSttKEoak+p18i/KjpSuz/1zOSzqMOhd91jXmDPjEWsj4E+B3iDvNLaPsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=exMRxsHVpg1lAcVliXsuus0Uv8cROtl/IERjGNBR/H4=; b=AL1AlSRZPHIsqqtQxp+N0J3xJPmz2yF5hJCl8xO26bRUPjNDnEzpL21frB8Lenxswja91sDyffmi4A+6wdOyIDlTTcaS70WR7fZ6uDHomiybO25NmpJZHEEYXnGkn/UAmlyTkL8KN8I89HanJWrpaksUKrpTbZcbhRqqIFsCEe0= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4892.namprd13.prod.outlook.com (2603:10b6:510:74::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.11; Thu, 22 Jul 2021 07:58:33 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3%7]) with mapi id 15.20.4352.024; Thu, 22 Jul 2021 07:58:33 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Yinjun Zhang , Louis Peens , Simon Horman Subject: [PATCH net-next 3/9] nfp: flower: refactor action offload code slightly Date: Thu, 22 Jul 2021 09:58:02 +0200 Message-Id: <20210722075808.10095-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722075808.10095-1-simon.horman@corigine.com> References: <20210722075808.10095-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Thu, 22 Jul 2021 07:58:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72d3c2d0-a680-408d-4c76-08d94ce68076 X-MS-TrafficTypeDiagnostic: PH0PR13MB4892: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:316; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YtAcJVx1uETY71SfSsPpZx7Hz1diEdAeuREUHrsaJ7BqvCKuObRvgIgui5Xx+pxNlef6JkvX05c66JcpiFm5YVS81zJMigc83rM9A9p7hc4o7QjN+QYDRzFslDVLWCwsy2SfrlOEO88QRqnQ4nSEg0BUbL2L6VRvYZx54e/NpUZ1UlLlPejLOaG7VC+eyJEaDX4pQXa9cj4wmMqiFZiki1ZBmAXyK4E2+ULpq2y9EQfCH8QUMANGuCH4UVs6Vj/41xs0whvBZG3xkTdRXPl3+JeI4RqUh/H6KVX1ougiWLfVeZbdo4POv75wZuGvo9kKVVegGITt8Z/XvkcQAi81nHGa0BikDZunVDzFhxASCJVNidynHw2LGmSUfQC7DH2cGs66rLzuptip3GFy/O2k8VTEGbN6te7I4x5lv4IzxJ+QG88w92bt+z3RmJX83HlJOMA0lerGhWTXqFEJuCvS6MDTNtRiwzQvnxB/hhzXzZiyrF+CE9J0J6LY8vPwNznbIF4h4Spmx+dzATXSJNIX9PN5XFiasaPesvWaitKVPUVgVbkJcng/yhQxVmK2NM3I9WqaLXOUK5uqy2vOrUQLgcHrwy8+fy4N8UVdhjzk8nkVJIwTqhS8DvdJsRJiRtiuSud/V0t6EL5for6CMzvgUA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(376002)(39830400003)(396003)(136003)(346002)(52116002)(4326008)(6666004)(316002)(6506007)(1076003)(8936002)(5660300002)(8676002)(6486002)(186003)(107886003)(6512007)(110136005)(478600001)(2906002)(54906003)(36756003)(86362001)(44832011)(83380400001)(38100700002)(2616005)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z/fGE94drQp9ZIfpJaVW6XYtGHcB3TPW0kKQbPZmjJU8ySmdYHbCn9ugC+iM2FwanTC4e4Bm7MKdjv/K9wkXl3QimdqZvMJ/HdhyRoYd8xJtQ7FUFerrzkRUib9JKkE2DTdzGJurRJRfkitV/FMm7srSnfrmYE97Ug0B1icOTQphBpPbzPCeqRhS6XkMbu0stN8m7NRrQuQZBhKGjhfZXaQE2WYcRiDfDcEi7oyFPEmMzJWqiUiCptQ2YUuUOVukgCo44lSjL4NJUNeDsedLl6505jk9ewUCzLkaPtYDtYZKTpFWvJkY5R0jyowf1PepIpeoLqPtklSm6Q++NtrbtcbOiTVtDjNDiHI0pIpjKIr3E6xbBPHpmCvNGPf5FbGIU106DPCFu+YU1K6oi55UAW2TFVcqFK+m6hyMnwv2VgAXDrgwBHsEdQEE7enN6l+ZoQpRs2/7mFCRFjaBPJ39vFoZWGaFExgTjqmG35pwv3X0fvV8W+YOF2HFuZEDKfL+1tkOSBOufCIpcXQ+xyF/v4j1Vq+0L8+no0Jq73q9NPLB2VPGFZIfxrinuyvJxNMVTMdMLz0wmcQiO6asvXRTL0SI3AdVHWunQdXGSpUrDpMvki4/ZdTNFGn2BWt8sNKI2VNbB6dqE7mk8Kb4FKIikf/X0yAZqdLbNFiIPmfWlg9X3THhnpKf9IDTJFqB9OAX5dMfPlIdohW8Q45A79CjL/+X/LB2Mk8gQR6p5Th6jzCUuxab5CkQXXuajz9Gv//r+KAC4LFrApR8kyct2w61qq7oSXWCjRjGQa1txe+x2P5MhWlhi5qh85+PKgUgdt1esqBsHXIraRyRUT2ydM484O1i33IjF15WY0gHL4Piiufutnc3IgJiYqUM8TQdZFaClvTGtYOex4qMkqNYCbEsM2ClTD3Dx0cS8zE3BhMeZJLeHAbQ/NMVZToZuvikKQyLvsX40Bi16b32GHiGYjsCTjxLXty2WcJg+0wfhbdYEeJBY248vzU65JWCSRLk2pSxth8UFuozwI/YTmIf4cABSG274v593WGl2QogL7GbeIqlT/kX32L6ngLmzt2f0/3jv2uZMFQHDNRnEtHen9sKlwA1rcj+YLPu66mogHyjEnpyakQnDlmM/f61rSvxeqVRlI8rRfFyvpIYK5O65ohYoqlysXMb1Tnubi7Ram276iltYzOvA+Z+4Os86NCWGYZA577+kgdqve9LhHBlvjr9TEA2BGZncFu0QJnhg0S/k33GC6D376zS1q1ZFbGC8OpxiGRKAsgDCtH6Q8RHzbmktndVY385xLF5oLWtgMZccz863DXLrR/frKDwDwYWobVNr/+A3w5l01MI4FLARQek/ehE84KkfvNGWn9g/GQaKaHKaA5cbFmiXaEkefxNoXga X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72d3c2d0-a680-408d-4c76-08d94ce68076 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:58:33.1967 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SUlRqWhuZ4kbY8hVoXbUw/nFnN2Ct9rftErQr/s4BZAPVuUKezv5fuJ953tknRErAPdwlxQ3DRHLSbL35Dzz2EWKnPSmJ+i6B3/lxQobpyw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4892 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Change the action related offload functions to take in flow_rule * as input instead of flow_cls_offload * as input. The flow_rule parts of flow_cls_offload is the only part that is used in any case, and this is required for more conntrack offload patches which will follow later. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/action.c | 35 +++++++++---------- .../net/ethernet/netronome/nfp/flower/main.h | 2 +- .../ethernet/netronome/nfp/flower/offload.c | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index 1cbe2c9f3959..2a432de11858 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c @@ -262,10 +262,10 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output, } static bool -nfp_flower_tun_is_gre(struct flow_cls_offload *flow, int start_idx) +nfp_flower_tun_is_gre(struct flow_rule *rule, int start_idx) { - struct flow_action_entry *act = flow->rule->action.entries; - int num_act = flow->rule->action.num_entries; + struct flow_action_entry *act = rule->action.entries; + int num_act = rule->action.num_entries; int act_idx; /* Preparse action list for next mirred or redirect action */ @@ -279,7 +279,7 @@ nfp_flower_tun_is_gre(struct flow_cls_offload *flow, int start_idx) static enum nfp_flower_tun_type nfp_fl_get_tun_from_act(struct nfp_app *app, - struct flow_cls_offload *flow, + struct flow_rule *rule, const struct flow_action_entry *act, int act_idx) { const struct ip_tunnel_info *tun = act->tunnel; @@ -288,7 +288,7 @@ nfp_fl_get_tun_from_act(struct nfp_app *app, /* Determine the tunnel type based on the egress netdev * in the mirred action for tunnels without l4. */ - if (nfp_flower_tun_is_gre(flow, act_idx)) + if (nfp_flower_tun_is_gre(rule, act_idx)) return NFP_FL_TUNNEL_GRE; switch (tun->key.tp_dst) { @@ -788,11 +788,10 @@ struct nfp_flower_pedit_acts { }; static int -nfp_fl_commit_mangle(struct flow_cls_offload *flow, char *nfp_action, +nfp_fl_commit_mangle(struct flow_rule *rule, char *nfp_action, int *a_len, struct nfp_flower_pedit_acts *set_act, u32 *csum_updated) { - struct flow_rule *rule = flow_cls_offload_flow_rule(flow); size_t act_size = 0; u8 ip_proto = 0; @@ -890,7 +889,7 @@ nfp_fl_commit_mangle(struct flow_cls_offload *flow, char *nfp_action, static int nfp_fl_pedit(const struct flow_action_entry *act, - struct flow_cls_offload *flow, char *nfp_action, int *a_len, + char *nfp_action, int *a_len, u32 *csum_updated, struct nfp_flower_pedit_acts *set_act, struct netlink_ext_ack *extack) { @@ -977,7 +976,7 @@ nfp_flower_output_action(struct nfp_app *app, static int nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, - struct flow_cls_offload *flow, + struct flow_rule *rule, struct nfp_fl_payload *nfp_fl, int *a_len, struct net_device *netdev, enum nfp_flower_tun_type *tun_type, int *tun_out_cnt, @@ -1045,7 +1044,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, case FLOW_ACTION_TUNNEL_ENCAP: { const struct ip_tunnel_info *ip_tun = act->tunnel; - *tun_type = nfp_fl_get_tun_from_act(app, flow, act, act_idx); + *tun_type = nfp_fl_get_tun_from_act(app, rule, act, act_idx); if (*tun_type == NFP_FL_TUNNEL_NONE) { NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported tunnel type in action list"); return -EOPNOTSUPP; @@ -1086,7 +1085,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, /* Tunnel decap is handled by default so accept action. */ return 0; case FLOW_ACTION_MANGLE: - if (nfp_fl_pedit(act, flow, &nfp_fl->action_data[*a_len], + if (nfp_fl_pedit(act, &nfp_fl->action_data[*a_len], a_len, csum_updated, set_act, extack)) return -EOPNOTSUPP; break; @@ -1195,7 +1194,7 @@ static bool nfp_fl_check_mangle_end(struct flow_action *flow_act, } int nfp_flower_compile_action(struct nfp_app *app, - struct flow_cls_offload *flow, + struct flow_rule *rule, struct net_device *netdev, struct nfp_fl_payload *nfp_flow, struct netlink_ext_ack *extack) @@ -1207,7 +1206,7 @@ int nfp_flower_compile_action(struct nfp_app *app, bool pkt_host = false; u32 csum_updated = 0; - if (!flow_action_hw_stats_check(&flow->rule->action, extack, + if (!flow_action_hw_stats_check(&rule->action, extack, FLOW_ACTION_HW_STATS_DELAYED_BIT)) return -EOPNOTSUPP; @@ -1219,18 +1218,18 @@ int nfp_flower_compile_action(struct nfp_app *app, tun_out_cnt = 0; out_cnt = 0; - flow_action_for_each(i, act, &flow->rule->action) { - if (nfp_fl_check_mangle_start(&flow->rule->action, i)) + flow_action_for_each(i, act, &rule->action) { + if (nfp_fl_check_mangle_start(&rule->action, i)) memset(&set_act, 0, sizeof(set_act)); - err = nfp_flower_loop_action(app, act, flow, nfp_flow, &act_len, + err = nfp_flower_loop_action(app, act, rule, nfp_flow, &act_len, netdev, &tun_type, &tun_out_cnt, &out_cnt, &csum_updated, &set_act, &pkt_host, extack, i); if (err) return err; act_cnt++; - if (nfp_fl_check_mangle_end(&flow->rule->action, i)) - nfp_fl_commit_mangle(flow, + if (nfp_fl_check_mangle_end(&rule->action, i)) + nfp_fl_commit_mangle(rule, &nfp_flow->action_data[act_len], &act_len, &set_act, &csum_updated); } diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 004665567b5a..b5bb13de73df 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -475,7 +475,7 @@ int nfp_flower_compile_flow_match(struct nfp_app *app, enum nfp_flower_tun_type tun_type, struct netlink_ext_ack *extack); int nfp_flower_compile_action(struct nfp_app *app, - struct flow_cls_offload *flow, + struct flow_rule *rule, struct net_device *netdev, struct nfp_fl_payload *nfp_flow, struct netlink_ext_ack *extack); diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 46bd5da89bfd..ad97770fa39c 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1338,7 +1338,7 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, if (err) goto err_destroy_flow; - err = nfp_flower_compile_action(app, flow, netdev, flow_pay, extack); + err = nfp_flower_compile_action(app, rule, netdev, flow_pay, extack); if (err) goto err_destroy_flow; From patchwork Thu Jul 22 07:58:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 484333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91D62C63793 for ; Thu, 22 Jul 2021 07:58:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7166F61221 for ; Thu, 22 Jul 2021 07:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231238AbhGVHSL (ORCPT ); Thu, 22 Jul 2021 03:18:11 -0400 Received: from mail-sn1anam02on2093.outbound.protection.outlook.com ([40.107.96.93]:59110 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231232AbhGVHSB (ORCPT ); Thu, 22 Jul 2021 03:18:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KZB4Q6vNkALJ1ZtjDtF4nf1rcoRYfSeiqPLHCiX9Bp/7jpmgmbfOrk16Obe7G/tLi67kceVglEASgpOp8SKf61YwQNCSKjWWsoAe/fnh3tq3meQ777pMDUUrdBBsx4sAvmmMgQN/vwQjCWkR68TIAkjR7CvsvuSthlx/UfTbmv0SsZClAMpAanfMValNXgI3jiHmr0xrNiaKrlBdhpssEmMNygavkZP3vwOi49GNwHPa1MFKOGcWwmc/onsuwNZwwLM8RLPl6IAcmHo7jElyrEs1bUInU0XP+5eLmLo7PxpmrSkA8BV797zo1d5Th9OorNTD5/ZSng4U38hIzafE2w== 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-SenderADCheck; bh=Ih75NE3OMmaYlyEDREK7dbRe3vakN/2EeVUD3UPxUZ0=; b=Uw8JwVt1pSdj7vInGvQyxXGLf32IdtB+hwauyGT9VEyHfvgpmmLnspf9Y7uWVLTlnsRfJFEUKi9CQ1LThzp73WCOhu0NFXSJGCPAPZK3zaDa6eWpYMgJ1s1DKaEKfT4q2XtARSRNkRMRtuA+WDEnPIq4A4yC7DFbUQgLGrlO3Luua4GSIYJ64F8YszzJJ9t9poXPLtlBFCEbjoJh9wkLyvCCC3UNq9QyNA9cr9X7FMqWqtWpnkVv4QsDu9GxZkLSfmSMWr0CWto39ewrQt+Wn5gIPSAj7kZs3D3ohczp88xTMNG7KhjSUU2SLHH5EzB/ob/ZT3jSBAoJZj/wYbr+pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ih75NE3OMmaYlyEDREK7dbRe3vakN/2EeVUD3UPxUZ0=; b=dqq/XzBccS3rmtDG8K9vX0UOoHCI4PIUllE+H5MiqGNItleWdEtL+ghBW69kVHhMw8Qy0H9/gfMJRPkpDcyrTSemCIF8hkboI6FFLuFZ9VXn6/QNcgrT8iFE3HBK6pE+8eTUebqZKLl73ZGcXQjao9kuJo3Ujs6Y0+yh5yPLuP8= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4778.namprd13.prod.outlook.com (2603:10b6:510:76::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Thu, 22 Jul 2021 07:58:34 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3%7]) with mapi id 15.20.4352.024; Thu, 22 Jul 2021 07:58:34 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Yinjun Zhang , Louis Peens , Simon Horman Subject: [PATCH net-next 4/9] nfp: flower-ct: calculate required key_layers Date: Thu, 22 Jul 2021 09:58:03 +0200 Message-Id: <20210722075808.10095-5-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722075808.10095-1-simon.horman@corigine.com> References: <20210722075808.10095-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Thu, 22 Jul 2021 07:58:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d8383a7-ec2d-42f6-2b95-08d94ce6816d X-MS-TrafficTypeDiagnostic: PH0PR13MB4778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xmK4ZTTuYOrhDptAaeS4Ms9RshkyKdDmB6FVTgzP+wywsaTm9bb5yRuVS/INGf3KgjqoSZHP5evwX2yPB3Quxg/F33LRk2KHchNW8NDu1z19tL27wMFYF9ND5U1i4EyzpYQ8dLWd4iSxz3z27C88QKqr0qCu+pZANsBdhMS6RSOas74/NEzzp8wRB7n6Mn3gY005LLd1zpegVBGq8zj0jLEsd0/7iONK0lo7M/zDNHAN3+NchLKcoWaKLSP8NnhlyeYs+ybVlFXueMb0hK3SsNUGPtO+QYxkQD9b42FqUqt1TeHtokriGluMz+/kb7xYP2J32Tmngp/IFQxTuglt85GZ2I5KsdSPYbgl2Fq5QioC6XgKBCOjCUXMal7tRiYqy//aYcwgF/c9raZuLWaGpQowNQBVi+Dm78gzfqM61Ljm9xv/+6Fli1l0HlNaTyrC55U1/xqDHLrHbeDf407FZTCuBz0RfTAXIfkp1prDVfbFmysNOnskrj3bc9pNe7T5ztfWPFs9+oQW4x3We6xTT5ZDH9BMob314U9TU7JXd7qhmskiGa2Ab+eZd6uhjenI+p94GmGebM8UC+f3NAe7nNxEjye73uVrOcZSjiN9wF7wVsiZEnWF7j5sFJ6aW64n+sw7cWbLyUcTzzkA2w2XOg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(396003)(366004)(39830400003)(44832011)(2616005)(36756003)(66476007)(8936002)(66556008)(8676002)(5660300002)(54906003)(6486002)(107886003)(186003)(38100700002)(6666004)(478600001)(2906002)(66946007)(6512007)(52116002)(1076003)(6506007)(110136005)(83380400001)(86362001)(4326008)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 99xB/TReXIOsJHM+uJM9AJolUyJQo8GCB4bfuBq99ZhAQCiuzobzgxw19q/lN/4ZJyVO7XJkGs/Hlu6qgzfCRsgZLKvjEhVS7WS5jTyRlELYqRlWzX/av6GthfLQP/vvrWLPiX9vAb1NWHSJGd5Ad6SJLKdohxoV1Ec5ovYldR51K4EPvHDlwXiXvvauXz8quhpFNwPeAL3AG0tIWUu04Owp8J9OCgEJhmiXdW1qHcq7ktiTbPghBId5YUZA+PcGF19CZNEkkdGcWT1/mze2IHp3HBndEKqrEAu2kbMjjDBk/u0a/2ZSfsDM/Xu0on+cEWJgGpe7+9bnCZ3ixHf1ktosYaeGAQ4DWuJAf+zH8L5TXooyvTTaObIROqoCmDrUIR14lWsfrB3vy90jnt59Hocs71FGFTz03Sq2jPfMa6fLNovHY+UNws6vK7nKCmIy4G7vwBTjEZw27pT8QnVmbw4y7iKEf8StTOzBrGBWheGA87shZubTK0NW1VnE2a/5fEL8KH2ebgQMVCmZLNtxAlIso0J7iRj/4kRsWXmKzmxBBtGbjw1lDZLde5jgNwZ2lG6+FPOcwONsn2G3+86ICw6cJjKt4+dPLb8ha0gp9f81f8z798HO6MpAXERVZZalxnmjOyiZdT/pEwhCqCzEEQ4/5/runZHuZU3DnGQdo1i8fmnCKW3xtSd2/Fovu9gGG7mHumd2wYUJZB7ThSjabq11GE+Fd3gI/a5b9fzX/IFlZJp+ALnQimlh58Oc4xwy+dxWHF3LlghvzIMCEpndIfMX6ccrUId/XPbDUmK6+7RVQz4dGPh4Yabw1CrbKcc8fqQUdB9n0Lp+K/7P7a9RTpWZNwIcLncS48C5PSwTJqf+L4a7T4pZkDfUHYlLt8nbtg1K3aKzUR1/2ONeJN5gUwnCTQ24P2xL2M277DHD3dQoVrB7uHX990lpSDC0E8V6lgfvDeaZ0It7j6Ae0kW0pqoOEzCnv7dRL9AV2S+Zw9LY9gJbyFiIZ9DX18pQS3j7oERaN1Phc0PmZguong3ULxjLmE2TgcJ6Dj7w6+mOU/yoD059ayAQS65rZj3IN3o8PDu2wd3puQChzJE5KDzm5zUoF/fM/SxhwYawfFLGQzuvf06SwXTMY8wSp2tlnMJjrzXTqYv+cTUF+DKBzmd6gc69V18y/oWF9xNtP6F9kGMsqg+4KG9D9cODOIaOpeVr56EWO7Mt9SgmbJhlcfeMFSfynDclHkbIPrJ/T4EkZlNIyw2BWP/fF/boU+5VNVWoA+DaSRc+gYDzrDIst8MI5hyNU6VSQubnuQneUlt9tmeHbRGXXqT91ek2s7F3Sfb2inUgmiIvfgbASVbDviJV2wyY3k/c0FnwaquysrtjxbqcUgxIh1hw2zod5Y0hBJDP X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d8383a7-ec2d-42f6-2b95-08d94ce6816d X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:58:34.8305 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gZsSMONeMMsRNYEy7MCsx6TFrLJZ67DLe8Fx07roGZrS6JAs4wY23TfSi954kDLrpFTE3hHmasvbTq8S9t13AKGpCXrqr6oZ2oLnjAyHR3Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4778 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens This calculates the correct combined keylayers and key_layer_size for the to-be-offloaded flow. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 94 +++++++++++++++++++ .../ethernet/netronome/nfp/flower/conntrack.h | 18 ++++ .../net/ethernet/netronome/nfp/flower/main.h | 9 ++ .../ethernet/netronome/nfp/flower/offload.c | 6 +- 4 files changed, 125 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 128020b1573e..e3fbd6b74746 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -407,8 +407,102 @@ static int nfp_ct_check_meta(struct nfp_fl_ct_flow_entry *post_ct_entry, return -EINVAL; } +static int +nfp_fl_calc_key_layers_sz(struct nfp_fl_key_ls in_key_ls, uint16_t *map) +{ + int key_size; + + /* This field must always be present */ + key_size = sizeof(struct nfp_flower_meta_tci); + map[FLOW_PAY_META_TCI] = 0; + + if (in_key_ls.key_layer & NFP_FLOWER_LAYER_EXT_META) { + map[FLOW_PAY_EXT_META] = key_size; + key_size += sizeof(struct nfp_flower_ext_meta); + } + if (in_key_ls.key_layer & NFP_FLOWER_LAYER_PORT) { + map[FLOW_PAY_INPORT] = key_size; + key_size += sizeof(struct nfp_flower_in_port); + } + if (in_key_ls.key_layer & NFP_FLOWER_LAYER_MAC) { + map[FLOW_PAY_MAC_MPLS] = key_size; + key_size += sizeof(struct nfp_flower_mac_mpls); + } + if (in_key_ls.key_layer & NFP_FLOWER_LAYER_TP) { + map[FLOW_PAY_L4] = key_size; + key_size += sizeof(struct nfp_flower_tp_ports); + } + if (in_key_ls.key_layer & NFP_FLOWER_LAYER_IPV4) { + map[FLOW_PAY_IPV4] = key_size; + key_size += sizeof(struct nfp_flower_ipv4); + } + if (in_key_ls.key_layer & NFP_FLOWER_LAYER_IPV6) { + map[FLOW_PAY_IPV6] = key_size; + key_size += sizeof(struct nfp_flower_ipv6); + } + + if (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_GRE) { + map[FLOW_PAY_GRE] = key_size; + if (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_TUN_IPV6) + key_size += sizeof(struct nfp_flower_ipv6_gre_tun); + else + key_size += sizeof(struct nfp_flower_ipv4_gre_tun); + } + + if (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_QINQ) { + map[FLOW_PAY_QINQ] = key_size; + key_size += sizeof(struct nfp_flower_vlan); + } + + if ((in_key_ls.key_layer & NFP_FLOWER_LAYER_VXLAN) || + (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_GENEVE)) { + map[FLOW_PAY_UDP_TUN] = key_size; + if (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_TUN_IPV6) + key_size += sizeof(struct nfp_flower_ipv6_udp_tun); + else + key_size += sizeof(struct nfp_flower_ipv4_udp_tun); + } + + if (in_key_ls.key_layer_two & NFP_FLOWER_LAYER2_GENEVE_OP) { + map[FLOW_PAY_GENEVE_OPT] = key_size; + key_size += sizeof(struct nfp_flower_geneve_options); + } + + return key_size; +} + static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) { + enum nfp_flower_tun_type tun_type = NFP_FL_TUNNEL_NONE; + struct nfp_fl_ct_zone_entry *zt = m_entry->zt; + struct nfp_fl_key_ls key_layer, tmp_layer; + struct nfp_flower_priv *priv = zt->priv; + u16 key_map[_FLOW_PAY_LAYERS_MAX]; + + struct flow_rule *rules[_CT_TYPE_MAX]; + int i, err; + + rules[CT_TYPE_PRE_CT] = m_entry->tc_m_parent->pre_ct_parent->rule; + rules[CT_TYPE_NFT] = m_entry->nft_parent->rule; + rules[CT_TYPE_POST_CT] = m_entry->tc_m_parent->post_ct_parent->rule; + + memset(&key_layer, 0, sizeof(struct nfp_fl_key_ls)); + memset(&key_map, 0, sizeof(key_map)); + + /* Calculate the resultant key layer and size for offload */ + for (i = 0; i < _CT_TYPE_MAX; i++) { + err = nfp_flower_calculate_key_layers(priv->app, + m_entry->netdev, + &tmp_layer, rules[i], + &tun_type, NULL); + if (err) + return err; + + key_layer.key_layer |= tmp_layer.key_layer; + key_layer.key_layer_two |= tmp_layer.key_layer_two; + } + key_layer.key_size = nfp_fl_calc_key_layers_sz(key_layer, key_map); + return 0; } diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index 170b6cdb8cd0..bd07a20d054b 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -83,6 +83,24 @@ enum ct_entry_type { CT_TYPE_PRE_CT, CT_TYPE_NFT, CT_TYPE_POST_CT, + _CT_TYPE_MAX, +}; + +enum nfp_nfp_layer_name { + FLOW_PAY_META_TCI = 0, + FLOW_PAY_INPORT, + FLOW_PAY_EXT_META, + FLOW_PAY_MAC_MPLS, + FLOW_PAY_L4, + FLOW_PAY_IPV4, + FLOW_PAY_IPV6, + FLOW_PAY_CT, + FLOW_PAY_GRE, + FLOW_PAY_QINQ, + FLOW_PAY_UDP_TUN, + FLOW_PAY_GENEVE_OPT, + + _FLOW_PAY_LAYERS_MAX }; /** diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index b5bb13de73df..226bcbf6e5b5 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -551,4 +551,13 @@ int nfp_flower_xmit_pre_tun_flow(struct nfp_app *app, struct nfp_fl_payload *flow); int nfp_flower_xmit_pre_tun_del_flow(struct nfp_app *app, struct nfp_fl_payload *flow); + +struct nfp_fl_payload * +nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer); +int nfp_flower_calculate_key_layers(struct nfp_app *app, + struct net_device *netdev, + struct nfp_fl_key_ls *ret_key_ls, + struct flow_rule *flow, + enum nfp_flower_tun_type *tun_type, + struct netlink_ext_ack *extack); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index ad97770fa39c..87a32e9fe4e5 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -41,6 +41,8 @@ BIT(FLOW_DISSECTOR_KEY_ENC_OPTS) | \ BIT(FLOW_DISSECTOR_KEY_ENC_IP) | \ BIT(FLOW_DISSECTOR_KEY_MPLS) | \ + BIT(FLOW_DISSECTOR_KEY_CT) | \ + BIT(FLOW_DISSECTOR_KEY_META) | \ BIT(FLOW_DISSECTOR_KEY_IP)) #define NFP_FLOWER_WHITELIST_TUN_DISSECTOR \ @@ -232,7 +234,7 @@ nfp_flower_calc_udp_tun_layer(struct flow_dissector_key_ports *enc_ports, return 0; } -static int +int nfp_flower_calculate_key_layers(struct nfp_app *app, struct net_device *netdev, struct nfp_fl_key_ls *ret_key_ls, @@ -538,7 +540,7 @@ nfp_flower_calculate_key_layers(struct nfp_app *app, return 0; } -static struct nfp_fl_payload * +struct nfp_fl_payload * nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer) { struct nfp_fl_payload *flow_pay; From patchwork Thu Jul 22 07:58:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 485119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D9B5C63797 for ; Thu, 22 Jul 2021 07:58:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03D54610CC for ; Thu, 22 Jul 2021 07:58:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231252AbhGVHSM (ORCPT ); Thu, 22 Jul 2021 03:18:12 -0400 Received: from mail-sn1anam02on2093.outbound.protection.outlook.com ([40.107.96.93]:59110 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231229AbhGVHSJ (ORCPT ); Thu, 22 Jul 2021 03:18:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ShtR8/u39h4YeliTJyec3srXj6phjsldsky2JPRwNKyIdzg2Bod0hAaoAH1jtO3oRNt7YfzY6wSP9s56hJ37IxS8xJYECddA0Fz6AvJvHYb1NZPqWdukVImwGM4uhB+8XCMrMzov4mUrph01UzCz/D2gBqBbJT3GCmV/Fo3IdVse4JXFQOHSbo33cDF9ckd2m8LRQA0VvWCocYtxZ6SX6P7F4JgT67kXG9CYQS/oA71PYtyyGXdyupm516SAWyxlprP/cJAS+cvajWJXKUsAFzZkL5jtSlTWKgLUYUSD/Ikw8tsD6DFLaZkXC32HS3aQaBypqdOMUzwVO3/JnDxC5g== 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-SenderADCheck; bh=wq87lS/zyx9+ZHwGuAZ/0BsU4bkRsIRTvBZ8wyilxOY=; b=mX3llmuhoKap3qVzYjAeQC+tMB01P0WnOYnrNM06vS9k1ufHCu9sWgyZnTGjt0UFJkdH0aPSb8gE99PVEi0F+0Ij56djQNXlMJaOE7s/1W7NdNkGjWhjzZ9bC+V8RahIAJAt8Xtj3pQjWh9PQTE5KDufEPmKtDQQLFWc2oWovV+F5uTl/mphyqB0hHD/CwV4/32OMU2V7BwrYN6gUNaqcpXvehb3he/WH4kTGdhn9TrB+PU+CF3eV9ANh7BH9jQCaLKXZSFb6UHg+qMONA78l4/2l/m+smInqY+p/6TBWWTfwOfu1hsXjkPRtz3gW7qigiAIkqrliFK6fZUKRRB2aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wq87lS/zyx9+ZHwGuAZ/0BsU4bkRsIRTvBZ8wyilxOY=; b=LjRQRarAHxzfVmxWMDojCYMBW/9fF7LD5oOULcuRRyntSDXVnRZJQgowPXgm1eRVcyTCZzN8EyKepuXMcuUX6ShT6GhkXuNT414Vj1VIelUtHeJXg+m5vN+XYWzumQ9nWyBAUH2IXJalkYGIUfRPulxtOKDHwpRlRCzOk9rOWQw= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4778.namprd13.prod.outlook.com (2603:10b6:510:76::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Thu, 22 Jul 2021 07:58:36 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3%7]) with mapi id 15.20.4352.024; Thu, 22 Jul 2021 07:58:36 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Yinjun Zhang , Louis Peens , Simon Horman Subject: [PATCH net-next 5/9] nfp: flower-ct: compile match sections of flow_payload Date: Thu, 22 Jul 2021 09:58:04 +0200 Message-Id: <20210722075808.10095-6-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722075808.10095-1-simon.horman@corigine.com> References: <20210722075808.10095-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Thu, 22 Jul 2021 07:58:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 802afa02-45b8-476d-044f-08d94ce68266 X-MS-TrafficTypeDiagnostic: PH0PR13MB4778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /b5wXBISlAIofImH2wY/JypYCYAsZoNEq/CBUQ2PrM6dCQm7gOWAxHj9EuLARZQPnNPMlna507W1grZdsxYPRSTVdaRfUb8fYYPOmEU/qQeCyJPB8X2P1+3WVdFvFx5dsFzpi/HIbNLQWJyo9DIDfQKrWSOa1frAztt3Df6meeARVUDX2VsU3ty6j1DSQO4rXFTM5YTREhs5K864zJbq02zMDdqEvhx1dTeQ7e3QFAnhY/am1gmXqJXnIqE3o/idPL5V72vYWCUCN6zjQNFk4gajcwIoZLisRSeMcRa1lKSBXo7nZ+j7FEqAuy5cyq3mrKLSPXq6VHkygcbgRGJD8m1cvHXWug9nklQFK55957M1uu0+KrL66fC37HxegLLYbnXxXxXvgvJvv5pEWs3u3fHKPUYHdSgFoOxZd9JC5c5NCMBoyQFLjhG6eYBp6tvkt+PSqCShHVjQ7JVOgbJYITjjrJAAbKA1nyUehyZU88WauO0vRhz0zhFLihOG9ZxEeeor3HMVtFQFlG18smLGkumTT2tsBdwXiZwtNc4TFWtYXQw05B57YtHTISKS28pqfTtV7WRXNM9B7AstyBFw394G8ZnAZ7sofUbFwq237Q0SQmvso8BjaOSkbRYyKvV2zxJFrJeUMEwVlDiqTkRcVg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(396003)(366004)(39830400003)(44832011)(2616005)(36756003)(66476007)(8936002)(66556008)(8676002)(5660300002)(54906003)(6486002)(107886003)(186003)(38100700002)(6666004)(478600001)(2906002)(66946007)(6512007)(52116002)(1076003)(6506007)(110136005)(83380400001)(86362001)(4326008)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4rSE5Xz1zGbu21+6lSL48wnkg9ly+XYX8KHnL3yC+vyf1+sxh4iFIShOr7Imw6n89CbUxhIoiH8ypmzTox6kR4pFOmhjjDvmUU23kNtwvl8tAluJ9MzrW5GvDHeKb/DscXIfkRU94l8De2Wk/79fPDUnz6B9oyDEac3bFKGWQrjsfbNrNvZuIplLKFAfQGAYLeY9XYNvDHT1dSYITEXlcDp9LVvXsU67Q3p5t1AiAMPi5NNwtViqPas7OfRpSryb9LntNX796QMgyqSqdm+ozKBzqUB8hwcsWRu05mmJN13WMNWvzM27x+ehRRmlfb7IhlX5CA9/YEFnqhikLRiv/sRbbZ+dQBtzx/MNarFOCrbJqrbHol3YGyUrQkt0hNE2u27XBRhESGhcdyCA1ZKSuVx5tcRvoXwSV7VSkz+g3E+sVWnn1AhkbOmTtBO6UQrJBFDu/8js9DRRsfRH3L+L/MwQPyAdA45W95kKPttstdsGYxOL4tMpy8FtrodkEBSuo5H5iH/3UY3ClwrA4ifqHObUh5EEkFWUQLlA6/PAo9G7FRGoO5EDNxolvhLzDgbwmyjiIu8ro2BCuTfkclKUJ+VYqKheX8Qpl6AAm/QOuZPbPhmcOoLdxoT1msrNM4yT9+9FmVu0i/Y50ch9JNRMlYBTVNQt86CVHYbv4TkMKnhK23pgF8JBqmWbfYuB4mtqPPOguMOXQ0MQ9KdtFNYLa6KmtRJBiMV203td6Hhk/YRp3WqLKHujDkZFhHwQ39xnw5mfQ4kne5eCx8HdHeKFhmO/vvmNavpOnoSvevvX5pYon/NAuiFzFMdrD2GA5Yn10zRktVpBoz8Koc709rAyxMQ05yyV7TGU3rwwJIBR6AgA1xd6v9qUFDATzxy9q9j8t8nJuuWJpu+mW5JNIkpFQ95jy8yU7fvw+5p+lnyTA6TgbAQY6LU968mytMs6VP4o2M/rhReAGbHrhZUiyNO1lmXb9HDwnOZKSnzoIx1uDfo5Wr+4RSli+4PlCNYy46IdwAFWAYRF55mGdOxtVeay/NyFpHR8aDisTXLKR3NCV6yh4l1Jjf3tqx7cWpGP4MLn/br2Li23WR5bxE2miw7z9xmzOYA+5NG/43fLFrovQpsf7kNvzEwVO5soBdRV9Rot0TUOl1dEdiDqeCmrbVP5HpYgxZ6nMqShioVocwiX1iQ+GUf09n/UaC3NT8k2ORxPo2l2+SO8qWCQ6y1jToiXz+ZBxEBt8wmOK5Fs+CihGLmBzd+q3iy1DPFBL3U4+HxrOHBoiT/uTkOQkwG+yr5fIQJatISYb74sxTSNI+FUfIaejx3Nh82st07ZMH++hvaMDm/9lZDBLyo3AZN+9szsY/dcoqQRaQwFsC5rQZbOs2sDEpjbN2GfXTEZcBoi80of X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 802afa02-45b8-476d-044f-08d94ce68266 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:58:36.4743 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YnqS/8bNReAqd+tYtzFO2GlnbaZs4NAlODw5fvUfBJeIHeyM+NHhN40bPAWkFQNtIxlUX6F3mzfb0LhBMVt2t7tywDg2Yrmi2IkoCBJiCqM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4778 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add in the code to compile match part of the payload that will be sent to the firmware. This works similar to match.c does it, but since three flows needs to be merged it iterates through all three rules in a loop and combine the match fields to get the most strict match as result. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 224 +++++++++++++++++- 1 file changed, 223 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index e3fbd6b74746..e057403c1a8f 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -478,10 +478,19 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) struct nfp_fl_key_ls key_layer, tmp_layer; struct nfp_flower_priv *priv = zt->priv; u16 key_map[_FLOW_PAY_LAYERS_MAX]; + struct nfp_fl_payload *flow_pay; struct flow_rule *rules[_CT_TYPE_MAX]; + u8 *key, *msk, *kdata, *mdata; + struct net_device *netdev; + bool qinq_sup; + u32 port_id; + u16 offset; int i, err; + netdev = m_entry->netdev; + qinq_sup = !!(priv->flower_ext_feats & NFP_FL_FEATS_VLAN_QINQ); + rules[CT_TYPE_PRE_CT] = m_entry->tc_m_parent->pre_ct_parent->rule; rules[CT_TYPE_NFT] = m_entry->nft_parent->rule; rules[CT_TYPE_POST_CT] = m_entry->tc_m_parent->post_ct_parent->rule; @@ -503,7 +512,220 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) } key_layer.key_size = nfp_fl_calc_key_layers_sz(key_layer, key_map); - return 0; + flow_pay = nfp_flower_allocate_new(&key_layer); + if (!flow_pay) + return -ENOMEM; + + memset(flow_pay->unmasked_data, 0, key_layer.key_size); + memset(flow_pay->mask_data, 0, key_layer.key_size); + + kdata = flow_pay->unmasked_data; + mdata = flow_pay->mask_data; + + offset = key_map[FLOW_PAY_META_TCI]; + key = kdata + offset; + msk = mdata + offset; + nfp_flower_compile_meta((struct nfp_flower_meta_tci *)key, + (struct nfp_flower_meta_tci *)msk, + key_layer.key_layer); + + if (NFP_FLOWER_LAYER_EXT_META & key_layer.key_layer) { + offset = key_map[FLOW_PAY_EXT_META]; + key = kdata + offset; + msk = mdata + offset; + nfp_flower_compile_ext_meta((struct nfp_flower_ext_meta *)key, + key_layer.key_layer_two); + nfp_flower_compile_ext_meta((struct nfp_flower_ext_meta *)msk, + key_layer.key_layer_two); + } + + /* Using in_port from the -trk rule. The tc merge checks should already + * be checking that the ingress netdevs are the same + */ + port_id = nfp_flower_get_port_id_from_netdev(priv->app, netdev); + offset = key_map[FLOW_PAY_INPORT]; + key = kdata + offset; + msk = mdata + offset; + err = nfp_flower_compile_port((struct nfp_flower_in_port *)key, + port_id, false, tun_type, NULL); + if (err) + goto ct_offload_err; + err = nfp_flower_compile_port((struct nfp_flower_in_port *)msk, + port_id, true, tun_type, NULL); + if (err) + goto ct_offload_err; + + /* This following part works on the assumption that previous checks has + * already filtered out flows that has different values for the different + * layers. Here we iterate through all three rules and merge their respective + * masked value(cared bits), basic method is: + * final_key = (r1_key & r1_mask) | (r2_key & r2_mask) | (r3_key & r3_mask) + * final_mask = r1_mask | r2_mask | r3_mask + * If none of the rules contains a match that is also fine, that simply means + * that the layer is not present. + */ + if (!qinq_sup) { + for (i = 0; i < _CT_TYPE_MAX; i++) { + offset = key_map[FLOW_PAY_META_TCI]; + key = kdata + offset; + msk = mdata + offset; + nfp_flower_compile_tci((struct nfp_flower_meta_tci *)key, + (struct nfp_flower_meta_tci *)msk, + rules[i]); + } + } + + if (NFP_FLOWER_LAYER_MAC & key_layer.key_layer) { + offset = key_map[FLOW_PAY_MAC_MPLS]; + key = kdata + offset; + msk = mdata + offset; + for (i = 0; i < _CT_TYPE_MAX; i++) { + nfp_flower_compile_mac((struct nfp_flower_mac_mpls *)key, + (struct nfp_flower_mac_mpls *)msk, + rules[i]); + err = nfp_flower_compile_mpls((struct nfp_flower_mac_mpls *)key, + (struct nfp_flower_mac_mpls *)msk, + rules[i], NULL); + if (err) + goto ct_offload_err; + } + } + + if (NFP_FLOWER_LAYER_IPV4 & key_layer.key_layer) { + offset = key_map[FLOW_PAY_IPV4]; + key = kdata + offset; + msk = mdata + offset; + for (i = 0; i < _CT_TYPE_MAX; i++) { + nfp_flower_compile_ipv4((struct nfp_flower_ipv4 *)key, + (struct nfp_flower_ipv4 *)msk, + rules[i]); + } + } + + if (NFP_FLOWER_LAYER_IPV6 & key_layer.key_layer) { + offset = key_map[FLOW_PAY_IPV6]; + key = kdata + offset; + msk = mdata + offset; + for (i = 0; i < _CT_TYPE_MAX; i++) { + nfp_flower_compile_ipv6((struct nfp_flower_ipv6 *)key, + (struct nfp_flower_ipv6 *)msk, + rules[i]); + } + } + + if (NFP_FLOWER_LAYER_TP & key_layer.key_layer) { + offset = key_map[FLOW_PAY_L4]; + key = kdata + offset; + msk = mdata + offset; + for (i = 0; i < _CT_TYPE_MAX; i++) { + nfp_flower_compile_tport((struct nfp_flower_tp_ports *)key, + (struct nfp_flower_tp_ports *)msk, + rules[i]); + } + } + + if (key_layer.key_layer_two & NFP_FLOWER_LAYER2_GRE) { + offset = key_map[FLOW_PAY_GRE]; + key = kdata + offset; + msk = mdata + offset; + if (key_layer.key_layer_two & NFP_FLOWER_LAYER2_TUN_IPV6) { + struct nfp_flower_ipv6_gre_tun *gre_match; + struct nfp_ipv6_addr_entry *entry; + struct in6_addr *dst; + + for (i = 0; i < _CT_TYPE_MAX; i++) { + nfp_flower_compile_ipv6_gre_tun((void *)key, + (void *)msk, rules[i]); + } + gre_match = (struct nfp_flower_ipv6_gre_tun *)key; + dst = &gre_match->ipv6.dst; + + entry = nfp_tunnel_add_ipv6_off(priv->app, dst); + if (!entry) + goto ct_offload_err; + + flow_pay->nfp_tun_ipv6 = entry; + } else { + __be32 dst; + + for (i = 0; i < _CT_TYPE_MAX; i++) { + nfp_flower_compile_ipv4_gre_tun((void *)key, + (void *)msk, rules[i]); + } + dst = ((struct nfp_flower_ipv4_gre_tun *)key)->ipv4.dst; + + /* Store the tunnel destination in the rule data. + * This must be present and be an exact match. + */ + flow_pay->nfp_tun_ipv4_addr = dst; + nfp_tunnel_add_ipv4_off(priv->app, dst); + } + } + + if (NFP_FLOWER_LAYER2_QINQ & key_layer.key_layer_two) { + offset = key_map[FLOW_PAY_QINQ]; + key = kdata + offset; + msk = mdata + offset; + for (i = 0; i < _CT_TYPE_MAX; i++) { + nfp_flower_compile_vlan((struct nfp_flower_vlan *)key, + (struct nfp_flower_vlan *)msk, + rules[i]); + } + } + + if (key_layer.key_layer & NFP_FLOWER_LAYER_VXLAN || + key_layer.key_layer_two & NFP_FLOWER_LAYER2_GENEVE) { + offset = key_map[FLOW_PAY_UDP_TUN]; + key = kdata + offset; + msk = mdata + offset; + if (key_layer.key_layer_two & NFP_FLOWER_LAYER2_TUN_IPV6) { + struct nfp_flower_ipv6_udp_tun *udp_match; + struct nfp_ipv6_addr_entry *entry; + struct in6_addr *dst; + + for (i = 0; i < _CT_TYPE_MAX; i++) { + nfp_flower_compile_ipv6_udp_tun((void *)key, + (void *)msk, rules[i]); + } + udp_match = (struct nfp_flower_ipv6_udp_tun *)key; + dst = &udp_match->ipv6.dst; + + entry = nfp_tunnel_add_ipv6_off(priv->app, dst); + if (!entry) + goto ct_offload_err; + + flow_pay->nfp_tun_ipv6 = entry; + } else { + __be32 dst; + + for (i = 0; i < _CT_TYPE_MAX; i++) { + nfp_flower_compile_ipv4_udp_tun((void *)key, + (void *)msk, rules[i]); + } + dst = ((struct nfp_flower_ipv4_udp_tun *)key)->ipv4.dst; + + /* Store the tunnel destination in the rule data. + * This must be present and be an exact match. + */ + flow_pay->nfp_tun_ipv4_addr = dst; + nfp_tunnel_add_ipv4_off(priv->app, dst); + } + + if (key_layer.key_layer_two & NFP_FLOWER_LAYER2_GENEVE_OP) { + offset = key_map[FLOW_PAY_GENEVE_OPT]; + key = kdata + offset; + msk = mdata + offset; + for (i = 0; i < _CT_TYPE_MAX; i++) + nfp_flower_compile_geneve_opt(key, msk, rules[i]); + } + } + +ct_offload_err: + kfree(flow_pay->action_data); + kfree(flow_pay->mask_data); + kfree(flow_pay->unmasked_data); + kfree(flow_pay); + return err; } static int nfp_fl_ct_del_offload(struct nfp_app *app, unsigned long cookie, From patchwork Thu Jul 22 07:58:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 484332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51E4EC63793 for ; Thu, 22 Jul 2021 07:58:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 351A960FDA for ; Thu, 22 Jul 2021 07:58:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231269AbhGVHSN (ORCPT ); Thu, 22 Jul 2021 03:18:13 -0400 Received: from mail-sn1anam02on2093.outbound.protection.outlook.com ([40.107.96.93]:59110 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231237AbhGVHSL (ORCPT ); Thu, 22 Jul 2021 03:18:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ApOsc4soMI3jCVFUqFmg+2RJ8tBV9vXYRVjeyCKwvHGeoStTEcu/3IW3b+7OUMxyvAmx9sHhtbSo97OI+I8rl9tMCYcs7ssG7d2bUkUQWjQY83w7btyynW5poP6gUr5uRtz5RM491K5h09t3V2LaopLVEBsf0d94a2jaMvZ+zLtIk5Ue+/9PQ4LWDbWCE4yzpAPKbj61/HNDJwl3uWhUhQhYri1+RoWaeHB4lDwxdS59TT+bIX3LKNbR6EvuU3HGGyIDA7WK1+yaqwVGSs73JoaZEz2IdGc1Z9mM+YKBmDXG/xyUPlgcwf47C4DszqY6AjISMUnHQETHQBcNr5TLnA== 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-SenderADCheck; bh=trYWb5VjcpTu8pmrejUxW7d92FYCKYAgeZrnLAxI61Y=; b=NatUcqwA/4h84f+i79ZWGlCflZqjAOHaxnIUSWeS/s4zj7CASlUR7pgRs8KyPqa6Nk2rpDNR+cxivX34BCOB5iGT4W6nY5f9XT3YgaHgJkyoIxCgiCn3CKEEau+rtg3OouSttT9k4z71dLOu4vD5tegkBefZUg5iIq77LDis7bOqmvlMnTjTMT/akqnF9H4Jdbz/08Y6dZk92+S0zDWFw7ltfPHOtHNvrVdZesFV2u7pppV/ohV4Ibfu1Dgs2OM6I78w1peUq/cwdVCZ3MrqMeLnhzNt6GXggWAWYOz04XKsONCptOvfMbFpeWQn9GmqrOwyarNElnfVOR4xdjIwrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=trYWb5VjcpTu8pmrejUxW7d92FYCKYAgeZrnLAxI61Y=; b=EA/J72vQaE2jyikT2BxjUPlkHn99rofJ3m6qKHqLAipXUsb4Uonxxzs61T8A3ow2Df3rZwHp4pOcszzc0Z0B+VembXW+CT0fghLk2PgIOfDdrD8BaMR9+TjQYS5zvG1BRhLQpH24/pZc4+7D7+r7+9KJeKuhbWm1fOphoUQ7APM= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4778.namprd13.prod.outlook.com (2603:10b6:510:76::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Thu, 22 Jul 2021 07:58:38 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3%7]) with mapi id 15.20.4352.024; Thu, 22 Jul 2021 07:58:38 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Yinjun Zhang , Louis Peens , Simon Horman Subject: [PATCH net-next 6/9] nfp: flower-ct: add actions into flow_pay for offload Date: Thu, 22 Jul 2021 09:58:05 +0200 Message-Id: <20210722075808.10095-7-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722075808.10095-1-simon.horman@corigine.com> References: <20210722075808.10095-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Thu, 22 Jul 2021 07:58:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01ac2ed9-f60b-4c36-44e3-08d94ce68363 X-MS-TrafficTypeDiagnostic: PH0PR13MB4778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zDpy9T6M9Jn1a5Dg9zDwuhVNL3LFb9c1ll4QYuqQ+zbuXnmMf1vkXVed2rYfdS450d4quJX/DWW8C+5FhIFvStFcHqaZa8OW7lOUeefqIRzPGt1vRtXi5n+m1SahkaB69vi2G8GObKZdAgYhqhyp5ywG7jYPT29hyQSNbq/1qnFwtRVo+Q61aS8eoPGUfhio9N82u5RcvLxmdkCIwA3Ls5o1f9r6K4ujxc2TEX81B1QKqp3lD10ZhGbRnF7QP4P2JE4sfjdObRRwSaVOjg/NRoFK+/mQbYwr11lFL0Mes6n1DAVRkk6uZTolLN+hb3TP/UvMMZiSFkzK88R5aKb5LRraGftQaPWF1ODuWzOxlF1R+an1VE0KPGokpQsPEHbDLFmu+nZ7VX9xydPxVBkufSyntm78xJTAJf75l63wK/fTaQcJ/dtIJ3vkTmi3B4CBzFWskDp5987cSWcOJ/gxShav/tuHvkZTpnF/cg3nG1/kceJuk6QLsdG2u8r5L58PO1JEApQz8i4OaXlw7srWChLjugcBux6tYpxaxpZVu0jxlfV+aV0Isc7/8+ozZLOmpaWy0GirukZn1Y/vCaMwO9Bl8XvXHTthUa6sKVO719YH6Hhb6s0mXREx6ZMWAFoYjKZf2PgyBVPEbQ6hyevw1g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(396003)(366004)(39830400003)(44832011)(2616005)(36756003)(66476007)(8936002)(66556008)(8676002)(5660300002)(54906003)(6486002)(107886003)(186003)(38100700002)(6666004)(478600001)(2906002)(66946007)(6512007)(52116002)(1076003)(6506007)(110136005)(83380400001)(86362001)(4326008)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H3MG51hKVaDV1/2dOQj08fCLzUwtNbd2S1P2jsc0ZXF3d1zkWXQa359m1ffBgGzk3GswGQRF5qjNbF9HRtPwHzI9wd8WoQZD7budgIsS07NesH915HWNAwa4J7u+cz+6uF+CP+5/WefrnPUwKWFiUpQj9cXPplE59nEkwAipIOlPMXOfNhIvwFgEvIs2RWK4JV/Bsoje9lOd9x8uq9hep0o8TqqNEpPxvIsUOk6LBWqIq7tJzrs0nJaRTayUTe0lwGLQ7rxqvAeQW3kkV/idzdxgHAAoPYep94z/J1KvVEQyWIp+HV1dnAc81q52Uf2EwVmw0Us9idRRk+p2eqQKhjj7eYrj7410eenikIAMthsW/ejDbS59Th58/sug3aoMIk7D6xIBGyrhMFlcnFYXYborrmDM/xc90yc91cmef8WC/cpvBoOfUPMIJ+yjYeTAldgdEBaPkpU6rAFPwoRrbghApFT15em36KqfUGrnZluzphUkNcN+mUCrXtDDjf2sMKkjv0qQqADQ5Vt8mXOC1HTdLynBo6k/X5NF/RKfhz4miZw0E2dFDEyBUos+Frms0PYUNmx2XA8h+lRNautXtZ3VuK3u87WDJi9v/3tF1QKvjWQ3TjGWHPAUz9cwGJ3X9F7xAyFBXwPtbOHuv6ejtIj/s0ve1ySttkD9ieokt/d+hv/uhWI3zaP10MHcrHXaNzQ9KomVo0HqIZ8ILT/WaNWYJgS6tqX135m5mcUH3gISFUmDSfeudF2nEnJXPPUo87RvNd/IONajjQUOxmN1fAFx2naQeYmqtOC0835BR/XLkpcHWk17eGrq8tQLuqdHWTUs+T919QJF/A3bRqN8gODkwzGAEwnGpjFseklHvpOexZz+SYgFl2ymTO94oZeyjjgRnr+UBdev7CKyY9AOJ2KHvs+906TT9bxOOZpvPPgDEV8uJewe3csP26WuGGoOYgsSqEi3I5lj2+nAF3CTyyi2udkfygfElTdXtQA0rx+LoRDEvYJ7XhugbKxAFKCqz5kA04bNb/w0dyMmMIPIao837+T8lsEOZ8NTldH6P23MQyoJI/DRtXaDFm3GYuJV1aJAAfNjCuosuXTsOp8hesHBP/Ohyihd0qna9lTCCdMlC8yM6VT292t7k3KHMKcGUE+oW1bfQJIBYqaCih/Jvk7QUaKz1cPy5+Ir5y1jFW5zYdVeXRTsLPwzD9tNLsShA4y/xTuzbXFP/A7W7p2B582dCHlywGaC3/VW0zkW1h15RpZzwrbJfTqEgIsKEdTevSuGombVpfi10jpIZHibRdsXdb38+lAm6OZrvs0Yjoi0XpnEIUxBPS9H3LN6dilUmAEmP8DXJepfCl5xKqbZkgtGVOozytQskEFOll9aDC3JkHp4zSGfbTDtxtLehsZg X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01ac2ed9-f60b-4c36-44e3-08d94ce68363 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:58:38.1051 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EQs6eZKd3FeidCX1k8xSldLzaYoI/Hkv2oISBEWuVxJafYpX2CsLgCY4QZnlf2rJvs8d2MbjipIDUbg3EwCIRBd7G+DoVv4GT06v6cEq7Mw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4778 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Combine the actions from the three different rules into one and convert into the payload format expected by the nfp. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index e057403c1a8f..41b1f9773d46 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -471,6 +471,73 @@ nfp_fl_calc_key_layers_sz(struct nfp_fl_key_ls in_key_ls, uint16_t *map) return key_size; } +static int nfp_fl_merge_actions_offload(struct flow_rule **rules, + struct nfp_flower_priv *priv, + struct net_device *netdev, + struct nfp_fl_payload *flow_pay) +{ + struct flow_action_entry *a_in; + int i, j, num_actions, id; + struct flow_rule *a_rule; + int err = 0, offset = 0; + + num_actions = rules[CT_TYPE_PRE_CT]->action.num_entries + + rules[CT_TYPE_NFT]->action.num_entries + + rules[CT_TYPE_POST_CT]->action.num_entries; + + a_rule = flow_rule_alloc(num_actions); + if (!a_rule) + return -ENOMEM; + + /* Actions need a BASIC dissector. */ + a_rule->match = rules[CT_TYPE_PRE_CT]->match; + + /* Copy actions */ + for (j = 0; j < _CT_TYPE_MAX; j++) { + if (flow_rule_match_key(rules[j], FLOW_DISSECTOR_KEY_BASIC)) { + struct flow_match_basic match; + + /* ip_proto is the only field that needed in later compile_action, + * needed to set the correct checksum flags. It doesn't really matter + * which input rule's ip_proto field we take as the earlier merge checks + * would have made sure that they don't conflict. We do not know which + * of the subflows would have the ip_proto filled in, so we need to iterate + * through the subflows and assign the proper subflow to a_rule + */ + flow_rule_match_basic(rules[j], &match); + if (match.mask->ip_proto) + a_rule->match = rules[j]->match; + } + + for (i = 0; i < rules[j]->action.num_entries; i++) { + a_in = &rules[j]->action.entries[i]; + id = a_in->id; + + /* Ignore CT related actions as these would already have + * been taken care of by previous checks, and we do not send + * any CT actions to the firmware. + */ + switch (id) { + case FLOW_ACTION_CT: + case FLOW_ACTION_GOTO: + case FLOW_ACTION_CT_METADATA: + continue; + default: + memcpy(&a_rule->action.entries[offset++], + a_in, sizeof(struct flow_action_entry)); + break; + } + } + } + + /* Some actions would have been ignored, so update the num_entries field */ + a_rule->action.num_entries = offset; + err = nfp_flower_compile_action(priv->app, a_rule, netdev, flow_pay, NULL); + kfree(a_rule); + + return err; +} + static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) { enum nfp_flower_tun_type tun_type = NFP_FL_TUNNEL_NONE; @@ -720,6 +787,11 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) } } + /* Merge actions into flow_pay */ + err = nfp_fl_merge_actions_offload(rules, priv, netdev, flow_pay); + if (err) + goto ct_offload_err; + ct_offload_err: kfree(flow_pay->action_data); kfree(flow_pay->mask_data); From patchwork Thu Jul 22 07:58:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 485118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 249C3C63797 for ; Thu, 22 Jul 2021 07:58:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1132260FDA for ; Thu, 22 Jul 2021 07:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231243AbhGVHSP (ORCPT ); Thu, 22 Jul 2021 03:18:15 -0400 Received: from mail-sn1anam02on2093.outbound.protection.outlook.com ([40.107.96.93]:59110 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231232AbhGVHSL (ORCPT ); Thu, 22 Jul 2021 03:18:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QDjdYhDu5Cw2GSAFoQN+cvwKjRxyVfq4QcehKyOAHOkbfmAaDeExrDCmW5kZulAceS8YuxsmCRVINIaiagFwWrbogtRiyZghKa5pjW6syfxi9+089hEL5WM9PrSzuuD0wgrCZZ+QdgJ6XGmIlFGKi/JW0KqXJd0ML8qPPTakguJ4Nr6gBFrYyXADPLFNhJFth4Q5ueVGZUqhSEgk1lXaVY5FJZ5uFomCkPOHlU1B82LLXab7hQ27jQQ9q8lK7hRnn8fnDCO4+90EaMTE1/pK80fnM/aRW7HrUqIt5VyMHOjD/vzTin7+DViOJy+6X1N6Ova4Y2MrV5XEUiLiBteiVA== 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-SenderADCheck; bh=HvfA56G63wbRvRyuupyX7BCDW7gg2yoEdx0YsTMhWUI=; b=GToPBUrVWd0u35j1tA0wjQ+mYec83yE8D3WjZVDqDKS37TLfi7yCSH8l5WMPJmgxKcQPfiOcNlpvrWXt/ZVKS2veWcAjhjCXesltjdDsx2xVnzaFwH7bs3lb0wZH9QEGVs7GGKjpw18hjX+Mx8fxkcMGLcH/mmEr58cJf0TgTrzGElbB/s2Pq6LhHen4NY1Gi5CUSmECSBiXLQcZ60kgrfaqm3KnUSTFRl+766Tclz5olLwqqOsLHVbClviDhiZ+IHxUburoXGwdnh9uyVqM2GRUChcIgT9RBT3+ZbnwouAdk2oVuuuf5t6RG//AsbXmF/Budi5VgLM4HrSHhecZlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HvfA56G63wbRvRyuupyX7BCDW7gg2yoEdx0YsTMhWUI=; b=r3XCEjMNxK0/z5irsQqq4FWTvfUXock04ff1vC+8M9oaR366KHu+CXblyO2x+UxTXV4u7y1E5wVIGB2dezsvYj3EFquOYWm8p9kUyJyuCW/jLiL1Kq1YLlh7HEQDH5WwiTy1QHzP2fwZ4Ah5bcIUgKMgkQlkQB3bR+6OvsDBz1M= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4778.namprd13.prod.outlook.com (2603:10b6:510:76::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Thu, 22 Jul 2021 07:58:40 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3%7]) with mapi id 15.20.4352.024; Thu, 22 Jul 2021 07:58:40 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Yinjun Zhang , Louis Peens , Simon Horman Subject: [PATCH net-next 7/9] nfp: flower-ct: add flow_pay to the offload table Date: Thu, 22 Jul 2021 09:58:06 +0200 Message-Id: <20210722075808.10095-8-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722075808.10095-1-simon.horman@corigine.com> References: <20210722075808.10095-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Thu, 22 Jul 2021 07:58:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 739aaae3-a90a-4db6-49b9-08d94ce68491 X-MS-TrafficTypeDiagnostic: PH0PR13MB4778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pEkPYG1No6mBrH98gOgjV0RYmQ6AcLSz8xGCU67RtsxKBTPVh8v9VpMq6PnYdKoWwqUwVyJHIum/qe3bS2PPOoUCJ6ZxlK0m1nnAvCJwzk1PiyYOS1NeenHwzLb0MRV8Krj3iZcIsO8PFb7Gov3ezGSqiWbfWFR+kz2tfcwL6QwXjHOQ+tuUUHsJ8GCKi8c5HFyI6SU55UGTV6mbhrYC+UofJ/6nGiiWvM3xWXT8xgh/nYCHaT7GQlNDUdYsFxynAMTYEt/J6gAIo795pL0cVFdwkPzHPz7dRL+Dy2QPNAm8d4kTSVnH367q0ewOTvHm8tvk3Indn/8phJ97ZzSIiwY0g+jteXEHXbB0+io9pUcPwIazTT9JcOef4wh7ru+p/yxCC+FxZPyAbVPJWQrVLq/9Kii7V2tsNMpyfi/0JNF+Zl/wKkdi8Vp6MpOnRCTKk1TnoR258RZoBgPEJ+J16P9ZaRTGVoEkXeUX57WzMv5aGqUgaP9mPSq5j6triOHwYIDRP8rRtU1d4VTqFPYM/n5fdUPawVFHO4JkWOpKOqYfV9+/imhDPeYMdMyK+g8d4bc8QRW7Yk+cbbLYTYzxZB9gWYuuKMuyvvndZiXtlyNeOy1YcMO7difJU5X/lXNchWqjTz33SR4zKKO5k2uHng== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(396003)(366004)(39830400003)(44832011)(2616005)(36756003)(66476007)(8936002)(66556008)(8676002)(5660300002)(54906003)(6486002)(107886003)(186003)(38100700002)(6666004)(478600001)(2906002)(66946007)(6512007)(52116002)(1076003)(6506007)(110136005)(83380400001)(86362001)(4326008)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LLPLtut6u8MY+iR2FFLM6FyJYowUrDq68sQKBotDjApCmrfzYH+iXXZO+86kB1Re9WZ5Aoel+Z79Klg0d18juwjx/zu2C1EVLd9+CZOQHpQNc1FDPJ7QW14nCtLVIh+TUxNXfoWSJHQAP1QgSHKsFbNw8+S44yJYm84qFhr+Do7+qHL8x2DO35ItEaGKXAKYdjAlMFrhzGKkJ5PBQkYSlgpgZ6B+Bw5y1dr5TQvLz9yVetAamrmosKjhKa4JBJplFC6rAC7W47i9U0oiWMkrSSvmGvdE7PneX4foOzbiUF+Umv+WoYx+Wtig+M4rtZN7qoEmg/2H498pujiQHHFW66FP5dGfUU2PidEh+rVNzH28sM3mHFn3iTV44zf8MZGvyxxwUAefs5atfgCtqAZCopeXmWZKV+Ql1DjzDfyaqSTD08GqqjlyBu4eMC21A+l2Vs52H1yZHnJC6/IGUHgry8OOhlVuTXZdvbP7RmlvpeGwLwWDD11VymKue3yRS1KqIpH82AwlJWFbYBwRejJtG7OirCdQdnf2/VqkcQReNUph/UAW9xHkWOOhFIqoX0dyHUtlwiEub9qofQni5UHlZzIYqd9QkY4+hQqXMAP6ldzWQ/ViB7xjiKTP4CjMEgDHxp5xXh19YmFIX6CylEG8pL/V++EkDJ8Qid4ao+WFphswJgFUtsRThj2VwZoObpI4a9Ql2e/JQ3GeaQApAHGaVyqgxyFhLgtN8B81geVmiwXuFwEJH/esJRwxLdA6Na8e8B0E267zacnhtv5FGeHjS2XkiuSvHW3G2vBLbBJYn2dVtje+ZiB6z+8GkuZ/9FXBxU6dX255m4xj/O2G1KB1PpNxkv+2FHWvxj/vJFgsKfPGAXP8IudEPaAj8WirTj/a4QEp/Qd2UnyE9YMg2njb85Ptq+Bz4G5q9J7p0TJN09rxBGYNokoohdjsvoFcSk2rlGq/EIGVDxZnktomV1xgdYI6bXvhNpaWJgAolwjEiGkfkLE1FhMEs09W+qA9Wi60bmuNBA1mOaa5iG+fHZ48W1uSSlx5A7/Mos1elbYSSHJC4/Zff+Wlo9SX/wD2cSZfO9Uh/FpeWSu0ZRQ/O2/lAiEscgmKaS4D0ufc/fFoGaV1cDBsAdH/XrSgXfqt7nAUKp/Ilz3U3PF3NxQZ5H3kdb0Zl8GpvWOiYXvx75YefjO6o9FTanzRDJU161l8eVG3EuF40+H+t6LvIN413gQxwCI0DeD7uKcgwg2I91pwnqIPp8mpzCESZSpnVuet4jZHswZEiYi1AEjVlCdEPWY8csOtf9fnj1qf/spSjDQfuFDUkdra2CwgplOVLUKuzgtV3wo61Q+PlqSviQJR34zWlr9iSYqAQd6qZAW/pjhe/5tgYRJckZhIIAl4Up/AfjSO X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 739aaae3-a90a-4db6-49b9-08d94ce68491 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:58:40.0914 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RdUrNfgttmj0UJ3UtwOgsDickqxc4kG6YsYp66PUl1UMu8IrCr+V2R/fViGLaeY7RggKKK2kr+tyirNDrIGYl+HkZPB0i1LEFbZWHx6rVZ8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4778 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Compile the offload flow metadata and add flow_pay to the offload table. Also add in the delete paths. This does not include actual offloading to the card yet, this will follow soon. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 75 ++++++++++++++++++- .../net/ethernet/netronome/nfp/flower/main.h | 3 + .../ethernet/netronome/nfp/flower/offload.c | 2 +- 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 41b1f9773d46..8ab7c7e8792d 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -2,6 +2,7 @@ /* Copyright (C) 2021 Corigine, Inc. */ #include "conntrack.h" +#include "../nfp_port.h" const struct rhashtable_params nfp_tc_ct_merge_params = { .head_offset = offsetof(struct nfp_fl_ct_tc_merge, @@ -549,6 +550,7 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) struct flow_rule *rules[_CT_TYPE_MAX]; u8 *key, *msk, *kdata, *mdata; + struct nfp_port *port = NULL; struct net_device *netdev; bool qinq_sup; u32 port_id; @@ -792,7 +794,40 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) if (err) goto ct_offload_err; + /* Use the pointer address as the cookie, but set the last bit to 1. + * This is to avoid the 'is_merge_flow' check from detecting this as + * an already merged flow. This works since address alignment means + * that the last bit for pointer addresses will be 0. + */ + flow_pay->tc_flower_cookie = ((unsigned long)flow_pay) | 0x1; + err = nfp_compile_flow_metadata(priv->app, flow_pay->tc_flower_cookie, + flow_pay, netdev, NULL); + if (err) + goto ct_offload_err; + + if (nfp_netdev_is_nfp_repr(netdev)) + port = nfp_port_from_netdev(netdev); + + err = rhashtable_insert_fast(&priv->flow_table, &flow_pay->fl_node, + nfp_flower_table_params); + if (err) + goto ct_release_offload_meta_err; + + m_entry->tc_flower_cookie = flow_pay->tc_flower_cookie; + m_entry->flow_pay = flow_pay; + + if (port) + port->tc_offload_cnt++; + + return err; + +ct_release_offload_meta_err: + nfp_modify_flow_metadata(priv->app, flow_pay); ct_offload_err: + if (flow_pay->nfp_tun_ipv4_addr) + nfp_tunnel_del_ipv4_off(priv->app, flow_pay->nfp_tun_ipv4_addr); + if (flow_pay->nfp_tun_ipv6) + nfp_tunnel_put_ipv6_off(priv->app, flow_pay->nfp_tun_ipv6); kfree(flow_pay->action_data); kfree(flow_pay->mask_data); kfree(flow_pay->unmasked_data); @@ -803,7 +838,45 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) static int nfp_fl_ct_del_offload(struct nfp_app *app, unsigned long cookie, struct net_device *netdev) { - return 0; + struct nfp_flower_priv *priv = app->priv; + struct nfp_fl_payload *flow_pay; + struct nfp_port *port = NULL; + int err = 0; + + if (nfp_netdev_is_nfp_repr(netdev)) + port = nfp_port_from_netdev(netdev); + + flow_pay = nfp_flower_search_fl_table(app, cookie, netdev); + if (!flow_pay) + return -ENOENT; + + err = nfp_modify_flow_metadata(app, flow_pay); + if (err) + goto err_free_merge_flow; + + if (flow_pay->nfp_tun_ipv4_addr) + nfp_tunnel_del_ipv4_off(app, flow_pay->nfp_tun_ipv4_addr); + + if (flow_pay->nfp_tun_ipv6) + nfp_tunnel_put_ipv6_off(app, flow_pay->nfp_tun_ipv6); + + if (!flow_pay->in_hw) { + err = 0; + goto err_free_merge_flow; + } + +err_free_merge_flow: + nfp_flower_del_linked_merge_flows(app, flow_pay); + if (port) + port->tc_offload_cnt--; + kfree(flow_pay->action_data); + kfree(flow_pay->mask_data); + kfree(flow_pay->unmasked_data); + WARN_ON_ONCE(rhashtable_remove_fast(&priv->flow_table, + &flow_pay->fl_node, + nfp_flower_table_params)); + kfree_rcu(flow_pay, rcu); + return err; } static int nfp_ct_do_nft_merge(struct nfp_fl_ct_zone_entry *zt, diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 226bcbf6e5b5..9e933deabfe2 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -560,4 +560,7 @@ int nfp_flower_calculate_key_layers(struct nfp_app *app, struct flow_rule *flow, enum nfp_flower_tun_type *tun_type, struct netlink_ext_ack *extack); +void +nfp_flower_del_linked_merge_flows(struct nfp_app *app, + struct nfp_fl_payload *sub_flow); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 87a32e9fe4e5..e510711f6398 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1470,7 +1470,7 @@ nfp_flower_remove_merge_flow(struct nfp_app *app, kfree_rcu(merge_flow, rcu); } -static void +void nfp_flower_del_linked_merge_flows(struct nfp_app *app, struct nfp_fl_payload *sub_flow) { From patchwork Thu Jul 22 07:58:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 484331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E95C5C63793 for ; Thu, 22 Jul 2021 07:58:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2C5A610CC for ; Thu, 22 Jul 2021 07:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231304AbhGVHSV (ORCPT ); Thu, 22 Jul 2021 03:18:21 -0400 Received: from mail-sn1anam02on2093.outbound.protection.outlook.com ([40.107.96.93]:59110 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230200AbhGVHSM (ORCPT ); Thu, 22 Jul 2021 03:18:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jZstyQIPgTHv1DXOYyNTR5Aq6Maa5sVVC+CFe/8QLp0YmwN9/KZwod8DUNttZO79Ur8b1m9WtTM9JFwk1ZgcBH/KRC2vY8gc6CiZz5NlGmXx/8eDlfsD2gGJRSlRtqclTnWNr8PojvBeCbq13Ux28nFd0fQ9M3p9e8tojgPMUIbPE+IopfiS/4ypcmrAmFWzf5+g+K7yIdCNRp8lfSfGQQLOVOZlPmvFlulCRS0PKmj7DrXWdxM7BbzEMBaRQhfDsQzB33LMIHevJtsK6sIYZeKkGF79QOO2b9yxVW+JEaKQWkKfSDv9m6bHTMRzWmKSAwwws49bWep7rLd6ze+alQ== 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-SenderADCheck; bh=I7Zi2uRmzpQEOh7LvDdQnVAWUHWHUVCLWo+RKsyC9Ag=; b=Mj05iWovcprburSLfUV0IsDOoyw91n93pG6DO+ewt2gdbrKhGUbYIjh9ozXL43wD2IFY+VcbwHAux+1/ESaoyUkrRTXSypZPkM1Je9aaSh4F8DtGB6yPiw4uAt+Adu+LE8iYCKxJliQbA+YlkuFjlJBKdjDYGJ6j5DuKBjW2Zfa/0++y+zth0hyrC+8Y9d0SgUERlF98vMs3/WiujhKBhdVGh8gLx9fCUFncgKRjOA0OK7QabyEGV1AzhjewS+NS/0BKN/98FO3hw+RV9QEbWmteqbNmGPZqGglb5tD/sYfhdfVVsj9cpJCSpK4ZTNWW3p4O8gIVvzCKBXaikYDHGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I7Zi2uRmzpQEOh7LvDdQnVAWUHWHUVCLWo+RKsyC9Ag=; b=ClzFqUcsDlZLFsvBUODtPEI3rUdcsYLCIakHS6IlDPMJ5VoXPh/DAJmbyIcVz6aQBzr0SZmxi9ynk3n/ky9g6On0bNHt751qjBZJc0fHA5jWXfdCku9qtdv+PbIdtXkZgQNM3bW/DFJ6B8BRtbDnRVikBoqHKPinTJX1SOn1r6I= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4778.namprd13.prod.outlook.com (2603:10b6:510:76::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Thu, 22 Jul 2021 07:58:42 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3%7]) with mapi id 15.20.4352.024; Thu, 22 Jul 2021 07:58:42 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Yinjun Zhang , Louis Peens , Simon Horman Subject: [PATCH net-next 8/9] nfp: flower-ct: add offload calls to the nfp Date: Thu, 22 Jul 2021 09:58:07 +0200 Message-Id: <20210722075808.10095-9-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722075808.10095-1-simon.horman@corigine.com> References: <20210722075808.10095-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Thu, 22 Jul 2021 07:58:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f365d605-688c-4d57-fd5a-08d94ce685b9 X-MS-TrafficTypeDiagnostic: PH0PR13MB4778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jeS5Oieb53PP585jcQyz3MF1NvJokGjwyo2x6ceDu5tT/4CIr6vK+DfJ3eDJ7JZfF3OxjfvNMJ8b/zblBPLXwbc3PUTbydi+lv8mNbcaTbDFQf2KX+mr0ySIeZMtXTqDhuwhSZM1fAqNh/OAemT9akA7oGBEgJcqfShR7FSExzIKzcUxVcqT/aThBP2ztyhqIkX3F1gLxYlkMh3u+zcQv6uSZXhpPI/5K3//Sreo7QWLNWZaV3M1IYqwq1dhkedhemI4sO3I/XupA9S1y9aochCoSQq0FfxEUAzUghoJtcZhUwlbrSQbnU8gSPcFRw8KTHyKepHZKikcCWpBd5P1GV6ycZBRwHFRcXUVnUJLDqif3f59uksuT5i/mveFeDO98N00TSFKWNqVLmjE3Tsy3AdnxwW2FAkltL9a5Y3qV+uOIohsbU9chOIU2VNy76fUX8vGRy9ttxzklT5rnHjdB0CulH+P1y4Tj5WbT7IqdMhP+R5tGuAxpORldYAtpUzvm0F3rHrFb+5/52noRadpOMJjgTbN1JDvB4Q6/ESW083hqlBiYKBzhQjP3W0RqGp1AzBSZs60z/dXxW/o9rN4oLF/TVNKoMQ7O+FyNDp3HlDW3juiV02UyGVVqc+15AB8gKV0l4ianInJxUJg17GfGA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(396003)(39840400004)(366004)(44832011)(2616005)(36756003)(66476007)(8936002)(66556008)(8676002)(5660300002)(54906003)(6486002)(107886003)(186003)(38100700002)(6666004)(478600001)(2906002)(66946007)(6512007)(52116002)(1076003)(6506007)(110136005)(83380400001)(86362001)(4326008)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cj58ddFIMyrdukd1KYnYEm+MkRdmoegBFWp7p7unH1F4TU9eYGGvY37txoRy067AXCrJefchQ8P/HFKOdf+zpY3BHPHekvUwgu4UZUFIKOurGawwUAp1QdE1e3jWYq/Fc8mnKY+K9cYEOpSCV2XSbg33RVorLXFK4/d0jFEJu0uzbpptA9YmgDpOs0zgeE/ea1bd9WHiiMevp6uMKmTYlVWNPGHGC5eX+MLt1D83r3x0++3P1wTwPrOJ5sAVgdcK72Uv8sg0kEaY51m+MTEQ4QMVjK9v4GEizEGscXbeGKeXpILyGmuimmOS2OKVpaLESYeaOcFCn9tCEj5qbbkvShWHqVoxsr9xteMqXBNvYdOq76OrtTtIiDxkZzCCeJ+zNW2fhPpov+v5wiTQVzo2/SNtHxIZ7gmikBDD3Nj/WqgVPio21vKMbzmT7RpKSnW3lSG4Ftjh0PG4GBRx5Tm8hMWhCEv9AfBZ5Bl8/eeHJxm9t3q5K0+nuY2EAdLYRvhyd+pFYBh6CkVOtArfhTr7V0ZeAtiiYJkJlsRN8iZShH3hUob/YAqW4i+X5jxRSWUh3boClU/s1UnnAXpbIgTdwYZYb+3JHQCDHNEDvij8pmeHR1fw/lS6qgT2wc7UygMzay8MfKHkqC9CRvZIIBnoj41Z6v62RAFKy/JLmldE0dQ86TsqgrkmMs9l1bUoiQvxwo0JeBBFe6buKrS75ONlfO/D1I5jyDY8GWCvsXbz1DJPC85xPrx+uZXcB8tETb7sIvF18lt7jgFpa6Ott/RepK6/X5jwjFWNZAKQ0FXUoOmEAKJBrQGu/dOR1lHPNjcvoYK95DEvZ8T86YTSINIj5BaHurDZP7Lop9JwiIlOjncTioL0kYmAQ6NOxMHutDOQ9RAb96k+3LH55vJVM1PBCOgTJvd1GmF1GvCspu9Ja6Xcybc+vrKrDqQyTMKYNNu0eXNUioPoRlatdtk/pYS4fLpnaLNy5OhHvlf2c89vdafUSs74xnNv6JohZxngyWzQXdaIMhbJ67CLWk6nt7UJxhOkMjLDy+nZPcxG4tQEE3thbCYTJw0J3qj3EmpHGCM4brCdWuSGF03I4guFIgIi9l9ZYEpAwcOiaYElk6AcFFSu8a8pkXXJC1N2nmfao9NnTAR2kACrFnNBTozrZ7AzIjpZehvv3TDwgfP8SDEmCqK00NZSBfek54SMdXK54msn5hZ0YlcEQA8+o/3qiCUG0F3HbzS5qv43wsvoCoAqwJJH2sE5O6l5AyRgF8+CVMuE6IF2t/T354eRj8Vr6kRix/sqbHANTYzrQw5psk+pD9y4Duo7Lb6TUMlTtnVAXAs2jAUqp4h8hobW3RakXYfe0lq7N5YhroBPS9dYucGjw1kVXGdW6qLuKnaw7tgfA7am X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f365d605-688c-4d57-fd5a-08d94ce685b9 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:58:42.0568 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1SJ5+Ce/017F//9pUver8t/goWUYzNvmHOCq8PwretdqxCIKk7b8Bkv2KjGtOJc224zctdAV+/UpfA/2GFCaRaOwHfdbgSBZumMVM6kVwWA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4778 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add the offload parts (ADD_FLOW/DEL_FLOW) calls to add and delete the flows from the nfp. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../net/ethernet/netronome/nfp/flower/conntrack.c | 12 ++++++++++++ drivers/net/ethernet/netronome/nfp/flower/main.h | 3 +++ drivers/net/ethernet/netronome/nfp/flower/offload.c | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index 8ab7c7e8792d..df782a175a67 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -813,6 +813,11 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) if (err) goto ct_release_offload_meta_err; + err = nfp_flower_xmit_flow(priv->app, flow_pay, + NFP_FLOWER_CMSG_TYPE_FLOW_ADD); + if (err) + goto ct_remove_rhash_err; + m_entry->tc_flower_cookie = flow_pay->tc_flower_cookie; m_entry->flow_pay = flow_pay; @@ -821,6 +826,10 @@ static int nfp_fl_ct_add_offload(struct nfp_fl_nft_tc_merge *m_entry) return err; +ct_remove_rhash_err: + WARN_ON_ONCE(rhashtable_remove_fast(&priv->flow_table, + &flow_pay->fl_node, + nfp_flower_table_params)); ct_release_offload_meta_err: nfp_modify_flow_metadata(priv->app, flow_pay); ct_offload_err: @@ -865,6 +874,9 @@ static int nfp_fl_ct_del_offload(struct nfp_app *app, unsigned long cookie, goto err_free_merge_flow; } + err = nfp_flower_xmit_flow(app, flow_pay, + NFP_FLOWER_CMSG_TYPE_FLOW_DEL); + err_free_merge_flow: nfp_flower_del_linked_merge_flows(app, flow_pay); if (port) diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 9e933deabfe2..d77b569b097f 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -563,4 +563,7 @@ int nfp_flower_calculate_key_layers(struct nfp_app *app, void nfp_flower_del_linked_merge_flows(struct nfp_app *app, struct nfp_fl_payload *sub_flow); +int +nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow, + u8 mtype); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index e510711f6398..2929b6b67f8b 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -91,7 +91,7 @@ struct nfp_flower_merge_check { }; }; -static int +int nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow, u8 mtype) { From patchwork Thu Jul 22 07:58:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 485117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E2AEC63799 for ; Thu, 22 Jul 2021 07:58:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A996610CC for ; Thu, 22 Jul 2021 07:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231270AbhGVHSX (ORCPT ); Thu, 22 Jul 2021 03:18:23 -0400 Received: from mail-sn1anam02on2093.outbound.protection.outlook.com ([40.107.96.93]:59110 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231281AbhGVHSS (ORCPT ); Thu, 22 Jul 2021 03:18:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B7sZQ2Srs/tkaok6dEAoHQM30tbtOxQbvkBPaSi8S5poXDGukK17Cdg4Mi48DXPB8YLu7RJkhWzplz9NumIAA+CNqGX1AICoWAESms3bnrkx9IYAGjOOKSoHoYJLXOhsLtqRE7uozeN+srMOC+UHwY5RI2gmByRLYZJ/opXHQ/1MoI10RBAMofDC6igXzTvIuAZ8Ww6senAu4Z2oGijg/7UmidnFzhoD/GKDjIN0ZzABDr6mDPwGH46bqQ/eGBRbw3I44P52y1D41BEB8hggR9MtOFZxHAtUcxf+Di7n9h4Vy89JATybWG6diPfpMB+YbruEN6iowKqos4mn1NlBQw== 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-SenderADCheck; bh=j2pDO+sBjUIJ+8w/bIXbTBeUMqrFSNajIxAAAzfBeQs=; b=RWrEYHZe6bi77JLnywMBqLP1N6a8PW00tdBlAVEnFBqr+NVVEK8kyAPrzA3JjPu9Rgc9nXzQoKywNwF+cDry/vFQsu0jjpMXE77x/wxuYlNZyrIsZR9bD27+y56Vh71d9Axx7ORfeVBq7N6EzzDaJGtKAqyvMrsGOBmu9r49t+oimnnNlpTLN96p7uhThWkNic8CY5ikjqsnNhAJa7FdjkXGLF3jPqEXyuewNHF4rvby7q9BKpGnEwwNqcwsXtK7KCgdH6fDrXCVTceU5MWtduTmX50XkTJEnpGW5boyJfT0Qg8xD2A0WnoKu7LTRXhCJkqVuRFrJFdL3kcaIliEig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j2pDO+sBjUIJ+8w/bIXbTBeUMqrFSNajIxAAAzfBeQs=; b=W7H4gBQQcyHuO3g0csm8sczNBOwjypgehqza8/nBoAsOI0CMycuT3yVfPDnykQG0wH21V8IhBKOAnB0m4ykoFDdwqpbaC+PHnTdpP5c7W4UnH5UCyGwy70IMm4+Z9VWFrMvri5uxhbyc3q5hOj6sbGqTM7CkD8L+FUZg3K0CnXk= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH0PR13MB4778.namprd13.prod.outlook.com (2603:10b6:510:76::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24; Thu, 22 Jul 2021 07:58:43 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::cd1:e3ba:77fd:f4f3%7]) with mapi id 15.20.4352.024; Thu, 22 Jul 2021 07:58:43 +0000 From: Simon Horman To: David Miller , Jakub Kicinski Cc: netdev@vger.kernel.org, oss-drivers@corigine.com, Yinjun Zhang , Louis Peens , Simon Horman Subject: [PATCH net-next 9/9] nfp: flower-tc: add flow stats updates for ct Date: Thu, 22 Jul 2021 09:58:08 +0200 Message-Id: <20210722075808.10095-10-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722075808.10095-1-simon.horman@corigine.com> References: <20210722075808.10095-1-simon.horman@corigine.com> X-ClientProxiedBy: AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from madeliefje.horms.nl (2001:982:7ed1:403:201:8eff:fe22:8fea) by AM0PR06CA0136.eurprd06.prod.outlook.com (2603:10a6:208:ab::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Thu, 22 Jul 2021 07:58:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 871e48cb-d3f1-4d3e-3418-08d94ce686b4 X-MS-TrafficTypeDiagnostic: PH0PR13MB4778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6cq34Wihk7nh5PFcxxONzb6aOpn/NmFVVHTfxXPkH7RLqJwlwPgUfmbf7/FRNjvOkrhA/sEVgSoPXeQyRrq6uPf6MhPxb7Jl+8RLTWZuMTgg4joJsRkhfyHumhMO5yYF3B81PtOi1XGcrq9qdy/v9iZvNFVqczvyW2c57H9PXN7v5U9RCHYaSzt0B38je5xaUg/49LU5tG7ifZschjQ2ygN8ApXwdtfIQxyqInqt7yBR1LkMbbtiz3yd2mqsVY29LH19jlAKv+1RPblWHHg8wrXIIQFk1SRiI4WWBVk602d+UmFB5Ra2YMe7YGZyDd181csdr53MdFtwfExfs0UTRhvrtH6uHWUu4AC91JnMiiVJBLDGLPBATeMVtV9Fmma3As+n0v8JvLkulE9y7Cfy3SOrSJTV6l/iYIwZfzpmSa8EsFsaFbKociF5XECIrEAycemnwP9jys9pcpIJLjegdFcYO+DqQgS+3Ef36UiicZ+hEdMYX9h1ZFLBtcKfwhwgy21fasKoaHR/GvwJvv7iakBTSwiriertXWn0j1NpCShMG6Xt6NdykNUm7L/ZNA3Lhh2RQECHaJ9PxTeRx8u+6lecL+wNYaqOyGdRcHgUUF1cCh4VF3i3A5oinmBiTZjGXkZPYZMhfbnz1RxQqyn15Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR13MB4842.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(396003)(39840400004)(366004)(44832011)(2616005)(36756003)(66476007)(8936002)(66556008)(8676002)(5660300002)(54906003)(6486002)(107886003)(186003)(38100700002)(6666004)(478600001)(2906002)(66946007)(6512007)(15650500001)(52116002)(1076003)(6506007)(110136005)(83380400001)(86362001)(4326008)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i0PjhMCq//w9zXXVLNeblgXpAOabi90Uwjq0tMoEtuQdFxkgueOBmIZkTsIl4OnECvdzj+Wp+TNJqFtk1IsdGDCx9VZ9/0nzYQEDtHQUsfLPJpWr2VG2lval+GXGTFWWDuV1lhDCWxW6T0DgcUmN8g3fOvfY6T79lpTdyAzHkLIeYN51uaPpe6DgonF5iC09q8RteIFPhH7DEWc5Pr9djqYBATzcmLepsfs9/WGadkGWIcSQpAS6PoYdLuMM6IClDt6QdEF+prZWSReCaBbnVxn2F0boUM78a3CZQWktrTIl217WNYvbWwgZBHMT6/QHbjA/l5YgtPoZR2P8qXiFYL+dJ5kd8B25cpKQt8dePSuQSrNBFHdI+J6ocm4L3ckWXVeXIEuEsBTLtDyDAF+rkuaLs5tIwjwJ2Zo+JSc1A6AM3/kbtXhW/20UA5/JcVDbO1puq4sV0iJb50p1GWb5RSef8lLN7QeYDMT0DRP80AiizYuuU4KOWBaOJyXrgmLg9DDcb0gZRkXl9JUpcEq0G09U3MX2aSOGpZrem6SG4EW0Ij4s9AbZClmLlpVba5ghA9rLbkmWkMjcRFh4S+azPieSZmpQY/R34g7u19f/ck/YC2uctpUq2OZsgk4nSh4GesuSHQ5wFeMyOsnu2URbP4dh1yp+KjSisugRKMFTdync6bebSdlCH8LCV4ymA84h1SlHq19HV/Ug7xBnLq/cwSXekMi1REE1A1ssRZkWmuj97xKJxqos+XUKl0yDquvHhKPLj439CBEB4Q9sKJ059sTB6KCUBrKCNpNtxg5OUGItk2jiYDw5+J99fhuYv6NP1LAJ+1X3v+hk690dK8aVNuL3JgmrcghlktfZdoxaDsmLwNh4ayOV6V68jmIdckkzQt177NjdDEBpghHO5ih1yHn5yo9TGcUU1Njd5u/dgYU7diPwcRS+/k69FhCf6ErpsDLqcst5JEuTDAR+9i6UYQFBpOyB/w86DKNixu33TsLcAE04wBDwNq62+5ANJc/ofeZKHX7CwO2SK3ftdm0phtkfMULgTXJInylO3cnliDZeCUOM5bmVTWTTCVo3DiOegGExTQpakPoXFT2+fGANzKcx82Q863A7HY1ufisWk1F4qTeIhy5zv4wOCTy6cKRvV8I7AWVhOc7gw6TJY8KpziakBdwqnYQUGljmAyra7J1+oTFgud+8TZaS/ZOHMJMz5NiguQIhSseFPMcoQT0dDtz9TeJnDIwapA0kTKMbWEvx1WQeAWdAZcXgdwHug/bexI6J+qfFBhLC7aSDd2vWBAeHlw8aQ8vDLLrEGzh4q1nvPjvSdCy7Ik061oNXmN74GSs8+IoPJRvoAOS3sSC1o8ThWGwK3Vw0qVUhuB5f6ZTm+8+E7aKbx+LJNN9KWnS7 X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 871e48cb-d3f1-4d3e-3418-08d94ce686b4 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:58:43.6757 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ACcE3OUKqVbeNTQ9OoeP7v2Iugg0zLm4GYT7ZtDemL2opzw23WvY73zfxhq9RJ7tUvg5+Csrf+HcmGaKyn1Zq6wZzC+x76NlhtTsDY88pGo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB4778 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Louis Peens Add in the logic to update flow stats. The flow stats from the nfp is saved in the flow_pay struct, which is associated with the final merged flow. This saves deltas however, so once read it needs to be cleared. However the flow stats requests from the kernel is from the other side of the chain, and a single tc flow from the kernel can be merged into multiple other tc flows to form multiple offloaded flows. This means that all linked flows needs to be updated for each stats request. Signed-off-by: Louis Peens Signed-off-by: Yinjun Zhang Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/flower/conntrack.c | 139 +++++++++++++++++- .../ethernet/netronome/nfp/flower/conntrack.h | 8 + .../net/ethernet/netronome/nfp/flower/main.h | 3 + .../ethernet/netronome/nfp/flower/offload.c | 9 +- 4 files changed, 157 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c index df782a175a67..2abf02eed7fb 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -1521,6 +1521,139 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv, return 0; } +static void +nfp_fl_ct_sub_stats(struct nfp_fl_nft_tc_merge *nft_merge, + enum ct_entry_type type, u64 *m_pkts, + u64 *m_bytes, u64 *m_used) +{ + struct nfp_flower_priv *priv = nft_merge->zt->priv; + struct nfp_fl_payload *nfp_flow; + u32 ctx_id; + + nfp_flow = nft_merge->flow_pay; + if (!nfp_flow) + return; + + ctx_id = be32_to_cpu(nfp_flow->meta.host_ctx_id); + *m_pkts += priv->stats[ctx_id].pkts; + *m_bytes += priv->stats[ctx_id].bytes; + *m_used = max_t(u64, *m_used, priv->stats[ctx_id].used); + + /* If request is for a sub_flow which is part of a tunnel merged + * flow then update stats from tunnel merged flows first. + */ + if (!list_empty(&nfp_flow->linked_flows)) + nfp_flower_update_merge_stats(priv->app, nfp_flow); + + if (type != CT_TYPE_NFT) { + /* Update nft cached stats */ + flow_stats_update(&nft_merge->nft_parent->stats, + priv->stats[ctx_id].bytes, + priv->stats[ctx_id].pkts, + 0, priv->stats[ctx_id].used, + FLOW_ACTION_HW_STATS_DELAYED); + } else { + /* Update pre_ct cached stats */ + flow_stats_update(&nft_merge->tc_m_parent->pre_ct_parent->stats, + priv->stats[ctx_id].bytes, + priv->stats[ctx_id].pkts, + 0, priv->stats[ctx_id].used, + FLOW_ACTION_HW_STATS_DELAYED); + /* Update post_ct cached stats */ + flow_stats_update(&nft_merge->tc_m_parent->post_ct_parent->stats, + priv->stats[ctx_id].bytes, + priv->stats[ctx_id].pkts, + 0, priv->stats[ctx_id].used, + FLOW_ACTION_HW_STATS_DELAYED); + } + /* Reset stats from the nfp */ + priv->stats[ctx_id].pkts = 0; + priv->stats[ctx_id].bytes = 0; +} + +int nfp_fl_ct_stats(struct flow_cls_offload *flow, + struct nfp_fl_ct_map_entry *ct_map_ent) +{ + struct nfp_fl_ct_flow_entry *ct_entry = ct_map_ent->ct_entry; + struct nfp_fl_nft_tc_merge *nft_merge, *nft_m_tmp; + struct nfp_fl_ct_tc_merge *tc_merge, *tc_m_tmp; + + u64 pkts = 0, bytes = 0, used = 0; + u64 m_pkts, m_bytes, m_used; + + spin_lock_bh(&ct_entry->zt->priv->stats_lock); + + if (ct_entry->type == CT_TYPE_PRE_CT) { + /* Iterate tc_merge entries associated with this flow */ + list_for_each_entry_safe(tc_merge, tc_m_tmp, &ct_entry->children, + pre_ct_list) { + m_pkts = 0; + m_bytes = 0; + m_used = 0; + /* Iterate nft_merge entries associated with this tc_merge flow */ + list_for_each_entry_safe(nft_merge, nft_m_tmp, &tc_merge->children, + tc_merge_list) { + nfp_fl_ct_sub_stats(nft_merge, CT_TYPE_PRE_CT, + &m_pkts, &m_bytes, &m_used); + } + pkts += m_pkts; + bytes += m_bytes; + used = max_t(u64, used, m_used); + /* Update post_ct partner */ + flow_stats_update(&tc_merge->post_ct_parent->stats, + m_bytes, m_pkts, 0, m_used, + FLOW_ACTION_HW_STATS_DELAYED); + } + } else if (ct_entry->type == CT_TYPE_POST_CT) { + /* Iterate tc_merge entries associated with this flow */ + list_for_each_entry_safe(tc_merge, tc_m_tmp, &ct_entry->children, + post_ct_list) { + m_pkts = 0; + m_bytes = 0; + m_used = 0; + /* Iterate nft_merge entries associated with this tc_merge flow */ + list_for_each_entry_safe(nft_merge, nft_m_tmp, &tc_merge->children, + tc_merge_list) { + nfp_fl_ct_sub_stats(nft_merge, CT_TYPE_POST_CT, + &m_pkts, &m_bytes, &m_used); + } + pkts += m_pkts; + bytes += m_bytes; + used = max_t(u64, used, m_used); + /* Update pre_ct partner */ + flow_stats_update(&tc_merge->pre_ct_parent->stats, + m_bytes, m_pkts, 0, m_used, + FLOW_ACTION_HW_STATS_DELAYED); + } + } else { + /* Iterate nft_merge entries associated with this nft flow */ + list_for_each_entry_safe(nft_merge, nft_m_tmp, &ct_entry->children, + nft_flow_list) { + nfp_fl_ct_sub_stats(nft_merge, CT_TYPE_NFT, + &pkts, &bytes, &used); + } + } + + /* Add stats from this request to stats potentially cached by + * previous requests. + */ + flow_stats_update(&ct_entry->stats, bytes, pkts, 0, used, + FLOW_ACTION_HW_STATS_DELAYED); + /* Finally update the flow stats from the original stats request */ + flow_stats_update(&flow->stats, ct_entry->stats.bytes, + ct_entry->stats.pkts, 0, + ct_entry->stats.lastused, + FLOW_ACTION_HW_STATS_DELAYED); + /* Stats has been synced to original flow, can now clear + * the cache. + */ + ct_entry->stats.pkts = 0; + ct_entry->stats.bytes = 0; + spin_unlock_bh(&ct_entry->zt->priv->stats_lock); + + return 0; +} + static int nfp_fl_ct_offload_nft_flow(struct nfp_fl_ct_zone_entry *zt, struct flow_cls_offload *flow) { @@ -1553,7 +1686,11 @@ nfp_fl_ct_offload_nft_flow(struct nfp_fl_ct_zone_entry *zt, struct flow_cls_offl nfp_ct_map_params); return nfp_fl_ct_del_flow(ct_map_ent); case FLOW_CLS_STATS: - return 0; + ct_map_ent = rhashtable_lookup_fast(&zt->priv->ct_map_table, &flow->cookie, + nfp_ct_map_params); + if (ct_map_ent) + return nfp_fl_ct_stats(flow, ct_map_ent); + break; default: break; } diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h index bd07a20d054b..beb6cceff9d8 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -246,4 +246,12 @@ int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent); */ int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data, void *cb_priv); + +/** + * nfp_fl_ct_stats() - Handle flower stats callbacks for ct flows + * @flow: TC flower classifier offload structure. + * @ct_map_ent: ct map entry for the flow that needs deleting + */ +int nfp_fl_ct_stats(struct flow_cls_offload *flow, + struct nfp_fl_ct_map_entry *ct_map_ent); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index d77b569b097f..917c450a7aad 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h @@ -566,4 +566,7 @@ nfp_flower_del_linked_merge_flows(struct nfp_app *app, int nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow, u8 mtype); +void +nfp_flower_update_merge_stats(struct nfp_app *app, + struct nfp_fl_payload *sub_flow); #endif diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 2929b6b67f8b..556c3495211d 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c @@ -1595,7 +1595,7 @@ __nfp_flower_update_merge_stats(struct nfp_app *app, } } -static void +void nfp_flower_update_merge_stats(struct nfp_app *app, struct nfp_fl_payload *sub_flow) { @@ -1622,10 +1622,17 @@ nfp_flower_get_stats(struct nfp_app *app, struct net_device *netdev, struct flow_cls_offload *flow) { struct nfp_flower_priv *priv = app->priv; + struct nfp_fl_ct_map_entry *ct_map_ent; struct netlink_ext_ack *extack = NULL; struct nfp_fl_payload *nfp_flow; u32 ctx_id; + /* Check ct_map table first */ + ct_map_ent = rhashtable_lookup_fast(&priv->ct_map_table, &flow->cookie, + nfp_ct_map_params); + if (ct_map_ent) + return nfp_fl_ct_stats(flow, ct_map_ent); + extack = flow->common.extack; nfp_flow = nfp_flower_search_fl_table(app, flow->cookie, netdev); if (!nfp_flow) {