Jing Huang | 7725ccf | 2009-09-23 17:46:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. |
| 3 | * All rights reserved |
| 4 | * www.brocade.com |
| 5 | * |
| 6 | * Linux driver for Brocade Fibre Channel Host Bus Adapter. |
| 7 | * |
| 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 |
| 11 | * |
| 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. |
| 16 | */ |
| 17 | |
| 18 | #ifndef __BFA_INTR_PRIV_H__ |
| 19 | #define __BFA_INTR_PRIV_H__ |
| 20 | |
| 21 | /** |
| 22 | * Message handler |
| 23 | */ |
| 24 | typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m); |
| 25 | void bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m); |
| 26 | void bfa_isr_bind(enum bfi_mclass mc, bfa_isr_func_t isr_func); |
| 27 | |
| 28 | |
| 29 | #define bfa_reqq_pi(__bfa, __reqq) (__bfa)->iocfc.req_cq_pi[__reqq] |
| 30 | #define bfa_reqq_ci(__bfa, __reqq) \ |
| 31 | *(u32 *)((__bfa)->iocfc.req_cq_shadow_ci[__reqq].kva) |
| 32 | |
| 33 | #define bfa_reqq_full(__bfa, __reqq) \ |
| 34 | (((bfa_reqq_pi(__bfa, __reqq) + 1) & \ |
| 35 | ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1)) == \ |
| 36 | bfa_reqq_ci(__bfa, __reqq)) |
| 37 | |
| 38 | #define bfa_reqq_next(__bfa, __reqq) \ |
| 39 | (bfa_reqq_full(__bfa, __reqq) ? NULL : \ |
| 40 | ((void *)((struct bfi_msg_s *)((__bfa)->iocfc.req_cq_ba[__reqq].kva) \ |
| 41 | + bfa_reqq_pi((__bfa), (__reqq))))) |
| 42 | |
| 43 | #define bfa_reqq_produce(__bfa, __reqq) do { \ |
| 44 | (__bfa)->iocfc.req_cq_pi[__reqq]++; \ |
| 45 | (__bfa)->iocfc.req_cq_pi[__reqq] &= \ |
| 46 | ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1); \ |
| 47 | bfa_reg_write((__bfa)->iocfc.bfa_regs.cpe_q_pi[__reqq], \ |
| 48 | (__bfa)->iocfc.req_cq_pi[__reqq]); \ |
| 49 | bfa_os_mmiowb(); \ |
| 50 | } while (0) |
| 51 | |
| 52 | #define bfa_rspq_pi(__bfa, __rspq) \ |
| 53 | *(u32 *)((__bfa)->iocfc.rsp_cq_shadow_pi[__rspq].kva) |
| 54 | |
| 55 | #define bfa_rspq_ci(__bfa, __rspq) (__bfa)->iocfc.rsp_cq_ci[__rspq] |
| 56 | #define bfa_rspq_elem(__bfa, __rspq, __ci) \ |
| 57 | &((struct bfi_msg_s *)((__bfa)->iocfc.rsp_cq_ba[__rspq].kva))[__ci] |
| 58 | |
| 59 | #define CQ_INCR(__index, __size) \ |
| 60 | (__index)++; (__index) &= ((__size) - 1) |
| 61 | |
| 62 | /** |
| 63 | * Queue element to wait for room in request queue. FIFO order is |
| 64 | * maintained when fullfilling requests. |
| 65 | */ |
| 66 | struct bfa_reqq_wait_s { |
| 67 | struct list_head qe; |
| 68 | void (*qresume) (void *cbarg); |
| 69 | void *cbarg; |
| 70 | }; |
| 71 | |
| 72 | /** |
| 73 | * Circular queue usage assignments |
| 74 | */ |
| 75 | enum { |
| 76 | BFA_REQQ_IOC = 0, /* all low-priority IOC msgs */ |
| 77 | BFA_REQQ_FCXP = 0, /* all FCXP messages */ |
| 78 | BFA_REQQ_LPS = 0, /* all lport service msgs */ |
| 79 | BFA_REQQ_PORT = 0, /* all port messages */ |
| 80 | BFA_REQQ_FLASH = 0, /* for flash module */ |
| 81 | BFA_REQQ_DIAG = 0, /* for diag module */ |
| 82 | BFA_REQQ_RPORT = 0, /* all port messages */ |
| 83 | BFA_REQQ_SBOOT = 0, /* all san boot messages */ |
| 84 | BFA_REQQ_QOS_LO = 1, /* all low priority IO */ |
| 85 | BFA_REQQ_QOS_MD = 2, /* all medium priority IO */ |
| 86 | BFA_REQQ_QOS_HI = 3, /* all high priority IO */ |
| 87 | }; |
| 88 | |
| 89 | static inline void |
| 90 | bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg), |
| 91 | void *cbarg) |
| 92 | { |
| 93 | wqe->qresume = qresume; |
| 94 | wqe->cbarg = cbarg; |
| 95 | } |
| 96 | |
| 97 | #define bfa_reqq(__bfa, __reqq) &(__bfa)->reqq_waitq[__reqq] |
| 98 | |
| 99 | /** |
| 100 | * static inline void |
| 101 | * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe) |
| 102 | */ |
| 103 | #define bfa_reqq_wait(__bfa, __reqq, __wqe) do { \ |
| 104 | \ |
| 105 | struct list_head *waitq = bfa_reqq(__bfa, __reqq); \ |
| 106 | \ |
| 107 | bfa_assert(((__reqq) < BFI_IOC_MAX_CQS)); \ |
| 108 | bfa_assert((__wqe)->qresume && (__wqe)->cbarg); \ |
| 109 | \ |
| 110 | list_add_tail(&(__wqe)->qe, waitq); \ |
| 111 | } while (0) |
| 112 | |
| 113 | #define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe) |
| 114 | |
| 115 | #endif /* __BFA_INTR_PRIV_H__ */ |