Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / drivers / scsi / bfa / bfa_port.c
blob95e4ad8759acfbcfc5d7ff27d29b40bac2e2f7b9
1 /*
2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
18 #include "bfad_drv.h"
19 #include "bfa_defs_svc.h"
20 #include "bfa_port.h"
21 #include "bfi.h"
22 #include "bfa_ioc.h"
25 BFA_TRC_FILE(CNA, PORT);
27 static void
28 bfa_port_stats_swap(struct bfa_port_s *port, union bfa_port_stats_u *stats)
30 u32 *dip = (u32 *) stats;
31 __be32 t0, t1;
32 int i;
34 for (i = 0; i < sizeof(union bfa_port_stats_u)/sizeof(u32);
35 i += 2) {
36 t0 = dip[i];
37 t1 = dip[i + 1];
38 #ifdef __BIG_ENDIAN
39 dip[i] = be32_to_cpu(t0);
40 dip[i + 1] = be32_to_cpu(t1);
41 #else
42 dip[i] = be32_to_cpu(t1);
43 dip[i + 1] = be32_to_cpu(t0);
44 #endif
49 * bfa_port_enable_isr()
52 * @param[in] port - Pointer to the port module
53 * status - Return status from the f/w
55 * @return void
57 static void
58 bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status)
60 bfa_trc(port, status);
61 port->endis_pending = BFA_FALSE;
62 port->endis_cbfn(port->endis_cbarg, status);
66 * bfa_port_disable_isr()
69 * @param[in] port - Pointer to the port module
70 * status - Return status from the f/w
72 * @return void
74 static void
75 bfa_port_disable_isr(struct bfa_port_s *port, bfa_status_t status)
77 bfa_trc(port, status);
78 port->endis_pending = BFA_FALSE;
79 port->endis_cbfn(port->endis_cbarg, status);
83 * bfa_port_get_stats_isr()
86 * @param[in] port - Pointer to the Port module
87 * status - Return status from the f/w
89 * @return void
91 static void
92 bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
94 port->stats_status = status;
95 port->stats_busy = BFA_FALSE;
97 if (status == BFA_STATUS_OK) {
98 struct timeval tv;
100 memcpy(port->stats, port->stats_dma.kva,
101 sizeof(union bfa_port_stats_u));
102 bfa_port_stats_swap(port, port->stats);
104 do_gettimeofday(&tv);
105 port->stats->fc.secs_reset = tv.tv_sec - port->stats_reset_time;
108 if (port->stats_cbfn) {
109 port->stats_cbfn(port->stats_cbarg, status);
110 port->stats_cbfn = NULL;
115 * bfa_port_clear_stats_isr()
118 * @param[in] port - Pointer to the Port module
119 * status - Return status from the f/w
121 * @return void
123 static void
124 bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
126 struct timeval tv;
128 port->stats_status = status;
129 port->stats_busy = BFA_FALSE;
132 * re-initialize time stamp for stats reset
134 do_gettimeofday(&tv);
135 port->stats_reset_time = tv.tv_sec;
137 if (port->stats_cbfn) {
138 port->stats_cbfn(port->stats_cbarg, status);
139 port->stats_cbfn = NULL;
144 * bfa_port_isr()
147 * @param[in] Pointer to the Port module data structure.
149 * @return void
151 static void
152 bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
154 struct bfa_port_s *port = (struct bfa_port_s *) cbarg;
155 union bfi_port_i2h_msg_u *i2hmsg;
157 i2hmsg = (union bfi_port_i2h_msg_u *) m;
158 bfa_trc(port, m->mh.msg_id);
160 switch (m->mh.msg_id) {
161 case BFI_PORT_I2H_ENABLE_RSP:
162 if (port->endis_pending == BFA_FALSE)
163 break;
164 bfa_port_enable_isr(port, i2hmsg->enable_rsp.status);
165 break;
167 case BFI_PORT_I2H_DISABLE_RSP:
168 if (port->endis_pending == BFA_FALSE)
169 break;
170 bfa_port_disable_isr(port, i2hmsg->disable_rsp.status);
171 break;
173 case BFI_PORT_I2H_GET_STATS_RSP:
174 /* Stats busy flag is still set? (may be cmd timed out) */
175 if (port->stats_busy == BFA_FALSE)
176 break;
177 bfa_port_get_stats_isr(port, i2hmsg->getstats_rsp.status);
178 break;
180 case BFI_PORT_I2H_CLEAR_STATS_RSP:
181 if (port->stats_busy == BFA_FALSE)
182 break;
183 bfa_port_clear_stats_isr(port, i2hmsg->clearstats_rsp.status);
184 break;
186 default:
187 WARN_ON(1);
192 * bfa_port_meminfo()
195 * @param[in] void
197 * @return Size of DMA region
200 bfa_port_meminfo(void)
202 return BFA_ROUNDUP(sizeof(union bfa_port_stats_u), BFA_DMA_ALIGN_SZ);
206 * bfa_port_mem_claim()
209 * @param[in] port Port module pointer
210 * dma_kva Kernel Virtual Address of Port DMA Memory
211 * dma_pa Physical Address of Port DMA Memory
213 * @return void
215 void
216 bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa)
218 port->stats_dma.kva = dma_kva;
219 port->stats_dma.pa = dma_pa;
223 * bfa_port_enable()
225 * Send the Port enable request to the f/w
227 * @param[in] Pointer to the Port module data structure.
229 * @return Status
231 bfa_status_t
232 bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
233 void *cbarg)
235 struct bfi_port_generic_req_s *m;
237 /* If port is PBC disabled, return error */
238 if (port->pbc_disabled) {
239 bfa_trc(port, BFA_STATUS_PBC);
240 return BFA_STATUS_PBC;
243 if (bfa_ioc_is_disabled(port->ioc)) {
244 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
245 return BFA_STATUS_IOC_DISABLED;
248 if (!bfa_ioc_is_operational(port->ioc)) {
249 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
250 return BFA_STATUS_IOC_FAILURE;
253 if (port->endis_pending) {
254 bfa_trc(port, BFA_STATUS_DEVBUSY);
255 return BFA_STATUS_DEVBUSY;
258 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
260 port->msgtag++;
261 port->endis_cbfn = cbfn;
262 port->endis_cbarg = cbarg;
263 port->endis_pending = BFA_TRUE;
265 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_ENABLE_REQ,
266 bfa_ioc_portid(port->ioc));
267 bfa_ioc_mbox_queue(port->ioc, &port->endis_mb);
269 return BFA_STATUS_OK;
273 * bfa_port_disable()
275 * Send the Port disable request to the f/w
277 * @param[in] Pointer to the Port module data structure.
279 * @return Status
281 bfa_status_t
282 bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
283 void *cbarg)
285 struct bfi_port_generic_req_s *m;
287 /* If port is PBC disabled, return error */
288 if (port->pbc_disabled) {
289 bfa_trc(port, BFA_STATUS_PBC);
290 return BFA_STATUS_PBC;
293 if (bfa_ioc_is_disabled(port->ioc)) {
294 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
295 return BFA_STATUS_IOC_DISABLED;
298 if (!bfa_ioc_is_operational(port->ioc)) {
299 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
300 return BFA_STATUS_IOC_FAILURE;
303 if (port->endis_pending) {
304 bfa_trc(port, BFA_STATUS_DEVBUSY);
305 return BFA_STATUS_DEVBUSY;
308 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
310 port->msgtag++;
311 port->endis_cbfn = cbfn;
312 port->endis_cbarg = cbarg;
313 port->endis_pending = BFA_TRUE;
315 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_DISABLE_REQ,
316 bfa_ioc_portid(port->ioc));
317 bfa_ioc_mbox_queue(port->ioc, &port->endis_mb);
319 return BFA_STATUS_OK;
323 * bfa_port_get_stats()
325 * Send the request to the f/w to fetch Port statistics.
327 * @param[in] Pointer to the Port module data structure.
329 * @return Status
331 bfa_status_t
332 bfa_port_get_stats(struct bfa_port_s *port, union bfa_port_stats_u *stats,
333 bfa_port_stats_cbfn_t cbfn, void *cbarg)
335 struct bfi_port_get_stats_req_s *m;
337 if (!bfa_ioc_is_operational(port->ioc)) {
338 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
339 return BFA_STATUS_IOC_FAILURE;
342 if (port->stats_busy) {
343 bfa_trc(port, BFA_STATUS_DEVBUSY);
344 return BFA_STATUS_DEVBUSY;
347 m = (struct bfi_port_get_stats_req_s *) port->stats_mb.msg;
349 port->stats = stats;
350 port->stats_cbfn = cbfn;
351 port->stats_cbarg = cbarg;
352 port->stats_busy = BFA_TRUE;
353 bfa_dma_be_addr_set(m->dma_addr, port->stats_dma.pa);
355 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_GET_STATS_REQ,
356 bfa_ioc_portid(port->ioc));
357 bfa_ioc_mbox_queue(port->ioc, &port->stats_mb);
359 return BFA_STATUS_OK;
363 * bfa_port_clear_stats()
366 * @param[in] Pointer to the Port module data structure.
368 * @return Status
370 bfa_status_t
371 bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
372 void *cbarg)
374 struct bfi_port_generic_req_s *m;
376 if (!bfa_ioc_is_operational(port->ioc)) {
377 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
378 return BFA_STATUS_IOC_FAILURE;
381 if (port->stats_busy) {
382 bfa_trc(port, BFA_STATUS_DEVBUSY);
383 return BFA_STATUS_DEVBUSY;
386 m = (struct bfi_port_generic_req_s *) port->stats_mb.msg;
388 port->stats_cbfn = cbfn;
389 port->stats_cbarg = cbarg;
390 port->stats_busy = BFA_TRUE;
392 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_CLEAR_STATS_REQ,
393 bfa_ioc_portid(port->ioc));
394 bfa_ioc_mbox_queue(port->ioc, &port->stats_mb);
396 return BFA_STATUS_OK;
400 * bfa_port_notify()
402 * Port module IOC event handler
404 * @param[in] Pointer to the Port module data structure.
405 * @param[in] IOC event structure
407 * @return void
409 void
410 bfa_port_notify(void *arg, enum bfa_ioc_event_e event)
412 struct bfa_port_s *port = (struct bfa_port_s *) arg;
414 switch (event) {
415 case BFA_IOC_E_DISABLED:
416 case BFA_IOC_E_FAILED:
417 /* Fail any pending get_stats/clear_stats requests */
418 if (port->stats_busy) {
419 if (port->stats_cbfn)
420 port->stats_cbfn(port->stats_cbarg,
421 BFA_STATUS_FAILED);
422 port->stats_cbfn = NULL;
423 port->stats_busy = BFA_FALSE;
426 /* Clear any enable/disable is pending */
427 if (port->endis_pending) {
428 if (port->endis_cbfn)
429 port->endis_cbfn(port->endis_cbarg,
430 BFA_STATUS_FAILED);
431 port->endis_cbfn = NULL;
432 port->endis_pending = BFA_FALSE;
434 break;
435 default:
436 break;
441 * bfa_port_attach()
444 * @param[in] port - Pointer to the Port module data structure
445 * ioc - Pointer to the ioc module data structure
446 * dev - Pointer to the device driver module data structure
447 * The device driver specific mbox ISR functions have
448 * this pointer as one of the parameters.
449 * trcmod -
451 * @return void
453 void
454 bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
455 void *dev, struct bfa_trc_mod_s *trcmod)
457 struct timeval tv;
459 WARN_ON(!port);
461 port->dev = dev;
462 port->ioc = ioc;
463 port->trcmod = trcmod;
465 port->stats_busy = BFA_FALSE;
466 port->endis_pending = BFA_FALSE;
467 port->stats_cbfn = NULL;
468 port->endis_cbfn = NULL;
469 port->pbc_disabled = BFA_FALSE;
471 bfa_ioc_mbox_regisr(port->ioc, BFI_MC_PORT, bfa_port_isr, port);
472 bfa_q_qe_init(&port->ioc_notify);
473 bfa_ioc_notify_init(&port->ioc_notify, bfa_port_notify, port);
474 list_add_tail(&port->ioc_notify.qe, &port->ioc->notify_q);
477 * initialize time stamp for stats reset
479 do_gettimeofday(&tv);
480 port->stats_reset_time = tv.tv_sec;
482 bfa_trc(port, 0);
486 * CEE module specific definitions
490 * bfa_cee_get_attr_isr()
492 * @brief CEE ISR for get-attributes responses from f/w
494 * @param[in] cee - Pointer to the CEE module
495 * status - Return status from the f/w
497 * @return void
499 static void
500 bfa_cee_get_attr_isr(struct bfa_cee_s *cee, bfa_status_t status)
502 struct bfa_cee_lldp_cfg_s *lldp_cfg = &cee->attr->lldp_remote;
504 cee->get_attr_status = status;
505 bfa_trc(cee, 0);
506 if (status == BFA_STATUS_OK) {
507 bfa_trc(cee, 0);
508 memcpy(cee->attr, cee->attr_dma.kva,
509 sizeof(struct bfa_cee_attr_s));
510 lldp_cfg->time_to_live = be16_to_cpu(lldp_cfg->time_to_live);
511 lldp_cfg->enabled_system_cap =
512 be16_to_cpu(lldp_cfg->enabled_system_cap);
514 cee->get_attr_pending = BFA_FALSE;
515 if (cee->cbfn.get_attr_cbfn) {
516 bfa_trc(cee, 0);
517 cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, status);
522 * bfa_cee_get_stats_isr()
524 * @brief CEE ISR for get-stats responses from f/w
526 * @param[in] cee - Pointer to the CEE module
527 * status - Return status from the f/w
529 * @return void
531 static void
532 bfa_cee_get_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
534 u32 *buffer;
535 int i;
537 cee->get_stats_status = status;
538 bfa_trc(cee, 0);
539 if (status == BFA_STATUS_OK) {
540 bfa_trc(cee, 0);
541 memcpy(cee->stats, cee->stats_dma.kva,
542 sizeof(struct bfa_cee_stats_s));
543 /* swap the cee stats */
544 buffer = (u32 *)cee->stats;
545 for (i = 0; i < (sizeof(struct bfa_cee_stats_s) /
546 sizeof(u32)); i++)
547 buffer[i] = cpu_to_be32(buffer[i]);
549 cee->get_stats_pending = BFA_FALSE;
550 bfa_trc(cee, 0);
551 if (cee->cbfn.get_stats_cbfn) {
552 bfa_trc(cee, 0);
553 cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, status);
558 * bfa_cee_reset_stats_isr()
560 * @brief CEE ISR for reset-stats responses from f/w
562 * @param[in] cee - Pointer to the CEE module
563 * status - Return status from the f/w
565 * @return void
567 static void
568 bfa_cee_reset_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
570 cee->reset_stats_status = status;
571 cee->reset_stats_pending = BFA_FALSE;
572 if (cee->cbfn.reset_stats_cbfn)
573 cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, status);
577 * bfa_cee_meminfo()
579 * @brief Returns the size of the DMA memory needed by CEE module
581 * @param[in] void
583 * @return Size of DMA region
586 bfa_cee_meminfo(void)
588 return BFA_ROUNDUP(sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ) +
589 BFA_ROUNDUP(sizeof(struct bfa_cee_stats_s), BFA_DMA_ALIGN_SZ);
593 * bfa_cee_mem_claim()
595 * @brief Initialized CEE DMA Memory
597 * @param[in] cee CEE module pointer
598 * dma_kva Kernel Virtual Address of CEE DMA Memory
599 * dma_pa Physical Address of CEE DMA Memory
601 * @return void
603 void
604 bfa_cee_mem_claim(struct bfa_cee_s *cee, u8 *dma_kva, u64 dma_pa)
606 cee->attr_dma.kva = dma_kva;
607 cee->attr_dma.pa = dma_pa;
608 cee->stats_dma.kva = dma_kva + BFA_ROUNDUP(
609 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
610 cee->stats_dma.pa = dma_pa + BFA_ROUNDUP(
611 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
612 cee->attr = (struct bfa_cee_attr_s *) dma_kva;
613 cee->stats = (struct bfa_cee_stats_s *) (dma_kva + BFA_ROUNDUP(
614 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ));
618 * bfa_cee_get_attr()
620 * @brief
621 * Send the request to the f/w to fetch CEE attributes.
623 * @param[in] Pointer to the CEE module data structure.
625 * @return Status
628 bfa_status_t
629 bfa_cee_get_attr(struct bfa_cee_s *cee, struct bfa_cee_attr_s *attr,
630 bfa_cee_get_attr_cbfn_t cbfn, void *cbarg)
632 struct bfi_cee_get_req_s *cmd;
634 WARN_ON((cee == NULL) || (cee->ioc == NULL));
635 bfa_trc(cee, 0);
636 if (!bfa_ioc_is_operational(cee->ioc)) {
637 bfa_trc(cee, 0);
638 return BFA_STATUS_IOC_FAILURE;
640 if (cee->get_attr_pending == BFA_TRUE) {
641 bfa_trc(cee, 0);
642 return BFA_STATUS_DEVBUSY;
644 cee->get_attr_pending = BFA_TRUE;
645 cmd = (struct bfi_cee_get_req_s *) cee->get_cfg_mb.msg;
646 cee->attr = attr;
647 cee->cbfn.get_attr_cbfn = cbfn;
648 cee->cbfn.get_attr_cbarg = cbarg;
649 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_CFG_REQ,
650 bfa_ioc_portid(cee->ioc));
651 bfa_dma_be_addr_set(cmd->dma_addr, cee->attr_dma.pa);
652 bfa_ioc_mbox_queue(cee->ioc, &cee->get_cfg_mb);
654 return BFA_STATUS_OK;
658 * bfa_cee_get_stats()
660 * @brief
661 * Send the request to the f/w to fetch CEE statistics.
663 * @param[in] Pointer to the CEE module data structure.
665 * @return Status
668 bfa_status_t
669 bfa_cee_get_stats(struct bfa_cee_s *cee, struct bfa_cee_stats_s *stats,
670 bfa_cee_get_stats_cbfn_t cbfn, void *cbarg)
672 struct bfi_cee_get_req_s *cmd;
674 WARN_ON((cee == NULL) || (cee->ioc == NULL));
676 if (!bfa_ioc_is_operational(cee->ioc)) {
677 bfa_trc(cee, 0);
678 return BFA_STATUS_IOC_FAILURE;
680 if (cee->get_stats_pending == BFA_TRUE) {
681 bfa_trc(cee, 0);
682 return BFA_STATUS_DEVBUSY;
684 cee->get_stats_pending = BFA_TRUE;
685 cmd = (struct bfi_cee_get_req_s *) cee->get_stats_mb.msg;
686 cee->stats = stats;
687 cee->cbfn.get_stats_cbfn = cbfn;
688 cee->cbfn.get_stats_cbarg = cbarg;
689 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_STATS_REQ,
690 bfa_ioc_portid(cee->ioc));
691 bfa_dma_be_addr_set(cmd->dma_addr, cee->stats_dma.pa);
692 bfa_ioc_mbox_queue(cee->ioc, &cee->get_stats_mb);
694 return BFA_STATUS_OK;
698 * bfa_cee_reset_stats()
700 * @brief Clears CEE Stats in the f/w.
702 * @param[in] Pointer to the CEE module data structure.
704 * @return Status
707 bfa_status_t
708 bfa_cee_reset_stats(struct bfa_cee_s *cee,
709 bfa_cee_reset_stats_cbfn_t cbfn, void *cbarg)
711 struct bfi_cee_reset_stats_s *cmd;
713 WARN_ON((cee == NULL) || (cee->ioc == NULL));
714 if (!bfa_ioc_is_operational(cee->ioc)) {
715 bfa_trc(cee, 0);
716 return BFA_STATUS_IOC_FAILURE;
718 if (cee->reset_stats_pending == BFA_TRUE) {
719 bfa_trc(cee, 0);
720 return BFA_STATUS_DEVBUSY;
722 cee->reset_stats_pending = BFA_TRUE;
723 cmd = (struct bfi_cee_reset_stats_s *) cee->reset_stats_mb.msg;
724 cee->cbfn.reset_stats_cbfn = cbfn;
725 cee->cbfn.reset_stats_cbarg = cbarg;
726 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_RESET_STATS,
727 bfa_ioc_portid(cee->ioc));
728 bfa_ioc_mbox_queue(cee->ioc, &cee->reset_stats_mb);
730 return BFA_STATUS_OK;
734 * bfa_cee_isrs()
736 * @brief Handles Mail-box interrupts for CEE module.
738 * @param[in] Pointer to the CEE module data structure.
740 * @return void
743 void
744 bfa_cee_isr(void *cbarg, struct bfi_mbmsg_s *m)
746 union bfi_cee_i2h_msg_u *msg;
747 struct bfi_cee_get_rsp_s *get_rsp;
748 struct bfa_cee_s *cee = (struct bfa_cee_s *) cbarg;
749 msg = (union bfi_cee_i2h_msg_u *) m;
750 get_rsp = (struct bfi_cee_get_rsp_s *) m;
751 bfa_trc(cee, msg->mh.msg_id);
752 switch (msg->mh.msg_id) {
753 case BFI_CEE_I2H_GET_CFG_RSP:
754 bfa_trc(cee, get_rsp->cmd_status);
755 bfa_cee_get_attr_isr(cee, get_rsp->cmd_status);
756 break;
757 case BFI_CEE_I2H_GET_STATS_RSP:
758 bfa_cee_get_stats_isr(cee, get_rsp->cmd_status);
759 break;
760 case BFI_CEE_I2H_RESET_STATS_RSP:
761 bfa_cee_reset_stats_isr(cee, get_rsp->cmd_status);
762 break;
763 default:
764 WARN_ON(1);
769 * bfa_cee_notify()
771 * @brief CEE module IOC event handler.
773 * @param[in] Pointer to the CEE module data structure.
774 * @param[in] IOC event type
776 * @return void
779 void
780 bfa_cee_notify(void *arg, enum bfa_ioc_event_e event)
782 struct bfa_cee_s *cee = (struct bfa_cee_s *) arg;
784 bfa_trc(cee, event);
786 switch (event) {
787 case BFA_IOC_E_DISABLED:
788 case BFA_IOC_E_FAILED:
789 if (cee->get_attr_pending == BFA_TRUE) {
790 cee->get_attr_status = BFA_STATUS_FAILED;
791 cee->get_attr_pending = BFA_FALSE;
792 if (cee->cbfn.get_attr_cbfn) {
793 cee->cbfn.get_attr_cbfn(
794 cee->cbfn.get_attr_cbarg,
795 BFA_STATUS_FAILED);
798 if (cee->get_stats_pending == BFA_TRUE) {
799 cee->get_stats_status = BFA_STATUS_FAILED;
800 cee->get_stats_pending = BFA_FALSE;
801 if (cee->cbfn.get_stats_cbfn) {
802 cee->cbfn.get_stats_cbfn(
803 cee->cbfn.get_stats_cbarg,
804 BFA_STATUS_FAILED);
807 if (cee->reset_stats_pending == BFA_TRUE) {
808 cee->reset_stats_status = BFA_STATUS_FAILED;
809 cee->reset_stats_pending = BFA_FALSE;
810 if (cee->cbfn.reset_stats_cbfn) {
811 cee->cbfn.reset_stats_cbfn(
812 cee->cbfn.reset_stats_cbarg,
813 BFA_STATUS_FAILED);
816 break;
818 default:
819 break;
824 * bfa_cee_attach()
826 * @brief CEE module-attach API
828 * @param[in] cee - Pointer to the CEE module data structure
829 * ioc - Pointer to the ioc module data structure
830 * dev - Pointer to the device driver module data structure
831 * The device driver specific mbox ISR functions have
832 * this pointer as one of the parameters.
834 * @return void
836 void
837 bfa_cee_attach(struct bfa_cee_s *cee, struct bfa_ioc_s *ioc,
838 void *dev)
840 WARN_ON(cee == NULL);
841 cee->dev = dev;
842 cee->ioc = ioc;
844 bfa_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
845 bfa_q_qe_init(&cee->ioc_notify);
846 bfa_ioc_notify_init(&cee->ioc_notify, bfa_cee_notify, cee);
847 list_add_tail(&cee->ioc_notify.qe, &cee->ioc->notify_q);