diff options
author | Iwona Winiarska <iwona.winiarska@intel.com> | 2021-01-29 00:31:31 +0300 |
---|---|---|
committer | Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | 2021-10-20 01:10:37 +0300 |
commit | 8414dc5fd37b29d3d4a2ec5cfe2a06bfccc53fbd (patch) | |
tree | 52180bf0bf9489128268be4af33ee7c0bebd3df9 | |
parent | be4fc3a8ac4afce3ccd5c8d8653c49375e84fc47 (diff) | |
download | linux-8414dc5fd37b29d3d4a2ec5cfe2a06bfccc53fbd.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.c | 19 | ||||
-rw-r--r-- | include/linux/aspeed-mctp.h | 12 |
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); |