Control NVMeOF

Overview

API for control NVMe Over Fabrics

Copyright (C) 2004-2022 OKTET Labs Ltd. More…

// typedefs

typedef const char* tapi_nvme_subnqn;

typedef te_errno (*tapi_nvme_target_method_init)(
    struct tapi_nvme_target *tgt,
    void *opts
    );

typedef te_errno (*tapi_nvme_target_method_setup)(struct tapi_nvme_target *tgt);
typedef void (*tapi_nvme_target_method_cleanup)(struct tapi_nvme_target *tgt);
typedef void (*tapi_nvme_target_method_fini)(struct tapi_nvme_target *tgt);
typedef struct tapi_nvme_target_methods tapi_nvme_target_methods;
typedef struct tapi_nvme_target tapi_nvme_target;
typedef struct tapi_nvme_host_ctrl tapi_nvme_host_ctrl;
typedef struct tapi_nvme_connect_opts tapi_nvme_connect_opts;
typedef enum tapi_nvme_feature tapi_nvme_feature;

// enums

enum tapi_nvme_feature;
enum tapi_nvme_transport;

// structs

struct tapi_nvme_connect_opts;
struct tapi_nvme_host_ctrl;
struct tapi_nvme_target;
struct tapi_nvme_target_methods;

// global functions

