@@ -772,11 +772,19 @@ int nvme_mi_admin_identify_partial(nvme_mi_ctrl_t ctrl,
772772}
773773
774774/* retrieves a MCTP-messsage-sized chunk of log page data. offset and len are
775- * specified within the args->data area */
775+ * specified within the args->data area. The `offset` parameter is a relative
776+ * offset to the args->lpo !
777+ *
778+ * What's more, we change the LPO of original command to chunk the request
779+ * message into proper size which is allowed by MI interface. One reason is that
780+ * this option seems to be supported better by devices. For more information
781+ * about this option, please check https://github.com/linux-nvme/libnvme/pull/539
782+ * */
776783static int __nvme_mi_admin_get_log (nvme_mi_ctrl_t ctrl ,
777784 const struct nvme_get_log_args * args ,
778785 off_t offset , size_t * lenp , bool final )
779786{
787+ __u64 log_page_offset = args -> lpo + offset ;
780788 struct nvme_mi_admin_resp_hdr resp_hdr ;
781789 struct nvme_mi_admin_req_hdr req_hdr ;
782790 struct nvme_mi_resp resp ;
@@ -808,17 +816,13 @@ static int __nvme_mi_admin_get_log(nvme_mi_ctrl_t ctrl,
808816 (args -> lid & 0xff ));
809817 req_hdr .cdw11 = cpu_to_le32 (args -> lsi << 16 |
810818 ndw >> 16 );
811- req_hdr .cdw12 = cpu_to_le32 (args -> lpo & 0xffffffff );
812- req_hdr .cdw13 = cpu_to_le32 (args -> lpo >> 32 );
819+ req_hdr .cdw12 = cpu_to_le32 (log_page_offset & 0xffffffff );
820+ req_hdr .cdw13 = cpu_to_le32 (log_page_offset >> 32 );
813821 req_hdr .cdw14 = cpu_to_le32 (args -> csi << 24 |
814822 (args -> ot ? 1 : 0 ) << 23 |
815823 args -> uuidx );
816824 req_hdr .flags = 0x1 ;
817825 req_hdr .dlen = cpu_to_le32 (len & 0xffffffff );
818- if (offset ) {
819- req_hdr .flags |= 0x2 ;
820- req_hdr .doff = cpu_to_le32 (offset );
821- }
822826
823827 nvme_mi_calc_req_mic (& req );
824828
@@ -848,6 +852,11 @@ int nvme_mi_admin_get_log(nvme_mi_ctrl_t ctrl, struct nvme_get_log_args *args)
848852 return -1 ;
849853 }
850854
855+ if (args -> ot && (args -> len > max_xfer_size )) {
856+ errno = EINVAL ;
857+ return -1 ;
858+ }
859+
851860 for (xfer_offset = 0 ; xfer_offset < args -> len ;) {
852861 size_t xfered_size , cur_xfer_size = max_xfer_size ;
853862 bool final ;
0 commit comments