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