aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrishna Gudipati <kgudipat@brocade.com>2011-07-20 20:01:52 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-07-27 06:47:45 -0400
commit42a8e6e298f39518445785c53a16357267db37ef (patch)
tree11e02e5579c5eef3cb5226b881f83808f2e862ca
parentf2ee76017b30c84f128dfbf716950ffc0e4d949a (diff)
[SCSI] bfa: Add support for IO profiling.
- Made changes to support IO profiling. - Added support to configure and query IO profiling info. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/bfa/bfa_fcpim.c73
-rw-r--r--drivers/scsi/bfa/bfa_fcpim.h26
-rw-r--r--drivers/scsi/bfa/bfad_bsg.c53
-rw-r--r--drivers/scsi/bfa/bfad_bsg.h18
4 files changed, 162 insertions, 8 deletions
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index a4e7951c6063..7bc010dc17b1 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -437,6 +437,59 @@ bfa_fcpim_port_iostats(struct bfa_s *bfa,
437 return BFA_STATUS_OK; 437 return BFA_STATUS_OK;
438} 438}
439 439
440void
441bfa_ioim_profile_comp(struct bfa_ioim_s *ioim)
442{
443 struct bfa_itnim_latency_s *io_lat =
444 &(ioim->itnim->ioprofile.io_latency);
445 u32 val, idx;
446
447 val = (u32)(jiffies - ioim->start_time);
448 idx = bfa_ioim_get_index(scsi_bufflen((struct scsi_cmnd *)ioim->dio));
449 bfa_itnim_ioprofile_update(ioim->itnim, idx);
450
451 io_lat->count[idx]++;
452 io_lat->min[idx] = (io_lat->min[idx] < val) ? io_lat->min[idx] : val;
453 io_lat->max[idx] = (io_lat->max[idx] > val) ? io_lat->max[idx] : val;
454 io_lat->avg[idx] += val;
455}
456
457void
458bfa_ioim_profile_start(struct bfa_ioim_s *ioim)
459{
460 ioim->start_time = jiffies;
461}
462
463bfa_status_t
464bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time)
465{
466 struct bfa_itnim_s *itnim;
467 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
468 struct list_head *qe, *qen;
469
470 /* accumulate IO stats from itnim */
471 list_for_each_safe(qe, qen, &fcpim->itnim_q) {
472 itnim = (struct bfa_itnim_s *) qe;
473 bfa_itnim_clear_stats(itnim);
474 }
475 fcpim->io_profile = BFA_TRUE;
476 fcpim->io_profile_start_time = time;
477 fcpim->profile_comp = bfa_ioim_profile_comp;
478 fcpim->profile_start = bfa_ioim_profile_start;
479 return BFA_STATUS_OK;
480}
481
482bfa_status_t
483bfa_fcpim_profile_off(struct bfa_s *bfa)
484{
485 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
486 fcpim->io_profile = BFA_FALSE;
487 fcpim->io_profile_start_time = 0;
488 fcpim->profile_comp = NULL;
489 fcpim->profile_start = NULL;
490 return BFA_STATUS_OK;
491}
492
440u16 493u16
441bfa_fcpim_qdepth_get(struct bfa_s *bfa) 494bfa_fcpim_qdepth_get(struct bfa_s *bfa)
442{ 495{
@@ -1401,6 +1454,26 @@ bfa_itnim_hold_io(struct bfa_itnim_s *itnim)
1401 bfa_sm_cmp_state(itnim, bfa_itnim_sm_iocdisable)); 1454 bfa_sm_cmp_state(itnim, bfa_itnim_sm_iocdisable));
1402} 1455}
1403 1456
1457#define bfa_io_lat_clock_res_div HZ
1458#define bfa_io_lat_clock_res_mul 1000
1459bfa_status_t
1460bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim,
1461 struct bfa_itnim_ioprofile_s *ioprofile)
1462{
1463 struct bfa_fcpim_s *fcpim = BFA_FCPIM(itnim->bfa);
1464 if (!fcpim->io_profile)
1465 return BFA_STATUS_IOPROFILE_OFF;
1466
1467 itnim->ioprofile.index = BFA_IOBUCKET_MAX;
1468 itnim->ioprofile.io_profile_start_time =
1469 bfa_io_profile_start_time(itnim->bfa);
1470 itnim->ioprofile.clock_res_mul = bfa_io_lat_clock_res_mul;
1471 itnim->ioprofile.clock_res_div = bfa_io_lat_clock_res_div;
1472 *ioprofile = itnim->ioprofile;
1473
1474 return BFA_STATUS_OK;
1475}
1476
1404void 1477void
1405bfa_itnim_clear_stats(struct bfa_itnim_s *itnim) 1478bfa_itnim_clear_stats(struct bfa_itnim_s *itnim)
1406{ 1479{
diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
index 57b695ad4ee5..c224987b9c30 100644
--- a/drivers/scsi/bfa/bfa_fcpim.h
+++ b/drivers/scsi/bfa/bfa_fcpim.h
@@ -79,14 +79,22 @@ bfa_ioim_get_index(u32 n) {
79 if (n >= (1UL)<<22) 79 if (n >= (1UL)<<22)
80 return BFA_IOBUCKET_MAX - 1; 80 return BFA_IOBUCKET_MAX - 1;
81 n >>= 8; 81 n >>= 8;
82 if (n >= (1UL)<<16) 82 if (n >= (1UL)<<16) {
83 n >>= 16; pos += 16; 83 n >>= 16;
84 if (n >= 1 << 8) 84 pos += 16;
85 n >>= 8; pos += 8; 85 }
86 if (n >= 1 << 4) 86 if (n >= 1 << 8) {
87 n >>= 4; pos += 4; 87 n >>= 8;
88 if (n >= 1 << 2) 88 pos += 8;
89 n >>= 2; pos += 2; 89 }
90 if (n >= 1 << 4) {
91 n >>= 4;
92 pos += 4;
93 }
94 if (n >= 1 << 2) {
95 n >>= 2;
96 pos += 2;
97 }
90 if (n >= 1 << 1) 98 if (n >= 1 << 1)
91 pos += 1; 99 pos += 1;
92 100
@@ -297,6 +305,8 @@ bfa_status_t bfa_fcpim_port_iostats(struct bfa_s *bfa,
297 struct bfa_itnim_iostats_s *stats, u8 lp_tag); 305 struct bfa_itnim_iostats_s *stats, u8 lp_tag);
298void bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *fcpim_stats, 306void bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *fcpim_stats,
299 struct bfa_itnim_iostats_s *itnim_stats); 307 struct bfa_itnim_iostats_s *itnim_stats);
308bfa_status_t bfa_fcpim_profile_on(struct bfa_s *bfa, u32 time);
309bfa_status_t bfa_fcpim_profile_off(struct bfa_s *bfa);
300 310
301#define bfa_fcpim_ioredirect_enabled(__bfa) \ 311#define bfa_fcpim_ioredirect_enabled(__bfa) \
302 (((struct bfa_fcpim_s *)(BFA_FCPIM(__bfa)))->ioredirect) 312 (((struct bfa_fcpim_s *)(BFA_FCPIM(__bfa)))->ioredirect)
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 45753dcba571..26def664cb83 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -1977,6 +1977,52 @@ bfad_iocmd_porglog_ctl(struct bfad_s *bfad, void *cmd)
1977 return 0; 1977 return 0;
1978} 1978}
1979 1979
1980int
1981bfad_iocmd_fcpim_cfg_profile(struct bfad_s *bfad, void *cmd, unsigned int v_cmd)
1982{
1983 struct bfa_bsg_fcpim_profile_s *iocmd =
1984 (struct bfa_bsg_fcpim_profile_s *)cmd;
1985 struct timeval tv;
1986 unsigned long flags;
1987
1988 do_gettimeofday(&tv);
1989 spin_lock_irqsave(&bfad->bfad_lock, flags);
1990 if (v_cmd == IOCMD_FCPIM_PROFILE_ON)
1991 iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, tv.tv_sec);
1992 else if (v_cmd == IOCMD_FCPIM_PROFILE_OFF)
1993 iocmd->status = bfa_fcpim_profile_off(&bfad->bfa);
1994 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1995
1996 return 0;
1997}
1998
1999static int
2000bfad_iocmd_itnim_get_ioprofile(struct bfad_s *bfad, void *cmd)
2001{
2002 struct bfa_bsg_itnim_ioprofile_s *iocmd =
2003 (struct bfa_bsg_itnim_ioprofile_s *)cmd;
2004 struct bfa_fcs_lport_s *fcs_port;
2005 struct bfa_fcs_itnim_s *itnim;
2006 unsigned long flags;
2007
2008 spin_lock_irqsave(&bfad->bfad_lock, flags);
2009 fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs,
2010 iocmd->vf_id, iocmd->lpwwn);
2011 if (!fcs_port)
2012 iocmd->status = BFA_STATUS_UNKNOWN_LWWN;
2013 else {
2014 itnim = bfa_fcs_itnim_lookup(fcs_port, iocmd->rpwwn);
2015 if (itnim == NULL)
2016 iocmd->status = BFA_STATUS_UNKNOWN_RWWN;
2017 else
2018 iocmd->status = bfa_itnim_get_ioprofile(
2019 bfa_fcs_itnim_get_halitn(itnim),
2020 &iocmd->ioprofile);
2021 }
2022 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
2023 return 0;
2024}
2025
1980static int 2026static int
1981bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd, 2027bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd,
1982 unsigned int payload_len) 2028 unsigned int payload_len)
@@ -2238,6 +2284,13 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd,
2238 case IOCMD_DEBUG_PORTLOG_CTL: 2284 case IOCMD_DEBUG_PORTLOG_CTL:
2239 rc = bfad_iocmd_porglog_ctl(bfad, iocmd); 2285 rc = bfad_iocmd_porglog_ctl(bfad, iocmd);
2240 break; 2286 break;
2287 case IOCMD_FCPIM_PROFILE_ON:
2288 case IOCMD_FCPIM_PROFILE_OFF:
2289 rc = bfad_iocmd_fcpim_cfg_profile(bfad, iocmd, cmd);
2290 break;
2291 case IOCMD_ITNIM_GET_IOPROFILE:
2292 rc = bfad_iocmd_itnim_get_ioprofile(bfad, iocmd);
2293 break;
2241 default: 2294 default:
2242 rc = -EINVAL; 2295 rc = -EINVAL;
2243 break; 2296 break;
diff --git a/drivers/scsi/bfa/bfad_bsg.h b/drivers/scsi/bfa/bfad_bsg.h
index b6ff2a30a143..91cb2123dec0 100644
--- a/drivers/scsi/bfa/bfad_bsg.h
+++ b/drivers/scsi/bfa/bfad_bsg.h
@@ -116,6 +116,9 @@ enum {
116 IOCMD_DEBUG_START_DTRC, 116 IOCMD_DEBUG_START_DTRC,
117 IOCMD_DEBUG_STOP_DTRC, 117 IOCMD_DEBUG_STOP_DTRC,
118 IOCMD_DEBUG_PORTLOG_CTL, 118 IOCMD_DEBUG_PORTLOG_CTL,
119 IOCMD_FCPIM_PROFILE_ON,
120 IOCMD_FCPIM_PROFILE_OFF,
121 IOCMD_ITNIM_GET_IOPROFILE,
119}; 122};
120 123
121struct bfa_bsg_gen_s { 124struct bfa_bsg_gen_s {
@@ -132,6 +135,21 @@ struct bfa_bsg_portlogctl_s {
132 int inst_no; 135 int inst_no;
133}; 136};
134 137
138struct bfa_bsg_fcpim_profile_s {
139 bfa_status_t status;
140 u16 bfad_num;
141 u16 rsvd;
142};
143
144struct bfa_bsg_itnim_ioprofile_s {
145 bfa_status_t status;
146 u16 bfad_num;
147 u16 vf_id;
148 wwn_t lpwwn;
149 wwn_t rpwwn;
150 struct bfa_itnim_ioprofile_s ioprofile;
151};
152
135struct bfa_bsg_ioc_name_s { 153struct bfa_bsg_ioc_name_s {
136 bfa_status_t status; 154 bfa_status_t status;
137 u16 bfad_num; 155 u16 bfad_num;