Skip to content

Commit 37ea055

Browse files
Krishna GudipatiJames Bottomley
authored andcommitted
[SCSI] bfa: Added support to collect and reset fcport stats
- Added support to collect and reset fcport stats. - Modified design to allow multiple requests for fcport stats. - fcport will remember the stats request in its stats_pending queue and service each of the queued requests after receiving a firmware response for the prior request. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 42a8e6e commit 37ea055

7 files changed

Lines changed: 172 additions & 69 deletions

File tree

‎drivers/scsi/bfa/bfa.h‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
struct bfa_s;
2828

2929
typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m);
30+
typedef void (*bfa_cb_cbfn_status_t) (void *cbarg, bfa_status_t status);
3031

3132
/*
3233
* Interrupt message handlers
@@ -121,6 +122,7 @@ bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
121122
#define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
122123
(__hcb_qe)->cbfn = (__cbfn); \
123124
(__hcb_qe)->cbarg = (__cbarg); \
125+
(__hcb_qe)->pre_rmv = BFA_FALSE; \
124126
list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
125127
} while (0)
126128

@@ -135,6 +137,11 @@ bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
135137
} \
136138
} while (0)
137139

140+
#define bfa_cb_queue_status(__bfa, __hcb_qe, __status) do { \
141+
(__hcb_qe)->fw_status = (__status); \
142+
list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
143+
} while (0)
144+
138145
#define bfa_cb_queue_done(__hcb_qe) do { \
139146
(__hcb_qe)->once = BFA_FALSE; \
140147
} while (0)
@@ -408,4 +415,18 @@ void bfa_iocfc_disable(struct bfa_s *bfa);
408415
#define bfa_timer_start(_bfa, _timer, _timercb, _arg, _timeout) \
409416
bfa_timer_begin(&(_bfa)->timer_mod, _timer, _timercb, _arg, _timeout)
410417

418+
struct bfa_cb_pending_q_s {
419+
struct bfa_cb_qe_s hcb_qe;
420+
void *data; /* Driver buffer */
421+
};
422+
423+
/* Common macros to operate on pending stats/attr apis */
424+
#define bfa_pending_q_init(__qe, __cbfn, __cbarg, __data) do { \
425+
bfa_q_qe_init(&((__qe)->hcb_qe.qe)); \
426+
(__qe)->hcb_qe.cbfn = (__cbfn); \
427+
(__qe)->hcb_qe.cbarg = (__cbarg); \
428+
(__qe)->hcb_qe.pre_rmv = BFA_TRUE; \
429+
(__qe)->data = (__data); \
430+
} while (0)
431+
411432
#endif /* __BFA_H__ */

‎drivers/scsi/bfa/bfa_core.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,10 +1533,17 @@ bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q)
15331533
struct list_head *qe;
15341534
struct list_head *qen;
15351535
struct bfa_cb_qe_s *hcb_qe;
1536+
bfa_cb_cbfn_status_t cbfn;
15361537

15371538
list_for_each_safe(qe, qen, comp_q) {
15381539
hcb_qe = (struct bfa_cb_qe_s *) qe;
1539-
hcb_qe->cbfn(hcb_qe->cbarg, BFA_TRUE);
1540+
if (hcb_qe->pre_rmv) {
1541+
/* qe is invalid after return, dequeue before cbfn() */
1542+
list_del(qe);
1543+
cbfn = (bfa_cb_cbfn_status_t)(hcb_qe->cbfn);
1544+
cbfn(hcb_qe->cbarg, hcb_qe->fw_status);
1545+
} else
1546+
hcb_qe->cbfn(hcb_qe->cbarg, BFA_TRUE);
15401547
}
15411548
}
15421549

@@ -1549,6 +1556,7 @@ bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q)
15491556
while (!list_empty(comp_q)) {
15501557
bfa_q_deq(comp_q, &qe);
15511558
hcb_qe = (struct bfa_cb_qe_s *) qe;
1559+
WARN_ON(hcb_qe->pre_rmv);
15521560
hcb_qe->cbfn(hcb_qe->cbarg, BFA_FALSE);
15531561
}
15541562
}

‎drivers/scsi/bfa/bfa_ioc.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ struct bfa_cb_qe_s {
367367
struct list_head qe;
368368
bfa_cb_cbfn_t cbfn;
369369
bfa_boolean_t once;
370+
bfa_boolean_t pre_rmv; /* set for stack based qe(s) */
371+
bfa_status_t fw_status; /* to access fw status in comp proc */
370372
void *cbarg;
371373
};
372374

