@@ -146,23 +146,26 @@ static void nvme_mi_admin_init_resp(struct nvme_mi_resp *resp,
146146 resp -> hdr_len = sizeof (* hdr );
147147}
148148
149- static int nvme_mi_admin_identify (nvme_mi_ctrl_t ctrl ,
150- enum nvme_identify_cns cns ,
151- __u16 cid , __u16 nsid , void * id ,
152- off_t offset , size_t size )
149+ int nvme_mi_admin_identify_partial (nvme_mi_ctrl_t ctrl ,
150+ struct nvme_identify_args * args ,
151+ off_t offset , size_t size )
153152{
154153 struct nvme_mi_admin_resp_hdr resp_hdr ;
155154 struct nvme_mi_admin_req_hdr req_hdr ;
156155 struct nvme_mi_resp resp ;
157156 struct nvme_mi_req req ;
158157 int rc ;
159158
159+ if (args -> args_size < sizeof (* args ))
160+ return - EINVAL ;
161+
160162 if (!size || size > 0xffffffff )
161163 return - EINVAL ;
162164
163165 nvme_mi_admin_init_req (& req , & req_hdr , ctrl -> id , nvme_admin_identify );
164- req_hdr .cdw10 = cpu_to_le16 (cid ) << 16 | cpu_to_le16 (cns );
165- req_hdr .cdw11 = cpu_to_le16 (nsid );
166+ req_hdr .cdw10 = cpu_to_le16 (args -> cntid ) << 16 | cpu_to_le16 (args -> cns );
167+ req_hdr .cdw11 = cpu_to_le16 (args -> nsid );
168+ req_hdr .cdw14 = args -> uuidx & 0xff ;
166169 req_hdr .dlen = cpu_to_le32 (size & 0xffffffff );
167170 req_hdr .flags = 0x1 ;
168171 if (offset ) {
@@ -173,50 +176,36 @@ static int nvme_mi_admin_identify(nvme_mi_ctrl_t ctrl,
173176 nvme_mi_calc_req_mic (& req );
174177
175178 nvme_mi_admin_init_resp (& resp , & resp_hdr );
176- resp .data = id ;
179+ resp .data = args -> data ;
177180 resp .data_len = size ;
178181
179182 rc = nvme_mi_submit (ctrl -> ep , & req , & resp );
180183 if (rc )
181184 return rc ;
182185
183- /* check status, map to return value */
186+ if (args -> result )
187+ * args -> result = le32_to_cpu (resp_hdr .cdw0 );
188+
189+ /* callers will expect a full response; if the data buffer isn't
190+ * fully valid, return an error */
191+ if (resp .data_len != size )
192+ return - EPROTO ;
184193
185194 return 0 ;
186195}
187196
188197int nvme_mi_admin_identify_ctrl (nvme_mi_ctrl_t ctrl ,
189198 struct nvme_id_ctrl * id )
190199{
191- return nvme_mi_admin_identify (ctrl , NVME_IDENTIFY_CNS_CTRL ,
192- 0 , 0 , id , 0 , sizeof (* id ));
193- }
194-
195- int nvme_mi_admin_identify_ctrl_partial (nvme_mi_ctrl_t ctrl ,
196- struct nvme_id_ctrl * id ,
197- off_t offset , size_t size )
198- {
199- void * buf ;
200-
201- if (offset > sizeof (* id ))
202- return - EINVAL ;
203- if (size > sizeof (* id ))
204- return - EINVAL ;
205- if (offset + size > sizeof (* id ))
206- return - EINVAL ;
207-
208- buf = id ;
209- buf += offset ;
210-
211- return nvme_mi_admin_identify (ctrl , NVME_IDENTIFY_CNS_CTRL ,
212- 0 , 0 , buf , offset , size );
213- }
214-
215- int nvme_mi_admin_identify_ctrl_list (nvme_mi_ctrl_t ctrl ,
216- struct nvme_ctrl_list * ctrllist )
217- {
218- return nvme_mi_admin_identify (ctrl , NVME_IDENTIFY_CNS_CTRL_LIST ,
219- 0 , 0 , ctrllist , 0 , sizeof (* ctrllist ));
200+ struct nvme_identify_args id_args = {
201+ .args_size = sizeof (id_args ),
202+ .data = id ,
203+ .cns = NVME_IDENTIFY_CNS_CTRL ,
204+ .nsid = NVME_NSID_NONE ,
205+ .cntid = ctrl -> id ,
206+ };
207+
208+ return nvme_mi_admin_identify (ctrl , & id_args );
220209}
221210
222211static int nvme_mi_read_data (nvme_mi_ep_t ep , __u32 cdw0 ,
0 commit comments