From patchwork Thu May 11 17:38:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 1780223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=VFI9C6yW; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QHK0F0P5Lz214S for ; Fri, 12 May 2023 03:39:41 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pxAGL-0005Mb-H1; Thu, 11 May 2023 17:39:33 +0000 Received: from mail-bn1nam02on2069.outbound.protection.outlook.com ([40.107.212.69] helo=NAM02-BN1-obe.outbound.protection.outlook.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pxAGH-0005I3-M4 for kernel-team@lists.ubuntu.com; Thu, 11 May 2023 17:39:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sl0bR/pQQJMn/9Z4xcdBMoDcAhlFEf2/zQhPf+0F7QFrm2utxJYT+KzQbs3cgR0GP00s90SWq+X7+gq3T38isCh7ZL6ugG1V8T8OK4P/sqgBaefc3epJr8dScjDTo8tL4H5RsL4vov7ageEuREf3Ume4QK3bR/q1BE0MWBOGQ4KslBlDCKDV9KwP8XYv51VLHtLwWWl9OGyzq5WSOWYm0FiWwtZomNK8z1Z/Ggs8mM7fOwloGAcxRedolIltf4eCK5VSzVp1Z+BMmmqy7uXVnvXW157g+bCEAcXryP3JsPyon3AiOwcdWEzEDj06a4F0BtrQp3gxwGgn7TRiKU8aAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mGuac8QgLVrpHN4bNqxuoiwog3tl6JMN/6IoZzzBnzs=; b=QFtAioK7mRRpIhnvAWhL80YtTIES1ZxPOQb/mJz9/ETW7gRyn6g6i8CRCkEzoIV6ZhKpZ278AqpzpXwlTm0S+QM+rf9kvs04XmY4lqkEox8qSswSFaW3qoHZafaVqAEmTj3/5qLajPNv+dikygY5c9OjSxIFQcyeWE1Tj776ODY7j1NBu7bm/Hr31Iu1hSQUms7gAt5HE72UantDMZrTAmRGAsW9wIOgbCU1/pigEW+y1Vti3oHy033uifCFD8Hn7UdfRYYddeDqdxo2cn8t6LixMlQsE9U1dXijOb89gq2KJUtCCN/aQUlNktbB2Oj7tNQkmkRlffw2rzFWVDV9kg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=canonical.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mGuac8QgLVrpHN4bNqxuoiwog3tl6JMN/6IoZzzBnzs=; b=VFI9C6yWDMGhu+iJS36XM2IOtRjPWkGIFja8e4rL13h4Ja5gmfg4SeH8WSu3ukaRMBYvGOPet5VdQ8l2SWShKm8ioeiuLXOdcwj0OKwxugk9ZK/9ywr/+og7PLGEDTe8QL04zgePepp7zdjAIwrhjJmLilwuaxgQFPgrZh6IjBNT3uEmj1Ul+pxyuGWky7+pu40EYbBspd4qMLyhIOyWm90SISfa6OQAWlUX5+msqyqM/FHycy2KozHPQ6u50yPKFfRjAnJZMsLRj12P5t42QXVQe94kDdySqTTxbD1Xyw6RR3WeyTaNr/eB5w8EvY8zmWGrhHr4zFVDrrzI2Kxpbw== Received: from MW4PR03CA0351.namprd03.prod.outlook.com (2603:10b6:303:dc::26) by PH7PR12MB6612.namprd12.prod.outlook.com (2603:10b6:510:210::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Thu, 11 May 2023 17:39:26 +0000 Received: from CO1NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::f3) by MW4PR03CA0351.outlook.office365.com (2603:10b6:303:dc::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.21 via Frontend Transport; Thu, 11 May 2023 17:39:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT016.mail.protection.outlook.com (10.13.175.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.22 via Frontend Transport; Thu, 11 May 2023 17:39:26 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 11 May 2023 10:39:07 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 11 May 2023 10:39:07 -0700 Received: from mtl123.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37 via Frontend Transport; Thu, 11 May 2023 10:39:06 -0700 Received: from sw-mtx-002.mtx.labs.mlnx (sw-mtx-002.mtx.labs.mlnx [10.9.151.106]) by mtl123.mtl.labs.mlnx (8.14.4/8.14.4) with ESMTP id 34BHcvs7018109; Thu, 11 May 2023 20:39:03 +0300 From: William Tu To: Subject: [SRU][J:linux-bluefield][PATCH v1 3/5] net/sched: flower: Move filter handle initialization earlier Date: Thu, 11 May 2023 20:38:54 +0300 Message-ID: <20230511173856.706923-4-witu@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230511173856.706923-1-witu@nvidia.com> References: <20230511173856.706923-1-witu@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT016:EE_|PH7PR12MB6612:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d97687c-4915-451e-22c4-08db5246aa9b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s76kB3vgUeyyMPC84FfHQrZwfopa73G90R9zj1G8x1+I1SOiHcnCU58za4DXutAT7moY+k737QZEzw4P2f9PrWiD2N/O9uygOxbMMRiWNw57RMyJHN941Oi2ATQTUm+jphXxkwyegmx77qzvzwMfQQv56MKXwtX0lgEsLUuGRDcPbH7QUKlhMizfNY7qvyunRLFKF4z4gI2ZO/CzdWqG2FXN4Z3Sw795ObVd+ssGgFpq7HKz3X3ROCSICeKjodIKyAIe+YHcXzBcOgkHSfdcLTtd/gfgpNOWVv/LC/MCwtBHggcyX2QM6Yk05bJNE+Cb8lsSqJby8A4CifxIABFUr4JEAaHpqgXErkIY4pfj192tLGd4yo8WSEU9raSaOa8ecoXFRtQlZtxD3hQw6uejID9W018Wal2ohLOGdNbhZMpxVzdFTmiaJhdnBw4vr4VkhQFB6+io4lIBEjbAEIdkRdCl6PXta5vd/b3t1aFlqLz+KmpPj811pTpy8vOeuuDhRQ7rNKAV3uBzz1r9oKriXBER0PQSy6s8WQL0dcF5ENXGdQxjJr9ashgTku/rWYeai9BPnFraqsT53O+xLdCHisBY0yibW+c19yH6Ch6ZE+4MQ8y+V7TTH7iXdCxflT5UCkyOGqWEn0Y4niPLIeJ4lJccPHDoQCe8c29XXncGlaPlyPXYOb+XAWPr2D7p12IfdcRvDjuS/K8MmmURom3pHL9BS/bp9B1oX7zShFAqfpT5FBLHoJ8d++EAoYu0Ega0 X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199021)(40470700004)(46966006)(36840700001)(356005)(36756003)(86362001)(4326008)(70586007)(966005)(54906003)(478600001)(316002)(6916009)(70206006)(186003)(5660300002)(2906002)(40480700001)(82310400005)(41300700001)(7636003)(8936002)(8676002)(82740400003)(1076003)(107886003)(36860700001)(26005)(336012)(2616005)(83380400001)(47076005)(6666004)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 17:39:26.5601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d97687c-4915-451e-22c4-08db5246aa9b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6612 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dann.frazier@canonical.com, paulb@nvidia.com, vlad@nvidia.com, yifeid@nvidia.com, bodong@nvidia.com Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Paul Blakey BugLink: https://bugs.launchpad.net/bugs/2012571 To support miss to action during hardware offload the filter's handle is needed when setting up the actions (tcf_exts_init()), and before offloading. Move filter handle initialization earlier. Signed-off-by: Paul Blakey Reviewed-by: Jiri Pirko Reviewed-by: Simon Horman Reviewed-by: Marcelo Ricardo Leitner Signed-off-by: Jakub Kicinski (cherry picked from commit 08a0063df3aed8d76a4034279117db12dbc1050f) Signed-off-by: Paul Blakey Signed-off-by: William Tu Acked-by: Tim Gardner Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Bartlomiej Zolnierkiewicz --- net/sched/cls_flower.c | 62 ++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index e3e6c44cf016..54228e684f86 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -2032,10 +2032,6 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, INIT_LIST_HEAD(&fnew->hw_list); refcount_set(&fnew->refcnt, 1); - err = tcf_exts_init(&fnew->exts, net, TCA_FLOWER_ACT, 0); - if (err < 0) - goto errout; - if (tb[TCA_FLOWER_FLAGS]) { fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]); @@ -2045,14 +2041,44 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, } } + if (!fold) { + spin_lock(&tp->lock); + if (!handle) { + handle = 1; + err = idr_alloc_u32(&head->handle_idr, fnew, &handle, + INT_MAX, GFP_ATOMIC); + } else { + err = idr_alloc_u32(&head->handle_idr, fnew, &handle, + handle, GFP_ATOMIC); + + /* Filter with specified handle was concurrently + * inserted after initial check in cls_api. This is not + * necessarily an error if NLM_F_EXCL is not set in + * message flags. Returning EAGAIN will cause cls_api to + * try to update concurrently inserted rule. + */ + if (err == -ENOSPC) + err = -EAGAIN; + } + spin_unlock(&tp->lock); + + if (err) + goto errout; + } + fnew->handle = handle; + + err = tcf_exts_init(&fnew->exts, net, TCA_FLOWER_ACT, 0); + if (err < 0) + goto errout_idr; + err = fl_set_parms(net, tp, fnew, mask, base, tb, tca[TCA_RATE], tp->chain->tmplt_priv, flags, extack); if (err) - goto errout; + goto errout_idr; err = fl_check_assign_mask(head, fnew, fold, mask); if (err) - goto errout; + goto errout_idr; err = fl_ht_insert_unique(fnew, fold, &in_ht); if (err) @@ -2118,29 +2144,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, refcount_dec(&fold->refcnt); __fl_put(fold); } else { - if (handle) { - /* user specifies a handle and it doesn't exist */ - err = idr_alloc_u32(&head->handle_idr, fnew, &handle, - handle, GFP_ATOMIC); - - /* Filter with specified handle was concurrently - * inserted after initial check in cls_api. This is not - * necessarily an error if NLM_F_EXCL is not set in - * message flags. Returning EAGAIN will cause cls_api to - * try to update concurrently inserted rule. - */ - if (err == -ENOSPC) - err = -EAGAIN; - } else { - handle = 1; - err = idr_alloc_u32(&head->handle_idr, fnew, &handle, - INT_MAX, GFP_ATOMIC); - } - if (err) - goto errout_hw; + idr_replace(&head->handle_idr, fnew, fnew->handle); refcount_inc(&fnew->refcnt); - fnew->handle = handle; list_add_tail_rcu(&fnew->list, &fnew->mask->filters); spin_unlock(&tp->lock); } @@ -2163,6 +2169,8 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, fnew->mask->filter_ht_params); errout_mask: fl_mask_put(head, fnew->mask); +errout_idr: + idr_remove(&head->handle_idr, fnew->handle); errout: __fl_put(fnew); errout_tb: