signature.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) */
  2. /*
  3. * Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved.
  4. */
  5. #ifndef _RDMA_SIGNATURE_H_
  6. #define _RDMA_SIGNATURE_H_
  7. #include <linux/types.h>
  8. enum ib_signature_prot_cap {
  9. IB_PROT_T10DIF_TYPE_1 = 1,
  10. IB_PROT_T10DIF_TYPE_2 = 1 << 1,
  11. IB_PROT_T10DIF_TYPE_3 = 1 << 2,
  12. };
  13. enum ib_signature_guard_cap {
  14. IB_GUARD_T10DIF_CRC = 1,
  15. IB_GUARD_T10DIF_CSUM = 1 << 1,
  16. };
  17. /**
  18. * enum ib_signature_type - Signature types
  19. * @IB_SIG_TYPE_NONE: Unprotected.
  20. * @IB_SIG_TYPE_T10_DIF: Type T10-DIF
  21. */
  22. enum ib_signature_type {
  23. IB_SIG_TYPE_NONE,
  24. IB_SIG_TYPE_T10_DIF,
  25. };
  26. /**
  27. * enum ib_t10_dif_bg_type - Signature T10-DIF block-guard types
  28. * @IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules.
  29. * @IB_T10DIF_CSUM: Corresponds to IP checksum rules.
  30. */
  31. enum ib_t10_dif_bg_type {
  32. IB_T10DIF_CRC,
  33. IB_T10DIF_CSUM,
  34. };
  35. /**
  36. * struct ib_t10_dif_domain - Parameters specific for T10-DIF
  37. * domain.
  38. * @bg_type: T10-DIF block guard type (CRC|CSUM)
  39. * @pi_interval: protection information interval.
  40. * @bg: seed of guard computation.
  41. * @app_tag: application tag of guard block
  42. * @ref_tag: initial guard block reference tag.
  43. * @ref_remap: Indicate wethear the reftag increments each block
  44. * @app_escape: Indicate to skip block check if apptag=0xffff
  45. * @ref_escape: Indicate to skip block check if reftag=0xffffffff
  46. * @apptag_check_mask: check bitmask of application tag.
  47. */
  48. struct ib_t10_dif_domain {
  49. enum ib_t10_dif_bg_type bg_type;
  50. u16 pi_interval;
  51. u16 bg;
  52. u16 app_tag;
  53. u32 ref_tag;
  54. bool ref_remap;
  55. bool app_escape;
  56. bool ref_escape;
  57. u16 apptag_check_mask;
  58. };
  59. /**
  60. * struct ib_sig_domain - Parameters for signature domain
  61. * @sig_type: specific signauture type
  62. * @sig: union of all signature domain attributes that may
  63. * be used to set domain layout.
  64. */
  65. struct ib_sig_domain {
  66. enum ib_signature_type sig_type;
  67. union {
  68. struct ib_t10_dif_domain dif;
  69. } sig;
  70. };
  71. /**
  72. * struct ib_sig_attrs - Parameters for signature handover operation
  73. * @check_mask: bitmask for signature byte check (8 bytes)
  74. * @mem: memory domain layout descriptor.
  75. * @wire: wire domain layout descriptor.
  76. * @meta_length: metadata length
  77. */
  78. struct ib_sig_attrs {
  79. u8 check_mask;
  80. struct ib_sig_domain mem;
  81. struct ib_sig_domain wire;
  82. int meta_length;
  83. };
  84. enum ib_sig_err_type {
  85. IB_SIG_BAD_GUARD,
  86. IB_SIG_BAD_REFTAG,
  87. IB_SIG_BAD_APPTAG,
  88. };
  89. /*
  90. * Signature check masks (8 bytes in total) according to the T10-PI standard:
  91. * -------- -------- ------------
  92. * | GUARD | APPTAG | REFTAG |
  93. * | 2B | 2B | 4B |
  94. * -------- -------- ------------
  95. */
  96. enum {
  97. IB_SIG_CHECK_GUARD = 0xc0,
  98. IB_SIG_CHECK_APPTAG = 0x30,
  99. IB_SIG_CHECK_REFTAG = 0x0f,
  100. };
  101. /*
  102. * struct ib_sig_err - signature error descriptor
  103. */
  104. struct ib_sig_err {
  105. enum ib_sig_err_type err_type;
  106. u32 expected;
  107. u32 actual;
  108. u64 sig_err_offset;
  109. u32 key;
  110. };
  111. #endif /* _RDMA_SIGNATURE_H_ */