]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
types: Update position of elbatm in struct nvme_copy_range{_f1}
authorzerone <wuzengkun@Dapustor.com>
Wed, 1 Mar 2023 10:58:26 +0000 (18:58 +0800)
committerDaniel Wagner <dwagner@suse.de>
Tue, 14 Mar 2023 14:45:11 +0000 (15:45 +0100)
Update the Expected Logical Block Application Tag and Reference Tag in
struct nvme_copy_range and struct nvme_copy_range_f1.

 1. The elbatm is behind elbat fields, which are defined in section
    3.2.2 Copy command

 2. Storage and Reference Space is declared as an big-endian order,
    the elbt[10] fields need to reassigned

[dwagner: squashed changes and updated commit message]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/nvme/types.h
src/nvme/util.c

index 2edc8930811f9c6983dd26bd23c0846a1b52588b..8a993715ea542f1320c2fde2b1d6de93f95010ac 100644 (file)
@@ -4640,8 +4640,8 @@ struct nvme_copy_range {
        __le16                  nlb;
        __u8                    rsvd18[6];
        __le32                  eilbrt;
-       __le16                  elbatm;
        __le16                  elbat;
+       __le16                  elbatm;
 };
 
 /**
@@ -4661,8 +4661,8 @@ struct nvme_copy_range_f1 {
        __le16                  nlb;
        __u8                    rsvd18[8];
        __u8                    elbt[10];
-       __le16                  elbatm;
        __le16                  elbat;
+       __le16                  elbatm;
 };
 
 /**
index 0354afefa397ba226950591c90e7cf8d5fa75753..e7cbc8a8328e5698905a1394ad2d0c08abe92657 100644 (file)
@@ -403,14 +403,17 @@ void nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
                          __u64 *slbas, __u64 *eilbrts, __u32 *elbatms,
                          __u32 *elbats, __u16 nr)
 {
-       int i;
+       int i, j;
 
        for (i = 0; i < nr; i++) {
                copy[i].nlb = cpu_to_le16(nlbs[i]);
                copy[i].slba = cpu_to_le64(slbas[i]);
-               copy[i].elbt[2] = cpu_to_le64(eilbrts[i]);
                copy[i].elbatm = cpu_to_le16(elbatms[i]);
                copy[i].elbat = cpu_to_le16(elbats[i]);
+               for (j = 0; j < 8; j++)
+                       copy[i].elbt[9 - j] = (eilbrts[i] >> (8 * j)) & 0xff;
+               copy[i].elbt[1] = 0;
+               copy[i].elbt[0] = 0;
        }  
 }