]>
git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/nvme/nvme_show.c
2 * Copyright (C) 2017 NXP Semiconductors
3 * Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com>
5 * SPDX-License-Identifier: GPL-2.0+
15 static void print_optional_admin_cmd(u16 oacs
, int devnum
)
17 printf("Blk device %d: Optional Admin Command Support:\n",
19 printf("\tNamespace Management/Attachment: %s\n",
20 oacs
& 0x08 ? "yes" : "no");
21 printf("\tFirmware Commit/Image download: %s\n",
22 oacs
& 0x04 ? "yes" : "no");
23 printf("\tFormat NVM: %s\n",
24 oacs
& 0x02 ? "yes" : "no");
25 printf("\tSecurity Send/Receive: %s\n",
26 oacs
& 0x01 ? "yes" : "no");
29 static void print_optional_nvm_cmd(u16 oncs
, int devnum
)
31 printf("Blk device %d: Optional NVM Command Support:\n",
33 printf("\tReservation: %s\n",
34 oncs
& 0x10 ? "yes" : "no");
35 printf("\tSave/Select field in the Set/Get features: %s\n",
36 oncs
& 0x08 ? "yes" : "no");
37 printf("\tWrite Zeroes: %s\n",
38 oncs
& 0x04 ? "yes" : "no");
39 printf("\tDataset Management: %s\n",
40 oncs
& 0x02 ? "yes" : "no");
41 printf("\tWrite Uncorrectable: %s\n",
42 oncs
& 0x01 ? "yes" : "no");
45 static void print_format_nvme_attributes(u8 fna
, int devnum
)
47 printf("Blk device %d: Format NVM Attributes:\n", devnum
);
48 printf("\tSupport Cryptographic Erase: %s\n",
49 fna
& 0x04 ? "yes" : "No");
50 printf("\tSupport erase a particular namespace: %s\n",
51 fna
& 0x02 ? "No" : "Yes");
52 printf("\tSupport format a particular namespace: %s\n",
53 fna
& 0x01 ? "No" : "Yes");
56 static void print_format(struct nvme_lbaf
*lbaf
)
58 u8 str
[][10] = {"Best", "Better", "Good", "Degraded"};
60 printf("\t\tMetadata Size: %d\n", le16_to_cpu(lbaf
->ms
));
61 printf("\t\tLBA Data Size: %d\n", 1 << lbaf
->ds
);
62 printf("\t\tRelative Performance: %s\n", str
[lbaf
->rp
& 0x03]);
65 static void print_formats(struct nvme_id_ns
*id
, struct nvme_ns
*ns
)
69 printf("Blk device %d: LBA Format Support:\n", ns
->devnum
);
71 for (i
= 0; i
< id
->nlbaf
; i
++) {
72 printf("\tLBA Foramt %d Support: ", i
);
74 printf("(current)\n");
77 print_format(id
->lbaf
+ i
);
81 static void print_data_protect_cap(u8 dpc
, int devnum
)
83 printf("Blk device %d: End-to-End Data", devnum
);
84 printf("Protect Capabilities:\n");
85 printf("\tAs last eight bytes: %s\n",
86 dpc
& 0x10 ? "yes" : "No");
87 printf("\tAs first eight bytes: %s\n",
88 dpc
& 0x08 ? "yes" : "No");
89 printf("\tSupport Type3: %s\n",
90 dpc
& 0x04 ? "yes" : "No");
91 printf("\tSupport Type2: %s\n",
92 dpc
& 0x02 ? "yes" : "No");
93 printf("\tSupport Type1: %s\n",
94 dpc
& 0x01 ? "yes" : "No");
97 static void print_metadata_cap(u8 mc
, int devnum
)
99 printf("Blk device %d: Metadata capabilities:\n", devnum
);
100 printf("\tAs part of a separate buffer: %s\n",
101 mc
& 0x02 ? "yes" : "No");
102 printf("\tAs part of an extended data LBA: %s\n",
103 mc
& 0x01 ? "yes" : "No");
106 int nvme_print_info(struct udevice
*udev
)
108 struct nvme_ns
*ns
= dev_get_priv(udev
);
109 struct nvme_dev
*dev
= ns
->dev
;
110 ALLOC_CACHE_ALIGN_BUFFER(char, buf_ns
, sizeof(struct nvme_id_ns
));
111 struct nvme_id_ns
*id
= (struct nvme_id_ns
*)buf_ns
;
112 ALLOC_CACHE_ALIGN_BUFFER(char, buf_ctrl
, sizeof(struct nvme_id_ctrl
));
113 struct nvme_id_ctrl
*ctrl
= (struct nvme_id_ctrl
*)buf_ctrl
;
115 if (nvme_identify(dev
, 0, 1, (dma_addr_t
)ctrl
))
118 print_optional_admin_cmd(le16_to_cpu(ctrl
->oacs
), ns
->devnum
);
119 print_optional_nvm_cmd(le16_to_cpu(ctrl
->oncs
), ns
->devnum
);
120 print_format_nvme_attributes(ctrl
->fna
, ns
->devnum
);
122 if (nvme_identify(dev
, ns
->ns_id
, 0, (dma_addr_t
)id
))
125 print_formats(id
, ns
);
126 print_data_protect_cap(id
->dpc
, ns
->devnum
);
127 print_metadata_cap(id
->mc
, ns
->devnum
);