| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef __CSIO_MB_H__ |
| #define __CSIO_MB_H__ |
| |
| #include <linux/timer.h> |
| #include <linux/completion.h> |
| |
| #include "t4fw_api.h" |
| #include "t4fw_api_stor.h" |
| #include "csio_defs.h" |
| |
| #define CSIO_STATS_OFFSET (2) |
| #define CSIO_NUM_STATS_PER_MB (6) |
| |
| struct fw_fcoe_port_cmd_params { |
| <------>uint8_t portid; |
| <------>uint8_t idx; |
| <------>uint8_t nstats; |
| }; |
| |
| #define CSIO_DUMP_MB(__hw, __num, __mb) \ |
| <------>csio_dbg(__hw, "\t%llx %llx %llx %llx %llx %llx %llx %llx\n", \ |
| <------><------>(unsigned long long)csio_rd_reg64(__hw, __mb), \ |
| <------><------>(unsigned long long)csio_rd_reg64(__hw, __mb + 8), \ |
| <------><------>(unsigned long long)csio_rd_reg64(__hw, __mb + 16), \ |
| <------><------>(unsigned long long)csio_rd_reg64(__hw, __mb + 24), \ |
| <------><------>(unsigned long long)csio_rd_reg64(__hw, __mb + 32), \ |
| <------><------>(unsigned long long)csio_rd_reg64(__hw, __mb + 40), \ |
| <------><------>(unsigned long long)csio_rd_reg64(__hw, __mb + 48), \ |
| <------><------>(unsigned long long)csio_rd_reg64(__hw, __mb + 56)) |
| |
| #define CSIO_MB_MAX_REGS 8 |
| #define CSIO_MAX_MB_SIZE 64 |
| #define CSIO_MB_POLL_FREQ 5 |
| #define CSIO_MB_DEFAULT_TMO FW_CMD_MAX_TIMEOUT |
| |
| |
| enum csio_dev_master { CSIO_MASTER_CANT, CSIO_MASTER_MAY, CSIO_MASTER_MUST }; |
| |
| enum csio_mb_owner { CSIO_MBOWNER_NONE, CSIO_MBOWNER_FW, CSIO_MBOWNER_PL }; |
| |
| enum csio_dev_state { |
| <------>CSIO_DEV_STATE_UNINIT, |
| <------>CSIO_DEV_STATE_INIT, |
| <------>CSIO_DEV_STATE_ERR |
| }; |
| |
| #define FW_PARAM_DEV(param) \ |
| <------>(FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) | \ |
| <------> FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_##param)) |
| |
| #define FW_PARAM_PFVF(param) \ |
| <------>(FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) | \ |
| <------> FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_##param)| \ |
| <------> FW_PARAMS_PARAM_Y_V(0) | \ |
| <------> FW_PARAMS_PARAM_Z_V(0)) |
| |
| #define CSIO_INIT_MBP(__mbp, __cp, __tmo, __priv, __fn, __clear) \ |
| do { \ |
| <------>if (__clear) \ |
| <------><------>memset((__cp), 0, \ |
| <------><------><------> CSIO_MB_MAX_REGS * sizeof(__be64)); \ |
| <------>INIT_LIST_HEAD(&(__mbp)->list); \ |
| <------>(__mbp)->tmo = (__tmo); \ |
| <------>(__mbp)->priv = (void *)(__priv); \ |
| <------>(__mbp)->mb_cbfn = (__fn); \ |
| <------>(__mbp)->mb_size = sizeof(*(__cp)); \ |
| } while (0) |
| |
| struct csio_mbm_stats { |
| <------>uint32_t n_req; |
| <------>uint32_t n_rsp; |
| <------>uint32_t n_activeq; |
| <------>uint32_t n_cbfnq; |
| <------>uint32_t n_tmo; |
| <------>uint32_t n_cancel; |
| <------>uint32_t n_err; |
| }; |
| |
| |
| struct csio_mb { |
| <------>struct list_head list; |
| <------><------><------><------><------><------><------> |
| <------>__be64 mb[CSIO_MB_MAX_REGS]; |
| <------>int mb_size; |
| <------><------><------><------><------><------><------> * mailbox. |
| <------><------><------><------><------><------><------> */ |
| <------>uint32_t tmo; |
| <------>struct completion cmplobj; |
| <------><------><------><------><------><------><------> * object |
| <------><------><------><------><------><------><------> */ |
| <------>void (*mb_cbfn) (struct csio_hw *, struct csio_mb *); |
| <------><------><------><------><------><------><------> |
| <------>void *priv; |
| }; |
| |
| struct csio_mbm { |
| <------>uint32_t a_mbox; |
| <------>uint32_t intr_idx; |
| <------>struct timer_list timer; |
| <------>struct csio_hw *hw; |
| <------>struct list_head req_q; |
| <------>struct list_head cbfn_q; |
| <------>struct csio_mb *mcurrent; |
| <------>uint32_t req_q_cnt; |
| <------><------><------><------><------><------><------> * cmds |
| <------><------><------><------><------><------><------> */ |
| <------>struct csio_mbm_stats stats; |
| }; |
| |
| #define csio_set_mb_intr_idx(_m, _i) ((_m)->intr_idx = (_i)) |
| #define csio_get_mb_intr_idx(_m) ((_m)->intr_idx) |
| |
| struct csio_iq_params; |
| struct csio_eq_params; |
| |
| enum fw_retval csio_mb_fw_retval(struct csio_mb *); |
| |
| |
| void csio_mb_hello(struct csio_hw *, struct csio_mb *, uint32_t, |
| <------><------> uint32_t, uint32_t, enum csio_dev_master, |
| <------><------> void (*)(struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_process_hello_rsp(struct csio_hw *, struct csio_mb *, |
| <------><------><------> enum fw_retval *, enum csio_dev_state *, |
| <------><------><------> uint8_t *); |
| |
| void csio_mb_bye(struct csio_hw *, struct csio_mb *, uint32_t, |
| <------><------> void (*)(struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_reset(struct csio_hw *, struct csio_mb *, uint32_t, int, int, |
| <------><------> void (*)(struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_params(struct csio_hw *, struct csio_mb *, uint32_t, unsigned int, |
| <------><------> unsigned int, unsigned int, const u32 *, u32 *, bool, |
| <------><------> void (*)(struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_process_read_params_rsp(struct csio_hw *, struct csio_mb *, |
| <------><------><------><------>enum fw_retval *, unsigned int , u32 *); |
| |
| void csio_mb_ldst(struct csio_hw *hw, struct csio_mb *mbp, uint32_t tmo, |
| <------><------> int reg); |
| |
| void csio_mb_caps_config(struct csio_hw *, struct csio_mb *, uint32_t, |
| <------><------><------> bool, bool, bool, bool, |
| <------><------><------> void (*)(struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_port(struct csio_hw *, struct csio_mb *, uint32_t, |
| <------><------> uint8_t, bool, uint32_t, uint16_t, |
| <------><------> void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_process_read_port_rsp(struct csio_hw *, struct csio_mb *, |
| <------><------><------><------> enum fw_retval *, uint16_t, |
| <------><------><------><------> uint32_t *, uint32_t *); |
| |
| void csio_mb_initialize(struct csio_hw *, struct csio_mb *, uint32_t, |
| <------><------><------>void (*)(struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_iq_alloc_write(struct csio_hw *, struct csio_mb *, void *, |
| <------><------><------>uint32_t, struct csio_iq_params *, |
| <------><------><------>void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_iq_alloc_write_rsp(struct csio_hw *, struct csio_mb *, |
| <------><------><------><------>enum fw_retval *, struct csio_iq_params *); |
| |
| void csio_mb_iq_free(struct csio_hw *, struct csio_mb *, void *, |
| <------><------> uint32_t, struct csio_iq_params *, |
| <------><------> void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_eq_ofld_alloc_write(struct csio_hw *, struct csio_mb *, void *, |
| <------><------><------><------> uint32_t, struct csio_eq_params *, |
| <------><------><------><------> void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_eq_ofld_alloc_write_rsp(struct csio_hw *, struct csio_mb *, |
| <------><------><------><------> enum fw_retval *, struct csio_eq_params *); |
| |
| void csio_mb_eq_ofld_free(struct csio_hw *, struct csio_mb *, void *, |
| <------><------><------> uint32_t , struct csio_eq_params *, |
| <------><------><------> void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_fcoe_read_res_info_init_mb(struct csio_hw *, struct csio_mb *, |
| <------><------><------>uint32_t, |
| <------><------><------>void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_write_fcoe_link_cond_init_mb(struct csio_lnode *, struct csio_mb *, |
| <------><------><------>uint32_t, uint8_t, uint32_t, uint8_t, bool, uint32_t, |
| <------><------><------>void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_fcoe_vnp_alloc_init_mb(struct csio_lnode *, struct csio_mb *, |
| <------><------><------>uint32_t, uint32_t , uint32_t , uint16_t, |
| <------><------><------>uint8_t [8], uint8_t [8], |
| <------><------><------>void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_fcoe_vnp_read_init_mb(struct csio_lnode *, struct csio_mb *, |
| <------><------><------>uint32_t, uint32_t , uint32_t , |
| <------><------><------>void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_fcoe_vnp_free_init_mb(struct csio_lnode *, struct csio_mb *, |
| <------><------><------>uint32_t , uint32_t, uint32_t , |
| <------><------><------>void (*) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_fcoe_read_fcf_init_mb(struct csio_lnode *, struct csio_mb *, |
| <------><------><------>uint32_t, uint32_t, uint32_t, |
| <------><------><------>void (*cbfn) (struct csio_hw *, struct csio_mb *)); |
| |
| void csio_fcoe_read_portparams_init_mb(struct csio_hw *hw, |
| <------><------><------>struct csio_mb *mbp, uint32_t mb_tmo, |
| <------><------><------>struct fw_fcoe_port_cmd_params *portparams, |
| <------><------><------>void (*cbfn)(struct csio_hw *, struct csio_mb *)); |
| |
| void csio_mb_process_portparams_rsp(struct csio_hw *hw, struct csio_mb *mbp, |
| <------><------><------><------>enum fw_retval *retval, |
| <------><------><------><------>struct fw_fcoe_port_cmd_params *portparams, |
| <------><------><------><------>struct fw_fcoe_port_stats *portstats); |
| |
| |
| int csio_mbm_init(struct csio_mbm *, struct csio_hw *, |
| <------><------><------> void (*)(struct timer_list *)); |
| void csio_mbm_exit(struct csio_mbm *); |
| void csio_mb_intr_enable(struct csio_hw *); |
| void csio_mb_intr_disable(struct csio_hw *); |
| |
| int csio_mb_issue(struct csio_hw *, struct csio_mb *); |
| void csio_mb_completions(struct csio_hw *, struct list_head *); |
| int csio_mb_fwevt_handler(struct csio_hw *, __be64 *); |
| int csio_mb_isr_handler(struct csio_hw *); |
| struct csio_mb *csio_mb_tmo_handler(struct csio_hw *); |
| void csio_mb_cancel_all(struct csio_hw *, struct list_head *); |
| |
| #endif |
| |