Skip to contentSkip to conversation

atl1: Ancillary C files for Attansic L1 driver

PATCH In review Jay Cliburn 5 participants 14 messages Jan 21, 2007 – Jan 27, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/4 atl1: Ancillary C files for Attansic L1 driver

From: Jay Cliburn <[email protected]>
From: Chris Snook <[email protected]>

This patch contains auxiliary C files for the Attansic L1 gigabit ethernet adapter driver.

---

 atl1_ethtool.c |  436 ++++++++++++++++++++++++++++++++++
 atl1_hw.c      |  728 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 atl1_param.c   |  223 +++++++++++++++++
 3 files changed, 1387 insertions(+)
drivers/net/atl1/atl1_ethtool.c new file +436 -0
new file mode 100644
index 0000000..4c6e505
@@ -0,0 +1,436 @@
+/**
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <[email protected]>
+ * Copyright(c) 2006 Jay Cliburn <[email protected]>
+ * 
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 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.
+ **/
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/ethtool.h>
+#include <linux/netdevice.h>
+#include <linux/mii.h>
+#include <asm/uaccess.h>
+
+#include "atl1.h"
+
+
+extern char atl1_driver_name[];
+extern char atl1_driver_version[];
+
+struct atl1_stats {
+	char stat_string[ETH_GSTRING_LEN];
+	int sizeof_stat;
+	int stat_offset;
+};
+
+#define ATL1_STAT(m) sizeof(((struct atl1_adapter *)0)->m), \
+	offsetof(struct atl1_adapter, m)
+
+static struct atl1_stats atl1_gstrings_stats[] = {
+	{"rx_packets", ATL1_STAT(soft_stats.rx_packets)},
+	{"tx_packets", ATL1_STAT(soft_stats.tx_packets)},
+	{"rx_bytes", ATL1_STAT(soft_stats.rx_bytes)},
+	{"tx_bytes", ATL1_STAT(soft_stats.tx_bytes)},
+	{"rx_errors", ATL1_STAT(soft_stats.rx_errors)},
+	{"tx_errors", ATL1_STAT(soft_stats.tx_errors)},
+	{"rx_dropped", ATL1_STAT(net_stats.rx_dropped)},
+	{"tx_dropped", ATL1_STAT(net_stats.tx_dropped)},
+	{"multicast", ATL1_STAT(soft_stats.multicast)},
+	{"collisions", ATL1_STAT(soft_stats.collisions)},
+	{"rx_length_errors", ATL1_STAT(soft_stats.rx_length_errors)},
+	{"rx_over_errors", ATL1_STAT(soft_stats.rx_missed_errors)},
+	{"rx_crc_errors", ATL1_STAT(soft_stats.rx_crc_errors)},
+	{"rx_frame_errors", ATL1_STAT(soft_stats.rx_frame_errors)},
+	{"rx_fifo_errors", ATL1_STAT(soft_stats.rx_fifo_errors)},
+	{"rx_missed_errors", ATL1_STAT(soft_stats.rx_missed_errors)},
+	{"tx_aborted_errors", ATL1_STAT(soft_stats.tx_aborted_errors)},
+	{"tx_carrier_errors", ATL1_STAT(soft_stats.tx_carrier_errors)},
+	{"tx_fifo_errors", ATL1_STAT(soft_stats.tx_fifo_errors)},
+	{"tx_window_errors", ATL1_STAT(soft_stats.tx_window_errors)},
+	{"tx_abort_exce_coll", ATL1_STAT(soft_stats.excecol)},
+	{"tx_abort_late_coll", ATL1_STAT(soft_stats.latecol)},
+	{"tx_deferred_ok", ATL1_STAT(soft_stats.deffer)},
+	{"tx_single_coll_ok", ATL1_STAT(soft_stats.scc)},
+	{"tx_multi_coll_ok", ATL1_STAT(soft_stats.mcc)},
+	{"tx_underun", ATL1_STAT(soft_stats.tx_underun)},
+	{"tx_trunc", ATL1_STAT(soft_stats.tx_trunc)},
+	{"tx_pause", ATL1_STAT(soft_stats.tx_pause)},
+	{"rx_pause", ATL1_STAT(soft_stats.rx_pause)},
+	{"rx_rrd_ov", ATL1_STAT(soft_stats.rx_rrd_ov)},
+	{"rx_trunc", ATL1_STAT(soft_stats.rx_trunc)}
+};
+
+static void atl1_get_ethtool_stats(struct net_device *netdev,
+				struct ethtool_stats *stats, u64 *data)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+	int i;
+	char *p;
+
+	for (i = 0; i < ARRAY_SIZE(atl1_gstrings_stats); i++) {
+		p = (char *)adapter+atl1_gstrings_stats[i].stat_offset;
+		data[i] = (atl1_gstrings_stats[i].sizeof_stat ==
+			sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
+	}
+
+}
+
+static int atl1_get_stats_count(struct net_device *netdev)
+{
+	return ARRAY_SIZE(atl1_gstrings_stats);
+}
+
+static int atl1_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+	struct atl1_hw *hw = &adapter->hw;
+
+	ecmd->supported = (SUPPORTED_10baseT_Half |
+			   SUPPORTED_10baseT_Full |
+			   SUPPORTED_100baseT_Half |
+			   SUPPORTED_100baseT_Full |
+			   SUPPORTED_1000baseT_Full |
+			   SUPPORTED_Autoneg | SUPPORTED_TP);
+	ecmd->advertising = ADVERTISED_TP;
+	if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+	    hw->media_type == MEDIA_TYPE_1000M_FULL) {
+		ecmd->advertising |= ADVERTISED_Autoneg;
+		if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR) {
+			ecmd->advertising |= ADVERTISED_Autoneg;
+			ecmd->advertising |=
+			    (ADVERTISED_10baseT_Half |
+			     ADVERTISED_10baseT_Full |
+			     ADVERTISED_100baseT_Half |
+			     ADVERTISED_100baseT_Full |
+			     ADVERTISED_1000baseT_Full);
+		} else {
+			ecmd->advertising |= (ADVERTISED_1000baseT_Full);
+		}
+	}
+	ecmd->port = PORT_TP;
+	ecmd->phy_address = 0;
+	ecmd->transceiver = XCVR_INTERNAL;
+
+	if (netif_carrier_ok(adapter->netdev)) {
+		u16 link_speed, link_duplex;
+		atl1_get_speed_and_duplex(hw, &link_speed, &link_duplex);
+		ecmd->speed = link_speed;
+		if (link_duplex == FULL_DUPLEX)
+			ecmd->duplex = DUPLEX_FULL;
+		else
+			ecmd->duplex = DUPLEX_HALF;
+	} else {
+		ecmd->speed = -1;
+		ecmd->duplex = -1;
+	}
+	if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+	    hw->media_type == MEDIA_TYPE_1000M_FULL) {
+		ecmd->autoneg = AUTONEG_ENABLE;
+	} else {
+		ecmd->autoneg = AUTONEG_DISABLE;
+	}
+	
+	return 0;
+}
+
+static int atl1_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+	struct atl1_hw *hw = &adapter->hw;
+	u16 phy_data;
+	int ret_val = 0;
+	u16 old_media_type = hw->media_type;
+
+	if (netif_running(adapter->netdev)) {
+		printk(KERN_DEBUG "%s: ethtool shutting down link adapter\n", 
+			atl1_driver_name);
+		atl1_down(adapter);
+	}
+
+	if (ecmd->autoneg == AUTONEG_ENABLE) {
+		hw->media_type = MEDIA_TYPE_AUTO_SENSOR;
+	} else {
+		if (ecmd->speed == SPEED_1000) {
+			if (ecmd->duplex != DUPLEX_FULL) {
+				printk(KERN_WARNING
+				       "%s: can't force to 1000M half duplex\n",
+					atl1_driver_name);
+				ret_val = -EINVAL;
+				goto exit_sset;
+			}
+			hw->media_type = MEDIA_TYPE_1000M_FULL;
+		} else if (ecmd->speed == SPEED_100) {
+			if (ecmd->duplex == DUPLEX_FULL) {
+				hw->media_type = MEDIA_TYPE_100M_FULL;
+			} else {
+				hw->media_type = MEDIA_TYPE_100M_HALF;
+			}
+		} else {
+			if (ecmd->duplex == DUPLEX_FULL) {
+				hw->media_type = MEDIA_TYPE_10M_FULL;
+			} else {
+				hw->media_type = MEDIA_TYPE_10M_HALF;
+			}
+		}
+	}
+	switch (hw->media_type) {
+	case MEDIA_TYPE_AUTO_SENSOR:
+		ecmd->advertising =
+		    ADVERTISED_10baseT_Half |
+		    ADVERTISED_10baseT_Full |
+		    ADVERTISED_100baseT_Half |
+		    ADVERTISED_100baseT_Full |
+		    ADVERTISED_1000baseT_Full |
+		    ADVERTISED_Autoneg | ADVERTISED_TP;
+		break;
+	case MEDIA_TYPE_1000M_FULL:
+		ecmd->advertising =
+		    ADVERTISED_1000baseT_Full |
+		    ADVERTISED_Autoneg | ADVERTISED_TP;
+		break;
+	default:
+		ecmd->advertising = 0;
+		break;
+	}
+	if (atl1_phy_setup_autoneg_adv(hw)) {
+		ret_val = -EINVAL;
+		printk(KERN_WARNING 
+			"%s: invalid ethtool speed/duplex setting\n", 
+			atl1_driver_name);
+		goto exit_sset;
+	}
+	if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+	    hw->media_type == MEDIA_TYPE_1000M_FULL) {
+		phy_data = MII_CR_RESET | MII_CR_AUTO_NEG_EN;
+	} else {
+		switch (hw->media_type) {
+		case MEDIA_TYPE_100M_FULL:
+			phy_data =
+			    MII_CR_FULL_DUPLEX | MII_CR_SPEED_100 |
+			    MII_CR_RESET;
+			break;
+		case MEDIA_TYPE_100M_HALF:
+			phy_data = MII_CR_SPEED_100 | MII_CR_RESET;
+			break;
+		case MEDIA_TYPE_10M_FULL:
+			phy_data =
+			    MII_CR_FULL_DUPLEX | MII_CR_SPEED_10 | MII_CR_RESET;
+			break;
+		default:	/* MEDIA_TYPE_10M_HALF: */
+			phy_data = MII_CR_SPEED_10 | MII_CR_RESET;
+			break;
+		}
+	}
+	atl1_write_phy_reg(hw, MII_BMCR, phy_data);
+exit_sset:
+	if (ret_val) {
+		hw->media_type = old_media_type;
+	}
+	if (netif_running(adapter->netdev)) {
+		printk(KERN_DEBUG "%s: ethtool starting link adapter\n", 
+			atl1_driver_name);
+		atl1_up(adapter);
+	} else if (!ret_val) {
+		printk(KERN_DEBUG "%s: ethtool resetting link adapter\n", 
+			atl1_driver_name);
+		atl1_reset(adapter);
+	}
+	return ret_val;
+}
+
+static void atl1_get_drvinfo(struct net_device *netdev,
+				struct ethtool_drvinfo *drvinfo)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+
+	strncpy(drvinfo->driver, atl1_driver_name, 32);
+	strncpy(drvinfo->version, atl1_driver_version, 32);
+	strncpy(drvinfo->fw_version, "N/A", 32);
+	strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
+	drvinfo->eedump_len = 48;
+}
+
+static void atl1_get_wol(struct net_device *netdev,
+			    struct ethtool_wolinfo *wol)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+
+	wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC;
+	wol->wolopts = 0;
+	if (adapter->wol & ATL1_WUFC_EX)
+		wol->wolopts |= WAKE_UCAST;
+	if (adapter->wol & ATL1_WUFC_MC)
+		wol->wolopts |= WAKE_MCAST;
+	if (adapter->wol & ATL1_WUFC_BC)
+		wol->wolopts |= WAKE_BCAST;
+	if (adapter->wol & ATL1_WUFC_MAG)
+		wol->wolopts |= WAKE_MAGIC;
+	return;
+}
+
+static int atl1_set_wol(struct net_device *netdev,
+			struct ethtool_wolinfo *wol)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+
+	if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
+		return -EOPNOTSUPP;
+	adapter->wol = 0;
+	if (wol->wolopts & WAKE_UCAST)
+		adapter->wol |= ATL1_WUFC_EX;
+	if (wol->wolopts & WAKE_MCAST)
+		adapter->wol |= ATL1_WUFC_MC;
+	if (wol->wolopts & WAKE_BCAST)
+		adapter->wol |= ATL1_WUFC_BC;
+	if (wol->wolopts & WAKE_MAGIC)
+		adapter->wol |= ATL1_WUFC_MAG;
+	return 0;
+}
+
+static void atl1_get_ringparam(struct net_device *netdev,
+			    struct ethtool_ringparam *ring)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+	struct atl1_tpd_ring *txdr = &adapter->tpd_ring;
+	struct atl1_rfd_ring *rxdr = &adapter->rfd_ring;
+
+	ring->rx_max_pending = 2048;
+	ring->tx_max_pending = 1024;
+	ring->rx_mini_max_pending = 0;
+	ring->rx_jumbo_max_pending = 0;
+	ring->rx_pending = rxdr->count;
+	ring->tx_pending = txdr->count;
+	ring->rx_mini_pending = 0;
+	ring->rx_jumbo_pending = 0;
+}
+
+static void atl1_get_pauseparam(struct net_device *netdev,
+			     struct ethtool_pauseparam *epause)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+	struct atl1_hw *hw = &adapter->hw;
+
+	if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+	    hw->media_type == MEDIA_TYPE_1000M_FULL) {
+		epause->autoneg = AUTONEG_ENABLE;
+	} else {
+		epause->autoneg = AUTONEG_DISABLE;
+	}
+	epause->rx_pause = 1;
+	epause->tx_pause = 1;
+}
+
+static int atl1_set_pauseparam(struct net_device *netdev,
+			     struct ethtool_pauseparam *epause)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+	struct atl1_hw *hw = &adapter->hw;
+
+	if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+	    hw->media_type == MEDIA_TYPE_1000M_FULL) {
+		epause->autoneg = AUTONEG_ENABLE;
+	} else {
+		epause->autoneg = AUTONEG_DISABLE;
+	}
+
+	epause->rx_pause = 1;
+	epause->tx_pause = 1;
+
+	return 0;
+}
+
+static u32 atl1_get_rx_csum(struct net_device *netdev)
+{
+	return 1;	
+}
+
+static void atl1_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
+{
+	u8 *p = data;
+	int i;
+
+	switch (stringset) {
+	case ETH_SS_STATS:
+		for (i = 0; i < ARRAY_SIZE(atl1_gstrings_stats); i++) {
+			memcpy(p, atl1_gstrings_stats[i].stat_string,
+				ETH_GSTRING_LEN);
+			p += ETH_GSTRING_LEN;
+		}
+		break;
+	}
+}
+
+static int atl1_nway_reset(struct net_device *netdev)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+	struct atl1_hw *hw = &adapter->hw;	
+	
+	if (netif_running(netdev)) {
+		u16 phy_data;
+		atl1_down(adapter);
+
+		if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+			hw->media_type == MEDIA_TYPE_1000M_FULL) {
+			phy_data = MII_CR_RESET | MII_CR_AUTO_NEG_EN;
+		} else {
+			switch (hw->media_type) {
+			case MEDIA_TYPE_100M_FULL:
+				phy_data = MII_CR_FULL_DUPLEX |
+					MII_CR_SPEED_100 | MII_CR_RESET;
+				break;
+			case MEDIA_TYPE_100M_HALF:
+				phy_data = MII_CR_SPEED_100 | MII_CR_RESET;
+				break;	
+			case MEDIA_TYPE_10M_FULL:
+				phy_data = MII_CR_FULL_DUPLEX |
+					MII_CR_SPEED_10 | MII_CR_RESET;
+				break;
+			default:  /* MEDIA_TYPE_10M_HALF */
+				phy_data = MII_CR_SPEED_10 | MII_CR_RESET;
+			}
+		}
+		atl1_write_phy_reg(hw, MII_BMCR, phy_data);
+		atl1_up(adapter);
+	}
+	return 0;
+}
+
+const struct ethtool_ops atl1_ethtool_ops = {
+	.get_settings		= atl1_get_settings,
+	.set_settings		= atl1_set_settings,
+	.get_drvinfo		= atl1_get_drvinfo,
+	.get_wol		= atl1_get_wol,
+	.set_wol		= atl1_set_wol,
+	.get_ringparam		= atl1_get_ringparam,
+	.get_pauseparam		= atl1_get_pauseparam,
+	.set_pauseparam 	= atl1_set_pauseparam,
+	.get_rx_csum		= atl1_get_rx_csum,
+	.get_tx_csum		= ethtool_op_get_tx_csum,
+	.set_tx_csum		= ethtool_op_set_tx_hw_csum,
+	.get_link		= ethtool_op_get_link,
+	.get_sg			= ethtool_op_get_sg,
+	.set_sg			= ethtool_op_set_sg,
+	.get_strings		= atl1_get_strings,
+	.nway_reset		= atl1_nway_reset,
+	.get_ethtool_stats	= atl1_get_ethtool_stats,
+	.get_stats_count	= atl1_get_stats_count,
+	.get_tso		= ethtool_op_get_tso,
+	.set_tso		= ethtool_op_set_tso,
+};
drivers/net/atl1/atl1_hw.c new file +728 -0

