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