Debian Codegraph @

ptl_ips/ips_proto_dump.c

raw ◀ ▶
1 Debian patch touch this file
1 /*
2 * Copyright (c) 2013. Intel Corporation. All rights reserved.
3 * Copyright (c) 2006-2012. QLogic Corporation. All rights reserved.
4 * Copyright (c) 2003-2006, PathScale, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35 #include "ips_proto.h"
36 #include "ips_proto_internal.h"
37 #include "ips_proto_header.h"
38 #include "ips_proto_help.h"
39 #include "ips_epstate.h"
40
41 void ips_proto_dump_frame(void *frame, int lenght, char *message)
42 {
43 uint8_t *raw_frame = frame;
44 int counter;
45 char default_message[] = "<UNKNOWN>";
46
47 if(!message)
48 message = default_message;
49
50 printf("\nHex dump of %i bytes at %p from %s\n", lenght, frame, message);
51
52 for(counter = 0; counter < lenght; counter++) {
53 if((counter % 16) == 0)
54 printf("\n");
55
56 if((counter % 4) == 0)
57 printf(" ");
58
59 printf("%02X ", raw_frame[counter]);
60 }
61 printf("\n");
62 }
63
64 void ips_proto_dump_data(void *data, int data_length)
65 {
66 int counter;
67 uint8_t *payload = (uint8_t *)data;
68
69 printf("\nHex dump of data, length = %i\n",
70 data_length);
71
72 for(counter = 0; counter < data_length; counter++) {
73 if((counter % 16) == 0)
74 printf("\n %04d: ", counter);
75
76 if((counter % 4) == 0)
77 printf(" ");
78
79 printf("%02X ", payload[counter]);
80 }
81 printf("\n");
82 }
83
84 void ips_proto_show_header(struct ips_message_header *p_hdr, char *msg)
85 {
86 uint32_t tid;
87 psm_protocol_type_t protocol;
88 psmi_seqnum_t ack_seq_num;
89
90 printf("\nHeader decoding %s\n",msg?msg:"");
91
92 printf("LRH: VL4-LVer4-SL4-Res2-LNH2: %x\n",
93 __be16_to_cpu(p_hdr->lrh[0]));
94 printf("LRH: DLID %x\n", __be16_to_cpu(p_hdr->lrh[1]));
95 printf("LRH: PktLen %i (0x%x)\n", __be16_to_cpu(p_hdr->lrh[2]),
96 __be16_to_cpu(p_hdr->lrh[2]));
97 printf("LRH: SLID %x\n", __be16_to_cpu(p_hdr->lrh[3]));
98 printf("BTH: OpCode8-SE1-M1-PC2-TVer4-Pkey16 %x\n",
99 __be32_to_cpu(p_hdr->bth[0]));
100 printf("BTH: R8-DestQP24 %x\n", __be32_to_cpu(p_hdr->bth[1]));
101 printf("BTH: AR1-Res7-PSN24 %x\n", __be32_to_cpu(p_hdr->bth[2]));
102 printf("IPH: chksum %x\n", __le16_to_cpu(p_hdr->iph.chksum));
103 printf("IPH: pkt_flags %x\n", __le16_to_cpu(
104 p_hdr->iph.pkt_flags) & INFINIPATH_KPF_INTR_HDRSUPP_MASK);
105 printf("IPH: ver %i\n",
106 (__le32_to_cpu(p_hdr->iph.ver_context_tid_offset)
107 >> INFINIPATH_I_VERS_SHIFT) & INFINIPATH_I_VERS_MASK);
108 printf("IPH: context %i\n",
109 (__le32_to_cpu(p_hdr->iph.ver_context_tid_offset)
110 >> INFINIPATH_I_CONTEXT_SHIFT) & INFINIPATH_I_CONTEXT_MASK);
111 printf("IPH: subcontext %i\n", p_hdr->dst_subcontext);
112 tid = (__le32_to_cpu(p_hdr->iph.ver_context_tid_offset)
113 >> INFINIPATH_I_TID_SHIFT) & INFINIPATH_I_TID_MASK;
114 printf("IPH: tid %x\n", tid);
115 printf("IPH: offset %x\n",
116 (__le32_to_cpu(p_hdr->iph.ver_context_tid_offset)
117 >> INFINIPATH_I_OFFSET_SHIFT) & INFINIPATH_I_OFFSET_MASK);
118
119 printf("sub-opcode %x\n", p_hdr->sub_opcode);
120
121 ack_seq_num.psn = p_hdr->ack_seq_num;
122 protocol = IPS_FLOWID_GET_PROTO(p_hdr->flowid);
123 if (protocol == PSM_PROTOCOL_GO_BACK_N)
124 printf("ack_seq_num %x\n", ack_seq_num.psn);
125 else
126 printf("TidFlow Flow: %x, Gen: %x, Seq: %x\n", ack_seq_num.flow, ack_seq_num.gen, ack_seq_num.seq);
127
128 printf("context %d (src_context %d src_context_ext %d) src_subcontext %d\n",
129 IPS_HEADER_SRCCONTEXT_GET(p_hdr), p_hdr->src_context, p_hdr->src_context_ext,
130 p_hdr->src_subcontext);
131 printf("src_rank/commidx %i\n", p_hdr->commidx |
132 INFINIPATH_KPF_RESERVED_BITS(p_hdr->iph.pkt_flags));
133 if (tid != IPATH_EAGER_TID_ID)
134 printf("expected_tid_session_id %i\n", p_hdr->data[0].u32w0);
135 printf("flags %x\n", p_hdr->flags);
136 printf("mqhdr %x\n", p_hdr->mqhdr);
137 }
138
139 // decode RHF errors; only used one place now, may want more later
140 void ips_proto_get_rhf_errstring(uint32_t err, char *msg, size_t len)
141 {
142 *msg = '\0'; // if no errors, and so don't need to check what's first
143
144 if(err & INFINIPATH_RHF_H_ICRCERR)
145 strlcat(msg, "icrcerr ", len);
146 if(err & INFINIPATH_RHF_H_VCRCERR)
147 strlcat(msg, "vcrcerr ", len);
148 if(err & INFINIPATH_RHF_H_PARITYERR)
149 strlcat(msg, "parityerr ", len);
150 if(err & INFINIPATH_RHF_H_LENERR)
151 strlcat(msg, "lenerr ", len);
152 if(err & INFINIPATH_RHF_H_MTUERR)
153 strlcat(msg, "mtuerr ", len);
154 if(err & INFINIPATH_RHF_H_IHDRERR)
155 strlcat(msg, "ipathhdrerr ", len);
156 if(err & INFINIPATH_RHF_H_TIDERR)
157 strlcat(msg, "tiderr ", len);
158 if(err & INFINIPATH_RHF_H_MKERR)
159 strlcat(msg, "mkerr ", len);
160 if(err & INFINIPATH_RHF_H_IBERR)
161 strlcat(msg, "iberr ", len);
162 if(err & INFINIPATH_RHF_L_SWA)
163 strlcat(msg, "swA ", len);
164 if(err & INFINIPATH_RHF_L_SWB)
165 strlcat(msg, "swB ", len);
166 }
167
168 void ips_proto_dump_err_stats(struct ips_proto *proto)
169 {
170 char err_stat_msg[2048];
171 char tmp_buf[128];
172 int len = sizeof(err_stat_msg);
173
174 if (!(infinipath_debug & __IPATH_PKTDBG))
175 return;
176
177 *err_stat_msg = '\0';
178
179 if (proto->error_stats.num_icrc_err ||
180 proto->error_stats.num_vcrc_err ||
181 proto->error_stats.num_ecc_err ||
182 proto->error_stats.num_len_err ||
183 proto->error_stats.num_mtu_err ||
184 proto->error_stats.num_khdr_err ||
185 proto->error_stats.num_tid_err ||
186 proto->error_stats.num_mk_err ||
187 proto->error_stats.num_ib_err) {
188
189 snprintf(tmp_buf, sizeof(tmp_buf), "ERROR STATS: ");
190
191 if (proto->error_stats.num_icrc_err) {
192 snprintf(tmp_buf, sizeof(tmp_buf), "ICRC: %"PRIu64" ", proto->error_stats.num_icrc_err);
193 strlcat(err_stat_msg, tmp_buf, len);
194 }
195
196 if (proto->error_stats.num_vcrc_err) {
197 snprintf(tmp_buf, sizeof(tmp_buf), "VCRC: %"PRIu64" ", proto->error_stats.num_vcrc_err);
198 strlcat(err_stat_msg, tmp_buf, len);
199 }
200
201 if (proto->error_stats.num_ecc_err) {
202 snprintf(tmp_buf, sizeof(tmp_buf), "ECC: %"PRIu64" ", proto->error_stats.num_ecc_err);
203 strlcat(err_stat_msg, tmp_buf, len);
204 }
205
206 if (proto->error_stats.num_len_err) {
207 snprintf(tmp_buf, sizeof(tmp_buf), "LEN: %"PRIu64" ", proto->error_stats.num_len_err);
208 strlcat(err_stat_msg, tmp_buf, len);
209 }
210
211 if (proto->error_stats.num_mtu_err) {
212 snprintf(tmp_buf, sizeof(tmp_buf), "MTU: %"PRIu64" ", proto->error_stats.num_mtu_err);
213 strlcat(err_stat_msg, tmp_buf, len);
214 }
215
216 if (proto->error_stats.num_khdr_err) {
217 snprintf(tmp_buf, sizeof(tmp_buf), "KHDR: %"PRIu64" ", proto->error_stats.num_khdr_err);
218 strlcat(err_stat_msg, tmp_buf, len);
219 }
220
221 if (proto->error_stats.num_tid_err) {
222 snprintf(tmp_buf, sizeof(tmp_buf), "TID: %"PRIu64" ", proto->error_stats.num_tid_err);
223 strlcat(err_stat_msg, tmp_buf, len);
224 }
225
226 if (proto->error_stats.num_mk_err) {
227 snprintf(tmp_buf, sizeof(tmp_buf), "MKERR: %"PRIu64" ", proto->error_stats.num_mk_err);
228 strlcat(err_stat_msg, tmp_buf, len);
229 }
230
231 if (proto->error_stats.num_ib_err) {
232 snprintf(tmp_buf, sizeof(tmp_buf), "IBERR: %"PRIu64" ", proto->error_stats.num_ib_err);
233 strlcat(err_stat_msg, tmp_buf, len);
234 }
235 strlcat(err_stat_msg, "\n", len);
236 }
237 else
238 strlcat(err_stat_msg, "No previous errors.\n", len);
239
240 _IPATH_ERROR("%s", err_stat_msg);
241 }
242