728 lines not on this page · raw message

drivers/net/atl1/atl1_param.c new file +223 -0

223 lines not on this page · raw message

#1 lore raw
Quoted 18 lines · On Sun, 21 Jan 2007 15:07:37 -0600 Jay Cliburn wrote:

This patch contains auxiliary C files for the Attansic L1 gigabit ethernet adapter driver.

---

 atl1_ethtool.c |  436 ++++++++++++++++++++++++++++++++++
 atl1_hw.c      |  728 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 atl1_param.c   |  223 +++++++++++++++++
 3 files changed, 1387 insertions(+)
drivers/net/atl1/atl1_ethtool.c new file +0 -0
new file mode 100644
index 0000000..4c6e505

drivers/net/atl1/atl1_ethtool.c line 1

Quoted 1 line
drivers/net/atl1/atl1_ethtool.c new file +1 -0
@@ -0,0 +1,436 @@
+/**

Please use "/**" _only_ to begin kernel-doc comments (and this is not a kernel-doc comment).
(occurs at multiple other places in this and the other patches)

Quoted 38 lines
drivers/net/atl1/atl1_ethtool.c new file +38 -0
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <[email protected]>
+ * Copyright(c) 2006 Jay Cliburn <[email protected]>
+ * 
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 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.
+ **/
+
+
+static int atl1_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+	struct atl1_hw *hw = &adapter->hw;
+
+	ecmd->supported = (SUPPORTED_10baseT_Half |
+			   SUPPORTED_10baseT_Full |
+			   SUPPORTED_100baseT_Half |
+			   SUPPORTED_100baseT_Full |
+			   SUPPORTED_1000baseT_Full |
+			   SUPPORTED_Autoneg | SUPPORTED_TP);
+	ecmd->advertising = ADVERTISED_TP;
+	if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+	    hw->media_type == MEDIA_TYPE_1000M_FULL) {
+		ecmd->advertising |= ADVERTISED_Autoneg;

drivers/net/atl1/atl1_ethtool.c line 124

Quoted 10 lines
drivers/net/atl1/atl1_ethtool.c new file +10 -0
+		if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR) {
+			ecmd->advertising |= ADVERTISED_Autoneg;
+			ecmd->advertising |=
+			    (ADVERTISED_10baseT_Half |
+			     ADVERTISED_10baseT_Full |
+			     ADVERTISED_100baseT_Half |
+			     ADVERTISED_100baseT_Full |
+			     ADVERTISED_1000baseT_Full);
+		} else {
+			ecmd->advertising |= (ADVERTISED_1000baseT_Full);

Kernel coding style is not to use braces around one-statement "blocks." (occurs in multiple other places)

Quoted 28 lines
drivers/net/atl1/atl1_ethtool.c new file +28 -0
+		}
+	}
+	ecmd->port = PORT_TP;
+	ecmd->phy_address = 0;
+	ecmd->transceiver = XCVR_INTERNAL;
+
+	if (netif_carrier_ok(adapter->netdev)) {
+		u16 link_speed, link_duplex;
+		atl1_get_speed_and_duplex(hw, &link_speed, &link_duplex);
+		ecmd->speed = link_speed;
+		if (link_duplex == FULL_DUPLEX)
+			ecmd->duplex = DUPLEX_FULL;
+		else
+			ecmd->duplex = DUPLEX_HALF;
+	} else {
+		ecmd->speed = -1;
+		ecmd->duplex = -1;
+	}
+	if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
+	    hw->media_type == MEDIA_TYPE_1000M_FULL) {
+		ecmd->autoneg = AUTONEG_ENABLE;
+	} else {
+		ecmd->autoneg = AUTONEG_DISABLE;
+	}
+	
+	return 0;
+}
+

