Lines Matching refs:ctx
41 struct mdns_discovery_ctx *ctx;
64 create_mdns_discovery_entry_ctx(struct mdns_discovery_ctx *ctx, struct spdk_nvme_transport_id *trid)
68 assert(ctx);
76 new_ctx->ctx = ctx;
78 snprintf(new_ctx->name, sizeof(new_ctx->name), "%s%u_nvme", ctx->name, ctx->seqno);
79 memcpy(&new_ctx->drv_opts, &ctx->drv_opts, sizeof(ctx->drv_opts));
80 snprintf(new_ctx->drv_opts.hostnqn, sizeof(ctx->drv_opts.hostnqn), "%s", ctx->hostnqn);
81 ctx->seqno = ctx->seqno + 1;
93 &entry_ctx->ctx->drv_opts,
94 &entry_ctx->ctx->bdev_opts,
98 entry_ctx->ctx->name, entry_ctx->trid.traddr, entry_ctx->trid.trsvcid,
104 free_mdns_discovery_entry_ctx(struct mdns_discovery_ctx *ctx)
108 if (!ctx) {
112 TAILQ_FOREACH_SAFE(entry_ctx, &ctx->mdns_discovery_entry_ctxs, tailq, tmp) {
113 TAILQ_REMOVE(&ctx->mdns_discovery_entry_ctxs, entry_ctx, tailq);
119 free_mdns_discovery_ctx(struct mdns_discovery_ctx *ctx)
121 if (!ctx) {
125 free(ctx->name);
126 free(ctx->svcname);
127 free(ctx->hostnqn);
128 avahi_service_browser_free(ctx->sb);
129 free_mdns_discovery_entry_ctx(ctx);
130 free(ctx);
211 struct mdns_discovery_ctx *ctx = NULL, *tmp_ctx = NULL;
217 TAILQ_FOREACH_SAFE(ctx, &g_mdns_discovery_ctxs, tailq, tmp_ctx) {
218 if (strcmp(ctx->svcname, svcname) == 0) {
219 return ctx;
249 struct mdns_discovery_ctx *ctx = NULL;
279 ctx = get_mdns_discovery_ctx_by_svcname(svc_type);
280 if (!ctx) {
300 SPDK_ERRLOG("subnqn received is empty for service %s\n", ctx->svcname);
307 SPDK_ERRLOG("Protocol not received for service %s\n", ctx->svcname);
315 SPDK_ERRLOG("Unable to derive nvme transport type for service %s\n", ctx->svcname);
321 TAILQ_FOREACH(entry_ctx, &ctx->mdns_discovery_entry_ctxs, tailq) {
332 entry_ctx = create_mdns_discovery_entry_ctx(ctx, trid);
333 TAILQ_INSERT_TAIL(&ctx->mdns_discovery_entry_ctxs, entry_ctx, tailq);
334 spdk_thread_send_msg(ctx->calling_thread, mdns_bdev_nvme_start_discovery, entry_ctx);
421 struct mdns_discovery_ctx *ctx = arg;
424 if (ctx->stop) {
425 SPDK_INFOLOG(bdev_nvme, "Stopping avahi poller for service %s\n", ctx->svcname);
426 spdk_poller_unregister(&ctx->poller);
427 TAILQ_REMOVE(&g_mdns_discovery_ctxs, ctx, tailq);
428 free_mdns_discovery_ctx(ctx);
433 spdk_poller_unregister(&ctx->poller);
439 SPDK_ERRLOG("avahi poll returned error for service: %s/n", ctx->svcname);
449 struct mdns_discovery_ctx *ctx = arg;
452 TAILQ_INSERT_TAIL(&g_mdns_discovery_ctxs, ctx, tailq);
453 ctx->poller = SPDK_POLLER_REGISTER(bdev_nvme_avahi_iterate, ctx, 100 * 1000);
464 struct mdns_discovery_ctx *ctx;
469 TAILQ_FOREACH(ctx, &g_mdns_discovery_ctxs, tailq) {
470 if (strcmp(ctx->name, base_name) == 0) {
475 if (strcmp(ctx->svcname, svcname) == 0) {
511 ctx = calloc(1, sizeof(*ctx));
512 if (ctx == NULL) {
513 SPDK_ERRLOG("Error creating mDNS discovery ctx for service: %s\n", svcname);
518 ctx->svcname = strdup(svcname);
519 if (ctx->svcname == NULL) {
520 SPDK_ERRLOG("Error creating mDNS discovery ctx svcname for service: %s\n", svcname);
521 free_mdns_discovery_ctx(ctx);
525 ctx->name = strdup(base_name);
526 if (ctx->name == NULL) {
527 SPDK_ERRLOG("Error creating mDNS discovery ctx name for service: %s\n", svcname);
528 free_mdns_discovery_ctx(ctx);
532 memcpy(&ctx->drv_opts, drv_opts, sizeof(*drv_opts));
533 memcpy(&ctx->bdev_opts, bdev_opts, sizeof(*bdev_opts));
534 ctx->sb = sb;
535 ctx->calling_thread = spdk_get_thread();
536 TAILQ_INIT(&ctx->mdns_discovery_entry_ctxs);
538 ctx->hostnqn = strdup(ctx->drv_opts.hostnqn);
539 if (ctx->hostnqn == NULL) {
540 SPDK_ERRLOG("Error creating mDNS discovery ctx hostnqn for service: %s\n", svcname);
541 free_mdns_discovery_ctx(ctx);
545 spdk_thread_send_msg(g_bdev_nvme_init_thread, start_mdns_discovery_poller, ctx);
550 mdns_stop_discovery_entry(struct mdns_discovery_ctx *ctx)
554 assert(ctx);
556 TAILQ_FOREACH(entry_ctx, &ctx->mdns_discovery_entry_ctxs, tailq) {
564 struct mdns_discovery_ctx *ctx;
567 TAILQ_FOREACH(ctx, &g_mdns_discovery_ctxs, tailq) {
568 if (strcmp(name, ctx->name) == 0) {
569 if (ctx->stop) {
573 ctx->stop = true;
574 mdns_stop_discovery_entry(ctx);
585 struct mdns_discovery_ctx *ctx;
591 TAILQ_FOREACH(ctx, &g_mdns_discovery_ctxs, tailq) {
593 spdk_json_write_named_string(w, "name", ctx->name);
594 spdk_json_write_named_string(w, "svcname", ctx->svcname);
597 TAILQ_FOREACH(entry_ctx, &ctx->mdns_discovery_entry_ctxs, tailq) {
616 struct mdns_discovery_ctx *ctx;
618 TAILQ_FOREACH(ctx, &g_mdns_discovery_ctxs, tailq) {
624 spdk_json_write_named_string(w, "name", ctx->name);
625 spdk_json_write_named_string(w, "svcname", ctx->svcname);
626 spdk_json_write_named_string(w, "hostnqn", ctx->hostnqn);