Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) */
0002 /*
0003  * Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved.
0004  */
0005 
0006 #ifndef _RDMA_SIGNATURE_H_
0007 #define _RDMA_SIGNATURE_H_
0008 
0009 #include <linux/types.h>
0010 
0011 enum ib_signature_prot_cap {
0012     IB_PROT_T10DIF_TYPE_1 = 1,
0013     IB_PROT_T10DIF_TYPE_2 = 1 << 1,
0014     IB_PROT_T10DIF_TYPE_3 = 1 << 2,
0015 };
0016 
0017 enum ib_signature_guard_cap {
0018     IB_GUARD_T10DIF_CRC = 1,
0019     IB_GUARD_T10DIF_CSUM    = 1 << 1,
0020 };
0021 
0022 /**
0023  * enum ib_signature_type - Signature types
0024  * @IB_SIG_TYPE_NONE: Unprotected.
0025  * @IB_SIG_TYPE_T10_DIF: Type T10-DIF
0026  */
0027 enum ib_signature_type {
0028     IB_SIG_TYPE_NONE,
0029     IB_SIG_TYPE_T10_DIF,
0030 };
0031 
0032 /**
0033  * enum ib_t10_dif_bg_type - Signature T10-DIF block-guard types
0034  * @IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules.
0035  * @IB_T10DIF_CSUM: Corresponds to IP checksum rules.
0036  */
0037 enum ib_t10_dif_bg_type {
0038     IB_T10DIF_CRC,
0039     IB_T10DIF_CSUM,
0040 };
0041 
0042 /**
0043  * struct ib_t10_dif_domain - Parameters specific for T10-DIF
0044  *     domain.
0045  * @bg_type: T10-DIF block guard type (CRC|CSUM)
0046  * @pi_interval: protection information interval.
0047  * @bg: seed of guard computation.
0048  * @app_tag: application tag of guard block
0049  * @ref_tag: initial guard block reference tag.
0050  * @ref_remap: Indicate wethear the reftag increments each block
0051  * @app_escape: Indicate to skip block check if apptag=0xffff
0052  * @ref_escape: Indicate to skip block check if reftag=0xffffffff
0053  * @apptag_check_mask: check bitmask of application tag.
0054  */
0055 struct ib_t10_dif_domain {
0056     enum ib_t10_dif_bg_type bg_type;
0057     u16         pi_interval;
0058     u16         bg;
0059     u16         app_tag;
0060     u32         ref_tag;
0061     bool            ref_remap;
0062     bool            app_escape;
0063     bool            ref_escape;
0064     u16         apptag_check_mask;
0065 };
0066 
0067 /**
0068  * struct ib_sig_domain - Parameters for signature domain
0069  * @sig_type: specific signauture type
0070  * @sig: union of all signature domain attributes that may
0071  *     be used to set domain layout.
0072  */
0073 struct ib_sig_domain {
0074     enum ib_signature_type sig_type;
0075     union {
0076         struct ib_t10_dif_domain dif;
0077     } sig;
0078 };
0079 
0080 /**
0081  * struct ib_sig_attrs - Parameters for signature handover operation
0082  * @check_mask: bitmask for signature byte check (8 bytes)
0083  * @mem: memory domain layout descriptor.
0084  * @wire: wire domain layout descriptor.
0085  * @meta_length: metadata length
0086  */
0087 struct ib_sig_attrs {
0088     u8          check_mask;
0089     struct ib_sig_domain    mem;
0090     struct ib_sig_domain    wire;
0091     int         meta_length;
0092 };
0093 
0094 enum ib_sig_err_type {
0095     IB_SIG_BAD_GUARD,
0096     IB_SIG_BAD_REFTAG,
0097     IB_SIG_BAD_APPTAG,
0098 };
0099 
0100 /*
0101  * Signature check masks (8 bytes in total) according to the T10-PI standard:
0102  *  -------- -------- ------------
0103  * | GUARD  | APPTAG |   REFTAG   |
0104  * |  2B    |  2B    |    4B      |
0105  *  -------- -------- ------------
0106  */
0107 enum {
0108     IB_SIG_CHECK_GUARD = 0xc0,
0109     IB_SIG_CHECK_APPTAG = 0x30,
0110     IB_SIG_CHECK_REFTAG = 0x0f,
0111 };
0112 
0113 /*
0114  * struct ib_sig_err - signature error descriptor
0115  */
0116 struct ib_sig_err {
0117     enum ib_sig_err_type    err_type;
0118     u32         expected;
0119     u32         actual;
0120     u64         sig_err_offset;
0121     u32         key;
0122 };
0123 
0124 #endif /* _RDMA_SIGNATURE_H_ */