nvme_rdma: Add source addr info to RPC
Change-Id: Id6b5aee4b36d828a0f9e5ddc85293a15342d2aae Signed-off-by: Seth Howell <seth.howell@intel.com> Reviewed-on: https://review.gerrithub.io/436220 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
b1ecb314b7
commit
088379cf74
@ -28,6 +28,9 @@ arg refers to a Discovery Controller or not.
|
||||
Added an API function `spdk_nvme_host_id_parse` and corresponding object `spdk_nvme_host_id`
|
||||
for parsing host address and host service ID arguments on a per connection basis.
|
||||
|
||||
The RPC `construct_nvme_bdev` now allows a user to specify a source address and service id for the host to
|
||||
use when connecting to the controller backing the NVMe bdev.
|
||||
|
||||
### NVMe-oF Target
|
||||
|
||||
The `spdk_nvmf_tgt_opts` struct has been deprecated in favor of `spdk_nvmf_transport_opts`.
|
||||
|
@ -1036,6 +1036,8 @@ adrfam | Optional | string | NVMe-oF target adrfam: ipv4,
|
||||
trsvcid | Optional | string | NVMe-oF target trsvcid: port number
|
||||
subnqn | Optional | string | NVMe-oF target subnqn
|
||||
hostnqn | Optional | string | NVMe-oF target hostnqn
|
||||
hostaddr | Optional | string | NVMe-oF host address: ip address
|
||||
hostsvcid | Optional | string | NVMe-oF host trsvcid: port number
|
||||
|
||||
### Example
|
||||
|
||||
|
@ -1192,6 +1192,7 @@ spdk_bdev_nvme_set_hotplug(bool enabled, uint64_t period_us, spdk_msg_fn cb, voi
|
||||
|
||||
int
|
||||
spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
|
||||
struct spdk_nvme_host_id *hostid,
|
||||
const char *base_name,
|
||||
const char **names, size_t *count,
|
||||
const char *hostnqn)
|
||||
@ -1219,6 +1220,14 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
|
||||
snprintf(opts.hostnqn, sizeof(opts.hostnqn), "%s", hostnqn);
|
||||
}
|
||||
|
||||
if (hostid->hostaddr[0] != '\0') {
|
||||
snprintf(opts.src_addr, sizeof(opts.src_addr), "%s", hostid->hostaddr);
|
||||
}
|
||||
|
||||
if (hostid->hostsvcid[0] != '\0') {
|
||||
snprintf(opts.src_svcid, sizeof(opts.src_svcid), "%s", hostid->hostsvcid);
|
||||
}
|
||||
|
||||
ctrlr = spdk_nvme_connect(trid, &opts, sizeof(opts));
|
||||
if (!ctrlr) {
|
||||
SPDK_ERRLOG("Failed to create new device\n");
|
||||
|
@ -96,6 +96,7 @@ int spdk_bdev_nvme_set_opts(const struct spdk_bdev_nvme_opts *opts);
|
||||
int spdk_bdev_nvme_set_hotplug(bool enabled, uint64_t period_us, spdk_msg_fn cb, void *cb_ctx);
|
||||
|
||||
int spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
|
||||
struct spdk_nvme_host_id *hostid,
|
||||
const char *base_name,
|
||||
const char **names, size_t *count,
|
||||
const char *hostnqn);
|
||||
|
@ -165,6 +165,8 @@ struct rpc_construct_nvme {
|
||||
char *trsvcid;
|
||||
char *subnqn;
|
||||
char *hostnqn;
|
||||
char *hostaddr;
|
||||
char *hostsvcid;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -177,6 +179,8 @@ free_rpc_construct_nvme(struct rpc_construct_nvme *req)
|
||||
free(req->trsvcid);
|
||||
free(req->subnqn);
|
||||
free(req->hostnqn);
|
||||
free(req->hostaddr);
|
||||
free(req->hostsvcid);
|
||||
}
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_construct_nvme_decoders[] = {
|
||||
@ -187,7 +191,10 @@ static const struct spdk_json_object_decoder rpc_construct_nvme_decoders[] = {
|
||||
{"adrfam", offsetof(struct rpc_construct_nvme, adrfam), spdk_json_decode_string, true},
|
||||
{"trsvcid", offsetof(struct rpc_construct_nvme, trsvcid), spdk_json_decode_string, true},
|
||||
{"subnqn", offsetof(struct rpc_construct_nvme, subnqn), spdk_json_decode_string, true},
|
||||
{"hostnqn", offsetof(struct rpc_construct_nvme, hostnqn), spdk_json_decode_string, true}
|
||||
{"hostnqn", offsetof(struct rpc_construct_nvme, hostnqn), spdk_json_decode_string, true},
|
||||
{"hostaddr", offsetof(struct rpc_construct_nvme, hostaddr), spdk_json_decode_string, true},
|
||||
{"hostsvcid", offsetof(struct rpc_construct_nvme, hostsvcid), spdk_json_decode_string, true}
|
||||
|
||||
};
|
||||
|
||||
#define NVME_MAX_BDEVS_PER_RPC 128
|
||||
@ -199,6 +206,7 @@ spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
|
||||
struct rpc_construct_nvme req = {};
|
||||
struct spdk_json_write_ctx *w;
|
||||
struct spdk_nvme_transport_id trid = {};
|
||||
struct spdk_nvme_host_id hostid = {};
|
||||
const char *names[NVME_MAX_BDEVS_PER_RPC];
|
||||
size_t count;
|
||||
size_t i;
|
||||
@ -240,8 +248,16 @@ spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
|
||||
snprintf(trid.subnqn, sizeof(trid.subnqn), "%s", req.subnqn);
|
||||
}
|
||||
|
||||
if (req.hostaddr) {
|
||||
snprintf(hostid.hostaddr, sizeof(hostid.hostaddr), "%s", req.hostaddr);
|
||||
}
|
||||
|
||||
if (req.hostsvcid) {
|
||||
snprintf(hostid.hostsvcid, sizeof(hostid.hostsvcid), "%s", req.hostsvcid);
|
||||
}
|
||||
|
||||
count = NVME_MAX_BDEVS_PER_RPC;
|
||||
if (spdk_bdev_nvme_create(&trid, req.name, names, &count, req.hostnqn)) {
|
||||
if (spdk_bdev_nvme_create(&trid, &hostid, req.name, names, &count, req.hostnqn)) {
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,9 @@ if __name__ == "__main__":
|
||||
traddr=args.traddr,
|
||||
adrfam=args.adrfam,
|
||||
trsvcid=args.trsvcid,
|
||||
subnqn=args.subnqn))
|
||||
subnqn=args.subnqn,
|
||||
hostaddr=args.hostaddr,
|
||||
hostsvcid=args.hostsvcid))
|
||||
|
||||
p = subparsers.add_parser('construct_nvme_bdev',
|
||||
help='Add bdevs with nvme backend')
|
||||
@ -265,6 +267,10 @@ if __name__ == "__main__":
|
||||
p.add_argument('-s', '--trsvcid',
|
||||
help='NVMe-oF target trsvcid: e.g., a port number')
|
||||
p.add_argument('-n', '--subnqn', help='NVMe-oF target subnqn')
|
||||
p.add_argument('-i', '--hostaddr',
|
||||
help='NVMe-oF host address: e.g., an ip address')
|
||||
p.add_argument('-c', '--hostsvcid',
|
||||
help='NVMe-oF host svcid: e.g., a port number')
|
||||
p.set_defaults(func=construct_nvme_bdev)
|
||||
|
||||
def get_nvme_controllers(args):
|
||||
|
@ -215,7 +215,7 @@ def set_bdev_nvme_hotplug(client, enable, period_us=None):
|
||||
return client.call('set_bdev_nvme_hotplug', params)
|
||||
|
||||
|
||||
def construct_nvme_bdev(client, name, trtype, traddr, adrfam=None, trsvcid=None, subnqn=None):
|
||||
def construct_nvme_bdev(client, name, trtype, traddr, adrfam=None, trsvcid=None, subnqn=None, hostaddr=None, hostsvcid=None):
|
||||
"""Construct NVMe namespace block devices.
|
||||
|
||||
Args:
|
||||
@ -225,6 +225,8 @@ def construct_nvme_bdev(client, name, trtype, traddr, adrfam=None, trsvcid=None,
|
||||
adrfam: address family ("IPv4", "IPv6", "IB", or "FC") (optional for PCIe)
|
||||
trsvcid: transport service ID (port number for IP-based addresses; optional for PCIe)
|
||||
subnqn: subsystem NQN to connect to (optional)
|
||||
hostaddr: host transport address (IP address for IP-based transports, NULL for PCIe or FC; optional)
|
||||
hostsvcid: host transport service ID (port number for IP-based transports, NULL for PCIe or FC; optional)
|
||||
|
||||
Returns:
|
||||
Names of created block devices.
|
||||
@ -233,6 +235,12 @@ def construct_nvme_bdev(client, name, trtype, traddr, adrfam=None, trsvcid=None,
|
||||
'trtype': trtype,
|
||||
'traddr': traddr}
|
||||
|
||||
if hostaddr:
|
||||
params['hostaddr'] = hostaddr
|
||||
|
||||
if hostsvcid:
|
||||
params['hostsvcid'] = hostsvcid
|
||||
|
||||
if adrfam:
|
||||
params['adrfam'] = adrfam
|
||||
|
||||
|
@ -55,7 +55,7 @@ $rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1
|
||||
if [ $RUN_NIGHTLY -eq 1 ]; then
|
||||
# Test fio_plugin as host with nvme lvol backend
|
||||
bdfs=$(iter_pci_class_code 01 08 02)
|
||||
$rpc_py construct_nvme_bdev -b Nvme0 -t PCIe -a $(echo $bdfs | awk '{ print $1 }')
|
||||
$rpc_py construct_nvme_bdev -b Nvme0 -t PCIe -a $(echo $bdfs | awk '{ print $1 }') -i $NVMF_FIRST_TARGET_IP
|
||||
ls_guid=$($rpc_py construct_lvol_store Nvme0n1 lvs_0)
|
||||
get_lvs_free_mb $ls_guid
|
||||
lb_guid=$($rpc_py construct_lvol_bdev -u $ls_guid lbd_0 $free_mb)
|
||||
|
Loading…
Reference in New Issue
Block a user