From patchwork Fri Oct 20 13:49:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430766 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 AC756C001DF for ; Fri, 20 Oct 2023 13:50:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377481AbjJTNuT (ORCPT ); Fri, 20 Oct 2023 09:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377304AbjJTNuS (ORCPT ); Fri, 20 Oct 2023 09:50:18 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32721D4C for ; Fri, 20 Oct 2023 06:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809816; x=1729345816; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=xfWZrcLhOyBWr6bw+0L6MFZ1c4l2R/4V4LyEPE9NcZ0=; b=RJa5nu9gh4BAxQYRG8jXm9Gj5ZBx3RL7c3c0YXvfZx0xi5OvEYbZ7Str ZfP/6MOHROsjNWCMvvkBa4GJ2hRATUL/23P9umaxxRyoN4PapIfHaBvL5 +bCDgbgIwpAA12nWf4QC2eJnVYdSa/Q3Sy9+lcQne2evGjXhB1Oid6KmW 3hRo7FRWmQ1aaXTJQTKPfoImwxwyF74kBo4eVWzibQfpjYJyalgcoqRBy 7aGiyv4oPWqHmsRA0+Gabd+AEQHefZOExGEPIRqKj8nA88vzUi6pfyqQS RjtVw9p4GifelsrYYR8qXKfKPMUPwAay5m/nqu+odt4n+aA5gc1F+seG7 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="452976858" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="452976858" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="733967936" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="733967936" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga006.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:15 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:15 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:15 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WhWkygUsro0li/eKA2G3rRzioOUvw1jk9lsDigsi5K0MP16Xuf70b6rfuGgMaEvwG+eWEaRkK9nZJVBIrb2q8Y3AmKYh+/sFQXzKb2kVywxnGLZ0xEyoBldu29TG5RDkQ/R8vqTnINXCLHhUGWRnDqGy72YW2KrzMacQYyVV5nWa/AjeQyhtDuKsO4kVH/7B8W4rSjtk9AhwNQVy54QvAD4IP7P1eP5aQGLwythVXpZCE1A0W5crDboIFPn04u/365lBUK+/IoQ+cCBbiyPUMkPsisNwyIoFVuzbg5mzwSdabF9Wb998/6+TlKf1Ilq9DzyIZriLmBchZAn+7yu5DQ== 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=mHVbZKL7CMxwWhzI1BI44BBWb2hNxp7szSiDofCTjdY=; b=FlpApG9euULHoccnDNJ9LPbv5rljJaqkbr3KmEbIEboL3/dc8ZBkDNLIstlnHZQw6VNfyXLktEikL3NGntYc6JLq0T7hkpfgCQqOYdej14F7sJZYi8vdBDlUE2cZZYQCFP/DDjZP7VYQkWlTrmOwk04KSzjj/XvFVyVbjXEitEOFKYSCNDJ1SoazyH2mTVBq8OYu+EMJcGJjBWQfO7DBQE9EgLPc0EvnOVprbxeGE0qUO+/kpQEQIqB8QY7e7MI5jjYV3kwuPeMdlZaT7wzFdhWCE3bshqz6X2eYFGQfI8qF5lJc4hklzSyC9VCAtAXXgh5pIhqMh7Kbdbh+IAZ+gA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by PH7PR11MB8035.namprd11.prod.outlook.com (2603:10b6:510:245::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Fri, 20 Oct 2023 13:50:10 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:10 +0000 From: Damian Muszynski To: CC: , , Giovanni Cabiddu , Damian Muszynski , Tero Kristo Subject: [PATCH v2 01/11] crypto: qat - refactor fw config related functions Date: Fri, 20 Oct 2023 15:49:21 +0200 Message-ID: <20231020134931.7530-2-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|PH7PR11MB8035:EE_ X-MS-Office365-Filtering-Correlation-Id: 97717cff-49e7-416d-3e51-08dbd1737a1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6kKCe6qU5LdGK1oAuKwfgNwup5HW9U/Yo2AfusnfL59wgp7+tgz60yJqBNEDNa1bUCLtHEzwQ1XgFbfDuFujvD0mC5DkbnIIEG6JBeNEjwRFrMxzfRdfEG85rw9dhzByUYYJgyiT3vIUMyV2++9Uj0xD3xSzdvTbCMAcUfqktLrNK127qd/HT+Luk+D9swTD+BuQ9k5Rao4Nn7bykqETsRHH5XD5CCJk+urvzYR+PoOYMATeL46pt0450BRaQg11YJ+8d/5sN093PhUMqjTLIpkdaoRRCvZTyOf97SQEYBp2bnp42DJ1YxrG8j+J9Kd4uqKNSvr1lZpor4PCLaP5GGs/3etJ0yAxtoG9vPtTYkoLLW9sB5MuRXbdnsvCYr40W06oMUy82yUyIRNds7mifbk1allVgN66AHRheSHxbHlcvxLPWwE7xC16zS1NtK9PaVbuY2ZBwS8DeUL01qyqcVNss/irI3ybZmjfloGXGocmarodPbPeBTUW+B25n2VlzJzyVY+sRaXY9B0ZZPnOTADrwd+qWVpFyql4RM+QjCeDIxG5JH0kGDfWv28cek8k X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(83380400001)(54906003)(38100700002)(6916009)(66476007)(41300700001)(6512007)(36756003)(2616005)(1076003)(86362001)(44832011)(2906002)(4326008)(66946007)(5660300002)(8676002)(8936002)(6666004)(36916002)(316002)(66556008)(6506007)(6486002)(478600001)(26005)(82960400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K1xib+SBKTvM7hE2goBAIrmIk4FIicU2+e0FnVgHKJ5fQ6r/ue1dFOS8ZgFnaJOfUuEDgCSOC3urwbsGk8gz3PbpRjhbhrkoDHUlpSMBd42TVVp35N5gt3X61Fh/11nXOQCr6doYgxoaRsabci2kXGrswU4ugRl3KFIAzNLdFn1h7cFuRKojaJJquy80mza6hAAAhy4JYNhuddtdfStX+daObUIGiAvG+lgsTOpPuFxvOC4TqOhmnVKfan3Yaaz0mJxXPsGNdLkFUwf5KD6IglSLnPFrWbeTy2BzJ0X2iVOkF3ysbyZtrYHJmWKLS+WE3Caf1K48gx9zYPRTyy3gRv6NBYn5yWkL+1+KJNJwILohs5InJ+8XwoU1hvK80i5b7DwBJYa1//nCHP/9i1tBPirRhsRT7DKOBe6wA60Cezrtx2qIWNivG0RAf1TpUOyXAUuRNWExMLdDXE2sDvfE6VF5gROvPz+EEuRthJI7gHwT+UymUZvo0TJWLOytQDbanQz/FYdkMcT4Ig1acogFTi1cdvqjwmHTneG7Pl6zMyqPr1InGL6axU8VXpH0oAMnthOKXSw9lHFt7AtccI/GI/DWuljkhn51SYBJk8oDwrJf4DY9qNqNCywCQQ69SZgDl2+01t408m18vF5SnOFRRylbZZXwQMD9Xw560m/Pg3pPyezIq2vFzTkf6B/XUmolL5tMNrMcaag2ZNFLOfYteOwM6UZCVuqu0RJa0XFzuU5Jes4Riomt7KyFPmnpKoGWMgxfa5tuYwXNMiVMDM+8G7vyDquVZy0gObLrr6ibBLKyJ9PhUxvPLCtcBPaOa2HPXUm37Ez3BTdnmzCRokgOMEe1w52oDjvCCwmdUqb/cBVzWpdgRvdNPSlWKQa+SYKNdqvfZzG5kQgALdXxe18oRhVRjFu+kI5ft02f9KhvTYk8kymlQxg+k2c5vT2/17F+9EiCKTG+SfvyBzRGyHowFPQ5+zQ1hxzELRs2j75iOPdrDAqGGP1EjG/SsRLVWhz5oIeU4Vtw43CFUnv3v9H9+QSFmEKrnmPsD2lHMYxbWTIILlR4sNxThtv6ZvRP17OFNvoEQ8qa/rdjUJ8fpO/KzPH13VA01Yk5zmvGSatpcZRQIIWauEVwSdhbTWpEsSlN9kf19rVGejZ2WPSDrW6iD4reeWvZB9Oee/uVDbAecoaBVQ7cd/JMGeXqdZ3ub4anHrK/cbN7jzvI2jAtWfmGpD6d7gYagCD9Xlz1TG5o5vIZogo8pMA62IANt6GbJ6MWAtIGTB0+ogzpZ5eeGqVdJLLM3map1m6E2d3bDCt7joqXAsjT/C4o1EmBn9fbfoyQfn1jpWyGKnj0/jOdPk7czzolDpsOEMukZnEFN/yDUr0t5Dfu2MmowEZFSmVHhw/X4iv/UHMgebxX1IV31y1Zp8iiaTMIf0/zCi+kAYgpO0/55H0WRvFyUK55aqe1PO1cOvfp4HphJ44mMbrO5Wz+83whmB+Z/FKJcD1nVnbj4ZCYBls7fzbn1gkarUHYvwzTAvYXfvd0eT0GTdgapTxp9QT6wPM1Q4+R8QEI4x2Rvx38br7I1YjPHVCPDIoI6/TwB1YdWJD8toeDk1lnhXr24Q== X-MS-Exchange-CrossTenant-Network-Message-Id: 97717cff-49e7-416d-3e51-08dbd1737a1c X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:10.5162 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xPLUwkPMDatqzptu/Q2ey4ci2U3CROS8pXT7cMFU9zVOaTWuAc7Btlwid+01pbycIMq8MpKDIXPEFBI3iCGDJTQzvQMG2DpV3wnYe4OpWUI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB8035 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Giovanni Cabiddu The logic that selects the correct adf_fw_config structure based on the configured service is replicated twice in the uof_get_name() and uof_get_ae_mask() functions. Refactor the code so that there is no replication. This does not introduce any functional change. Signed-off-by: Giovanni Cabiddu Reviewed-by: Damian Muszynski Reviewed-by: Tero Kristo --- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 69 ++++++++----------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c index 51db004641bf..3ea4bfc91bfe 100644 --- a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +++ b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c @@ -395,40 +395,42 @@ static u32 uof_get_num_objs(void) return ARRAY_SIZE(adf_fw_cy_config); } -static const char *uof_get_name(struct adf_accel_dev *accel_dev, u32 obj_num, - const char * const fw_objs[], int num_objs) +static const struct adf_fw_config *get_fw_config(struct adf_accel_dev *accel_dev) { - int id; - switch (get_service_enabled(accel_dev)) { case SVC_CY: case SVC_CY2: - id = adf_fw_cy_config[obj_num].obj; - break; + return adf_fw_cy_config; case SVC_DC: - id = adf_fw_dc_config[obj_num].obj; - break; + return adf_fw_dc_config; case SVC_DCC: - id = adf_fw_dcc_config[obj_num].obj; - break; + return adf_fw_dcc_config; case SVC_SYM: - id = adf_fw_sym_config[obj_num].obj; - break; + return adf_fw_sym_config; case SVC_ASYM: - id = adf_fw_asym_config[obj_num].obj; - break; + return adf_fw_asym_config; case SVC_ASYM_DC: case SVC_DC_ASYM: - id = adf_fw_asym_dc_config[obj_num].obj; - break; + return adf_fw_asym_dc_config; case SVC_SYM_DC: case SVC_DC_SYM: - id = adf_fw_sym_dc_config[obj_num].obj; - break; + return adf_fw_sym_dc_config; default: - id = -EINVAL; - break; + return NULL; } +} + +static const char *uof_get_name(struct adf_accel_dev *accel_dev, u32 obj_num, + const char * const fw_objs[], int num_objs) +{ + const struct adf_fw_config *fw_config; + int id; + + fw_config = get_fw_config(accel_dev); + if (fw_config) + id = fw_config[obj_num].obj; + else + id = -EINVAL; if (id < 0 || id > num_objs) return NULL; @@ -452,28 +454,13 @@ static const char *uof_get_name_402xx(struct adf_accel_dev *accel_dev, u32 obj_n static u32 uof_get_ae_mask(struct adf_accel_dev *accel_dev, u32 obj_num) { - switch (get_service_enabled(accel_dev)) { - case SVC_CY: - return adf_fw_cy_config[obj_num].ae_mask; - case SVC_DC: - return adf_fw_dc_config[obj_num].ae_mask; - case SVC_DCC: - return adf_fw_dcc_config[obj_num].ae_mask; - case SVC_CY2: - return adf_fw_cy_config[obj_num].ae_mask; - case SVC_SYM: - return adf_fw_sym_config[obj_num].ae_mask; - case SVC_ASYM: - return adf_fw_asym_config[obj_num].ae_mask; - case SVC_ASYM_DC: - case SVC_DC_ASYM: - return adf_fw_asym_dc_config[obj_num].ae_mask; - case SVC_SYM_DC: - case SVC_DC_SYM: - return adf_fw_sym_dc_config[obj_num].ae_mask; - default: + const struct adf_fw_config *fw_config; + + fw_config = get_fw_config(accel_dev); + if (!fw_config) return 0; - } + + return fw_config[obj_num].ae_mask; } static void adf_gen4_set_err_mask(struct adf_dev_err_mask *dev_err_mask) From patchwork Fri Oct 20 13:49:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430767 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 8B275CDB474 for ; Fri, 20 Oct 2023 13:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377405AbjJTNuU (ORCPT ); Fri, 20 Oct 2023 09:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377395AbjJTNuS (ORCPT ); Fri, 20 Oct 2023 09:50:18 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B912ACA for ; Fri, 20 Oct 2023 06:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809816; x=1729345816; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=jq4nS4tvy3im0kjDjxUZ+Nvi845EiJC6fWoucNyDfSs=; b=XeZCuUNRpmQCXqMPINtRw/6118UfXBTi7auFZTZm1AYhhunua55UL5VQ dMv53ZoGGJvDnpv1wNTR5pDtgBKgvVkvQ6vqKAQSZ7+RANreE8ZB5azdu s+NqoprB4FrKRdH1jryiItIQP7uhOJtFTWboBe28BgFSGuxmBIBBuBoQS lHgCLdwwVdpEMue5OjcRa4H712GUX+zdYEiS3BK9OhfhkXHnebTljkk8b 1ij9D/A5DKqzdIIrOs2451AJgtgqM7B5VQWf0sVm2DRFUIHWzu8PtTCJq bD+XLMNBFxm/s8Xtfkjt5Z+N4Xr8NTBdSERFCEWgit7mBmslitdu9/1Sv w==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="385376709" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="385376709" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="931012623" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="931012623" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:16 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:15 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:15 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GLrShgs4JL5+tfih6JIKnuGkhNrkEFA0Cf7cnFOkwTZM17tquAh8gqsC92Zd5ot4r+R3n1U3MsuKcI27Y5b47oTuHK1Q/0r1rj8bDw5y/qn7pNAHkiOsQdwyD6/DDzog9gKLy/7ZHuNswOfgROO33+2Mwq5rVrtrDK8UjUubjisDdpoHXR+BJtClaKW0tbHY4VduD+5X42vpjAGlGAfnfBPStb/d1EOwocTimQFdUWcGcwVOzxNmCABZZnl19QhtVAo2LChuaAqgctZQSxdhCVIDM8yQFoohvLXCeEqpq1rKzz+kQZrGkj4TCZ46TX+5+0R1eXSgnPEANiPtrlgSqg== 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=gRvYgiPo5YIxcu+t5W6Dwor0XqqnLr1KYcv0QplImhg=; b=dYlvgE2SK7Ilm2IqFZrmtfVHEX6KUCuZdBr3DY38CJkk003hFFB9J5TOGAT66wQP4tEcTP1tFWRzyNbtPt5VZ6oYV/iWDdidAwTK9unqDpH1L0/xw31HEDv1B33b0xr3BzudfR8P9sW9BFXiUEaYwBVKOjDCdCRVFyde1PDbVYKSTETPlyjkvUfUH/0mEX3+k7dF1pC6IvAIAos2+AMSfQLIPIr3HvIrMaTdxAqFgpn5TyoRuTkG9rJIPD4tqO/qzFJHg0KuEusRc40IEDdCGiGK7Thw14yad/0SulJdyS1upGwhCnwN4O0S/A8jqqhwwQhBGD+j/skVLM0uHpeNTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by PH7PR11MB8035.namprd11.prod.outlook.com (2603:10b6:510:245::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Fri, 20 Oct 2023 13:50:14 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:14 +0000 From: Damian Muszynski To: CC: , , Giovanni Cabiddu , Damian Muszynski , Tero Kristo Subject: [PATCH v2 02/11] crypto: qat - use masks for AE groups Date: Fri, 20 Oct 2023 15:49:22 +0200 Message-ID: <20231020134931.7530-3-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|PH7PR11MB8035:EE_ X-MS-Office365-Filtering-Correlation-Id: 98375f33-ef05-4839-576b-08dbd1737c45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V8MmUmDpx+lm6fmw9+XvJ8J/+yr63c3RGYjLYqVE5sD2gokB+gakbpEByXRJyLzyVPkBwqN6brOIn17EzKWgUxDNepm+jBBblkb9vq/vZO3mFmKTt41zcDbeNnCOfU4qNJ9wa1se6K0T260cNMH+Q11fKmtF0gq8qnVU6k/CoZrtdVYvhbtxBhh+DF/Cb7CfIskq8o//tPcPP9kKhfDzlibDffgAiYuuIP7hBt8ka9nLho25Y7OnjpqoJ/lGHsHoVX0NXHKpselMo1Kmz43QuPx+I7B8c4fOglzgIhQ6s5mRfP4NPfXWLhhr26MYzUc700mi9paJHvWf1fEoKhWYPQcfYWxCjRkXxK+hrAVvLPvOTZusF/GzXFl29W9V8nEaTd2/IRe2w7GRokKPmGk/s3eVcv9s0CoRFJZV9chyhL7qp3WOwVMK14553IsC8AACsgLuQTxQ1YvmdvfTPVdM65vFP89Ovaxm12u2QZipIryNjWmmOw4Cj4O27LZxvF4freda8+8/3ykddTH7cWfvyyz3pGVdArwH5951n+iEdn0VaGz9GCCz1AHK4MqQO+uV X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(83380400001)(54906003)(38100700002)(6916009)(66476007)(41300700001)(6512007)(36756003)(2616005)(1076003)(86362001)(44832011)(2906002)(4326008)(66946007)(5660300002)(8676002)(8936002)(6666004)(36916002)(316002)(66556008)(6506007)(6486002)(478600001)(26005)(82960400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ppe91UXvyTGyeD3EFSfPIgb8H5mX1Xl/+35e2HkijbRP9ZBtZXcxWU8hzYOskHwskFfjNlCUkzyUbWagiLPpkxHidhf2DaEeAOyyMdkG0btT+bEPy677Lw/kbhhD2mmX/jnYBwyDFpdatn8N8exXALZr6NepFtjppg3AWGVFW0+BcxbrXdzQsobrMZA3OeDaHXOnz/QfpayU874vhZedekrzFc5/jGhfJZELY3PBx3X7twe1at4jxdx+1qSf1pghTgwaTFbxFXiJQAZE/vREpWst2CpMOW6mW/KXgV1bktSgQS6cd3H7f261Utik7dEnAlvquS9U/mWu6Ht8q9excZM35cyOVVsIsAJM1+k3zREyXBvT3pbKeXTFX/sgHc9vYwO8WR5L8Pl74Do+OdYkQwf9H+YRW4zhBTUnzwVKktWTg5MV+DTbTbMAWzM5+rX/xO+KwAA2vr2UJlWLJPf+xPNA8d3vMkxBPzIVohr4ISd/CFImMiQOZstacB1zykdicNSJ+xiTGm8Y1Ugq9fONwDq6GvFWy3bWd9ublXCOw23jqT3GXLrbmM98L5QjkNy6oLSCGlmy0W6ybgve+1eKEbwkx/aS11PvxmXJ5yMD1RHJVp+Ep8fBi1mgJcSsdTpApmTrcHoU/Rwf7sG13cIIpdQSK7t1fP8Gcxzi0UfS1UnF6ML/7UqMX254jQBxt8Jik37+VywNcVEf9rcdaa5fyNlajtr8op70s1IQz/5n5PVpS6BaNg8BqMY9ge1q3W+CXN9unA2NqRiEGq6kYZ1OVjmF/e4dXw2gDQped0kLsoQtvVqjv7lbO/D3ktsLMncZ28VdJwZTVZoJGLWEx5bVJlVwV/SOK93ylVa+cNVWxtEb7p4cg/UBU45x+TON5B5F7bg8BY1rIM7nRmWed3mJo2SVCfjdrWrqe/gZ/DVUsYbjGyJiI1awtB7ULRQbN3fLjR7b/ECtbFMCRoZANT8+sEbhvHseNtI+Dx4JT/4OjRT3m3jdUZX8G6rBQV6Jypkwp4Y7mqGdQG3fKYoLFxCVspiiC3v4Zcehux7/LDQUHD17M8BT+/V+fhJD1bWDydhVWVwijbkFq+HowR+sYlwBnqhYt2chZ/ueQb/CnmSbU6+gdj5lX331chbXRELHiIEfrM1g0zOXiK9rwnkncbqrToauMCPKnZ1yQE0mYnamaeAaXyAOaVrsyMzPOvtW8oZIkK5dZaYx20gQtxG5cD74A4KAbgJxhr4gsRfXTKIatZs2rpYBdcWJJCqmmgKQ959pwM8apkXqRScsQm00mYT3Y4cfysmViXpL9Ftsoa6nEgiuTa0gEyXee2IpFWI8uordgjplszmKSKD0LPCqjH09AyYbG+QElZoAbs6eozDWlZNQi+HKdRj+iHJg29ihLBeRRZKN9uyWa1MTCLPkcmqXilxo7lg1Mqula6soXGCoAo/MRt4S3lHePnJYK7JObKptyMkRIxuvOJVg26IeZexN3bshoJca2Oii3sPLzEPoOmG4idb+bflGfhG+a8sYd5WVUoITBx3N2Hh+IdaWrDAzf0m9wIo1bNHtomdCBs4NS6yE61uNxChHS+hBqocr2TSpP/qMCQchFNG2sbWrHLmEdA== X-MS-Exchange-CrossTenant-Network-Message-Id: 98375f33-ef05-4839-576b-08dbd1737c45 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:14.1831 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NJeKZ82DBbIK+AjIiI70wKx/0ZmCMzwP9ivfClZQV4AF3zV7em6NAnZa2L05l36X+DJ6AVMt15lQk9rLEp/UlZ9tA9nE+gTFC3lSYj3Hykg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB8035 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Giovanni Cabiddu The adf_fw_config structures hardcode a bit mask that represents the acceleration engines (AEs) where a certain firmware image will have to be loaded to. Remove the hardcoded masks and replace them with defines. This does not introduce any functional change. Signed-off-by: Giovanni Cabiddu Reviewed-by: Damian Muszynski Reviewed-by: Tero Kristo --- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c index 3ea4bfc91bfe..1f1e318eeabe 100644 --- a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +++ b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c @@ -15,6 +15,10 @@ #include "adf_cfg_services.h" #include "icp_qat_hw.h" +#define ADF_AE_GROUP_0 GENMASK(3, 0) +#define ADF_AE_GROUP_1 GENMASK(7, 4) +#define ADF_AE_GROUP_2 BIT(8) + enum adf_fw_objs { ADF_FW_SYM_OBJ, ADF_FW_ASYM_OBJ, @@ -42,45 +46,45 @@ struct adf_fw_config { }; static const struct adf_fw_config adf_fw_cy_config[] = { - {0xF0, ADF_FW_SYM_OBJ}, - {0xF, ADF_FW_ASYM_OBJ}, - {0x100, ADF_FW_ADMIN_OBJ}, + {ADF_AE_GROUP_1, ADF_FW_SYM_OBJ}, + {ADF_AE_GROUP_0, ADF_FW_ASYM_OBJ}, + {ADF_AE_GROUP_2, ADF_FW_ADMIN_OBJ}, }; static const struct adf_fw_config adf_fw_dc_config[] = { - {0xF0, ADF_FW_DC_OBJ}, - {0xF, ADF_FW_DC_OBJ}, - {0x100, ADF_FW_ADMIN_OBJ}, + {ADF_AE_GROUP_1, ADF_FW_DC_OBJ}, + {ADF_AE_GROUP_0, ADF_FW_DC_OBJ}, + {ADF_AE_GROUP_2, ADF_FW_ADMIN_OBJ}, }; static const struct adf_fw_config adf_fw_sym_config[] = { - {0xF0, ADF_FW_SYM_OBJ}, - {0xF, ADF_FW_SYM_OBJ}, - {0x100, ADF_FW_ADMIN_OBJ}, + {ADF_AE_GROUP_1, ADF_FW_SYM_OBJ}, + {ADF_AE_GROUP_0, ADF_FW_SYM_OBJ}, + {ADF_AE_GROUP_2, ADF_FW_ADMIN_OBJ}, }; static const struct adf_fw_config adf_fw_asym_config[] = { - {0xF0, ADF_FW_ASYM_OBJ}, - {0xF, ADF_FW_ASYM_OBJ}, - {0x100, ADF_FW_ADMIN_OBJ}, + {ADF_AE_GROUP_1, ADF_FW_ASYM_OBJ}, + {ADF_AE_GROUP_0, ADF_FW_ASYM_OBJ}, + {ADF_AE_GROUP_2, ADF_FW_ADMIN_OBJ}, }; static const struct adf_fw_config adf_fw_asym_dc_config[] = { - {0xF0, ADF_FW_ASYM_OBJ}, - {0xF, ADF_FW_DC_OBJ}, - {0x100, ADF_FW_ADMIN_OBJ}, + {ADF_AE_GROUP_1, ADF_FW_ASYM_OBJ}, + {ADF_AE_GROUP_0, ADF_FW_DC_OBJ}, + {ADF_AE_GROUP_2, ADF_FW_ADMIN_OBJ}, }; static const struct adf_fw_config adf_fw_sym_dc_config[] = { - {0xF0, ADF_FW_SYM_OBJ}, - {0xF, ADF_FW_DC_OBJ}, - {0x100, ADF_FW_ADMIN_OBJ}, + {ADF_AE_GROUP_1, ADF_FW_SYM_OBJ}, + {ADF_AE_GROUP_0, ADF_FW_DC_OBJ}, + {ADF_AE_GROUP_2, ADF_FW_ADMIN_OBJ}, }; static const struct adf_fw_config adf_fw_dcc_config[] = { - {0xF0, ADF_FW_DC_OBJ}, - {0xF, ADF_FW_SYM_OBJ}, - {0x100, ADF_FW_ADMIN_OBJ}, + {ADF_AE_GROUP_1, ADF_FW_DC_OBJ}, + {ADF_AE_GROUP_0, ADF_FW_SYM_OBJ}, + {ADF_AE_GROUP_2, ADF_FW_ADMIN_OBJ}, }; static_assert(ARRAY_SIZE(adf_fw_cy_config) == ARRAY_SIZE(adf_fw_dc_config)); From patchwork Fri Oct 20 13:49:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430768 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 A5A8DC001DF for ; Fri, 20 Oct 2023 13:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377274AbjJTNu0 (ORCPT ); Fri, 20 Oct 2023 09:50:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377304AbjJTNuV (ORCPT ); Fri, 20 Oct 2023 09:50:21 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A8D593 for ; Fri, 20 Oct 2023 06:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809820; x=1729345820; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=aSiqd+TCmSSnpiwKxnBHjE3UQOrnnu4zIT8HmNI9e24=; b=U5LQYMVjfuboY9R2XW1iGWlExtgj53CxM+vOCcMYZZxo6kGm0Qt/WhMx ZxyT+CMTozilpPHs8/PUHiUpzoYeHMdY0KLiEZac1Y63m4Va1mcA0q1o0 m/bWc94HK57qQyWTGpDG/CoidIQC1dA5ZBPDoeXNMeM3cfPCy+mXzWdn2 Kwy7lR/vMCyS4RE8LsGmOwfaLSzmEfVDy5Mt42bfGuW2pd9nnEKherHrZ 3vDhSBSVMbVgBSFMLWww/pNBEx4LsATGCbVdBAPuRS7+RGO+xll73vA8F cpS9IdmZWtUDz9r9kVTt46yCffwFLtil3ll0EQT4xjfWrCCwTJxhM9Z3n g==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="385376734" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="385376734" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="931012664" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="931012664" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:19 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:19 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:19 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ajo9Q7KFxRXzVKs63cjZ8kOh4Nh3HwJzx4yvv8dTszQh9MzKO6iSR0aOzz/VSQ2e227zR9Kf9Sn0ULAVmaT1W40n7ZjmUtMseTo6dbfx1N7Rvs2efzr76sq9hZZmE3R1Fu+hFGIuKWPuu2+upX0Y2cFGaNQRVeYui7BVB6oWWtwJ0V0pF/SPY0LuvGzvb8/zbNOgq9qet1T5vWTimPShOLNqamXrRyoBYivKqY5++EgiweAyryfXsFOlgbLENxNf3WeUROacW+Z1RLaKlsao8IRnVFZI20T70QzwW4jsmyDT40RnZ7h8AMMoaytLse8/JUUOSrMTSWDcqCeJlzHxpA== 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=PcVaaLCrUauKSHt/K12clGOZkcYE4/fCVRqTRSTbuRk=; b=R4/dVYGmRWe45gT5wYMyCqiCvX9oUT/NHy1uEic0xPjYr4ySMjfsYaxj+tavcRzTCyC2FgwrJ0KWlJzlBZ5/sv3lfMlY04ugOf9kZ3dHVEoUB4N6euCDFwrwLIdy6s718LFk11W9/CXXprqQQNVUKIIN3rZHDWy64JL1Ru47ncIrFkh2Wy9J55G17AQVLIX8HzKeapCzBYOBXVLfBxSNhDM3uPSoVgV3OLttW3DX4XNzbx6E+GfWeASS++OnsuC7+OqcFAw72BI2p8Q7WKiyN3XDP8Z6qEay3l47aPuep4fehIZcYSRkf/g540v1HICQxwTEtk4vFlEDCYFZxggfAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by BL3PR11MB6363.namprd11.prod.outlook.com (2603:10b6:208:3b6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 13:50:17 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:16 +0000 From: Damian Muszynski To: CC: , , Giovanni Cabiddu , Damian Muszynski , Tero Kristo Subject: [PATCH v2 03/11] crypto: qat - fix ring to service map for QAT GEN4 Date: Fri, 20 Oct 2023 15:49:23 +0200 Message-ID: <20231020134931.7530-4-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|BL3PR11MB6363:EE_ X-MS-Office365-Filtering-Correlation-Id: 21bb3ad1-4348-4356-da66-08dbd1737df4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q7ynVN26ZnwHJlaVnARzCy4bxl81H5l8xoFx7N8zyiNH1cf/3tTvkq+rg/PDtk1cPJjGLru4lbPPnWTMEsixfhiwdibzW3M5rTg7AI9dla6j0LOJcJBio2MXapXXQM9/LSaQD9IUd4F5uoCMTQbFTDNIHRuTSTuFUfh5nA2sG7EYxFnSgg7ZOnvirYEa2hbSdMsyt6CF0WEEn4i3Zz6dqG3RXp+E24/xS/My5HckIKYnq+U+0eRq6NCgtu8P/6hPv7wsa6X0M7szqx+8ZiwMPwhUNUBU4ZPGe5ftfLX4Ma10CVOul0K0XizgU+Rs5wX60d4R/29Uhj33XanVoEHUmggnj8/75VLZ7wzo3IrwyzXgIthDXsHuue48uYTzC2L4HCDsbhFgaSyd8Rr8XJ01OBoome3Ld+4ZD/YASqqn95hRhOVYmcfefMlVNPcLvL4XZImgfhvA4mev1fspFcDgo18slWlVCKZDBBjeEcPrnWEjqwaSwnN3R4k2qyvZVclgqzUlBmLh2AzwtttcrT+2WkgCtFBlyYPAulF78hynKok= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(66556008)(6666004)(54906003)(66476007)(478600001)(6916009)(83380400001)(6486002)(66946007)(6512007)(38100700002)(1076003)(41300700001)(26005)(36916002)(316002)(2616005)(6506007)(82960400001)(36756003)(86362001)(8676002)(8936002)(44832011)(2906002)(5660300002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MmJvO6IMrx6iknyXKfAmN7ZV3+9h4lPeybPYMdEaw50dN7b30dOv9qo1ZSN8zKeNGRYaaIzerhq7SYOY4HV9dQWL+3352zUqd7wTMP7Ykn2V0I+Wu/O5VHIrXjuuRXN2a+eToDxHmaNkb2bHRNrFycosGI7io4xt+RyeyyGqf2bBiwkA4dCxAjPJ8Odow23YrNZGHrQ7qT8LtYWLx+CJ6epJMycSHkgyf5JnQsH74lrmzK/gd7jIINjYZYJqPJ1ElmVRIsD+madhxqx/Q66y7nZhBH8BmZ/dKQVdOHUfMQV4W93j4BlgiWWoPy1bMbNm5vZuZhQ0k6Ld07vusGypPg3bZqOydlyafWwfgCSrYmAdV4vdgwualgpWVp9oW+3NkhWu2jEZK+ecZjtKQ2cga6ylQ0pTmY6E3CdO9FSKi6GfHHSlACFAMn9shPE2wrehWspvaaWaH68FeMz7JJtzFgHQbKGELNU6XZs10xeQm1bIhQte1Oi3cbjgxmsc/5c9DHOxphcy+d9T2JggQyGVzox874MffyjDb4rr0JHhIX3cTMNPEwDkS41lfuf51DiqS1guxVoY00KUoaH2QCqeqzG8xpspbMuCyeiI712bgH0l2GnP7J+t/FHrjZBfmH2g90Iwmo+SUb9SHFbNnw0/aQ4HaswUfO/nhGJ7Wc29hYRQ54Oy08IDqg23oJecOLEn3XFMYTltEWmWGIqFRIRze/JKXAlSEEBhXAtmDVLSTm3VXHhxwSlJxKMjWMOtrZGjwxm9rr8cqg1sWr7mzKFTjFVoEPbBtSgwPQhPszU/bWvNcSPCaoRTIIC6WonAHb0EJbtCRXs76vVXuEVj2Z2lDO9ii/qtwQlOdDnHW9DbjwLxtMJV03BXFJbrZ7U8OFQ3NzJ682cvZ4Ooxgm6B6SQxfhRT1X1Uu5YAUCpZyMsBzVtsjleFBPmDvFPK/VAgrrEd8OX44hiWbS3jvPA6cZ2IZk5MXmxYIBfNl6yY6bAVU7bKmac6OHjr3nTZ81gxiLRUkRKYe4kJ2LRRVUTCtCpwsjOX+pGEor5SeSTMXk4pZiWH12dL7UkttL+0Nbx+TfSO7bL5u72M8p9edtm3HEXUfCDO+W+7r8k2tl/TTjyk93/14RKiY2Iq3XnRap9pdjH35oEjLFPNEOmhoi82/oSSFD/IKOAxqJ25UMdHI+Fes/QyKJMNJ3i6gQQZQ2ocBT01+1UE5wcCy9GOgcdryS6NAJbP+wHmA+urpvoBc2OS8VPnqk7QFw13KQ04tOOck0zwk6PY6fN/FRvqQe7ZCcFxTfJJWEPOvM5tB47IZXL9n1wPXehNO23dHNHL8GyGIJ0KRU1qjKqaaZgVWY19VkGu8xSPiuR5s5NwYyoXGtY14qVgN1voNtJ61Ah++wKtqYqueT+bm7EJO3o+z+ue2k4p3FXwBWkFkw7QEjZJwBbGM5LaR5cVhnxcNJD2drL+3aPZ0wUEtag+AvtT8fVfjb98SQZ/Yh/onStkuL+DIyrRp/VxFHUrWleHFLvXZ6MNNLNPvqKj9zjzGd+Dz2eKDkv7lx8MHJ+TCKoc3o2ShgAXPI+vCq4FXB7DuTCkoB6QINKeslgbp9gnGwqz6G85fYS2w== X-MS-Exchange-CrossTenant-Network-Message-Id: 21bb3ad1-4348-4356-da66-08dbd1737df4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:16.8860 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /tHydgnq6bApau+j/DMtG6JeqVfLP2nCboo3DiaLsDdzbtDhz0dX30Kg5TGjGK2jfWE5UokINrgACrPFuLyL13Ko43/+tYd03byjitw4uq0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6363 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Giovanni Cabiddu The 4xxx drivers hardcode the ring to service mapping. However, when additional configurations where added to the driver, the mappings were not updated. This implies that an incorrect mapping might be reported through pfvf for certain configurations. Add an algorithm that computes the correct ring to service mapping based on the firmware loaded on the device. Fixes: 0cec19c761e5 ("crypto: qat - add support for compression for 4xxx") Signed-off-by: Giovanni Cabiddu Reviewed-by: Damian Muszynski Reviewed-by: Tero Kristo --- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 54 +++++++++++++++++++ .../intel/qat/qat_common/adf_accel_devices.h | 1 + .../crypto/intel/qat/qat_common/adf_init.c | 3 ++ 3 files changed, 58 insertions(+) diff --git a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c index 1f1e318eeabe..37bb2b3618cd 100644 --- a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +++ b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c @@ -424,6 +424,59 @@ static const struct adf_fw_config *get_fw_config(struct adf_accel_dev *accel_dev } } +enum adf_rp_groups { + RP_GROUP_0 = 0, + RP_GROUP_1, + RP_GROUP_COUNT +}; + +static u16 get_ring_to_svc_map(struct adf_accel_dev *accel_dev) +{ + enum adf_cfg_service_type rps[RP_GROUP_COUNT]; + const struct adf_fw_config *fw_config; + u16 ring_to_svc_map; + int i, j; + + fw_config = get_fw_config(accel_dev); + if (!fw_config) + return 0; + + for (i = 0; i < RP_GROUP_COUNT; i++) { + switch (fw_config[i].ae_mask) { + case ADF_AE_GROUP_0: + j = RP_GROUP_0; + break; + case ADF_AE_GROUP_1: + j = RP_GROUP_1; + break; + default: + return 0; + } + + switch (fw_config[i].obj) { + case ADF_FW_SYM_OBJ: + rps[j] = SYM; + break; + case ADF_FW_ASYM_OBJ: + rps[j] = ASYM; + break; + case ADF_FW_DC_OBJ: + rps[j] = COMP; + break; + default: + rps[j] = 0; + break; + } + } + + ring_to_svc_map = rps[RP_GROUP_0] << ADF_CFG_SERV_RING_PAIR_0_SHIFT | + rps[RP_GROUP_1] << ADF_CFG_SERV_RING_PAIR_1_SHIFT | + rps[RP_GROUP_0] << ADF_CFG_SERV_RING_PAIR_2_SHIFT | + rps[RP_GROUP_1] << ADF_CFG_SERV_RING_PAIR_3_SHIFT; + + return ring_to_svc_map; +} + static const char *uof_get_name(struct adf_accel_dev *accel_dev, u32 obj_num, const char * const fw_objs[], int num_objs) { @@ -530,6 +583,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data, u32 dev_id) hw_data->uof_get_ae_mask = uof_get_ae_mask; hw_data->set_msix_rttable = set_msix_default_rttable; hw_data->set_ssm_wdtimer = adf_gen4_set_ssm_wdtimer; + hw_data->get_ring_to_svc_map = get_ring_to_svc_map; hw_data->disable_iov = adf_disable_sriov; hw_data->ring_pair_reset = adf_gen4_ring_pair_reset; hw_data->enable_pm = adf_gen4_enable_pm; diff --git a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h index 197e10eb5534..1c11d90bd9f3 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +++ b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h @@ -212,6 +212,7 @@ struct adf_hw_device_data { void (*get_arb_info)(struct arb_info *arb_csrs_info); void (*get_admin_info)(struct admin_info *admin_csrs_info); enum dev_sku_info (*get_sku)(struct adf_hw_device_data *self); + u16 (*get_ring_to_svc_map)(struct adf_accel_dev *accel_dev); int (*alloc_irq)(struct adf_accel_dev *accel_dev); void (*free_irq)(struct adf_accel_dev *accel_dev); void (*enable_error_correction)(struct adf_accel_dev *accel_dev); diff --git a/drivers/crypto/intel/qat/qat_common/adf_init.c b/drivers/crypto/intel/qat/qat_common/adf_init.c index 00a32efdfc59..ef51c4d028d2 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_init.c +++ b/drivers/crypto/intel/qat/qat_common/adf_init.c @@ -97,6 +97,9 @@ static int adf_dev_init(struct adf_accel_dev *accel_dev) return -EFAULT; } + if (hw_data->get_ring_to_svc_map) + hw_data->ring_to_svc_map = hw_data->get_ring_to_svc_map(accel_dev); + if (adf_ae_init(accel_dev)) { dev_err(&GET_DEV(accel_dev), "Failed to initialise Acceleration Engine\n"); From patchwork Fri Oct 20 13:49:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430769 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 2E0CDCDB474 for ; Fri, 20 Oct 2023 13:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377395AbjJTNu1 (ORCPT ); Fri, 20 Oct 2023 09:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377304AbjJTNu0 (ORCPT ); Fri, 20 Oct 2023 09:50:26 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 222BF19E for ; Fri, 20 Oct 2023 06:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809824; x=1729345824; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=/QLsk07hupOFnt2EU0uu5DpSjIzm9FJOJmBO6Agsh1Q=; b=irfiiOiHFbsat7b0NFlBD/g0M4wKpVDDUhhecmQ3s2BYJ7JDllcSpkou HdHA/qjwNaZnQdM14KpCPjFBNKI2a+iIHLwUzjrTrpNlDLk7XxzMz5St/ OS8e2DvAGM1AgmM2zF0Lc4+cZA8huNWpZlmWd6nhP+GzWiuVjKPk9BBce 8FEUpBpW7ealcANe5COf2hyCRP1hHo5BmaP6OasmXz7cllnPONqRkSnB6 1a2mqLdKi+aHl/pcd4mpx2bXykCSDS/X3ffDuwfUHKUGPiQ7xaaBTnU4o 2khs9/gDV6utg1Kb9XIrEYvsPIqlUX/6m1MGMA5IG8V6e/59z80+fTILv g==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="450725539" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="450725539" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="761058801" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="761058801" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga007.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:22 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:22 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:22 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:22 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:21 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OCHWYSwo5Cy2ZVwVVTF4XaCJsB+NBUdbMdSFjAg+J3FxPWLMSpo9XZ0rjfQ+NXBcKxZosr6jokssdVDx7/zFIkhm+PhE55OeWBwjjL2VxhNqI04fCDSIejvtFmfw6OKnr2UjWGi/NsEO/7Eg53eag5f6VwUNUcsiG/5j8enFrZjubHcSYCmHOotaq8tqle25SFiP1jb6V07JAPoEXUyQCo0kxw/lN1fsl9hjIZi45qs9oLMflrlyqWYvcU5jo0StiUEDWhAjbrzoeiJZ6lEv59joxuzy5BJZCJemiu0YuXuoZu4X+nYkda7qjJRWn3haqpWJ5O5eNmXOT80re8MU2w== 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=Z6OMrKxBj6rwQmRmOUukfQqPSfIrYOWlsw63n9F9ABI=; b=GsSALBUoz6aDptfOrNA4/6WI/2x7/vnzd6cOG2Jj9oHdgoo3JM5Bw7mYvcW7bBTkaRHHRoinqIKbT+tEq3+mD/bot1WADMSqQuZ+24Guw56JFUHEXaTLR/PsbbMj5BWgtG0frssB7IJ5wPQsQwrEVFkqxQAWta/oVE0buiiJCt2+6hBYRuk1wv+YFxNe5dOGk9wMb7qIHGBjTdMT1QB5OnfS1pdNd3QtynprPuUrMkv3LETJHmtD/Gsq12vC/ywgwTN9RdednvZ+z8MqSapujVZlOU5tqy3FvHpuoAXYx0KaV3Iz50JCy217/z/Zyz9ABWltOnDvDEVHzNs0LvFyQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by BL3PR11MB6363.namprd11.prod.outlook.com (2603:10b6:208:3b6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 13:50:19 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:19 +0000 From: Damian Muszynski To: CC: , , Giovanni Cabiddu , Damian Muszynski , Tero Kristo Subject: [PATCH v2 04/11] crypto: qat - move admin api Date: Fri, 20 Oct 2023 15:49:24 +0200 Message-ID: <20231020134931.7530-5-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|BL3PR11MB6363:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f662c58-a8ff-4d27-73ae-08dbd1737f79 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R/mqfEPKIWFRVkiDtu668u/oI4rPkA5YYXsEVecc9R2llo+ZXkobr1KF5MeB/Jf82X3QJs/BosmbRsXTjy6vAodBVaBbiKmN3yS/un8BPckjgNvocPqW1oisSYNQ9hx8Nr3sM78sVg9abzAVHWs/smUK1Aqnu0384VFBGZbAGqFvUwgyRZre9ZGgpaAKAncieqA95cTORUD/9XHc/nHX5Bpe2WgIGIN3a5VO/ShfTbIC53JMZd7ohLf9RDzLt9Rwu77+XITjIxxkekH+vN+3w6rWjmi7EEGhS4tYrdVRTAKL5lwtXT1j+bGHkk8YwoEpRCiEmu0Kozy5H4/2F2rvtTtoTTkR8JLrDyTn5GNvIYbgaCXfnyInNDz/HAdA7kQoh1TRInbmxwQaohoWYx7BJQFv6aAFjieVJ6sjaO8MQjFsT83Bb6LkgUe1rSxi4KqbansTsTxgpeUDqZN/Ks8jw843A80lsVcfG3aP8hYLfJw0dDuUmuUTdyCK8eu9BzczWj6Y7W9YcGmQHO8L1CGetJEKBkcaGzt7g2iAEgUZmRdYOmh9zJYfJDWzGq90I6r3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(66556008)(6666004)(54906003)(66476007)(478600001)(6916009)(83380400001)(6486002)(66946007)(6512007)(38100700002)(1076003)(41300700001)(26005)(36916002)(316002)(2616005)(6506007)(82960400001)(30864003)(36756003)(86362001)(8676002)(8936002)(44832011)(2906002)(5660300002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SuhfdH7jbJPajAkaxBKCsiTIyGQPIkqK2Gax5P4zrhRrvFXAAKScW8FcXjuLwtjbhquM7nOuW0r5R895d7/+IhZ9z7oyZ+KxzQ6NgoV2mMXGdMo2UK/yVWcjLHS3YkqyFw+WMlQZuszGizQUf50qq8snGA7UaWnIeV9kocB0utm5W4T65vGB93Y6iGE7KUmP9JJgvMnKaG5mYzVgxuh9qJZ3IeGajL+kc1EJOx6Fy2ombtRs2XK2SQlweU36POdlndVLIfmIq4SnCrpkIrkBnZab99u719kaMsFxhqxVWJW2N6mhBPzse9vCCT5TBmmnTL6T1k/yUc6B0TzPwHaOixkJ7PBzlc8EvLdyM/yp1F5byIU5HQwA/3/5atJsL/R6TlT0gS3bBV2PdEgSXFoqFjBzZCgsm9YBKB4vxAwWCYpnw8RP9fTvJ4xP1yr4djFkiMz8/t/UbeqhGswYE/5rheEg05V32/UCAFUlj/fzTUP5xrmuktrnFEcCPnXrcCC6law7YhNxaCXlJ45Mq0/sWAdJrTzwxq5cyONaQ4Am+HALo7z9nhGWnyO2QTiv99ctIBrxYcP5MJzEgXzPt2TKU3Oln8ejuV0qQKWBl+Qr4qkiBX1hnWNvxi/Z82HbTex0a+kvCtHnSsC4DeATe8OwRgsslUZ39mLJUGPp69S8535/R6N3OUjo4d/rHBNE3uSX3r4hVDZwQxtuaHtyAu89tADEkr94DHf/IDZDExurotZYMMzVTWn9h7EMrVYXx/BD82gqeuJMGAi/pLpVcwi9IfHdFirlC83cl3h+xk3wGESjEXHDAhz1CLmhuzsiuYPmq73XHG/8XYooWewbrNvOlKnR4c6s0J+LjPVVXxNIyt6VMEnOJphMrF9/+MC9G468Ixi8JE7C9S4xb7Wmu8zICTjkG9icXtvzaT817Pjp1o6mqRbZa5KllQYPkqQnvzISkJb1+zAr4ndxOUB8EYlhCWhCkkxKHjto7h47OvudtjRaREF5WLOYxzNWtlLrtjL0ZmMQ7y9ip3QwAM2R8UPIpnm3D8Is/K+yzUpQoJDZ9X11AMypWTo205d6+BinEdiZk/lWtibD0k1HJWilGzfhgMbjxFw5XGgNsc1MBaz1cmozSq0lwmiH9D+9bLS2UdYLw/DNaI8Ewi3lynU03ayLIZ5StBPxZmzTm8GSC/o8Vqj1L49pxB9lZFHyHZa1XKCkJodGfQ5VNzsowuu9AFqwm1Y3djUhI1d6VY7R/c1jA5aJZ7YmQDYjC6Rfgdlov7LWlw0aWfEcTCXkN0MSUhqKzyLXzdXNSHdp0yu2sLs/xB3KAsltIZOVnd2zJUcBhMtxOHq+UeIxJqkoGYAuHmeldMrE4BDGfbLEfKsnfKWU9C2JpAFpopctp56XydXuCVbjshs4x1d8RlGD+H/wHvcP3OveqenesE9vvcLspkoepdJvmCdeIucXtvqH4QzxNTj3LdIiCMFlx8E7PVhDbDT1U2yhP6Hf25DJjbYZObWJ8M3A0+Z5IOqnFNmWngDx+R/hQp34WvnNN9RabvRS5ol3LDyXRWoR++n7naUiNGMn6/9NTBPt+jqp2IVPHl/jQkpoeuNZmA23mX7CZDafzVbITw== X-MS-Exchange-CrossTenant-Network-Message-Id: 2f662c58-a8ff-4d27-73ae-08dbd1737f79 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:19.4718 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: f4gAMzpJ0wG0bH11XufSN/cywj7lgRZTCgR6bOfn8B3TBvZSePkeLN4fnQrqqq8cmaSHceZGDCCP38BOOUzgygvDgqb3pnemJXMFe408NcE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6363 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Giovanni Cabiddu The admin API is growing and deserves its own include. Move it from adf_common_drv.h to adf_admin.h. Signed-off-by: Giovanni Cabiddu Reviewed-by: Damian Muszynski Reviewed-by: Tero Kristo --- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 1 + .../intel/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 1 + .../intel/qat/qat_c62x/adf_c62x_hw_data.c | 1 + .../crypto/intel/qat/qat_common/adf_admin.c | 1 + .../crypto/intel/qat/qat_common/adf_admin.h | 19 +++++++++++++++++++ .../crypto/intel/qat/qat_common/adf_clock.c | 1 + .../intel/qat/qat_common/adf_cnv_dbgfs.c | 1 + .../intel/qat/qat_common/adf_common_drv.h | 10 ---------- .../intel/qat/qat_common/adf_fw_counters.c | 1 + .../crypto/intel/qat/qat_common/adf_gen4_pm.c | 1 + .../qat/qat_common/adf_gen4_pm_debugfs.c | 1 + .../intel/qat/qat_common/adf_gen4_timer.c | 1 + .../intel/qat/qat_common/adf_heartbeat.c | 1 + .../qat/qat_common/adf_heartbeat_dbgfs.c | 1 + .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 1 + 15 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 drivers/crypto/intel/qat/qat_common/adf_admin.h diff --git a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c index 37bb2b3618cd..ea47a05e12ed 100644 --- a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +++ b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c @@ -2,6 +2,7 @@ /* Copyright(c) 2020 - 2021 Intel Corporation */ #include #include +#include #include #include #include diff --git a/drivers/crypto/intel/qat/qat_c3xxx/adf_c3xxx_hw_data.c b/drivers/crypto/intel/qat/qat_c3xxx/adf_c3xxx_hw_data.c index 9c00c441b602..a882e0ea2279 100644 --- a/drivers/crypto/intel/qat/qat_c3xxx/adf_c3xxx_hw_data.c +++ b/drivers/crypto/intel/qat/qat_c3xxx/adf_c3xxx_hw_data.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2014 - 2021 Intel Corporation */ #include +#include #include #include #include diff --git a/drivers/crypto/intel/qat/qat_c62x/adf_c62x_hw_data.c b/drivers/crypto/intel/qat/qat_c62x/adf_c62x_hw_data.c index 355a781693eb..48cf3eb7c734 100644 --- a/drivers/crypto/intel/qat/qat_c62x/adf_c62x_hw_data.c +++ b/drivers/crypto/intel/qat/qat_c62x/adf_c62x_hw_data.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2014 - 2021 Intel Corporation */ #include +#include #include #include #include diff --git a/drivers/crypto/intel/qat/qat_common/adf_admin.c b/drivers/crypto/intel/qat/qat_common/adf_admin.c index 3a04e743497f..15ffda582334 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_admin.c +++ b/drivers/crypto/intel/qat/qat_common/adf_admin.c @@ -7,6 +7,7 @@ #include #include #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_cfg.h" #include "adf_heartbeat.h" diff --git a/drivers/crypto/intel/qat/qat_common/adf_admin.h b/drivers/crypto/intel/qat/qat_common/adf_admin.h new file mode 100644 index 000000000000..03507ec3a51d --- /dev/null +++ b/drivers/crypto/intel/qat/qat_common/adf_admin.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2023 Intel Corporation */ +#ifndef ADF_ADMIN +#define ADF_ADMIN + +struct adf_accel_dev; + +int adf_init_admin_comms(struct adf_accel_dev *accel_dev); +void adf_exit_admin_comms(struct adf_accel_dev *accel_dev); +int adf_send_admin_init(struct adf_accel_dev *accel_dev); +int adf_get_ae_fw_counters(struct adf_accel_dev *accel_dev, u16 ae, u64 *reqs, u64 *resps); +int adf_init_admin_pm(struct adf_accel_dev *accel_dev, u32 idle_delay); +int adf_send_admin_tim_sync(struct adf_accel_dev *accel_dev, u32 cnt); +int adf_send_admin_hb_timer(struct adf_accel_dev *accel_dev, uint32_t ticks); +int adf_get_fw_timestamp(struct adf_accel_dev *accel_dev, u64 *timestamp); +int adf_get_pm_info(struct adf_accel_dev *accel_dev, dma_addr_t p_state_addr, size_t buff_size); +int adf_get_cnv_stats(struct adf_accel_dev *accel_dev, u16 ae, u16 *err_cnt, u16 *latest_err); + +#endif diff --git a/drivers/crypto/intel/qat/qat_common/adf_clock.c b/drivers/crypto/intel/qat/qat_common/adf_clock.c index dc0778691eb0..01e0a389e462 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_clock.c +++ b/drivers/crypto/intel/qat/qat_common/adf_clock.c @@ -10,6 +10,7 @@ #include #include #include +#include "adf_admin.h" #include "adf_accel_devices.h" #include "adf_clock.h" #include "adf_common_drv.h" diff --git a/drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c b/drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c index aa5b6ff1dfb4..07119c487da0 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c +++ b/drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c @@ -6,6 +6,7 @@ #include #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_cnv_dbgfs.h" #include "qat_compression.h" diff --git a/drivers/crypto/intel/qat/qat_common/adf_common_drv.h b/drivers/crypto/intel/qat/qat_common/adf_common_drv.h index d9342634f9c1..f06188033a93 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_common_drv.h +++ b/drivers/crypto/intel/qat/qat_common/adf_common_drv.h @@ -87,16 +87,6 @@ void adf_reset_flr(struct adf_accel_dev *accel_dev); void adf_dev_restore(struct adf_accel_dev *accel_dev); int adf_init_aer(void); void adf_exit_aer(void); -int adf_init_admin_comms(struct adf_accel_dev *accel_dev); -void adf_exit_admin_comms(struct adf_accel_dev *accel_dev); -int adf_send_admin_init(struct adf_accel_dev *accel_dev); -int adf_get_ae_fw_counters(struct adf_accel_dev *accel_dev, u16 ae, u64 *reqs, u64 *resps); -int adf_init_admin_pm(struct adf_accel_dev *accel_dev, u32 idle_delay); -int adf_send_admin_tim_sync(struct adf_accel_dev *accel_dev, u32 cnt); -int adf_send_admin_hb_timer(struct adf_accel_dev *accel_dev, uint32_t ticks); -int adf_get_fw_timestamp(struct adf_accel_dev *accel_dev, u64 *timestamp); -int adf_get_pm_info(struct adf_accel_dev *accel_dev, dma_addr_t p_state_addr, size_t buff_size); -int adf_get_cnv_stats(struct adf_accel_dev *accel_dev, u16 ae, u16 *err_cnt, u16 *latest_err); int adf_init_arb(struct adf_accel_dev *accel_dev); void adf_exit_arb(struct adf_accel_dev *accel_dev); void adf_update_ring_arb(struct adf_etr_ring_data *ring); diff --git a/drivers/crypto/intel/qat/qat_common/adf_fw_counters.c b/drivers/crypto/intel/qat/qat_common/adf_fw_counters.c index 6abe4736eab8..98fb7ccfed9f 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_fw_counters.c +++ b/drivers/crypto/intel/qat/qat_common/adf_fw_counters.c @@ -9,6 +9,7 @@ #include #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_fw_counters.h" diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_pm.c b/drivers/crypto/intel/qat/qat_common/adf_gen4_pm.c index c663d3a20c5b..5dafd9a270db 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_gen4_pm.c +++ b/drivers/crypto/intel/qat/qat_common/adf_gen4_pm.c @@ -5,6 +5,7 @@ #include #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_gen4_pm.h" #include "adf_cfg_strings.h" diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c b/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c index 5114759287c6..ee0b5079de3e 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c +++ b/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c @@ -6,6 +6,7 @@ #include #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_common_drv.h" #include "adf_gen4_pm.h" #include "icp_qat_fw_init_admin.h" diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_timer.c b/drivers/crypto/intel/qat/qat_common/adf_gen4_timer.c index 646c57922fcd..35ccb91d6ec1 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_gen4_timer.c +++ b/drivers/crypto/intel/qat/qat_common/adf_gen4_timer.c @@ -9,6 +9,7 @@ #include #include +#include "adf_admin.h" #include "adf_accel_devices.h" #include "adf_common_drv.h" #include "adf_gen4_timer.h" diff --git a/drivers/crypto/intel/qat/qat_common/adf_heartbeat.c b/drivers/crypto/intel/qat/qat_common/adf_heartbeat.c index beef9a5f6c75..13f48d2f6da8 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_heartbeat.c +++ b/drivers/crypto/intel/qat/qat_common/adf_heartbeat.c @@ -12,6 +12,7 @@ #include #include #include "adf_accel_devices.h" +#include "adf_admin.h" #include "adf_cfg.h" #include "adf_cfg_strings.h" #include "adf_clock.h" diff --git a/drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c b/drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c index 803cbfd838f0..2661af6a2ef6 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c +++ b/drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c @@ -8,6 +8,7 @@ #include #include #include +#include "adf_admin.h" #include "adf_cfg.h" #include "adf_common_drv.h" #include "adf_heartbeat.h" diff --git a/drivers/crypto/intel/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c b/drivers/crypto/intel/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c index 09551f949126..af14090cc4be 100644 --- a/drivers/crypto/intel/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +++ b/drivers/crypto/intel/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) /* Copyright(c) 2014 - 2021 Intel Corporation */ #include +#include #include #include #include From patchwork Fri Oct 20 13:49:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430770 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 88481CDB474 for ; Fri, 20 Oct 2023 13:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377304AbjJTNuf (ORCPT ); Fri, 20 Oct 2023 09:50:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377424AbjJTNuc (ORCPT ); Fri, 20 Oct 2023 09:50:32 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A997FA3 for ; Fri, 20 Oct 2023 06:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809830; x=1729345830; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ny+J88a9fUWxk02zbew/tNCGAtRBiuUXV4EPwl4yxYM=; b=iPg+8dvEuAAQu1Fd84Wu6sYDVXiYXdX/wdqvbLT43z93fE6AEAWqS/uV ecvJMIT5wN1qmm9f9untCxbKbbgpPmxCkgjdtJkzxus3s9GE2eoZymMoB 2A0Q3KCBc3q4S5VHhbOKq+GaWB/GvdhkiRy4xncbH+3IjlE3Tqc88f4/c n8NhrUmfcSudkov2CVSE6rHvzlkDW+5brMMZdzJdEtRdnIgd2B42cghf1 eGru0oLMO+pk/nj+05rA0ENu24kAn7penfrY4H3g6KirrsK/UCnxfydJ2 nViDO+au9jv5JI7qgqkOnHQRrO8Sqj9rp/VscJEhzku35ugib2yNWFCV/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="450725565" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="450725565" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="848086559" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="848086559" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by FMSMGA003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:30 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:29 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:29 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e4PdANTSR9LDbYIuedrOaKf4IVBuvRNVfkIB+oXN96VMnIe5p8sPfv50kL3dAG6VAWIQMOZLEfuhbeCfg2DSMhb9ShVm00A43BY9/WM0jyWwpU7b1jQpApd+TqIlUbYOsVUNipzxaK+jjVtWESaXHCZsbSZQwyG+kT0SKmm9e91Z2FsRqty8gm70sqvJFPzMaIoFajUWtQq8ICrlfxQkcf4YUDNOUPb8q1mxZUBY74tIuWDc0wT2vnaKpen+6FOJVLfJqyjZqKp+Eegxd8QStLxiHTH21+d/7onqB+0mv59hCXLjDtPpyyZ/Pzh/1Ij48B7HMY2Nq7Muol1xUmjRRg== 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=K0xf/lALibDNelJevs5VpWI9lc8jYgawj4q/yrrI2Ww=; b=FMHQbev6HKJUm6MnlhIGaiXut7M0GO9pZhTvBRWd66wZlOC760YjcE2mQuqjj9Az8Q7oHTHWte0MbgWe9gy9YDz42VcTU6KB/qXXGB8SRj8C2c0vSAObFN/IRhILAxRWeEEwSTGzLqmdI2Q9GF/Nu+ipjWJrKssKMEjj2rll4uDGByS0Eg4G7AozCW9ICX463shjLuKCvRej2sNbjw1PQWC46BU2MyxhA7y7JqbnUcCU+P2lzGNvPwpfmsRtKazcNnRGQLUH2B/VrlJyS4ORfPQRKj7D8lOg4rA5wmj7nxPVHeItK7vHEL4XI2YiyH61cH/e/ostVqVUlRAVLEcQuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by BL3PR11MB6363.namprd11.prod.outlook.com (2603:10b6:208:3b6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 13:50:22 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:22 +0000 From: Damian Muszynski To: CC: , , Damian Muszynski , Giovanni Cabiddu , Tero Kristo Subject: [PATCH v2 05/11] units: Add BYTES_PER_*BIT Date: Fri, 20 Oct 2023 15:49:25 +0200 Message-ID: <20231020134931.7530-6-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|BL3PR11MB6363:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f79931b-c98c-4065-6f49-08dbd1738100 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kLL2Pz1OxcLjXxC2R3FSLuHLhSVxWHz4jgKAi7BreaHcMN4d1fxY7NF3mNI2+qMwBD1DvbdzqEDwzfI6IHI8Z9FLe+vAju+8OBEtpMO4a4qeMO6WHVpLUsqxfm58K18Fqvada/9Fn8kFxW3Xn54U6PFKZ1tmjHULnY8eAo5UTPhe2WlvENLJsV7vKvSu1D8sXLk353jPtH8BDgyrhoM7Jy1usR8oNKUfrFcDkzrXuCxFAASk5YARC0TZPph75N4cmqRi/wia2CRzZN5pcMghGnY1iDK0rK5swHdRx/Lr+YHHZPsSebn9D7o2/Z9CNfZB2J6EjyJo+/+hjh3nOifwTJvSyntOKiYbeyoJpzaoevMyYZ4bCvm04YAyDGs//vtZ13EeNbeCt2RLTfeYCHRk1QA7rz9qAnlbeQHgE6Z05nSKeypOSJqtCabbK61ObicBfUf10EKaYFYo1aueKcmpJStAKSsvUY+gE1rehjxN8KmYmH+AiUswyRmOIM9zCOGCkQBrK7uRhWIf1P5+qoX7+2xiELAOven7UP0dUieTxy2r3LaBZn+rIrBygcqo6jyI X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(66556008)(54906003)(66476007)(478600001)(6916009)(83380400001)(6486002)(66946007)(6512007)(38100700002)(1076003)(41300700001)(26005)(36916002)(316002)(2616005)(4744005)(6506007)(82960400001)(36756003)(86362001)(8676002)(8936002)(44832011)(2906002)(5660300002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fbremNSQUpqT/BQFQCa+2/ls7qcl04ENAk2Mr4eyafEv/b1IkrnJdE9d7uyQB+gXymtYfJVoLLJJ/ooY7VxWDlj4fyD5KmlWTWRlov9hMa7eK5/DQq4vaA6AGebtMuGa/9icajjoX9q5ZXZzHejaixJih68znChxBPMjIfGpIle/nUMYFfoGWZuQj+Pyb8/SMBhoY7T3kie9KpAldUNCvJIruc8QoPTaeuBHk6za3klKhM+D/2vscIl/kNdQ/Rqblqx/WHzLKioyeCquf8TOIniJP+5vtt9rzA9LFRsmeha4JFQHbRw2uPPmVbclf1lXHsqougvrMSWC+Xq0c4GsJZOHqoNUcA8L7sN5KX7YzgtRwmK7nAIK6vkCjsHiTK5GviUePSY2cprh73Yw4cRYohNrEHAugyZLybadyi/wsLSsneatGA2DTCHtgaaBfQ9K1qXB5WzUxhPmB7JSAPCp7IwosSdaAUyDUbNz4yf1v8GoMj7fiZEnZzOHnmyTsMPM82NEloUbNC6XejwI/Z+RJHJ+XUjjfQWmRmAEXJ1LAAycqJDiZPhRY+u/IQHCwbptvJH7Q6vjCKs5EP8zcqaBbwprQZptt3QsjRaS4ywDoxG+d/zOl5WS5h9dt12rkZjT727uh3kKeIRIL3jmFIaq6LoKwIxi9y2Fccy/wkkD+Gn98eaaQTiM8RMtRCwnhOo3h018hYylfq6HuofGMrvyxcHAiDxuRi4tAx+xCmIxGo5WYlmZpnJe3XDQu0DiIfXfnbYp51F7QyL/lJSx9SzyQx6ItRLo1Bmo65R9U+oX/To+IJBW8ZJJPcnccFX9Qig9neX3DHul1SMPx5cXiYucSjONEyviQ8IpG54Ny5UlZoenXhBzoequq7EVqLadYVH1e2+Qg4Th1ks9zLy6LHYYeVh2V/1BGPa4VghwCh2d0cDbwMyvbtMm+J6/eGC4wokM8rzytIOKesvnSuDqTJyskCR0SmfzXlXfin1VptVScCCribU1DVRhpYaKrvwHDRVuSow20z+kpQBKNylVo9Av4mhOtBj6hIhoXugTqeXtAiQmmXS+WcgHvVm4GlmhOGZWR8e+B+Il08xs/LMWmIzlZUlnBzhZ1vwoTQMYZgrd9wmFLMscGKh4a1bowrKnN03ty2vsqaGn8V8XoK8fTiDY1su2zjnONKSPXEHicKyV+bgmzB8XkieX2HG9Uj1zTvW5h995fZx8HdMwMeSWI9UveRgRM0ZVYER1EIJeZt0W7w6ZESZi9RvFjtGk2XXpBSByxXWxXWsgmdc9kaehReemPPgqUIgOziQkN5o0bp3MBfRkKhadMDtnzQiSerp5IR+Q9jr8YGN2L6xOXp/rRcHNr5wAz9SMunfJN3ScceY94ce9K6KQWk82xPO+5yUvqi55/FzpCnjNsKXdWeF5F8r7c44UL7/NGg79cyw+rUYPsn+3WuqbrmjJhCWYJwetu8pxgGntDJpa4yyp3RkaO+vezkksuPh2CzWBJFkjh+hu8jsgjQBY+0fb09QKFObFsV0AeX0Yap17hS8Xldlc7e6pRxkMOCsk0EY7I/EMFNluvMGCoGbgxg01U8I92wsqqVtCEtgdVb1jiPbcTrTAvpurOg== X-MS-Exchange-CrossTenant-Network-Message-Id: 0f79931b-c98c-4065-6f49-08dbd1738100 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:22.1579 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qotizgfSI8gEGBhCyP5zgrDRRUkHJtGcvHsWuxWuEn9jJALTTA0agHJho5xOjPdkx6P9w5f1E8n/DOm1qkJhIs/96+g5vWORB39jzCB3bsk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6363 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org There is going to be a new user of the BYTES_PER_[K/M/G]BIT definition besides possibly existing ones. Add them to the header. Signed-off-by: Damian Muszynski Reviewed-by: Giovanni Cabiddu Reviewed-by: Tero Kristo --- include/linux/units.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/units.h b/include/linux/units.h index 2793a41e73a2..ff1bd6b5f5b3 100644 --- a/include/linux/units.h +++ b/include/linux/units.h @@ -31,6 +31,10 @@ #define MICROWATT_PER_MILLIWATT 1000UL #define MICROWATT_PER_WATT 1000000UL +#define BYTES_PER_KBIT (KILO / BITS_PER_BYTE) +#define BYTES_PER_MBIT (MEGA / BITS_PER_BYTE) +#define BYTES_PER_GBIT (GIGA / BITS_PER_BYTE) + #define ABSOLUTE_ZERO_MILLICELSIUS -273150 static inline long milli_kelvin_to_millicelsius(long t) From patchwork Fri Oct 20 13:49:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430771 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 1C5E2C001DF for ; Fri, 20 Oct 2023 13:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377419AbjJTNuh (ORCPT ); Fri, 20 Oct 2023 09:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377424AbjJTNuf (ORCPT ); Fri, 20 Oct 2023 09:50:35 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A4BC93 for ; Fri, 20 Oct 2023 06:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809833; x=1729345833; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=yQGB3xXizo3RDe5guSPSRF78I5xvLp75E32p5aPc5so=; b=LA9mg6V1YAeNzMXW4FrAwXlTk5wNNzllAfNPaOplwEPypR9PW3TlluFa udkJ6vSPsBXEpUuHg5bvhgZuNd9QXj33eCgi9AH+xtCeIDzkHBeDNrufK wwkkZw8YV/0OnJgSfiEBFJobXPBWkjsZrJ8kkQ/kHzSSzWBv8X0VqheY2 WlOIaMJVEZfyqCK0Y+pa836MdQocLUzLVsIuWnGNuz20JNgcQq47KWM9z 7Y85OkyHRJ/0qEtdOBetSmQKsVSstVHJkGQrzY6Fyfjl/VjmvSsSRvoYT G/lup/Rum73ud55crVtqNeBIhK8BRRSxYo9xVkBABmDpqYblfRnnZGgQ6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="365836083" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="365836083" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="1088748566" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="1088748566" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga005.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:32 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:32 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:32 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:32 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SK3uFWLPJGooCCgYJm8ktoW2tcT4+yegr6mYPz3UmgYnkJj2MeeM1pjbVCbaGMm9yzjdLs2EeOvGtf2Y95jD+JQ2CvdZuUHnAv4zdIZV6ZRqJFsch3xhl8Xd/UjKXmyvXXtJWRbPhwgocoeYGcvbxyJli+5AY8bvJtz+u0zT56ok4xRrUv4M4iwUhunCcCE5rypVMSfklrcvdQwgeT2hhqsIpCnI3ov6mmv8Sj7k1cpugp/HhXHrQ90F/V8bs40pmFhW4tI1El7dQiEbTypW4jIJS0kHrGcDDD8STo0ceyooP3b/wswS/U11J2fhiZ0pY1LdtPVcg4V2fu/l/BRW/g== 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=vkEzy/W5Y+OGdt3wgK5v7awsR+Y96F8IR0BiVrOxRSs=; b=JXL2GlQpLBoQ6Ln73xLV8dUz2sRQqbhHs3oEZd69IL99g7pwDGZP5MipJ+ePRMnrYUPWc9BnrqjG0SHVxaoGkKSDxmZCTaS308wHK3qNVHdsiei61DPTni1U6MlANuE8Xen9GoIuky9q+jjxxopdmk9ee701TzIO2mmr7O3eMuCWJTmx7tEAZIR5oDfT1Lx5CpebHO7ntwkenmqcEwF/76bzy9GcbKeJ5vlUjhnKemOlFFaW96uLz3yJZbynpGLQ3tpG7Gd57f+5QPmy92BV4reU6rvEW4K3v52x+KzvXPBz6Kur+W335CYkXR9vuT746GNOrRpr9+ohwgwmkSQnOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by BL3PR11MB6363.namprd11.prod.outlook.com (2603:10b6:208:3b6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 13:50:25 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:24 +0000 From: Damian Muszynski To: CC: , , Damian Muszynski , Giovanni Cabiddu , Tero Kristo Subject: [PATCH v2 06/11] crypto: qat - add bits.h to icp_qat_hw.h Date: Fri, 20 Oct 2023 15:49:26 +0200 Message-ID: <20231020134931.7530-7-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|BL3PR11MB6363:EE_ X-MS-Office365-Filtering-Correlation-Id: 18622f72-e15a-4d69-cd20-08dbd1738289 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FPbXtm1o53myRsItlfM51OC0YUWUU1s5OU1mnxYYA9csdA27ZezIUE9LOXn3R1izoPFpGOdcTfSDTU7ShcnJ+TVlH5naeI3f6CA/Gz5epE/JDOcOPKyeXoAq7taurceXKR+zFamIh8kr0vXe2ONrcOvbw3EYd6JS+JoyMlDsyBPhQakaslkcXkNBtowFEJhpFeEZCZfMobddTx0lx585mtUAumdktMu0mVpgaFJLkBy8d98n07JTmozEbDnX9XFTj9BWp72zWBJpg4AyJx64jsnZi9CkRVq9n5fWOGDrXJC2itihZjHRVgZaz4cXZXGvSH152Me4Q+tm88c1a6D3+ugWWprW5JM5+Qpjq2qGCAcaZvyG+hdpNINuPNYZwtiN+NN9JYd1JOn4pOfCO0MZ8DMoY1ljzY7NXPwRZ5DVS7jMhmb6AypAJdlZ1DEXwKc0WvRZpQCMYOLePl2aWBmaQVZxYdhnOGT0RCYx0Ma1kcxsP/SBz1MfV0ftZputH1yMXU/dp+gfddey58wudor4PWyejt8JtS7MEquy3ap0sWzE0vc11XIjIwy+L72Tv3gI X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(66556008)(54906003)(66476007)(478600001)(6916009)(6486002)(66946007)(6512007)(38100700002)(1076003)(41300700001)(26005)(36916002)(316002)(2616005)(4744005)(6506007)(82960400001)(36756003)(86362001)(8676002)(8936002)(44832011)(2906002)(5660300002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: T32WYv4zzPYhFCu+TrpxVVmsh3v+zZjiJ+J6epK0azBglyRTP5zi418G1VPT2MRu5le2vFu/20OWRF2E2XhQ25xSzmw6E6YhnVveUdf7n2uD5NjRJN8NaY6zb1cH6/YE6+SLHSe9531a1dG9YslqltPoEUgPT975BRRb5Z6u/ZWZpVHBm4g2F0U5aqOtG8HtfiawZmZJSF4auFjCugP+aVYCArMIb0e0Oo84KKf9MZOYIVRhQ40QVEEbObTU833Xuz0EB1iSHuowRkY3g3f+jW2WFSEeFX5351tZ6KHPa0NAAPpJLNlxp0oW2/swq8dpFMkdTXGws+hLZfSI0SDYNaF8NE2kQVKIimkH1NAyBhO6sPTmQsNYI7ykdOgvXWQ1kwHAl8NjbQVpFhDt1LvrzKIkc0kBqbQstXeICz3+bE7PU+V6aMNkkB/hXmXKCOx+89WycLkuUPkW97BoOOcVjhXqvUeOJRIaFZvizTiSdH6/qeusGcMBlhkU+1tvRBehteSdgr5N62h7l6Bu16CIW2s15ah6Xzb/vxHnESABIkUuU7yXXLBImXZI0FBilEePERxNmiHIHCMlLa4G9ZfhN6Er0qqZ9TX+CAOK2LE5Zf7YBuAQQ/nPhHCjA/6kOQcMtqB8G2o0AFxsTHGY5XO06tsjGHDoYk7TwoJZHQod/E2KNdF1iv/3SZnjX3nS6z8jyBwtNEVVd1FSvm5mW+oXHkhk/K06d0WFQGKEwtHifEshJL/h15Lo9OBwcHz0oZQ0Mksoa4ORYwZ85kw3GpMiY6i5DWxGl3GEJKhEvm+PPoXkKGP7AWAkgorMMQkNTkPzlvyr5hqd9lg8T8JPl46b3IckI53L1rlxhn7JUX3ITU9ewOD7LZP+jXGYAamvsvo7o73qzdYIpCAAlKF3NVJDGKmXla9ECxDuO8EI8YG5VHgDSWOVMYVEJ6U4YrcNYKjjunpummxgm7BOrXR2IztxUbD2ecBRD2otkBzf9sXmtNip2b+4nZpi5Q4geOJlRZwnhoP/uHn+S3kyVZj0U7IXDz4lhZ7QuPwdvRQ9lMa5UIlS2NVJsIXum5Im2YuxkdnFaFegwXBQOA0CY4w8uhEi8HZ4oyVxoxuY8Wu9aUVtHI9sr0oP2RNk72xr/Ry5FZVFhsrl6MEyjkGEpG4+pUwpYi76FYYKEXlJHmez6lF5epzfhrs++/1CyjYHZlWL+xiYS3djov5TkdqbToJL1ATq4aos6eph/U+jTYtvFlAxY4PicNqBf1b12VR1De1fSGukHni6nt7B7737LFMuUHvU5ZhcEOy4joZWve3WCkfXS2zn6JPGiJg9sm1OnEdWR5hqazPQEQofVuFuaxTjbiNAYUp+uW3KXlqA9X/xB3ng8VSrVZqyQUB1EWDouIR1i6zXyb6HhD/39hjnHx5cyzhj8H797I6ciK+3EV/IqhMMNbkGT3EzWKR+hR+pEtHZNx87+pAAZ7ErflA4us6SgO4TqUEVNyT6RPQKrBzQI7EnvHNm5nZD7E1kIvwZEpo9kC6ccNt/leUwZ5NNXoO2GWvsT25TM+PvL3u1j4/+4xqDAS70BCCaOv1bsVqol3x1BeXU23GA+Qxf1jlmLlcCs8Eo2Q== X-MS-Exchange-CrossTenant-Network-Message-Id: 18622f72-e15a-4d69-cd20-08dbd1738289 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:24.7568 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tsIisgAZ8X8RSG/sQub31U7vWo/rY1xTsYFReGjj07mcsAlrUSIfTsN3Poy2opTgYmhCOKKxHDDi67ejvEF6LVe9MZArLLfGlOLi6DpE7BU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6363 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Some enums use the macro BIT. Include bits.h as it is missing. Signed-off-by: Damian Muszynski Reviewed-by: Giovanni Cabiddu Reviewed-by: Tero Kristo --- drivers/crypto/intel/qat/qat_common/icp_qat_hw.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/crypto/intel/qat/qat_common/icp_qat_hw.h b/drivers/crypto/intel/qat/qat_common/icp_qat_hw.h index 0c8883e2ccc6..eb2ef225bcee 100644 --- a/drivers/crypto/intel/qat/qat_common/icp_qat_hw.h +++ b/drivers/crypto/intel/qat/qat_common/icp_qat_hw.h @@ -3,6 +3,8 @@ #ifndef _ICP_QAT_HW_H_ #define _ICP_QAT_HW_H_ +#include + enum icp_qat_hw_ae_id { ICP_QAT_HW_AE_0 = 0, ICP_QAT_HW_AE_1 = 1, From patchwork Fri Oct 20 13:49:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430772 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 1B9B1CDB474 for ; Fri, 20 Oct 2023 13:50:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377482AbjJTNul (ORCPT ); Fri, 20 Oct 2023 09:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377423AbjJTNuh (ORCPT ); Fri, 20 Oct 2023 09:50:37 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 364CFCA for ; Fri, 20 Oct 2023 06:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809835; x=1729345835; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=qu1nOuYeuKn+4XVQacCqHy9yrfjMsytpjUlu4U+wmlI=; b=OKvSPcuWTQnnRoT4sUTNxHNEIU+aZooByq8IbsVLzPSPtQKnvJuxcYNV V3TsLYIr4YkYjG7tua0RQcte0ixfTXIQ896ZyC0/Pj9sM5T84vcE8Bs3F f9d+6HWX4ykPoHy6sNrwhyYb7Q9Ue83GIYtAkChVGsPmhiir+qF9oqQ9D k7eT1R6zJA10WH1t/ATTNsM6QnXg8jGyMpq8IriQcL/MKLHQYywbLaGF/ jQhtuZVYVReRe9ex9JS14TE5DDpRiebrEpWrNBdVXViX2+a7hzJRk7lVD rZtAriu+YJ2XQdxOSR+LHYjpfg3Z3xruKWXf8gmitHg5dD2ldeKp7v9Qz g==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="365836088" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="365836088" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="1088748579" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="1088748579" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga005.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:34 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:33 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:33 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:33 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oexSWSGSdyV6wVKNxZl0d7gmMLtsNHu5nRuyDY28kpa1RSPKbGrsUiDcNdLuK8wYaF8wqW+Ff6sFfxT0gRW24ci/HwxszJKDwrjQAUo3nfOcusOItm3KWQs6igwkRt3gwrHoQ32y8erdVqPrKZDhPpJZJq1q4r/DWAWGxc0R3qvHpFWKQYXv5VQIOXZiRkaCr9y3Tu+aE497HTOZikkbwGEL1vND3VoOhb9cC49vG/R52uis4fkX/TUDWzMwgYaZWOO4EMkjLs4NrwZxGb2b+Z6jQDKP4iyb5JSR4rZGaPrOJUF8Wu0xL6wAvedgCdTri66V30Hx+Ls2piDMDBvrlA== 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=CfYcXvh7mRZL3MQDv53VOIJ/d5Hv1tN4NH+hHr9YeJM=; b=bo2bqyswXK/pQs1GAcrOv7hXWhq/ZQB3D06eVt9Jd8GbpW05qGE2E0Mlgb9LVt67f+af0LeAiW0zQiuGg+Cyhc/26oRFgXJQGTKv84utUbNDsDRFhjSPjxH7xSQW9g8WdhIA5/A0a3DfjfPzRCVUZYC6IZD4ORQxyYPwDRLm7sn3VzbtVivFti02iB0UhO/SnmosmQKHjXG/3Ff9lK13hy3r2YrCwEb6N9NREElwqRUK3kbt/SkQzTAqhu35YlggxldOk36Lx3QQyDkVP3dmw8aaM2z53AX5l6CO1ZB2KMBn0m7WWM2ntbatbqvrlae6oh3sYkHwkvHB2ze3t1JY1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by BL3PR11MB6363.namprd11.prod.outlook.com (2603:10b6:208:3b6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 13:50:27 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:27 +0000 From: Damian Muszynski To: CC: , , Damian Muszynski , Giovanni Cabiddu , Tero Kristo Subject: [PATCH v2 07/11] crypto: qat - add retrieval of fw capabilities Date: Fri, 20 Oct 2023 15:49:27 +0200 Message-ID: <20231020134931.7530-8-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|BL3PR11MB6363:EE_ X-MS-Office365-Filtering-Correlation-Id: d4905fe0-11c0-46c7-2b0d-08dbd1738413 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sw28Z60fP55yLcZma99Ymptd1gqvcwN9Fb6oU00Gq9PHU2tsZxX2o4JnQWJ86rQTwV6CnTuJTFDHQJPasFiCxUK2lFdFP3kAenDlwSZZgQtjRl9ly2c927D+K41B+QNjN8duggO33epgpP2weJRCiZO/KtQeVd/QOyZuJRp5uVwTCv0wMJWFcmnGgMSGfIRMvM17SoN3jgs4+X6OqvPeV/oiYxtoY8yMzg3c3K1fBS2YLQxZTPtcrqNyOI3DvIbxMky8dTmjPz6wphfa4PUBtvPb1DrkA9n/kw/t1KIGuGlg2WIu08B5EQmnBZDBxc8LTA83TX/z2U+AKm+RfIORNWnEHrkIjR2zildT0jGhxDpJbIc4Ejw5zNzUG/RYWCCxCZVplrex8ntHqz2uI3GBWLWqdnUoeTI05/U+LTsDsWeKvqa+O2YC28T0g2dUticso4okOumpRz997ZZWG1T3TEpX0ocL2IO5gKMABcxJ0Ri3mGolzodZis8WxdxwOoWinQTwlnwjfA2V4lD3jc9zvHOiT3CMFarPhZcsaa/Wz6A/eyF5Jjmz8wLazkCQnY3R X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(66556008)(54906003)(66476007)(478600001)(6916009)(83380400001)(6486002)(66946007)(6512007)(38100700002)(1076003)(41300700001)(26005)(36916002)(316002)(2616005)(6506007)(82960400001)(36756003)(86362001)(8676002)(8936002)(44832011)(2906002)(5660300002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hr1kHL1aqHdRiFqmcbH8gZZBmT6/xrfJ+areQxkqL+TjbE/15SBJs/64znmY53mSavGfTo5XmRXslWGKrazMe8hsWwBb4h6oL5+0KjSxvn36XGaw+8IoTpy4VDtYoYDuSoCy+uGSlLII8n7a9NlAaEfSk2DNWa09jnPZTehMBcBzznGwmtJrPAyxCMGkjTrHm1nU1zuBuHDGjNnlnLblYEs4MW9SVQTsg2GT67kp6nkFzpX0BW+uM10qTSRY7dRB1gFrQ31xnkyhVAZQjKVvjMUTMRKdJovisjae3UVO7kViNNChxMgSkmKBO054RF4bX32Wtji6KNWFFSKNlRaKT+tATLYhwBcr0RkRrK5dvhgOa+qfqZAfrEDsLNOW7VBpbdHRfE86Qj70ZLS1aYgaTnRnJACA831h5/RWNKDogiNZvpJiKfHsXn124lpgLbUV7GyqmOLZNd3W/T/1E+5wMHnrZH+vlRJ+9l/IngMMqfwUsmKyjrF45oZD0Dv5UeUox86hajsfPfup66PG2zW1d2gkOGr9XiixS6UWHDa4pz3hmk0jK5MIkjFN5EYvDogMWFMyRmYUpCjMRZzEHv2amO4TpFhf90pSesMmAJ9CWbO+S4emSQjCY+aEFo+RZr7qft6YDVvRdRDkBsgFcZbC7612hXzN+sN1kFG5zRrEdf4hJoeVs8av51DWH/z467o1jE+uVGj7genxHTijA0BoeryzWIhtPDdV15tYWwWUtzv7C5y0KhE4+Cq2ecgsZ41lURLQoOIXsI5bpMbcCbsYous4pLdl0qidHOtUIPpLU0s41Tv65/XZM/ugbXh6V2Rya9Toq0uvod8/s7E4MlANBPx+ohd5xIijPBfaIgXRpErIFwpWaAAA1AScBSaCZhtE2j2lNzNeH4DM+1zjuhiBZDW2v+A2Q+TfZtMfck5C+S5uocRH+y99qvtdwwmywDVnt/Q6YNLC6R/jFUzbLbZFKWVfMc/OSNDUAdwBigF+Yrf6UTdEB/igVfMT00szGp+z6zsO9NFm08IhNZpBaKNAcu51zwwXtCC2222OOCXs+Tdsp/JkytEZrCPIahgzcY/K4sVwp3VWoO6TTi2MdN/1MOQI1XAMyXLbDF/XWHNXrmBw5bQvqKFg9aQXOzIzJI41tNF5sVrDs1z24VbeDqb3MM4nbe5mpS+eoSp6JAwbJkUungb2dQXPw/nrvNRiN8dsv38QYEMRUFnjQRP833VcNBAPHfCHAOUmzJzLQ/JCqCVp55NDpEDkE4aciwmlMAvtd1ImIKCzun/zCFzXlxa7kSdoTZuU2PwZ8zDlPjjdVeApgPDS8DC3ji1/VB2celscULSgnuMVFKtsuAbzMqYcB3MwNBkdR6QIhQRU8r0C4Xk/qsFcwof7XbMAck8+4B/3hNBSsWgvjBt9d2oSpDrxRhgOamlnJPmNwTIUQFrWZaLHSJzpyt8aC436KGTpy/5Zq3lN01kevZ+/Rl1DrMZeXy3VA87agu/2N9H7VSRq8HayaidvsDJPKIOjdHsfSUBcly6XV/2VPcyQcinvIHsGUZdpxyXSN25ABZ34sDjSjJ54VW1YP7xsyvkP3skHLDImSBQFU20T3B2TLdM8oGI6LA== X-MS-Exchange-CrossTenant-Network-Message-Id: d4905fe0-11c0-46c7-2b0d-08dbd1738413 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:27.1546 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DXdsXibqiS/3mxM/VID9Zxn8dtdPgzH/T3zeK8UakmTHz+ZxIDsZWbP+rgxSTX5uEfmbiSR6CiCcimaw+cZg2jG6VIvdq6yGNB8vaEjvZp8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6363 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The QAT firmware provides a mechanism to retrieve its capabilities through the init admin interface. Add logic to retrieve the firmware capability mask from the firmware through the init/admin channel. This mask reports if the power management, telemetry and rate limiting features are supported. The fw capabilities are stored in the accel_dev structure and are used to detect if a certain feature is supported by the firmware loaded in the device. This is supported only by devices which have an admin AE. Signed-off-by: Damian Muszynski Reviewed-by: Giovanni Cabiddu Reviewed-by: Tero Kristo --- .../intel/qat/qat_common/adf_accel_devices.h | 1 + .../crypto/intel/qat/qat_common/adf_admin.c | 23 +++++++++++++++++++ .../qat/qat_common/icp_qat_fw_init_admin.h | 3 +++ 3 files changed, 27 insertions(+) diff --git a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h index 1c11d90bd9f3..908959288ce5 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +++ b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h @@ -253,6 +253,7 @@ struct adf_hw_device_data { u32 straps; u32 accel_capabilities_mask; u32 extended_dc_capabilities; + u16 fw_capabilities; u32 clock_frequency; u32 instance_id; u16 accel_mask; diff --git a/drivers/crypto/intel/qat/qat_common/adf_admin.c b/drivers/crypto/intel/qat/qat_common/adf_admin.c index 15ffda582334..50e054ba2c33 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_admin.c +++ b/drivers/crypto/intel/qat/qat_common/adf_admin.c @@ -310,6 +310,26 @@ static bool is_dcc_enabled(struct adf_accel_dev *accel_dev) return !strcmp(services, "dcc"); } +static int adf_get_fw_capabilities(struct adf_accel_dev *accel_dev, u16 *caps) +{ + u32 ae_mask = accel_dev->hw_device->admin_ae_mask; + struct icp_qat_fw_init_admin_resp resp = { }; + struct icp_qat_fw_init_admin_req req = { }; + int ret; + + if (!ae_mask) + return 0; + + req.cmd_id = ICP_QAT_FW_CAPABILITIES_GET; + ret = adf_send_admin(accel_dev, &req, &resp, ae_mask); + if (ret) + return ret; + + *caps = resp.fw_capabilities; + + return 0; +} + /** * adf_send_admin_init() - Function sends init message to FW * @accel_dev: Pointer to acceleration device. @@ -320,6 +340,7 @@ static bool is_dcc_enabled(struct adf_accel_dev *accel_dev) */ int adf_send_admin_init(struct adf_accel_dev *accel_dev) { + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); u32 dc_capabilities = 0; int ret; @@ -340,6 +361,8 @@ int adf_send_admin_init(struct adf_accel_dev *accel_dev) } accel_dev->hw_device->extended_dc_capabilities = dc_capabilities; + adf_get_fw_capabilities(accel_dev, &hw_data->fw_capabilities); + return adf_init_ae(accel_dev); } EXPORT_SYMBOL_GPL(adf_send_admin_init); diff --git a/drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h b/drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h index 9e5ce419d875..e4de9a30e0bd 100644 --- a/drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h +++ b/drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h @@ -16,6 +16,7 @@ enum icp_qat_fw_init_admin_cmd_id { ICP_QAT_FW_HEARTBEAT_SYNC = 7, ICP_QAT_FW_HEARTBEAT_GET = 8, ICP_QAT_FW_COMP_CAPABILITY_GET = 9, + ICP_QAT_FW_CRYPTO_CAPABILITY_GET = 10, ICP_QAT_FW_DC_CHAIN_INIT = 11, ICP_QAT_FW_HEARTBEAT_TIMER_SET = 13, ICP_QAT_FW_TIMER_GET = 19, @@ -109,10 +110,12 @@ struct icp_qat_fw_init_admin_resp { __u32 unsuccessful_count; __u64 resrvd8; }; + __u16 fw_capabilities; }; } __packed; #define ICP_QAT_FW_SYNC ICP_QAT_FW_HEARTBEAT_SYNC +#define ICP_QAT_FW_CAPABILITIES_GET ICP_QAT_FW_CRYPTO_CAPABILITY_GET #define ICP_QAT_NUMBER_OF_PM_EVENTS 8 From patchwork Fri Oct 20 13:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430775 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 7261AC001DF for ; Fri, 20 Oct 2023 13:50:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377483AbjJTNuv (ORCPT ); Fri, 20 Oct 2023 09:50:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377429AbjJTNut (ORCPT ); Fri, 20 Oct 2023 09:50:49 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66D9919E for ; Fri, 20 Oct 2023 06:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809844; x=1729345844; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=LsWdpjB6G+S1STD7HPRjVE+VMKjH9Z53DF5uJw4WCEE=; b=W8U7Vh0oDctVn4r+nXP10uMNU+j5fq6bSBxRyUvQ5/COtrtQqcvvpofI W81dJnPKeYS1o8FbXuboT6rh57zmWp6q70RZctfFD62KjbmwHK8/zpCcq syWkk42Pg/6pu/ybj02E8esw3WzmXDTJ72sWX+lDDnvnlCMjZjqqKolUi dwkKq/qu/a0kgYIaMkJEaGDLPGNpwT+V7W4H4iY0ZpdwHedZMRnX/GqmA Cory+cHAvrbevz2eRx2lOwxDzdj640iCHobU4bdKEvNlOpF6nt72faqrz B5DyJen/Ibt7wA9uOQq3OJDEdv2LhPvltPjeYGvd5oYYdARL7N6L4CoQM A==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="365836121" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="365836121" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="1088748687" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="1088748687" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga005.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:44 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:43 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:43 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:43 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ydw6Xwv9SeNCOlpMs3lqTemTGz93NI3erltedrqLBzzlXkCL1e35bHWYJMjvVC0TSOwPgkjtFbDHASyp8fRabmk9BQYKGignNpMQ/FVY9NCcHhviMpzfiWHz256e4rQOmsRgfrj4+L43eXUFOwrp9PzT+LudUq3yrQDO5ZRgzTH83zBKrr/kOBeDrQdpIpJ/uCKT2sWfatW6wgj7rM5ReVIlNuf7dCdLdei51NXe0NLJ1Y3QjkFCJQAHUH/c+T9UIkcO1CdB3nIoKOBDCOkZPmcCrEs1x0rc9+G8t37rSpuau8X0riNWU98C8tdG5n5MkVYWga7kqPGUcmEio/EInA== 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=iwFez0vi+kzZ9zMRDwMaTs666M7+HhYuHTQjXRJmZro=; b=SnpcXDPZyxavfi69RCrcR34vpPem3orstzhkdiLTT7Xw7hu3Ih+AOpUMqNNDaRxtn1fssQNsJvzXGc8mQf4DySNqDmmXDdv4RNOYi/1q4197Dkk/pXMBAGaDAhIZjN262CE3dLvmCkGt1lEcQQsBEP1KeY1VtX8ym53HLl6h8BfiSviSu1S+1BpzLmtRZNnA31MVD/4/2cTCOWnca1VGiWBZDqpGvwUqQ34xXnd6P3xokqbbCw2jQSwtEB2qXZmKa/0bfqWrfc2ukmd2NoJvp8UA54mNDOoj34Dpml1CFry9xwst6zMBMxlm3BfqVvl9VrEIAY+5M8Z788VRT+eoSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by BL3PR11MB6363.namprd11.prod.outlook.com (2603:10b6:208:3b6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 13:50:32 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:30 +0000 From: Damian Muszynski To: CC: , , Damian Muszynski , Giovanni Cabiddu , Tero Kristo Subject: [PATCH v2 08/11] crypto: qat - add rate limiting feature to qat_4xxx Date: Fri, 20 Oct 2023 15:49:28 +0200 Message-ID: <20231020134931.7530-9-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|BL3PR11MB6363:EE_ X-MS-Office365-Filtering-Correlation-Id: 163e2770-0844-4c29-22f1-08dbd17385d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jPnWIzw0kndyzm9gJQo8y4AHOsgg0xWhaZ7ynDvjO1FmypUdU9CmdYgbiJ7Q8If77vZxt8hxV1XE0/QgyjJbKGhnul3LTFGASPp8dcNres9MNK8IIpZCjRVxDkUEjSUIHDAT2nOuo9zGE7nu9AhSCjcc0jrIbw7EQQs0P/F63K9Jv8qr+Elw52ZINbtmbc8RQ+JLIqX7hHnVta0Uw0Qn46lg/YqCglNObDHCQfNd9xrAl344BrTedYvLlz0y47OecZyUHELMRwoeDvB3rlouIsTfOG/+MoQbtA7oP4WICSHzDme3L9AHSkvtXa/L+MjdArSli9T10VocOMrZT70C3qIdM+xOO0dyBoMwZ9+dUZ2NeeiMrkKxmzqohmMYlLwirl5ETVh4OYaEbejkyTfNxqH7xlKjMG+os/xE5cuEdEtphs81M+dSB8lspvm/Omp5vk+BTllvMno4zSmxw1knWGFb4VggrcUS5Fivm1sg1Vu/n4MNy0xMu9Rktgs9vfSHdHC77Uxr88M1kfmS41f9mOVZsjv4XfXBAxSeP7vc3nRqYnrTyj07VTstvr2C5Rt1 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(66556008)(54906003)(66476007)(478600001)(6916009)(83380400001)(6486002)(66946007)(6512007)(38100700002)(1076003)(41300700001)(26005)(36916002)(316002)(2616005)(6506007)(82960400001)(30864003)(36756003)(86362001)(8676002)(8936002)(44832011)(2906002)(5660300002)(4326008)(559001)(579004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Av9PoTH351RXDsWKXlV5TSnG2RT6BcOiFmB94jxxkJ0RlHoxo1epVm+xpTj69FTseMXnukLnQp9kcHhlKZdxenXfsG6U2upomUC20njSaWaMP5K6djvRJy0vY4WBaOTbNc/Eg5kIGOaoYyq4R2LSQf+DFWX7k7YkZhRIdO7DaDKqq2h5FnLTCBAnOQ2sZPxkRu7GF4ujOZoTGMgwrfYCopn+YKn1eMzqcE8Ab/hjoNOG24z7vJvxQ/gaCVBSk7fhEbq2JId4O0CoN3OCUbVdeBJYlt9bRNY2pyWSs30p7J7xydXGAHs6ZbTta6yyaZ3Fn572WXjgRQwyJQDC5BwPoj0X2P0ICrlQok2pR7bjta3deFaWHKVWxWeC5pn2C5mxtManSw5vOC/BnXCoiOhyDB/tfSeWbrQITTShnEUcAR5qtw1pdD5RFGVO702na65DI+x9hr19oPRWDjQKwygq+Eu1gKXM5t4vmSNZ0yPeX5NkEy3x3GOBxheB3XJg2rLuqHMKMTrBRX5lNJHqpvhXPoNe/PraRuD+ZzHKQyksQ0Y01zxaTjpG6KmI5QffYfLXp7jHPt1T3K2cFpZonIs2D9A4wsN26X6KHZq/8RJ1Y17jD9om051HaRNLOOhfHpZ6MNQj71g4+E99Bug/5o/EqWSDzKdwHMFCK0jKqLIRy0h1xer+sT9r1uuXm4qWoRYWIf4Frm23F3GoTtTtbUT0kv2szhlaLt5gtxg1stF18eE84Nkc8QN3GmrKDmHbYDQGYzWUT7ahhcze97fMaxSIPQOGrcwkLseiT5neTcxd9hgRZmnM6SnxKDUapOWHipBvi5qzi58Auhc6bwFhKSAJeW6Be4/ZgGku0liDCOYrRcQ+NvOSamOkKq6Bn5Z3czMPlmtYL4GdauG/h9CcZ4zUymwaBvV6ayBImeJtHYYge5dzW2iu24Mm79lvf14wbOD34caBu7TJhXzgHK3UWBj8fbD72mbfo4Iz4a4HVmHjDanhmhDRJSDIxU0ruYBRTLerRdwqR7R2bd2nT6120YMJ6c4yGnoKqesj+PkbfALtQy7ocn6+aJ2xDcpRtd/eN+H8vbZ5QegwSo2R2Z1pPXuwW0wbY0CmtFZz5BmL87o9nbmyBFcJZBnMZVxXSABOgV12VxrSktqXRDyHbUcBErjsL6Twpkt9HOgigEqQR0QdZ2S9He3Q2sXlPFKMp5n9ZtJoeR/IPRC4NZ+W8z2+nuLOeAEE1DMtHXNQrhS7/f09U8v/0dpXzXD7Mpk6Rxq0cvQgdQ9ZtBZn/+4QLFwbfcJXugzc6D++FJHg8tQ6CnuhFLavQ+At3KOTvUm1Ds1G2V8G08A4T2QUthxgcItM5rjaJ111jI3yOGTr5z3GWUwB4bjDhom9wIqoXTQ1u0NbIPtGKJfnTPkXfvmsRnW8izA48r4tQYDxPz9gLsoEf+PlxlWuQH6ITpCZlM7tWpzWQygiy0iNYqwAdEYdseY5yYGaROha2MhtLorGgGcOW1A8Wi6oCVOsBARLTLEBUCEobh4yAbmPo7YtkgDZzLx9EsPiSt340Gnjzj9ndcSCWFF39GCZPgAtsfoazrTH9d9iDkEnFcPUtUed3xkAsiGiNxIEsw== X-MS-Exchange-CrossTenant-Network-Message-Id: 163e2770-0844-4c29-22f1-08dbd17385d8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:30.2267 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: L4fs+deIR06pTabeJOyk65Efq9lYShOo2RFQdyqwNB9y7DljAdWsIl/Et8Oowdc03gPBaYc6++6XozZy/DGjps5RVxuuw6zdsXM2qEVUfF8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6363 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The Rate Limiting (RL) feature allows to control the rate of requests that can be submitted on a ring pair (RP). This allows sharing a QAT device among multiple users while ensuring a guaranteed throughput. The driver provides a mechanism that allows users to set policies, that are programmed to the device. The device is then enforcing those policies. Configuration of RL is accomplished through entities called SLAs (Service Level Agreement). Each SLA object gets a unique identifier and defines the limitations for a single service across up to four ring pairs (RPs count allocated to a single VF). The rate is determined using two fields: * CIR (Committed Information Rate), i.e., the guaranteed rate. * PIR (Peak Information Rate), i.e., the maximum rate achievable when the device has available resources. The rate values are expressed in permille scale i.e. 0-1000. Ring pair selection is achieved by providing a 64-bit mask, where each bit corresponds to one of the ring pairs. This adds an interface and logic that allow to add, update, retrieve and remove an SLA. Signed-off-by: Damian Muszynski Reviewed-by: Giovanni Cabiddu Reviewed-by: Tero Kristo --- .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c | 20 + .../intel/qat/qat_4xxx/adf_4xxx_hw_data.h | 13 +- drivers/crypto/intel/qat/qat_common/Makefile | 2 + .../intel/qat/qat_common/adf_accel_devices.h | 3 + .../crypto/intel/qat/qat_common/adf_admin.c | 47 + .../crypto/intel/qat/qat_common/adf_admin.h | 8 + .../intel/qat/qat_common/adf_gen4_hw_data.h | 7 + .../crypto/intel/qat/qat_common/adf_init.c | 10 + drivers/crypto/intel/qat/qat_common/adf_rl.c | 1159 +++++++++++++++++ drivers/crypto/intel/qat/qat_common/adf_rl.h | 169 +++ .../intel/qat/qat_common/adf_rl_admin.c | 97 ++ .../intel/qat/qat_common/adf_rl_admin.h | 18 + .../qat/qat_common/icp_qat_fw_init_admin.h | 38 + 13 files changed, 1590 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl.h create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl_admin.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_rl_admin.h diff --git a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c index ea47a05e12ed..2bba58a2c76f 100644 --- a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c +++ b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c @@ -343,6 +343,24 @@ static u32 get_heartbeat_clock(struct adf_hw_device_data *self) return ADF_4XXX_KPT_COUNTER_FREQ; } +static void adf_init_rl_data(struct adf_rl_hw_data *rl_data) +{ + rl_data->pciout_tb_offset = ADF_GEN4_RL_TOKEN_PCIEOUT_BUCKET_OFFSET; + rl_data->pciin_tb_offset = ADF_GEN4_RL_TOKEN_PCIEIN_BUCKET_OFFSET; + rl_data->r2l_offset = ADF_GEN4_RL_R2L_OFFSET; + rl_data->l2c_offset = ADF_GEN4_RL_L2C_OFFSET; + rl_data->c2s_offset = ADF_GEN4_RL_C2S_OFFSET; + + rl_data->pcie_scale_div = ADF_4XXX_RL_PCIE_SCALE_FACTOR_DIV; + rl_data->pcie_scale_mul = ADF_4XXX_RL_PCIE_SCALE_FACTOR_MUL; + rl_data->dcpr_correction = ADF_4XXX_RL_DCPR_CORRECTION; + rl_data->max_tp[ADF_SVC_ASYM] = ADF_4XXX_RL_MAX_TP_ASYM; + rl_data->max_tp[ADF_SVC_SYM] = ADF_4XXX_RL_MAX_TP_SYM; + rl_data->max_tp[ADF_SVC_DC] = ADF_4XXX_RL_MAX_TP_DC; + rl_data->scan_interval = ADF_4XXX_RL_SCANS_PER_SEC; + rl_data->scale_ref = ADF_4XXX_RL_SLICE_REF; +} + static void adf_enable_error_correction(struct adf_accel_dev *accel_dev) { struct adf_bar *misc_bar = &GET_BARS(accel_dev)[ADF_4XXX_PMISC_BAR]; @@ -594,12 +612,14 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data, u32 dev_id) hw_data->stop_timer = adf_gen4_timer_stop; hw_data->get_hb_clock = get_heartbeat_clock; hw_data->num_hb_ctrs = ADF_NUM_HB_CNT_PER_AE; + hw_data->clock_frequency = ADF_4XXX_AE_FREQ; adf_gen4_set_err_mask(&hw_data->dev_err_mask); adf_gen4_init_hw_csr_ops(&hw_data->csr_ops); adf_gen4_init_pf_pfvf_ops(&hw_data->pfvf_ops); adf_gen4_init_dc_ops(&hw_data->dc_ops); adf_gen4_init_ras_ops(&hw_data->ras_ops); + adf_init_rl_data(&hw_data->rl_data); } void adf_clean_hw_data_4xxx(struct adf_hw_device_data *hw_data) diff --git a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.h b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.h index efd5dadc19ed..33423295e90f 100644 --- a/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.h +++ b/drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.h @@ -82,8 +82,19 @@ #define ADF_402XX_ASYM_OBJ "qat_402xx_asym.bin" #define ADF_402XX_ADMIN_OBJ "qat_402xx_admin.bin" +/* RL constants */ +#define ADF_4XXX_RL_PCIE_SCALE_FACTOR_DIV 100 +#define ADF_4XXX_RL_PCIE_SCALE_FACTOR_MUL 102 +#define ADF_4XXX_RL_DCPR_CORRECTION 1 +#define ADF_4XXX_RL_SCANS_PER_SEC 954 +#define ADF_4XXX_RL_MAX_TP_ASYM 173750UL +#define ADF_4XXX_RL_MAX_TP_SYM 95000UL +#define ADF_4XXX_RL_MAX_TP_DC 45000UL +#define ADF_4XXX_RL_SLICE_REF 1000UL + /* Clocks frequency */ -#define ADF_4XXX_KPT_COUNTER_FREQ (100 * HZ_PER_MHZ) +#define ADF_4XXX_KPT_COUNTER_FREQ (100 * HZ_PER_MHZ) +#define ADF_4XXX_AE_FREQ (1000 * HZ_PER_MHZ) /* qat_4xxx fuse bits are different from old GENs, redefine them */ enum icp_qat_4xxx_slice_mask { diff --git a/drivers/crypto/intel/qat/qat_common/Makefile b/drivers/crypto/intel/qat/qat_common/Makefile index 58f3c181b2ce..408b3959da1d 100644 --- a/drivers/crypto/intel/qat/qat_common/Makefile +++ b/drivers/crypto/intel/qat/qat_common/Makefile @@ -28,6 +28,8 @@ intel_qat-objs := adf_cfg.o \ qat_algs.o \ qat_asym_algs.o \ qat_algs_send.o \ + adf_rl.o \ + adf_rl_admin.o \ qat_uclo.o \ qat_hal.o \ qat_bl.o diff --git a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h index 908959288ce5..30c2b15ff801 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +++ b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h @@ -9,6 +9,7 @@ #include #include #include "adf_cfg_common.h" +#include "adf_rl.h" #include "adf_pfvf_msg.h" #define ADF_DH895XCC_DEVICE_NAME "dh895xcc" @@ -247,6 +248,7 @@ struct adf_hw_device_data { struct adf_dc_ops dc_ops; struct adf_ras_ops ras_ops; struct adf_dev_err_mask dev_err_mask; + struct adf_rl_hw_data rl_data; const char *fw_name; const char *fw_mmp_name; u32 fuses; @@ -358,6 +360,7 @@ struct adf_accel_dev { struct adf_accel_pci accel_pci_dev; struct adf_timer *timer; struct adf_heartbeat *heartbeat; + struct adf_rl *rate_limiting; union { struct { /* protects VF2PF interrupts access */ diff --git a/drivers/crypto/intel/qat/qat_common/adf_admin.c b/drivers/crypto/intel/qat/qat_common/adf_admin.c index 50e054ba2c33..54b673ec2362 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_admin.c +++ b/drivers/crypto/intel/qat/qat_common/adf_admin.c @@ -330,6 +330,53 @@ static int adf_get_fw_capabilities(struct adf_accel_dev *accel_dev, u16 *caps) return 0; } +int adf_send_admin_rl_init(struct adf_accel_dev *accel_dev, + struct icp_qat_fw_init_admin_slice_cnt *slices) +{ + u32 ae_mask = accel_dev->hw_device->admin_ae_mask; + struct icp_qat_fw_init_admin_resp resp = { }; + struct icp_qat_fw_init_admin_req req = { }; + int ret; + + req.cmd_id = ICP_QAT_FW_RL_INIT; + + ret = adf_send_admin(accel_dev, &req, &resp, ae_mask); + if (ret) + return ret; + + memcpy(slices, &resp.slices, sizeof(*slices)); + + return 0; +} + +int adf_send_admin_rl_add_update(struct adf_accel_dev *accel_dev, + struct icp_qat_fw_init_admin_req *req) +{ + u32 ae_mask = accel_dev->hw_device->admin_ae_mask; + struct icp_qat_fw_init_admin_resp resp = { }; + + /* + * req struct filled in rl implementation. Used commands + * ICP_QAT_FW_RL_ADD for a new SLA + * ICP_QAT_FW_RL_UPDATE for update SLA + */ + return adf_send_admin(accel_dev, req, &resp, ae_mask); +} + +int adf_send_admin_rl_delete(struct adf_accel_dev *accel_dev, u16 node_id, + u8 node_type) +{ + u32 ae_mask = accel_dev->hw_device->admin_ae_mask; + struct icp_qat_fw_init_admin_resp resp = { }; + struct icp_qat_fw_init_admin_req req = { }; + + req.cmd_id = ICP_QAT_FW_RL_REMOVE; + req.node_id = node_id; + req.node_type = node_type; + + return adf_send_admin(accel_dev, &req, &resp, ae_mask); +} + /** * adf_send_admin_init() - Function sends init message to FW * @accel_dev: Pointer to acceleration device. diff --git a/drivers/crypto/intel/qat/qat_common/adf_admin.h b/drivers/crypto/intel/qat/qat_common/adf_admin.h index 03507ec3a51d..55cbcbc66c9f 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_admin.h +++ b/drivers/crypto/intel/qat/qat_common/adf_admin.h @@ -3,6 +3,8 @@ #ifndef ADF_ADMIN #define ADF_ADMIN +#include "icp_qat_fw_init_admin.h" + struct adf_accel_dev; int adf_init_admin_comms(struct adf_accel_dev *accel_dev); @@ -12,6 +14,12 @@ int adf_get_ae_fw_counters(struct adf_accel_dev *accel_dev, u16 ae, u64 *reqs, u int adf_init_admin_pm(struct adf_accel_dev *accel_dev, u32 idle_delay); int adf_send_admin_tim_sync(struct adf_accel_dev *accel_dev, u32 cnt); int adf_send_admin_hb_timer(struct adf_accel_dev *accel_dev, uint32_t ticks); +int adf_send_admin_rl_init(struct adf_accel_dev *accel_dev, + struct icp_qat_fw_init_admin_slice_cnt *slices); +int adf_send_admin_rl_add_update(struct adf_accel_dev *accel_dev, + struct icp_qat_fw_init_admin_req *req); +int adf_send_admin_rl_delete(struct adf_accel_dev *accel_dev, u16 node_id, + u8 node_type); int adf_get_fw_timestamp(struct adf_accel_dev *accel_dev, u64 *timestamp); int adf_get_pm_info(struct adf_accel_dev *accel_dev, dma_addr_t p_state_addr, size_t buff_size); int adf_get_cnv_stats(struct adf_accel_dev *accel_dev, u16 ae, u16 *err_cnt, u16 *latest_err); diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.h b/drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.h index 02d7a019ebf8..1813fe1d5a06 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.h +++ b/drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.h @@ -139,6 +139,13 @@ do { \ /* Number of heartbeat counter pairs */ #define ADF_NUM_HB_CNT_PER_AE ADF_NUM_THREADS_PER_AE +/* Rate Limiting */ +#define ADF_GEN4_RL_R2L_OFFSET 0x508000 +#define ADF_GEN4_RL_L2C_OFFSET 0x509000 +#define ADF_GEN4_RL_C2S_OFFSET 0x508818 +#define ADF_GEN4_RL_TOKEN_PCIEIN_BUCKET_OFFSET 0x508800 +#define ADF_GEN4_RL_TOKEN_PCIEOUT_BUCKET_OFFSET 0x508804 + void adf_gen4_set_ssm_wdtimer(struct adf_accel_dev *accel_dev); void adf_gen4_init_hw_csr_ops(struct adf_hw_csr_ops *csr_ops); int adf_gen4_ring_pair_reset(struct adf_accel_dev *accel_dev, u32 bank_number); diff --git a/drivers/crypto/intel/qat/qat_common/adf_init.c b/drivers/crypto/intel/qat/qat_common/adf_init.c index ef51c4d028d2..81c39f3d07e1 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_init.c +++ b/drivers/crypto/intel/qat/qat_common/adf_init.c @@ -9,6 +9,7 @@ #include "adf_common_drv.h" #include "adf_dbgfs.h" #include "adf_heartbeat.h" +#include "adf_rl.h" #include "adf_sysfs_ras_counters.h" static LIST_HEAD(service_table); @@ -137,6 +138,9 @@ static int adf_dev_init(struct adf_accel_dev *accel_dev) } adf_heartbeat_init(accel_dev); + ret = adf_rl_init(accel_dev); + if (ret && ret != -EOPNOTSUPP) + return ret; /* * Subservice initialisation is divided into two stages: init and start. @@ -212,6 +216,9 @@ static int adf_dev_start(struct adf_accel_dev *accel_dev) } adf_heartbeat_start(accel_dev); + ret = adf_rl_start(accel_dev); + if (ret && ret != -EOPNOTSUPP) + return ret; list_for_each_entry(service, &service_table, list) { if (service->event_hld(accel_dev, ADF_EVENT_START)) { @@ -272,6 +279,7 @@ static void adf_dev_stop(struct adf_accel_dev *accel_dev) !test_bit(ADF_STATUS_STARTING, &accel_dev->status)) return; + adf_rl_stop(accel_dev); adf_dbgfs_rm(accel_dev); adf_sysfs_stop_ras(accel_dev); @@ -359,6 +367,8 @@ static void adf_dev_shutdown(struct adf_accel_dev *accel_dev) clear_bit(accel_dev->accel_id, service->init_status); } + adf_rl_exit(accel_dev); + if (hw_data->ras_ops.disable_ras_errors) hw_data->ras_ops.disable_ras_errors(accel_dev); diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl.c b/drivers/crypto/intel/qat/qat_common/adf_rl.c new file mode 100644 index 000000000000..88a03105b52a --- /dev/null +++ b/drivers/crypto/intel/qat/qat_common/adf_rl.c @@ -0,0 +1,1159 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright(c) 2023 Intel Corporation */ + +#define dev_fmt(fmt) "RateLimiting: " fmt + +#include +#include + +#include +#include +#include +#include +#include + +#include "adf_accel_devices.h" +#include "adf_common_drv.h" +#include "adf_rl_admin.h" +#include "adf_rl.h" + +#define RL_TOKEN_GRANULARITY_PCIEIN_BUCKET 0U +#define RL_TOKEN_GRANULARITY_PCIEOUT_BUCKET 0U +#define RL_TOKEN_PCIE_SIZE 64 +#define RL_TOKEN_ASYM_SIZE 1024 +#define RL_CSR_SIZE 4U +#define RL_CAPABILITY_MASK GENMASK(6, 4) +#define RL_CAPABILITY_VALUE 0x70 +#define RL_VALIDATE_NON_ZERO(input) ((input) == 0) +#define ROOT_MASK GENMASK(1, 0) +#define CLUSTER_MASK GENMASK(3, 0) +#define LEAF_MASK GENMASK(5, 0) + +static int validate_user_input(struct adf_accel_dev *accel_dev, + struct adf_rl_sla_input_data *sla_in, + bool is_update) +{ + const unsigned long rp_mask = sla_in->rp_mask; + size_t rp_mask_size; + int i, cnt; + + if (sla_in->pir < sla_in->cir) { + dev_notice(&GET_DEV(accel_dev), + "PIR must be >= CIR, setting PIR to CIR\n"); + sla_in->pir = sla_in->cir; + } + + if (!is_update) { + cnt = 0; + rp_mask_size = sizeof(sla_in->rp_mask) * BITS_PER_BYTE; + for_each_set_bit(i, &rp_mask, rp_mask_size) { + if (++cnt > RL_RP_CNT_PER_LEAF_MAX) { + dev_notice(&GET_DEV(accel_dev), + "Too many ring pairs selected for this SLA\n"); + return -EINVAL; + } + } + + if (sla_in->srv >= ADF_SVC_NONE) { + dev_notice(&GET_DEV(accel_dev), + "Wrong service type\n"); + return -EINVAL; + } + + if (sla_in->type > RL_LEAF) { + dev_notice(&GET_DEV(accel_dev), + "Wrong node type\n"); + return -EINVAL; + } + + if (sla_in->parent_id < RL_PARENT_DEFAULT_ID || + sla_in->parent_id >= RL_NODES_CNT_MAX) { + dev_notice(&GET_DEV(accel_dev), + "Wrong parent ID\n"); + return -EINVAL; + } + } + + return 0; +} + +static int validate_sla_id(struct adf_accel_dev *accel_dev, int sla_id) +{ + struct rl_sla *sla; + + if (sla_id <= RL_SLA_EMPTY_ID || sla_id >= RL_NODES_CNT_MAX) { + dev_notice(&GET_DEV(accel_dev), "Provided ID is out of bounds\n"); + return -EINVAL; + } + + sla = accel_dev->rate_limiting->sla[sla_id]; + + if (!sla) { + dev_notice(&GET_DEV(accel_dev), "SLA with provided ID does not exist\n"); + return -EINVAL; + } + + if (sla->type != RL_LEAF) { + dev_notice(&GET_DEV(accel_dev), "This ID is reserved for internal use\n"); + return -EINVAL; + } + + return 0; +} + +/** + * find_parent() - Find the parent for a new SLA + * @rl_data: pointer to ratelimiting data + * @sla_in: pointer to user input data for a new SLA + * + * Function returns a pointer to the parent SLA. If the parent ID is provided + * as input in the user data, then such ID is validated and the parent SLA + * is returned. + * Otherwise, it returns the default parent SLA (root or cluster) for + * the new object. + * + * Return: + * * Pointer to the parent SLA object + * * NULL - when parent cannot be found + */ +static struct rl_sla *find_parent(struct adf_rl *rl_data, + struct adf_rl_sla_input_data *sla_in) +{ + int input_parent_id = sla_in->parent_id; + struct rl_sla *root = NULL; + struct rl_sla *parent_sla; + int i; + + if (sla_in->type == RL_ROOT) + return NULL; + + if (input_parent_id > RL_PARENT_DEFAULT_ID) { + parent_sla = rl_data->sla[input_parent_id]; + /* + * SLA can be a parent if it has the same service as the child + * and its type is higher in the hierarchy, + * for example the parent type of a LEAF must be a CLUSTER. + */ + if (parent_sla && parent_sla->srv == sla_in->srv && + parent_sla->type == sla_in->type - 1) + return parent_sla; + + return NULL; + } + + /* If input_parent_id is not valid, get root for this service type. */ + for (i = 0; i < RL_ROOT_MAX; i++) { + if (rl_data->root[i] && rl_data->root[i]->srv == sla_in->srv) { + root = rl_data->root[i]; + break; + } + } + + if (!root) + return NULL; + + /* + * If the type of this SLA is cluster, then return the root. + * Otherwise, find the default (i.e. first) cluster for this service. + */ + if (sla_in->type == RL_CLUSTER) + return root; + + for (i = 0; i < RL_CLUSTER_MAX; i++) { + if (rl_data->cluster[i] && rl_data->cluster[i]->parent == root) + return rl_data->cluster[i]; + } + + return NULL; +} + +static enum adf_cfg_service_type srv_to_cfg_svc_type(enum adf_base_services rl_srv) +{ + switch (rl_srv) { + case ADF_SVC_ASYM: + return ASYM; + case ADF_SVC_SYM: + return SYM; + case ADF_SVC_DC: + return COMP; + default: + return UNUSED; + } +} + +/** + * get_sla_arr_of_type() - Returns a pointer to SLA type specific array + * @rl_data: pointer to ratelimiting data + * @type: SLA type + * @sla_arr: pointer to variable where requested pointer will be stored + * + * Return: Max number of elements allowed for the returned array + */ +static u32 get_sla_arr_of_type(struct adf_rl *rl_data, enum rl_node_type type, + struct rl_sla ***sla_arr) +{ + switch (type) { + case RL_LEAF: + *sla_arr = rl_data->leaf; + return RL_LEAF_MAX; + case RL_CLUSTER: + *sla_arr = rl_data->cluster; + return RL_CLUSTER_MAX; + case RL_ROOT: + *sla_arr = rl_data->root; + return RL_ROOT_MAX; + default: + *sla_arr = NULL; + return 0; + } +} + +static bool is_service_enabled(struct adf_accel_dev *accel_dev, + enum adf_base_services rl_srv) +{ + enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(rl_srv); + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); + u8 rps_per_bundle = hw_data->num_banks_per_vf; + int i; + + for (i = 0; i < rps_per_bundle; i++) { + if (GET_SRV_TYPE(accel_dev, i) == arb_srv) + return true; + } + + return false; +} + +/** + * prepare_rp_ids() - Creates an array of ring pair IDs from bitmask + * @accel_dev: pointer to acceleration device structure + * @sla: SLA object data where result will be written + * @rp_mask: bitmask of ring pair IDs + * + * Function tries to convert provided bitmap to an array of IDs. It checks if + * RPs aren't in use, are assigned to SLA service or if a number of provided + * IDs is not too big. If successful, writes the result into the field + * sla->ring_pairs_cnt. + * + * Return: + * * 0 - ok + * * -EINVAL - ring pairs array cannot be created from provided mask + */ +static int prepare_rp_ids(struct adf_accel_dev *accel_dev, struct rl_sla *sla, + const unsigned long rp_mask) +{ + enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(sla->srv); + u16 rps_per_bundle = GET_HW_DATA(accel_dev)->num_banks_per_vf; + bool *rp_in_use = accel_dev->rate_limiting->rp_in_use; + size_t rp_cnt_max = ARRAY_SIZE(sla->ring_pairs_ids); + u16 rp_id_max = GET_HW_DATA(accel_dev)->num_banks; + u16 cnt = 0; + u16 rp_id; + + for_each_set_bit(rp_id, &rp_mask, rp_id_max) { + if (cnt >= rp_cnt_max) { + dev_notice(&GET_DEV(accel_dev), + "Assigned more ring pairs than supported"); + return -EINVAL; + } + + if (rp_in_use[rp_id]) { + dev_notice(&GET_DEV(accel_dev), + "RP %u already assigned to other SLA", rp_id); + return -EINVAL; + } + + if (GET_SRV_TYPE(accel_dev, rp_id % rps_per_bundle) != arb_srv) { + dev_notice(&GET_DEV(accel_dev), + "RP %u does not support SLA service", rp_id); + return -EINVAL; + } + + sla->ring_pairs_ids[cnt++] = rp_id; + } + + sla->ring_pairs_cnt = cnt; + + return 0; +} + +static void mark_rps_usage(struct rl_sla *sla, bool *rp_in_use, bool used) +{ + u16 rp_id; + int i; + + for (i = 0; i < sla->ring_pairs_cnt; i++) { + rp_id = sla->ring_pairs_ids[i]; + rp_in_use[rp_id] = used; + } +} + +static void assign_rps_to_leaf(struct adf_accel_dev *accel_dev, + struct rl_sla *sla, bool clear) +{ + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); + void __iomem *pmisc_addr = adf_get_pmisc_base(accel_dev); + u32 base_offset = hw_data->rl_data.r2l_offset; + u32 node_id = clear ? 0U : (sla->node_id & LEAF_MASK); + u32 offset; + int i; + + for (i = 0; i < sla->ring_pairs_cnt; i++) { + offset = base_offset + (RL_CSR_SIZE * sla->ring_pairs_ids[i]); + ADF_CSR_WR(pmisc_addr, offset, node_id); + } +} + +static void assign_leaf_to_cluster(struct adf_accel_dev *accel_dev, + struct rl_sla *sla, bool clear) +{ + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); + void __iomem *pmisc_addr = adf_get_pmisc_base(accel_dev); + u32 base_offset = hw_data->rl_data.l2c_offset; + u32 node_id = sla->node_id & LEAF_MASK; + u32 parent_id = clear ? 0U : (sla->parent->node_id & CLUSTER_MASK); + u32 offset; + + offset = base_offset + (RL_CSR_SIZE * node_id); + ADF_CSR_WR(pmisc_addr, offset, parent_id); +} + +static void assign_cluster_to_root(struct adf_accel_dev *accel_dev, + struct rl_sla *sla, bool clear) +{ + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); + void __iomem *pmisc_addr = adf_get_pmisc_base(accel_dev); + u32 base_offset = hw_data->rl_data.c2s_offset; + u32 node_id = sla->node_id & CLUSTER_MASK; + u32 parent_id = clear ? 0U : (sla->parent->node_id & ROOT_MASK); + u32 offset; + + offset = base_offset + (RL_CSR_SIZE * node_id); + ADF_CSR_WR(pmisc_addr, offset, parent_id); +} + +static void assign_node_to_parent(struct adf_accel_dev *accel_dev, + struct rl_sla *sla, bool clear_assignment) +{ + switch (sla->type) { + case RL_LEAF: + assign_rps_to_leaf(accel_dev, sla, clear_assignment); + assign_leaf_to_cluster(accel_dev, sla, clear_assignment); + break; + case RL_CLUSTER: + assign_cluster_to_root(accel_dev, sla, clear_assignment); + break; + default: + break; + } +} + +/** + * can_parent_afford_sla() - Verifies if parent allows to create an SLA + * @sla_in: pointer to user input data for a new SLA + * @sla_parent: pointer to parent SLA object + * @sla_cir: current child CIR value (only for update) + * @is_update: request is a update + * + * Algorithm verifies if parent has enough remaining budget to take assignment + * of a child with provided parameters. In update case current CIR value must be + * returned to budget first. + * PIR value cannot exceed the PIR assigned to parent. + * + * Return: + * * true - SLA can be created + * * false - SLA cannot be created + */ +static bool can_parent_afford_sla(struct adf_rl_sla_input_data *sla_in, + struct rl_sla *sla_parent, u32 sla_cir, + bool is_update) +{ + u32 rem_cir = sla_parent->rem_cir; + + if (is_update) + rem_cir += sla_cir; + + if (sla_in->cir > rem_cir || sla_in->pir > sla_parent->pir) + return false; + + return true; +} + +/** + * can_node_afford_update() - Verifies if SLA can be updated with input data + * @sla_in: pointer to user input data for a new SLA + * @sla: pointer to SLA object selected for update + * + * Algorithm verifies if a new CIR value is big enough to satisfy currently + * assigned child SLAs and if PIR can be updated + * + * Return: + * * true - SLA can be updated + * * false - SLA cannot be updated + */ +static bool can_node_afford_update(struct adf_rl_sla_input_data *sla_in, + struct rl_sla *sla) +{ + u32 cir_in_use = sla->cir - sla->rem_cir; + + /* new CIR cannot be smaller then currently consumed value */ + if (cir_in_use > sla_in->cir) + return false; + + /* PIR of root/cluster cannot be reduced in node with assigned children */ + if (sla_in->pir < sla->pir && sla->type != RL_LEAF && cir_in_use > 0) + return false; + + return true; +} + +static bool is_enough_budget(struct adf_rl *rl_data, struct rl_sla *sla, + struct adf_rl_sla_input_data *sla_in, + bool is_update) +{ + u32 max_val = rl_data->device_data->scale_ref; + struct rl_sla *parent = sla->parent; + bool ret = true; + + if (sla_in->cir > max_val || sla_in->pir > max_val) + ret = false; + + switch (sla->type) { + case RL_LEAF: + ret &= can_parent_afford_sla(sla_in, parent, sla->cir, + is_update); + break; + case RL_CLUSTER: + ret &= can_parent_afford_sla(sla_in, parent, sla->cir, + is_update); + + if (is_update) + ret &= can_node_afford_update(sla_in, sla); + + break; + case RL_ROOT: + if (is_update) + ret &= can_node_afford_update(sla_in, sla); + + break; + default: + ret = false; + break; + } + + return ret; +} + +static void update_budget(struct rl_sla *sla, u32 old_cir, bool is_update) +{ + switch (sla->type) { + case RL_LEAF: + if (is_update) + sla->parent->rem_cir += old_cir; + + sla->parent->rem_cir -= sla->cir; + sla->rem_cir = 0; + break; + case RL_CLUSTER: + if (is_update) { + sla->parent->rem_cir += old_cir; + sla->rem_cir = sla->cir - (old_cir - sla->rem_cir); + } else { + sla->rem_cir = sla->cir; + } + + sla->parent->rem_cir -= sla->cir; + break; + case RL_ROOT: + if (is_update) + sla->rem_cir = sla->cir - (old_cir - sla->rem_cir); + else + sla->rem_cir = sla->cir; + break; + default: + break; + } +} + +/** + * get_next_free_sla_id() - finds next free ID in the SLA array + * @rl_data: Pointer to ratelimiting data structure + * + * Return: + * * 0 : RL_NODES_CNT_MAX - correct ID + * * -ENOSPC - all SLA slots are in use + */ +static int get_next_free_sla_id(struct adf_rl *rl_data) +{ + int i = 0; + + while (i < RL_NODES_CNT_MAX && rl_data->sla[i++]) + ; + + if (i == RL_NODES_CNT_MAX) + return -ENOSPC; + + return i - 1; +} + +/** + * get_next_free_node_id() - finds next free ID in the array of that node type + * @rl_data: Pointer to ratelimiting data structure + * @sla: Pointer to SLA object for which the ID is searched + * + * Return: + * * 0 : RL_[NODE_TYPE]_MAX - correct ID + * * -ENOSPC - all slots of that type are in use + */ +static int get_next_free_node_id(struct adf_rl *rl_data, struct rl_sla *sla) +{ + struct adf_hw_device_data *hw_device = GET_HW_DATA(rl_data->accel_dev); + int max_id, i, step, rp_per_leaf; + struct rl_sla **sla_list; + + rp_per_leaf = hw_device->num_banks / hw_device->num_banks_per_vf; + + /* + * Static nodes mapping: + * root0 - cluster[0,4,8,12] - leaf[0-15] + * root1 - cluster[1,5,9,13] - leaf[16-31] + * root2 - cluster[2,6,10,14] - leaf[32-47] + */ + switch (sla->type) { + case RL_LEAF: + i = sla->srv * rp_per_leaf; + step = 1; + max_id = i + rp_per_leaf; + sla_list = rl_data->leaf; + break; + case RL_CLUSTER: + i = sla->srv; + step = 4; + max_id = RL_CLUSTER_MAX; + sla_list = rl_data->cluster; + break; + case RL_ROOT: + return sla->srv; + default: + return -EINVAL; + } + + while (i < max_id && sla_list[i]) + i += step; + + if (i >= max_id) + return -ENOSPC; + + return i; +} + +u32 adf_rl_calculate_slice_tokens(struct adf_accel_dev *accel_dev, u32 sla_val, + enum adf_base_services svc_type) +{ + struct adf_rl_hw_data *device_data = &accel_dev->hw_device->rl_data; + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); + u64 avail_slice_cycles, allocated_tokens; + + if (!sla_val) + return 0; + + avail_slice_cycles = hw_data->clock_frequency; + + switch (svc_type) { + case ADF_SVC_ASYM: + avail_slice_cycles *= device_data->slices.pke_cnt; + break; + case ADF_SVC_SYM: + avail_slice_cycles *= device_data->slices.cph_cnt; + break; + case ADF_SVC_DC: + avail_slice_cycles *= device_data->slices.dcpr_cnt; + break; + default: + break; + } + + do_div(avail_slice_cycles, device_data->scan_interval); + allocated_tokens = avail_slice_cycles * sla_val; + do_div(allocated_tokens, device_data->scale_ref); + + return allocated_tokens; +} + +u32 adf_rl_calculate_ae_cycles(struct adf_accel_dev *accel_dev, u32 sla_val, + enum adf_base_services svc_type) +{ + struct adf_rl_hw_data *device_data = &accel_dev->hw_device->rl_data; + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); + u64 allocated_ae_cycles, avail_ae_cycles; + + if (!sla_val) + return 0; + + avail_ae_cycles = hw_data->clock_frequency; + avail_ae_cycles *= hw_data->get_num_aes(hw_data) - 1; + do_div(avail_ae_cycles, device_data->scan_interval); + + sla_val *= device_data->max_tp[svc_type]; + sla_val /= device_data->scale_ref; + + allocated_ae_cycles = (sla_val * avail_ae_cycles); + do_div(allocated_ae_cycles, device_data->max_tp[svc_type]); + + return allocated_ae_cycles; +} + +u32 adf_rl_calculate_pci_bw(struct adf_accel_dev *accel_dev, u32 sla_val, + enum adf_base_services svc_type, bool is_bw_out) +{ + struct adf_rl_hw_data *device_data = &accel_dev->hw_device->rl_data; + u64 sla_to_bytes, allocated_bw, sla_scaled; + + if (!sla_val) + return 0; + + sla_to_bytes = sla_val; + sla_to_bytes *= device_data->max_tp[svc_type]; + do_div(sla_to_bytes, device_data->scale_ref); + + sla_to_bytes *= (svc_type == ADF_SVC_ASYM) ? RL_TOKEN_ASYM_SIZE : + BYTES_PER_MBIT; + if (svc_type == ADF_SVC_DC && is_bw_out) + sla_to_bytes *= device_data->slices.dcpr_cnt - + device_data->dcpr_correction; + + sla_scaled = sla_to_bytes * device_data->pcie_scale_mul; + do_div(sla_scaled, device_data->pcie_scale_div); + allocated_bw = sla_scaled; + do_div(allocated_bw, RL_TOKEN_PCIE_SIZE); + do_div(allocated_bw, device_data->scan_interval); + + return allocated_bw; +} + +/** + * add_new_sla_entry() - creates a new SLA object and fills it with user data + * @accel_dev: pointer to acceleration device structure + * @sla_in: pointer to user input data for a new SLA + * @sla_out: Pointer to variable that will contain the address of a new + * SLA object if the operation succeeds + * + * Return: + * * 0 - ok + * * -ENOMEM - memory allocation failed + * * -EINVAL - invalid user input + * * -ENOSPC - all available SLAs are in use + */ +static int add_new_sla_entry(struct adf_accel_dev *accel_dev, + struct adf_rl_sla_input_data *sla_in, + struct rl_sla **sla_out) +{ + struct adf_rl *rl_data = accel_dev->rate_limiting; + struct rl_sla *sla; + int ret = 0; + + sla = kzalloc(sizeof(*sla), GFP_KERNEL); + if (!sla) { + ret = -ENOMEM; + goto ret_err; + } + *sla_out = sla; + + if (!is_service_enabled(accel_dev, sla_in->srv)) { + dev_notice(&GET_DEV(accel_dev), + "Provided service is not enabled\n"); + ret = -EINVAL; + goto ret_err; + } + + sla->srv = sla_in->srv; + sla->type = sla_in->type; + ret = get_next_free_node_id(rl_data, sla); + if (ret < 0) { + dev_notice(&GET_DEV(accel_dev), + "Exceeded number of available nodes for that service\n"); + goto ret_err; + } + sla->node_id = ret; + + ret = get_next_free_sla_id(rl_data); + if (ret < 0) { + dev_notice(&GET_DEV(accel_dev), + "Allocated maximum SLAs number\n"); + goto ret_err; + } + sla->sla_id = ret; + + sla->parent = find_parent(rl_data, sla_in); + if (!sla->parent && sla->type != RL_ROOT) { + if (sla_in->parent_id != RL_PARENT_DEFAULT_ID) + dev_notice(&GET_DEV(accel_dev), + "Provided parent ID does not exist or cannot be parent for this SLA."); + else + dev_notice(&GET_DEV(accel_dev), + "Unable to find parent node for this service. Is service enabled?"); + ret = -EINVAL; + goto ret_err; + } + + if (sla->type == RL_LEAF) { + ret = prepare_rp_ids(accel_dev, sla, sla_in->rp_mask); + if (!sla->ring_pairs_cnt || ret) { + dev_notice(&GET_DEV(accel_dev), + "Unable to find ring pairs to assign to the leaf"); + if (!ret) + ret = -EINVAL; + + goto ret_err; + } + } + + return 0; + +ret_err: + kfree(sla); + *sla_out = NULL; + + return ret; +} + +static int initialize_default_nodes(struct adf_accel_dev *accel_dev) +{ + struct adf_rl *rl_data = accel_dev->rate_limiting; + struct adf_rl_hw_data *device_data = rl_data->device_data; + struct adf_rl_sla_input_data sla_in = { }; + int ret = 0; + int i; + + /* Init root for each enabled service */ + sla_in.type = RL_ROOT; + sla_in.parent_id = RL_PARENT_DEFAULT_ID; + + for (i = 0; i < ADF_SVC_NONE; i++) { + if (!is_service_enabled(accel_dev, i)) + continue; + + sla_in.cir = device_data->scale_ref; + sla_in.pir = sla_in.cir; + sla_in.srv = i; + + ret = adf_rl_add_sla(accel_dev, &sla_in); + if (ret) + return ret; + } + + /* Init default cluster for each root */ + sla_in.type = RL_CLUSTER; + for (i = 0; i < ADF_SVC_NONE; i++) { + if (!rl_data->root[i]) + continue; + + sla_in.cir = rl_data->root[i]->cir; + sla_in.pir = sla_in.cir; + sla_in.srv = rl_data->root[i]->srv; + + ret = adf_rl_add_sla(accel_dev, &sla_in); + if (ret) + return ret; + } + + return 0; +} + +static void clear_sla(struct adf_rl *rl_data, struct rl_sla *sla) +{ + bool *rp_in_use = rl_data->rp_in_use; + struct rl_sla **sla_type_arr = NULL; + int i, sla_id, node_id; + u32 old_cir; + + sla_id = sla->sla_id; + node_id = sla->node_id; + old_cir = sla->cir; + sla->cir = 0; + sla->pir = 0; + + for (i = 0; i < sla->ring_pairs_cnt; i++) + rp_in_use[sla->ring_pairs_ids[i]] = false; + + update_budget(sla, old_cir, true); + get_sla_arr_of_type(rl_data, sla->type, &sla_type_arr); + assign_node_to_parent(rl_data->accel_dev, sla, true); + adf_rl_send_admin_delete_msg(rl_data->accel_dev, node_id, sla->type); + mark_rps_usage(sla, rl_data->rp_in_use, false); + + kfree(sla); + rl_data->sla[sla_id] = NULL; + sla_type_arr[node_id] = NULL; +} + +/** + * add_update_sla() - handles the creation and the update of an SLA + * @accel_dev: pointer to acceleration device structure + * @sla_in: pointer to user input data for a new/updated SLA + * @is_update: flag to indicate if this is an update or an add operation + * + * Return: + * * 0 - ok + * * -ENOMEM - memory allocation failed + * * -EINVAL - user input data cannot be used to create SLA + * * -ENOSPC - all available SLAs are in use + */ +static int add_update_sla(struct adf_accel_dev *accel_dev, + struct adf_rl_sla_input_data *sla_in, bool is_update) +{ + struct adf_rl *rl_data = accel_dev->rate_limiting; + struct rl_sla **sla_type_arr = NULL; + struct rl_sla *sla = NULL; + u32 old_cir = 0; + int ret; + + if (!sla_in) { + dev_warn(&GET_DEV(accel_dev), + "SLA input data pointer is missing\n"); + ret = -EFAULT; + goto ret_err; + } + + /* Input validation */ + ret = validate_user_input(accel_dev, sla_in, is_update); + if (ret) + goto ret_err; + + mutex_lock(&rl_data->rl_lock); + + if (is_update) { + ret = validate_sla_id(accel_dev, sla_in->sla_id); + if (ret) + goto ret_err; + + sla = rl_data->sla[sla_in->sla_id]; + old_cir = sla->cir; + } else { + ret = add_new_sla_entry(accel_dev, sla_in, &sla); + if (ret) + goto ret_err; + } + + if (!is_enough_budget(rl_data, sla, sla_in, is_update)) { + dev_notice(&GET_DEV(accel_dev), + "Input value exceeds the remaining budget%s\n", + is_update ? " or more budget is already in use" : ""); + ret = -EINVAL; + goto ret_err; + } + sla->cir = sla_in->cir; + sla->pir = sla_in->pir; + + /* Apply SLA */ + assign_node_to_parent(accel_dev, sla, false); + ret = adf_rl_send_admin_add_update_msg(accel_dev, sla, is_update); + if (ret) { + dev_notice(&GET_DEV(accel_dev), + "Failed to apply an SLA\n"); + goto ret_err; + } + update_budget(sla, old_cir, is_update); + + if (!is_update) { + mark_rps_usage(sla, rl_data->rp_in_use, true); + get_sla_arr_of_type(rl_data, sla->type, &sla_type_arr); + sla_type_arr[sla->node_id] = sla; + rl_data->sla[sla->sla_id] = sla; + } + + sla_in->sla_id = sla->sla_id; + goto ret_ok; + +ret_err: + if (!is_update) { + sla_in->sla_id = -1; + kfree(sla); + } +ret_ok: + mutex_unlock(&rl_data->rl_lock); + return ret; +} + +/** + * adf_rl_add_sla() - handles the creation of an SLA + * @accel_dev: pointer to acceleration device structure + * @sla_in: pointer to user input data required to add an SLA + * + * Return: + * * 0 - ok + * * -ENOMEM - memory allocation failed + * * -EINVAL - invalid user input + * * -ENOSPC - all available SLAs are in use + */ +int adf_rl_add_sla(struct adf_accel_dev *accel_dev, + struct adf_rl_sla_input_data *sla_in) +{ + return add_update_sla(accel_dev, sla_in, false); +} + +/** + * adf_rl_update_sla() - handles the update of an SLA + * @accel_dev: pointer to acceleration device structure + * @sla_in: pointer to user input data required to update an SLA + * + * Return: + * * 0 - ok + * * -EINVAL - user input data cannot be used to update SLA + */ +int adf_rl_update_sla(struct adf_accel_dev *accel_dev, + struct adf_rl_sla_input_data *sla_in) +{ + return add_update_sla(accel_dev, sla_in, true); +} + +/** + * adf_rl_get_sla() - returns an existing SLA data + * @accel_dev: pointer to acceleration device structure + * @sla_in: pointer to user data where SLA info will be stored + * + * The sla_id for which data are requested should be set in sla_id structure + * + * Return: + * * 0 - ok + * * -EINVAL - provided sla_id does not exist + */ +int adf_rl_get_sla(struct adf_accel_dev *accel_dev, + struct adf_rl_sla_input_data *sla_in) +{ + struct rl_sla *sla; + int ret, i; + + ret = validate_sla_id(accel_dev, sla_in->sla_id); + if (ret) + return ret; + + sla = accel_dev->rate_limiting->sla[sla_in->sla_id]; + sla_in->type = sla->type; + sla_in->srv = sla->srv; + sla_in->cir = sla->cir; + sla_in->pir = sla->pir; + sla_in->rp_mask = 0U; + if (sla->parent) + sla_in->parent_id = sla->parent->sla_id; + else + sla_in->parent_id = RL_PARENT_DEFAULT_ID; + + for (i = 0; i < sla->ring_pairs_cnt; i++) + sla_in->rp_mask |= BIT(sla->ring_pairs_ids[i]); + + return 0; +} + +/** + * adf_rl_get_capability_remaining() - returns the remaining SLA value (CIR) for + * selected service or provided sla_id + * @accel_dev: pointer to acceleration device structure + * @srv: service ID for which capability is requested + * @sla_id: ID of the cluster or root to which we want assign a new SLA + * + * Check if the provided SLA id is valid. If it is and the service matches + * the requested service and the type is cluster or root, return the remaining + * capability. + * If the provided ID does not match the service or type, return the remaining + * capacity of the default cluster for that service. + * + * Return: + * * Positive value - correct remaining value + * * -EINVAL - algorithm cannot find a remaining value for provided data + */ +int adf_rl_get_capability_remaining(struct adf_accel_dev *accel_dev, + enum adf_base_services srv, int sla_id) +{ + struct adf_rl *rl_data = accel_dev->rate_limiting; + struct rl_sla *sla = NULL; + int i; + + if (srv >= ADF_SVC_NONE) + return -EINVAL; + + if (sla_id > RL_SLA_EMPTY_ID && !validate_sla_id(accel_dev, sla_id)) { + sla = rl_data->sla[sla_id]; + + if (sla->srv == srv && sla->type <= RL_CLUSTER) + goto ret_ok; + } + + for (i = 0; i < RL_CLUSTER_MAX; i++) { + if (!rl_data->cluster[i]) + continue; + + if (rl_data->cluster[i]->srv == srv) { + sla = rl_data->cluster[i]; + goto ret_ok; + } + } + + return -EINVAL; +ret_ok: + return sla->rem_cir; +} + +/** + * adf_rl_remove_sla() - removes provided sla_id + * @accel_dev: pointer to acceleration device structure + * @sla_id: ID of the cluster or root to which we want assign an new SLA + * + * Return: + * * 0 - ok + * * -EINVAL - wrong sla_id or it still have assigned children + */ +int adf_rl_remove_sla(struct adf_accel_dev *accel_dev, u32 sla_id) +{ + struct adf_rl *rl_data = accel_dev->rate_limiting; + struct rl_sla *sla; + int ret = 0; + + mutex_lock(&rl_data->rl_lock); + ret = validate_sla_id(accel_dev, sla_id); + if (ret) + goto err_ret; + + sla = rl_data->sla[sla_id]; + + if (sla->type < RL_LEAF && sla->rem_cir != sla->cir) { + dev_notice(&GET_DEV(accel_dev), + "To remove parent SLA all its children must be removed first"); + ret = -EINVAL; + goto err_ret; + } + + clear_sla(rl_data, sla); + +err_ret: + mutex_unlock(&rl_data->rl_lock); + return ret; +} + +/** + * adf_rl_remove_sla_all() - removes all SLAs from device + * @accel_dev: pointer to acceleration device structure + * @incl_default: set to true if default SLAs also should be removed + */ +void adf_rl_remove_sla_all(struct adf_accel_dev *accel_dev, bool incl_default) +{ + struct adf_rl *rl_data = accel_dev->rate_limiting; + int end_type = incl_default ? RL_ROOT : RL_LEAF; + struct rl_sla **sla_type_arr = NULL; + u32 max_id; + int i, j; + + mutex_lock(&rl_data->rl_lock); + + /* Unregister and remove all SLAs */ + for (j = RL_LEAF; j >= end_type; j--) { + max_id = get_sla_arr_of_type(rl_data, j, &sla_type_arr); + + for (i = 0; i < max_id; i++) { + if (!sla_type_arr[i]) + continue; + + clear_sla(rl_data, sla_type_arr[i]); + } + } + + mutex_unlock(&rl_data->rl_lock); +} + +int adf_rl_init(struct adf_accel_dev *accel_dev) +{ + struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev); + struct adf_rl_hw_data *rl_hw_data = &hw_data->rl_data; + struct adf_rl *rl; + int ret = 0; + + /* Validate device parameters */ + if (RL_VALIDATE_NON_ZERO(rl_hw_data->max_tp[ADF_SVC_ASYM]) || + RL_VALIDATE_NON_ZERO(rl_hw_data->max_tp[ADF_SVC_SYM]) || + RL_VALIDATE_NON_ZERO(rl_hw_data->max_tp[ADF_SVC_DC]) || + RL_VALIDATE_NON_ZERO(rl_hw_data->scan_interval) || + RL_VALIDATE_NON_ZERO(rl_hw_data->pcie_scale_div) || + RL_VALIDATE_NON_ZERO(rl_hw_data->pcie_scale_mul) || + RL_VALIDATE_NON_ZERO(rl_hw_data->scale_ref)) { + ret = -EOPNOTSUPP; + goto err_ret; + } + + rl = kzalloc(sizeof(*rl), GFP_KERNEL); + if (!rl) { + ret = -ENOMEM; + goto err_ret; + } + + mutex_init(&rl->rl_lock); + rl->device_data = &accel_dev->hw_device->rl_data; + rl->accel_dev = accel_dev; + accel_dev->rate_limiting = rl; + +err_ret: + return ret; +} + +int adf_rl_start(struct adf_accel_dev *accel_dev) +{ + struct adf_rl_hw_data *rl_hw_data = &GET_HW_DATA(accel_dev)->rl_data; + void __iomem *pmisc_addr = adf_get_pmisc_base(accel_dev); + u16 fw_caps = GET_HW_DATA(accel_dev)->fw_capabilities; + int ret; + + if (!accel_dev->rate_limiting) { + ret = -EOPNOTSUPP; + goto ret_err; + } + + if ((fw_caps & RL_CAPABILITY_MASK) != RL_CAPABILITY_VALUE) { + dev_info(&GET_DEV(accel_dev), "not supported\n"); + ret = -EOPNOTSUPP; + goto ret_free; + } + + ADF_CSR_WR(pmisc_addr, rl_hw_data->pciin_tb_offset, + RL_TOKEN_GRANULARITY_PCIEIN_BUCKET); + ADF_CSR_WR(pmisc_addr, rl_hw_data->pciout_tb_offset, + RL_TOKEN_GRANULARITY_PCIEOUT_BUCKET); + + ret = adf_rl_send_admin_init_msg(accel_dev, &rl_hw_data->slices); + if (ret) { + dev_err(&GET_DEV(accel_dev), "initialization failed\n"); + goto ret_free; + } + + ret = initialize_default_nodes(accel_dev); + if (ret) { + dev_err(&GET_DEV(accel_dev), + "failed to initialize default SLAs\n"); + goto ret_sla_rm; + } + + return 0; + +ret_sla_rm: + adf_rl_remove_sla_all(accel_dev, true); +ret_free: + kfree(accel_dev->rate_limiting); + accel_dev->rate_limiting = NULL; +ret_err: + return ret; +} + +void adf_rl_stop(struct adf_accel_dev *accel_dev) +{ + if (!accel_dev->rate_limiting) + return; + + adf_rl_remove_sla_all(accel_dev, true); +} + +void adf_rl_exit(struct adf_accel_dev *accel_dev) +{ + if (!accel_dev->rate_limiting) + return; + + kfree(accel_dev->rate_limiting); + accel_dev->rate_limiting = NULL; +} diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl.h b/drivers/crypto/intel/qat/qat_common/adf_rl.h new file mode 100644 index 000000000000..1ccb6613c92e --- /dev/null +++ b/drivers/crypto/intel/qat/qat_common/adf_rl.h @@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2023 Intel Corporation */ + +#ifndef ADF_RL_H_ +#define ADF_RL_H_ + +#include +#include + +struct adf_accel_dev; + +#define RL_ROOT_MAX 4 +#define RL_CLUSTER_MAX 16 +#define RL_LEAF_MAX 64 +#define RL_NODES_CNT_MAX (RL_ROOT_MAX + RL_CLUSTER_MAX + RL_LEAF_MAX) +#define RL_RP_CNT_PER_LEAF_MAX 4U +#define RL_RP_CNT_MAX 64 +#define RL_SLA_EMPTY_ID -1 +#define RL_PARENT_DEFAULT_ID -1 + +enum rl_node_type { + RL_ROOT, + RL_CLUSTER, + RL_LEAF, +}; + +enum adf_base_services { + ADF_SVC_ASYM = 0, + ADF_SVC_SYM, + ADF_SVC_DC, + ADF_SVC_NONE, +}; + +/** + * struct adf_rl_sla_input_data - ratelimiting user input data structure + * @rp_mask: 64 bit bitmask of ring pair IDs which will be assigned to SLA. + * Eg. 0x5 -> RP0 and RP2 assigned; 0xA005 -> RP0,2,13,15 assigned. + * @sla_id: ID of current SLA for operations update, rm, get. For the add + * operation, this field will be updated with the ID of the newly + * added SLA + * @parent_id: ID of the SLA to which the current one should be assigned. + * Set to -1 to refer to the default parent. + * @cir: Committed information rate. Rate guaranteed to be achieved. Input value + * is expressed in permille scale, i.e. 1000 refers to the maximum + * device throughput for a selected service. + * @pir: Peak information rate. Maximum rate available that the SLA can achieve. + * Input value is expressed in permille scale, i.e. 1000 refers to + * the maximum device throughput for a selected service. + * @type: SLA type: root, cluster, node + * @srv: Service associated to the SLA: asym, sym dc. + * + * This structure is used to perform operations on an SLA. + * Depending on the operation, some of the parameters are ignored. + * The following list reports which parameters should be set for each operation. + * - add: all except sla_id + * - update: cir, pir, sla_id + * - rm: sla_id + * - rm_all: - + * - get: sla_id + * - get_capability_rem: srv, sla_id + */ +struct adf_rl_sla_input_data { + u64 rp_mask; + int sla_id; + int parent_id; + unsigned int cir; + unsigned int pir; + enum rl_node_type type; + enum adf_base_services srv; +}; + +struct rl_slice_cnt { + u8 dcpr_cnt; + u8 pke_cnt; + u8 cph_cnt; +}; + +struct adf_rl_hw_data { + u32 scale_ref; + u32 scan_interval; + u32 r2l_offset; + u32 l2c_offset; + u32 c2s_offset; + u32 pciin_tb_offset; + u32 pciout_tb_offset; + u32 pcie_scale_mul; + u32 pcie_scale_div; + u32 dcpr_correction; + u32 max_tp[RL_ROOT_MAX]; + struct rl_slice_cnt slices; +}; + +/** + * struct adf_rl - ratelimiting data structure + * @accel_dev: pointer to acceleration device data + * @device_data: pointer to rate limiting data specific to a device type (or revision) + * @sla: array of pointers to SLA objects + * @root: array of pointers to root type SLAs, element number reflects node_id + * @cluster: array of pointers to cluster type SLAs, element number reflects node_id + * @leaf: array of pointers to leaf type SLAs, element number reflects node_id + * @rp_in_use: array of ring pair IDs already used in one of SLAs + * @rl_lock: mutex object which is protecting data in this structure + * @input: structure which is used for holding the data received from user + */ +struct adf_rl { + struct adf_accel_dev *accel_dev; + struct adf_rl_hw_data *device_data; + /* mapping sla_id to SLA objects */ + struct rl_sla *sla[RL_NODES_CNT_MAX]; + struct rl_sla *root[RL_ROOT_MAX]; + struct rl_sla *cluster[RL_CLUSTER_MAX]; + struct rl_sla *leaf[RL_LEAF_MAX]; + bool rp_in_use[RL_RP_CNT_MAX]; + /* Mutex protecting writing to SLAs lists */ + struct mutex rl_lock; +}; + +/** + * struct rl_sla - SLA object data structure + * @parent: pointer to the parent SLA (root/cluster) + * @type: SLA type + * @srv: service associated with this SLA + * @sla_id: ID of the SLA, used as element number in SLA array and as identifier + * shared with the user + * @node_id: ID of node, each of SLA type have a separate ID list + * @cir: committed information rate + * @pir: peak information rate (PIR >= CIR) + * @rem_cir: if this SLA is a parent then this field represents a remaining + * value to be used by child SLAs. + * @ring_pairs_ids: array with numeric ring pairs IDs assigned to this SLA + * @ring_pairs_cnt: number of assigned ring pairs listed in the array above + */ +struct rl_sla { + struct rl_sla *parent; + enum rl_node_type type; + enum adf_base_services srv; + u32 sla_id; + u32 node_id; + u32 cir; + u32 pir; + u32 rem_cir; + u16 ring_pairs_ids[RL_RP_CNT_PER_LEAF_MAX]; + u16 ring_pairs_cnt; +}; + +int adf_rl_add_sla(struct adf_accel_dev *accel_dev, + struct adf_rl_sla_input_data *sla_in); +int adf_rl_update_sla(struct adf_accel_dev *accel_dev, + struct adf_rl_sla_input_data *sla_in); +int adf_rl_get_sla(struct adf_accel_dev *accel_dev, + struct adf_rl_sla_input_data *sla_in); +int adf_rl_get_capability_remaining(struct adf_accel_dev *accel_dev, + enum adf_base_services srv, int sla_id); +int adf_rl_remove_sla(struct adf_accel_dev *accel_dev, u32 sla_id); +void adf_rl_remove_sla_all(struct adf_accel_dev *accel_dev, bool incl_default); + +int adf_rl_init(struct adf_accel_dev *accel_dev); +int adf_rl_start(struct adf_accel_dev *accel_dev); +void adf_rl_stop(struct adf_accel_dev *accel_dev); +void adf_rl_exit(struct adf_accel_dev *accel_dev); + +u32 adf_rl_calculate_pci_bw(struct adf_accel_dev *accel_dev, u32 sla_val, + enum adf_base_services svc_type, bool is_bw_out); +u32 adf_rl_calculate_ae_cycles(struct adf_accel_dev *accel_dev, u32 sla_val, + enum adf_base_services svc_type); +u32 adf_rl_calculate_slice_tokens(struct adf_accel_dev *accel_dev, u32 sla_val, + enum adf_base_services svc_type); + +#endif /* ADF_RL_H_ */ diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl_admin.c b/drivers/crypto/intel/qat/qat_common/adf_rl_admin.c new file mode 100644 index 000000000000..698a14f4ce66 --- /dev/null +++ b/drivers/crypto/intel/qat/qat_common/adf_rl_admin.c @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright(c) 2023 Intel Corporation */ + +#include +#include + +#include "adf_admin.h" +#include "adf_accel_devices.h" +#include "adf_rl_admin.h" + +static void +prep_admin_req_msg(struct rl_sla *sla, dma_addr_t dma_addr, + struct icp_qat_fw_init_admin_sla_config_params *fw_params, + struct icp_qat_fw_init_admin_req *req, bool is_update) +{ + req->cmd_id = is_update ? ICP_QAT_FW_RL_UPDATE : ICP_QAT_FW_RL_ADD; + req->init_cfg_ptr = dma_addr; + req->init_cfg_sz = sizeof(*fw_params); + req->node_id = sla->node_id; + req->node_type = sla->type; + req->rp_count = sla->ring_pairs_cnt; + req->svc_type = sla->srv; +} + +static void +prep_admin_req_params(struct adf_accel_dev *accel_dev, struct rl_sla *sla, + struct icp_qat_fw_init_admin_sla_config_params *fw_params) +{ + fw_params->pcie_in_cir = + adf_rl_calculate_pci_bw(accel_dev, sla->cir, sla->srv, false); + fw_params->pcie_in_pir = + adf_rl_calculate_pci_bw(accel_dev, sla->pir, sla->srv, false); + fw_params->pcie_out_cir = + adf_rl_calculate_pci_bw(accel_dev, sla->cir, sla->srv, true); + fw_params->pcie_out_pir = + adf_rl_calculate_pci_bw(accel_dev, sla->pir, sla->srv, true); + + fw_params->slice_util_cir = + adf_rl_calculate_slice_tokens(accel_dev, sla->cir, sla->srv); + fw_params->slice_util_pir = + adf_rl_calculate_slice_tokens(accel_dev, sla->pir, sla->srv); + + fw_params->ae_util_cir = + adf_rl_calculate_ae_cycles(accel_dev, sla->cir, sla->srv); + fw_params->ae_util_pir = + adf_rl_calculate_ae_cycles(accel_dev, sla->pir, sla->srv); + + memcpy(fw_params->rp_ids, sla->ring_pairs_ids, + sizeof(sla->ring_pairs_ids)); +} + +int adf_rl_send_admin_init_msg(struct adf_accel_dev *accel_dev, + struct rl_slice_cnt *slices_int) +{ + struct icp_qat_fw_init_admin_slice_cnt slices_resp = { }; + int ret; + + ret = adf_send_admin_rl_init(accel_dev, &slices_resp); + if (ret) + return ret; + + slices_int->dcpr_cnt = slices_resp.dcpr_cnt; + slices_int->pke_cnt = slices_resp.pke_cnt; + /* For symmetric crypto, slice tokens are relative to the UCS slice */ + slices_int->cph_cnt = slices_resp.ucs_cnt; + + return 0; +} + +int adf_rl_send_admin_add_update_msg(struct adf_accel_dev *accel_dev, + struct rl_sla *sla, bool is_update) +{ + struct icp_qat_fw_init_admin_sla_config_params *fw_params; + struct icp_qat_fw_init_admin_req req = { }; + dma_addr_t dma_addr; + int ret; + + fw_params = dma_alloc_coherent(&GET_DEV(accel_dev), sizeof(*fw_params), + &dma_addr, GFP_KERNEL); + if (!fw_params) + return -ENOMEM; + + prep_admin_req_params(accel_dev, sla, fw_params); + prep_admin_req_msg(sla, dma_addr, fw_params, &req, is_update); + ret = adf_send_admin_rl_add_update(accel_dev, &req); + + dma_free_coherent(&GET_DEV(accel_dev), sizeof(*fw_params), fw_params, + dma_addr); + + return ret; +} + +int adf_rl_send_admin_delete_msg(struct adf_accel_dev *accel_dev, u16 node_id, + u8 node_type) +{ + return adf_send_admin_rl_delete(accel_dev, node_id, node_type); +} diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl_admin.h b/drivers/crypto/intel/qat/qat_common/adf_rl_admin.h new file mode 100644 index 000000000000..dd5419b7e896 --- /dev/null +++ b/drivers/crypto/intel/qat/qat_common/adf_rl_admin.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2023 Intel Corporation */ + +#ifndef ADF_RL_ADMIN_H_ +#define ADF_RL_ADMIN_H_ + +#include + +#include "adf_rl.h" + +int adf_rl_send_admin_init_msg(struct adf_accel_dev *accel_dev, + struct rl_slice_cnt *slices_int); +int adf_rl_send_admin_add_update_msg(struct adf_accel_dev *accel_dev, + struct rl_sla *sla, bool is_update); +int adf_rl_send_admin_delete_msg(struct adf_accel_dev *accel_dev, u16 node_id, + u8 node_type); + +#endif /* ADF_RL_ADMIN_H_ */ diff --git a/drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h b/drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h index e4de9a30e0bd..cd418b51d9f3 100644 --- a/drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h +++ b/drivers/crypto/intel/qat/qat_common/icp_qat_fw_init_admin.h @@ -5,6 +5,8 @@ #include "icp_qat_fw.h" +#define RL_MAX_RP_IDS 16 + enum icp_qat_fw_init_admin_cmd_id { ICP_QAT_FW_INIT_AE = 0, ICP_QAT_FW_TRNG_ENABLE = 1, @@ -19,10 +21,14 @@ enum icp_qat_fw_init_admin_cmd_id { ICP_QAT_FW_CRYPTO_CAPABILITY_GET = 10, ICP_QAT_FW_DC_CHAIN_INIT = 11, ICP_QAT_FW_HEARTBEAT_TIMER_SET = 13, + ICP_QAT_FW_RL_INIT = 15, ICP_QAT_FW_TIMER_GET = 19, ICP_QAT_FW_CNV_STATS_GET = 20, ICP_QAT_FW_PM_STATE_CONFIG = 128, ICP_QAT_FW_PM_INFO = 129, + ICP_QAT_FW_RL_ADD = 134, + ICP_QAT_FW_RL_UPDATE = 135, + ICP_QAT_FW_RL_REMOVE = 136, }; enum icp_qat_fw_init_admin_resp_status { @@ -30,6 +36,30 @@ enum icp_qat_fw_init_admin_resp_status { ICP_QAT_FW_INIT_RESP_STATUS_FAIL }; +struct icp_qat_fw_init_admin_slice_cnt { + __u8 cpr_cnt; + __u8 xlt_cnt; + __u8 dcpr_cnt; + __u8 pke_cnt; + __u8 wat_cnt; + __u8 wcp_cnt; + __u8 ucs_cnt; + __u8 cph_cnt; + __u8 ath_cnt; +}; + +struct icp_qat_fw_init_admin_sla_config_params { + __u32 pcie_in_cir; + __u32 pcie_in_pir; + __u32 pcie_out_cir; + __u32 pcie_out_pir; + __u32 slice_util_cir; + __u32 slice_util_pir; + __u32 ae_util_cir; + __u32 ae_util_pir; + __u16 rp_ids[RL_MAX_RP_IDS]; +}; + struct icp_qat_fw_init_admin_req { __u16 init_cfg_sz; __u8 resrvd1; @@ -49,6 +79,13 @@ struct icp_qat_fw_init_admin_req { struct { __u32 heartbeat_ticks; }; + struct { + __u16 node_id; + __u8 node_type; + __u8 svc_type; + __u8 resrvd5[3]; + __u8 rp_count; + }; __u32 idle_filter; }; @@ -110,6 +147,7 @@ struct icp_qat_fw_init_admin_resp { __u32 unsuccessful_count; __u64 resrvd8; }; + struct icp_qat_fw_init_admin_slice_cnt slices; __u16 fw_capabilities; }; } __packed; From patchwork Fri Oct 20 13:49:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430776 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 34DF9C0032E for ; Fri, 20 Oct 2023 13:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377489AbjJTNuw (ORCPT ); Fri, 20 Oct 2023 09:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377423AbjJTNuu (ORCPT ); Fri, 20 Oct 2023 09:50:50 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2EFBD63 for ; Fri, 20 Oct 2023 06:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809846; x=1729345846; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ih+TNGFG1SZvhbhGDNZBFXChqR9knbofk+GpmvYD+Xk=; b=fOS+zrgztxWqVUWJy1BB4e5uvOyVaVlLtOodi8fJSM3mGBQwFDqX17qP mrKihC19NtqeDl90ZKd4DXSN/ETMnLMtYvOhHIdNMeYiqoPCSLmtNGM7n YfxuBPct9KzJk5hjDImAr7nwRvrrdHAqFNXmCh1QsmnLTC8vhMUmK/Q72 n/7ED9R2U168shh7pIf43Om7tFZZMYTiFIOuiN+HlvWTtdlaMZkgHGEe/ RoDzJI+z2rdWVHOZA2muF8Xo2IIKZhGkWxYJAlkIyzb/4vVSY7433NWJx 2nT+SHa1zcsjZi4yN5zkrA7bnbOvxs/OUT7ICHWvuQTtFL1ORDQXouzxD Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="472721230" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="472721230" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="707231440" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="707231440" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga003.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:45 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:45 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:44 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:44 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D8eyDYtwD8Glt1KSsxI2ZRK1euDjzKtIYXCccG8YY9FT5I/fss1YLg3y/SQ9ypll4xqv+Ek9v4SEeJBwvTvd48fdxbkTp1FQKGT424CybtG4MEubO/zr+9+YvOCIjqUjqUVY7pw1XJ4SvHnRR6c8mDK9psbwyrwKjbFGvYC5wF2GI0JWypQyNhECqqaoCAJxKFVB78QstfsRu8bl5h9LyxEQmfPHA98ogW3qK7PReo52i0fGlwegK1a+qVKhWx5ybdPhgqg+KWy7HgLhC8J/yEofdbaylPFnsUR6stfEEvtMhrHlw7xrItSjNgGajKU6TNjF+JxdJNrueKMTAhmjnA== 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=YhwYDaxu1b9swwymwCTpn/jbyE/vumJ6+qhBY5nuCSo=; b=kS+t8C/zUafDlQMefZJQuhmkD9JsA4q5eaOavO8HvqReA7VqCRjNnJeoKOlsnuR7XKHtUmgNVmF56PRWfXshxuql7GxLkOAAr6gXykLoRJvfB7am+Z5uc3Whmrc4sZ+Ez7GHzqh5i890v9iggaxJuhoLG0t9tSc+5kvPJ7EvbQEmLriISFMCnkwkhPhpZViQKeIOGFTfhFfPb3Y6/k1dVsy7QaIFbth0aYq1y6Lt3Y0J2mfYxh5Mnjhlq9icPHtL66yRTlYxDDPfJV7uurfD0nFIb+zJ0kbEfkakM91o8qzTSTsssD2QuH6YUrNO8LV6phYInvGtvddiS2r/u/nj9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by BL3PR11MB6363.namprd11.prod.outlook.com (2603:10b6:208:3b6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 13:50:34 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:34 +0000 From: Damian Muszynski To: CC: , , Ciunas Bennett , Giovanni Cabiddu , Damian Muszynski , Tero Kristo Subject: [PATCH v2 09/11] crypto: qat - add rate limiting sysfs interface Date: Fri, 20 Oct 2023 15:49:29 +0200 Message-ID: <20231020134931.7530-10-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|BL3PR11MB6363:EE_ X-MS-Office365-Filtering-Correlation-Id: a6fefd83-bdf3-4f72-d1f4-08dbd173887a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rp27yx12G5FXARqZ7PhwxZ0mAyZ6oyJtwEF20ZUKtKppa0/16fmM4BHKTEhagEBjp/8Apq1PrgyxVd9SzCy4gYJNg5r3wcRFARTEkZc958etVbZhfd/6oI++tUw+AzgzJFA8tFaSeqEOTDw0J7fsgzvkIprQm/OIjsvMXU/fvByxoImG7shgQ2DKHKEErY0jdlFZ1I6aSKXpmjbV0Bs3qN5JJ4SzjvpyyATVVt9XNE8vLPVDvTfJ6q8v3tQhEJ09dOyZKw4ykCbGnlHxlpMKUcXWJCKZpg861QJ3vhroQjL9cDupzYcAkZwu2B8ZwH7sYuNHzWRmnrLNGh6VFwUO0Gj9fUnALdapPcxs1vWE94RJmeLL7y7ejy3XVedTPP8LNcTIBELiYRtzTW24yCvoIv765DVVzONCzUqqZWGuTVpOKPFQDMo6jITeJiUIEWMJQaMJy8cJQ9zg3rzXYGQSNOjKLHcrLxevgLBvNt4hfrqLqdoHRPZOwlYH4vcNGAjumxNCYb7owBOxtHCR99vtNa5HpgDu/UjHZCMkew11rwrWMbQA8wnhehgqdvjI8Kto X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(66556008)(6666004)(54906003)(66476007)(478600001)(6916009)(83380400001)(6486002)(66946007)(6512007)(38100700002)(1076003)(41300700001)(26005)(36916002)(316002)(2616005)(6506007)(82960400001)(30864003)(36756003)(86362001)(8676002)(8936002)(44832011)(2906002)(5660300002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TNGhiQkIjTJbXAY2Ach+BxizwBCG3DGiNWNWf/7gaWE5xiAbusXrH8vr/bxWD5HV7HgCIUNQYhfLNqG5ArzmsSvhk8xwko823ytgw7RcqmafkQp7PHb481eqdI7XEVRA3NRmSsjNlChcZimqnnxYpPrQoJMpWi+TtVg7EWxuM2WWY+biUBtzI6Giy7ohZNLWhAdrJz5Q7OSXfmWpxPBUGdu2c9X4sxE0bRhQbRz1GpuZBf2jVSairRBAq7EAx1IUw297R7RF5Jk8bBUgvafHRU87vsKtG/L5v4O5vEHTVtNbOwnR4wmlA8gP7CiZZ6eafDVLcRvGwtCP2mysjzTwqrvEwQTJgW6G+pQluKgCg577Sgel0RmCAAGWZMtRki6OG0IaxDlJ4G0aAsWTaOoke7yVDeNtcQHbgSQ2IdWY8VDOXVjBLDeO3QgqMjTuWkWZzZqiApa+HCa5/nfxnsMRdbQOYE55LfMh7qFNZJRumnpiTF3txrVstHzdX2esAhchNR2N2JIU65DCVv/LyBCchb4yK9DuaQYRpdHA4oY1tPZfsFmqc2gVntwK+AeTYvpHZE8AVSo83B05GdHPtIRuBoxceg2B7mpVayAFSuZ9A8RTOQweUPVk56IT/9dsqCeR3+4eoF4AmC/CD3szp0XniX5Y1MblsBL3sEsOpXB4fV9pU8YO2Qzh6ItiVK6YVbDdHeehU1O0JW2j+StAYOVq2jKKDDivXZ0VmRkAw9m9/z9trxeIuQuGszfYFEVaqZTAuNwuTvtJYElE+a4EpYTbv9Lqr2nZpL7XpLxtziHmw7+dLHcQryiiw+uIFWoyFePNCfJNJoIgUHhwTkMMM3cyXUxYuKum2UpB6sJnRfL5bK146IMBjqOxL9QP6BKC0xJW9O06VXto0sLHLrxgPfSw047ZxWgr9DhYPbqwEKNIXj1wEji7g+4tnGYg9bFequs6xTubYf/jQ8Pw4aYfkm5qRGVUHiYJLvDkKos37wr2Ay25iZqp6nvKZ2+rCHHL9/vaITSlrYTyRrdyIwNrY+cupBw7+xEuBf/lTujm47fUyR3LIeKZeqft2gFPSKEcjq4fQPhaLp9xJyLMieoV4CdendP2eqy7TElz7pegMGPLt6g1sQyFau1sBK+Z3wxKsXQG0+JbaQhQQQSHL0IVSRQ48QXOoYJ1kIHbxdKGe/q5rLO0C09pVNURUZDaVyZAcu/qHk909ovCx6vkhZ1mx6JmRtM6RtT6r2vd/m9FARZ1LfQCSgRq5XKyXCNLcI0ju7Lics4WKPWdy+vFhgnpIt7HKgCr+ZHmf8o476UKFOiJfsplRXI6M+Jo3Wnw9fx93S5DySvivlUpqHzJZG+5A1nrXA0TBoHsLZcEPLdyV5kPUnkzjlhDCsiCNydjl5mHD6QFFtPNR6BjHjtw7LOQOe/7emWpQ7pwqGG5vZylYaimwQTyobTSAH/2C8T9uo7hPl77GTFh/CcrjDF4/DxSyoD7LoLh+PjidiYZUY4RAYvPJkfIESlqe16neyjk6P8XHl4fwD/szt7o7Avp+4QzURTv6MfNRaDqMLn5Lhco17+m49ezgldKVWjsSPsEt0xXzo09DPhdlNETYqryzCTLoRo0nw== X-MS-Exchange-CrossTenant-Network-Message-Id: a6fefd83-bdf3-4f72-d1f4-08dbd173887a X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:34.5789 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AlN8cI1RNFIuUuS2GaTxufVRIVyhayZ6XXAlCP5bneFqVVPIO6hR6n4niJbUAv2STbTrTIPOWgx1PWUdXf477kM69Pgb2wtmT4BkYaj7KUY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6363 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Ciunas Bennett Add an interface for the rate limiting feature which allows to add, remove and modify a QAT SLA (Service Level Agreement). This adds a new sysfs attribute group, `qat_rl`, which can be accessed from /sys/bus/pci/devices/ with the following hierarchy: |-+ qat_rl |---- id (RW) # SLA identifier |---- cir (RW) # Committed Information Rate |---- pir (RW) # Peak Information Rate |---- srv (RW) # Service to be rate limited |---- rp (RW) (HEX) # Ring pairs to be rate limited |---- cap_rem (RW) # Remaining capability for a service |---- sla_op (WO) # Allows to perform an operation on an SLA The API works by setting the appropriate RW attributes and then issuing a command through the `sla_op`. For example, to create an SLA, a user needs to input the necessary data into the attributes cir, pir, srv and rp and then write into `sla_op` the command `add` to execute the operation. The API also provides `cap_rem` attribute to get information about the remaining device capability within a certain service which is required when setting an SLA. Signed-off-by: Ciunas Bennett Reviewed-by: Giovanni Cabiddu Reviewed-by: Damian Muszynski Reviewed-by: Tero Kristo --- Documentation/ABI/testing/sysfs-driver-qat_rl | 227 +++++++++ drivers/crypto/intel/qat/qat_common/Makefile | 1 + drivers/crypto/intel/qat/qat_common/adf_rl.c | 10 + drivers/crypto/intel/qat/qat_common/adf_rl.h | 7 + .../intel/qat/qat_common/adf_sysfs_rl.c | 451 ++++++++++++++++++ .../intel/qat/qat_common/adf_sysfs_rl.h | 11 + 6 files changed, 707 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-qat_rl create mode 100644 drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.h diff --git a/Documentation/ABI/testing/sysfs-driver-qat_rl b/Documentation/ABI/testing/sysfs-driver-qat_rl new file mode 100644 index 000000000000..41e774cc8646 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-qat_rl @@ -0,0 +1,227 @@ +What: /sys/bus/pci/devices//qat_rl/sla_op +Date: January 2024 +KernelVersion: 6.7 +Contact: qat-linux@intel.com +Description: + (WO) This attribute is used to perform an operation on an SLA. + The supported operations are: add, update, rm, rm_all, and get. + + Input values must be filled through the associated attribute in + this group before a write to this file. + If the operation completes successfully, the associated + attributes will be updated. + The associated attributes are: cir, pir, srv, rp, and id. + + Supported operations: + + * add: Creates a new SLA with the provided inputs from user. + * Inputs: cir, pir, srv, and rp + * Output: id + + * get: Returns the configuration of the specified SLA in id attribute + * Inputs: id + * Outputs: cir, pir, srv, and rp + + * update: Updates the SLA with new values set in the following attributes + * Inputs: id, cir, and pir + + * rm: Removes the specified SLA in the id attribute. + * Inputs: id + + * rm_all: Removes all the configured SLAs. + * Inputs: None + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat_rl/rp +Date: January 2024 +KernelVersion: 6.7 +Contact: qat-linux@intel.com +Description: + (RW) When read, reports the current assigned ring pairs for the + queried SLA. + When wrote to, configures the ring pairs associated to a new SLA. + + The value is a 64-bit bit mask and is written/displayed in hex. + Each bit of this mask represents a single ring pair i.e., + bit 1 == ring pair id 0; bit 3 == ring pair id 2. + + Selected ring pairs must to be assigned to a single service, + i.e. the one provided with the srv attribute. The service + assigned to a certain ring pair can be checked by querying + the attribute qat/rp2srv. + + The maximum number of ring pairs is 4 per SLA. + + Applicability in sla_op: + + * WRITE: add operation + * READ: get operation + + Example usage:: + + ## Read + # echo 4 > /sys/bus/pci/devices//qat_rl/id + # cat /sys/bus/pci/devices//qat_rl/rp + 0x5 + + ## Write + # echo 0x5 > /sys/bus/pci/devices//qat_rl/rp + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat_rl/id +Date: January 2024 +KernelVersion: 6.7 +Contact: qat-linux@intel.com +Description: + (RW) If written to, the value is used to retrieve a particular + SLA and operate on it. + This is valid only for the following operations: update, rm, + and get. + A read of this attribute is only guaranteed to have correct data + after creation of an SLA. + + Applicability in sla_op: + + * WRITE: rm and update operations + * READ: add and get operations + + Example usage:: + + ## Read + ## Set attributes e.g. cir, pir, srv, etc + # echo "add" > /sys/bus/pci/devices//qat_rl/sla_op + # cat /sys/bus/pci/devices//qat_rl/id + 4 + + ## Write + # echo 7 > /sys/bus/pci/devices//qat_rl/id + # echo "get" > /sys/bus/pci/devices//qat_rl/sla_op + # cat /sys/bus/pci/devices//qat_rl/rp + 0x5 ## ring pair ID 0 and ring pair ID 2 + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat_rl/cir +Date: January 2024 +KernelVersion: 6.7 +Contact: qat-linux@intel.com +Description: + (RW) Committed information rate (CIR). Rate guaranteed to be + achieved by a particular SLA. The value is expressed in + permille scale, i.e. 1000 refers to the maximum device + throughput for a selected service. + + After sending a "get" to sla_op, this will be populated with the + CIR for that queried SLA. + Write to this file before sending an "add/update" sla_op, to set + the SLA to the specified value. + + Applicability in sla_op: + + * WRITE: add and update operations + * READ: get operation + + Example usage:: + + ## Write + # echo 500 > /sys/bus/pci/devices//qat_rl/cir + # echo "add" /sys/bus/pci/devices//qat_rl/sla_op + + ## Read + # echo 4 > /sys/bus/pci/devices//qat_rl/id + # echo "get" > /sys/bus/pci/devices//qat_rl/sla_op + # cat /sys/bus/pci/devices//qat_rl/cir + 500 + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat_rl/pir +Date: January 2024 +KernelVersion: 6.7 +Contact: qat-linux@intel.com +Description: + (RW) Peak information rate (PIR). The maximum rate that can be + achieved by that particular SLA. An SLA can reach a value + between CIR and PIR when the device is not fully utilized by + requests from other users (assigned to different SLAs). + + After sending a "get" to sla_op, this will be populated with the + PIR for that queried SLA. + Write to this file before sending an "add/update" sla_op, to set + the SLA to the specified value. + + Applicability in sla_op: + + * WRITE: add and update operations + * READ: get operation + + Example usage:: + + ## Write + # echo 750 > /sys/bus/pci/devices//qat_rl/pir + # echo "add" > /sys/bus/pci/devices//qat_rl/sla_op + + ## Read + # echo 4 > /sys/bus/pci/devices//qat_rl/id + # echo "get" > /sys/bus/pci/devices//qat_rl/sla_op + # cat /sys/bus/pci/devices//qat_rl/pir + 750 + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat_rl/srv +Date: January 2024 +KernelVersion: 6.7 +Contact: qat-linux@intel.com +Description: + (RW) Service (SRV). Represents the service (sym, asym, dc) + associated to an SLA. + Can be written to or queried to set/show the SRV type for an SLA. + The SRV attribute is used to specify the SRV type before adding + an SLA. After an SLA is configured, reports the service + associated to that SLA. + + Applicability in sla_op: + + * WRITE: add and update operations + * READ: get operation + + Example usage:: + + ## Write + # echo "dc" > /sys/bus/pci/devices//qat_rl/srv + # echo "add" > /sys/bus/pci/devices//qat_rl/sla_op + # cat /sys/bus/pci/devices//qat_rl/id + 4 + + ## Read + # echo 4 > /sys/bus/pci/devices//qat_rl/id + # echo "get" > /sys/bus/pci/devices//qat_rl/sla_op + # cat /sys/bus/pci/devices//qat_rl/srv + dc + + This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat_rl/cap_rem +Date: January 2024 +KernelVersion: 6.7 +Contact: qat-linux@intel.com +Description: + (RW) This file will return the remaining capability for a + particular service/sla. This is the remaining value that a new + SLA can be set to or a current SLA can be increased with. + + Example usage:: + + # echo "asym" > /sys/bus/pci/devices//qat_rl/cap_rem + # cat /sys/bus/pci/devices//qat_rl/cap_rem + 250 + # echo 250 > /sys/bus/pci/devices//qat_rl/cir + # echo "add" > /sys/bus/pci/devices//qat_rl/sla_op + # cat /sys/bus/pci/devices//qat_rl/cap_rem + 0 + + This attribute is only available for qat_4xxx devices. + diff --git a/drivers/crypto/intel/qat/qat_common/Makefile b/drivers/crypto/intel/qat/qat_common/Makefile index 408b3959da1d..800ad5eba16b 100644 --- a/drivers/crypto/intel/qat/qat_common/Makefile +++ b/drivers/crypto/intel/qat/qat_common/Makefile @@ -30,6 +30,7 @@ intel_qat-objs := adf_cfg.o \ qat_algs_send.o \ adf_rl.o \ adf_rl_admin.o \ + adf_sysfs_rl.o \ qat_uclo.o \ qat_hal.o \ qat_bl.o diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl.c b/drivers/crypto/intel/qat/qat_common/adf_rl.c index 88a03105b52a..86e3e2152b1b 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_rl.c +++ b/drivers/crypto/intel/qat/qat_common/adf_rl.c @@ -16,6 +16,7 @@ #include "adf_common_drv.h" #include "adf_rl_admin.h" #include "adf_rl.h" +#include "adf_sysfs_rl.h" #define RL_TOKEN_GRANULARITY_PCIEIN_BUCKET 0U #define RL_TOKEN_GRANULARITY_PCIEOUT_BUCKET 0U @@ -1130,8 +1131,16 @@ int adf_rl_start(struct adf_accel_dev *accel_dev) goto ret_sla_rm; } + ret = adf_sysfs_rl_add(accel_dev); + if (ret) { + dev_err(&GET_DEV(accel_dev), "failed to add sysfs interface\n"); + goto ret_sysfs_rm; + } + return 0; +ret_sysfs_rm: + adf_sysfs_rl_rm(accel_dev); ret_sla_rm: adf_rl_remove_sla_all(accel_dev, true); ret_free: @@ -1146,6 +1155,7 @@ void adf_rl_stop(struct adf_accel_dev *accel_dev) if (!accel_dev->rate_limiting) return; + adf_sysfs_rl_rm(accel_dev); adf_rl_remove_sla_all(accel_dev, true); } diff --git a/drivers/crypto/intel/qat/qat_common/adf_rl.h b/drivers/crypto/intel/qat/qat_common/adf_rl.h index 1ccb6613c92e..eb5a330f8543 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_rl.h +++ b/drivers/crypto/intel/qat/qat_common/adf_rl.h @@ -75,6 +75,12 @@ struct rl_slice_cnt { u8 cph_cnt; }; +struct adf_rl_interface_data { + struct adf_rl_sla_input_data input; + enum adf_base_services cap_rem_srv; + struct rw_semaphore lock; +}; + struct adf_rl_hw_data { u32 scale_ref; u32 scan_interval; @@ -113,6 +119,7 @@ struct adf_rl { bool rp_in_use[RL_RP_CNT_MAX]; /* Mutex protecting writing to SLAs lists */ struct mutex rl_lock; + struct adf_rl_interface_data user_input; }; /** diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c b/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c new file mode 100644 index 000000000000..abf9c52474ec --- /dev/null +++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c @@ -0,0 +1,451 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright(c) 2023 Intel Corporation */ + +#define dev_fmt(fmt) "RateLimiting: " fmt + +#include +#include +#include +#include + +#include "adf_common_drv.h" +#include "adf_rl.h" +#include "adf_sysfs_rl.h" + +#define GET_RL_STRUCT(accel_dev) ((accel_dev)->rate_limiting->user_input) + +enum rl_ops { + ADD, + UPDATE, + RM, + RM_ALL, + GET, +}; + +enum rl_params { + RP_MASK, + ID, + CIR, + PIR, + SRV, + CAP_REM_SRV, +}; + +static const char *const rl_services[] = { + [ADF_SVC_ASYM] = "asym", + [ADF_SVC_SYM] = "sym", + [ADF_SVC_DC] = "dc", +}; + +static const char *const rl_operations[] = { + [ADD] = "add", + [UPDATE] = "update", + [RM] = "rm", + [RM_ALL] = "rm_all", + [GET] = "get", +}; + +static int set_param_u(struct device *dev, enum rl_params param, u64 set) +{ + struct adf_rl_interface_data *data; + struct adf_accel_dev *accel_dev; + int ret = 0; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev) + return -EINVAL; + + data = &GET_RL_STRUCT(accel_dev); + + down_write(&data->lock); + switch (param) { + case RP_MASK: + data->input.rp_mask = set; + break; + case CIR: + data->input.cir = set; + break; + case PIR: + data->input.pir = set; + break; + case SRV: + data->input.srv = set; + break; + case CAP_REM_SRV: + data->cap_rem_srv = set; + break; + default: + ret = -EINVAL; + break; + } + up_write(&data->lock); + + return ret; +} + +static int set_param_s(struct device *dev, enum rl_params param, int set) +{ + struct adf_rl_interface_data *data; + struct adf_accel_dev *accel_dev; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev || param != ID) + return -EINVAL; + + data = &GET_RL_STRUCT(accel_dev); + + down_write(&data->lock); + data->input.sla_id = set; + up_write(&data->lock); + + return 0; +} + +static int get_param_u(struct device *dev, enum rl_params param, u64 *get) +{ + struct adf_rl_interface_data *data; + struct adf_accel_dev *accel_dev; + int ret = 0; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev) + return -EINVAL; + + data = &GET_RL_STRUCT(accel_dev); + + down_read(&data->lock); + switch (param) { + case RP_MASK: + *get = data->input.rp_mask; + break; + case CIR: + *get = data->input.cir; + break; + case PIR: + *get = data->input.pir; + break; + case SRV: + *get = data->input.srv; + break; + default: + ret = -EINVAL; + } + up_read(&data->lock); + + return ret; +} + +static int get_param_s(struct device *dev, enum rl_params param) +{ + struct adf_rl_interface_data *data; + struct adf_accel_dev *accel_dev; + int ret = 0; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev) + return -EINVAL; + + data = &GET_RL_STRUCT(accel_dev); + + down_read(&data->lock); + if (param == ID) + ret = data->input.sla_id; + up_read(&data->lock); + + return ret; +} + +static ssize_t rp_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int ret; + u64 get; + + ret = get_param_u(dev, RP_MASK, &get); + if (ret) + return ret; + + return sysfs_emit(buf, "%#llx\n", get); +} + +static ssize_t rp_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + int err; + u64 val; + + err = kstrtou64(buf, 16, &val); + if (err) + return err; + + err = set_param_u(dev, RP_MASK, val); + if (err) + return err; + + return count; +} +static DEVICE_ATTR_RW(rp); + +static ssize_t id_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sysfs_emit(buf, "%d\n", get_param_s(dev, ID)); +} + +static ssize_t id_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + int err; + int val; + + err = kstrtoint(buf, 10, &val); + if (err) + return err; + + err = set_param_s(dev, ID, val); + if (err) + return err; + + return count; +} +static DEVICE_ATTR_RW(id); + +static ssize_t cir_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int ret; + u64 get; + + ret = get_param_u(dev, CIR, &get); + if (ret) + return ret; + + return sysfs_emit(buf, "%llu\n", get); +} + +static ssize_t cir_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned int val; + int err; + + err = kstrtouint(buf, 10, &val); + if (err) + return err; + + err = set_param_u(dev, CIR, val); + if (err) + return err; + + return count; +} +static DEVICE_ATTR_RW(cir); + +static ssize_t pir_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int ret; + u64 get; + + ret = get_param_u(dev, PIR, &get); + if (ret) + return ret; + + return sysfs_emit(buf, "%llu\n", get); +} + +static ssize_t pir_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned int val; + int err; + + err = kstrtouint(buf, 10, &val); + if (err) + return err; + + err = set_param_u(dev, PIR, val); + if (err) + return err; + + return count; +} +static DEVICE_ATTR_RW(pir); + +static ssize_t srv_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int ret; + u64 get; + + ret = get_param_u(dev, SRV, &get); + if (ret) + return ret; + + if (get == ADF_SVC_NONE) + return -EINVAL; + + return sysfs_emit(buf, "%s\n", rl_services[get]); +} + +static ssize_t srv_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned int val; + int ret; + + ret = sysfs_match_string(rl_services, buf); + if (ret < 0) + return ret; + + val = ret; + ret = set_param_u(dev, SRV, val); + if (ret) + return ret; + + return count; +} +static DEVICE_ATTR_RW(srv); + +static ssize_t cap_rem_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct adf_rl_interface_data *data; + struct adf_accel_dev *accel_dev; + int ret, rem_cap; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev) + return -EINVAL; + + data = &GET_RL_STRUCT(accel_dev); + + down_read(&data->lock); + rem_cap = adf_rl_get_capability_remaining(accel_dev, data->cap_rem_srv, + RL_SLA_EMPTY_ID); + up_read(&data->lock); + if (rem_cap < 0) + return rem_cap; + + ret = sysfs_emit(buf, "%u\n", rem_cap); + + return ret; +} + +static ssize_t cap_rem_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned int val; + int ret; + + ret = sysfs_match_string(rl_services, buf); + if (ret < 0) + return ret; + + val = ret; + ret = set_param_u(dev, CAP_REM_SRV, val); + if (ret) + return ret; + + return count; +} +static DEVICE_ATTR_RW(cap_rem); + +static ssize_t sla_op_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct adf_rl_interface_data *data; + struct adf_accel_dev *accel_dev; + int ret; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev) + return -EINVAL; + + data = &GET_RL_STRUCT(accel_dev); + + ret = sysfs_match_string(rl_operations, buf); + if (ret < 0) + return ret; + + down_write(&data->lock); + switch (ret) { + case ADD: + data->input.parent_id = RL_PARENT_DEFAULT_ID; + data->input.type = RL_LEAF; + data->input.sla_id = 0; + ret = adf_rl_add_sla(accel_dev, &data->input); + if (ret) + goto err_free_lock; + break; + case UPDATE: + ret = adf_rl_update_sla(accel_dev, &data->input); + if (ret) + goto err_free_lock; + break; + case RM: + ret = adf_rl_remove_sla(accel_dev, data->input.sla_id); + if (ret) + goto err_free_lock; + break; + case RM_ALL: + adf_rl_remove_sla_all(accel_dev, false); + break; + case GET: + ret = adf_rl_get_sla(accel_dev, &data->input); + if (ret) + goto err_free_lock; + break; + default: + ret = -EINVAL; + goto err_free_lock; + } + up_write(&data->lock); + + return count; + +err_free_lock: + up_write(&data->lock); + + return ret; +} +static DEVICE_ATTR_WO(sla_op); + +static struct attribute *qat_rl_attrs[] = { + &dev_attr_rp.attr, + &dev_attr_id.attr, + &dev_attr_cir.attr, + &dev_attr_pir.attr, + &dev_attr_srv.attr, + &dev_attr_cap_rem.attr, + &dev_attr_sla_op.attr, + NULL, +}; + +static struct attribute_group qat_rl_group = { + .attrs = qat_rl_attrs, + .name = "qat_rl", +}; + +int adf_sysfs_rl_add(struct adf_accel_dev *accel_dev) +{ + struct adf_rl_interface_data *data; + int ret; + + data = &GET_RL_STRUCT(accel_dev); + + ret = device_add_group(&GET_DEV(accel_dev), &qat_rl_group); + if (ret) + dev_err(&GET_DEV(accel_dev), + "Failed to create qat_rl attribute group\n"); + + data->cap_rem_srv = ADF_SVC_NONE; + data->input.srv = ADF_SVC_NONE; + + return ret; +} + +void adf_sysfs_rl_rm(struct adf_accel_dev *accel_dev) +{ + device_remove_group(&GET_DEV(accel_dev), &qat_rl_group); +} diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.h b/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.h new file mode 100644 index 000000000000..22d36aa8a757 --- /dev/null +++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright(c) 2023 Intel Corporation */ +#ifndef ADF_SYSFS_RL_H_ +#define ADF_SYSFS_RL_H_ + +struct adf_accel_dev; + +int adf_sysfs_rl_add(struct adf_accel_dev *accel_dev); +void adf_sysfs_rl_rm(struct adf_accel_dev *accel_dev); + +#endif /* ADF_SYSFS_RL_H_ */ From patchwork Fri Oct 20 13:49:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430773 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 1C12CC07480 for ; Fri, 20 Oct 2023 13:50:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377490AbjJTNux (ORCPT ); Fri, 20 Oct 2023 09:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377487AbjJTNuv (ORCPT ); Fri, 20 Oct 2023 09:50:51 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD695A3 for ; Fri, 20 Oct 2023 06:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809849; x=1729345849; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=NMdAFjwGq7BahmMNPGjxfdxGjcK2OLK8M84GpARINFI=; b=jAGqoGuElpBaldRFI2ZNwV1F/SBg+pfVrSHwPYxLrnHPsFQisvFJ99+r Eht2M9mpCX/kmln0QuccWepao6mTP2RgF49nyL6CuBVCmNVy4h/RLoTzl Ck/MrnnNuVrv6bIVWyXySA8ThgccWjriDRw5az0S7SygRCweKzQTZDb8r 35Mer4k/BbyO2zD5hEDdKRAAEy6yRK+QY0xxZfksfHJNev7qhoLF/3gX8 t0RRLytsRcSyieXzV5/afHlcs/AxtFr8YJErBMbpPCmHc2w9zQkjKwGaR 3rfJxRIoeO0YfLpzk0wHKURq0DEH84Ns3iKCuVgV0spQNI4ccxf37xV4J A==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="472721235" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="472721235" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="707231443" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="707231443" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga003.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:45 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:45 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:45 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZdBOyghyKIn1VtTaxH89t/tQ9Ftk103jzg01W/zWfyHz3dDWFh7XvISiXEizdVSNwM6Kd1YhAd3cDmj9WpoctMmXo1QF/erABLbdBOrm9oco8+lOG0Fnya1umM3K7TMwM0FqpLFmpAAtfBm/H7UNxeljH5XV3pUsKnrlpwAcS9plABE5wayNBVHfSh5r+DqPBdXszILmUuYmCR/lzjppu7a3cQe4SJjAJO8L3KfURD+I0NaqA9IEJHuonFz2roStFBLSTjkh2oDvfzzXDILpjbWTslA5VnUMzzds/qasOKo9EL4X6NiXf0lTRLEQ+LQJhxJtm3yfJAmWFf9NnieyXw== 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=BhtlNptHFv5SGQ14qDb0koVi9AJMgGI9+xcODbiwjV0=; b=jx9znnWVCnn9uRfZZxm6AdZilBGLEZriL+kztkm0EIvIO5UF85dZx9rtu78RshGbAwVlq1AZe7q9Jgrj+0CsozEz7t5TJpfhyy97ULat8O25HZT8R8oAuVjGfpAClkw/6mxj1C2XGHk3voyKb+Avu/fbSDq6kJQYFwv+BzjF4MczKwDN3TuS9NkTpgtSrDArVAVqDP1kCPxtf0Y3M9vkifaxgANQTFjE1cIBVba2rw8D5zxr0O2AyBEXWOMe3FQSkdxq++7tdxU6/t8cYVaBjhdWL5AsdsjnHDOY7/klBTZ9eeB05ASy9bTs2B1z4v+hXp67OWAYHBHHMxuPSrI4nA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by BL3PR11MB6363.namprd11.prod.outlook.com (2603:10b6:208:3b6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 13:50:37 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:37 +0000 From: Damian Muszynski To: CC: , , Ciunas Bennett , Giovanni Cabiddu , Damian Muszynski , Tero Kristo Subject: [PATCH v2 10/11] crypto: qat - add rp2svc sysfs attribute Date: Fri, 20 Oct 2023 15:49:30 +0200 Message-ID: <20231020134931.7530-11-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|BL3PR11MB6363:EE_ X-MS-Office365-Filtering-Correlation-Id: 37ed858a-d8a7-4728-6951-08dbd1738a1e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NvI+ebVCgavyN30jcWFkai3LPmO3LzpdsZK82pwCM8v64dK+CJ2/wdhmQ5QpQt4//0PSg6wUFxj5u5WvjLEm6Cjz/S+OnJURKStXkboks7PijtojtmS+DYB3Dkry+qsJJfi/S5vuSIrEz7aAhlbHXpSh2Fku3d8YWVfBz7ClciJHQsXItCloJ1/Qx/jGtmZ5AoQiyh8gg2LDRL/mQtYXnNMC/B0fv+3G223yDUJb81Lai+slwL+42XYCpKuQ1oAuzWDrNIffcQtrFkXq/ORHFAgibtUagt5C3ntTRF3fyrof1zQYDuBQtUhrdK/a8ReHsUB26skfqj1aLUdyjj9h+G24qkeFhEFYhrdQr5lNCY1O7DGLXwrviFRbpTKnU0MvD4czp0pG+Mziv5171zovlK7R3duCeX65apMH61eIaAIAClAm+82DyZyet+SqkIWiP4JQaA/Grkmk5GvoOyZht4eppbUwBe/ubQ6LCLal4eAAowS4bwYqyQ8XmJCKEtbg84HAVGw7FAJzcF/iFeGc4HA1exuXxgM5zTv0LKPCd5Mi9bl9u+3nB421C4clj825 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(66556008)(6666004)(54906003)(66476007)(478600001)(6916009)(83380400001)(6486002)(66946007)(6512007)(38100700002)(1076003)(41300700001)(26005)(36916002)(316002)(2616005)(6506007)(82960400001)(36756003)(86362001)(8676002)(8936002)(44832011)(2906002)(5660300002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gaC8f+D2WTrrXpeC+5w9I92VQnx7ugf0qQCWLyhurWXFyd2X3H0RZKnu9DVWdqAQhxOq+K4FLF5Zj+olUGpIP+9nsSqeHJWjzaPqKu5ndyYp5/hw69LnELlC006pbICub2T1euiODVrMcmZTlBQ6FmqUuCzDJ9C9Vvf8OqgkGeqScvRz9ihxBziCexTpjh5fMnq/7AiKH3dAck9E5SncX60bOa9rJOzvn7qbXfFxljbaz3NzVcxz3L1fZoExNum1a7/wkq/OmCdqp+yqH+PiMmR3xKAuwaZ+3PoFEsmGUWPiCHqlZgO8St/CNVO6Z1yVY//+2Q9pG4Do1slnzTM/I41afkneV00nw9CwmrLrBluuDcN8ziKf0pr2zPdCBg++N5ZcqplyN/8VBmk6QgXF2uMsdJ6iO3+E1j+62NLkuno/TmGAZk0tDzyvXi1Og8GdXwpsHl+eE56vRe+JmXkTkc/WyErmZ8fe2GU6IcvmmgBTt5HyC209vwIQtA5cuot4yiuWwBN3G7J4iyZsobcmiPDpUjYbfEP+irBZyHYp7wP7hldSCnT4nRka8RXf+/YzL8kvB0LptyQdkEfSOQ5zz13xOBMJOriLbTxd0L5mlOV0YjcJHFs3WpfYr7kCpqx5+v3nhITCGtqA6Ydg5GThd5hz+6D5M/w65ZFQUWGJ5tsJZlOmtsD+ObEHjEwMekr8GDL5UfbKoR3qGZSfc4jiBF1aVvOhomYjSYl52gks9lHPZmKdblKq8u5r9J35qGbGTZuH17nepEBMsJDSMuf4hZX7t3AkC6OgwLttms5qAAcQ69QR0gw6REmQv4BeWcpQ+QX2dhgCAiysDKR8xYRS6gW1TfHvg7tYmHHC72llse3i+c3yRY2js4P1FMHp+Ez6n33SiqAtvLqUI9HpIUAesk8rJ8GxsEMwDynTPkpYHACFyfDOzG35CRpmoCRn+blO1h21k9bB12tLAWl+teCq653hO2tfBEUjaZVKkZt7+Gy3mEv5XeiTV8AXrLHU+hxi2d6PDPTwqquf3BehonGu3CoWaG/NZcH/W2P8UoBLKD0vdX6VQqjyO1fkWu+Nh/fERkimKbSKUF0ufBSqhEGvvMUuSn+P6ZU9ZgLnoCHN3vNBV2ecX2H8x88ZNtXG6Rr/Qze6X7cqClQjdFj9GENw9zGMhJ3A34qgmdf4vw6F6ln8QAWOfBMA+aVxQu6k+7pngwWM+4f4lIvPgsWGxVW966X9BLYcSMCDHrRNeyM1FcWof5n2/G6o4Y5ChwNKi59AfG+L8VUAnFlbgM5wkTUl80F0Q1XauW8zgd03WcQ7uAqEWKl+oe1EB5Z+8fWSW0ZPYKII0T1JaK94Vg02k+rVSEMY7QGTgnCvciFhG+WjkZsNgZJuOJQ9BlScwRWSQXU3GiwKWZz7JY74/Jh010qtSsd19BprjinUaOricO/yGtQ1ZnWbSYpPZ4vx21yrEXvkaVR/zTp6aWRzm2buiKezxyPJjBH0POOoqhI9klWTPwF8cUt4UHA/+CwKtaGg7vK9SB1w5JraKJRmtUw5Cc+tZnGLP2vnllMnq5M+GPi+sih/yaYNaQB6L9qtOR81Ail44yEhk3pEmKMDzOs7sZIIIw== X-MS-Exchange-CrossTenant-Network-Message-Id: 37ed858a-d8a7-4728-6951-08dbd1738a1e X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:37.4114 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: v04xJWYVMJJ1jn6TPeJgt8ELCAXKBWWjEQM0yfJIyHabr/nqnCQO5UX36aTU+XR57gEXZXhX7hy5CgVutNGJS5nbQSo5rhav0HhTbd9o/oM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6363 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Ciunas Bennett Add the attribute `rp2svc` to the `qat` attribute group. This provides a way for a user to query a specific ring pair for the type of service that is currently configured for. When read, the service will be returned for the defined ring pair. When written to this value will be stored as the ring pair to return the service of. Signed-off-by: Ciunas Bennett Reviewed-by: Giovanni Cabiddu Reviewed-by: Damian Muszynski Reviewed-by: Tero Kristo --- Documentation/ABI/testing/sysfs-driver-qat | 32 +++++++++ .../intel/qat/qat_common/adf_accel_devices.h | 6 ++ .../crypto/intel/qat/qat_common/adf_sysfs.c | 66 +++++++++++++++++++ 3 files changed, 104 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-driver-qat b/Documentation/ABI/testing/sysfs-driver-qat index 96834d103a09..f24a5ddca94b 100644 --- a/Documentation/ABI/testing/sysfs-driver-qat +++ b/Documentation/ABI/testing/sysfs-driver-qat @@ -95,3 +95,35 @@ Description: (RW) This configuration option provides a way to force the device i 0 This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat/rp2srv +Date: January 2024 +KernelVersion: 6.7 +Contact: qat-linux@intel.com +Description: + (RW) This attribute provides a way for a user to query a + specific ring pair for the type of service that it is currently + configured for. + + When written to, the value is cached and used to perform the + read operation. Allowed values are in the range 0 to N-1, where + N is the max number of ring pairs supported by a device. This + can be queried using the attribute qat/num_rps. + + A read returns the service associated to the ring pair queried. + + The values are: + + * dc: the ring pair is configured for running compression services + * sym: the ring pair is configured for running symmetric crypto + services + * asym: the ring pair is configured for running asymmetric crypto + services + + Example usage:: + + # echo 1 > /sys/bus/pci/devices//qat/rp2srv + # cat /sys/bus/pci/devices//qat/rp2srv + sym + + This attribute is only available for qat_4xxx devices. diff --git a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h index 30c2b15ff801..4ff5729a3496 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h +++ b/drivers/crypto/intel/qat/qat_common/adf_accel_devices.h @@ -340,6 +340,11 @@ struct adf_pm { char __user *buf, size_t count, loff_t *pos); }; +struct adf_sysfs { + int ring_num; + struct rw_semaphore lock; /* protects access to the fields in this struct */ +}; + struct adf_accel_dev { struct adf_etr_data *transport; struct adf_hw_device_data *hw_device; @@ -361,6 +366,7 @@ struct adf_accel_dev { struct adf_timer *timer; struct adf_heartbeat *heartbeat; struct adf_rl *rate_limiting; + struct adf_sysfs sysfs; union { struct { /* protects VF2PF interrupts access */ diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c index f4a89f7ed4e9..9317127128a9 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c +++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c @@ -8,6 +8,8 @@ #include "adf_cfg_services.h" #include "adf_common_drv.h" +#define UNSET_RING_NUM -1 + static const char * const state_operations[] = { [DEV_DOWN] = "down", [DEV_UP] = "up", @@ -205,10 +207,72 @@ static DEVICE_ATTR_RW(pm_idle_enabled); static DEVICE_ATTR_RW(state); static DEVICE_ATTR_RW(cfg_services); +static ssize_t rp2srv_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct adf_hw_device_data *hw_data; + struct adf_accel_dev *accel_dev; + enum adf_cfg_service_type svc; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + hw_data = GET_HW_DATA(accel_dev); + + if (accel_dev->sysfs.ring_num == UNSET_RING_NUM) + return -EINVAL; + + down_read(&accel_dev->sysfs.lock); + svc = GET_SRV_TYPE(accel_dev, accel_dev->sysfs.ring_num % + hw_data->num_banks_per_vf); + up_read(&accel_dev->sysfs.lock); + + switch (svc) { + case COMP: + return sysfs_emit(buf, "%s\n", ADF_CFG_DC); + case SYM: + return sysfs_emit(buf, "%s\n", ADF_CFG_SYM); + case ASYM: + return sysfs_emit(buf, "%s\n", ADF_CFG_ASYM); + default: + break; + } + return -EINVAL; +} + +static ssize_t rp2srv_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct adf_accel_dev *accel_dev; + int ring, num_rings, ret; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev) + return -EINVAL; + + ret = kstrtouint(buf, 10, &ring); + if (ret) + return ret; + + num_rings = GET_MAX_BANKS(accel_dev); + if (ring >= num_rings) { + dev_err(&GET_DEV(accel_dev), + "Device does not support more than %u ring pairs\n", + num_rings); + return -EINVAL; + } + + down_write(&accel_dev->sysfs.lock); + accel_dev->sysfs.ring_num = ring; + up_write(&accel_dev->sysfs.lock); + + return count; +} +static DEVICE_ATTR_RW(rp2srv); + static struct attribute *qat_attrs[] = { &dev_attr_state.attr, &dev_attr_cfg_services.attr, &dev_attr_pm_idle_enabled.attr, + &dev_attr_rp2srv.attr, NULL, }; @@ -227,6 +291,8 @@ int adf_sysfs_init(struct adf_accel_dev *accel_dev) "Failed to create qat attribute group: %d\n", ret); } + accel_dev->sysfs.ring_num = UNSET_RING_NUM; + return ret; } EXPORT_SYMBOL_GPL(adf_sysfs_init); From patchwork Fri Oct 20 13:49:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damian Muszynski X-Patchwork-Id: 13430774 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 50DCAC00A98 for ; Fri, 20 Oct 2023 13:50:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377429AbjJTNuv (ORCPT ); Fri, 20 Oct 2023 09:50:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377424AbjJTNut (ORCPT ); Fri, 20 Oct 2023 09:50:49 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6D25D66 for ; Fri, 20 Oct 2023 06:50:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697809847; x=1729345847; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=eBs6t0dguCb3C4PI+AeeUvJFCzk1/Vywh9P9+qZWMjM=; b=FSXHUXx0eFjx8zzJWyii4x00UcNO0eFskYCOJC95J778QVgVH6SwffEX hlK/AVBe70QVgzHT3YKaHTv8+MF44ph15s2LHoGz0As7IfPYh3Kx1CZRR hChYkpAXEKea1Epf/QtXHROqmh0nsyQCACkW01/sRBF3ouEhDlRFvEBWq JSfXtk+01n0rCP9MPM/pwMPZd7yisKhSHuFU3DmWaE8kw+wRLEquYdm/s /P6QTW00vhlg8tmTvKJcJtF8CENaQkhcHqtlcS12t68OKfXWQesbBpthf ybH11GIQ9bCSvH1JBIEYO1ksHh5U80gEdUhWrg1oJSIQZf2CdxjujV9NX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="450725619" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="450725619" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 06:50:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="848086668" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="848086668" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by FMSMGA003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Oct 2023 06:50:46 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:46 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:46 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 20 Oct 2023 06:50:46 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 20 Oct 2023 06:50:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q+mTzNRyIXPQOkPvC5UJOyGi89yVvBmuhSENRtysOaWYyIrJXB3NVh9eib5lHp2g41Q3XDGEL52pBEEauUiAFQJ/hdytpV4bKLb9FdqupUfdNloSVO+fHW8h0tPdv8x/7GZCu81ydhjBBmUrzz/hDcCF8dqjqJ7B4s24iQ8PKRVj3SsOL4fTit9n3UhMv5iseCsaQTCfzIM0kbCJotpY9Mv9BXVzWpbnAi8I3m1AWW64DpfUeiA7BzUKPlFMA58SGFatmZ9CS1buN+REylKeecHdeXvz1VJ5f8GVEmwDLCP4V2R7bPgodR+mJ0HkwI5zPS5PzOMzeG5xmsadkrHQmw== 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=njoOqE0ISWBXWaXpNoC3/dSCdsD/aEO0tvRct5aM4p8=; b=oeeFlSPKhjsW2Y34gI5wzhLWdF9p79CHq6Azgq6dlbwfOgZtb3Ajcjo1eA5/y7ml8G0nK+ZjFT8NwmLIfYgSznCx146IMs91y8fNlbcIDB2ybKZLbyilAVf70Pi8UHRnNnjzD2oIPxFck0B3KWdlS0qiP/EyDGkYz4yVzVFcFZR5ndbc7duXe0Z1KyPVgKBxUr2JM7VzSvCd+RG12s8vWmQB3e8csKiOtkgQvyvXqiLoWuAXOm0GvaQ1tWzSUm4aQStT0R3lOJdNouQxfAbXhGJ5YZv7GwnvWYpYwHPBuakQmqwFj6JgryOvF2Zb8K1+xsunF0QII2g+U8ArNxh9VA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) by BL3PR11MB6363.namprd11.prod.outlook.com (2603:10b6:208:3b6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 13:50:40 +0000 Received: from BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9]) by BYAPR11MB3734.namprd11.prod.outlook.com ([fe80::95aa:def7:9d78:d6c9%4]) with mapi id 15.20.6863.032; Fri, 20 Oct 2023 13:50:40 +0000 From: Damian Muszynski To: CC: , , Ciunas Bennett , Giovanni Cabiddu , Damian Muszynski , Tero Kristo Subject: [PATCH v2 11/11] crypto: qat - add num_rps sysfs attribute Date: Fri, 20 Oct 2023 15:49:31 +0200 Message-ID: <20231020134931.7530-12-damian.muszynski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020134931.7530-1-damian.muszynski@intel.com> References: <20231020134931.7530-1-damian.muszynski@intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 X-ClientProxiedBy: FR5P281CA0027.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::7) To BYAPR11MB3734.namprd11.prod.outlook.com (2603:10b6:a03:fe::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR11MB3734:EE_|BL3PR11MB6363:EE_ X-MS-Office365-Filtering-Correlation-Id: c760715e-bf2a-493f-27b1-08dbd1738bc9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kG6fHr0Loc+MU5QpYwsYh/7Or0MT1bDYHRm+epPKZC+WSBgfxARsGcI4pHkvbytDcNpzX8gyFXNTiS7ZiPJ84Uw/paX+2Okn2FfRNuub/pURKWdNXmKJl5UQQ7nnfNTx2CIZIl3UrGVCNeu/8DDllzqFqPCgEW6Og2zrZ0ATjQEVVAiAOmO03Yvjsu3dm76ARD5TfHBH9iUVFTEKjed64uarXVBdyuRKDEbosVbLzvqlIsGf3JfgQLXARzWjQe8SB2Am/HPu3G0ykWDT32ZAV2UY0PYbCv9owZdChjdqTM9/0Q4zWrPHNqCkVeKItJIC8fDlXUN7D05vnDuslI7RteXHVnRvoUs9qB4NHaAbH2DcSBVL0OnHbWzRPMVVRnsKJzpOnit7P61vjmR4+iTbNwgaf5blGTlZFikahcSjUit/XColwzB/SM9GvugxPp1KjPfdyhchGBHn0zXL8kqzMQIDI3UNJgBNCcnkD9yl093M8waWTot1DaAK2FGPwLWotTJ6Dy4SVw9IjNjWeJFAM502jMzBmg3/BDlpW9S3dP+R23uxs+2UeIKiC1cvpYts X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(39860400002)(346002)(396003)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(66556008)(6666004)(54906003)(66476007)(478600001)(6916009)(83380400001)(6486002)(66946007)(6512007)(38100700002)(1076003)(41300700001)(26005)(36916002)(316002)(2616005)(6506007)(82960400001)(36756003)(86362001)(8676002)(8936002)(44832011)(2906002)(5660300002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SgI3PZyEbNs7KOF0atvjG7sPN9rBuCh/YFY5WTJgnLfBmnCKVd+Xw34hLls8Kiyv3d/DlQCSyxhSUmWjl2M5Bi7GlcA06ICHW9q6Sz2k46742bC9AQP9W+NsMlIMl68BOwJNAqX7cORHxwHzfdgsWK/5ATbGmmFpPE68E0EGLLgYp8L8Iyy/llm6A2v+GDwoumuhk9jEkaSWTgBMja6GzYyUXfFY3wrs0gKXhPMi4lEC1g9pdUSSajoOjmX9TkIfWZeEyCFP9igU9QzIH5WvbF0rjjlX4Pgm7QaLfYNK8hjqQQuXieCoYlaLmXc44PAA3aXUKqCM5PuAIidN5Hfmcrc3AUhchwbPramyACtuldfoEsIPIzeWijQVUS0GifmJpgz+xSwpgpScqMiTkmToJZqyLKgOxTKi2gf4eW8LCGHW5rNStGue2hCKWup4311sXMIF5UmPqUwc6vCWvcsI71677KQSeca4QXwLuKeuiQWDtXbHUB0PP7CR3eCLY2OEoRTMXdPIizh7Kq5b7OBcTnxTvPeMlrepT/OSC7Q+/qOvvmGEjTIB9nieFjukgcOtPFPqobPSgkRN/1SN7OKASDhN/R8PY2Jh/3UdmPKmgF4aP9zH5iK+xfGn+XmmtEddWUsmjpougY2lImYkzjy2pd56VIPuTyJvVoWonzeTYju04jzo1Xk4qoKTO19+5PFd4mndqpvLQ9ZkFXt0W/A2thvAnxaH/m5mbbAbzqtCYAlrWriM1jhT6beZk8+ojA9mqDD6eYabWO4mOkQOJnMFeGeuS1+yq0JK+07mbkDEmiIZ457aJctXl2M7VNdulZk167gonGY+chxd7gYNzpflvkQUU/IadyWf8Ur8blNmUor/9LA/YuxcfiB6FxFobeVVclcuPY7tm4h5IAwGLoZGoqooYwRZ6v9Oju3ORviseKy0cGdj2f+OTGuCm+Sc+aFTNRdhm7szvW3Tyi8Pzr+uJJTfmrex0tVle5QhLJIF/YcxPYPzIZncLSkibUu8fMScZxenN9Xt3PV6X95QCaK2p5kg+tcK9senvPS24VJuU6tqw0oUVQl+z4GEYsxVKOmZY/wQmQqW+w3fL7aot3Q2LRn2uoAt+SEHKe12RdVmNrNcTYA/xL8jeNt1k0CZWe2YDfA47I46xG+wgWWPKu+uv2fy/8XCfu1gaAgYfzjI83/yRa/QOEsG+7s2qGbli4OiH0KELpyR5qi+69yxSgM069+7VRKC0kzTlpyTdV+hfcHkqTW9indUFijPDaJkaPqWLH+TgfuuhEHdBawodj+qahOyMHvD1aAopwDcIuhccu0BjAlhOpawYWour2oUYGLlyWWB5LpIebvlSJ9dnMSMEOYQ+zeq9lT8cBDT34G/BnnY9oVJWrSnnxyAGpsMdgMe0/lbHTv9tH4p24o+V4lmiqzZceBs480b7AhKSGyofoAfb5guYvxd/chYV7lpU1MfHm4C+YseTq9vHmLxT/VzupRoMINYudNkeA6P/T+dKRtGo74XZWNc/ddoetNnobKjrZUumZa4L9vEvXT3h+VUd1datry1hE9Sh0OUtiyNnRY3hmRSfdFFsejWrCg6nIIjuFx5V+tKdSl4Ruqd7uBRcg== X-MS-Exchange-CrossTenant-Network-Message-Id: c760715e-bf2a-493f-27b1-08dbd1738bc9 X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:50:40.1007 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GHmXqkK8Q93k4uPon7uzyIy/w/rEMkqxl0E1DpppguVQNN3QVrQ5zAmjy+c9CpdXCTdEbPc884Mh7UTyLqs/BeN6RrhorfZDHdmc7OQlJYo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR11MB6363 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Ciunas Bennett Add the attribute `num_rps` to the `qat` attribute group. This returns the number of ring pairs that a single device has. This allows to know the maximum value that can be set to the attribute `rp2svc`. Signed-off-by: Ciunas Bennett Reviewed-by: Giovanni Cabiddu Reviewed-by: Damian Muszynski Reviewed-by: Tero Kristo --- Documentation/ABI/testing/sysfs-driver-qat | 14 ++++++++++++++ drivers/crypto/intel/qat/qat_common/adf_sysfs.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-driver-qat b/Documentation/ABI/testing/sysfs-driver-qat index f24a5ddca94b..bbf329cf0d67 100644 --- a/Documentation/ABI/testing/sysfs-driver-qat +++ b/Documentation/ABI/testing/sysfs-driver-qat @@ -127,3 +127,17 @@ Description: sym This attribute is only available for qat_4xxx devices. + +What: /sys/bus/pci/devices//qat/num_rps +Date: January 2024 +KernelVersion: 6.7 +Contact: qat-linux@intel.com +Description: + (RO) Returns the number of ring pairs that a single device has. + + Example usage:: + + # cat /sys/bus/pci/devices//qat/num_rps + 64 + + This attribute is only available for qat_4xxx devices. diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c index 9317127128a9..ddffc98119c6 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c +++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c @@ -268,11 +268,25 @@ static ssize_t rp2srv_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RW(rp2srv); +static ssize_t num_rps_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct adf_accel_dev *accel_dev; + + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); + if (!accel_dev) + return -EINVAL; + + return sysfs_emit(buf, "%u\n", GET_MAX_BANKS(accel_dev)); +} +static DEVICE_ATTR_RO(num_rps); + static struct attribute *qat_attrs[] = { &dev_attr_state.attr, &dev_attr_cfg_services.attr, &dev_attr_pm_idle_enabled.attr, &dev_attr_rp2srv.attr, + &dev_attr_num_rps.attr, NULL, };