smc_loopback.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Shared Memory Communications Direct over loopback-ism device.
  4. *
  5. * SMC-D loopback-ism device structure definitions.
  6. *
  7. * Copyright (c) 2024, Alibaba Inc.
  8. *
  9. * Author: Wen Gu <guwen@linux.alibaba.com>
  10. * Tony Lu <tonylu@linux.alibaba.com>
  11. *
  12. */
  13. #ifndef _SMC_LOOPBACK_H
  14. #define _SMC_LOOPBACK_H
  15. #include <linux/device.h>
  16. #include <net/smc.h>
  17. #if IS_ENABLED(CONFIG_SMC_LO)
  18. #define SMC_LO_MAX_DMBS 5000
  19. #define SMC_LO_DMBS_HASH_BITS 12
  20. #define SMC_LO_RESERVED_CHID 0xFFFF
  21. struct smc_lo_dmb_node {
  22. struct hlist_node list;
  23. u64 token;
  24. u32 len;
  25. u32 sba_idx;
  26. void *cpu_addr;
  27. dma_addr_t dma_addr;
  28. refcount_t refcnt;
  29. };
  30. struct smc_lo_dev {
  31. struct smcd_dev *smcd;
  32. struct device dev;
  33. u16 chid;
  34. struct smcd_gid local_gid;
  35. atomic_t dmb_cnt;
  36. rwlock_t dmb_ht_lock;
  37. DECLARE_BITMAP(sba_idx_mask, SMC_LO_MAX_DMBS);
  38. DECLARE_HASHTABLE(dmb_ht, SMC_LO_DMBS_HASH_BITS);
  39. wait_queue_head_t ldev_release;
  40. };
  41. int smc_loopback_init(void);
  42. void smc_loopback_exit(void);
  43. #else
  44. static inline int smc_loopback_init(void)
  45. {
  46. return 0;
  47. }
  48. static inline void smc_loopback_exit(void)
  49. {
  50. }
  51. #endif
  52. #endif /* _SMC_LOOPBACK_H */