drivers/net/atl1/atl1_ethtool.c line 162

Quoted 10 lines
drivers/net/atl1/atl1_ethtool.c new file +10 -0
+static int atl1_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+	struct atl1_hw *hw = &adapter->hw;
+	u16 phy_data;
+	int ret_val = 0;
+	u16 old_media_type = hw->media_type;
+
+	if (netif_running(adapter->netdev)) {
+		printk(KERN_DEBUG "%s: ethtool shutting down link adapter\n", 

What's a "link adapter"?

Quoted 30 lines
drivers/net/atl1/atl1_ethtool.c new file +30 -0
+			atl1_driver_name);
+		atl1_down(adapter);
+	}
+
+	if (ecmd->autoneg == AUTONEG_ENABLE) {
+		hw->media_type = MEDIA_TYPE_AUTO_SENSOR;
+	} else {
+		if (ecmd->speed == SPEED_1000) {
+			if (ecmd->duplex != DUPLEX_FULL) {
+				printk(KERN_WARNING
+				       "%s: can't force to 1000M half duplex\n",
+					atl1_driver_name);
+				ret_val = -EINVAL;
+				goto exit_sset;
+			}
+			hw->media_type = MEDIA_TYPE_1000M_FULL;
+		} else if (ecmd->speed == SPEED_100) {
+			if (ecmd->duplex == DUPLEX_FULL) {
+				hw->media_type = MEDIA_TYPE_100M_FULL;
+			} else {
+				hw->media_type = MEDIA_TYPE_100M_HALF;
+			}
+		} else {
+			if (ecmd->duplex == DUPLEX_FULL) {
+				hw->media_type = MEDIA_TYPE_10M_FULL;
+			} else {
+				hw->media_type = MEDIA_TYPE_10M_HALF;
+			}
+		}
+	}

