dm thin metadata: fix __udivdi3 undefined on 32-bit
[linux/fpc-iii.git] / drivers / scsi / bfa / bfa_port.c
blob8ea7697deb9bdd87f6be661d6cf5a70ff44c171a
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 is d-port enabled, return error */
254 if (port->dport_enabled) {
255 bfa_trc(port, BFA_STATUS_DPORT_ERR);
256 return BFA_STATUS_DPORT_ERR;
259 if (port->endis_pending) {
260 bfa_trc(port, BFA_STATUS_DEVBUSY);
261 return BFA_STATUS_DEVBUSY;
264 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
266 port->msgtag++;
267 port->endis_cbfn = cbfn;
268 port->endis_cbarg = cbarg;
269 port->endis_pending = BFA_TRUE;
271 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_ENABLE_REQ,
272 bfa_ioc_portid(port->ioc));
273 bfa_ioc_mbox_queue(port->ioc, &port->endis_mb);
275 return BFA_STATUS_OK;
279 * bfa_port_disable()
281 * Send the Port disable request to the f/w
283 * @param[in] Pointer to the Port module data structure.
285 * @return Status
287 bfa_status_t
288 bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
289 void *cbarg)
291 struct bfi_port_generic_req_s *m;
293 /* If port is PBC disabled, return error */
294 if (port->pbc_disabled) {
295 bfa_trc(port, BFA_STATUS_PBC);
296 return BFA_STATUS_PBC;
299 if (bfa_ioc_is_disabled(port->ioc)) {
300 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
301 return BFA_STATUS_IOC_DISABLED;
304 if (!bfa_ioc_is_operational(port->ioc)) {
305 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
306 return BFA_STATUS_IOC_FAILURE;
309 /* if port is d-port enabled, return error */
310 if (port->dport_enabled) {
311 bfa_trc(port, BFA_STATUS_DPORT_ERR);
312 return BFA_STATUS_DPORT_ERR;
315 if (port->endis_pending) {
316 bfa_trc(port, BFA_STATUS_DEVBUSY);
317 return BFA_STATUS_DEVBUSY;
320 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
322 port->msgtag++;
323 port->endis_cbfn = cbfn;
324 port->endis_cbarg = cbarg;
325 port->endis_pending = BFA_TRUE;
327 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_DISABLE_REQ,
328 bfa_ioc_portid(port->ioc));
329 bfa_ioc_mbox_queue(port->ioc, &port->endis_mb);
331 return BFA_STATUS_OK;
335 * bfa_port_get_stats()
337 * Send the request to the f/w to fetch Port statistics.
339 * @param[in] Pointer to the Port module data structure.
341 * @return Status
343 bfa_status_t
344 bfa_port_get_stats(struct bfa_port_s *port, union bfa_port_stats_u *stats,
345 bfa_port_stats_cbfn_t cbfn, void *cbarg)
347 struct bfi_port_get_stats_req_s *m;
349 if (!bfa_ioc_is_operational(port->ioc)) {
350 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
351 return BFA_STATUS_IOC_FAILURE;
354 if (port->stats_busy) {
355 bfa_trc(port, BFA_STATUS_DEVBUSY);
356 return BFA_STATUS_DEVBUSY;
359 m = (struct bfi_port_get_stats_req_s *) port->stats_mb.msg;
361 port->stats = stats;
362 port->stats_cbfn = cbfn;
363 port->stats_cbarg = cbarg;
364 port->stats_busy = BFA_TRUE;
365 bfa_dma_be_addr_set(m->dma_addr, port->stats_dma.pa);
367 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_GET_STATS_REQ,
368 bfa_ioc_portid(port->ioc));
369 bfa_ioc_mbox_queue(port->ioc, &port->stats_mb);
371 return BFA_STATUS_OK;
375 * bfa_port_clear_stats()
378 * @param[in] Pointer to the Port module data structure.
380 * @return Status
382 bfa_status_t
383 bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
384 void *cbarg)
386 struct bfi_port_generic_req_s *m;
388 if (!bfa_ioc_is_operational(port->ioc)) {
389 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
390 return BFA_STATUS_IOC_FAILURE;
393 if (port->stats_busy) {
394 bfa_trc(port, BFA_STATUS_DEVBUSY);
395 return BFA_STATUS_DEVBUSY;
398 m = (struct bfi_port_generic_req_s *) port->stats_mb.msg;
400 port->stats_cbfn = cbfn;
401 port->stats_cbarg = cbarg;
402 port->stats_busy = BFA_TRUE;
404 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_CLEAR_STATS_REQ,
405 bfa_ioc_portid(port->ioc));
406 bfa_ioc_mbox_queue(port->ioc, &port->stats_mb);
408 return BFA_STATUS_OK;
412 * bfa_port_notify()
414 * Port module IOC event handler
416 * @param[in] Pointer to the Port module data structure.
417 * @param[in] IOC event structure
419 * @return void
421 void
422 bfa_port_notify(void *arg, enum bfa_ioc_event_e event)
424 struct bfa_port_s *port = (struct bfa_port_s *) arg;
426 switch (event) {
427 case BFA_IOC_E_DISABLED:
428 case BFA_IOC_E_FAILED:
429 /* Fail any pending get_stats/clear_stats requests */
430 if (port->stats_busy) {
431 if (port->stats_cbfn)
432 port->stats_cbfn(port->stats_cbarg,
433 BFA_STATUS_FAILED);
434 port->stats_cbfn = NULL;
435 port->stats_busy = BFA_FALSE;
438 /* Clear any enable/disable is pending */
439 if (port->endis_pending) {
440 if (port->endis_cbfn)
441 port->endis_cbfn(port->endis_cbarg,
442 BFA_STATUS_FAILED);
443 port->endis_cbfn = NULL;
444 port->endis_pending = BFA_FALSE;
447 /* clear D-port mode */
448 if (port->dport_enabled)
449 bfa_port_set_dportenabled(port, BFA_FALSE);
450 break;
451 default:
452 break;
457 * bfa_port_attach()
460 * @param[in] port - Pointer to the Port module data structure
461 * ioc - Pointer to the ioc module data structure
462 * dev - Pointer to the device driver module data structure
463 * The device driver specific mbox ISR functions have
464 * this pointer as one of the parameters.
465 * trcmod -
467 * @return void
469 void
470 bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
471 void *dev, struct bfa_trc_mod_s *trcmod)
473 struct timeval tv;
475 WARN_ON(!port);
477 port->dev = dev;
478 port->ioc = ioc;
479 port->trcmod = trcmod;
481 port->stats_busy = BFA_FALSE;
482 port->endis_pending = BFA_FALSE;
483 port->stats_cbfn = NULL;
484 port->endis_cbfn = NULL;
485 port->pbc_disabled = BFA_FALSE;
486 port->dport_enabled = BFA_FALSE;
488 bfa_ioc_mbox_regisr(port->ioc, BFI_MC_PORT, bfa_port_isr, port);
489 bfa_q_qe_init(&port->ioc_notify);
490 bfa_ioc_notify_init(&port->ioc_notify, bfa_port_notify, port);
491 list_add_tail(&port->ioc_notify.qe, &port->ioc->notify_q);
494 * initialize time stamp for stats reset
496 do_gettimeofday(&tv);
497 port->stats_reset_time = tv.tv_sec;
499 bfa_trc(port, 0);
503 * bfa_port_set_dportenabled();
505 * Port module- set pbc disabled flag
507 * @param[in] port - Pointer to the Port module data structure
509 * @return void
511 void
512 bfa_port_set_dportenabled(struct bfa_port_s *port, bfa_boolean_t enabled)
514 port->dport_enabled = enabled;
518 * CEE module specific definitions
522 * bfa_cee_get_attr_isr()
524 * @brief CEE ISR for get-attributes 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_attr_isr(struct bfa_cee_s *cee, bfa_status_t status)
534 struct bfa_cee_lldp_cfg_s *lldp_cfg = &cee->attr->lldp_remote;
536 cee->get_attr_status = status;
537 bfa_trc(cee, 0);
538 if (status == BFA_STATUS_OK) {
539 bfa_trc(cee, 0);
540 memcpy(cee->attr, cee->attr_dma.kva,
541 sizeof(struct bfa_cee_attr_s));
542 lldp_cfg->time_to_live = be16_to_cpu(lldp_cfg->time_to_live);
543 lldp_cfg->enabled_system_cap =
544 be16_to_cpu(lldp_cfg->enabled_system_cap);
546 cee->get_attr_pending = BFA_FALSE;
547 if (cee->cbfn.get_attr_cbfn) {
548 bfa_trc(cee, 0);
549 cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, status);
554 * bfa_cee_get_stats_isr()
556 * @brief CEE ISR for get-stats responses from f/w
558 * @param[in] cee - Pointer to the CEE module
559 * status - Return status from the f/w
561 * @return void
563 static void
564 bfa_cee_get_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
566 u32 *buffer;
567 int i;
569 cee->get_stats_status = status;
570 bfa_trc(cee, 0);
571 if (status == BFA_STATUS_OK) {
572 bfa_trc(cee, 0);
573 memcpy(cee->stats, cee->stats_dma.kva,
574 sizeof(struct bfa_cee_stats_s));
575 /* swap the cee stats */
576 buffer = (u32 *)cee->stats;
577 for (i = 0; i < (sizeof(struct bfa_cee_stats_s) /
578 sizeof(u32)); i++)
579 buffer[i] = cpu_to_be32(buffer[i]);
581 cee->get_stats_pending = BFA_FALSE;
582 bfa_trc(cee, 0);
583 if (cee->cbfn.get_stats_cbfn) {
584 bfa_trc(cee, 0);
585 cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, status);
590 * bfa_cee_reset_stats_isr()
592 * @brief CEE ISR for reset-stats responses from f/w
594 * @param[in] cee - Pointer to the CEE module
595 * status - Return status from the f/w
597 * @return void
599 static void
600 bfa_cee_reset_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
602 cee->reset_stats_status = status;
603 cee->reset_stats_pending = BFA_FALSE;
604 if (cee->cbfn.reset_stats_cbfn)
605 cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, status);
609 * bfa_cee_meminfo()
611 * @brief Returns the size of the DMA memory needed by CEE module
613 * @param[in] void
615 * @return Size of DMA region
618 bfa_cee_meminfo(void)
620 return BFA_ROUNDUP(sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ) +
621 BFA_ROUNDUP(sizeof(struct bfa_cee_stats_s), BFA_DMA_ALIGN_SZ);
625 * bfa_cee_mem_claim()
627 * @brief Initialized CEE DMA Memory
629 * @param[in] cee CEE module pointer
630 * dma_kva Kernel Virtual Address of CEE DMA Memory
631 * dma_pa Physical Address of CEE DMA Memory
633 * @return void
635 void
636 bfa_cee_mem_claim(struct bfa_cee_s *cee, u8 *dma_kva, u64 dma_pa)
638 cee->attr_dma.kva = dma_kva;
639 cee->attr_dma.pa = dma_pa;
640 cee->stats_dma.kva = dma_kva + BFA_ROUNDUP(
641 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
642 cee->stats_dma.pa = dma_pa + BFA_ROUNDUP(
643 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
644 cee->attr = (struct bfa_cee_attr_s *) dma_kva;
645 cee->stats = (struct bfa_cee_stats_s *) (dma_kva + BFA_ROUNDUP(
646 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ));
650 * bfa_cee_get_attr()
652 * @brief
653 * Send the request to the f/w to fetch CEE attributes.
655 * @param[in] Pointer to the CEE module data structure.
657 * @return Status
660 bfa_status_t
661 bfa_cee_get_attr(struct bfa_cee_s *cee, struct bfa_cee_attr_s *attr,
662 bfa_cee_get_attr_cbfn_t cbfn, void *cbarg)
664 struct bfi_cee_get_req_s *cmd;
666 WARN_ON((cee == NULL) || (cee->ioc == NULL));
667 bfa_trc(cee, 0);
668 if (!bfa_ioc_is_operational(cee->ioc)) {
669 bfa_trc(cee, 0);
670 return BFA_STATUS_IOC_FAILURE;
672 if (cee->get_attr_pending == BFA_TRUE) {
673 bfa_trc(cee, 0);
674 return BFA_STATUS_DEVBUSY;
676 cee->get_attr_pending = BFA_TRUE;
677 cmd = (struct bfi_cee_get_req_s *) cee->get_cfg_mb.msg;
678 cee->attr = attr;
679 cee->cbfn.get_attr_cbfn = cbfn;
680 cee->cbfn.get_attr_cbarg = cbarg;
681 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_CFG_REQ,
682 bfa_ioc_portid(cee->ioc));
683 bfa_dma_be_addr_set(cmd->dma_addr, cee->attr_dma.pa);
684 bfa_ioc_mbox_queue(cee->ioc, &cee->get_cfg_mb);
686 return BFA_STATUS_OK;
690 * bfa_cee_get_stats()
692 * @brief
693 * Send the request to the f/w to fetch CEE statistics.
695 * @param[in] Pointer to the CEE module data structure.
697 * @return Status
700 bfa_status_t
701 bfa_cee_get_stats(struct bfa_cee_s *cee, struct bfa_cee_stats_s *stats,
702 bfa_cee_get_stats_cbfn_t cbfn, void *cbarg)
704 struct bfi_cee_get_req_s *cmd;
706 WARN_ON((cee == NULL) || (cee->ioc == NULL));
708 if (!bfa_ioc_is_operational(cee->ioc)) {
709 bfa_trc(cee, 0);
710 return BFA_STATUS_IOC_FAILURE;
712 if (cee->get_stats_pending == BFA_TRUE) {
713 bfa_trc(cee, 0);
714 return BFA_STATUS_DEVBUSY;
716 cee->get_stats_pending = BFA_TRUE;
717 cmd = (struct bfi_cee_get_req_s *) cee->get_stats_mb.msg;
718 cee->stats = stats;
719 cee->cbfn.get_stats_cbfn = cbfn;
720 cee->cbfn.get_stats_cbarg = cbarg;
721 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_STATS_REQ,
722 bfa_ioc_portid(cee->ioc));
723 bfa_dma_be_addr_set(cmd->dma_addr, cee->stats_dma.pa);
724 bfa_ioc_mbox_queue(cee->ioc, &cee->get_stats_mb);
726 return BFA_STATUS_OK;
730 * bfa_cee_reset_stats()
732 * @brief Clears CEE Stats in the f/w.
734 * @param[in] Pointer to the CEE module data structure.
736 * @return Status
739 bfa_status_t
740 bfa_cee_reset_stats(struct bfa_cee_s *cee,
741 bfa_cee_reset_stats_cbfn_t cbfn, void *cbarg)
743 struct bfi_cee_reset_stats_s *cmd;
745 WARN_ON((cee == NULL) || (cee->ioc == NULL));
746 if (!bfa_ioc_is_operational(cee->ioc)) {
747 bfa_trc(cee, 0);
748 return BFA_STATUS_IOC_FAILURE;
750 if (cee->reset_stats_pending == BFA_TRUE) {
751 bfa_trc(cee, 0);
752 return BFA_STATUS_DEVBUSY;
754 cee->reset_stats_pending = BFA_TRUE;
755 cmd = (struct bfi_cee_reset_stats_s *) cee->reset_stats_mb.msg;
756 cee->cbfn.reset_stats_cbfn = cbfn;
757 cee->cbfn.reset_stats_cbarg = cbarg;
758 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_RESET_STATS,
759 bfa_ioc_portid(cee->ioc));
760 bfa_ioc_mbox_queue(cee->ioc, &cee->reset_stats_mb);
762 return BFA_STATUS_OK;
766 * bfa_cee_isrs()
768 * @brief Handles Mail-box interrupts for CEE module.
770 * @param[in] Pointer to the CEE module data structure.
772 * @return void
775 void
776 bfa_cee_isr(void *cbarg, struct bfi_mbmsg_s *m)
778 union bfi_cee_i2h_msg_u *msg;
779 struct bfi_cee_get_rsp_s *get_rsp;
780 struct bfa_cee_s *cee = (struct bfa_cee_s *) cbarg;
781 msg = (union bfi_cee_i2h_msg_u *) m;
782 get_rsp = (struct bfi_cee_get_rsp_s *) m;
783 bfa_trc(cee, msg->mh.msg_id);
784 switch (msg->mh.msg_id) {
785 case BFI_CEE_I2H_GET_CFG_RSP:
786 bfa_trc(cee, get_rsp->cmd_status);
787 bfa_cee_get_attr_isr(cee, get_rsp->cmd_status);
788 break;
789 case BFI_CEE_I2H_GET_STATS_RSP:
790 bfa_cee_get_stats_isr(cee, get_rsp->cmd_status);
791 break;
792 case BFI_CEE_I2H_RESET_STATS_RSP:
793 bfa_cee_reset_stats_isr(cee, get_rsp->cmd_status);
794 break;
795 default:
796 WARN_ON(1);
801 * bfa_cee_notify()
803 * @brief CEE module IOC event handler.
805 * @param[in] Pointer to the CEE module data structure.
806 * @param[in] IOC event type
808 * @return void
811 void
812 bfa_cee_notify(void *arg, enum bfa_ioc_event_e event)
814 struct bfa_cee_s *cee = (struct bfa_cee_s *) arg;
816 bfa_trc(cee, event);
818 switch (event) {
819 case BFA_IOC_E_DISABLED:
820 case BFA_IOC_E_FAILED:
821 if (cee->get_attr_pending == BFA_TRUE) {
822 cee->get_attr_status = BFA_STATUS_FAILED;
823 cee->get_attr_pending = BFA_FALSE;
824 if (cee->cbfn.get_attr_cbfn) {
825 cee->cbfn.get_attr_cbfn(
826 cee->cbfn.get_attr_cbarg,
827 BFA_STATUS_FAILED);
830 if (cee->get_stats_pending == BFA_TRUE) {
831 cee->get_stats_status = BFA_STATUS_FAILED;
832 cee->get_stats_pending = BFA_FALSE;
833 if (cee->cbfn.get_stats_cbfn) {
834 cee->cbfn.get_stats_cbfn(
835 cee->cbfn.get_stats_cbarg,
836 BFA_STATUS_FAILED);
839 if (cee->reset_stats_pending == BFA_TRUE) {
840 cee->reset_stats_status = BFA_STATUS_FAILED;
841 cee->reset_stats_pending = BFA_FALSE;
842 if (cee->cbfn.reset_stats_cbfn) {
843 cee->cbfn.reset_stats_cbfn(
844 cee->cbfn.reset_stats_cbarg,
845 BFA_STATUS_FAILED);
848 break;
850 default:
851 break;
856 * bfa_cee_attach()
858 * @brief CEE module-attach API
860 * @param[in] cee - Pointer to the CEE module data structure
861 * ioc - Pointer to the ioc module data structure
862 * dev - Pointer to the device driver module data structure
863 * The device driver specific mbox ISR functions have
864 * this pointer as one of the parameters.
866 * @return void
868 void
869 bfa_cee_attach(struct bfa_cee_s *cee, struct bfa_ioc_s *ioc,
870 void *dev)
872 WARN_ON(cee == NULL);
873 cee->dev = dev;
874 cee->ioc = ioc;
876 bfa_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
877 bfa_q_qe_init(&cee->ioc_notify);
878 bfa_ioc_notify_init(&cee->ioc_notify, bfa_cee_notify, cee);
879 list_add_tail(&cee->ioc_notify.qe, &cee->ioc->notify_q);