smc_ib.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 <rdma/ib_verbs.h>
  16. #include <net/smc.h>
  17. #define SMC_MAX_PORTS 2 /* Max # of ports */
  18. #define SMC_GID_SIZE sizeof(union ib_gid)
  19. #define SMC_IB_MAX_SEND_SGE 2
  20. struct smc_ib_devices { /* list of smc ib devices definition */
  21. struct list_head list;
  22. spinlock_t lock; /* protects list of smc ib devices */
  23. };
  24. extern struct smc_ib_devices smc_ib_devices; /* list of smc ib devices */
  25. struct smc_ib_device { /* ib-device infos for smc */
  26. struct list_head list;
  27. struct ib_device *ibdev;
  28. struct ib_port_attr pattr[SMC_MAX_PORTS]; /* ib dev. port attrs */
  29. struct ib_event_handler event_handler; /* global ib_event handler */
  30. struct ib_cq *roce_cq_send; /* send completion queue */
  31. struct ib_cq *roce_cq_recv; /* recv completion queue */
  32. struct tasklet_struct send_tasklet; /* called by send cq handler */
  33. struct tasklet_struct recv_tasklet; /* called by recv cq handler */
  34. char mac[SMC_MAX_PORTS][ETH_ALEN];
  35. /* mac address per port*/
  36. u8 pnetid[SMC_MAX_PORTS][SMC_MAX_PNETID_LEN];
  37. /* pnetid per port */
  38. u8 initialized : 1; /* ib dev CQ, evthdl done */
  39. struct work_struct port_event_work;
  40. unsigned long port_event_mask;
  41. };
  42. struct smc_buf_desc;
  43. struct smc_link;
  44. int smc_ib_register_client(void) __init;
  45. void smc_ib_unregister_client(void);
  46. bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport);
  47. int smc_ib_buf_map_sg(struct smc_ib_device *smcibdev,
  48. struct smc_buf_desc *buf_slot,
  49. enum dma_data_direction data_direction);
  50. void smc_ib_buf_unmap_sg(struct smc_ib_device *smcibdev,
  51. struct smc_buf_desc *buf_slot,
  52. enum dma_data_direction data_direction);
  53. void smc_ib_dealloc_protection_domain(struct smc_link *lnk);
  54. int smc_ib_create_protection_domain(struct smc_link *lnk);
  55. void smc_ib_destroy_queue_pair(struct smc_link *lnk);
  56. int smc_ib_create_queue_pair(struct smc_link *lnk);
  57. int smc_ib_ready_link(struct smc_link *lnk);
  58. int smc_ib_modify_qp_rts(struct smc_link *lnk);
  59. int smc_ib_modify_qp_reset(struct smc_link *lnk);
  60. long smc_ib_setup_per_ibdev(struct smc_ib_device *smcibdev);
  61. int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags,
  62. struct smc_buf_desc *buf_slot);
  63. void smc_ib_put_memory_region(struct ib_mr *mr);
  64. void smc_ib_sync_sg_for_cpu(struct smc_ib_device *smcibdev,
  65. struct smc_buf_desc *buf_slot,
  66. enum dma_data_direction data_direction);
  67. void smc_ib_sync_sg_for_device(struct smc_ib_device *smcibdev,
  68. struct smc_buf_desc *buf_slot,
  69. enum dma_data_direction data_direction);
  70. int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport,
  71. unsigned short vlan_id, u8 gid[], u8 *sgid_index);
  72. #endif