smc.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #define SMC_MAX_PNETID_LEN 16 /* Max. length of PNET id */
  14. struct smc_hashinfo {
  15. rwlock_t lock;
  16. struct hlist_head ht;
  17. };
  18. int smc_hash_sk(struct sock *sk);
  19. void smc_unhash_sk(struct sock *sk);
  20. /* SMCD/ISM device driver interface */
  21. struct smcd_dmb {
  22. u64 dmb_tok;
  23. u64 rgid;
  24. u32 dmb_len;
  25. u32 sba_idx;
  26. u32 vlan_valid;
  27. u32 vlan_id;
  28. void *cpu_addr;
  29. dma_addr_t dma_addr;
  30. };
  31. #define ISM_EVENT_DMB 0
  32. #define ISM_EVENT_GID 1
  33. #define ISM_EVENT_SWR 2
  34. struct smcd_event {
  35. u32 type;
  36. u32 code;
  37. u64 tok;
  38. u64 time;
  39. u64 info;
  40. };
  41. struct smcd_dev;
  42. struct smcd_ops {
  43. int (*query_remote_gid)(struct smcd_dev *dev, u64 rgid, u32 vid_valid,
  44. u32 vid);
  45. int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
  46. int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
  47. int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
  48. int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
  49. int (*set_vlan_required)(struct smcd_dev *dev);
  50. int (*reset_vlan_required)(struct smcd_dev *dev);
  51. int (*signal_event)(struct smcd_dev *dev, u64 rgid, u32 trigger_irq,
  52. u32 event_code, u64 info);
  53. int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx,
  54. bool sf, unsigned int offset, void *data,
  55. unsigned int size);
  56. };
  57. struct smcd_dev {
  58. const struct smcd_ops *ops;
  59. struct device dev;
  60. void *priv;
  61. u64 local_gid;
  62. struct list_head list;
  63. spinlock_t lock;
  64. struct smc_connection **conn;
  65. struct list_head vlan;
  66. struct workqueue_struct *event_wq;
  67. u8 pnetid[SMC_MAX_PNETID_LEN];
  68. };
  69. struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
  70. const struct smcd_ops *ops, int max_dmbs);
  71. int smcd_register_dev(struct smcd_dev *smcd);
  72. void smcd_unregister_dev(struct smcd_dev *smcd);
  73. void smcd_free_dev(struct smcd_dev *smcd);
  74. void smcd_handle_event(struct smcd_dev *dev, struct smcd_event *event);
  75. void smcd_handle_irq(struct smcd_dev *dev, unsigned int bit);
  76. #endif /* _SMC_H */