Spdk/module/event/subsystems/vmd/vmd.c
paul luse a6dbe3721e update Intel copyright notices
per Intel policy to include file commit date using git cmd
below.  The policy does not apply to non-Intel (C) notices.

git log --follow -C90% --format=%ad --date default <file> | tail -1

and then pull just the 4 digit year from the result.

Intel copyrights were not added to files where Intel either had
no contribution ot the contribution lacked substance (ie license
header updates, formatting changes, etc).  Contribution date used
"--follow -C95%" to get the most accurate date.

Note that several files in this patch didn't end the license/(c)
block with a blank comment line so these were added as the vast
majority of files do have this last blank line.  Simply there for
consistency.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: Id5b7ce4f658fe87132f14139ead58d6e285c04d4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15192
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
2022-11-10 08:28:53 +00:00

100 lines
1.8 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (C) 2019 Intel Corporation.
* All rights reserved.
*/
#include "spdk/stdinc.h"
#include "spdk/json.h"
#include "spdk/thread.h"
#include "spdk/likely.h"
#include "spdk/log.h"
#include "spdk/vmd.h"
#include "spdk_internal/init.h"
#include "event_vmd.h"
static struct spdk_poller *g_hotplug_poller;
static bool g_enabled;
void
vmd_subsystem_enable(void)
{
g_enabled = true;
}
bool
vmd_subsystem_is_enabled(void)
{
return g_enabled;
}
static int
vmd_hotplug_monitor(void *ctx)
{
return spdk_vmd_hotplug_monitor();
}
static void
vmd_subsystem_init(void)
{
int rc = 0;
if (!g_enabled) {
goto out;
}
rc = spdk_vmd_init();
if (spdk_likely(rc != 0)) {
SPDK_ERRLOG("Failed to initialize the VMD library\n");
goto out;
}
assert(g_hotplug_poller == NULL);
g_hotplug_poller = SPDK_POLLER_REGISTER(vmd_hotplug_monitor, NULL, 1000000ULL);
if (g_hotplug_poller == NULL) {
SPDK_ERRLOG("Failed to register hotplug monitor poller\n");
rc = -ENOMEM;
goto out;
}
out:
spdk_subsystem_init_next(rc);
}
static void
vmd_subsystem_fini(void)
{
spdk_poller_unregister(&g_hotplug_poller);
spdk_vmd_fini();
spdk_subsystem_fini_next();
}
static void
vmd_write_config_json(struct spdk_json_write_ctx *w)
{
spdk_json_write_array_begin(w);
if (g_enabled) {
spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "method", "vmd_enable");
spdk_json_write_named_object_begin(w, "params");
spdk_json_write_object_end(w);
spdk_json_write_object_end(w);
}
spdk_json_write_array_end(w);
}
static struct spdk_subsystem g_spdk_subsystem_vmd = {
.name = "vmd",
.init = vmd_subsystem_init,
.fini = vmd_subsystem_fini,
.write_config_json = vmd_write_config_json,
};
SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_vmd);