Skip to content

Commit

Permalink
[SCSI] qla2xxx: Add host-statistics FC transport attributes.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
  • Loading branch information
andrew.vasquez@qlogic.com authored and Unknown committed Feb 4, 2006
1 parent 8d06762 commit 392e2f6
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 7 deletions.
37 changes: 36 additions & 1 deletion drivers/scsi/qla2xxx/qla_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "qla_def.h"

#include <linux/vmalloc.h>
#include <scsi/scsi_transport_fc.h>

/* SYSFS attributes --------------------------------------------------------- */

Expand Down Expand Up @@ -555,6 +554,41 @@ qla2x00_issue_lip(struct Scsi_Host *shost)
return 0;
}

static struct fc_host_statistics *
qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
{
scsi_qla_host_t *ha = to_qla_host(shost);
int rval;
uint16_t mb_stat[1];
link_stat_t stat_buf;
struct fc_host_statistics *pfc_host_stat;

pfc_host_stat = &ha->fc_host_stat;
memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics));

if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
rval = qla24xx_get_isp_stats(ha, (uint32_t *)&stat_buf,
sizeof(stat_buf) / 4, mb_stat);
} else {
rval = qla2x00_get_link_status(ha, ha->loop_id, &stat_buf,
mb_stat);
}
if (rval != 0) {
qla_printk(KERN_WARNING, ha,
"Unable to retrieve host statistics (%d).\n", mb_stat[0]);
return pfc_host_stat;
}

pfc_host_stat->link_failure_count = stat_buf.link_fail_cnt;
pfc_host_stat->loss_of_sync_count = stat_buf.loss_sync_cnt;
pfc_host_stat->loss_of_signal_count = stat_buf.loss_sig_cnt;
pfc_host_stat->prim_seq_protocol_err_count = stat_buf.prim_seq_err_cnt;
pfc_host_stat->invalid_tx_word_count = stat_buf.inval_xmit_word_cnt;
pfc_host_stat->invalid_crc_count = stat_buf.inval_crc_cnt;

return pfc_host_stat;
}

struct fc_function_template qla2xxx_transport_functions = {

.show_host_node_name = 1,
Expand Down Expand Up @@ -583,6 +617,7 @@ struct fc_function_template qla2xxx_transport_functions = {
.show_rport_dev_loss_tmo = 1,

.issue_fc_host_lip = qla2x00_issue_lip,
.get_fc_host_stats = qla2x00_get_fc_host_stats,
};

void
Expand Down
2 changes: 2 additions & 0 deletions drivers/scsi/qla2xxx/qla_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <scsi/scsi_host.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_transport_fc.h>

#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
#if defined(CONFIG_SCSI_QLA21XX) || defined(CONFIG_SCSI_QLA21XX_MODULE)
Expand Down Expand Up @@ -2496,6 +2497,7 @@ typedef struct scsi_qla_host {

uint16_t zio_mode;
uint16_t zio_timer;
struct fc_host_statistics fc_host_stat;
} scsi_qla_host_t;


Expand Down
7 changes: 7 additions & 0 deletions drivers/scsi/qla2xxx/qla_gbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *, uint16_t *, uint16_t *, uint16_t *,
extern int
qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map);

extern int
qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, link_stat_t *,
uint16_t *);

extern int
qla24xx_get_isp_stats(scsi_qla_host_t *, uint32_t *, uint32_t, uint16_t *);

extern int qla24xx_abort_command(scsi_qla_host_t *, srb_t *);
extern int qla24xx_abort_target(fc_port_t *);

Expand Down
1 change: 0 additions & 1 deletion drivers/scsi/qla2xxx/qla_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <linux/delay.h>
#include <linux/vmalloc.h>
#include <scsi/scsi_transport_fc.h>

#include "qla_devtbl.h"

Expand Down
105 changes: 102 additions & 3 deletions drivers/scsi/qla2xxx/qla_mbx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "qla_def.h"

#include <linux/delay.h>
#include <scsi/scsi_transport_fc.h>

static void
qla2x00_mbx_sem_timeout(unsigned long data)
Expand Down Expand Up @@ -2017,8 +2016,109 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map)

return rval;
}
#endif

/*
* qla2x00_get_link_status
*
* Input:
* ha = adapter block pointer.
* loop_id = device loop ID.
* ret_buf = pointer to link status return buffer.
*
* Returns:
* 0 = success.
* BIT_0 = mem alloc error.
* BIT_1 = mailbox error.
*/
int
qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
link_stat_t *ret_buf, uint16_t *status)
{
int rval;
mbx_cmd_t mc;
mbx_cmd_t *mcp = &mc;
link_stat_t *stat_buf;
dma_addr_t stat_buf_dma;

DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)

stat_buf = dma_pool_alloc(ha->s_dma_pool, GFP_ATOMIC, &stat_buf_dma);
if (stat_buf == NULL) {
DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
__func__, ha->host_no));
return BIT_0;
}
memset(stat_buf, 0, sizeof(link_stat_t));

mcp->mb[0] = MBC_GET_LINK_STATUS;
mcp->mb[2] = MSW(stat_buf_dma);
mcp->mb[3] = LSW(stat_buf_dma);
mcp->mb[6] = MSW(MSD(stat_buf_dma));
mcp->mb[7] = LSW(MSD(stat_buf_dma));
mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
mcp->in_mb = MBX_0;
if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
mcp->mb[1] = loop_id;
mcp->mb[4] = 0;
mcp->mb[10] = 0;
mcp->out_mb |= MBX_10|MBX_4|MBX_1;
mcp->in_mb |= MBX_1;
} else if (HAS_EXTENDED_IDS(ha)) {
mcp->mb[1] = loop_id;
mcp->mb[10] = 0;
mcp->out_mb |= MBX_10|MBX_1;
} else {
mcp->mb[1] = loop_id << 8;
mcp->out_mb |= MBX_1;
}
mcp->tov = 30;
mcp->flags = IOCTL_CMD;
rval = qla2x00_mailbox_command(ha, mcp);

if (rval == QLA_SUCCESS) {
if (mcp->mb[0] != MBS_COMMAND_COMPLETE) {
DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
__func__, ha->host_no, mcp->mb[0]);)
status[0] = mcp->mb[0];
rval = BIT_1;
} else {
/* copy over data -- firmware data is LE. */
ret_buf->link_fail_cnt =
le32_to_cpu(stat_buf->link_fail_cnt);
ret_buf->loss_sync_cnt =
le32_to_cpu(stat_buf->loss_sync_cnt);
ret_buf->loss_sig_cnt =
le32_to_cpu(stat_buf->loss_sig_cnt);
ret_buf->prim_seq_err_cnt =
le32_to_cpu(stat_buf->prim_seq_err_cnt);
ret_buf->inval_xmit_word_cnt =
le32_to_cpu(stat_buf->inval_xmit_word_cnt);
ret_buf->inval_crc_cnt =
le32_to_cpu(stat_buf->inval_crc_cnt);

DEBUG11(printk("%s(%ld): stat dump: fail_cnt=%d "
"loss_sync=%d loss_sig=%d seq_err=%d "
"inval_xmt_word=%d inval_crc=%d.\n", __func__,
ha->host_no, stat_buf->link_fail_cnt,
stat_buf->loss_sync_cnt, stat_buf->loss_sig_cnt,
stat_buf->prim_seq_err_cnt,
stat_buf->inval_xmit_word_cnt,
stat_buf->inval_crc_cnt);)
}
} else {
/* Failed. */
DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__,
ha->host_no, rval);)
rval = BIT_1;
}

dma_pool_free(ha->s_dma_pool, stat_buf, stat_buf_dma);

uint8_t
return rval;
}

int
qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords,
uint16_t *status)
{
Expand Down Expand Up @@ -2080,7 +2180,6 @@ qla24xx_get_isp_stats(scsi_qla_host_t *ha, uint32_t *dwbuf, uint32_t dwords,

return rval;
}
#endif

int
qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
Expand Down
2 changes: 0 additions & 2 deletions drivers/scsi/qla2xxx/qla_rscn.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/
#include "qla_def.h"

#include <scsi/scsi_transport_fc.h>

/**
* IO descriptor handle definitions.
*
Expand Down

0 comments on commit 392e2f6

Please sign in to comment.