return 0;
}
+int nvme_get_feature_length2(int fid, __u32 cdw11, enum nvme_data_tfr dir,
+ __u32 *len)
+{
+ switch (fid) {
+ case NVME_FEAT_FID_HOST_MEM_BUF:
+ if (dir == NVME_DATA_TFR_HOST_TO_CTRL) {
+ *len = 0;
+ break;
+ }
+ fallthrough;
+ default:
+ return nvme_get_feature_length(fid, cdw11, len);
+ }
+ return 0;
+}
+
int nvme_get_directive_receive_length(enum nvme_directive_dtype dtype,
enum nvme_directive_receive_doper doper, __u32 *len)
{
* libnvme utility functions
*/
+#if __has_attribute(__fallthrough__)
+# define fallthrough __attribute__((__fallthrough__))
+#else
+# define fallthrough do {} while (0) /* fallthrough */
+#endif
+
/**
* enum nvme_connect_err - nvme connect error codes
* @ENVME_CONNECT_RESOLVE: failed to resolve host
*/
int nvme_get_feature_length(int fid, __u32 cdw11, __u32 *len);
+/**
+ * enum nvme_data_tfr - Data transfer direction of the command
+ * @NVME_DATA_TFR_NO_DATA_TFR: No data transfer
+ * @NVME_DATA_TFR_HOST_TO_CTRL: Host to controller
+ * @NVME_DATA_TFR_CTRL_TO_HOST: Controller to host
+ * @NVME_DATA_TFR_BIDIRECTIONAL: Bidirectional
+ */
+enum nvme_data_tfr {
+ NVME_DATA_TFR_NO_DATA_TFR,
+ NVME_DATA_TFR_HOST_TO_CTRL,
+ NVME_DATA_TFR_CTRL_TO_HOST,
+ NVME_DATA_TFR_BIDIRECTIONAL
+};
+
+/**
+ * nvme_get_feature_length2() - Retreive the command payload length for a
+ * specific feature identifier
+ * @fid: Feature identifier, see &enum nvme_features_id.
+ * @cdw11: The cdw11 value may affect the transfer (only known fid is
+ * %NVME_FEAT_FID_HOST_ID)
+ * @dir: Data transfer direction: false - host to controller, true -
+ * controller to host may affect the transfer (only known fid is
+ * %NVME_FEAT_FID_HOST_MEM_BUF).
+ * @len: On success, set to this features payload length in bytes.
+ *
+ * Return: 0 on success, -1 with errno set to EINVAL if the function did not
+ * recognize &fid.
+ */
+int nvme_get_feature_length2(int fid, __u32 cdw11, enum nvme_data_tfr dir,
+ __u32 *len);
+
/**
* nvme_get_directive_receive_length() - Get directive receive length
* @dtype: Directive type, see &enum nvme_directive_dtype