From patchwork Wed Feb 12 14:36:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiju Jose X-Patchwork-Id: 13971688 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 841E9214A8F; Wed, 12 Feb 2025 14:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739371056; cv=none; b=FVn4grAGsrzCYEqLVQOW+M8PavHQjHuX/KE6XFHHJUmcBH6Znjon1a6zaq1zz1bTfaNYAtc+CvNX4EEEPSzvzOg+mRvQLURPgCDObF/tGT40Q6jiFt1Swz5J0aWRFSFZLH2O9B2XBcIjWpxdEy2rrV//KyH6KTsUN2n/7htU3Lo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739371056; c=relaxed/simple; bh=JFxnRjzX7nkCUVVRW0c1qZLwzsc/1e4StdZrbc0C0X4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U0Exxs9U9MDHJcPY6WB+QZgoM3DoBvqG3/3+p+as4GDaCSNp2rf+efIpf5HY323LSR6lQqshfH8BqdnI7kJAha1FSiH3h8Pc7Dw1WmWgKgPLzYZF/ck0gSb4A1p4nwLH/HbFFNwTYJvygy+2d9Iu/0QYwhKQ4lBHATwQVX0msJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4YtLSW28YRz6J7db; Wed, 12 Feb 2025 22:35:07 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id AAFA5140525; Wed, 12 Feb 2025 22:37:32 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.126.169.206) 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, 12 Feb 2025 15:37:30 +0100 From: To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v20 07/15] cxl: Add helper function to retrieve a feature entry Date: Wed, 12 Feb 2025 14:36:45 +0000 Message-ID: <20250212143654.1893-8-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20250212143654.1893-1-shiju.jose@huawei.com> References: <20250212143654.1893-1-shiju.jose@huawei.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: lhrpeml100003.china.huawei.com (7.191.160.210) To frapeml500007.china.huawei.com (7.182.85.172) From: Shiju Jose Add helper function to retrieve a feature entry from the supported features list, if supported. Signed-off-by: Shiju Jose --- drivers/cxl/core/core.h | 2 ++ drivers/cxl/core/features.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index f67b3d99461e..3f5474f155d0 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -118,6 +118,8 @@ int cxl_port_get_switch_dport_bandwidth(struct cxl_port *port, struct access_coordinate *c); #ifdef CONFIG_CXL_FEATURES +struct cxl_feat_entry *cxl_get_feature_entry(struct cxl_dev_state *cxlds, + const uuid_t *feat_uuid); size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, enum cxl_get_feat_selection selection, void *feat_out, size_t feat_out_size, u16 offset, diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c index 61298b79dc4f..66ed8e97fc08 100644 --- a/drivers/cxl/core/features.c +++ b/drivers/cxl/core/features.c @@ -209,6 +209,26 @@ int devm_cxl_setup_features(struct cxl_dev_state *cxlds) } EXPORT_SYMBOL_NS_GPL(devm_cxl_setup_features, "CXL"); +struct cxl_feat_entry *cxl_get_feature_entry(struct cxl_dev_state *cxlds, + const uuid_t *feat_uuid) +{ + struct cxl_features_state *cxlfs = to_cxlfs(cxlds); + struct cxl_feat_entry *feat_entry; + int count; + + /* + * Retrieve the feature entry from the supported features list, + * if the feature is supported. + */ + feat_entry = cxlfs->entries->ent; + for (count = 0; count < cxlfs->entries->num_features; count++, feat_entry++) { + if (uuid_equal(&feat_entry->uuid, feat_uuid)) + return feat_entry; + } + + return ERR_PTR(-ENOENT); +} + size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, enum cxl_get_feat_selection selection, void *feat_out, size_t feat_out_size, u16 offset,