@@ -390,389 +390,6 @@ int nvme_identify(struct nvme_identify_args *args)
390390 return nvme_submit_admin_passthru (args -> fd , & cmd , args -> result );
391391}
392392
393- static int __nvme_identify (int fd , __u8 cns , __u32 nsid , void * data )
394- {
395- struct nvme_identify_args args = {
396- .args_size = sizeof (args ),
397- .fd = fd ,
398- .cns = cns ,
399- .nsid = nsid ,
400- .cntid = NVME_CNTLID_NONE ,
401- .nvmsetid = NVME_NVMSETID_NONE ,
402- .domid = NVME_DOMID_NONE ,
403- .uuidx = NVME_UUID_NONE ,
404- .csi = NVME_CSI_NVM ,
405- .data = data ,
406- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
407- .result = NULL ,
408- };
409-
410- return nvme_identify (& args );
411- }
412-
413- int nvme_identify_ctrl (int fd , struct nvme_id_ctrl * id )
414- {
415- BUILD_ASSERT (sizeof (struct nvme_id_ctrl ) == 4096 );
416- return __nvme_identify (fd , NVME_IDENTIFY_CNS_CTRL , NVME_NSID_NONE , id );
417- }
418-
419- int nvme_identify_ns (int fd , __u32 nsid , struct nvme_id_ns * ns )
420- {
421- BUILD_ASSERT (sizeof (struct nvme_id_ns ) == 4096 );
422- return __nvme_identify (fd , NVME_IDENTIFY_CNS_NS , nsid , ns );
423- }
424-
425- int nvme_identify_allocated_ns (int fd , __u32 nsid , struct nvme_id_ns * ns )
426- {
427- return __nvme_identify (fd , NVME_IDENTIFY_CNS_ALLOCATED_NS , nsid , ns );
428- }
429-
430- int nvme_identify_active_ns_list (int fd , __u32 nsid , struct nvme_ns_list * list )
431- {
432- BUILD_ASSERT (sizeof (struct nvme_ns_list ) == 4096 );
433- return __nvme_identify (fd , NVME_IDENTIFY_CNS_NS_ACTIVE_LIST , nsid ,
434- list );
435- }
436-
437- int nvme_identify_allocated_ns_list (int fd , __u32 nsid ,
438- struct nvme_ns_list * list )
439- {
440- return __nvme_identify (fd , NVME_IDENTIFY_CNS_ALLOCATED_NS_LIST , nsid ,
441- list );
442- }
443-
444- int nvme_identify_ctrl_list (int fd , __u16 cntid ,
445- struct nvme_ctrl_list * ctrlist )
446- {
447- struct nvme_identify_args args = {
448- .args_size = sizeof (args ),
449- .fd = fd ,
450- .cns = NVME_IDENTIFY_CNS_CTRL_LIST ,
451- .nsid = NVME_NSID_NONE ,
452- .cntid = NVME_CNTLID_NONE ,
453- .nvmsetid = NVME_NVMSETID_NONE ,
454- .domid = NVME_DOMID_NONE ,
455- .uuidx = NVME_UUID_NONE ,
456- .csi = NVME_CSI_NVM ,
457- .data = ctrlist ,
458- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
459- .result = NULL ,
460- };
461-
462- BUILD_ASSERT (sizeof (struct nvme_ctrl_list ) == 4096 );
463- return nvme_identify (& args );
464- }
465-
466- int nvme_identify_nsid_ctrl_list (int fd , __u32 nsid , __u16 cntid ,
467- struct nvme_ctrl_list * ctrlist )
468- {
469- struct nvme_identify_args args = {
470- .args_size = sizeof (args ),
471- .fd = fd ,
472- .cns = NVME_IDENTIFY_CNS_NS_CTRL_LIST ,
473- .nsid = nsid ,
474- .cntid = cntid ,
475- .nvmsetid = NVME_NVMSETID_NONE ,
476- .domid = NVME_DOMID_NONE ,
477- .uuidx = NVME_UUID_NONE ,
478- .csi = NVME_CSI_NVM ,
479- .data = ctrlist ,
480- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
481- .result = NULL ,
482- };
483-
484- return nvme_identify (& args );
485- }
486-
487- int nvme_identify_ns_descs (int fd , __u32 nsid , struct nvme_ns_id_desc * descs )
488- {
489- return __nvme_identify (fd , NVME_IDENTIFY_CNS_NS_DESC_LIST , nsid , descs );
490- }
491-
492- int nvme_identify_nvmset_list (int fd , __u16 nvmsetid ,
493- struct nvme_id_nvmset_list * nvmset )
494- {
495- struct nvme_identify_args args = {
496- .args_size = sizeof (args ),
497- .fd = fd ,
498- .cns = NVME_IDENTIFY_CNS_NVMSET_LIST ,
499- .nsid = NVME_NSID_NONE ,
500- .cntid = NVME_CNTLID_NONE ,
501- .nvmsetid = nvmsetid ,
502- .domid = NVME_DOMID_NONE ,
503- .uuidx = NVME_UUID_NONE ,
504- .csi = NVME_CSI_NVM ,
505- .data = nvmset ,
506- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
507- .result = NULL ,
508- };
509-
510- BUILD_ASSERT (sizeof (struct nvme_id_nvmset_list ) == 4096 );
511- return nvme_identify (& args );
512- }
513-
514- int nvme_identify_primary_ctrl (int fd , __u16 cntid ,
515- struct nvme_primary_ctrl_cap * cap )
516- {
517- struct nvme_identify_args args = {
518- .args_size = sizeof (args ),
519- .fd = fd ,
520- .cns = NVME_IDENTIFY_CNS_PRIMARY_CTRL_CAP ,
521- .nsid = NVME_NSID_NONE ,
522- .cntid = cntid ,
523- .nvmsetid = NVME_NVMSETID_NONE ,
524- .domid = NVME_DOMID_NONE ,
525- .uuidx = NVME_UUID_NONE ,
526- .csi = NVME_CSI_NVM ,
527- .data = cap ,
528- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
529- .result = NULL ,
530- };
531-
532- BUILD_ASSERT (sizeof (struct nvme_primary_ctrl_cap ) == 4096 );
533- return nvme_identify (& args );
534- }
535-
536- int nvme_identify_secondary_ctrl_list (int fd , __u32 nsid , __u16 cntid ,
537- struct nvme_secondary_ctrl_list * list )
538- {
539- struct nvme_identify_args args = {
540- .args_size = sizeof (args ),
541- .fd = fd ,
542- .cns = NVME_IDENTIFY_CNS_SECONDARY_CTRL_LIST ,
543- .nsid = nsid ,
544- .cntid = cntid ,
545- .nvmsetid = NVME_NVMSETID_NONE ,
546- .domid = NVME_DOMID_NONE ,
547- .uuidx = NVME_UUID_NONE ,
548- .csi = NVME_CSI_NVM ,
549- .data = list ,
550- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
551- .result = NULL ,
552- };
553-
554- BUILD_ASSERT (sizeof (struct nvme_secondary_ctrl_list ) == 4096 );
555- return nvme_identify (& args );
556- }
557-
558- int nvme_identify_ns_granularity (int fd ,
559- struct nvme_id_ns_granularity_list * list )
560- {
561- BUILD_ASSERT (sizeof (struct nvme_id_ns_granularity_list ) == 4096 );
562- return __nvme_identify (fd , NVME_IDENTIFY_CNS_NS_GRANULARITY ,
563- NVME_NSID_NONE , list );
564- }
565-
566- int nvme_identify_uuid (int fd , struct nvme_id_uuid_list * list )
567- {
568- BUILD_ASSERT (sizeof (struct nvme_id_uuid_list ) == 4096 );
569- return __nvme_identify (fd , NVME_IDENTIFY_CNS_UUID_LIST , NVME_NSID_NONE ,
570- list );
571- }
572-
573- int nvme_identify_ctrl_csi (int fd , __u8 csi , void * data )
574- {
575- struct nvme_identify_args args = {
576- .args_size = sizeof (args ),
577- .fd = fd ,
578- .cns = NVME_IDENTIFY_CNS_CSI_CTRL ,
579- .nsid = NVME_NSID_NONE ,
580- .cntid = NVME_CNTLID_NONE ,
581- .nvmsetid = NVME_NVMSETID_NONE ,
582- .domid = NVME_DOMID_NONE ,
583- .uuidx = NVME_UUID_NONE ,
584- .csi = csi ,
585- .data = data ,
586- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
587- .result = NULL ,
588- };
589-
590- return nvme_identify (& args );
591- }
592-
593- int nvme_identify_ns_csi (int fd , __u32 nsid , __u8 csi , void * data )
594- {
595- struct nvme_identify_args args = {
596- .args_size = sizeof (args ),
597- .fd = fd ,
598- .cns = NVME_IDENTIFY_CNS_CSI_NS ,
599- .nsid = nsid ,
600- .cntid = NVME_CNTLID_NONE ,
601- .nvmsetid = NVME_NVMSETID_NONE ,
602- .domid = NVME_DOMID_NONE ,
603- .uuidx = NVME_UUID_NONE ,
604- .csi = csi ,
605- .data = data ,
606- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
607- .result = NULL ,
608- };
609-
610- return nvme_identify (& args );
611- }
612-
613- int nvme_identify_active_ns_list_csi (int fd , __u32 nsid , __u8 csi ,
614- struct nvme_ns_list * list )
615- {
616- struct nvme_identify_args args = {
617- .args_size = sizeof (args ),
618- .fd = fd ,
619- .cns = NVME_IDENTIFY_CNS_NS_ACTIVE_LIST ,
620- .nsid = nsid ,
621- .cntid = NVME_CNTLID_NONE ,
622- .nvmsetid = NVME_NVMSETID_NONE ,
623- .domid = NVME_DOMID_NONE ,
624- .uuidx = NVME_UUID_NONE ,
625- .csi = csi ,
626- .data = list ,
627- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
628- .result = NULL ,
629- };
630-
631- BUILD_ASSERT (sizeof (struct nvme_ns_list ) == 4096 );
632- return nvme_identify (& args );
633- }
634-
635- int nvme_identify_allocated_ns_list_css (int fd , __u32 nsid , __u8 csi ,
636- struct nvme_ns_list * list )
637- {
638- struct nvme_identify_args args = {
639- .args_size = sizeof (args ),
640- .fd = fd ,
641- .cns = NVME_IDENTIFY_CNS_ALLOCATED_NS_LIST ,
642- .nsid = nsid ,
643- .cntid = NVME_CNTLID_NONE ,
644- .nvmsetid = NVME_NVMSETID_NONE ,
645- .domid = NVME_DOMID_NONE ,
646- .uuidx = NVME_UUID_NONE ,
647- .csi = csi ,
648- .data = list ,
649- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
650- .result = NULL ,
651- };
652-
653- return nvme_identify (& args );
654- }
655-
656- int nvme_identify_domain_list (int fd , __u16 domid ,
657- struct nvme_id_domain_list * list )
658- {
659- struct nvme_identify_args args = {
660- .args_size = sizeof (args ),
661- .fd = fd ,
662- .cns = NVME_IDENTIFY_CNS_DOMAIN_LIST ,
663- .nsid = NVME_NSID_NONE ,
664- .cntid = NVME_CNTLID_NONE ,
665- .nvmsetid = NVME_NVMSETID_NONE ,
666- .domid = domid ,
667- .uuidx = NVME_UUID_NONE ,
668- .csi = NVME_CSI_NVM ,
669- .data = list ,
670- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
671- .result = NULL ,
672- };
673-
674- BUILD_ASSERT (sizeof (struct nvme_id_domain_list ) == 4096 );
675- return nvme_identify (& args );
676- }
677-
678- int nvme_identify_endurance_group_list (int fd , __u16 endgrp_id ,
679- struct nvme_id_endurance_group_list * list )
680- {
681- struct nvme_identify_args args = {
682- .args_size = sizeof (args ),
683- .fd = fd ,
684- .cns = NVME_IDENTIFY_CNS_ENDURANCE_GROUP_ID ,
685- .nsid = NVME_NSID_NONE ,
686- .cntid = NVME_CNTLID_NONE ,
687- .nvmsetid = NVME_NVMSETID_NONE ,
688- .domid = endgrp_id ,
689- .uuidx = NVME_UUID_NONE ,
690- .csi = NVME_CSI_NVM ,
691- .data = list ,
692- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
693- .result = NULL ,
694- };
695-
696- BUILD_ASSERT (sizeof (struct nvme_id_endurance_group_list ) == 4096 );
697- return nvme_identify (& args );
698- }
699-
700- int nvme_identify_independent_identify_ns (int fd , __u32 nsid ,
701- struct nvme_id_independent_id_ns * ns )
702- {
703- struct nvme_identify_args args = {
704- .args_size = sizeof (args ),
705- .fd = fd ,
706- .cns = NVME_IDENTIFY_CNS_CSI_INDEPENDENT_ID_NS ,
707- .nsid = nsid ,
708- .cntid = NVME_CNTLID_NONE ,
709- .nvmsetid = NVME_NVMSETID_NONE ,
710- .domid = NVME_DOMID_NONE ,
711- .uuidx = NVME_UUID_NONE ,
712- .csi = NVME_CSI_NVM ,
713- .data = ns ,
714- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
715- .result = NULL ,
716- };
717-
718- BUILD_ASSERT (sizeof (struct nvme_id_independent_id_ns ) == 4096 );
719- return nvme_identify (& args );
720- }
721-
722- int nvme_identify_iocs (int fd , __u16 cntlid , struct nvme_id_iocs * iocs )
723- {
724- struct nvme_identify_args args = {
725- .args_size = sizeof (args ),
726- .fd = fd ,
727- .cns = NVME_IDENTIFY_CNS_COMMAND_SET_STRUCTURE ,
728- .nsid = NVME_NSID_NONE ,
729- .cntid = cntlid ,
730- .nvmsetid = NVME_NVMSETID_NONE ,
731- .domid = NVME_DOMID_NONE ,
732- .uuidx = NVME_UUID_NONE ,
733- .csi = NVME_CSI_NVM ,
734- .data = iocs ,
735- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
736- .result = NULL ,
737- };
738-
739- BUILD_ASSERT (sizeof (struct nvme_id_iocs ) == 4096 );
740- return nvme_identify (& args );
741- }
742-
743- int nvme_zns_identify_ns (int fd , __u32 nsid , struct nvme_zns_id_ns * data )
744- {
745- struct nvme_identify_args args = {
746- .args_size = sizeof (args ),
747- .fd = fd ,
748- .cns = NVME_IDENTIFY_CNS_CSI_NS ,
749- .nsid = nsid ,
750- .cntid = NVME_CNTLID_NONE ,
751- .nvmsetid = NVME_NVMSETID_NONE ,
752- .domid = NVME_DOMID_NONE ,
753- .uuidx = NVME_UUID_NONE ,
754- .csi = NVME_CSI_ZNS ,
755- .data = data ,
756- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
757- .result = NULL ,
758- };
759-
760- BUILD_ASSERT (sizeof (struct nvme_zns_id_ns ) == 4096 );
761- return nvme_identify (& args );
762- }
763-
764- int nvme_zns_identify_ctrl (int fd , struct nvme_zns_id_ctrl * id )
765- {
766- BUILD_ASSERT (sizeof (struct nvme_zns_id_ctrl ) == 4096 );
767- return nvme_identify_ctrl_csi (fd , NVME_CSI_ZNS , id );
768- }
769-
770- int nvme_nvm_identify_ctrl (int fd , struct nvme_id_ctrl_nvm * id )
771- {
772- BUILD_ASSERT (sizeof (struct nvme_id_ctrl_nvm ) == 4096 );
773- return nvme_identify_ctrl_csi (fd , NVME_CSI_NVM , id );
774- }
775-
776393int nvme_get_log (struct nvme_get_log_args * args )
777394{
778395 __u32 numd = (args -> len >> 2 ) - 1 ;
0 commit comments