smc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Shared Memory Communications over RDMA (SMC-R) and RoCE
  4. *
  5. * Definitions for the SMC module (socket related)
  6. *
  7. * Copyright IBM Corp. 2016
  8. *
  9. * Author(s): Ursula Braun <ubraun@linux.vnet.ibm.com>
  10. */
  11. #ifndef _SMC_H
  12. #define _SMC_H
  13. #include <linux/device.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/types.h>
  16. #include <linux/wait.h>
  17. #include "linux/ism.h"
  18. struct sock;
  19. #define SMC_MAX_PNETID_LEN 16 /* Max. length of PNET id */
  20. struct smc_hashinfo {
  21. rwlock_t lock;
  22. struct hlist_head ht;
  23. };
  24. /* SMCD/ISM device driver interface */
  25. struct smcd_dmb {
  26. u64 dmb_tok;
  27. u64 rgid;
  28. u32 dmb_len;
  29. u32 sba_idx;
  30. u32 vlan_valid;
  31. u32 vlan_id;
  32. void *cpu_addr;
  33. dma_addr_t dma_addr;
  34. };
  35. #define ISM_EVENT_DMB 0
  36. #define ISM_EVENT_GID 1
  37. #define ISM_EVENT_SWR 2
  38. #define ISM_RESERVED_VLANID 0x1FFF
  39. #define ISM_ERROR 0xFFFF
  40. struct smcd_dev;
  41. struct smcd_gid {
  42. u64 gid;
  43. u64 gid_ext;
  44. };
  45. struct smcd_ops {
  46. int (*query_remote_gid)(struct smcd_dev *dev, struct smcd_gid *rgid,
  47. u32 vid_valid, u32 vid);
  48. int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb,
  49. void *client);
  50. int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
  51. int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx,
  52. bool sf, unsigned int offset, void *data,
  53. unsigned int size);
  54. int (*supports_v2)(void);
  55. void (*get_local_gid)(struct smcd_dev *dev, struct smcd_gid *gid);
  56. u16 (*get_chid)(struct smcd_dev *dev);
  57. struct device* (*get_dev)(struct smcd_dev *dev);
  58. /* optional operations */
  59. int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
  60. int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
  61. int (*set_vlan_required)(struct smcd_dev *dev);
  62. int (*reset_vlan_required)(struct smcd_dev *dev);
  63. int (*signal_event)(struct smcd_dev *dev, struct smcd_gid *rgid,
  64. u32 trigger_irq, u32 event_code, u64 info);
  65. int (*support_dmb_nocopy)(struct smcd_dev *dev);
  66. int (*attach_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
  67. int (*detach_dmb)(struct smcd_dev *dev, u64 token);
  68. };
  69. struct smcd_dev {
  70. const struct smcd_ops *ops;
  71. void *priv;
  72. void *client;
  73. struct list_head list;
  74. spinlock_t lock;
  75. struct smc_connection **conn;
  76. struct list_head vlan;
  77. struct workqueue_struct *event_wq;
  78. u8 pnetid[SMC_MAX_PNETID_LEN];
  79. bool pnetid_by_user;
  80. struct list_head lgr_list;
  81. spinlock_t lgr_lock;
  82. atomic_t lgr_cnt;
  83. wait_queue_head_t lgrs_deleted;
  84. u8 going_away : 1;
  85. };
  86. #endif /* _SMC_H */