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

📄 e1000_main.c

📁 COPE the first practical network coding scheme which is developped on click
💻 C
📖 第 1 页 / 共 5 页
字号:
/***************************************************************************** *****************************************************************************Copyright (c) 1999 - 2000, Intel Corporation All rights reserved.Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice,     this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice,    this list of conditions and the following disclaimer in the documentation     and/or other materials provided with the distribution. 3. Neither the name of Intel Corporation nor the names of its contributors     may be used to endorse or promote products derived from this software     without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, ORPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  ***************************************************************************** ****************************************************************************//***********************************************************************                                                                     ** INTEL CORPORATION                                                   **                                                                     ** This software is supplied under the terms of the license included   ** above.  All use of this driver must be in accordance with the terms ** of that license.                                                    **                                                                     ** Module Name:  e1000.c                                               **                                                                     ** Abstract:     Functions for the driver entry points like load,      **               unload, open and close. All board specific calls made **               by the network interface section of the driver.       **                                                                     ** Environment:  This file is intended to be specific to the Linux     **               operating system.                                     **                                                                     ***********************************************************************/ /* This first section contains the setable parametes for configuring the  * driver into the kernel. */#define E1000_DEBUG_DEFAULT 0static int e1000_debug_level = E1000_DEBUG_DEFAULT;/* global defines */#define MAX_TCB      256            /* number of transmit descriptors */#define MAX_RFD      256            /* number of receive descriptors *//* includes */#ifdef MODULE#ifdef MODVERSIONS#include <linux/modversions.h>#endif#include <linux/module.h>#endif#define E1000_MAIN_STATIC#ifdef IANS#define _IANS_MAIN_MODULE_C_#endif#include "e1000.h"#include "e1000_vendor_info.h"#include "e1000_proc.h"/* Global Data structures and variables */static const char *version ="Intel(R) PRO/1000 Gigabit Ethernet Adapter - Loadable driver, ver. 2.5.11\n";static char e1000_copyright[] = "         Copyright (c) 1999-2000 Intel Corporation\n";static char e1000id_string[128] = "Intel(R) PRO/1000 Gigabit Server Adapter";static char e1000_driver[] = "e1000";static char e1000_version[] = "2.5.11";static bd_config_t *e1000first = NULL;static int e1000boards = 0;static int e1000_rxfree_cnt = 0;/* Driver performance tuning variables */static uint_t e1000_pcimlt_override = 0;static uint_t e1000_pcimwi_enable = 1;static uint_t e1000_txint_delay = 128;#if 1static uint_t e1000_rxint_delay = 128; /* RTM turn on rcv intr coalescing? microseconds? */#elsestatic uint_t e1000_rxint_delay = 0;#endif#if 1static int e1000_flow_ctrl = 0; /* RTM turn off flow control */#elsestatic int e1000_flow_ctrl = 3;#endifstatic int e1000_rxpci_priority = 0;static uint_t e1000_maxdpc_count = 5;static int TxDescriptors[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };static int RxDescriptors[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };/* Feature enable/disable */static int Jumbo[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };static int WaitForLink[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };static int SBP[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };/* Speed and Duplex Settings */static int AutoNeg[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };static int Speed[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };static int ForceDuplex[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };/* This parameter determines whether the driver sets the RS bit or the * RPS bit in a transmit packet. These are the possible values for this * parameter: * e1000_ReportTxEarly = 0  ==>  set the RPS bit *                      = 1  ==>  set the RS bit *                      = 2  ==>  (default) let the driver auto-detect * * If the RS bit is set in a packet, an interrupts is generated as soon * as the packet is DMAed from host memory to the FIFO. If the RPS bit * is set, an interrupt is generated after the packet has been transmitted * on the wire. */static uchar_t e1000_ReportTxEarly = 2;    /* let the driver auto-detect *//* these next ones are for Linux specific things */static int probed = 0;static int e1000_tx_queue(struct device *dev, struct sk_buff *skb);static int e1000_tx_start(struct device *dev);static int e1000_rx_refill(struct device *dev, struct sk_buff **);static int e1000_tx_eob(struct device *dev);static struct sk_buff *e1000_tx_clean(struct device *dev);static struct sk_buff *e1000_rx_poll(struct device *dev, int *want);static int e1000_poll_on(struct device *dev);static int e1000_poll_off(struct device *dev);/* The system interface routines *//***************************************************************************** Name:        e1000_probe** Description: This routine is called when the dynamic driver module*              "e1000" is loaded using the command "insmod".**               This is a Linux required routine.** Author:      IntelCorporation** Born on Date:    07/11/99** Arguments:   *       NONE** Returns:** Modification log:* Date      Who  Description* --------  ---  -------------------------------------------------------- *****************************************************************************/inte1000_probe(){    device_t *dev;    bd_config_t *bdp;    PADAPTER_STRUCT Adapter;    pci_dev_t *pcid = NULL;    int num_boards = 0;    int first_time = 0, loop_cnt = 0;    if (e1000_debug_level >= 1)        printk("e1000_probe()\n");    /* Has the probe routine been called before? The driver can be probed only     * once.     */    if (probed)        return (0);    else        probed++;    /* does the system support pci? */    if ((!CONFIG_PCI) || (!pci_present()))        return (0);#ifdef CONFIG_PROC_FS  {    int     len;    /* first check if e1000_proc_dir already exists */    len = strlen(ADAPTERS_PROC_DIR);    for (e1000_proc_dir=proc_net->subdir;e1000_proc_dir;        e1000_proc_dir=e1000_proc_dir->next) {        if ((e1000_proc_dir->namelen == len) &&            (!memcmp(e1000_proc_dir->name, ADAPTERS_PROC_DIR, len)))            break;        }        if (!e1000_proc_dir)            e1000_proc_dir =                 create_proc_entry(ADAPTERS_PROC_DIR, S_IFDIR, proc_net);        if (!e1000_proc_dir) return -ENODEV;  }#endif        /* loop through all of the ethernet PCI devices looking for ours */    while ((pcid = pci_find_class(PCI_CLASS_NETWORK_ETHERNET << 8, pcid))) {        dev = NULL;        if (e1000_debug_level >= 2)            printk("e1000_probe: vendor = 0x%x, device = 0x%x \n",                     pcid->vendor, pcid->device);                         /* is the device ours? */        if ((pcid->vendor != E1000_VENDOR_ID) ||            !((pcid->device == WISEMAN_DEVICE_ID) ||              (pcid->device == LIVENGOOD_FIBER_DEVICE_ID) ||              (pcid->device == LIVENGOOD_COPPER_DEVICE_ID))) continue;    /* No, continue */        if (!first_time) {            /* only display the version message one time */            first_time = 1;            /* print out the version */            printk("%s", version);            printk("%s\n", e1000_copyright);        }        /* register the net device, but don't allocate a private structure yet */        dev = init_etherdev(dev, 0);        if (dev == NULL) {            printk(KERN_ERR "Not able to alloc etherdev struct\n");            break;        }        /* Allocate all the memory that the driver will need */        if (!(bdp = e1000_alloc_space())) {            printk("%s - Failed to allocate memory\n", e1000_driver);            e1000_dealloc_space(bdp);            return 0;        }        bdp->device = dev;#ifdef CONFIG_PROC_FS        if (e1000_create_proc_dev(bdp) < 0) {            e1000_remove_proc_dev(dev);            e1000_dealloc_space(bdp);            continue; /*return e100nics;*/        }#endif                /* init the timer */        bdp->timer_val = -1;        /* point the Adapter to the bddp */        Adapter = (PADAPTER_STRUCT) bdp->bddp;#ifdef IANS        bdp->iANSdata = kmalloc(sizeof(iANSsupport_t), GFP_KERNEL);        memset((PVOID) bdp->iANSdata, 0, sizeof(iANSsupport_t));        bd_ans_drv_InitANS(bdp, bdp->iANSdata);#endif        /*         * Obtain the PCI specific information about the driver.         */        if (e1000_find_pci_device(pcid, Adapter) == 0) {            printk("%s - Failed to find PCI device\n", e1000_driver);            return (0);        }          /* range check the command line parameters for this board */        if(!e1000_GetBrandingMesg(Adapter->DeviceId, Adapter->SubVendorId, Adapter->SubSystemId)) {            continue;            }            printk("%s\n", e1000id_string);         e1000_check_options(loop_cnt);    switch (Speed[loop_cnt]) {    case SPEED_10:        switch(ForceDuplex[loop_cnt]) {        case HALF_DUPLEX:            Adapter->AutoNeg = 0;            Adapter->ForcedSpeedDuplex = HALF_10;            break;        case FULL_DUPLEX:            Adapter->AutoNeg = 0;            Adapter->ForcedSpeedDuplex = FULL_10;            break;        default:            Adapter->AutoNeg = 1;            Adapter->AutoNegAdvertised =                ADVERTISE_10_HALF | ADVERTISE_10_FULL;        }        break;    case SPEED_100:        switch(ForceDuplex[loop_cnt]) {        case HALF_DUPLEX:            Adapter->AutoNeg = 0;            Adapter->ForcedSpeedDuplex = HALF_100;            break;        case FULL_DUPLEX:            Adapter->AutoNeg = 0;            Adapter->ForcedSpeedDuplex = FULL_100;            break;        default:            Adapter->AutoNeg = 1;            Adapter->AutoNegAdvertised =                ADVERTISE_100_HALF | ADVERTISE_100_FULL;        }        break;    case SPEED_1000:        Adapter->AutoNeg = 1;        Adapter->AutoNegAdvertised = ADVERTISE_1000_FULL;        break;    default:        Adapter->AutoNeg = 1;        switch(ForceDuplex[loop_cnt]) {        case HALF_DUPLEX:            Adapter->AutoNegAdvertised =                 ADVERTISE_10_HALF | ADVERTISE_100_HALF;             break;        case FULL_DUPLEX:            Adapter->AutoNegAdvertised =                 ADVERTISE_10_FULL | ADVERTISE_100_FULL | ADVERTISE_1000_FULL;             break;        default:            Adapter->AutoNegAdvertised = AutoNeg[loop_cnt];        }    }        Adapter->WaitAutoNegComplete = WaitForLink[loop_cnt];        /* Set Adapter->MacType */        switch (pcid->device) {        case WISEMAN_DEVICE_ID:            if (Adapter->RevID == WISEMAN_2_0_REV_ID)                Adapter->MacType = MAC_WISEMAN_2_0;            else {                if (Adapter->RevID == WISEMAN_2_1_REV_ID)                    Adapter->MacType = MAC_WISEMAN_2_1;                else {                    Adapter->MacType = MAC_WISEMAN_2_0;                    printk(KERN_ERR                           "Could not identify hardware revision\n");                }            }            break;        case LIVENGOOD_FIBER_DEVICE_ID:        case LIVENGOOD_COPPER_DEVICE_ID:            Adapter->MacType = MAC_LIVENGOOD;            break;        default:            Adapter->MacType = MAC_WISEMAN_2_0;            printk(KERN_ERR "Could not identify hardware revision\n");            break;        }        /* save off the needed information */        bdp->device = dev;        dev->priv = bdp;        Adapter = bdp->bddp;        /* save off the pci device structure pointer */        Adapter->pci_dev = pcid;        bdp->vendor = pcid->vendor;        /* set the irq into the dev and bdp structures */        dev->irq = pcid->irq;        bdp->irq_level = pcid->irq;        /* point to all of our entry point to let the system know where we are */        dev->open = &e1000_open;        dev->hard_start_xmit = &e1000_xmit_frame;        dev->stop = &e1000_close;        dev->get_stats = &e1000_get_stats;        dev->set_multicast_list = &e1000_set_multi;        dev->set_mac_address = &e1000_set_mac;        dev->change_mtu = &e1000_change_mtu;#ifdef IANS        dev->do_ioctl = &bd_ans_os_Ioctl;#endif        /* set memory base addr */        dev->base_addr = pci_resource_start(pcid, 0);#ifdef CLICK_POLLING	/* Click - polling extensions */	dev->polling = 0;	dev->rx_poll = e1000_rx_poll;	dev->rx_refill = e1000_rx_refill;

⌨️ 快捷键说明

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