2 * PMC-Sierra PM8001/8081/8088/8089 SAS/SATA based host adapters driver
4 * Copyright (c) 2008-2009 USI Co., Ltd.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification.
13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 * substantially similar to the "NO WARRANTY" disclaimer below
15 * ("Disclaimer") and any redistribution must be conditioned upon
16 * including a substantially similar Disclaimer requirement for further
17 * binary redistribution.
18 * 3. Neither the names of the above-listed copyright holders nor the names
19 * of any contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * Alternatively, this software may be distributed under the terms of the
23 * GNU General Public License ("GPL") version 2 as published by the Free
24 * Software Foundation.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
36 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGES.
41 #ifndef _PM8001_SAS_H_
42 #define _PM8001_SAS_H_
44 #include <linux/kernel.h>
45 #include <linux/module.h>
46 #include <linux/spinlock.h>
47 #include <linux/delay.h>
48 #include <linux/types.h>
49 #include <linux/ctype.h>
50 #include <linux/dma-mapping.h>
51 #include <linux/pci.h>
52 #include <linux/interrupt.h>
53 #include <linux/workqueue.h>
54 #include <scsi/libsas.h>
55 #include <scsi/scsi_tcq.h>
56 #include <scsi/sas_ata.h>
57 #include <linux/atomic.h>
58 #include <linux/blk-mq.h>
59 #include <linux/blk-mq-pci.h>
60 #include "pm8001_defs.h"
62 #define DRV_NAME "pm80xx"
63 #define DRV_VERSION "0.1.40"
64 #define PM8001_FAIL_LOGGING 0x01 /* Error message logging */
65 #define PM8001_INIT_LOGGING 0x02 /* driver init logging */
66 #define PM8001_DISC_LOGGING 0x04 /* discovery layer logging */
67 #define PM8001_IO_LOGGING 0x08 /* I/O path logging */
68 #define PM8001_EH_LOGGING 0x10 /* libsas EH function logging*/
69 #define PM8001_IOCTL_LOGGING 0x20 /* IOCTL message logging */
70 #define PM8001_MSG_LOGGING 0x40 /* misc message logging */
71 #define PM8001_DEV_LOGGING 0x80 /* development message logging */
72 #define PM8001_DEVIO_LOGGING 0x100 /* development io message logging */
73 #define PM8001_IOERR_LOGGING 0x200 /* development io err message logging */
74 #define PM8001_EVENT_LOGGING 0x400 /* HW event logging */
76 #define pm8001_info(HBA, fmt, ...) \
77 pr_info("%s:: %s %d: " fmt, \
78 (HBA)->name, __func__, __LINE__, ##__VA_ARGS__)
80 #define pm8001_dbg(HBA, level, fmt, ...) \
82 if (unlikely((HBA)->logging_level & PM8001_##level##_LOGGING)) \
83 pm8001_info(HBA, fmt, ##__VA_ARGS__); \
86 extern bool pm8001_use_msix
;
88 #define IS_SPCV_12G(dev) ((dev->device == 0X8074) \
89 || (dev->device == 0X8076) \
90 || (dev->device == 0X8077) \
91 || (dev->device == 0X8070) \
92 || (dev->device == 0X8072))
94 #define PM8001_NAME_LENGTH 32/* generic length of strings */
95 extern struct list_head hba_list
;
96 extern const struct pm8001_dispatch pm8001_8001_dispatch
;
97 extern const struct pm8001_dispatch pm8001_80xx_dispatch
;
99 extern uint pcs_event_log_severity
;
101 struct pm8001_hba_info
;
102 struct pm8001_ccb_info
;
103 struct pm8001_device
;
105 struct pm8001_ioctl_payload
{
117 #define MPI_FATAL_ERROR_TABLE_OFFSET_MASK 0xFFFFFF
118 #define MPI_FATAL_ERROR_TABLE_SIZE(value) ((0xFF000000 & value) >> SHIFT24)
119 #define MPI_FATAL_EDUMP_TABLE_LO_OFFSET 0x00 /* HNFBUFL */
120 #define MPI_FATAL_EDUMP_TABLE_HI_OFFSET 0x04 /* HNFBUFH */
121 #define MPI_FATAL_EDUMP_TABLE_LENGTH 0x08 /* HNFBLEN */
122 #define MPI_FATAL_EDUMP_TABLE_HANDSHAKE 0x0C /* FDDHSHK */
123 #define MPI_FATAL_EDUMP_TABLE_STATUS 0x10 /* FDDTSTAT */
124 #define MPI_FATAL_EDUMP_TABLE_ACCUM_LEN 0x14 /* ACCDDLEN */
125 #define MPI_FATAL_EDUMP_TABLE_TOTAL_LEN 0x18 /* TOTALLEN */
126 #define MPI_FATAL_EDUMP_TABLE_SIGNATURE 0x1C /* SIGNITURE */
127 #define MPI_FATAL_EDUMP_HANDSHAKE_RDY 0x1
128 #define MPI_FATAL_EDUMP_HANDSHAKE_BUSY 0x0
129 #define MPI_FATAL_EDUMP_TABLE_STAT_RSVD 0x0
130 #define MPI_FATAL_EDUMP_TABLE_STAT_DMA_FAILED 0x1
131 #define MPI_FATAL_EDUMP_TABLE_STAT_NF_SUCCESS_MORE_DATA 0x2
132 #define MPI_FATAL_EDUMP_TABLE_STAT_NF_SUCCESS_DONE 0x3
133 #define TYPE_GSM_SPACE 1
136 #define TYPE_NON_FATAL 4
137 #define TYPE_INBOUND 1
138 #define TYPE_OUTBOUND 2
139 struct forensic_data
{
162 /* bit31-26 - mask bar */
163 #define SCRATCH_PAD0_BAR_MASK 0xFC000000
164 /* bit25-0 - offset mask */
165 #define SCRATCH_PAD0_OFFSET_MASK 0x03FFFFFF
166 /* if AAP error state */
167 #define SCRATCH_PAD0_AAPERR_MASK 0xFFFFFFFF
168 /* Inbound doorbell bit7 */
169 #define SPCv_MSGU_CFG_TABLE_NONFATAL_DUMP 0x80
170 /* Inbound doorbell bit7 SPCV */
171 #define SPCV_MSGU_CFG_TABLE_TRANSFER_DEBUG_INFO 0x80
172 #define MAIN_MERRDCTO_MERRDCES 0xA0/* DWORD 0x28) */
174 struct pm8001_dispatch
{
176 int (*chip_init
)(struct pm8001_hba_info
*pm8001_ha
);
177 void (*chip_post_init
)(struct pm8001_hba_info
*pm8001_ha
);
178 int (*chip_soft_rst
)(struct pm8001_hba_info
*pm8001_ha
);
179 void (*chip_rst
)(struct pm8001_hba_info
*pm8001_ha
);
180 int (*chip_ioremap
)(struct pm8001_hba_info
*pm8001_ha
);
181 void (*chip_iounmap
)(struct pm8001_hba_info
*pm8001_ha
);
182 irqreturn_t (*isr
)(struct pm8001_hba_info
*pm8001_ha
, u8 vec
);
183 u32 (*is_our_interrupt
)(struct pm8001_hba_info
*pm8001_ha
);
184 int (*isr_process_oq
)(struct pm8001_hba_info
*pm8001_ha
, u8 vec
);
185 void (*interrupt_enable
)(struct pm8001_hba_info
*pm8001_ha
, u8 vec
);
186 void (*interrupt_disable
)(struct pm8001_hba_info
*pm8001_ha
, u8 vec
);
187 void (*make_prd
)(struct scatterlist
*scatter
, int nr
, void *prd
);
188 int (*smp_req
)(struct pm8001_hba_info
*pm8001_ha
,
189 struct pm8001_ccb_info
*ccb
);
190 int (*ssp_io_req
)(struct pm8001_hba_info
*pm8001_ha
,
191 struct pm8001_ccb_info
*ccb
);
192 int (*sata_req
)(struct pm8001_hba_info
*pm8001_ha
,
193 struct pm8001_ccb_info
*ccb
);
194 int (*phy_start_req
)(struct pm8001_hba_info
*pm8001_ha
, u8 phy_id
);
195 int (*phy_stop_req
)(struct pm8001_hba_info
*pm8001_ha
, u8 phy_id
);
196 int (*reg_dev_req
)(struct pm8001_hba_info
*pm8001_ha
,
197 struct pm8001_device
*pm8001_dev
, u32 flag
);
198 int (*dereg_dev_req
)(struct pm8001_hba_info
*pm8001_ha
, u32 device_id
);
199 int (*phy_ctl_req
)(struct pm8001_hba_info
*pm8001_ha
,
200 u32 phy_id
, u32 phy_op
);
201 int (*task_abort
)(struct pm8001_hba_info
*pm8001_ha
,
202 struct pm8001_ccb_info
*ccb
);
203 int (*ssp_tm_req
)(struct pm8001_hba_info
*pm8001_ha
,
204 struct pm8001_ccb_info
*ccb
, struct sas_tmf_task
*tmf
);
205 int (*get_nvmd_req
)(struct pm8001_hba_info
*pm8001_ha
, void *payload
);
206 int (*set_nvmd_req
)(struct pm8001_hba_info
*pm8001_ha
, void *payload
);
207 int (*fw_flash_update_req
)(struct pm8001_hba_info
*pm8001_ha
,
209 int (*set_dev_state_req
)(struct pm8001_hba_info
*pm8001_ha
,
210 struct pm8001_device
*pm8001_dev
, u32 state
);
211 int (*sas_diag_start_end_req
)(struct pm8001_hba_info
*pm8001_ha
,
213 int (*sas_diag_execute_req
)(struct pm8001_hba_info
*pm8001_ha
,
215 int (*sas_re_init_req
)(struct pm8001_hba_info
*pm8001_ha
);
216 int (*fatal_errors
)(struct pm8001_hba_info
*pm8001_ha
);
217 void (*hw_event_ack_req
)(struct pm8001_hba_info
*pm8001_ha
,
218 u32 Qnum
, u32 SEA
, u32 port_id
, u32 phyId
, u32 param0
,
222 struct pm8001_chip_info
{
225 const struct pm8001_dispatch
*dispatch
;
227 #define PM8001_CHIP_DISP (pm8001_ha->chip->dispatch)
230 struct asd_sas_port sas_port
;
232 u16 wide_port_phymap
;
235 struct list_head list
;
239 struct pm8001_hba_info
*pm8001_ha
;
240 struct pm8001_port
*port
;
241 struct asd_sas_phy sas_phy
;
242 struct sas_identify identify
;
243 struct scsi_device
*sdev
;
246 struct completion
*enable_completion
;
251 enum sas_linkrate minimum_linkrate
;
252 enum sas_linkrate maximum_linkrate
;
253 struct completion
*reset_completion
;
254 bool port_reset_status
;
258 /* port reset status */
259 #define PORT_RESET_SUCCESS 0x00
260 #define PORT_RESET_TMO 0x01
262 struct pm8001_device
{
263 enum sas_device_type dev_type
;
264 struct domain_device
*sas_device
;
267 struct completion
*dcompletion
;
268 struct completion
*setds_completion
;
270 atomic_t running_req
;
273 struct pm8001_prd_imt
{
279 __le64 addr
; /* 64-bit buffer address */
280 struct pm8001_prd_imt im_len
; /* 64-bit length */
281 } __attribute__ ((packed
));
283 * CCB(Command Control Block)
285 struct pm8001_ccb_info
{
286 struct sas_task
*task
;
289 dma_addr_t ccb_dma_handle
;
290 struct pm8001_device
*device
;
291 struct pm8001_prd
*buf_prd
;
292 struct fw_control_ex
*fw_control_context
;
298 dma_addr_t phys_addr
;
308 /* The number of element in the mpiMemory array */
310 /* The array of structures that define memroy regions*/
311 struct mpi_mem region
[USI_MAX_MEMCNT
];
321 struct sas_phy_attribute_table
{
322 u32 phystart1_16
[16];
323 u32 outbound_hw_event_pid1_16
[16];
326 union main_cfg_table
{
335 u32 inbound_queue_offset
;
336 u32 outbound_queue_offset
;
337 u32 inbound_q_nppd_hppd
;
338 u32 outbound_hw_event_pid0_3
;
339 u32 outbound_hw_event_pid4_7
;
340 u32 outbound_ncq_event_pid0_3
;
341 u32 outbound_ncq_event_pid4_7
;
342 u32 outbound_tgt_ITNexus_event_pid0_3
;
343 u32 outbound_tgt_ITNexus_event_pid4_7
;
344 u32 outbound_tgt_ssp_event_pid0_3
;
345 u32 outbound_tgt_ssp_event_pid4_7
;
346 u32 outbound_tgt_smp_event_pid0_3
;
347 u32 outbound_tgt_smp_event_pid4_7
;
348 u32 upper_event_log_addr
;
349 u32 lower_event_log_addr
;
351 u32 event_log_option
;
352 u32 upper_iop_event_log_addr
;
353 u32 lower_iop_event_log_addr
;
354 u32 iop_event_log_size
;
355 u32 iop_event_log_option
;
356 u32 fatal_err_interrupt
;
357 u32 fatal_err_dump_offset0
;
358 u32 fatal_err_dump_length0
;
359 u32 fatal_err_dump_offset1
;
360 u32 fatal_err_dump_length1
;
362 u32 anolog_setup_table_offset
;
374 u32 inbound_queue_offset
;
375 u32 outbound_queue_offset
;
376 u32 inbound_q_nppd_hppd
;
380 u32 upper_event_log_addr
;
381 u32 lower_event_log_addr
;
383 u32 event_log_severity
;
384 u32 upper_pcs_event_log_addr
;
385 u32 lower_pcs_event_log_addr
;
386 u32 pcs_event_log_size
;
387 u32 pcs_event_log_severity
;
388 u32 fatal_err_interrupt
;
389 u32 fatal_err_dump_offset0
;
390 u32 fatal_err_dump_length0
;
391 u32 fatal_err_dump_offset1
;
392 u32 fatal_err_dump_length1
;
393 u32 gpio_led_mapping
;
394 u32 analog_setup_table_offset
;
395 u32 int_vec_table_offset
;
396 u32 phy_attr_table_offset
;
397 u32 port_recovery_timer
;
398 u32 interrupt_reassertion_delay
;
399 u32 fatal_n_non_fatal_dump
; /* 0x28 */
405 union general_status_table
{
407 u32 gst_len_mpistate
;
408 u32 iq_freeze_state0
;
409 u32 iq_freeze_state1
;
416 u32 recover_err_info
[8];
419 u32 gst_len_mpistate
;
420 u32 iq_freeze_state0
;
421 u32 iq_freeze_state1
;
427 u32 recover_err_info
[8];
430 struct inbound_queue_table
{
431 u32 element_pri_size_cnt
;
434 u32 ci_upper_base_addr
;
435 u32 ci_lower_base_addr
;
442 __le32 consumer_index
;
446 struct outbound_queue_table
{
447 u32 element_size_cnt
;
451 u32 pi_upper_base_addr
;
452 u32 pi_lower_base_addr
;
457 u32 interrup_vec_cnt_delay
;
458 u32 dinterrup_to_pci_offset
;
459 __le32 producer_index
;
462 unsigned long lock_flags
;
464 struct pm8001_hba_memspace
{
465 void __iomem
*memvirtaddr
;
470 struct pm8001_hba_info
*drv_inst
;
473 struct pm8001_hba_info
{
474 char name
[PM8001_NAME_LENGTH
];
475 struct list_head list
;
477 spinlock_t lock
;/* host-wide lock */
478 spinlock_t bitmap_lock
;
479 struct pci_dev
*pdev
;/* our device */
481 struct pm8001_hba_memspace io_mem
[6];
482 struct mpi_mem_req memoryMap
;
483 struct encrypt encrypt_info
; /* support encryption */
484 struct forensic_data forensic_info
;
486 u32 forensic_last_offset
;
487 u32 fatal_forensic_shift_offset
;
488 u32 forensic_fatal_step
;
489 u32 forensic_preserved_accumulated_transfer
;
490 u32 evtlog_ib_offset
;
491 u32 evtlog_ob_offset
;
492 void __iomem
*msg_unit_tbl_addr
;/*Message Unit Table Addr*/
493 void __iomem
*main_cfg_tbl_addr
;/*Main Config Table Addr*/
494 void __iomem
*general_stat_tbl_addr
;/*General Status Table Addr*/
495 void __iomem
*inbnd_q_tbl_addr
;/*Inbound Queue Config Table Addr*/
496 void __iomem
*outbnd_q_tbl_addr
;/*Outbound Queue Config Table Addr*/
497 void __iomem
*pspa_q_tbl_addr
;
498 /*MPI SAS PHY attributes Queue Config Table Addr*/
499 void __iomem
*ivt_tbl_addr
; /*MPI IVT Table Addr */
500 void __iomem
*fatal_tbl_addr
; /*MPI IVT Table Addr */
501 union main_cfg_table main_cfg_tbl
;
502 union general_status_table gs_tbl
;
503 struct inbound_queue_table inbnd_q_tbl
[PM8001_MAX_INB_NUM
];
504 struct outbound_queue_table outbnd_q_tbl
[PM8001_MAX_OUTB_NUM
];
505 struct sas_phy_attribute_table phy_attr_table
;
506 /* MPI SAS PHY attributes */
507 u8 sas_addr
[SAS_ADDR_SIZE
];
508 struct sas_ha_struct
*sas
;/* SCSI/SAS glue */
509 struct Scsi_Host
*shost
;
511 const struct pm8001_chip_info
*chip
;
512 struct completion
*nvmd_completion
;
513 unsigned long *rsvd_tags
;
514 struct pm8001_phy phy
[PM8001_MAX_PHYS
];
515 struct pm8001_port port
[PM8001_MAX_PHYS
];
518 u32 iomb_size
; /* SPC and SPCV IOMB size */
519 struct pm8001_device
*devices
;
520 struct pm8001_ccb_info
*ccb_info
;
524 int number_of_intr
;/*will be used in remove()*/
525 char intr_drvname
[PM8001_MAX_MSIX_VEC
]
526 [PM8001_NAME_LENGTH
+1+3+1];
527 struct tasklet_struct tasklet
[PM8001_MAX_MSIX_VEC
];
532 bool controller_fatal_error
;
533 const struct firmware
*fw_image
;
534 struct isr_param irq_vector
[PM8001_MAX_MSIX_VEC
];
536 u32 non_fatal_read_length
;
546 struct work_struct work
;
547 struct pm8001_hba_info
*pm8001_ha
;
552 struct pm8001_fw_image_header
{
561 __be32 startup_entry
;
562 } __attribute__((packed
, aligned(4)));
566 * FW Flash Update status values
568 #define FLASH_UPDATE_COMPLETE_PENDING_REBOOT 0x00
569 #define FLASH_UPDATE_IN_PROGRESS 0x01
570 #define FLASH_UPDATE_HDR_ERR 0x02
571 #define FLASH_UPDATE_OFFSET_ERR 0x03
572 #define FLASH_UPDATE_CRC_ERR 0x04
573 #define FLASH_UPDATE_LENGTH_ERR 0x05
574 #define FLASH_UPDATE_HW_ERR 0x06
575 #define FLASH_UPDATE_DNLD_NOT_SUPPORTED 0x10
576 #define FLASH_UPDATE_DISABLED 0x11
579 #define DS_OPERATIONAL 0x01
580 #define DS_PORT_IN_RESET 0x02
581 #define DS_IN_RECOVERY 0x03
582 #define DS_IN_ERROR 0x04
583 #define DS_NON_OPERATIONAL 0x07
586 * brief param structure for firmware flash update.
588 struct fw_flash_updata_info
{
589 u32 cur_image_offset
;
592 struct pm8001_prd sgl
;
595 struct fw_control_info
{
596 u32 retcode
;/*ret code (status)*/
597 u32 phase
;/*ret code phase*/
598 u32 phaseCmplt
;/*percent complete for the current
600 u32 version
;/*Hex encoded firmware version number*/
601 u32 offset
;/*Used for downloading firmware */
602 u32 len
; /*len of buffer*/
603 u32 size
;/* Used in OS VPD and Trace get size
605 u32 reserved
;/* padding required for 64 bit
607 u8 buffer
[];/* Start of buffer */
609 struct fw_control_ex
{
610 struct fw_control_info
*fw_control
;
611 void *buffer
;/* keep buffer pointer to be
612 freed when the response comes*/
613 void *virtAddr
;/* keep virtual address of the data */
614 void *usrAddr
;/* keep virtual address of the
616 dma_addr_t phys_addr
;
617 u32 len
; /* len of buffer */
618 void *payload
; /* pointer to IOCTL Payload */
619 u8 inProgress
;/*if 1 - the IOCTL request is in
626 /* pm8001 workqueue */
627 extern struct workqueue_struct
*pm8001_wq
;
629 /******************** function prototype *********************/
630 int pm8001_tag_alloc(struct pm8001_hba_info
*pm8001_ha
, u32
*tag_out
);
631 u32
pm8001_get_ncq_tag(struct sas_task
*task
, u32
*tag
);
632 void pm8001_ccb_task_free(struct pm8001_hba_info
*pm8001_ha
,
633 struct pm8001_ccb_info
*ccb
);
634 int pm8001_phy_control(struct asd_sas_phy
*sas_phy
, enum phy_func func
,
636 void pm8001_scan_start(struct Scsi_Host
*shost
);
637 int pm8001_scan_finished(struct Scsi_Host
*shost
, unsigned long time
);
638 int pm8001_queue_command(struct sas_task
*task
, gfp_t gfp_flags
);
639 int pm8001_abort_task(struct sas_task
*task
);
640 int pm8001_clear_task_set(struct domain_device
*dev
, u8
*lun
);
641 int pm8001_dev_found(struct domain_device
*dev
);
642 void pm8001_dev_gone(struct domain_device
*dev
);
643 int pm8001_lu_reset(struct domain_device
*dev
, u8
*lun
);
644 int pm8001_I_T_nexus_reset(struct domain_device
*dev
);
645 int pm8001_I_T_nexus_event_handler(struct domain_device
*dev
);
646 int pm8001_query_task(struct sas_task
*task
);
647 void pm8001_port_formed(struct asd_sas_phy
*sas_phy
);
648 void pm8001_open_reject_retry(
649 struct pm8001_hba_info
*pm8001_ha
,
650 struct sas_task
*task_to_close
,
651 struct pm8001_device
*device_to_close
);
652 int pm8001_mem_alloc(struct pci_dev
*pdev
, void **virt_addr
,
653 dma_addr_t
*pphys_addr
, u32
*pphys_addr_hi
, u32
*pphys_addr_lo
,
654 u32 mem_size
, u32 align
);
656 void pm8001_chip_iounmap(struct pm8001_hba_info
*pm8001_ha
);
657 int pm8001_mpi_build_cmd(struct pm8001_hba_info
*pm8001_ha
,
658 u32 q_index
, u32 opCode
, void *payload
, size_t nb
,
660 int pm8001_mpi_msg_free_get(struct inbound_queue_table
*circularQ
,
661 u16 messageSize
, void **messagePtr
);
662 u32
pm8001_mpi_msg_free_set(struct pm8001_hba_info
*pm8001_ha
, void *pMsg
,
663 struct outbound_queue_table
*circularQ
, u8 bc
);
664 u32
pm8001_mpi_msg_consume(struct pm8001_hba_info
*pm8001_ha
,
665 struct outbound_queue_table
*circularQ
,
666 void **messagePtr1
, u8
*pBC
);
667 int pm8001_chip_set_dev_state_req(struct pm8001_hba_info
*pm8001_ha
,
668 struct pm8001_device
*pm8001_dev
, u32 state
);
669 int pm8001_chip_fw_flash_update_req(struct pm8001_hba_info
*pm8001_ha
,
671 int pm8001_chip_fw_flash_update_build(struct pm8001_hba_info
*pm8001_ha
,
672 void *fw_flash_updata_info
, u32 tag
);
673 int pm8001_chip_set_nvmd_req(struct pm8001_hba_info
*pm8001_ha
, void *payload
);
674 int pm8001_chip_get_nvmd_req(struct pm8001_hba_info
*pm8001_ha
, void *payload
);
675 int pm8001_chip_ssp_tm_req(struct pm8001_hba_info
*pm8001_ha
,
676 struct pm8001_ccb_info
*ccb
,
677 struct sas_tmf_task
*tmf
);
678 int pm8001_chip_abort_task(struct pm8001_hba_info
*pm8001_ha
,
679 struct pm8001_ccb_info
*ccb
);
680 int pm8001_chip_dereg_dev_req(struct pm8001_hba_info
*pm8001_ha
, u32 device_id
);
681 void pm8001_chip_make_sg(struct scatterlist
*scatter
, int nr
, void *prd
);
682 void pm8001_work_fn(struct work_struct
*work
);
683 int pm8001_handle_event(struct pm8001_hba_info
*pm8001_ha
,
684 void *data
, int handler
);
685 void pm8001_mpi_set_dev_state_resp(struct pm8001_hba_info
*pm8001_ha
,
687 void pm8001_mpi_set_nvmd_resp(struct pm8001_hba_info
*pm8001_ha
,
689 void pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info
*pm8001_ha
,
691 int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info
*pm8001_ha
,
693 void pm8001_get_lrate_mode(struct pm8001_phy
*phy
, u8 link_rate
);
694 void pm8001_get_attached_sas_addr(struct pm8001_phy
*phy
, u8
*sas_addr
);
695 void pm8001_bytes_dmaed(struct pm8001_hba_info
*pm8001_ha
, int i
);
696 int pm8001_mpi_reg_resp(struct pm8001_hba_info
*pm8001_ha
, void *piomb
);
697 int pm8001_mpi_dereg_resp(struct pm8001_hba_info
*pm8001_ha
, void *piomb
);
698 int pm8001_mpi_fw_flash_update_resp(struct pm8001_hba_info
*pm8001_ha
,
700 int pm8001_mpi_general_event(struct pm8001_hba_info
*pm8001_ha
, void *piomb
);
701 int pm8001_mpi_task_abort_resp(struct pm8001_hba_info
*pm8001_ha
, void *piomb
);
702 void pm8001_tag_free(struct pm8001_hba_info
*pm8001_ha
, u32 tag
);
703 struct pm8001_device
*pm8001_find_dev(struct pm8001_hba_info
*pm8001_ha
,
705 int pm80xx_set_thermal_config(struct pm8001_hba_info
*pm8001_ha
);
707 int pm8001_bar4_shift(struct pm8001_hba_info
*pm8001_ha
, u32 shiftValue
);
708 void pm8001_set_phy_profile(struct pm8001_hba_info
*pm8001_ha
,
709 u32 length
, u8
*buf
);
710 void pm8001_set_phy_profile_single(struct pm8001_hba_info
*pm8001_ha
,
711 u32 phy
, u32 length
, u32
*buf
);
712 int pm80xx_bar4_shift(struct pm8001_hba_info
*pm8001_ha
, u32 shiftValue
);
713 ssize_t
pm80xx_get_fatal_dump(struct device
*cdev
,
714 struct device_attribute
*attr
, char *buf
);
715 ssize_t
pm80xx_get_non_fatal_dump(struct device
*cdev
,
716 struct device_attribute
*attr
, char *buf
);
717 ssize_t
pm8001_get_gsm_dump(struct device
*cdev
, u32
, char *buf
);
718 int pm80xx_fatal_errors(struct pm8001_hba_info
*pm8001_ha
);
719 void pm8001_free_dev(struct pm8001_device
*pm8001_dev
);
721 extern const struct attribute_group
*pm8001_host_groups
[];
722 extern const struct attribute_group
*pm8001_sdev_groups
[];
724 #define PM8001_INVALID_TAG ((u32)-1)
727 * Allocate a new tag and return the corresponding ccb after initializing it.
729 static inline struct pm8001_ccb_info
*
730 pm8001_ccb_alloc(struct pm8001_hba_info
*pm8001_ha
,
731 struct pm8001_device
*dev
, struct sas_task
*task
)
733 struct pm8001_ccb_info
*ccb
;
734 struct request
*rq
= NULL
;
738 rq
= sas_task_find_rq(task
);
741 tag
= rq
->tag
+ PM8001_RESERVE_SLOT
;
742 } else if (pm8001_tag_alloc(pm8001_ha
, &tag
)) {
743 pm8001_dbg(pm8001_ha
, FAIL
, "Failed to allocate a tag\n");
747 ccb
= &pm8001_ha
->ccb_info
[tag
];
752 ccb
->fw_control_context
= NULL
;
759 * Free the tag of an initialized ccb.
761 static inline void pm8001_ccb_free(struct pm8001_hba_info
*pm8001_ha
,
762 struct pm8001_ccb_info
*ccb
)
764 u32 tag
= ccb
->ccb_tag
;
767 * Cleanup the ccb to make sure that a manual scan of the adapter
768 * ccb_info array can detect ccb's that are in use.
769 * C.f. pm8001_open_reject_retry()
772 ccb
->ccb_tag
= PM8001_INVALID_TAG
;
774 ccb
->fw_control_context
= NULL
;
776 pm8001_tag_free(pm8001_ha
, tag
);
779 static inline void pm8001_ccb_task_free_done(struct pm8001_hba_info
*pm8001_ha
,
780 struct pm8001_ccb_info
*ccb
)
782 struct sas_task
*task
= ccb
->task
;
784 pm8001_ccb_task_free(pm8001_ha
, ccb
);
785 smp_mb(); /*in order to force CPU ordering*/
786 task
->task_done(task
);
788 void pm8001_setds_completion(struct domain_device
*dev
);
789 void pm8001_tmf_aborted(struct sas_task
*task
);