‎drivers/scsi/bfa/bfa_svc.c‎

Lines changed: 71 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,6 +2910,9 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
29102910

29112911
port_cfg->trl_def_speed = BFA_PORT_SPEED_1GBPS;
29122912

2913+
INIT_LIST_HEAD(&fcport->stats_pending_q);
2914+
INIT_LIST_HEAD(&fcport->statsclr_pending_q);
2915+
29132916
bfa_reqq_winit(&fcport->reqq_wait, bfa_fcport_qresume, fcport);
29142917
}
29152918

@@ -3138,30 +3141,38 @@ bfa_fcport_fcoe_stats_swap(struct bfa_fcoe_stats_s *d,
31383141
static void
31393142
__bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete)
31403143
{
3141-
struct bfa_fcport_s *fcport = cbarg;
3144+
struct bfa_fcport_s *fcport = (struct bfa_fcport_s *)cbarg;
3145+
struct bfa_cb_pending_q_s *cb;
3146+
struct list_head *qe, *qen;
3147+
union bfa_fcport_stats_u *ret;
31423148

31433149
if (complete) {
3144-
if (fcport->stats_status == BFA_STATUS_OK) {
3145-
struct timeval tv;
3146-
3147-
/* Swap FC QoS or FCoE stats */
3148-
if (bfa_ioc_get_fcmode(&fcport->bfa->ioc)) {
3149-
bfa_fcport_qos_stats_swap(
3150-
&fcport->stats_ret->fcqos,
3151-
&fcport->stats->fcqos);
3152-
} else {
3153-
bfa_fcport_fcoe_stats_swap(
3154-
&fcport->stats_ret->fcoe,
3155-
&fcport->stats->fcoe);
3156-
3157-
do_gettimeofday(&tv);
3158-
fcport->stats_ret->fcoe.secs_reset =
3150+
struct timeval tv;
3151+
if (fcport->stats_status == BFA_STATUS_OK)
3152+
do_gettimeofday(&tv);
3153+
3154+
list_for_each_safe(qe, qen, &fcport->stats_pending_q) {
3155+
bfa_q_deq(&fcport->stats_pending_q, &qe);
3156+
cb = (struct bfa_cb_pending_q_s *)qe;
3157+
if (fcport->stats_status == BFA_STATUS_OK) {
3158+
ret = (union bfa_fcport_stats_u *)cb->data;
3159+
/* Swap FC QoS or FCoE stats */
3160+
if (bfa_ioc_get_fcmode(&fcport->bfa->ioc))
3161+
bfa_fcport_qos_stats_swap(&ret->fcqos,
3162+
&fcport->stats->fcqos);
3163+
else {
3164+
bfa_fcport_fcoe_stats_swap(&ret->fcoe,
3165+
&fcport->stats->fcoe);
3166+
ret->fcoe.secs_reset =
31593167
tv.tv_sec - fcport->stats_reset_time;
3168+
}
31603169
}
3170+
bfa_cb_queue_status(fcport->bfa, &cb->hcb_qe,
3171+
fcport->stats_status);
31613172
}
3162-
fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status);
3173+
fcport->stats_status = BFA_STATUS_OK;
31633174
} else {
3164-
fcport->stats_busy = BFA_FALSE;
3175+
INIT_LIST_HEAD(&fcport->stats_pending_q);
31653176
fcport->stats_status = BFA_STATUS_OK;
31663177
}
31673178
}
@@ -3179,8 +3190,7 @@ bfa_fcport_stats_get_timeout(void *cbarg)
31793190
}
31803191

31813192
fcport->stats_status = BFA_STATUS_ETIMER;
3182-
bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, __bfa_cb_fcport_stats_get,
3183-
fcport);
3193+
__bfa_cb_fcport_stats_get(fcport, BFA_TRUE);
31843194
}
31853195

