Skip to contentSkip to conversation

ixgb: driver update (upstream)

PATCH In review Jeff Kirsher 6 participants 19 messages Apr 22, 2006 – May 19, 2006

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

cover ixgb: driver update (upstream)

The following patches were diff's against Garzik's latest "upstream" branch and can be pulled from the following location:

git://lost.foo-projects.org/linux-2.6.git ixgb-upstream

The following series implements...
01. Fix compilation errors by initializing variables
02. Fix the use of dprintk rather than printk
03. Fix hard coded numbers
04. Fix duplicate code
05. Fix timeout code
06. Fix TSO
07. Fixed flow control parameters
08. Add support for copper 10GbE
09. Add performance enhancements to the buffer_info struct
10. Add whitespace changes
11. Add prefetch
--
Cheers,
Jeff

#1 lore raw

PATCH 1/11 ixgb: Fix compilation errors by initializing variables

- initialized varaibles
- rev'd driver version

---

 drivers/net/ixgb/ixgb_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ixgb/ixgb_main.c +2 -2
index cfd67d8..0b9481a 100644
@@ -52,7 +52,7 @@ static char ixgb_driver_string[] = "Inte
 #else
 #define DRIVERNAPI "-NAPI"
 #endif
-#define DRV_VERSION		"1.0.100-k2"DRIVERNAPI
+#define DRV_VERSION		"1.0.104-k2"DRIVERNAPI
 char ixgb_driver_version[] = DRV_VERSION;
 static char ixgb_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
 
