1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_1394_ADAPTERS_HCI1394_ISOCH_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_1394_ADAPTERS_HCI1394_ISOCH_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * hci1394_isoch.h 32*7c478bd9Sstevel@tonic-gate * Function declarations for front-end functions for hci1394 isochronous 33*7c478bd9Sstevel@tonic-gate * support. Also all isochronous related soft_state structures and defs. 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #include <sys/note.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/1394/adapters/hci1394_def.h> 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate /* handle passed back from init() and used for rest of functions */ 45*7c478bd9Sstevel@tonic-gate typedef struct hci1394_isoch_s *hci1394_isoch_handle_t; 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate /* 48*7c478bd9Sstevel@tonic-gate * Isochronous structures and defs used in the hci1394 soft state. 49*7c478bd9Sstevel@tonic-gate * (see hci1394_state.h). 50*7c478bd9Sstevel@tonic-gate */ 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate /* 53*7c478bd9Sstevel@tonic-gate * control structure for allocated isochronous dma descriptor memory. 54*7c478bd9Sstevel@tonic-gate * when attempting to bind memory, if ddi_addr_bind_handle indicates multiple 55*7c478bd9Sstevel@tonic-gate * cookies, each cookie will be tracked within a separate copy of this 56*7c478bd9Sstevel@tonic-gate * structure. Only the last cookie's idma_desc_mem structure will contain 57*7c478bd9Sstevel@tonic-gate * a valid mem_handle and mem, to be used when freeing all the memory. 58*7c478bd9Sstevel@tonic-gate * 59*7c478bd9Sstevel@tonic-gate * 'used' specifies the number of bytes used for descriptors in this cookie. 60*7c478bd9Sstevel@tonic-gate * 'offset' is this cookie's offset relative to the beginning of the buffer. 61*7c478bd9Sstevel@tonic-gate */ 62*7c478bd9Sstevel@tonic-gate typedef struct hci1394_idma_desc_mem_s { 63*7c478bd9Sstevel@tonic-gate struct hci1394_idma_desc_mem_s *dma_nextp; 64*7c478bd9Sstevel@tonic-gate hci1394_buf_handle_t mem_handle; 65*7c478bd9Sstevel@tonic-gate hci1394_buf_info_t mem; 66*7c478bd9Sstevel@tonic-gate uint32_t used; 67*7c478bd9Sstevel@tonic-gate uint32_t offset; 68*7c478bd9Sstevel@tonic-gate } hci1394_idma_desc_mem_t; 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Single thread modifies", hci1394_idma_desc_mem_s)) 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate /* structure to track one isochronous context */ 73*7c478bd9Sstevel@tonic-gate /* XXX if IR Multichan mode support is added, this must be modified */ 74*7c478bd9Sstevel@tonic-gate typedef struct hci1394_iso_ctxt_s { 75*7c478bd9Sstevel@tonic-gate int ctxt_index; /* 0-31 -- which context this is */ 76*7c478bd9Sstevel@tonic-gate int ctxt_io_mode; /* xmit, recv pkt or buf, hdrs, multi */ 77*7c478bd9Sstevel@tonic-gate uint32_t ctxt_flags; /* general context info */ 78*7c478bd9Sstevel@tonic-gate volatile uint32_t intr_flags; /* flags while context is running */ 79*7c478bd9Sstevel@tonic-gate kmutex_t intrprocmutex; /* interrupt/update coordination */ 80*7c478bd9Sstevel@tonic-gate kcondvar_t intr_cv; /* interrupt completion cv */ 81*7c478bd9Sstevel@tonic-gate uint16_t isospd; /* speed of packets for context */ 82*7c478bd9Sstevel@tonic-gate uint16_t isochan; /* isochronous channel for contxt */ 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate hci1394_ctxt_regs_t *ctxt_regsp; /* ctxt regs within hci1394_regs_t */ 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate void *xcs_firstp; /* first alloc xfer_ctl_t struct */ 87*7c478bd9Sstevel@tonic-gate hci1394_idma_desc_mem_t *dma_firstp; /* 1st alloc dma descriptor mem */ 88*7c478bd9Sstevel@tonic-gate uint32_t dma_mem_execp; /* exec start(bound mem w/Z bits) */ 89*7c478bd9Sstevel@tonic-gate uint32_t reserved; 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate ixl1394_command_t *ixl_firstp; /* 1st ixl cmmand in linked list */ 92*7c478bd9Sstevel@tonic-gate ixl1394_command_t *ixl_execp; /* currently executing ixl cmmand */ 93*7c478bd9Sstevel@tonic-gate uint_t ixl_exec_depth; /* curr exec ixl cmd xfer_ctl idx */ 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate uint_t max_dma_skips; /* max skips allowed before xmit */ 96*7c478bd9Sstevel@tonic-gate /* recovery required (16 => 2ms) */ 97*7c478bd9Sstevel@tonic-gate uint_t max_noadv_intrs; /* max intrs with no dma descriptor */ 98*7c478bd9Sstevel@tonic-gate /* block advances (8) */ 99*7c478bd9Sstevel@tonic-gate uint_t rem_noadv_intrs; /* remaining intrs allowed with no */ 100*7c478bd9Sstevel@tonic-gate /* dma advances (i.e. no status set) */ 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate uint16_t dma_last_time; /* last completd desc blk tmestmp */ 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate uint16_t default_tag; /* default tag value */ 105*7c478bd9Sstevel@tonic-gate uint16_t default_sync; /* default sync value */ 106*7c478bd9Sstevel@tonic-gate uint16_t default_skipmode; /* default skip mode */ 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate ixl1394_command_t *default_skiplabelp; /* set if needed */ 109*7c478bd9Sstevel@tonic-gate ixl1394_command_t *default_skipxferp; /* xfercmd for default skiplabl */ 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate void *global_callback_arg; /* provided to IXLcallbacks */ 112*7c478bd9Sstevel@tonic-gate opaque_t idma_evt_arg; /* provided to "stopped" callback */ 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate /* target callback if dma stops */ 115*7c478bd9Sstevel@tonic-gate void (*isoch_dma_stopped)(struct isoch_dma_handle *idma_hdl, 116*7c478bd9Sstevel@tonic-gate opaque_t idma_evt_arg, id1394_isoch_dma_stopped_t idma_stop_args); 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate } hci1394_iso_ctxt_t; 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Single thread modifies", hci1394_iso_ctxt_s)) 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate /* 123*7c478bd9Sstevel@tonic-gate * defs for hci1394_iso_ctxt_t.ctxt_io_mode. 124*7c478bd9Sstevel@tonic-gate * overall io characteristics of the contexts, initialized during isoch init 125*7c478bd9Sstevel@tonic-gate * and never changed. 126*7c478bd9Sstevel@tonic-gate */ 127*7c478bd9Sstevel@tonic-gate /* 128*7c478bd9Sstevel@tonic-gate * defs for hci1394_iso_ctxt_t.ctxt_flags 129*7c478bd9Sstevel@tonic-gate * These flags are protected by the context list mutex in the isoch handle 130*7c478bd9Sstevel@tonic-gate * (see hci1394_isoch.c for mutex definition) 131*7c478bd9Sstevel@tonic-gate */ 132*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_INUSE 0x00000001 /* context is in use */ 133*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_RUNNING 0x00000002 /* context is running */ 134*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_RECV 0x00000004 /* isoch receive context */ 135*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_CMDREG 0x00000008 /* dev has readable dma cmdptr */ 136*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_BFFILL 0x00000010 /* on=BufFill off=Pkt IR only */ 137*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_RHDRS 0x00000020 /* recv packet hdrs into mem */ 138*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_MULTI 0x00000040 /* in multichan mode - IR only */ 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate /* 141*7c478bd9Sstevel@tonic-gate * defs for hci1394_iso_ctxt_t.intr_flags 142*7c478bd9Sstevel@tonic-gate * These flags are protected by the per-context mutex "intrprocmutex" 143*7c478bd9Sstevel@tonic-gate */ 144*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_STOP 0x00000010 /* context stopped */ 145*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_INTRSET 0x00000020 /* intr flagged, not processed */ 146*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_ININTR 0x00000040 /* in intrproc, not due to int */ 147*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_INUPDATE 0x00000080 /* in intrproc, not due to int */ 148*7c478bd9Sstevel@tonic-gate #define HCI1394_ISO_CTXT_INCALL 0x00000100 /* intrproc is doing callback */ 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate /* 151*7c478bd9Sstevel@tonic-gate * structure used to do accounting for interrupt usage. Specifically, 152*7c478bd9Sstevel@tonic-gate * used to determine when CYCLE_LOST or CYCLE_INCONSISTENT storms 153*7c478bd9Sstevel@tonic-gate * should cause us to disable those interrupts. 154*7c478bd9Sstevel@tonic-gate */ 155*7c478bd9Sstevel@tonic-gate typedef struct hci1394_intr_thresh_s { 156*7c478bd9Sstevel@tonic-gate hrtime_t last_intr_time; 157*7c478bd9Sstevel@tonic-gate hrtime_t delta_t_thresh; 158*7c478bd9Sstevel@tonic-gate int delta_t_counter; 159*7c478bd9Sstevel@tonic-gate int counter_thresh; 160*7c478bd9Sstevel@tonic-gate } hci1394_intr_thresh_t; 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate /* defs for the hci1394_intr_thresh_t struct */ 163*7c478bd9Sstevel@tonic-gate #define HCI1394_CYC_LOST_DELTA 400000; /* 400ms */ 164*7c478bd9Sstevel@tonic-gate #define HCI1394_CYC_LOST_COUNT 25; 165*7c478bd9Sstevel@tonic-gate #define HCI1394_CYC_INCON_DELTA 400000; /* 400ms */ 166*7c478bd9Sstevel@tonic-gate #define HCI1394_CYC_INCON_COUNT 25; 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate /* 169*7c478bd9Sstevel@tonic-gate * Structure used for tracking all transmit and receive isochronous contexts 170*7c478bd9Sstevel@tonic-gate * Also contains the information necessary for tracking CYCLE_LOST and 171*7c478bd9Sstevel@tonic-gate * CYCLE_INCONSISTENT interrupt usage. 172*7c478bd9Sstevel@tonic-gate * The ctxt_list mutex protects the in-use status of the contexts while 173*7c478bd9Sstevel@tonic-gate * searching for a free isoch context to use in hci1394_alloc_isoch_dma(), 174*7c478bd9Sstevel@tonic-gate * during interrupt processing, and during free_isoch_dma processing. 175*7c478bd9Sstevel@tonic-gate * An openHCI 1.0 hardware implementation may support up to 32 separate DMA 176*7c478bd9Sstevel@tonic-gate * engines each for transmit and receive, referred to as "contexts". 177*7c478bd9Sstevel@tonic-gate * The number of supported contexts is determined during ohci board 178*7c478bd9Sstevel@tonic-gate * initialization, and can be different for transmit vs. receive. 179*7c478bd9Sstevel@tonic-gate */ 180*7c478bd9Sstevel@tonic-gate typedef struct hci1394_isoch_s { 181*7c478bd9Sstevel@tonic-gate hci1394_intr_thresh_t cycle_lost_thresh; 182*7c478bd9Sstevel@tonic-gate hci1394_intr_thresh_t cycle_incon_thresh; 183*7c478bd9Sstevel@tonic-gate int isoch_dma_alloc_cnt; 184*7c478bd9Sstevel@tonic-gate int unused; 185*7c478bd9Sstevel@tonic-gate int ctxt_xmit_count; 186*7c478bd9Sstevel@tonic-gate int ctxt_recv_count; 187*7c478bd9Sstevel@tonic-gate hci1394_iso_ctxt_t ctxt_xmit[HCI1394_MAX_ISOCH_CONTEXTS]; 188*7c478bd9Sstevel@tonic-gate hci1394_iso_ctxt_t ctxt_recv[HCI1394_MAX_ISOCH_CONTEXTS]; 189*7c478bd9Sstevel@tonic-gate kmutex_t ctxt_list_mutex; 190*7c478bd9Sstevel@tonic-gate } hci1394_isoch_t; 191*7c478bd9Sstevel@tonic-gate 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate void hci1394_isoch_init(hci1394_drvinfo_t *drvinfo, hci1394_ohci_handle_t ohci, 194*7c478bd9Sstevel@tonic-gate hci1394_isoch_handle_t *isoch_hdl); 195*7c478bd9Sstevel@tonic-gate void hci1394_isoch_fini(hci1394_isoch_handle_t *isoch_hdl); 196*7c478bd9Sstevel@tonic-gate void hci1394_isoch_cycle_inconsistent(hci1394_state_t *soft_statep); 197*7c478bd9Sstevel@tonic-gate void hci1394_isoch_cycle_lost(hci1394_state_t *soft_statep); 198*7c478bd9Sstevel@tonic-gate int hci1394_isoch_resume(hci1394_state_t *soft_statep); 199*7c478bd9Sstevel@tonic-gate void hci1394_isoch_error_ints_enable(hci1394_state_t *soft_statep); 200*7c478bd9Sstevel@tonic-gate 201*7c478bd9Sstevel@tonic-gate int hci1394_isoch_recv_count_get(hci1394_isoch_handle_t isoch_hdl); 202*7c478bd9Sstevel@tonic-gate hci1394_iso_ctxt_t *hci1394_isoch_recv_ctxt_get(hci1394_isoch_handle_t 203*7c478bd9Sstevel@tonic-gate isoch_hdl, int num); 204*7c478bd9Sstevel@tonic-gate int hci1394_isoch_xmit_count_get(hci1394_isoch_handle_t isoch_hdl); 205*7c478bd9Sstevel@tonic-gate hci1394_iso_ctxt_t *hci1394_isoch_xmit_ctxt_get(hci1394_isoch_handle_t 206*7c478bd9Sstevel@tonic-gate isoch_hdl, int num); 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate int hci1394_alloc_isoch_dma(void *hal_private, id1394_isoch_dmainfo_t *idi, 210*7c478bd9Sstevel@tonic-gate void **hal_idma_handle, int *resultp); 211*7c478bd9Sstevel@tonic-gate void hci1394_free_isoch_dma(void *hal_private, void *hal_isoch_dma_handle); 212*7c478bd9Sstevel@tonic-gate int hci1394_start_isoch_dma(void *hal_private, void *hal_isoch_dma_handle, 213*7c478bd9Sstevel@tonic-gate id1394_isoch_dma_ctrlinfo_t *idma_ctrlinfo, uint_t flags, int *resultp); 214*7c478bd9Sstevel@tonic-gate int hci1394_update_isoch_dma(void *hal_private, void *hal_isoch_dma_handle, 215*7c478bd9Sstevel@tonic-gate id1394_isoch_dma_updateinfo_t *idma_updateinfop, uint_t flags, 216*7c478bd9Sstevel@tonic-gate int *resultp); 217*7c478bd9Sstevel@tonic-gate void hci1394_stop_isoch_dma(void *hal_private, void *hal_isoch_dma_handle, 218*7c478bd9Sstevel@tonic-gate int *resultp); 219*7c478bd9Sstevel@tonic-gate void hci1394_do_stop(hci1394_state_t *soft_statep, hci1394_iso_ctxt_t *ctxtp, 220*7c478bd9Sstevel@tonic-gate boolean_t do_callback, id1394_isoch_dma_stopped_t stop_args); 221*7c478bd9Sstevel@tonic-gate 222*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 223*7c478bd9Sstevel@tonic-gate } 224*7c478bd9Sstevel@tonic-gate #endif 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate #endif /* _SYS_1394_ADAPTERS_HCI1394_ISOCH_H */ 227