31863196
static void
@@ -3210,7 +3220,9 @@ bfa_fcport_send_stats_get(void *cbarg)
32103220
static void
32113221
__bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete)
32123222
{
3213-
struct bfa_fcport_s *fcport = cbarg;
3223+
struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
3224+
struct bfa_cb_pending_q_s *cb;
3225+
struct list_head *qe, *qen;
32143226

32153227
if (complete) {
32163228
struct timeval tv;
@@ -3220,10 +3232,15 @@ __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete)
32203232
*/
32213233
do_gettimeofday(&tv);
32223234
fcport->stats_reset_time = tv.tv_sec;
3223-
3224-
fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status);
3235+
list_for_each_safe(qe, qen, &fcport->statsclr_pending_q) {
3236+
bfa_q_deq(&fcport->statsclr_pending_q, &qe);
3237+
cb = (struct bfa_cb_pending_q_s *)qe;
3238+
bfa_cb_queue_status(fcport->bfa, &cb->hcb_qe,
3239+
fcport->stats_status);
3240+
}
3241+
fcport->stats_status = BFA_STATUS_OK;
32253242
} else {
3226-
fcport->stats_busy = BFA_FALSE;
3243+
INIT_LIST_HEAD(&fcport->statsclr_pending_q);
32273244
fcport->stats_status = BFA_STATUS_OK;
32283245
}
32293246
}
@@ -3241,8 +3258,7 @@ bfa_fcport_stats_clr_timeout(void *cbarg)
32413258
}
32423259

32433260
fcport->stats_status = BFA_STATUS_ETIMER;
3244-
bfa_cb_queue(fcport->bfa, &fcport->hcb_qe,
3245-
__bfa_cb_fcport_stats_clr, fcport);
3261+
__bfa_cb_fcport_stats_clr(fcport, BFA_TRUE);
32463262
}
32473263

32483264
static void
@@ -3462,28 +3478,26 @@ bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
34623478
/*
34633479
* check for timer pop before processing the rsp
34643480
*/
3465-
if (fcport->stats_busy == BFA_FALSE ||
3466-
fcport->stats_status == BFA_STATUS_ETIMER)
3481+
if (list_empty(&fcport->stats_pending_q) ||
3482+
(fcport->stats_status == BFA_STATUS_ETIMER))
34673483
break;
34683484

34693485
bfa_timer_stop(&fcport->timer);
34703486
fcport->stats_status = i2hmsg.pstatsget_rsp->status;
3471-
bfa_cb_queue(fcport->bfa, &fcport->hcb_qe,
3472-
__bfa_cb_fcport_stats_get, fcport);
3487+
__bfa_cb_fcport_stats_get(fcport, BFA_TRUE);
34733488
break;
34743489

34753490
case BFI_FCPORT_I2H_STATS_CLEAR_RSP:
34763491
/*
34773492
* check for timer pop before processing the rsp
34783493
*/
3479-
if (fcport->stats_busy == BFA_FALSE ||
3480-
fcport->stats_status == BFA_STATUS_ETIMER)
3494+
if (list_empty(&fcport->statsclr_pending_q) ||
3495+
(fcport->stats_status == BFA_STATUS_ETIMER))
34813496
break;
34823497

34833498
bfa_timer_stop(&fcport->timer);
34843499
fcport->stats_status = BFA_STATUS_OK;
3485-
bfa_cb_queue(fcport->bfa, &fcport->hcb_qe,
3486-
__bfa_cb_fcport_stats_clr, fcport);
3500+
__bfa_cb_fcport_stats_clr(fcport, BFA_TRUE);
34873501
break;
34883502

34893503
case BFI_FCPORT_I2H_ENABLE_AEN:
@@ -3815,53 +3829,51 @@ bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr)
38153829
* Fetch port statistics (FCQoS or FCoE).
38163830
*/
38173831
bfa_status_t
3818-
bfa_fcport_get_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats,
3819-
bfa_cb_port_t cbfn, void *cbarg)
3832+
bfa_fcport_get_stats(struct bfa_s *bfa, struct bfa_cb_pending_q_s *cb)
38203833
{
38213834
struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
38223835

3823-
if (fcport->stats_busy) {
3824-
bfa_trc(bfa, fcport->stats_busy);
3825-
return BFA_STATUS_DEVBUSY;
3826-
}
3836+
if (bfa_ioc_is_disabled(&bfa->ioc))
3837+
return BFA_STATUS_IOC_DISABLED;
38273838

3828-
fcport->stats_busy = BFA_TRUE;
3829-
fcport->stats_ret = stats;
3830-
fcport->stats_cbfn = cbfn;
3831-
fcport->stats_cbarg = cbarg;
3839+
if (!list_empty(&fcport->statsclr_pending_q))
3840+
return BFA_STATUS_DEVBUSY;
38323841

3833-
bfa_fcport_send_stats_get(fcport);
3842+
if (list_empty(&fcport->stats_pending_q)) {
3843+
list_add_tail(&cb->hcb_qe.qe, &fcport->stats_pending_q);
3844+
bfa_fcport_send_stats_get(fcport);
3845+
bfa_timer_start(bfa, &fcport->timer,
3846+
bfa_fcport_stats_get_timeout,
3847+
fcport, BFA_FCPORT_STATS_TOV);
3848+
} else
3849+
list_add_tail(&cb->hcb_qe.qe, &fcport->stats_pending_q);
38343850

3835-
bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_get_timeout,
3836-
fcport, BFA_FCPORT_STATS_TOV);
38373851
return BFA_STATUS_OK;
38383852
}
38393853

