qla2x00.c
来自「这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自」· C语言 代码 · 共 2,417 行 · 第 1/5 页
C
2,417 行
QLA2100_VERSION); len += size; size = sprintf(PROC_BUF, "Entry address = %p\n",qla2x00_set_info); len += size; tmp_sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1; size = sprintf(PROC_BUF, "HBA: %s, Serial# %c%05d\n", bdp->bdName, ('A' + tmp_sn/100000), (tmp_sn%100000)); len += size; size = sprintf(PROC_BUF, "Request Queue = 0x%lx, Response Queue = 0x%lx\n", (long unsigned int)ha->request_dma, (long unsigned int)ha->response_dma); len += size; size = sprintf(PROC_BUF, "Request Queue count= %ld, Response Queue count= %ld\n", (long)REQUEST_ENTRY_CNT, (long)RESPONSE_ENTRY_CNT); len += size; size = sprintf(PROC_BUF, "Total number of active commands = %ld\n", ha->actthreads); len += size; size = sprintf(PROC_BUF, "Total number of interrupts = %ld\n", (long)ha->total_isr_cnt); len += size;#if defined(FC_IP_SUPPORT) size = sprintf(PROC_BUF, "Total number of active IP commands = %ld\n", ha->ipreq_cnt); len += size;#endif#if defined(IOCB_HIT_RATE) size = sprintf(PROC_BUF, "Total number of IOCBs (used/max/#hit) " "= (%d/%d/%d)\n", (int)ha->iocb_cnt, (int)ha->iocb_hiwat, (int)ha->iocb_overflow_cnt);#else size = sprintf(PROC_BUF, "Total number of IOCBs (used/max) " "= (%d/%d)\n", (int)ha->iocb_cnt, (int)ha->iocb_hiwat);#endif len += size; size = sprintf(PROC_BUF, "Total number of queued commands = %d\n", (max_srbs - ha->srb_cnt)); len += size; size = sprintf(PROC_BUF, " Device queue depth = 0x%x\n", (ql2xmaxqdepth == 0) ? 16 : ql2xmaxqdepth); len += size; size = sprintf(PROC_BUF, "Number of free request entries = %d\n", ha->req_q_cnt); len += size; size = sprintf(PROC_BUF, "Number of mailbox timeouts = %ld\n", qla2x00_stats.mboxtout); len += size; size = sprintf(PROC_BUF, "Number of ISP aborts = %ld\n",qla2x00_stats.ispAbort); len += size; size = sprintf(PROC_BUF, "Number of loop resyncs = %ld\n", qla2x00_stats.loop_resync); len += size; size = sprintf(PROC_BUF, "Number of retries for empty slots = %ld\n", qla2x00_stats.outarray_full); len += size; size = sprintf(PROC_BUF, "Number of reqs in pending_q= %ld, retry_q= %d, " "done_q= %ld, scsi_retry_q= %d\n", ha->qthreads, ha->retry_q_cnt, ha->done_q_cnt, ha->scsi_retry_q_cnt); len += size;#if MPIO_SUPPORT size = sprintf(PROC_BUF, "Number of reqs in failover_q= %d\n", ha->failover_cnt); len += size;#endif flags = (unsigned long *) &ha->flags; if (ha->loop_state == LOOP_DOWN) loop_state = "DOWN"; else if (ha->loop_state ==LOOP_UP) loop_state = "UP"; else if (ha->loop_state ==LOOP_READY) loop_state = "READY"; else if (ha->loop_state ==LOOP_TIMEOUT) loop_state = "TIMEOUT"; else if (ha->loop_state ==LOOP_UPDATE) loop_state = "UPDATE"; else loop_state = "UNKNOWN"; size = sprintf(PROC_BUF, "Host adapter:loop state= <%s>, flags= 0x%lx\n", loop_state , *flags); len += size; size = sprintf(PROC_BUF, "Dpc flags = 0x%lx\n",ha->dpc_flags); len += size; size = sprintf(PROC_BUF, "MBX flags = 0x%x\n",ha->mbx_flags); len += size; size = sprintf(PROC_BUF, "SRB Free Count = %d\n",ha->srb_cnt); len += size; size = sprintf(PROC_BUF, "Port down retry = %3.3d\n", ha->port_down_retry_count); len += size; size = sprintf(PROC_BUF, "\n"); len += size;#if REQ_TRACE if (qla2x00_req_dmp) { size = sprintf(PROC_BUF, "Outstanding Commands on controller:\n"); len += size; for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { if ((sp = ha->outstanding_cmds[i]) == NULL) continue; if ((cp = sp->cmd) == NULL) continue; size = sprintf(PROC_BUF, "(%d): Pid=%d, sp flags=0x%lx" ", cmd=0x%p, state=%d\n", i, (int)sp->cmd->serial_number, (long)sp->flags, CMD_SP(sp->cmd), (int)sp->state); len += size; if (len >= qla2x00_buffer_size - 256) goto profile_stop; } }#endif /* REQ_TRACE */ if (qla2x00_retryq_dmp) { if (!list_empty(&ha->retry_queue)) { size = sprintf(PROC_BUF, "qla%ld: Retry queue requests:\n", ha->host_no); len += size; spin_lock_irqsave(&ha->list_lock, cpu_flags); i = 0; list_for_each_safe(list, temp, &ha->retry_queue) { sp = list_entry(list, srb_t, list); t = SCSI_TCN_32(sp->cmd); l = SCSI_LUN_32(sp->cmd); size = sprintf(PROC_BUF, "%d: target=%d, lun=%d, " "pid=%ld sp=%p, sp->flags=0x%x," "sp->state= %d\n", i, t, l, sp->cmd->serial_number, sp, sp->flags, sp->state ); len += size; i++; if (len >= qla2x00_buffer_size - 256) goto profile_stop; } spin_unlock_irqrestore(&ha->list_lock, cpu_flags); } /* if (!list_empty(&ha->retry_queue))*/ } /* if ( qla2x00_retryq_dmp ) */ /* 2.25 node/port display to proc */ /* Display the node name for adapter */ size = sprintf(PROC_BUF, "\nSCSI Device Information:\n"); len += size; size = sprintf(PROC_BUF, "scsi-qla%d-adapter-node=" "%02x%02x%02x%02x%02x%02x%02x%02x;\n", (int)ha->instance, ha->init_cb->node_name[0], ha->init_cb->node_name[1], ha->init_cb->node_name[2], ha->init_cb->node_name[3], ha->init_cb->node_name[4], ha->init_cb->node_name[5], ha->init_cb->node_name[6], ha->init_cb->node_name[7]); len += size; /* display the port name for adapter */ size = sprintf(PROC_BUF, "scsi-qla%d-adapter-port=" "%02x%02x%02x%02x%02x%02x%02x%02x;\n", (int)ha->instance, ha->init_cb->port_name[0], ha->init_cb->port_name[1], ha->init_cb->port_name[2], ha->init_cb->port_name[3], ha->init_cb->port_name[4], ha->init_cb->port_name[5], ha->init_cb->port_name[6], ha->init_cb->port_name[7]); len += size; /* Print out device port names */ for (i = 0; i < MAX_FIBRE_DEVICES; i++) { if (ha->fc_db[i].loop_id == PORT_UNUSED) continue; if (ha->flags.failover_enabled) { size = sprintf(PROC_BUF, "scsi-qla%d-port-%d=" "%02x%02x%02x%02x%02x%02x%02x%02x:" "%02x%02x%02x%02x%02x%02x%02x%02x;\n", (int)ha->instance, i, ha->fc_db[i].name[0], ha->fc_db[i].name[1], ha->fc_db[i].name[2], ha->fc_db[i].name[3], ha->fc_db[i].name[4], ha->fc_db[i].name[5], ha->fc_db[i].name[6], ha->fc_db[i].name[7], ha->fc_db[i].wwn[0], ha->fc_db[i].wwn[1], ha->fc_db[i].wwn[2], ha->fc_db[i].wwn[3], ha->fc_db[i].wwn[4], ha->fc_db[i].wwn[5], ha->fc_db[i].wwn[6], ha->fc_db[i].wwn[7]); } else {#if USE_PORTNAME /* updated to use conditional compile */ size = sprintf(PROC_BUF, "scsi-qla%d-target-%d=" "%02x%02x%02x%02x%02x%02x%02x%02x;\n", (int)ha->instance, i, ha->fc_db[i].wwn[0], ha->fc_db[i].wwn[1], ha->fc_db[i].wwn[2], ha->fc_db[i].wwn[3], ha->fc_db[i].wwn[4], ha->fc_db[i].wwn[5], ha->fc_db[i].wwn[6], ha->fc_db[i].wwn[7]);#else size = sprintf(PROC_BUF, "scsi-qla%d-target-%d=" "%02x%02x%02x%02x%02x%02x%02x%02x;\n", (int)ha->instance, i, ha->fc_db[i].name[0], ha->fc_db[i].name[1], ha->fc_db[i].name[2], ha->fc_db[i].name[3], ha->fc_db[i].name[4], ha->fc_db[i].name[5], ha->fc_db[i].name[6], ha->fc_db[i].name[7]);#endif /* USE_PORT_NAME */ } len += size; } /* 2.25 node/port display to proc */ size = sprintf(PROC_BUF, "\nSCSI LUN Information:\n"); len += size; size = sprintf(PROC_BUF, "(Id:Lun)\n"); len += size; /* scan for all equipment stats */ for (t = 0; t < MAX_FIBRE_DEVICES; t++) { /* valid target */ if (ha->fc_db[t].loop_id == PORT_UNUSED) continue; /* scan all luns */ for (l = 0; l < ha->max_luns; l++) { up = (os_lun_t *) GET_LU_Q(ha, t, l); if (up == NULL) continue; if (up->io_cnt == 0 || #if SHOW_ONLY_SCSI_SCANNED_LUNS up->io_cnt < 3 ||#endif up->fclun == NULL) continue; size = sprintf(PROC_BUF, "(%2d:%2d): Total reqs %ld,", t,l,up->io_cnt); len += size; size = sprintf(PROC_BUF, " Pending reqs %ld,", up->out_cnt); len += size; if (up->io_cnt < 3) { size = sprintf(PROC_BUF, " flags 0x%x*,", (int)up->q_flag); } else { size = sprintf(PROC_BUF, " flags 0x%x,", (int)up->q_flag); } len += size; size = sprintf(PROC_BUF, " %ld:%d:%02x,", up->fclun->fcport->ha->instance, up->fclun->fcport->cur_path, up->fclun->fcport->loop_id); len += size; size = sprintf(PROC_BUF, "\n"); len += size; if (len >= qla2x00_buffer_size - 256) goto profile_stop; } if (len >= qla2x00_buffer_size - 256) break; }profile_stop: if (len >= qla2x00_buffer_size) { printk(KERN_WARNING "qla2x00: Overflow buffer at line %d\n", __LINE__); } if (offset > len - 1 ) { kfree(qla2x00_buffer); qla2x00_buffer = NULL; qla2x00_buffer_size = length = 0; *start = NULL; } else { *start = buffer; if (len - offset < length) { length = len - offset; } memcpy(buffer, &qla2x00_buffer[offset], length); } DEBUG3(printk(KERN_INFO "Exiting proc_info: qlabuff=%p, offset=0x%lx, " "length=0x%x\n", qla2x00_buffer, offset, length);)#if QLA2100_LIPTEST qla2x00_lip = 1;#endif#else return (0);#endif /* QLA2100_PROFILE */ return (length);} #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3)inline intpci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask){ if (!pci_dma_supported(dev,mask)) return -EIO; dev->dma_mask = mask; return 0;} #endif/*************************************************************************** sp_put** Description:* Decrement reference count and call the callback if we're the last* owner of the specified sp. Will get io_request_lock before calling* the callback.** Input:* ha - pointer to the scsi_qla_host_t where the callback is to occur.* sp - pointer to srb_t structure to use.** Returns:***************************************************************************/static inline voidsp_put(struct scsi_qla_host * ha, srb_t *sp){ unsigned long flags; if (atomic_read(&sp->ref_count) == 0) BUG(); if (!atomic_dec_and_test(&sp->ref_count)) { return; }#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) spin_lock_irqsave(&io_request_lock, flags);#else spin_lock_irqsave(ha->host->host_lock, flags);#endif qla2x00_callback(ha, sp->cmd);#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) spin_unlock_irqrestore(&io_request_lock, flags);#else spin_unlock_irqrestore(ha->host->host_lock, flags);#endif}/*************************************************************************** sp_get** Description:* Increment reference count of the specified sp.** Input:* sp - pointer to srb_t structure to use.** Returns:***************************************************************************/static inline voidsp_get(struct scsi_qla_host * ha, srb_t *sp){ atomic_inc(&sp->ref_count); if (atomic_read(&sp->ref_count) > 2) BUG();}/*************************************************************************** __sp_put** Description:* Decrement reference count and call the callback if we're the last* owner of the specified sp. Will NOT get io_request_lock before calling* the callback.** Input:* ha - pointer to the scsi_qla_host_t where the callback is to occur.* sp - pointer to srb_t structure to use.** Returns:***************************************************************************/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?