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

📄 e100_proc.c

📁 linux intel 网卡驱动,利用他可以让inel的pro 100 网卡进行网络配置和实用
💻 C
📖 第 1 页 / 共 3 页
字号:
/*******************************************************************************    Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved.    This program is free software; you can redistribute it and/or modify it   under the terms of the GNU General Public License as published by the Free   Software Foundation; either version 2 of the License, or (at your option)   any later version.    This program is distributed in the hope that it will be useful, but WITHOUT   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   more details.    You should have received a copy of the GNU General Public License along with  this program; if not, write to the Free Software Foundation, Inc., 59   Temple Place - Suite 330, Boston, MA  02111-1307, USA.    The full GNU General Public License is included in this distribution in the  file called LICENSE.    Contact Information:  Linux NICS <linux.nics@intel.com>  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497*******************************************************************************//***********************************************************************                                                                       ** 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:  e100_proc.c                                             **                                                                       ** Abstract:     Functions to handle the proc file system.               **               Create the proc directories and files and run read and  **               write requests from the user                            **                                                                       ** Environment:  This file is intended to be specific to the Linux       **               operating system.                                       **                                                                       ***********************************************************************/#include <linux/config.h>#ifdef CONFIG_PROC_FS#include "e100.h"#include "e100_phy.h"/* MDI sleep time is at least 50 ms, in jiffies */#define MDI_SLEEP_TIME ((HZ / 20) + 1)/***************************************************************************//*       /proc File System Interaface Support Functions                    *//***************************************************************************/static struct proc_dir_entry *adapters_proc_dir = 0;/* externs from e100_main.c */extern char e100_short_driver_name[];extern char e100_driver_version[];extern struct net_device_stats *e100_get_stats(struct net_device *dev);extern char *e100_get_brand_msg(struct e100_private *bdp);extern int e100_mdi_write(struct e100_private *, u32, u32, u16);static void e100_proc_cleanup(void);static unsigned char e100_init_proc_dir(void);#define E100_EOU#define ADAPTERS_PROC_DIR "PRO_LAN_Adapters"#define WRITE_BUF_MAX_LEN 20	#define READ_BUF_MAX_LEN  256#define E100_PE_LEN       25#define bdp_net_off(off) (unsigned long)(offsetof(struct e100_private, drv_stats.net_stats.off))#define bdp_drv_off(off) (unsigned long)(offsetof(struct e100_private, drv_stats.off))#define bdp_prm_off(off) (unsigned long)(offsetof(struct e100_private, params.off))typedef struct _e100_proc_entry {	char *name;	read_proc_t *read_proc;	write_proc_t *write_proc;	unsigned long offset;	/* offset into bdp. ~0 means no value, pass NULL. */} e100_proc_entry;static intgeneric_read(char *page, char **start, off_t off, int count, int *eof, int len){	if (len <= off + count)		*eof = 1;	*start = page + off;	len -= off;	if (len > count)		len = count;	if (len < 0)		len = 0;	return len;}static intread_ulong(char *page, char **start, off_t off,	   int count, int *eof, unsigned long l){	int len;	len = sprintf(page, "%lu\n", l);	return generic_read(page, start, off, count, eof, len);}static intread_ulong_hex(char *page, char **start, off_t off,	       int count, int *eof, unsigned long l){	int len;	len = sprintf(page, "0x%04lx\n", l);	return generic_read(page, start, off, count, eof, len);}static intread_gen_ulong(char *page, char **start, off_t off,	       int count, int *eof, void *data){	unsigned long val = 0;	if (data)		val = *((unsigned long *) data);	return read_ulong(page, start, off, count, eof, val);}static intread_hwaddr(char *page, char **start, off_t off,	    int count, int *eof, unsigned char *hwaddr){	int len;	len = sprintf(page, "%02X:%02X:%02X:%02X:%02X:%02X\n",		      hwaddr[0], hwaddr[1], hwaddr[2],		      hwaddr[3], hwaddr[4], hwaddr[5]);	return generic_read(page, start, off, count, eof, len);}static intread_descr(char *page, char **start, off_t off, int count, int *eof, void *data){	struct e100_private *bdp = data;	int len;	len = sprintf(page, "%s\n", bdp->id_string);	return generic_read(page, start, off, count, eof, len);}static intread_mdix_status(char *page, char **start, off_t off,		 int count, int *eof, void *data){	struct e100_private *bdp = data;	int len;	len = sprintf(page, "%s\n", bdp->mdix_status);		return generic_read(page, start, off, count, eof, len);}static intread_cable_status(char *page, char **start, off_t off,		  int count, int *eof, void *data){	struct e100_private *bdp = data;	int len;	len = sprintf(page, "%s\n", bdp->cable_status);	return generic_read(page, start, off, count, eof, len);}static intread_drvr_name(char *page, char **start, off_t off,	       int count, int *eof, void *data){	int len;	len = sprintf(page, "%s\n", e100_short_driver_name);	return generic_read(page, start, off, count, eof, len);}static intread_drvr_ver(char *page, char **start, off_t off,	      int count, int *eof, void *data){	int len;	len = sprintf(page, "%s\n", e100_driver_version);	return generic_read(page, start, off, count, eof, len);}static intread_pci_vendor(char *page, char **start, off_t off,		int count, int *eof, void *data){	unsigned long val;	struct e100_private *bdp = data;	val = (unsigned long) bdp->pdev->vendor;	return read_ulong_hex(page, start, off, count, eof, val);}static intread_pci_device(char *page, char **start, off_t off,		int count, int *eof, void *data){	unsigned long val;	struct e100_private *bdp = data;	val = (unsigned long) bdp->pdev->device;	return read_ulong_hex(page, start, off, count, eof, val);}static intread_pci_sub_vendor(char *page, char **start, off_t off,		    int count, int *eof, void *data){	unsigned long val;	struct e100_private *bdp = data;#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)	val = (unsigned long) bdp->sub_ven_id;#else	val = (unsigned long) bdp->pdev->subsystem_vendor;#endif	return read_ulong_hex(page, start, off, count, eof, val);}static intread_pci_sub_device(char *page, char **start, off_t off,		    int count, int *eof, void *data){	unsigned long val;	struct e100_private *bdp = data;#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)	val = (unsigned long) bdp->sub_dev_id;#else	val = (unsigned long) bdp->pdev->subsystem_device;#endif	return read_ulong_hex(page, start, off, count, eof, val);}static intread_pci_revision(char *page, char **start, off_t off,		  int count, int *eof, void *data){	unsigned long val;	struct e100_private *bdp = data;	val = (unsigned long) bdp->rev_id;	return read_ulong_hex(page, start, off, count, eof, val);}static intread_pci_bus(char *page, char **start, off_t off,	     int count, int *eof, void *data){	unsigned long val;	struct e100_private *bdp = data;	val = (unsigned long) bdp->pdev->bus->number;	return read_ulong(page, start, off, count, eof, val);}static intread_pci_slot(char *page, char **start, off_t off,	      int count, int *eof, void *data){	unsigned long val;	struct e100_private *bdp = data;	val = (unsigned long) (PCI_SLOT(bdp->pdev->devfn));	return read_ulong(page, start, off, count, eof, val);}static intread_irq(char *page, char **start, off_t off, int count, int *eof, void *data){	unsigned long val;	struct e100_private *bdp = data;	val = (unsigned long) (bdp->device->irq);	return read_ulong(page, start, off, count, eof, val);}static intread_dev_name(char *page, char **start, off_t off,	      int count, int *eof, void *data){	struct e100_private *bdp = data;	int len;	len = sprintf(page, "%s\n", bdp->device->name);	return generic_read(page, start, off, count, eof, len);}static intread_current_hwaddr(char *page, char **start, off_t off,		    int count, int *eof, void *data){	struct e100_private *bdp = data;	unsigned char *hwaddr = bdp->device->dev_addr;	return read_hwaddr(page, start, off, count, eof, hwaddr);}static intread_permanent_hwaddr(char *page, char **start, off_t off,		      int count, int *eof, void *data){	struct e100_private *bdp = data;	unsigned char *hwaddr = bdp->perm_node_address;	return read_hwaddr(page, start, off, count, eof, hwaddr);}static intread_part_number(char *page, char **start, off_t off,		 int count, int *eof, void *data){	struct e100_private *bdp = data;	int len;	len = sprintf(page, "%06lx-%03x\n",		      (unsigned long) (bdp->pwa_no >> 8),		      (unsigned int) (bdp->pwa_no & 0xFF));	return generic_read(page, start, off, count, eof, len);}static intread_link_status(char *page, char **start, off_t off,		 int count, int *eof, void *data){	struct e100_private *bdp = data;	int len;#ifdef IANS	if (bdp->flags & DF_OPENED) {#else	if (netif_running(bdp->device)) {#endif		if (netif_carrier_ok(bdp->device))			len = sprintf(page, "up\n");		else			len = sprintf(page, "down\n");	} else {		len = sprintf(page, "N/A\n");	}	return generic_read(page, start, off, count, eof, len);}static intread_speed(char *page, char **start, off_t off, int count, int *eof, void *data){	struct e100_private *bdp = data;	int len;	if (netif_carrier_ok(bdp->device))		return read_ulong(page, start, off, count, eof,				  (unsigned long) (bdp->cur_line_speed));	len = sprintf(page, "N/A\n");	return generic_read(page, start, off, count, eof, len);}static intread_dplx_mode(char *page, char **start, off_t off,	       int count, int *eof, void *data){	struct e100_private *bdp = data;	int len;	if (netif_carrier_ok(bdp->device)) {		if (bdp->cur_dplx_mode == FULL_DUPLEX)			len = sprintf(page, "full\n");		else			len = sprintf(page, "half\n");	} else {		len = sprintf(page, "N/A\n");	}	return generic_read(page, start, off, count, eof, len);}

⌨️ 快捷键说明

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