treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / scsi / bfa / bfa_port.c
blob4511ec865f06a03e79b1d47921fba513ba09dca3
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
4 * Copyright (c) 2014- QLogic Corporation.
5 * All rights reserved
6 * www.qlogic.com
8 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
9 */
11 #include "bfad_drv.h"
12 #include "bfa_defs_svc.h"
13 #include "bfa_port.h"
14 #include "bfi.h"
15 #include "bfa_ioc.h"
18 BFA_TRC_FILE(CNA, PORT);
20 static void
21 bfa_port_stats_swap(struct bfa_port_s *port, union bfa_port_stats_u *stats)
23 u32 *dip = (u32 *) stats;
24 __be32 t0, t1;
25 int i;
27 for (i = 0; i < sizeof(union bfa_port_stats_u)/sizeof(u32);
28 i += 2) {
29 t0 = dip[i];
30 t1 = dip[i + 1];
31 #ifdef __BIG_ENDIAN
32 dip[i] = be32_to_cpu(t0);
33 dip[i + 1] = be32_to_cpu(t1);
34 #else
35 dip[i] = be32_to_cpu(t1);
36 dip[i + 1] = be32_to_cpu(t0);
37 #endif
42 * bfa_port_enable_isr()
45 * @param[in] port - Pointer to the port module
46 * status - Return status from the f/w
48 * @return void
50 static void
51 bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status)
53 bfa_trc(port, status);
54 port->endis_pending = BFA_FALSE;
55 port->endis_cbfn(port->endis_cbarg, status);
59 * bfa_port_disable_isr()
62 * @param[in] port - Pointer to the port module
63 * status - Return status from the f/w
65 * @return void
67 static void
68 bfa_port_disable_isr(struct bfa_port_s *port, bfa_status_t status)
70 bfa_trc(port, status);
71 port->endis_pending = BFA_FALSE;
72 port->endis_cbfn(port->endis_cbarg, status);
76 * bfa_port_get_stats_isr()
79 * @param[in] port - Pointer to the Port module
80 * status - Return status from the f/w
82 * @return void
84 static void
85 bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
87 port->stats_status = status;
88 port->stats_busy = BFA_FALSE;
90 if (status == BFA_STATUS_OK) {
91 memcpy(port->stats, port->stats_dma.kva,
92 sizeof(union bfa_port_stats_u));
93 bfa_port_stats_swap(port, port->stats);
95 port->stats->fc.secs_reset = ktime_get_seconds() - port->stats_reset_time;
98 if (port->stats_cbfn) {
99 port->stats_cbfn(port->stats_cbarg, status);
100 port->stats_cbfn = NULL;
105 * bfa_port_clear_stats_isr()
108 * @param[in] port - Pointer to the Port module
109 * status - Return status from the f/w
111 * @return void
113 static void
114 bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
116 port->stats_status = status;
117 port->stats_busy = BFA_FALSE;
120 * re-initialize time stamp for stats reset
122 port->stats_reset_time = ktime_get_seconds();
124 if (port->stats_cbfn) {
125 port->stats_cbfn(port->stats_cbarg, status);
126 port->stats_cbfn = NULL;
131 * bfa_port_isr()
134 * @param[in] Pointer to the Port module data structure.
136 * @return void
138 static void
139 bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
141 struct bfa_port_s *port = (struct bfa_port_s *) cbarg;
142 union bfi_port_i2h_msg_u *i2hmsg;
144 i2hmsg = (union bfi_port_i2h_msg_u *) m;
145 bfa_trc(port, m->mh.msg_id);
147 switch (m->mh.msg_id) {
148 case BFI_PORT_I2H_ENABLE_RSP:
149 if (port->endis_pending == BFA_FALSE)
150 break;
151 bfa_port_enable_isr(port, i2hmsg->enable_rsp.status);
152 break;
154 case BFI_PORT_I2H_DISABLE_RSP:
155 if (port->endis_pending == BFA_FALSE)
156 break;
157 bfa_port_disable_isr(port, i2hmsg->disable_rsp.status);
158 break;
160 case BFI_PORT_I2H_GET_STATS_RSP:
161 /* Stats busy flag is still set? (may be cmd timed out) */
162 if (port->stats_busy == BFA_FALSE)
163 break;
164 bfa_port_get_stats_isr(port, i2hmsg->getstats_rsp.status);
165 break;
167 case BFI_PORT_I2H_CLEAR_STATS_RSP:
168 if (port->stats_busy == BFA_FALSE)
169 break;
170 bfa_port_clear_stats_isr(port, i2hmsg->clearstats_rsp.status);
171 break;
173 default:
174 WARN_ON(1);
179 * bfa_port_meminfo()
182 * @param[in] void
184 * @return Size of DMA region
187 bfa_port_meminfo(void)
189 return BFA_ROUNDUP(sizeof(union bfa_port_stats_u), BFA_DMA_ALIGN_SZ);
193 * bfa_port_mem_claim()
196 * @param[in] port Port module pointer
197 * dma_kva Kernel Virtual Address of Port DMA Memory
198 * dma_pa Physical Address of Port DMA Memory
200 * @return void
202 void
203 bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa)
205 port->stats_dma.kva = dma_kva;
206 port->stats_dma.pa = dma_pa;
210 * bfa_port_enable()
212 * Send the Port enable request to the f/w
214 * @param[in] Pointer to the Port module data structure.
216 * @return Status
218 bfa_status_t
219 bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
220 void *cbarg)
222 struct bfi_port_generic_req_s *m;
224 /* If port is PBC disabled, return error */
225 if (port->pbc_disabled) {
226 bfa_trc(port, BFA_STATUS_PBC);
227 return BFA_STATUS_PBC;
230 if (bfa_ioc_is_disabled(port->ioc)) {
231 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
232 return BFA_STATUS_IOC_DISABLED;
235 if (!bfa_ioc_is_operational(port->ioc)) {
236 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
237 return BFA_STATUS_IOC_FAILURE;
240 /* if port is d-port enabled, return error */
241 if (port->dport_enabled) {
242 bfa_trc(port, BFA_STATUS_DPORT_ERR);
243 return BFA_STATUS_DPORT_ERR;
246 if (port->endis_pending) {
247 bfa_trc(port, BFA_STATUS_DEVBUSY);
248 return BFA_STATUS_DEVBUSY;
251 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
253 port->msgtag++;
254 port->endis_cbfn = cbfn;
255 port->endis_cbarg = cbarg;
256 port->endis_pending = BFA_TRUE;
258 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_ENABLE_REQ,
259 bfa_ioc_portid(port->ioc));
260 bfa_ioc_mbox_queue(port->ioc, &port->endis_mb);
262 return BFA_STATUS_OK;
266 * bfa_port_disable()
268 * Send the Port disable request to the f/w
270 * @param[in] Pointer to the Port module data structure.
272 * @return Status
274 bfa_status_t
275 bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
276 void *cbarg)
278 struct bfi_port_generic_req_s *m;
280 /* If port is PBC disabled, return error */
281 if (port->pbc_disabled) {
282 bfa_trc(port, BFA_STATUS_PBC);
283 return BFA_STATUS_PBC;
286 if (bfa_ioc_is_disabled(port->ioc)) {
287 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
288 return BFA_STATUS_IOC_DISABLED;
291 if (!bfa_ioc_is_operational(port->ioc)) {
292 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
293 return BFA_STATUS_IOC_FAILURE;
296 /* if port is d-port enabled, return error */
297 if (port->dport_enabled) {
298 bfa_trc(port, BFA_STATUS_DPORT_ERR);
299 return BFA_STATUS_DPORT_ERR;
302 if (port->endis_pending) {
303 bfa_trc(port, BFA_STATUS_DEVBUSY);
304 return BFA_STATUS_DEVBUSY;
307 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
309 port->msgtag++;
310 port->endis_cbfn = cbfn;
311 port->endis_cbarg = cbarg;
312 port->endis_pending = BFA_TRUE;
314 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_DISABLE_REQ,
315 bfa_ioc_portid(port->ioc));
316 bfa_ioc_mbox_queue(port->ioc, &port->endis_mb);
318 return BFA_STATUS_OK;
322 * bfa_port_get_stats()
324 * Send the request to the f/w to fetch Port statistics.
326 * @param[in] Pointer to the Port module data structure.
328 * @return Status
330 bfa_status_t
331 bfa_port_get_stats(struct bfa_port_s *port, union bfa_port_stats_u *stats,
332 bfa_port_stats_cbfn_t cbfn, void *cbarg)
334 struct bfi_port_get_stats_req_s *m;
336 if (!bfa_ioc_is_operational(port->ioc)) {
337 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
338 return BFA_STATUS_IOC_FAILURE;
341 if (port->stats_busy) {
342 bfa_trc(port, BFA_STATUS_DEVBUSY);
343 return BFA_STATUS_DEVBUSY;
346 m = (struct bfi_port_get_stats_req_s *) port->stats_mb.msg;
348 port->stats = stats;
349 port->stats_cbfn = cbfn;
350 port->stats_cbarg = cbarg;
351 port->stats_busy = BFA_TRUE;
352 bfa_dma_be_addr_set(m->dma_addr, port->stats_dma.pa);
354 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_GET_STATS_REQ,
355 bfa_ioc_portid(port->ioc));
356 bfa_ioc_mbox_queue(port->ioc, &port->stats_mb);
358 return BFA_STATUS_OK;
362 * bfa_port_clear_stats()
365 * @param[in] Pointer to the Port module data structure.
367 * @return Status
369 bfa_status_t
370 bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
371 void *cbarg)
373 struct bfi_port_generic_req_s *m;
375 if (!bfa_ioc_is_operational(port->ioc)) {
376 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
377 return BFA_STATUS_IOC_FAILURE;
380 if (port->stats_busy) {
381 bfa_trc(port, BFA_STATUS_DEVBUSY);
382 return BFA_STATUS_DEVBUSY;
385 m = (struct bfi_port_generic_req_s *) port->stats_mb.msg;
387 port->stats_cbfn = cbfn;
388 port->stats_cbarg = cbarg;
389 port->stats_busy = BFA_TRUE;
391 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_CLEAR_STATS_REQ,
392 bfa_ioc_portid(port->ioc));
393 bfa_ioc_mbox_queue(port->ioc, &port->stats_mb);
395 return BFA_STATUS_OK;
399 * bfa_port_notify()
401 * Port module IOC event handler
403 * @param[in] Pointer to the Port module data structure.
404 * @param[in] IOC event structure
406 * @return void
408 void
409 bfa_port_notify(void *arg, enum bfa_ioc_event_e event)
411 struct bfa_port_s *port = (struct bfa_port_s *) arg;
413 switch (event) {
414 case BFA_IOC_E_DISABLED:
415 case BFA_IOC_E_FAILED:
416 /* Fail any pending get_stats/clear_stats requests */
417 if (port->stats_busy) {
418 if (port->stats_cbfn)
419 port->stats_cbfn(port->stats_cbarg,
420 BFA_STATUS_FAILED);
421 port->stats_cbfn = NULL;
422 port->stats_busy = BFA_FALSE;
425 /* Clear any enable/disable is pending */
426 if (port->endis_pending) {
427 if (port->endis_cbfn)
428 port->endis_cbfn(port->endis_cbarg,
429 BFA_STATUS_FAILED);
430 port->endis_cbfn = NULL;
431 port->endis_pending = BFA_FALSE;
434 /* clear D-port mode */
435 if (port->dport_enabled)
436 bfa_port_set_dportenabled(port, BFA_FALSE);
437 break;
438 default:
439 break;
444 * bfa_port_attach()
447 * @param[in] port - Pointer to the Port module data structure
448 * ioc - Pointer to the ioc module data structure
449 * dev - Pointer to the device driver module data structure
450 * The device driver specific mbox ISR functions have
451 * this pointer as one of the parameters.
452 * trcmod -
454 * @return void
456 void
457 bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
458 void *dev, struct bfa_trc_mod_s *trcmod)
460 WARN_ON(!port);
462 port->dev = dev;
463 port->ioc = ioc;
464 port->trcmod = trcmod;
466 port->stats_busy = BFA_FALSE;
467 port->endis_pending = BFA_FALSE;
468 port->stats_cbfn = NULL;
469 port->endis_cbfn = NULL;
470 port->pbc_disabled = BFA_FALSE;
471 port->dport_enabled = BFA_FALSE;
473 bfa_ioc_mbox_regisr(port->ioc, BFI_MC_PORT, bfa_port_isr, port);
474 bfa_q_qe_init(&port->ioc_notify);
475 bfa_ioc_notify_init(&port->ioc_notify, bfa_port_notify, port);
476 list_add_tail(&port->ioc_notify.qe, &port->ioc->notify_q);
479 * initialize time stamp for stats reset
481 port->stats_reset_time = ktime_get_seconds();
483 bfa_trc(port, 0);
487 * bfa_port_set_dportenabled();
489 * Port module- set pbc disabled flag
491 * @param[in] port - Pointer to the Port module data structure
493 * @return void
495 void
496 bfa_port_set_dportenabled(struct bfa_port_s *port, bfa_boolean_t enabled)
498 port->dport_enabled = enabled;
502 * CEE module specific definitions
506 * bfa_cee_get_attr_isr()
508 * @brief CEE ISR for get-attributes responses from f/w
510 * @param[in] cee - Pointer to the CEE module
511 * status - Return status from the f/w
513 * @return void
515 static void
516 bfa_cee_get_attr_isr(struct bfa_cee_s *cee, bfa_status_t status)
518 struct bfa_cee_lldp_cfg_s *lldp_cfg = &cee->attr->lldp_remote;
520 cee->get_attr_status = status;
521 bfa_trc(cee, 0);
522 if (status == BFA_STATUS_OK) {
523 bfa_trc(cee, 0);
524 memcpy(cee->attr, cee->attr_dma.kva,
525 sizeof(struct bfa_cee_attr_s));
526 lldp_cfg->time_to_live = be16_to_cpu(lldp_cfg->time_to_live);
527 lldp_cfg->enabled_system_cap =
528 be16_to_cpu(lldp_cfg->enabled_system_cap);
530 cee->get_attr_pending = BFA_FALSE;
531 if (cee->cbfn.get_attr_cbfn) {
532 bfa_trc(cee, 0);
533 cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, status);
538 * bfa_cee_get_stats_isr()
540 * @brief CEE ISR for get-stats responses from f/w
542 * @param[in] cee - Pointer to the CEE module
543 * status - Return status from the f/w
545 * @return void
547 static void
548 bfa_cee_get_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
550 u32 *buffer;
551 int i;
553 cee->get_stats_status = status;
554 bfa_trc(cee, 0);
555 if (status == BFA_STATUS_OK) {
556 bfa_trc(cee, 0);
557 memcpy(cee->stats, cee->stats_dma.kva,
558 sizeof(struct bfa_cee_stats_s));
559 /* swap the cee stats */
560 buffer = (u32 *)cee->stats;
561 for (i = 0; i < (sizeof(struct bfa_cee_stats_s) /
562 sizeof(u32)); i++)
563 buffer[i] = cpu_to_be32(buffer[i]);
565 cee->get_stats_pending = BFA_FALSE;
566 bfa_trc(cee, 0);
567 if (cee->cbfn.get_stats_cbfn) {
568 bfa_trc(cee, 0);
569 cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, status);
574 * bfa_cee_reset_stats_isr()
576 * @brief CEE ISR for reset-stats responses from f/w
578 * @param[in] cee - Pointer to the CEE module
579 * status - Return status from the f/w
581 * @return void
583 static void
584 bfa_cee_reset_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
586 cee->reset_stats_status = status;
587 cee->reset_stats_pending = BFA_FALSE;
588 if (cee->cbfn.reset_stats_cbfn)
589 cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, status);
593 * bfa_cee_meminfo()
595 * @brief Returns the size of the DMA memory needed by CEE module
597 * @param[in] void
599 * @return Size of DMA region
602 bfa_cee_meminfo(void)
604 return BFA_ROUNDUP(sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ) +
605 BFA_ROUNDUP(sizeof(struct bfa_cee_stats_s), BFA_DMA_ALIGN_SZ);
609 * bfa_cee_mem_claim()
611 * @brief Initialized CEE DMA Memory
613 * @param[in] cee CEE module pointer
614 * dma_kva Kernel Virtual Address of CEE DMA Memory
615 * dma_pa Physical Address of CEE DMA Memory
617 * @return void
619 void
620 bfa_cee_mem_claim(struct bfa_cee_s *cee, u8 *dma_kva, u64 dma_pa)
622 cee->attr_dma.kva = dma_kva;
623 cee->attr_dma.pa = dma_pa;
624 cee->stats_dma.kva = dma_kva + BFA_ROUNDUP(
625 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
626 cee->stats_dma.pa = dma_pa + BFA_ROUNDUP(
627 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
628 cee->attr = (struct bfa_cee_attr_s *) dma_kva;
629 cee->stats = (struct bfa_cee_stats_s *) (dma_kva + BFA_ROUNDUP(
630 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ));
634 * bfa_cee_get_attr()
636 * @brief
637 * Send the request to the f/w to fetch CEE attributes.
639 * @param[in] Pointer to the CEE module data structure.
641 * @return Status
644 bfa_status_t
645 bfa_cee_get_attr(struct bfa_cee_s *cee, struct bfa_cee_attr_s *attr,
646 bfa_cee_get_attr_cbfn_t cbfn, void *cbarg)
648 struct bfi_cee_get_req_s *cmd;
650 WARN_ON((cee == NULL) || (cee->ioc == NULL));
651 bfa_trc(cee, 0);
652 if (!bfa_ioc_is_operational(cee->ioc)) {
653 bfa_trc(cee, 0);
654 return BFA_STATUS_IOC_FAILURE;
656 if (cee->get_attr_pending == BFA_TRUE) {
657 bfa_trc(cee, 0);
658 return BFA_STATUS_DEVBUSY;
660 cee->get_attr_pending = BFA_TRUE;
661 cmd = (struct bfi_cee_get_req_s *) cee->get_cfg_mb.msg;
662 cee->attr = attr;
663 cee->cbfn.get_attr_cbfn = cbfn;
664 cee->cbfn.get_attr_cbarg = cbarg;
665 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_CFG_REQ,
666 bfa_ioc_portid(cee->ioc));
667 bfa_dma_be_addr_set(cmd->dma_addr, cee->attr_dma.pa);
668 bfa_ioc_mbox_queue(cee->ioc, &cee->get_cfg_mb);
670 return BFA_STATUS_OK;
674 * bfa_cee_get_stats()
676 * @brief
677 * Send the request to the f/w to fetch CEE statistics.
679 * @param[in] Pointer to the CEE module data structure.
681 * @return Status
684 bfa_status_t
685 bfa_cee_get_stats(struct bfa_cee_s *cee, struct bfa_cee_stats_s *stats,
686 bfa_cee_get_stats_cbfn_t cbfn, void *cbarg)
688 struct bfi_cee_get_req_s *cmd;
690 WARN_ON((cee == NULL) || (cee->ioc == NULL));
692 if (!bfa_ioc_is_operational(cee->ioc)) {
693 bfa_trc(cee, 0);
694 return BFA_STATUS_IOC_FAILURE;
696 if (cee->get_stats_pending == BFA_TRUE) {
697 bfa_trc(cee, 0);
698 return BFA_STATUS_DEVBUSY;
700 cee->get_stats_pending = BFA_TRUE;
701 cmd = (struct bfi_cee_get_req_s *) cee->get_stats_mb.msg;
702 cee->stats = stats;
703 cee->cbfn.get_stats_cbfn = cbfn;
704 cee->cbfn.get_stats_cbarg = cbarg;
705 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_STATS_REQ,
706 bfa_ioc_portid(cee->ioc));
707 bfa_dma_be_addr_set(cmd->dma_addr, cee->stats_dma.pa);
708 bfa_ioc_mbox_queue(cee->ioc, &cee->get_stats_mb);
710 return BFA_STATUS_OK;
714 * bfa_cee_reset_stats()
716 * @brief Clears CEE Stats in the f/w.
718 * @param[in] Pointer to the CEE module data structure.
720 * @return Status
723 bfa_status_t
724 bfa_cee_reset_stats(struct bfa_cee_s *cee,
725 bfa_cee_reset_stats_cbfn_t cbfn, void *cbarg)
727 struct bfi_cee_reset_stats_s *cmd;
729 WARN_ON((cee == NULL) || (cee->ioc == NULL));
730 if (!bfa_ioc_is_operational(cee->ioc)) {
731 bfa_trc(cee, 0);
732 return BFA_STATUS_IOC_FAILURE;
734 if (cee->reset_stats_pending == BFA_TRUE) {
735 bfa_trc(cee, 0);
736 return BFA_STATUS_DEVBUSY;
738 cee->reset_stats_pending = BFA_TRUE;
739 cmd = (struct bfi_cee_reset_stats_s *) cee->reset_stats_mb.msg;
740 cee->cbfn.reset_stats_cbfn = cbfn;
741 cee->cbfn.reset_stats_cbarg = cbarg;
742 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_RESET_STATS,
743 bfa_ioc_portid(cee->ioc));
744 bfa_ioc_mbox_queue(cee->ioc, &cee->reset_stats_mb);
746 return BFA_STATUS_OK;
750 * bfa_cee_isrs()
752 * @brief Handles Mail-box interrupts for CEE module.
754 * @param[in] Pointer to the CEE module data structure.
756 * @return void
759 void
760 bfa_cee_isr(void *cbarg, struct bfi_mbmsg_s *m)
762 union bfi_cee_i2h_msg_u *msg;
763 struct bfi_cee_get_rsp_s *get_rsp;
764 struct bfa_cee_s *cee = (struct bfa_cee_s *) cbarg;
765 msg = (union bfi_cee_i2h_msg_u *) m;
766 get_rsp = (struct bfi_cee_get_rsp_s *) m;
767 bfa_trc(cee, msg->mh.msg_id);
768 switch (msg->mh.msg_id) {
769 case BFI_CEE_I2H_GET_CFG_RSP:
770 bfa_trc(cee, get_rsp->cmd_status);
771 bfa_cee_get_attr_isr(cee, get_rsp->cmd_status);
772 break;
773 case BFI_CEE_I2H_GET_STATS_RSP:
774 bfa_cee_get_stats_isr(cee, get_rsp->cmd_status);
775 break;
776 case BFI_CEE_I2H_RESET_STATS_RSP:
777 bfa_cee_reset_stats_isr(cee, get_rsp->cmd_status);
778 break;
779 default:
780 WARN_ON(1);
785 * bfa_cee_notify()
787 * @brief CEE module IOC event handler.
789 * @param[in] Pointer to the CEE module data structure.
790 * @param[in] IOC event type
792 * @return void
795 void
796 bfa_cee_notify(void *arg, enum bfa_ioc_event_e event)
798 struct bfa_cee_s *cee = (struct bfa_cee_s *) arg;
800 bfa_trc(cee, event);
802 switch (event) {
803 case BFA_IOC_E_DISABLED:
804 case BFA_IOC_E_FAILED:
805 if (cee->get_attr_pending == BFA_TRUE) {
806 cee->get_attr_status = BFA_STATUS_FAILED;
807 cee->get_attr_pending = BFA_FALSE;
808 if (cee->cbfn.get_attr_cbfn) {
809 cee->cbfn.get_attr_cbfn(
810 cee->cbfn.get_attr_cbarg,
811 BFA_STATUS_FAILED);
814 if (cee->get_stats_pending == BFA_TRUE) {
815 cee->get_stats_status = BFA_STATUS_FAILED;
816 cee->get_stats_pending = BFA_FALSE;
817 if (cee->cbfn.get_stats_cbfn) {
818 cee->cbfn.get_stats_cbfn(
819 cee->cbfn.get_stats_cbarg,
820 BFA_STATUS_FAILED);
823 if (cee->reset_stats_pending == BFA_TRUE) {
824 cee->reset_stats_status = BFA_STATUS_FAILED;
825 cee->reset_stats_pending = BFA_FALSE;
826 if (cee->cbfn.reset_stats_cbfn) {
827 cee->cbfn.reset_stats_cbfn(
828 cee->cbfn.reset_stats_cbarg,
829 BFA_STATUS_FAILED);
832 break;
834 default:
835 break;
840 * bfa_cee_attach()
842 * @brief CEE module-attach API
844 * @param[in] cee - Pointer to the CEE module data structure
845 * ioc - Pointer to the ioc module data structure
846 * dev - Pointer to the device driver module data structure
847 * The device driver specific mbox ISR functions have
848 * this pointer as one of the parameters.
850 * @return void
852 void
853 bfa_cee_attach(struct bfa_cee_s *cee, struct bfa_ioc_s *ioc,
854 void *dev)
856 WARN_ON(cee == NULL);
857 cee->dev = dev;
858 cee->ioc = ioc;
860 bfa_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
861 bfa_q_qe_init(&cee->ioc_notify);
862 bfa_ioc_notify_init(&cee->ioc_notify, bfa_cee_notify, cee);
863 list_add_tail(&cee->ioc_notify.qe, &cee->ioc->notify_q);