summaryrefslogtreecommitdiffstats
path: root/libnvme/nvme.i
diff options
context:
space:
mode:
Diffstat (limited to 'libnvme/nvme.i')
-rw-r--r--libnvme/nvme.i80
1 files changed, 61 insertions, 19 deletions
diff --git a/libnvme/nvme.i b/libnvme/nvme.i
index 14e2415..6f20e2c 100644
--- a/libnvme/nvme.i
+++ b/libnvme/nvme.i
@@ -21,10 +21,13 @@
%{
#include <ccan/list/list.h>
+#include <ccan/endian/endian.h>
#include "nvme/tree.h"
#include "nvme/fabrics.h"
#include "nvme/private.h"
#include "nvme/log.h"
+#include "nvme/ioctl.h"
+#include "nvme/types.h"
static int host_iter_err = 0;
static int subsys_iter_err = 0;
@@ -287,7 +290,9 @@ struct nvme_host {
char *hostnqn;
char *hostid;
char *hostsymname;
- char *dhchap_key;
+ %extend {
+ char *dhchap_key;
+ }
};
struct nvme_subsystem {
@@ -314,6 +319,7 @@ struct nvme_ctrl {
%immutable subsysnqn;
%immutable traddr;
%immutable trsvcid;
+ %immutable dhchap_host_key;
%immutable dhchap_key;
%immutable cntrltype;
%immutable dctype;
@@ -332,7 +338,10 @@ struct nvme_ctrl {
char *subsysnqn;
char *traddr;
char *trsvcid;
- char *dhchap_key;
+ %extend {
+ char *dhchap_host_key:
+ char *dhchap_key;
+ }
char *cntrltype;
char *dctype;
bool discovery_ctrl;
@@ -448,6 +457,15 @@ struct nvme_ns {
}
}
+%{
+ const char *nvme_host_dhchap_key_get(struct nvme_host *h) {
+ return nvme_host_get_dhchap_key(h);
+ }
+ void nvme_host_dhchap_key_set(struct nvme_host *h, char *key) {
+ nvme_host_set_dhchap_key(h, key);
+ }
+%};
+
%extend subsystem_iter {
struct subsystem_iter *__iter__() {
return $self;
@@ -610,25 +628,46 @@ struct nvme_ns {
}
%newobject discover;
- struct nvmf_discovery_log *discover(int max_retries = 6) {
- struct nvmf_discovery_log *logp = NULL;
+ struct nvmf_discovery_log *discover(int lsp = 0, int max_retries = 6) {
+ struct nvme_get_discovery_args args = {
+ .c = $self,
+ .args_size = sizeof(args),
+ .max_retries = max_retries,
+ .result = NULL,
+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
+ .lsp = lsp,
+ };
+ struct nvmf_discovery_log *logp = nvmf_get_discovery_wargs(&args);
+ if (logp == NULL)
+ discover_err = 1;
+ return logp;
+ }
+
+ %feature("autodoc", "@return: List of supported log pages") supported_log_pages;
+ PyObject * supported_log_pages(bool rae=true) {
+ struct nvme_supported_log_pages log;
+ PyObject *obj = NULL;
int ret = 0;
- ret = nvmf_get_discovery_log($self, &logp, max_retries);
+
+ ret = nvme_get_log_supported_log_pages(nvme_ctrl_get_fd($self), rae, &log);
if (ret < 0) {
- discover_err = 1;
- return NULL;
+ Py_RETURN_NONE;
}
- return logp;
+
+ obj = PyList_New(NVME_LOG_SUPPORTED_LOG_PAGES_MAX);
+ if (!obj)
+ Py_RETURN_NONE;
+
+ for (int i = 0; i < NVME_LOG_SUPPORTED_LOG_PAGES_MAX; i++)
+ PyList_SetItem(obj, i, PyLong_FromLong(le32_to_cpu(log.lid_support[i]))); /* steals ref. */
+
+ return obj;
}
- char *__str__() {
- static char tmp[1024];
- if ($self->address)
- sprintf(tmp, "nvme_ctrl(transport=%s,%s)", $self->transport,
- $self->address);
- else
- sprintf(tmp, "nvme_ctrl(transport=%s)", $self->transport);
- return tmp;
+ PyObject *__str__() {
+ return $self->address ?
+ PyUnicode_FromFormat("nvme_ctrl(transport=%s,%s)", $self->transport, $self->address) :
+ PyUnicode_FromFormat("nvme_ctrl(transport=%s)", $self->transport);
}
struct ctrl_iter __iter__() {
struct ctrl_iter ret = { .subsystem = nvme_ctrl_get_subsystem($self),
@@ -656,6 +695,12 @@ struct nvme_ns {
const char *nvme_ctrl_state_get(struct nvme_ctrl *c) {
return nvme_ctrl_get_state(c);
}
+ const char *nvme_ctrl_dhchap_key_get(struct nvme_ctrl *c) {
+ return nvme_ctrl_get_dhchap_key(c);
+ }
+ const char *nvme_ctrl_dhchap_host_key_get(struct nvme_ctrl *c) {
+ return nvme_ctrl_get_dhchap_host_key(c);
+ }
%};
%extend nvme_ns {
@@ -689,9 +734,6 @@ struct nvme_ns {
// We want to swig all the #define and enum from types.h, but none of the structs.
-%{
-#include "nvme/types.h"
-%}
#define __attribute__(x)
%rename($ignore, %$isclass) ""; // ignore all classes/structs
%rename($ignore, %$isfunction) ""; // ignore all functions