@@ -414,11 +414,56 @@ static int nvme_mi_verify_resp_mic(struct nvme_mi_resp *resp)
414414 return resp -> mic != ~crc ;
415415}
416416
417+ __attribute__((weak )) void nvme_mi_admin_submit_entry (const nvme_mi_ep_t ep ,
418+ const struct nvme_mi_admin_req_hdr * req ,
419+ const void * data , size_t data_len ) { }
420+ __attribute__((weak )) void nvme_mi_admin_submit_exit (const nvme_mi_ep_t ep ,
421+ const struct nvme_mi_admin_resp_hdr * resp ,
422+ const void * data , size_t data_len ) { }
423+
424+ static void nvme_mi_submit_entry (const nvme_mi_ep_t ep , const struct nvme_mi_req * req )
425+ {
426+ const struct nvme_mi_admin_req_hdr * hdr ;
427+
428+ switch (req -> hdr -> type ) {
429+ case NVME_MI_MT_CONTROL :
430+ case NVME_MI_MT_MI :
431+ break ;
432+ case NVME_MI_MT_ADMIN :
433+ hdr = (const struct nvme_mi_admin_req_hdr * )req -> hdr ;
434+ nvme_mi_admin_submit_entry (ep , hdr , req -> data , req -> data_len );
435+ break ;
436+ case NVME_MI_MT_PCIE :
437+ default :
438+ break ;
439+ }
440+ }
441+
442+ static void nvme_mi_submit_exit (const nvme_mi_ep_t ep , struct nvme_mi_resp * resp )
443+ {
444+ const struct nvme_mi_admin_resp_hdr * hdr ;
445+
446+ switch (resp -> hdr -> type ) {
447+ case NVME_MI_MT_CONTROL :
448+ case NVME_MI_MT_MI :
449+ break ;
450+ case NVME_MI_MT_ADMIN :
451+ hdr = (const struct nvme_mi_admin_resp_hdr * )resp -> hdr ;
452+ nvme_mi_admin_submit_exit (ep , hdr , resp -> data , resp -> data_len );
453+ break ;
454+ case NVME_MI_MT_PCIE :
455+ default :
456+ break ;
457+ }
458+ }
459+
417460int nvme_mi_submit (nvme_mi_ep_t ep , struct nvme_mi_req * req ,
418461 struct nvme_mi_resp * resp )
419462{
420463 int rc ;
421464
465+ nvme_mi_submit_entry (ep , req );
466+
422467 if (req -> hdr_len < sizeof (struct nvme_mi_msg_hdr )) {
423468 errno = EINVAL ;
424469 return -1 ;
@@ -502,6 +547,8 @@ int nvme_mi_submit(nvme_mi_ep_t ep, struct nvme_mi_req *req,
502547 return -1 ;
503548 }
504549
550+ nvme_mi_submit_exit (ep , resp );
551+
505552 return 0 ;
506553}
507554
0 commit comments