/* * This file is part of the Chelsio FCoE driver for Linux. * * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <linux/pci.h> #include <linux/pci_regs.h> #include <linux/firmware.h> #include <linux/stddef.h> #include <linux/delay.h> #include <linux/string.h> #include <linux/compiler.h> #include <linux/jiffies.h> #include <linux/kernel.h> #include <linux/log2.h> #include "csio_hw.h" #include "csio_lnode.h" #include "csio_rnode.h" int csio_dbg_level = …; unsigned int csio_port_mask = …; /* Default FW event queue entries. */ static uint32_t csio_evtq_sz = …; /* Default MSI param level */ int csio_msi = …; /* FCoE function instances */ static int dev_num; /* FCoE Adapter types & its description */ static const struct csio_adap_desc csio_t5_fcoe_adapters[] = …; static void csio_mgmtm_cleanup(struct csio_mgmtm *); static void csio_hw_mbm_cleanup(struct csio_hw *); /* State machine forward declarations */ static void csio_hws_uninit(struct csio_hw *, enum csio_hw_ev); static void csio_hws_configuring(struct csio_hw *, enum csio_hw_ev); static void csio_hws_initializing(struct csio_hw *, enum csio_hw_ev); static void csio_hws_ready(struct csio_hw *, enum csio_hw_ev); static void csio_hws_quiescing(struct csio_hw *, enum csio_hw_ev); static void csio_hws_quiesced(struct csio_hw *, enum csio_hw_ev); static void csio_hws_resetting(struct csio_hw *, enum csio_hw_ev); static void csio_hws_removing(struct csio_hw *, enum csio_hw_ev); static void csio_hws_pcierr(struct csio_hw *, enum csio_hw_ev); static void csio_hw_initialize(struct csio_hw *hw); static void csio_evtq_stop(struct csio_hw *hw); static void csio_evtq_start(struct csio_hw *hw); int csio_is_hw_ready(struct csio_hw *hw) { … } int csio_is_hw_removing(struct csio_hw *hw) { … } /* * csio_hw_wait_op_done_val - wait until an operation is completed * @hw: the HW module * @reg: the register to check for completion * @mask: a single-bit field within @reg that indicates completion * @polarity: the value of the field when the operation is completed * @attempts: number of check iterations * @delay: delay in usecs between iterations * @valp: where to store the value of the register at completion time * * Wait until an operation is completed by checking a bit in a register * up to @attempts times. If @valp is not NULL the value of the register * at the time it indicated completion is stored there. Returns 0 if the * operation completes and -EAGAIN otherwise. */ int csio_hw_wait_op_done_val(struct csio_hw *hw, int reg, uint32_t mask, int polarity, int attempts, int delay, uint32_t *valp) { … } /* * csio_hw_tp_wr_bits_indirect - set/clear bits in an indirect TP register * @hw: the adapter * @addr: the indirect TP register address * @mask: specifies the field within the register to modify * @val: new value for the field * * Sets a field of an indirect TP register to the given value. */ void csio_hw_tp_wr_bits_indirect(struct csio_hw *hw, unsigned int addr, unsigned int mask, unsigned int val) { … } void csio_set_reg_field(struct csio_hw *hw, uint32_t reg, uint32_t mask, uint32_t value) { … } static int csio_memory_write(struct csio_hw *hw, int mtype, u32 addr, u32 len, u32 *buf) { … } /* * EEPROM reads take a few tens of us while writes can take a bit over 5 ms. */ #define EEPROM_MAX_RD_POLL … #define EEPROM_MAX_WR_POLL … #define EEPROM_STAT_ADDR … #define VPD_BASE … #define VPD_BASE_OLD … #define VPD_LEN … #define VPD_INFO_FLD_HDR_SIZE … /* * csio_hw_seeprom_read - read a serial EEPROM location * @hw: hw to read * @addr: EEPROM virtual address * @data: where to store the read data * * Read a 32-bit word from a location in serial EEPROM using the card's PCI * VPD capability. Note that this function must be called with a virtual * address. */ static int csio_hw_seeprom_read(struct csio_hw *hw, uint32_t addr, uint32_t *data) { … } /* * Partial EEPROM Vital Product Data structure. Includes only the ID and * VPD-R sections. */ struct t4_vpd_hdr { … }; /* * csio_hw_get_vpd_keyword_val - Locates an information field keyword in * the VPD * @v: Pointer to buffered vpd data structure * @kw: The keyword to search for * * Returns the value of the information field keyword or * -EINVAL otherwise. */ static int csio_hw_get_vpd_keyword_val(const struct t4_vpd_hdr *v, const char *kw) { … } static int csio_pci_capability(struct pci_dev *pdev, int cap, int *pos) { … } /* * csio_hw_get_vpd_params - read VPD parameters from VPD EEPROM * @hw: HW module * @p: where to store the parameters * * Reads card parameters stored in VPD EEPROM. */ static int csio_hw_get_vpd_params(struct csio_hw *hw, struct csio_vpd *p) { … } /* * csio_hw_sf1_read - read data from the serial flash * @hw: the HW module * @byte_cnt: number of bytes to read * @cont: whether another operation will be chained * @lock: whether to lock SF for PL access only * @valp: where to store the read data * * Reads up to 4 bytes of data from the serial flash. The location of * the read needs to be specified prior to calling this by issuing the * appropriate commands to the serial flash. */ static int csio_hw_sf1_read(struct csio_hw *hw, uint32_t byte_cnt, int32_t cont, int32_t lock, uint32_t *valp) { … } /* * csio_hw_sf1_write - write data to the serial flash * @hw: the HW module * @byte_cnt: number of bytes to write * @cont: whether another operation will be chained * @lock: whether to lock SF for PL access only * @val: value to write * * Writes up to 4 bytes of data to the serial flash. The location of * the write needs to be specified prior to calling this by issuing the * appropriate commands to the serial flash. */ static int csio_hw_sf1_write(struct csio_hw *hw, uint32_t byte_cnt, uint32_t cont, int32_t lock, uint32_t val) { … } /* * csio_hw_flash_wait_op - wait for a flash operation to complete * @hw: the HW module * @attempts: max number of polls of the status register * @delay: delay between polls in ms * * Wait for a flash operation to complete by polling the status register. */ static int csio_hw_flash_wait_op(struct csio_hw *hw, int32_t attempts, int32_t delay) { … } /* * csio_hw_read_flash - read words from serial flash * @hw: the HW module * @addr: the start address for the read * @nwords: how many 32-bit words to read * @data: where to store the read data * @byte_oriented: whether to store data as bytes or as words * * Read the specified number of 32-bit words from the serial flash. * If @byte_oriented is set the read data is stored as a byte array * (i.e., big-endian), otherwise as 32-bit words in the platform's * natural endianess. */ static int csio_hw_read_flash(struct csio_hw *hw, uint32_t addr, uint32_t nwords, uint32_t *data, int32_t byte_oriented) { … } /* * csio_hw_write_flash - write up to a page of data to the serial flash * @hw: the hw * @addr: the start address to write * @n: length of data to write in bytes * @data: the data to write * * Writes up to a page of data (256 bytes) to the serial flash starting * at the given address. All the data must be written to the same page. */ static int csio_hw_write_flash(struct csio_hw *hw, uint32_t addr, uint32_t n, const uint8_t *data) { … } /* * csio_hw_flash_erase_sectors - erase a range of flash sectors * @hw: the HW module * @start: the first sector to erase * @end: the last sector to erase * * Erases the sectors in the given inclusive range. */ static int csio_hw_flash_erase_sectors(struct csio_hw *hw, int32_t start, int32_t end) { … } static void csio_hw_print_fw_version(struct csio_hw *hw, char *str) { … } /* * csio_hw_get_fw_version - read the firmware version * @hw: HW module * @vers: where to place the version * * Reads the FW version from flash. */ static int csio_hw_get_fw_version(struct csio_hw *hw, uint32_t *vers) { … } /* * csio_hw_get_tp_version - read the TP microcode version * @hw: HW module * @vers: where to place the version * * Reads the TP microcode version from flash. */ static int csio_hw_get_tp_version(struct csio_hw *hw, u32 *vers) { … } /* * csio_hw_fw_dload - download firmware. * @hw: HW module * @fw_data: firmware image to write. * @size: image size * * Write the supplied firmware image to the card's serial flash. */ static int csio_hw_fw_dload(struct csio_hw *hw, uint8_t *fw_data, uint32_t size) { … } static int csio_hw_get_flash_params(struct csio_hw *hw) { … } /*****************************************************************************/ /* HW State machine assists */ /*****************************************************************************/ static int csio_hw_dev_ready(struct csio_hw *hw) { … } /* * csio_do_hello - Perform the HELLO FW Mailbox command and process response. * @hw: HW module * @state: Device state * * FW_HELLO_CMD has to be polled for completion. */ static int csio_do_hello(struct csio_hw *hw, enum csio_dev_state *state) { … } /* * csio_do_bye - Perform the BYE FW Mailbox command and process response. * @hw: HW module * */ static int csio_do_bye(struct csio_hw *hw) { … } /* * csio_do_reset- Perform the device reset. * @hw: HW module * @fw_rst: FW reset * * If fw_rst is set, issues FW reset mbox cmd otherwise * does PIO reset. * Performs reset of the function. */ static int csio_do_reset(struct csio_hw *hw, bool fw_rst) { … } static int csio_hw_validate_caps(struct csio_hw *hw, struct csio_mb *mbp) { … } /* * csio_hw_fw_halt - issue a reset/halt to FW and put uP into RESET * @hw: the HW module * @mbox: mailbox to use for the FW RESET command (if desired) * @force: force uP into RESET even if FW RESET command fails * * Issues a RESET command to firmware (if desired) with a HALT indication * and then puts the microprocessor into RESET state. The RESET command * will only be issued if a legitimate mailbox is provided (mbox <= * PCIE_FW_MASTER_MASK). * * This is generally used in order for the host to safely manipulate the * adapter without fear of conflicting with whatever the firmware might * be doing. The only way out of this state is to RESTART the firmware * ... */ static int csio_hw_fw_halt(struct csio_hw *hw, uint32_t mbox, int32_t force) { … } /* * csio_hw_fw_restart - restart the firmware by taking the uP out of RESET * @hw: the HW module * @reset: if we want to do a RESET to restart things * * Restart firmware previously halted by csio_hw_fw_halt(). On successful * return the previous PF Master remains as the new PF Master and there * is no need to issue a new HELLO command, etc. * * We do this in two ways: * * 1. If we're dealing with newer firmware we'll simply want to take * the chip's microprocessor out of RESET. This will cause the * firmware to start up from its start vector. And then we'll loop * until the firmware indicates it's started again (PCIE_FW.HALT * reset to 0) or we timeout. * * 2. If we're dealing with older firmware then we'll need to RESET * the chip since older firmware won't recognize the PCIE_FW.HALT * flag and automatically RESET itself on startup. */ static int csio_hw_fw_restart(struct csio_hw *hw, uint32_t mbox, int32_t reset) { … } /* * csio_hw_fw_upgrade - perform all of the steps necessary to upgrade FW * @hw: the HW module * @mbox: mailbox to use for the FW RESET command (if desired) * @fw_data: the firmware image to write * @size: image size * @force: force upgrade even if firmware doesn't cooperate * * Perform all of the steps necessary for upgrading an adapter's * firmware image. Normally this requires the cooperation of the * existing firmware in order to halt all existing activities * but if an invalid mailbox token is passed in we skip that step * (though we'll still put the adapter microprocessor into RESET in * that case). * * On successful return the new firmware will have been loaded and * the adapter will have been fully RESET losing all previous setup * state. On unsuccessful return the adapter may be completely hosed ... * positive errno indicates that the adapter is ~probably~ intact, a * negative errno indicates that things are looking bad ... */ static int csio_hw_fw_upgrade(struct csio_hw *hw, uint32_t mbox, const u8 *fw_data, uint32_t size, int32_t force) { … } /* * csio_get_device_params - Get device parameters. * @hw: HW module * */ static int csio_get_device_params(struct csio_hw *hw) { … } /* * csio_config_device_caps - Get and set device capabilities. * @hw: HW module * */ static int csio_config_device_caps(struct csio_hw *hw) { … } static inline enum cc_fec fwcap_to_cc_fec(fw_port_cap32_t fw_fec) { … } static inline fw_port_cap32_t cc_to_fwcap_pause(enum cc_pause cc_pause) { … } static inline fw_port_cap32_t cc_to_fwcap_fec(enum cc_fec cc_fec) { … } /** * fwcap_to_fwspeed - return highest speed in Port Capabilities * @acaps: advertised Port Capabilities * * Get the highest speed for the port from the advertised Port * Capabilities. */ fw_port_cap32_t fwcap_to_fwspeed(fw_port_cap32_t acaps) { … } /** * fwcaps16_to_caps32 - convert 16-bit Port Capabilities to 32-bits * @caps16: a 16-bit Port Capabilities value * * Returns the equivalent 32-bit Port Capabilities value. */ fw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t caps16) { … } /** * fwcaps32_to_caps16 - convert 32-bit Port Capabilities to 16-bits * @caps32: a 32-bit Port Capabilities value * * Returns the equivalent 16-bit Port Capabilities value. Note that * not all 32-bit Port Capabilities can be represented in the 16-bit * Port Capabilities and some fields/values may not make it. */ fw_port_cap16_t fwcaps32_to_caps16(fw_port_cap32_t caps32) { … } /** * lstatus_to_fwcap - translate old lstatus to 32-bit Port Capabilities * @lstatus: old FW_PORT_ACTION_GET_PORT_INFO lstatus value * * Translates old FW_PORT_ACTION_GET_PORT_INFO lstatus field into new * 32-bit Port Capabilities value. */ fw_port_cap32_t lstatus_to_fwcap(u32 lstatus) { … } /** * csio_init_link_config - initialize a link's SW state * @lc: pointer to structure holding the link state * @pcaps: link Port Capabilities * @acaps: link current Advertised Port Capabilities * * Initializes the SW state maintained for each link, including the link's * capabilities and default speed/flow-control/autonegotiation settings. */ static void csio_init_link_config(struct link_config *lc, fw_port_cap32_t pcaps, fw_port_cap32_t acaps) { … } static void csio_link_l1cfg(struct link_config *lc, uint16_t fw_caps, uint32_t *rcaps) { … } /* * csio_enable_ports - Bring up all available ports. * @hw: HW module. * */ static int csio_enable_ports(struct csio_hw *hw) { … } /* * csio_get_fcoe_resinfo - Read fcoe fw resource info. * @hw: HW module * Issued with lock held. */ static int csio_get_fcoe_resinfo(struct csio_hw *hw) { … } static int csio_hw_check_fwconfig(struct csio_hw *hw, u32 *param) { … } static int csio_hw_flash_config(struct csio_hw *hw, u32 *fw_cfg_param, char *path) { … } /* * HW initialization: contact FW, obtain config, perform basic init. * * If the firmware we're dealing with has Configuration File support, then * we use that to perform all configuration -- either using the configuration * file stored in flash on the adapter or using a filesystem-local file * if available. * * If we don't have configuration file support in the firmware, then we'll * have to set things up the old fashioned way with hard-coded register * writes and firmware commands ... */ /* * Attempt to initialize the HW via a Firmware Configuration File. */ static int csio_hw_use_fwconfig(struct csio_hw *hw, int reset, u32 *fw_cfg_param) { … } /* Is the given firmware API compatible with the one the driver was compiled * with? */ static int fw_compatible(const struct fw_hdr *hdr1, const struct fw_hdr *hdr2) { … } /* The firmware in the filesystem is usable, but should it be installed? * This routine explains itself in detail if it indicates the filesystem * firmware should be installed. */ static int csio_should_install_fs_fw(struct csio_hw *hw, int card_fw_usable, int k, int c) { … } static struct fw_info fw_info_array[] = …; static struct fw_info *find_fw_info(int chip) { … } static int csio_hw_prep_fw(struct csio_hw *hw, struct fw_info *fw_info, const u8 *fw_data, unsigned int fw_size, struct fw_hdr *card_fw, enum csio_dev_state state, int *reset) { … } /* * Returns -EINVAL if attempts to flash the firmware failed, * -ENOMEM if memory allocation failed else returns 0, * if flashing was not attempted because the card had the * latest firmware ECANCELED is returned */ static int csio_hw_flash_fw(struct csio_hw *hw, int *reset) { … } static int csio_hw_check_fwver(struct csio_hw *hw) { … } /* * csio_hw_configure - Configure HW * @hw - HW module * */ static void csio_hw_configure(struct csio_hw *hw) { … } /* * csio_hw_initialize - Initialize HW * @hw - HW module * */ static void csio_hw_initialize(struct csio_hw *hw) { … } #define PF_INTR_MASK … /* * csio_hw_intr_enable - Enable HW interrupts * @hw: Pointer to HW module. * * Enable interrupts in HW registers. */ static void csio_hw_intr_enable(struct csio_hw *hw) { … } /* * csio_hw_intr_disable - Disable HW interrupts * @hw: Pointer to HW module. * * Turn off Mailbox and PCI_PF_CFG interrupts. */ void csio_hw_intr_disable(struct csio_hw *hw) { … } void csio_hw_fatal_err(struct csio_hw *hw) { … } /*****************************************************************************/ /* START: HW SM */ /*****************************************************************************/ /* * csio_hws_uninit - Uninit state * @hw - HW module * @evt - Event * */ static void csio_hws_uninit(struct csio_hw *hw, enum csio_hw_ev evt) { … } /* * csio_hws_configuring - Configuring state * @hw - HW module * @evt - Event * */ static void csio_hws_configuring(struct csio_hw *hw, enum csio_hw_ev evt) { … } /* * csio_hws_initializing - Initializing state * @hw - HW module * @evt - Event * */ static void csio_hws_initializing(struct csio_hw *hw, enum csio_hw_ev evt) { … } /* * csio_hws_ready - Ready state * @hw - HW module * @evt - Event * */ static void csio_hws_ready(struct csio_hw *hw, enum csio_hw_ev evt) { … } /* * csio_hws_quiescing - Quiescing state * @hw - HW module * @evt - Event * */ static void csio_hws_quiescing(struct csio_hw *hw, enum csio_hw_ev evt) { … } /* * csio_hws_quiesced - Quiesced state * @hw - HW module * @evt - Event * */ static void csio_hws_quiesced(struct csio_hw *hw, enum csio_hw_ev evt) { … } /* * csio_hws_resetting - HW Resetting state * @hw - HW module * @evt - Event * */ static void csio_hws_resetting(struct csio_hw *hw, enum csio_hw_ev evt) { … } /* * csio_hws_removing - PCI Hotplug removing state * @hw - HW module * @evt - Event * */ static void csio_hws_removing(struct csio_hw *hw, enum csio_hw_ev evt) { … } /* * csio_hws_pcierr - PCI Error state * @hw - HW module * @evt - Event * */ static void csio_hws_pcierr(struct csio_hw *hw, enum csio_hw_ev evt) { … } /*****************************************************************************/ /* END: HW SM */ /*****************************************************************************/ /* * csio_handle_intr_status - table driven interrupt handler * @hw: HW instance * @reg: the interrupt status register to process * @acts: table of interrupt actions * * A table driven interrupt handler that applies a set of masks to an * interrupt status word and performs the corresponding actions if the * interrupts described by the mask have occurred. The actions include * optionally emitting a warning or alert message. The table is terminated * by an entry specifying mask 0. Returns the number of fatal interrupt * conditions. */ int csio_handle_intr_status(struct csio_hw *hw, unsigned int reg, const struct intr_info *acts) { … } /* * TP interrupt handler. */ static void csio_tp_intr_handler(struct csio_hw *hw) { … } /* * SGE interrupt handler. */ static void csio_sge_intr_handler(struct csio_hw *hw) { … } #define CIM_OBQ_INTR … #define CIM_IBQ_INTR … /* * CIM interrupt handler. */ static void csio_cim_intr_handler(struct csio_hw *hw) { … } /* * ULP RX interrupt handler. */ static void csio_ulprx_intr_handler(struct csio_hw *hw) { … } /* * ULP TX interrupt handler. */ static void csio_ulptx_intr_handler(struct csio_hw *hw) { … } /* * PM TX interrupt handler. */ static void csio_pmtx_intr_handler(struct csio_hw *hw) { … } /* * PM RX interrupt handler. */ static void csio_pmrx_intr_handler(struct csio_hw *hw) { … } /* * CPL switch interrupt handler. */ static void csio_cplsw_intr_handler(struct csio_hw *hw) { … } /* * LE interrupt handler. */ static void csio_le_intr_handler(struct csio_hw *hw) { … } /* * MPS interrupt handler. */ static void csio_mps_intr_handler(struct csio_hw *hw) { … } #define MEM_INT_MASK … /* * EDC/MC interrupt handler. */ static void csio_mem_intr_handler(struct csio_hw *hw, int idx) { … } /* * MA interrupt handler. */ static void csio_ma_intr_handler(struct csio_hw *hw) { … } /* * SMB interrupt handler. */ static void csio_smb_intr_handler(struct csio_hw *hw) { … } /* * NC-SI interrupt handler. */ static void csio_ncsi_intr_handler(struct csio_hw *hw) { … } /* * XGMAC interrupt handler. */ static void csio_xgmac_intr_handler(struct csio_hw *hw, int port) { … } /* * PL interrupt handler. */ static void csio_pl_intr_handler(struct csio_hw *hw) { … } /* * csio_hw_slow_intr_handler - control path interrupt handler * @hw: HW module * * Interrupt handler for non-data global interrupt events, e.g., errors. * The designation 'slow' is because it involves register reads, while * data interrupts typically don't involve any MMIOs. */ int csio_hw_slow_intr_handler(struct csio_hw *hw) { … } /***************************************************************************** * HW <--> mailbox interfacing routines. ****************************************************************************/ /* * csio_mberr_worker - Worker thread (dpc) for mailbox/error completions * * @data: Private data pointer. * * Called from worker thread context. */ static void csio_mberr_worker(void *data) { … } /* * csio_hw_mb_timer - Top-level Mailbox timeout handler. * * @data: private data pointer * **/ static void csio_hw_mb_timer(struct timer_list *t) { … } /* * csio_hw_mbm_cleanup - Cleanup Mailbox module. * @hw: HW module * * Called with lock held, should exit with lock held. * Cancels outstanding mailboxes (waiting, in-flight) and gathers them * into a local queue. Drops lock and calls the completions. Holds * lock and returns. */ static void csio_hw_mbm_cleanup(struct csio_hw *hw) { … } /***************************************************************************** * Event handling ****************************************************************************/ int csio_enqueue_evt(struct csio_hw *hw, enum csio_evt type, void *evt_msg, uint16_t len) { … } static int csio_enqueue_evt_lock(struct csio_hw *hw, enum csio_evt type, void *evt_msg, uint16_t len, bool msg_sg) { … } static void csio_free_evt(struct csio_hw *hw, struct csio_evt_msg *evt_entry) { … } void csio_evtq_flush(struct csio_hw *hw) { … } static void csio_evtq_stop(struct csio_hw *hw) { … } static void csio_evtq_start(struct csio_hw *hw) { … } static void csio_evtq_cleanup(struct csio_hw *hw) { … } static void csio_process_fwevtq_entry(struct csio_hw *hw, void *wr, uint32_t len, struct csio_fl_dma_buf *flb, void *priv) { … } void csio_evtq_worker(struct work_struct *work) { … } int csio_fwevtq_handler(struct csio_hw *hw) { … } /**************************************************************************** * Entry points ****************************************************************************/ /* Management module */ /* * csio_mgmt_req_lookup - Lookup the given IO req exist in Active Q. * mgmt - mgmt module * @io_req - io request * * Return - 0:if given IO Req exists in active Q. * -EINVAL :if lookup fails. */ int csio_mgmt_req_lookup(struct csio_mgmtm *mgmtm, struct csio_ioreq *io_req) { … } #define ECM_MIN_TMO … /* * csio_mgmts_tmo_handler - MGMT IO Timeout handler. * @data - Event data. * * Return - none. */ static void csio_mgmt_tmo_handler(struct timer_list *t) { … } static void csio_mgmtm_cleanup(struct csio_mgmtm *mgmtm) { … } /* * csio_mgmt_init - Mgmt module init entry point * @mgmtsm - mgmt module * @hw - HW module * * Initialize mgmt timer, resource wait queue, active queue, * completion q. Allocate Egress and Ingress * WR queues and save off the queue index returned by the WR * module for future use. Allocate and save off mgmt reqs in the * mgmt_req_freelist for future use. Make sure their SM is initialized * to uninit state. * Returns: 0 - on success * -ENOMEM - on error. */ static int csio_mgmtm_init(struct csio_mgmtm *mgmtm, struct csio_hw *hw) { … } /* * csio_mgmtm_exit - MGMT module exit entry point * @mgmtsm - mgmt module * * This function called during MGMT module uninit. * Stop timers, free ioreqs allocated. * Returns: None * */ static void csio_mgmtm_exit(struct csio_mgmtm *mgmtm) { … } /** * csio_hw_start - Kicks off the HW State machine * @hw: Pointer to HW module. * * It is assumed that the initialization is a synchronous operation. * So when we return after posting the event, the HW SM should be in * the ready state, if there were no errors during init. */ int csio_hw_start(struct csio_hw *hw) { … } int csio_hw_stop(struct csio_hw *hw) { … } /* Max reset retries */ #define CSIO_MAX_RESET_RETRIES … /** * csio_hw_reset - Reset the hardware * @hw: HW module. * * Caller should hold lock across this function. */ int csio_hw_reset(struct csio_hw *hw) { … } /* * csio_hw_get_device_id - Caches the Adapter's vendor & device id. * @hw: HW module. */ static void csio_hw_get_device_id(struct csio_hw *hw) { … } /* csio_hw_get_device_id */ /* * csio_hw_set_description - Set the model, description of the hw. * @hw: HW module. * @ven_id: PCI Vendor ID * @dev_id: PCI Device ID */ static void csio_hw_set_description(struct csio_hw *hw, uint16_t ven_id, uint16_t dev_id) { … } /* csio_hw_set_description */ /** * csio_hw_init - Initialize HW module. * @hw: Pointer to HW module. * * Initialize the members of the HW module. */ int csio_hw_init(struct csio_hw *hw) { … } /** * csio_hw_exit - Un-initialize HW module. * @hw: Pointer to HW module. * */ void csio_hw_exit(struct csio_hw *hw) { … }