| Wireshark 4.7.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 <gerald@wireshark.org>
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 struct 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
38 struct nvme_cmd_ctx {
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 uint64_t off;
57 unsigned records;
58 unsigned tr_rcrd_id;
59 unsigned tr_off;
60 unsigned tr_sub_entries;
61 uint16_t lsi;
62 uint8_t lid;
63 uint8_t lsp;
64 uint8_t uid_idx;
65 uint8_t tr_type;
66 } get_logpage;
67 struct {
68 uint8_t fid;
69 } set_features;
70 struct {
71 union {
72 struct {
73 uint8_t offset;
74 } prop_get;
75 struct {
76 uint16_t qid;
77 } cnct;
78 };
79 uint8_t fctype; /* fabric cmd type */
80 } fabric_cmd;
81 } cmd_ctx;
82 uint8_t opcode;
83};
84
85 extern int hf_nvmeof_cmd_pkt;
86 extern int hf_nvmeof_data_req;
87
88 const char *get_nvmeof_cmd_string(uint8_t fctype);
89
90 void
91nvme_publish_qid(proto_tree *tree, int field_index, uint16_t qid);
92
93 void
94nvme_publish_cmd_latency(proto_tree *tree, struct nvme_cmd_ctx *cmd_ctx,
95 int field_index);
96 void
97nvme_publish_to_cmd_link(proto_tree *tree, tvbuff_t *tvb,
98 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
99 void
100nvme_publish_to_cqe_link(proto_tree *tree, tvbuff_t *tvb,
101 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
102 void
103nvme_publish_to_data_req_link(proto_tree *tree, tvbuff_t *tvb,
104 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
105 void
106nvme_publish_to_data_resp_link(proto_tree *tree, tvbuff_t *tvb,
107 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
108 void
109nvme_publish_link(proto_tree *tree, tvbuff_t *tvb, int hf_index,
110 uint32_t pkt_no, bool zero_ok);
111
112 void nvme_update_cmd_end_info(packet_info *pinfo, struct nvme_cmd_ctx *cmd_ctx);
113
114 void
115nvme_add_cmd_to_pending_list(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
116 struct nvme_cmd_ctx *cmd_ctx,
117 void *ctx, uint16_t cmd_id);
118 void* nvme_lookup_cmd_in_pending_list(struct nvme_q_ctx *q_ctx, uint16_t cmd_id);
119
120 struct keyed_data_req
121{
122 uint64_t addr;
123 uint32_t key;
124 uint32_t size;
125};
126
127 void
128dissect_nvmeof_fabric_cmd(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *nvme_tree,
129 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd, unsigned off, bool link_data_req);
130 void
131dissect_nvmeof_cmd_data(tvbuff_t *data_tvb, packet_info *pinfo, proto_tree *data_tree,
132 unsigned pkt_off, struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd, unsigned len);
133 void
134dissect_nvmeof_fabric_cqe(tvbuff_t *nvme_tvb, packet_info *pinfo,
135 proto_tree *nvme_tree,
136 struct nvme_cmd_ctx *cmd_ctx, unsigned off);
137
138 void
139nvme_add_data_request(struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx,
140 struct keyed_data_req *req);
141
142 struct nvme_cmd_ctx*
143nvme_lookup_data_request(struct nvme_q_ctx *q_ctx, struct keyed_data_req *req);
144
145 void
146nvme_add_data_tr_pkt(struct nvme_q_ctx *q_ctx,
147 struct nvme_cmd_ctx *cmd_ctx, uint32_t rkey, uint32_t frame_num);
148 struct nvme_cmd_ctx*
149nvme_lookup_data_tr_pkt(struct nvme_q_ctx *q_ctx,
150 uint32_t rkey, uint32_t frame_num);
151
152 void
153nvme_add_data_tr_off(struct nvme_q_ctx *q_ctx, uint32_t off, uint32_t frame_num);
154
155uint32_t
156nvme_lookup_data_tr_off(struct nvme_q_ctx *q_ctx, uint32_t frame_num);
157
158 void
159nvme_add_cmd_cqe_to_done_list(struct nvme_q_ctx *q_ctx,
160 struct nvme_cmd_ctx *cmd_ctx, uint16_t cmd_id);
161 void*
162nvme_lookup_cmd_in_done_list(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
163 uint16_t cmd_id);
164
165 void dissect_nvme_cmd_sgl(tvbuff_t *cmd_tvb, proto_tree *cmd_tree, int field_index,
166 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx, unsigned cmd_off, bool visited);
167
168 void
169dissect_nvme_cmd(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
170 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx);
171
172 void nvme_update_transfer_request(packet_info *pinfo, struct nvme_cmd_ctx *cmd_ctx, struct nvme_q_ctx *q_ctx);
173
174 void
175dissect_nvme_data_response(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
176 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx, unsigned len, bool is_inline);
177
178 void
179dissect_nvme_cqe(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
180 struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx);
181
186 const char *
187nvme_get_opcode_string(uint8_t opcode, uint16_t qid);
188
189/*
190 * Tells if opcode can be an opcode of io queue.
191 * Used to "Guess" queue type for nvme-tcp in case that "connect"
192 * command was not recorded
193 */
194 int
195nvme_is_io_queue_opcode(uint8_t opcode);
196
197#endif
198
199/*
200 * Editor modelines - https://www.wireshark.org/tools/modelines.html
201 *
202 * Local variables:
203 * c-basic-offset: 4
204 * tab-width: 8
205 * indent-tabs-mode: nil
206 * End:
207 *
208 * vi: set shiftwidth=4 tabstop=8 expandtab:
209 * :indentSize=4:tabSize=8:noTabs=true:
210 */
_packet_info
Definition packet_info.h:43
_proto_node
Definition proto.h:905
_wmem_tree_t
Internal representation of a wmem balanced tree.
Definition wmem_tree-int.h:81
keyed_data_req
Definition packet-nvme.h:121
nstime_t
Definition nstime.h:26
nvme_cmd_ctx
Definition packet-nvme.h:38
nvme_q_ctx
Definition packet-nvme.h:27
tvbuff
Definition tvbuff-int.h:36