From patchwork Fri Mar 4 10:22:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12768919 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 003E4C433EF for ; Fri, 4 Mar 2022 10:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233430AbiCDKXp (ORCPT ); Fri, 4 Mar 2022 05:23:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232757AbiCDKXf (ORCPT ); Fri, 4 Mar 2022 05:23:35 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2115.outbound.protection.outlook.com [40.107.243.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1DD34FC78 for ; Fri, 4 Mar 2022 02:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=daBWISHLG8JP7SiEc/cF6rHpJRoWEPt6IR6J/TsioUWbjWvUHHCHHYYZb7lCV6zvOlCDdnJlvf4MGKkAVJhw96cVIW9B7aNR0FEk3y9XfT8MOr8luAuPUGo3UIvbmC3pO/zG75klOCSP1bGKmiEdCndctaFPLAP2CslLTXBxcHYWNJezJDymfrP7ekvm6aYNlc4k6DQxLn61muY+vBTJrgqOf7uE8BHgqu3u44jaJXZ3Zg2zqaVO4TwLXT1qgpNq3pWAwQM0Tg7E5wDxlGdyM1pHq24A1QimHXxqrE3A4cUyp44dWCPgOtSov5EH/2ve3z8CK4ve7+vKgrY09TgAfw== 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=hU0B925EyjRBDADBs2ULn9tGrWSG7S0lYlorGoKvivs=; b=XvxeV3DjPE2Bnx0wh6IH1AdT1LWqFLXxjdg4HmlIYDeFlSdlRhAByBklG8oWO0z9KqoOHhtpPK8lQVNZU91LIlpOG8czdKzKCbSaq3fSDWjj4q2vkmOICbL2rpiGnaO8FRyNiE5p+ChD11NAJR25v385R0L3VghnjoFVH1EDGweUWLhHm6PWWDlS2nMoCeijE2N3aznJ0PZqJxyvgIov0iZLUUcTut1RwG6GuUo/wcbNoWHITQuzsh5dMopqwOO4QcXI5Zz1rJRLfo6/5tXqHnhTPDXY2zn8YXkQ9CkNL52mIL5rm+joJp4vw9el1HV0KCnQl+w9KxT5hMXRBqErBQ== 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=hU0B925EyjRBDADBs2ULn9tGrWSG7S0lYlorGoKvivs=; b=D7bR4mDW/SdXM2wNdnA0xgoT4w/s0HxtDfuGnb7rJhf5kqju29CiDAcydqBUwPAl0iFGoisqw60uv8bz7mHkw07oLJZrJJMbGg7dk+GEvOnaEV3DU5VVEbh8/2qKhK9FI/EHtNizNri122F7PmLWIP150desuyimhurK2HNH6XU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by BN7PR13MB2404.namprd13.prod.outlook.com (2603:10b6:406:b7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.11; Fri, 4 Mar 2022 10:22:44 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::d27:c7d9:8880:a73e]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::d27:c7d9:8880:a73e%2]) with mapi id 15.20.5038.017; Fri, 4 Mar 2022 10:22:44 +0000 From: Simon Horman To: David Miller , Jakub Kicinski , =?utf-8?q?Niklas_S=C3=B6derlund?= Cc: netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 3/5] nfp: xsk: add an array of xsk buffer pools to each data path Date: Fri, 4 Mar 2022 11:22:12 +0100 Message-Id: <20220304102214.25903-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220304102214.25903-1-simon.horman@corigine.com> References: <20220304102214.25903-1-simon.horman@corigine.com> X-ClientProxiedBy: AM8P190CA0012.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::17) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 633e3909-a068-4906-ee6c-08d9fdc8ebf4 X-MS-TrafficTypeDiagnostic: BN7PR13MB2404:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UZltEl/VApJy5JKWKBQw8+ViuLaWjF8mlxKQJPSrG7LeNQ1GGG2vFyGy5+HO3Me129FYvIYy4gkXVum6SQXvRgqfS4seh8ThgA1SGt1L0OrkHyvanb0w967lS0QRI4b2gDYCRoUfb1HuoTTMpTLFW1GCKqvvwO5bH4KowMxBFO5ydL/UUWPOw2Oc6wllpXW2q3XfvMTnBgjw41x5oN/nHfVhZaJzKRDHyuxR0CTJ5T7KKJe2dNRde57O3sUgtB8fLVwT+bvuhP32JYsmJXcGDF/R2JhhtLSmMPJ8w0SgIhYMku93g60mOF/l+Ei60sMFjkfstguGjjL+ey56eU3NR4obvkDXcaHLjK7PYAQsU/4JLzq0YD7Dwzh7wwxYEMttkMVOcvnmB3CcJkgvHoDWGXzdD3rfr3g8n4pUqEoYoY8dda37Z42ubngHbpENlb/n6H3t53WpcLq/xNbj7ruRPRIqhyE5voQakOUT1X2BZB1Lto6BOjCWXoJiidFgXn0drnf6NWBp7bXXfVYtIjnkCRh2K1bkCR4VLfC59OpMOP6dc1URNqfiKEQi/gQfmxtIGH/3fMvxx0pJizor2siQ4O9Nb+fYoWUYDDU7mHCZuTzUM/c3tWgkXeT2EaOxboVyC0bb9Nci+QcAZUgI3lNahA== 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:(13230001)(366004)(396003)(346002)(136003)(376002)(39840400004)(110136005)(316002)(86362001)(4326008)(8676002)(38100700002)(52116002)(66476007)(66556008)(66946007)(6666004)(6512007)(6636002)(6506007)(6486002)(508600001)(8936002)(44832011)(107886003)(5660300002)(186003)(2616005)(2906002)(1076003)(36756003)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?5aG75+7cstYYixhawTj26JNAi1Nq?= =?utf-8?q?Rd3V1r/a4Ul4+71dPWjPDhZQzekO9BVYf3AqsBsBLVunT7AQsn9G7Wz4TKMuCqL5K?= =?utf-8?q?O7ftugR2v1y/9ftsexsr53uxOpQRrfobl335FHdqehVGsHi7M8RJ+vtRo7uSeeUrK?= =?utf-8?q?cC2epuXrIcvFqILq9rLyX0OeMWCs6G0Igosof1QMxd1pQsRDktUouiFmWptTLSLoB?= =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rfJMADFxMjesAMPkbhrBb+JYSXPgZ1PDC9uI3siq8nIFwqJwVtAMoBhlM?= =?utf-8?q?ieSlXbr9LVRVVOUwP4fA+BkoZ76bRmiiXyHzin1x3nBZbLVi3Nc422xvJx+sUDK9L?= =?utf-8?q?0RncSG9FtMg2hIJYewWT/vQZyJOC7pMQu7crdfwSxePSxY2LF5KSYZFpjEwgKnaGq?= =?utf-8?q?uTXfy78QLHwt1q97MGctLzGyVzOWEJ2nUoIRBzbI1Hocli8ZmG5HjyGIDjILEOVWC?= =?utf-8?q?DsXFoqoV7PKp5AY1VsEcWts+MmMMR/0kmNVmRWfLzXkYIK59F5xNLPFTHPuDYxszE?= =?utf-8?q?dOlUUU4i/v2sMobgUnnAtJKsuRMzp4Wa086q9/5jjCl0QJ/ESzhe794ZWIagNzNxc?= =?utf-8?q?T5UXUCS6XkxoVfXnQxcvrrTQ1QoKOgkM6ytGDc18x0lORAvz9eTW3ZCN8GPsSoON3?= =?utf-8?q?+ZU+Y+ykJr1k/6oWFF2jCuLF8Sxh0PCK8r3Ew+p4vAt/9GTy8jFceQ9bM85tEAzfe?= =?utf-8?q?RpqeHKmVoIs1TSUbkEtqPgjOa8JZPLvrHN3Cy90DyMXNC2Ikt5RETvknRM8GBpPCQ?= =?utf-8?q?pVDEyVc02WgwrVcxCBhBkgJRR/xIzD6oQH1cOa2A6oDo0d6X9M/8s=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 633e3909-a068-4906-ee6c-08d9fdc8ebf4 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2022 10:22:44.5025 (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: ZakFWGlb8BAjgttDwr6rXH1450QU63o61qFxlfm+zoLpad3OMfpuqZqJNMrvzEycyfpANWgE+Kz1rygmlVn1/nlmlB3oIUB2PQINrPtjEoU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR13MB2404 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Niklas Söderlund Each data path needs an array of xsk pools to track if an xsk socket is in use. Add this array and make sure it's handled correctly when the data path is duplicated. Signed-off-by: Niklas Söderlund Signed-off-by: Simon Horman --- drivers/net/ethernet/netronome/nfp/nfp_net.h | 4 ++++ .../ethernet/netronome/nfp/nfp_net_common.c | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net.h b/drivers/net/ethernet/netronome/nfp/nfp_net.h index fa40d339df8d..12f403d004ee 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_net.h @@ -109,6 +109,7 @@ struct nfp_eth_table_port; struct nfp_net; struct nfp_net_r_vector; struct nfp_port; +struct xsk_buff_pool; /* Convenience macro for wrapping descriptor index on ring size */ #define D_IDX(ring, idx) ((idx) & ((ring)->cnt - 1)) @@ -501,6 +502,7 @@ struct nfp_stat_pair { * @num_stack_tx_rings: Number of TX rings used by the stack (not XDP) * @num_rx_rings: Currently configured number of RX rings * @mtu: Device MTU + * @xsk_pools: AF_XDP UMEM table (@num_r_vecs in size) */ struct nfp_net_dp { struct device *dev; @@ -537,6 +539,8 @@ struct nfp_net_dp { unsigned int num_rx_rings; unsigned int mtu; + + struct xsk_buff_pool **xsk_pools; }; /** diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index e6a17af731ba..abfc4f3963c5 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -3302,6 +3302,15 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn) *new = nn->dp; + new->xsk_pools = kmemdup(new->xsk_pools, + array_size(nn->max_r_vecs, + sizeof(new->xsk_pools)), + GFP_KERNEL); + if (!new->xsk_pools) { + kfree(new); + return NULL; + } + /* Clear things which need to be recomputed */ new->fl_bufsz = 0; new->tx_rings = NULL; @@ -3312,6 +3321,12 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn) return new; } +static void nfp_net_free_dp(struct nfp_net_dp *dp) +{ + kfree(dp->xsk_pools); + kfree(dp); +} + static int nfp_net_check_config(struct nfp_net *nn, struct nfp_net_dp *dp, struct netlink_ext_ack *extack) @@ -3395,7 +3410,7 @@ int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp, nfp_net_open_stack(nn); exit_free_dp: - kfree(dp); + nfp_net_free_dp(dp); return err; @@ -3404,7 +3419,7 @@ int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *dp, err_cleanup_vecs: for (r = dp->num_r_vecs - 1; r >= nn->dp.num_r_vecs; r--) nfp_net_cleanup_vector(nn, &nn->r_vecs[r]); - kfree(dp); + nfp_net_free_dp(dp); return err; }