Skip to content

Commit fcfc388

Browse files
authored
Merge pull request #248 from igaw/tp8010-support-refactored
TP8010 support refactored
2 parents 9e03cd0 + ad69eca commit fcfc388

14 files changed

Lines changed: 1086 additions & 36 deletions

File tree

doc/config-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"description": "NVMe host ID",
2626
"type": "string"
2727
},
28+
"hostsymname": {
29+
"description": "NVMe host symbolic name",
30+
"type": "string"
31+
},
2832
"required": [ "hostnqn" ],
2933
"subsystems": {
3034
"description": "Array of NVMe subsystem properties",

libnvme/nvme.i

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* Authors: Hannes Reinecke <[email protected]>
77
*/
88

9-
%module nvme
9+
%module(docstring="Python bindings for libnvme") nvme
10+
%feature("autodoc", "1");
1011

1112
%include "exception.i"
1213

@@ -280,8 +281,10 @@ struct nvme_root {
280281
struct nvme_host {
281282
%immutable hostnqn;
282283
%immutable hostid;
284+
%immutable hostsymname;
283285
char *hostnqn;
284286
char *hostid;
287+
char *hostsymname;
285288
char *dhchap_key;
286289
};
287290

@@ -373,6 +376,9 @@ struct nvme_ns {
373376
void update_config() {
374377
nvme_update_config($self);
375378
}
379+
void dump_config() {
380+
nvme_dump_config($self);
381+
}
376382
}
377383

378384
%extend host_iter {
@@ -393,14 +399,28 @@ struct nvme_ns {
393399

394400
%extend nvme_host {
395401
nvme_host(struct nvme_root *r, const char *hostnqn = NULL,
396-
const char *hostid = NULL) {
397-
if (!hostnqn)
398-
return nvme_default_host(r);
399-
return nvme_lookup_host(r, hostnqn, hostid);
402+
const char *hostid = NULL, const char *hostsymname = NULL) {
403+
404+
nvme_host_t h = hostnqn ? nvme_lookup_host(r, hostnqn, hostid) : nvme_default_host(r);
405+
if (hostsymname)
406+
nvme_host_set_hostsymname(h, hostsymname);
407+
return h;
400408
}
401409
~nvme_host() {
402410
nvme_free_host($self);
403411
}
412+
%define SET_SYMNAME_DOCSTRING
413+
"@brief Set or Clear Host's Symbolic Name
414+
415+
@param hostsymname: A symbolic name, or None to clear the symbolic name.
416+
@type hostsymname: str|None
417+
418+
@return: None"
419+
%enddef
420+
%feature("autodoc", SET_SYMNAME_DOCSTRING) set_symname;
421+
void set_symname(const char *hostsymname) {
422+
nvme_host_set_hostsymname($self, hostsymname);
423+
}
404424
char *__str__() {
405425
static char tmp[2048];
406426

@@ -555,6 +575,29 @@ struct nvme_ns {
555575
nvme_disconnect_ctrl($self);
556576
}
557577

578+
%feature("autodoc", "@return: True if controller supports explicit registration. False otherwise.") is_registration_supported;
579+
bool is_registration_supported() {
580+
return nvmf_is_registration_supported($self);
581+
}
582+
583+
%feature("autodoc", "@return None on success or Error string on error.") registration_ctlr;
584+
PyObject *registration_ctlr(enum nvmf_dim_tas tas) {
585+
__u32 result;
586+
int status;
587+
588+
status = nvmf_register_ctrl($self, NVMF_DIM_TAS_REGISTER, &result);
589+
if (status != NVME_SC_SUCCESS) {
590+
/* On error, return an error message */
591+
if (status < 0)
592+
return PyUnicode_FromFormat("Status:0x%04x - %s", status, nvme_status_to_string(status, false));
593+
else
594+
return PyUnicode_FromFormat("Result:0x%04x, Status:0x%04x - %s", result, status, nvme_status_to_string(status, false));
595+
}
596+
597+
/* On success, return None */
598+
Py_RETURN_NONE;
599+
}
600+
558601
%newobject discover;
559602
struct nvmf_discovery_log *discover(int max_retries = 6) {
560603
struct nvmf_discovery_log *logp = NULL;

src/libnvme.map

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ LIBNVME_1_0 {
4242
nvme_ctrls_filter;
4343
nvme_default_host;
4444
nvme_dev_self_test;
45+
nvme_dim_send;
4546
nvme_directive_recv;
4647
nvme_directive_recv_identify_parameters;
4748
nvme_directive_recv_stream_allocate;
@@ -144,8 +145,10 @@ LIBNVME_1_0 {
144145
nvme_host_get_dhchap_key;
145146
nvme_host_get_hostid;
146147
nvme_host_get_hostnqn;
148+
nvme_host_get_hostsymname;
147149
nvme_host_get_root;
148150
nvme_host_set_dhchap_key;
151+
nvme_host_set_hostsymname;
149152
nvme_identify;
150153
nvme_identify_active_ns_list;
151154
nvme_identify_allocated_ns;
@@ -322,8 +325,10 @@ LIBNVME_1_0 {
322325
nvmf_hostid_from_file;
323326
nvmf_hostnqn_from_file;
324327
nvmf_hostnqn_generate;
328+
nvmf_is_registration_supported;
325329
nvmf_prtype_str;
326330
nvmf_qptype_str;
331+
nvmf_register_ctrl;
327332
nvmf_sectype_str;
328333
nvmf_subtype_str;
329334
nvmf_treq_str;

0 commit comments

Comments
 (0)