smc_pnet.h 1.7 KB

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