@@ -634,325 +634,6 @@ int nvme_get_ana_log_atomic(nvme_link_t l, bool rgo, bool rae, unsigned int retr
634634 return - EAGAIN ;
635635}
636636
637- int nvme_set_features (nvme_link_t l , struct nvme_set_features_args * args )
638- {
639- __u32 cdw10 = NVME_SET (args -> fid , FEATURES_CDW10_FID ) |
640- NVME_SET (!!args -> save , SET_FEATURES_CDW10_SAVE );
641- __u32 cdw14 = NVME_SET (args -> uuidx , FEATURES_CDW14_UUID );
642-
643- struct nvme_passthru_cmd cmd = {
644- .opcode = nvme_admin_set_features ,
645- .nsid = args -> nsid ,
646- .addr = (__u64 )(uintptr_t )args -> data ,
647- .data_len = args -> data_len ,
648- .cdw10 = cdw10 ,
649- .cdw11 = args -> cdw11 ,
650- .cdw12 = args -> cdw12 ,
651- .cdw13 = args -> cdw13 ,
652- .cdw14 = cdw14 ,
653- .cdw15 = args -> cdw15 ,
654- .timeout_ms = args -> timeout ,
655- };
656- if (args -> args_size < sizeof (* args ))
657- return - EINVAL ;
658-
659- return nvme_submit_admin_passthru (l , & cmd , args -> result );
660- }
661-
662- static int __nvme_set_features (nvme_link_t l , __u8 fid , __u32 cdw11 , bool save ,
663- __u32 * result )
664- {
665- struct nvme_set_features_args args = {
666- .args_size = sizeof (args ),
667- .fid = fid ,
668- .nsid = NVME_NSID_NONE ,
669- .cdw11 = cdw11 ,
670- .cdw12 = 0 ,
671- .save = save ,
672- .uuidx = NVME_UUID_NONE ,
673- .cdw15 = 0 ,
674- .data_len = 0 ,
675- .data = NULL ,
676- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
677- .result = result ,
678- };
679- return nvme_set_features (l , & args );
680- }
681-
682- int nvme_set_features_arbitration (nvme_link_t l , __u8 ab , __u8 lpw , __u8 mpw ,
683- __u8 hpw , bool save , __u32 * result )
684- {
685- __u32 value = NVME_SET (ab , FEAT_ARBITRATION_BURST ) |
686- NVME_SET (lpw , FEAT_ARBITRATION_LPW ) |
687- NVME_SET (mpw , FEAT_ARBITRATION_MPW ) |
688- NVME_SET (hpw , FEAT_ARBITRATION_HPW );
689-
690- return __nvme_set_features (l , NVME_FEAT_FID_ARBITRATION , value , save ,
691- result );
692- }
693-
694- int nvme_set_features_power_mgmt (nvme_link_t l , __u8 ps , __u8 wh , bool save ,
695- __u32 * result )
696- {
697- __u32 value = NVME_SET (ps , FEAT_PWRMGMT_PS ) |
698- NVME_SET (wh , FEAT_PWRMGMT_WH );
699-
700- return __nvme_set_features (l , NVME_FEAT_FID_POWER_MGMT , value , save ,
701- result );
702- }
703-
704- int nvme_set_features_lba_range (nvme_link_t l , __u32 nsid , __u8 nr_ranges , bool save ,
705- struct nvme_lba_range_type * data , __u32 * result )
706- {
707- return nvme_set_features_data (
708- l , NVME_FEAT_FID_LBA_RANGE , nsid , nr_ranges - 1 , save ,
709- sizeof (* data ), data , result );
710- }
711-
712- int nvme_set_features_temp_thresh (nvme_link_t l , __u16 tmpth , __u8 tmpsel ,
713- enum nvme_feat_tmpthresh_thsel thsel , __u8 tmpthh ,
714- bool save , __u32 * result )
715- {
716- __u32 value = NVME_SET (tmpth , FEAT_TT_TMPTH ) |
717- NVME_SET (tmpsel , FEAT_TT_TMPSEL ) |
718- NVME_SET (thsel , FEAT_TT_THSEL ) |
719- NVME_SET (tmpthh , FEAT_TT_TMPTHH );
720-
721- return __nvme_set_features (l , NVME_FEAT_FID_TEMP_THRESH , value , save ,
722- result );
723- }
724-
725- int nvme_set_features_err_recovery (nvme_link_t l , __u32 nsid , __u16 tler , bool dulbe ,
726- bool save , __u32 * result )
727- {
728- __u32 value = NVME_SET (tler , FEAT_ERROR_RECOVERY_TLER ) |
729- NVME_SET (!!dulbe , FEAT_ERROR_RECOVERY_DULBE );
730-
731- return nvme_set_features_simple (
732- l , NVME_FEAT_FID_ERR_RECOVERY , nsid , value , save , result );
733- }
734-
735- int nvme_set_features_volatile_wc (nvme_link_t l , bool wce , bool save , __u32 * result )
736- {
737- __u32 value = NVME_SET (!!wce , FEAT_VWC_WCE );
738-
739- return __nvme_set_features (l , NVME_FEAT_FID_VOLATILE_WC , value , save ,
740- result );
741- }
742-
743- int nvme_set_features_irq_coalesce (nvme_link_t l , __u8 thr , __u8 time , bool save ,
744- __u32 * result )
745- {
746- __u32 value = NVME_SET (thr , FEAT_IRQC_THR ) |
747- NVME_SET (time , FEAT_IRQC_TIME );
748-
749- return __nvme_set_features (l , NVME_FEAT_FID_IRQ_COALESCE , value , save ,
750- result );
751- }
752-
753- int nvme_set_features_irq_config (nvme_link_t l , __u16 iv , bool cd , bool save ,
754- __u32 * result )
755- {
756- __u32 value = NVME_SET (iv , FEAT_ICFG_IV ) |
757- NVME_SET (!!cd , FEAT_ICFG_CD );
758-
759- return __nvme_set_features (l , NVME_FEAT_FID_IRQ_CONFIG , value , save ,
760- result );
761- }
762-
763- int nvme_set_features_write_atomic (nvme_link_t l , bool dn , bool save , __u32 * result )
764- {
765- __u32 value = NVME_SET (!!dn , FEAT_WA_DN );
766-
767- return __nvme_set_features (l , NVME_FEAT_FID_WRITE_ATOMIC , value , save ,
768- result );
769- }
770-
771- int nvme_set_features_async_event (nvme_link_t l , __u32 events ,
772- bool save , __u32 * result )
773- {
774- return __nvme_set_features (l , NVME_FEAT_FID_ASYNC_EVENT , events , save ,
775- result );
776- }
777-
778- int nvme_set_features_auto_pst (nvme_link_t l , bool apste , bool save ,
779- struct nvme_feat_auto_pst * apst , __u32 * result )
780- {
781- return nvme_set_features_data (l , NVME_FEAT_FID_AUTO_PST ,
782- NVME_NSID_NONE , NVME_SET (!!apste , FEAT_APST_APSTE ), save ,
783- sizeof (* apst ), apst , result );
784- }
785-
786- int nvme_set_features_timestamp (nvme_link_t l , bool save , __u64 timestamp )
787- {
788- __le64 t = cpu_to_le64 (timestamp );
789- struct nvme_timestamp ts = {};
790- memcpy (ts .timestamp , & t , sizeof (ts .timestamp ));
791-
792- return nvme_set_features_data (l , NVME_FEAT_FID_TIMESTAMP ,
793- NVME_NSID_NONE , 0 , save , sizeof (ts ), & ts , NULL );
794- }
795-
796- int nvme_set_features_hctm (nvme_link_t l , __u16 tmt2 , __u16 tmt1 ,
797- bool save , __u32 * result )
798- {
799- __u32 value = NVME_SET (tmt2 , FEAT_HCTM_TMT2 ) |
800- NVME_SET (tmt1 , FEAT_HCTM_TMT1 );
801-
802- return __nvme_set_features (l , NVME_FEAT_FID_HCTM , value , save ,
803- result );
804- }
805-
806- int nvme_set_features_nopsc (nvme_link_t l , bool noppme , bool save , __u32 * result )
807- {
808- __u32 value = NVME_SET (noppme , FEAT_NOPS_NOPPME );
809-
810- return __nvme_set_features (l , NVME_FEAT_FID_NOPSC , value , save ,
811- result );
812- }
813-
814- int nvme_set_features_rrl (nvme_link_t l , __u8 rrl , __u16 nvmsetid ,
815- bool save , __u32 * result )
816- {
817- struct nvme_set_features_args args = {
818- .args_size = sizeof (args ),
819- .fid = NVME_FEAT_FID_RRL ,
820- .nsid = NVME_NSID_NONE ,
821- .cdw11 = nvmsetid ,
822- .cdw12 = rrl ,
823- .save = save ,
824- .uuidx = NVME_UUID_NONE ,
825- .cdw15 = 0 ,
826- .data_len = 0 ,
827- .data = NULL ,
828- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
829- .result = result ,
830- };
831-
832- return nvme_set_features (l , & args );
833- }
834-
835- int nvme_set_features_plm_config (nvme_link_t l , bool plm , __u16 nvmsetid , bool save ,
836- struct nvme_plm_config * data , __u32 * result )
837- {
838- struct nvme_set_features_args args = {
839- .args_size = sizeof (args ),
840- .fid = NVME_FEAT_FID_PLM_CONFIG ,
841- .nsid = NVME_NSID_NONE ,
842- .cdw11 = nvmsetid ,
843- .cdw12 = !!plm ,
844- .save = save ,
845- .uuidx = NVME_UUID_NONE ,
846- .cdw15 = 0 ,
847- .data_len = sizeof (* data ),
848- .data = data ,
849- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
850- .result = result ,
851- };
852-
853- return nvme_set_features (l , & args );
854- }
855-
856- int nvme_set_features_plm_window (nvme_link_t l , enum nvme_feat_plm_window_select sel ,
857- __u16 nvmsetid , bool save , __u32 * result )
858- {
859- __u32 cdw12 = NVME_SET (sel , FEAT_PLMW_WS );
860- struct nvme_set_features_args args = {
861- .args_size = sizeof (args ),
862- .fid = NVME_FEAT_FID_PLM_WINDOW ,
863- .nsid = NVME_NSID_NONE ,
864- .cdw11 = nvmsetid ,
865- .cdw12 = cdw12 ,
866- .save = save ,
867- .uuidx = NVME_UUID_NONE ,
868- .cdw15 = 0 ,
869- .data_len = 0 ,
870- .data = NULL ,
871- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
872- .result = result ,
873- };
874-
875- return nvme_set_features (l , & args );
876- }
877-
878- int nvme_set_features_lba_sts_interval (nvme_link_t l , __u16 lsiri , __u16 lsipi ,
879- bool save , __u32 * result )
880- {
881- __u32 value = NVME_SET (lsiri , FEAT_LBAS_LSIRI ) |
882- NVME_SET (lsipi , FEAT_LBAS_LSIPI );
883-
884- return __nvme_set_features (l , NVME_FEAT_FID_LBA_STS_INTERVAL , value ,
885- save , result );
886- }
887-
888- int nvme_set_features_host_behavior (nvme_link_t l , bool save ,
889- struct nvme_feat_host_behavior * data )
890- {
891- return nvme_set_features_data (l , NVME_FEAT_FID_HOST_BEHAVIOR ,
892- NVME_NSID_NONE , 0 , false, sizeof (* data ), data , NULL );
893- }
894-
895- int nvme_set_features_sanitize (nvme_link_t l , bool nodrm , bool save , __u32 * result )
896- {
897- return __nvme_set_features (l , NVME_FEAT_FID_SANITIZE , !!nodrm , save ,
898- result );
899- }
900-
901- int nvme_set_features_endurance_evt_cfg (nvme_link_t l , __u16 endgid , __u8 egwarn ,
902- bool save , __u32 * result )
903- {
904- __u32 value = endgid | egwarn << 16 ;
905-
906- return __nvme_set_features (l , NVME_FEAT_FID_ENDURANCE_EVT_CFG , value ,
907- save , result );
908- }
909-
910- int nvme_set_features_sw_progress (nvme_link_t l , __u8 pbslc , bool save ,
911- __u32 * result )
912- {
913- return __nvme_set_features (l , NVME_FEAT_FID_SW_PROGRESS , pbslc , save ,
914- result );
915- }
916-
917- int nvme_set_features_host_id (nvme_link_t l , bool exhid , bool save , __u8 * hostid )
918- {
919- __u32 len = exhid ? 16 : 8 ;
920- __u32 value = !!exhid ;
921-
922- return nvme_set_features_data (l , NVME_FEAT_FID_HOST_ID ,
923- NVME_NSID_NONE , value , save , len , hostid , NULL );
924- }
925-
926- int nvme_set_features_resv_mask (nvme_link_t l , __u32 nsid , __u32 mask , bool save ,
927- __u32 * result )
928- {
929- return nvme_set_features_simple (
930- l , NVME_FEAT_FID_RESV_MASK , nsid , mask , save , result );
931- }
932-
933- int nvme_set_features_resv_persist (nvme_link_t l , __u32 nsid , bool ptpl , bool save ,
934- __u32 * result )
935- {
936- return nvme_set_features_simple (
937- l , NVME_FEAT_FID_RESV_PERSIST , nsid , !!ptpl , save , result );
938- }
939-
940- int nvme_set_features_write_protect (nvme_link_t l , __u32 nsid ,
941- enum nvme_feat_nswpcfg_state state ,
942- bool save , __u32 * result )
943- {
944- return nvme_set_features_simple (
945- l , NVME_FEAT_FID_WRITE_PROTECT , nsid , state , false, result );
946- }
947-
948- int nvme_set_features_iocs_profile (nvme_link_t l , __u16 iocsi , bool save )
949- {
950- __u32 value = NVME_SET (iocsi , FEAT_IOCSP_IOCSCI );
951-
952- return __nvme_set_features (l , NVME_FEAT_FID_IOCS_PROFILE , value ,
953- save , NULL );
954- }
955-
956637int nvme_get_features (nvme_link_t l , struct nvme_get_features_args * args )
957638{
958639 __u32 cdw10 = NVME_SET (args -> fid , FEATURES_CDW10_FID ) |
@@ -2194,24 +1875,6 @@ int nvme_lm_migration_recv(nvme_link_t l, struct nvme_lm_migration_recv_args *ar
21941875 return nvme_submit_admin_passthru (l , & cmd , args -> result );
21951876}
21961877
2197- int nvme_lm_set_features_ctrl_data_queue (nvme_link_t l , __u16 cdqid , __u32 hp , __u32 tpt , bool etpt ,
2198- __u32 * result )
2199- {
2200- struct nvme_set_features_args args = {
2201- .args_size = sizeof (args ),
2202- .fid = NVME_FEAT_FID_CTRL_DATA_QUEUE ,
2203- .nsid = NVME_NSID_NONE ,
2204- .cdw11 = cdqid | NVME_SET (etpt , LM_CTRL_DATA_QUEUE_ETPT ),
2205- .cdw12 = hp ,
2206- .cdw13 = tpt ,
2207- .save = false,
2208- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
2209- .result = result ,
2210- };
2211-
2212- return nvme_set_features (l , & args );
2213- }
2214-
22151878int nvme_lm_get_features_ctrl_data_queue (nvme_link_t l , __u16 cdqid ,
22161879 struct nvme_lm_ctrl_data_queue_fid_data * data ,
22171880 __u32 * result )
0 commit comments