Skip to content

Commit 612a752

Browse files
committed
libnvme/cmds: change copy desc format elbatm and elbat to big-endian
Since the format elbt values are set as big-endian then follow it. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 4fe3b3e commit 612a752

4 files changed

Lines changed: 39 additions & 31 deletions

File tree

libnvme/src/nvme/cmds.h

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5262,8 +5262,8 @@ nvme_init_copy_range_elbt(__u8 *elbt, __u8 *eilbrt, int size)
52625262
*/
52635263
static inline void
52645264
nvme_init_copy_range_f0(struct nvme_copy_range_f0 *copy, __u16 *nlbs,
5265-
__u64 *slbas, __u32 *elbts, __u32 *elbatms,
5266-
__u32 *elbats, __u16 nr)
5265+
__u64 *slbas, __u32 *elbts, __u16 *elbatms,
5266+
__u16 *elbats, __u16 nr)
52675267
{
52685268
int i;
52695269

@@ -5272,8 +5272,10 @@ nvme_init_copy_range_f0(struct nvme_copy_range_f0 *copy, __u16 *nlbs,
52725272
copy[i].slba = htole64(slbas[i]);
52735273
nvme_init_copy_range_elbt(copy[i].elbt, (__u8 *)&elbts[i],
52745274
sizeof(elbts[i]));
5275-
copy[i].elbatm = htole16(elbatms[i]);
5276-
copy[i].elbat = htole16(elbats[i]);
5275+
nvme_init_copy_range_elbt(copy[i].elbatm, (__u8 *)&elbatms[i],
5276+
sizeof(copy[i].elbatm));
5277+
nvme_init_copy_range_elbt(copy[i].elbat, (__u8 *)&elbats[i],
5278+
sizeof(copy[i].elbat));
52775279
}
52785280
}
52795281

@@ -5289,8 +5291,8 @@ nvme_init_copy_range_f0(struct nvme_copy_range_f0 *copy, __u16 *nlbs,
52895291
*/
52905292
static inline void
52915293
nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
5292-
__u64 *slbas, __u64 *eilbrts, __u32 *elbatms,
5293-
__u32 *elbats, __u16 nr)
5294+
__u64 *slbas, __u64 *eilbrts, __u16 *elbatms,
5295+
__u16 *elbats, __u16 nr)
52945296
{
52955297
int i;
52965298

@@ -5299,10 +5301,12 @@ nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
52995301
for (i = 0; i < nr; i++) {
53005302
copy[i].nlb = htole16(nlbs[i]);
53015303
copy[i].slba = htole64(slbas[i]);
5302-
copy[i].elbatm = htole16(elbatms[i]);
5303-
copy[i].elbat = htole16(elbats[i]);
53045304
nvme_init_copy_range_elbt(&copy[i].elbt[2], (__u8 *)&eilbrts[i],
53055305
sizeof(eilbrts[i]));
5306+
nvme_init_copy_range_elbt(copy[i].elbatm, (__u8 *)&elbatms[i],
5307+
sizeof(copy[i].elbatm));
5308+
nvme_init_copy_range_elbt(copy[i].elbat, (__u8 *)&elbats[i],
5309+
sizeof(copy[i].elbat));
53065310
}
53075311
}
53085312

@@ -5321,7 +5325,7 @@ nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
53215325
static inline void
53225326
nvme_init_copy_range_f2(struct nvme_copy_range_f2 *copy,
53235327
__u32 *snsids, __u16 *nlbs, __u64 *slbas, __u16 *sopts,
5324-
__u32 *elbts, __u32 *elbatms, __u32 *elbats,
5328+
__u32 *elbts, __u16 *elbatms, __u16 *elbats,
53255329
__u16 nr)
53265330
{
53275331
int i;
@@ -5333,8 +5337,10 @@ nvme_init_copy_range_f2(struct nvme_copy_range_f2 *copy,
53335337
copy[i].sopt = htole16(sopts[i]);
53345338
nvme_init_copy_range_elbt(copy[i].elbt, (__u8 *)&elbts[i],
53355339
sizeof(elbts[i]));
5336-
copy[i].elbatm = htole16(elbatms[i]);
5337-
copy[i].elbat = htole16(elbats[i]);
5340+
nvme_init_copy_range_elbt(copy[i].elbatm, (__u8 *)&elbatms[i],
5341+
sizeof(copy[i].elbatm));
5342+
nvme_init_copy_range_elbt(copy[i].elbat, (__u8 *)&elbats[i],
5343+
sizeof(copy[i].elbat));
53385344
}
53395345
}
53405346

