⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x400p-ss7.c

📁 OpenSS7 This the fourth public release of the OpenSS7 Master Package. See README in the release for
💻 C
📖 第 1 页 / 共 5 页
字号:
/***************************************************************************** @(#) x400p-ss7.c,v openss7-0_9_2_E(0.9.2.22) 2006/12/06 11:45:24 ----------------------------------------------------------------------------- Copyright (c) 2001-2006  OpenSS7 Corporation <http://www.openss7.com/> Copyright (c) 1997-2000  Brian F. G. Bidulock <bidulock@openss7.org> All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ----------------------------------------------------------------------------- U.S. GOVERNMENT RESTRICTED RIGHTS.  If you are licensing this Software on behalf of the U.S. Government ("Government"), the following provisions apply to you.  If the Software is supplied by the Department of Defense ("DoD"), it is classified as "Commercial Computer Software" under paragraph 252.227-7014 of the DoD Supplement to the Federal Acquisition Regulations ("DFARS") (or any successor regulations) and the Government is acquiring only the license rights granted herein (the license rights customarily provided to non-Government users).  If the Software is supplied to any unit or agency of the Government other than DoD, it is classified as "Restricted Computer Software" and the Government's rights in the Software are defined in paragraph 52.227-19 of the Federal Acquisition Regulations ("FAR") (or any successor regulations) or, in the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR (or any successor regulations). ----------------------------------------------------------------------------- Commercial licensing and support of this software is available from OpenSS7 Corporation at a fee.  See http://www.openss7.com/ ----------------------------------------------------------------------------- Last Modified 2006/12/06 11:45:24 by brian ----------------------------------------------------------------------------- x400p-ss7.c,v Revision 0.9.2.22  2006/12/06 11:45:24  brian - updated X400P driver and test suites Revision 0.9.2.21  2006/06/05 02:53:32  brian - working up udp zero-copy Revision 0.9.2.20  2006/04/24 05:01:03  brian - call interface corrections Revision 0.9.2.19  2006/03/04 13:00:31  brian - FC4 x86_64 gcc 4.0.4 2.6.15 changes *****************************************************************************/#ident "@(#) x400p-ss7.c,v openss7-0_9_2_E(0.9.2.22) 2006/12/06 11:45:24"static char const ident[] =    "x400p-ss7.c,v openss7-0_9_2_E(0.9.2.22) 2006/12/06 11:45:24";/* *  This is an SL (Signalling Link) kernel module which provides all of the *  capabilities of the SLI for the E400P-SS7 and T400P-SS7 cards.  This is a *  complete SS7 MTP Level 2 OpenSS7 implementation. */#define X400P_DOWNLOAD_FIRMWARE#include <sys/os7/compat.h>#ifdef LINUX#include <linux/ioport.h>#include <asm/io.h>#include <asm/dma.h>#include <linux/pci.h>#include <linux/interrupt.h>#endif				/* LINUX */#include <ss7/lmi.h>#include <ss7/lmi_ioctl.h>#include <ss7/sdli.h>#include <ss7/sdli_ioctl.h>#include <ss7/sdti.h>#include <ss7/sdti_ioctl.h>#include <ss7/sli.h>#include <ss7/sli_ioctl.h>#include <ss7/chi.h>#include <ss7/chi_ioctl.h>#include <ss7/mxi.h>#include <ss7/mxi_ioctl.h>#ifdef X400P_DOWNLOAD_FIRMWARE#include "x400pfw.h"		/* X400P-SS7 firmware load */#endif#define X400P_DESCRIP		"E/T400P-SS7: SS7/SL (Signalling Link) STREAMS DRIVER."#define X400P_EXTRA		"Part of the OpenSS7 Stack for Linux Fast-STREAMS."#define X400P_REVISION		"OpenSS7 x400p-ss7.c,v openss7-0_9_2_E (0.9.2.22) 2006/12/06 11:45:24"#define X400P_COPYRIGHT		"Copyright (c) 1997-2006 OpenSS7 Corporation.  All Rights Reserved."#define X400P_DEVICE		"Supports the T/E400P-SS7 T1/E1 PCI boards."#define X400P_CONTACT		"Brian Bidulock <bidulock@openss7.org>"#define X400P_LICENSE		"GPL"#define X400P_BANNER		X400P_DESCRIP		"\n" \				X400P_EXTRA		"\n" \				X400P_REVISION		"\n" \				X400P_COPYRIGHT		"\n" \				X400P_DEVICE		"\n" \				X400P_CONTACT#define X400P_SPLASH		X400P_DESCRIP		" - " \				X400P_REVISION#ifdef LINUXMODULE_AUTHOR(X400P_CONTACT);MODULE_DESCRIPTION(X400P_DESCRIP);MODULE_SUPPORTED_DEVICE(X400P_DEVICE);#ifdef MODULE_LICENSEMODULE_LICENSE(X400P_LICENSE);#endif				/* MODULE_LICENSE */#if defined MODULE_ALIASMODULE_ALIAS("streams-x400p-ss7");#endif#endif				/* LINUX */#ifdef LFS#define X400P_DRV_ID		CONFIG_STREAMS_X400P_MODID#define X400P_DRV_NAME		CONFIG_STREAMS_X400P_NAME#define X400P_CMAJORS		CONFIG_STREAMS_X400P_NMAJORS#define X400P_CMAJOR_0		CONFIG_STREAMS_X400P_MAJOR#define X400P_UNITS		CONFIG_STREAMS_X400P_NMINORS#endif#define X400P_CMINOR_SDLI	1#define X400P_CMINOR_CHI	2#define X400P_CMINOR_MXI	3#define X400P_CMINOR_LMI	4#define X400P_CMINOR_FREE	5/* *  ======================================================================= * *  STREAMS Definitions * *  ======================================================================= */#define DRV_ID		X400P_DRV_ID#define DRV_NAME	X400P_DRV_NAME#define CMAJORS		X400P_CMAJORS#define CMAJOR_0	X400P_CMAJOR_0#define UNITS		X400P_UNITS#ifdef MODULE#define DRV_BANNER	X400P_BANNER#else				/* MODULE */#define DRV_BANNER	X400P_SPLASH#endif				/* MODULE */STATIC struct module_info xp_minfo = {	.mi_idnum = DRV_ID,		/* Module ID number */	.mi_idname = DRV_NAME,		/* Module name */	.mi_minpsz = 1,			/* Min packet size accepted */	.mi_maxpsz = INFPSZ,		/* Max packet size accepted */	.mi_hiwat = 1024,		/* Hi water mark */	.mi_lowat = 0			/* Lo water mark */};STATIC struct module_stat xp_mstat = { 0, };STATIC streamscall int xp_open(queue_t *, dev_t *, int, int, cred_t *);STATIC streamscall int xp_close(queue_t *, int, cred_t *);STATIC struct qinit xp_rinit = {	.qi_putp = ss7_oput,		/* Read put (message from below) */	.qi_srvp = ss7_osrv,		/* Read queue service */	.qi_qopen = xp_open,		/* Each open */	.qi_qclose = xp_close,		/* Last close */	.qi_minfo = &xp_minfo,		/* Information */	.qi_mstat = &xp_mstat,		/* Statistics */};STATIC struct qinit xp_winit = {	.qi_putp = ss7_iput,		/* Write put (message from above) */	.qi_srvp = ss7_isrv,		/* Write queue service */	.qi_minfo = &xp_minfo,		/* Information */	.qi_mstat = &xp_mstat,		/* Statistics */};STATIC struct streamtab x400pinfo = {	.st_rdinit = &xp_rinit,		/* Upper read queue */	.st_wrinit = &xp_winit,		/* Upper write queue */};/* *  ======================================================================== * *  Private structure * *  ======================================================================== */struct xp;struct sp;struct cd;typedef struct xp {	STR_DECLARATION (struct xp);	/* stream declaration */	struct sp *sp;			/* span for this channel */	int chan;			/* index (chan) */	union {		struct {			sdl_timers_t timers;			sdl_statem_t statem;			sdl_notify_t notify;			sdl_config_t config;			sdl_stats_t stats;			sdl_stats_t statsp;		} sdl;		struct {			ch_statem_t statem;			ch_notify_t notify;			ch_config_t config;			ch_stats_t stats;			ch_stats_t statsp;		} ch;		struct {			mx_statem_t statem;			mx_notify_t notify;			mx_config_t config;			mx_stats_t stats;			mx_stats_t statsp;		} mx;	} obj;} xp_t;#define XP_PRIV(__q) ((struct xp *)(__q)->q_ptr)STATIC struct xp *xp_alloc_priv(queue_t *, struct xp **, dev_t *, cred_t *, minor_t);STATIC void xp_free_priv(struct xp *);STATIC struct xp *xp_get(struct xp *);STATIC void xp_put(struct xp *);typedef struct xp_path {	mblk_t *msg;			/* message */	mblk_t *nxt;			/* message chain block */	bufq_t buf;			/* buffer */} xp_path_t;typedef struct ts {	HEAD_DECLARATION (struct ts);	/* head declaration */	struct xp *xp;			/* interface for this slot */	struct sp *sp;			/* span for this slot */	int slot;			/* 32-bit backplane slot */	struct xp_path rx;		/* tx path */	struct xp_path tx;		/* rx path */	sdl_config_t config;		/* slot configuration */} ts_t;STATIC struct ts *xp_alloc_ts(struct xp *, struct sp *, uint8_t);STATIC void xp_free_ts(struct ts *);STATIC struct ts *ts_get(struct ts *);STATIC void ts_put(struct ts *);typedef struct sp {	HEAD_DECLARATION (struct sp);	/* head declaration */	struct xp *xp;			/* interface for this span */	struct cd *cd;			/* card for this span */	struct ts *slots[32];		/* timeslot structures */	ulong recovertime;		/* alarm recover time */	ulong iobase;			/* span iobase */	int span;			/* index (span) */	volatile ulong loopcnt;		/* loop command count */	sdl_config_t config;		/* span configuration */} sp_t;STATIC struct sp *xp_alloc_sp(struct cd *, uint8_t);STATIC void xp_free_sp(struct sp *);STATIC struct sp *sp_get(struct sp *);STATIC void sp_put(struct sp *);typedef struct cd {	HEAD_DECLARATION (struct cd);	/* head declaration */	ulong xll_region;		/* Xilinx 32-bit memory region */	ulong xll_length;		/* Xilinx 32-bit memory length */	volatile uint32_t *xll;		/* Xilinx 32-bit memory map */	ulong xlb_region;		/* Xilinx 8-bit memory region */	ulong xlb_length;		/* Xilinx 8-bit memory lenght */	volatile uint8_t *xlb;		/* Xilinx 8-bit memory map */	ulong plx_region;		/* PLX 9030 memory region */	ulong plx_length;		/* PLX 9030 memory length */	volatile uint16_t *plx;		/* PLX 9030 memory map */	uint frame;			/* frame number */	struct sp *spans[4];		/* structures for spans */	uint32_t *wbuf;			/* wr buffer */	uint32_t *rbuf;			/* rd buffer */	volatile int uebno;		/* upper elastic buffer number */	volatile int lebno;		/* lower elastic buffer number */	volatile int eval_syncsrc;	/* need to reevaluate sync src */	volatile int leds;		/* leds on the card */	int card;			/* index (card) */	ulong irq;			/* card irq */	ulong iobase;			/* card iobase */	struct tasklet_struct tasklet;	/* card tasklet */	sdl_config_t config;		/* card configuration */} cd_t;STATIC struct cd *xp_alloc_cd(void);STATIC void xp_free_cd(struct cd *);STATIC struct cd *cd_get(struct cd *);STATIC void cd_put(struct cd *);STATIC struct ss7_bufpool xp_bufpool = { 0, };/* *  ------------------------------------------------------------------------ * *  Card Structures and Macros * *  ------------------------------------------------------------------------ */static const char *xp_t1_framer[] = {	"DS2152",	"DS21352",	"DS21552",	"DS21752",};static const char *xp_e1_framer[] = {	"DS2154",	"DS21354",	"DS21554",	"DS21754",};#ifdef X400P_DOWNLOAD_FIRMWARE#define GPIOC		(0x54 >> 1)	/* GPIO control register */#define GPIO_WRITE	0x4000	/* GPIO4 data */#define GPIO_PROGRAM	0x20000	/* GPIO5 data */#define GPIO_INIT	0x100000	/* GPIO6 data */#define GPIO_DONE	0x800000	/* GPIO7 data */#endif#define INTCSR (0x4c >> 1)#define PLX_INTENA 0x43#define SYNREG	0x400#define CTLREG	0x401#define LEDREG	0x402#define STAREG	0x400#define RIR2	0x31#define LOOPUP	0x80#define LOOPDN	0x40#define INTENA	0x01#define OUTBIT	0x02#define E1DIV	0x10#define INTACK	0x80#define INTACTIVE 2#define SYNCSELF 0#define SYNC1 1#define SYNC2 2#define SYNC3 3#define SYNC4 4#define LEDBLK 0#define LEDGRN 1#define LEDRED 2#define LEDYEL 3#define X400_ABIT 8#define X400_BBIT 4#define X400_SPANS 4		/* 4 spans per card */#define X400P_SDL_ALARM_SETTLE_TIME	    5000	/* allow alarms to settle for 5 seconds *//* *  Mapping of channels 0-23 for T1, 1-31 for E1 into PCM highway timeslots. */STATIC int xp_t1_chan_map[] = {	1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15,	17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 31};STATIC int xp_e1_chan_map[] = {	1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,	17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};#define X400P_T1_CHAN_DESCRIPTOR 0xEEEEEEEE#define X400P_E1_CHAN_DESCRIPTOR 0xFFFFFFFE#ifdef __LITTLE_ENDIAN#define span_to_byte(__span) (3-(__span))#else#ifdef __BIG_ENDIAN#define span_to_byte(__span) (__span)#else#error "Must know the endianess of processor\n"#endif#endiftypedef enum {	PLX9030 = 0,	PLXDEVBRD,	X400P,	X400PSS7,} xp_board_t;/* indexed by xp_board_t above *//* *INDENT-OFF* */static struct {	char *name;	u32 hw_flags;} xp_board_info[] __devinitdata = {	{ "PLX 9030", 0 },	{ "PLX Development Board", 0 },	{ "X400P", 1 },	{ "X400P-SS7", 1 },};/* *INDENT-ON* */STATIC struct pci_device_id xp_pci_tbl[] __devinitdata = {	{PCI_VENDOR_ID_PLX, 0x9030, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PLX9030},	{PCI_VENDOR_ID_PLX, 0x3001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PLXDEVBRD},	{PCI_VENDOR_ID_PLX, 0xD00D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, X400P},	{PCI_VENDOR_ID_PLX, 0x0557, PCI_ANY_ID, PCI_ANY_ID, 0, 0, X400PSS7},	{0,}};STATIC int __devinit xp_probe(struct pci_dev *, const struct pci_device_id *);STATIC void __devexit xp_remove(struct pci_dev *);#ifdef CONFIG_PM#ifndef HAVE_KTYPE_PM_MESSAGE_Ttypedef u32 pm_message_t;#endifSTATIC int xp_suspend(struct pci_dev *pdev, pm_message_t state);STATIC int xp_resume(struct pci_dev *pdev);#endifSTATIC struct pci_driver xp_driver = {	name:DRV_NAME,	id_table:xp_pci_tbl,	probe:xp_probe,	remove:__devexit_p(xp_remove),#ifdef CONFIG_PM	suspend:xp_suspend,	resume:xp_resume,#endif#if 0	enable_wake:xp_wake,	shutdown:xp_shutdown,#endif};STATIC int x400p_boards = 0;STATIC struct cd *x400p_cards;#define X400P_EBUFNO (1<<7)	/* 128k elastic buffers *//* *  ======================================================================== * *  PRIMITIVES Sent Upstream * *  ======================================================================== *//* *  M_ERROR *  ----------------------------------- */STATIC intm_error(queue_t *q, struct xp *xp, int err){	mblk_t *mp;	if ((mp = ss7_allocb(q, 2, BPRI_MED))) {		mp->b_datap->db_type = M_ERROR;		*(mp->b_wptr)++ = err < 0 ? -err : err;		*(mp->b_wptr)++ = err < 0 ? -err : err;		ss7_oput(xp->oq, mp);		return (QR_DONE);	}	rare();	return (-ENOBUFS);}/* *  SDL_RECEIVED_BITS_IND *  ----------------------------------- *  Quickly we just copy the buffer and leave the original for the lower level *  driver. */STATIC INLINE intsdl_received_bits_ind(queue_t *q, struct xp *xp, mblk_t *dp){	if (canputnext(xp->oq)) {		ss7_oput(xp->oq, dp);		return (QR_ABSORBED);	}	rare();	dp->b_wptr = dp->b_rptr;	/* discard contents */	return (-EBUSY);}#if 0/* *  SDL_DISCONNECT_IND *  ----------------------------------- */STATIC INLINE intsdl_disconnect_ind(queue_t *q, struct xp *xp){	mblk_t *mp;	sdl_disconnect_ind_t *p;	(void) xp;	if ((mp = allocb(sizeof(*p), BPRI_MED))) {		mp->b_datap->db_type = M_PCPROTO;		p = (typeof(p)) mp->b_wptr;		mp->b_wptr += sizeof(*p);		p->sdl_primitive = SDL_DISCONNECT_IND;		ss7_oput(xp->oq, mp);		return (QR_DONE);	}	rare();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -