Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163257339
D19275.id54163.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D19275.id54163.diff
View Options
Index: sbin/nvmecontrol/logpage.c
===================================================================
--- sbin/nvmecontrol/logpage.c
+++ sbin/nvmecontrol/logpage.c
@@ -53,7 +53,14 @@
#define MAX_FW_SLOTS (7)
-SET_CONCAT_DEF(logpage, struct logpage_function);
+static SLIST_HEAD(,logpage_function) logpages;
+
+void
+logpage_register(struct logpage_function *p)
+{
+
+ SLIST_INSERT_HEAD(&logpages, p, link);
+}
const char *
kv_lookup(const struct kv_name *kv, size_t kv_count, uint32_t key)
@@ -326,15 +333,15 @@
static void
logpage_help(void)
{
- const struct logpage_function * const *f;
+ const struct logpage_function *f;
const char *v;
fprintf(stderr, "\n");
fprintf(stderr, "%-8s %-10s %s\n", "Page", "Vendor","Page Name");
fprintf(stderr, "-------- ---------- ----------\n");
- for (f = logpage_begin(); f < logpage_limit(); f++) {
- v = (*f)->vendor == NULL ? "-" : (*f)->vendor;
- fprintf(stderr, "0x%02x %-10s %s\n", (*f)->log_page, v, (*f)->name);
+ SLIST_FOREACH(f, &logpages, link) {
+ v = f->vendor == NULL ? "-" : f->vendor;
+ fprintf(stderr, "0x%02x %-10s %s\n", f->log_page, v, f->name);
}
exit(1);
@@ -352,7 +359,7 @@
uint32_t nsid, size;
void *buf;
const char *vendor = NULL;
- const struct logpage_function * const *f;
+ const struct logpage_function *f;
struct nvme_controller_data cdata;
print_fn_t print_fn;
uint8_t ns_smart;
@@ -438,14 +445,14 @@
* the page is vendor specific, don't match the print function
* unless the vendors match.
*/
- for (f = logpage_begin(); f < logpage_limit(); f++) {
- if ((*f)->vendor != NULL && vendor != NULL &&
- strcmp((*f)->vendor, vendor) != 0)
+ SLIST_FOREACH(f, &logpages, link) {
+ if (f->vendor != NULL && vendor != NULL &&
+ strcmp(f->vendor, vendor) != 0)
continue;
- if (log_page != (*f)->log_page)
+ if (log_page != f->log_page)
continue;
- print_fn = (*f)->print_fn;
- size = (*f)->size;
+ print_fn = f->print_fn;
+ size = f->size;
break;
}
}
Index: sbin/nvmecontrol/nvmecontrol.h
===================================================================
--- sbin/nvmecontrol/nvmecontrol.h
+++ sbin/nvmecontrol/nvmecontrol.h
@@ -32,6 +32,7 @@
#define __NVMECONTROL_H__
#include <sys/linker_set.h>
+#include <sys/queue.h>
#include <dev/nvme/nvme.h>
struct nvme_function;
@@ -56,6 +57,7 @@
typedef void (*print_fn_t)(const struct nvme_controller_data *cdata, void *buf, uint32_t size);
struct logpage_function {
+ SLIST_ENTRY(logpage_function) link;
uint8_t log_page;
const char *vendor;
const char *name;
@@ -64,7 +66,6 @@
};
-#define NVME_LOGPAGESET(sym) DATA_SET(NVME_SETNAME(logpage), sym)
#define NVME_LOGPAGE(unique, lp, vend, nam, fn, sz) \
static struct logpage_function unique ## _lpf = { \
.log_page = lp, \
@@ -73,10 +74,8 @@
.print_fn = fn, \
.size = sz, \
} ; \
- NVME_LOGPAGESET(unique ## _lpf)
-#define NVME_LOGPAGE_BEGIN SET_BEGIN(NVME_SETNAME(logpage))
-#define NVME_LOGPAGE_LIMIT SET_LIMIT(NVME_SETNAME(logpage))
-#define NVME_LOGPAGE_DECLARE(t) SET_DECLARE(NVME_SETNAME(logpage), t)
+ static void logpage_reg_##unique(void) __attribute__((constructor)); \
+ static void logpage_reg_##unique(void) { logpage_register(&unique##_lpf); }
#define DEFAULT_SIZE (4096)
struct kv_name {
@@ -87,7 +86,7 @@
const char *kv_lookup(const struct kv_name *kv, size_t kv_count, uint32_t key);
NVME_CMD_DECLARE(top, struct nvme_function);
-NVME_LOGPAGE_DECLARE(struct logpage_function);
+void logpage_register(struct logpage_function *p);
struct set_concat {
void **begin;
@@ -105,7 +104,6 @@
#define SET_CONCAT_DECL(set, t) \
void add_to_ ## set(t **b, t **e)
SET_CONCAT_DECL(top, struct nvme_function);
-SET_CONCAT_DECL(logpage, struct logpage_function);
#define NVME_CTRLR_PREFIX "nvme"
#define NVME_NS_PREFIX "ns"
Index: sbin/nvmecontrol/nvmecontrol.c
===================================================================
--- sbin/nvmecontrol/nvmecontrol.c
+++ sbin/nvmecontrol/nvmecontrol.c
@@ -312,19 +312,17 @@
warnx("Can't load %s: %s", path, dlerror());
else {
/*
- * Add in the top (for cli commands) and logpage (for
- * logpage parsing) linker sets. We have to do this by
- * hand because linker sets aren't automatically merged.
+ * Add in the top (for cli commands)linker sets. We have
+ * to do this by hand because linker sets aren't
+ * automatically merged.
*/
void *begin, *limit;
+
begin = dlsym(h, "__start_set_top");
limit = dlsym(h, "__stop_set_top");
if (begin)
add_to_top(begin, limit);
- begin = dlsym(h, "__start_set_logpage");
- limit = dlsym(h, "__stop_set_logpage");
- if (begin)
- add_to_logpage(begin, limit);
+ /* log pages use constructors so are done on load */
}
free(path);
path = NULL;
@@ -337,7 +335,6 @@
{
add_to_top(NVME_CMD_BEGIN(top), NVME_CMD_LIMIT(top));
- add_to_logpage(NVME_LOGPAGE_BEGIN, NVME_LOGPAGE_LIMIT);
load_dir("/lib/nvmecontrol");
load_dir("/usr/local/lib/nvmecontrol");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 22, 12:10 PM (11 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35363677
Default Alt Text
D19275.id54163.diff (5 KB)
Attached To
Mode
D19275: Rework logpage extensibility.
Attached
Detach File
Event Timeline
Log In to Comment