@@ -287,6 +287,70 @@ bool nvme_transport_handle_is_direct(struct nvme_transport_handle *hdl);
287287 */
288288bool nvme_transport_handle_is_mi (struct nvme_transport_handle * hdl );
289289
290+ /**
291+ * nvme_transport_handle_set_submit_entry() - Install a submit-entry callback
292+ * @hdl: Transport handle to configure
293+ * @submit_entry: Callback invoked immediately before a passthrough command is
294+ * submitted. The function receives the command about to be issued
295+ * and may return an opaque pointer representing per-command
296+ * context. This pointer is later passed unmodified to the
297+ * submit-exit callback. Implementations typically use this hook
298+ * for logging, tracing, or allocating per-command state.
299+ *
300+ * Installs a user-defined callback that is invoked at the moment a passthrough
301+ * command enters the NVMe submission path. Passing NULL removes any previously
302+ * installed callback.
303+ *
304+ * Return: None.
305+ */
306+ void nvme_transport_handle_set_submit_entry (struct nvme_transport_handle * hdl ,
307+ void * (* submit_entry )(struct nvme_transport_handle * hdl ,
308+ struct nvme_passthru_cmd * cmd ));
309+
310+ /**
311+ * nvme_transport_handle_set_submit_exit() - Install a submit-exit callback
312+ * @hdl: Transport handle to configure
313+ * @submit_exit: Callback invoked after a passthrough command completes. The
314+ * function receives the command, the completion status @err
315+ * (0 for success, a negative errno, or an NVMe status value), and
316+ * the @user_data pointer returned earlier by the submit-entry
317+ * callback. Implementations typically use this hook for logging,
318+ * tracing, or freeing per-command state.
319+ *
320+ * Installs a callback that is invoked when a passthrough command leaves the
321+ * NVMe submission path. Passing NULL removes any previously installed callback.
322+ *
323+ * Return: None.
324+ */
325+ void nvme_transport_handle_set_submit_exit (struct nvme_transport_handle * hdl ,
326+ void (* submit_exit )(struct nvme_transport_handle * hdl ,
327+ struct nvme_passthru_cmd * cmd ,
328+ int err , void * user_data ));
329+
330+ /**
331+ * nvme_transport_handle_set_decide_retry() - Install a retry-decision callback
332+ * @hdl: Transport handle to configure
333+ * @decide_retry: Callback used to determine whether a passthrough command
334+ * should be retried after an error. The function is called with
335+ * the command that failed and the error code returned by the
336+ * kernel or device. The callback should return true if the
337+ * submission path should retry the command, or false if the
338+ * error is final.
339+ *
340+ * Installs a user-provided callback to control retry behavior for
341+ * passthrough commands issued through @hdl. This allows transports or
342+ * higher-level logic to implement custom retry policies, such as retrying on
343+ * transient conditions like -EAGAIN or device-specific status codes.
344+ *
345+ * Passing NULL clears any previously installed callback and reverts to the
346+ * default behavior (no retries).
347+ *
348+ * Return: None.
349+ */
350+ void nvme_transport_handle_set_decide_retry (struct nvme_transport_handle * hdl ,
351+ bool (* decide_retry )(struct nvme_transport_handle * hdl ,
352+ struct nvme_passthru_cmd * cmd , int err ));
353+
290354/**
291355 * enum nvme_hmac_alg - HMAC algorithm
292356 * @NVME_HMAC_ALG_NONE: No HMAC algorithm
@@ -636,22 +700,15 @@ int nvme_import_tls_key_versioned(const char *encoded_key,
636700 unsigned char * hmac ,
637701 size_t * key_len ,
638702 unsigned char * * key );
703+
639704/**
640- * nvme_submit_passthru - Low level ioctl wrapper for passthru commands
641- * @hdl: Transport handle
642- * @ioctl_cmd: IOCTL command id
643- * @cmd: Passhtru command
644- * @result: Optional field to return the result
645- *
646- * This is a low level library function which should not be used directly. It is
647- * exposed as weak symbol so that the user application is able to provide their own
648- * implementation of this function with additional debugging or logging code.
705+ * nvme_set_dry_run() - Set global dry run state
706+ * @ctx: struct nvme_global_ctx object
707+ * @enable: Enable/disable dry run state
649708 *
650- * Return: The value from the ioctl system call (see ioctl documentation) or
651- * a negative error code otherwise .
709+ * When dry_run is enabled, any IOCTL commands send via the passthru
710+ * interface wont be executed .
652711 */
653- __attribute__((weak ))
654- int nvme_submit_passthru (struct nvme_transport_handle * hdl , unsigned long ioctl_cmd ,
655- struct nvme_passthru_cmd * cmd , __u64 * result );
712+ void nvme_set_dry_run (struct nvme_global_ctx * ctx , bool enable );
656713
657714#endif /* _LIBNVME_LINUX_H */
0 commit comments