...

drivers/net/atl1/atl1_ethtool.c line 266

Quoted 11 lines
drivers/net/atl1/atl1_ethtool.c new file +11 -0
+}
+
+static void atl1_get_drvinfo(struct net_device *netdev,
+				struct ethtool_drvinfo *drvinfo)
+{
+	struct atl1_adapter *adapter = netdev_priv(netdev);
+
+	strncpy(drvinfo->driver, atl1_driver_name, 32);
+	strncpy(drvinfo->version, atl1_driver_version, 32);
+	strncpy(drvinfo->fw_version, "N/A", 32);
+	strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);

Use sizeof(drvinfo->driver) etc. above instead of "32".

drivers/net/atl1/atl1_hw.c line 2

Quoted 13 lines
drivers/net/atl1/atl1_ethtool.c new file +4 -0
+	drvinfo->eedump_len = 48;
+}
+
+
drivers/net/atl1/atl1_hw.c new file +2 -0
new file mode 100644
index 0000000..4062abd
@@ -0,0 +1,728 @@
+
+extern char atl1_driver_name[];

Externs should be in header files.

drivers/net/atl1/atl1_hw.c line 40

Quoted 5 lines
drivers/net/atl1/atl1_hw.c new file +5 -0
+/**
+ * Reset the transmit and receive units; mask and clear all interrupts.
+ * hw - Struct containing variables accessed by shared code
+ * return : ATL1_SUCCESS  or  idle status (if error)
+ **/

This function comment block is almost kernel-doc... It would be good to make it so.

drivers/net/atl1/atl1_hw.c line 41

Quoted 1 line
drivers/net/atl1/atl1_hw.c new file +1 -0
+s32 atl1_reset_hw(struct atl1_hw * hw)
                                    *hw)
Quoted 1 line
drivers/net/atl1/atl1_hw.c new file +1 -0
+{

...

drivers/net/atl1/atl1_hw.c line 90

Quoted 7 lines
drivers/net/atl1/atl1_hw.c new file +7 -0
+}
+
+/** function about EEPROM
+ *
+ * check_eeprom_exist
+ * return 0 if eeprom exist
+ **/

Use kernel-doc format or don't begin comment block with /**. See Documentation/kernel-doc-nano-HOWTO.txt for info. (multiple places)

drivers/net/atl1/atl1_hw.c line 101

Quoted 11 lines
drivers/net/atl1/atl1_hw.c new file +11 -0
+static int atl1_check_eeprom_exist(struct atl1_hw *hw)
+{
+	u32 value;
+	value = ioread32(hw->hw_addr + REG_SPI_FLASH_CTRL);
+	if (value & SPI_FLASH_CTRL_EN_VPD) {
+		value &= ~SPI_FLASH_CTRL_EN_VPD;
+		iowrite32(value, hw->hw_addr + REG_SPI_FLASH_CTRL);
+	}
+
+	value = ioread16(hw->hw_addr + REG_PCIE_CAP_LIST);
+	return ((value & 0xFF00) == 0x6C00) ? 0 : 1;

Are there defines or enums for these?
Fewer magic numbers would be nice/helpful/readable.

drivers/net/atl1/atl1_hw.c line 104

Quoted 3 lines
drivers/net/atl1/atl1_hw.c new file +3 -0
+}
+
+static bool atl1_read_eeprom(struct atl1_hw *hw, u32 offset, u32 * p_value)
                                                                    *p_value)
Quoted 1 line

+{

...

drivers/net/atl1/atl1_hw.c line 134

Quoted 7 lines
drivers/net/atl1/atl1_hw.c new file +7 -0
+}
+
+/**
+ * Reads the value from a PHY register
+ * hw - Struct containing variables accessed by shared code
+ * reg_addr - address of the PHY register to read
+ **/

kernel-doc

Quoted 1 line

+s32 atl1_read_phy_reg(struct atl1_hw * hw, u16 reg_addr, u16 * phy_data)

