aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrishna Gudipati <kgudipat@brocade.com>2011-06-24 23:25:15 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-06-29 18:16:54 -0400
commit601380669baa2ba6427b821a14e5c91afb580dfc (patch)
tree61eb7c58f09a91161db9d28be195335bcf7cef7c
parentd7be54cc5c5f6f9cb9ac67462aadda57813698b8 (diff)
[SCSI] bfa: Extend BSG interface.
- Added support to collect driver/fw stats. - Added support to perform adapter/ioc enable, disable operations. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/bfa/bfa.h1
-rw-r--r--drivers/scsi/bfa/bfa_core.c21
-rw-r--r--drivers/scsi/bfa/bfa_defs_fcs.h8
-rw-r--r--drivers/scsi/bfa/bfa_defs_svc.h55
-rw-r--r--drivers/scsi/bfa/bfa_fcpim.c72
-rw-r--r--drivers/scsi/bfa/bfa_fcpim.h4
-rw-r--r--drivers/scsi/bfa/bfa_fcs.h2
-rw-r--r--drivers/scsi/bfa/bfa_fcs_rport.c40
-rw-r--r--drivers/scsi/bfa/bfad_bsg.c535
-rw-r--r--drivers/scsi/bfa/bfad_bsg.h135
-rw-r--r--drivers/scsi/bfa/bfad_drv.h1
11 files changed, 867 insertions, 7 deletions
diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h
index 67742dca675f..c7cfc585c656 100644
--- a/drivers/scsi/bfa/bfa.h
+++ b/drivers/scsi/bfa/bfa.h
@@ -249,6 +249,7 @@ struct bfa_iocfc_s {
249 struct bfa_cb_qe_s init_hcb_qe; 249 struct bfa_cb_qe_s init_hcb_qe;
250 struct bfa_cb_qe_s stop_hcb_qe; 250 struct bfa_cb_qe_s stop_hcb_qe;
251 struct bfa_cb_qe_s dis_hcb_qe; 251 struct bfa_cb_qe_s dis_hcb_qe;
252 struct bfa_cb_qe_s en_hcb_qe;
252 struct bfa_cb_qe_s stats_hcb_qe; 253 struct bfa_cb_qe_s stats_hcb_qe;
253 bfa_boolean_t cfgdone; 254 bfa_boolean_t cfgdone;
254 255
diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index 602dc3508ed8..21343c26721d 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -125,6 +125,7 @@ enum {
125 BFA_IOCFC_ACT_INIT = 1, 125 BFA_IOCFC_ACT_INIT = 1,
126 BFA_IOCFC_ACT_STOP = 2, 126 BFA_IOCFC_ACT_STOP = 2,
127 BFA_IOCFC_ACT_DISABLE = 3, 127 BFA_IOCFC_ACT_DISABLE = 3,
128 BFA_IOCFC_ACT_ENABLE = 4,
128}; 129};
129 130
130#define DEF_CFG_NUM_FABRICS 1 131#define DEF_CFG_NUM_FABRICS 1
@@ -678,6 +679,16 @@ bfa_iocfc_stop_cb(void *bfa_arg, bfa_boolean_t compl)
678} 679}
679 680
680static void 681static void
682bfa_iocfc_enable_cb(void *bfa_arg, bfa_boolean_t compl)
683{
684 struct bfa_s *bfa = bfa_arg;
685 struct bfad_s *bfad = bfa->bfad;
686
687 if (compl)
688 complete(&bfad->enable_comp);
689}
690
691static void
681bfa_iocfc_disable_cb(void *bfa_arg, bfa_boolean_t compl) 692bfa_iocfc_disable_cb(void *bfa_arg, bfa_boolean_t compl)
682{ 693{
683 struct bfa_s *bfa = bfa_arg; 694 struct bfa_s *bfa = bfa_arg;
@@ -760,8 +771,12 @@ bfa_iocfc_cfgrsp(struct bfa_s *bfa)
760 771
761 if (iocfc->action == BFA_IOCFC_ACT_INIT) 772 if (iocfc->action == BFA_IOCFC_ACT_INIT)
762 bfa_cb_queue(bfa, &iocfc->init_hcb_qe, bfa_iocfc_init_cb, bfa); 773 bfa_cb_queue(bfa, &iocfc->init_hcb_qe, bfa_iocfc_init_cb, bfa);
763 else 774 else {
775 if (bfa->iocfc.action == BFA_IOCFC_ACT_ENABLE)
776 bfa_cb_queue(bfa, &bfa->iocfc.en_hcb_qe,
777 bfa_iocfc_enable_cb, bfa);
764 bfa_iocfc_start_submod(bfa); 778 bfa_iocfc_start_submod(bfa);
779 }
765} 780}
766void 781void
767bfa_iocfc_reset_queues(struct bfa_s *bfa) 782bfa_iocfc_reset_queues(struct bfa_s *bfa)
@@ -970,6 +985,9 @@ bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status)
970 if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT) 985 if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
971 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, 986 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
972 bfa_iocfc_init_cb, bfa); 987 bfa_iocfc_init_cb, bfa);
988 else if (bfa->iocfc.action == BFA_IOCFC_ACT_ENABLE)
989 bfa_cb_queue(bfa, &bfa->iocfc.en_hcb_qe,
990 bfa_iocfc_enable_cb, bfa);
973 return; 991 return;
974 } 992 }
975 993
@@ -1236,6 +1254,7 @@ bfa_iocfc_enable(struct bfa_s *bfa)
1236{ 1254{
1237 bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0, 1255 bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
1238 "IOC Enable"); 1256 "IOC Enable");
1257 bfa->iocfc.action = BFA_IOCFC_ACT_ENABLE;
1239 bfa_ioc_enable(&bfa->ioc); 1258 bfa_ioc_enable(&bfa->ioc);
1240} 1259}
1241 1260
diff --git a/drivers/scsi/bfa/bfa_defs_fcs.h b/drivers/scsi/bfa/bfa_defs_fcs.h
index 5e95976d81b8..3bbc583f65cf 100644
--- a/drivers/scsi/bfa/bfa_defs_fcs.h
+++ b/drivers/scsi/bfa/bfa_defs_fcs.h
@@ -93,9 +93,11 @@ struct bfa_lport_cfg_s {
93 wwn_t pwwn; /* port wwn */ 93 wwn_t pwwn; /* port wwn */
94 wwn_t nwwn; /* node wwn */ 94 wwn_t nwwn; /* node wwn */
95 struct bfa_lport_symname_s sym_name; /* vm port symbolic name */ 95 struct bfa_lport_symname_s sym_name; /* vm port symbolic name */
96 bfa_boolean_t preboot_vp; /* vport created from PBC */ 96 enum bfa_lport_role roles; /* FCS port roles */
97 enum bfa_lport_role roles; /* FCS port roles */ 97 u32 rsvd;
98 u8 tag[16]; /* opaque tag from application */ 98 bfa_boolean_t preboot_vp; /* vport created from PBC */
99 u8 tag[16]; /* opaque tag from application */
100 u8 padding[4];
99}; 101};
100 102
101/* 103/*
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 7f3584380a42..95a17ef631f0 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -65,8 +65,12 @@ struct bfa_iocfc_drvcfg_s {
65 u16 ioc_recover; /* IOC recovery mode */ 65 u16 ioc_recover; /* IOC recovery mode */
66 u16 min_cfg; /* minimum configuration */ 66 u16 min_cfg; /* minimum configuration */
67 u16 path_tov; /* device path timeout */ 67 u16 path_tov; /* device path timeout */
68 u16 num_tio_reqs; /*!< number of TM IO reqs */
69 u8 port_mode;
70 u8 rsvd_a;
68 bfa_boolean_t delay_comp; /* delay completion of 71 bfa_boolean_t delay_comp; /* delay completion of
69 failed inflight IOs */ 72 failed inflight IOs */
73 u16 num_ttsk_reqs; /* TM task management requests */
70 u32 rsvd; 74 u32 rsvd;
71}; 75};
72 76
@@ -81,7 +85,7 @@ struct bfa_iocfc_cfg_s {
81/* 85/*
82 * IOC firmware IO stats 86 * IOC firmware IO stats
83 */ 87 */
84struct bfa_fw_io_stats_s { 88struct bfa_fw_ioim_stats_s {
85 u32 host_abort; /* IO aborted by host driver*/ 89 u32 host_abort; /* IO aborted by host driver*/
86 u32 host_cleanup; /* IO clean up by host driver */ 90 u32 host_cleanup; /* IO clean up by host driver */
87 91
@@ -151,6 +155,54 @@ struct bfa_fw_io_stats_s {
151 */ 155 */
152}; 156};
153 157
158struct bfa_fw_tio_stats_s {
159 u32 tio_conf_proc; /* TIO CONF processed */
160 u32 tio_conf_drop; /* TIO CONF dropped */
161 u32 tio_cleanup_req; /* TIO cleanup requested */
162 u32 tio_cleanup_comp; /* TIO cleanup completed */
163 u32 tio_abort_rsp; /* TIO abort response */
164 u32 tio_abort_rsp_comp; /* TIO abort rsp completed */
165 u32 tio_abts_req; /* TIO ABTS requested */
166 u32 tio_abts_ack; /* TIO ABTS ack-ed */
167 u32 tio_abts_ack_nocomp; /* TIO ABTS ack-ed but not completed */
168 u32 tio_abts_tmo; /* TIO ABTS timeout */
169 u32 tio_snsdata_dma; /* TIO sense data DMA */
170 u32 tio_rxwchan_wait; /* TIO waiting for RX wait channel */
171 u32 tio_rxwchan_avail; /* TIO RX wait channel available */
172 u32 tio_hit_bls; /* TIO IOH BLS event */
173 u32 tio_uf_recv; /* TIO received UF */
174 u32 tio_rd_invalid_sm; /* TIO read reqst in wrong state machine */
175 u32 tio_wr_invalid_sm;/* TIO write reqst in wrong state machine */
176
177 u32 ds_rxwchan_wait; /* DS waiting for RX wait channel */
178 u32 ds_rxwchan_avail; /* DS RX wait channel available */
179 u32 ds_unaligned_rd; /* DS unaligned read */
180 u32 ds_rdcomp_invalid_sm; /* DS read completed in wrong state machine */
181 u32 ds_wrcomp_invalid_sm; /* DS write completed in wrong state machine */
182 u32 ds_flush_req; /* DS flush requested */
183 u32 ds_flush_comp; /* DS flush completed */
184 u32 ds_xfrdy_exp; /* DS XFER_RDY expired */
185 u32 ds_seq_cnt_err; /* DS seq cnt error */
186 u32 ds_seq_len_err; /* DS seq len error */
187 u32 ds_data_oor; /* DS data out of order */
188 u32 ds_hit_bls; /* DS hit BLS */
189 u32 ds_edtov_timer_exp; /* DS edtov expired */
190 u32 ds_cpu_owned; /* DS cpu owned */
191 u32 ds_hit_class2; /* DS hit class2 */
192 u32 ds_length_err; /* DS length error */
193 u32 ds_ro_ooo_err; /* DS relative offset out-of-order error */
194 u32 ds_rectov_timer_exp; /* DS rectov expired */
195 u32 ds_unexp_fr_err; /* DS unexp frame error */
196};
197
198/*
199 * IOC firmware IO stats
200 */
201struct bfa_fw_io_stats_s {
202 struct bfa_fw_ioim_stats_s ioim_stats;
203 struct bfa_fw_tio_stats_s tio_stats;
204};
205
154/* 206/*
155 * IOC port firmware stats 207 * IOC port firmware stats
156 */ 208 */
@@ -204,6 +256,7 @@ struct bfa_fw_port_lksm_stats_s {
204 u32 nos_tx; /* No. of times NOS tx started */ 256 u32 nos_tx; /* No. of times NOS tx started */
205 u32 hwsm_lrr_rx; /* No. of times LRR rx-ed by HWSM */ 257 u32 hwsm_lrr_rx; /* No. of times LRR rx-ed by HWSM */
206 u32 hwsm_lr_rx; /* No. of times LR rx-ed by HWSM */ 258 u32 hwsm_lr_rx; /* No. of times LR rx-ed by HWSM */
259 u32 bbsc_lr; /* LKSM LR tx for credit recovery */
207}; 260};
208 261
209struct bfa_fw_port_snsm_stats_s { 262struct bfa_fw_port_snsm_stats_s {
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index 27eab36f89a5..a4e7951c6063 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -365,6 +365,78 @@ bfa_fcpim_path_tov_get(struct bfa_s *bfa)
365 return fcpim->path_tov / 1000; 365 return fcpim->path_tov / 1000;
366} 366}
367 367
368#define bfa_fcpim_add_iostats(__l, __r, __stats) \
369 (__l->__stats += __r->__stats)
370
371void
372bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *lstats,
373 struct bfa_itnim_iostats_s *rstats)
374{
375 bfa_fcpim_add_iostats(lstats, rstats, total_ios);
376 bfa_fcpim_add_iostats(lstats, rstats, qresumes);
377 bfa_fcpim_add_iostats(lstats, rstats, no_iotags);
378 bfa_fcpim_add_iostats(lstats, rstats, io_aborts);
379 bfa_fcpim_add_iostats(lstats, rstats, no_tskims);
380 bfa_fcpim_add_iostats(lstats, rstats, iocomp_ok);
381 bfa_fcpim_add_iostats(lstats, rstats, iocomp_underrun);
382 bfa_fcpim_add_iostats(lstats, rstats, iocomp_overrun);
383 bfa_fcpim_add_iostats(lstats, rstats, iocomp_aborted);
384 bfa_fcpim_add_iostats(lstats, rstats, iocomp_timedout);
385 bfa_fcpim_add_iostats(lstats, rstats, iocom_nexus_abort);
386 bfa_fcpim_add_iostats(lstats, rstats, iocom_proto_err);
387 bfa_fcpim_add_iostats(lstats, rstats, iocom_dif_err);
388 bfa_fcpim_add_iostats(lstats, rstats, iocom_sqer_needed);
389 bfa_fcpim_add_iostats(lstats, rstats, iocom_res_free);
390 bfa_fcpim_add_iostats(lstats, rstats, iocom_hostabrts);
391 bfa_fcpim_add_iostats(lstats, rstats, iocom_utags);
392 bfa_fcpim_add_iostats(lstats, rstats, io_cleanups);
393 bfa_fcpim_add_iostats(lstats, rstats, io_tmaborts);
394 bfa_fcpim_add_iostats(lstats, rstats, onlines);
395 bfa_fcpim_add_iostats(lstats, rstats, offlines);
396 bfa_fcpim_add_iostats(lstats, rstats, creates);
397 bfa_fcpim_add_iostats(lstats, rstats, deletes);
398 bfa_fcpim_add_iostats(lstats, rstats, create_comps);
399 bfa_fcpim_add_iostats(lstats, rstats, delete_comps);
400 bfa_fcpim_add_iostats(lstats, rstats, sler_events);
401 bfa_fcpim_add_iostats(lstats, rstats, fw_create);
402 bfa_fcpim_add_iostats(lstats, rstats, fw_delete);
403 bfa_fcpim_add_iostats(lstats, rstats, ioc_disabled);
404 bfa_fcpim_add_iostats(lstats, rstats, cleanup_comps);
405 bfa_fcpim_add_iostats(lstats, rstats, tm_cmnds);
406 bfa_fcpim_add_iostats(lstats, rstats, tm_fw_rsps);
407 bfa_fcpim_add_iostats(lstats, rstats, tm_success);
408 bfa_fcpim_add_iostats(lstats, rstats, tm_failures);
409 bfa_fcpim_add_iostats(lstats, rstats, tm_io_comps);
410 bfa_fcpim_add_iostats(lstats, rstats, tm_qresumes);
411 bfa_fcpim_add_iostats(lstats, rstats, tm_iocdowns);
412 bfa_fcpim_add_iostats(lstats, rstats, tm_cleanups);
413 bfa_fcpim_add_iostats(lstats, rstats, tm_cleanup_comps);
414 bfa_fcpim_add_iostats(lstats, rstats, io_comps);
415 bfa_fcpim_add_iostats(lstats, rstats, input_reqs);
416 bfa_fcpim_add_iostats(lstats, rstats, output_reqs);
417 bfa_fcpim_add_iostats(lstats, rstats, rd_throughput);
418 bfa_fcpim_add_iostats(lstats, rstats, wr_throughput);
419}
420
421bfa_status_t
422bfa_fcpim_port_iostats(struct bfa_s *bfa,
423 struct bfa_itnim_iostats_s *stats, u8 lp_tag)
424{
425 struct bfa_fcpim_s *fcpim = BFA_FCPIM(bfa);
426 struct list_head *qe, *qen;
427 struct bfa_itnim_s *itnim;
428
429 /* accumulate IO stats from itnim */
430 memset(stats, 0, sizeof(struct bfa_itnim_iostats_s));
431 list_for_each_safe(qe, qen, &fcpim->itnim_q) {
432 itnim = (struct bfa_itnim_s *) qe;
433 if (itnim->rport->rport_info.lp_tag != lp_tag)
434 continue;
435 bfa_fcpim_add_stats(stats, &(itnim->stats));
436 }
437 return BFA_STATUS_OK;
438}
439
368u16 440u16
369bfa_fcpim_qdepth_get(struct bfa_s *bfa) 441bfa_fcpim_qdepth_get(struct bfa_s *bfa)
370{ 442{
diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
index ccb7c6ebebf9..57b695ad4ee5 100644
--- a/drivers/scsi/bfa/bfa_fcpim.h
+++ b/drivers/scsi/bfa/bfa_fcpim.h
@@ -293,6 +293,10 @@ bfa_boolean_t bfa_itnim_hold_io(struct bfa_itnim_s *itnim);
293void bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov); 293void bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov);
294u16 bfa_fcpim_path_tov_get(struct bfa_s *bfa); 294u16 bfa_fcpim_path_tov_get(struct bfa_s *bfa);
295u16 bfa_fcpim_qdepth_get(struct bfa_s *bfa); 295u16 bfa_fcpim_qdepth_get(struct bfa_s *bfa);
296bfa_status_t bfa_fcpim_port_iostats(struct bfa_s *bfa,
297 struct bfa_itnim_iostats_s *stats, u8 lp_tag);
298void bfa_fcpim_add_stats(struct bfa_itnim_iostats_s *fcpim_stats,
299 struct bfa_itnim_iostats_s *itnim_stats);
296 300
297#define bfa_fcpim_ioredirect_enabled(__bfa) \ 301#define bfa_fcpim_ioredirect_enabled(__bfa) \
298 (((struct bfa_fcpim_s *)(BFA_FCPIM(__bfa)))->ioredirect) 302 (((struct bfa_fcpim_s *)(BFA_FCPIM(__bfa)))->ioredirect)
diff --git a/drivers/scsi/bfa/bfa_fcs.h b/drivers/scsi/bfa/bfa_fcs.h
index e32cb19e32c3..a5f1faf335a7 100644
--- a/drivers/scsi/bfa/bfa_fcs.h
+++ b/drivers/scsi/bfa/bfa_fcs.h
@@ -452,6 +452,8 @@ bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport)
452/* 452/*
453 * bfa fcs rport API functions 453 * bfa fcs rport API functions
454 */ 454 */
455void bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
456 struct bfa_rport_attr_s *attr);
455struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port, 457struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port,
456 wwn_t rpwwn); 458 wwn_t rpwwn);
457struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn( 459struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn(
diff --git a/drivers/scsi/bfa/bfa_fcs_rport.c b/drivers/scsi/bfa/bfa_fcs_rport.c
index a42949d045eb..2c514458a6b4 100644
--- a/drivers/scsi/bfa/bfa_fcs_rport.c
+++ b/drivers/scsi/bfa/bfa_fcs_rport.c
@@ -2536,7 +2536,45 @@ bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, __be16 ox_id)
2536 bfa_sm_send_event(rport, RPSM_EVENT_PRLO_RCVD); 2536 bfa_sm_send_event(rport, RPSM_EVENT_PRLO_RCVD);
2537} 2537}
2538 2538
2539 2539void
2540bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
2541 struct bfa_rport_attr_s *rport_attr)
2542{
2543 struct bfa_rport_qos_attr_s qos_attr;
2544 struct bfa_fcs_lport_s *port = rport->port;
2545 bfa_port_speed_t rport_speed = rport->rpf.rpsc_speed;
2546
2547 memset(rport_attr, 0, sizeof(struct bfa_rport_attr_s));
2548 memset(&qos_attr, 0, sizeof(struct bfa_rport_qos_attr_s));
2549
2550 rport_attr->pid = rport->pid;
2551 rport_attr->pwwn = rport->pwwn;
2552 rport_attr->nwwn = rport->nwwn;
2553 rport_attr->cos_supported = rport->fc_cos;
2554 rport_attr->df_sz = rport->maxfrsize;
2555 rport_attr->state = bfa_fcs_rport_get_state(rport);
2556 rport_attr->fc_cos = rport->fc_cos;
2557 rport_attr->cisc = rport->cisc;
2558 rport_attr->scsi_function = rport->scsi_function;
2559 rport_attr->curr_speed = rport->rpf.rpsc_speed;
2560 rport_attr->assigned_speed = rport->rpf.assigned_speed;
2561
2562 qos_attr.qos_priority = rport->bfa_rport->qos_attr.qos_priority;
2563 qos_attr.qos_flow_id =
2564 cpu_to_be32(rport->bfa_rport->qos_attr.qos_flow_id);
2565 rport_attr->qos_attr = qos_attr;
2566
2567 rport_attr->trl_enforced = BFA_FALSE;
2568 if (bfa_fcport_is_ratelim(port->fcs->bfa) &&
2569 (rport->scsi_function == BFA_RPORT_TARGET)) {
2570 if (rport_speed == BFA_PORT_SPEED_UNKNOWN)
2571 rport_speed =
2572 bfa_fcport_get_ratelim_speed(rport->fcs->bfa);
2573
2574 if (rport_speed < bfa_fcs_lport_get_rport_max_speed(port))
2575 rport_attr->trl_enforced = BFA_TRUE;
2576 }
2577}
2540 2578
2541/* 2579/*
2542 * Remote port implementation. 2580 * Remote port implementation.
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index 9ec8f04b16c0..5ae591b062b3 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -46,6 +46,55 @@ bfad_im_bsg_put_kobject(struct fc_bsg_job *job)
46 spin_unlock_irqrestore(shost->host_lock, flags); 46 spin_unlock_irqrestore(shost->host_lock, flags);
47} 47}
48 48
49int
50bfad_iocmd_ioc_enable(struct bfad_s *bfad, void *cmd)
51{
52 struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd;
53 int rc = 0;
54 unsigned long flags;
55
56 spin_lock_irqsave(&bfad->bfad_lock, flags);
57 /* If IOC is not in disabled state - return */
58 if (!bfa_ioc_is_disabled(&bfad->bfa.ioc)) {
59 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
60 iocmd->status = BFA_STATUS_IOC_FAILURE;
61 return rc;
62 }
63
64 init_completion(&bfad->enable_comp);
65 bfa_iocfc_enable(&bfad->bfa);
66 iocmd->status = BFA_STATUS_OK;
67 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
68 wait_for_completion(&bfad->enable_comp);
69
70 return rc;
71}
72
73int
74bfad_iocmd_ioc_disable(struct bfad_s *bfad, void *cmd)
75{
76 struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd;
77 int rc = 0;
78 unsigned long flags;
79
80 spin_lock_irqsave(&bfad->bfad_lock, flags);
81 if (bfad->disable_active) {
82 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
83 return EBUSY;
84 }
85
86 bfad->disable_active = BFA_TRUE;
87 init_completion(&bfad->disable_comp);
88 bfa_iocfc_disable(&bfad->bfa);
89 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
90
91 wait_for_completion(&bfad->disable_comp);
92 bfad->disable_active = BFA_FALSE;
93 iocmd->status = BFA_STATUS_OK;
94
95 return rc;
96}
97
49static int 98static int
50bfad_iocmd_ioc_get_info(struct bfad_s *bfad, void *cmd) 99bfad_iocmd_ioc_get_info(struct bfad_s *bfad, void *cmd)
51{ 100{
@@ -112,6 +161,113 @@ bfad_iocmd_ioc_get_attr(struct bfad_s *bfad, void *cmd)
112 return 0; 161 return 0;
113} 162}
114 163
164int
165bfad_iocmd_ioc_get_stats(struct bfad_s *bfad, void *cmd)
166{
167 struct bfa_bsg_ioc_stats_s *iocmd = (struct bfa_bsg_ioc_stats_s *)cmd;
168
169 bfa_ioc_get_stats(&bfad->bfa, &iocmd->ioc_stats);
170 iocmd->status = BFA_STATUS_OK;
171 return 0;
172}
173
174int
175bfad_iocmd_ioc_get_fwstats(struct bfad_s *bfad, void *cmd,
176 unsigned int payload_len)
177{
178 struct bfa_bsg_ioc_fwstats_s *iocmd =
179 (struct bfa_bsg_ioc_fwstats_s *)cmd;
180 void *iocmd_bufptr;
181 unsigned long flags;
182
183 if (bfad_chk_iocmd_sz(payload_len,
184 sizeof(struct bfa_bsg_ioc_fwstats_s),
185 sizeof(struct bfa_fw_stats_s)) != BFA_STATUS_OK) {
186 iocmd->status = BFA_STATUS_VERSION_FAIL;
187 goto out;
188 }
189
190 iocmd_bufptr = (char *)iocmd + sizeof(struct bfa_bsg_ioc_fwstats_s);
191 spin_lock_irqsave(&bfad->bfad_lock, flags);
192 iocmd->status = bfa_ioc_fw_stats_get(&bfad->bfa.ioc, iocmd_bufptr);
193 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
194
195 if (iocmd->status != BFA_STATUS_OK) {
196 bfa_trc(bfad, iocmd->status);
197 goto out;
198 }
199out:
200 bfa_trc(bfad, 0x6666);
201 return 0;
202}
203
204int
205bfad_iocmd_iocfc_get_attr(struct bfad_s *bfad, void *cmd)
206{
207 struct bfa_bsg_iocfc_attr_s *iocmd = (struct bfa_bsg_iocfc_attr_s *)cmd;
208
209 iocmd->status = BFA_STATUS_OK;
210 bfa_iocfc_get_attr(&bfad->bfa, &iocmd->iocfc_attr);
211
212 return 0;
213}
214
215int
216bfad_iocmd_iocfc_set_intr(struct bfad_s *bfad, void *cmd)
217{
218 struct bfa_bsg_iocfc_intr_s *iocmd = (struct bfa_bsg_iocfc_intr_s *)cmd;
219 unsigned long flags;
220
221 spin_lock_irqsave(&bfad->bfad_lock, flags);
222 iocmd->status = bfa_iocfc_israttr_set(&bfad->bfa, &iocmd->attr);
223 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
224
225 return 0;
226}
227
228int
229bfad_iocmd_port_enable(struct bfad_s *bfad, void *cmd)
230{
231 struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd;
232 struct bfad_hal_comp fcomp;
233 unsigned long flags;
234
235 init_completion(&fcomp.comp);
236 spin_lock_irqsave(&bfad->bfad_lock, flags);
237 iocmd->status = bfa_port_enable(&bfad->bfa.modules.port,
238 bfad_hcb_comp, &fcomp);
239 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
240 if (iocmd->status != BFA_STATUS_OK) {
241 bfa_trc(bfad, iocmd->status);
242 return 0;
243 }
244 wait_for_completion(&fcomp.comp);
245 iocmd->status = fcomp.status;
246 return 0;
247}
248
249int
250bfad_iocmd_port_disable(struct bfad_s *bfad, void *cmd)
251{
252 struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd;
253 struct bfad_hal_comp fcomp;
254 unsigned long flags;
255
256 init_completion(&fcomp.comp);
257 spin_lock_irqsave(&bfad->bfad_lock, flags);
258 iocmd->status = bfa_port_disable(&bfad->bfa.modules.port,
259 bfad_hcb_comp, &fcomp);
260 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
261
262 if (iocmd->status != BFA_STATUS_OK) {
263 bfa_trc(bfad, iocmd->status);
264 return 0;
265 }
266 wait_for_completion(&fcomp.comp);
267 iocmd->status = fcomp.status;
268 return 0;
269}
270
115static int 271static int
116bfad_iocmd_port_get_attr(struct bfad_s *bfad, void *cmd) 272bfad_iocmd_port_get_attr(struct bfad_s *bfad, void *cmd)
117{ 273{
@@ -140,6 +296,40 @@ bfad_iocmd_port_get_attr(struct bfad_s *bfad, void *cmd)
140 return 0; 296 return 0;
141} 297}
142 298
299int
300bfad_iocmd_port_get_stats(struct bfad_s *bfad, void *cmd,
301 unsigned int payload_len)
302{
303 struct bfa_bsg_port_stats_s *iocmd = (struct bfa_bsg_port_stats_s *)cmd;
304 struct bfad_hal_comp fcomp;
305 void *iocmd_bufptr;
306 unsigned long flags;
307
308 if (bfad_chk_iocmd_sz(payload_len,
309 sizeof(struct bfa_bsg_port_stats_s),
310 sizeof(union bfa_port_stats_u)) != BFA_STATUS_OK) {
311 iocmd->status = BFA_STATUS_VERSION_FAIL;
312 return 0;
313 }
314
315 iocmd_bufptr = (char *)iocmd + sizeof(struct bfa_bsg_port_stats_s);
316
317 init_completion(&fcomp.comp);
318 spin_lock_irqsave(&bfad->bfad_lock, flags);
319 iocmd->status = bfa_port_get_stats(&bfad->bfa.modules.port,
320 iocmd_bufptr, bfad_hcb_comp, &fcomp);
321 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
322 if (iocmd->status != BFA_STATUS_OK) {
323 bfa_trc(bfad, iocmd->status);
324 goto out;
325 }
326
327 wait_for_completion(&fcomp.comp);
328 iocmd->status = fcomp.status;
329out:
330 return 0;
331}
332
143static int 333static int
144bfad_iocmd_lport_get_attr(struct bfad_s *bfad, void *cmd) 334bfad_iocmd_lport_get_attr(struct bfad_s *bfad, void *cmd)
145{ 335{
@@ -163,6 +353,128 @@ out:
163 return 0; 353 return 0;
164} 354}
165 355
356int
357bfad_iocmd_lport_get_stats(struct bfad_s *bfad, void *cmd)
358{
359 struct bfa_fcs_lport_s *fcs_port;
360 struct bfa_bsg_lport_stats_s *iocmd =
361 (struct bfa_bsg_lport_stats_s *)cmd;
362 unsigned long flags;
363
364 spin_lock_irqsave(&bfad->bfad_lock, flags);
365 fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs,
366 iocmd->vf_id, iocmd->pwwn);
367 if (fcs_port == NULL) {
368 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
369 iocmd->status = BFA_STATUS_UNKNOWN_LWWN;
370 goto out;
371 }
372
373 bfa_fcs_lport_get_stats(fcs_port, &iocmd->port_stats);
374 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
375 iocmd->status = BFA_STATUS_OK;
376out:
377 return 0;
378}
379
380int
381bfad_iocmd_lport_get_iostats(struct bfad_s *bfad, void *cmd)
382{
383 struct bfa_fcs_lport_s *fcs_port;
384 struct bfa_bsg_lport_iostats_s *iocmd =
385 (struct bfa_bsg_lport_iostats_s *)cmd;
386 unsigned long flags;
387
388 spin_lock_irqsave(&bfad->bfad_lock, flags);
389 fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs,
390 iocmd->vf_id, iocmd->pwwn);
391 if (fcs_port == NULL) {
392 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
393 iocmd->status = BFA_STATUS_UNKNOWN_LWWN;
394 goto out;
395 }
396
397 bfa_fcpim_port_iostats(&bfad->bfa, &iocmd->iostats,
398 fcs_port->lp_tag);
399 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
400 iocmd->status = BFA_STATUS_OK;
401out:
402 return 0;
403}
404
405int
406bfad_iocmd_lport_get_rports(struct bfad_s *bfad, void *cmd,
407 unsigned int payload_len)
408{
409 struct bfa_bsg_lport_get_rports_s *iocmd =
410 (struct bfa_bsg_lport_get_rports_s *)cmd;
411 struct bfa_fcs_lport_s *fcs_port;
412 unsigned long flags;
413 void *iocmd_bufptr;
414
415 if (iocmd->nrports == 0)
416 return EINVAL;
417
418 if (bfad_chk_iocmd_sz(payload_len,
419 sizeof(struct bfa_bsg_lport_get_rports_s),
420 sizeof(wwn_t) * iocmd->nrports) != BFA_STATUS_OK) {
421 iocmd->status = BFA_STATUS_VERSION_FAIL;
422 return 0;
423 }
424
425 iocmd_bufptr = (char *)iocmd +
426 sizeof(struct bfa_bsg_lport_get_rports_s);
427 spin_lock_irqsave(&bfad->bfad_lock, flags);
428 fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs,
429 iocmd->vf_id, iocmd->pwwn);
430 if (fcs_port == NULL) {
431 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
432 bfa_trc(bfad, 0);
433 iocmd->status = BFA_STATUS_UNKNOWN_LWWN;
434 goto out;
435 }
436
437 bfa_fcs_lport_get_rports(fcs_port, (wwn_t *)iocmd_bufptr,
438 &iocmd->nrports);
439 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
440 iocmd->status = BFA_STATUS_OK;
441out:
442 return 0;
443}
444
445int
446bfad_iocmd_rport_get_attr(struct bfad_s *bfad, void *cmd)
447{
448 struct bfa_bsg_rport_attr_s *iocmd = (struct bfa_bsg_rport_attr_s *)cmd;
449 struct bfa_fcs_lport_s *fcs_port;
450 struct bfa_fcs_rport_s *fcs_rport;
451 unsigned long flags;
452
453 spin_lock_irqsave(&bfad->bfad_lock, flags);
454 fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs,
455 iocmd->vf_id, iocmd->pwwn);
456 if (fcs_port == NULL) {
457 bfa_trc(bfad, 0);
458 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
459 iocmd->status = BFA_STATUS_UNKNOWN_LWWN;
460 goto out;
461 }
462
463 fcs_rport = bfa_fcs_rport_lookup(fcs_port, iocmd->rpwwn);
464 if (fcs_rport == NULL) {
465 bfa_trc(bfad, 0);
466 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
467 iocmd->status = BFA_STATUS_UNKNOWN_RWWN;
468 goto out;
469 }
470
471 bfa_fcs_rport_get_attr(fcs_rport, &iocmd->attr);
472 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
473 iocmd->status = BFA_STATUS_OK;
474out:
475 return 0;
476}
477
166static int 478static int
167bfad_iocmd_rport_get_addr(struct bfad_s *bfad, void *cmd) 479bfad_iocmd_rport_get_addr(struct bfad_s *bfad, void *cmd)
168{ 480{
@@ -212,6 +524,45 @@ out:
212 return 0; 524 return 0;
213} 525}
214 526
527int
528bfad_iocmd_rport_get_stats(struct bfad_s *bfad, void *cmd)
529{
530 struct bfa_bsg_rport_stats_s *iocmd =
531 (struct bfa_bsg_rport_stats_s *)cmd;
532 struct bfa_fcs_lport_s *fcs_port;
533 struct bfa_fcs_rport_s *fcs_rport;
534 unsigned long flags;
535
536 spin_lock_irqsave(&bfad->bfad_lock, flags);
537 fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs,
538 iocmd->vf_id, iocmd->pwwn);
539 if (fcs_port == NULL) {
540 bfa_trc(bfad, 0);
541 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
542 iocmd->status = BFA_STATUS_UNKNOWN_LWWN;
543 goto out;
544 }
545
546 fcs_rport = bfa_fcs_rport_lookup(fcs_port, iocmd->rpwwn);
547 if (fcs_rport == NULL) {
548 bfa_trc(bfad, 0);
549 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
550 iocmd->status = BFA_STATUS_UNKNOWN_RWWN;
551 goto out;
552 }
553
554 memcpy((void *)&iocmd->stats, (void *)&fcs_rport->stats,
555 sizeof(struct bfa_rport_stats_s));
556 memcpy((void *)&iocmd->stats.hal_stats,
557 (void *)&(bfa_fcs_rport_get_halrport(fcs_rport)->stats),
558 sizeof(struct bfa_rport_hal_stats_s));
559
560 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
561 iocmd->status = BFA_STATUS_OK;
562out:
563 return 0;
564}
565
215static int 566static int
216bfad_iocmd_fabric_get_lports(struct bfad_s *bfad, void *cmd, 567bfad_iocmd_fabric_get_lports(struct bfad_s *bfad, void *cmd,
217 unsigned int payload_len) 568 unsigned int payload_len)
@@ -254,6 +605,45 @@ out:
254 return 0; 605 return 0;
255} 606}
256 607
608int
609bfad_iocmd_fcpim_get_modstats(struct bfad_s *bfad, void *cmd)
610{
611 struct bfa_bsg_fcpim_modstats_s *iocmd =
612 (struct bfa_bsg_fcpim_modstats_s *)cmd;
613 struct bfa_fcpim_s *fcpim = BFA_FCPIM(&bfad->bfa);
614 struct list_head *qe, *qen;
615 struct bfa_itnim_s *itnim;
616 unsigned long flags;
617
618 spin_lock_irqsave(&bfad->bfad_lock, flags);
619 /* accumulate IO stats from itnim */
620 memset((void *)&iocmd->modstats, 0, sizeof(struct bfa_itnim_iostats_s));
621 list_for_each_safe(qe, qen, &fcpim->itnim_q) {
622 itnim = (struct bfa_itnim_s *) qe;
623 bfa_fcpim_add_stats(&iocmd->modstats, &(itnim->stats));
624 }
625 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
626 iocmd->status = BFA_STATUS_OK;
627 return 0;
628}
629
630int
631bfad_iocmd_fcpim_get_del_itn_stats(struct bfad_s *bfad, void *cmd)
632{
633 struct bfa_bsg_fcpim_del_itn_stats_s *iocmd =
634 (struct bfa_bsg_fcpim_del_itn_stats_s *)cmd;
635 struct bfa_fcpim_s *fcpim = BFA_FCPIM(&bfad->bfa);
636 unsigned long flags;
637
638 spin_lock_irqsave(&bfad->bfad_lock, flags);
639 memcpy((void *)&iocmd->modstats, (void *)&fcpim->del_itn_stats,
640 sizeof(struct bfa_fcpim_del_itn_stats_s));
641 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
642
643 iocmd->status = BFA_STATUS_OK;
644 return 0;
645}
646
257static int 647static int
258bfad_iocmd_itnim_get_attr(struct bfad_s *bfad, void *cmd) 648bfad_iocmd_itnim_get_attr(struct bfad_s *bfad, void *cmd)
259{ 649{
@@ -273,6 +663,91 @@ bfad_iocmd_itnim_get_attr(struct bfad_s *bfad, void *cmd)
273 return 0; 663 return 0;
274} 664}
275 665
666static int
667bfad_iocmd_itnim_get_iostats(struct bfad_s *bfad, void *cmd)
668{
669 struct bfa_bsg_itnim_iostats_s *iocmd =
670 (struct bfa_bsg_itnim_iostats_s *)cmd;
671 struct bfa_fcs_lport_s *fcs_port;
672 struct bfa_fcs_itnim_s *itnim;
673 unsigned long flags;
674
675 spin_lock_irqsave(&bfad->bfad_lock, flags);
676 fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs,
677 iocmd->vf_id, iocmd->lpwwn);
678 if (!fcs_port) {
679 iocmd->status = BFA_STATUS_UNKNOWN_LWWN;
680 bfa_trc(bfad, 0);
681 } else {
682 itnim = bfa_fcs_itnim_lookup(fcs_port, iocmd->rpwwn);
683 if (itnim == NULL)
684 iocmd->status = BFA_STATUS_UNKNOWN_RWWN;
685 else {
686 iocmd->status = BFA_STATUS_OK;
687 memcpy((void *)&iocmd->iostats, (void *)
688 &(bfa_fcs_itnim_get_halitn(itnim)->stats),
689 sizeof(struct bfa_itnim_iostats_s));
690 }
691 }
692 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
693 return 0;
694}
695
696static int
697bfad_iocmd_itnim_get_itnstats(struct bfad_s *bfad, void *cmd)
698{
699 struct bfa_bsg_itnim_itnstats_s *iocmd =
700 (struct bfa_bsg_itnim_itnstats_s *)cmd;
701 struct bfa_fcs_lport_s *fcs_port;
702 struct bfa_fcs_itnim_s *itnim;
703 unsigned long flags;
704
705 spin_lock_irqsave(&bfad->bfad_lock, flags);
706 fcs_port = bfa_fcs_lookup_port(&bfad->bfa_fcs,
707 iocmd->vf_id, iocmd->lpwwn);
708 if (!fcs_port) {
709 iocmd->status = BFA_STATUS_UNKNOWN_LWWN;
710 bfa_trc(bfad, 0);
711 } else {
712 itnim = bfa_fcs_itnim_lookup(fcs_port, iocmd->rpwwn);
713 if (itnim == NULL)
714 iocmd->status = BFA_STATUS_UNKNOWN_RWWN;
715 else {
716 iocmd->status = BFA_STATUS_OK;
717 bfa_fcs_itnim_stats_get(fcs_port, iocmd->rpwwn,
718 &iocmd->itnstats);
719 }
720 }
721 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
722 return 0;
723}
724
725int
726bfad_iocmd_fcport_enable(struct bfad_s *bfad, void *cmd)
727{
728 struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd;
729 unsigned long flags;
730
731 spin_lock_irqsave(&bfad->bfad_lock, flags);
732 iocmd->status = bfa_fcport_enable(&bfad->bfa);
733 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
734
735 return 0;
736}
737
738int
739bfad_iocmd_fcport_disable(struct bfad_s *bfad, void *cmd)
740{
741 struct bfa_bsg_gen_s *iocmd = (struct bfa_bsg_gen_s *)cmd;
742 unsigned long flags;
743
744 spin_lock_irqsave(&bfad->bfad_lock, flags);
745 iocmd->status = bfa_fcport_disable(&bfad->bfa);
746 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
747
748 return 0;
749}
750
276int 751int
277bfad_iocmd_ioc_get_pcifn_cfg(struct bfad_s *bfad, void *cmd) 752bfad_iocmd_ioc_get_pcifn_cfg(struct bfad_s *bfad, void *cmd)
278{ 753{
@@ -511,27 +986,87 @@ bfad_iocmd_handler(struct bfad_s *bfad, unsigned int cmd, void *iocmd,
511 int rc = EINVAL; 986 int rc = EINVAL;
512 987
513 switch (cmd) { 988 switch (cmd) {
989 case IOCMD_IOC_ENABLE:
990 rc = bfad_iocmd_ioc_enable(bfad, iocmd);
991 break;
992 case IOCMD_IOC_DISABLE:
993 rc = bfad_iocmd_ioc_disable(bfad, iocmd);
994 break;
514 case IOCMD_IOC_GET_INFO: 995 case IOCMD_IOC_GET_INFO:
515 rc = bfad_iocmd_ioc_get_info(bfad, iocmd); 996 rc = bfad_iocmd_ioc_get_info(bfad, iocmd);
516 break; 997 break;
517 case IOCMD_IOC_GET_ATTR: 998 case IOCMD_IOC_GET_ATTR:
518 rc = bfad_iocmd_ioc_get_attr(bfad, iocmd); 999 rc = bfad_iocmd_ioc_get_attr(bfad, iocmd);
519 break; 1000 break;
1001 case IOCMD_IOC_GET_STATS:
1002 rc = bfad_iocmd_ioc_get_stats(bfad, iocmd);
1003 break;
1004 case IOCMD_IOC_GET_FWSTATS:
1005 rc = bfad_iocmd_ioc_get_fwstats(bfad, iocmd, payload_len);
1006 break;
1007 case IOCMD_IOCFC_GET_ATTR:
1008 rc = bfad_iocmd_iocfc_get_attr(bfad, iocmd);
1009 break;
1010 case IOCMD_IOCFC_SET_INTR:
1011 rc = bfad_iocmd_iocfc_set_intr(bfad, iocmd);
1012 break;
1013 case IOCMD_PORT_ENABLE:
1014 rc = bfad_iocmd_port_enable(bfad, iocmd);
1015 break;
1016 case IOCMD_PORT_DISABLE:
1017 rc = bfad_iocmd_port_disable(bfad, iocmd);
1018 break;
520 case IOCMD_PORT_GET_ATTR: 1019 case IOCMD_PORT_GET_ATTR:
521 rc = bfad_iocmd_port_get_attr(bfad, iocmd); 1020 rc = bfad_iocmd_port_get_attr(bfad, iocmd);
522 break; 1021 break;
1022 case IOCMD_PORT_GET_STATS:
1023 rc = bfad_iocmd_port_get_stats(bfad, iocmd, payload_len);
1024 break;
523 case IOCMD_LPORT_GET_ATTR: 1025 case IOCMD_LPORT_GET_ATTR:
524 rc = bfad_iocmd_lport_get_attr(bfad, iocmd); 1026 rc = bfad_iocmd_lport_get_attr(bfad, iocmd);
525 break; 1027 break;
1028 case IOCMD_LPORT_GET_STATS:
1029 rc = bfad_iocmd_lport_get_stats(bfad, iocmd);
1030 break;
1031 case IOCMD_LPORT_GET_IOSTATS:
1032 rc = bfad_iocmd_lport_get_iostats(bfad, iocmd);
1033 break;
1034 case IOCMD_LPORT_GET_RPORTS:
1035 rc = bfad_iocmd_lport_get_rports(bfad, iocmd, payload_len);
1036 break;
1037 case IOCMD_RPORT_GET_ATTR:
1038 rc = bfad_iocmd_rport_get_attr(bfad, iocmd);
1039 break;
526 case IOCMD_RPORT_GET_ADDR: 1040 case IOCMD_RPORT_GET_ADDR:
527 rc = bfad_iocmd_rport_get_addr(bfad, iocmd); 1041 rc = bfad_iocmd_rport_get_addr(bfad, iocmd);
528 break; 1042 break;
1043 case IOCMD_RPORT_GET_STATS:
1044 rc = bfad_iocmd_rport_get_stats(bfad, iocmd);
1045 break;
529 case IOCMD_FABRIC_GET_LPORTS: 1046 case IOCMD_FABRIC_GET_LPORTS:
530 rc = bfad_iocmd_fabric_get_lports(bfad, iocmd, payload_len); 1047 rc = bfad_iocmd_fabric_get_lports(bfad, iocmd, payload_len);
531 break; 1048 break;
1049 case IOCMD_FCPIM_MODSTATS:
1050 rc = bfad_iocmd_fcpim_get_modstats(bfad, iocmd);
1051 break;
1052 case IOCMD_FCPIM_DEL_ITN_STATS:
1053 rc = bfad_iocmd_fcpim_get_del_itn_stats(bfad, iocmd);
1054 break;
532 case IOCMD_ITNIM_GET_ATTR: 1055 case IOCMD_ITNIM_GET_ATTR:
533 rc = bfad_iocmd_itnim_get_attr(bfad, iocmd); 1056 rc = bfad_iocmd_itnim_get_attr(bfad, iocmd);
534 break; 1057 break;
1058 case IOCMD_ITNIM_GET_IOSTATS:
1059 rc = bfad_iocmd_itnim_get_iostats(bfad, iocmd);
1060 break;
1061 case IOCMD_ITNIM_GET_ITNSTATS:
1062 rc = bfad_iocmd_itnim_get_itnstats(bfad, iocmd);
1063 break;
1064 case IOCMD_FCPORT_ENABLE:
1065 rc = bfad_iocmd_fcport_enable(bfad, iocmd);
1066 break;
1067 case IOCMD_FCPORT_DISABLE:
1068 rc = bfad_iocmd_fcport_disable(bfad, iocmd);
1069 break;
535 case IOCMD_IOC_PCIFN_CFG: 1070 case IOCMD_IOC_PCIFN_CFG:
536 rc = bfad_iocmd_ioc_get_pcifn_cfg(bfad, iocmd); 1071 rc = bfad_iocmd_ioc_get_pcifn_cfg(bfad, iocmd);
537 break; 1072 break;
diff --git a/drivers/scsi/bfa/bfad_bsg.h b/drivers/scsi/bfa/bfad_bsg.h
index 49f558fc2375..0abb2d2036a3 100644
--- a/drivers/scsi/bfa/bfad_bsg.h
+++ b/drivers/scsi/bfa/bfad_bsg.h
@@ -24,14 +24,34 @@
24 * using FC_BSG_HST_VENDOR message code. 24 * using FC_BSG_HST_VENDOR message code.
25 */ 25 */
26enum { 26enum {
27 IOCMD_IOC_GET_ATTR = 0x1, 27 IOCMD_IOC_ENABLE = 0x1,
28 IOCMD_IOC_DISABLE,
29 IOCMD_IOC_GET_ATTR,
28 IOCMD_IOC_GET_INFO, 30 IOCMD_IOC_GET_INFO,
31 IOCMD_IOC_GET_STATS,
32 IOCMD_IOC_GET_FWSTATS,
33 IOCMD_IOCFC_GET_ATTR,
34 IOCMD_IOCFC_SET_INTR,
35 IOCMD_PORT_ENABLE,
36 IOCMD_PORT_DISABLE,
29 IOCMD_PORT_GET_ATTR, 37 IOCMD_PORT_GET_ATTR,
38 IOCMD_PORT_GET_STATS,
30 IOCMD_LPORT_GET_ATTR, 39 IOCMD_LPORT_GET_ATTR,
40 IOCMD_LPORT_GET_RPORTS,
41 IOCMD_LPORT_GET_STATS,
42 IOCMD_LPORT_GET_IOSTATS,
43 IOCMD_RPORT_GET_ATTR,
31 IOCMD_RPORT_GET_ADDR, 44 IOCMD_RPORT_GET_ADDR,
45 IOCMD_RPORT_GET_STATS,
32 IOCMD_FABRIC_GET_LPORTS, 46 IOCMD_FABRIC_GET_LPORTS,
47 IOCMD_FCPIM_MODSTATS,
48 IOCMD_FCPIM_DEL_ITN_STATS,
33 IOCMD_ITNIM_GET_ATTR, 49 IOCMD_ITNIM_GET_ATTR,
50 IOCMD_ITNIM_GET_IOSTATS,
51 IOCMD_ITNIM_GET_ITNSTATS,
34 IOCMD_IOC_PCIFN_CFG, 52 IOCMD_IOC_PCIFN_CFG,
53 IOCMD_FCPORT_ENABLE,
54 IOCMD_FCPORT_DISABLE,
35 IOCMD_PCIFN_CREATE, 55 IOCMD_PCIFN_CREATE,
36 IOCMD_PCIFN_DELETE, 56 IOCMD_PCIFN_DELETE,
37 IOCMD_PCIFN_BW, 57 IOCMD_PCIFN_BW,
@@ -83,6 +103,36 @@ struct bfa_bsg_ioc_attr_s {
83 struct bfa_ioc_attr_s ioc_attr; 103 struct bfa_ioc_attr_s ioc_attr;
84}; 104};
85 105
106struct bfa_bsg_ioc_stats_s {
107 bfa_status_t status;
108 u16 bfad_num;
109 u16 rsvd;
110 struct bfa_ioc_stats_s ioc_stats;
111};
112
113struct bfa_bsg_ioc_fwstats_s {
114 bfa_status_t status;
115 u16 bfad_num;
116 u16 rsvd;
117 u32 buf_size;
118 u32 rsvd1;
119 u64 buf_ptr;
120};
121
122struct bfa_bsg_iocfc_attr_s {
123 bfa_status_t status;
124 u16 bfad_num;
125 u16 rsvd;
126 struct bfa_iocfc_attr_s iocfc_attr;
127};
128
129struct bfa_bsg_iocfc_intr_s {
130 bfa_status_t status;
131 u16 bfad_num;
132 u16 rsvd;
133 struct bfa_iocfc_intr_attr_s attr;
134};
135
86struct bfa_bsg_port_attr_s { 136struct bfa_bsg_port_attr_s {
87 bfa_status_t status; 137 bfa_status_t status;
88 u16 bfad_num; 138 u16 bfad_num;
@@ -90,6 +140,15 @@ struct bfa_bsg_port_attr_s {
90 struct bfa_port_attr_s attr; 140 struct bfa_port_attr_s attr;
91}; 141};
92 142
143struct bfa_bsg_port_stats_s {
144 bfa_status_t status;
145 u16 bfad_num;
146 u16 rsvd;
147 u32 buf_size;
148 u32 rsvd1;
149 u64 buf_ptr;
150};
151
93struct bfa_bsg_lport_attr_s { 152struct bfa_bsg_lport_attr_s {
94 bfa_status_t status; 153 bfa_status_t status;
95 u16 bfad_num; 154 u16 bfad_num;
@@ -98,6 +157,50 @@ struct bfa_bsg_lport_attr_s {
98 struct bfa_lport_attr_s port_attr; 157 struct bfa_lport_attr_s port_attr;
99}; 158};
100 159
160struct bfa_bsg_lport_stats_s {
161 bfa_status_t status;
162 u16 bfad_num;
163 u16 vf_id;
164 wwn_t pwwn;
165 struct bfa_lport_stats_s port_stats;
166};
167
168struct bfa_bsg_lport_iostats_s {
169 bfa_status_t status;
170 u16 bfad_num;
171 u16 vf_id;
172 wwn_t pwwn;
173 struct bfa_itnim_iostats_s iostats;
174};
175
176struct bfa_bsg_lport_get_rports_s {
177 bfa_status_t status;
178 u16 bfad_num;
179 u16 vf_id;
180 wwn_t pwwn;
181 u64 rbuf_ptr;
182 u32 nrports;
183 u32 rsvd;
184};
185
186struct bfa_bsg_rport_attr_s {
187 bfa_status_t status;
188 u16 bfad_num;
189 u16 vf_id;
190 wwn_t pwwn;
191 wwn_t rpwwn;
192 struct bfa_rport_attr_s attr;
193};
194
195struct bfa_bsg_rport_stats_s {
196 bfa_status_t status;
197 u16 bfad_num;
198 u16 vf_id;
199 wwn_t pwwn;
200 wwn_t rpwwn;
201 struct bfa_rport_stats_s stats;
202};
203
101struct bfa_bsg_rport_scsi_addr_s { 204struct bfa_bsg_rport_scsi_addr_s {
102 bfa_status_t status; 205 bfa_status_t status;
103 u16 bfad_num; 206 u16 bfad_num;
@@ -119,6 +222,18 @@ struct bfa_bsg_fabric_get_lports_s {
119 u32 rsvd; 222 u32 rsvd;
120}; 223};
121 224
225struct bfa_bsg_fcpim_modstats_s {
226 bfa_status_t status;
227 u16 bfad_num;
228 struct bfa_itnim_iostats_s modstats;
229};
230
231struct bfa_bsg_fcpim_del_itn_stats_s {
232 bfa_status_t status;
233 u16 bfad_num;
234 struct bfa_fcpim_del_itn_stats_s modstats;
235};
236
122struct bfa_bsg_itnim_attr_s { 237struct bfa_bsg_itnim_attr_s {
123 bfa_status_t status; 238 bfa_status_t status;
124 u16 bfad_num; 239 u16 bfad_num;
@@ -128,6 +243,24 @@ struct bfa_bsg_itnim_attr_s {
128 struct bfa_itnim_attr_s attr; 243 struct bfa_itnim_attr_s attr;
129}; 244};
130 245
246struct bfa_bsg_itnim_iostats_s {
247 bfa_status_t status;
248 u16 bfad_num;
249 u16 vf_id;
250 wwn_t lpwwn;
251 wwn_t rpwwn;
252 struct bfa_itnim_iostats_s iostats;
253};
254
255struct bfa_bsg_itnim_itnstats_s {
256 bfa_status_t status;
257 u16 bfad_num;
258 u16 vf_id;
259 wwn_t lpwwn;
260 wwn_t rpwwn;
261 struct bfa_itnim_stats_s itnstats;
262};
263
131struct bfa_bsg_pcifn_cfg_s { 264struct bfa_bsg_pcifn_cfg_s {
132 bfa_status_t status; 265 bfa_status_t status;
133 u16 bfad_num; 266 u16 bfad_num;
diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h
index 35bf0a630a68..6363dd7e15b4 100644
--- a/drivers/scsi/bfa/bfad_drv.h
+++ b/drivers/scsi/bfa/bfad_drv.h
@@ -194,6 +194,7 @@ struct bfad_s {
194 void __iomem *pci_bar2_kva; 194 void __iomem *pci_bar2_kva;
195 struct completion comp; 195 struct completion comp;
196 struct completion suspend; 196 struct completion suspend;
197 struct completion enable_comp;
197 struct completion disable_comp; 198 struct completion disable_comp;
198 bfa_boolean_t disable_active; 199 bfa_boolean_t disable_active;
199 struct bfad_port_s pport; /* physical port of the BFAD */ 200 struct bfad_port_s pport; /* physical port of the BFAD */