xref: /linux/include/rdma/signature.h (revision 39289bfc)
136b1e47fSMax Gurtovoy /* SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) */
236b1e47fSMax Gurtovoy /*
336b1e47fSMax Gurtovoy  * Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved.
436b1e47fSMax Gurtovoy  */
536b1e47fSMax Gurtovoy 
636b1e47fSMax Gurtovoy #ifndef _RDMA_SIGNATURE_H_
736b1e47fSMax Gurtovoy #define _RDMA_SIGNATURE_H_
836b1e47fSMax Gurtovoy 
9*39289bfcSJason Gunthorpe #include <linux/types.h>
10*39289bfcSJason Gunthorpe 
1136b1e47fSMax Gurtovoy enum ib_signature_prot_cap {
1236b1e47fSMax Gurtovoy 	IB_PROT_T10DIF_TYPE_1 = 1,
1336b1e47fSMax Gurtovoy 	IB_PROT_T10DIF_TYPE_2 = 1 << 1,
1436b1e47fSMax Gurtovoy 	IB_PROT_T10DIF_TYPE_3 = 1 << 2,
1536b1e47fSMax Gurtovoy };
1636b1e47fSMax Gurtovoy 
1736b1e47fSMax Gurtovoy enum ib_signature_guard_cap {
1836b1e47fSMax Gurtovoy 	IB_GUARD_T10DIF_CRC	= 1,
1936b1e47fSMax Gurtovoy 	IB_GUARD_T10DIF_CSUM	= 1 << 1,
2036b1e47fSMax Gurtovoy };
2136b1e47fSMax Gurtovoy 
2236b1e47fSMax Gurtovoy /**
2336b1e47fSMax Gurtovoy  * enum ib_signature_type - Signature types
2436b1e47fSMax Gurtovoy  * @IB_SIG_TYPE_NONE: Unprotected.
2536b1e47fSMax Gurtovoy  * @IB_SIG_TYPE_T10_DIF: Type T10-DIF
2636b1e47fSMax Gurtovoy  */
2736b1e47fSMax Gurtovoy enum ib_signature_type {
2836b1e47fSMax Gurtovoy 	IB_SIG_TYPE_NONE,
2936b1e47fSMax Gurtovoy 	IB_SIG_TYPE_T10_DIF,
3036b1e47fSMax Gurtovoy };
3136b1e47fSMax Gurtovoy 
3236b1e47fSMax Gurtovoy /**
3336b1e47fSMax Gurtovoy  * enum ib_t10_dif_bg_type - Signature T10-DIF block-guard types
3436b1e47fSMax Gurtovoy  * @IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules.
3536b1e47fSMax Gurtovoy  * @IB_T10DIF_CSUM: Corresponds to IP checksum rules.
3636b1e47fSMax Gurtovoy  */
3736b1e47fSMax Gurtovoy enum ib_t10_dif_bg_type {
3836b1e47fSMax Gurtovoy 	IB_T10DIF_CRC,
3936b1e47fSMax Gurtovoy 	IB_T10DIF_CSUM,
4036b1e47fSMax Gurtovoy };
4136b1e47fSMax Gurtovoy 
4236b1e47fSMax Gurtovoy /**
4336b1e47fSMax Gurtovoy  * struct ib_t10_dif_domain - Parameters specific for T10-DIF
4436b1e47fSMax Gurtovoy  *     domain.
4536b1e47fSMax Gurtovoy  * @bg_type: T10-DIF block guard type (CRC|CSUM)
4636b1e47fSMax Gurtovoy  * @pi_interval: protection information interval.
4736b1e47fSMax Gurtovoy  * @bg: seed of guard computation.
4836b1e47fSMax Gurtovoy  * @app_tag: application tag of guard block
4936b1e47fSMax Gurtovoy  * @ref_tag: initial guard block reference tag.
5036b1e47fSMax Gurtovoy  * @ref_remap: Indicate wethear the reftag increments each block
5136b1e47fSMax Gurtovoy  * @app_escape: Indicate to skip block check if apptag=0xffff
5236b1e47fSMax Gurtovoy  * @ref_escape: Indicate to skip block check if reftag=0xffffffff
5336b1e47fSMax Gurtovoy  * @apptag_check_mask: check bitmask of application tag.
5436b1e47fSMax Gurtovoy  */
5536b1e47fSMax Gurtovoy struct ib_t10_dif_domain {
5636b1e47fSMax Gurtovoy 	enum ib_t10_dif_bg_type bg_type;
5736b1e47fSMax Gurtovoy 	u16			pi_interval;
5836b1e47fSMax Gurtovoy 	u16			bg;
5936b1e47fSMax Gurtovoy 	u16			app_tag;
6036b1e47fSMax Gurtovoy 	u32			ref_tag;
6136b1e47fSMax Gurtovoy 	bool			ref_remap;
6236b1e47fSMax Gurtovoy 	bool			app_escape;
6336b1e47fSMax Gurtovoy 	bool			ref_escape;
6436b1e47fSMax Gurtovoy 	u16			apptag_check_mask;
6536b1e47fSMax Gurtovoy };
6636b1e47fSMax Gurtovoy 
6736b1e47fSMax Gurtovoy /**
6836b1e47fSMax Gurtovoy  * struct ib_sig_domain - Parameters for signature domain
6936b1e47fSMax Gurtovoy  * @sig_type: specific signauture type
7036b1e47fSMax Gurtovoy  * @sig: union of all signature domain attributes that may
7136b1e47fSMax Gurtovoy  *     be used to set domain layout.
7236b1e47fSMax Gurtovoy  */
7336b1e47fSMax Gurtovoy struct ib_sig_domain {
7436b1e47fSMax Gurtovoy 	enum ib_signature_type sig_type;
7536b1e47fSMax Gurtovoy 	union {
7636b1e47fSMax Gurtovoy 		struct ib_t10_dif_domain dif;
7736b1e47fSMax Gurtovoy 	} sig;
7836b1e47fSMax Gurtovoy };
7936b1e47fSMax Gurtovoy 
8036b1e47fSMax Gurtovoy /**
8136b1e47fSMax Gurtovoy  * struct ib_sig_attrs - Parameters for signature handover operation
8236b1e47fSMax Gurtovoy  * @check_mask: bitmask for signature byte check (8 bytes)
8336b1e47fSMax Gurtovoy  * @mem: memory domain layout descriptor.
8436b1e47fSMax Gurtovoy  * @wire: wire domain layout descriptor.
857c717d3aSMax Gurtovoy  * @meta_length: metadata length
8636b1e47fSMax Gurtovoy  */
8736b1e47fSMax Gurtovoy struct ib_sig_attrs {
8836b1e47fSMax Gurtovoy 	u8			check_mask;
8936b1e47fSMax Gurtovoy 	struct ib_sig_domain	mem;
9036b1e47fSMax Gurtovoy 	struct ib_sig_domain	wire;
917c717d3aSMax Gurtovoy 	int			meta_length;
9236b1e47fSMax Gurtovoy };
9336b1e47fSMax Gurtovoy 
9436b1e47fSMax Gurtovoy enum ib_sig_err_type {
9536b1e47fSMax Gurtovoy 	IB_SIG_BAD_GUARD,
9636b1e47fSMax Gurtovoy 	IB_SIG_BAD_REFTAG,
9736b1e47fSMax Gurtovoy 	IB_SIG_BAD_APPTAG,
9836b1e47fSMax Gurtovoy };
9936b1e47fSMax Gurtovoy 
10036b1e47fSMax Gurtovoy /*
10136b1e47fSMax Gurtovoy  * Signature check masks (8 bytes in total) according to the T10-PI standard:
10236b1e47fSMax Gurtovoy  *  -------- -------- ------------
10336b1e47fSMax Gurtovoy  * | GUARD  | APPTAG |   REFTAG   |
10436b1e47fSMax Gurtovoy  * |  2B    |  2B    |    4B      |
10536b1e47fSMax Gurtovoy  *  -------- -------- ------------
10636b1e47fSMax Gurtovoy  */
10736b1e47fSMax Gurtovoy enum {
10836b1e47fSMax Gurtovoy 	IB_SIG_CHECK_GUARD = 0xc0,
10936b1e47fSMax Gurtovoy 	IB_SIG_CHECK_APPTAG = 0x30,
11036b1e47fSMax Gurtovoy 	IB_SIG_CHECK_REFTAG = 0x0f,
11136b1e47fSMax Gurtovoy };
11236b1e47fSMax Gurtovoy 
11336b1e47fSMax Gurtovoy /*
11436b1e47fSMax Gurtovoy  * struct ib_sig_err - signature error descriptor
11536b1e47fSMax Gurtovoy  */
11636b1e47fSMax Gurtovoy struct ib_sig_err {
11736b1e47fSMax Gurtovoy 	enum ib_sig_err_type	err_type;
11836b1e47fSMax Gurtovoy 	u32			expected;
11936b1e47fSMax Gurtovoy 	u32			actual;
12036b1e47fSMax Gurtovoy 	u64			sig_err_offset;
12136b1e47fSMax Gurtovoy 	u32			key;
12236b1e47fSMax Gurtovoy };
12336b1e47fSMax Gurtovoy 
12436b1e47fSMax Gurtovoy #endif /* _RDMA_SIGNATURE_H_ */
125