- Turn the hea and hfa HARP storage pools into UMA zones and insert

the necesary uma_zcreate() and uma_zdestroy calls into module loading
  handler and the device attach handling.
- Change the related HARP netatm code to use UMA zone functions when
  dealing with the zones that were formerly the ATM interface (hea, hfa)
  storage pools.
- Have atm_physif_freenifs() now get passed an uma_zone_t so that we can
  properly free the allocated NIF's back to their zone.

This should be the last commit to remove any code that makes use of the
netatm storage pool api.  I will be removing the api code within the near
future.

Reviewed by:	mdodd
This commit is contained in:
Andrew R. Reiter 2002-06-14 16:59:38 +00:00
parent dc20d4b9d4
commit b6037a7953
14 changed files with 77 additions and 63 deletions

View File

@ -415,8 +415,8 @@ eni_pci_attach ( pcici_t config_id, int unit )
eup->eu_openvcc = eni_openvcc;
eup->eu_closevcc = eni_closevcc;
eup->eu_output = eni_output;
eup->eu_vcc_pool = &eni_vcc_pool;
eup->eu_nif_pool = &eni_nif_pool;
eup->eu_vcc_zone = eni_vcc_zone;
eup->eu_nif_zone = eni_nif_zone;
/*
* Enable Memory Mapping / Bus Mastering

View File

@ -491,8 +491,8 @@ typedef struct eni_unit Eni_unit;
#define eu_mtu eu_cmn.cu_mtu
#define eu_open_vcc eu_cmn.cu_open_vcc
#define eu_vcc eu_cmn.cu_vcc
#define eu_vcc_pool eu_cmn.cu_vcc_pool
#define eu_nif_pool eu_cmn.cu_nif_pool
#define eu_vcc_zone eu_cmn.cu_vcc_zone
#define eu_nif_zone eu_cmn.cu_nif_zone
#define eu_ioctl eu_cmn.cu_ioctl
#define eu_instvcc eu_cmn.cu_instvcc
#define eu_openvcc eu_cmn.cu_openvcc

View File

@ -53,6 +53,8 @@
#include <dev/hea/eni_stats.h>
#include <dev/hea/eni.h>
#include <vm/uma.h>
#ifndef lint
__RCSID("@(#) $FreeBSD$");
#endif
@ -98,17 +100,5 @@ struct stack_defn *eni_services = &eni_svaal0;
/*
* Storage pools
*/
struct sp_info eni_nif_pool = {
"eni nif pool", /* si_name */
sizeof(struct atm_nif), /* si_blksiz */
5, /* si_blkcnt */
52 /* si_maxallow */
};
struct sp_info eni_vcc_pool = {
"eni vcc pool", /* si_name */
sizeof(Eni_vcc), /* si_blksiz */
10, /* si_blkcnt */
100 /* si_maxallow */
};
uma_zone_t eni_nif_zone;
uma_zone_t eni_vcc_zone;

View File

@ -79,7 +79,7 @@ int eni_closevcc(Cmn_unit *, Cmn_vcc *);
*/
extern Eni_unit *eni_units[];
extern struct stack_defn *eni_services;
extern struct sp_info eni_nif_pool;
extern struct sp_info eni_vcc_pool;
extern uma_zone_t eni_nif_zone;
extern uma_zone_t eni_vcc_zone;
#endif /* _ENI_ENI_VAR_H */

View File

