1a36c61f9SKrishna Gudipati /* 2a36c61f9SKrishna Gudipati * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. 3a36c61f9SKrishna Gudipati * All rights reserved 4a36c61f9SKrishna Gudipati * www.brocade.com 5a36c61f9SKrishna Gudipati * 6a36c61f9SKrishna Gudipati * Linux driver for Brocade Fibre Channel Host Bus Adapter. 7a36c61f9SKrishna Gudipati * 8a36c61f9SKrishna Gudipati * This program is free software; you can redistribute it and/or modify it 9a36c61f9SKrishna Gudipati * under the terms of the GNU General Public License (GPL) Version 2 as 10a36c61f9SKrishna Gudipati * published by the Free Software Foundation 11a36c61f9SKrishna Gudipati * 12a36c61f9SKrishna Gudipati * This program is distributed in the hope that it will be useful, but 13a36c61f9SKrishna Gudipati * WITHOUT ANY WARRANTY; without even the implied warranty of 14a36c61f9SKrishna Gudipati * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15a36c61f9SKrishna Gudipati * General Public License for more details. 16a36c61f9SKrishna Gudipati */ 17a36c61f9SKrishna Gudipati 18a36c61f9SKrishna Gudipati #ifndef __BFA_SVC_H__ 19a36c61f9SKrishna Gudipati #define __BFA_SVC_H__ 20a36c61f9SKrishna Gudipati 21a36c61f9SKrishna Gudipati #include "bfa_cs.h" 22a36c61f9SKrishna Gudipati #include "bfi_ms.h" 23a36c61f9SKrishna Gudipati 24a36c61f9SKrishna Gudipati 25acdc79a6SJing Huang /* 26a36c61f9SKrishna Gudipati * Scatter-gather DMA related defines 27a36c61f9SKrishna Gudipati */ 28a36c61f9SKrishna Gudipati #define BFA_SGPG_MIN (16) 294507025dSKrishna Gudipati #define BFA_SGPG_MAX (8192) 30a36c61f9SKrishna Gudipati 31acdc79a6SJing Huang /* 32a36c61f9SKrishna Gudipati * Alignment macro for SG page allocation 33a36c61f9SKrishna Gudipati */ 34a36c61f9SKrishna Gudipati #define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1)) \ 35a36c61f9SKrishna Gudipati & ~(sizeof(struct bfi_sgpg_s) - 1)) 36a36c61f9SKrishna Gudipati 37a36c61f9SKrishna Gudipati struct bfa_sgpg_wqe_s { 38a36c61f9SKrishna Gudipati struct list_head qe; /* queue sg page element */ 39a36c61f9SKrishna Gudipati int nsgpg; /* pages to be allocated */ 40a36c61f9SKrishna Gudipati int nsgpg_total; /* total pages required */ 41a36c61f9SKrishna Gudipati void (*cbfn) (void *cbarg); /* callback function */ 42a36c61f9SKrishna Gudipati void *cbarg; /* callback arg */ 43a36c61f9SKrishna Gudipati struct list_head sgpg_q; /* queue of alloced sgpgs */ 44a36c61f9SKrishna Gudipati }; 45a36c61f9SKrishna Gudipati 46a36c61f9SKrishna Gudipati struct bfa_sgpg_s { 47a36c61f9SKrishna Gudipati struct list_head qe; /* queue sg page element */ 48a36c61f9SKrishna Gudipati struct bfi_sgpg_s *sgpg; /* va of SG page */ 49a36c61f9SKrishna Gudipati union bfi_addr_u sgpg_pa; /* pa of SG page */ 50a36c61f9SKrishna Gudipati }; 51a36c61f9SKrishna Gudipati 52acdc79a6SJing Huang /* 53a36c61f9SKrishna Gudipati * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of 54a36c61f9SKrishna Gudipati * SG pages required. 55a36c61f9SKrishna Gudipati */ 56a36c61f9SKrishna Gudipati #define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1) 57a36c61f9SKrishna Gudipati 584507025dSKrishna Gudipati /* Max SGPG dma segs required */ 594507025dSKrishna Gudipati #define BFA_SGPG_DMA_SEGS \ 604507025dSKrishna Gudipati BFI_MEM_DMA_NSEGS(BFA_SGPG_MAX, (uint32_t)sizeof(struct bfi_sgpg_s)) 614507025dSKrishna Gudipati 62a36c61f9SKrishna Gudipati struct bfa_sgpg_mod_s { 63a36c61f9SKrishna Gudipati struct bfa_s *bfa; 64a36c61f9SKrishna Gudipati int num_sgpgs; /* number of SG pages */ 65a36c61f9SKrishna Gudipati int free_sgpgs; /* number of free SG pages */ 66a36c61f9SKrishna Gudipati struct list_head sgpg_q; /* queue of free SG pages */ 67a36c61f9SKrishna Gudipati struct list_head sgpg_wait_q; /* wait queue for SG pages */ 684507025dSKrishna Gudipati struct bfa_mem_dma_s dma_seg[BFA_SGPG_DMA_SEGS]; 694507025dSKrishna Gudipati struct bfa_mem_kva_s kva_seg; 70a36c61f9SKrishna Gudipati }; 71a36c61f9SKrishna Gudipati #define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod) 724507025dSKrishna Gudipati #define BFA_MEM_SGPG_KVA(__bfa) (&(BFA_SGPG_MOD(__bfa)->kva_seg)) 73a36c61f9SKrishna Gudipati 74a36c61f9SKrishna Gudipati bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q, 75a36c61f9SKrishna Gudipati int nsgpgs); 76a36c61f9SKrishna Gudipati void bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs); 77a36c61f9SKrishna Gudipati void bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe, 78a36c61f9SKrishna Gudipati void (*cbfn) (void *cbarg), void *cbarg); 79a36c61f9SKrishna Gudipati void bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpgs); 80a36c61f9SKrishna Gudipati void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe); 81a36c61f9SKrishna Gudipati 82a36c61f9SKrishna Gudipati 83acdc79a6SJing Huang /* 84a36c61f9SKrishna Gudipati * FCXP related defines 85a36c61f9SKrishna Gudipati */ 86a36c61f9SKrishna Gudipati #define BFA_FCXP_MIN (1) 874507025dSKrishna Gudipati #define BFA_FCXP_MAX (256) 88a36c61f9SKrishna Gudipati #define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256) 89a36c61f9SKrishna Gudipati #define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256) 90a36c61f9SKrishna Gudipati 914507025dSKrishna Gudipati /* Max FCXP dma segs required */ 924507025dSKrishna Gudipati #define BFA_FCXP_DMA_SEGS \ 934507025dSKrishna Gudipati BFI_MEM_DMA_NSEGS(BFA_FCXP_MAX, \ 944507025dSKrishna Gudipati (u32)BFA_FCXP_MAX_IBUF_SZ + BFA_FCXP_MAX_LBUF_SZ) 954507025dSKrishna Gudipati 96a36c61f9SKrishna Gudipati struct bfa_fcxp_mod_s { 97a36c61f9SKrishna Gudipati struct bfa_s *bfa; /* backpointer to BFA */ 98a36c61f9SKrishna Gudipati struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */ 99a36c61f9SKrishna Gudipati u16 num_fcxps; /* max num FCXP requests */ 100c3f1b123SKrishna Gudipati struct list_head fcxp_req_free_q; /* free FCXPs used for sending req */ 101c3f1b123SKrishna Gudipati struct list_head fcxp_rsp_free_q; /* free FCXPs used for sending req */ 102a36c61f9SKrishna Gudipati struct list_head fcxp_active_q; /* active FCXPs */ 103c3f1b123SKrishna Gudipati struct list_head req_wait_q; /* wait queue for free req_fcxp */ 104c3f1b123SKrishna Gudipati struct list_head rsp_wait_q; /* wait queue for free rsp_fcxp */ 105c3f1b123SKrishna Gudipati struct list_head fcxp_req_unused_q; /* unused req_fcxps */ 106c3f1b123SKrishna Gudipati struct list_head fcxp_rsp_unused_q; /* unused rsp_fcxps */ 107a36c61f9SKrishna Gudipati u32 req_pld_sz; 108a36c61f9SKrishna Gudipati u32 rsp_pld_sz; 1094507025dSKrishna Gudipati struct bfa_mem_dma_s dma_seg[BFA_FCXP_DMA_SEGS]; 1104507025dSKrishna Gudipati struct bfa_mem_kva_s kva_seg; 111a36c61f9SKrishna Gudipati }; 112a36c61f9SKrishna Gudipati 113a36c61f9SKrishna Gudipati #define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod) 114a36c61f9SKrishna Gudipati #define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag]) 1154507025dSKrishna Gudipati #define BFA_MEM_FCXP_KVA(__bfa) (&(BFA_FCXP_MOD(__bfa)->kva_seg)) 116a36c61f9SKrishna Gudipati 117a36c61f9SKrishna Gudipati typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp, 118a36c61f9SKrishna Gudipati void *cb_arg, bfa_status_t req_status, 119a36c61f9SKrishna Gudipati u32 rsp_len, u32 resid_len, 120a36c61f9SKrishna Gudipati struct fchs_s *rsp_fchs); 121a36c61f9SKrishna Gudipati 122a36c61f9SKrishna Gudipati typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid); 123a36c61f9SKrishna Gudipati typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid); 124a36c61f9SKrishna Gudipati typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp, 125a36c61f9SKrishna Gudipati void *cbarg, enum bfa_status req_status, 126a36c61f9SKrishna Gudipati u32 rsp_len, u32 resid_len, 127a36c61f9SKrishna Gudipati struct fchs_s *rsp_fchs); 128a36c61f9SKrishna Gudipati typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp); 129a36c61f9SKrishna Gudipati 130a36c61f9SKrishna Gudipati 131a36c61f9SKrishna Gudipati 132acdc79a6SJing Huang /* 133a36c61f9SKrishna Gudipati * Information needed for a FCXP request 134a36c61f9SKrishna Gudipati */ 135a36c61f9SKrishna Gudipati struct bfa_fcxp_req_info_s { 136a36c61f9SKrishna Gudipati struct bfa_rport_s *bfa_rport; 137acdc79a6SJing Huang /* Pointer to the bfa rport that was 138a36c61f9SKrishna Gudipati * returned from bfa_rport_create(). 139a36c61f9SKrishna Gudipati * This could be left NULL for WKA or 140a36c61f9SKrishna Gudipati * for FCXP interactions before the 141a36c61f9SKrishna Gudipati * rport nexus is established 142a36c61f9SKrishna Gudipati */ 143a36c61f9SKrishna Gudipati struct fchs_s fchs; /* request FC header structure */ 14425985edcSLucas De Marchi u8 cts; /* continuous sequence */ 145a36c61f9SKrishna Gudipati u8 class; /* FC class for the request/response */ 146a36c61f9SKrishna Gudipati u16 max_frmsz; /* max send frame size */ 147a36c61f9SKrishna Gudipati u16 vf_id; /* vsan tag if applicable */ 148a36c61f9SKrishna Gudipati u8 lp_tag; /* lport tag */ 149a36c61f9SKrishna Gudipati u32 req_tot_len; /* request payload total length */ 150a36c61f9SKrishna Gudipati }; 151a36c61f9SKrishna Gudipati 152a36c61f9SKrishna Gudipati struct bfa_fcxp_rsp_info_s { 153a36c61f9SKrishna Gudipati struct fchs_s rsp_fchs; 154acdc79a6SJing Huang /* Response frame's FC header will 155a36c61f9SKrishna Gudipati * be sent back in this field */ 156a36c61f9SKrishna Gudipati u8 rsp_timeout; 157acdc79a6SJing Huang /* timeout in seconds, 0-no response */ 158a36c61f9SKrishna Gudipati u8 rsvd2[3]; 159a36c61f9SKrishna Gudipati u32 rsp_maxlen; /* max response length expected */ 160a36c61f9SKrishna Gudipati }; 161a36c61f9SKrishna Gudipati 162a36c61f9SKrishna Gudipati struct bfa_fcxp_s { 163a36c61f9SKrishna Gudipati struct list_head qe; /* fcxp queue element */ 164a36c61f9SKrishna Gudipati bfa_sm_t sm; /* state machine */ 165a36c61f9SKrishna Gudipati void *caller; /* driver or fcs */ 166a36c61f9SKrishna Gudipati struct bfa_fcxp_mod_s *fcxp_mod; 167a36c61f9SKrishna Gudipati /* back pointer to fcxp mod */ 168a36c61f9SKrishna Gudipati u16 fcxp_tag; /* internal tag */ 169a36c61f9SKrishna Gudipati struct bfa_fcxp_req_info_s req_info; 170a36c61f9SKrishna Gudipati /* request info */ 171a36c61f9SKrishna Gudipati struct bfa_fcxp_rsp_info_s rsp_info; 172a36c61f9SKrishna Gudipati /* response info */ 173a36c61f9SKrishna Gudipati u8 use_ireqbuf; /* use internal req buf */ 174a36c61f9SKrishna Gudipati u8 use_irspbuf; /* use internal rsp buf */ 175a36c61f9SKrishna Gudipati u32 nreq_sgles; /* num request SGLEs */ 176a36c61f9SKrishna Gudipati u32 nrsp_sgles; /* num response SGLEs */ 177a36c61f9SKrishna Gudipati struct list_head req_sgpg_q; /* SG pages for request buf */ 178a36c61f9SKrishna Gudipati struct list_head req_sgpg_wqe; /* wait queue for req SG page */ 179a36c61f9SKrishna Gudipati struct list_head rsp_sgpg_q; /* SG pages for response buf */ 180a36c61f9SKrishna Gudipati struct list_head rsp_sgpg_wqe; /* wait queue for rsp SG page */ 181a36c61f9SKrishna Gudipati 182a36c61f9SKrishna Gudipati bfa_fcxp_get_sgaddr_t req_sga_cbfn; 183a36c61f9SKrishna Gudipati /* SG elem addr user function */ 184a36c61f9SKrishna Gudipati bfa_fcxp_get_sglen_t req_sglen_cbfn; 185a36c61f9SKrishna Gudipati /* SG elem len user function */ 186a36c61f9SKrishna Gudipati bfa_fcxp_get_sgaddr_t rsp_sga_cbfn; 187a36c61f9SKrishna Gudipati /* SG elem addr user function */ 188a36c61f9SKrishna Gudipati bfa_fcxp_get_sglen_t rsp_sglen_cbfn; 189a36c61f9SKrishna Gudipati /* SG elem len user function */ 190a36c61f9SKrishna Gudipati bfa_cb_fcxp_send_t send_cbfn; /* send completion callback */ 191a36c61f9SKrishna Gudipati void *send_cbarg; /* callback arg */ 192a36c61f9SKrishna Gudipati struct bfa_sge_s req_sge[BFA_FCXP_MAX_SGES]; 193a36c61f9SKrishna Gudipati /* req SG elems */ 194a36c61f9SKrishna Gudipati struct bfa_sge_s rsp_sge[BFA_FCXP_MAX_SGES]; 195a36c61f9SKrishna Gudipati /* rsp SG elems */ 196a36c61f9SKrishna Gudipati u8 rsp_status; /* comp: rsp status */ 197a36c61f9SKrishna Gudipati u32 rsp_len; /* comp: actual response len */ 198a36c61f9SKrishna Gudipati u32 residue_len; /* comp: residual rsp length */ 199a36c61f9SKrishna Gudipati struct fchs_s rsp_fchs; /* comp: response fchs */ 200a36c61f9SKrishna Gudipati struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */ 201a36c61f9SKrishna Gudipati struct bfa_reqq_wait_s reqq_wqe; 202a36c61f9SKrishna Gudipati bfa_boolean_t reqq_waiting; 203c3f1b123SKrishna Gudipati bfa_boolean_t req_rsp; /* Used to track req/rsp fcxp */ 204a36c61f9SKrishna Gudipati }; 205a36c61f9SKrishna Gudipati 206a36c61f9SKrishna Gudipati struct bfa_fcxp_wqe_s { 207a36c61f9SKrishna Gudipati struct list_head qe; 208a36c61f9SKrishna Gudipati bfa_fcxp_alloc_cbfn_t alloc_cbfn; 209a36c61f9SKrishna Gudipati void *alloc_cbarg; 210a36c61f9SKrishna Gudipati void *caller; 211a36c61f9SKrishna Gudipati struct bfa_s *bfa; 212a36c61f9SKrishna Gudipati int nreq_sgles; 213a36c61f9SKrishna Gudipati int nrsp_sgles; 214a36c61f9SKrishna Gudipati bfa_fcxp_get_sgaddr_t req_sga_cbfn; 215a36c61f9SKrishna Gudipati bfa_fcxp_get_sglen_t req_sglen_cbfn; 216a36c61f9SKrishna Gudipati bfa_fcxp_get_sgaddr_t rsp_sga_cbfn; 217a36c61f9SKrishna Gudipati bfa_fcxp_get_sglen_t rsp_sglen_cbfn; 218a36c61f9SKrishna Gudipati }; 219a36c61f9SKrishna Gudipati 220a36c61f9SKrishna Gudipati #define BFA_FCXP_REQ_PLD(_fcxp) (bfa_fcxp_get_reqbuf(_fcxp)) 221a36c61f9SKrishna Gudipati #define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs)) 222a36c61f9SKrishna Gudipati #define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp)) 223a36c61f9SKrishna Gudipati 224a36c61f9SKrishna Gudipati #define BFA_FCXP_REQ_PLD_PA(_fcxp) \ 2254507025dSKrishna Gudipati bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \ 2264507025dSKrishna Gudipati (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz) 227a36c61f9SKrishna Gudipati 2284507025dSKrishna Gudipati /* fcxp_buf = req_buf + rsp_buf :- add req_buf_sz to get to rsp_buf */ 229a36c61f9SKrishna Gudipati #define BFA_FCXP_RSP_PLD_PA(_fcxp) \ 2304507025dSKrishna Gudipati (bfa_mem_get_dmabuf_pa((_fcxp)->fcxp_mod, (_fcxp)->fcxp_tag, \ 2314507025dSKrishna Gudipati (_fcxp)->fcxp_mod->req_pld_sz + (_fcxp)->fcxp_mod->rsp_pld_sz) + \ 2324507025dSKrishna Gudipati (_fcxp)->fcxp_mod->req_pld_sz) 233a36c61f9SKrishna Gudipati 234a36c61f9SKrishna Gudipati void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); 235a36c61f9SKrishna Gudipati 236a36c61f9SKrishna Gudipati 237acdc79a6SJing Huang /* 238a36c61f9SKrishna Gudipati * RPORT related defines 239a36c61f9SKrishna Gudipati */ 240f7f73812SMaggie Zhang enum bfa_rport_event { 241f7f73812SMaggie Zhang BFA_RPORT_SM_CREATE = 1, /* rport create event */ 242f7f73812SMaggie Zhang BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */ 243f7f73812SMaggie Zhang BFA_RPORT_SM_ONLINE = 3, /* rport is online */ 244f7f73812SMaggie Zhang BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */ 245f7f73812SMaggie Zhang BFA_RPORT_SM_FWRSP = 5, /* firmware response */ 246f7f73812SMaggie Zhang BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */ 247f7f73812SMaggie Zhang BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */ 248f7f73812SMaggie Zhang BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */ 249f7f73812SMaggie Zhang BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */ 250f7f73812SMaggie Zhang }; 251f7f73812SMaggie Zhang 252a36c61f9SKrishna Gudipati #define BFA_RPORT_MIN 4 253a36c61f9SKrishna Gudipati 254a36c61f9SKrishna Gudipati struct bfa_rport_mod_s { 255a36c61f9SKrishna Gudipati struct bfa_rport_s *rps_list; /* list of rports */ 256a36c61f9SKrishna Gudipati struct list_head rp_free_q; /* free bfa_rports */ 257a36c61f9SKrishna Gudipati struct list_head rp_active_q; /* free bfa_rports */ 2583fd45980SKrishna Gudipati struct list_head rp_unused_q; /* unused bfa rports */ 259a36c61f9SKrishna Gudipati u16 num_rports; /* number of rports */ 2604507025dSKrishna Gudipati struct bfa_mem_kva_s kva_seg; 261a36c61f9SKrishna Gudipati }; 262a36c61f9SKrishna Gudipati 263a36c61f9SKrishna Gudipati #define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod) 2644507025dSKrishna Gudipati #define BFA_MEM_RPORT_KVA(__bfa) (&(BFA_RPORT_MOD(__bfa)->kva_seg)) 265a36c61f9SKrishna Gudipati 266acdc79a6SJing Huang /* 267a36c61f9SKrishna Gudipati * Convert rport tag to RPORT 268a36c61f9SKrishna Gudipati */ 269a36c61f9SKrishna Gudipati #define BFA_RPORT_FROM_TAG(__bfa, _tag) \ 270a36c61f9SKrishna Gudipati (BFA_RPORT_MOD(__bfa)->rps_list + \ 271a36c61f9SKrishna Gudipati ((_tag) & (BFA_RPORT_MOD(__bfa)->num_rports - 1))) 272a36c61f9SKrishna Gudipati 273a36c61f9SKrishna Gudipati /* 274a36c61f9SKrishna Gudipati * protected functions 275a36c61f9SKrishna Gudipati */ 276a36c61f9SKrishna Gudipati void bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); 2773fd45980SKrishna Gudipati void bfa_rport_res_recfg(struct bfa_s *bfa, u16 num_rport_fw); 278a36c61f9SKrishna Gudipati 279acdc79a6SJing Huang /* 280a36c61f9SKrishna Gudipati * BFA rport information. 281a36c61f9SKrishna Gudipati */ 282a36c61f9SKrishna Gudipati struct bfa_rport_info_s { 283a36c61f9SKrishna Gudipati u16 max_frmsz; /* max rcv pdu size */ 284a36c61f9SKrishna Gudipati u32 pid:24, /* remote port ID */ 285a36c61f9SKrishna Gudipati lp_tag:8; /* tag */ 286a36c61f9SKrishna Gudipati u32 local_pid:24, /* local port ID */ 287a36c61f9SKrishna Gudipati cisc:8; /* CIRO supported */ 288a36c61f9SKrishna Gudipati u8 fc_class; /* supported FC classes. enum fc_cos */ 289a36c61f9SKrishna Gudipati u8 vf_en; /* virtual fabric enable */ 290a36c61f9SKrishna Gudipati u16 vf_id; /* virtual fabric ID */ 291a36c61f9SKrishna Gudipati enum bfa_port_speed speed; /* Rport's current speed */ 292a36c61f9SKrishna Gudipati }; 293a36c61f9SKrishna Gudipati 294acdc79a6SJing Huang /* 295a36c61f9SKrishna Gudipati * BFA rport data structure 296a36c61f9SKrishna Gudipati */ 297a36c61f9SKrishna Gudipati struct bfa_rport_s { 298a36c61f9SKrishna Gudipati struct list_head qe; /* queue element */ 299a36c61f9SKrishna Gudipati bfa_sm_t sm; /* state machine */ 300a36c61f9SKrishna Gudipati struct bfa_s *bfa; /* backpointer to BFA */ 301a36c61f9SKrishna Gudipati void *rport_drv; /* fcs/driver rport object */ 302a36c61f9SKrishna Gudipati u16 fw_handle; /* firmware rport handle */ 303a36c61f9SKrishna Gudipati u16 rport_tag; /* BFA rport tag */ 30483763d59SKrishna Gudipati u8 lun_mask; /* LUN mask flag */ 305a36c61f9SKrishna Gudipati struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */ 306a36c61f9SKrishna Gudipati struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */ 307a36c61f9SKrishna Gudipati struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */ 308a36c61f9SKrishna Gudipati struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */ 309a36c61f9SKrishna Gudipati struct bfa_rport_qos_attr_s qos_attr; 310a36c61f9SKrishna Gudipati union a { 311a36c61f9SKrishna Gudipati bfa_status_t status; /* f/w status */ 312a36c61f9SKrishna Gudipati void *fw_msg; /* QoS scn event */ 313a36c61f9SKrishna Gudipati } event_arg; 314a36c61f9SKrishna Gudipati }; 315a36c61f9SKrishna Gudipati #define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class) 316a36c61f9SKrishna Gudipati 317a36c61f9SKrishna Gudipati 318acdc79a6SJing Huang /* 319a36c61f9SKrishna Gudipati * UF - unsolicited receive related defines 320a36c61f9SKrishna Gudipati */ 321a36c61f9SKrishna Gudipati 322a36c61f9SKrishna Gudipati #define BFA_UF_MIN (4) 3234507025dSKrishna Gudipati #define BFA_UF_MAX (256) 324a36c61f9SKrishna Gudipati 325a36c61f9SKrishna Gudipati struct bfa_uf_s { 326a36c61f9SKrishna Gudipati struct list_head qe; /* queue element */ 327a36c61f9SKrishna Gudipati struct bfa_s *bfa; /* bfa instance */ 328a36c61f9SKrishna Gudipati u16 uf_tag; /* identifying tag fw msgs */ 329a36c61f9SKrishna Gudipati u16 vf_id; 330a36c61f9SKrishna Gudipati u16 src_rport_handle; 331a36c61f9SKrishna Gudipati u16 rsvd; 332a36c61f9SKrishna Gudipati u8 *data_ptr; 333a36c61f9SKrishna Gudipati u16 data_len; /* actual receive length */ 334a36c61f9SKrishna Gudipati u16 pb_len; /* posted buffer length */ 335a36c61f9SKrishna Gudipati void *buf_kva; /* buffer virtual address */ 336a36c61f9SKrishna Gudipati u64 buf_pa; /* buffer physical address */ 337a36c61f9SKrishna Gudipati struct bfa_cb_qe_s hcb_qe; /* comp: BFA comp qelem */ 338a36c61f9SKrishna Gudipati struct bfa_sge_s sges[BFI_SGE_INLINE_MAX]; 339a36c61f9SKrishna Gudipati }; 340a36c61f9SKrishna Gudipati 341acdc79a6SJing Huang /* 342a36c61f9SKrishna Gudipati * Callback prototype for unsolicited frame receive handler. 343a36c61f9SKrishna Gudipati * 344a36c61f9SKrishna Gudipati * @param[in] cbarg callback arg for receive handler 345a36c61f9SKrishna Gudipati * @param[in] uf unsolicited frame descriptor 346a36c61f9SKrishna Gudipati * 347a36c61f9SKrishna Gudipati * @return None 348a36c61f9SKrishna Gudipati */ 349a36c61f9SKrishna Gudipati typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf); 350a36c61f9SKrishna Gudipati 3514507025dSKrishna Gudipati #define BFA_UF_BUFSZ (2 * 1024 + 256) 3524507025dSKrishna Gudipati 3534507025dSKrishna Gudipati struct bfa_uf_buf_s { 3544507025dSKrishna Gudipati u8 d[BFA_UF_BUFSZ]; 3554507025dSKrishna Gudipati }; 3564507025dSKrishna Gudipati 3574507025dSKrishna Gudipati #define BFA_PER_UF_DMA_SZ \ 3584507025dSKrishna Gudipati (u32)BFA_ROUNDUP(sizeof(struct bfa_uf_buf_s), BFA_DMA_ALIGN_SZ) 3594507025dSKrishna Gudipati 3604507025dSKrishna Gudipati /* Max UF dma segs required */ 3614507025dSKrishna Gudipati #define BFA_UF_DMA_SEGS BFI_MEM_DMA_NSEGS(BFA_UF_MAX, BFA_PER_UF_DMA_SZ) 3624507025dSKrishna Gudipati 363a36c61f9SKrishna Gudipati struct bfa_uf_mod_s { 364a36c61f9SKrishna Gudipati struct bfa_s *bfa; /* back pointer to BFA */ 365a36c61f9SKrishna Gudipati struct bfa_uf_s *uf_list; /* array of UFs */ 366a36c61f9SKrishna Gudipati u16 num_ufs; /* num unsolicited rx frames */ 367a36c61f9SKrishna Gudipati struct list_head uf_free_q; /* free UFs */ 368a36c61f9SKrishna Gudipati struct list_head uf_posted_q; /* UFs posted to IOC */ 3693fd45980SKrishna Gudipati struct list_head uf_unused_q; /* unused UF's */ 370a36c61f9SKrishna Gudipati struct bfi_uf_buf_post_s *uf_buf_posts; 371a36c61f9SKrishna Gudipati /* pre-built UF post msgs */ 372a36c61f9SKrishna Gudipati bfa_cb_uf_recv_t ufrecv; /* uf recv handler function */ 373a36c61f9SKrishna Gudipati void *cbarg; /* uf receive handler arg */ 3744507025dSKrishna Gudipati struct bfa_mem_dma_s dma_seg[BFA_UF_DMA_SEGS]; 3754507025dSKrishna Gudipati struct bfa_mem_kva_s kva_seg; 376a36c61f9SKrishna Gudipati }; 377a36c61f9SKrishna Gudipati 378a36c61f9SKrishna Gudipati #define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod) 3794507025dSKrishna Gudipati #define BFA_MEM_UF_KVA(__bfa) (&(BFA_UF_MOD(__bfa)->kva_seg)) 380a36c61f9SKrishna Gudipati 381a36c61f9SKrishna Gudipati #define ufm_pbs_pa(_ufmod, _uftag) \ 3824507025dSKrishna Gudipati bfa_mem_get_dmabuf_pa(_ufmod, _uftag, BFA_PER_UF_DMA_SZ) 383a36c61f9SKrishna Gudipati 384a36c61f9SKrishna Gudipati void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); 3853fd45980SKrishna Gudipati void bfa_uf_res_recfg(struct bfa_s *bfa, u16 num_uf_fw); 386a36c61f9SKrishna Gudipati 387acdc79a6SJing Huang /* 388a36c61f9SKrishna Gudipati * LPS - bfa lport login/logout service interface 389a36c61f9SKrishna Gudipati */ 390a36c61f9SKrishna Gudipati struct bfa_lps_s { 391a36c61f9SKrishna Gudipati struct list_head qe; /* queue element */ 392a36c61f9SKrishna Gudipati struct bfa_s *bfa; /* parent bfa instance */ 393a36c61f9SKrishna Gudipati bfa_sm_t sm; /* finite state machine */ 3943fd45980SKrishna Gudipati u8 bfa_tag; /* lport tag */ 3953fd45980SKrishna Gudipati u8 fw_tag; /* lport fw tag */ 396a36c61f9SKrishna Gudipati u8 reqq; /* lport request queue */ 397a36c61f9SKrishna Gudipati u8 alpa; /* ALPA for loop topologies */ 398a36c61f9SKrishna Gudipati u32 lp_pid; /* lport port ID */ 399a36c61f9SKrishna Gudipati bfa_boolean_t fdisc; /* snd FDISC instead of FLOGI */ 400a36c61f9SKrishna Gudipati bfa_boolean_t auth_en; /* enable authentication */ 401a36c61f9SKrishna Gudipati bfa_boolean_t auth_req; /* authentication required */ 402a36c61f9SKrishna Gudipati bfa_boolean_t npiv_en; /* NPIV is allowed by peer */ 403a36c61f9SKrishna Gudipati bfa_boolean_t fport; /* attached peer is F_PORT */ 404a36c61f9SKrishna Gudipati bfa_boolean_t brcd_switch; /* attached peer is brcd sw */ 405a36c61f9SKrishna Gudipati bfa_status_t status; /* login status */ 406a36c61f9SKrishna Gudipati u16 pdusz; /* max receive PDU size */ 407a36c61f9SKrishna Gudipati u16 pr_bbcred; /* BB_CREDIT from peer */ 408be540a99SKrishna Gudipati u8 pr_bbscn; /* BB_SCN from peer */ 409be540a99SKrishna Gudipati u8 bb_scn; /* local BB_SCN */ 410a36c61f9SKrishna Gudipati u8 lsrjt_rsn; /* LSRJT reason */ 411a36c61f9SKrishna Gudipati u8 lsrjt_expl; /* LSRJT explanation */ 41283763d59SKrishna Gudipati u8 lun_mask; /* LUN mask flag */ 413a36c61f9SKrishna Gudipati wwn_t pwwn; /* port wwn of lport */ 414a36c61f9SKrishna Gudipati wwn_t nwwn; /* node wwn of lport */ 415a36c61f9SKrishna Gudipati wwn_t pr_pwwn; /* port wwn of lport peer */ 416a36c61f9SKrishna Gudipati wwn_t pr_nwwn; /* node wwn of lport peer */ 417a36c61f9SKrishna Gudipati mac_t lp_mac; /* fpma/spma MAC for lport */ 418a36c61f9SKrishna Gudipati mac_t fcf_mac; /* FCF MAC of lport */ 419a36c61f9SKrishna Gudipati struct bfa_reqq_wait_s wqe; /* request wait queue element */ 420a36c61f9SKrishna Gudipati void *uarg; /* user callback arg */ 421a36c61f9SKrishna Gudipati struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */ 422a36c61f9SKrishna Gudipati struct bfi_lps_login_rsp_s *loginrsp; 423a36c61f9SKrishna Gudipati bfa_eproto_status_t ext_status; 424a36c61f9SKrishna Gudipati }; 425a36c61f9SKrishna Gudipati 426a36c61f9SKrishna Gudipati struct bfa_lps_mod_s { 427a36c61f9SKrishna Gudipati struct list_head lps_free_q; 428a36c61f9SKrishna Gudipati struct list_head lps_active_q; 4293fd45980SKrishna Gudipati struct list_head lps_login_q; 430a36c61f9SKrishna Gudipati struct bfa_lps_s *lps_arr; 431a36c61f9SKrishna Gudipati int num_lps; 4324507025dSKrishna Gudipati struct bfa_mem_kva_s kva_seg; 433a36c61f9SKrishna Gudipati }; 434a36c61f9SKrishna Gudipati 435a36c61f9SKrishna Gudipati #define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod) 436a36c61f9SKrishna Gudipati #define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag]) 4374507025dSKrishna Gudipati #define BFA_MEM_LPS_KVA(__bfa) (&(BFA_LPS_MOD(__bfa)->kva_seg)) 438a36c61f9SKrishna Gudipati 439a36c61f9SKrishna Gudipati /* 440a36c61f9SKrishna Gudipati * external functions 441a36c61f9SKrishna Gudipati */ 442a36c61f9SKrishna Gudipati void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); 443a36c61f9SKrishna Gudipati 444a36c61f9SKrishna Gudipati 445acdc79a6SJing Huang /* 446a36c61f9SKrishna Gudipati * FCPORT related defines 447a36c61f9SKrishna Gudipati */ 448a36c61f9SKrishna Gudipati 449a36c61f9SKrishna Gudipati #define BFA_FCPORT(_bfa) (&((_bfa)->modules.port)) 450a36c61f9SKrishna Gudipati 451acdc79a6SJing Huang /* 452a36c61f9SKrishna Gudipati * Link notification data structure 453a36c61f9SKrishna Gudipati */ 454a36c61f9SKrishna Gudipati struct bfa_fcport_ln_s { 455a36c61f9SKrishna Gudipati struct bfa_fcport_s *fcport; 456a36c61f9SKrishna Gudipati bfa_sm_t sm; 457a36c61f9SKrishna Gudipati struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */ 458a36c61f9SKrishna Gudipati enum bfa_port_linkstate ln_event; /* ln event for callback */ 459a36c61f9SKrishna Gudipati }; 460a36c61f9SKrishna Gudipati 461a36c61f9SKrishna Gudipati struct bfa_fcport_trunk_s { 462a36c61f9SKrishna Gudipati struct bfa_trunk_attr_s attr; 463a36c61f9SKrishna Gudipati }; 464a36c61f9SKrishna Gudipati 465acdc79a6SJing Huang /* 466a36c61f9SKrishna Gudipati * BFA FC port data structure 467a36c61f9SKrishna Gudipati */ 468a36c61f9SKrishna Gudipati struct bfa_fcport_s { 469a36c61f9SKrishna Gudipati struct bfa_s *bfa; /* parent BFA instance */ 470a36c61f9SKrishna Gudipati bfa_sm_t sm; /* port state machine */ 471a36c61f9SKrishna Gudipati wwn_t nwwn; /* node wwn of physical port */ 472a36c61f9SKrishna Gudipati wwn_t pwwn; /* port wwn of physical oprt */ 473a36c61f9SKrishna Gudipati enum bfa_port_speed speed_sup; 474a36c61f9SKrishna Gudipati /* supported speeds */ 475a36c61f9SKrishna Gudipati enum bfa_port_speed speed; /* current speed */ 476a36c61f9SKrishna Gudipati enum bfa_port_topology topology; /* current topology */ 477a36c61f9SKrishna Gudipati u8 rsvd[3]; 478bc0e2c2aSKrishna Gudipati u8 myalpa; /* my ALPA in LOOP topology */ 479bc0e2c2aSKrishna Gudipati u8 alpabm_valid; /* alpa bitmap valid or not */ 480bc0e2c2aSKrishna Gudipati struct fc_alpabm_s alpabm; /* alpa bitmap */ 481a36c61f9SKrishna Gudipati struct bfa_port_cfg_s cfg; /* current port configuration */ 482f3a060caSKrishna Gudipati bfa_boolean_t use_flash_cfg; /* get port cfg from flash */ 483a36c61f9SKrishna Gudipati struct bfa_qos_attr_s qos_attr; /* QoS Attributes */ 484a36c61f9SKrishna Gudipati struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */ 485a36c61f9SKrishna Gudipati struct bfa_reqq_wait_s reqq_wait; 486a36c61f9SKrishna Gudipati /* to wait for room in reqq */ 487a36c61f9SKrishna Gudipati struct bfa_reqq_wait_s svcreq_wait; 488a36c61f9SKrishna Gudipati /* to wait for room in reqq */ 489a36c61f9SKrishna Gudipati struct bfa_reqq_wait_s stats_reqq_wait; 490a36c61f9SKrishna Gudipati /* to wait for room in reqq (stats) */ 491a36c61f9SKrishna Gudipati void *event_cbarg; 492a36c61f9SKrishna Gudipati void (*event_cbfn) (void *cbarg, 493a36c61f9SKrishna Gudipati enum bfa_port_linkstate event); 494a36c61f9SKrishna Gudipati union { 495a36c61f9SKrishna Gudipati union bfi_fcport_i2h_msg_u i2hmsg; 496a36c61f9SKrishna Gudipati } event_arg; 497a36c61f9SKrishna Gudipati void *bfad; /* BFA driver handle */ 498a36c61f9SKrishna Gudipati struct bfa_fcport_ln_s ln; /* Link Notification */ 499a36c61f9SKrishna Gudipati struct bfa_cb_qe_s hcb_qe; /* BFA callback queue elem */ 500a36c61f9SKrishna Gudipati struct bfa_timer_s timer; /* timer */ 501a36c61f9SKrishna Gudipati u32 msgtag; /* fimrware msg tag for reply */ 502a36c61f9SKrishna Gudipati u8 *stats_kva; 503a36c61f9SKrishna Gudipati u64 stats_pa; 504a36c61f9SKrishna Gudipati union bfa_fcport_stats_u *stats; 505a36c61f9SKrishna Gudipati bfa_status_t stats_status; /* stats/statsclr status */ 50637ea0558SKrishna Gudipati struct list_head stats_pending_q; 50737ea0558SKrishna Gudipati struct list_head statsclr_pending_q; 508a36c61f9SKrishna Gudipati bfa_boolean_t stats_qfull; 509a36c61f9SKrishna Gudipati u32 stats_reset_time; /* stats reset time stamp */ 510a36c61f9SKrishna Gudipati bfa_boolean_t diag_busy; /* diag busy status */ 511a36c61f9SKrishna Gudipati bfa_boolean_t beacon; /* port beacon status */ 512a36c61f9SKrishna Gudipati bfa_boolean_t link_e2e_beacon; /* link beacon status */ 513be540a99SKrishna Gudipati bfa_boolean_t bbsc_op_state; /* Cred recov Oper State */ 514a36c61f9SKrishna Gudipati struct bfa_fcport_trunk_s trunk; 515a36c61f9SKrishna Gudipati u16 fcoe_vlan; 5164507025dSKrishna Gudipati struct bfa_mem_dma_s fcport_dma; 5176894f013SKrishna Gudipati bfa_boolean_t stats_dma_ready; 518a36c61f9SKrishna Gudipati }; 519a36c61f9SKrishna Gudipati 520a36c61f9SKrishna Gudipati #define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport) 5214507025dSKrishna Gudipati #define BFA_MEM_FCPORT_DMA(__bfa) (&(BFA_FCPORT_MOD(__bfa)->fcport_dma)) 522a36c61f9SKrishna Gudipati 523a36c61f9SKrishna Gudipati /* 524a36c61f9SKrishna Gudipati * protected functions 525a36c61f9SKrishna Gudipati */ 526a36c61f9SKrishna Gudipati void bfa_fcport_init(struct bfa_s *bfa); 527a36c61f9SKrishna Gudipati void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg); 528a36c61f9SKrishna Gudipati 529a36c61f9SKrishna Gudipati /* 530a36c61f9SKrishna Gudipati * bfa fcport API functions 531a36c61f9SKrishna Gudipati */ 532a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_enable(struct bfa_s *bfa); 533a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_disable(struct bfa_s *bfa); 534a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa, 535a36c61f9SKrishna Gudipati enum bfa_port_speed speed); 536a36c61f9SKrishna Gudipati enum bfa_port_speed bfa_fcport_get_speed(struct bfa_s *bfa); 537a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa, 538a36c61f9SKrishna Gudipati enum bfa_port_topology topo); 539a36c61f9SKrishna Gudipati enum bfa_port_topology bfa_fcport_get_topology(struct bfa_s *bfa); 540bc0e2c2aSKrishna Gudipati enum bfa_port_topology bfa_fcport_get_cfg_topology(struct bfa_s *bfa); 541a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa); 542a36c61f9SKrishna Gudipati bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa); 543a36c61f9SKrishna Gudipati u8 bfa_fcport_get_myalpa(struct bfa_s *bfa); 544a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa); 545a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize); 546a36c61f9SKrishna Gudipati u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa); 547a36c61f9SKrishna Gudipati u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa); 548a36c61f9SKrishna Gudipati void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr); 549a36c61f9SKrishna Gudipati wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node); 550a36c61f9SKrishna Gudipati void bfa_fcport_event_register(struct bfa_s *bfa, 551a36c61f9SKrishna Gudipati void (*event_cbfn) (void *cbarg, 552a36c61f9SKrishna Gudipati enum bfa_port_linkstate event), void *event_cbarg); 553a36c61f9SKrishna Gudipati bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa); 554e353546eSKrishna Gudipati bfa_boolean_t bfa_fcport_is_dport(struct bfa_s *bfa); 5556894f013SKrishna Gudipati bfa_status_t bfa_fcport_set_qos_bw(struct bfa_s *bfa, 5566894f013SKrishna Gudipati struct bfa_qos_bw_s *qos_bw); 557a36c61f9SKrishna Gudipati enum bfa_port_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa); 558a36c61f9SKrishna Gudipati 559be540a99SKrishna Gudipati void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit, u8 bb_scn); 560a36c61f9SKrishna Gudipati bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa); 5613d7fc66dSKrishna Gudipati void bfa_fcport_beacon(void *dev, bfa_boolean_t beacon, 5623d7fc66dSKrishna Gudipati bfa_boolean_t link_e2e_beacon); 563a36c61f9SKrishna Gudipati bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa); 564a36c61f9SKrishna Gudipati bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa, 56537ea0558SKrishna Gudipati struct bfa_cb_pending_q_s *cb); 56637ea0558SKrishna Gudipati bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, 56737ea0558SKrishna Gudipati struct bfa_cb_pending_q_s *cb); 568a36c61f9SKrishna Gudipati bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa); 569be540a99SKrishna Gudipati bfa_boolean_t bfa_fcport_is_trunk_enabled(struct bfa_s *bfa); 570e353546eSKrishna Gudipati void bfa_fcport_dportenable(struct bfa_s *bfa); 571e353546eSKrishna Gudipati void bfa_fcport_dportdisable(struct bfa_s *bfa); 57243ffdf4dSKrishna Gudipati bfa_status_t bfa_fcport_is_pbcdisabled(struct bfa_s *bfa); 573a714134aSKrishna Gudipati void bfa_fcport_cfg_faa(struct bfa_s *bfa, u8 state); 574a36c61f9SKrishna Gudipati 575a36c61f9SKrishna Gudipati /* 576a36c61f9SKrishna Gudipati * bfa rport API functions 577a36c61f9SKrishna Gudipati */ 578a36c61f9SKrishna Gudipati struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv); 579a36c61f9SKrishna Gudipati void bfa_rport_online(struct bfa_rport_s *rport, 580a36c61f9SKrishna Gudipati struct bfa_rport_info_s *rport_info); 581a36c61f9SKrishna Gudipati void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed); 582a36c61f9SKrishna Gudipati void bfa_cb_rport_online(void *rport); 583a36c61f9SKrishna Gudipati void bfa_cb_rport_offline(void *rport); 584a36c61f9SKrishna Gudipati void bfa_cb_rport_qos_scn_flowid(void *rport, 585a36c61f9SKrishna Gudipati struct bfa_rport_qos_attr_s old_qos_attr, 586a36c61f9SKrishna Gudipati struct bfa_rport_qos_attr_s new_qos_attr); 587bc0e2c2aSKrishna Gudipati void bfa_cb_rport_scn_online(struct bfa_s *bfa); 588bc0e2c2aSKrishna Gudipati void bfa_cb_rport_scn_offline(struct bfa_s *bfa); 589bc0e2c2aSKrishna Gudipati void bfa_cb_rport_scn_no_dev(void *rp); 590a36c61f9SKrishna Gudipati void bfa_cb_rport_qos_scn_prio(void *rport, 591a36c61f9SKrishna Gudipati struct bfa_rport_qos_attr_s old_qos_attr, 592a36c61f9SKrishna Gudipati struct bfa_rport_qos_attr_s new_qos_attr); 593a36c61f9SKrishna Gudipati 594a36c61f9SKrishna Gudipati /* 59583763d59SKrishna Gudipati * Rport LUN masking related 59683763d59SKrishna Gudipati */ 59783763d59SKrishna Gudipati #define BFA_RPORT_TAG_INVALID 0xffff 59883763d59SKrishna Gudipati #define BFA_LP_TAG_INVALID 0xff 59983763d59SKrishna Gudipati void bfa_rport_set_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp); 60083763d59SKrishna Gudipati void bfa_rport_unset_lunmask(struct bfa_s *bfa, struct bfa_rport_s *rp); 60183763d59SKrishna Gudipati 60283763d59SKrishna Gudipati /* 603a36c61f9SKrishna Gudipati * bfa fcxp API functions 604a36c61f9SKrishna Gudipati */ 605c3f1b123SKrishna Gudipati struct bfa_fcxp_s *bfa_fcxp_req_rsp_alloc(void *bfad_fcxp, struct bfa_s *bfa, 606a36c61f9SKrishna Gudipati int nreq_sgles, int nrsp_sgles, 607a36c61f9SKrishna Gudipati bfa_fcxp_get_sgaddr_t get_req_sga, 608a36c61f9SKrishna Gudipati bfa_fcxp_get_sglen_t get_req_sglen, 609a36c61f9SKrishna Gudipati bfa_fcxp_get_sgaddr_t get_rsp_sga, 610c3f1b123SKrishna Gudipati bfa_fcxp_get_sglen_t get_rsp_sglen, 611c3f1b123SKrishna Gudipati bfa_boolean_t req); 612c3f1b123SKrishna Gudipati void bfa_fcxp_req_rsp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe, 613a36c61f9SKrishna Gudipati bfa_fcxp_alloc_cbfn_t alloc_cbfn, 614a36c61f9SKrishna Gudipati void *cbarg, void *bfad_fcxp, 615a36c61f9SKrishna Gudipati int nreq_sgles, int nrsp_sgles, 616a36c61f9SKrishna Gudipati bfa_fcxp_get_sgaddr_t get_req_sga, 617a36c61f9SKrishna Gudipati bfa_fcxp_get_sglen_t get_req_sglen, 618a36c61f9SKrishna Gudipati bfa_fcxp_get_sgaddr_t get_rsp_sga, 619c3f1b123SKrishna Gudipati bfa_fcxp_get_sglen_t get_rsp_sglen, 620c3f1b123SKrishna Gudipati bfa_boolean_t req); 621a36c61f9SKrishna Gudipati void bfa_fcxp_walloc_cancel(struct bfa_s *bfa, 622a36c61f9SKrishna Gudipati struct bfa_fcxp_wqe_s *wqe); 623a36c61f9SKrishna Gudipati void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp); 624a36c61f9SKrishna Gudipati 625a36c61f9SKrishna Gudipati void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp); 626a36c61f9SKrishna Gudipati void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp); 627a36c61f9SKrishna Gudipati 628a36c61f9SKrishna Gudipati void bfa_fcxp_free(struct bfa_fcxp_s *fcxp); 629a36c61f9SKrishna Gudipati 630a36c61f9SKrishna Gudipati void bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport, 631a36c61f9SKrishna Gudipati u16 vf_id, u8 lp_tag, 632a36c61f9SKrishna Gudipati bfa_boolean_t cts, enum fc_cos cos, 633a36c61f9SKrishna Gudipati u32 reqlen, struct fchs_s *fchs, 634a36c61f9SKrishna Gudipati bfa_cb_fcxp_send_t cbfn, 635a36c61f9SKrishna Gudipati void *cbarg, 636a36c61f9SKrishna Gudipati u32 rsp_maxlen, u8 rsp_timeout); 637a36c61f9SKrishna Gudipati bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp); 638a36c61f9SKrishna Gudipati u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp); 639a36c61f9SKrishna Gudipati u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa); 6403fd45980SKrishna Gudipati void bfa_fcxp_res_recfg(struct bfa_s *bfa, u16 num_fcxp_fw); 641a36c61f9SKrishna Gudipati 642a36c61f9SKrishna Gudipati static inline void * 643a36c61f9SKrishna Gudipati bfa_uf_get_frmbuf(struct bfa_uf_s *uf) 644a36c61f9SKrishna Gudipati { 645a36c61f9SKrishna Gudipati return uf->data_ptr; 646a36c61f9SKrishna Gudipati } 647a36c61f9SKrishna Gudipati 648a36c61f9SKrishna Gudipati static inline u16 649a36c61f9SKrishna Gudipati bfa_uf_get_frmlen(struct bfa_uf_s *uf) 650a36c61f9SKrishna Gudipati { 651a36c61f9SKrishna Gudipati return uf->data_len; 652a36c61f9SKrishna Gudipati } 653a36c61f9SKrishna Gudipati 654a36c61f9SKrishna Gudipati /* 655a36c61f9SKrishna Gudipati * bfa uf API functions 656a36c61f9SKrishna Gudipati */ 657a36c61f9SKrishna Gudipati void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv, 658a36c61f9SKrishna Gudipati void *cbarg); 659a36c61f9SKrishna Gudipati void bfa_uf_free(struct bfa_uf_s *uf); 660a36c61f9SKrishna Gudipati 661acdc79a6SJing Huang /* 662a36c61f9SKrishna Gudipati * bfa lport service api 663a36c61f9SKrishna Gudipati */ 664a36c61f9SKrishna Gudipati 665a36c61f9SKrishna Gudipati u32 bfa_lps_get_max_vport(struct bfa_s *bfa); 666a36c61f9SKrishna Gudipati struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa); 667a36c61f9SKrishna Gudipati void bfa_lps_delete(struct bfa_lps_s *lps); 668a36c61f9SKrishna Gudipati void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa, 669a36c61f9SKrishna Gudipati u16 pdusz, wwn_t pwwn, wwn_t nwwn, 670be540a99SKrishna Gudipati bfa_boolean_t auth_en, u8 bb_scn); 671a36c61f9SKrishna Gudipati void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz, 672a36c61f9SKrishna Gudipati wwn_t pwwn, wwn_t nwwn); 673a36c61f9SKrishna Gudipati void bfa_lps_fdisclogo(struct bfa_lps_s *lps); 674b704495cSKrishna Gudipati void bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, u32 n2n_pid); 6753fd45980SKrishna Gudipati u8 bfa_lps_get_fwtag(struct bfa_s *bfa, u8 lp_tag); 676a36c61f9SKrishna Gudipati u32 bfa_lps_get_base_pid(struct bfa_s *bfa); 677a36c61f9SKrishna Gudipati u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid); 678a36c61f9SKrishna Gudipati void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status); 679881c1b3cSKrishna Gudipati void bfa_cb_lps_flogo_comp(void *bfad, void *uarg); 680a36c61f9SKrishna Gudipati void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status); 681a36c61f9SKrishna Gudipati void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg); 682a36c61f9SKrishna Gudipati void bfa_cb_lps_cvl_event(void *bfad, void *uarg); 683a36c61f9SKrishna Gudipati 684a714134aSKrishna Gudipati /* FAA specific APIs */ 685a714134aSKrishna Gudipati bfa_status_t bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr, 686a714134aSKrishna Gudipati bfa_cb_iocfc_t cbfn, void *cbarg); 687a714134aSKrishna Gudipati 6883d7fc66dSKrishna Gudipati /* 6893d7fc66dSKrishna Gudipati * FC DIAG data structure 6903d7fc66dSKrishna Gudipati */ 6913d7fc66dSKrishna Gudipati struct bfa_fcdiag_qtest_s { 6923d7fc66dSKrishna Gudipati struct bfa_diag_qtest_result_s *result; 6933d7fc66dSKrishna Gudipati bfa_cb_diag_t cbfn; 6943d7fc66dSKrishna Gudipati void *cbarg; 6953d7fc66dSKrishna Gudipati struct bfa_timer_s timer; 6963d7fc66dSKrishna Gudipati u32 status; 6973d7fc66dSKrishna Gudipati u32 count; 6983d7fc66dSKrishna Gudipati u8 lock; 6993d7fc66dSKrishna Gudipati u8 queue; 7003d7fc66dSKrishna Gudipati u8 all; 7013d7fc66dSKrishna Gudipati u8 timer_active; 7023d7fc66dSKrishna Gudipati }; 7033d7fc66dSKrishna Gudipati 7043d7fc66dSKrishna Gudipati struct bfa_fcdiag_lb_s { 7053d7fc66dSKrishna Gudipati bfa_cb_diag_t cbfn; 7063d7fc66dSKrishna Gudipati void *cbarg; 7073d7fc66dSKrishna Gudipati void *result; 7083d7fc66dSKrishna Gudipati bfa_boolean_t lock; 7093d7fc66dSKrishna Gudipati u32 status; 7103d7fc66dSKrishna Gudipati }; 7113d7fc66dSKrishna Gudipati 712e353546eSKrishna Gudipati struct bfa_dport_s { 713e353546eSKrishna Gudipati struct bfa_s *bfa; /* Back pointer to BFA */ 714e353546eSKrishna Gudipati bfa_sm_t sm; /* finite state machine */ 715e353546eSKrishna Gudipati u32 msgtag; /* firmware msg tag for reply */ 716e353546eSKrishna Gudipati struct bfa_reqq_wait_s reqq_wait; 717e353546eSKrishna Gudipati bfa_cb_diag_t cbfn; 718e353546eSKrishna Gudipati void *cbarg; 719e353546eSKrishna Gudipati }; 720e353546eSKrishna Gudipati 7213d7fc66dSKrishna Gudipati struct bfa_fcdiag_s { 7223d7fc66dSKrishna Gudipati struct bfa_s *bfa; /* Back pointer to BFA */ 7233d7fc66dSKrishna Gudipati struct bfa_trc_mod_s *trcmod; 7243d7fc66dSKrishna Gudipati struct bfa_fcdiag_lb_s lb; 7253d7fc66dSKrishna Gudipati struct bfa_fcdiag_qtest_s qtest; 726e353546eSKrishna Gudipati struct bfa_dport_s dport; 7273d7fc66dSKrishna Gudipati }; 7283d7fc66dSKrishna Gudipati 7293d7fc66dSKrishna Gudipati #define BFA_FCDIAG_MOD(__bfa) (&(__bfa)->modules.fcdiag) 7303d7fc66dSKrishna Gudipati 7313d7fc66dSKrishna Gudipati void bfa_fcdiag_intr(struct bfa_s *bfa, struct bfi_msg_s *msg); 7323d7fc66dSKrishna Gudipati 7333d7fc66dSKrishna Gudipati bfa_status_t bfa_fcdiag_loopback(struct bfa_s *bfa, 7343d7fc66dSKrishna Gudipati enum bfa_port_opmode opmode, 7353d7fc66dSKrishna Gudipati enum bfa_port_speed speed, u32 lpcnt, u32 pat, 7363d7fc66dSKrishna Gudipati struct bfa_diag_loopback_result_s *result, 7373d7fc66dSKrishna Gudipati bfa_cb_diag_t cbfn, void *cbarg); 7383d7fc66dSKrishna Gudipati bfa_status_t bfa_fcdiag_queuetest(struct bfa_s *bfa, u32 ignore, 7393d7fc66dSKrishna Gudipati u32 queue, struct bfa_diag_qtest_result_s *result, 7403d7fc66dSKrishna Gudipati bfa_cb_diag_t cbfn, void *cbarg); 7413d7fc66dSKrishna Gudipati bfa_status_t bfa_fcdiag_lb_is_running(struct bfa_s *bfa); 742e353546eSKrishna Gudipati bfa_status_t bfa_dport_enable(struct bfa_s *bfa, bfa_cb_diag_t cbfn, 743e353546eSKrishna Gudipati void *cbarg); 744e353546eSKrishna Gudipati bfa_status_t bfa_dport_disable(struct bfa_s *bfa, bfa_cb_diag_t cbfn, 745e353546eSKrishna Gudipati void *cbarg); 746e353546eSKrishna Gudipati bfa_status_t bfa_dport_get_state(struct bfa_s *bfa, 747e353546eSKrishna Gudipati enum bfa_dport_state *state); 7483d7fc66dSKrishna Gudipati 749a36c61f9SKrishna Gudipati #endif /* __BFA_SVC_H__ */ 750