@@ -346,7 +346,7 @@ ixgb_probe(struct pci_dev *pdev,
 		const struct pci_device_id *ent)
 {
 	struct net_device *netdev = NULL;
-	struct ixgb_adapter *adapter;
+	struct ixgb_adapter *adapter = NULL;
 	static int cards_found = 0;
 	unsigned long mmio_start;
 	int mmio_len;
#2 lore raw

Re: [PATCH 01/11] ixgb: Fix compilation errors by initializing variables

Jeff Kirsher <[email protected]> :

Quoted 4 lines
drivers/net/ixgb/ixgb_main.c +0 -0
index cfd67d8..0b9481a 100644

[...]

drivers/net/ixgb/ixgb_main.c ixgb_probe(struct pci_dev *pdev, · line 349

Quoted 6 lines
drivers/net/ixgb/ixgb_main.c +1 -1
@@ -346,7 +346,7 @@ ixgb_probe(struct pci_dev *pdev,
 		const struct pci_device_id *ent)
 {
 	struct net_device *netdev = NULL;
-	struct ixgb_adapter *adapter;
+	struct ixgb_adapter *adapter = NULL;

Afaiks the warning/error from the compiler is bogus.

netdev initialization is useless as well.

Are we supposed to bloat the kernel code on a large scale just to please a compiler which emits bogus warning or is the option left to the maintainer ?

Signature · 1 line
Ueimor
#3 lore raw

PATCH 2/11 ixgb: Fix the use of dprintk rather than printk

In reply to Jeff Kirsher

- use DPRINTK and msglvl instead of printk
- allow ethtool control of msglvl

---

 drivers/net/ixgb/ixgb.h         |    8 +++++-
 drivers/net/ixgb/ixgb_ethtool.c |   16 ++++++++++++
 drivers/net/ixgb/ixgb_main.c    |   52 +++++++++++++++++++++++++--------------
 3 files changed, 56 insertions(+), 20 deletions(-)
drivers/net/ixgb/ixgb.h +7 -1
index c83271b..a696c33 100644
@@ -84,7 +84,12 @@ struct ixgb_adapter;
 #define IXGB_DBG(args...)
 #endif
 
-#define IXGB_ERR(args...) printk(KERN_ERR "ixgb: " args)
+#define PFX "ixgb: "
+#define DPRINTK(nlevel, klevel, fmt, args...) \
+   (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
+   printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
+       __FUNCTION__ , ## args))
+
 
 /* TX/RX descriptor defines */
 #define DEFAULT_TXD	 256
@@ -192,6 +197,7 @@ struct ixgb_adapter {
 
 	/* structs defined in ixgb_hw.h */
 	struct ixgb_hw hw;
+	u16 msg_enable;
 	struct ixgb_hw_stats stats;
 #ifdef CONFIG_PCI_MSI
 	boolean_t have_msi;
drivers/net/ixgb/ixgb_ethtool.c +16 -0
index d38ade5..e8d83de 100644
@@ -251,6 +251,20 @@ ixgb_set_tso(struct net_device *netdev, 
 } 
 #endif /* NETIF_F_TSO */
 
+static uint32_t
+ixgb_get_msglevel(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	return adapter->msg_enable;
+}
+
+static void
+ixgb_set_msglevel(struct net_device *netdev, uint32_t data)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	adapter->msg_enable = data;
+}
+
 #define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_
 
 static int 
@@ -714,6 +728,8 @@ static struct ethtool_ops ixgb_ethtool_o
 	.set_tx_csum = ixgb_set_tx_csum,
 	.get_sg	= ethtool_op_get_sg,
 	.set_sg	= ethtool_op_set_sg,
+	.get_msglevel = ixgb_get_msglevel,
+	.set_msglevel = ixgb_set_msglevel,
 #ifdef NETIF_F_TSO
 	.get_tso = ethtool_op_get_tso,
 	.set_tso = ixgb_set_tso,
drivers/net/ixgb/ixgb_main.c +33 -19

161 lines not on this page · raw message

#4 lore raw

Re: [PATCH 02/11] ixgb: Fix the use of dprintk rather than printk

Jeff Kirsher <[email protected]> :
[...]

Quoted 4 lines
drivers/net/ixgb/ixgb.h +0 -0
index c83271b..a696c33 100644

[...]

Quoted 20 lines
drivers/net/ixgb/ixgb.h +1 -0
@@ -192,6 +197,7 @@ struct ixgb_adapter {
 
 	/* structs defined in ixgb_hw.h */
 	struct ixgb_hw hw;
+	u16 msg_enable;
 	struct ixgb_hw_stats stats;
 #ifdef CONFIG_PCI_MSI
 	boolean_t have_msi;
drivers/net/ixgb/ixgb_ethtool.c +4 -0
index d38ade5..e8d83de 100644
@@ -251,6 +251,20 @@ ixgb_set_tso(struct net_device *netdev, 
 } 
 #endif /* NETIF_F_TSO */
 
+static uint32_t
+ixgb_get_msglevel(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;

drivers/net/ixgb/ixgb_ethtool.c ixgb_set_tso(struct net_device *netdev, · line 267

Quoted 10 lines
drivers/net/ixgb/ixgb_ethtool.c +10 -0
+	return adapter->msg_enable;
+}
+
+static void
+ixgb_set_msglevel(struct net_device *netdev, uint32_t data)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	adapter->msg_enable = data;
+}
+

Minor nits:
- you may consider removing the u{8/16/32} in drivers/net/ixgb for consistency sake in a different patch (there is a strong majority of uint_something in the driver).

- s/netdev->priv/netdev_priv(netdev)/ ?

[...]

drivers/net/ixgb/ixgb_ethtool.c ixgb_probe(struct pci_dev *pdev, · line 498

Quoted 7 lines
drivers/net/ixgb/ixgb_ethtool.c +1 -2
@@ -486,8 +495,7 @@ ixgb_probe(struct pci_dev *pdev,
 	netif_carrier_off(netdev);
 	netif_stop_queue(netdev);
 
-	printk(KERN_INFO "%s: Intel(R) PRO/10GbE Network Connection\n",
-		   netdev->name);
+	DPRINTK(PROBE, INFO, "Intel(R) PRO/10GbE Network Connection\n");

It could probably be factored out with ixgb_driver_string.

Signature · 1 line
Ueimor
#5 lore raw

Re: [PATCH 02/11] ixgb: Fix the use of dprintk rather than printk

Quoted 34 lines · On Sat, 22 Apr 2006 11:03:01 +0200 Francois Romieu <[email protected]> wrote:

Jeff Kirsher <[email protected]> :
[...]

Quoted 4 lines
drivers/net/ixgb/ixgb.h +0 -0
index c83271b..a696c33 100644

[...]

Quoted 27 lines
drivers/net/ixgb/ixgb.h +1 -0
@@ -192,6 +197,7 @@ struct ixgb_adapter {
 
 	/* structs defined in ixgb_hw.h */
 	struct ixgb_hw hw;
+	u16 msg_enable;
 	struct ixgb_hw_stats stats;
 #ifdef CONFIG_PCI_MSI
 	boolean_t have_msi;
drivers/net/ixgb/ixgb_ethtool.c +11 -0
index d38ade5..e8d83de 100644
@@ -251,6 +251,20 @@ ixgb_set_tso(struct net_device *netdev, 
 } 
 #endif /* NETIF_F_TSO */
 
+static uint32_t
+ixgb_get_msglevel(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
+	return adapter->msg_enable;
+}
+
+static void
+ixgb_set_msglevel(struct net_device *netdev, uint32_t data)
+{
+	struct ixgb_adapter *adapter = netdev->priv;
Quoted 8 lines

drivers/net/ixgb/ixgb_ethtool.c ixgb_set_tso(struct net_device *netdev, · line 267

Quoted 3 lines
drivers/net/ixgb/ixgb_ethtool.c +3 -0
+	adapter->msg_enable = data;
+}
+

Minor nits:
- you may consider removing the u{8/16/32} in drivers/net/ixgb for consistency sake in a different patch (there is a strong majority of uint_something in the driver).

All the uint32_t should be removed. Kernel style is u32.

#6 lore raw

Re: [PATCH 02/11] ixgb: Fix the use of dprintk rather than printk

In reply to Francois Romieu
Quoted 10 lines · Francois Romieu

Jeff Kirsher <[email protected]> :

drivers/net/ixgb/ixgb_main.c ixgb_probe(struct pci_dev *pdev, · line 498

Quoted 7 lines
drivers/net/ixgb/ixgb_main.c +1 -2
@@ -486,8 +495,7 @@ ixgb_probe(struct pci_dev *pdev,
 	netif_carrier_off(netdev);
 	netif_stop_queue(netdev);
 
-	printk(KERN_INFO "%s: Intel(R) PRO/10GbE Network Connection\n",
-		   netdev->name);
+	DPRINTK(PROBE, INFO, "Intel(R) PRO/10GbE Network Connection\n");

It could probably be factored out with ixgb_driver_string.

the driver name is different from the interface/device that it drives - Hence the different name. The 'Connection' name as above is the branding name as well, and that's why we print it here as such. e1000 does the same thing for the same reason.

Auke

#7 lore raw

PATCH 3/11 ixgb: Fix hard coded numbers

In reply to Jeff Kirsher

- removed hard coded numbers and used constants instead

---

 drivers/net/ixgb/ixgb_ethtool.c |    4 +++-
 drivers/net/ixgb/ixgb_main.c    |    8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/net/ixgb/ixgb_ethtool.c +3 -1
index e8d83de..978be30 100644
@@ -44,6 +44,8 @@ extern void ixgb_free_rx_resources(struc
 extern void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
 extern void ixgb_update_stats(struct ixgb_adapter *adapter);
 
+#define IXGB_ALL_RAR_ENTRIES 16
+
 struct ixgb_stats {
 	char stat_string[ETH_GSTRING_LEN];
 	int sizeof_stat;
@@ -317,7 +319,7 @@ ixgb_get_regs(struct net_device *netdev,
 	*reg++ = IXGB_READ_REG(hw, RXCSUM);	/*  20 */
 
 	/* there are 16 RAR entries in hardware, we only use 3 */
-	for(i = 0; i < 16; i++) {
+	for(i = 0; i < IXGB_ALL_RAR_ENTRIES; i++) {
 		*reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1)); /*21,...,51 */
 		*reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1)); /*22,...,52 */
 	}
drivers/net/ixgb/ixgb_main.c +4 -4
index 6f8fd6f..f468d5d 100644
@@ -1227,11 +1227,11 @@ ixgb_tso(struct ixgb_adapter *adapter, s
 		if(++i == adapter->tx_ring.count) i = 0;
 		adapter->tx_ring.next_to_use = i;
 
-		return 1;
+		return TRUE;
 	}
 #endif
 
-	return 0;
+	return FALSE;
 }
 
 static inline boolean_t
@@ -1413,7 +1413,7 @@ ixgb_xmit_frame(struct sk_buff *skb, str
 	if(unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED)) {
 		netif_stop_queue(netdev);
 		spin_unlock_irqrestore(&adapter->tx_lock, flags);
-		return 1;
+		return NETDEV_TX_BUSY;
 	}
 	spin_unlock_irqrestore(&adapter->tx_lock, flags);
 
@@ -1440,7 +1440,7 @@ ixgb_xmit_frame(struct sk_buff *skb, str
 
 	netdev->trans_start = jiffies;
 
-	return 0;
+	return NETDEV_TX_OK;
 }
 
 /**
#8 lore raw

Re: [PATCH 03/11] ixgb: Fix hard coded numbers

Jeff Kirsher <[email protected]> :
[...]

Quoted 4 lines
drivers/net/ixgb/ixgb_ethtool.c +0 -0
index e8d83de..978be30 100644

[...]

Quoted 6 lines
drivers/net/ixgb/ixgb_main.c +0 -0
index 6f8fd6f..f468d5d 100644
@@ -1227,11 +1227,11 @@ ixgb_tso(struct ixgb_adapter *adapter, s
 		if(++i == adapter->tx_ring.count) i = 0;

drivers/net/ixgb/ixgb_main.c ixgb_tso(struct ixgb_adapter *adapter, s · line 1235

Quoted 10 lines
drivers/net/ixgb/ixgb_main.c +2 -2
 		adapter->tx_ring.next_to_use = i;
 
-		return 1;
+		return TRUE;
 	}
 #endif
 
-	return 0;
+	return FALSE;
 }

Grmbl... TRUE/FALSE

More importantly, it seems bogus. See below:

drivers/net/ixgb/ixgb_main.c::ixgb_xmit_frame
[...]

        tso = ixgb_tso(adapter, skb);
        if (tso < 0) {
               ^^^
                dev_kfree_skb_any(skb);
                return N

[...]

drivers/net/ixgb/ixgb_main.c ixgb_xmit_frame(struct sk_buff *skb, str · line 1417

Quoted 7 lines
drivers/net/ixgb/ixgb_main.c +1 -1
@@ -1413,7 +1413,7 @@ ixgb_xmit_frame(struct sk_buff *skb, str
 	if(unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED)) {
 		netif_stop_queue(netdev);
 		spin_unlock_irqrestore(&adapter->tx_lock, flags);
-		return 1;
+		return NETDEV_TX_BUSY;
 	}

It is considered a bug. You can check for this situation on the current skb but the driver should check if there is enough room for the *next* packet before it leaves ixgb_xmit_frame().

Signature · 1 line
Ueimor
#9 lore raw

PATCH 4/11 ixgb: Fix duplicate code

In reply to Jeff Kirsher

- created function ixgb_set_speed_duplex to remove duplicate code

---

 drivers/net/ixgb/ixgb_ethtool.c |   35 ++++++++++++++---------------------
 1 files changed, 14 insertions(+), 21 deletions(-)
drivers/net/ixgb/ixgb_ethtool.c +14 -21
index 978be30..55a54bb 100644
@@ -119,6 +119,16 @@ ixgb_get_settings(struct net_device *net
 	return 0;
 }
 
+static void ixgb_set_speed_duplex(struct net_device *netdev)
+{
+	struct ixgb_adapter *adapter = netdev_priv(netdev);
+	/* be optimistic about our link, since we were up before */
+	adapter->link_speed = 10000;
+	adapter->link_duplex = FULL_DUPLEX;
+	netif_carrier_on(netdev);
+	netif_wake_queue(netdev);
+}
+
 static int
 ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 {
@@ -132,12 +142,7 @@ ixgb_set_settings(struct net_device *net
 		ixgb_down(adapter, TRUE);
 		ixgb_reset(adapter);
 		ixgb_up(adapter);
-		/* be optimistic about our link, since we were up before */
-		adapter->link_speed = 10000;
-		adapter->link_duplex = FULL_DUPLEX;
-		netif_carrier_on(netdev);
-		netif_wake_queue(netdev);
-		
+		ixgb_set_speed_duplex(netdev);
 	} else
 		ixgb_reset(adapter);
 
@@ -185,11 +190,7 @@ ixgb_set_pauseparam(struct net_device *n
 	if(netif_running(adapter->netdev)) {
 		ixgb_down(adapter, TRUE);
 		ixgb_up(adapter);
-		/* be optimistic about our link, since we were up before */
-		adapter->link_speed = 10000;
-		adapter->link_duplex = FULL_DUPLEX;
-		netif_carrier_on(netdev);
-		netif_wake_queue(netdev);
+		ixgb_set_speed_duplex(netdev);
 	} else
 		ixgb_reset(adapter);
 		
@@ -214,11 +215,7 @@ ixgb_set_rx_csum(struct net_device *netd
 	if(netif_running(netdev)) {
 		ixgb_down(adapter,TRUE);
 		ixgb_up(adapter);
-		/* be optimistic about our link, since we were up before */
-		adapter->link_speed = 10000;
-		adapter->link_duplex = FULL_DUPLEX;
-		netif_carrier_on(netdev);
-		netif_wake_queue(netdev);
+		ixgb_set_speed_duplex(netdev);
 	} else
 		ixgb_reset(adapter);
 	return 0;
@@ -609,11 +606,7 @@ ixgb_set_ringparam(struct net_device *ne
 		adapter->tx_ring = tx_new;
 		if((err = ixgb_up(adapter)))
 			return err;
-		/* be optimistic about our link, since we were up before */
-		adapter->link_speed = 10000;
-		adapter->link_duplex = FULL_DUPLEX;
-		netif_carrier_on(netdev);
-		netif_wake_queue(netdev);
+		ixgb_set_speed_duplex(netdev);
 	}
 
 	return 0;
#10 lore raw

PATCH 5/11 ixgb: Fix timeout code

In reply to Jeff Kirsher

- aligned timeout code to match e1000

---

 drivers/net/ixgb/ixgb.h         |    1 +
 drivers/net/ixgb/ixgb_ethtool.c |    1 +
 drivers/net/ixgb/ixgb_main.c    |   29 +++++++++++++++++++++++++----
 3 files changed, 27 insertions(+), 4 deletions(-)
drivers/net/ixgb/ixgb.h +1 -0
index a696c33..f23e04f 100644
@@ -180,6 +180,7 @@ struct ixgb_adapter {
 	uint64_t hw_csum_tx_good;
 	uint64_t hw_csum_tx_error;
 	uint32_t tx_int_delay;
+	uint32_t tx_timeout_count;
 	boolean_t tx_int_delay_enable;
 	boolean_t detect_tx_hung;
 
drivers/net/ixgb/ixgb_ethtool.c +1 -0
index 55a54bb..1e06f26 100644
@@ -78,6 +78,7 @@ static struct ixgb_stats ixgb_gstrings_s
 	{"tx_heartbeat_errors", IXGB_STAT(net_stats.tx_heartbeat_errors)},
 	{"tx_window_errors", IXGB_STAT(net_stats.tx_window_errors)},
 	{"tx_deferred_ok", IXGB_STAT(stats.dc)},
+	{"tx_timeout_count", IXGB_STAT(tx_timeout_count) },
 	{"rx_long_length_errors", IXGB_STAT(stats.roc)},
 	{"rx_short_length_errors", IXGB_STAT(stats.ruc)},
 #ifdef NETIF_F_TSO
drivers/net/ixgb/ixgb_main.c +25 -4
index f468d5d..93a518f 100644
@@ -423,7 +423,7 @@ ixgb_probe(struct pci_dev *pdev,
 	netdev->change_mtu = &ixgb_change_mtu;
 	ixgb_set_ethtool_ops(netdev);
 	netdev->tx_timeout = &ixgb_tx_timeout;
-	netdev->watchdog_timeo = HZ;
+	netdev->watchdog_timeo = 5 * HZ;
 #ifdef CONFIG_IXGB_NAPI
 	netdev->poll = &ixgb_clean;
 	netdev->weight = 64;
@@ -1462,6 +1462,7 @@ ixgb_tx_timeout_task(struct net_device *
 {
 	struct ixgb_adapter *adapter = netdev_priv(netdev);
 
+	adapter->tx_timeout_count++;
 	ixgb_down(adapter, TRUE);
 	ixgb_up(adapter);
 }
@@ -1791,11 +1792,31 @@ ixgb_clean_tx_irq(struct ixgb_adapter *a
 		/* detect a transmit hang in hardware, this serializes the
 		 * check with the clearing of time_stamp and movement of i */
 		adapter->detect_tx_hung = FALSE;
-		if(tx_ring->buffer_info[i].dma &&
-		   time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ)
+		if(tx_ring->buffer_info[eop].dma &&
+		   time_after(jiffies, tx_ring->buffer_info[eop].time_stamp + HZ)
 		   && !(IXGB_READ_REG(&adapter->hw, STATUS) &
-			IXGB_STATUS_TXOFF))
+				IXGB_STATUS_TXOFF)) {
+			/* detected Tx unit hang */
+			DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
+					"  TDH				  <%x>\n"
+					"  TDT				  <%x>\n"
+					"  next_to_use		  <%x>\n"
+					"  next_to_clean		<%x>\n"
+					"buffer_info[next_to_clean]\n"
+					"  time_stamp		   <%lx>\n"
+					"  next_to_watch		<%x>\n"
+					"  jiffies			  <%lx>\n"
+					"  next_to_watch.status <%x>\n",
+				IXGB_READ_REG(&adapter->hw, TDH),
+				IXGB_READ_REG(&adapter->hw, TDT),
+				tx_ring->next_to_use,
+				tx_ring->next_to_clean,
+				tx_ring->buffer_info[eop].time_stamp,
+				eop,
+				jiffies,
+				eop_desc->status);
 			netif_stop_queue(netdev);
+		}
 	}
 
 	return cleaned;
#11 lore raw

PATCH 6/11 ixgb: Fix TSO

In reply to Jeff Kirsher

- this fixes an issue of premature desc writeback by hardware

---

 drivers/net/ixgb/ixgb_main.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
drivers/net/ixgb/ixgb_main.c +15 -2
index 93a518f..9d262c8 100644
@@ -1280,6 +1280,7 @@ ixgb_tx_map(struct ixgb_adapter *adapter
 	struct ixgb_buffer *buffer_info;
 	int len = skb->len;
 	unsigned int offset = 0, size, count = 0, i;
+	unsigned int mss = skb_shinfo(skb)->tso_size;
 
 	unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
 	unsigned int f;
@@ -1291,6 +1292,11 @@ ixgb_tx_map(struct ixgb_adapter *adapter
 	while(len) {
 		buffer_info = &tx_ring->buffer_info[i];
 		size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
+		/* Workaround for premature desc write-backs
+		 * in TSO mode.  Append 4-byte sentinel desc */
+		if(unlikely(mss && !nr_frags && size == len && size > 8))
+			size -= 4;
+
 		buffer_info->length = size;
 		buffer_info->dma =
 			pci_map_single(adapter->pdev,
@@ -1315,6 +1321,12 @@ ixgb_tx_map(struct ixgb_adapter *adapter
 		while(len) {
 			buffer_info = &tx_ring->buffer_info[i];
 			size = min(len, IXGB_MAX_JUMBO_FRAME_SIZE);
+			/* Workaround for premature desc write-backs
+			 * in TSO mode.  Append 4-byte sentinel desc */
+			if(unlikely(mss && (f == (nr_frags-1)) && (size == len)
+						&& (size > 8)))
+				size -= 4;
+
 			buffer_info->length = size;
 			buffer_info->dma =
 				pci_map_page(adapter->pdev,
@@ -1392,7 +1404,8 @@ ixgb_tx_queue(struct ixgb_adapter *adapt
 #define TXD_USE_COUNT(S) (((S) >> IXGB_MAX_TXD_PWR) + \
 			 (((S) & (IXGB_MAX_DATA_PER_TXD - 1)) ? 1 : 0))
 #define DESC_NEEDED TXD_USE_COUNT(IXGB_MAX_DATA_PER_TXD) + \
-	MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1
+	MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1 \
+	/* one more for TSO workaround */ + 1
 
 static int
 ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
@@ -1430,7 +1443,7 @@ ixgb_xmit_frame(struct sk_buff *skb, str
 		return NETDEV_TX_OK;
 	}
 
-	if (tso)
+	if (likely(tso))
 		tx_flags |= IXGB_TX_FLAGS_TSO;
 	else if(ixgb_tx_csum(adapter, skb))
 		tx_flags |= IXGB_TX_FLAGS_CSUM;
#12 lore raw

PATCH 7/11 ixgb: Fixed flow control parameters

In reply to Jeff Kirsher

- make default flow control only have *sending* of flow control packets enabled
- fix to disable / enable flow control correctly

---

 drivers/net/ixgb/ixgb_param.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
drivers/net/ixgb/ixgb_param.c +10 -12
index 8a83dfd..39e0a47 100644
@@ -137,7 +137,7 @@ IXGB_PARAM(RxFCLowThresh, "Receive Flow 
  *
  * Valid Range: 1 - 65535 
  *
- * Default Value:  256 (0x100)
+ * Default Value:  65535 (0xffff) (we'll send an xon if we recover)
  */
 
 IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout");
@@ -165,8 +165,6 @@ IXGB_PARAM(IntDelayEnable, "Transmit Int
 
 #define XSUMRX_DEFAULT		 OPTION_ENABLED
 
-#define FLOW_CONTROL_FULL	   ixgb_fc_full
-#define FLOW_CONTROL_DEFAULT  FLOW_CONTROL_FULL
 #define DEFAULT_FCRTL	  		0x28000
 #define DEFAULT_FCRTH			0x30000
 #define MIN_FCRTL			      0
@@ -174,9 +172,9 @@ IXGB_PARAM(IntDelayEnable, "Transmit Int
 #define MIN_FCRTH			      8
 #define MAX_FCRTH			0x3FFF0
 
-#define DEFAULT_FCPAUSE		  	0x100	/* this may be too long */
 #define MIN_FCPAUSE			      1
 #define MAX_FCPAUSE			 0xffff
+#define DEFAULT_FCPAUSE		  	 0xFFFF /* this may be too long */
 
 struct ixgb_option {
 	enum { enable_option, range_option, list_option } type;
@@ -336,7 +334,7 @@ ixgb_check_options(struct ixgb_adapter *
 			.type = list_option,
 			.name = "Flow Control",
 			.err  = "reading default settings from EEPROM",
-			.def  = ixgb_fc_full,
+			.def  = ixgb_fc_tx_pause,
 			.arg  = { .l = { .nr = LIST_LEN(fc_list),
 					 .p = fc_list }}
 		};
@@ -365,8 +363,8 @@ ixgb_check_options(struct ixgb_adapter *
 		} else {
 			adapter->hw.fc.high_water = opt.def;
 		}
-		if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) )
-			printk (KERN_INFO 
+		if( !(adapter->hw.fc.type & ixgb_fc_tx_pause) )
+			printk (KERN_INFO
 				"Ignoring RxFCHighThresh when no RxFC\n");
 	}
 	{ /* Receive Flow Control Low Threshold */
@@ -385,8 +383,8 @@ ixgb_check_options(struct ixgb_adapter *
 		} else {
 			adapter->hw.fc.low_water = opt.def;
 		}
-		if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) )
-			printk (KERN_INFO 
+		if( !(adapter->hw.fc.type & ixgb_fc_tx_pause) )
+			printk (KERN_INFO
 				"Ignoring RxFCLowThresh when no RxFC\n");
 	}
 	{ /* Flow Control Pause Time Request*/
@@ -406,12 +404,12 @@ ixgb_check_options(struct ixgb_adapter *
 		} else {
 			adapter->hw.fc.pause_time = opt.def;
 		}
-		if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) )
-			printk (KERN_INFO 
+		if( !(adapter->hw.fc.type & ixgb_fc_tx_pause) )
+			printk (KERN_INFO
 				"Ignoring FCReqTimeout when no RxFC\n");
 	}
 	/* high low and spacing check for rx flow control thresholds */
-	if (adapter->hw.fc.type & ixgb_fc_rx_pause) {
+	if (adapter->hw.fc.type & ixgb_fc_tx_pause) {
 		/* high must be greater than low */
 		if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) {
 			/* set defaults */
#13 lore raw

PATCH 8/11 ixgb: Add support for copper 10GbE

In reply to Jeff Kirsher

- Add support for Copper 10GbE device ID 109E

---

 drivers/net/ixgb/ixgb_hw.h   |    1 +
 drivers/net/ixgb/ixgb_ids.h  |    4 +++-
 drivers/net/ixgb/ixgb_main.c |    7 +++++--
 3 files changed, 9 insertions(+), 3 deletions(-)
drivers/net/ixgb/ixgb_hw.h +1 -0
index 382c630..19513c6 100644
@@ -57,6 +57,7 @@ typedef enum {
 typedef enum {
 	ixgb_media_type_unknown = 0,
 	ixgb_media_type_fiber = 1,
+	ixgb_media_type_copper = 2,
 	ixgb_num_media_types
 } ixgb_media_type;
 
drivers/net/ixgb/ixgb_ids.h +3 -1
index aee207e..e119c05 100644
@@ -43,6 +43,8 @@
 #define IXGB_SUBDEVICE_ID_A11F      0xA11F   
 #define IXGB_SUBDEVICE_ID_A01F      0xA01F   
 
-#endif /* #ifndef _IXGB_IDS_H_ */
+#define IXGB_DEVICE_ID_82597EX_CX4   0x109E
+#define IXGB_SUBDEVICE_ID_A00C  0xA00C
 
+#endif /* #ifndef _IXGB_IDS_H_ */
 /* End of File */
drivers/net/ixgb/ixgb_main.c +5 -2
index 9d262c8..be7b43b 100644
@@ -67,6 +67,8 @@ static char ixgb_copyright[] = "Copyrigh
 static struct pci_device_id ixgb_pci_tbl[] = {
 	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_CX4,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_SR,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_LR,  
@@ -570,8 +572,9 @@ ixgb_sw_init(struct ixgb_adapter *adapte
 	hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
 
 	if((hw->device_id == IXGB_DEVICE_ID_82597EX)
-	   ||(hw->device_id == IXGB_DEVICE_ID_82597EX_LR)
-	   ||(hw->device_id == IXGB_DEVICE_ID_82597EX_SR))
+	   || (hw->device_id == IXGB_DEVICE_ID_82597EX_CX4)
+	   || (hw->device_id == IXGB_DEVICE_ID_82597EX_LR)
+	   || (hw->device_id == IXGB_DEVICE_ID_82597EX_SR))
 			hw->mac_type = ixgb_82597;
 	else {
 		/* should never have loaded on this device */
#14 lore raw

PATCH 9/11 ixgb: Add performance enhancements to the buffer_info struct

In reply to Jeff Kirsher

---

 drivers/net/ixgb/ixgb_main.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)
drivers/net/ixgb/ixgb_main.c +20 -16
index be7b43b..443d675 100644
@@ -922,17 +922,20 @@ ixgb_unmap_and_free_tx_resource(struct i
 					struct ixgb_buffer *buffer_info)
 {
 	struct pci_dev *pdev = adapter->pdev;
-	if(buffer_info->dma) {
-		pci_unmap_page(pdev,
-			   buffer_info->dma,
-			   buffer_info->length,
-			   PCI_DMA_TODEVICE);
-		buffer_info->dma = 0;
-	}
-	if(buffer_info->skb) {
+
+	if (buffer_info->dma)
+		pci_unmap_page(pdev, buffer_info->dma, buffer_info->length,
+					   PCI_DMA_TODEVICE);
+
+	if (buffer_info->skb)
 		dev_kfree_skb_any(buffer_info->skb);
-		buffer_info->skb = NULL;
-	}
+
+	buffer_info->skb = NULL;
+	buffer_info->dma = 0;
+	buffer_info->time_stamp = 0;
+	/* these fields must always be initialized in tx
+	 * buffer_info->length = 0;
+	 * buffer_info->next_to_watch = 0; */
 }
 
 /**
@@ -1307,6 +1310,7 @@ ixgb_tx_map(struct ixgb_adapter *adapter
 				size,
 				PCI_DMA_TODEVICE);
 		buffer_info->time_stamp = jiffies;
+		buffer_info->next_to_watch = 0;
 
 		len -= size;
 		offset += size;
@@ -1338,6 +1342,7 @@ ixgb_tx_map(struct ixgb_adapter *adapter
 					size,
 					PCI_DMA_TODEVICE);
 			buffer_info->time_stamp = jiffies;
+			buffer_info->next_to_watch = 0;
 
 			len -= size;
 			offset += size;
@@ -1909,6 +1914,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *a
 #endif
 		status = rx_desc->status;
 		skb = buffer_info->skb;
+		buffer_info->skb = NULL;
 
 		prefetch(skb->data);
 
@@ -1982,7 +1988,6 @@ ixgb_clean_rx_irq(struct ixgb_adapter *a
 rxdesc_done:
 		/* clean up descriptor, might be written over by hw */
 		rx_desc->status = 0;
-		buffer_info->skb = NULL;
 
 		/* use prefetched values */
 		rx_desc = next_rxd;
@@ -2041,11 +2046,10 @@ ixgb_alloc_rx_buffers(struct ixgb_adapte
 
 		buffer_info->skb = skb;
 		buffer_info->length = adapter->rx_buffer_len;
-		buffer_info->dma =
-			pci_map_single(pdev,
-				   skb->data,
-				   adapter->rx_buffer_len,
-				   PCI_DMA_FROMDEVICE);
+		buffer_info->dma = pci_map_single(pdev,
+										  skb->data,
+										  adapter->rx_buffer_len,
+										  PCI_DMA_FROMDEVICE);
 
 		rx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
 		/* guarantee DD bit not set now before h/w gets descriptor
#15 lore raw

PATCH 10/11 ixgb: clean up whitespace

In reply to Jeff Kirsher

- remove trailing whitespace

---

 drivers/net/ixgb/ixgb.h         |   28 ++++++++--------
 drivers/net/ixgb/ixgb_ethtool.c |   68 ++++++++++++++++++++-------------------
 drivers/net/ixgb/ixgb_main.c    |   62 ++++++++++++++++++------------------
 drivers/net/ixgb/ixgb_osdep.h   |   26 +++++++--------
 4 files changed, 92 insertions(+), 92 deletions(-)
drivers/net/ixgb/ixgb.h +14 -14
index f23e04f..e968f64 100644
@@ -1,25 +1,25 @@
 /*******************************************************************************
 
-  
+
   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) 
+
+  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 
+
+  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 
+  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 <[email protected]>
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
@@ -97,7 +97,7 @@ struct ixgb_adapter;
 #define MIN_TXD	  64
 
 /* hardware cannot reliably support more than 512 descriptors owned by
- * hardware descrioptor cache otherwise an unreliable ring under heavy 
+ * hardware descrioptor cache otherwise an unreliable ring under heavy
  * recieve load may result */
 /* #define DEFAULT_RXD	   1024 */
 /* #define MAX_RXD	   4096 */
drivers/net/ixgb/ixgb_ethtool.c +34 -34

183 lines not on this page · raw message

drivers/net/ixgb/ixgb_main.c +31 -31

165 lines not on this page · raw message

drivers/net/ixgb/ixgb_osdep.h +13 -13
index dba2048..d96d13f 100644
@@ -1,25 +1,25 @@
 /*******************************************************************************
 
-  
+
   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) 
+
+  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 
+
+  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 
+  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 <[email protected]>
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
#16 lore raw

PATCH 11/11 ixgb: Add prefetch

In reply to Jeff Kirsher

- This patch is to improve performance by adding prefetch to the ixgb driver
- Add driver comments

---

 drivers/net/ixgb/ixgb_main.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/net/ixgb/ixgb_main.c +9 -1
index 26cb0d5..98303cb 100644
@@ -29,6 +29,13 @@
 #include "ixgb.h"
 
 /* Change Log
+ * 1.0.104 10-Jan-2006
+ * - fix for copybreak/recycle
+ * 1.0.103 Oct-3
+ * - suck in some e1000 changes, including copybreak and LLTX
+ * - support for CX4 adapters
+ * 1.0.102 June-20-2005
+ * - add a workaround for a hardware issue when using TSO
  * 1.0.96 04/19/05
  * - Make needlessly global code static -- [email protected]
  * - ethtool cleanup -- [email protected]
@@ -1916,7 +1923,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *a
 		skb = buffer_info->skb;
 		buffer_info->skb = NULL;
 
-		prefetch(skb->data);
+		prefetch(skb->data - NET_IP_ALIGN);
 
 		if(++i == rx_ring->count) i = 0;
 		next_rxd = IXGB_RX_DESC(*rx_ring, i);
@@ -1929,6 +1936,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *a
 		next_buffer = &rx_ring->buffer_info[i];
 		next_skb = next_buffer->skb;
 		prefetch(next_skb);
+		prefetch(next_skb->data - NET_IP_ALIGN);
 
 		cleaned = TRUE;
 
#17 lore raw

Re: [PATCH 11/11] ixgb: Add prefetch

Quoted 30 lines · Jeff Kirsher

- This patch is to improve performance by adding prefetch to the ixgb driver
- Add driver comments

---

 drivers/net/ixgb/ixgb_main.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/net/ixgb/ixgb_main.c +7 -0
index 26cb0d5..98303cb 100644
@@ -29,6 +29,13 @@
 #include "ixgb.h"
 
 /* Change Log
+ * 1.0.104 10-Jan-2006
+ * - fix for copybreak/recycle
+ * 1.0.103 Oct-3
+ * - suck in some e1000 changes, including copybreak and LLTX
+ * - support for CX4 adapters
+ * 1.0.102 June-20-2005
+ * - add a workaround for a hardware issue when using TSO
  * 1.0.96 04/19/05
  * - Make needlessly global code static -- [email protected]
  * - ethtool cleanup -- [email protected]

drivers/net/ixgb/ixgb_main.c ixgb_clean_rx_irq(struct ixgb_adapter *a · line 1926

Quoted 5 lines
drivers/net/ixgb/ixgb_main.c +1 -1
@@ -1916,7 +1923,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *a
 		skb = buffer_info->skb;
 		buffer_info->skb = NULL;
 
-		prefetch(skb->data);
+		prefetch(skb->data - NET_IP_ALIGN);

I doubt this change is usefull.

skb->data and dkb->dta - NET_IP_ALIGN are on the same cache line.
So prefetch(skb->data) is cheaper for he compiler and has the same effect on the memory prefetch that is eventually done by the cpu.

drivers/net/ixgb/ixgb_main.c ixgb_clean_rx_irq(struct ixgb_adapter *a · line 1939

Quoted 8 lines
drivers/net/ixgb/ixgb_main.c +1 -0
 		if(++i == rx_ring->count) i = 0;
 		next_rxd = IXGB_RX_DESC(*rx_ring, i);
@@ -1929,6 +1936,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *a
 		next_buffer = &rx_ring->buffer_info[i];
 		next_skb = next_buffer->skb;
 		prefetch(next_skb);
+		prefetch(next_skb->data - NET_IP_ALIGN);

I doubt that next->skb_data is available for free just after a prefetch(next_skb). This second prefetch has a hidden cost : The memory location (&next_skb->data) must be in L1 cache. So basically the prefetch(next_skb) is useless...

prefetch are not magic things. They have a cost (they increase the code size), and should be used carefully.

Eric

#18 lore raw
In reply to Jeff Kirsher
Quoted 3 lines · Jeff Kirsher

The following patches were diff's against Garzik's latest "upstream" branch and can be pulled from the following location:

git://lost.foo-projects.org/linux-2.6.git ixgb-upstream

pull failed:

[jgarzik@pretzel netdev-2.6]$ git pull git://lost.foo-projects.org/linux-2.6.git ixgb-upstream
error: no such remote ref refs/heads/ixgb-upstream
Fetch failure: git://lost.foo-projects.org/linux-2.6.git