From patchwork Fri Mar 4 10:22:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 12768918 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 47FE1C433FE for ; Fri, 4 Mar 2022 10:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233317AbiCDKXn (ORCPT ); Fri, 4 Mar 2022 05:23:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbiCDKXd (ORCPT ); Fri, 4 Mar 2022 05:23:33 -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 BB0FD3982A for ; Fri, 4 Mar 2022 02:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KeHnqdD9ON8EEbkoFqpAerRSlF6pPmlBjsDdErOQHgVGg6W0q+Sk7xfGsbxI4HOZYcTi4RqB44IepZ9h3CNBzh1tpldaKOZaA87qxzVS/rHTp850n4sWScNH/X6CDj04BvT828VNrmz5KWcAvp1gSVYgAE9AOwF2vA4VpUOqkHi5ZD8aBcr/16OCAEYcAVOI09flGjTayBWI46ab+mlXg/b1amIdCqx272tdgLeRe3UGH6Z8VFvLjvzJz7pjY0kd9rHLvFMDTCqYsEk/CiakUaw+oY3NkIN4CJk/+TtiLg4qWxW4JX0u0ykzk58qrcfBal7La/3R6BTHr/q4eqizLA== 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=FESGjbWHNHBlPyIYx56n6E/WhnW/5Vv+TOUVWTpBUWE=; b=Xy9TlDpflEQXcuO1GrxKBMwF/CLbs5OFNg4lFGsv7f3z9LSNPaYiNESzo04MlhlfRAefKLF1jp1dARDIRXAAir2A12usTprFscO2UicI7QP1E2kXsbRY25yVGlCGgI0dlgIp1Q0I7yteZSI4udaUgSColeR8CHm1po6Kjf4/Hs8HCnHNMPYvgU5DO7M3HqWnakBvGAduTSIyxtsMkGvJvsceggmVPTmiPgB55fISgwLAABTxcoZtxpkds30JeYdalHQyCYxLGvfZljmYtJczhe6caeGPghwdFFwdlzpMlIHkipZNn2P4wzGj/EbDEWV5m8PR3C53KkOs0FG28lhyuA== 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=FESGjbWHNHBlPyIYx56n6E/WhnW/5Vv+TOUVWTpBUWE=; b=dWtj/tgPSTNXT+HwvfUrxAA36GSq10D4l30nip9uR2Vh/yZ+VFi+E60nCK57ESZTmTygksqDV8TfWFKIC3h9ao4nua1xKirDmCv6mu/51MyVjAeuAo9tFj7JqxddW1e+gQmNlc7p/xGg2RzCQLGUFvTjgZcS6kLIfkoMqej6t4I= 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:43 +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:43 +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 2/5] nfp: wrap napi add/del logic Date: Fri, 4 Mar 2022 11:22:11 +0100 Message-Id: <20220304102214.25903-3-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: 19602b54-2bea-4cea-587e-08d9fdc8eb1e 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: 2CsLshtJNJUusKI7SDcf37+hlYaYJV6D3UalESD1fVo/G/DeoGpD57lv60W/pNclRcD1EUATuiXNnZXGbXcBPDLwEYJAzIJ7q3bIZgBqZ3bHOU1zPUVbva75HWJM1nYQfFOdMqODWUlz405dPKP5Wr1U8vvk7fHTOwii1g3V2Zvr60P9W2HkXXoqhE+csYeembFZ6dewARYmCzcC4iLVLbALX0h3rEGXb+fCbnbG9f3m8SV6J4G3KTTiX/9C7vhtFREnnPPFpCRfkniCGyFqjyYl6yzLE+e3tUMxAz97Gb1FumtErtQ0szFAfj2sAH2ZvdDhGuXbdr69ajaoMfdOE/JtRrcQrbQVzDzykxmiaVeSD0OGpto/Zao7TOEkqJZsoN33DRklDOuq63V/5gZTOXPRe5NSBQiPoNXgJCWkHdyMgs/cMKBPQEyoCr0S+juTzIU+eGHuIue8pNSlKAZQD0/ZDFyHXv38hpS9247bdqksVjuponnjYlUpPBuTqfKO/83XGSYWp89qXvKGkLvIdL1kpJcuW7X78M8fQkGSff3CteLbGaHLyqNVU5pf5L/p6Gd6tpmcmvOlKJ07h1jp1Ogh8OIeBM6uua/7LeY6phNmhfpz5DM8OTZ7mM7c8ADC7MPlZF8ZlrYM+29pHZzfPQ== 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)(66574015)(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?O2nAzW9VrQDfOFMIHDtpgvuDtTC1?= =?utf-8?q?Z+rojkhjp0RoQlnbKUi2tx+VBkbNxSauWHszGqVHPWt66/aSkkEYiR4XY7WYb88Y0?= =?utf-8?q?ndpnqVFFmkTxMLY3+L9HykoF53iYwJoXERB/P5EBvfDd+s8un8qeQ9srQjJOP+vFZ?= =?utf-8?q?ODfQDC41gkpAUHi2dunX1sjjZIbAw7bDsLZLtQ+uPjTQYA1Bj38j35uK6miaMOlsh?= =?utf-8?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ousgdymWyUrYscj/RQQL7xaTkXaBD/oSXpIwY/rWoXhUcH27xHKAOyhTCEVoK5zwS?= =?utf-8?q?6R7mXSGsCN2TPwVlxuOJCbYTNBOfETpJirXUiAbcQAjIiuuRoujatdisPBqeGq7Yv?= =?utf-8?q?XYJNjpXRQI6hR4EJeJz6rOTpHNDOcU+rK8YbYSa8l+n9Q9qsXDUOUmnd0+C5nqk0e?= =?utf-8?q?Ny3yftsAL6iY0PwpMHBVKOUsuG94i3fxpQKWSEqg7VHxQpcwxyr7rFb3Pr+l8t7F9?= =?utf-8?q?GeOIwl0KpUBSkBga0LBpSxPNr5qH3McQGXCGadtz+SHEuWTI2YM7+ii8wxvtLBhJc?= =?utf-8?q?gkgQccP1MWQpNTw4V9BfwscSj8/9m43t+ncJaM4mNInhtUEnBljkkpYiXMwY6WUqK?= =?utf-8?q?19wtlCjjOp91Q4XnIiCLW3aGe+jXVAzJe7V+GL8b/bdHzj0ZHQhL+nQnYoNhB/4Wf?= =?utf-8?q?vU2dTDBRMI8PEFayquWj0DeGgYl8p6wTTdYL0j4ONtGUy9WhSx0EaDjo6WHUGXkG5?= =?utf-8?q?+wVthBw1b2X8urb+VcWspYNjdFzd7DCynBtvIbTAGkLml3TvfrnShYUVyl1E0752Z?= =?utf-8?q?e1kkyb9MMoixDV5SNvJlMPOgfCemiiXIlMgMXpEVSsAeAoLRMF7PQ=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19602b54-2bea-4cea-587e-08d9fdc8eb1e 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:43.0649 (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: Ad8Zsc3OiXT+hieQ4rRQ/wY/09hQYD2v0F5WCa1jStD/A7GHZGVELpgWt4ryDM53rxXjdEXG0r64sjP3fCr7gkPtWzBFXGAomfnPHN5AyAc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR13MB2404 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jakub Kicinski There will be more NAPI register logic once AF_XDP support is added, wrap our already conditional napi add/del into helpers. Signed-off-by: Jakub Kicinski Signed-off-by: Niklas Söderlund Signed-off-by: Simon Horman --- .../ethernet/netronome/nfp/nfp_net_common.c | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index edf7b8716a70..e6a17af731ba 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -2638,6 +2638,25 @@ static void nfp_net_rx_rings_free(struct nfp_net_dp *dp) kfree(dp->rx_rings); } +static void +nfp_net_napi_add(struct nfp_net_dp *dp, struct nfp_net_r_vector *r_vec) +{ + if (dp->netdev) + netif_napi_add(dp->netdev, &r_vec->napi, + nfp_net_poll, NAPI_POLL_WEIGHT); + else + tasklet_enable(&r_vec->tasklet); +} + +static void +nfp_net_napi_del(struct nfp_net_dp *dp, struct nfp_net_r_vector *r_vec) +{ + if (dp->netdev) + netif_napi_del(&r_vec->napi); + else + tasklet_disable(&r_vec->tasklet); +} + static void nfp_net_vector_assign_rings(struct nfp_net_dp *dp, struct nfp_net_r_vector *r_vec, int idx) @@ -2656,23 +2675,14 @@ nfp_net_prepare_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec, { int err; - /* Setup NAPI */ - if (nn->dp.netdev) - netif_napi_add(nn->dp.netdev, &r_vec->napi, - nfp_net_poll, NAPI_POLL_WEIGHT); - else - tasklet_enable(&r_vec->tasklet); + nfp_net_napi_add(&nn->dp, r_vec); snprintf(r_vec->name, sizeof(r_vec->name), "%s-rxtx-%d", nfp_net_name(nn), idx); err = request_irq(r_vec->irq_vector, r_vec->handler, 0, r_vec->name, r_vec); if (err) { - if (nn->dp.netdev) - netif_napi_del(&r_vec->napi); - else - tasklet_disable(&r_vec->tasklet); - + nfp_net_napi_del(&nn->dp, r_vec); nn_err(nn, "Error requesting IRQ %d\n", r_vec->irq_vector); return err; } @@ -2690,11 +2700,7 @@ static void nfp_net_cleanup_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec) { irq_set_affinity_hint(r_vec->irq_vector, NULL); - if (nn->dp.netdev) - netif_napi_del(&r_vec->napi); - else - tasklet_disable(&r_vec->tasklet); - + nfp_net_napi_del(&nn->dp, r_vec); free_irq(r_vec->irq_vector, r_vec); }