@@ -5353,7 +5359,7 @@ nvme_init_copy_range_f2(struct nvme_copy_range_f2 *copy,
53535359
static inline void
53545360
nvme_init_copy_range_f3(struct nvme_copy_range_f3 *copy, __u32 *snsids,
53555361
__u16 *nlbs, __u64 *slbas, __u16 *sopts,
5356-
__u64 *eilbrts, __u32 *elbatms, __u32 *elbats,
5362+
__u64 *eilbrts, __u16 *elbatms, __u16 *elbats,
53575363
__u16 nr)
53585364
{
53595365
int i;
@@ -5365,10 +5371,12 @@ nvme_init_copy_range_f3(struct nvme_copy_range_f3 *copy, __u32 *snsids,
53655371
copy[i].nlb = htole16(nlbs[i]);
53665372
copy[i].slba = htole64(slbas[i]);
53675373
copy[i].sopt = htole16(sopts[i]);
5368-
copy[i].elbatm = htole16(elbatms[i]);
5369-
copy[i].elbat = htole16(elbats[i]);
53705374
nvme_init_copy_range_elbt(&copy[i].elbt[2], (__u8 *)&eilbrts[i],
53715375
sizeof(eilbrts[i]));
5376+
nvme_init_copy_range_elbt(copy[i].elbatm, (__u8 *)&elbatms[i],
5377+
sizeof(copy[i].elbatm));
5378+
nvme_init_copy_range_elbt(copy[i].elbat, (__u8 *)&elbats[i],
5379+
sizeof(copy[i].elbat));
53725380
}
53735381
}
53745382

libnvme/src/nvme/types.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6458,8 +6458,8 @@ struct nvme_copy_range_f0 {
64586458
__le16 cev;
64596459
__u8 rsvd22[2];
64606460
__u8 elbt[4];
6461-
__le16 elbat;
6462-
__le16 elbatm;
6461+
__u8 elbat[2];
6462+
__u8 elbatm[2];
64636463
};
64646464

64656465
/**
@@ -6485,8 +6485,8 @@ struct nvme_copy_range_f1 {
64856485
__le16 cev;
64866486
__u8 rsvd22[4];
64876487
__u8 elbt[10];
6488-
__le16 elbat;
6489-
__le16 elbatm;
6488+
__u8 elbat[2];
6489+
__u8 elbatm[2];
64906490
};
64916491

64926492
/**
@@ -6522,8 +6522,8 @@ struct nvme_copy_range_f2 {
65226522
__le16 cev;
65236523
__le16 sopt;
65246524
__u8 elbt[4];
6525-
__le16 elbat;
6526-
__le16 elbatm;
6525+
__u8 elbat[2];
6526+
__u8 elbatm[2];
65276527
};
65286528

65296529
/**
@@ -6553,8 +6553,8 @@ struct nvme_copy_range_f3 {
65536553
__le16 sopt;
65546554
__u8 rsvd24[2];
65556555
__u8 elbt[10];
6556-
__le16 elbat;
6557-
__le16 elbatm;
6556+
__u8 elbat[2];
6557+
__u8 elbatm[2];
65586558
};
65596559

65606560
/**

libnvme/test/ioctl/misc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,15 +991,15 @@ static void test_copy(void)
991991
__u16 nlbs[TEST_COPY_NR] = { 0xa, 0xb, 0xc };
992992
__u64 slbas[TEST_COPY_NR] = { 0x1000, 0x20000000, 0x300040000000 };
993993
__u32 short_pi[TEST_COPY_NR] = { 0x1000, 0x20000000, 0x40000000 };
994-
__u32 elbatms[TEST_COPY_NR] = { 0x1ff, 0x3ff, 0x3ff };
995-
__u32 elbats[TEST_COPY_NR] = { 0x111, 0x222, 0x333 };
994+
__u16 elbatms[TEST_COPY_NR] = { 0x1ff, 0x3ff, 0x3ff };
995+
__u16 elbats[TEST_COPY_NR] = { 0x111, 0x222, 0x333 };
996996
__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,
998-
0xa, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0x11, 1, 0xff, 1,
998+
0xa, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 1, 0x11, 1, 0xff,
999999
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x20, 0, 0, 0, 0,
1000-
0xb, 0, 0, 0, 0, 0, 0, 0, 0x20, 0, 0, 0, 0x22, 2, 0xff, 3,
1000+
0xb, 0, 0, 0, 0, 0, 0, 0, 0x20, 0, 0, 0, 2, 0x22, 3, 0xff,
10011001
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0x30, 0, 0,
1002-
0xc, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0, 0, 0x33, 3, 0xff, 3
1002+
0xc, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0, 0, 3, 0x33, 3, 0xff
10031003
};
10041004

10051005
_cleanup_free_ struct nvme_copy_range_f0 *copy = NULL;

nvme.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7766,8 +7766,8 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *
77667766
__u64 long_pi[256];
77677767
} eilbrts;
77687768

7769-
__u32 elbatms[256] = { 0 };
7770-
__u32 elbats[256] = { 0 };
7769+
__u16 elbatms[256] = { 0 };
7770+
__u16 elbats[256] = { 0 };
77717771

77727772
_cleanup_free_ union {
77737773
struct nvme_copy_range_f0 f0[256];
@@ -7876,9 +7876,9 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *
78767876
return -EINVAL;
78777877
}
78787878

7879-
natms = argconfig_parse_comma_sep_array_u32(cfg.elbatms, elbatms,
7879+
natms = argconfig_parse_comma_sep_array_u16(cfg.elbatms, elbatms,
78807880
ARRAY_SIZE(elbatms));
7881-
nats = argconfig_parse_comma_sep_array_u32(cfg.elbats, elbats,
7881+
nats = argconfig_parse_comma_sep_array_u16(cfg.elbats, elbats,
78827882
ARRAY_SIZE(elbats));
78837883

78847884
nr = max(nb, max(ns, max(nrts, max(natms, nats))));

0 commit comments

Comments
 (0)