Linux 4.16.11
[linux/fpc-iii.git] / drivers / scsi / bfa / bfa_port.c
blob079bc77f4102665beddb004323ce16a99f2053c0
1 /*
2 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
3 * Copyright (c) 2014- QLogic Corporation.
4 * All rights reserved
5 * www.qlogic.com
7 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License (GPL) Version 2 as
11 * published by the Free Software Foundation
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
19 #include "bfad_drv.h"
20 #include "bfa_defs_svc.h"
21 #include "bfa_port.h"
22 #include "bfi.h"
23 #include "bfa_ioc.h"
26 BFA_TRC_FILE(CNA, PORT);
28 static void
29 bfa_port_stats_swap(struct bfa_port_s *port, union bfa_port_stats_u *stats)
31 u32 *dip = (u32 *) stats;
32 __be32 t0, t1;
33 int i;
35 for (i = 0; i < sizeof(union bfa_port_stats_u)/sizeof(u32);
36 i += 2) {
37 t0 = dip[i];
38 t1 = dip[i + 1];
39 #ifdef __BIG_ENDIAN
40 dip[i] = be32_to_cpu(t0);
41 dip[i + 1] = be32_to_cpu(t1);
42 #else
43 dip[i] = be32_to_cpu(t1);
44 dip[i + 1] = be32_to_cpu(t0);
45 #endif
50 * bfa_port_enable_isr()
53 * @param[in] port - Pointer to the port module
54 * status - Return status from the f/w
56 * @return void
58 static void
59 bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status)
61 bfa_trc(port, status);
62 port->endis_pending = BFA_FALSE;
63 port->endis_cbfn(port->endis_cbarg, status);
67 * bfa_port_disable_isr()
70 * @param[in] port - Pointer to the port module
71 * status - Return status from the f/w
73 * @return void
75 static void
76 bfa_port_disable_isr(struct bfa_port_s *port, bfa_status_t status)
78 bfa_trc(port, status);
79 port->endis_pending = BFA_FALSE;
80 port->endis_cbfn(port->endis_cbarg, status);
84 * bfa_port_get_stats_isr()
87 * @param[in] port - Pointer to the Port module
88 * status - Return status from the f/w
90 * @return void
92 static void
93 bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
95 port->stats_status = status;
96 port->stats_busy = BFA_FALSE;
98 if (status == BFA_STATUS_OK) {
99 memcpy(port->stats, port->stats_dma.kva,
100 sizeof(union bfa_port_stats_u));
101 bfa_port_stats_swap(port, port->stats);
103 port->stats->fc.secs_reset = ktime_get_seconds() - port->stats_reset_time;
106 if (port->stats_cbfn) {
107 port->stats_cbfn(port->stats_cbarg, status);
108 port->stats_cbfn = NULL;
113 * bfa_port_clear_stats_isr()
116 * @param[in] port - Pointer to the Port module
117 * status - Return status from the f/w
119 * @return void
121 static void
122 bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
124 port->stats_status = status;
125 port->stats_busy = BFA_FALSE;
128 * re-initialize time stamp for stats reset
130 port->stats_reset_time = ktime_get_seconds();
132 if (port->stats_cbfn) {
133 port->stats_cbfn(port->stats_cbarg, status);
134 port->stats_cbfn = NULL;
139 * bfa_port_isr()
142 * @param[in] Pointer to the Port module data structure.
144 * @return void
146 static void
147 bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
149 struct bfa_port_s *port = (struct bfa_port_s *) cbarg;
150 union bfi_port_i2h_msg_u *i2hmsg;
152 i2hmsg = (union bfi_port_i2h_msg_u *) m;
153 bfa_trc(port, m->mh.msg_id);
155 switch (m->mh.msg_id) {
156 case BFI_PORT_I2H_ENABLE_RSP:
157 if (port->endis_pending == BFA_FALSE)
158 break;
159 bfa_port_enable_isr(port, i2hmsg->enable_rsp.status);
160 break;
162 case BFI_PORT_I2H_DISABLE_RSP:
163 if (port->endis_pending == BFA_FALSE)
164 break;
165 bfa_port_disable_isr(port, i2hmsg->disable_rsp.status);
166 break;
168 case BFI_PORT_I2H_GET_STATS_RSP:
169 /* Stats busy flag is still set? (may be cmd timed out) */
170 if (port->stats_busy == BFA_FALSE)
171 break;
172 bfa_port_get_stats_isr(port, i2hmsg->getstats_rsp.status);
173 break;
175 case BFI_PORT_I2H_CLEAR_STATS_RSP:
176 if (port->stats_busy == BFA_FALSE)
177 break;
178 bfa_port_clear_stats_isr(port, i2hmsg->clearstats_rsp.status);
179 break;
181 default:
182 WARN_ON(1);
187 * bfa_port_meminfo()
190 * @param[in] void
192 * @return Size of DMA region
195 bfa_port_meminfo(void)
197 return BFA_ROUNDUP(sizeof(union bfa_port_stats_u), BFA_DMA_ALIGN_SZ);
201 * bfa_port_mem_claim()
204 * @param[in] port Port module pointer
205 * dma_kva Kernel Virtual Address of Port DMA Memory
206 * dma_pa Physical Address of Port DMA Memory
208 * @return void
210 void
211 bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa)
213 port->stats_dma.kva = dma_kva;
214 port->stats_dma.pa = dma_pa;
218 * bfa_port_enable()
220 * Send the Port enable request to the f/w
222 * @param[in] Pointer to the Port module data structure.
224 * @return Status
226 bfa_status_t
227 bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
228 void *cbarg)
230 struct bfi_port_generic_req_s *m;
232 /* If port is PBC disabled, return error */
233 if (port->pbc_disabled) {
234 bfa_trc(port, BFA_STATUS_PBC);
235 return BFA_STATUS_PBC;
238 if (bfa_ioc_is_disabled(port->ioc)) {
239 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
240 return BFA_STATUS_IOC_DISABLED;
243 if (!bfa_ioc_is_operational(port->ioc)) {
244 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
245 return BFA_STATUS_IOC_FAILURE;
248 /* if port is d-port enabled, return error */
249 if (port->dport_enabled) {
250 bfa_trc(port, BFA_STATUS_DPORT_ERR);
251 return BFA_STATUS_DPORT_ERR;
254 if (port->endis_pending) {
255 bfa_trc(port, BFA_STATUS_DEVBUSY);
256 return BFA_STATUS_DEVBUSY;
259 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
261 port->msgtag++;
262 port->endis_cbfn = cbfn;
263 port->endis_cbarg = cbarg;
264 port->endis_pending = BFA_TRUE;
266 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_ENABLE_REQ,
267 bfa_ioc_portid(port->ioc));
268 bfa_ioc_mbox_queue(port->ioc, &port->endis_mb);
270 return BFA_STATUS_OK;
274 * bfa_port_disable()
276 * Send the Port disable request to the f/w
278 * @param[in] Pointer to the Port module data structure.
280 * @return Status
282 bfa_status_t
283 bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
284 void *cbarg)
286 struct bfi_port_generic_req_s *m;
288 /* If port is PBC disabled, return error */
289 if (port->pbc_disabled) {
290 bfa_trc(port, BFA_STATUS_PBC);
291 return BFA_STATUS_PBC;
294 if (bfa_ioc_is_disabled(port->ioc)) {
295 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
296 return BFA_STATUS_IOC_DISABLED;
299 if (!bfa_ioc_is_operational(port->ioc)) {
300 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
301 return BFA_STATUS_IOC_FAILURE;
304 /* if port is d-port enabled, return error */
305 if (port->dport_enabled) {
306 bfa_trc(port, BFA_STATUS_DPORT_ERR);
307 return BFA_STATUS_DPORT_ERR;
310 if (port->endis_pending) {
311 bfa_trc(port, BFA_STATUS_DEVBUSY);
312 return BFA_STATUS_DEVBUSY;
315 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
317 port->msgtag++;
318 port->endis_cbfn = cbfn;
319 port->endis_cbarg = cbarg;
320 port->endis_pending = BFA_TRUE;
322 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_DISABLE_REQ,
323 bfa_ioc_portid(port->ioc));
324 bfa_ioc_mbox_queue(port->ioc, &port->endis_mb);
326 return BFA_STATUS_OK;
330 * bfa_port_get_stats()
332 * Send the request to the f/w to fetch Port statistics.
334 * @param[in] Pointer to the Port module data structure.
336 * @return Status
338 bfa_status_t
339 bfa_port_get_stats(struct bfa_port_s *port, union bfa_port_stats_u *stats,
340 bfa_port_stats_cbfn_t cbfn, void *cbarg)
342 struct bfi_port_get_stats_req_s *m;
344 if (!bfa_ioc_is_operational(port->ioc)) {
345 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
346 return BFA_STATUS_IOC_FAILURE;
349 if (port->stats_busy) {
350 bfa_trc(port, BFA_STATUS_DEVBUSY);
351 return BFA_STATUS_DEVBUSY;
354 m = (struct bfi_port_get_stats_req_s *) port->stats_mb.msg;
356 port->stats = stats;
357 port->stats_cbfn = cbfn;
358 port->stats_cbarg = cbarg;
359 port->stats_busy = BFA_TRUE;
360 bfa_dma_be_addr_set(m->dma_addr, port->stats_dma.pa);
362 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_GET_STATS_REQ,
363 bfa_ioc_portid(port->ioc));
364 bfa_ioc_mbox_queue(port->ioc, &port->stats_mb);
366 return BFA_STATUS_OK;
370 * bfa_port_clear_stats()
373 * @param[in] Pointer to the Port module data structure.
375 * @return Status
377 bfa_status_t
378 bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
379 void *cbarg)
381 struct bfi_port_generic_req_s *m;
383 if (!bfa_ioc_is_operational(port->ioc)) {
384 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
385 return BFA_STATUS_IOC_FAILURE;
388 if (port->stats_busy) {
389 bfa_trc(port, BFA_STATUS_DEVBUSY);
390 return BFA_STATUS_DEVBUSY;
393 m = (struct bfi_port_generic_req_s *) port->stats_mb.msg;
395 port->stats_cbfn = cbfn;
396 port->stats_cbarg = cbarg;
397 port->stats_busy = BFA_TRUE;
399 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_CLEAR_STATS_REQ,
400 bfa_ioc_portid(port->ioc));
401 bfa_ioc_mbox_queue(port->ioc, &port->stats_mb);
403 return BFA_STATUS_OK;
407 * bfa_port_notify()
409 * Port module IOC event handler
411 * @param[in] Pointer to the Port module data structure.
412 * @param[in] IOC event structure
414 * @return void
416 void
417 bfa_port_notify(void *arg, enum bfa_ioc_event_e event)
419 struct bfa_port_s *port = (struct bfa_port_s *) arg;
421 switch (event) {
422 case BFA_IOC_E_DISABLED:
423 case BFA_IOC_E_FAILED:
424 /* Fail any pending get_stats/clear_stats requests */
425 if (port->stats_busy) {
426 if (port->stats_cbfn)
427 port->stats_cbfn(port->stats_cbarg,
428 BFA_STATUS_FAILED);
429 port->stats_cbfn = NULL;
430 port->stats_busy = BFA_FALSE;
433 /* Clear any enable/disable is pending */
434 if (port->endis_pending) {
435 if (port->endis_cbfn)
436 port->endis_cbfn(port->endis_cbarg,
437 BFA_STATUS_FAILED);
438 port->endis_cbfn = NULL;
439 port->endis_pending = BFA_FALSE;
442 /* clear D-port mode */
443 if (port->dport_enabled)
444 bfa_port_set_dportenabled(port, BFA_FALSE);
445 break;
446 default:
447 break;
452 * bfa_port_attach()
455 * @param[in] port - Pointer to the Port module data structure
456 * ioc - Pointer to the ioc module data structure
457 * dev - Pointer to the device driver module data structure
458 * The device driver specific mbox ISR functions have
459 * this pointer as one of the parameters.
460 * trcmod -
462 * @return void
464 void
465 bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
466 void *dev, struct bfa_trc_mod_s *trcmod)
468 WARN_ON(!port);
470 port->dev = dev;
471 port->ioc = ioc;
472 port->trcmod = trcmod;
474 port->stats_busy = BFA_FALSE;
475 port->endis_pending = BFA_FALSE;
476 port->stats_cbfn = NULL;
477 port->endis_cbfn = NULL;
478 port->pbc_disabled = BFA_FALSE;
479 port->dport_enabled = BFA_FALSE;
481 bfa_ioc_mbox_regisr(port->ioc, BFI_MC_PORT, bfa_port_isr, port);
482 bfa_q_qe_init(&port->ioc_notify);
483 bfa_ioc_notify_init(&port->ioc_notify, bfa_port_notify, port);
484 list_add_tail(&port->ioc_notify.qe, &port->ioc->notify_q);
487 * initialize time stamp for stats reset
489 port->stats_reset_time = ktime_get_seconds();
491 bfa_trc(port, 0);
495 * bfa_port_set_dportenabled();
497 * Port module- set pbc disabled flag
499 * @param[in] port - Pointer to the Port module data structure
501 * @return void
503 void
504 bfa_port_set_dportenabled(struct bfa_port_s *port, bfa_boolean_t enabled)
506 port->dport_enabled = enabled;
510 * CEE module specific definitions
514 * bfa_cee_get_attr_isr()
516 * @brief CEE ISR for get-attributes responses from f/w
518 * @param[in] cee - Pointer to the CEE module
519 * status - Return status from the f/w
521 * @return void
523 static void
524 bfa_cee_get_attr_isr(struct bfa_cee_s *cee, bfa_status_t status)
526 struct bfa_cee_lldp_cfg_s *lldp_cfg = &cee->attr->lldp_remote;
528 cee->get_attr_status = status;
529 bfa_trc(cee, 0);
530 if (status == BFA_STATUS_OK) {
531 bfa_trc(cee, 0);
532 memcpy(cee->attr, cee->attr_dma.kva,
533 sizeof(struct bfa_cee_attr_s));
534 lldp_cfg->time_to_live = be16_to_cpu(lldp_cfg->time_to_live);
535 lldp_cfg->enabled_system_cap =
536 be16_to_cpu(lldp_cfg->enabled_system_cap);
538 cee->get_attr_pending = BFA_FALSE;
539 if (cee->cbfn.get_attr_cbfn) {
540 bfa_trc(cee, 0);
541 cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, status);
546 * bfa_cee_get_stats_isr()
548 * @brief CEE ISR for get-stats responses from f/w
550 * @param[in] cee - Pointer to the CEE module
551 * status - Return status from the f/w
553 * @return void
555 static void
556 bfa_cee_get_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
558 u32 *buffer;
559 int i;
561 cee->get_stats_status = status;
562 bfa_trc(cee, 0);
563 if (status == BFA_STATUS_OK) {
564 bfa_trc(cee, 0);
565 memcpy(cee->stats, cee->stats_dma.kva,
566 sizeof(struct bfa_cee_stats_s));
567 /* swap the cee stats */
568 buffer = (u32 *)cee->stats;
569 for (i = 0; i < (sizeof(struct bfa_cee_stats_s) /
570 sizeof(u32)); i++)
571 buffer[i] = cpu_to_be32(buffer[i]);
573 cee->get_stats_pending = BFA_FALSE;
574 bfa_trc(cee, 0);
575 if (cee->cbfn.get_stats_cbfn) {
576 bfa_trc(cee, 0);
577 cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, status);
582 * bfa_cee_reset_stats_isr()
584 * @brief CEE ISR for reset-stats responses from f/w
586 * @param[in] cee - Pointer to the CEE module
587 * status - Return status from the f/w
589 * @return void
591 static void
592 bfa_cee_reset_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
594 cee->reset_stats_status = status;
595 cee->reset_stats_pending = BFA_FALSE;
596 if (cee->cbfn.reset_stats_cbfn)
597 cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, status);
601 * bfa_cee_meminfo()
603 * @brief Returns the size of the DMA memory needed by CEE module
605 * @param[in] void
607 * @return Size of DMA region
610 bfa_cee_meminfo(void)
612 return BFA_ROUNDUP(sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ) +
613 BFA_ROUNDUP(sizeof(struct bfa_cee_stats_s), BFA_DMA_ALIGN_SZ);
617 * bfa_cee_mem_claim()
619 * @brief Initialized CEE DMA Memory
621 * @param[in] cee CEE module pointer
622 * dma_kva Kernel Virtual Address of CEE DMA Memory
623 * dma_pa Physical Address of CEE DMA Memory
625 * @return void
627 void
628 bfa_cee_mem_claim(struct bfa_cee_s *cee, u8 *dma_kva, u64 dma_pa)
630 cee->attr_dma.kva = dma_kva;
631 cee->attr_dma.pa = dma_pa;
632 cee->stats_dma.kva = dma_kva + BFA_ROUNDUP(
633 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
634 cee->stats_dma.pa = dma_pa + BFA_ROUNDUP(
635 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
636 cee->attr = (struct bfa_cee_attr_s *) dma_kva;
637 cee->stats = (struct bfa_cee_stats_s *) (dma_kva + BFA_ROUNDUP(
638 sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ));
642 * bfa_cee_get_attr()
644 * @brief
645 * Send the request to the f/w to fetch CEE attributes.
647 * @param[in] Pointer to the CEE module data structure.
649 * @return Status
652 bfa_status_t
653 bfa_cee_get_attr(struct bfa_cee_s *cee, struct bfa_cee_attr_s *attr,
654 bfa_cee_get_attr_cbfn_t cbfn, void *cbarg)
656 struct bfi_cee_get_req_s *cmd;
658 WARN_ON((cee == NULL) || (cee->ioc == NULL));
659 bfa_trc(cee, 0);
660 if (!bfa_ioc_is_operational(cee->ioc)) {
661 bfa_trc(cee, 0);
662 return BFA_STATUS_IOC_FAILURE;
664 if (cee->get_attr_pending == BFA_TRUE) {
665 bfa_trc(cee, 0);
666 return BFA_STATUS_DEVBUSY;
668 cee->get_attr_pending = BFA_TRUE;
669 cmd = (struct bfi_cee_get_req_s *) cee->get_cfg_mb.msg;
670 cee->attr = attr;
671 cee->cbfn.get_attr_cbfn = cbfn;
672 cee->cbfn.get_attr_cbarg = cbarg;
673 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_CFG_REQ,
674 bfa_ioc_portid(cee->ioc));
675 bfa_dma_be_addr_set(cmd->dma_addr, cee->attr_dma.pa);
676 bfa_ioc_mbox_queue(cee->ioc, &cee->get_cfg_mb);
678 return BFA_STATUS_OK;
682 * bfa_cee_get_stats()
684 * @brief
685 * Send the request to the f/w to fetch CEE statistics.
687 * @param[in] Pointer to the CEE module data structure.
689 * @return Status
692 bfa_status_t
693 bfa_cee_get_stats(struct bfa_cee_s *cee, struct bfa_cee_stats_s *stats,
694 bfa_cee_get_stats_cbfn_t cbfn, void *cbarg)
696 struct bfi_cee_get_req_s *cmd;
698 WARN_ON((cee == NULL) || (cee->ioc == NULL));
700 if (!bfa_ioc_is_operational(cee->ioc)) {
701 bfa_trc(cee, 0);
702 return BFA_STATUS_IOC_FAILURE;
704 if (cee->get_stats_pending == BFA_TRUE) {
705 bfa_trc(cee, 0);
706 return BFA_STATUS_DEVBUSY;
708 cee->get_stats_pending = BFA_TRUE;
709 cmd = (struct bfi_cee_get_req_s *) cee->get_stats_mb.msg;
710 cee->stats = stats;
711 cee->cbfn.get_stats_cbfn = cbfn;
712 cee->cbfn.get_stats_cbarg = cbarg;
713 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_STATS_REQ,
714 bfa_ioc_portid(cee->ioc));
715 bfa_dma_be_addr_set(cmd->dma_addr, cee->stats_dma.pa);
716 bfa_ioc_mbox_queue(cee->ioc, &cee->get_stats_mb);
718 return BFA_STATUS_OK;
722 * bfa_cee_reset_stats()
724 * @brief Clears CEE Stats in the f/w.
726 * @param[in] Pointer to the CEE module data structure.
728 * @return Status
731 bfa_status_t
732 bfa_cee_reset_stats(struct bfa_cee_s *cee,
733 bfa_cee_reset_stats_cbfn_t cbfn, void *cbarg)
735 struct bfi_cee_reset_stats_s *cmd;
737 WARN_ON((cee == NULL) || (cee->ioc == NULL));
738 if (!bfa_ioc_is_operational(cee->ioc)) {
739 bfa_trc(cee, 0);
740 return BFA_STATUS_IOC_FAILURE;
742 if (cee->reset_stats_pending == BFA_TRUE) {
743 bfa_trc(cee, 0);
744 return BFA_STATUS_DEVBUSY;
746 cee->reset_stats_pending = BFA_TRUE;
747 cmd = (struct bfi_cee_reset_stats_s *) cee->reset_stats_mb.msg;
748 cee->cbfn.reset_stats_cbfn = cbfn;
749 cee->cbfn.reset_stats_cbarg = cbarg;
750 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_RESET_STATS,
751 bfa_ioc_portid(cee->ioc));
752 bfa_ioc_mbox_queue(cee->ioc, &cee->reset_stats_mb);
754 return BFA_STATUS_OK;
758 * bfa_cee_isrs()
760 * @brief Handles Mail-box interrupts for CEE module.
762 * @param[in] Pointer to the CEE module data structure.
764 * @return void
767 void
768 bfa_cee_isr(void *cbarg, struct bfi_mbmsg_s *m)
770 union bfi_cee_i2h_msg_u *msg;
771 struct bfi_cee_get_rsp_s *get_rsp;
772 struct bfa_cee_s *cee = (struct bfa_cee_s *) cbarg;
773 msg = (union bfi_cee_i2h_msg_u *) m;
774 get_rsp = (struct bfi_cee_get_rsp_s *) m;
775 bfa_trc(cee, msg->mh.msg_id);
776 switch (msg->mh.msg_id) {
777 case BFI_CEE_I2H_GET_CFG_RSP:
778 bfa_trc(cee, get_rsp->cmd_status);
779 bfa_cee_get_attr_isr(cee, get_rsp->cmd_status);
780 break;
781 case BFI_CEE_I2H_GET_STATS_RSP:
782 bfa_cee_get_stats_isr(cee, get_rsp->cmd_status);
783 break;
784 case BFI_CEE_I2H_RESET_STATS_RSP:
785 bfa_cee_reset_stats_isr(cee, get_rsp->cmd_status);
786 break;
787 default:
788 WARN_ON(1);
793 * bfa_cee_notify()
795 * @brief CEE module IOC event handler.
797 * @param[in] Pointer to the CEE module data structure.
798 * @param[in] IOC event type
800 * @return void
803 void
804 bfa_cee_notify(void *arg, enum bfa_ioc_event_e event)
806 struct bfa_cee_s *cee = (struct bfa_cee_s *) arg;
808 bfa_trc(cee, event);
810 switch (event) {
811 case BFA_IOC_E_DISABLED:
812 case BFA_IOC_E_FAILED:
813 if (cee->get_attr_pending == BFA_TRUE) {
814 cee->get_attr_status = BFA_STATUS_FAILED;
815 cee->get_attr_pending = BFA_FALSE;
816 if (cee->cbfn.get_attr_cbfn) {
817 cee->cbfn.get_attr_cbfn(
818 cee->cbfn.get_attr_cbarg,
819 BFA_STATUS_FAILED);
822 if (cee->get_stats_pending == BFA_TRUE) {
823 cee->get_stats_status = BFA_STATUS_FAILED;
824 cee->get_stats_pending = BFA_FALSE;
825 if (cee->cbfn.get_stats_cbfn) {
826 cee->cbfn.get_stats_cbfn(
827 cee->cbfn.get_stats_cbarg,
828 BFA_STATUS_FAILED);
831 if (cee->reset_stats_pending == BFA_TRUE) {
832 cee->reset_stats_status = BFA_STATUS_FAILED;
833 cee->reset_stats_pending = BFA_FALSE;
834 if (cee->cbfn.reset_stats_cbfn) {
835 cee->cbfn.reset_stats_cbfn(
836 cee->cbfn.reset_stats_cbarg,
837 BFA_STATUS_FAILED);
840 break;
842 default:
843 break;
848 * bfa_cee_attach()
850 * @brief CEE module-attach API
852 * @param[in] cee - Pointer to the CEE module data structure
853 * ioc - Pointer to the ioc module data structure
854 * dev - Pointer to the device driver module data structure
855 * The device driver specific mbox ISR functions have
856 * this pointer as one of the parameters.
858 * @return void
860 void
861 bfa_cee_attach(struct bfa_cee_s *cee, struct bfa_ioc_s *ioc,
862 void *dev)
864 WARN_ON(cee == NULL);
865 cee->dev = dev;
866 cee->ioc = ioc;
868 bfa_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
869 bfa_q_qe_init(&cee->ioc_notify);
870 bfa_ioc_notify_init(&cee->ioc_notify, bfa_cee_notify, cee);
871 list_add_tail(&cee->ioc_notify.qe, &cee->ioc->notify_q);