7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 /*
30 * Multidata, as described in the following papers:
31 *
32 * Adi Masputra,
33 * Multidata V.2: VA-Disjoint Packet Extents Framework Interface
34 * Design Specification. August 2004.
35 * Available as http://sac.sfbay/PSARC/2004/594/materials/mmd2.pdf.
36 *
37 * Adi Masputra,
38 * Multidata Interface Design Specification. Sep 2002.
39 * Available as http://sac.sfbay/PSARC/2002/276/materials/mmd.pdf.
40 *
41 * Adi Masputra, Frank DiMambro, Kacheong Poon,
42 * An Efficient Networking Transmit Mechanism for Solaris:
43 * Multidata Transmit (MDT). May 2002.
44 * Available as http://sac.sfbay/PSARC/2002/276/materials/mdt.pdf.
45 */
46
47 #include <sys/types.h>
48 #include <sys/stream.h>
1277 uint_t size;
1278
1279 ASSERT(mmd != NULL);
1280 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
1281 ASSERT(pd == NULL || pd->pd_magic == PDESC_MAGIC);
1282 ASSERT(pai != NULL);
1283
1284 /* pointer to the attribute hash table (local or global) */
1285 tbl_p = pd != NULL ? &(pd->pd_pattbl) : &(mmd->mmd_pattbl);
1286
1287 /*
1288 * See if the hash table has not yet been created; if so,
1289 * we create the table and store its address atomically.
1290 */
1291 if ((tbl = *tbl_p) == NULL) {
1292 tbl = kmem_cache_alloc(pattbl_cache, kmflags);
1293 if (tbl == NULL)
1294 return (NULL);
1295
1296 /* if someone got there first, use his table instead */
1297 if ((o_tbl = casptr(tbl_p, NULL, tbl)) != NULL) {
1298 kmem_cache_free(pattbl_cache, tbl);
1299 tbl = o_tbl;
1300 }
1301 }
1302
1303 ASSERT(tbl->pbkt_tbl_sz > 0);
1304 bkt = &(tbl[PATTBL_HASH(pai->type, tbl->pbkt_tbl_sz)]);
1305
1306 /* attribute of the same type already exists? */
1307 if ((pa = mmd_find_pattr(bkt, pai->type)) != NULL)
1308 return (NULL);
1309
1310 size = sizeof (*pa) + pai->len;
1311 if ((pa = kmem_zalloc(size, kmflags)) == NULL)
1312 return (NULL);
1313
1314 pa->pat_magic = PATTR_MAGIC;
1315 pa->pat_lock = &(bkt->pbkt_lock);
1316 pa->pat_mmd = mmd;
1317 pa->pat_buflen = size;
|
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Multidata, as described in the following papers:
29 *
30 * Adi Masputra,
31 * Multidata V.2: VA-Disjoint Packet Extents Framework Interface
32 * Design Specification. August 2004.
33 * Available as http://sac.sfbay/PSARC/2004/594/materials/mmd2.pdf.
34 *
35 * Adi Masputra,
36 * Multidata Interface Design Specification. Sep 2002.
37 * Available as http://sac.sfbay/PSARC/2002/276/materials/mmd.pdf.
38 *
39 * Adi Masputra, Frank DiMambro, Kacheong Poon,
40 * An Efficient Networking Transmit Mechanism for Solaris:
41 * Multidata Transmit (MDT). May 2002.
42 * Available as http://sac.sfbay/PSARC/2002/276/materials/mdt.pdf.
43 */
44
45 #include <sys/types.h>
46 #include <sys/stream.h>
1275 uint_t size;
1276
1277 ASSERT(mmd != NULL);
1278 ASSERT(mmd->mmd_magic == MULTIDATA_MAGIC);
1279 ASSERT(pd == NULL || pd->pd_magic == PDESC_MAGIC);
1280 ASSERT(pai != NULL);
1281
1282 /* pointer to the attribute hash table (local or global) */
1283 tbl_p = pd != NULL ? &(pd->pd_pattbl) : &(mmd->mmd_pattbl);
1284
1285 /*
1286 * See if the hash table has not yet been created; if so,
1287 * we create the table and store its address atomically.
1288 */
1289 if ((tbl = *tbl_p) == NULL) {
1290 tbl = kmem_cache_alloc(pattbl_cache, kmflags);
1291 if (tbl == NULL)
1292 return (NULL);
1293
1294 /* if someone got there first, use his table instead */
1295 if ((o_tbl = atomic_cas_ptr(tbl_p, NULL, tbl)) != NULL) {
1296 kmem_cache_free(pattbl_cache, tbl);
1297 tbl = o_tbl;
1298 }
1299 }
1300
1301 ASSERT(tbl->pbkt_tbl_sz > 0);
1302 bkt = &(tbl[PATTBL_HASH(pai->type, tbl->pbkt_tbl_sz)]);
1303
1304 /* attribute of the same type already exists? */
1305 if ((pa = mmd_find_pattr(bkt, pai->type)) != NULL)
1306 return (NULL);
1307
1308 size = sizeof (*pa) + pai->len;
1309 if ((pa = kmem_zalloc(size, kmflags)) == NULL)
1310 return (NULL);
1311
1312 pa->pat_magic = PATTR_MAGIC;
1313 pa->pat_lock = &(bkt->pbkt_lock);
1314 pa->pat_mmd = mmd;
1315 pa->pat_buflen = size;
|