smc_ib.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Shared Memory Communications over RDMA (SMC-R) and RoCE
  4. *
  5. * Definitions for IB environment
  6. *
  7. * Copyright IBM Corp. 2016
  8. *
  9. * Author(s): Ursula Braun <Ursula Braun@linux.vnet.ibm.com>
  10. */
  11. #ifndef _SMC_IB_H
  12. #define _SMC_IB_H
  13. #include <linux/interrupt.h>
  14. #include <linux/if_ether.h>
  15. #include <linux/mutex.h>
  16. #include <linux/wait.h>
  17. #include <rdma/ib_verbs.h>
  18. #include <net/smc.h>
  19. #define SMC_MAX_PORTS 2 /* Max # of ports */
  20. #define SMC_GID_SIZE sizeof(union ib_gid)
  21. #define SMC_IB_MAX_SEND_SGE 2
  22. struct smc_ib_devices { /* list of smc ib devices definition */
  23. struct list_head list;
  24. struct mutex mutex; /* protects list of smc ib devices */
  25. };
  26. extern struct smc_ib_devices smc_ib_devices; /* list of smc ib devices */
  27. struct smc_ib_device { /* ib-device infos for smc */
  28. struct list_head list;
  29. struct ib_device *ibdev;
  30. struct ib_port_attr pattr[SMC_MAX_PORTS]; /* ib dev. port attrs */
  31. struct ib_event_handler event_handler; /* global ib_event handler */
  32. struct ib_cq *roce_cq_send; /* send completion queue */
  33. struct ib_cq *roce_cq_recv; /* recv completion queue */
  34. struct tasklet_struct send_tasklet; /* called by send cq handler */
  35. struct tasklet_struct recv_tasklet; /* called by recv cq handler */
  36. char mac[SMC_MAX_PORTS][ETH_ALEN];
  37. /* mac address per port*/
  38. u8 pnetid[SMC_MAX_PORTS][SMC_MAX_PNETID_LEN];
  39. /* pnetid per port */
  40. bool pnetid_by_user[SMC_MAX_PORTS];
  41. /* pnetid defined by user? */
  42. u8 initialized : 1; /* ib dev CQ, evthdl done */
  43. struct work_struct port_event_work;
  44. unsigned long port_event_mask;
  45. DECLARE_BITMAP(ports_going_away, SMC_MAX_PORTS);
  46. atomic_t lnk_cnt; /* number of links on ibdev */
  47. wait_queue_head_t lnks_deleted; /* wait 4 removal of all links*/
  48. struct mutex mutex; /* protect dev setup+cleanup */
  49. };
  50. struct smc_buf_desc;
  51. struct smc_link;
  52. int smc_ib_register_client(void) __init;
  53. void smc_ib_unregister_client(void);
  54. bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport);
  55. int smc_ib_buf_map_sg(struct smc_link *lnk,
  56. struct smc_buf_desc *buf_slot,
  57. enum dma_data_direction data_direction);
  58. void smc_ib_buf_unmap_sg(struct smc_link *lnk,
  59. struct smc_buf_desc *buf_slot,
  60. enum dma_data_direction data_direction);
  61. void smc_ib_dealloc_protection_domain(struct smc_link *lnk);
  62. int smc_ib_create_protection_domain(struct smc_link *lnk);
  63. void smc_ib_destroy_queue_pair(struct smc_link *lnk);
  64. int smc_ib_create_queue_pair(struct smc_link *lnk);
  65. int smc_ib_ready_link(struct smc_link *lnk);
  66. int smc_ib_modify_qp_rts(struct smc_link *lnk);
  67. int smc_ib_modify_qp_reset(struct smc_link *lnk);
  68. int smc_ib_modify_qp_error(struct smc_link *lnk);
  69. long smc_ib_setup_per_ibdev(struct smc_ib_device *smcibdev);
  70. int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags,
  71. struct smc_buf_desc *buf_slot, u8 link_idx);
  72. void smc_ib_put_memory_region(struct ib_mr *mr);
  73. void smc_ib_sync_sg_for_cpu(struct smc_link *lnk,
  74. struct smc_buf_desc *buf_slot,
  75. enum dma_data_direction data_direction);
  76. void smc_ib_sync_sg_for_device(struct smc_link *lnk,
  77. struct smc_buf_desc *buf_slot,
  78. enum dma_data_direction data_direction);
  79. int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport,
  80. unsigned short vlan_id, u8 gid[], u8 *sgid_index);
  81. bool smc_ib_is_valid_local_systemid(void);
  82. #endif