Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Linux network driver for QLogic BR-series Converged Network Adapter.
0004  */
0005 /*
0006  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
0007  * Copyright (c) 2014-2015 QLogic Corporation
0008  * All rights reserved
0009  * www.qlogic.com
0010  */
0011 
0012 #ifndef __BFA_MSGQ_H__
0013 #define __BFA_MSGQ_H__
0014 
0015 #include "bfa_defs.h"
0016 #include "bfi.h"
0017 #include "bfa_ioc.h"
0018 #include "bfa_cs.h"
0019 
0020 #define BFA_MSGQ_FREE_CNT(_q)                       \
0021     (((_q)->consumer_index - (_q)->producer_index - 1) & ((_q)->depth - 1))
0022 
0023 #define BFA_MSGQ_INDX_ADD(_q_indx, _qe_num, _q_depth)           \
0024     ((_q_indx) = (((_q_indx) + (_qe_num)) & ((_q_depth) - 1)))
0025 
0026 #define BFA_MSGQ_CMDQ_NUM_ENTRY     128
0027 #define BFA_MSGQ_CMDQ_SIZE                      \
0028     (BFI_MSGQ_CMD_ENTRY_SIZE * BFA_MSGQ_CMDQ_NUM_ENTRY)
0029 
0030 #define BFA_MSGQ_RSPQ_NUM_ENTRY     128
0031 #define BFA_MSGQ_RSPQ_SIZE                      \
0032     (BFI_MSGQ_RSP_ENTRY_SIZE * BFA_MSGQ_RSPQ_NUM_ENTRY)
0033 
0034 #define bfa_msgq_cmd_set(_cmd, _cbfn, _cbarg, _msg_size, _msg_hdr)  \
0035 do {                                    \
0036     (_cmd)->cbfn = (_cbfn);                     \
0037     (_cmd)->cbarg = (_cbarg);                   \
0038     (_cmd)->msg_size = (_msg_size);                 \
0039     (_cmd)->msg_hdr = (_msg_hdr);                   \
0040 } while (0)
0041 
0042 struct bfa_msgq;
0043 
0044 typedef void (*bfa_msgq_cmdcbfn_t)(void *cbarg, enum bfa_status status);
0045 
0046 struct bfa_msgq_cmd_entry {
0047     struct list_head                qe;
0048     bfa_msgq_cmdcbfn_t      cbfn;
0049     void                *cbarg;
0050     size_t              msg_size;
0051     struct bfi_msgq_mhdr *msg_hdr;
0052 };
0053 
0054 enum bfa_msgq_cmdq_flags {
0055     BFA_MSGQ_CMDQ_F_DB_UPDATE   = 1,
0056 };
0057 
0058 struct bfa_msgq_cmdq {
0059     bfa_fsm_t           fsm;
0060     enum bfa_msgq_cmdq_flags flags;
0061 
0062     u16         producer_index;
0063     u16         consumer_index;
0064     u16         depth; /* FW Q depth is 16 bits */
0065     struct bfa_dma addr;
0066     struct bfa_mbox_cmd dbell_mb;
0067 
0068     u16         token;
0069     int             offset;
0070     int             bytes_to_copy;
0071     struct bfa_mbox_cmd copy_mb;
0072 
0073     struct list_head        pending_q; /* pending command queue */
0074 
0075     struct bfa_msgq *msgq;
0076 };
0077 
0078 enum bfa_msgq_rspq_flags {
0079     BFA_MSGQ_RSPQ_F_DB_UPDATE   = 1,
0080 };
0081 
0082 typedef void (*bfa_msgq_mcfunc_t)(void *cbarg, struct bfi_msgq_mhdr *mhdr);
0083 
0084 struct bfa_msgq_rspq {
0085     bfa_fsm_t           fsm;
0086     enum bfa_msgq_rspq_flags flags;
0087 
0088     u16         producer_index;
0089     u16         consumer_index;
0090     u16         depth; /* FW Q depth is 16 bits */
0091     struct bfa_dma addr;
0092     struct bfa_mbox_cmd dbell_mb;
0093 
0094     int             nmclass;
0095     struct {
0096         bfa_msgq_mcfunc_t   cbfn;
0097         void            *cbarg;
0098     } rsphdlr[BFI_MC_MAX];
0099 
0100     struct bfa_msgq *msgq;
0101 };
0102 
0103 struct bfa_msgq {
0104     struct bfa_msgq_cmdq cmdq;
0105     struct bfa_msgq_rspq rspq;
0106 
0107     struct bfa_wc           init_wc;
0108     struct bfa_mbox_cmd init_mb;
0109 
0110     struct bfa_ioc_notify ioc_notify;
0111     struct bfa_ioc *ioc;
0112 };
0113 
0114 u32 bfa_msgq_meminfo(void);
0115 void bfa_msgq_memclaim(struct bfa_msgq *msgq, u8 *kva, u64 pa);
0116 void bfa_msgq_attach(struct bfa_msgq *msgq, struct bfa_ioc *ioc);
0117 void bfa_msgq_regisr(struct bfa_msgq *msgq, enum bfi_mclass mc,
0118              bfa_msgq_mcfunc_t cbfn, void *cbarg);
0119 void bfa_msgq_cmd_post(struct bfa_msgq *msgq,
0120                struct bfa_msgq_cmd_entry *cmd);
0121 void bfa_msgq_rsp_copy(struct bfa_msgq *msgq, u8 *buf, size_t buf_len);
0122 
0123 #endif