Blame view
drivers/nvme/nvme_show.c
3.76 KB
f6aa61d59 nvme: Add show ro... |
1 2 3 4 5 6 7 8 9 10 |
/* * Copyright (C) 2017 NXP Semiconductors * Copyright (C) 2017 Bin Meng <bmeng.cn@gmail.com> * * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <dm.h> #include <errno.h> |
704e040a5 nvme: Apply cache... |
11 |
#include <memalign.h> |
f6aa61d59 nvme: Add show ro... |
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
#include <nvme.h> #include "nvme.h" static void print_optional_admin_cmd(u16 oacs, int devnum) { printf("Blk device %d: Optional Admin Command Support: ", devnum); printf("\tNamespace Management/Attachment: %s ", oacs & 0x08 ? "yes" : "no"); printf("\tFirmware Commit/Image download: %s ", oacs & 0x04 ? "yes" : "no"); printf("\tFormat NVM: %s ", oacs & 0x02 ? "yes" : "no"); printf("\tSecurity Send/Receive: %s ", oacs & 0x01 ? "yes" : "no"); } static void print_optional_nvm_cmd(u16 oncs, int devnum) { printf("Blk device %d: Optional NVM Command Support: ", devnum); printf("\tReservation: %s ", oncs & 0x10 ? "yes" : "no"); printf("\tSave/Select field in the Set/Get features: %s ", oncs & 0x08 ? "yes" : "no"); printf("\tWrite Zeroes: %s ", oncs & 0x04 ? "yes" : "no"); printf("\tDataset Management: %s ", oncs & 0x02 ? "yes" : "no"); printf("\tWrite Uncorrectable: %s ", oncs & 0x01 ? "yes" : "no"); } static void print_format_nvme_attributes(u8 fna, int devnum) { printf("Blk device %d: Format NVM Attributes: ", devnum); printf("\tSupport Cryptographic Erase: %s ", fna & 0x04 ? "yes" : "No"); printf("\tSupport erase a particular namespace: %s ", fna & 0x02 ? "No" : "Yes"); printf("\tSupport format a particular namespace: %s ", fna & 0x01 ? "No" : "Yes"); } static void print_format(struct nvme_lbaf *lbaf) { u8 str[][10] = {"Best", "Better", "Good", "Degraded"}; printf("\t\tMetadata Size: %d ", le16_to_cpu(lbaf->ms)); printf("\t\tLBA Data Size: %d ", 1 << lbaf->ds); printf("\t\tRelative Performance: %s ", str[lbaf->rp & 0x03]); } static void print_formats(struct nvme_id_ns *id, struct nvme_ns *ns) { int i; printf("Blk device %d: LBA Format Support: ", ns->devnum); for (i = 0; i < id->nlbaf; i++) { printf("\tLBA Foramt %d Support: ", i); if (i == ns->flbas) printf("(current) "); else printf(" "); print_format(id->lbaf + i); } } static void print_data_protect_cap(u8 dpc, int devnum) { printf("Blk device %d: End-to-End Data", devnum); printf("Protect Capabilities: "); printf("\tAs last eight bytes: %s ", dpc & 0x10 ? "yes" : "No"); printf("\tAs first eight bytes: %s ", dpc & 0x08 ? "yes" : "No"); printf("\tSupport Type3: %s ", dpc & 0x04 ? "yes" : "No"); printf("\tSupport Type2: %s ", dpc & 0x02 ? "yes" : "No"); printf("\tSupport Type1: %s ", dpc & 0x01 ? "yes" : "No"); } static void print_metadata_cap(u8 mc, int devnum) { printf("Blk device %d: Metadata capabilities: ", devnum); printf("\tAs part of a separate buffer: %s ", mc & 0x02 ? "yes" : "No"); printf("\tAs part of an extended data LBA: %s ", mc & 0x01 ? "yes" : "No"); } int nvme_print_info(struct udevice *udev) { struct nvme_ns *ns = dev_get_priv(udev); struct nvme_dev *dev = ns->dev; |
704e040a5 nvme: Apply cache... |
140 141 142 143 |
ALLOC_CACHE_ALIGN_BUFFER(char, buf_ns, sizeof(struct nvme_id_ns)); struct nvme_id_ns *id = (struct nvme_id_ns *)buf_ns; ALLOC_CACHE_ALIGN_BUFFER(char, buf_ctrl, sizeof(struct nvme_id_ctrl)); struct nvme_id_ctrl *ctrl = (struct nvme_id_ctrl *)buf_ctrl; |
f6aa61d59 nvme: Add show ro... |
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
if (nvme_identify(dev, 0, 1, (dma_addr_t)ctrl)) return -EIO; print_optional_admin_cmd(le16_to_cpu(ctrl->oacs), ns->devnum); print_optional_nvm_cmd(le16_to_cpu(ctrl->oncs), ns->devnum); print_format_nvme_attributes(ctrl->fna, ns->devnum); if (nvme_identify(dev, ns->ns_id, 0, (dma_addr_t)id)) return -EIO; print_formats(id, ns); print_data_protect_cap(id->dpc, ns->devnum); print_metadata_cap(id->mc, ns->devnum); return 0; } |