CodingStyle: *hw, ... *phy_data)

Quoted 1 line

+{

...

Quoted 10 lines
drivers/net/atl1/atl1_hw.c new file +10 -0
+}
+
+#define CUSTOM_SPI_CS_SETUP	2
+#define CUSTOM_SPI_CLK_HI	2
+#define CUSTOM_SPI_CLK_LO	2
+#define CUSTOM_SPI_CS_HOLD	2
+#define CUSTOM_SPI_CS_HI	3
+
+static bool atl1_spi_read(struct atl1_hw *hw, u32 addr, u32 * buf)
+{

...

drivers/net/atl1/atl1_hw.c line 211

Quoted 6 lines
drivers/net/atl1/atl1_hw.c new file +6 -0
+}
+
+/**
+ * get_permanent_address
+ * return 0 if get valid mac address, 
+ **/

kernel-doc

drivers/net/atl1/atl1_hw.c line 217

Quoted 6 lines
drivers/net/atl1/atl1_hw.c new file +6 -0
+int atl1_get_permanent_address(struct atl1_hw *hw)
+{
+	u32 addr[2];
+	u32 i, control;
+	u16 reg;
+	u8 eth_addr[NODE_ADDRESS_SIZE];

Use ETH_ALEN from if_ether.h instead of your own NODE_ADDRESS_SIZE.

Quoted 5 lines
drivers/net/atl1/atl1_hw.c new file +5 -0
+	bool key_valid;
+
+	if (is_valid_ether_addr(hw->perm_mac_addr))
+		return 0;
+	}

...

drivers/net/atl1/atl1_hw.c line 414

Quoted 13 lines
drivers/net/atl1/atl1_hw.c new file +13 -0
+}
+
+
+/**
+ * Make L001's PHY out of Power Saving State (bug)
+ * hw - Struct containing variables accessed by shared code
+ * when power on, L001's PHY always on Power saving State
+ * (Gigabit Link forbidden)
+ **/
+static s32 atl1_phy_leave_power_saving(struct atl1_hw *hw)
+{
+	s32 ret;
+	ret = atl1_write_phy_reg(hw, 29, 0x0029);

Fewer magic numbers?

Quoted 11 lines
drivers/net/atl1/atl1_hw.c new file +4 -0
+	if (ret)
+		return ret;
+	return atl1_write_phy_reg(hw, 30, 0);
+}
drivers/net/atl1/atl1_param.c new file +0 -0
new file mode 100644
index 0000000..4732f43

drivers/net/atl1/atl1_param.c line 7

Quoted 7 lines
drivers/net/atl1/atl1_param.c new file +7 -0
@@ -0,0 +1,223 @@
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/moduleparam.h>
+#include "atl1.h"
+
+extern char atl1_driver_name[];

in a header file, please.

Quoted 33 lines
drivers/net/atl1/atl1_param.c new file +33 -0
+/**
+ * This is the only thing that needs to be changed to adjust the
+ * maximum number of ports that the driver can manage.
+ **/
+#define ATL1_MAX_NIC 4
+
+#define OPTION_UNSET    -1
+#define OPTION_DISABLED 0
+#define OPTION_ENABLED  1
+
+#define ATL1_PARAM_INIT { [0 ... ATL1_MAX_NIC] = OPTION_UNSET }
+
+/**
+ * Interrupt Moderate Timer in units of 2 us
+ *
+ * Valid Range: 10-65535
+ *
+ * Default Value: 100 (200us)
+ **/
+static int __devinitdata int_mod_timer[ATL1_MAX_NIC+1] = ATL1_PARAM_INIT;
+static int num_int_mod_timer = 0;
+module_param_array_named(int_mod_timer, int_mod_timer, int, &num_int_mod_timer, 0);
+MODULE_PARM_DESC(int_mod_timer, "Interrupt moderator timer");
+
+/**
+ * flash_vendor
+ *
+ * Valid Range: 0-2
+ *
+ * 0 - Atmel
+ * 1 - SST
+ * 2 - ST
+ *

drivers/net/atl1/atl1_param.c line 73

Quoted 10 lines
drivers/net/atl1/atl1_param.c new file +10 -0
+ * Default Value: 0
+ **/
+static int __devinitdata flash_vendor[ATL1_MAX_NIC+1] = ATL1_PARAM_INIT;
+static int num_flash_vendor = 0;
+module_param_array_named(flash_vendor, flash_vendor, int, &num_flash_vendor, 0);
+MODULE_PARM_DESC(flash_vendor, "SPI flash vendor");
+
+int enable_msi;
+module_param(enable_msi, int, 0444);
+MODULE_PARM_DESC(enable_msi, "Enable PCI MSI");

Hm, I thought that we didn't want individual drivers having MSI config options...

Quoted 10 lines
drivers/net/atl1/atl1_param.c new file +10 -0
+
+#define DEFAULT_INT_MOD_CNT	100	/* 200us */
+#define MAX_INT_MOD_CNT		65000
+#define MIN_INT_MOD_CNT		50
+
+#define FLASH_VENDOR_DEFAULT	0
+#define FLASH_VENDOR_MIN	0
+#define FLASH_VENDOR_MAX	2
+
+

drivers/net/atl1/atl1_param.c line 164

Quoted 10 lines
drivers/net/atl1/atl1_param.c new file +10 -0
+
+/**
+ * atl1_check_options - Range Checking for Command Line Parameters
+ * @adapter: board private structure
+ *
+ * This routine checks all command line parameters for valid user
+ * input.  If an invalid value is given, or if no user specified
+ * value exists, a default value is used.  The final value is stored
+ * in a variable in the adapter structure.
+ **/

Hey, it's kernel-doc. :)

Quoted 3 lines
drivers/net/atl1/atl1_param.c new file +3 -0
+void __devinit atl1_check_options(struct atl1_adapter *adapter)
+{
+

...

drivers/net/atl1/atl1_param.c

Quoted 10 lines
drivers/net/atl1/atl1_param.c new file +9 -1
+	{			/* PCI MSI usage */
+
+#ifdef CONFIG_PCI_MSI
+		adapter->enable_msi = enable_msi;
+#else
+		adapter->enable_msi = 0;
+#endif
+	}
+}
-

---
~Randy

#2 lore raw
Quoted 1 line · Randy Dunlap

On Sun, 21 Jan 2007 15:07:37 -0600 Jay Cliburn wrote:

[snip]

Quoted 5 lines

drivers/net/atl1/atl1_hw.c line 101

Quoted 2 lines
drivers/net/atl1/atl1_hw.c new file +2 -0
+	value = ioread16(hw->hw_addr + REG_PCIE_CAP_LIST);
+	return ((value & 0xFF00) == 0x6C00) ? 0 : 1;

Are there defines or enums for these?
Fewer magic numbers would be nice/helpful/readable.

