MCPcopy Create free account
hub / github.com/ScaleX-IO/uGDS / nvm_admin_ctrl_info

Function nvm_admin_ctrl_info

src/libnvm/admin.cpp:103–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101
102
103int nvm_admin_ctrl_info(nvm_aq_ref ref, struct nvm_ctrl_info* info, void* ptr, uint64_t ioaddr)
104{
105 nvm_cmd_t command;
106 nvm_cpl_t completion;
107
108 if (info == NULL || ptr == NULL || ioaddr == 0)
109 {
110 return NVM_ERR_PACK(NULL, EINVAL);
111 }
112
113 memset(&command, 0, sizeof(command));
114 memset(&completion, 0, sizeof(completion));
115 memset(info, 0, sizeof(struct nvm_ctrl_info));
116 memset(ptr, 0, 0x1000);
117
118 nvm_cache_invalidate(ptr, 0x1000);
119
120 const nvm_ctrl_t* ctrl = nvm_ctrl_from_aq_ref(ref);
121
122 info->nvme_version = (uint32_t) *VER(ctrl->mm_ptr);
123 info->page_size = ctrl->page_size;
124 info->db_stride = 1UL << ctrl->dstrd;
125 info->timeout = CAP$TO(ctrl->mm_ptr) * 500UL;
126 info->contiguous = !!CAP$CQR(ctrl->mm_ptr);
127 info->max_entries = CAP$MQES(ctrl->mm_ptr) + 1;
128
129 admin_identify_ctrl(&command, ioaddr);
130
131 int err = nvm_raw_rpc(ref, &command, &completion);
132 if (!nvm_ok(err))
133 {
134 dprintf("Identify controller failed: %s\n", nvm_strerror(err));
135 return err;
136 }
137
138 nvm_cache_invalidate(ptr, 0x1000);
139
140 const unsigned char* bytes = (const unsigned char*) ptr;
141 memcpy(info->pci_vendor, bytes, 4);
142 memcpy(info->serial_no, bytes + 4, 20);
143 memcpy(info->model_no, bytes + 24, 40);
144 memcpy(info->firmware, bytes + 64, 8);
145
146 info->max_data_size = (1UL << bytes[77]) * (1UL << (12 + CAP$MPSMIN(ctrl->mm_ptr)));
147 info->max_data_pages = info->max_data_size / info->page_size;
148 info->sq_entry_size = 1 << _RB(bytes[512], 3, 0);
149 info->cq_entry_size = 1 << _RB(bytes[513], 3, 0);
150 info->max_out_cmds = *((uint16_t*) (bytes + 514));
151 info->max_n_ns = *((uint32_t*) (bytes + 516));
152
153 return NVM_ERR_PACK(NULL, 0);
154}
155
156
157

Callers 1

uGDSHandleRegisterFunction · 0.85

Calls 4

nvm_ctrl_from_aq_refFunction · 0.85
admin_identify_ctrlFunction · 0.85
nvm_raw_rpcFunction · 0.85
nvm_strerrorFunction · 0.85

Tested by

no test coverage detected