📄 e1000_proc.c
字号:
/***************************************************************************** ***************************************************************************** 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, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 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. *********************************************************************************************************************************************************//***************************************************************************//* /proc File System Interaface Support Functions *//***************************************************************************/#include "e1000.h"extern char e1000_driver[];extern char e1000_version[];extern char *e1000id_string;#include "e1000_proc.h"#include <linux/proc_fs.h>struct proc_dir_entry *e1000_proc_dir;static int e1000_generic_read(char *page, char **start, off_t off, int count, int *eof){ int len; len = strlen(page); page[len++] = '\n'; if (len <= off + count) *eof = 1; *start = page + off; len -= off; if (len > count) len = count; if (len < 0) len = 0; return len;}static int e1000_read_ulong(char *page, char **start, off_t off, int count, int *eof, unsigned long l){ sprintf(page, "%lu", l); return e1000_generic_read(page, start, off, count, eof);}static int e1000_read_ulong_hex(char *page, char **start, off_t off, int count, int *eof, unsigned long l){ sprintf(page, "0x%04lx", l); return e1000_generic_read(page, start, off, count, eof);}static int e1000_read_hwaddr(char *page, char **start, off_t off, int count, int *eof, unsigned char *hwaddr){ sprintf(page, "%02X:%02X:%02X:%02X:%02X:%02X", hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]); return e1000_generic_read(page, start, off, count, eof);}/* need to check page boundaries !!! */static int e1000_read_info(char *page, char **start, off_t off, int count, int *eof, void *data){ bd_config_t *bdp = (bd_config_t *) data; PADAPTER_STRUCT Adapter = bdp->bddp; struct net_device_stats *stats = &bdp->net_stats; unsigned char *hwaddr; char *pagep = page; char *msg;#if 0 e1000_GetBrandingMesg(Adapter->DeviceId, Adapter->SubVendorId, Adapter->SubSystemId); msg = e1000id_string; page += sprintf(page, "%-25s %s\n", DESCRIPTION_TAG, msg);#endif page += sprintf(page, "%-25s %s\n", DRVR_NAME_TAG, e1000_driver); page += sprintf(page, "%-25s %s\n", DRVR_VERSION_TAG, e1000_version); page += sprintf(page, "%-25s 0x%04lx\n", PCI_VENDOR_TAG, (unsigned long) Adapter->VendorId); page += sprintf(page, "%-25s 0x%04lx\n", PCI_DEVICE_ID_TAG, (unsigned long) Adapter->DeviceId); page += sprintf(page, "%-25s 0x%04lx\n", PCI_SUBSYSTEM_VENDOR_TAG, (unsigned long) Adapter->SubVendorId); page += sprintf(page, "%-25s 0x%04lx\n", PCI_SUBSYSTEM_ID_TAG, (unsigned long) Adapter->SubSystemId); page += sprintf(page, "%-25s 0x%02lx\n", PCI_REVISION_ID_TAG, (unsigned long) Adapter->RevID); page += sprintf(page, "%-25s %lu\n", PCI_BUS_TAG, (unsigned long) (Adapter->pci_dev->bus->number)); page += sprintf(page, "%-25s %lu\n", PCI_SLOT_TAG, (unsigned long) (PCI_SLOT((Adapter->pci_dev->devfn)))); page += sprintf(page, "%-25s %lu\n", IRQ_TAG, (unsigned long) (bdp->irq_level)); page += sprintf(page, "%-25s %s\n", SYSTEM_DEVICE_NAME_TAG, bdp->device->name); hwaddr = bdp->device->dev_addr; page += sprintf(page, "%-25s %02X:%02X:%02X:%02X:%02X:%02X\n", CURRENT_HWADDR_TAG, hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]); hwaddr = Adapter->perm_node_address; page += sprintf(page, "%-25s %02X:%02X:%02X:%02X:%02X:%02X\n", PERMANENT_HWADDR_TAG, hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]); page += sprintf(page, "\n"); if (Adapter->LinkIsActive == 1) msg = "up"; else msg = "down"; page += sprintf(page, "%-25s %s\n", LINK_TAG, msg); if (Adapter->cur_line_speed) page += sprintf(page, "%-25s %lu\n", SPEED_TAG, (unsigned long) (Adapter->cur_line_speed)); else page += sprintf(page, "%-25s %s\n", SPEED_TAG, "N/A"); msg = Adapter->FullDuplex == FULL_DUPLEX ? "full" : ((Adapter->FullDuplex == 0) ? "N/A" : "half"); page += sprintf(page, "%-25s %s\n", DUPLEX_TAG, msg); if (bdp->device->flags & IFF_UP) msg = "up"; else msg = "down"; page += sprintf(page, "%-25s %s\n", STATE_TAG, msg); page += sprintf(page, "\n"); page += sprintf(page, "%-25s %lu\n", RX_PACKETS_TAG, (unsigned long) stats->rx_packets); page += sprintf(page, "%-25s %lu\n", TX_PACKETS_TAG, (unsigned long) stats->tx_packets); page += sprintf(page, "%-25s %lu\n", RX_BYTES_TAG, (unsigned long) stats->rx_bytes); page += sprintf(page, "%-25s %lu\n", TX_BYTES_TAG, (unsigned long) stats->tx_bytes); page += sprintf(page, "%-25s %lu\n", RX_ERRORS_TAG, (unsigned long) stats->rx_errors); page += sprintf(page, "%-25s %lu\n", TX_ERRORS_TAG, (unsigned long) stats->tx_errors); page += sprintf(page, "%-25s %lu\n", RX_DROPPED_TAG, (unsigned long) stats->rx_dropped); page += sprintf(page, "%-25s %lu\n", TX_DROPPED_TAG, (unsigned long) stats->tx_dropped); page += sprintf(page, "%-25s %lu\n", MULTICAST_TAG, (unsigned long) stats->multicast); page += sprintf(page, "%-25s %lu\n", COLLISIONS_TAG, (unsigned long) stats->collisions); page += sprintf(page, "%-25s %lu\n", RX_LENGTH_ERRORS_TAG, (unsigned long) stats->rx_length_errors); page += sprintf(page, "%-25s %lu\n", RX_OVER_ERRORS_TAG, (unsigned long) stats->rx_over_errors); page += sprintf(page, "%-25s %lu\n", RX_CRC_ERRORS_TAG, (unsigned long) stats->rx_crc_errors); page += sprintf(page, "%-25s %lu\n", RX_FRAME_ERRORS_TAG, (unsigned long) stats->rx_frame_errors); page += sprintf(page, "%-25s %lu\n", RX_FIFO_ERRORS_TAG, (unsigned long) stats->rx_fifo_errors); page += sprintf(page, "%-25s %lu\n", RX_MISSED_ERRORS_TAG, (unsigned long) stats->rx_missed_errors); page += sprintf(page, "%-25s %lu\n", TX_ABORTED_ERRORS_TAG, (unsigned long) stats->tx_aborted_errors); page += sprintf(page, "%-25s %lu\n", TX_CARRIER_ERRORS_TAG, (unsigned long) stats->tx_carrier_errors); page += sprintf(page, "%-25s %lu\n", TX_FIFO_ERRORS_TAG, (unsigned long) stats->tx_fifo_errors); page += sprintf(page, "%-25s %lu\n", TX_HEARTBEAT_ERRORS_TAG, (unsigned long) stats->tx_heartbeat_errors); page += sprintf(page, "%-25s %lu\n", TX_WINDOW_ERRORS_TAG, (unsigned long) stats->tx_window_errors); page += sprintf(page, "\n"); /* 8254x specific stats */ page += sprintf(page, "%-25s %lu\n", TX_LATE_COLL_TAG, Adapter->TxLateCollisions); page += sprintf(page, "%-25s %lu\n", TX_DEFERRED_TAG, Adapter->DeferCount); page += sprintf(page, "%-25s %lu\n", TX_SINGLE_COLL_TAG, Adapter->SingleCollisions); page += sprintf(page, "%-25s %lu\n", TX_MULTI_COLL_TAG, Adapter->MultiCollisions); page += sprintf(page, "%-25s %lu\n", RX_LONG_ERRORS_TAG, Adapter->RcvOversizeCnt); page += sprintf(page, "%-25s %lu\n", RX_SHORT_ERRORS_TAG, Adapter->RcvUndersizeCnt); /* The 82542 does not have an alignment error count register */ /* ALGNERRC is only valid in MII mode at 10 or 100 Mbps */ if(Adapter->MacType >= MAC_LIVENGOOD) page += sprintf(page, "%-25s %lu\n", RX_ALIGN_ERRORS_TAG, Adapter->AlignmentErrors); page += sprintf(page, "%-25s %lu\n", RX_XON_TAG, Adapter->RcvXonFrame); page += sprintf(page, "%-25s %lu\n", RX_XOFF_TAG, Adapter->RcvXoffFrame); page += sprintf(page, "%-25s %lu\n", TX_XON_TAG, Adapter->TxXonFrame); page += sprintf(page, "%-25s %lu\n", TX_XOFF_TAG, Adapter->TxXoffFrame); *page = 0; return e1000_generic_read(pagep, start, off, count, eof);}#if 0static int e1000_read_descr(char *page, char **start, off_t off, int count, int *eof, void *data){ bd_config_t *bdp = (bd_config_t *) data; PADAPTER_STRUCT Adapter = bdp->bddp; char *msg; e1000_GetBrandingMesg(Adapter->DeviceId, Adapter->SubVendorId, Adapter->SubSystemId); msg = e1000id_string; strncpy(page, msg, PAGE_SIZE); return e1000_generic_read(page, start, off, count, eof);}#endifstatic int e1000_read_drvr_name(char *page, char **start, off_t off, int count, int *eof, void *data){ strncpy(page, e1000_driver, PAGE_SIZE); return e1000_generic_read(page, start, off, count, eof);}static int e1000_read_drvr_ver(char *page, char **start, off_t off, int count, int *eof, void *data){ strncpy(page, e1000_version, PAGE_SIZE); return e1000_generic_read(page, start, off, count, eof);}static int e1000_read_pci_vendor(char *page, char **start, off_t off, int count, int *eof, void *data){ bd_config_t *bdp = (bd_config_t *) data; PADAPTER_STRUCT Adapter = bdp->bddp; return e1000_read_ulong_hex(page, start, off, count, eof, (unsigned long) Adapter->VendorId);}static int e1000_read_pci_device(char *page, char **start, off_t off, int count, int *eof, void *data){ bd_config_t *bdp = (bd_config_t *) data; PADAPTER_STRUCT Adapter = bdp->bddp; return e1000_read_ulong_hex(page, start, off, count, eof, (unsigned long) Adapter->DeviceId);}static int e1000_read_pci_sub_vendor(char *page, char **start, off_t off, int count, int *eof, void *data){ bd_config_t *bdp = (bd_config_t *) data; PADAPTER_STRUCT Adapter = bdp->bddp; return e1000_read_ulong_hex(page, start, off, count, eof, (unsigned long) Adapter->SubVendorId);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -