Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-nvme.h
1/* packet-nvme.h
2 * data structures for NVMe Dissection
3 * Copyright 2016
4 * Code by Parav Pandit
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <[email protected]>
8 * Copyright 1998 Gerald Combs
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12#ifndef _PACKET_NVME_H_
13#define _PACKET_NVME_H_
14
15#define NVME_CMD_SIZE 64
16#define NVME_CQE_SIZE 16
17
18#define NVME_FABRIC_OPC 0x7F
19#define NVME_FCTYPE_PROP_SET 0x0
20#define NVME_FCTYPE_CONNECT 0x1
21#define NVME_FCTYPE_PROP_GET 0x4
22#define NVME_FCTYPE_AUTH_SEND 0x5
23#define NVME_FCTYPE_AUTH_RECV 0x6
24#define NVME_FCTYPE_DISCONNECT 0x8
25
26
27struct nvme_q_ctx {
28 wmem_tree_t *pending_cmds;
29 wmem_tree_t *done_cmds;
30 wmem_tree_t *data_requests;
31 wmem_tree_t *data_responses;
32 wmem_tree_t *data_offsets;
33 uint16_t qid;
34};
35
36#define NVME_CMD_MAX_TRS (16)
37
39 uint32_t cmd_pkt_num; /* pkt number of the cmd */
40 uint32_t cqe_pkt_num; /* pkt number of the cqe */
41
42 uint32_t data_req_pkt_num;
43 uint32_t data_tr_pkt_num[NVME_CMD_MAX_TRS];
44 uint32_t first_tr_psn;
45
46 nstime_t cmd_start_time;
47 nstime_t cmd_end_time;
48 uint32_t tr_bytes; /* bytes transferred so far */
49 bool fabric; /* indicate whether cmd fabric type or not */
50
51 union {
52 struct {
53 uint16_t cns;
54 } cmd_identify;
55 struct {
56 unsigned records;
57 unsigned tr_rcrd_id;
58 unsigned tr_off;
59 unsigned tr_sub_entries;
60 uint16_t lsi;
61 uint8_t lid;
62 uint8_t lsp;
63 uint64_t off;
64 uint8_t uid_idx;
65 } get_logpage;
66 struct {
67 uint8_t fid;
68 } set_features;
69 struct {
70 union {
71 struct {
72 uint8_t offset;
73 } prop_get;
74 struct {
75 uint16_t qid;
76 } cnct;
77 };
78 uint8_t fctype; /* fabric cmd type */
79 } fabric_cmd;
80 } cmd_ctx;
81 uint8_t opcode;
82};
83
84extern int hf_nvmeof_cmd_pkt;
85extern int hf_nvmeof_data_req;
86
87const char *get_nvmeof_cmd_string(uint8_t fctype);
88
89void
90nvme_publish_qid(proto_tree *tree, int field_index, uint16_t qid);
91
92void
93nvme_publish_cmd_latency(proto_tree *tree, struct nvme_cmd_ctx *cmd_ctx,
94 int field_index);
95void
96nvme_publish_to_cmd_link(proto_tree *tree, tvbuff_t *tvb,
97 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
98void
99nvme_publish_to_cqe_link(proto_tree *tree, tvbuff_t *tvb,
100 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
101void
102nvme_publish_to_data_req_link(proto_tree *tree, tvbuff_t *tvb,
103 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
104void
105nvme_publish_to_data_resp_link(proto_tree *tree, tvbuff_t *tvb,
106 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
107void
108nvme_publish_link(proto_tree *tree, tvbuff_t *tvb, int hf_index,
109 uint32_t pkt_no, bool zero_ok);
110
111void nvme_update_cmd_end_info(packet_info *pinfo, struct nvme_cmd_ctx *cmd_ctx);
112
113void
114nvme_add_cmd_to_pending_list(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
115 struct nvme_cmd_ctx *cmd_ctx,
116 void *ctx, uint16_t cmd_id);
117void* nvme_lookup_cmd_in_pending_list(struct nvme_q_ctx *q_ctx, uint16_t cmd_id);
118
120{
121 uint64_t addr;
122 uint32_t key;
123 uint32_t size;
124};
125
126void
127dissect_nvmeof_fabric_cmd(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *nvme_tree,
128 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd, unsigned off, bool link_data_req);
129void
130dissect_nvmeof_cmd_data(tvbuff_t *data_tvb, packet_info *pinfo, proto_tree *data_tree,
131 unsigned pkt_off, struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd, unsigned len);
132void
133dissect_nvmeof_fabric_cqe(tvbuff_t *nvme_tvb, packet_info *pinfo,
134 proto_tree *nvme_tree,
135 struct nvme_cmd_ctx *cmd_ctx, unsigned off);
136
137void
138nvme_add_data_request(struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx,
139 struct keyed_data_req *req);
140
141struct nvme_cmd_ctx*
142nvme_lookup_data_request(struct nvme_q_ctx *q_ctx, struct keyed_data_req *req);
143
144void
145nvme_add_data_tr_pkt(struct nvme_q_ctx *q_ctx,
146 struct nvme_cmd_ctx *cmd_ctx, uint32_t rkey, uint32_t frame_num);
147struct nvme_cmd_ctx*
148nvme_lookup_data_tr_pkt(struct nvme_q_ctx *q_ctx,
149 uint32_t rkey, uint32_t frame_num);
150
151void
152nvme_add_data_tr_off(struct nvme_q_ctx *q_ctx, uint32_t off, uint32_t frame_num);
153
154uint32_t
155nvme_lookup_data_tr_off(struct nvme_q_ctx *q_ctx, uint32_t frame_num);
156
157void
158nvme_add_cmd_cqe_to_done_list(struct nvme_q_ctx *q_ctx,
159 struct nvme_cmd_ctx *cmd_ctx, uint16_t cmd_id);
160void*
161nvme_lookup_cmd_in_done_list(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
162 uint16_t cmd_id);
163
164void dissect_nvme_cmd_sgl(tvbuff_t *cmd_tvb, proto_tree *cmd_tree, int field_index,
165 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx, unsigned cmd_off, bool visited);
166
167void
168dissect_nvme_cmd(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
169 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx);
170
171void nvme_update_transfer_request(packet_info *pinfo, struct nvme_cmd_ctx *cmd_ctx, struct nvme_q_ctx *q_ctx);
172
173void
174dissect_nvme_data_response(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
175 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx, unsigned len, bool is_inline);
176
177void
178dissect_nvme_cqe(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
179 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx);
180
185const char *
186nvme_get_opcode_string(uint8_t opcode, uint16_t qid);
187
188/*
189 * Tells if opcode can be an opcode of io queue.
190 * Used to "Guess" queue type for nvme-tcp in case that "connect"
191 * command was not recorded
192 */
193int
194nvme_is_io_queue_opcode(uint8_t opcode);
195
196#endif
197
198/*
199 * Editor modelines - https://www.wireshark.org/tools/modelines.html
200 *
201 * Local variables:
202 * c-basic-offset: 4
203 * tab-width: 8
204 * indent-tabs-mode: nil
205 * End:
206 *
207 * vi: set shiftwidth=4 tabstop=8 expandtab:
208 * :indentSize=4:tabSize=8:noTabs=true:
209 */
Definition packet_info.h:43
Definition proto.h:901
Definition wmem_tree-int.h:48
Definition packet-nvme.h:120
Definition nstime.h:26
Definition packet-nvme.h:38
Definition packet-nvme.h:27
Definition tvbuff-int.h:35