38403854
/*
38413855
* Reset port statistics (FCQoS or FCoE).
38423856
*/
38433857
bfa_status_t
3844-
bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_port_t cbfn, void *cbarg)
3858+
bfa_fcport_clear_stats(struct bfa_s *bfa, struct bfa_cb_pending_q_s *cb)
38453859
{
38463860
struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
38473861

3848-
if (fcport->stats_busy) {
3849-
bfa_trc(bfa, fcport->stats_busy);
3862+
if (!list_empty(&fcport->stats_pending_q))
38503863
return BFA_STATUS_DEVBUSY;
3851-
}
38523864

3853-
fcport->stats_busy = BFA_TRUE;
3854-
fcport->stats_cbfn = cbfn;
3855-
fcport->stats_cbarg = cbarg;
3865+
if (list_empty(&fcport->statsclr_pending_q)) {
3866+
list_add_tail(&cb->hcb_qe.qe, &fcport->statsclr_pending_q);
3867+
bfa_fcport_send_stats_clear(fcport);
3868+
bfa_timer_start(bfa, &fcport->timer,
3869+
bfa_fcport_stats_clr_timeout,
3870+
fcport, BFA_FCPORT_STATS_TOV);
3871+
} else
3872+
list_add_tail(&cb->hcb_qe.qe, &fcport->statsclr_pending_q);
38563873

3857-
bfa_fcport_send_stats_clear(fcport);
3858-
3859-
bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_clr_timeout,
3860-
fcport, BFA_FCPORT_STATS_TOV);
38613874
return BFA_STATUS_OK;
38623875
}
38633876

3864-
38653877
/*
38663878
* Fetch port attributes.
38673879
*/

‎drivers/scsi/bfa/bfa_svc.h‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
441441
*/
442442

443443
#define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
444-
typedef void (*bfa_cb_port_t) (void *cbarg, enum bfa_status status);
445444

446445
/*
447446
* Link notification data structure
@@ -495,13 +494,11 @@ struct bfa_fcport_s {
495494
u8 *stats_kva;
496495
u64 stats_pa;
497496
union bfa_fcport_stats_u *stats;
498-
union bfa_fcport_stats_u *stats_ret; /* driver stats location */
499497
bfa_status_t stats_status; /* stats/statsclr status */
500-
bfa_boolean_t stats_busy; /* outstanding stats/statsclr */
498+
struct list_head stats_pending_q;
499+
struct list_head statsclr_pending_q;
501500
bfa_boolean_t stats_qfull;
502501
u32 stats_reset_time; /* stats reset time stamp */
503-
bfa_cb_port_t stats_cbfn; /* driver callback function */
504-
void *stats_cbarg; /* *!< user callback arg */
505502
bfa_boolean_t diag_busy; /* diag busy status */
506503
bfa_boolean_t beacon; /* port beacon status */
507504
bfa_boolean_t link_e2e_beacon; /* link beacon status */
@@ -552,10 +549,9 @@ void bfa_fcport_beacon(void *dev, bfa_boolean_t beacon,
552549
bfa_boolean_t link_e2e_beacon);
553550
bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa);
554551
bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
555-
union bfa_fcport_stats_u *stats,
556-
bfa_cb_port_t cbfn, void *cbarg);
557-
bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_port_t cbfn,
558-
void *cbarg);
552+
struct bfa_cb_pending_q_s *cb);
553+
bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa,
554+
struct bfa_cb_pending_q_s *cb);
559555
bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
560556
bfa_boolean_t bfa_fcport_is_trunk_enabled(struct bfa_s *bfa);
561557
bfa_status_t bfa_fcport_is_pbcdisabled(struct bfa_s *bfa);

0 commit comments

Comments
 (0)