summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-nvme-mi.c
blob: dabfcd91c5d3ce31881b6d975011ccee784b2455 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
/* packet-nvme-mi.c
 * Routines for NVMe Management Interface (NVMe-MI), over MCTP
 * Copyright 2022, Jeremy Kerr <jk@codeconstruct.com.au>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

/* NVMe is defined by the NVM Express Management Interface standard,
 * athttps://nvmexpress.org/developers/nvme-mi-specification/
 */

#include <config.h>

#include <epan/conversation.h>
#include <epan/crc32-tvb.h>
#include <epan/packet.h>
#include <epan/to_str.h>
#include "packet-sll.h"
#include "packet-mctp.h"
#include "packet-nvme.h"

void proto_register_nvme_mi(void);
void proto_reg_handoff_nvme_mi(void);

static int proto_nvme_mi = -1;

static int hf_nvme_mi_mctp_mt = -1;
static int hf_nvme_mi_mctp_ic = -1;
static int hf_nvme_mi_csi = -1;
static int hf_nvme_mi_type = -1;
static int hf_nvme_mi_ror = -1;
static int hf_nvme_mi_meb = -1;
static int hf_nvme_mi_mic = -1;

static int hf_nvme_mi_mi_opcode = -1;
static int hf_nvme_mi_mi_cdw0 = -1;
static int hf_nvme_mi_mi_cdw1 = -1;
static int hf_nvme_mi_mi_status = -1;
static int hf_nvme_mi_mi_nmresp = -1;
static int hf_nvme_mi_mi_data = -1;

static int hf_nvme_mi_admin_opcode = -1;
static int hf_nvme_mi_admin_status = -1;
static int hf_nvme_mi_admin_flags = -1;
static int hf_nvme_mi_admin_flags_doff = -1;
static int hf_nvme_mi_admin_flags_dlen = -1;
static int hf_nvme_mi_admin_ctrl_id = -1;
static int hf_nvme_mi_admin_sqe1 = -1;
static int hf_nvme_mi_admin_sqe2 = -1;
static int hf_nvme_mi_admin_sqe3 = -1;
static int hf_nvme_mi_admin_sqe4 = -1;
static int hf_nvme_mi_admin_sqe5 = -1;
static int hf_nvme_mi_admin_doff = -1;
static int hf_nvme_mi_admin_dlen = -1;
static int hf_nvme_mi_admin_resv0 = -1;
static int hf_nvme_mi_admin_resv1 = -1;
static int hf_nvme_mi_admin_sqe10 = -1;
static int hf_nvme_mi_admin_sqe11 = -1;
static int hf_nvme_mi_admin_sqe12 = -1;
static int hf_nvme_mi_admin_sqe13 = -1;
static int hf_nvme_mi_admin_sqe14 = -1;
static int hf_nvme_mi_admin_sqe15 = -1;
static int hf_nvme_mi_admin_data = -1;
static int hf_nvme_mi_admin_cqe1 = -1;
static int hf_nvme_mi_admin_cqe2 = -1;
static int hf_nvme_mi_admin_cqe3 = -1;

static int hf_nvme_mi_response_in = -1;
static int hf_nvme_mi_response_to = -1;
static int hf_nvme_mi_response_time = -1;


static gint ett_nvme_mi = -1;
static gint ett_nvme_mi_hdr = -1;
static gint ett_nvme_mi_mi = -1;
static gint ett_nvme_mi_admin = -1;
static gint ett_nvme_mi_admin_flags = -1;

enum nvme_mi_type {
    NVME_MI_TYPE_CONTROL = 0x0,
    NVME_MI_TYPE_MI = 0x1,
    NVME_MI_TYPE_ADMIN = 0x2,
    NVME_MI_TYPE_PCIE = 0x4,
};

struct nvme_mi_command {
    gboolean            init;
    enum nvme_mi_type   type;
    guint               opcode;
    guint32             req_frame;
    guint32             resp_frame;
    nstime_t            req_time;
};

struct nvme_mi_conv_info {
    struct nvme_mi_command command_slots[2];
};

static const value_string mi_mctp_type_vals[] = {
    { 4, "NVMe-MI" },
    { 0, NULL },
};

static const value_string mi_type_vals[] = {
    { NVME_MI_TYPE_CONTROL, "Control primitive" },
    { NVME_MI_TYPE_MI,      "MI command" },
    { NVME_MI_TYPE_ADMIN,   "NVMe Admin command" },
    { NVME_MI_TYPE_PCIE,    "PCIe command" },
    { 0, NULL },
};

static const value_string mi_opcode_vals[] = {
    { 0x00, "Read NVMe-MI Data Structure" },
    { 0x01, "NVM Subsystem Health Status Poll" },
    { 0x02, "Controller Health Status Poll" },
    { 0x03, "Configuration Set" },
    { 0x04, "Configuration Get" },
    { 0, NULL },
};

static const value_string admin_opcode_vals[] = {
    { 0x00, "Delete I/O Submission Queue" },
    { 0x01, "Create I/O Submission Queue" },
    { 0x02, "Get Log Page" },
    { 0x04, "Delete I/O Completion Queue" },
    { 0x05, "Create I/O Completion Queue" },
    { 0x06, "Identify" },
    { 0x09, "Set Features" },
    { 0x0a, "Get Features" },
    { 0x0d, "Namespace Management" },
    { 0x10, "Firmware Commit" },
    { 0x11, "Firmware Image Download" },
    { 0x80, "Format NVM" },
    { 0x81, "Security Send" },
    { 0x82, "Security Receive" },
    { 0, NULL },
};

static const true_false_string tfs_meb = { "data in MEB", "data in message" };

static int
dissect_nvme_mi_mi(tvbuff_t *tvb, bool resp, struct nvme_mi_command *cmd,
                   proto_tree *tree)
{
    proto_item *it, *it2;
    proto_tree *mi_tree;

    it = proto_tree_add_item(tree, proto_nvme_mi, tvb, 0, -1, ENC_NA);
    mi_tree = proto_item_add_subtree(it, ett_nvme_mi_mi);

    if (!resp) {
        proto_tree_add_item_ret_uint(mi_tree, hf_nvme_mi_mi_opcode,
                                     tvb, 0, 1, ENC_NA, &cmd->opcode);

        proto_tree_add_item(mi_tree, hf_nvme_mi_mi_cdw0,
                            tvb, 4, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(mi_tree, hf_nvme_mi_mi_cdw1,
                            tvb, 8, 4, ENC_LITTLE_ENDIAN);

        if (tvb_reported_length(tvb) > 12)
            proto_tree_add_item(mi_tree, hf_nvme_mi_mi_data,
                                tvb, 12, -1, ENC_NA);
    } else {
        it2 = proto_tree_add_uint(mi_tree, hf_nvme_mi_mi_opcode,
                                  tvb, 0, 0, cmd->opcode);
        proto_item_set_generated(it2);

        proto_tree_add_item(mi_tree, hf_nvme_mi_mi_status,
                            tvb, 0, 1, ENC_NA);
        proto_tree_add_item(mi_tree, hf_nvme_mi_mi_nmresp,
                            tvb, 1, 3, ENC_LITTLE_ENDIAN);

        if (tvb_reported_length(tvb) > 4)
            proto_tree_add_item(mi_tree, hf_nvme_mi_mi_data,
                                tvb, 4, -1, ENC_NA);
    }

    return 0;
}

static int
dissect_nvme_mi_admin(tvbuff_t *tvb, bool resp, struct nvme_mi_command *cmd,
                      proto_tree *tree)
{
    proto_tree *admin_tree;
    proto_item *it, *it2;

    it = proto_tree_add_item(tree, proto_nvme_mi, tvb, 0, -1, ENC_NA);
    admin_tree = proto_item_add_subtree(it, ett_nvme_mi_admin);

    proto_item_set_text(it, "NVMe Admin %s",
                        resp ? "response" : "request");

    if (resp) {
        it2 = proto_tree_add_uint(admin_tree, hf_nvme_mi_admin_opcode,
                                  tvb, 0, 0, cmd->opcode);
        proto_item_set_generated(it2);

        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_status,
                            tvb, 0, 1, ENC_NA);

        if (tvb_reported_length(tvb) >= 16) {
            proto_tree_add_item(admin_tree, hf_nvme_mi_admin_cqe1,
                                tvb, 4, 4, ENC_LITTLE_ENDIAN);
            proto_tree_add_item(admin_tree, hf_nvme_mi_admin_cqe2,
                                tvb, 8, 4, ENC_LITTLE_ENDIAN);
            proto_tree_add_item(admin_tree, hf_nvme_mi_admin_cqe3,
                                tvb, 12, 4, ENC_LITTLE_ENDIAN);
        }

        if (tvb_reported_length(tvb) > 16)
            proto_tree_add_item(admin_tree, hf_nvme_mi_admin_data,
                                tvb, 16, -1, ENC_NA);
    } else {
        static int * const nvme_mi_admin_flags[] = {
            &hf_nvme_mi_admin_flags_doff,
            &hf_nvme_mi_admin_flags_dlen,
            NULL,
        };

        proto_tree_add_item_ret_uint(admin_tree, hf_nvme_mi_admin_opcode,
                                     tvb, 0, 1, ENC_NA, &cmd->opcode);

        proto_tree_add_bitmask(admin_tree, tvb, 1, hf_nvme_mi_admin_flags,
                               ett_nvme_mi_admin_flags, nvme_mi_admin_flags,
                               ENC_NA);

        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_ctrl_id,
                            tvb, 2, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe1,
                            tvb, 4, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe2,
                            tvb, 8, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe3,
                            tvb, 12, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe4,
                            tvb, 16, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe5,
                            tvb, 20, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_doff,
                            tvb, 24, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_dlen,
                            tvb, 28, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_resv0,
                            tvb, 32, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_resv1,
                            tvb, 36, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe10,
                            tvb, 40, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe11,
                            tvb, 44, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe12,
                            tvb, 48, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe13,
                            tvb, 52, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe14,
                            tvb, 56, 4, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(admin_tree, hf_nvme_mi_admin_sqe15,
                            tvb, 60, 4, ENC_LITTLE_ENDIAN);

        if (tvb_reported_length(tvb) > 64)
            proto_tree_add_item(admin_tree, hf_nvme_mi_admin_data,
                                tvb, 64, -1, ENC_NA);
    }

    return 0;
}

static int
dissect_nvme_mi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                void *data _U_)
{
    proto_tree *nvme_mi_tree, *nvme_mi_hdr_tree;
    struct nvme_mi_conv_info *mi_conv;
    guint len, payload_len, type;
    gboolean resp, mic_enabled;
    proto_item *ti, *it2;
    conversation_t *conv;
    tvbuff_t *sub_tvb;
    guint32 mic = 0;
    guint csi;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NVMe-MI");
    col_clear(pinfo->cinfo, COL_INFO);

    /* Check that the packet is long enough for it to belong to us. */
    len = tvb_reported_length(tvb);

    if (len < 4) {
        col_add_fstr(pinfo->cinfo, COL_INFO, "Bogus length %u, minimum %u",
                     len, 4);
        return tvb_captured_length(tvb);
    }

    ti = proto_tree_add_item(tree, proto_nvme_mi, tvb, 0, -1, ENC_NA);
    nvme_mi_tree = proto_item_add_subtree(ti, ett_nvme_mi);

    ti = proto_tree_add_item(nvme_mi_tree, proto_nvme_mi, tvb, 0, 4, ENC_NA);
    proto_item_set_text(ti, "NVMe-MI header");
    nvme_mi_hdr_tree = proto_item_add_subtree(ti, ett_nvme_mi_hdr);

    proto_tree_add_item(nvme_mi_hdr_tree, hf_nvme_mi_mctp_mt,
                        tvb, 0, 4, ENC_LITTLE_ENDIAN);

    proto_tree_add_item_ret_boolean(nvme_mi_hdr_tree, hf_nvme_mi_mctp_ic,
                                    tvb, 0, 4, ENC_LITTLE_ENDIAN, &mic_enabled);

    proto_tree_add_item_ret_uint(nvme_mi_hdr_tree, hf_nvme_mi_csi,
                                 tvb, 0, 4, ENC_LITTLE_ENDIAN, &csi);

    proto_tree_add_item_ret_uint(nvme_mi_hdr_tree, hf_nvme_mi_type,
                                 tvb, 0, 4, ENC_LITTLE_ENDIAN, &type);

    proto_tree_add_item_ret_boolean(nvme_mi_hdr_tree, hf_nvme_mi_ror,
                                    tvb, 0, 4, ENC_LITTLE_ENDIAN, &resp);

    proto_tree_add_item(nvme_mi_hdr_tree, hf_nvme_mi_meb,
                        tvb, 0, 4, ENC_LITTLE_ENDIAN);

    payload_len = tvb_reported_length(tvb) - 4;
    if (mic_enabled) {
        mic = ~crc32c_tvb_offset_calculate(tvb, 0, payload_len, 0xffffffff);
        payload_len -= 4;
    }

    col_add_fstr(pinfo->cinfo, COL_INFO, "NVMe-MI %s %s",
                 val_to_str_const(type, mi_type_vals, "command"),
                 tfs_get_string(resp, &tfs_response_request));

    conv = find_or_create_conversation(pinfo);
    mi_conv = conversation_get_proto_data(conv, proto_nvme_mi);
    if (!mi_conv) {
        mi_conv = wmem_new0(wmem_file_scope(), struct nvme_mi_conv_info);
        conversation_add_proto_data(conv, proto_nvme_mi, mi_conv);
    }

    struct nvme_mi_command *cmd = &mi_conv->command_slots[csi];

    if (resp) {
        if (cmd->req_frame) {
            nstime_t ns;

            nstime_delta(&ns, &pinfo->fd->abs_ts, &cmd->req_time);

            it2 = proto_tree_add_uint(nvme_mi_tree, hf_nvme_mi_response_to,
                                      tvb, 0, 0, cmd->req_frame);
            proto_item_set_generated(it2);
            it2 = proto_tree_add_time(nvme_mi_tree, hf_nvme_mi_response_time,
                                      tvb, 0, 0, &ns);
            proto_item_set_generated(it2);
        } else {
            /* TODO: no request frame available? */
        }
        cmd->resp_frame = pinfo->num;

    } else {
        if (cmd->resp_frame) {
            it2 = proto_tree_add_uint(nvme_mi_tree, hf_nvme_mi_response_in,
                                      tvb, 0, 0, cmd->resp_frame);
            proto_item_set_generated(it2);
        }
        cmd->type = type;
        cmd->opcode = 0;
        cmd->init = true;
        cmd->req_frame = pinfo->num;
        cmd->req_time = pinfo->fd->abs_ts;
    }

    sub_tvb = tvb_new_subset_length(tvb, 4, payload_len);

    switch (type) {
    case NVME_MI_TYPE_MI:
        dissect_nvme_mi_mi(sub_tvb, resp, cmd, nvme_mi_tree);
        break;
    case NVME_MI_TYPE_ADMIN:
        dissect_nvme_mi_admin(sub_tvb, resp, cmd, nvme_mi_tree);
        break;
    default:
        break;
    }

    if (mic_enabled)
        proto_tree_add_checksum(nvme_mi_tree, tvb, payload_len + 4,
                                hf_nvme_mi_mic, -1, NULL, pinfo, mic,
                                ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);

    return tvb_captured_length(tvb);
}

void
proto_register_nvme_mi(void)
{
    /* *INDENT-OFF* */
    /* Field definitions */
    static hf_register_info hf[] = {
        /* base MI header */
        { &hf_nvme_mi_mctp_mt,
          { "MCTP message type", "nvme-mi.mctp-mt",
            FT_UINT32, BASE_HEX, VALS(mi_mctp_type_vals), 0x7f,
            NULL, HFILL },
        },
        { &hf_nvme_mi_mctp_ic,
          { "MCTP IC", "nvme-mi.mctp-ic",
            FT_BOOLEAN, 32, NULL, 0x00000080,
            NULL, HFILL },
        },
        { &hf_nvme_mi_csi,
          { "CSI", "nvme-mi.csi",
            FT_UINT32, BASE_DEC, NULL, 0x00000100,
            NULL, HFILL },
        },
        { &hf_nvme_mi_type,
          { "Type", "nvme-mi.type",
            FT_UINT32, BASE_HEX, VALS(mi_type_vals), 0x00007800,
            NULL, HFILL },
        },
        { &hf_nvme_mi_ror,
          { "ROR", "nvme-mi.ror",
            FT_BOOLEAN, 32, TFS(&tfs_response_request), 0x00008000,
            NULL, HFILL },
        },
        { &hf_nvme_mi_meb,
          { "MEB", "nvme-mi.meb",
            FT_BOOLEAN, 32, TFS(&tfs_meb), 0x00010000,
            NULL, HFILL },
        },
        { &hf_nvme_mi_mic,
          { "Message Integrity Check", "nvme-mi.mic",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },

        /* meta */
        { &hf_nvme_mi_response_in,
            { "Response In", "nvme-mi.response_in",
                FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
                "The response to this NVMe-MI request is in this frame", HFILL }
        },
        { &hf_nvme_mi_response_to,
            { "Request In", "nvme-mi.response_to",
                FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
                "This is a response to the NVMe-MI request in this frame", HFILL }
        },
        { &hf_nvme_mi_response_time,
            { "Response Time", "nvme-mi.response_time",
                FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
                "The time between the request and the response", HFILL }
        },

        /* MI commands */
        { &hf_nvme_mi_mi_opcode,
          { "Opcode", "nvme-mi.mi.opcode",
            FT_UINT8, BASE_HEX, VALS(mi_opcode_vals), 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_mi_cdw0,
          { "Command dword 0", "nvme-mi.mi.cdw0",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_mi_cdw1,
          { "Command dword 1", "nvme-mi.mi.cdw1",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_mi_status,
          { "Status", "nvme-mi.mi.status",
            FT_UINT8, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_mi_nmresp,
          { "Management Response", "nvme-mi.mi.nmresp",
            FT_UINT24, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_mi_data,
          { "Data", "nvme-mi.mi.data",
            FT_BYTES, SEP_SPACE, NULL, 0,
            NULL, HFILL },
        },

        /* Admin commands */
        { &hf_nvme_mi_admin_opcode,
          { "Opcode", "nvme-mi.admin.opcode",
            FT_UINT8, BASE_HEX, VALS(admin_opcode_vals), 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_status,
          { "Status", "nvme-mi.admin.status",
            FT_UINT8, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_flags,
          { "Command Flags", "nvme-mi.admin.flags",
            FT_UINT8, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_flags_dlen,
          { "Use Data Length", "nvme-mi.admin.flags.dlen",
            FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x1,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_flags_doff,
          { "Use Data Offset", "nvme-mi.admin.flags.doff",
            FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x2,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_ctrl_id,
          { "Controller ID", "nvme-mi.admin.ctrl-id",
            FT_UINT16, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe1,
          { "Submission Queue Entry dword 1", "nvme-mi.admin.sqe1",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe2,
          { "Submission Queue Entry dword 2", "nvme-mi.admin.sqe2",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe3,
          { "Submission Queue Entry dword 3", "nvme-mi.admin.sqe3",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe4,
          { "Submission Queue Entry dword 4", "nvme-mi.admin.sqe4",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe5,
          { "Submission Queue Entry dword 5", "nvme-mi.admin.sqe5",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_doff,
          { "Data Offset", "nvme-mi.admin.doff",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_dlen,
          { "Data Length", "nvme-mi.admin.dlen",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_resv0,
          { "Reserved", "nvme-mi.admin.reserved",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_resv1,
          { "Reserved", "nvme-mi.admin.reserved",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe10,
          { "Submission Queue Entry dword 10", "nvme-mi.admin.sqe10",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe11,
          { "Submission Queue Entry dword 11", "nvme-mi.admin.sqe11",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe12,
          { "Submission Queue Entry dword 12", "nvme-mi.admin.sqe12",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe13,
          { "Submission Queue Entry dword 13", "nvme-mi.admin.sqe13",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe14,
          { "Submission Queue Entry dword 14", "nvme-mi.admin.sqe14",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_sqe15,
          { "Submission Queue Entry dword 15", "nvme-mi.admin.sqe15",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_cqe1,
          { "Completion Queue Entry dword 1", "nvme-mi.admin.cqe1",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_cqe2,
          { "Completion Queue Entry dword 2", "nvme-mi.admin.cqe2",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_cqe3,
          { "Completion Queue Entry dword 3", "nvme-mi.admin.cqe3",
            FT_UINT32, BASE_HEX, NULL, 0,
            NULL, HFILL },
        },
        { &hf_nvme_mi_admin_data,
          { "Data", "nvme-mi.admin.data",
            FT_BYTES, SEP_SPACE, NULL, 0,
            NULL, HFILL },
        },
    };

    /* protocol subtree */
    static gint *ett[] = {
        &ett_nvme_mi,
        &ett_nvme_mi_hdr,
        &ett_nvme_mi_mi,
        &ett_nvme_mi_admin,
        &ett_nvme_mi_admin_flags,
    };

    proto_nvme_mi = proto_register_protocol("NVMe-MI", "NVMe-MI", "nvme-mi");

    proto_register_field_array(proto_nvme_mi, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));
}

void
proto_reg_handoff_nvme_mi(void)
{
    dissector_handle_t nvme_mi_handle;
    nvme_mi_handle = create_dissector_handle(dissect_nvme_mi, proto_nvme_mi);
    dissector_add_uint("mctp.type", MCTP_TYPE_NVME, nvme_mi_handle);
}

/*
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * vi: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */