^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Shared Memory Communications over RDMA (SMC-R) and RoCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * PNET table queries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright IBM Corp. 2016
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Author(s): Thomas Richter <tmricht@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #ifndef _SMC_PNET_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define _SMC_PNET_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <net/smc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #if IS_ENABLED(CONFIG_HAVE_PNETID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/pnet.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct smc_ib_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct smcd_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct smc_init_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct smc_link_group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * struct smc_pnettable - SMC PNET table anchor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * @lock: Lock for list action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * @pnetlist: List of PNETIDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct smc_pnettable {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct list_head pnetlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct smc_pnetids_ndev { /* list of pnetids for net devices in UP state*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) rwlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct smc_pnetids_ndev_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) u8 pnetid[SMC_MAX_PNETID_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) refcount_t refcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static inline int smc_pnetid_by_dev_port(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned short port, u8 *pnetid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #if IS_ENABLED(CONFIG_HAVE_PNETID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) return pnet_id_by_dev_port(dev, port, pnetid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int smc_pnet_init(void) __init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) int smc_pnet_net_init(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void smc_pnet_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void smc_pnet_net_exit(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) void smc_pnet_find_roce_resource(struct sock *sk, struct smc_init_info *ini);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) void smc_pnet_find_ism_resource(struct sock *sk, struct smc_init_info *ini);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int smc_pnetid_by_table_ib(struct smc_ib_device *smcibdev, u8 ib_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int smc_pnetid_by_table_smcd(struct smcd_dev *smcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) void smc_pnet_find_alt_roce(struct smc_link_group *lgr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct smc_init_info *ini,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct smc_ib_device *known_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) bool smc_pnet_is_ndev_pnetid(struct net *net, u8 *pnetid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) bool smc_pnet_is_pnetid_set(u8 *pnetid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #endif