smc_ib.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Shared Memory Communications over RDMA (SMC-R) and RoCE
  3. *
  4. * Definitions for IB environment
  5. *
  6. * Copyright IBM Corp. 2016
  7. *
  8. * Author(s): Ursula Braun <Ursula Braun@linux.vnet.ibm.com>
  9. */
  10. #ifndef _SMC_IB_H
  11. #define _SMC_IB_H
  12. #include <linux/interrupt.h>
  13. #include <linux/if_ether.h>
  14. #include <rdma/ib_verbs.h>
  15. #define SMC_MAX_PORTS 2 /* Max # of ports */
  16. #define SMC_GID_SIZE sizeof(union ib_gid)
  17. #define SMC_IB_MAX_SEND_SGE 2
  18. struct smc_ib_devices { /* list of smc ib devices definition */
  19. struct list_head list;
  20. spinlock_t lock; /* protects list of smc ib devices */
  21. };
  22. extern struct smc_ib_devices smc_ib_devices; /* list of smc ib devices */
  23. struct smc_ib_device { /* ib-device infos for smc */
  24. struct list_head list;
  25. struct ib_device *ibdev;
  26. struct ib_port_attr pattr[SMC_MAX_PORTS]; /* ib dev. port attrs */
  27. struct ib_event_handler event_handler; /* global ib_event handler */
  28. struct ib_cq *roce_cq_send; /* send completion queue */
  29. struct ib_cq *roce_cq_recv; /* recv completion queue */
  30. struct tasklet_struct send_tasklet; /* called by send cq handler */
  31. struct tasklet_struct recv_tasklet; /* called by recv cq handler */
  32. char mac[SMC_MAX_PORTS][ETH_ALEN];
  33. /* mac address per port*/
  34. union ib_gid gid[SMC_MAX_PORTS]; /* gid per port */
  35. u8 initialized : 1; /* ib dev CQ, evthdl done */
  36. struct work_struct port_event_work;
  37. unsigned long port_event_mask;
  38. };
  39. struct smc_buf_desc;
  40. struct smc_link;
  41. int smc_ib_register_client(void) __init;
  42. void smc_ib_unregister_client(void);
  43. bool smc_ib_port_active(struct smc_ib_device *smcibdev, u8 ibport);
  44. int smc_ib_remember_port_attr(struct smc_ib_device *smcibdev, u8 ibport);
  45. int smc_ib_buf_map_sg(struct smc_ib_device *smcibdev,
  46. struct smc_buf_desc *buf_slot,
  47. enum dma_data_direction data_direction);
  48. void smc_ib_buf_unmap_sg(struct smc_ib_device *smcibdev,
  49. struct smc_buf_desc *buf_slot,
  50. enum dma_data_direction data_direction);
  51. void smc_ib_dealloc_protection_domain(struct smc_link *lnk);
  52. int smc_ib_create_protection_domain(struct smc_link *lnk);
  53. void smc_ib_destroy_queue_pair(struct smc_link *lnk);
  54. int smc_ib_create_queue_pair(struct smc_link *lnk);
  55. int smc_ib_ready_link(struct smc_link *lnk);
  56. int smc_ib_modify_qp_rts(struct smc_link *lnk);
  57. int smc_ib_modify_qp_reset(struct smc_link *lnk);
  58. long smc_ib_setup_per_ibdev(struct smc_ib_device *smcibdev);
  59. int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags,
  60. struct smc_buf_desc *buf_slot);
  61. void smc_ib_put_memory_region(struct ib_mr *mr);
  62. void smc_ib_sync_sg_for_cpu(struct smc_ib_device *smcibdev,
  63. struct smc_buf_desc *buf_slot,
  64. enum dma_data_direction data_direction);
  65. void smc_ib_sync_sg_for_device(struct smc_ib_device *smcibdev,
  66. struct smc_buf_desc *buf_slot,
  67. enum dma_data_direction data_direction);
  68. #endif