Skip to content

Commit 0143df1

Browse files
committed
mi: use libnvme prefix for mi API
Use a different prefix for the non NVMe specification part of the library. This avoids confusion what is NVMe specific and what part of the API is from the library itself. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 0690776 commit 0143df1

16 files changed

Lines changed: 665 additions & 665 deletions

File tree

libnvme/examples/mi-conf.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static int parse_mctp(const char *devstr, unsigned int *net, uint8_t *eid)
4040
return 0;
4141
}
4242

43-
int find_port(nvme_mi_ep_t ep, uint8_t *portp, uint16_t *mtup)
43+
int find_port(libnvme_mi_ep_t ep, uint8_t *portp, uint16_t *mtup)
4444
{
4545
struct nvme_mi_read_nvm_ss_info ss_info;
4646
struct nvme_mi_read_port_info port_info;
@@ -49,15 +49,15 @@ int find_port(nvme_mi_ep_t ep, uint8_t *portp, uint16_t *mtup)
4949
int rc;
5050

5151
/* query number of ports */
52-
rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info);
52+
rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info);
5353
if (rc) {
5454
warn("Failed reading subsystem info");
5555
return -1;
5656
}
5757

5858
found = false;
5959
for (port = 0; port <= ss_info.nump; port++) {
60-
rc = nvme_mi_mi_read_mi_data_port(ep, port, &port_info);
60+
rc = libnvme_mi_mi_read_mi_data_port(ep, port, &port_info);
6161
if (rc) {
6262
warn("Failed reading port info for port %ud", port);
6363
return -1;
@@ -143,7 +143,7 @@ int main(int argc, char **argv)
143143
const char *devstr;
144144
uint8_t eid, port;
145145
unsigned int net;
146-
nvme_mi_ep_t ep;
146+
libnvme_mi_ep_t ep;
147147
DBusError berr;
148148
int rc;
149149

@@ -161,7 +161,7 @@ int main(int argc, char **argv)
161161
if (!ctx)
162162
err(EXIT_FAILURE, "can't create global context");
163163

164-
ep = nvme_mi_open_mctp(ctx, net, eid);
164+
ep = libnvme_mi_open_mctp(ctx, net, eid);
165165
if (!ep) {
166166
warnx("can't open MCTP endpoint %d:%d", net, eid);
167167
goto out_free_ctx;
@@ -182,7 +182,7 @@ int main(int argc, char **argv)
182182
goto out_close_bus;
183183
}
184184

185-
rc = nvme_mi_mi_config_get_mctp_mtu(ep, port, &cur_mtu);
185+
rc = libnvme_mi_mi_config_get_mctp_mtu(ep, port, &cur_mtu);
186186
if (rc) {
187187
cur_mtu = 0;
188188
warn("Can't query current MTU; no way to revert on failure");
@@ -193,7 +193,7 @@ int main(int argc, char **argv)
193193
goto out_close_bus;
194194
}
195195

196-
rc = nvme_mi_mi_config_set_mctp_mtu(ep, port, mtu);
196+
rc = libnvme_mi_mi_config_set_mctp_mtu(ep, port, mtu);
197197
if (rc) {
198198
warn("Can't set MCTP MTU");
199199
goto out_close_bus;
@@ -203,7 +203,7 @@ int main(int argc, char **argv)
203203
if (rc) {
204204
/* revert if we have an old setting */
205205
if (cur_mtu) {
206-
rc = nvme_mi_mi_config_set_mctp_mtu(ep, port, cur_mtu);
206+
rc = libnvme_mi_mi_config_set_mctp_mtu(ep, port, cur_mtu);
207207
if (rc)
208208
warn("Failed to restore previous MTU!");
209209
rc = -1;
@@ -217,7 +217,7 @@ int main(int argc, char **argv)
217217
dbus_connection_unref(bus);
218218
out_close_ep:
219219
dbus_error_free(&berr);
220-
nvme_mi_close(ep);
220+
libnvme_mi_close(ep);
221221
out_free_ctx:
222222
libnvme_free_global_ctx(ctx);
223223

libnvme/examples/mi-mctp-ae.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void print_byte_array(void *data, size_t len)
3838
printf("\n");
3939
}
4040

41-
static void print_event_info(struct nvme_mi_event *event)
41+
static void print_event_info(struct libnvme_mi_event *event)
4242
{
4343
printf("aeoi: %02X\n", event->aeoi);
4444
printf("aeocidi: %04X\n", event->aeocidi);
@@ -55,15 +55,15 @@ static void print_event_info(struct nvme_mi_event *event)
5555
}
5656
}
5757

58-
enum nvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_events, void *userdata)
58+
enum libnvme_mi_aem_handler_next_action aem_handler(libnvme_mi_ep_t ep, size_t num_events, void *userdata)
5959
{
6060
struct app_userdata *data = (struct app_userdata *) userdata;
6161

6262
data->count++;
6363

6464
printf("Received notification #%d with %zu events:\n", data->count, num_events);
6565
for (int i = 0; i < num_events; i++) {
66-
struct nvme_mi_event *event = nvme_mi_aem_get_next_event(ep);
66+
struct libnvme_mi_event *event = libnvme_mi_aem_get_next_event(ep);
6767

6868
if (event == NULL)
6969
printf("Unexpected NULL event\n");
@@ -80,11 +80,11 @@ enum nvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_eve
8080
int main(int argc, char **argv)
8181
{
8282
struct libnvme_global_ctx *ctx;
83-
nvme_mi_ep_t ep;
83+
libnvme_mi_ep_t ep;
8484
uint8_t eid = 0;
8585
int rc = 0, net = 0;
86-
struct nvme_mi_aem_config aem_config = {0};
87-
struct nvme_mi_aem_enabled_map enabled_map = {0};
86+
struct libnvme_mi_aem_config aem_config = {0};
87+
struct libnvme_mi_aem_enabled_map enabled_map = {0};
8888
struct app_userdata data = {0};
8989

9090
const uint8_t AEM_FD_INDEX = 0;
@@ -114,15 +114,15 @@ int main(int argc, char **argv)
114114
if (!ctx)
115115
err(EXIT_FAILURE, "can't create NVMe root");
116116

117-
ep = nvme_mi_open_mctp(ctx, net, eid);
117+
ep = libnvme_mi_open_mctp(ctx, net, eid);
118118
if (!ep)
119119
err(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid);
120120

121121
aem_config.aem_handler = aem_handler;
122122
aem_config.aemd = 1;
123123
aem_config.aerd = 100;
124124

125-
rc = nvme_mi_aem_get_enabled(ep, &enabled_map);
125+
rc = libnvme_mi_aem_get_enabled(ep, &enabled_map);
126126
if (rc)
127127
err(EXIT_FAILURE, "Can't query enabled aems:%d", rc);
128128
printf("The following events were previously enabled:\n");
@@ -131,19 +131,19 @@ int main(int argc, char **argv)
131131
printf("Event: %d\n", i);
132132
}
133133

134-
rc = nvme_mi_aem_enable(ep, &aem_config, &data);
134+
rc = libnvme_mi_aem_enable(ep, &aem_config, &data);
135135
if (rc == EOPNOTSUPP)
136136
errx(EXIT_FAILURE, "MCTP Peer-Bind is required for AEM");
137137
else if (rc)
138138
err(EXIT_FAILURE, "Can't enable aem:%d", rc);
139139

140-
rc = nvme_mi_aem_get_enabled(ep, &enabled_map);
140+
rc = libnvme_mi_aem_get_enabled(ep, &enabled_map);
141141
if (rc)
142142
err(EXIT_FAILURE, "Can't query enabled aems:%d", rc);
143143

144144
struct pollfd fds[2];
145145

146-
fds[AEM_FD_INDEX].fd = nvme_mi_aem_get_fd(ep);
146+
fds[AEM_FD_INDEX].fd = libnvme_mi_aem_get_fd(ep);
147147
if (fds[AEM_FD_INDEX].fd < 0)
148148
errx(EXIT_FAILURE, "Can't get aem fd");
149149

@@ -162,18 +162,18 @@ int main(int argc, char **argv)
162162
}
163163
//Time to do the work
164164
if (fds[AEM_FD_INDEX].revents & POLLIN) {
165-
rc = nvme_mi_aem_process(ep, &data);
165+
rc = libnvme_mi_aem_process(ep, &data);
166166
if (rc)
167167
err(EXIT_FAILURE,
168-
"nvme_mi_aem_process failed with:%d", rc);
168+
"libnvme_mi_aem_process failed with:%d", rc);
169169
}
170170
if (fds[STD_IN_FD_INDEX].revents & POLLIN)
171171
break;//we are done
172172
}
173173

174174
//Cleanup
175-
nvme_mi_aem_disable(ep);
176-
nvme_mi_close(ep);
175+
libnvme_mi_aem_disable(ep);
176+
libnvme_mi_close(ep);
177177
libnvme_free_global_ctx(ctx);
178178

179179
return rc ? EXIT_FAILURE : EXIT_SUCCESS;

libnvme/examples/mi-mctp-csi-test.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void hexdump(const unsigned char *buf, int len)
5454
fhexdump(stdout, buf, len);
5555
}
5656

57-
int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
57+
int do_get_log_page(libnvme_mi_ep_t ep, int argc, char **argv)
5858
{
5959
struct libnvme_transport_handle *hdl;
6060
enum nvme_cmd_get_log_lid lid;
@@ -83,7 +83,7 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
8383
lid = 0x1;
8484
}
8585

86-
hdl = nvme_mi_init_transport_handle(ep, ctrl_id);
86+
hdl = libnvme_mi_init_transport_handle(ep, ctrl_id);
8787
if (!hdl) {
8888
warn("can't create controller");
8989
return -1;
@@ -104,7 +104,7 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
104104
}
105105

106106
struct thread_struct {
107-
nvme_mi_ep_t ep;
107+
libnvme_mi_ep_t ep;
108108
int argc;
109109
char **argv;
110110
int rc;
@@ -126,19 +126,19 @@ int do_csi_test(struct libnvme_global_ctx *ctx, int net, __u8 eid,
126126
int argc, char **argv)
127127
{
128128
int rc = 0;
129-
nvme_mi_ep_t ep1, ep2;
129+
libnvme_mi_ep_t ep1, ep2;
130130

131-
ep1 = nvme_mi_open_mctp(ctx, net, eid);
131+
ep1 = libnvme_mi_open_mctp(ctx, net, eid);
132132
if (!ep1)
133133
errx(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid);
134-
ep2 = nvme_mi_open_mctp(ctx, net, eid);
134+
ep2 = libnvme_mi_open_mctp(ctx, net, eid);
135135
if (!ep2)
136136
errx(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid);
137137

138138
pthread_t thread;
139139

140-
nvme_mi_set_csi(ep1, 0);//Not necessary, but to be explicit
141-
nvme_mi_set_csi(ep2, 1);
140+
libnvme_mi_set_csi(ep1, 0);//Not necessary, but to be explicit
141+
libnvme_mi_set_csi(ep2, 1);
142142
struct thread_struct s;
143143

144144
s.ep = ep2;
@@ -164,8 +164,8 @@ int do_csi_test(struct libnvme_global_ctx *ctx, int net, __u8 eid,
164164

165165
printf("Second thread finished with rc=%d\n", s.rc);
166166

167-
nvme_mi_close(ep1);
168-
nvme_mi_close(ep2);
167+
libnvme_mi_close(ep1);
168+
libnvme_mi_close(ep2);
169169

170170
if (rc)
171171
return rc;

0 commit comments

Comments
 (0)