Skip to content

Commit da2f1b1

Browse files
committed
libnvme: rename nvmf_ API prefix to libnvmf_
Use the libnvme_ prefix for the library fabrics API. This makes this part of the library consistent with the other parts. The spec API uses nvme_, the rest libnvme_. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 3b3e691 commit da2f1b1

28 files changed

Lines changed: 432 additions & 432 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ ABI-stable opaque structs. Two sets of accessors are maintained:
309309
| Set | Input header | Generated files |
310310
|-----|-------------|-----------------|
311311
| Common NVMe | `libnvme/src/nvme/private.h` | `src/nvme/accessors.{h,c}`, `src/accessors.ld` |
312-
| NVMe-oF | `libnvme/src/nvme/private-fabrics.h` | `src/nvme/nvmf-accessors.{h,c}`, `src/nvmf-accessors.ld` |
312+
| NVMe-oF | `libnvme/src/nvme/private-fabrics.h` | `src/nvme/accessors-fabrics.{h,c}`, `src/accessors-fabrics.ld` |
313313

314314
The generated `.h` and `.c` files are committed to the source tree and are
315315
**not** regenerated during a normal build. To regenerate after modifying a

fabrics.c

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static void save_discovery_log(char *raw, struct nvmf_discovery_log *log)
169169
close(fd);
170170
}
171171

