aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bna
diff options
context:
space:
mode:
authorRasesh Mody <rmody@brocade.com>2011-07-22 04:07:42 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-22 20:01:13 -0400
commitbd5a92e9a0eb03c4e7d04c64aa99e9050459faf5 (patch)
treefe2ea8edebefc97372a198346e1191f3db5bd87c /drivers/net/bna
parent0120b99c8d56b5d3f2d80aaf8769dea05ef80439 (diff)
bna: IOC Event Notification Enhancement
Change details: - Replace IOC HB failure event notification with a more generic mechanism that is capable of sending enble, disable, and failed events to registered modules. As a result, cee module event handling callback bfa_cee_hbfail() is replaced with bfa_cee_notify() so that it can receive and handle different events from IOC. Signed-off-by: Rasesh Mody <rmody@brocade.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bna')
-rw-r--r--drivers/net/bna/bfa_cee.c65
-rw-r--r--drivers/net/bna/bfa_cee.h3
-rw-r--r--drivers/net/bna/bfa_ioc.c54
-rw-r--r--drivers/net/bna/bfa_ioc.h31
4 files changed, 99 insertions, 54 deletions
diff --git a/drivers/net/bna/bfa_cee.c b/drivers/net/bna/bfa_cee.c
index dcfbf08bcf43..39e5ab9fde59 100644
--- a/drivers/net/bna/bfa_cee.c
+++ b/drivers/net/bna/bfa_cee.c
@@ -223,44 +223,56 @@ bfa_cee_isr(void *cbarg, struct bfi_mbmsg *m)
223} 223}
224 224
225/** 225/**
226 * bfa_cee_hbfail() 226 * bfa_cee_notify()
227 * 227 *
228 * @brief CEE module heart-beat failure handler. 228 * @brief CEE module heart-beat failure handler.
229 * @brief CEE module IOC event handler.
229 * 230 *
230 * @param[in] Pointer to the CEE module data structure. 231 * @param[in] IOC event type
231 * 232 *
232 * @return void 233 * @return void
233 */ 234 */
234 235
235static void 236static void
236bfa_cee_hbfail(void *arg) 237bfa_cee_notify(void *arg, enum bfa_ioc_event event)
237{ 238{
238 struct bfa_cee *cee; 239 struct bfa_cee *cee;
239 cee = arg; 240 cee = (struct bfa_cee *) arg;
240 241
241 if (cee->get_attr_pending == true) { 242 switch (event) {
242 cee->get_attr_status = BFA_STATUS_FAILED; 243 case BFA_IOC_E_DISABLED:
243 cee->get_attr_pending = false; 244 case BFA_IOC_E_FAILED:
244 if (cee->cbfn.get_attr_cbfn) { 245 if (cee->get_attr_pending == true) {
245 cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, 246 cee->get_attr_status = BFA_STATUS_FAILED;
246 BFA_STATUS_FAILED); 247 cee->get_attr_pending = false;
248 if (cee->cbfn.get_attr_cbfn) {
249 cee->cbfn.get_attr_cbfn(
250 cee->cbfn.get_attr_cbarg,
251 BFA_STATUS_FAILED);
252 }
247 } 253 }
248 } 254 if (cee->get_stats_pending == true) {
249 if (cee->get_stats_pending == true) { 255 cee->get_stats_status = BFA_STATUS_FAILED;
250 cee->get_stats_status = BFA_STATUS_FAILED; 256 cee->get_stats_pending = false;
251 cee->get_stats_pending = false; 257 if (cee->cbfn.get_stats_cbfn) {
252 if (cee->cbfn.get_stats_cbfn) { 258 cee->cbfn.get_stats_cbfn(
253 cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, 259 cee->cbfn.get_stats_cbarg,
254 BFA_STATUS_FAILED); 260 BFA_STATUS_FAILED);
261 }
255 } 262 }
256 } 263 if (cee->reset_stats_pending == true) {
257 if (cee->reset_stats_pending == true) { 264 cee->reset_stats_status = BFA_STATUS_FAILED;
258 cee->reset_stats_status = BFA_STATUS_FAILED; 265 cee->reset_stats_pending = false;
259 cee->reset_stats_pending = false; 266 if (cee->cbfn.reset_stats_cbfn) {
260 if (cee->cbfn.reset_stats_cbfn) { 267 cee->cbfn.reset_stats_cbfn(
261 cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, 268 cee->cbfn.reset_stats_cbarg,
262 BFA_STATUS_FAILED); 269 BFA_STATUS_FAILED);
270 }
263 } 271 }
272 break;
273
274 default:
275 break;
264 } 276 }
265} 277}
266 278
@@ -286,6 +298,7 @@ bfa_nw_cee_attach(struct bfa_cee *cee, struct bfa_ioc *ioc,
286 cee->ioc = ioc; 298 cee->ioc = ioc;
287 299
288 bfa_nw_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee); 300 bfa_nw_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
289 bfa_ioc_hbfail_init(&cee->hbfail, bfa_cee_hbfail, cee); 301 bfa_q_qe_init(&cee->ioc_notify);
290 bfa_nw_ioc_hbfail_register(cee->ioc, &cee->hbfail); 302 bfa_ioc_notify_init(&cee->ioc_notify, bfa_cee_notify, cee);
303 bfa_nw_ioc_notify_register(cee->ioc, &cee->ioc_notify);
291} 304}
diff --git a/drivers/net/bna/bfa_cee.h b/drivers/net/bna/bfa_cee.h
index 20543d15b64f..58d54e98d595 100644
--- a/drivers/net/bna/bfa_cee.h
+++ b/drivers/net/bna/bfa_cee.h
@@ -25,7 +25,6 @@
25typedef void (*bfa_cee_get_attr_cbfn_t) (void *dev, enum bfa_status status); 25typedef void (*bfa_cee_get_attr_cbfn_t) (void *dev, enum bfa_status status);
26typedef void (*bfa_cee_get_stats_cbfn_t) (void *dev, enum bfa_status status); 26typedef void (*bfa_cee_get_stats_cbfn_t) (void *dev, enum bfa_status status);
27typedef void (*bfa_cee_reset_stats_cbfn_t) (void *dev, enum bfa_status status); 27typedef void (*bfa_cee_reset_stats_cbfn_t) (void *dev, enum bfa_status status);
28typedef void (*bfa_cee_hbfail_cbfn_t) (void *dev, enum bfa_status status);
29 28
30struct bfa_cee_cbfn { 29struct bfa_cee_cbfn {
31 bfa_cee_get_attr_cbfn_t get_attr_cbfn; 30 bfa_cee_get_attr_cbfn_t get_attr_cbfn;
@@ -45,7 +44,7 @@ struct bfa_cee {
45 enum bfa_status get_stats_status; 44 enum bfa_status get_stats_status;
46 enum bfa_status reset_stats_status; 45 enum bfa_status reset_stats_status;
47 struct bfa_cee_cbfn cbfn; 46 struct bfa_cee_cbfn cbfn;
48 struct bfa_ioc_hbfail_notify hbfail; 47 struct bfa_ioc_notify ioc_notify;
49 struct bfa_cee_attr *attr; 48 struct bfa_cee_attr *attr;
50 struct bfa_cee_stats *stats; 49 struct bfa_cee_stats *stats;
51 struct bfa_dma attr_dma; 50 struct bfa_dma attr_dma;
diff --git a/drivers/net/bna/bfa_ioc.c b/drivers/net/bna/bfa_ioc.c
index 04bfb29bdc93..c52ef6347dc6 100644
--- a/drivers/net/bna/bfa_ioc.c
+++ b/drivers/net/bna/bfa_ioc.c
@@ -71,6 +71,7 @@ static void bfa_ioc_mbox_poll(struct bfa_ioc *ioc);
71static void bfa_ioc_mbox_hbfail(struct bfa_ioc *ioc); 71static void bfa_ioc_mbox_hbfail(struct bfa_ioc *ioc);
72static void bfa_ioc_recover(struct bfa_ioc *ioc); 72static void bfa_ioc_recover(struct bfa_ioc *ioc);
73static void bfa_ioc_check_attr_wwns(struct bfa_ioc *ioc); 73static void bfa_ioc_check_attr_wwns(struct bfa_ioc *ioc);
74static void bfa_ioc_event_notify(struct bfa_ioc *, enum bfa_ioc_event);
74static void bfa_ioc_disable_comp(struct bfa_ioc *ioc); 75static void bfa_ioc_disable_comp(struct bfa_ioc *ioc);
75static void bfa_ioc_lpu_stop(struct bfa_ioc *ioc); 76static void bfa_ioc_lpu_stop(struct bfa_ioc *ioc);
76static void bfa_ioc_fail_notify(struct bfa_ioc *ioc); 77static void bfa_ioc_fail_notify(struct bfa_ioc *ioc);
@@ -1123,23 +1124,28 @@ bfa_iocpf_sm_fail(struct bfa_iocpf *iocpf, enum iocpf_event event)
1123 * BFA IOC private functions 1124 * BFA IOC private functions
1124 */ 1125 */
1125 1126
1127/**
1128 * Notify common modules registered for notification.
1129 */
1126static void 1130static void
1127bfa_ioc_disable_comp(struct bfa_ioc *ioc) 1131bfa_ioc_event_notify(struct bfa_ioc *ioc, enum bfa_ioc_event event)
1128{ 1132{
1133 struct bfa_ioc_notify *notify;
1129 struct list_head *qe; 1134 struct list_head *qe;
1130 struct bfa_ioc_hbfail_notify *notify;
1131 1135
1132 ioc->cbfn->disable_cbfn(ioc->bfa); 1136 list_for_each(qe, &ioc->notify_q) {
1133 1137 notify = (struct bfa_ioc_notify *)qe;
1134 /** 1138 notify->cbfn(notify->cbarg, event);
1135 * Notify common modules registered for notification.
1136 */
1137 list_for_each(qe, &ioc->hb_notify_q) {
1138 notify = (struct bfa_ioc_hbfail_notify *) qe;
1139 notify->cbfn(notify->cbarg);
1140 } 1139 }
1141} 1140}
1142 1141
1142static void
1143bfa_ioc_disable_comp(struct bfa_ioc *ioc)
1144{
1145 ioc->cbfn->disable_cbfn(ioc->bfa);
1146 bfa_ioc_event_notify(ioc, BFA_IOC_E_DISABLED);
1147}
1148
1143bool 1149bool
1144bfa_nw_ioc_sem_get(void __iomem *sem_reg) 1150bfa_nw_ioc_sem_get(void __iomem *sem_reg)
1145{ 1151{
@@ -1650,17 +1656,11 @@ bfa_ioc_mbox_hbfail(struct bfa_ioc *ioc)
1650static void 1656static void
1651bfa_ioc_fail_notify(struct bfa_ioc *ioc) 1657bfa_ioc_fail_notify(struct bfa_ioc *ioc)
1652{ 1658{
1653 struct list_head *qe;
1654 struct bfa_ioc_hbfail_notify *notify;
1655
1656 /** 1659 /**
1657 * Notify driver and common modules registered for notification. 1660 * Notify driver and common modules registered for notification.
1658 */ 1661 */
1659 ioc->cbfn->hbfail_cbfn(ioc->bfa); 1662 ioc->cbfn->hbfail_cbfn(ioc->bfa);
1660 list_for_each(qe, &ioc->hb_notify_q) { 1663 bfa_ioc_event_notify(ioc, BFA_IOC_E_FAILED);
1661 notify = (struct bfa_ioc_hbfail_notify *) qe;
1662 notify->cbfn(notify->cbarg);
1663 }
1664} 1664}
1665 1665
1666static void 1666static void
@@ -1839,7 +1839,7 @@ bfa_nw_ioc_attach(struct bfa_ioc *ioc, void *bfa, struct bfa_ioc_cbfn *cbfn)
1839 ioc->iocpf.ioc = ioc; 1839 ioc->iocpf.ioc = ioc;
1840 1840
1841 bfa_ioc_mbox_attach(ioc); 1841 bfa_ioc_mbox_attach(ioc);
1842 INIT_LIST_HEAD(&ioc->hb_notify_q); 1842 INIT_LIST_HEAD(&ioc->notify_q);
1843 1843
1844 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit); 1844 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
1845 bfa_fsm_send_event(ioc, IOC_E_RESET); 1845 bfa_fsm_send_event(ioc, IOC_E_RESET);
@@ -1969,6 +1969,8 @@ bfa_nw_ioc_mbox_queue(struct bfa_ioc *ioc, struct bfa_mbox_cmd *cmd)
1969 * mailbox is free -- queue command to firmware 1969 * mailbox is free -- queue command to firmware
1970 */ 1970 */
1971 bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg)); 1971 bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg));
1972
1973 return;
1972} 1974}
1973 1975
1974/** 1976/**
@@ -2005,14 +2007,24 @@ bfa_nw_ioc_error_isr(struct bfa_ioc *ioc)
2005} 2007}
2006 2008
2007/** 2009/**
2010 * return true if IOC is disabled
2011 */
2012bool
2013bfa_nw_ioc_is_disabled(struct bfa_ioc *ioc)
2014{
2015 return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabling) ||
2016 bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabled);
2017}
2018
2019/**
2008 * Add to IOC heartbeat failure notification queue. To be used by common 2020 * Add to IOC heartbeat failure notification queue. To be used by common
2009 * modules such as cee, port, diag. 2021 * modules such as cee, port, diag.
2010 */ 2022 */
2011void 2023void
2012bfa_nw_ioc_hbfail_register(struct bfa_ioc *ioc, 2024bfa_nw_ioc_notify_register(struct bfa_ioc *ioc,
2013 struct bfa_ioc_hbfail_notify *notify) 2025 struct bfa_ioc_notify *notify)
2014{ 2026{
2015 list_add_tail(&notify->qe, &ioc->hb_notify_q); 2027 list_add_tail(&notify->qe, &ioc->notify_q);
2016} 2028}
2017 2029
2018#define BFA_MFG_NAME "Brocade" 2030#define BFA_MFG_NAME "Brocade"
diff --git a/drivers/net/bna/bfa_ioc.h b/drivers/net/bna/bfa_ioc.h
index 8473c00b9427..c6cf218d9f81 100644
--- a/drivers/net/bna/bfa_ioc.h
+++ b/drivers/net/bna/bfa_ioc.h
@@ -97,9 +97,12 @@ struct bfa_ioc_regs {
97/** 97/**
98 * IOC Mailbox structures 98 * IOC Mailbox structures
99 */ 99 */
100typedef void (*bfa_mbox_cmd_cbfn_t)(void *cbarg);
100struct bfa_mbox_cmd { 101struct bfa_mbox_cmd {
101 struct list_head qe; 102 struct list_head qe;
102 u32 msg[BFI_IOC_MSGSZ]; 103 bfa_mbox_cmd_cbfn_t cbfn;
104 void *cbarg;
105 u32 msg[BFI_IOC_MSGSZ];
103}; 106};
104 107
105/** 108/**
@@ -130,6 +133,23 @@ struct bfa_ioc_cbfn {
130}; 133};
131 134
132/** 135/**
136 * IOC event notification mechanism.
137 */
138enum bfa_ioc_event {
139 BFA_IOC_E_ENABLED = 1,
140 BFA_IOC_E_DISABLED = 2,
141 BFA_IOC_E_FAILED = 3,
142};
143
144typedef void (*bfa_ioc_notify_cbfn_t)(void *, enum bfa_ioc_event);
145
146struct bfa_ioc_notify {
147 struct list_head qe;
148 bfa_ioc_notify_cbfn_t cbfn;
149 void *cbarg;
150};
151
152/**
133 * Heartbeat failure notification queue element. 153 * Heartbeat failure notification queue element.
134 */ 154 */
135struct bfa_ioc_hbfail_notify { 155struct bfa_ioc_hbfail_notify {
@@ -141,7 +161,7 @@ struct bfa_ioc_hbfail_notify {
141/** 161/**
142 * Initialize a heartbeat failure notification structure 162 * Initialize a heartbeat failure notification structure
143 */ 163 */
144#define bfa_ioc_hbfail_init(__notify, __cbfn, __cbarg) do { \ 164#define bfa_ioc_notify_init(__notify, __cbfn, __cbarg) do { \
145 (__notify)->cbfn = (__cbfn); \ 165 (__notify)->cbfn = (__cbfn); \
146 (__notify)->cbarg = (__cbarg); \ 166 (__notify)->cbarg = (__cbarg); \
147} while (0) 167} while (0)
@@ -162,7 +182,7 @@ struct bfa_ioc {
162 struct timer_list sem_timer; 182 struct timer_list sem_timer;
163 struct timer_list hb_timer; 183 struct timer_list hb_timer;
164 u32 hb_count; 184 u32 hb_count;
165 struct list_head hb_notify_q; 185 struct list_head notify_q;
166 void *dbg_fwsave; 186 void *dbg_fwsave;
167 int dbg_fwsave_len; 187 int dbg_fwsave_len;
168 bool dbg_fwsave_once; 188 bool dbg_fwsave_once;
@@ -263,9 +283,10 @@ void bfa_nw_ioc_enable(struct bfa_ioc *ioc);
263void bfa_nw_ioc_disable(struct bfa_ioc *ioc); 283void bfa_nw_ioc_disable(struct bfa_ioc *ioc);
264 284
265void bfa_nw_ioc_error_isr(struct bfa_ioc *ioc); 285void bfa_nw_ioc_error_isr(struct bfa_ioc *ioc);
286bool bfa_nw_ioc_is_disabled(struct bfa_ioc *ioc);
266void bfa_nw_ioc_get_attr(struct bfa_ioc *ioc, struct bfa_ioc_attr *ioc_attr); 287void bfa_nw_ioc_get_attr(struct bfa_ioc *ioc, struct bfa_ioc_attr *ioc_attr);
267void bfa_nw_ioc_hbfail_register(struct bfa_ioc *ioc, 288void bfa_nw_ioc_notify_register(struct bfa_ioc *ioc,
268 struct bfa_ioc_hbfail_notify *notify); 289 struct bfa_ioc_notify *notify);
269bool bfa_nw_ioc_sem_get(void __iomem *sem_reg); 290bool bfa_nw_ioc_sem_get(void __iomem *sem_reg);
270void bfa_nw_ioc_sem_release(void __iomem *sem_reg); 291void bfa_nw_ioc_sem_release(void __iomem *sem_reg);
271void bfa_nw_ioc_hw_sem_release(struct bfa_ioc *ioc); 292void bfa_nw_ioc_hw_sem_release(struct bfa_ioc *ioc);