?? arlan-main.c
字號:
spin_unlock_irqrestore(&priv->lock, flags); ARLAN_DEBUG_EXIT("arlan_command"); return -1;}static inline void arlan_command_process(struct net_device *dev){ struct arlan_private *priv = dev->priv; int times = 0; while (priv->waiting_command_mask && times < 8) { if (priv->waiting_command_mask) { if (arlan_command(dev, 0)) break; times++; } /* if long command, we won't repeat trying */ ; if (priv->card_polling_interval > 1) break; times++; }}static inline void arlan_retransmit_now(struct net_device *dev){ struct arlan_private *priv = dev->priv; ARLAN_DEBUG_ENTRY("arlan_retransmit_now"); if (TXLAST(dev).offset == 0) { if (TXHEAD(dev).offset) { priv->txLast = 0; IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_DEBUG "TX buff switch to head \n"); } else if (TXTAIL(dev).offset) { IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_DEBUG "TX buff switch to tail \n"); priv->txLast = 1; } else IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "ReTransmit buff empty"); netif_wake_queue (dev); return; } arlan_command(dev, ARLAN_COMMAND_TX); priv->Conf->driverRetransmissions++; priv->retransmissions++; IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk("Retransmit %d bytes \n", TXLAST(dev).length); ARLAN_DEBUG_EXIT("arlan_retransmit_now");}static void arlan_registration_timer(unsigned long data){ struct net_device *dev = (struct net_device *) data; struct arlan_private *priv = dev->priv; int bh_mark_needed = 0; int next_tick = 1; long lostTime = ((long)jiffies - (long)priv->registrationLastSeen) * (1000/HZ); if (registrationBad(dev)) { priv->registrationLostCount++; if (lostTime > 7000 && lostTime < 7200) { printk(KERN_NOTICE "%s registration Lost \n", dev->name); } if (lostTime / priv->reRegisterExp > 2000) arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_CONF); if (lostTime / (priv->reRegisterExp) > 3500) arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET); if (priv->reRegisterExp < 400) priv->reRegisterExp += 2; if (lostTime > 7200) { next_tick = HZ; arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET); } } else { if (priv->Conf->registrationMode && lostTime > 10000 && priv->registrationLostCount) { printk(KERN_NOTICE "%s registration is back after %ld milliseconds\n", dev->name, lostTime); } priv->registrationLastSeen = jiffies; priv->registrationLostCount = 0; priv->reRegisterExp = 1; if (!netif_running(dev) ) netif_wake_queue(dev); if (time_after(priv->tx_last_sent,priv->tx_last_cleared) && time_after(jiffies, priv->tx_last_sent * 5*HZ) ){ arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET); priv->tx_last_cleared = jiffies; } } if (!registrationBad(dev) && priv->ReTransmitRequested) { IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "Retransmit from timer \n"); priv->ReTransmitRequested = 0; arlan_retransmit_now(dev); } if (!registrationBad(dev) && time_after(jiffies, priv->tx_done_delayed) && priv->tx_done_delayed != 0) { TXLAST(dev).offset = 0; if (priv->txLast) priv->txLast = 0; else if (TXTAIL(dev).offset) priv->txLast = 1; if (TXLAST(dev).offset) { arlan_retransmit_now(dev); dev->trans_start = jiffies; } if (!(TXHEAD(dev).offset && TXTAIL(dev).offset)) { netif_wake_queue (dev); } priv->tx_done_delayed = 0; bh_mark_needed = 1; } if (bh_mark_needed) { netif_wake_queue (dev); } arlan_process_interrupt(dev); if (next_tick < priv->card_polling_interval) next_tick = priv->card_polling_interval; priv->timer.expires = jiffies + next_tick; add_timer(&priv->timer);}#ifdef ARLAN_DEBUGGINGstatic void arlan_print_registers(struct net_device *dev, int line){ struct arlan_private *priv = dev->priv; volatile struct arlan_shmem *arlan = priv->card; u_char hostcpuLock, lancpuLock, controlRegister, cntrlRegImage, txStatus, rxStatus, interruptInProgress, commandByte; ARLAN_DEBUG_ENTRY("arlan_print_registers"); READSHM(interruptInProgress, arlan->interruptInProgress, u_char); READSHM(hostcpuLock, arlan->hostcpuLock, u_char); READSHM(lancpuLock, arlan->lancpuLock, u_char); READSHM(controlRegister, arlan->controlRegister, u_char); READSHM(cntrlRegImage, arlan->cntrlRegImage, u_char); READSHM(txStatus, arlan->txStatus, u_char); READSHM(rxStatus, arlan->rxStatus, u_char); READSHM(commandByte, arlan->commandByte, u_char); printk(KERN_WARNING "line %04d IP %02x HL %02x LL %02x CB %02x CR %02x CRI %02x TX %02x RX %02x\n", line, interruptInProgress, hostcpuLock, lancpuLock, commandByte, controlRegister, cntrlRegImage, txStatus, rxStatus); ARLAN_DEBUG_EXIT("arlan_print_registers");}#endifstatic int arlan_hw_tx(struct net_device *dev, char *buf, int length){ int i; struct arlan_private *priv = dev->priv; volatile struct arlan_shmem *arlan = priv->card; struct arlan_conf_stru *conf = priv->Conf; int tailStarts = 0x800; int headEnds = 0x0; ARLAN_DEBUG_ENTRY("arlan_hw_tx"); if (TXHEAD(dev).offset) headEnds = (((TXHEAD(dev).offset + TXHEAD(dev).length - (((int) arlan->txBuffer) - ((int) arlan))) / 64) + 1) * 64; if (TXTAIL(dev).offset) tailStarts = 0x800 - (((TXTAIL(dev).offset - (((int) arlan->txBuffer) - ((int) arlan))) / 64) + 2) * 64; if (!TXHEAD(dev).offset && length < tailStarts) { IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "TXHEAD insert, tailStart %d\n", tailStarts); TXHEAD(dev).offset = (((int) arlan->txBuffer) - ((int) arlan)); TXHEAD(dev).length = length - ARLAN_FAKE_HDR_LEN; for (i = 0; i < 6; i++) TXHEAD(dev).dest[i] = buf[i]; TXHEAD(dev).clear = conf->txClear; TXHEAD(dev).retries = conf->txRetries; /* 0 is use default */ TXHEAD(dev).routing = conf->txRouting; TXHEAD(dev).scrambled = conf->txScrambled; memcpy_toio(((char *) arlan + TXHEAD(dev).offset), buf + ARLAN_FAKE_HDR_LEN, TXHEAD(dev).length); } else if (!TXTAIL(dev).offset && length < (0x800 - headEnds)) { IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "TXTAIL insert, headEnd %d\n", headEnds); TXTAIL(dev).offset = (((int) arlan->txBuffer) - ((int) arlan)) + 0x800 - (length / 64 + 2) * 64; TXTAIL(dev).length = length - ARLAN_FAKE_HDR_LEN; for (i = 0; i < 6; i++) TXTAIL(dev).dest[i] = buf[i]; TXTAIL(dev).clear = conf->txClear; TXTAIL(dev).retries = conf->txRetries; TXTAIL(dev).routing = conf->txRouting; TXTAIL(dev).scrambled = conf->txScrambled; memcpy_toio(((char *) arlan + TXTAIL(dev).offset), buf + ARLAN_FAKE_HDR_LEN, TXTAIL(dev).length); } else { netif_stop_queue (dev); IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "TX TAIL & HEAD full, return, tailStart %d headEnd %d\n", tailStarts, headEnds); return -1; } priv->out_bytes += length; priv->out_bytes10 += length; if (conf->measure_rate < 1) conf->measure_rate = 1; if (time_after(jiffies, priv->out_time + conf->measure_rate * HZ)) { conf->out_speed = priv->out_bytes / conf->measure_rate; priv->out_bytes = 0; priv->out_time = jiffies; } if (time_after(jiffies, priv->out_time10 + conf->measure_rate * 10*HZ)) { conf->out_speed10 = priv->out_bytes10 / (10 * conf->measure_rate); priv->out_bytes10 = 0; priv->out_time10 = jiffies; } if (TXHEAD(dev).offset && TXTAIL(dev).offset) { netif_stop_queue (dev); return 0; } else netif_start_queue (dev); IFDEBUG(ARLAN_DEBUG_HEADER_DUMP) printk(KERN_WARNING "%s Transmit t %2x:%2x:%2x:%2x:%2x:%2x f %2x:%2x:%2x:%2x:%2x:%2x \n", dev->name, (unsigned char) buf[0], (unsigned char) buf[1], (unsigned char) buf[2], (unsigned char) buf[3], (unsigned char) buf[4], (unsigned char) buf[5], (unsigned char) buf[6], (unsigned char) buf[7], (unsigned char) buf[8], (unsigned char) buf[9], (unsigned char) buf[10], (unsigned char) buf[11]); IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "TX command prepare for buffer %d\n", priv->txLast); arlan_command(dev, ARLAN_COMMAND_TX); priv->tx_last_sent = jiffies; IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk("%s TX Qued %d bytes \n", dev->name, length); ARLAN_DEBUG_EXIT("arlan_hw_tx"); return 0;}static int arlan_hw_config(struct net_device *dev){ struct arlan_private *priv = dev->priv; volatile struct arlan_shmem *arlan = priv->card; struct arlan_conf_stru *conf = priv->Conf; ARLAN_DEBUG_ENTRY("arlan_hw_config"); printk(KERN_NOTICE "%s arlan configure called \n", dev->name); if (arlan_EEPROM_bad) printk(KERN_NOTICE "arlan configure with eeprom bad option \n"); WRITESHM(arlan->spreadingCode, conf->spreadingCode, u_char); WRITESHM(arlan->channelSet, conf->channelSet, u_char); if (arlan_EEPROM_bad) WRITESHM(arlan->defaultChannelSet, conf->channelSet, u_char); WRITESHM(arlan->channelNumber, conf->channelNumber, u_char); WRITESHM(arlan->scramblingDisable, conf->scramblingDisable, u_char); WRITESHM(arlan->txAttenuation, conf->txAttenuation, u_char); WRITESHM(arlan->systemId, conf->systemId, u_int); WRITESHM(arlan->maxRetries, conf->maxRetries, u_char); WRITESHM(arlan->receiveMode, conf->receiveMode, u_char); WRITESHM(arlan->priority, conf->priority, u_char); WRITESHM(arlan->rootOrRepeater, conf->rootOrRepeater, u_char); WRITESHM(arlan->SID, conf->SID, u_int); WRITESHM(arlan->registrationMode, conf->registrationMode, u_char); WRITESHM(arlan->registrationFill, conf->registrationFill, u_char); WRITESHM(arlan->localTalkAddress, conf->localTalkAddress, u_char); WRITESHM(arlan->codeFormat, conf->codeFormat, u_char); WRITESHM(arlan->numChannels, conf->numChannels, u_char); WRITESHM(arlan->channel1, conf->channel1, u_char); WRITESHM(arlan->channel2, conf->channel2, u_char); WRITESHM(arlan->channel3, conf->channel3, u_char); WRITESHM(arlan->channel4, conf->channel4, u_char); WRITESHM(arlan->radioNodeId, conf->radioNodeId, u_short); WRITESHM(arlan->SID, conf->SID, u_int); WRITESHM(arlan->waitTime, conf->waitTime, u_short); WRITESHM(arlan->lParameter, conf->lParameter, u_short); memcpy_toio(&(arlan->_15), &(conf->_15), 3); WRITESHM(arlan->_15, conf->_15, u_short); WRITESHM(arlan->headerSize, conf->headerSize, u_short); if (arlan_EEPROM_bad) WRITESHM(arlan->hardwareType, conf->hardwareType, u_char); WRITESHM(arlan->radioType, conf->radioType, u_char); if (arlan_EEPROM_bad) WRITESHM(arlan->radioModule, conf->radioType, u_char); memcpy_toio(arlan->encryptionKey + keyStart, encryptionKey, 8); memcpy_toio(arlan->name, conf->siteName, 16); WRITESHMB(arlan->commandByte, ARLAN_COM_INT | ARLAN_COM_CONF); /* do configure */ memset_io(arlan->commandParameter, 0, 0xf); /* 0xf */ memset_io(arlan->commandParameter + 1, 0, 2); if (conf->writeEEPROM) { memset_io(arlan->commandParameter, conf->writeEEPROM, 1);// conf->writeEEPROM=0; } if (conf->registrationMode && conf->registrationInterrupts) memset_io(arlan->commandParameter + 3, 1, 1); else memset_io(arlan->commandParameter + 3, 0, 1); priv->irq_test_done = 0; if (conf->tx_queue_len) dev->tx_queue_len = conf->tx_queue_len; udelay(100); ARLAN_DEBUG_EXIT("arlan_hw_config"); return 0;}static int arlan_read_card_configuration(struct net_device *dev){ u_char tlx415; struct arlan_private *priv = dev->priv; volatile struct arlan_shmem *arlan = priv->card; struct arlan_conf_stru *conf = priv->Conf; ARLAN_DEBUG_ENTRY("arlan_read_card_configuration"); if (radioNodeId == radioNodeIdUNKNOWN) { READSHM(conf->radioNodeId, arlan->radioNodeId, u_short); } else conf->radioNodeId = radioNodeId; if (SID == SIDUNKNOWN) { READSHM(conf->SID, arlan->SID, u_int); } else conf->SID = SID; if (spreadingCode == spreadingCodeUNKNOWN) { READSHM(conf->spreadingCode, arlan->spreadingCode, u_char); } else conf->spreadingCode = spreadingCode; if (channelSet == channelSetUNKNOWN) { READSHM(conf->channelSet, arlan->channelSet, u_char); } else conf->channelSet = channelSet; if (channelNumber == channelNumberUNKNOWN) { READSHM(conf->channelNumber, arlan->channelNumber, u_char); } else conf->channelNumber = channelNumber; READSHM(conf->scramblingDisable, arlan->scramblingDisable, u_char); READSHM(conf->txAttenuation, arlan->txAttenuation, u_char); if (systemId == systemIdUNKNOWN) { READSHM(conf->systemId, arlan->systemId, u_int); } else conf->systemId = systemId; READSHM(conf->maxDatagramSize, arlan->maxDatagramSize, u_short); READSHM(conf->maxFrameSize, arlan->maxFrameSize, u_short); READSHM(conf->maxRetries, arlan->maxRetries, u_char); READSHM(conf->receiveMode, arlan->receiveMode, u_char); READSHM(conf->priority, arlan->priority, u_char); READSHM(conf->rootOrRepeater, arlan->rootOrRepeater, u_char); if (SID == SIDUNKNOWN) { READSHM(conf->SID, arlan->SID, u_int); } else conf->SID = SID; if (registrationMode == registrationModeUNKNOWN) { READSHM(conf->registrationMode, arlan->registrationMode, u_char); } else conf->registrationMode = registrationMode; READSHM(conf->registrationFill, arlan->registrationFill, u_char); READSHM(conf->localTalkAddress, arlan->localTalkAddress, u_char); READSHM(conf->codeFormat, arlan->codeFormat, u_char); READSHM(conf->numChannels, arlan->numChannels, u_char); READSHM(conf->channel1, arlan->channel1, u_char); READSHM(conf->channel2, arlan->channel2, u_char); READSHM(conf->channel3, arlan->channel3, u_char); READSHM(conf->channel4, arlan->channel4, u_char); READSHM(conf->waitTime, arlan->waitTime, u_short); READSHM(conf->lParameter, arlan->lParameter, u_short); READSHM(conf->_15, arlan->_15, u_short); READSHM(conf->headerSize, arlan->headerSize, u_short); READSHM(conf->hardwareType, arlan->hardwareType, u_char); READSHM(conf->radioType, arlan->radioModule, u_char); if (conf->radioType == 0) conf->radioType = 0xc; WRITESHM(arlan->configStatus, 0xA5, u_char); READSHM(tlx415, arlan->configStatus, u_char); if (tlx415 != 0xA5) printk(KERN_INFO "%s tlx415 chip \n", dev->name); conf->txClear = 0; conf->txRetries = 1; conf->txRouting = 1; conf->txScrambled = 0; conf->rxParameter = 1; conf->txTimeoutMs = 4000; conf->waitCardTimeout = 100000; conf->receiveMode = ARLAN_RCV_CLEAN; memcpy_fromio(conf->siteName, arlan->name, 16); conf->siteName[16] = '\0'; conf->retries = retries;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -