/* * PMC-Sierra PM8001/8081/8088/8089 SAS/SATA based host adapters driver * * Copyright (c) 2008-2009 USI Co., Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, * without modification. * 2. Redistributions in binary form must reproduce at minimum a disclaimer * substantially similar to the "NO WARRANTY" disclaimer below * ("Disclaimer") and any redistribution must be conditioned upon * including a substantially similar Disclaimer requirement for further * binary redistribution. * 3. Neither the names of the above-listed copyright holders nor the names * of any contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * NO WARRANTY * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * */ #include <linux/slab.h> #include "pm8001_sas.h" #include "pm80xx_tracepoints.h" /** * pm8001_find_tag - from sas task to find out tag that belongs to this task * @task: the task sent to the LLDD * @tag: the found tag associated with the task */ static int pm8001_find_tag(struct sas_task *task, u32 *tag) { … } /** * pm8001_tag_free - free the no more needed tag * @pm8001_ha: our hba struct * @tag: the found tag associated with the task */ void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag) { … } /** * pm8001_tag_alloc - allocate a empty tag for task used. * @pm8001_ha: our hba struct * @tag_out: the found empty tag . */ int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) { … } /** * pm8001_mem_alloc - allocate memory for pm8001. * @pdev: pci device. * @virt_addr: the allocated virtual address * @pphys_addr: DMA address for this device * @pphys_addr_hi: the physical address high byte address. * @pphys_addr_lo: the physical address low byte address. * @mem_size: memory size. * @align: requested byte alignment */ int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr, dma_addr_t *pphys_addr, u32 *pphys_addr_hi, u32 *pphys_addr_lo, u32 mem_size, u32 align) { … } /** * pm8001_find_ha_by_dev - from domain device which come from sas layer to * find out our hba struct. * @dev: the domain device which from sas layer. */ static struct pm8001_hba_info *pm8001_find_ha_by_dev(struct domain_device *dev) { … } /** * pm8001_phy_control - this function should be registered to * sas_domain_function_template to provide libsas used, note: this is just * control the HBA phy rather than other expander phy if you want control * other phy, you should use SMP command. * @sas_phy: which phy in HBA phys. * @func: the operation. * @funcdata: always NULL. */ int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, void *funcdata) { … } /** * pm8001_scan_start - we should enable all HBA phys by sending the phy_start * command to HBA. * @shost: the scsi host data. */ void pm8001_scan_start(struct Scsi_Host *shost) { … } int pm8001_scan_finished(struct Scsi_Host *shost, unsigned long time) { … } /** * pm8001_task_prep_smp - the dispatcher function, prepare data for smp task * @pm8001_ha: our hba card information * @ccb: the ccb which attached to smp task */ static int pm8001_task_prep_smp(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb) { … } u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag) { … } /** * pm8001_task_prep_ata - the dispatcher function, prepare data for sata task * @pm8001_ha: our hba card information * @ccb: the ccb which attached to sata task */ static int pm8001_task_prep_ata(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb) { … } /** * pm8001_task_prep_internal_abort - the dispatcher function, prepare data * for internal abort task * @pm8001_ha: our hba card information * @ccb: the ccb which attached to sata task */ static int pm8001_task_prep_internal_abort(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb) { … } /** * pm8001_task_prep_ssp_tm - the dispatcher function, prepare task management data * @pm8001_ha: our hba card information * @ccb: the ccb which attached to TM * @tmf: the task management IU */ static int pm8001_task_prep_ssp_tm(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb, struct sas_tmf_task *tmf) { … } /** * pm8001_task_prep_ssp - the dispatcher function, prepare ssp data for ssp task * @pm8001_ha: our hba card information * @ccb: the ccb which attached to ssp task */ static int pm8001_task_prep_ssp(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb) { … } /* Find the local port id that's attached to this device */ static int sas_find_local_port_id(struct domain_device *dev) { … } #define DEV_IS_GONE(pm8001_dev) … static int pm8001_deliver_command(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb) { … } /** * pm8001_queue_command - register for upper layer used, all IO commands sent * to HBA are from this interface. * @task: the task to be execute. * @gfp_flags: gfp_flags */ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags) { … } /** * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb. * @pm8001_ha: our hba card information * @ccb: the ccb which attached to ssp task to free */ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, struct pm8001_ccb_info *ccb) { … } /** * pm8001_alloc_dev - find a empty pm8001_device * @pm8001_ha: our hba card information */ static struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha) { … } /** * pm8001_find_dev - find a matching pm8001_device * @pm8001_ha: our hba card information * @device_id: device ID to match against */ struct pm8001_device *pm8001_find_dev(struct pm8001_hba_info *pm8001_ha, u32 device_id) { … } void pm8001_free_dev(struct pm8001_device *pm8001_dev) { … } /** * pm8001_dev_found_notify - libsas notify a device is found. * @dev: the device structure which sas layer used. * * when libsas find a sas domain device, it should tell the LLDD that * device is found, and then LLDD register this device to HBA firmware * by the command "OPC_INB_REG_DEV", after that the HBA will assign a * device ID(according to device's sas address) and returned it to LLDD. From * now on, we communicate with HBA FW with the device ID which HBA assigned * rather than sas address. it is the necessary step for our HBA but it is * the optional for other HBA driver. */ static int pm8001_dev_found_notify(struct domain_device *dev) { … } int pm8001_dev_found(struct domain_device *dev) { … } #define PM8001_TASK_TIMEOUT … /** * pm8001_dev_gone_notify - see the comments for "pm8001_dev_found_notify" * @dev: the device structure which sas layer used. */ static void pm8001_dev_gone_notify(struct domain_device *dev) { … } void pm8001_dev_gone(struct domain_device *dev) { … } /* retry commands by ha, by task and/or by device */ void pm8001_open_reject_retry( struct pm8001_hba_info *pm8001_ha, struct sas_task *task_to_close, struct pm8001_device *device_to_close) { … } /** * pm8001_I_T_nexus_reset() - reset the initiator/target connection * @dev: the device structure for the device to reset. * * Standard mandates link reset for ATA (type 0) and hard reset for * SSP (type 1), only for RECOVERY */ int pm8001_I_T_nexus_reset(struct domain_device *dev) { … } /* * This function handle the IT_NEXUS_XXX event or completion * status code for SSP/SATA/SMP I/O request. */ int pm8001_I_T_nexus_event_handler(struct domain_device *dev) { … } /* mandatory SAM-3, the task reset the specified LUN*/ int pm8001_lu_reset(struct domain_device *dev, u8 *lun) { … } /* optional SAM-3 */ int pm8001_query_task(struct sas_task *task) { … } /* mandatory SAM-3, still need free task/ccb info, abort the specified task */ int pm8001_abort_task(struct sas_task *task) { … } int pm8001_clear_task_set(struct domain_device *dev, u8 *lun) { … } void pm8001_port_formed(struct asd_sas_phy *sas_phy) { … } void pm8001_setds_completion(struct domain_device *dev) { … } void pm8001_tmf_aborted(struct sas_task *task) { … }