X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/1c79356b52d46aa6b508fb032f5ae709b1f2897b..0b4c1975fb5e4eccf1012a35081f7e7799b81046:/bsd/netat/atp_alloc.c diff --git a/bsd/netat/atp_alloc.c b/bsd/netat/atp_alloc.c index fc2d97724..cf9a4375c 100644 --- a/bsd/netat/atp_alloc.c +++ b/bsd/netat/atp_alloc.c @@ -1,23 +1,29 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* Modified for MP, 1996 by Tuyen Nguyen */ /* @@ -51,26 +57,25 @@ #define TRPS_PER_BLK 16 gbuf_t *atp_resource_m = 0; -extern atlock_t atpgen_lock; +extern caddr_t atp_free_cluster_list; +extern struct atp_rcb_qhead atp_need_rel; + struct atp_trans *atp_trans_alloc(atp) struct atp_state *atp; { - int s; int i; gbuf_t *m; register struct atp_trans *trp, *trp_array; - ATDISABLE(s, atpgen_lock); if (atp_trans_free_list == 0) { - ATENABLE(s, atpgen_lock); - if ((m = gbuf_alloc(TRPS_PER_BLK*sizeof(struct atp_trans),PRI_HI)) == 0) + if ((m = gbuf_alloc_wait(TRPS_PER_BLK*sizeof(struct atp_trans), + atp == NULL)) == 0) return (struct atp_trans *)0; bzero(gbuf_rptr(m), TRPS_PER_BLK*sizeof(struct atp_trans)); trp_array = (struct atp_trans *)gbuf_rptr(m); for (i=0; i < TRPS_PER_BLK-1; i++) trp_array[i].tr_list.next = (struct atp_trans *)&trp_array[i+1]; - ATDISABLE(s, atpgen_lock); gbuf_cont(m) = atp_resource_m; atp_resource_m = m; trp_array[i].tr_list.next = atp_trans_free_list; @@ -79,11 +84,9 @@ struct atp_state *atp; trp = atp_trans_free_list; atp_trans_free_list = trp->tr_list.next; - ATENABLE(s, atpgen_lock); trp->tr_queue = atp; trp->tr_state = TRANS_TIMEOUT; trp->tr_local_node = 0; - ATLOCKINIT(trp->tr_lock); ATEVENTINIT(trp->tr_event); dPrintf(D_M_ATP_LOW, D_L_TRACE, @@ -100,13 +103,10 @@ struct atp_state *atp; void atp_trans_free(trp) register struct atp_trans *trp; { - int s; - ATDISABLE(s, atpgen_lock); trp->tr_queue = 0; trp->tr_list.next = atp_trans_free_list; atp_trans_free_list = trp; - ATENABLE(s, atpgen_lock); } /* @@ -119,16 +119,13 @@ struct atp_rcb *atp_rcb_alloc(atp) struct atp_state *atp; { register struct atp_rcb *rcbp; - int s; - ATDISABLE(s, atpgen_lock); if ((rcbp = atp_rcb_free_list) != NULL) { atp_rcb_free_list = rcbp->rc_list.next; rcbp->rc_queue = atp; rcbp->rc_pktcnt = 0; rcbp->rc_local_node = 0; } - ATENABLE(s, atpgen_lock); dPrintf(D_M_ATP_LOW, D_L_TRACE, ("atp_rcb_alloc: allocated rcbp 0x%x\n", (u_int) rcbp)); return(rcbp); @@ -145,14 +142,11 @@ register struct atp_rcb *rcbp; register struct atp_state *atp; register int i; register int rc_state; - int s; dPrintf(D_M_ATP_LOW, D_L_TRACE, ("atp_rcb_free: freeing rcbp 0x%x\n", (u_int) rcbp)); - ATDISABLE(s, atpgen_lock); atp = rcbp->rc_queue; if ((rc_state = rcbp->rc_state) == -1) { - ATENABLE(s, atpgen_lock); dPrintf(D_M_ATP, D_L_WARNING, ("atp_rcb_free(%d): tid=%d,loc=%d,rem=%d\n", 0, rcbp->rc_tid, @@ -164,8 +158,6 @@ register struct atp_rcb *rcbp; rcbp->rc_queue = 0; if (rcbp->rc_timestamp) { - extern struct atp_rcb_qhead atp_need_rel; - rcbp->rc_timestamp = 0; ATP_Q_REMOVE(atp_need_rel, rcbp, rc_tlist); rcbp->rc_tlist.prev = NULL; @@ -178,6 +170,8 @@ register struct atp_rcb *rcbp; for (i=0; i < rcbp->rc_pktcnt; i++) rcbp->rc_snd[i] = 0; } + if (atp_free_cluster_list) + atp_delete_free_clusters(NULL); if (rc_state != RCB_UNQUEUED) { if (rc_state == RCB_PENDING) { ATP_Q_REMOVE(atp->atp_attached, rcbp, rc_list); @@ -191,5 +185,4 @@ register struct atp_rcb *rcbp; } rcbp->rc_list.next = atp_rcb_free_list; atp_rcb_free_list = rcbp; - ATENABLE(s, atpgen_lock); }