// SPDX-License-Identifier: GPL-2.0-or-later /****************************************************************************** * * (C)Copyright 1998,1999 SysKonnect, * a business unit of Schneider & Koch & Co. Datensysteme GmbH. * * See the file "skfddi.c" for further information. * * The information in this file is provided "AS IS" without warranty. *
******************************************************************************/
void mac_update_counter(struct s_smc *smc)
{
smc->mib.m[MAC0].fddiMACFrame_Ct =
(smc->mib.m[MAC0].fddiMACFrame_Ct & 0xffff0000L)
+ (u_short) inpw(FM_A(FM_FCNTR)) ;
smc->mib.m[MAC0].fddiMACLost_Ct =
(smc->mib.m[MAC0].fddiMACLost_Ct & 0xffff0000L)
+ (u_short) inpw(FM_A(FM_LCNTR)) ;
smc->mib.m[MAC0].fddiMACError_Ct =
(smc->mib.m[MAC0].fddiMACError_Ct & 0xffff0000L)
+ (u_short) inpw(FM_A(FM_ECNTR)) ;
smc->mib.m[MAC0].fddiMACT_Neg = mac_get_tneg(smc) ; #ifdef SMT_REAL_TOKEN_CT /* * If the token counter is emulated it is updated in smt_event.
*/
TBD #else
smt_emulate_token_ct( smc, MAC0 ); #endif
}
/* * write long value into buffer memory over memory data register (MDR),
*/ staticvoid write_mdr(struct s_smc *smc, u_long val)
{
CHECK_NPP() ;
MDRW(val) ;
}
#if 0 /* * read long value from buffer memory over memory data register (MDR),
*/ static u_long read_mdr(struct s_smc *smc, unsignedint addr)
{ long p ;
CHECK_NPP() ;
MARR(addr) ;
outpw(FM_A(FM_CMDREG1),FM_IRMEMWO) ;
CHECK_NPP() ; /* needed for PCI to prevent from timeing violations */ /* p = MDRR() ; */ /* bad read values if the workaround */ /* smc->hw.mc_dummy = *((short volatile far *)(addr)))*/ /* is used */
p = (u_long)inpw(FM_A(FM_MDRU))<<16 ;
p += (u_long)inpw(FM_A(FM_MDRL)) ; return p;
} #endif
/* * init all tx data structures for receive queue 1
*/
smc->hw.fp.rx[QUEUE_R1] = queue = &smc->hw.fp.rx_q[QUEUE_R1] ;
queue->rx_bmu_ctl = (HW_PTR) ADDR(B0_R1_CSR) ;
queue->rx_bmu_dsc = (HW_PTR) ADDR(B4_R1_DA) ;
/* * init all tx data structures for receive queue 2
*/
smc->hw.fp.rx[QUEUE_R2] = queue = &smc->hw.fp.rx_q[QUEUE_R2] ;
queue->rx_bmu_ctl = (HW_PTR) ADDR(B0_R2_CSR) ;
queue->rx_bmu_dsc = (HW_PTR) ADDR(B4_R2_DA) ;
}
/* * set the TSYNC register of the FORMAC to regulate synchronous transmission
*/ void set_formac_tsync(struct s_smc *smc, long sync_bw)
{
outpw(FM_A(FM_TSYNC),(unsignedint) (((-sync_bw) >> 5) & 0xffff) ) ;
}
/* * init all tx data structures
*/ staticvoid init_tx(struct s_smc *smc)
{ struct s_smt_tx_queue *queue ;
/* * init all tx data structures for the synchronous queue
*/
smc->hw.fp.tx[QUEUE_S] = queue = &smc->hw.fp.tx_q[QUEUE_S] ;
queue->tx_bmu_ctl = (HW_PTR) ADDR(B0_XS_CSR) ;
queue->tx_bmu_dsc = (HW_PTR) ADDR(B5_XS_DA) ;
/* * copy TX descriptor to buffer mem * append FC field and MAC frame * if more bit is set in descr * append pointer to descriptor (endless loop) * else * append 'end of chain' pointer
*/ staticvoid copy_tx_mac(struct s_smc *smc, u_long td, struct fddi_mac *mac, unsignedint off, int len) /* u_long td; transmit descriptor */ /* struct fddi_mac *mac; mac frame pointer */ /* unsigned int off; start address within buffer memory */ /* int len ; length of the frame including the FC */
{ int i ;
__le32 *p ;
CHECK_NPP() ;
MARW(off) ; /* set memory address reg for writes */
p = (__le32 *) mac ; for (i = (len + 3)/4 ; i ; i--) { if (i == 1) { /* last word, set the tag bit */
outpw(FM_A(FM_CMDREG2),FM_ISTTB) ;
}
write_mdr(smc,le32_to_cpu(*p)) ;
p++ ;
}
outpw(FM_A(FM_CMDREG2),FM_ISTTB) ; /* set the tag bit */
write_mdr(smc,td) ; /* write over memory data reg to buffer */
}
/* BEGIN_MANUAL_ENTRY(module;tests;3) How to test directed beacon frames ----------------------------------------------------------------
o Insert a break point in the function build_claim_beacon() before calling copy_tx_mac() for building the claim frame. o Modify the RM3_DETECT case so that the RM6_DETECT state will always entered from the RM3_DETECT state (function rmt_fsm(), rmt.c) o Compile the driver. o Set the parameter TREQ in the protocol.ini or net.cfg to a small value to make sure your station will win the claim process. o Start the driver. o When you reach the break point, modify the SA and DA address of the claim frame (e.g. SA = DA = 10005affffff). o When you see RM3_DETECT and RM6_DETECT, observe the direct beacon frames on the UPPSLANA.
/* * set UNA in frame * enable FORMAC to send endless queue of directed beacon * important: the UNA starts at byte 1 (not at byte 0)
*/
* (char *) a = (char) ((long)DBEACON_INFO<<24L) ;
a[1] = 0 ;
memcpy((char *)a+1, (char *) &smc->mib.m[MAC0].fddiMACUpstreamNbr, ETH_ALEN);
CHECK_NPP() ; /* set memory address reg for writes */
MARW(smc->hw.fp.fifo.rbc_ram_start+DBEACON_FRAME_OFF+4) ;
write_mdr(smc,le32_to_cpu(a[0])) ;
outpw(FM_A(FM_CMDREG2),FM_ISTTB) ; /* set the tag bit */
write_mdr(smc,le32_to_cpu(a[1])) ;
/* setup claim & beacon pointer NOTE : special frame packets end with a pointer to their own descriptor, and the MORE bit is set in the descriptor
*/ staticvoid build_claim_beacon(struct s_smc *smc, u_long t_request)
{
u_int td ; int len ; struct fddi_mac_sf *mac ;
/* * build claim packet
*/
len = 17 ;
td = TX_DESCRIPTOR | ((((u_int)len-1)&3)<<27) ;
mac = &smc->hw.fp.mac_sfb ;
mac->mac_fc = FC_CLAIM ; /* DA == SA in claim frame */
mac->mac_source = mac->mac_dest = MA ; /* 2's complement */
set_int((char *)mac->mac_info,(int)t_request) ;
Function DOWNCALL (SMT, fplustm.c) enable_tx_irq() enables the FORMACs transmit complete interrupt of the queue.
Para queue = QUEUE_S: synchronous queue = QUEUE_A0: asynchronous queue
Note After any ring operational change the transmit complete interrupts are disabled. The operating system dependent module must enable the transmit complete interrupt of a queue, - when it queues the first frame, because of no transmit resources are beeing available and - when it escapes from the function llc_restart_tx while some frames are still queued.
Function DOWNCALL (SMT, fplustm.c) disable_tx_irq disables the FORMACs transmit complete interrupt of the queue
Para queue = QUEUE_S: synchronous queue = QUEUE_A0: asynchronous queue
Note The operating system dependent module should disable the transmit complete interrupts if it escapes from the function llc_restart_tx and no frames are queued.
staticvoid mac_ring_up(struct s_smc *smc, int up)
{ if (up) {
formac_rcv_restart(smc) ; /* enable receive function */
smc->hw.mac_ring_is_up = TRUE ;
llc_restart_tx(smc) ; /* TX queue */
} else { /* disable receive function */
SETMASK(FM_A(FM_MDREG1),FM_MDISRCV,FM_ADDET) ;
/* abort current transmit activity */
outpw(FM_A(FM_CMDREG2),FM_IACTR) ;
smc->hw.mac_ring_is_up = FALSE ;
}
}
/*--------------------------- ISR handling ----------------------------------*/ /* * mac1_irq is in drvfbi.c
*/
/* * mac2_irq: status bits for the receive queue 1, and ring status * ring status indication bits
*/ void mac2_irq(struct s_smc *smc, u_short code_s2u, u_short code_s2l)
{
u_short change_s2l ;
u_short change_s2u ;
/* (jd) 22-Feb-1999 * Restart 2_DMax Timer after end of claiming or beaconing
*/ if (code_s2u & (FM_SCLM|FM_SHICLM|FM_SBEC|FM_SOTRBEC)) {
queue_event(smc,EVENT_RMT,RM_TX_STATE_CHANGE) ;
} elseif (code_s2l & (FM_STKISS)) {
queue_event(smc,EVENT_RMT,RM_TX_STATE_CHANGE) ;
}
/* * XOR current st bits with the last to avoid useless RMT event queuing
*/
change_s2l = smc->hw.fp.s2l ^ code_s2l ;
change_s2u = smc->hw.fp.s2u ^ code_s2u ;
if ((change_s2l & FM_SRNGOP) ||
(!smc->hw.mac_ring_is_up && ((code_s2l & FM_SRNGOP)))) { if (code_s2l & FM_SRNGOP) {
mac_ring_up(smc,1) ;
queue_event(smc,EVENT_RMT,RM_RING_OP) ;
smc->mib.m[MAC0].fddiMACRingOp_Ct++ ;
} else {
mac_ring_up(smc,0) ;
queue_event(smc,EVENT_RMT,RM_RING_NON_OP) ;
} goto mac2_end ;
} if (code_s2l & FM_SMISFRM) { /* missed frame */
smc->mib.m[MAC0].fddiMACNotCopied_Ct++ ;
} if (code_s2u & (FM_SRCVOVR | /* recv. FIFO overflow */
FM_SRBFL)) { /* recv. buffer full */
smc->hw.mac_ct.mac_r_restart_counter++ ; /* formac_rcv_restart(smc) ; */
smt_stat_counter(smc,1) ; /* goto mac2_end ; */
} if (code_s2u & FM_SOTRBEC)
queue_event(smc,EVENT_RMT,RM_OTHER_BEACON) ; if (code_s2u & FM_SMYBEC)
queue_event(smc,EVENT_RMT,RM_MY_BEACON) ; if (change_s2u & code_s2u & FM_SLOCLM) {
DB_RMTN(2, "RMT : lower claim received");
} if ((code_s2u & FM_SMYCLM) && !(code_s2l & FM_SDUPCLM)) { /* * This is my claim and that claim is not detected as a * duplicate one.
*/
queue_event(smc,EVENT_RMT,RM_MY_CLAIM) ;
} if (code_s2l & FM_SDUPCLM) { /* * If a duplicate claim frame (same SA but T_Bid != T_Req) * this flag will be set. * In the RMT state machine we need a RM_VALID_CLAIM event * to do the appropriate state change. * RM(34c)
*/
queue_event(smc,EVENT_RMT,RM_VALID_CLAIM) ;
} if (change_s2u & code_s2u & FM_SHICLM) {
DB_RMTN(2, "RMT : higher claim received");
} if ( (code_s2l & FM_STRTEXP) ||
(code_s2l & FM_STRTEXR) )
queue_event(smc,EVENT_RMT,RM_TRT_EXP) ; if (code_s2l & FM_SMULTDA) { /* * The MAC has found a 2. MAC with the same address. * Signal dup_addr_test = failed to RMT state machine. * RM(25)
*/
smc->r.dup_addr_test = DA_FAILED ;
queue_event(smc,EVENT_RMT,RM_DUP_ADDR) ;
} if (code_s2u & FM_SBEC)
smc->hw.fp.err_stats.err_bec_stat++ ; if (code_s2u & FM_SCLM)
smc->hw.fp.err_stats.err_clm_stat++ ; if (code_s2l & FM_STVXEXP)
smc->mib.m[MAC0].fddiMACTvxExpired_Ct++ ; if ((code_s2u & (FM_SBEC|FM_SCLM))) { if (!(change_s2l & FM_SRNGOP) && (smc->hw.fp.s2l & FM_SRNGOP)) {
mac_ring_up(smc,0) ;
queue_event(smc,EVENT_RMT,RM_RING_NON_OP) ;
mac_ring_up(smc,1) ;
queue_event(smc,EVENT_RMT,RM_RING_OP) ;
smc->mib.m[MAC0].fddiMACRingOp_Ct++ ;
}
} if (code_s2l & FM_SPHINV)
smc->hw.fp.err_stats.err_phinv++ ; if (code_s2l & FM_SSIFG)
smc->hw.fp.err_stats.err_sifg_det++ ; if (code_s2l & FM_STKISS)
smc->hw.fp.err_stats.err_tkiss++ ; if (code_s2l & FM_STKERR)
smc->hw.fp.err_stats.err_tkerr++ ; if (code_s2l & FM_SFRMCTR)
smc->mib.m[MAC0].fddiMACFrame_Ct += 0x10000L ; if (code_s2l & FM_SERRCTR)
smc->mib.m[MAC0].fddiMACError_Ct += 0x10000L ; if (code_s2l & FM_SLSTCTR)
smc->mib.m[MAC0].fddiMACLost_Ct += 0x10000L ; if (code_s2u & FM_SERRSF) {
SMT_PANIC(smc,SMT_E0114, SMT_E0114_MSG) ;
}
mac2_end: /* notice old status */
smc->hw.fp.s2l = code_s2l ;
smc->hw.fp.s2u = code_s2u ;
outpw(FM_A(FM_IMSK2U),~mac_imsk2u) ;
}
/* set RX threshold */ /* see Errata #SN2 Phantom receive overflow */
outpw(FM_A(FM_FRMTHR),14<<12) ; /* switch on */
/* set formac work mode */
outpw(FM_A(FM_MDREG1),MDR1INIT | FM_SELRA | smc->hw.fp.rx_mode) ;
outpw(FM_A(FM_MDREG2),smc->hw.fp.mdr2init) ;
outpw(FM_A(FM_MDREG3),smc->hw.fp.mdr3init) ;
outpw(FM_A(FM_FRSELREG),smc->hw.fp.frselreg_init) ;
/* set timer */ /* * errata #22 fplus: * T_MAX must not be FFFE * or one of FFDF, FFB8, FF91 (-0x27 etc..)
*/
t_max = (u_short)(smc->mib.m[MAC0].fddiMACT_Max/32) ;
x = t_max/0x27 ;
x *= 0x27 ; if ((t_max == 0xfffe) || (t_max - x == 0x16))
t_max-- ;
outpw(FM_A(FM_TMAX),(u_short)t_max) ;
/* Auto unlock receice threshold for receive queue 1 and 2 */
outpw(FM_A(FM_UNLCKDLY),(0xff|(0xff<<8))) ;
rtm_init(smc) ; /* RT-Monitor */
if (!all) { /* * after 10ms, reset the BMUs and repair the rings
*/
hwt_wait_time(smc,time,MS2BCLK(10)) ;
outpd(ADDR(B0_R1_CSR),CSR_SET_RESET) ;
outpd(ADDR(B0_XA_CSR),CSR_SET_RESET) ;
outpd(ADDR(B0_XS_CSR),CSR_SET_RESET) ;
outp(ADDR(B0_CTRL), CTRL_HPI_CLR) ;
outpd(ADDR(B0_R1_CSR),CSR_CLR_RESET) ;
outpd(ADDR(B0_XA_CSR),CSR_CLR_RESET) ;
outpd(ADDR(B0_XS_CSR),CSR_CLR_RESET) ; if (!smc->hw.hw_is_64bit) {
outpd(ADDR(B4_R1_F), RX_WATERMARK) ;
outpd(ADDR(B5_XA_F), TX_WATERMARK) ;
outpd(ADDR(B5_XS_F), TX_WATERMARK) ;
}
smc->hw.hw_state = STOPPED ;
mac_drv_repair_descr(smc) ;
}
smc->hw.hw_state = STARTED ;
return 0;
}
/* * called by CFM
*/ void config_mux(struct s_smc *smc, int mux)
{
plc_config_mux(smc,mux) ;
SETMASK(FM_A(FM_MDREG1),FM_SELRA,FM_SELRA) ;
}
/* * called by RMT * enable CLAIM/BEACON interrupts * (only called if these events are of interest, e.g. in DETECT state * the interrupt must not be permanently enabled * RMT calls this function periodically (timer driven polling)
*/ void sm_mac_check_beacon_claim(struct s_smc *smc)
{ /* set formac IMSK : 0 enables irq */
outpw(FM_A(FM_IMSK2U),~(mac_imsk2u | mac_beacon_imsk2u)) ; /* the driver must receive the directed beacons */
formac_rcv_restart(smc) ;
process_receive(smc) ;
}
/*-------------------------- interface functions ----------------------------*/ /* * control MAC layer (called by RMT)
*/ void sm_ma_control(struct s_smc *smc, int mode)
{ switch(mode) { case MA_OFFLINE : /* Add to make the MAC offline in RM0_ISOLATED state */
formac_offline(smc) ; break ; case MA_RESET :
(void)init_mac(smc,0) ; break ; case MA_BEACON :
formac_online(smc) ; break ; case MA_DIRECTED :
directed_beacon(smc) ; break ; case MA_TREQ : /* * 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
*/
staticstruct 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 = bitrev8(*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 (!ether_addr_equal((char *)&tb->a, (char *)own)) 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_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 table
Para 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
Returns 0: success 1: address table full
Note 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;
}
}
/* * 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 promiscuous 4 RX_DISABLE_PROMISC disable promiscuous 5 RX_ENABLE_NSA enable reception of NSA frames 6 RX_DISABLE_NSA disable reception of NSA frames
Note The selected receive modes will be lost after 'driver reset' or 'set station address'
/* 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 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.
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",
(int)smc->mib.a[PATH0].fddiPATHT_Rmode);
outpd(ADDR(B2_RTM_INI),smc->mib.a[PATH0].fddiPATHT_Rmode) ;
}
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) ;
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.