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 (c) 1999-2000 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_1394_ADAPTERS_HCI1394_TLABEL_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_1394_ADAPTERS_HCI1394_TLABEL_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * hci1394_tlabel.h 32*7c478bd9Sstevel@tonic-gate * These routines track the tlabel usage for a 1394 adapter. 33*7c478bd9Sstevel@tonic-gate */ 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 36*7c478bd9Sstevel@tonic-gate extern "C" { 37*7c478bd9Sstevel@tonic-gate #endif 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/conf.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/time.h> 45*7c478bd9Sstevel@tonic-gate #include <sys/note.h> 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate /* 48*7c478bd9Sstevel@tonic-gate * TLABEL_RANGE specifies the number of tlabels that will be allocated for a 49*7c478bd9Sstevel@tonic-gate * given node. tlabels are allocated starting at 0 and going up to 50*7c478bd9Sstevel@tonic-gate * (TLABEL_RANGE - 1). 51*7c478bd9Sstevel@tonic-gate * 52*7c478bd9Sstevel@tonic-gate * e.g. if TLABEL_RANGE was set to 4, each node could have at most 4 outstanding 53*7c478bd9Sstevel@tonic-gate * transactions to any other node at any given time and the tlabels allocated 54*7c478bd9Sstevel@tonic-gate * would be 0, 1, 2, and 3. 55*7c478bd9Sstevel@tonic-gate * 56*7c478bd9Sstevel@tonic-gate * NOTE: the maximum value of TLABEL_RANGE is 64. 57*7c478bd9Sstevel@tonic-gate */ 58*7c478bd9Sstevel@tonic-gate #define TLABEL_RANGE 64 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate /* TLABEL_MASK is the mask used to extract the 6-bit tlabel */ 61*7c478bd9Sstevel@tonic-gate #define TLABEL_MASK 0x3F 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate /* 65*7c478bd9Sstevel@tonic-gate * destination - a 16-bit value where the most significant 10-bits are the bus 66*7c478bd9Sstevel@tonic-gate * # and the least significant 6 bits are the node #. The upper 67*7c478bd9Sstevel@tonic-gate * 16 bits of this word are not used. 68*7c478bd9Sstevel@tonic-gate * 69*7c478bd9Sstevel@tonic-gate * tlabel - the 1394 tlabel to be used. A number ranging from 70*7c478bd9Sstevel@tonic-gate * 0 - (TLABEL_RANGE - 1) 71*7c478bd9Sstevel@tonic-gate */ 72*7c478bd9Sstevel@tonic-gate typedef struct hci1394_tlabel_info_s { 73*7c478bd9Sstevel@tonic-gate uint_t tbi_destination; 74*7c478bd9Sstevel@tonic-gate uint_t tbi_tlabel; 75*7c478bd9Sstevel@tonic-gate } hci1394_tlabel_info_t; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Single thread modifies", \ 78*7c478bd9Sstevel@tonic-gate hci1394_tlabel_info_s::tbi_destination \ 79*7c478bd9Sstevel@tonic-gate hci1394_tlabel_info_s::tbi_tlabel)) 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate /* structure used to keep track of tlabels */ 82*7c478bd9Sstevel@tonic-gate typedef struct hci1394_tlabel_s { 83*7c478bd9Sstevel@tonic-gate /* 84*7c478bd9Sstevel@tonic-gate * The maximum node number that we have sent a tlabel to inclusive. This 85*7c478bd9Sstevel@tonic-gate * is used as an optimization during reset processing. 86*7c478bd9Sstevel@tonic-gate */ 87*7c478bd9Sstevel@tonic-gate uint_t tb_max_node; 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate /* 90*7c478bd9Sstevel@tonic-gate * Status if we have sent a broadcast request out. This is used as an 91*7c478bd9Sstevel@tonic-gate * optimization during reset processing. 92*7c478bd9Sstevel@tonic-gate */ 93*7c478bd9Sstevel@tonic-gate boolean_t tb_bcast_sent; 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate /* 96*7c478bd9Sstevel@tonic-gate * free is used to keep track of free tlabels. The free tlabels are 97*7c478bd9Sstevel@tonic-gate * tracked as a bit mask. If the bit is set to 1 the tlabel is free, 98*7c478bd9Sstevel@tonic-gate * if set to 0 the tlabel is used. 99*7c478bd9Sstevel@tonic-gate */ 100*7c478bd9Sstevel@tonic-gate uint64_t tb_free[IEEE1394_MAX_NODES]; 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate /* 103*7c478bd9Sstevel@tonic-gate * bad is used to keep track of bad tlabels. A bad tlabel is used for a 104*7c478bd9Sstevel@tonic-gate * ATREQ that was pended but the response was never received. They will 105*7c478bd9Sstevel@tonic-gate * be put back into the free list when > 2 times the split timeout has 106*7c478bd9Sstevel@tonic-gate * gone by (from the initial transfer). The bad tlabels are tracked as 107*7c478bd9Sstevel@tonic-gate * a bit mask. If the bit is set to 1 the tlabel is bad, if set to 0 the 108*7c478bd9Sstevel@tonic-gate * tlabel is good. 109*7c478bd9Sstevel@tonic-gate */ 110*7c478bd9Sstevel@tonic-gate uint64_t tb_bad[IEEE1394_MAX_NODES]; 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate /* 113*7c478bd9Sstevel@tonic-gate * last tracks the last used tlabel for a given node. This allows us to 114*7c478bd9Sstevel@tonic-gate * walk through the tlabels for each node during tlabel allocation 115*7c478bd9Sstevel@tonic-gate * (i.e. so we always don't allocate the same tlabel over and over again 116*7c478bd9Sstevel@tonic-gate * if the device is accessed serially). 117*7c478bd9Sstevel@tonic-gate */ 118*7c478bd9Sstevel@tonic-gate uint8_t tb_last[IEEE1394_MAX_NODES]; 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* 121*7c478bd9Sstevel@tonic-gate * Times are in nS. reclaim_time is set to the duration to wait to 122*7c478bd9Sstevel@tonic-gate * reclaim the bad tlabels. bad_timestamp is a timestamp for when the 123*7c478bd9Sstevel@tonic-gate * last bad tlabel was added into the bit mask. 124*7c478bd9Sstevel@tonic-gate */ 125*7c478bd9Sstevel@tonic-gate hrtime_t tb_bad_timestamp[IEEE1394_MAX_NODES]; 126*7c478bd9Sstevel@tonic-gate hrtime_t tb_reclaim_time; 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate /* 129*7c478bd9Sstevel@tonic-gate * *_lookup[node][tlabel] 130*7c478bd9Sstevel@tonic-gate * Used to track a generic pointer for a given node/tlabel. 131*7c478bd9Sstevel@tonic-gate */ 132*7c478bd9Sstevel@tonic-gate void *tb_lookup[IEEE1394_MAX_NODES][TLABEL_RANGE]; 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate /* general driver info */ 135*7c478bd9Sstevel@tonic-gate hci1394_drvinfo_t *tb_drvinfo; 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate kmutex_t tb_mutex; 138*7c478bd9Sstevel@tonic-gate } hci1394_tlabel_t; 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Single thread modifies", \ 141*7c478bd9Sstevel@tonic-gate hci1394_tlabel_s::tb_reclaim_time)) 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate /* handle passed back from init() and used for rest of functions */ 144*7c478bd9Sstevel@tonic-gate typedef struct hci1394_tlabel_s *hci1394_tlabel_handle_t; 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate void hci1394_tlabel_init(hci1394_drvinfo_t *drvinfo, hrtime_t reclaim_time_nS, 149*7c478bd9Sstevel@tonic-gate hci1394_tlabel_handle_t *tlabel_handle); 150*7c478bd9Sstevel@tonic-gate void hci1394_tlabel_fini(hci1394_tlabel_handle_t *tlabel_handle); 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate int hci1394_tlabel_alloc(hci1394_tlabel_handle_t tlabel_handle, 153*7c478bd9Sstevel@tonic-gate uint_t destination, hci1394_tlabel_info_t *tlabel_info); 154*7c478bd9Sstevel@tonic-gate void hci1394_tlabel_free(hci1394_tlabel_handle_t tlabel_handle, 155*7c478bd9Sstevel@tonic-gate hci1394_tlabel_info_t *tlabel_info); 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate void hci1394_tlabel_register(hci1394_tlabel_handle_t tlabel_handle, 158*7c478bd9Sstevel@tonic-gate hci1394_tlabel_info_t *tlabel_info, void *cmd); 159*7c478bd9Sstevel@tonic-gate void hci1394_tlabel_lookup(hci1394_tlabel_handle_t tlabel_handle, 160*7c478bd9Sstevel@tonic-gate hci1394_tlabel_info_t *tlabel_info, void **cmd); 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate void hci1394_tlabel_bad(hci1394_tlabel_handle_t tlabel_handle, 163*7c478bd9Sstevel@tonic-gate hci1394_tlabel_info_t *tlabel_info); 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate void hci1394_tlabel_reset(hci1394_tlabel_handle_t tlabel_handle); 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate void hci1394_tlabel_set_reclaim_time(hci1394_tlabel_handle_t tlabel_handle, 168*7c478bd9Sstevel@tonic-gate hrtime_t reclaim_time_nS); 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 172*7c478bd9Sstevel@tonic-gate } 173*7c478bd9Sstevel@tonic-gate #endif 174*7c478bd9Sstevel@tonic-gate 175*7c478bd9Sstevel@tonic-gate #endif /* _SYS_1394_ADAPTERS_HCI1394_TLABEL_H */ 176