[snip]

Quoted 4 lines

drivers/net/atl1/atl1_hw.c line 414

Quoted 2 lines
drivers/net/atl1/atl1_hw.c new file +2 -0
+	s32 ret;
+	ret = atl1_write_phy_reg(hw, 29, 0x0029);

Fewer magic numbers?

Unfortunately, we don't have a spec. This is how the vendor coded it.

[snip]

Quoted 7 lines

drivers/net/atl1/atl1_param.c line 73

Quoted 4 lines
drivers/net/atl1/atl1_param.c new file +4 -0
+
+int enable_msi;
+module_param(enable_msi, int, 0444);
+MODULE_PARM_DESC(enable_msi, "Enable PCI MSI");

Hm, I thought that we didn't want individual drivers having MSI config options...

Luca? This one was yours IIRC. Care to chime in?

Randy, thank you for the review.

Jay

#3 lore raw

Il Sun, Jan 21, 2007 at 09:33:39PM -0600, Jay Cliburn ha scritto:

Quoted 26 lines
Quoted 1 line · Randy Dunlap

On Sun, 21 Jan 2007 15:07:37 -0600 Jay Cliburn wrote:

[snip]

Quoted 5 lines

drivers/net/atl1/atl1_hw.c line 101

Quoted 2 lines
drivers/net/atl1/atl1_hw.c new file +2 -0
+	value = ioread16(hw->hw_addr + REG_PCIE_CAP_LIST);
+	return ((value & 0xFF00) == 0x6C00) ? 0 : 1;

Are there defines or enums for these?
Fewer magic numbers would be nice/helpful/readable.

[snip]

Quoted 4 lines

drivers/net/atl1/atl1_hw.c line 414

Quoted 2 lines
drivers/net/atl1/atl1_hw.c new file +2 -0
+	s32 ret;
+	ret = atl1_write_phy_reg(hw, 29, 0x0029);

Fewer magic numbers?

Unfortunately, we don't have a spec. This is how the vendor coded it.

[snip]

Quoted 7 lines

drivers/net/atl1/atl1_param.c line 73

Quoted 4 lines
drivers/net/atl1/atl1_param.c new file +4 -0
+
+int enable_msi;
+module_param(enable_msi, int, 0444);
+MODULE_PARM_DESC(enable_msi, "Enable PCI MSI");

Hm, I thought that we didn't want individual drivers having MSI config options...

Quoted 1 line

Luca? This one was yours IIRC. Care to chime in?

I remember that discussion, but since there's no sistem-wide MSI blacklist (or whitelist) I don't think it's safe to enable it unconditionally. Judging from bug reports on lkml it's not safe to assume that MSI support is sane on non-Intel chipsets.

Luca

Signature · 2 lines
Il coraggio non mi manca.
E` la paura che mi frega...
#4 lore raw
Quoted 27 lines · On Mon, 22 Jan 2007 21:00:04 +0100 Luca Tettamanti <[email protected]> wrote:

Il Sun, Jan 21, 2007 at 09:33:39PM -0600, Jay Cliburn ha scritto:

Quoted 26 lines
Quoted 1 line · Randy Dunlap

On Sun, 21 Jan 2007 15:07:37 -0600 Jay Cliburn wrote:

[snip]

Quoted 5 lines

drivers/net/atl1/atl1_hw.c line 101

Quoted 2 lines
drivers/net/atl1/atl1_hw.c new file +2 -0
+	value = ioread16(hw->hw_addr + REG_PCIE_CAP_LIST);
+	return ((value & 0xFF00) == 0x6C00) ? 0 : 1;

Are there defines or enums for these?
Fewer magic numbers would be nice/helpful/readable.

[snip]

Quoted 4 lines

drivers/net/atl1/atl1_hw.c line 414

Quoted 2 lines
drivers/net/atl1/atl1_hw.c new file +2 -0
+	s32 ret;
+	ret = atl1_write_phy_reg(hw, 29, 0x0029);

Fewer magic numbers?

Unfortunately, we don't have a spec. This is how the vendor coded it.

[snip]

Quoted 7 lines

drivers/net/atl1/atl1_param.c line 73

Quoted 4 lines
drivers/net/atl1/atl1_param.c new file +4 -0
+
+int enable_msi;
+module_param(enable_msi, int, 0444);
+MODULE_PARM_DESC(enable_msi, "Enable PCI MSI");

Hm, I thought that we didn't want individual drivers having MSI config options...

Quoted 8 lines
Quoted 1 line

Luca? This one was yours IIRC. Care to chime in?

I remember that discussion, but since there's no sistem-wide MSI blacklist (or whitelist) I don't think it's safe to enable it unconditionally. Judging from bug reports on lkml it's not safe to assume that MSI support is sane on non-Intel chipsets.

Luca

There is MSI blacklisting see drivers/pci/quirks.c code. But the blacklist isn't complete enough yet.

IMHO the MSI disabling should be removed from drivers and be done in the PCI core. But it doesn't seem to have gotten widespread support.

Signature · 1 line
Stephen Hemminger <[email protected]>
#5 lore raw

Il Tue, Jan 23, 2007 at 11:25:22AM -0800, Stephen Hemminger ha scritto:

Quoted 22 lines
Quoted 19 lines · On Mon, 22 Jan 2007 21:00:04 +0100 Luca Tettamanti <[email protected]> wrote:

Il Sun, Jan 21, 2007 at 09:33:39PM -0600, Jay Cliburn ha scritto:

Quoted 11 lines
Quoted 1 line · Randy Dunlap

On Sun, 21 Jan 2007 15:07:37 -0600 Jay Cliburn wrote:

[snip]

Quoted 7 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+
+int enable_msi;
+module_param(enable_msi, int, 0444);
+MODULE_PARM_DESC(enable_msi, "Enable PCI MSI");

Hm, I thought that we didn't want individual drivers having MSI config options...

Quoted 1 line

Luca? This one was yours IIRC. Care to chime in?

I remember that discussion, but since there's no sistem-wide MSI blacklist (or whitelist) I don't think it's safe to enable it unconditionally. Judging from bug reports on lkml it's not safe to assume that MSI support is sane on non-Intel chipsets.

Quoted 8 lines
Quoted 1 line

Luca

There is MSI blacklisting see drivers/pci/quirks.c code. But the blacklist isn't complete enough yet.

IMHO the MSI disabling should be removed from drivers and be done in the PCI core. But it doesn't seem to have gotten widespread support.

Does the INTx madness (like this one:
http://marc.theaimsgroup.com/?l=linux-kernel&m=116668921431574&w=2
) affect also PCI-E INTx emulation?

Anyway...

Unconditionally enable MSI in atl1 driver. Also remove some useless #ifdef since pci_{en,dis}able_msi() are no-op when MSI support is not configured in.

---
Patch against current netdev tree.

 drivers/net/atl1/atl1.h       |    1 -
 drivers/net/atl1/atl1_main.c  |   22 +++++++---------------
 drivers/net/atl1/atl1_param.c |   13 -------------
 3 files changed, 7 insertions(+), 29 deletions(-)
drivers/net/atl1/atl1.h +0 -1
index 1d13e8f..0b30e1c 100644
@@ -281,7 +281,6 @@ struct atl1_adapter {
 	struct atl1_smb smb;
 	struct atl1_cmb cmb;
 
-	int enable_msi;
 	u32 pci_state[16];
 };
 
drivers/net/atl1/atl1_main.c +7 -15
index c0b1555..68e6cd1 100644
@@ -1793,18 +1793,12 @@ s32 atl1_up(struct atl1_adapter *adapter)
 		goto err_up;
 	}
 
-#ifdef CONFIG_PCI_MSI
-	if (adapter->enable_msi) {
-		err = pci_enable_msi(adapter->pdev);
-		if (err) {
-			dev_info(&adapter->pdev->dev, "Unable to enable MSI: %d\n", err);
-			adapter->enable_msi = 0;
-		}
-	}
-#endif
-	if (!adapter->enable_msi)
+	err = pci_enable_msi(adapter->pdev);
+	if (err) {
+		dev_info(&adapter->pdev->dev, "Unable to enable MSI: %d\n", err);
 		irq_flags |= IRQF_SHARED;
-
+	}
+	
 	err = request_irq(adapter->pdev->irq, &atl1_intr, irq_flags,
 			netdev->name, netdev);
 	if (unlikely(err))
@@ -1821,6 +1815,7 @@ s32 atl1_up(struct atl1_adapter *adapter)
 	free_irq(adapter->pdev->irq, netdev);
 
 err_up:
+	pci_disable_msi(adapter->pdev);
 	/* free rx_buffers */
 	atl1_clean_rx_ring(adapter);
 	return err;
@@ -1836,10 +1831,7 @@ void atl1_down(struct atl1_adapter *adapter)
 
 	atl1_irq_disable(adapter);
 	free_irq(adapter->pdev->irq, netdev);
-#ifdef CONFIG_PCI_MSI
-	if (adapter->enable_msi)
-		pci_disable_msi(adapter->pdev);
-#endif
+	pci_disable_msi(adapter->pdev);
 	atl1_reset_hw(&adapter->hw);
 	adapter->cmb.cmb->int_stats = 0;
 
drivers/net/atl1/atl1_param.c +0 -13
index 4732f43..caa2d83 100644
@@ -68,10 +68,6 @@ static int num_flash_vendor = 0;
 module_param_array_named(flash_vendor, flash_vendor, int, &num_flash_vendor, 0);
 MODULE_PARM_DESC(flash_vendor, "SPI flash vendor");
 
-int enable_msi;
-module_param(enable_msi, int, 0444);
-MODULE_PARM_DESC(enable_msi, "Enable PCI MSI");
-
 #define DEFAULT_INT_MOD_CNT	100	/* 200us */
 #define MAX_INT_MOD_CNT		65000
 #define MIN_INT_MOD_CNT		50
@@ -211,13 +207,4 @@ void __devinit atl1_check_options(struct atl1_adapter *adapter)
 			adapter->hw.flash_vendor = (u8) (opt.def);
 		}
 	}
-
-	{			/* PCI MSI usage */
-
-#ifdef CONFIG_PCI_MSI
-		adapter->enable_msi = enable_msi;
-#else
-		adapter->enable_msi = 0;
-#endif
-	}
 }

Luca

Signature · 3 lines
Inquietudine sintetica
Solo, davanti all'ignoto
Tienimi stretto a te
#10 lore raw
In reply to Stephen Hemminger
Quoted 2 lines · Stephen Hemminger

IMHO the MSI disabling should be removed from drivers and be done in the PCI core.

That is the consensus opinion.

Currently drivers implement the MSI tests because the core PCI code hasn't been up to snuff. I (and others) have been discouraging that, but when a user faces a choice between working and non-working network, the pragmatic solution wins.

All efforts to get us to the point where we can remove the MSI tests from drivers are strongly supported...

Jeff

#11 lore raw
Quoted 11 lines · On Tue, 23 Jan 2007 16:33:29 -0500 Jeff Garzik <[email protected]> wrote:
Quoted 2 lines · Stephen Hemminger

IMHO the MSI disabling should be removed from drivers and be done in the PCI core.

That is the consensus opinion.

Currently drivers implement the MSI tests because the core PCI code hasn't been up to snuff. I (and others) have been discouraging that, but when a user faces a choice between working and non-working network, the pragmatic solution wins.

Quoted 4 lines

All efforts to get us to the point where we can remove the MSI tests from drivers are strongly supported...

Jeff

So far, either MSI works for all devices or is broken, so it makes sense to have a "msi=off" boot option (if there isn't already)

Signature · 1 line
Stephen Hemminger <[email protected]>
#12 lore raw
Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Tue, 23 Jan 2007 16:33:29 -0500 Jeff Garzik <[email protected]> wrote:
Quoted 2 lines · Stephen Hemminger

IMHO the MSI disabling should be removed from drivers and be done in the PCI core.

That is the consensus opinion.

Currently drivers implement the MSI tests because the core PCI code hasn't been up to snuff. I (and others) have been discouraging that, but when a user faces a choice between working and non-working network, the pragmatic solution wins.

Linus's remark (IIRC) was to not enable CONFIG_PCI_MSI then.

Quoted 7 lines
Quoted 3 lines

All efforts to get us to the point where we can remove the MSI tests from drivers are strongly supported...

Jeff

So far, either MSI works for all devices or is broken, so it makes sense to have a "msi=off" boot option (if there isn't already)

There is one, but it's spelled "pci=nomsi".

Signature · 1 line
~Randy
#13 lore raw
Quoted 4 lines · Randy Dunlap
Quoted 3 lines · Stephen Hemminger

On Tue, 23 Jan 2007 16:33:29 -0500
Jeff Garzik <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines · Stephen Hemminger

IMHO the MSI disabling should be removed from drivers and be done in the PCI core.

That is the consensus opinion.

Currently drivers implement the MSI tests because the core PCI code hasn't been up to snuff. I (and others) have been discouraging that, but when a user faces a choice between working and non-working network, the pragmatic solution wins.

Linus's remark (IIRC) was to not enable CONFIG_PCI_MSI then.

Most distros, especially cutting edge ones like Fedora, will enable CONFIG_PCI_MSI.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

All efforts to get us to the point where we can remove the MSI tests from drivers are strongly supported...

Jeff

So far, either MSI works for all devices or is broken, so it makes sense to have a "msi=off" boot option (if there isn't already)

There is one, but it's spelled "pci=nomsi".

Yep. Thanks for repeating this, and refreshing the collective memory.

Jeff

author Acked-by
#6 lore raw
In reply to Luca Tettamanti

Luca Tettamanti wrote:
[snip]

Quoted 8 lines

Anyway...

Unconditionally enable MSI in atl1 driver. Also remove some useless #ifdef since pci_{en,dis}able_msi() are no-op when MSI support is not configured in.

I tested this patch today. Works fine on my Asus M2V mainboard (Via K8T890).

Here are the eth0 entries in /proc/interrupts before and after the patch.

BEFORE:    36:   93   322091   IO-APIC-fasteoi   eth0
AFTER:   2298:   85     7289   PCI-MSI-edge      eth0

Jeff, shall I add this to the larger patch I'm working on for submittal later this weekend, or do you just add it directly to netdev? (I prefer to do the former if it's okay with you.)

Jay

Quoted 97 lines

---
Patch against current netdev tree.

 drivers/net/atl1/atl1.h       |    1 -
 drivers/net/atl1/atl1_main.c  |   22 +++++++---------------
 drivers/net/atl1/atl1_param.c |   13 -------------
 3 files changed, 7 insertions(+), 29 deletions(-)
drivers/net/atl1/atl1.h +0 -1
index 1d13e8f..0b30e1c 100644
@@ -281,7 +281,6 @@ struct atl1_adapter {
 	struct atl1_smb smb;
 	struct atl1_cmb cmb;
 
-	int enable_msi;
 	u32 pci_state[16];
 };
 
drivers/net/atl1/atl1_main.c +7 -15
index c0b1555..68e6cd1 100644
@@ -1793,18 +1793,12 @@ s32 atl1_up(struct atl1_adapter *adapter)
 		goto err_up;
 	}
 
-#ifdef CONFIG_PCI_MSI
-	if (adapter->enable_msi) {
-		err = pci_enable_msi(adapter->pdev);
-		if (err) {
-			dev_info(&adapter->pdev->dev, "Unable to enable MSI: %d\n", err);
-			adapter->enable_msi = 0;
-		}
-	}
-#endif
-	if (!adapter->enable_msi)
+	err = pci_enable_msi(adapter->pdev);
+	if (err) {
+		dev_info(&adapter->pdev->dev, "Unable to enable MSI: %d\n", err);
 		irq_flags |= IRQF_SHARED;
-
+	}
+	
 	err = request_irq(adapter->pdev->irq, &atl1_intr, irq_flags,
 			netdev->name, netdev);
 	if (unlikely(err))
@@ -1821,6 +1815,7 @@ s32 atl1_up(struct atl1_adapter *adapter)
 	free_irq(adapter->pdev->irq, netdev);
 
 err_up:
+	pci_disable_msi(adapter->pdev);
 	/* free rx_buffers */
 	atl1_clean_rx_ring(adapter);
 	return err;
@@ -1836,10 +1831,7 @@ void atl1_down(struct atl1_adapter *adapter)
 
 	atl1_irq_disable(adapter);
 	free_irq(adapter->pdev->irq, netdev);
-#ifdef CONFIG_PCI_MSI
-	if (adapter->enable_msi)
-		pci_disable_msi(adapter->pdev);
-#endif
+	pci_disable_msi(adapter->pdev);
 	atl1_reset_hw(&adapter->hw);
 	adapter->cmb.cmb->int_stats = 0;
 
drivers/net/atl1/atl1_param.c +0 -13
index 4732f43..caa2d83 100644
@@ -68,10 +68,6 @@ static int num_flash_vendor = 0;
 module_param_array_named(flash_vendor, flash_vendor, int, &num_flash_vendor, 0);
 MODULE_PARM_DESC(flash_vendor, "SPI flash vendor");
 
-int enable_msi;
-module_param(enable_msi, int, 0444);
-MODULE_PARM_DESC(enable_msi, "Enable PCI MSI");
-
 #define DEFAULT_INT_MOD_CNT	100	/* 200us */
 #define MAX_INT_MOD_CNT		65000
 #define MIN_INT_MOD_CNT		50
@@ -211,13 +207,4 @@ void __devinit atl1_check_options(struct atl1_adapter *adapter)
 			adapter->hw.flash_vendor = (u8) (opt.def);
 		}
 	}
-
-	{			/* PCI MSI usage */
-
-#ifdef CONFIG_PCI_MSI
-		adapter->enable_msi = enable_msi;
-#else
-		adapter->enable_msi = 0;
-#endif
-	}
 }
#7 lore raw
Quoted 1 line · Jay Cliburn

Jeff, shall I add this to the larger patch I'm working on for submittal later this weekend, or do you just add it directly to netdev? (I prefer to do the former if it's okay with you.)

As a driver maintainer, you need to patch sets, and submit them in a timely fashion to me. Note I said patch set, not patch, in following with Rule #3 from Documentation/SubmittingPatches. Also make sure to review http://linux.yyz.us/patch-format.html

Jeff

#8 lore raw
Quoted 1 line · Jeff Garzik

As a driver maintainer, you need to patch sets, and submit them in a timely fashion to me. Note I said patch set, not patch, in following with Rule #3 from Documentation/SubmittingPatches. Also make sure to review http://linux.yyz.us/patch-format.html

Understood. Both references reviewed. Thanks.

Sorry, but one last question... These two patches generated overnight by Andrew:

Message-Id: <[email protected]>
Subject: + git-netdev-all-atl1-pm-fix.patch added to -mm tree

and

Message-Id: <[email protected]>
Subject: + git-netdev-all-atl1-build-fix.patch added to -mm tree

Do I include these in my patch set that I submit to you, or do you apply them to netdev directly?

Jay

#9 lore raw
Quoted 10 lines · Jay Cliburn
Quoted 1 line · Jeff Garzik

As a driver maintainer, you need to patch sets, and submit them in a timely fashion to me. Note I said patch set, not patch, in following with Rule #3 from Documentation/SubmittingPatches. Also make sure to review http://linux.yyz.us/patch-format.html

Understood. Both references reviewed. Thanks.

Sorry, but one last question... These two patches generated overnight by Andrew:

Message-Id: <[email protected]>
Subject: + git-netdev-all-atl1-pm-fix.patch added to -mm tree

Quoted 6 lines

and

Message-Id: <[email protected]>
Subject: + git-netdev-all-atl1-build-fix.patch added to -mm tree

Do I include these in my patch set that I submit to you, or do you apply them to netdev directly?

There is no hard and fast rule. If the patch is obvious and submitted in correct form (Andrew's notifications are not in such a form), then I might go ahead and apply it. But I usually reply to the patch with "applied" if so.

In general, you can answer this question yourself. Look at netdev-2.6.git#atl1 and see what's in there.

Jeff