summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIwona Winiarska <iwona.winiarska@intel.com>2021-01-29 00:31:31 +0300
committerJae Hyun Yoo <jae.hyun.yoo@intel.com>2021-07-14 20:05:11 +0300
commit43b691f5a9b9694f6fbc954fc42bb95100b8c0b8 (patch)
tree1dccdea0daca8406c7ee0670605c8093e613ad77
parentd2f75c4e5cabf90dc8980b8f5e83dc6bf9000039 (diff)
downloadlinux-43b691f5a9b9694f6fbc954fc42bb95100b8c0b8.tar.xz
soc: aspeed: mctp: Export function used to read BDF
Recently, aspeed-mctp driver functionality was extended to store BDF values for already discovered MCTP endpoints on PCIe bus. Let's expose kernel API to read BDF based on endpoint ID. Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com>
-rw-r--r--drivers/soc/aspeed/aspeed-mctp.c19
-rw-r--r--include/linux/aspeed-mctp.h12
2 files changed, 31 insertions, 0 deletions
diff --git a/drivers/soc/aspeed/aspeed-mctp.c b/drivers/soc/aspeed/aspeed-mctp.c
index a534cceddb67..18755b70bbc6 100644
--- a/drivers/soc/aspeed/aspeed-mctp.c
+++ b/drivers/soc/aspeed/aspeed-mctp.c
@@ -995,6 +995,25 @@ aspeed_mctp_get_mtu(struct aspeed_mctp *priv, void __user *userbuf)
return 0;
}
+int aspeed_mctp_get_eid_bdf(struct mctp_client *client, u8 eid, u16 *bdf)
+{
+ struct aspeed_mctp_endpoint *endpoint;
+ int ret = -ENOENT;
+
+ mutex_lock(&client->priv->endpoints_lock);
+ list_for_each_entry(endpoint, &client->priv->endpoints, link) {
+ if (endpoint->data.eid == eid) {
+ *bdf = endpoint->data.bdf;
+ ret = 0;
+ break;
+ }
+ }
+ mutex_unlock(&client->priv->endpoints_lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(aspeed_mctp_get_eid_bdf);
+
static int
aspeed_mctp_get_eid_info(struct aspeed_mctp *priv, void __user *userbuf)
{
diff --git a/include/linux/aspeed-mctp.h b/include/linux/aspeed-mctp.h
index 3ec0bb2fad69..d56dceaf146d 100644
--- a/include/linux/aspeed-mctp.h
+++ b/include/linux/aspeed-mctp.h
@@ -117,6 +117,18 @@ struct mctp_pcie_packet *aspeed_mctp_receive_packet(struct mctp_client *client,
*/
void aspeed_mctp_flush_rx_queue(struct mctp_client *client);
+/**
+ * aspeed_mctp_get_eid_bdf() - return PCIe address for requested endpoint ID
+ * @client: pointer to existing mctp_client context
+ * @eid: requested eid
+ * @bdf: pointer to store BDF value
+ *
+ * Return:
+ * * 0 - success,
+ * * -ENOENT - there is no record for requested endpoint id.
+ */
+int aspeed_mctp_get_eid_bdf(struct mctp_client *client, u8 eid, u16 *bdf);
+
void *aspeed_mctp_packet_alloc(gfp_t flags);
void aspeed_mctp_packet_free(void *packet);