'\" t
.\" Automatically generated by Pandoc 3.1.11.1
.\"
.TH "mlx5dv_wr_set_mkey_sig_block" "3" "" "" ""
.SH NAME
mlx5dv_wr_set_mkey_sig_block \- Configure a MKEY for block signature
(data integrity) operation.
.SH SYNOPSIS
.IP
.EX
#include <infiniband/mlx5dv.h>

static inline void mlx5dv_wr_set_mkey_sig_block(struct mlx5dv_qp_ex *mqp,
                                                const struct mlx5dv_sig_block_attr *attr)
.EE
.SH DESCRIPTION
Configure a MKEY with block\-level data protection properties.
With this, the device can add/modify/strip/validate integrity fields per
block when transmitting data from memory to network and when receiving
data from network to memory.
.PP
This setter can be optionally called after a MKEY configuration work
request posting has started using \f[B]mlx5dv_wr_mkey_configure\f[R](3).
Configuring block signature properties to a MKEY is done by describing
what kind of signature is required (or expected) in two domains: the
wire domain and the memory domain.
.PP
The MKEY represents a virtually contiguous memory, by configuring a
layout to it.
The memory signature domain describes whether data in this virtually
contiguous memory includes integrity fields, and if so, what
kind(\f[B]enum mlx5dv_sig_type\f[R]) and what block size(\f[B]enum
mlx5dv_block_size\f[R]).
.PP
The wire signature domain describes the same kind of properties for the
data as it is seen on the wire.
Now, depending on the actual operation that happens (TX or RX), the
device will do the \[lq]right thing\[rq] based on the signature
configurations of the two domains.
.SS Example 1:
Memory signature domain is configured for CRC32 every 512B block.
.PP
Wire signature domain is configured for no signature.
.PP
A SEND is issued using the MKEY as a local key.
.PP
Result: device will gather the data with the CRC32 fields from the MKEY
(using whatever layout configured to the MKEY to locate the actual
memory), validate each CRC32 against the previous 512 bytes of data,
strip the CRC32 field, and transmit only 512 bytes of data to the wire.
.SS Example 1.1:
Same as above, but a RECV is issued with the same key, and RX happens.
.PP
Result: device will receive the data from the wire, scatter it to the
MKEY (using whatever layout configured to the MKEY to locate the actual
memory), generating and scattering additional CRC32 field after every
512 bytes that are scattered.
.SS Example 2:
Memory signature domain is configured for no signature.
.PP
Wire signature domain is configured for T10DIF every 4K block.
.PP
The MKEY is sent to a remote node that issues a RDMA_READ to this MKEY.
.PP
Result: device will gather the data from the MKEY (using whatever layout
configured to the MKEY to locate the actual memory), transmit it to the
wire while generating an additional T10DIF field every 4K of data.
.SS Example 2.1:
Same as above, but remote node issues a RDMA_WRITE to this MKEY.
.PP
Result: Device will receive the data from the wire, validate each T10DIF
field against the previous 4K of data, strip the T10DIF field, and
scatter the data alone to the MKEY (using whatever layout configured to
the MKEY to locate the actual memory).
.SH ARGUMENTS
.TP
\f[I]mqp\f[R]
.IP
.EX
The QP where an MKEY configuration work request was created by
.EE
.RS
.PP
\f[B]mlx5dv_wr_mkey_configure()\f[R].
.RE
.TP
\f[I]attr\f[R]
Block signature attributes to set for the MKEY.
.SS Block signature attributes
Block signature attributes describe the input and output data structures
in memory and wire domains.
.IP
.EX
struct mlx5dv_sig_block_attr {
    const struct mlx5dv_sig_block_domain *mem;
    const struct mlx5dv_sig_block_domain *wire;
    uint32_t flags;
    uint8_t check_mask;
    uint8_t copy_mask;
    uint64_t comp_mask;
};
.EE
.TP
\f[I]mem\f[R]
A pointer to the signature configuration for the memory domain or NULL
if the domain does not have a signature.
.TP
\f[I]wire\f[R]
A pointer to the signature configuration for the wire domain or NULL if
the domain does not have a signature.
.TP
\f[I]flags\f[R]
A bitwise OR of the various values described below.
.RS
.TP
\f[B]MLX5DV_SIG_BLOCK_ATTR_FLAG_COPY_MASK\f[R]
If the bit is not set, then \f[I]copy_mask\f[R] is ignored.
See details in the \f[I]copy_mask\f[R] description.
.RE
.TP
\f[I]check_mask\f[R]
Each bit of \f[I]check_mask\f[R] corresponds to a byte of the signature
field in input domain.
Byte of the input signature is checked if corresponding bit in
\f[I]check_mask\f[R] is set.
Bits not relevant to the signature type are ignored.
.RS
.PP
Layout of \f[I]check_mask\f[R].
.TS
tab(@);
lw(14.7n) lw(6.9n) lw(6.9n) lw(6.9n) lw(6.9n) lw(6.9n) lw(6.9n) lw(6.9n) lw(6.9n).
T{
check_mask (bits)
T}@T{
7
T}@T{
6
T}@T{
5
T}@T{
4
T}@T{
3
T}@T{
2
T}@T{
1
T}@T{
0
T}
_
T{
T10\-DIF (bytes)
T}@T{
GUARD[1]
T}@T{
GUARD[0]
T}@T{
APP[1]
T}@T{
APP[0]
T}@T{
REF[3]
T}@T{
REF[2]
T}@T{
REF[1]
T}@T{
REF[0]
T}
T{
CRC32C/CRC32 (bytes)
T}@T{
3
T}@T{
2
T}@T{
1
T}@T{
0
T}@T{
T}@T{
T}@T{
T}@T{
T}
T{
CRC64_XP10 (bytes)
T}@T{
7
T}@T{
6
T}@T{
5
T}@T{
4
T}@T{
3
T}@T{
2
T}@T{
1
T}@T{
0
T}
.TE
.PP
Common used masks are defined in \f[B]enum mlx5dv_sig_mask\f[R].
Other masks are also supported.
Follow the above table to define a custom mask.
For example, this can be useful for the application tag field of the
T10DIF signature.
Using the application tag is out of the scope of the T10DIF
specification and depends on the implementation.
\f[I]check_mask\f[R] allows validating a part of the application tag if
needed.
.RE
.TP
\f[I]copy_mask\f[R]
A mask to specify what part of the signature is copied from the source
domain to the destination domain.
The copy mask is usually calculated automatically.
The signature is copied if the same signature type is configurted on
both domains.
The parts of the T10\-DIF are compared and handled independetly.
.RS
.PP
If \f[B]MLX5DV_SIG_BLOCK_ATTR_FLAG_COPY_MASK\f[R] is set, the
\f[I]copy_mask\f[R] attribute overrides the calculated value of the copy
mask.
Otherwise, \f[I]copy_mask\f[R] is ignored.
.PP
Each bit of \f[I]copy_mask\f[R] corresponds to a byte of the signature
field.
If corresponding bit in \f[I]copy_mask\f[R] is set, byte of the
signature field is copied from the input domain to the output domain.
Calculation according to the output domain configuration is not
performed in this case.
Bits not relevant to the signature type are ignored.
\f[I]copy_mask\f[R] may be used only if input and output domains have
the same structure, i.e.\ same block size and signature type.
The MKEY configuration will fail if
\f[B]MLX5DV_SIG_BLOCK_ATTR_FLAG_COPY_MASK\f[R] is set but the domains
have different signature structures.
.PP
The predefined masks are available in \f[B]enum mlx5dv_sig_mask\f[R].
It is also supported to specify a user\-defined mask.
Follow the table in \f[I]check_mask\f[R] description to define a custom
mask.
.PP
\f[I]copy_mask\f[R] can be useful when some bytes of the signature are
not known in advance, hence can\[cq]t be checked, but shall be
preserved.
In this case corresponding bits should be cleared in
\f[I]check_mask\f[R] and set in \f[I]copy_mask\f[R].
.RE
.TP
\f[I]comp_mask\f[R]
Reserved for future extension, must be 0 now.
.SS Block signature domain
.IP
.EX
struct mlx5dv_sig_block_domain {
    enum mlx5dv_sig_type sig_type;
    union {
        const struct mlx5dv_sig_t10dif *dif;
        const struct mlx5dv_sig_crc *crc;
    } sig;
    enum mlx5dv_block_size block_size;
    uint64_t comp_mask;
};
.EE
.TP
\f[I]sig_type\f[R]
The signature type for this domain, one of the following
.RS
.TP
\f[B]MLX5DV_SIG_TYPE_T10DIF\f[R]
The block\-level data protection defined in the T10 specifications (T10
SBC\-3).
.TP
\f[B]MLX5DV_SIG_TYPE_CRC\f[R]
The block\-level data protection based on cyclic redundancy check (CRC).
The specific type of CRC is defined in \f[I]sig\f[R].
.RE
.TP
\f[I]sig\f[R]
Depending on \f[I]sig_type\f[R], this is the per signature type specific
configuration.
.TP
\f[I]block_size\f[R]
The block size for this domain, one of \f[B]enum mlx5dv_block_size\f[R].
.TP
\f[I]comp_mask\f[R]
Reserved for future extension, must be 0 now.
.SS CRC signature
.IP
.EX
struct mlx5dv_sig_crc {
    enum mlx5dv_sig_crc_type type;
    uint64_t seed;
};
.EE
.TP
\f[I]type\f[R]
The specific CRC type, one of the following.
.RS
.TP
\f[B]MLX5DV_SIG_CRC_TYPE_CRC32\f[R]
CRC32 signature is created by calculating a 32\-bit CRC defined in Fibre
Channel Physical and Signaling Interface (FC\-PH), ANSI X3.230:1994.
.TP
\f[B]MLX5DV_SIG_CRC_TYPE_CRC32C\f[R]
CRC32C signature is created by calculating a 32\-bit CRC called the
Castagnoli CRC, defined in the Internet Small Computer Systems Interface
(iSCSI) rfc3720.
.TP
\f[B]MLX5DV_SIG_CRC_TYPE_CRC64_XP10\f[R]
CRC64_XP10 signature is created by calculating a 64\-bit CRC defined in
Microsoft XP10 compression standard.
.RE
.TP
\f[I]seed\f[R]
A seed for the CRC calculation per block.
Bits not relevant to the CRC type are ignored.
For example, all bits are used for CRC64_XP10, but only the 32 least
significant bits are used for CRC32/CRC32C.
.RS
.PP
Only the following values are supported as a seed: CRC32/CRC32C \- 0,
0xFFFFFFFF(UINT32_MAX); CRC64_XP10 \- 0, 0xFFFFFFFFFFFFFFFF(UINT64_MAX).
.RE
.SS T10DIF signature
T10DIF signature is defined in the T10 specifications (T10 SBC\-3) for
block\-level data protection.
The size of data block protected by T10DIF must be modulo 8bytes as
required in the T10DIF specifications.
Note that when setting the initial LBA value to \f[I]ref_tag\f[R], it
should be the value of the first block to be transmitted.
.IP
.EX
struct mlx5dv_sig_t10dif {
    enum mlx5dv_sig_t10dif_bg_type bg_type;
    uint16_t bg;
    uint16_t app_tag;
    uint32_t ref_tag;
    uint16_t flags;
};
.EE
.TP
\f[I]bg_type\f[R]
The block guard type to be used, one of the following.
.RS
.TP
\f[B]MLX5DV_SIG_T10DIF_CRC\f[R]
Use CRC in the block guard field as required in the T10DIF
specifications.
.TP
\f[B]MLX5DV_SIG_T10DIF_CSUM\f[R]
Use IP checksum instead of CRC in the block guard field.
.RE
.TP
\f[I]bg\f[R]
A seed for the block guard calculation per block.
.RS
.PP
The following values are supported as a seed: 0, 0xFFFF(UINT16_MAX).
.RE
.TP
\f[I]app_tag\f[R]
An application tag to generate or validate.
.TP
\f[I]ref_tag\f[R]
A reference tag to generate or validate.
.TP
\f[I]flags\f[R]
Flags for the T10DIF attributes, one of the following.
.RS
.TP
\f[B]MLX5DV_SIG_T10DIF_FLAG_REF_REMAP\f[R]
Increment reference tag per block.
.TP
\f[B]MLX5DV_SIG_T10DIF_FLAG_APP_ESCAPE\f[R]
Do not check block guard if application tag is 0xFFFF.
.TP
\f[B]MLX5DV_SIG_T10DIF_FLAG_APP_REF_ESCAPE\f[R]
Do not check block guard if application tag is 0xFFFF and reference tag
is 0xFFFFFFFF.
.RE
.SH RETURN VALUE
This function does not return a value.
.PP
In case of error, user will be notified later when completing the DV WRs
chain.
.SH Notes
A DEVX context should be opened by using
\f[B]mlx5dv_open_device\f[R](3).
.PP
MKEY must be created with
\f[B]MLX5DV_MKEY_INIT_ATTR_FLAGS_BLOCK_SIGNATURE\f[R] flag.
.PP
The last operation posted on the supplied QP should be
\f[B]mlx5dv_wr_mkey_configure\f[R](3), or one of its related setters,
and the operation must still be open (no doorbell issued).
.PP
In case of \f[B]ibv_wr_complete()\f[R] failure or calling to
\f[B]ibv_wr_abort()\f[R], the MKey may be left in an unknown state.
The next configuration of it should not assume any previous state of the
MKey, i.e.\ signature/crypto should be re\-configured or reset, as
required.
For example, assuming \f[B]mlx5dv_wr_set_mkey_sig_block()\f[R] and then
\f[B]ibv_wr_abort()\f[R] were called, then on the next configuration of
the MKey, if signature is not needed, it should be reset using
\f[B]MLX5DV_MKEY_CONF_FLAG_RESET_SIG_ATTR\f[R].
.SH SEE ALSO
\f[B]mlx5dv_wr_mkey_configure\f[R](3), \f[B]mlx5dv_create_mkey\f[R](3),
\f[B]mlx5dv_destroy_mkey\f[R](3)
.SH AUTHORS
Oren Duer \c
.MT oren@nvidia.com
.ME \c
.PP
Sergey Gorenko \c
.MT sergeygo@nvidia.com
.ME \c
