suntpi.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
3853N/A * The contents of this file are subject to the terms of the 3853N/A * Common Development and Distribution License, Version 1.0 only 3853N/A * (the "License"). You may not use this file except in compliance 3853N/A * See the License for the specific language governing permissions 3853N/A * and limitations under the License. 3853N/A * When distributing Covered Code, include this CDDL HEADER in each 3853N/A * If applicable, add the following below this CDDL HEADER, with the 3853N/A * fields enclosed by brackets "[]" replaced with your own identifying 3853N/A * information: Portions Copyright [yyyy] [name of copyright owner] 3853N/A * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 3853N/A * Use is subject to license terms. 3853N/A#
pragma ident "%Z%%M% %I% %E% SMI" 3853N/A * Hash table parameters for tpi_provinfo_table. 4518N/A * Use the first element in the key for the hash. 3853N/A * SAMESTR is a very confusing name. LAST_QUEUE is introduced for readability. 3853N/A * In most cases there is some transport provider (like tcp or udp) below 3853N/A * transport user (like timod or sockets). However, it is possible to construct 3853N/A * stream without transport provider (e.g. by pushing timod into FIFO). It is 3853N/A * hardly of any use, but this condition was observed with sparcv9 abi tests. 3853N/A * To count for such special case, a special tpi_nullprov static data is 3853N/A * provided to cache information about such degenerated null-transport case. 3853N/A * Initialise the TPI support routines. Called from strinit(). 4141N/A * Calculate the right shift for hashing a tpi_provinfo_t. 4141N/A * Generate a downstream signature given the write-side queue. It 4141N/A * passes back the size of the generated key in *keylenp. This routine 4141N/A * cannot multithread as it returns a pointer to a static data item. 4518N/A * There is no way (in the current module loading infrastructure) to 4518N/A * _absolutely_ guarantee that the key below uniquely identifies an 4141N/A * arrangement of modules and drivers. A module _might_ be unloaded and 4141N/A * another module _might_ be loaded such that the qi_minfo is at _exactly_ 3853N/A * same kernel address, and then it _might_ be placed in a transport 3853N/A * provider stream in exactly the same configuration (modules above and 4920N/A * below all identical) - but it would take quite a few coincidences 3853N/A * and modules loading and unloading does not usually happen n times a 3853N/A /* assert this queue is write queue and qprocson() is called before */ 3853N/A * This can be global because tpi_makekey is called with 3853N/A * Go down q_next to the driver, but no further. We use the qi_minfo 3853N/A * because we can find in from the queue and it is a stable part of 3853N/A * Allocate the actual key with the proper length, and pass it 3853N/A * Find an existing provider entry given a queue pointer, or allocate a 3853N/A * new empty entry if not found. Because this routine calls kmem_alloc 3853N/A * with KM_SLEEP, and because it traverses the q_next pointers of a stream 3853N/A * it must be called with a proper user context and within a perimeter 3853N/A * which protects the STREAM e.g. an open routine. This routine always 3853N/A * Must hold tpi_provinfo_lock since tpi_makekey() returns a pointer 3853N/A /* there is nothing below us, return special nullprov entry */ 3853N/A * Look for an existing entry, or the place to put a new one. 4060N/A * Allocate and fill in the new tpi_provinfo_t. 4060N/A * Allocate a TPI ACK reusing the old message if possible.