📄 skge.c
字号:
#ifdef ENABLE_FUTURE_ETH SET_ETHTOOL_OPS(dev, &sk98lin_ethtool_ops);#endif dev->open = &SkGeOpen; dev->stop = &SkGeClose; dev->get_stats = &SkGeStats; dev->set_multicast_list = &SkGeSetRxMode; dev->set_mac_address = &SkGeSetMacAddr; dev->do_ioctl = &SkGeIoctl; dev->change_mtu = &SkGeChangeMtu; dev->flags &= ~IFF_RUNNING;#ifdef SK_POLL_CONTROLLER dev->poll_controller = SkGeNetPoll;#endif SET_NETDEV_DEV(dev, &pdev->dev); pAC->Index = sk98lin_boards_found; if (SkGeBoardInit(dev, pAC)) { free_netdev(dev); return -ENODEV; } else { ProductStr(pAC); } if (pci_using_dac) dev->features |= NETIF_F_HIGHDMA; /* shifter to later moment in time... */ if (CHIP_ID_YUKON_2(pAC)) { dev->hard_start_xmit = &SkY2Xmit;#ifdef CONFIG_SK98LIN_NAPI dev->poll = &SkY2Poll; dev->weight = 64;#endif } else { dev->hard_start_xmit = &SkGeXmit;#ifdef CONFIG_SK98LIN_NAPI dev->poll = &SkGePoll; dev->weight = 64;#endif }#ifdef NETIF_F_TSO#ifdef USE_SK_TSO_FEATURE if (CHIP_ID_YUKON_2(pAC)) { dev->features |= NETIF_F_TSO; }#endif#endif#ifdef CONFIG_SK98LIN_ZEROCOPY if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) dev->features |= NETIF_F_SG;#endif#ifdef USE_SK_TX_CHECKSUM if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) dev->features |= NETIF_F_IP_CSUM;#endif#ifdef USE_SK_RX_CHECKSUM pAC->RxPort[0].UseRxCsum = SK_TRUE; if (pAC->GIni.GIMacsFound == 2 ) { pAC->RxPort[1].UseRxCsum = SK_TRUE; }#endif /* Save the hardware revision */ pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) + (pAC->GIni.GIPciHwRev & 0x0F); /* Set driver globals */ pAC->Pnmi.pDriverFileName = DRIVER_FILE_NAME; pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE; SK_MEMSET(&(pAC->PnmiBackup), 0, sizeof(SK_PNMI_STRUCT_DATA)); SK_MEMCPY(&(pAC->PnmiBackup), &(pAC->PnmiStruct), sizeof(SK_PNMI_STRUCT_DATA)); /* Register net device */ retval = register_netdev(dev); if (retval) { printk(KERN_ERR "SKGE: Could not register device.\n"); FreeResources(dev); free_netdev(dev); return retval; } /* Save initial device name */ strcpy(pNet->InitialDevName, dev->name); /* Set network to off */ netif_stop_queue(dev); netif_carrier_off(dev); /* Print adapter specific string from vpd and config settings */ printk("%s: %s\n", pNet->InitialDevName, pAC->DeviceStr); printk(" PrefPort:%c RlmtMode:%s\n", 'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber, (pAC->RlmtMode==0) ? "Check Link State" : ((pAC->RlmtMode==1) ? "Check Link State" : ((pAC->RlmtMode==3) ? "Check Local Port" : ((pAC->RlmtMode==7) ? "Check Segmentation" : ((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error"))))); SkGeYellowLED(pAC, pAC->IoBase, 1); memcpy((caddr_t) &dev->dev_addr, (caddr_t) &pAC->Addr.Net[0].CurrentMacAddress, 6); /* First adapter... Create proc and print message */#ifdef CONFIG_PROC_FS if (!sk98lin_proc_entry) { sk98lin_proc_entry = SK_TRUE; SK_MEMCPY(&SK_Root_Dir_entry, BootString, sizeof(SK_Root_Dir_entry) - 1); /*Create proc (directory)*/ if(!pSkRootDir) {#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);#else pSkRootDir = proc_mkdir(SK_Root_Dir_entry, init_net.proc_net);#endif if (!pSkRootDir) { printk(KERN_WARNING "%s: Unable to create /proc/net/%s", dev->name, SK_Root_Dir_entry); } else { pSkRootDir->owner = THIS_MODULE; } } } /* Create proc file */ /* No further proc file creation here */#endif pNet->PortNr = 0; pNet->NetNr = 0; sk98lin_boards_found++; pci_set_drvdata(pdev, dev); /* More then one port found */ if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { dev = alloc_etherdev(sizeof(DEV_NET)); if (!dev) { printk(KERN_ERR "Unable to allocate etherdev " "structure!\n"); return -ENODEV; } pAC->dev[1] = dev; pNet = dev->priv; pNet->PortNr = 1; pNet->NetNr = 1; pNet->pAC = pAC; if (CHIP_ID_YUKON_2(pAC)) { dev->hard_start_xmit = &SkY2Xmit;#ifdef CONFIG_SK98LIN_NAPI dev->poll = &SkY2Poll; dev->weight = 64;#endif } else { dev->hard_start_xmit = &SkGeXmit;#ifdef CONFIG_SK98LIN_NAPI dev->poll = &SkGePoll; dev->weight = 64;#endif }#ifdef ENABLE_FUTURE_ETH SET_ETHTOOL_OPS(dev, &sk98lin_ethtool_ops);#endif dev->open = &SkGeOpen; dev->stop = &SkGeClose; dev->get_stats = &SkGeStats; dev->set_multicast_list = &SkGeSetRxMode; dev->set_mac_address = &SkGeSetMacAddr; dev->do_ioctl = &SkGeIoctl; dev->change_mtu = &SkGeChangeMtu; dev->flags &= ~IFF_RUNNING;#ifdef SK_POLL_CONTROLLER dev->poll_controller = SkGeNetPoll;#endif#ifdef NETIF_F_TSO#ifdef USE_SK_TSO_FEATURE if (CHIP_ID_YUKON_2(pAC)) { dev->features |= NETIF_F_TSO; }#endif#endif#ifdef CONFIG_SK98LIN_ZEROCOPY /* Don't handle if Genesis chipset */ if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) dev->features |= NETIF_F_SG;#endif#ifdef USE_SK_TX_CHECKSUM /* Don't handle if Genesis chipset */ if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) dev->features |= NETIF_F_IP_CSUM;#endif if (register_netdev(dev)) { printk(KERN_ERR "SKGE: Could not register device.\n"); free_netdev(dev); pAC->dev[1] = pAC->dev[0]; } else { /* Save initial device name */ strcpy(pNet->InitialDevName, dev->name); /* Set network to off */ netif_stop_queue(dev); netif_carrier_off(dev);#ifdef CONFIG_PROC_FS /* No further proc file creation here */#endif memcpy((caddr_t) &dev->dev_addr, (caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6); printk("%s: %s\n", pNet->InitialDevName, pAC->DeviceStr); printk(" PrefPort:B RlmtMode:Dual Check Link State\n"); } } pAC->Index = sk98lin_boards_found; sk98lin_max_boards_found = sk98lin_boards_found; return 0;}/***************************************************************************** * * SkGeInitPCI - Init the PCI resources * * Description: * This function initialize the PCI resources and IO * * Returns: N/A * */static int SkGeInitPCI(SK_AC *pAC){ struct SK_NET_DEVICE *dev = pAC->dev[0]; struct pci_dev *pdev = pAC->PciDev; int retval; if (pci_enable_device(pdev) != 0) { return 1; } dev->mem_start = pci_resource_start (pdev, 0); pci_set_master(pdev); if (pci_request_regions(pdev, DRIVER_FILE_NAME) != 0) { retval = 2; goto out_disable; }#ifdef SK_BIG_ENDIAN /* * On big endian machines, we use the adapter's aibility of * reading the descriptors as big endian. */ { SK_U32 our2; SkPciReadCfgDWord(pAC, PCI_OUR_REG_2, &our2); our2 |= PCI_REV_DESC; SkPciWriteCfgDWord(pAC, PCI_OUR_REG_2, our2); }#endif /* * Remap the regs into kernel space. */ pAC->IoBase = ioremap_nocache(dev->mem_start, 0x4000); if (!pAC->IoBase){ retval = 3; goto out_release; } return 0; out_release: pci_release_regions(pdev); out_disable: pci_disable_device(pdev); return retval;}#ifdef CONFIG_PROC_FS/***************************************************************************** * * SkGeHandleProcfsTimer - Handle the procfs timer requests * * Description: * Checks, if the device's name changed. If this is the case * it deletes the old profs entry and creates a new one with * the new name. * * Returns: N/A * */static void SkGeHandleProcfsTimer(unsigned long ptr){ DEV_NET *pNet = (DEV_NET*) ptr; struct proc_dir_entry *pProcFile; /* * If the current name and the last saved name of the device differ * we need to update our procfs entry. */ if ( (pSkRootDir) && (strcmp(pNet->CurrentName, pNet->pAC->dev[pNet->NetNr]->name) != 0) ) { if (pNet->pAC->InterfaceUp[pNet->NetNr] == 1) remove_proc_entry(pNet->CurrentName, pSkRootDir); /* * InterfaceUp only holds 1 if both the network interface is up and * the corresponding procfs entry is done. Otherwise it is set to 0. */ pNet->pAC->InterfaceUp[pNet->NetNr] = 0; pProcFile = create_proc_entry(pNet->pAC->dev[pNet->NetNr]->name, S_IRUGO, pSkRootDir); pProcFile->proc_fops = &sk_proc_fops; pProcFile->data = pNet->pAC->dev[pNet->NetNr]; /* * Remember, interface dev nr pNet->NetNr is up and procfs entry is created. */ pNet->pAC->InterfaceUp[pNet->NetNr] = 1; strcpy(pNet->CurrentName, pNet->pAC->dev[pNet->NetNr]->name); } /* * Restart Procfs Timer */ pNet->ProcfsTimer.expires = jiffies + HZ*5; /* 5 secs */ add_timer(&pNet->ProcfsTimer);}#endif#ifdef USE_ASF_DASH_FWstatic void SkGeHandleLLCTimer(unsigned long ptr) /* holds the pointer to adapter control context */{ DEV_NET *pNet = (DEV_NET*) ptr; SK_AC *pAC = pNet->pAC; if ( (pAC->MaxPorts > 0) && (pAC->SendLLCPacket == 1) ) { pAC->SendLLCPacket = 0;// Ok, we waited! Now send... printk("sk98lin: Sending LLC test command\n"); SkSendLLCPacket(pAC, pAC->IoBase, 0); }} /* SkGeHandleLLCTimer */static void SkGeHandleWakeupTimer(unsigned long ptr) /* holds the pointer to adapter control context */{ DEV_NET *pNet = (DEV_NET*) ptr; SK_AC *pAC = pNet->pAC; static SK_U8 CntNetWUPP = 0; /* Count Network Stack Wake Up Packet Passes */ SK_U8 ret8 = 0; if (pAC->ReceivedPacket == SK_FALSE) { if ((pAC->SendWolPattern == SK_TRUE) && (pAC->MaxPorts > 0)) { CntNetWUPP++; if (CntNetWUPP > 5) { printk("sk98lin: Wakeup packet could not be passed to protocol stack (more than 5 retries)\n"); pAC->SendWolPattern = SK_FALSE; CntNetWUPP = 0; } else { /* Read pattern from ASF Fifo and send it up the stack. */ SetRamAddr(pAC, SK_ST_FIFOTYPE, SK_ST_BUFADDR_LOW, SK_ST_BUFADDR_HIGH); ret8 = AccessRamBuf(pAC, SK_ST_BUFSIZE, SK_TRUE); if (ret8 == 0) { pAC->SendWolPattern = SK_FALSE; printk("sk98lin: Wakeup packet passed to protocol stack (%u retries)\n", (CntNetWUPP-1) ); CntNetWUPP = 0; } if (ret8 == 2) { pAC->SendWolPattern = SK_FALSE; printk("sk98lin: No wakeup packet passed to protocol stack (other reason)\n"); CntNetWUPP = 0; } } } if (ret8 == 1) { pNet->WakeupTimer.expires = jiffies + (HZ/4); // 0.25s later... add_timer(&pNet->WakeupTimer); } }} /* SkGeHandleWakeupTimer */#endif#ifdef Y2_RECOVERY/***************************************************************************** * * SkGeHandleKernelTimer - Handle the kernel timer requests * * Description: * If the requested time interval for the timer has elapsed, * this function checks the link state. * * Returns: N/A * */static void SkGeHandleKernelTimer(unsigned long ptr) /* holds the pointer to adapter control context */{ DEV_NET *pNet = (DEV_NET*) ptr; SkGeCheckTimer(pNet); }/***************************************************************************** * * sk98lin_check_timer - Resume the the card * * Description: * This function checks the kernel timer * * Returns: N/A * */void SkGeCheckTimer(DEV_NET *pNet) /* holds the pointer to adapter control context */{ SK_AC *pAC = pNet->pAC; SK_BOOL StartTimer = SK_TRUE; SK_U32 StatSpeed, StatDuplex, NewTimerInterval;#ifdef SK_EXTREME if (HW_IS_EXT_LE_FORMAT(pAC)) { /* Disable checks for Yukon Extreme */ return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -