📄 aic79xx.h
字号:
uint16_t qinfifonext; uint16_t qinfifo[AHD_SCB_MAX]; uint16_t *qoutfifo; /* Critical Section Data */ struct cs *critical_sections; u_int num_critical_sections; /* Buffer for handling packetized bitbucket. */ uint8_t *overrun_buf; /* Links for chaining softcs */ TAILQ_ENTRY(ahd_softc) links; /* Channel Names ('A', 'B', etc.) */ char channel; /* Initiator Bus ID */ uint8_t our_id; /* * Target incoming command FIFO. */ struct target_cmd *targetcmds; uint8_t tqinfifonext; /* * Cached verson of the hs_mailbox so we can avoid * pausing the sequencer during mailbox updates. */ uint8_t hs_mailbox; /* * Incoming and outgoing message handling. */ uint8_t send_msg_perror; ahd_msg_flags msg_flags; ahd_msg_type msg_type; uint8_t msgout_buf[12];/* Message we are sending */ uint8_t msgin_buf[12];/* Message we are receiving */ u_int msgout_len; /* Length of message to send */ u_int msgout_index; /* Current index in msgout */ u_int msgin_index; /* Current index in msgin */ /* * Mapping information for data structures shared * between the sequencer and kernel. */ bus_dma_tag_t parent_dmat; bus_dma_tag_t shared_data_dmat; bus_dmamap_t shared_data_dmamap; dma_addr_t shared_data_busaddr; /* Information saved through suspend/resume cycles */ struct ahd_suspend_state suspend_state; /* Number of enabled target mode device on this card */ u_int enabled_luns; /* Initialization level of this data structure */ u_int init_level; /* PCI cacheline size. */ u_int pci_cachesize; /* IO Cell Parameters */ uint8_t iocell_opts[AHD_NUM_PER_DEV_ANNEXCOLS]; u_int stack_size; uint16_t *saved_stack; /* Per-Unit descriptive information */ const char *description; const char *bus_description; char *name; int unit; /* Selection Timer settings */ int seltime; /* * Interrupt coalescing settings. */#define AHD_INT_COALESCING_TIMER_DEFAULT 250 /*us*/#define AHD_INT_COALESCING_MAXCMDS_DEFAULT 10#define AHD_INT_COALESCING_MAXCMDS_MAX 127#define AHD_INT_COALESCING_MINCMDS_DEFAULT 5#define AHD_INT_COALESCING_MINCMDS_MAX 127#define AHD_INT_COALESCING_THRESHOLD_DEFAULT 2000#define AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT 1000 u_int int_coalescing_timer; u_int int_coalescing_maxcmds; u_int int_coalescing_mincmds; u_int int_coalescing_threshold; u_int int_coalescing_stop_threshold; uint16_t user_discenable;/* Disconnection allowed */ uint16_t user_tagenable;/* Tagged Queuing allowed */};/*************************** IO Cell Configuration ****************************/#define AHD_PRECOMP_SLEW_INDEX \ (AHD_ANNEXCOL_PRECOMP_SLEW - AHD_ANNEXCOL_PER_DEV0)#define AHD_AMPLITUDE_INDEX \ (AHD_ANNEXCOL_AMPLITUDE - AHD_ANNEXCOL_PER_DEV0)#define AHD_SET_SLEWRATE(ahd, new_slew) \do { \ (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_SLEWRATE_MASK; \ (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] |= \ (((new_slew) << AHD_SLEWRATE_SHIFT) & AHD_SLEWRATE_MASK); \} while (0)#define AHD_SET_PRECOMP(ahd, new_pcomp) \do { \ (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK; \ (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] |= \ (((new_pcomp) << AHD_PRECOMP_SHIFT) & AHD_PRECOMP_MASK); \} while (0)#define AHD_SET_AMPLITUDE(ahd, new_amp) \do { \ (ahd)->iocell_opts[AHD_AMPLITUDE_INDEX] &= ~AHD_AMPLITUDE_MASK; \ (ahd)->iocell_opts[AHD_AMPLITUDE_INDEX] |= \ (((new_amp) << AHD_AMPLITUDE_SHIFT) & AHD_AMPLITUDE_MASK); \} while (0)/************************ Active Device Information ***************************/typedef enum { ROLE_UNKNOWN, ROLE_INITIATOR, ROLE_TARGET} role_t;struct ahd_devinfo { int our_scsiid; int target_offset; uint16_t target_mask; u_int target; u_int lun; char channel; role_t role; /* * Only guaranteed to be correct if not * in the busfree state. */};/****************************** PCI Structures ********************************/#define AHD_PCI_IOADDR0 PCIR_MAPS /* I/O BAR*/#define AHD_PCI_MEMADDR (PCIR_MAPS + 4) /* Memory BAR */#define AHD_PCI_IOADDR1 (PCIR_MAPS + 12)/* Second I/O BAR */typedef int (ahd_device_setup_t)(struct ahd_softc *);struct ahd_pci_identity { uint64_t full_id; uint64_t id_mask; char *name; ahd_device_setup_t *setup;};extern struct ahd_pci_identity ahd_pci_ident_table [];extern const u_int ahd_num_pci_devs;/***************************** VL/EISA Declarations ***************************/struct aic7770_identity { uint32_t full_id; uint32_t id_mask; char *name; ahd_device_setup_t *setup;};extern struct aic7770_identity aic7770_ident_table [];extern const int ahd_num_aic7770_devs;#define AHD_EISA_SLOT_OFFSET 0xc00#define AHD_EISA_IOSIZE 0x100/*************************** Function Declarations ****************************//******************************************************************************/void ahd_reset_cmds_pending(struct ahd_softc *ahd);u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);void ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int busyid);static __inline void ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl);static __inline voidahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl){ ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);}/***************************** PCI Front End *********************************/struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t);int ahd_pci_config(struct ahd_softc *, struct ahd_pci_identity *);int ahd_pci_test_register_access(struct ahd_softc *);/************************** SCB and SCB queue management **********************/int ahd_probe_scbs(struct ahd_softc *);void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, struct scb *scb);int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target, char channel, int lun, u_int tag, role_t role);/****************************** Initialization ********************************/struct ahd_softc *ahd_alloc(void *platform_arg, char *name);int ahd_softc_init(struct ahd_softc *);void ahd_controller_info(struct ahd_softc *ahd, char *buf);int ahd_init(struct ahd_softc *ahd);int ahd_default_config(struct ahd_softc *ahd);int ahd_parse_vpddata(struct ahd_softc *ahd, struct vpd_config *vpd);int ahd_parse_cfgdata(struct ahd_softc *ahd, struct seeprom_config *sc);void ahd_intr_enable(struct ahd_softc *ahd, int enable);void ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds, u_int mincmds);void ahd_enable_coalescing(struct ahd_softc *ahd, int enable);void ahd_pause_and_flushwork(struct ahd_softc *ahd);int ahd_suspend(struct ahd_softc *ahd); int ahd_resume(struct ahd_softc *ahd);void ahd_set_unit(struct ahd_softc *, int);void ahd_set_name(struct ahd_softc *, char *);struct scb *ahd_get_scb(struct ahd_softc *ahd, u_int col_idx);void ahd_free_scb(struct ahd_softc *ahd, struct scb *scb);void ahd_alloc_scbs(struct ahd_softc *ahd);void ahd_free(struct ahd_softc *ahd);int ahd_reset(struct ahd_softc *ahd, int reinit);void ahd_shutdown(void *arg);int ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value);int ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value);int ahd_wait_flexport(struct ahd_softc *ahd);/*************************** Interrupt Services *******************************/void ahd_pci_intr(struct ahd_softc *ahd);void ahd_clear_intstat(struct ahd_softc *ahd);void ahd_flush_qoutfifo(struct ahd_softc *ahd);void ahd_run_qoutfifo(struct ahd_softc *ahd);#ifdef AHD_TARGET_MODEvoid ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);#endifvoid ahd_handle_hwerrint(struct ahd_softc *ahd);void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);void ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat);void ahd_clear_critical_section(struct ahd_softc *ahd);/***************************** Error Recovery *********************************/typedef enum { SEARCH_COMPLETE, SEARCH_COUNT, SEARCH_REMOVE, SEARCH_PRINT} ahd_search_action;int ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel, int lun, u_int tag, role_t role, uint32_t status, ahd_search_action action);int ahd_search_disc_list(struct ahd_softc *ahd, int target, char channel, int lun, u_int tag, int stop_on_first, int remove, int save_state);void ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb);int ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset);int ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel, int lun, u_int tag, role_t role, uint32_t status);void ahd_restart(struct ahd_softc *ahd);void ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo);void ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb);void ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb);void ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb);/*************************** Utility Functions ********************************/struct ahd_phase_table_entry* ahd_lookup_phase_entry(int phase);void ahd_compile_devinfo(struct ahd_devinfo *devinfo, u_int our_id, u_int target, u_int lun, char channel, role_t role);/************************** Transfer Negotiation ******************************/void ahd_find_syncrate(struct ahd_softc *ahd, u_int *period, u_int *ppr_options, u_int maxsync);void ahd_validate_offset(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, u_int period, u_int *offset, int wide, role_t role);void ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, u_int *bus_width, role_t role);/* * Negotiation types. These are used to qualify if we should renegotiate * even if our goal and current transport parameters are identical. */typedef enum { AHD_NEG_TO_GOAL, /* Renegotiate only if goal and curr differ. */ AHD_NEG_IF_NON_ASYNC, /* Renegotiate so long as goal is non-async. */ AHD_NEG_ALWAYS /* Renegotiat even if goal is async. */} ahd_neg_type;int ahd_update_neg_request(struct ahd_softc*, struct ahd_devinfo*, struct ahd_tmode_tstate*, struct ahd_initiator_tinfo*, ahd_neg_type);void ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, u_int width, u_int type, int paused);void ahd_set_syncrate(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, u_int period, u_int offset, u_int ppr_options, u_int type, int paused);typedef enum { AHD_QUEUE_NONE, AHD_QUEUE_BASIC, AHD_QUEUE_TAGGED} ahd_queue_alg;void ahd_set_tags(struct ahd_softc *ahd, struct ahd_devinfo *devinfo, ahd_queue_alg alg);/**************************** Target Mode *************************************/#ifdef AHD_TARGET_MODEvoid ahd_send_lstate_events(struct ahd_softc *, struct ahd_tmode_lstate *);void ahd_handle_en_lun(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb);cam_status ahd_find_tmode_devs(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb, struct ahd_tmode_tstate **tstate, struct ahd_tmode_lstate **lstate, int notfound_failure);#ifndef AHD_TMODE_ENABLE#define AHD_TMODE_ENABLE 0#endif#endif/******************************* Debug ***************************************/#ifdef AHD_DEBUGextern uint32_t ahd_debug;#define AHD_SHOW_MISC 0x00001#define AHD_SHOW_SENSE 0x00002#define AHD_SHOW_RECOVERY 0x00004#define AHD_DUMP_SEEPROM 0x00008#define AHD_SHOW_TERMCTL 0x00010#define AHD_SHOW_MEMORY 0x00020#define AHD_SHOW_MESSAGES 0x00040#define AHD_SHOW_MODEPTR 0x00080#define AHD_SHOW_SELTO 0x00100#define AHD_SHOW_FIFOS 0x00200#define AHD_SHOW_QFULL 0x00400#define AHD_SHOW_DV 0x00800#define AHD_SHOW_MASKED_ERRORS 0x01000#define AHD_SHOW_QUEUE 0x02000#define AHD_SHOW_TQIN 0x04000#define AHD_SHOW_SG 0x08000#define AHD_SHOW_INT_COALESCING 0x10000#define AHD_DEBUG_SEQUENCER 0x20000#endifvoid ahd_print_scb(struct scb *scb);void ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo);void ahd_dump_sglist(struct scb *scb);void ahd_dump_card_state(struct ahd_softc *ahd);int ahd_print_register(ahd_reg_parse_entry_t *table, u_int num_entries, const char *name, u_int address, u_int value, u_int *cur_column, u_int wrap_point);void ahd_dump_scbs(struct ahd_softc *ahd);#endif /* _AIC79XX_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -