Skip to contentSkip to conversation

replace code with FIELD_SIZEOF

PATCH In review Auke Kok 2 participants 7 messages Feb 11, 2008

Subsystems (2)
lore
Share & tools
lore

Auke Kok

author
#0 lore raw

PATCH 1/6 replace code with FIELD_SIZEOF

From: Julia Lawall <[email protected]>

---

 drivers/net/e1000/e1000_ethtool.c |    2 +-
 drivers/net/igb/igb_ethtool.c     |    2 +-
 drivers/net/ixgb/ixgb_ethtool.c   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/e1000/e1000_ethtool.c +1 -1
index d876787..85e66f4 100644
@@ -50,7 +50,7 @@ struct e1000_stats {
 	int stat_offset;
 };
 
-#define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \
+#define E1000_STAT(m) FIELD_SIZEOF(struct e1000_adapter, m), \
 		      offsetof(struct e1000_adapter, m)
 static const struct e1000_stats e1000_gstrings_stats[] = {
 	{ "rx_packets", E1000_STAT(stats.gprc) },
drivers/net/igb/igb_ethtool.c +1 -1
index f69721e..0447f9b 100644
@@ -43,7 +43,7 @@ struct igb_stats {
 	int stat_offset;
 };
 
-#define IGB_STAT(m) sizeof(((struct igb_adapter *)0)->m), \
+#define IGB_STAT(m) FIELD_SIZEOF(struct igb_adapter, m), \
 		      offsetof(struct igb_adapter, m)
 static const struct igb_stats igb_gstrings_stats[] = {
 	{ "rx_packets", IGB_STAT(stats.gprc) },
drivers/net/ixgb/ixgb_ethtool.c +1 -1
index a267dd8..53a9fd0 100644
@@ -49,7 +49,7 @@ struct ixgb_stats {
 	int stat_offset;
 };
 
-#define IXGB_STAT(m) sizeof(((struct ixgb_adapter *)0)->m), \
+#define IXGB_STAT(m) FIELD_SIZEOF(struct ixgb_adapter, m), \
 		      offsetof(struct ixgb_adapter, m)
 static struct ixgb_stats ixgb_gstrings_stats[] = {
 	{"rx_packets", IXGB_STAT(net_stats.rx_packets)},
author
#1 lore raw

PATCH 2/6 e1000: warn if this driver is used for e1000e devices

We're already starting to see reports from users still using e1000 where they should be using e1000e now that this is actually possible. Just to prevent some of this thrash, add a big warning on load on these devices that people should switch to e1000e.

---

 drivers/net/e1000/e1000_main.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/net/e1000/e1000_main.c +8 -0
index 7c5b05a..81db7fd 100644
@@ -1203,6 +1203,14 @@ e1000_probe(struct pci_dev *pdev,
 
 	printk("%s\n", print_mac(mac, netdev->dev_addr));
 
+	if (adapter->hw.bus_type == e1000_bus_type_pci_express) {
+		DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no "
+			"longer be supported by this driver in the future.\n",
+			pdev->vendor, pdev->device);
+		DPRINTK(PROBE, WARNING, "please use the \"e1000e\" "
+			"driver instead.\n");
+	}
+
 	/* reset the hardware with the new settings */
 	e1000_reset(adapter);
 
author
#2 lore raw

PATCH 3/6 e1000e: Fix logic reversal keeping link active

In reply to Auke Kok

A logic mishap caused the adapter to keep link while we can disable it due to WoL not being active, and vice versa.

---

 drivers/net/e1000e/netdev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/e1000e/netdev.c +1 -1
index f58f017..b9b0d32 100644
@@ -2008,7 +2008,7 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)
 	u16 mii_reg;
 
 	/* WoL is enabled */
-	if (!adapter->wol)
+	if (adapter->wol)
 		return;
 
 	/* non-copper PHY? */
author
#3 lore raw

PATCH 4/6 ixgbe: warn when device is in a x4 or lower width slot

In reply to Auke Kok

It's easy to oversee this issue when working with this card as evrything will work OK but performance is severely limited (something like 1.5gbit on a x1 link) if the pci-express slot does not offer more bandwidth.

---

 drivers/net/ixgbe/ixgbe_main.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/net/ixgbe/ixgbe_main.c +8 -0
index ead49e5..576fb51 100644
@@ -2778,6 +2778,14 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
 		 hw->mac.type, hw->phy.type,
 		 (part_num >> 8), (part_num & 0xff));
 
+	if (link_width <= IXGBE_PCI_LINK_WIDTH_4) {
+		dev_warn(&pdev->dev, "PCI-Express bandwidth available for "
+			 "this card is not sufficient for optimal "
+			 "performance.\n");
+		dev_warn(&pdev->dev, "For optimal performance a x8 "
+			 "PCI-Express slot is required.\n");
+	}
+
 	/* reset the hardware with the new settings */
 	ixgbe_start_hw(hw);
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

author
#4 lore raw

PATCH 5/6 ixgbe: Disallow device reset during ethtool test

In reply to Auke Kok

---

 drivers/net/ixgbe/ixgbe_main.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/ixgbe/ixgbe_main.c +4 -0
index 576fb51..a4aeaec 100644
@@ -1942,6 +1942,10 @@ static int ixgbe_open(struct net_device *netdev)
 	int err;
 	u32 num_rx_queues = adapter->num_rx_queues;
 
+	/* disallow open during test */
+	if (test_bit(__IXGBE_TESTING, &adapter->state))
+		return -EBUSY;
+
 try_intr_reinit:
 	/* allocate transmit descriptors */
 	err = ixgbe_setup_all_tx_resources(adapter);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

author
#5 lore raw

PATCH 6/6 ixgbe: remove accidentally added #ifdef

In reply to Auke Kok

Let's not add these #ifdef NETIF_F_TSO's back.

---

 drivers/net/ixgbe/ixgbe_main.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/net/ixgbe/ixgbe_main.c +0 -5
index a4aeaec..540b647 100644
@@ -220,7 +220,6 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_adapter *adapter,
 			tx_ring->stats.bytes += tx_buffer_info->length;
 			if (cleaned) {
 				struct sk_buff *skb = tx_buffer_info->skb;
-#ifdef NETIF_F_TSO
 				unsigned int segs, bytecount;
 				segs = skb_shinfo(skb)->gso_segs ?: 1;
 				/* multiply data chunks by size of headers */
@@ -228,10 +227,6 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_adapter *adapter,
 					    skb->len;
 				total_tx_packets += segs;
 				total_tx_bytes += bytecount;
-#else
-				total_tx_packets++;
-				total_tx_bytes += skb->len;
-#endif
 			}
 			ixgbe_unmap_and_free_tx_resource(adapter,
 							 tx_buffer_info);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#6 lore raw
In reply to Auke Kok
Quoted 10 lines · Auke Kok

From: Julia Lawall <[email protected]>

---

 drivers/net/e1000/e1000_ethtool.c |    2 +-
 drivers/net/igb/igb_ethtool.c     |    2 +-
 drivers/net/ixgb/ixgb_ethtool.c   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

applied 1-6 to #upstream-fixes

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/