@@ -2666,7 +2666,7 @@ int nvme_get_features_iocs_profile(int fd, enum nvme_get_features_sel sel,
26662666 __u32 * result );
26672667
26682668/**
2669- * nvme_format_nvm() - Format nvme namespace(s)
2669+ * nvme_format_nvm_args - Arguments for the Format Nvme Namespace command
26702670 * @fd: File descriptor of nvme device
26712671 * @nsid: Namespace ID to format
26722672 * @lbaf: Logical block address format
@@ -2677,6 +2677,23 @@ int nvme_get_features_iocs_profile(int fd, enum nvme_get_features_sel sel,
26772677 * @timeout: Set to override default timeout to this value in milliseconds;
26782678 * useful for long running formats. 0 will use system default.
26792679 * @result: The command completion result from CQE dword0
2680+ */
2681+ struct nvme_format_nvm_args {
2682+ int args_size ;
2683+ int fd ;
2684+ __u32 nsid ;
2685+ __u8 lbaf ;
2686+ enum nvme_cmd_format_mset mset ;
2687+ enum nvme_cmd_format_pi pi ;
2688+ enum nvme_cmd_format_pil pil ;
2689+ enum nvme_cmd_format_ses ses ;
2690+ __u32 timeout ;
2691+ __u32 * result ;
2692+ };
2693+
2694+ /**
2695+ * nvme_format_nvm() - Format nvme namespace(s)
2696+ * @args: &struct nvme_format_nvme_args argument structure
26802697 *
26812698 * The Format NVM command low level formats the NVM media. This command is used
26822699 * by the host to change the LBA data size and/or metadata size. A low level
@@ -2686,25 +2703,34 @@ int nvme_get_features_iocs_profile(int fd, enum nvme_get_features_sel sel,
26862703 * Return: The nvme command status if a response was received (see
26872704 * &enum nvme_status_field) or -1 with errno set otherwise.
26882705 */
2689- int nvme_format_nvm (int fd , __u32 nsid , __u8 lbaf ,
2690- enum nvme_cmd_format_mset mset ,
2691- enum nvme_cmd_format_pi pi ,
2692- enum nvme_cmd_format_pil pil ,
2693- enum nvme_cmd_format_ses ses ,
2694- __u32 timeout , __u32 * result );
2706+ int nvme_format_nvm (struct nvme_format_nvm_args * args );
26952707
26962708/**
2697- * nvme_ns_mgmt() -
2709+ * nvme_ns_mgmt_args - Arguments for NVMe Namespace Management command
26982710 * @fd: File descriptor of nvme device
26992711 * @nsid: Namespace identifier
2700- * @sel:
2712+ * @sel: Type of management operation to perform
27012713 * @ns: Namespace identication descriptors
27022714 * @result: NVMe command result
27032715 * @timeout: Timeout in ms
27042716 * @csi: Command Set Identifier
27052717 */
2706- int nvme_ns_mgmt (int fd , __u32 nsid , enum nvme_ns_mgmt_sel sel ,
2707- struct nvme_id_ns * ns , __u32 * result , __u32 timeout , __u8 csi );
2718+ struct nvme_ns_mgmt_args {
2719+ int args_size ;
2720+ int fd ;
2721+ __u32 nsid ;
2722+ enum nvme_ns_mgmt_sel sel ;
2723+ struct nvme_id_ns * ns ;
2724+ __u32 * result ;
2725+ __u32 timeout ;
2726+ __u8 csi ;
2727+ };
2728+
2729+ /**
2730+ * nvme_ns_mgmt() -
2731+ * @args: &struct nvme_ns_mgmt_args Argument structure
2732+ */
2733+ int nvme_ns_mgmt (struct nvme_ns_mgmt_args * args );
27082734
27092735/**
27102736 * nvme_ns_mgmt_create() -
@@ -2722,8 +2748,22 @@ int nvme_ns_mgmt(int fd, __u32 nsid, enum nvme_ns_mgmt_sel sel,
27222748 * Return: The nvme command status if a response was received (see
27232749 * &enum nvme_status_field) or -1 with errno set otherwise.
27242750 */
2725- int nvme_ns_mgmt_create (int fd , struct nvme_id_ns * ns , __u32 * nsid ,
2726- __u32 timeout , __u8 csi );
2751+ static inline int nvme_ns_mgmt_create (int fd , struct nvme_id_ns * ns ,
2752+ __u32 * nsid , __u32 timeout , __u8 csi )
2753+ {
2754+ struct nvme_ns_mgmt_args args = {
2755+ .args_size = sizeof (args ),
2756+ .fd = fd ,
2757+ .nsid = NVME_NSID_NONE ,
2758+ .sel = NVME_NS_MGMT_SEL_CREATE ,
2759+ .ns = ns ,
2760+ .result = nsid ,
2761+ .timeout = timeout ,
2762+ .csi = csi ,
2763+ };
2764+
2765+ return nvme_ns_mgmt (& args );
2766+ }
27272767
27282768/**
27292769 * nvme_ns_mgmt_delete() -
@@ -2737,34 +2777,86 @@ int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns, __u32 *nsid,
27372777 * Return: The nvme command status if a response was received (see
27382778 * &enum nvme_status_field) or -1 with errno set otherwise.
27392779 */
2740- int nvme_ns_mgmt_delete (int fd , __u32 nsid );
2780+ static inline int nvme_ns_mgmt_delete (int fd , __u32 nsid )
2781+ {
2782+ struct nvme_ns_mgmt_args args = {
2783+ .args_size = sizeof (args ),
2784+ .fd = fd ,
2785+ .nsid = nsid ,
2786+ .sel = NVME_NS_MGMT_SEL_DELETE ,
2787+ .ns = NULL ,
2788+ .result = NULL ,
2789+ .timeout = 0 ,
2790+ .csi = 0 ,
2791+ };
2792+
2793+ return nvme_ns_mgmt (& args );
2794+ }
27412795
27422796/**
2743- * nvme_ns_attach() - Attach or detach namespace to controller(s)
2797+ * nvme_ns_attach_args - Arguments for Nvme Namespace Management command
27442798 * @fd: File descriptor of nvme device
27452799 * @nsid: Namespace ID to execute attach selection
27462800 * @sel: Attachment selection, see &enum nvme_ns_attach_sel
27472801 * @ctrlist: Controller list to modify attachment state of nsid
27482802 * @timeout: Timeout in ms
27492803 */
2750- int nvme_ns_attach (int fd , __u32 nsid , enum nvme_ns_attach_sel sel ,
2751- struct nvme_ctrl_list * ctrlist , __u32 timeout );
2804+ struct nvme_ns_attach_args {
2805+ int args_size ;
2806+ int fd ;
2807+ __u32 nsid ;
2808+ enum nvme_ns_attach_sel sel ;
2809+ struct nvme_ctrl_list * ctrlist ;
2810+ __u32 timeout ;
2811+ };
2812+
2813+ /**
2814+ * nvme_ns_attach_args - Attach or detach namespace to controller(s)
2815+ * @args: &struct nvme_ns_attach_args Argument structure
2816+ */
2817+ int nvme_ns_attach (struct nvme_ns_attach_args * args );
27522818
27532819/**
27542820 * nvme_ns_attach_ctrls() -
27552821 * @fd: File descriptor of nvme device
27562822 * @nsid: Namespace ID to attach
27572823 * @ctrlist: Controller list to modify attachment state of nsid
27582824 */
2759- int nvme_ns_attach_ctrls (int fd , __u32 nsid , struct nvme_ctrl_list * ctrlist );
2825+ static inline int nvme_ns_attach_ctrls (int fd , __u32 nsid ,
2826+ struct nvme_ctrl_list * ctrlist )
2827+ {
2828+ struct nvme_ns_attach_args args = {
2829+ .args_size = sizeof (args ),
2830+ .fd = fd ,
2831+ .nsid = nsid ,
2832+ .sel = NVME_NS_ATTACH_SEL_CTRL_ATTACH ,
2833+ .ctrlist = ctrlist ,
2834+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
2835+ };
2836+
2837+ return nvme_ns_attach (& args );
2838+ }
27602839
27612840/**
27622841 * nvme_ns_detach_ctrls() -
27632842 * @fd: File descriptor of nvme device
27642843 * @nsid: Namespace ID to detach
27652844 * @ctrlist: Controller list to modify attachment state of nsid
27662845 */
2767- int nvme_ns_detach_ctrls (int fd , __u32 nsid , struct nvme_ctrl_list * ctrlist );
2846+ static inline int nvme_ns_detach_ctrls (int fd , __u32 nsid ,
2847+ struct nvme_ctrl_list * ctrlist )
2848+ {
2849+ struct nvme_ns_attach_args args = {
2850+ .args_size = sizeof (args ),
2851+ .fd = fd ,
2852+ .nsid = nsid ,
2853+ .sel = NVME_NS_ATTACH_SEL_CTRL_DEATTACH ,
2854+ .ctrlist = ctrlist ,
2855+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
2856+ };
2857+
2858+ return nvme_ns_attach (& args );
2859+ }
27682860
27692861/**
27702862 * nvme_fw_download() - Download part or all of a firmware image to the
@@ -3016,7 +3108,7 @@ int nvme_directive_recv_stream_allocate(int fd, __u32 nsid, __u16 nsr,
30163108 __u32 * result );
30173109
30183110/**
3019- * nvme_capacity_mgmt() -
3111+ * nvme_capacity_mgmt_args - Arguments for the NVMe Capacity Management command
30203112 * @fd: File descriptor of nvme device
30213113 * @op: Operation to be performed by the controller
30223114 * @element_id: Value specific to the value of the Operation field
0 commit comments