@ -158,13 +158,25 @@ hea_attach (device_t dev)
eup = &sc->eup;
error = 0;
eni_vcc_zone = uma_zcreate("eni vcc", sizeof(Eni_vcc), NULL,
NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
if (eni_vcc_zone == NULL)
panic("hea_attach: uma_zcreate vcc");
uma_zone_set_max(eni_vcc_zone, 100);
eni_nif_zone = uma_zcreate("eni nif", sizeof(struct atm_nif), NULL,
NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
if (eni_nif_zone == NULL)
panic("hea_attach: uma_zcreate nif");
uma_zone_set_max(eni_nif_zone, 52);
/*
* Start initializing it
*/
eup->eu_unit = device_get_unit(dev);
eup->eu_mtu = ENI_IFF_MTU;
eup->eu_vcc_pool = &eni_vcc_pool;
eup->eu_nif_pool = &eni_nif_pool;
eup->eu_vcc_zone = eni_vcc_zone;
eup->eu_nif_zone = eni_nif_zone;
eup->eu_ioctl = eni_atm_ioctl;
eup->eu_instvcc = eni_instvcc;
eup->eu_openvcc = eni_openvcc;
@ -329,6 +341,9 @@ hea_detach (device_t dev)
hea_free(dev);
uma_zdestroy(eni_vcc_zone);
uma_zdestroy(eni_nif_zone);
return (error);
}

View File

@ -57,6 +57,8 @@
#include <dev/hfa/fore_stats.h>
#include <dev/hfa/fore_var.h>
#include <vm/uma.h>
#ifndef lint
__RCSID("@(#) $FreeBSD$");
#endif
@ -104,20 +106,8 @@ struct stack_defn *fore_services = &fore_svaal0;
/*
* Storage pools
*/
struct sp_info fore_nif_pool = {
"fore nif pool", /* si_name */
sizeof(struct atm_nif), /* si_blksiz */
5, /* si_blkcnt */
52 /* si_maxallow */
};
struct sp_info fore_vcc_pool = {
"fore vcc pool", /* si_name */
sizeof(Fore_vcc), /* si_blksiz */
10, /* si_blkcnt */
100 /* si_maxallow */
};
uma_zone_t fore_nif_zone;
uma_zone_t fore_vcc_zone;
/*
* Watchdog timer

View File

@ -101,8 +101,8 @@ extern Fore_device fore_devices[];
extern Fore_unit *fore_units[];
extern int fore_nunits;
extern struct stack_defn *fore_services;
extern struct sp_info fore_nif_pool;
extern struct sp_info fore_vcc_pool;
extern uma_zone_t fore_nif_zone;
extern uma_zone_t fore_vcc_zone;
extern struct atm_time fore_timer;
#endif /* _FORE_INCLUDE_H */

View File

@ -225,8 +225,8 @@ fore_pci_attach(config_id, unit)
fup->fu_unit = unit;
fup->fu_mtu = FORE_IFF_MTU;
fup->fu_pcitag = config_id;
fup->fu_vcc_pool = &fore_vcc_pool;
fup->fu_nif_pool = &fore_nif_pool;
fup->fu_vcc_zone = fore_vcc_zone;
fup->fu_nif_zone = &fore_nif_zone;
fup->fu_ioctl = fore_atm_ioctl;
fup->fu_instvcc = fore_instvcc;
fup->fu_openvcc = fore_openvcc;

View File

@ -237,8 +237,8 @@ typedef struct fore_unit Fore_unit;
#define fu_vcc fu_cmn.cu_vcc
#define fu_intrpri fu_cmn.cu_intrpri
#define fu_savepri fu_cmn.cu_savepri
#define fu_vcc_pool fu_cmn.cu_vcc_pool
#define fu_nif_pool fu_cmn.cu_nif_pool
#define fu_vcc_zone fu_cmn.cu_vcc_zone
#define fu_nif_zone fu_cmn.cu_nif_zone
#define fu_ioctl fu_cmn.cu_ioctl
#define fu_instvcc fu_cmn.cu_instvcc
#define fu_openvcc fu_cmn.cu_openvcc

View File

@ -169,8 +169,8 @@ hfa_attach (device_t dev)
*/
fup->fu_unit = device_get_unit(dev);
fup->fu_mtu = FORE_IFF_MTU;
fup->fu_vcc_pool = &fore_vcc_pool;
fup->fu_nif_pool = &fore_nif_pool;
fup->fu_vcc_zone = fore_vcc_zone;
fup->fu_nif_zone = fore_nif_zone;
fup->fu_ioctl = fore_atm_ioctl;
fup->fu_instvcc = fore_instvcc;
fup->fu_openvcc = fore_openvcc;
@ -377,6 +377,19 @@ hfa_modevent (module_t mod, int what, void *arg)
error = EINVAL;
break;
}
fore_nif_zone = uma_zcreate("fore nif", sizeof(struct atm_nif), NULL,
NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
if (fore_nif_zone == NULL)
panic("hfa_modevent:uma_zcreate nif");
uma_zone_set_max(fore_nif_zone, 52);
fore_vcc_zone = uma_zcreate("fore vcc", sizeof(Fore_vcc), NULL,
NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
if (fore_vcc_zone == NULL)
panic("hfa_modevent: uma_zcreate vcc");
uma_zone_set_max(fore_vcc_zone, 100);
/*
* Initialize DMA mapping
*/
@ -399,6 +412,9 @@ hfa_modevent (module_t mod, int what, void *arg)
*/
atm_untimeout(&fore_timer);
uma_zdestroy(fore_nif_zone);
uma_zdestroy(fore_vcc_zone);
break;
default:
break;

View File

@ -170,7 +170,8 @@ atm_dev_inst(ssp, cvcp)
/*
* Allocate a VCC control block
*/
if ( ( cvp = (Cmn_vcc *)atm_allocate(cup->cu_vcc_pool) ) == NULL )
cvp = uma_zalloc(cup->cu_vcc_zone, M_WAITOK);
if (cvp == NULL)
return (ENOMEM);
cvp->cv_state = CVS_INST;
@ -183,7 +184,7 @@ atm_dev_inst(ssp, cvcp)
*/
err = (*cup->cu_instvcc)(cup, cvp);
if (err) {
atm_free((caddr_t)cvp);
uma_zfree(cup->cu_vcc_zone, cvp);
return (err);
}
@ -351,7 +352,7 @@ atm_dev_lower(cmd, tok, arg1, arg2)
/*
* Free VCC resources
*/
(void) atm_free((caddr_t)cvp);
uma_zfree(cup->cu_vcc_zone, cvp);
break;
}

View File

@ -214,14 +214,14 @@ atm_physif_deregister(cup)
/*
* Free all of our network interfaces
*/
atm_physif_freenifs(pip);
atm_physif_freenifs(pip, cup->cu_nif_zone);
/*
* Free unit's vcc information
*/
cvp = cup->cu_vcc;
while (cvp) {
atm_free(cvp);
uma_zfree(cup->cu_vcc_zone, cvp);
cvp = cvp->cv_next;
}
cup->cu_vcc = (Cmn_vcc *)NULL;
@ -243,8 +243,9 @@ atm_physif_deregister(cup)
*
*/
void
atm_physif_freenifs(pip)
atm_physif_freenifs(pip, zone)
struct atm_pif *pip;
uma_zone_t zone;
{
struct atm_nif *nip = pip->pif_nif;
int s = splnet();
@ -261,7 +262,7 @@ atm_physif_freenifs(pip)
* Clean up network i/f trails
*/
atm_nif_detach(nip);
atm_free ((caddr_t)nip);
uma_zfree(zone, nip);
nip = nipp;
}
pip->pif_nif = (struct atm_nif *)NULL;
@ -271,7 +272,6 @@ atm_physif_freenifs(pip)
return;
}
/*
* Handle physical interface ioctl's
*
@ -488,20 +488,20 @@ atm_physif_ioctl(code, data, arg)
/*
* Free any previously allocated NIFs
*/
atm_physif_freenifs(pip);
atm_physif_freenifs(pip, cup->cu_nif_zone);
/*
* Add list of interfaces
*/
for ( count = 0; count < asr->asr_nif_cnt; count++ )
{
nip = (struct atm_nif *)atm_allocate(cup->cu_nif_pool);
nip = uma_zalloc(cup->cu_nif_zone, M_WAITOK | M_ZERO);
if ( nip == NULL )
{
/*
* Destroy any successful nifs
*/
atm_physif_freenifs(pip);
atm_physif_freenifs(pip, cup->cu_nif_zone);
err = ENOMEM;
break;
}
@ -540,12 +540,11 @@ atm_physif_ioctl(code, data, arg)
break;
}
if ((err = atm_nif_attach(nip)) != 0) {
atm_free ( (caddr_t)nip );
uma_zfree(cup->cu_nif_zone, nip);
/*
* Destroy any successful nifs
*/
atm_physif_freenifs(pip);
atm_physif_freenifs(pip, cup->cu_nif_zone);
break;
}
/*

View File

@ -148,6 +148,9 @@ typedef struct atm_config Atm_config;
#ifdef _KERNEL
#include <vm/uma.h>
/*
* Common structure used to define each physical ATM device interface.
* This structure will (normally) be embedded at the top of each driver's
@ -261,8 +264,8 @@ struct cmn_unit {
u_int cu_intrpri; /* Highest unit interrupt priority */
int cu_savepri; /* Saved priority for locking device */
struct sp_info *cu_vcc_pool; /* Device VCC pool */
struct sp_info *cu_nif_pool; /* Device NIF pool */
uma_zone_t cu_vcc_zone; /* Device VCC zone */
uma_zone_t cu_nif_zone; /* Device NIF zone */
int (*cu_ioctl) /* Interface ioctl handler */
(int, caddr_t, caddr_t);

View File

@ -117,7 +117,7 @@ void atm_dev_pdu_print(Cmn_unit *, Cmn_vcc *, KBuffer *, char *);
int atm_physif_register(Cmn_unit *, char *,
struct stack_defn *);
int atm_physif_deregister(Cmn_unit *);
void atm_physif_freenifs(struct atm_pif *);
void atm_physif_freenifs(struct atm_pif *, uma_zone_t);
int atm_netconv_register(struct atm_ncm *);
int atm_netconv_deregister(struct atm_ncm *);
int atm_nif_attach(struct atm_nif *);