From patchwork Wed Sep 11 09:04:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13800003 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCD25EE021C for ; Wed, 11 Sep 2024 09:07:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6ACDE940018; Wed, 11 Sep 2024 05:07:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 633F1940015; Wed, 11 Sep 2024 05:07:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 484C3940018; Wed, 11 Sep 2024 05:07:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 23F3B940015 for ; Wed, 11 Sep 2024 05:07:28 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C67AC80592 for ; Wed, 11 Sep 2024 09:07:27 +0000 (UTC) X-FDA: 82551878934.30.E7A9D4F Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf08.hostedemail.com (Postfix) with ESMTP id CAF3E16001C for ; Wed, 11 Sep 2024 09:07:25 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726045618; a=rsa-sha256; cv=none; b=idDxmmxc+PAXxfvh9mphc1Yet2j0Gu4uxDpiViH+Uo1pCWATUoxKGD1AYu05VE+7DnLd9R qvSJz3IC3QAZslU1fpimojhjH9R++tbn32jnmtGyAzGazj59AzX39UiKMWu6UgzrqTZ3i6 O9lNQ/aQrkbnUqJIfteMt7TSAUE+ZwE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of shiju.jose@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=shiju.jose@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726045618; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rrHyVxTJVgTRvD2Zmry8sW7DL/RsDccTiNaHIzJuM54=; b=L1rcyWrTUJFYJa292H81dtg28sIQVbiPFkZO4jlwGAit9KYA/ywrID5P8TzHleVSrFVwK4 vc6e3gPo9QjXnUhhTgiDs7/qXW4bVSpYcW2RZtxuu+vvkON6uyrypK2mxfHbERLSQy0Yr7 7V197bXIjUKsoZGPGMbDVZ4A+Kq2iAA= Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4X3ZMx1xcVz6K6GK; Wed, 11 Sep 2024 17:02:37 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 33704140B3C; Wed, 11 Sep 2024 17:07:24 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.195.245.151) by frapeml500007.china.huawei.com (7.182.85.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 11 Sep 2024 11:07:21 +0200 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 08/17] cxl/mbox: Add GET_FEATURE mailbox command Date: Wed, 11 Sep 2024 10:04:37 +0100 Message-ID: <20240911090447.751-9-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20240911090447.751-1-shiju.jose@huawei.com> References: <20240911090447.751-1-shiju.jose@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.195.245.151] X-ClientProxiedBy: lhrpeml500003.china.huawei.com (7.191.162.67) To frapeml500007.china.huawei.com (7.182.85.172) X-Rspam-User: X-Rspamd-Queue-Id: CAF3E16001C X-Rspamd-Server: rspam01 X-Stat-Signature: pypbxo61a6epishyzkz9rhehkxymdyin X-HE-Tag: 1726045645-3327 X-HE-Meta: U2FsdGVkX1+gvNU80SOhL/Qo+mokIVqqOSy9OaGu0BIK6meCowRZrKu4NM5eTjcABW0MfWij2V23r9ZJFcHQ0I3aFBLKa9ovaMQQ9Evw4Na3gwFsH7rEoveGjYIqNrCy0b5qVmxp4tygEB8ZOzk1FAwrk+tHlepw/aypD/a8Xz/77UnofVxd1k4RqivgoKmpsU1vCHCq/T2xKQNDEKOnXX9VfvqB5Fuc17N6xS2owEY/0AI2J8XDAzsQXgWmgzWWzdZqC4m75SaTpWP7mWFCx87TIqje2Zletrz/vUzUszPfC6GXpHqOvPJd1CQSxz/Xr3ao4DjX4GVMp565VKSy3J0l+DukUafeSzjbgZtimBufynKr8sqLUb6uQ60XOx+/H5Euh1Fd3y63dnPGzvXsnCUneeU2tHGYVJbSFw0+wpCb3M2BVzMe7YDBBGzmkSr+0z2oyGXT/bapk6rs83z0ilNopH8WjZw7wLE4lqrHfTy8Pw/EBXU9HfKlRGfQTpQ2RJZdCe/9hnj8XTp5IDhEKRDMhGHyYJzxR+olOKXNcw9e+8OFVNVxWZbb2gDUVoNwO781O4vrqlAt6XCwrTssglcWeDMETL2CMi9y3MXuxve3mh7Xpd9A6pMxaB+sBKY88pjNZRemfpg3K/1wETYeFq9rBf60YKmPLyTsrznqm7t5zYMQ2R3qObBiDGgjcV/Tb5A1KdTxsHIowqIqnh5Yf3JWu+4q1IqG/TjQ7ig4YNxrMQxMuxWKkqsQqjVXDjcytiq/Q4LpcPj4lPBjvlkTEAjw0bd3T72QNciFKO4338y3HrgWu6Ci7ncSGyZXl3Wy97vZp19u/AC+6p9iMNzwR3L67QJyl1DIfwIjZtQKRQIREaGL2PtvjqfC28ScT5xnZ1t82mdaWA4FYuYYRvJsLSxxc3iiS37zRvB0+sfHQyxypa8C9PMBEpLnYw1zPvdRiJj3At1D/gJ7X7On5og yC0+1w+s KnE+yRS6lMn4jCTe6bsGC2lErwcXZE56h8EjEMa66ujJfrFTljKs1Oq3Lz/PHUcOL6bugNaNr6Fnw82OjoMRwWtdEh3DL0j2q3RdLPrVt9NMxJZrKTtsES7zy60JA5SgTL86f9YbPgvbeIaGXv9X5bTmU4jgG0k5WSmjr6OcP1jvrUVyBVQPiJyaS0SfNgPf2qS/Fpjc1zgggfxlWrkdXyY8VUQ1Q5dB3nuUmJOR3wM4c7zFSs0Lp6nv8HonuuBksaEaULhj7M8YM26s= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Shiju Jose Add support for GET_FEATURE mailbox command. CXL spec 3.1 section 8.2.9.6 describes optional device specific features. The settings of a feature can be retrieved using Get Feature command. CXL spec 3.1 section 8.2.9.6.2 describes Get Feature command. Signed-off-by: Shiju Jose Reviewed-by: Fan Ni --- drivers/cxl/core/mbox.c | 41 +++++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxlmem.h | 26 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index fe965ec5802f..3dfe411c6556 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -965,6 +965,47 @@ int cxl_get_supported_feature_entry(struct cxl_dev_state *cxlds, const uuid_t *f } EXPORT_SYMBOL_NS_GPL(cxl_get_supported_feature_entry, CXL); +size_t cxl_get_feature(struct cxl_dev_state *cxlds, const uuid_t feat_uuid, + enum cxl_get_feat_selection selection, + void *feat_out, size_t feat_out_size) +{ + struct cxl_mailbox *cxl_mbox = &cxlds->cxl_mbox; + size_t data_to_rd_size, size_out; + struct cxl_mbox_get_feat_in pi; + struct cxl_mbox_cmd mbox_cmd; + size_t data_rcvd_size = 0; + int rc; + + if (!feat_out || !feat_out_size) + return 0; + + size_out = min(feat_out_size, cxl_mbox->payload_size); + pi.uuid = feat_uuid; + pi.selection = selection; + do { + data_to_rd_size = min(feat_out_size - data_rcvd_size, + cxl_mbox->payload_size); + pi.offset = cpu_to_le16(data_rcvd_size); + pi.count = cpu_to_le16(data_to_rd_size); + + mbox_cmd = (struct cxl_mbox_cmd) { + .opcode = CXL_MBOX_OP_GET_FEATURE, + .size_in = sizeof(pi), + .payload_in = &pi, + .size_out = size_out, + .payload_out = feat_out + data_rcvd_size, + .min_out = data_to_rd_size, + }; + rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd); + if (rc < 0 || !mbox_cmd.size_out) + return 0; + data_rcvd_size += mbox_cmd.size_out; + } while (data_rcvd_size < feat_out_size); + + return data_rcvd_size; +} +EXPORT_SYMBOL_NS_GPL(cxl_get_feature, CXL); + /** * cxl_enumerate_cmds() - Enumerate commands for a device. * @mds: The driver data for the operation diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 5d149e64c247..57c9294bb7f3 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -487,6 +487,7 @@ enum cxl_opcode { CXL_MBOX_OP_CLEAR_LOG = 0x0403, CXL_MBOX_OP_GET_SUP_LOG_SUBLIST = 0x0405, CXL_MBOX_OP_GET_SUPPORTED_FEATURES = 0x0500, + CXL_MBOX_OP_GET_FEATURE = 0x0501, CXL_MBOX_OP_IDENTIFY = 0x4000, CXL_MBOX_OP_GET_PARTITION_INFO = 0x4100, CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101, @@ -812,6 +813,28 @@ struct cxl_mbox_get_sup_feats_out { struct cxl_feat_entry ents[] __counted_by(le32_to_cpu(supported_feats)); } __packed; +/* + * Get Feature CXL 3.1 Spec 8.2.9.6.2 + */ + +/* + * Get Feature input payload + * CXL rev 3.1 section 8.2.9.6.2 Table 8-99 + */ +enum cxl_get_feat_selection { + CXL_GET_FEAT_SEL_CURRENT_VALUE, + CXL_GET_FEAT_SEL_DEFAULT_VALUE, + CXL_GET_FEAT_SEL_SAVED_VALUE, + CXL_GET_FEAT_SEL_MAX +}; + +struct cxl_mbox_get_feat_in { + uuid_t uuid; + __le16 offset; + __le16 count; + u8 selection; +} __packed; + int cxl_internal_send_cmd(struct cxl_mailbox *cxl_mbox, struct cxl_mbox_cmd *cmd); int cxl_dev_state_identify(struct cxl_memdev_state *mds); @@ -875,4 +898,7 @@ void cxl_dpa_debug(struct seq_file *file, struct cxl_dev_state *cxlds); int cxl_get_supported_features(struct cxl_dev_state *cxlds); int cxl_get_supported_feature_entry(struct cxl_dev_state *cxlds, const uuid_t *feat_uuid, struct cxl_feat_entry *feat_entry_out); +size_t cxl_get_feature(struct cxl_dev_state *cxlds, const uuid_t feat_uuid, + enum cxl_get_feat_selection selection, + void *feat_out, size_t feat_out_size); #endif /* __CXL_MEM_H__ */