epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-nvme.h
blobba178127564d00bda13f12b2bf26e9e4b48de3d0
1 /* packet-nvme.h
2 * data structures for NVMe Dissection
3 * Copyright 2016
4 * Code by Parav Pandit
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef _PACKET_NVME_H_
13 #define _PACKET_NVME_H_
15 #define NVME_CMD_SIZE 64
16 #define NVME_CQE_SIZE 16
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
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;
36 #define NVME_CMD_MAX_TRS (16)
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 */
42 uint32_t data_req_pkt_num;
43 uint32_t data_tr_pkt_num[NVME_CMD_MAX_TRS];
44 uint32_t first_tr_psn;
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 */
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;
78 uint8_t fctype; /* fabric cmd type */
79 } fabric_cmd;
80 } cmd_ctx;
81 uint8_t opcode;
84 extern int hf_nvmeof_cmd_pkt;
85 extern int hf_nvmeof_data_req;
87 const char *get_nvmeof_cmd_string(uint8_t fctype);
89 void
90 nvme_publish_qid(proto_tree *tree, int field_index, uint16_t qid);
92 void
93 nvme_publish_cmd_latency(proto_tree *tree, struct nvme_cmd_ctx *cmd_ctx,
94 int field_index);
95 void
96 nvme_publish_to_cmd_link(proto_tree *tree, tvbuff_t *tvb,
97 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
98 void
99 nvme_publish_to_cqe_link(proto_tree *tree, tvbuff_t *tvb,
100 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
101 void
102 nvme_publish_to_data_req_link(proto_tree *tree, tvbuff_t *tvb,
103 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
104 void
105 nvme_publish_to_data_resp_link(proto_tree *tree, tvbuff_t *tvb,
106 int hf_index, struct nvme_cmd_ctx *cmd_ctx);
107 void
108 nvme_publish_link(proto_tree *tree, tvbuff_t *tvb, int hf_index,
109 uint32_t pkt_no, bool zero_ok);
111 void nvme_update_cmd_end_info(packet_info *pinfo, struct nvme_cmd_ctx *cmd_ctx);
113 void
114 nvme_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);
117 void* nvme_lookup_cmd_in_pending_list(struct nvme_q_ctx *q_ctx, uint16_t cmd_id);
119 struct keyed_data_req
121 uint64_t addr;
122 uint32_t key;
123 uint32_t size;
126 void
127 dissect_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);
129 void
130 dissect_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);
132 void
133 dissect_nvmeof_fabric_cqe(tvbuff_t *nvme_tvb, packet_info *pinfo,
134 proto_tree *nvme_tree,
135 struct nvme_cmd_ctx *cmd_ctx, unsigned off);
137 void
138 nvme_add_data_request(struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx,
139 struct keyed_data_req *req);
141 struct nvme_cmd_ctx*
142 nvme_lookup_data_request(struct nvme_q_ctx *q_ctx, struct keyed_data_req *req);
144 void
145 nvme_add_data_tr_pkt(struct nvme_q_ctx *q_ctx,
146 struct nvme_cmd_ctx *cmd_ctx, uint32_t rkey, uint32_t frame_num);
147 struct nvme_cmd_ctx*
148 nvme_lookup_data_tr_pkt(struct nvme_q_ctx *q_ctx,
149 uint32_t rkey, uint32_t frame_num);
151 void
152 nvme_add_data_tr_off(struct nvme_q_ctx *q_ctx, uint32_t off, uint32_t frame_num);
154 uint32_t
155 nvme_lookup_data_tr_off(struct nvme_q_ctx *q_ctx, uint32_t frame_num);
157 void
158 nvme_add_cmd_cqe_to_done_list(struct nvme_q_ctx *q_ctx,
159 struct nvme_cmd_ctx *cmd_ctx, uint16_t cmd_id);
160 void*
161 nvme_lookup_cmd_in_done_list(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
162 uint16_t cmd_id);
164 void 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);
167 void
168 dissect_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);
171 void nvme_update_transfer_request(packet_info *pinfo, struct nvme_cmd_ctx *cmd_ctx, struct nvme_q_ctx *q_ctx);
173 void
174 dissect_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);
177 void
178 dissect_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);
182 * Returns string representation of opcode according
183 * to opcode and queue id
185 const char *
186 nvme_get_opcode_string(uint8_t opcode, uint16_t qid);
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
194 nvme_is_io_queue_opcode(uint8_t opcode);
196 #endif
199 * Editor modelines - https://www.wireshark.org/tools/modelines.html
201 * Local variables:
202 * c-basic-offset: 4
203 * tab-width: 8
204 * indent-tabs-mode: nil
205 * End:
207 * vi: set shiftwidth=4 tabstop=8 expandtab:
208 * :indentSize=4:tabSize=8:noTabs=true: