Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp1089768lqs; Wed, 6 Mar 2024 06:10:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOXFv7iZcRn422J4FTfhWHL93WKH9HYnphGOEbYNeBBnsrzDVFaUT+I4LY7lILSpIN0ZO31zyd9ctPPeZuWNmXxhTjRqUpOBQ5cE8UWw== X-Google-Smtp-Source: AGHT+IH744QJRdT53jfKjUCD3INz5T4uxSXYFd6eCIVf+1UFb1+ZLWnfW+PnIpLYn8pqkN6Bim5B X-Received: by 2002:a05:620a:b8b:b0:788:23f1:6d56 with SMTP id k11-20020a05620a0b8b00b0078823f16d56mr4767390qkh.13.1709734211195; Wed, 06 Mar 2024 06:10:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709734211; cv=pass; d=google.com; s=arc-20160816; b=vUo6nmBUgvTj0rZiHJeCH8ToKxJxpMowAqtUJKIB2RL+FhYCTKa7kW1V8VlV+j7Lmk UNsUKo+/55eLK0kwkVkQloglWHHCCQKSeCHSNaFA/GwjTC2xWahW16E42S4hv/gPXRg3 bbpoi/xHyxMf385qJLiZxj3IxJh1CYNRuocINlm99qGEdbI6qSEEKn4WG3pEpbk5db5K YHFzF9uRWeao+QBY2/cFlpQUgK/+ExV953WqZD042rYwRdirYPMk4i6Z8ESQP9IfvjIi gQRB5zSUglovTzg3n2hfISlPj/8nmpHGwxqJw9CyMNFbRtEMoyqLvXynXlj2YNGiSCSd BTrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=f5V34d+v+9WtCrL/6crwi8C/ZZrO1PefzMKrgvPQbDI=; fh=3JrBpvDmjV/dD2Hsh+ULU1ufK/sogtWLXzzIwWn114E=; b=nDoB3gr6xa0e/vJ20ofbWCAMN85aDG3GmFcVOghHhV7ksDKn6rse7d4oHLieE4tcto fzEfBteyDpic9JZlIB6EgaqY6YWUqOWN+wLoEt+E73MznJctLiRJAOdLtJH7hDVXFrzB soWiwAsDCGxuecQ3CpWwTxHwmAxPrFpX356fLc1oMCTM80XDOCSBNJHRDge7i5YAMsn6 RHAI9Uor+Kklo6HCfoNnizAsOwvibX0RYcimFBE1ZTQRKN0LmT2YXIZP786/OSwAiM84 K1/PL1w5WyrRl6wL7MsAdQ6V+rtOU6qig6/wWUnJb/q7RqamVJeRK6BEnOdnV/2cMCif Ta5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Zxi2LqBx; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-94022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94022-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p28-20020a05620a113c00b007883f9d5c91si1138587qkk.286.2024.03.06.06.10.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 06:10:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Zxi2LqBx; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-94022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94022-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E3D771C20ED8 for ; Wed, 6 Mar 2024 14:10:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AC521350CA; Wed, 6 Mar 2024 14:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Zxi2LqBx" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8685C133414; Wed, 6 Mar 2024 14:08:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709734133; cv=none; b=upvTmFOThbhPl8xD2A2Zp05JIeTGUQ4hFOmxlW6ieCh7EwAcCS7zowz/1gJYpTqN97/T1JVukhvosqTZ8HEmIYLHHzGj0HXuRLTbnA+X4I8LUqyPrEv95iLVi0rQAI52QYNdLCMccEyfOXDQvVUhUk4HltCYGibojUSmF3ONSEg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709734133; c=relaxed/simple; bh=VS1AQhdQTxNirNpomKjqTD6WT1P/vvqx1Hx55sOh2ko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIPT+Q3ZKaG9gkRt1x/4S+jPE4Je95HB8BuWTAhLuTL0RX3JjJmNfqYf1P9atJZN47Xi2r2Xu87+2VhPacWrutpdEPpJk+9LqDTp04WIC42aVtR5CLya+hS1JRwEb4JxgL6ngTacAQejNEvdCFcVr/C5mgNc+OHGcnsWv3nLDEQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Zxi2LqBx; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 426E8dxb012908; Wed, 6 Mar 2024 14:08:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=f5V34d+v+9WtCrL/6crwi8C/ZZrO1PefzMKrgvPQbDI=; b=Zxi2LqBxiNr10bOIh3S3OHxRr269/Mq64bJcXzy8mwoIQq01O1izZktrGGAsUY21GuyU NKSnE7erTa5EHYsHtaP3wo97PsR90VE8Kkte8XXU67MFWYB/drRT9gEMp3U7W1dUsYiO ncCEczkTI9WHky86aHtPrwTwrqKfcly4UzQ5KYKFhBLmXOV4h0S8ZGlWRgb/85xjgDvh DLJeURQmlyncGyYP2djZCwsrzPpCuk5aXF3FSl9htCfL+gM3ieGM1VMd4bqC9dEq98FU sMrd3ZfnaVw170Cl+NA+2FdgfOYJPZSkl6nsKzWSH6ST41tThdq4oddaRaBf0zp2CHF8 Ng== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wpsyxg080-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:49 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 426Cmpuf025387; Wed, 6 Mar 2024 14:08:48 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wmetyq853-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Mar 2024 14:08:48 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 426E8jdl38404408 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Mar 2024 14:08:47 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 143B458068; Wed, 6 Mar 2024 14:08:45 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89B7058067; Wed, 6 Mar 2024 14:08:44 +0000 (GMT) Received: from jason-laptop.home.arpa (unknown [9.61.164.86]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 6 Mar 2024 14:08:44 +0000 (GMT) From: "Jason J. Herne" To: linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org, pasic@linux.ibm.com, akrowiak@linux.ibm.com, borntraeger@de.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com Subject: [PATCH v2 1/5] s390/ap: Externalize AP bus specific bitmap reading function Date: Wed, 6 Mar 2024 09:08:39 -0500 Message-ID: <20240306140843.10782-2-jjherne@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240306140843.10782-1-jjherne@linux.ibm.com> References: <20240306140843.10782-1-jjherne@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 4Yx-_XQB6pBNpnOZwbZB8iz9kuqRX4B3 X-Proofpoint-GUID: 4Yx-_XQB6pBNpnOZwbZB8iz9kuqRX4B3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-06_08,2024-03-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 phishscore=0 suspectscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403060113 Rename hex2bitmap() to ap_hex2bitmap() and export it for external use. This function will be used by the implementation of the vfio-ap queue_configuration sysfs attribute. Signed-off-by: Jason J. Herne Reviewed-by: Tony Krowiak Reviewed-by: Harald Freudenberger --- drivers/s390/crypto/ap_bus.c | 13 +++---------- drivers/s390/crypto/ap_bus.h | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index f46dd6abacd7..5d8e379eff44 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c @@ -1035,15 +1035,7 @@ void ap_bus_cfg_chg(void) ap_bus_force_rescan(); } -/* - * hex2bitmap() - parse hex mask string and set bitmap. - * Valid strings are "0x012345678" with at least one valid hex number. - * Rest of the bitmap to the right is padded with 0. No spaces allowed - * within the string, the leading 0x may be omitted. - * Returns the bitmask with exactly the bits set as given by the hex - * string (both in big endian order). - */ -static int hex2bitmap(const char *str, unsigned long *bitmap, int bits) +int ap_hex2bitmap(const char *str, unsigned long *bitmap, int bits) { int i, n, b; @@ -1070,6 +1062,7 @@ static int hex2bitmap(const char *str, unsigned long *bitmap, int bits) return -EINVAL; return 0; } +EXPORT_SYMBOL(ap_hex2bitmap); /* * modify_bitmap() - parse bitmask argument and modify an existing @@ -1135,7 +1128,7 @@ static int ap_parse_bitmap_str(const char *str, unsigned long *bitmap, int bits, rc = modify_bitmap(str, newmap, bits); } else { memset(newmap, 0, size); - rc = hex2bitmap(str, newmap, bits); + rc = ap_hex2bitmap(str, newmap, bits); } return rc; } diff --git a/drivers/s390/crypto/ap_bus.h b/drivers/s390/crypto/ap_bus.h index 98814839ef30..954f8d36c2d9 100644 --- a/drivers/s390/crypto/ap_bus.h +++ b/drivers/s390/crypto/ap_bus.h @@ -343,6 +343,28 @@ int ap_parse_mask_str(const char *str, unsigned long *bitmap, int bits, struct mutex *lock); +/* + * ap_hex2bitmap() - Convert a string containing a hexadecimal number (str) + * into a bitmap (bitmap) with bits set that correspond to the bits represented + * by the hex string. Input and output data is in big endian order. + * + * str - Input hex string of format "0x1234abcd". The leading "0x" is optional. + * At least one digit is required. Must be large enough to hold the number of + * bits represented by the bits parameter. + * + * bitmap - Pointer to a bitmap. Upon successful completion of this function, + * this bitmap will have bits set to match the value of str. If bitmap is longer + * than str, then the rightmost bits of bitmap are padded with zeros. Must be + * large enough to hold the number of bits represented by the bits parameter. + * + * bits - Length, in bits, of the bitmap represented by str. Must be a multiple + * of 8. + * + * Returns: 0 on success + * -EINVAL If str format is invalid or bits is not a multiple of 8. + */ +int ap_hex2bitmap(const char *str, unsigned long *bitmap, int bits); + /* * Interface to wait for the AP bus to have done one initial ap bus * scan and all detected APQNs have been bound to device drivers. -- 2.41.0