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

📄 fplustm.c

📁 h内核
💻 C
📖 第 1 页 / 共 3 页
字号:
		/*		 * no actions necessary, TREQ is already set		 */		break ;	}}int sm_mac_get_tx_state(struct s_smc *smc){	return((inpw(FM_A(FM_STMCHN))>>4)&7) ;}/* * multicast functions */static struct s_fpmc* mac_get_mc_table(struct s_smc *smc,				       struct fddi_addr *user,				       struct fddi_addr *own,				       int del, int can){	struct s_fpmc	*tb ;	struct s_fpmc	*slot ;	u_char	*p ;	int i ;	/*	 * set own = can(user)	 */	*own = *user ;	if (can) {		p = own->a ;		for (i = 0 ; i < 6 ; i++, p++)			*p = canonical[*p] ;	}	slot = NULL;	for (i = 0, tb = smc->hw.fp.mc.table ; i < FPMAX_MULTICAST ; i++, tb++){		if (!tb->n) {		/* not used */			if (!del && !slot)	/* if !del save first free */				slot = tb ;			continue ;		}		if (memcmp((char *)&tb->a,(char *)own,6))			continue ;		return(tb) ;	}	return(slot) ;			/* return first free or NULL */}/*	BEGIN_MANUAL_ENTRY(if,func;others;2)	void mac_clear_multicast(smc)	struct s_smc *smc ;Function	DOWNCALL	(SMT, fplustm.c)		Clear all multicast entries	END_MANUAL_ENTRY() */void mac_clear_multicast(struct s_smc *smc){	struct s_fpmc	*tb ;	int i ;	smc->hw.fp.os_slots_used = 0 ;	/* note the SMT addresses */					/* will not be deleted */	for (i = 0, tb = smc->hw.fp.mc.table ; i < FPMAX_MULTICAST ; i++, tb++){		if (!tb->perm) {			tb->n = 0 ;		}	}}/*	BEGIN_MANUAL_ENTRY(if,func;others;2)	int mac_set_func_addr(smc,f_addr)	struct s_smc *smc ;	u_long f_addr ;Function	DOWNCALL	(SMT, fplustm.c)		Set a Token-Ring functional address, the address will		be activated after calling mac_update_multicast()Para	f_addr	functional bits in non-canonical formatReturns	0: always success	END_MANUAL_ENTRY() */int mac_set_func_addr(struct s_smc *smc, u_long f_addr){	smc->hw.fp.func_addr = f_addr ;	return(0) ;}/*	BEGIN_MANUAL_ENTRY(if,func;others;2)	int mac_add_multicast(smc,addr,can)	struct s_smc *smc ;	struct fddi_addr *addr ;	int can ;Function	DOWNCALL	(SMC, fplustm.c)		Add an entry to the multicast tablePara	addr	pointer to a multicast address	can	= 0:	the multicast address has the physical format		= 1:	the multicast address has the canonical format		| 0x80	permanentReturns	0: success	1: address table fullNote	After a 'driver reset' or a 'station set address' all	entries of the multicast table are cleared.	In this case the driver has to fill the multicast table again.	After the operating system dependent module filled	the multicast table it must call mac_update_multicast	to activate the new multicast addresses!	END_MANUAL_ENTRY() */int mac_add_multicast(struct s_smc *smc, struct fddi_addr *addr, int can){	SK_LOC_DECL(struct fddi_addr,own) ;	struct s_fpmc	*tb ;	/*	 * check if there are free table entries	 */	if (can & 0x80) {		if (smc->hw.fp.smt_slots_used >= SMT_MAX_MULTI) {			return(1) ;		}	}	else {		if (smc->hw.fp.os_slots_used >= FPMAX_MULTICAST-SMT_MAX_MULTI) {			return(1) ;		}	}	/*	 * find empty slot	 */	if (!(tb = mac_get_mc_table(smc,addr,&own,0,can & ~0x80)))		return(1) ;	tb->n++ ;	tb->a = own ;	tb->perm = (can & 0x80) ? 1 : 0 ;	if (can & 0x80)		smc->hw.fp.smt_slots_used++ ;	else		smc->hw.fp.os_slots_used++ ;	return(0) ;}/*	BEGIN_MANUAL_ENTRY(if,func;others;2)	void mac_del_multicast(smc,addr,can)	struct s_smc *smc ;	struct fddi_addr *addr ;	int can ;Function	DOWNCALL	(SMT, fplustm.c)		Delete an entry from the multicast tablePara	addr	pointer to a multicast address	can	= 0:	the multicast address has the physical format		= 1:	the multicast address has the canonical format		| 0x80	permanent	END_MANUAL_ENTRY() */void mac_del_multicast(struct s_smc *smc, struct fddi_addr *addr, int can){	SK_LOC_DECL(struct fddi_addr,own) ;	struct s_fpmc	*tb ;	if (!(tb = mac_get_mc_table(smc,addr,&own,1,can & ~0x80)))		return ;	/*	 * permanent addresses must be deleted with perm bit	 * and vice versa	 */	if (( tb->perm &&  (can & 0x80)) ||	    (!tb->perm && !(can & 0x80))) {		/*		 * delete it		 */		if (tb->n) {			tb->n-- ;			if (tb->perm) {				smc->hw.fp.smt_slots_used-- ;			}			else {				smc->hw.fp.os_slots_used-- ;			}		}	}}/* * mode */#define RX_MODE_PROM		0x1#define RX_MODE_ALL_MULTI	0x2/*	BEGIN_MANUAL_ENTRY(if,func;others;2)	void mac_update_multicast(smc)	struct s_smc *smc ;Function	DOWNCALL	(SMT, fplustm.c)		Update FORMAC multicast registers	END_MANUAL_ENTRY() */void mac_update_multicast(struct s_smc *smc){	struct s_fpmc	*tb ;	u_char	*fu ;	int	i ;	/*	 * invalidate the CAM	 */	outpw(FM_A(FM_AFCMD),FM_IINV_CAM) ;	/*	 * set the functional address	 */	if (smc->hw.fp.func_addr) {		fu = (u_char *) &smc->hw.fp.func_addr ;		outpw(FM_A(FM_AFMASK2),0xffff) ;		outpw(FM_A(FM_AFMASK1),(u_short) ~((fu[0] << 8) + fu[1])) ;		outpw(FM_A(FM_AFMASK0),(u_short) ~((fu[2] << 8) + fu[3])) ;		outpw(FM_A(FM_AFPERS),FM_VALID|FM_DA) ;		outpw(FM_A(FM_AFCOMP2), 0xc000) ;		outpw(FM_A(FM_AFCOMP1), 0x0000) ;		outpw(FM_A(FM_AFCOMP0), 0x0000) ;		outpw(FM_A(FM_AFCMD),FM_IWRITE_CAM) ;	}	/*	 * set the mask and the personality register(s)	 */	outpw(FM_A(FM_AFMASK0),0xffff) ;	outpw(FM_A(FM_AFMASK1),0xffff) ;	outpw(FM_A(FM_AFMASK2),0xffff) ;	outpw(FM_A(FM_AFPERS),FM_VALID|FM_DA) ;	for (i = 0, tb = smc->hw.fp.mc.table; i < FPMAX_MULTICAST; i++, tb++) {		if (tb->n) {			CHECK_CAM() ;			/*			 * write the multicast address into the CAM			 */			outpw(FM_A(FM_AFCOMP2),				(u_short)((tb->a.a[0]<<8)+tb->a.a[1])) ;			outpw(FM_A(FM_AFCOMP1),				(u_short)((tb->a.a[2]<<8)+tb->a.a[3])) ;			outpw(FM_A(FM_AFCOMP0),				(u_short)((tb->a.a[4]<<8)+tb->a.a[5])) ;			outpw(FM_A(FM_AFCMD),FM_IWRITE_CAM) ;		}	}}/*	BEGIN_MANUAL_ENTRY(if,func;others;3)	void mac_set_rx_mode(smc,mode)	struct s_smc *smc ;	int mode ;Function	DOWNCALL/INTERN	(SMT, fplustm.c)		This function enables / disables the selected receive.		Don't call this function if the hardware module is		used -- use mac_drv_rx_mode() instead of.Para	mode =	1	RX_ENABLE_ALLMULTI	enable all multicasts		2	RX_DISABLE_ALLMULTI	disable "enable all multicasts"		3	RX_ENABLE_PROMISC	enable promiscous		4	RX_DISABLE_PROMISC	disable promiscous		5	RX_ENABLE_NSA		enable reception of NSA frames		6	RX_DISABLE_NSA		disable reception of NSA framesNote	The selected receive modes will be lost after 'driver reset'	or 'set station address'	END_MANUAL_ENTRY */void mac_set_rx_mode(struct s_smc *smc, int mode){	switch (mode) {	case RX_ENABLE_ALLMULTI :		smc->hw.fp.rx_prom |= RX_MODE_ALL_MULTI ;		break ;	case RX_DISABLE_ALLMULTI :		smc->hw.fp.rx_prom &= ~RX_MODE_ALL_MULTI ;		break ;	case RX_ENABLE_PROMISC :		smc->hw.fp.rx_prom |= RX_MODE_PROM ;		break ;	case RX_DISABLE_PROMISC :		smc->hw.fp.rx_prom &= ~RX_MODE_PROM ;		break ;	case RX_ENABLE_NSA :		smc->hw.fp.nsa_mode = FM_MDAMA ;		smc->hw.fp.rx_mode = (smc->hw.fp.rx_mode & ~FM_ADDET) |			smc->hw.fp.nsa_mode ;		break ;	case RX_DISABLE_NSA :		smc->hw.fp.nsa_mode = FM_MRNNSAFNMA ;		smc->hw.fp.rx_mode = (smc->hw.fp.rx_mode & ~FM_ADDET) |			smc->hw.fp.nsa_mode ;		break ;	}	if (smc->hw.fp.rx_prom & RX_MODE_PROM) {		smc->hw.fp.rx_mode = FM_MLIMPROM ;	}	else if (smc->hw.fp.rx_prom & RX_MODE_ALL_MULTI) {		smc->hw.fp.rx_mode = smc->hw.fp.nsa_mode | FM_EXGPA0 ;	}	else		smc->hw.fp.rx_mode = smc->hw.fp.nsa_mode ;	SETMASK(FM_A(FM_MDREG1),smc->hw.fp.rx_mode,FM_ADDRX) ;	mac_update_multicast(smc) ;}/*	BEGIN_MANUAL_ENTRY(module;tests;3)	How to test the Restricted Token Monitor	----------------------------------------------------------------	o Insert a break point in the function rtm_irq()	o Remove all stations with a restricted token monitor from the	  network.	o Connect a UPPS ISA or EISA station to the network.	o Give the FORMAC of UPPS station the command to send	  restricted tokens until the ring becomes instable.	o Now connect your test test client.	o The restricted token monitor should detect the restricted token,	  and your break point will be reached.	o You can ovserve how the station will clean the ring.	END_MANUAL_ENTRY */void rtm_irq(struct s_smc *smc){	outpw(ADDR(B2_RTM_CRTL),TIM_CL_IRQ) ;		/* clear IRQ */	if (inpw(ADDR(B2_RTM_CRTL)) & TIM_RES_TOK) {		outpw(FM_A(FM_CMDREG1),FM_ICL) ;	/* force claim */		DB_RMT("RMT: fddiPATHT_Rmode expired\n",0,0) ;		AIX_EVENT(smc, (u_long) FDDI_RING_STATUS,				(u_long) FDDI_SMT_EVENT,				(u_long) FDDI_RTT, smt_get_event_word(smc));	}	outpw(ADDR(B2_RTM_CRTL),TIM_START) ;	/* enable RTM monitoring */}static void rtm_init(struct s_smc *smc){	outpd(ADDR(B2_RTM_INI),0) ;		/* timer = 0 */	outpw(ADDR(B2_RTM_CRTL),TIM_START) ;	/* enable IRQ */}void rtm_set_timer(struct s_smc *smc){	/*	 * MIB timer and hardware timer have the same resolution of 80nS	 */	DB_RMT("RMT: setting new fddiPATHT_Rmode, t = %d ns \n",		(int) smc->mib.a[PATH0].fddiPATHT_Rmode,0) ;	outpd(ADDR(B2_RTM_INI),smc->mib.a[PATH0].fddiPATHT_Rmode) ;}static void smt_split_up_fifo(struct s_smc *smc){/*	BEGIN_MANUAL_ENTRY(module;mem;1)	-------------------------------------------------------------	RECEIVE BUFFER MEMORY DIVERSION	-------------------------------------------------------------	R1_RxD == SMT_R1_RXD_COUNT	R2_RxD == SMT_R2_RXD_COUNT	SMT_R1_RXD_COUNT must be unequal zero		   | R1_RxD R2_RxD |R1_RxD R2_RxD | R1_RxD R2_RxD		   |   x      0	   |  x	    1-3	  |   x     < 3	----------------------------------------------------------------------		   |   63,75 kB	   |    54,75	  |	R1_RxD	rx queue 1 | RX_FIFO_SPACE | RX_LARGE_FIFO| ------------- * 63,75 kB		   |		   |		  | R1_RxD+R2_RxD	----------------------------------------------------------------------		   |		   |    9 kB	  |     R2_RxD	rx queue 2 |	0 kB	   | RX_SMALL_FIFO| ------------- * 63,75 kB		   |  (not used)   |		  | R1_RxD+R2_RxD	END_MANUAL_ENTRY*/	if (SMT_R1_RXD_COUNT == 0) {		SMT_PANIC(smc,SMT_E0117, SMT_E0117_MSG) ;	}	switch(SMT_R2_RXD_COUNT) {	case 0:		smc->hw.fp.fifo.rx1_fifo_size = RX_FIFO_SPACE ;		smc->hw.fp.fifo.rx2_fifo_size = 0 ;		break ;	case 1:	case 2:	case 3:		smc->hw.fp.fifo.rx1_fifo_size = RX_LARGE_FIFO ;		smc->hw.fp.fifo.rx2_fifo_size = RX_SMALL_FIFO ;		break ;	default:	/* this is not the real defaule */		smc->hw.fp.fifo.rx1_fifo_size = RX_FIFO_SPACE *		SMT_R1_RXD_COUNT/(SMT_R1_RXD_COUNT+SMT_R2_RXD_COUNT) ;		smc->hw.fp.fifo.rx2_fifo_size = RX_FIFO_SPACE *		SMT_R2_RXD_COUNT/(SMT_R1_RXD_COUNT+SMT_R2_RXD_COUNT) ;		break ;	}/*	BEGIN_MANUAL_ENTRY(module;mem;1)	-------------------------------------------------------------	TRANSMIT BUFFER MEMORY DIVERSION	-------------------------------------------------------------		 | no sync bw	| sync bw available and | sync bw available and		 | available	| SynchTxMode = SPLIT	| SynchTxMode = ALL	-----------------------------------------------------------------------	sync tx	 |     0 kB	|	32 kB		|	55 kB	queue	 |		|   TX_MEDIUM_FIFO	|   TX_LARGE_FIFO	-----------------------------------------------------------------------	async tx |    64 kB	|	32 kB		|	 9 k	queue	 | TX_FIFO_SPACE|   TX_MEDIUM_FIFO	|   TX_SMALL_FIFO	END_MANUAL_ENTRY*/	/*	 * set the tx mode bits	 */	if (smc->mib.a[PATH0].fddiPATHSbaPayload) {#ifdef ESS		smc->hw.fp.fifo.fifo_config_mode |=			smc->mib.fddiESSSynchTxMode | SYNC_TRAFFIC_ON ;#endif	}	else {		smc->hw.fp.fifo.fifo_config_mode &=			~(SEND_ASYNC_AS_SYNC|SYNC_TRAFFIC_ON) ;	}	/*	 * split up the FIFO	 */	if (smc->hw.fp.fifo.fifo_config_mode & SYNC_TRAFFIC_ON) {		if (smc->hw.fp.fifo.fifo_config_mode & SEND_ASYNC_AS_SYNC) {			smc->hw.fp.fifo.tx_s_size = TX_LARGE_FIFO ;			smc->hw.fp.fifo.tx_a0_size = TX_SMALL_FIFO ;		}		else {			smc->hw.fp.fifo.tx_s_size = TX_MEDIUM_FIFO ;			smc->hw.fp.fifo.tx_a0_size = TX_MEDIUM_FIFO ;		}	}	else {			smc->hw.fp.fifo.tx_s_size = 0 ;			smc->hw.fp.fifo.tx_a0_size = TX_FIFO_SPACE ;	}	smc->hw.fp.fifo.rx1_fifo_start = smc->hw.fp.fifo.rbc_ram_start +		RX_FIFO_OFF ;	smc->hw.fp.fifo.tx_s_start = smc->hw.fp.fifo.rx1_fifo_start +		smc->hw.fp.fifo.rx1_fifo_size ;	smc->hw.fp.fifo.tx_a0_start = smc->hw.fp.fifo.tx_s_start +		smc->hw.fp.fifo.tx_s_size ;	smc->hw.fp.fifo.rx2_fifo_start = smc->hw.fp.fifo.tx_a0_start +		smc->hw.fp.fifo.tx_a0_size ;	DB_SMT("FIFO split: mode = %x\n",smc->hw.fp.fifo.fifo_config_mode,0) ;	DB_SMT("rbc_ram_start =	%x	 rbc_ram_end = 	%x\n",		smc->hw.fp.fifo.rbc_ram_start, smc->hw.fp.fifo.rbc_ram_end) ;	DB_SMT("rx1_fifo_start = %x	 tx_s_start = 	%x\n",		smc->hw.fp.fifo.rx1_fifo_start, smc->hw.fp.fifo.tx_s_start) ;	DB_SMT("tx_a0_start =	%x	 rx2_fifo_start = 	%x\n",		smc->hw.fp.fifo.tx_a0_start, smc->hw.fp.fifo.rx2_fifo_start) ;}void formac_reinit_tx(struct s_smc *smc){	/*	 * Split up the FIFO and reinitialize the MAC if synchronous	 * bandwidth becomes available but no synchronous queue is	 * configured.	 */	if (!smc->hw.fp.fifo.tx_s_size && smc->mib.a[PATH0].fddiPATHSbaPayload){		(void)init_mac(smc,0) ;	}}

⌨️ 快捷键说明

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