Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
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 struct nvme_q_ctx {
19  wmem_tree_t *pending_cmds;
20  wmem_tree_t *done_cmds;
21  wmem_tree_t *data_requests;
22  wmem_tree_t *data_responses;
23  guint16 qid;
24 };
25 
26 struct nvme_cmd_ctx {
27  guint32 cmd_pkt_num; /* pkt number of the cmd */
28  guint32 cqe_pkt_num; /* pkt number of the cqe */
29 
30  guint32 data_req_pkt_num;
31  guint32 data_resp_pkt_num;
32 
33  nstime_t cmd_start_time;
34  nstime_t cmd_end_time;
35  gboolean fabric; /* indicate whether cmd fabric type or not */
36 
37  guint8 opcode;
38  guint32 remote_key;
39  guint16 resp_type;
40 };
41 
42 void
43 nvme_publish_qid(proto_tree *tree, int field_index, guint16 qid);
44 
45 void
46 nvme_publish_cmd_latency(proto_tree *tree, struct nvme_cmd_ctx *cmd_ctx,
47  int field_index);
48 void
49 nvme_publish_cqe_to_cmd_link(proto_tree *cqe_tree, tvbuff_t *cqe_tvb,
50  int hf_index, struct nvme_cmd_ctx *cmd_ctx);
51 void
52 nvme_publish_cmd_to_cqe_link(proto_tree *cmd_tree, tvbuff_t *cqe_tvb,
53  int hf_index, struct nvme_cmd_ctx *cmd_ctx);
54 
55 void nvme_update_cmd_end_info(packet_info *pinfo, struct nvme_cmd_ctx *cmd_ctx);
56 
57 void
58 nvme_add_cmd_to_pending_list(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
59  struct nvme_cmd_ctx *cmd_ctx,
60  void *ctx, guint16 cmd_id);
61 void* nvme_lookup_cmd_in_pending_list(struct nvme_q_ctx *q_ctx, guint16 cmd_id);
62 
63 void nvme_add_data_request(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
64  struct nvme_cmd_ctx *cmd_ctx, void *ctx);
65 void* nvme_lookup_data_request(struct nvme_q_ctx *q_ctx, guint32 key);
66 
67 void
68 nvme_add_data_response(struct nvme_q_ctx *q_ctx,
69  struct nvme_cmd_ctx *cmd_ctx, guint32 rkey);
70 void*
71 nvme_lookup_data_response(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
72  guint32 rkey);
73 
74 void
75 nvme_add_cmd_cqe_to_done_list(struct nvme_q_ctx *q_ctx,
76  struct nvme_cmd_ctx *cmd_ctx, guint16 cmd_id);
77 void*
78 nvme_lookup_cmd_in_done_list(packet_info *pinfo, struct nvme_q_ctx *q_ctx,
79  guint16 cmd_id);
80 
81 void dissect_nvme_cmd_sgl(tvbuff_t *cmd_tvb, proto_tree *cmd_tree,
82  int field_index, struct nvme_cmd_ctx *cmd_ctx);
83 
84 void
85 dissect_nvme_cmd(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
86  struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx);
87 
88 void
89 dissect_nvme_data_response(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
90  struct nvme_q_ctx *q_ctx, struct nvme_cmd_ctx *cmd_ctx, guint len);
91 
92 void
93 dissect_nvme_cqe(tvbuff_t *nvme_tvb, packet_info *pinfo, proto_tree *root_tree,
94  struct nvme_cmd_ctx *cmd_ctx);
95 
96 #endif
97 
98 /*
99  * Editor modelines - http://www.wireshark.org/tools/modelines.html
100  *
101  * Local variables:
102  * c-basic-offset: 4
103  * tab-width: 8
104  * indent-tabs-mode: nil
105  * End:
106  *
107  * vi: set shiftwidth=4 tabstop=8 expandtab:
108  * :indentSize=4:tabSize=8:noTabs=true:
109  */
Definition: wmem_tree-int.h:47
Definition: packet-nvme.h:18
Definition: packet_info.h:44
Definition: tvbuff-int.h:35
Definition: nstime.h:27
Definition: proto.h:759
Definition: packet-nvme.h:26