2 * data structures for NVMe Dissection
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
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
;
36 #define NVME_CMD_MAX_TRS (16)
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 */
59 unsigned tr_sub_entries
;
78 uint8_t fctype
; /* fabric cmd type */
84 extern int hf_nvmeof_cmd_pkt
;
85 extern int hf_nvmeof_data_req
;
87 const char *get_nvmeof_cmd_string(uint8_t fctype
);
90 nvme_publish_qid(proto_tree
*tree
, int field_index
, uint16_t qid
);
93 nvme_publish_cmd_latency(proto_tree
*tree
, struct nvme_cmd_ctx
*cmd_ctx
,
96 nvme_publish_to_cmd_link(proto_tree
*tree
, tvbuff_t
*tvb
,
97 int hf_index
, struct nvme_cmd_ctx
*cmd_ctx
);
99 nvme_publish_to_cqe_link(proto_tree
*tree
, tvbuff_t
*tvb
,
100 int hf_index
, struct nvme_cmd_ctx
*cmd_ctx
);
102 nvme_publish_to_data_req_link(proto_tree
*tree
, tvbuff_t
*tvb
,
103 int hf_index
, struct nvme_cmd_ctx
*cmd_ctx
);
105 nvme_publish_to_data_resp_link(proto_tree
*tree
, tvbuff_t
*tvb
,
106 int hf_index
, struct nvme_cmd_ctx
*cmd_ctx
);
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
);
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
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
);
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
);
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
);
138 nvme_add_data_request(struct nvme_q_ctx
*q_ctx
, struct nvme_cmd_ctx
*cmd_ctx
,
139 struct keyed_data_req
*req
);
142 nvme_lookup_data_request(struct nvme_q_ctx
*q_ctx
, struct keyed_data_req
*req
);
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
);
148 nvme_lookup_data_tr_pkt(struct nvme_q_ctx
*q_ctx
,
149 uint32_t rkey
, uint32_t frame_num
);
152 nvme_add_data_tr_off(struct nvme_q_ctx
*q_ctx
, uint32_t off
, uint32_t frame_num
);
155 nvme_lookup_data_tr_off(struct nvme_q_ctx
*q_ctx
, uint32_t frame_num
);
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
);
161 nvme_lookup_cmd_in_done_list(packet_info
*pinfo
, struct nvme_q_ctx
*q_ctx
,
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
);
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
);
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
);
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
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
);
199 * Editor modelines - https://www.wireshark.org/tools/modelines.html
204 * indent-tabs-mode: nil
207 * vi: set shiftwidth=4 tabstop=8 expandtab:
208 * :indentSize=4:tabSize=8:noTabs=true: