- Turn two more storage pools into UMA zones and make the related memory

allocations and frees use the UMA api.
This commit is contained in:
arr 2002-05-23 00:34:12 +00:00
parent 17e61d99b2
commit a91cd9f63d
4 changed files with 31 additions and 30 deletions

View File

@ -124,7 +124,7 @@ ipatm_nifstat(cmd, nip, arg)
/*
* Get a new interface block
*/
inp = (struct ip_nif *)atm_allocate(&ipatm_nifpool);
inp = uma_zalloc(ipatm_nif_zone, M_WAITOK);
if (inp == NULL) {
err = ENOMEM;
break;
@ -168,7 +168,7 @@ ipatm_nifstat(cmd, nip, arg)
* Clean up and free block
*/
UNLINK(inp, struct ip_nif, ipatm_nif_head, inf_next);
atm_free((caddr_t)inp);
uma_zfree(ipatm_nif_zone, inp);
break;
case NCM_SETADDR:

View File

@ -65,6 +65,8 @@
#include <netatm/ipatm/ipatm.h>
#include <netatm/ipatm/ipatm_var.h>
#include <vm/uma.h>
#ifndef lint
__RCSID("@(#) $FreeBSD$");
#endif
@ -103,20 +105,8 @@ Atm_endpoint ipatm_endpt = {
NULL
};
struct sp_info ipatm_vcpool = {
"ipatm vcc pool", /* si_name */
sizeof(struct ipvcc), /* si_blksiz */
10, /* si_blkcnt */
100 /* si_maxallow */
};
struct sp_info ipatm_nifpool = {
"ipatm nif pool", /* si_name */
sizeof(struct ip_nif), /* si_blksiz */
5, /* si_blkcnt */
52 /* si_maxallow */
};
uma_zone_t ipatm_vc_zone;
uma_zone_t ipatm_nif_zone;
/*
* Local functions
@ -415,6 +405,18 @@ ipatm_start()
return (EINVAL);
}
ipatm_vc_zone = uma_zcreate("ipatm vc", sizeof(struct ipvcc), NULL,
NULL, NULL, NULL, UMA_ALIGN_PTR, M_ZERO|M_WAITOK);
if (ipatm_vc_zone == NULL)
panic("ipatm_start: unable to create ipatm_vc_zone");
uma_zone_set_max(ipatm_vc_zone, 100);
ipatm_nif_zone = uma_zcreate("ipatm nif", sizeof(struct ip_nif), NULL,
NULL, NULL, NULL, UMA_ALIGN_PTR, M_ZERO|M_WAITOK);
if (ipatm_nif_zone == NULL)
panic("ipatm_start: unable to create ipatm_nif_zone");
uma_zone_set_max(ipatm_nif_zone, 52);
/*
* Register ourselves as a network convergence module
*/
@ -602,9 +604,8 @@ ipatm_stop()
/*
* Free up our storage pools
*/
atm_release_pool(&ipatm_vcpool);
atm_release_pool(&ipatm_nifpool);
uma_zdestroy(ipatm_vc_zone);
uma_zdestroy(ipatm_nif_zone);
done:
(void) splx(s);
return (err);

View File

@ -200,8 +200,8 @@ extern int ipatm_print;
extern u_long last_map_ipdst;
extern struct ipvcc *last_map_ipvcc;
extern struct ip_nif *ipatm_nif_head;
extern struct sp_info ipatm_vcpool;
extern struct sp_info ipatm_nifpool;
extern uma_zone_t ipatm_vc_zone;
extern uma_zone_t ipatm_nif_zone;
extern struct ipatm_stat ipatm_stat;
extern struct atm_time ipatm_itimer;
extern Atm_endpoint ipatm_endpt;

View File

@ -382,7 +382,7 @@ ipatm_openpvc(pvp, sivp)
/*
* Allocate IP VCC block
*/
ivp = (struct ipvcc *)atm_allocate(&ipatm_vcpool);
ivp = uma_zalloc(ipatm_vc_zone, M_WAITOK);
if (ivp == NULL) {
err = ENOMEM;
goto done;
@ -423,7 +423,7 @@ ipatm_openpvc(pvp, sivp)
*/
err = atm_cm_connect(&ipatm_endpt, ivp, ap, &ivp->iv_conn);
if (err) {
atm_free((caddr_t)ivp);
uma_zfree(ipatm_vc_zone, ivp);
goto done;
}
@ -585,7 +585,7 @@ ipatm_createsvc(ifp, daf, dst, sivp)
/*
* Allocate IP VCC
*/
ivp = (struct ipvcc *)atm_allocate(&ipatm_vcpool);
ivp = uma_zalloc(ipatm_vc_zone, M_WAITOK);
if (ivp == NULL) {
err = ENOMEM;
goto done;
@ -624,7 +624,7 @@ ipatm_createsvc(ifp, daf, dst, sivp)
err = ipatm_opensvc(ivp);
if (err) {
(*inp->inf_serv->is_arp_close)(ivp);
atm_free((caddr_t)ivp);
uma_zfree(ipatm_vc_zone, ivp);
goto done;
}
break;
@ -633,7 +633,7 @@ ipatm_createsvc(ifp, daf, dst, sivp)
/*
* So sorry...come again
*/
atm_free((caddr_t)ivp);
uma_zfree(ipatm_vc_zone, ivp);
err = ENETDOWN;
goto done;
@ -655,7 +655,7 @@ ipatm_createsvc(ifp, daf, dst, sivp)
ivp->iv_arpent = &map;
err = ipatm_opensvc(ivp);
if (err) {
atm_free((caddr_t)ivp);
uma_zfree(ipatm_vc_zone, ivp);
goto done;
}
ivp->iv_arpent = NULL;
@ -937,7 +937,7 @@ ipatm_incoming(tok, cop, ap, tokp)
/*
* Allocate IP VCC
*/
ivp = (struct ipvcc *)atm_allocate(&ipatm_vcpool);
ivp = uma_zalloc(ipatm_vc_zone, M_WAITOK);
if (ivp == NULL) {
err = ENOMEM;
cause = T_ATM_CAUSE_UNSPECIFIED_RESOURCE_UNAVAILABLE;
@ -1015,7 +1015,7 @@ ipatm_incoming(tok, cop, ap, tokp)
*/
if (ivp) {
(*inp->inf_serv->is_arp_close)(ivp);
atm_free((caddr_t)ivp);
uma_zfree(ipatm_vc_zone, ivp);
}
ap->cause.tag = T_ATM_PRESENT;
ap->cause.v = ipatm_cause;
@ -1128,7 +1128,7 @@ ipatm_closevc(ivp, code)
* If ARP module is done with VCC too, then free it
*/
if (ivp->iv_arpconn == NULL)
atm_free((caddr_t)ivp);
uma_zfree(ipatm_vc_zone, ivp);
ipatm_vccnt--;
(void) splx(s);