Skip to content

Commit

Permalink
types: add enum for Protection Information Format
Browse files Browse the repository at this point in the history
Add enum for Protection Information Format (PIF).

Signed-off-by: Francis Pravin <[email protected]>
  • Loading branch information
francispravin5 authored and igaw committed May 31, 2024
1 parent 7dfae44 commit db3ff1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/nvme/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,13 +1674,11 @@ static int nvme_set_var_size_tags(__u32 *cmd_dw2, __u32 *cmd_dw3, __u32 *cmd_dw1
beint64_t be_storage_tag = cpu_to_be64(storage_tag);

switch (pif) {
/* 16b Protection Information */
case 0:
case NVME_NVM_PIF_16B_GUARD:
cdw14 = be_reftag & 0xffffffff;
cdw14 |= ((be_storage_tag << (32 - sts)) & 0xffffffff);
break;
/* 32b Protection Information */
case 1:
case NVME_NVM_PIF_32B_GUARD:
cdw14 = be_reftag & 0xffffffff;
cdw3 = be_reftag >> 32;
cdw14 |= ((be_storage_tag << (80 - sts)) & 0xffff0000);
Expand All @@ -1690,8 +1688,7 @@ static int nvme_set_var_size_tags(__u32 *cmd_dw2, __u32 *cmd_dw3, __u32 *cmd_dw1
cdw3 |= ((be_storage_tag << (48 - sts)) & 0xffffffff);
cdw2 = (be_storage_tag >> (sts - 16)) & 0xffff;
break;
/* 64b Protection Information */
case 2:
case NVME_NVM_PIF_64B_GUARD:
cdw14 = be_reftag & 0xffffffff;
cdw3 = (be_reftag >> 32) & 0xffff;
cdw14 |= ((be_storage_tag << (48 - sts)) & 0xffffffff);
Expand Down
13 changes: 13 additions & 0 deletions src/nvme/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,19 @@ enum nvme_nvm_id_ns_elbaf {
NVME_NVM_ELBAF_PIF_MASK = 3 << 7,
};

/**
* enum nvme_nvm_id_ns_pif - This field indicates the type of the Protection
* Information Format
* @NVME_NVM_PIF_16B_GUARD: 16-bit Guard Protection Information Format
* @NVME_NVM_PIF_32B_GUARD: 32-bit Guard Protection Information Format
* @NVME_NVM_PIF_64B_GUARD: 64-bit Guard Protection Information Format
*/
enum nvme_nvm_id_ns_pif {
NVME_NVM_PIF_16B_GUARD = 0,
NVME_NVM_PIF_32B_GUARD = 1,
NVME_NVM_PIF_64B_GUARD = 2,
};

/**
* enum nvme_id_ns_mc - This field indicates the capabilities for metadata.
* @NVME_NS_MC_EXTENDED: If set, indicates the namespace supports the metadata
Expand Down

0 comments on commit db3ff1a

Please sign in to comment.