diff options
author | Iwona Winiarska <iwona.winiarska@intel.com> | 2021-01-29 00:31:31 +0300 |
---|---|---|
committer | Iwona Winiarska <iwona.winiarska@intel.com> | 2021-02-04 16:16:07 +0300 |
commit | 706078bea2580f4af85d387de4d380d9c1432c57 (patch) | |
tree | e871331a645abf660540660a92be72609f7f8457 | |
parent | 5d84cfdc23ae7e4f5687228cd5de9c8f3f64a0b1 (diff) | |
download | linux-706078bea2580f4af85d387de4d380d9c1432c57.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.
Change-Id: I146e67a8c2f4f541b4c3065c18dcadf531f30670
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 8161d5bc7079..7a9d4bc332a0 100644 --- a/drivers/soc/aspeed/aspeed-mctp.c +++ b/drivers/soc/aspeed/aspeed-mctp.c @@ -996,6 +996,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); |