43 #define OCS_DEBUG_ENABLE(x) (x ? ~0 : 0)
46 #define OCS_DEBUG_MASK \
47 (OCS_DEBUG_ENABLE(1) & OCS_DEBUG_ALWAYS) | \
48 (OCS_DEBUG_ENABLE(0) & OCS_DEBUG_ENABLE_MQ_DUMP) | \
49 (OCS_DEBUG_ENABLE(0) & OCS_DEBUG_ENABLE_CQ_DUMP) | \
50 (OCS_DEBUG_ENABLE(0) & OCS_DEBUG_ENABLE_WQ_DUMP) | \
51 (OCS_DEBUG_ENABLE(0) & OCS_DEBUG_ENABLE_EQ_DUMP) | \
52 (OCS_DEBUG_ENABLE(0) & OCS_DEBUG_ENABLE_SPARAM_DUMP)
58 return ((c > 32) && (c < 127));
128 ocs_dump32(uint32_t mask, ocs_os_handle_t os,
const char *label,
void *buf, uint32_t buf_length)
130 uint32_t word_count = buf_length /
sizeof(uint32_t);
132 uint32_t columns = 8;
138 char *pbuf = linebuf;
144 ocs_log_info(os,
"%s\n", label);
147 while (word_count > 0) {
149 pbuf += ocs_snprintf(pbuf,
sizeof(linebuf) - (pbuf-linebuf),
"%08X: ", addr);
155 for (i = 0; i < n; i ++)
156 pbuf += ocs_snprintf(pbuf,
sizeof(linebuf) - (pbuf-linebuf),
"%08X ", wbuf[i]);
158 for (; i < columns; i ++)
159 pbuf += ocs_snprintf(pbuf,
sizeof(linebuf) - (pbuf-linebuf),
"%8s ",
"");
161 pbuf += ocs_snprintf(pbuf,
sizeof(linebuf) - (pbuf-linebuf),
" ");
163 for (i = 0; i < n*
sizeof(uint32_t); i ++)
164 pbuf += ocs_snprintf(pbuf,
sizeof(linebuf) - (pbuf-linebuf),
"%c",
_isprint(cbuf[i]) ? cbuf[i] :
'.');
165 pbuf += ocs_snprintf(pbuf,
sizeof(linebuf) - (pbuf-linebuf),
"\n");
167 ocs_log_info(os,
"%s", linebuf);
171 addr += n*
sizeof(uint32_t);
176 #if defined(OCS_DEBUG_QUEUE_HISTORY)
179 #define OCS_Q_HIST_WQE_WORD_MASK_DEFAULT (BIT(4) | BIT(6) | BIT(7) | BIT(9) | BIT(12))
180 #define OCS_Q_HIST_TRECV_CONT_WQE_WORD_MASK (BIT(4) | BIT(5) | BIT(6) | BIT(7) | BIT(9) | BIT(12))
181 #define OCS_Q_HIST_IWRITE_WQE_WORD_MASK (BIT(4) | BIT(5) | BIT(6) | BIT(7) | BIT(9))
182 #define OCS_Q_HIST_IREAD_WQE_WORD_MASK (BIT(4) | BIT(6) | BIT(7) | BIT(9))
183 #define OCS_Q_HIST_ABORT_WQE_WORD_MASK (BIT(3) | BIT(7) | BIT(8) | BIT(9))
184 #define OCS_Q_HIST_WCQE_WORD_MASK (BIT(0) | BIT(3))
185 #define OCS_Q_HIST_WCQE_WORD_MASK_ERR (BIT(0) | BIT(1) | BIT(2) | BIT(3))
186 #define OCS_Q_HIST_CQXABT_WORD_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3))
189 #define OCS_Q_HIST_ENABLE_Q_INFO 0
190 uint8_t ocs_queue_history_q_info_enabled(
void)
192 return OCS_Q_HIST_ENABLE_Q_INFO;
196 #define OCS_Q_HIST_ENABLE_TIMESTAMPS 0
197 uint8_t ocs_queue_history_timestamp_enabled(
void)
199 return OCS_Q_HIST_ENABLE_TIMESTAMPS;
203 ocs_q_hist_wqe_mask_t ocs_q_hist_wqe_masks[] = {
212 ocs_q_hist_cqe_mask_t ocs_q_hist_cqe_masks[] = {
214 {
SLI_QENTRY_WQ, OCS_Q_HIST_TYPE_CWQE, OCS_Q_HIST_WCQE_WORD_MASK, OCS_Q_HIST_WCQE_WORD_MASK_ERR},
215 {
SLI_QENTRY_XABT, OCS_Q_HIST_TYPE_CXABT, OCS_Q_HIST_CQXABT_WORD_MASK, OCS_Q_HIST_WCQE_WORD_MASK},
221 for (i = 0; i < ARRAY_SIZE(ocs_q_hist_wqe_masks); i++) {
222 if (ocs_q_hist_wqe_masks[i].command == wqe->
command) {
223 return ocs_q_hist_wqe_masks[i].mask;
227 return OCS_Q_HIST_WQE_WORD_MASK_DEFAULT;
243 if (q_hist->q_hist != NULL) {
245 ocs_log_debug(ocs,
"q_hist not NULL, skipping init\n");
249 q_hist->q_hist = ocs_malloc(ocs,
sizeof(*q_hist->q_hist) * OCS_Q_HIST_SIZE,
250 OCS_M_ZERO | OCS_M_NOWAIT | OCS_M_NONUMA);
251 if (q_hist->q_hist == NULL) {
252 ocs_log_err(ocs,
"Could not allocate queue history buffer\n");
254 ocs_lock_init(ocs, &q_hist->q_hist_lock,
"queue history lock[%d]",
ocs_instance(ocs));
257 q_hist->q_hist_index = 0;
271 ocs_t *ocs = q_hist->ocs;
273 if (q_hist->q_hist != NULL) {
274 ocs_free(ocs, q_hist->q_hist,
sizeof(*q_hist->q_hist)*OCS_Q_HIST_SIZE);
275 ocs_lock_free(&q_hist->q_hist_lock);
276 q_hist->q_hist = NULL;
281 ocs_queue_history_add_q_info(ocs_hal_q_hist_t *q_hist, uint32_t qid, uint32_t qindex)
283 if (ocs_queue_history_q_info_enabled()) {
285 q_hist->q_hist[q_hist->q_hist_index] = (qid << 16) | qindex;
286 q_hist->q_hist_index++;
287 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE;
292 ocs_queue_history_add_timestamp(ocs_hal_q_hist_t *q_hist)
294 if (ocs_queue_history_timestamp_enabled()) {
297 tsc_value = ocs_get_tsc();
298 q_hist->q_hist[q_hist->q_hist_index] = ((tsc_value >> 32 ) & 0xFFFFFFFF);
299 q_hist->q_hist_index++;
300 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE;
301 q_hist->q_hist[q_hist->q_hist_index] = (tsc_value & 0xFFFFFFFF);
302 q_hist->q_hist_index++;
303 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE;
322 ocs_q_hist_ftr_t ftr;
325 if (q_hist->q_hist == NULL) {
331 ftr.s.type = OCS_Q_HIST_TYPE_WQE;
332 ocs_lock(&q_hist->q_hist_lock);
334 for (i = ((
sizeof(wqe_word_mask)*8) - 1); i >= 0; i--){
335 if ((wqe_word_mask >> i) & 1) {
336 q_hist->q_hist[q_hist->q_hist_index] = entryw[i];
337 q_hist->q_hist_index++;
338 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE;
342 ocs_queue_history_add_q_info(q_hist, qid, qindex);
343 ocs_queue_history_add_timestamp(q_hist);
347 ftr.s.mask = wqe_word_mask;
348 q_hist->q_hist[q_hist->q_hist_index] = ftr.word;
349 q_hist->q_hist_index++;
350 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE;
353 ocs_unlock(&q_hist->q_hist_lock);
370 ocs_q_hist_ftr_t ftr;
373 if (q_hist->q_hist == NULL) {
379 ftr.s.type = OCS_Q_HIST_TYPE_MISC;
380 ocs_lock(&q_hist->q_hist_lock);
382 for (i = num_words-1; i >= 0; i--) {
383 q_hist->q_hist[q_hist->q_hist_index] = entryw[i];
384 q_hist->q_hist_index++;
385 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE;
389 ocs_queue_history_add_timestamp(q_hist);
394 q_hist->q_hist[q_hist->q_hist_index] = ftr.word;
395 q_hist->q_hist_index++;
396 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE;
399 ocs_unlock(&q_hist->q_hist_lock);
417 ocs_queue_history_cqe(ocs_hal_q_hist_t *q_hist, uint8_t ctype, uint32_t *entryw, uint8_t status, uint32_t qid, uint32_t qindex)
421 uint32_t cqe_word_mask = 0;
422 ocs_q_hist_ftr_t ftr;
424 if (q_hist->q_hist == NULL) {
430 for (j = 0; j < ARRAY_SIZE(ocs_q_hist_cqe_masks); j++) {
431 if (ocs_q_hist_cqe_masks[j].ctype == ctype) {
432 ftr.s.type = ocs_q_hist_cqe_masks[j].type;
434 cqe_word_mask = ocs_q_hist_cqe_masks[j].mask_err;
436 cqe_word_mask = ocs_q_hist_cqe_masks[j].mask;
440 ocs_lock(&q_hist->q_hist_lock);
442 for (i = ((
sizeof(cqe_word_mask)*8) - 1); i >= 0; i--){
443 if ((cqe_word_mask >> i) & 1) {
444 q_hist->q_hist[q_hist->q_hist_index] = entryw[i];
445 q_hist->q_hist_index++;
446 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE;
449 ocs_queue_history_add_q_info(q_hist, qid, qindex);
450 ocs_queue_history_add_timestamp(q_hist);
454 ftr.s.mask = cqe_word_mask;
455 q_hist->q_hist[q_hist->q_hist_index] = ftr.word;
456 q_hist->q_hist_index++;
457 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE;
460 ocs_unlock(&q_hist->q_hist_lock);
469 ocs_queue_history_prev_index(uint32_t index)
472 return OCS_Q_HIST_SIZE - 1;
478 #endif // OCS_DEBUG_QUEUE_HISTORY
499 if (sparams == NULL) {
505 if (prelabel != NULL) {
506 ocs_snprintf(label,
sizeof(label),
"[%s] sparam: %s", prelabel, reqlabel);
508 ocs_snprintf(label,
sizeof(label),
"sparam: %s", reqlabel);
#define ocs_queue_history_misc(...)
uint32_t ocs_instance(void *os)
Return instance index of an opaque ocs structure.
#define SLI4_WQE_FCP_CONT_TRECEIVE64
static int _isprint(int c)
#define ocs_queue_history_wq(...)
#define ocs_queue_history_init(...)
#define OCS_DEBUG_ENABLE_SPARAM_DUMP
#define ocs_queue_history_cqe(...)
const char const char void ocs_ddump_buffer(ocs_textbuf_t *textbuf, const char *name, uint32_t instance, void *buffer, uint32_t size)
Generate driver dump data for an arbitrary buffer of DWORDS.
void ocs_display_sparams(const char *prelabel, const char *reqlabel, int dest, void *textbuf, void *sparams)
Display service parameters.
void ocs_dump32(uint32_t mask, ocs_os_handle_t os, const char *label, void *buf, uint32_t buf_length)
Dump 32 bit hex/ascii data.
#define SLI4_WQE_FCP_IREAD64
#define ocs_queue_history_free(...)
void ocs_debug_enable(uint32_t mask)
enable debug options
int ocs_debug_is_enabled(uint32_t mask)
return true if debug bits are enabled
#define SLI4_WQE_FCP_IWRITE64
static uint32_t ocs_debug_mask
void ocs_debug_disable(uint32_t mask)
disable debug options