OpenSS7
SS7 for the
Common Man

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified:

Home Overview Status News Documentation Resources About
   
 Overview
 Status
 News
 Documentation
 Resources
 About

   
Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/drivers/sdli/cdi_mod.c


File /code/strss7/drivers/sdli/cdi_mod.c



#ident "@(#) $RCSfile: cdi_mod.c,v $ $Name:  $($Revision: 0.8.2.2 $) $Date: 2003/06/16 09:03:59 $"

static char const ident[] = "$RCSfile: cdi_mod.c,v $ $Name:  $($Revision: 0.8.2.2 $) $Date: 2003/06/16 09:03:59 $";

#include <linux/config.h>
#include <linux/version.h>
#ifdef MODVERSIONS
#include <linux/modversions.h>
#endif
#include <linux/module.h>

#include <sys/stream.h>
#include <sys/strops.h>
#include <sys/cmn_err.h>
#include <sys/dki.h>

#include <sys/cdi.h>

#include "../lock.h"
#include "../debug.h"
#include "../bufq.h"

#define CDI_DESCRIP	"CDI SIGNALLING DATA LINK (SDL) STREAMS MODULE."
#define CDI_COPYRIGHT	"Copyright (c) 1997-2002 OpenSS7 Corporation.  All Rights Reserved."
#define CDI_DEVICE	"Part of the OpenSS7 Stack for LiS STREAMS."
#define CDI_CONTACT	"Brian Bidulock <bidulock@openss7.org>"
#define CDI_LICENSE	"GPL"
#define CDI_BANNER	CDI_DESCRIP	"\n" \
			CDI_COPYRIGHT	"\n" \
			CDI_DEVICE	"\n" \
			CDI_CONTACT	"\n"

MODULE_AUTHOR(CDI_CONTACT);
MODULE_DESCRIPTION(CDI_DESCRIP);
MODULE_SUPPORTED_DEVICE(CDI_DEVICE);
#ifdef MODULE_LICENSE
MODULE_LICENSE(CDI_LICENSE);
#endif

#ifdef LINUX_2_4
#define INT int
#else
#define INT void
#endif

/* 
 *  =======================================================================
 *
 *  Private Structure allocation, deallocation and cache
 *
 *  =======================================================================
 */
STATIC kmem_cache_t *cd_cachep = NULL;
STATIC INLINE void cd_init_caches(void)
{
	if (!cd_cachep)
		if (!(cd_cachep = kmem_find_general_cachep(sizeof(cdi_t), GFP_ATOMIC)))
			if (!
			    (cd_cachep =
			     kmem_cache_create("cd_cachep", sizeof(cdi_t), 0, SLAB_HWCACHE_ALIGN,
					       NULL, NULL)))
				panic("%s: Cannot allocate cd_cache\n", __FUNCTION__);
	return;
}
STATIC INLINE void cd_term_caches(void)
{
	return;
}
extern cdi_t *cd_alloc_priv(queue_t * q)
{
	cdi_t *cd;
	if ((cd = kmem_cache_alloc(cd_cachep, SLAB_ATOMIC))) {
		MOD_INC_USE_COUNT;
		bzero(cd, sizeof(*cd));
		RD(q)->q_ptr = WR(q)->q_ptr = cd;
		cd->rq = RD(q);
		cd->wq = WR(q);
		cd->version = C_VERSION;
		cd->i_state = CS_IDLE;
		cd_init_lock(q);
	}
	return (cd);
}
extern void cd_free_priv(queue_t * q)
{
	cdi_t *cd = CD_PRIV(q);
	MOD_DEC_USE_COUNT;
	if (cd->rbid)
		unbufcall(xchg(&cd->rbid, 0));
	if (cd->wbid)
		unbufcall(xchg(&cd->wbid, 0));
	kmem_cache_free(cd_cachep, cd);
	return;
}

/* 
 *  =======================================================================
 *
 *  LiS Module Initialization
 *
 *  =======================================================================
 */
STATIC INLINE void cd_init(void)
{
	int modnum;
	unless(cd_minfo.mi_idnum, return);
	cmn_err(CE_NOTE, SDL_BANNER);	/* console splash */
	cd_init_caches();
	if (!(modnum = lis_register_strmod(&cd_info, cd_minfo.mi_idname))) {
		cd_minfo.mi_idnum = 0;
		cmn_err(CE_NOTE, "cdi-sdl: couldn't register module\n");
		return;
	}
	cd_minfo.mi_idnum = modnum;
	return;
}
STATIC INLINE void cd_terminate(void)
{
	ensure(cd_minfo.mi_idnum, return);
	if ((cd_minfo.mi_idnum = lis_unregister_strmod(&cd_info)))
		cmn_err(CE_WARN, "cdi-sdl: couldn't unregister as module\n");
	cd_term_caches();
	return;
}

/*
 *  =========================================================================
 *
 *  Linux Kernel Module Initialization
 *
 *  =========================================================================
 */

int init_module(void)
{
	cd_init();
	return (0);
}
void cleanup_module(void)
{
	cd_terminate();
	return;
}


Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/drivers/sdli/cdi_mod.c

OpenSS7
SS7 for the
Common Man
Home Overview Status News Documentation Resources About

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified: