Commit 5ef85cff authored by Jeff Garzik's avatar Jeff Garzik

[netdrvr e1000] small cleanups and fixes:

* Update change log
* Whitespace cleanup
* Bug fix: protect against zero-length skb in hard_start
* Bug fix: validate MAC address using is_valid_ether_addr()

Contributed by Scott Feldman @ Intel
parent 941c84e0
...@@ -194,7 +194,7 @@ e1000_ethtool_gregs(struct e1000_adapter *adapter, ...@@ -194,7 +194,7 @@ e1000_ethtool_gregs(struct e1000_adapter *adapter,
regs_buff[4] = E1000_READ_REG(hw, RDH); regs_buff[4] = E1000_READ_REG(hw, RDH);
regs_buff[5] = E1000_READ_REG(hw, RDT); regs_buff[5] = E1000_READ_REG(hw, RDT);
regs_buff[6] = E1000_READ_REG(hw, RDTR); regs_buff[6] = E1000_READ_REG(hw, RDTR);
regs_buff[7] = E1000_READ_REG(hw, TCTL); regs_buff[7] = E1000_READ_REG(hw, TCTL);
regs_buff[8] = E1000_READ_REG(hw, TDLEN); regs_buff[8] = E1000_READ_REG(hw, TDLEN);
regs_buff[9] = E1000_READ_REG(hw, TDH); regs_buff[9] = E1000_READ_REG(hw, TDH);
...@@ -233,7 +233,7 @@ e1000_ethtool_geeprom(struct e1000_adapter *adapter, ...@@ -233,7 +233,7 @@ e1000_ethtool_geeprom(struct e1000_adapter *adapter,
return 0; return 0;
} }
static int static int
e1000_ethtool_seeprom(struct e1000_adapter *adapter, e1000_ethtool_seeprom(struct e1000_adapter *adapter,
struct ethtool_eeprom *eeprom, void *user_data) struct ethtool_eeprom *eeprom, void *user_data)
{ {
...@@ -370,7 +370,7 @@ static void ...@@ -370,7 +370,7 @@ static void
e1000_led_blink_callback(unsigned long data) e1000_led_blink_callback(unsigned long data)
{ {
struct e1000_adapter *adapter = (struct e1000_adapter *) data; struct e1000_adapter *adapter = (struct e1000_adapter *) data;
if(test_and_change_bit(E1000_LED_ON, &adapter->led_status)) if(test_and_change_bit(E1000_LED_ON, &adapter->led_status))
e1000_led_off(&adapter->hw); e1000_led_off(&adapter->hw);
else else
...@@ -390,13 +390,13 @@ e1000_ethtool_led_blink(struct e1000_adapter *adapter, struct ethtool_value *id) ...@@ -390,13 +390,13 @@ e1000_ethtool_led_blink(struct e1000_adapter *adapter, struct ethtool_value *id)
e1000_setup_led(&adapter->hw); e1000_setup_led(&adapter->hw);
mod_timer(&adapter->blink_timer, jiffies); mod_timer(&adapter->blink_timer, jiffies);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if(id->data) if(id->data)
schedule_timeout(id->data * HZ); schedule_timeout(id->data * HZ);
else else
schedule_timeout(MAX_SCHEDULE_TIMEOUT); schedule_timeout(MAX_SCHEDULE_TIMEOUT);
del_timer_sync(&adapter->blink_timer); del_timer_sync(&adapter->blink_timer);
e1000_led_off(&adapter->hw); e1000_led_off(&adapter->hw);
clear_bit(E1000_LED_ON, &adapter->led_status); clear_bit(E1000_LED_ON, &adapter->led_status);
......
...@@ -26,11 +26,21 @@ ...@@ -26,11 +26,21 @@
*******************************************************************************/ *******************************************************************************/
#define __E1000_MAIN__
#include "e1000.h" #include "e1000.h"
/* Change Log /* Change Log
* *
* 4.4.19 11/27/02
* o Feature: Added user-settable knob for interrupt throttle rate (ITR).
* o Cleanup: removed large static array allocations.
* o Cleanup: C99 struct initializer format.
* o Bug fix: restore VLAN settings when interface is brought up.
* o Bug fix: return cleanly in probe if error in detecting MAC type.
* o Bug fix: Wake up on magic packet by default only if enabled in eeprom.
* o Bug fix: Validate MAC address in set_mac.
* o Bug fix: Throw away zero-length Tx skbs.
* o Bug fix: Make ethtool EEPROM acceses work on older versions of ethtool.
*
* 4.4.12 10/15/02 * 4.4.12 10/15/02
* o Clean up: use members of pci_device rather than direct calls to * o Clean up: use members of pci_device rather than direct calls to
* pci_read_config_word. * pci_read_config_word.
...@@ -43,30 +53,13 @@ ...@@ -43,30 +53,13 @@
* o Now setting netdev->mem_end in e1000_probe. * o Now setting netdev->mem_end in e1000_probe.
* o Clean up: Moved tx_timeout from interrupt context to process context * o Clean up: Moved tx_timeout from interrupt context to process context
* using schedule_task. * using schedule_task.
* *
* o Feature: merged in modified NAPI patch from Robert Olsson * 4.3.15 8/9/02
* <Robert.Olsson@its.uu.se> Uppsala Univeristy, Sweden.
*
* 4.3.15 8/9/02
* o Converted from Dual BSD/GPL license to GPL license.
* o Clean up: use pci_[clear|set]_mwi rather than direct calls to
* pci_write_config_word.
* o Bug fix: added read-behind-write calls to post writes before delays.
* o Bug fix: removed mdelay busy-waits in interrupt context.
* o Clean up: direct clear of descriptor bits rather than using memset.
* o Bug fix: added wmb() for ia-64 between descritor writes and advancing
* descriptor tail.
* o Feature: added locking mechanism for asf functionality.
* o Feature: exposed two Tx and one Rx interrupt delay knobs for finer
* control over interurpt rate tuning.
* o Misc ethtool bug fixes.
*
* 4.3.2 7/5/02
*/ */
char e1000_driver_name[] = "e1000"; char e1000_driver_name[] = "e1000";
char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
char e1000_driver_version[] = "4.4.12-k1"; char e1000_driver_version[] = "4.4.19-k1";
char e1000_copyright[] = "Copyright (c) 1999-2002 Intel Corporation."; char e1000_copyright[] = "Copyright (c) 1999-2002 Intel Corporation.";
/* e1000_pci_tbl - PCI Device ID Table /* e1000_pci_tbl - PCI Device ID Table
...@@ -587,6 +580,7 @@ e1000_sw_init(struct e1000_adapter *adapter) ...@@ -587,6 +580,7 @@ e1000_sw_init(struct e1000_adapter *adapter)
hw->subsystem_id = pdev->subsystem_device; hw->subsystem_id = pdev->subsystem_device;
pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id); pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word); pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
adapter->rx_buffer_len = E1000_RXBUFFER_2048; adapter->rx_buffer_len = E1000_RXBUFFER_2048;
...@@ -631,7 +625,7 @@ e1000_sw_init(struct e1000_adapter *adapter) ...@@ -631,7 +625,7 @@ e1000_sw_init(struct e1000_adapter *adapter)
hw->adaptive_ifs = TRUE; hw->adaptive_ifs = TRUE;
/* Copper options */ /* Copper options */
if(hw->media_type == e1000_media_type_copper) { if(hw->media_type == e1000_media_type_copper) {
hw->mdix = AUTO_ALL_MODES; hw->mdix = AUTO_ALL_MODES;
hw->disable_polarity_correction = FALSE; hw->disable_polarity_correction = FALSE;
...@@ -1148,6 +1142,9 @@ e1000_set_mac(struct net_device *netdev, void *p) ...@@ -1148,6 +1142,9 @@ e1000_set_mac(struct net_device *netdev, void *p)
struct e1000_adapter *adapter = netdev->priv; struct e1000_adapter *adapter = netdev->priv;
struct sockaddr *addr = p; struct sockaddr *addr = p;
if(!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
/* 82542 2.0 needs to be in reset to write receive address registers */ /* 82542 2.0 needs to be in reset to write receive address registers */
if(adapter->hw.mac_type == e1000_82542_rev2_0) if(adapter->hw.mac_type == e1000_82542_rev2_0)
...@@ -1404,7 +1401,6 @@ e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb) ...@@ -1404,7 +1401,6 @@ e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb)
int f; int f;
len = skb->len - skb->data_len; len = skb->len - skb->data_len;
i = (tx_ring->next_to_use + tx_ring->count - 1) % tx_ring->count; i = (tx_ring->next_to_use + tx_ring->count - 1) % tx_ring->count;
count = 0; count = 0;
...@@ -1511,11 +1507,16 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) ...@@ -1511,11 +1507,16 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
{ {
struct e1000_adapter *adapter = netdev->priv; struct e1000_adapter *adapter = netdev->priv;
int tx_flags = 0, count; int tx_flags = 0, count;
int f; int f;
count = TXD_USE_COUNT(skb->len - skb->data_len, count = TXD_USE_COUNT(skb->len - skb->data_len,
adapter->max_data_per_txd); adapter->max_data_per_txd);
if(count == 0) {
dev_kfree_skb_any(skb);
return 0;
}
for(f = 0; f < skb_shinfo(skb)->nr_frags; f++) for(f = 0; f < skb_shinfo(skb)->nr_frags; f++)
count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size, count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
adapter->max_data_per_txd); adapter->max_data_per_txd);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
*******************************************************************************/ *******************************************************************************/
/* glue for the OS independant part of e1000 /* glue for the OS independant part of e1000
* includes register access macros * includes register access macros
*/ */
......
...@@ -230,7 +230,6 @@ struct e1000_option { ...@@ -230,7 +230,6 @@ struct e1000_option {
} arg; } arg;
}; };
static int __devinit static int __devinit
e1000_validate_option(int *value, struct e1000_option *opt) e1000_validate_option(int *value, struct e1000_option *opt)
{ {
...@@ -273,7 +272,7 @@ e1000_validate_option(int *value, struct e1000_option *opt) ...@@ -273,7 +272,7 @@ e1000_validate_option(int *value, struct e1000_option *opt)
default: default:
BUG(); BUG();
} }
printk(KERN_INFO "Invalid %s specified (%i) %s\n", printk(KERN_INFO "Invalid %s specified (%i) %s\n",
opt->name, *value, opt->err); opt->name, *value, opt->err);
*value = opt->def; *value = opt->def;
...@@ -298,7 +297,7 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -298,7 +297,7 @@ e1000_check_options(struct e1000_adapter *adapter)
{ {
int bd = adapter->bd_number; int bd = adapter->bd_number;
if(bd >= E1000_MAX_NIC) { if(bd >= E1000_MAX_NIC) {
printk(KERN_NOTICE printk(KERN_NOTICE
"Warning: no configuration for board #%i\n", bd); "Warning: no configuration for board #%i\n", bd);
printk(KERN_NOTICE "Using defaults for all values\n"); printk(KERN_NOTICE "Using defaults for all values\n");
bd = E1000_MAX_NIC; bd = E1000_MAX_NIC;
...@@ -314,7 +313,7 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -314,7 +313,7 @@ e1000_check_options(struct e1000_adapter *adapter)
}; };
struct e1000_desc_ring *tx_ring = &adapter->tx_ring; struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
e1000_mac_type mac_type = adapter->hw.mac_type; e1000_mac_type mac_type = adapter->hw.mac_type;
opt.arg.r.max = mac_type < e1000_82544 ? opt.arg.r.max = mac_type < e1000_82544 ?
MAX_TXD : MAX_82544_TXD; MAX_TXD : MAX_82544_TXD;
tx_ring->count = TxDescriptors[bd]; tx_ring->count = TxDescriptors[bd];
...@@ -344,13 +343,13 @@ e1000_check_options(struct e1000_adapter *adapter) ...@@ -344,13 +343,13 @@ e1000_check_options(struct e1000_adapter *adapter)
.err = "defaulting to Enabled", .err = "defaulting to Enabled",
.def = OPTION_ENABLED .def = OPTION_ENABLED
}; };
int rx_csum = XsumRX[bd]; int rx_csum = XsumRX[bd];
e1000_validate_option(&rx_csum, &opt); e1000_validate_option(&rx_csum, &opt);
adapter->rx_csum = rx_csum; adapter->rx_csum = rx_csum;
} }
{ /* Flow Control */ { /* Flow Control */
struct e1000_opt_list fc_list[] = struct e1000_opt_list fc_list[] =
{{ e1000_fc_none, "Flow Control Disabled" }, {{ e1000_fc_none, "Flow Control Disabled" },
{ e1000_fc_rx_pause,"Flow Control Receive Only" }, { e1000_fc_rx_pause,"Flow Control Receive Only" },
...@@ -478,9 +477,10 @@ e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -478,9 +477,10 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
{ /* Speed */ { /* Speed */
struct e1000_opt_list speed_list[] = {{ 0, "" }, struct e1000_opt_list speed_list[] = {{ 0, "" },
{ SPEED_10, "" }, { SPEED_10, "" },
{ SPEED_100, "" }, { SPEED_100, "" },
{ SPEED_1000, "" }}; { SPEED_1000, "" }};
struct e1000_option opt = { struct e1000_option opt = {
.type = list_option, .type = list_option,
.name = "Speed", .name = "Speed",
...@@ -494,8 +494,9 @@ e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -494,8 +494,9 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
} }
{ /* Duplex */ { /* Duplex */
struct e1000_opt_list dplx_list[] = {{ 0, "" }, struct e1000_opt_list dplx_list[] = {{ 0, "" },
{ HALF_DUPLEX, "" }, { HALF_DUPLEX, "" },
{ FULL_DUPLEX, "" }}; { FULL_DUPLEX, "" }};
struct e1000_option opt = { struct e1000_option opt = {
.type = list_option, .type = list_option,
.name = "Duplex", .name = "Duplex",
...@@ -572,7 +573,7 @@ e1000_check_copper_options(struct e1000_adapter *adapter) ...@@ -572,7 +573,7 @@ e1000_check_copper_options(struct e1000_adapter *adapter)
printk(KERN_INFO "Half Duplex specified without Speed\n"); printk(KERN_INFO "Half Duplex specified without Speed\n");
printk(KERN_INFO "Using Autonegotiation at Half Duplex only\n"); printk(KERN_INFO "Using Autonegotiation at Half Duplex only\n");
adapter->hw.autoneg = 1; adapter->hw.autoneg = 1;
adapter->hw.autoneg_advertised = ADVERTISE_10_HALF | adapter->hw.autoneg_advertised = ADVERTISE_10_HALF |
ADVERTISE_100_HALF; ADVERTISE_100_HALF;
break; break;
case FULL_DUPLEX: case FULL_DUPLEX:
......
...@@ -109,7 +109,7 @@ e1000_proc_info_read(char *page, char **start, off_t off, ...@@ -109,7 +109,7 @@ e1000_proc_info_read(char *page, char **start, off_t off,
if(!strlen(elem->tag)) if(!strlen(elem->tag))
p += sprintf(p, "\n"); p += sprintf(p, "\n");
else else
p += sprintf(p, "%-*.*s %.*s\n", p += sprintf(p, "%-*.*s %.*s\n",
TAG_MAX_LENGTH, TAG_MAX_LENGTH, TAG_MAX_LENGTH, TAG_MAX_LENGTH,
elem->tag, FIELD_MAX_LENGTH, elem->tag, FIELD_MAX_LENGTH,
elem->func(elem->data, elem->len, buf)); elem->func(elem->data, elem->len, buf));
...@@ -126,7 +126,7 @@ e1000_proc_single_read(char *page, char **start, off_t off, ...@@ -126,7 +126,7 @@ e1000_proc_single_read(char *page, char **start, off_t off,
{ {
struct proc_list *elem = data; struct proc_list *elem = data;
sprintf(page, "%.*s", FIELD_MAX_LENGTH, elem->func(elem->data, sprintf(page, "%.*s", FIELD_MAX_LENGTH, elem->func(elem->data,
elem->len, page)); elem->len, page));
return e1000_proc_read(page, start, off, count, eof); return e1000_proc_read(page, start, off, count, eof);
...@@ -216,7 +216,7 @@ e1000_proc_singles_create(struct proc_dir_entry *parent, ...@@ -216,7 +216,7 @@ e1000_proc_singles_create(struct proc_dir_entry *parent,
} }
static void static void
e1000_proc_dirs_create(void *data, char *name, e1000_proc_dirs_create(void *data, char *name,
struct list_head *proc_list_head) struct list_head *proc_list_head)
{ {
struct proc_dir_entry *intel_proc_dir, *proc_dir, *info_entry; struct proc_dir_entry *intel_proc_dir, *proc_dir, *info_entry;
...@@ -257,7 +257,7 @@ e1000_proc_dirs_create(void *data, char *name, ...@@ -257,7 +257,7 @@ e1000_proc_dirs_create(void *data, char *name,
static void static void
e1000_proc_list_add(struct list_head *proc_list_head, char *tag, e1000_proc_list_add(struct list_head *proc_list_head, char *tag,
void *data, size_t len, void *data, size_t len,
char *(*func)(void *, size_t, char *)) char *(*func)(void *, size_t, char *))
{ {
struct proc_list *new = (struct proc_list *) struct proc_list *new = (struct proc_list *)
...@@ -509,8 +509,8 @@ e1000_proc_mdi_x_enabled(void *data, size_t len, char *buf) ...@@ -509,8 +509,8 @@ e1000_proc_mdi_x_enabled(void *data, size_t len, char *buf)
{ {
struct e1000_adapter *adapter = data; struct e1000_adapter *adapter = data;
e1000_auto_x_mode mdix_mode = adapter->phy_info.mdix_mode; e1000_auto_x_mode mdix_mode = adapter->phy_info.mdix_mode;
sprintf(buf, sprintf(buf,
mdix_mode == e1000_auto_x_mode_manual_mdi ? "MDI" : mdix_mode == e1000_auto_x_mode_manual_mdi ? "MDI" :
mdix_mode == e1000_auto_x_mode_manual_mdix ? "MDI-X" : mdix_mode == e1000_auto_x_mode_manual_mdix ? "MDI-X" :
"Unknown"); "Unknown");
return buf; return buf;
...@@ -531,7 +531,7 @@ e1000_proc_rx_status(void *data, size_t len, char *buf) ...@@ -531,7 +531,7 @@ e1000_proc_rx_status(void *data, size_t len, char *buf)
* e1000_proc_list_setup - build link list of proc praramters * e1000_proc_list_setup - build link list of proc praramters
* @adapter: board private structure * @adapter: board private structure
* *
* Order matters - ethx.info entries are ordered in the order links * Order matters - ethx.info entries are ordered in the order links
* are added to list. * are added to list.
*/ */
...@@ -610,7 +610,7 @@ e1000_proc_list_setup(struct e1000_adapter *adapter) ...@@ -610,7 +610,7 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
LIST_ADD_U("Tx_Aborted_Errors", &adapter->net_stats.tx_aborted_errors); LIST_ADD_U("Tx_Aborted_Errors", &adapter->net_stats.tx_aborted_errors);
LIST_ADD_U("Tx_Carrier_Errors", &adapter->net_stats.tx_carrier_errors); LIST_ADD_U("Tx_Carrier_Errors", &adapter->net_stats.tx_carrier_errors);
LIST_ADD_U("Tx_FIFO_Errors", &adapter->net_stats.tx_fifo_errors); LIST_ADD_U("Tx_FIFO_Errors", &adapter->net_stats.tx_fifo_errors);
LIST_ADD_U("Tx_Heartbeat_Errors", LIST_ADD_U("Tx_Heartbeat_Errors",
&adapter->net_stats.tx_heartbeat_errors); &adapter->net_stats.tx_heartbeat_errors);
LIST_ADD_U("Tx_Window_Errors", &adapter->net_stats.tx_window_errors); LIST_ADD_U("Tx_Window_Errors", &adapter->net_stats.tx_window_errors);
...@@ -649,17 +649,17 @@ e1000_proc_list_setup(struct e1000_adapter *adapter) ...@@ -649,17 +649,17 @@ e1000_proc_list_setup(struct e1000_adapter *adapter)
adapter, e1000_proc_cable_polarity); adapter, e1000_proc_cable_polarity);
LIST_ADD_F("PHY_Disable_Polarity_Correction", LIST_ADD_F("PHY_Disable_Polarity_Correction",
adapter, e1000_proc_polarity_correction); adapter, e1000_proc_polarity_correction);
LIST_ADD_U("PHY_Idle_Errors", LIST_ADD_U("PHY_Idle_Errors",
&adapter->phy_stats.idle_errors); &adapter->phy_stats.idle_errors);
LIST_ADD_U("PHY_Receive_Errors", LIST_ADD_U("PHY_Receive_Errors",
&adapter->phy_stats.receive_errors); &adapter->phy_stats.receive_errors);
LIST_ADD_F("PHY_MDI_X_Enabled", LIST_ADD_F("PHY_MDI_X_Enabled",
adapter, e1000_proc_mdi_x_enabled); adapter, e1000_proc_mdi_x_enabled);
LIST_ADD_F("PHY_Local_Receiver_Status", LIST_ADD_F("PHY_Local_Receiver_Status",
&adapter->phy_info.local_rx, &adapter->phy_info.local_rx,
e1000_proc_rx_status); e1000_proc_rx_status);
LIST_ADD_F("PHY_Remote_Receiver_Status", LIST_ADD_F("PHY_Remote_Receiver_Status",
&adapter->phy_info.remote_rx, &adapter->phy_info.remote_rx,
e1000_proc_rx_status); e1000_proc_rx_status);
} }
...@@ -675,7 +675,7 @@ e1000_proc_dev_setup(struct e1000_adapter *adapter) ...@@ -675,7 +675,7 @@ e1000_proc_dev_setup(struct e1000_adapter *adapter)
{ {
e1000_proc_list_setup(adapter); e1000_proc_list_setup(adapter);
e1000_proc_dirs_create(adapter, e1000_proc_dirs_create(adapter,
adapter->ifname, adapter->ifname,
&adapter->proc_list_head); &adapter->proc_list_head);
} }
......
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