Commit 7dbdd525 authored by Scott Feldman's avatar Scott Feldman Committed by David Mosberger
Browse files

Update e100 net driver:

Feedback from review by Arjan @ Redhat:
o Cleanup: Removed unneccesary #ifdef/#endif wrappers for features 
  already part of kernel.
o Bug fix: Added read-behind-write calls to post writes before delays.
o Cleanup: added "e100" prefix to all driver messages.
o Cleanup: removed unnecessary barrier() call because spin_unlock
  already implies a barrier.
o Cleanup: removed __NO_VERSION__
o Cleanup: fixed some spelling mistakes.
o Cleanup: removed some proprietary /proc entries.
parent c0e1c9e4
......@@ -95,10 +95,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <asm/io.h>
#include <asm/unaligned.h>
#include <asm/processor.h>
#ifdef SIOCETHTOOL
#include <linux/ethtool.h>
#include <linux/inetdevice.h>
#endif
#include <linux/if.h>
#include <asm/uaccess.h>
......@@ -782,15 +780,7 @@ typedef struct _tcb_ipcb_t {
u16 total_tcp_payload;
} tcb_ipcb_t __attribute__ ((__packed__));
#ifdef MAX_SKB_FRAGS
#define E100_ZEROCOPY
#endif
#ifdef E100_ZEROCOPY
#define E100_TBD_ARRAY_SIZE (2+MAX_SKB_FRAGS)
#else
#define E100_TBD_ARRAY_SIZE 2
#endif /*E100_ZEROCOPY */
/* Transmit Command Block (TCB)*/
struct _tcb_t {
......@@ -811,19 +801,15 @@ struct _tcb_t {
*/
tbd_t *tbd_ptr;
#ifdef E100_ZEROCOPY
u32 tcb_tbd_dflt_ptr; /* TBD address for non-segmented packet */
u32 tcb_tbd_expand_ptr; /* TBD address for segmented packet */
#endif /*E100_ZEROCOPY */
struct sk_buff *tcb_skb; /* the associated socket buffer */
dma_addr_t tcb_phys; /* phys addr of the TCB */
} __attribute__ ((__packed__));
#ifndef _TCB_T_
#define _TCB_T_
typedef struct _tcb_t tcb_t;
#endif
/* Receive Frame Descriptor (RFD) - will be using the simple model*/
struct _rfd_t {
......@@ -844,10 +830,8 @@ struct _rfd_t {
} __attribute__ ((__packed__));
#ifndef _RFD_T_
#define _RFD_T_
typedef struct _rfd_t rfd_t;
#endif
/* Receive Buffer Descriptor (RBD)*/
typedef struct _rbd_t {
......@@ -909,14 +893,12 @@ struct cfg_params {
int PollingMaxWork;
u32 b_params;
};
#ifdef ETHTOOL_TEST
struct ethtool_lpbk_data{
dma_addr_t dma_handle;
tcb_t *tcb;
rfd_t *rfd;
};
#endif
struct e100_private {
u32 flags; /* board management flags */
......@@ -1012,23 +994,16 @@ struct e100_private {
struct tasklet_struct polling_tasklet;
#ifdef ETHTOOL_GWOL
/* WOL params for ethtool */
u32 wolsupported;
u32 wolopts;
u16 ip_lbytes;
#endif
#ifdef ETHTOOL_TEST
struct ethtool_lpbk_data loopback;
#endif
#ifdef ETHTOOL_PHYS_ID
struct timer_list blink_timer; /* led blink timer id */
#endif
#ifdef CONFIG_PM
u32 pci_state[16];
#endif
};
#define E100_AUTONEG 0
......@@ -1056,8 +1031,6 @@ extern void e100_deisolate_driver(struct e100_private *bdp,
extern unsigned char e100_hw_reset_recover(struct e100_private *bdp,
u32 reset_cmd);
#ifdef ETHTOOL_TEST
#define ROM_TEST_FAIL 0x01
#define REGISTER_TEST_FAIL 0x02
#define SELF_TEST_FAIL 0x04
......@@ -1073,6 +1046,5 @@ enum test_offsets {
E100_LPBK_PHY_FAIL,
E100_MAX_TEST_RES
};
#endif
#endif
......@@ -535,7 +535,6 @@ e100_config_long_rx(struct e100_private *bdp, unsigned char enable)
}
}
#ifdef ETHTOOL_GWOL
/**
* e100_config_wol
* @bdp: atapter's private data struct
......@@ -560,7 +559,6 @@ e100_config_wol(struct e100_private *bdp)
spin_unlock_bh(&(bdp->config_lock));
}
#endif
/**
* e100_config_loopback_mode
......@@ -587,7 +585,7 @@ e100_config_loopback_mode(struct e100_private *bdp, u8 mode)
config_byte = CB_CFIG_LOOPBACK_EXTERNAL;
break;
default:
printk(KERN_NOTICE "e100_config_loopback_mode: "
printk(KERN_NOTICE "e100: e100_config_loopback_mode: "
"Invalid argument 'mode': %d\n", mode);
goto exit;
}
......
......@@ -145,8 +145,6 @@ eeprom_set_semaphore(struct e100_private *adapter)
data |= SCB_GCR2_EEPROM_ACCESS_SEMAPHORE;
writeb(data, &CSR_GENERAL_CONTROL2_FIELD(adapter));
barrier();
// Check to see if this bit set or not.
data = readb(&CSR_GENERAL_CONTROL2_FIELD(adapter));
......@@ -224,6 +222,7 @@ e100_eeprom_size(struct e100_private *adapter)
x &= ~EEDI; // address consists of all zeros
writew(x, &CSR_EEPROM_CONTROL_FIELD(adapter));
readw(&(adapter->scb->scb_status));
udelay(EEPROM_STALL_TIME);
raise_clock(adapter, &x);
lower_clock(adapter, &x);
......
This diff is collapsed.
......@@ -100,6 +100,7 @@ e100_mdi_write(struct e100_private *bdp, u32 reg_addr, u32 phy_addr, u16 data)
temp_val = (((u32) data) | (reg_addr << 16) |
(phy_addr << 21) | (MDI_WRITE << 26));
writel(temp_val, &bdp->scb->scb_mdi_cntrl);
readw(&bdp->scb->scb_status);
/* wait 20usec before checking status */
udelay(20);
......@@ -144,6 +145,7 @@ e100_mdi_read(struct e100_private *bdp, u32 reg_addr, u32 phy_addr, u16 *data)
/* Issue the read command to the MDI control register. */
temp_val = ((reg_addr << 16) | (phy_addr << 21) | (MDI_READ << 26));
writel(temp_val, &bdp->scb->scb_mdi_cntrl);
readw(&bdp->scb->scb_status);
/* wait 20usec before checking status */
udelay(20);
......@@ -267,21 +269,22 @@ e100_phy_specific_setup(struct e100_private *bdp)
case E100_AUTONEG:
/* The adapter can't autoneg. so set to 10/HALF */
printk(KERN_INFO
"503 serial component detected which "
"e100: 503 serial component detected which "
"cannot autonegotiate\n");
printk(KERN_INFO
"speed/duplex forced to 10Mbps / Half duplex\n");
"e100: speed/duplex forced to "
"10Mbps / Half duplex\n");
bdp->params.e100_speed_duplex = E100_SPEED_10_HALF;
break;
case E100_SPEED_100_HALF:
case E100_SPEED_100_FULL:
printk(KERN_ERR
"503 serial component detected which does not "
"support 100Mbps\n");
"e100: 503 serial component detected "
"which does not support 100Mbps\n");
printk(KERN_ERR
"Change the forced speed/duplex to a supported "
"setting\n");
"e100: Change the forced speed/duplex "
"to a supported setting\n");
return false;
}
......@@ -298,7 +301,7 @@ e100_phy_specific_setup(struct e100_private *bdp)
if ((bdp->params.e100_speed_duplex != E100_AUTONEG) &&
(bdp->params.e100_speed_duplex != E100_SPEED_100_FULL)) {
/* just inform user about 100 full */
printk(KERN_ERR "NC3133 NIC can only run "
printk(KERN_ERR "e100: NC3133 NIC can only run "
"at 100Mbps full duplex\n");
}
......
......@@ -91,11 +91,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <linux/config.h>
#ifndef CONFIG_PROC_FS
#undef E100_CONFIG_PROC_FS
#endif
#ifdef E100_CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS
#include "e100.h"
/* MDI sleep time is at least 50 ms, in jiffies */
#define MDI_SLEEP_TIME ((HZ / 20) + 1)
......@@ -115,8 +111,6 @@ extern void 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
......@@ -342,337 +336,6 @@ read_info(char *page, char **start, off_t off, int count, int *eof, void *data)
return generic_read(page, start, off, count, eof, len);
}
#ifdef E100_EOU
#ifdef MODULE
/**********************
* parameter entries
**********************/
static int
read_int_param(char *page, char *name, char *desc, int def, int min, int max)
{
int len;
len = sprintf(page, "Name: %s\n", name);
len += sprintf(page + len, "Description: %s\n", desc);
len += sprintf(page + len, "Default_Value: %d\n", def);
len += sprintf(page + len, "Type: Range\n");
len += sprintf(page + len, "Min: %d\n", min);
len += sprintf(page + len, "Max: %d\n", max);
len += sprintf(page + len, "Step:1\n");
len += sprintf(page + len, "Radix: dec\n");
return len;
}
static int
read_bool_param(char *page, char *name, char *desc, int def)
{
int len;
len = sprintf(page, "Name: %s\n", name);
len += sprintf(page + len, "Description: %s\n", desc);
len += sprintf(page + len, "Default_Value: %d\n", def);
len += sprintf(page + len, "Type: Enum\n");
len += sprintf(page + len, "0: Off\n");
len += sprintf(page + len, "1: On\n");
return len;
}
static int
read_speed_duplex_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = sprintf(page, "Name: Speed and Duplex\n");
len += sprintf(page + len, "Description: Sets the adapter's "
"speed and duplex mode\n");
len += sprintf(page + len, "Default_Value: 0\n");
len += sprintf(page + len, "Type: Enum\n");
len += sprintf(page + len, "0: Auto-Negotiate\n");
len += sprintf(page + len, "1: 10 Mbps / Half Duplex\n");
len += sprintf(page + len, "2: 10 Mbps / Full Duplex\n");
len += sprintf(page + len, "3: 100 Mbps / Half Duplex\n");
len += sprintf(page + len, "4: 100 Mbps / Full Duplex\n");
return generic_read(page, start, off, count, eof, len);
}
static int
read_tx_desc_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_int_param(page, "Transmit Descriptors",
"Sets the number of Tx descriptors "
"available for the adapter",
E100_DEFAULT_TCB, E100_MIN_TCB, E100_MAX_TCB);
return generic_read(page, start, off, count, eof, len);
}
static int
read_rx_desc_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_int_param(page, "Receive Descriptors",
"Sets the number of Rx descriptors "
"available for the adapter",
E100_DEFAULT_RFD, E100_MIN_RFD, E100_MAX_RFD);
return generic_read(page, start, off, count, eof, len);
}
static int
read_ber_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_int_param(page, "Bit Error Rate",
"Sets the value for the BER correction algorithm",
E100_DEFAULT_BER, 0, ZLOCK_MAX_ERRORS);
return generic_read(page, start, off, count, eof, len);
}
static int
read_xsum_rx_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_bool_param(page, "RX Checksum",
"Setting this value to \"On\" enables "
"receive checksum", E100_DEFAULT_XSUM);
return generic_read(page, start, off, count, eof, len);
}
static int
read_ucode_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_bool_param(page, "Microcode",
"Setting this value to \"On\" enables "
"the adapter's microcode", E100_DEFAULT_UCODE);
return generic_read(page, start, off, count, eof, len);
}
static int
read_bundle_small_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_bool_param(page, "Bundle Small Frames",
"Setting this value to \"On\" enables "
"interrupt bundling of small frames",
E100_DEFAULT_BUNDLE_SMALL_FR);
return generic_read(page, start, off, count, eof, len);
}
static int
read_fc_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_bool_param(page, "Flow Control",
"Setting this value to \"On\" enables processing "
"flow-control packets", E100_DEFAULT_FC);
return generic_read(page, start, off, count, eof, len);
}
static int
read_rcv_cong_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_bool_param(page, "Receive Congestion Control",
"Setting this value to \"On\" enables switching "
"to polling mode on receive",
E100_DEFAULT_RX_CONGESTION_CONTROL);
return generic_read(page, start, off, count, eof, len);
}
static int
read_poll_max_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct e100_private *bdp = data;
int len;
len = read_int_param(page, "Maximum Polling Work",
"Sets the max number of RX packets processed"
" by single polling function call",
bdp->params.RxDescriptors, 1, E100_MAX_RFD);
return generic_read(page, start, off, count, eof, len);
}
static int
read_int_delay_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_int_param(page, "CPU Saver Interrupt Delay",
"Sets the value for CPU saver's interrupt delay",
E100_DEFAULT_CPUSAVER_INTERRUPT_DELAY, 0x0,
0xFFFF);
return generic_read(page, start, off, count, eof, len);
}
static int
read_bundle_max_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_int_param(page, "CPU Saver Maximum Bundle",
"Sets CPU saver's maximum value",
E100_DEFAULT_CPUSAVER_BUNDLE_MAX, 0x1, 0xFFFF);
return generic_read(page, start, off, count, eof, len);
}
static int
read_ifs_def(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len;
len = read_bool_param(page, "IFS",
"Setting this value to \"On\" enables "
"the adaptive IFS algorithm", E100_DEFAULT_IFS);
return generic_read(page, start, off, count, eof, len);
}
static int
read_xsum_rx_val(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct e100_private *bdp = data;
unsigned long val;
val = (bdp->params.b_params & PRM_XSUMRX) ? 1 : 0;
return read_ulong(page, start, off, count, eof, val);
}
static int
read_ucode_val(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct e100_private *bdp = data;
unsigned long val;
val = (bdp->params.b_params & PRM_UCODE) ? 1 : 0;
return read_ulong(page, start, off, count, eof, val);
}
static int
read_fc_val(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct e100_private *bdp = data;
unsigned long val;
val = (bdp->params.b_params & PRM_FC) ? 1 : 0;
return read_ulong(page, start, off, count, eof, val);
}
static int
read_ifs_val(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct e100_private *bdp = data;
unsigned long val;
val = (bdp->params.b_params & PRM_IFS) ? 1 : 0;
return read_ulong(page, start, off, count, eof, val);
}
static int
read_bundle_small_val(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct e100_private *bdp = data;
unsigned long val;
val = (bdp->params.b_params & PRM_BUNDLE_SMALL) ? 1 : 0;
return read_ulong(page, start, off, count, eof, val);
}
static int
read_rcv_cong_val(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct e100_private *bdp = data;
unsigned long val;
val = (bdp->params.b_params & PRM_RX_CONG) ? 1 : 0;
return read_ulong(page, start, off, count, eof, val);
}
static int
read_gen_prm(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int val = 0;
if (data)
val = *((int *) data);
return read_ulong(page, start, off, count, eof, (unsigned long) val);
}
static e100_proc_entry e100_proc_params[] = {
/* definitions */
{"e100_speed_duplex.def", read_speed_duplex_def, 0, 0},
{"RxDescriptors.def", read_rx_desc_def, 0, 0},
{"TxDescriptors.def", read_tx_desc_def, 0, 0},
{"XsumRX.def", read_xsum_rx_def, 0, 0},
{"ucode.def", read_ucode_def, 0, 0},
{"BundleSmallFr.def", read_bundle_small_def, 0, 0},
{"IntDelay.def", read_int_delay_def, 0, 0},
{"BundleMax.def", read_bundle_max_def, 0, 0},
{"ber.def", read_ber_def, 0, 0},
{"flow_control.def", read_fc_def, 0, 0},
{"IFS.def", read_ifs_def, 0, 0},
{"RxCongestionControl.def", read_rcv_cong_def, 0, 0},
{"PollingMaxWork.def", read_poll_max_def, 0, 0},
/* values */
{"e100_speed_duplex.val", read_gen_prm, 0, bdp_prm_off(e100_speed_duplex)},
{"RxDescriptors.val", read_gen_prm, 0, bdp_prm_off(RxDescriptors)},
{"TxDescriptors.val", read_gen_prm, 0, bdp_prm_off(TxDescriptors)},
{"XsumRX.val", read_xsum_rx_val, 0, 0},
{"ucode.val", read_ucode_val, 0, 0},
{"BundleSmallFr.val", read_bundle_small_val, 0, 0},
{"IntDelay.val", read_gen_prm, 0, bdp_prm_off(IntDelay)},
{"BundleMax.val", read_gen_prm, 0, bdp_prm_off(BundleMax)},
{"ber.val", read_gen_prm, 0, bdp_prm_off(ber)},
{"flow_control.val", read_fc_val, 0, 0},
{"IFS.val", read_ifs_val, 0, 0},
{"RxCongestionControl.val", read_rcv_cong_val, 0, 0},
{"PollingMaxWork.val", read_gen_prm, 0, bdp_prm_off(PollingMaxWork)},
{"", 0, 0, 0}
};
#endif /* MODULE */
#endif /* E100_EOU */
static struct proc_dir_entry * __devinit
create_proc_rw(char *name, void *data, struct proc_dir_entry *parent,
read_proc_t * read_proc, write_proc_t * write_proc)
......@@ -699,60 +362,6 @@ create_proc_rw(char *name, void *data, struct proc_dir_entry *parent,
return pdep;
}
#ifdef E100_EOU
#ifdef MODULE
static int __devinit
create_proc_param_subdir(struct e100_private *bdp,
struct proc_dir_entry *dev_dir)
{
struct proc_dir_entry *param_dir;
e100_proc_entry *pe;
void *data;
param_dir = create_proc_entry("LoadParameters", S_IFDIR, dev_dir);
if (!param_dir)
return -ENOMEM;
for (pe = e100_proc_params; pe->name[0]; pe++) {
data = ((char *) bdp) + pe->offset;
if (!(create_proc_rw(pe->name, data, param_dir,
pe->read_proc, pe->write_proc))) {
return -ENOMEM;
}
}
return 0;
}
static void
remove_proc_param_subdir(struct proc_dir_entry *parent)
{
struct proc_dir_entry *de;
e100_proc_entry *pe;
int len;
len = strlen("LoadParameters");
for (de = parent->subdir; de; de = de->next) {
if ((de->namelen == len) &&
(!memcmp(de->name, "LoadParameters", len)))
break;
}
if (!de)
return;
for (pe = e100_proc_params; pe->name[0]; pe++) {
remove_proc_entry(pe->name, de);
}
remove_proc_entry("LoadParameters", parent);
}
#endif /* MODULE */
#endif
void
e100_remove_proc_subdir(struct e100_private *bdp)
{
......@@ -777,11 +386,6 @@ e100_remove_proc_subdir(struct e100_private *bdp)
remove_proc_entry(pe->name, bdp->proc_parent);
}
#ifdef E100_EOU
#ifdef MODULE
remove_proc_param_subdir(bdp->proc_parent);
#endif
#endif
remove_proc_entry(bdp->device->name, adapters_proc_dir);
bdp->proc_parent = NULL;
}
......@@ -842,15 +446,6 @@ e100_create_proc_subdir(struct e100_private *bdp)
}
}
#ifdef E100_EOU
#ifdef MODULE
if (create_proc_param_subdir(bdp, dev_dir)) {
e100_remove_proc_subdir(bdp);
return -ENOMEM;
}
#endif
#endif
return 0;
}
......
......@@ -72,7 +72,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "e100.h"
#include "e100_config.h"
#ifdef ETHTOOL_TEST
extern u16 e100_eeprom_read(struct e100_private *, u16);
extern int e100_wait_exec_cmplx(struct e100_private *, u32,u8);
......@@ -380,11 +379,11 @@ e100_diag_loopback_cu_ru_exec(struct e100_private *bdp)
{
/*load CU & RU base */
if (!e100_wait_exec_cmplx(bdp, 0, SCB_CUC_LOAD_BASE))
printk("@@@ SCB_CUC_LOAD_BASE failed\n");
printk("e100: SCB_CUC_LOAD_BASE failed\n");
if(!e100_wait_exec_cmplx(bdp, 0, SCB_RUC_LOAD_BASE))
printk("@@@ SCB_RUC_LOAD_BASE failed!\n");
printk("e100: SCB_RUC_LOAD_BASE failed!\n");
if(!e100_wait_exec_cmplx(bdp, bdp->loopback.dma_handle, SCB_RUC_START))
printk("@@@ SCB_RUC_START failed!\n");
printk("e100: SCB_RUC_START failed!\n");
bdp->next_cu_cmd = START_WAIT;
e100_start_cu(bdp, bdp->loopback.tcb);
......@@ -457,5 +456,3 @@ e100_diag_loopback_free (struct e100_private *bdp)
bdp->loopback.dma_handle);
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment