Wireshark 4.7.3
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/*
27 * NVMe Admin command opcodes. Promoted here from packet-nvme.c so transports
28 * that reuse the admin-command decode (e.g. NVMe-MI over MCTP) can share both
29 * the opcode constants and the dissector below. The 0x14-0x8c entries are the
30 * Admin opcodes that NVMe-MI 2.1 Figure 134 permits over the Management
31 * Interface.
32 */
33#define NVME_AQ_OPC_DELETE_SQ 0x00
34#define NVME_AQ_OPC_CREATE_SQ 0x01
35#define NVME_AQ_OPC_GET_LOG_PAGE 0x02
36#define NVME_AQ_OPC_DELETE_CQ 0x04
37#define NVME_AQ_OPC_CREATE_CQ 0x05
38#define NVME_AQ_OPC_IDENTIFY 0x06
39#define NVME_AQ_OPC_ABORT 0x08
40#define NVME_AQ_OPC_SET_FEATURES 0x09
41#define NVME_AQ_OPC_GET_FEATURES 0x0a
42#define NVME_AQ_OPC_ASYNC_EVE_REQ 0x0c
43#define NVME_AQ_OPC_NS_MGMT 0x0d
44#define NVME_AQ_OPC_FW_COMMIT 0x10
45#define NVME_AQ_OPC_FW_IMG_DOWNLOAD 0x11
46#define NVME_AQ_OPC_SELF_TEST 0x14
47#define NVME_AQ_OPC_NS_ATTACH 0x15
48#define NVME_AQ_OPC_KEEP_ALIVE 0x18
49#define NVME_AQ_OPC_VIRT_MGMT 0x1c
50#define NVME_AQ_OPC_CAP_MGMT 0x20
51#define NVME_AQ_OPC_LOCKDOWN 0x24
52#define NVME_AQ_OPC_CLEAR_EXP_NVM_CFG 0x28
53#define NVME_AQ_OPC_CREATE_EXP_NVM_SUBSYS 0x2a
54#define NVME_AQ_OPC_MANAGE_EXP_NVM_SUBSYS 0x2d
55#define NVME_AQ_OPC_MANAGE_EXP_NS 0x31
56#define NVME_AQ_OPC_MANAGE_EXP_PORT 0x35
57#define NVME_AQ_OPC_DBBUF_CONFIG 0x7c
58#define NVME_AQ_OPC_FORMAT_NVM 0x80
59#define NVME_AQ_OPC_SECURITY_SEND 0x81
60#define NVME_AQ_OPC_SECURITY_RECV 0x82
61#define NVME_AQ_OPC_SANITIZE 0x84
62#define NVME_AQ_OPC_GET_LBA_STATUS 0x86
63#define NVME_AQ_OPC_SANITIZE_NS 0x8c
64
65#define NVME_IDENTIFY_CNS_IDENTIFY_NS 0x0
66#define NVME_IDENTIFY_CNS_IDENTIFY_CTRL 0x1
67#define NVME_IDENTIFY_CNS_IDENTIFY_NSLIST 0x2
68#define NVME_IDENTIFY_CNS_NSID_DESC_LIST 0x3
69#define NVME_IDENTIFY_CNS_NVM_SET_LIST 0x4
70#define NVME_IDENTIFY_CNS_NS_ALLOC_LIST 0x10
71#define NVME_IDENTIFY_CNS_NS_ALLOC 0x11
72#define NVME_IDENTIFY_CNS_CTRL_LIST_NS 0x12
73#define NVME_IDENTIFY_CNS_CTRL_LIST 0x13
74#define NVME_IDENTIFY_CNS_PRI_CTRL_CAP 0x14
75#define NVME_IDENTIFY_CNS_SEC_CTRL_LIST 0x15
76#define NVME_IDENTIFY_CNS_NS_GRAN_LIST 0x16
77#define NVME_IDENTIFY_CNS_UUID_LIST 0x17
78
79
80struct nvme_q_ctx {
81 wmem_tree_t *pending_cmds;
82 wmem_tree_t *done_cmds;
83 wmem_tree_t *data_requests;
84 wmem_tree_t *data_responses;
85 wmem_tree_t *data_offsets;
86 uint16_t qid;
87};
88
89#define NVME_CMD_MAX_TRS (16)
90
92 uint32_t cmd_pkt_num; /* pkt number of the cmd */
93 uint32_t cqe_pkt_num; /* pkt number of the cqe */
94
95 uint32_t data_req_pkt_num;
96 uint32_t data_tr_pkt_num[NVME_CMD_MAX_TRS];
97 uint32_t first_tr_psn;
98
99 nstime_t cmd_start_time;
100 nstime_t cmd_end_time;
101 uint32_t tr_bytes; /* bytes transferred so far */
102 bool fabric; /* indicate whether cmd fabric type or not */
103
104 union {
105 struct {
106 uint16_t cns;
107 } cmd_identify;
108 struct {
109 uint64_t off;
110 unsigned records;
111 unsigned tr_rcrd_id;
112 unsigned tr_off;
113 unsigned tr_sub_entries;
114 uint16_t lsi;
115 uint8_t lid;
116 uint8_t lsp;
117 uint8_t uid_idx;
118 uint8_t tr_type;
119 } get_logpage;
120 struct {
121 uint8_t fid;
122 } set_features;
123 struct {
124 union {
125 struct {
126 uint8_t offset;
127 } prop_get;
128 struct {
129 uint16_t qid;
130 } cnct;
131 };
132 uint8_t fctype; /* fabric cmd type */
133 } fabric_cmd;
134 } cmd_ctx;
135 uint8_t opcode;
136};
137
138extern int hf_nvmeof_cmd_pkt;
139extern int hf_nvmeof_data_req;
140
141const char *get_nvmeof_cmd_string(uint8_t fctype);
142
143void
144nvme_publish_qid(proto_tree *tree, int field_index, uint16_t qid);
145
146void
147nvme_publish_cmd_latency(proto_tree *tree, struct nvme_cmd_ctx *cmd_ctx,
148 int field_index);
149void
150nvme_publish_to_cmd_link(proto_tree *tree, tvbuff_t *tvb,
151 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
152void
153nvme_publish_to_cqe_link(proto_tree *tree, tvbuff_t *tvb,
154 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
155void
156nvme_publish_to_data_req_link(proto_tree *tree, tvbuff_t *tvb,
157 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
158void
159nvme_publish_to_data_resp_link(proto_tree *tree, tvbuff_t *tvb,
160 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
161void
162nvme_publish_link(proto_tree *tree, tvbuff_t *tvb, int hf_index,
163 uint32_t pkt_no, bool zero_ok);
164
165void nvme_update_cmd_end_info(packet_info *pinfo, struct nvme_cmd_ctx *cmd_ctx);
166
167void
168nvme_add_cmd_to_pending_list(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
169 struct nvme_cmd_ctx *cmd_ctx,
170 void *ctx, uint16_t cmd_id);
171void* nvme_lookup_cmd_in_pending_list(struct nvme_q_ctx *q_ctx, uint16_t cmd_id);
172
174{
175 uint64_t addr;
176 uint32_t key;
177 uint32_t size;
178};
179
180void
181dissect_nvmeof_fabric_cmd(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *nvme_tree,
182 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd, unsigned off, bool link_data_req);
183void
184dissect_nvmeof_cmd_data(tvbuff_t *data_tvb, packet_info *pinfo, proto_tree *data_tree,
185 unsigned pkt_off, struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd, unsigned len);
186void
187dissect_nvmeof_fabric_cqe(tvbuff_t *nvme_tvb, packet_info *pinfo,
188 proto_tree *nvme_tree,
189 struct nvme_cmd_ctx *cmd_ctx, unsigned off);
190
191void
192nvme_add_data_request(struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx,
193 struct keyed_data_req *req);
194
195struct nvme_cmd_ctx*
196nvme_lookup_data_request(struct nvme_q_ctx *q_ctx, struct keyed_data_req *req);
197
198void
199nvme_add_data_tr_pkt(struct nvme_q_ctx *q_ctx,
200 struct nvme_cmd_ctx *cmd_ctx, uint32_t rkey, uint32_t frame_num);
201struct nvme_cmd_ctx*
202nvme_lookup_data_tr_pkt(struct nvme_q_ctx *q_ctx,
203 uint32_t rkey, uint32_t frame_num);
204
205void
206nvme_add_data_tr_off(struct nvme_q_ctx *q_ctx, uint32_t off, uint32_t frame_num);
207
208uint32_t
209nvme_lookup_data_tr_off(struct nvme_q_ctx *q_ctx, uint32_t frame_num);
210
211void
212nvme_add_cmd_cqe_to_done_list(struct nvme_q_ctx *q_ctx,
213 struct nvme_cmd_ctx *cmd_ctx, uint16_t cmd_id);
214void*
215nvme_lookup_cmd_in_done_list(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
216 uint16_t cmd_id);
217
218void dissect_nvme_cmd_sgl(tvbuff_t *cmd_tvb, proto_tree *cmd_tree, int field_index,
219 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx, unsigned cmd_off, bool visited);
220
221void
222dissect_nvme_cmd(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
223 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx);
224
225void nvme_update_transfer_request(packet_info *pinfo, struct nvme_cmd_ctx *cmd_ctx, struct nvme_q_ctx *q_ctx);
226
227void
228dissect_nvme_data_response(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
229 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx, unsigned len, bool is_inline);
230
231void
232dissect_nvme_cqe(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
233 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx);
234
239const char *
240nvme_get_opcode_string(uint8_t opcode, uint16_t qid);
241
242/* CSTS.SHST shutdown-status names; shared with the NVMe-MI CHDS decode. */
243extern const value_string shst_table[];
244
253void
254nvme_dissect_admin_sqe_cdws(tvbuff_t *sqe_tvb, packet_info *pinfo,
255 proto_tree *tree, struct nvme_cmd_ctx *cmd_ctx);
256
265void
266nvme_dissect_admin_cqe_dw0(tvbuff_t *nvme_tvb, int dw0_off, proto_tree *cqe_tree,
267 uint16_t status, struct nvme_cmd_ctx *cmd_ctx);
268
275void
276nvme_dissect_cqe_status(tvbuff_t *nvme_tvb, int status_off, proto_tree *cqe_tree);
277
288bool
289nvme_dissect_admin_data_resp(tvbuff_t *nvme_tvb, proto_tree *cmd_tree,
290 struct nvme_cmd_ctx *cmd_ctx, unsigned off, unsigned len);
291
292/*
293 * Tells if opcode can be an opcode of io queue.
294 * Used to "Guess" queue type for nvme-tcp in case that "connect"
295 * command was not recorded
296 */
297int
298nvme_is_io_queue_opcode(uint8_t opcode);
299
300#endif
301
302/*
303 * Editor modelines - https://www.wireshark.org/tools/modelines.html
304 *
305 * Local variables:
306 * c-basic-offset: 4
307 * tab-width: 8
308 * indent-tabs-mode: nil
309 * End:
310 *
311 * vi: set shiftwidth=4 tabstop=8 expandtab:
312 * :indentSize=4:tabSize=8:noTabs=true:
313 */
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
struct _wmem_tree_t wmem_tree_t
Opaque type representing a red-black tree in the wmem system.
Definition wmem_tree.h:49
Definition packet-nvme.h:174
Definition nstime.h:26
Definition packet-nvme.h:91
Definition packet-nvme.h:80
struct _value_string value_string
Mapping between a 32-bit integer value and its string representation.