Skip to content

Commit f148243

Browse files
committed
ioctl: nvme_set_features use nvme_passthru_cmd directly
Drop struct nvme_set_features_args. Signed-off-by: Dennis Maisenbacher <[email protected]>
1 parent 58a0811 commit f148243

File tree

5 files changed

+286
-469
lines changed

5 files changed

+286
-469
lines changed

src/nvme/api-types.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -86,38 +86,6 @@ struct nvme_get_log_args {
8686
bool ot;
8787
};
8888

89-
/**
90-
* struct nvme_set_features_args - Arguments for the NVMe Admin Set Feature command
91-
* @result: The command completion result from CQE dword0
92-
* @data: User address of feature data, if applicable
93-
* @args_size: Size of &struct nvme_set_features_args
94-
* @timeout: Timeout in ms
95-
* @nsid: Namespace ID, if applicable
96-
* @cdw11: Value to set the feature to
97-
* @cdw12: Feature specific command dword12 field
98-
* @cdw13: Feature specific command dword13 field
99-
* @cdw15: Feature specific command dword15 field
100-
* @data_len: Length of feature data, if applicable, in bytes
101-
* @save: Save value across power states
102-
* @uuidx: UUID Index for differentiating vendor specific encoding
103-
* @fid: Feature identifier
104-
*/
105-
struct nvme_set_features_args {
106-
__u32 *result;
107-
void *data;
108-
int args_size;
109-
__u32 timeout;
110-
__u32 nsid;
111-
__u32 cdw11;
112-
__u32 cdw12;
113-
__u32 cdw13;
114-
__u32 cdw15;
115-
__u32 data_len;
116-
bool save;
117-
__u8 uuidx;
118-
__u8 fid;
119-
};
120-
12189
/**
12290
* struct nvme_get_features_args - Arguments for the NVMe Admin Get Feature command
12391
* @args_size: Size of &struct nvme_get_features_args

src/nvme/ioctl.c

Lines changed: 0 additions & 337 deletions
Original file line numberDiff line numberDiff line change
@@ -635,325 +635,6 @@ int nvme_get_ana_log_atomic(nvme_link_t l, bool rae, bool rgo,
635635
return -EAGAIN;
636636
}
637637

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

2198-
int nvme_lm_set_features_ctrl_data_queue(nvme_link_t l, __u16 cdqid, __u32 hp, __u32 tpt, bool etpt,
2199-
__u32 *result)
2200-
{
2201-
struct nvme_set_features_args args = {
2202-
.args_size = sizeof(args),
2203-
.fid = NVME_FEAT_FID_CTRL_DATA_QUEUE,
2204-
.nsid = NVME_NSID_NONE,
2205-
.cdw11 = cdqid | NVME_SET(etpt, LM_CTRL_DATA_QUEUE_ETPT),
2206-
.cdw12 = hp,
2207-
.cdw13 = tpt,
2208-
.save = false,
2209-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2210-
.result = result,
2211-
};
2212-
2213-
return nvme_set_features(l, &args);
2214-
}
2215-
22161879
int nvme_lm_get_features_ctrl_data_queue(nvme_link_t l, __u16 cdqid,
22171880
struct nvme_lm_ctrl_data_queue_fid_data *data,
22181881
__u32 *result)

0 commit comments

Comments
 (0)