const char* tapi_nvme_transport_str(tapi_nvme_transport transport);
te_errno tapi_nvme_initiator_connect_opts(tapi_nvme_host_ctrl* host_ctrl, const tapi_nvme_target* target, const tapi_nvme_connect_opts* opts);
static te_errno tapi_nvme_initiator_connect(tapi_nvme_host_ctrl* host_ctrl, const tapi_nvme_target* target);
te_errno tapi_nvme_initiator_connect_all_opts(tapi_nvme_host_ctrl* host_ctrl, const tapi_nvme_target* target, const tapi_nvme_connect_opts* opts);
static te_errno tapi_nvme_initiator_connect_all(tapi_nvme_host_ctrl* host_ctrl, const tapi_nvme_target* target);
te_errno tapi_nvme_initiator_disconnect(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_initiator_disconnect_match(rcf_rpc_server* rpcs, const char* regexp);
te_errno tapi_nvme_initiator_disconnect_all(rcf_rpc_server* rpcs);
te_errno tapi_nvme_initiator_list(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_initiator_id_ctrl(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_initiator_id_ns(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_initiator_get_id_ns(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_initiator_show_regs(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_initiator_fw_log(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_initiator_smart_log(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_initiator_error_log(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_initiator_get_feature(tapi_nvme_host_ctrl* host_ctrl, int feature);
te_errno tapi_nvme_initiator_flush(tapi_nvme_host_ctrl* host_ctrl, const char* namespace);
te_errno tapi_nvme_initiator_discover_from(tapi_nvme_host_ctrl* host_ctrl);
static void tapi_nvme_initiator_init(tapi_nvme_host_ctrl* host_ctrl);
te_errno tapi_nvme_target_init(tapi_nvme_target* target, void* opts);
te_errno tapi_nvme_target_setup(tapi_nvme_target* target);
void tapi_nvme_target_cleanup(tapi_nvme_target* target);
void tapi_nvme_target_fini(tapi_nvme_target* target);
te_errno tapi_nvme_target_format(tapi_nvme_target* target);

// macros

#define TAPI_NVME_CONNECT_OPTS_DEFAULTS
#define TAPI_NVME_HOST_CTRL_DEFAULTS
#define TAPI_NVME_TARGET_DEFAULTS
#define TAPI_NVME_TARGET_METHODS_DEFAULTS
#define TAPI_NVME_TRANSPORT_MAPPING_LIST

Detailed Documentation

API for control NVMe Over Fabrics

Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.

Typedefs

typedef const char* tapi_nvme_subnqn

NVMe Qualified Name

typedef te_errno (*tapi_nvme_target_method_init)(
    struct tapi_nvme_target *tgt,
    void *opts
    )

Method for init target

Parameters:

tgt

Target for init

opts

Options for init target

Returns:

Status code

typedef te_errno (*tapi_nvme_target_method_setup)(struct tapi_nvme_target *tgt)

Method for setup target

Parameters:

tgt

Target for setup

Returns:

Status code

typedef void (*tapi_nvme_target_method_cleanup)(struct tapi_nvme_target *tgt)

Method for cleanup target

Parameters:

tgt

Target for cleanup

Returns:

Status code

typedef void (*tapi_nvme_target_method_fini)(struct tapi_nvme_target *tgt)

Method for fini target

Parameters:

tgt

Target for setup

Returns:

Status code

typedef struct tapi_nvme_target_methods tapi_nvme_target_methods

Available methods of target

typedef struct tapi_nvme_target tapi_nvme_target

Target context

typedef struct tapi_nvme_host_ctrl tapi_nvme_host_ctrl

Initiator context

typedef enum tapi_nvme_feature tapi_nvme_feature

Supported nvme feature

Global Functions

const char* tapi_nvme_transport_str(tapi_nvme_transport transport)

Convert transport str

Parameters:

transport

NVMe transport

Returns:

transport as string

te_errno tapi_nvme_initiator_connect_opts(tapi_nvme_host_ctrl* host_ctrl, const tapi_nvme_target* target, const tapi_nvme_connect_opts* opts)

Connect initiator host to target host with additional options

Parameters:

host_ctrl

handle of host_ctrl

target

handle of target

opts

additional opts for nvme connect

Returns:

TE error code

static te_errno tapi_nvme_initiator_connect(tapi_nvme_host_ctrl* host_ctrl, const tapi_nvme_target* target)

Connect initiator host to target host.

Parameters:

host_ctrl

handle of host_ctrl

target

handle of target

Returns:

TE error code

te_errno tapi_nvme_initiator_connect_all_opts(tapi_nvme_host_ctrl* host_ctrl, const tapi_nvme_target* target, const tapi_nvme_connect_opts* opts)

Do nvme connect-all to target host with additional options

Parameters:

host_ctrl

handle of host_ctrl

target

handle of target

opts

additional opts for nvme connect

Returns:

TE error code

static te_errno tapi_nvme_initiator_connect_all(tapi_nvme_host_ctrl* host_ctrl, const tapi_nvme_target* target)

Connect initiator host to target host.

Parameters:

host_ctrl

handle of host_ctrl

target

handle of target

Returns:

TE error code

te_errno tapi_nvme_initiator_disconnect(tapi_nvme_host_ctrl* host_ctrl)

Disconnect host_ctrl form connected target.

Parameters:

host_ctrl

handle of host_ctrl

Returns:

TE error code

te_errno tapi_nvme_initiator_disconnect_match(rcf_rpc_server* rpcs, const char* regexp)

Disconnect all devices matched by regexp

Parameters:

rpcs

RPC server

regexp

Regular expression

Returns:

TE error code

te_errno tapi_nvme_initiator_disconnect_all(rcf_rpc_server* rpcs)

Disconnect from all connected NVMeoF subsystems

Parameters:

rpcs

RPC server

Returns:

TE error code

te_errno tapi_nvme_initiator_list(tapi_nvme_host_ctrl* host_ctrl)

Call ‘nvme list’ on the initiator side.

Parameters:

host_ctrl

handle of host_ctrl

Returns:

TE error code

te_errno tapi_nvme_initiator_id_ctrl(tapi_nvme_host_ctrl* host_ctrl)

Send NVMe Identify Controller

nvme id-ctrl /dev/nvme0n1

Parameters:

host_ctrl

handle of host_ctrl

Returns:

TE error code

te_errno tapi_nvme_initiator_id_ns(tapi_nvme_host_ctrl* host_ctrl)

Send NVMe Identify Namespace

nvme id-ns /dev/nvme0n1

Parameters:

host_ctrl

handle of host_ctrl

Returns:

TE error code

te_errno tapi_nvme_initiator_get_id_ns(tapi_nvme_host_ctrl* host_ctrl)

Retrieve the namespace ID of opened block device

nvme get-ns-id /dev/nvme0n1

Parameters:

host_ctrl

handle of host ctrl on initiator side

Returns:

TE error code

te_errno tapi_nvme_initiator_show_regs(tapi_nvme_host_ctrl* host_ctrl)

Reads and shows the defined NVMe controller registers

nvme show-regs /dev/nvme0n1

Parameters:

host_ctrl

handle of host ctrl on initiator side

Returns:

TE error code

te_errno tapi_nvme_initiator_fw_log(tapi_nvme_host_ctrl* host_ctrl)

Retrieve FW Log, show it

nvme fw-log /dev/nvme0n1

Parameters:

host_ctrl

handle of host ctrl on initiator side

Returns:

TE error code

te_errno tapi_nvme_initiator_smart_log(tapi_nvme_host_ctrl* host_ctrl)

Retrieve SMART Log, show it

nvme smart-log /dev/nvme0n1

Parameters:

host_ctrl

handle of host ctrl on initiator side

Returns:

TE error code

te_errno tapi_nvme_initiator_error_log(tapi_nvme_host_ctrl* host_ctrl)

Retrieve Error Log, show it

nvme error-log /dev/nvme0n1

Parameters:

host_ctrl

handle of host ctrl on initiator side

Returns:

TE error code

te_errno tapi_nvme_initiator_get_feature(tapi_nvme_host_ctrl* host_ctrl, int feature)

Get feature and show the resulting value

nvme get-feature /dev/nvme0n1

Parameters:

host_ctrl

handle of host ctrl on initiator side

Returns:

TE error code

te_errno tapi_nvme_initiator_flush(tapi_nvme_host_ctrl* host_ctrl, const char* namespace)

Submit flush command

nvme flush /dev/nvme0n1 [-n <namespace>]

Parameters:

host_ctrl

handle of host ctrl on initiator side

namespace

NULL (all) or namespace name

Returns:

TE error code

te_errno tapi_nvme_initiator_discover_from(tapi_nvme_host_ctrl* host_ctrl)

Submit nvme discover command

Parameters:

host_ctrl

handle of host ctrl on initiator side

Returns:

TE error code

te_errno tapi_nvme_target_init(tapi_nvme_target* target, void* opts)

Target init

Parameters:

target

handle of target

opts

options for init target

Returns:

TE error code

te_errno tapi_nvme_target_setup(tapi_nvme_target* target)

Prepare target for accept connection

Parameters:

target

handle of target

Returns:

TE error code

void tapi_nvme_target_cleanup(tapi_nvme_target* target)

Cleanup target

Parameters:

target

handle of target

void tapi_nvme_target_fini(tapi_nvme_target* target)

Target deinit

Parameters:

target

handle of target

Returns:

TE error code

te_errno tapi_nvme_target_format(tapi_nvme_target* target)

Format NVMe disk on target

Parameters:

target

handle of target

Returns:

TE error code

Macros

#define TAPI_NVME_HOST_CTRL_DEFAULTS

Default host_ctrl initialization

#define TAPI_NVME_TARGET_DEFAULTS

Default target initialization

#define TAPI_NVME_TARGET_METHODS_DEFAULTS

Default available methods of target

#define TAPI_NVME_TRANSPORT_MAPPING_LIST

Transport mapping list