Skip to content

Commit 67562fa

Browse files
committed
libnvme: rename copy_range and add new fields
Rename to copy_range_f0 and follow NVMe command set spec revision 1.2. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 5263254 commit 67562fa

4 files changed

Lines changed: 47 additions & 26 deletions

File tree

libnvme/src/nvme/cmds.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4383,7 +4383,7 @@ nvme_init_copy(struct nvme_passthru_cmd *cmd, __u32 nsid, __u64 sdlba,
43834383
data_len = nr * sizeof(struct nvme_copy_range_f3);
43844384
break;
43854385
default:
4386-
data_len = nr * sizeof(struct nvme_copy_range);
4386+
data_len = nr * sizeof(struct nvme_copy_range_f0);
43874387
break;
43884388
}
43894389

@@ -5252,26 +5252,26 @@ nvme_init_copy_range_elbt(__u8 *elbt, __u64 eilbrt)
52525252
}
52535253

52545254
/**
5255-
* nvme_init_copy_range() - Constructs a copy range structure
5255+
* nvme_init_copy_range_f0() - Constructs a copy range structure
52565256
* @copy: Copy range array
52575257
* @nlbs: Number of logical blocks
52585258
* @slbas: Starting LBA
5259-
* @eilbrts: Expected initial logical block reference tag
5259+
* @elbts: Expected initial logical block reference tag
52605260
* @elbatms: Expected logical block application tag mask
52615261
* @elbats: Expected logical block application tag
52625262
* @nr: Number of descriptors to construct
52635263
*/
52645264
static inline void
5265-
nvme_init_copy_range(struct nvme_copy_range *copy, __u16 *nlbs,
5266-
__u64 *slbas, __u32 *eilbrts, __u32 *elbatms,
5265+
nvme_init_copy_range_f0(struct nvme_copy_range_f0 *copy, __u16 *nlbs,
5266+
__u64 *slbas, __u32 *elbts, __u32 *elbatms,
52675267
__u32 *elbats, __u16 nr)
52685268
{
52695269
int i;
52705270

52715271
for (i = 0; i < nr; i++) {
52725272
copy[i].nlb = htole16(nlbs[i]);
52735273
copy[i].slba = htole64(slbas[i]);
5274-
copy[i].eilbrt = htole32(eilbrts[i]);
5274+
copy[i].elbt = htole32(elbts[i]);
52755275
copy[i].elbatm = htole16(elbatms[i]);
52765276
copy[i].elbat = htole16(elbats[i]);
52775277
}

libnvme/src/nvme/types.h

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6436,22 +6436,28 @@ struct nvme_dsm_range {
64366436
};
64376437

64386438
/**
6439-
* struct nvme_copy_range - Copy - Source Range Entries Descriptor Format
6439+
* struct nvme_copy_range_f0 - Copy - Source Range Entries Descriptor Format 0h
64406440
* @rsvd0: Reserved
64416441
* @slba: Starting LBA
64426442
* @nlb: Number of Logical Blocks
6443-
* @rsvd18: Reserved
6444-
* @eilbrt: Expected Initial Logical Block Reference Tag /
6443+
* @cetype: Bits 3-0: Command Extension Type
6444+
* @rsvd19: Reserved
6445+
* @cev: Command Extension Value
6446+
* @rsvd22: Reserved
6447+
* @elbt: Expected Initial Logical Block Reference Tag /
64456448
* Expected Logical Block Storage Tag
64466449
* @elbatm: Expected Logical Block Application Tag Mask
64476450
* @elbat: Expected Logical Block Application Tag
64486451
*/
6449-
struct nvme_copy_range {
6452+
struct nvme_copy_range_f0 {
64506453
__u8 rsvd0[8];
64516454
__le64 slba;
64526455
__le16 nlb;
6453-
__u8 rsvd18[6];
6454-
__le32 eilbrt;
6456+
__u8 cetype;
6457+
__u8 rsvd19;
6458+
__le16 cev;
6459+
__u8 rsvd22[2];
6460+
__le32 elbt;
64556461
__le16 elbat;
64566462
__le16 elbatm;
64576463
};
@@ -6461,7 +6467,10 @@ struct nvme_copy_range {
64616467
* @rsvd0: Reserved
64626468
* @slba: Starting LBA
64636469
* @nlb: Number of Logical Blocks
6464-
* @rsvd18: Reserved
6470+
* @cetype: Bits 3-0: Command Extension Type
6471+
* @rsvd19: Reserved
6472+
* @cev: Command Extension Value
6473+
* @rsvd22: Reserved
64656474
* @elbt: Expected Initial Logical Block Reference Tag /
64666475
* Expected Logical Block Storage Tag
64676476
* @elbatm: Expected Logical Block Application Tag Mask
@@ -6471,7 +6480,10 @@ struct nvme_copy_range_f1 {
64716480
__u8 rsvd0[8];
64726481
__le64 slba;
64736482
__le16 nlb;
6474-
__u8 rsvd18[8];
6483+
__u8 cetype;
6484+
__u8 rsvd19;
6485+
__le16 cev;
6486+
__u8 rsvd22[4];
64756487
__u8 elbt[10];
64766488
__le16 elbat;
64776489
__le16 elbatm;
@@ -6491,7 +6503,9 @@ enum nvme_copy_range_sopt {
64916503
* @rsvd4: Reserved
64926504
* @slba: Starting LBA
64936505
* @nlb: Number of Logical Blocks
6494-
* @rsvd18: Reserved
6506+
* @cetype: Bits 3-0: Command Extension Type
6507+
* @rsvd19: Reserved
6508+
* @cev: Command Extension Value
64956509
* @sopt: Source Options
64966510
* @eilbrt: Expected Initial Logical Block Reference Tag /
64976511
* Expected Logical Block Storage Tag
@@ -6503,7 +6517,9 @@ struct nvme_copy_range_f2 {
65036517
__u8 rsvd4[4];
65046518
__le64 slba;
65056519
__le16 nlb;
6506-
__u8 rsvd18[4];
6520+
__u8 cetype;
6521+
__u8 rsvd19;
6522+
__le16 cev;
65076523
__le16 sopt;
65086524
__le32 eilbrt;
65096525
__le16 elbat;
@@ -6516,8 +6532,10 @@ struct nvme_copy_range_f2 {
65166532
* @rsvd4: Reserved
65176533
* @slba: Starting LBA
65186534
* @nlb: Number of Logical Blocks
6519-
* @rsvd18: Reserved
6535+
* @cetype: Bits 3-0: Command Extension Type
6536+
* @rsvd19: Reserved
65206537
* @sopt: Source Options
6538+
* @cev: Command Extension Value
65216539
* @rsvd24: Reserved
65226540
* @elbt: Expected Initial Logical Block Reference Tag /
65236541
* Expected Logical Block Storage Tag
@@ -6529,7 +6547,9 @@ struct nvme_copy_range_f3 {
65296547
__u8 rsvd4[4];
65306548
__le64 slba;
65316549
__le16 nlb;
6532-
__u8 rsvd18[4];
6550+
__u8 cetype;
6551+
__u8 rsvd19;
6552+
__le16 cev;
65336553
__le16 sopt;
65346554
__u8 rsvd24[2];
65356555
__u8 elbt[10];

libnvme/test/ioctl/misc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ static void test_dsm(void)
983983
static void test_copy(void)
984984
{
985985
__u16 nr = TEST_COPY_NR, cev = 0, dspec = 0;
986-
int copy_size = sizeof(struct nvme_copy_range) * nr, err;
986+
int copy_size = sizeof(struct nvme_copy_range_f0) * nr, err;
987987
bool prinfor = false, prinfow = false, stcw = false,
988988
stcr = false, fua = false, lr = false;
989989
__u8 cetype = 0, dtype = 0, desfmt = 0xf;
@@ -993,7 +993,7 @@ static void test_copy(void)
993993
__u32 short_pi[TEST_COPY_NR] = { 0x1000, 0x20000000, 0x40000000 };
994994
__u32 elbatms[TEST_COPY_NR] = { 0x1ff, 0x3ff, 0x3ff };
995995
__u32 elbats[TEST_COPY_NR] = { 0x111, 0x222, 0x333 };
996-
__u8 expected_data[sizeof(struct nvme_copy_range) * TEST_COPY_NR] = {
996+
__u8 expected_data[sizeof(struct nvme_copy_range_f0) * TEST_COPY_NR] = {
997997
0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0, 0, 0, 0,
998998
0xa, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0x11, 1, 0xff, 1,
999999
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x20, 0, 0, 0, 0,
@@ -1002,7 +1002,7 @@ static void test_copy(void)
10021002
0xc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x33, 3, 0xff, 3
10031003
};
10041004

1005-
_cleanup_free_ struct nvme_copy_range *copy = NULL;
1005+
_cleanup_free_ struct nvme_copy_range_f0 *copy = NULL;
10061006

10071007
copy = calloc(1, copy_size);
10081008
check(copy, "copy: ENOMEM");
@@ -1017,13 +1017,14 @@ static void test_copy(void)
10171017
((dtype & 0xf) << 20) |
10181018
((prinfow & 0xf) << 26) |
10191019
((fua & 0x1) << 30) | ((lr & 0x1) << 31),
1020-
.data_len = nr * sizeof(struct nvme_copy_range),
1020+
.data_len = nr * sizeof(struct nvme_copy_range_f0),
10211021
.in_data = expected_data,
10221022
};
10231023
struct nvme_passthru_cmd cmd;
10241024

10251025
set_mock_io_cmds(&mock_io_cmd, 1);
1026-
nvme_init_copy_range(copy, nlbs, slbas, short_pi, elbatms, elbats, nr);
1026+
nvme_init_copy_range_f0(copy, nlbs, slbas, short_pi, elbatms, elbats,
1027+
nr);
10271028
nvme_init_copy(&cmd, TEST_NSID, sdlba, nr, desfmt,
10281029
prinfor, prinfow, cetype, dtype, stcw, stcr,
10291030
fua, lr, cev, dspec, (void *)copy);

nvme.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7770,7 +7770,7 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *
77707770
__u32 elbats[256] = { 0 };
77717771

77727772
_cleanup_free_ union {
7773-
struct nvme_copy_range f0[256];
7773+
struct nvme_copy_range_f0 f0[256];
77747774
struct nvme_copy_range_f1 f1[256];
77757775
struct nvme_copy_range_f2 f2[256];
77767776
struct nvme_copy_range_f3 f3[256];
@@ -7922,8 +7922,8 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *
79227922
eilbrts.long_pi, elbatms, elbats, nr);
79237923
break;
79247924
default:
7925-
nvme_init_copy_range(copy->f0, nlbs, slbas, eilbrts.short_pi,
7926-
elbatms, elbats, nr);
7925+
nvme_init_copy_range_f0(copy->f0, nlbs, slbas, eilbrts.short_pi,
7926+
elbatms, elbats, nr);
79277927
break;
79287928
}
79297929

0 commit comments

Comments
 (0)