172-
static int setup_common_context(struct nvmf_context *fctx,
172+
static int setup_common_context(struct libnvmf_context *fctx,
173173
struct nvmf_args *fa);
174174

175175
struct cb_fabrics_data {
@@ -181,18 +181,18 @@ struct cb_fabrics_data {
181181
FILE *f;
182182
};
183183

184-
static bool cb_decide_retry(struct nvmf_context *fctx, int err,
184+
static bool cb_decide_retry(struct libnvmf_context *fctx, int err,
185185
void *user_data)
186186
{
187187
if (err == -EAGAIN || (err == -EINTR && !nvme_sigint_received)) {
188-
print_debug("nvmf_add_ctrl returned '%s'\n", libnvme_strerror(-err));
188+
print_debug("libnvmf_add_ctrl returned '%s'\n", libnvme_strerror(-err));
189189
return true;
190190
}
191191

192192
return false;
193193
}
194194

195-
static void cb_connected(struct nvmf_context *fctx,
195+
static void cb_connected(struct libnvmf_context *fctx,
196196
struct libnvme_ctrl *c, void *user_data)
197197
{
198198
struct cb_fabrics_data *cfd = user_data;
@@ -221,7 +221,7 @@ static void cb_connected(struct nvmf_context *fctx,
221221
#endif
222222
}
223223

224-
static void cb_already_connected(struct nvmf_context *fctx,
224+
static void cb_already_connected(struct libnvmf_context *fctx,
225225
struct libnvme_host *host, const char *subsysnqn,
226226
const char *transport, const char *traddr,
227227
const char *trsvcid, void *user_data)
@@ -234,7 +234,7 @@ static void cb_already_connected(struct nvmf_context *fctx,
234234
transport, traddr, trsvcid);
235235
}
236236

237-
static void cb_discovery_log(struct nvmf_context *fctx,
237+
static void cb_discovery_log(struct libnvmf_context *fctx,
238238
bool connect, struct nvmf_discovery_log *log,
239239
uint64_t numrec, void *user_data)
240240
{
@@ -246,7 +246,7 @@ static void cb_discovery_log(struct nvmf_context *fctx,
246246
nvme_show_discovery_log(log, numrec, cfd->flags);
247247
}
248248

249-
static int cb_parser_init(struct nvmf_context *dctx, void *user_data)
249+
static int cb_parser_init(struct libnvmf_context *dctx, void *user_data)
250250
{
251251
struct cb_fabrics_data *cfd = user_data;
252252

@@ -265,15 +265,15 @@ static int cb_parser_init(struct nvmf_context *dctx, void *user_data)
265265
return 0;
266266
}
267267

268-
static void cb_parser_cleanup(struct nvmf_context *fctx, void *user_data)
268+
static void cb_parser_cleanup(struct libnvmf_context *fctx, void *user_data)
269269
{
270270
struct cb_fabrics_data *cfd = user_data;
271271

272272
free(cfd->argv);
273273
fclose(cfd->f);
274274
}
275275

276-
static int cb_parser_next_line(struct nvmf_context *fctx, void *user_data)
276+
static int cb_parser_next_line(struct libnvmf_context *fctx, void *user_data)
277277
{
278278
struct cb_fabrics_data *cfd = user_data;
279279
struct libnvme_fabrics_config cfg;
@@ -308,37 +308,37 @@ static int cb_parser_next_line(struct nvmf_context *fctx, void *user_data)
308308
goto next;
309309

310310
if (!fa.trsvcid)
311-
fa.trsvcid = nvmf_get_default_trsvcid(fa.transport, true);
311+
fa.trsvcid = libnvmf_get_default_trsvcid(fa.transport, true);
312312

313313
ret = setup_common_context(fctx, &fa);
314314
if (ret)
315315
return ret;
316316

317-
ret = nvmf_context_set_fabrics_config(fctx, &cfg);
317+
ret = libnvmf_context_set_fabrics_config(fctx, &cfg);
318318
if (ret)
319319
return ret;
320320

321321
return 0;
322322
}
323323

324-
static int setup_common_context(struct nvmf_context *fctx,
324+
static int setup_common_context(struct libnvmf_context *fctx,
325325
struct nvmf_args *fa)
326326
{
327327
int err;
328328

329-
err = nvmf_context_set_connection(fctx,
329+
err = libnvmf_context_set_connection(fctx,
330330
fa->subsysnqn, fa->transport,
331331
fa->traddr, fa->trsvcid,
332332
fa->host_traddr, fa->host_iface);
333333
if (err)
334334
return err;
335335

336-
err = nvmf_context_set_hostnqn(fctx,
336+
err = libnvmf_context_set_hostnqn(fctx,
337337
fa->hostnqn, fa->hostid);
338338
if (err)
339339
return err;
340340

341-
err = nvmf_context_set_crypto(fctx,
341+
err = libnvmf_context_set_crypto(fctx,
342342
fa->hostkey, fa->ctrlkey,
343343
fa->keyring, fa->tls_key,
344344
fa->tls_key_identity);
@@ -351,36 +351,36 @@ static int setup_common_context(struct nvmf_context *fctx,
351351
static int create_common_context(struct libnvme_global_ctx *ctx,
352352
bool persistent, struct nvmf_args *fa,
353353
struct libnvme_fabrics_config *cfg,
354-
void *user_data, struct nvmf_context **fctxp)
354+
void *user_data, struct libnvmf_context **fctxp)
355355
{
356-
struct nvmf_context *fctx;
356+
struct libnvmf_context *fctx;
357357
int err;
358358

359-
err = nvmf_context_create(ctx, cb_decide_retry, cb_connected,
359+
err = libnvmf_context_create(ctx, cb_decide_retry, cb_connected,
360360
cb_already_connected, user_data, &fctx);
361361
if (err)
362362
return err;
363363

364-
err = nvmf_context_set_connection(fctx, fa->subsysnqn,
364+
err = libnvmf_context_set_connection(fctx, fa->subsysnqn,
365365
fa->transport, fa->traddr, fa->trsvcid,
366366
fa->host_traddr, fa->host_iface);
367367
if (err)
368368
goto err;
369369

370-
err = nvmf_context_set_hostnqn(fctx, fa->hostnqn, fa->hostid);
370+
err = libnvmf_context_set_hostnqn(fctx, fa->hostnqn, fa->hostid);
371371
if (err)
372372
goto err;
373373

374-
err = nvmf_context_set_fabrics_config(fctx, cfg);
374+
err = libnvmf_context_set_fabrics_config(fctx, cfg);
375375
if (err)
376376
goto err;
377377

378-
err = nvmf_context_set_crypto(fctx, fa->hostkey, fa->ctrlkey,
378+
err = libnvmf_context_set_crypto(fctx, fa->hostkey, fa->ctrlkey,
379379
fa->keyring, fa->tls_key, fa->tls_key_identity);
380380
if (err)
381381
goto err;
382382

383-
err = nvmf_context_set_persistent(fctx, persistent);
383+
err = libnvmf_context_set_persistent(fctx, persistent);
384384
if (err)
385385
goto err;
386386

@@ -389,43 +389,43 @@ static int create_common_context(struct libnvme_global_ctx *ctx,
389389
return 0;
390390

391391
err:
392-
nvmf_context_free(fctx);
392+
libnvmf_context_free(fctx);
393393
return err;
394394
}
395395

396396
static int create_discovery_context(struct libnvme_global_ctx *ctx,
397397
bool persistent, const char *device,
398398
struct nvmf_args *fa,
399399
struct libnvme_fabrics_config *cfg,
400-
void *user_data, struct nvmf_context **fctxp)
400+
void *user_data, struct libnvmf_context **fctxp)
401401
{
402-
struct nvmf_context *fctx;
402+
struct libnvmf_context *fctx;
403403
int err;
404404

405405
err = create_common_context(ctx, persistent, fa, cfg, user_data,
406406
&fctx);
407407
if (err)
408408
return err;
409409

410-
err = nvmf_context_set_discovery_cbs(fctx, cb_discovery_log,
410+
err = libnvmf_context_set_discovery_cbs(fctx, cb_discovery_log,
411411
cb_parser_init, cb_parser_cleanup, cb_parser_next_line);
412412
if (err)
413413
goto err;
414414

415-
err = nvmf_context_set_discovery_defaults(fctx, MAX_DISC_RETRIES,
415+
err = libnvmf_context_set_discovery_defaults(fctx, MAX_DISC_RETRIES,
416416
NVMF_DEF_DISC_TMO);
417417
if (err)
418418
goto err;
419419

420-
err = nvmf_context_set_device(fctx, device);
420+
err = libnvmf_context_set_device(fctx, device);
421421
if (err)
422422
goto err;
423423

424424
*fctxp = fctx;
425425
return 0;
426426

427427
err:
428-
nvmf_context_free(fctx);
428+
libnvmf_context_free(fctx);
429429
return err;
430430
}
431431

@@ -480,7 +480,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
480480
char *context = NULL;
481481
nvme_print_flags_t flags;
482482
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;
483-
_cleanup_nvmf_context_ struct nvmf_context *fctx = NULL;
483+
_cleanup_nvmf_context_ struct libnvmf_context *fctx = NULL;
484484
int ret;
485485
struct libnvme_fabrics_config cfg;
486486
struct nvmf_args fa = { .subsysnqn = NVME_DISC_SUBSYS_NAME };
@@ -503,7 +503,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
503503
OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"),
504504
OPT_STRING("context", 0, "STR", &context, nvmf_context));
505505

506-
nvmf_default_config(&cfg);
506+
libnvmf_default_config(&cfg);
507507

508508
ret = argconfig_parse(argc, argv, desc, opts);
509509
if (ret)
@@ -561,22 +561,22 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
561561

562562
if (!device && !fa.transport && !fa.traddr) {
563563
if (!nonbft)
564-
ret = nvmf_discovery_nbft(ctx, fctx,
564+
ret = libnvmf_discovery_nbft(ctx, fctx,
565565
connect, nbft_path);
566566
if (nbft)
567567
goto out_free;
568568

569569
if (json_config)
570-
ret = nvmf_discovery_config_json(ctx, fctx,
570+
ret = libnvmf_discovery_config_json(ctx, fctx,
571571
connect, force);
572572
if (ret || access(PATH_NVMF_DISC, F_OK))
573573
goto out_free;
574574

575-
ret = nvmf_discovery_config_file(ctx, fctx, connect, force);
575+
ret = libnvmf_discovery_config_file(ctx, fctx, connect, force);
576576
goto out_free;
577577
}
578578

579-
ret = nvmf_discovery(ctx, fctx, connect, force);
579+
ret = libnvmf_discovery(ctx, fctx, connect, force);
580580

581581
out_free:
582582
if (dump_config)
@@ -592,7 +592,7 @@ int fabrics_connect(const char *desc, int argc, char **argv)
592592
char *config_file = NULL;
593593
char *context = NULL;
594594
_cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL;
595-
_cleanup_nvmf_context_ struct nvmf_context *fctx = NULL;
595+
_cleanup_nvmf_context_ struct libnvmf_context *fctx = NULL;
596596
_cleanup_nvme_ctrl_ libnvme_ctrl_t c = NULL;
597597
int ret;
598598
nvme_print_flags_t flags;
@@ -604,7 +604,7 @@ int fabrics_connect(const char *desc, int argc, char **argv)
604604
OPT_FLAG("dump-config", 'O', &dump_config, "Dump JSON configuration to stdout"),
605605
OPT_STRING("context", 0, "STR", &context, nvmf_context));
606606

607-
nvmf_default_config(&cfg);
607+
libnvmf_default_config(&cfg);
608608

609609
ret = argconfig_parse(argc, argv, desc, opts);
610610
if (ret)
@@ -674,9 +674,9 @@ int fabrics_connect(const char *desc, int argc, char **argv)
674674
return ret;
675675

676676
if (config_file)
677-
return nvmf_connect_config_json(ctx, fctx);
677+
return libnvmf_connect_config_json(ctx, fctx);
678678

679-
ret = nvmf_connect(ctx, fctx);
679+
ret = libnvmf_connect(ctx, fctx);
680680
if (ret) {
681681
fprintf(stderr, "failed to connect: %s\n",
682682
libnvme_strerror(-ret));
@@ -900,7 +900,7 @@ int fabrics_config(const char *desc, int argc, char **argv)
900900
OPT_FLAG("dump", 'O', &dump_config, "Dump JSON configuration to stdout"),
901901
OPT_FLAG("update", 'U', &update_config, "Update JSON configuration file"));
902902

903-
nvmf_default_config(&cfg);
903+
libnvmf_default_config(&cfg);
904904

905905
ret = argconfig_parse(argc, argv, desc, opts);
906906
if (ret)
@@ -931,7 +931,7 @@ int fabrics_config(const char *desc, int argc, char **argv)
931931
}
932932

933933
if (modify_config) {
934-
_cleanup_nvmf_context_ struct nvmf_context *fctx = NULL;
934+
_cleanup_nvmf_context_ struct libnvmf_context *fctx = NULL;
935935

936936
if (!fa.subsysnqn) {
937937
fprintf(stderr,
@@ -950,7 +950,7 @@ int fabrics_config(const char *desc, int argc, char **argv)
950950
if (ret)
951951
return ret;
952952

953-
ret = nvmf_config_modify(ctx, fctx);
953+
ret = libnvmf_config_modify(ctx, fctx);
954954
if (ret) {
955955
fprintf(stderr, "failed to update config\n");
956956
return ret;
@@ -982,7 +982,7 @@ static int dim_operation(libnvme_ctrl_t c, enum nvmf_dim_tas tas, const char *na
982982
__u32 result;
983983

984984
t = (tas > NVMF_DIM_TAS_DEREGISTER || !task[tas]) ? "reserved" : task[tas];
985-
status = nvmf_register_ctrl(c, tas, &result);
985+
status = libnvmf_register_ctrl(c, tas, &result);
986986
if (status == NVME_SC_SUCCESS) {
987987
printf("%s DIM %s command success\n", name, t);
988988
} else if (status < NVME_SC_SUCCESS) {

libnvme/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ or PCIe-only) builds can exclude all fabrics code entirely.
201201
| Meson target | Input header | Generated files |
202202
|---|---|---|
203203
| `update-common-accessors` | `src/nvme/private.h` | `src/nvme/accessors.{h,c}`, `src/accessors.ld` |
204-
| `update-fabrics-accessors` | `src/nvme/private-fabrics.h` | `src/nvme/nvmf-accessors.{h,c}`, `src/nvmf-accessors.ld` |
204+
| `update-fabrics-accessors` | `src/nvme/private-fabrics.h` | `src/nvme/accessors-fabrics.{h,c}`, `src/accessors-fabrics.ld` |
205205

206206
### When to regenerate
207207

@@ -228,13 +228,13 @@ changes. Commit the updated files afterward:
228228

229229
```bash
230230
git add libnvme/src/nvme/accessors.h libnvme/src/nvme/accessors.c
231-
git add libnvme/src/nvme/nvmf-accessors.h libnvme/src/nvme/nvmf-accessors.c
231+
git add libnvme/src/nvme/accessors-fabrics.h libnvme/src/nvme/accessors-fabrics.c
232232
git commit -m "libnvme: regenerate accessors following <struct> changes"
233233
```
234234

235235
### Maintaining the .ld version-script files
236236

237-
The `.ld` files (`src/accessors.ld` and `src/nvmf-accessors.ld`) are GNU
237+
The `.ld` files (`src/accessors.ld` and `src/accessors-fabrics.ld`) are GNU
238238
linker version scripts that control which accessor symbols are exported from
239239
the shared library and under which ABI version label they were introduced
240240
(e.g. `LIBNVME_ACCESSORS_3`, `LIBNVMF_ACCESSORS_3`).

libnvme/examples/discover-loop.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ int main()
5757
libnvme_ctrl_t c;
5858
int ret;
5959
struct libnvme_fabrics_config cfg;
60-
struct nvmf_discovery_args *args;
60+
struct libnvmf_discovery_args *args;
6161

62-
nvmf_default_config(&cfg);
62+
libnvmf_default_config(&cfg);
6363

6464
ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL);
6565
if (!ctx)
@@ -81,17 +81,17 @@ int main()
8181
fprintf(stderr, "Failed to allocate memory\n");
8282
return 1;
8383
}
84-
ret = nvmf_add_ctrl(h, c, &cfg);
84+
ret = libnvmf_add_ctrl(h, c, &cfg);
8585
if (ret) {
8686
fprintf(stderr, "no controller found\n");
8787
return 1;
8888
}
8989

90-
ret = nvmf_discovery_args_create(&args);
90+
ret = libnvmf_discovery_args_create(&args);
9191
if (!ret) {
92-
nvmf_discovery_args_set_max_retries(args, 4);
93-
ret = nvmf_get_discovery_log(c, args, &log);
94-
nvmf_discovery_args_free(args);
92+
libnvmf_discovery_args_set_max_retries(args, 4);
93+
ret = libnvmf_get_discovery_log(c, args, &log);
94+
libnvmf_discovery_args_free(args);
9595
}
9696

9797
libnvme_disconnect_ctrl(c);

0 commit comments

Comments
 (0)