Skip to contentSkip to conversation

e1000: Convert boolean_t to bool

PATCH In review Auke Kok 2 participants 10 messages Mar 17, 2008 – Mar 19, 2008 2 messages not in the archive

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

PATCH 3/8 ixgb: convert boolean_t to bool

In reply to Auke Kok

From: Joe Perches <[email protected]>

Quoted 1 line

send me a patch for e1000 and for ixgb and I'll happily apply those :)

boolean_t to bool
TRUE to true
FALSE to false

---

 drivers/net/ixgb/ixgb.h         |    8 +++--
 drivers/net/ixgb/ixgb_ee.c      |   50 +++++++++++++++++-----------------
 drivers/net/ixgb/ixgb_ee.h      |    2 +
 drivers/net/ixgb/ixgb_ethtool.c |   10 +++----
 drivers/net/ixgb/ixgb_hw.c      |   57 +++++++++++++++++++--------------------
 drivers/net/ixgb/ixgb_hw.h      |   18 ++++++------
 drivers/net/ixgb/ixgb_main.c    |   44 +++++++++++++++---------------
 drivers/net/ixgb/ixgb_osdep.h   |    7 -----
 8 files changed, 94 insertions(+), 102 deletions(-)
drivers/net/ixgb/ixgb.h +4 -4
index 0078136..fad4e99 100644
@@ -173,15 +173,15 @@ struct ixgb_adapter {
 	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;
+	bool tx_int_delay_enable;
+	bool detect_tx_hung;
 
 	/* RX */
 	struct ixgb_desc_ring rx_ring;
 	uint64_t hw_csum_rx_error;
 	uint64_t hw_csum_rx_good;
 	uint32_t rx_int_delay;
-	boolean_t rx_csum;
+	bool rx_csum;
 
 	/* OS defined structs */
 	struct napi_struct napi;
@@ -194,7 +194,7 @@ struct ixgb_adapter {
 	u16 msg_enable;
 	struct ixgb_hw_stats stats;
 	uint32_t alloc_rx_buff_failed;
-	boolean_t have_msi;
+	bool have_msi;
 	unsigned long flags;
 };
 
drivers/net/ixgb/ixgb_ee.c +25 -25

144 lines not on this page · raw message

drivers/net/ixgb/ixgb_ee.h +1 -1
index 7908bf3..da62f58 100644
@@ -97,7 +97,7 @@ struct ixgb_ee_map_type {
 /* EEPROM Functions */
 uint16_t ixgb_read_eeprom(struct ixgb_hw *hw, uint16_t reg);
 
-boolean_t ixgb_validate_eeprom_checksum(struct ixgb_hw *hw);
+bool ixgb_validate_eeprom_checksum(struct ixgb_hw *hw);
 
 void ixgb_update_eeprom_checksum(struct ixgb_hw *hw);
 
drivers/net/ixgb/ixgb_ethtool.c +5 -5
index 75f3a68..5d61c2e 100644
@@ -33,7 +33,7 @@
 #include <asm/uaccess.h>
 
 extern int ixgb_up(struct ixgb_adapter *adapter);
-extern void ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog);
+extern void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
 extern void ixgb_reset(struct ixgb_adapter *adapter);
 extern int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
 extern int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
@@ -136,7 +136,7 @@ ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 		return -EINVAL;
 	
 	if(netif_running(adapter->netdev)) {
-		ixgb_down(adapter, TRUE);
+		ixgb_down(adapter, true);
 		ixgb_reset(adapter);
 		ixgb_up(adapter);
 		ixgb_set_speed_duplex(netdev);
@@ -185,7 +185,7 @@ ixgb_set_pauseparam(struct net_device *netdev,
 		hw->fc.type = ixgb_fc_none;
 
 	if(netif_running(adapter->netdev)) {
-		ixgb_down(adapter, TRUE);
+		ixgb_down(adapter, true);
 		ixgb_up(adapter);
 		ixgb_set_speed_duplex(netdev);
 	} else
@@ -210,7 +210,7 @@ ixgb_set_rx_csum(struct net_device *netdev, uint32_t data)
 	adapter->rx_csum = data;
 
 	if(netif_running(netdev)) {
-		ixgb_down(adapter,TRUE);
+		ixgb_down(adapter, true);
 		ixgb_up(adapter);
 		ixgb_set_speed_duplex(netdev);
 	} else
@@ -570,7 +570,7 @@ ixgb_set_ringparam(struct net_device *netdev,
 		return -EINVAL;
 
 	if(netif_running(adapter->netdev))
-		ixgb_down(adapter,TRUE);
+		ixgb_down(adapter, true);
 
 	rxdr->count = max(ring->rx_pending,(uint32_t)MIN_RXD);
 	rxdr->count = min(rxdr->count,(uint32_t)MAX_RXD);
drivers/net/ixgb/ixgb_hw.c +28 -29

180 lines not on this page · raw message

drivers/net/ixgb/ixgb_hw.h +9 -9
index 4f176ff..d4e9566 100644
@@ -650,7 +650,7 @@ struct ixgb_flash_buffer {
  * This is a little-endian specific check.
  */
 #define IS_MULTICAST(Address) \
-    (boolean_t)(((uint8_t *)(Address))[0] & ((uint8_t)0x01))
+    (bool)(((uint8_t *)(Address))[0] & ((uint8_t)0x01))
 
 /*
  * Check whether an address is broadcast.
@@ -663,7 +663,7 @@ struct ixgb_fc {
 	uint32_t high_water;	/* Flow Control High-water          */
 	uint32_t low_water;	/* Flow Control Low-water           */
 	uint16_t pause_time;	/* Flow Control Pause timer         */
-	boolean_t send_xon;	/* Flow control send XON            */
+	bool send_xon;		/* Flow control send XON            */
 	ixgb_fc_type type;	/* Type of flow control             */
 };
 
@@ -700,8 +700,8 @@ struct ixgb_hw {
 	uint32_t num_tx_desc;	/* Number of Transmit descriptors   */
 	uint32_t num_rx_desc;	/* Number of Receive descriptors    */
 	uint32_t rx_buffer_size;	/* Size of Receive buffer           */
-	boolean_t link_up;	/* TRUE if link is valid            */
-	boolean_t adapter_stopped;	/* State of adapter                 */
+	bool link_up;		/* true if link is valid            */
+	bool adapter_stopped;	/* State of adapter                 */
 	uint16_t device_id;	/* device id from PCI configuration space */
 	uint16_t vendor_id;	/* vendor id from PCI configuration space */
 	uint8_t revision_id;	/* revision id from PCI configuration space */
@@ -783,11 +783,11 @@ struct ixgb_hw_stats {
 };
 
 /* Function Prototypes */
-extern boolean_t ixgb_adapter_stop(struct ixgb_hw *hw);
-extern boolean_t ixgb_init_hw(struct ixgb_hw *hw);
-extern boolean_t ixgb_adapter_start(struct ixgb_hw *hw);
+extern bool ixgb_adapter_stop(struct ixgb_hw *hw);
+extern bool ixgb_init_hw(struct ixgb_hw *hw);
+extern bool ixgb_adapter_start(struct ixgb_hw *hw);
 extern void ixgb_check_for_link(struct ixgb_hw *hw);
-extern boolean_t ixgb_check_for_bad_link(struct ixgb_hw *hw);
+extern bool ixgb_check_for_bad_link(struct ixgb_hw *hw);
 
 extern void ixgb_rar_set(struct ixgb_hw *hw,
 				uint8_t *addr,
@@ -809,7 +809,7 @@ extern void ixgb_write_vfta(struct ixgb_hw *hw,
 void ixgb_get_ee_mac_addr(struct ixgb_hw *hw, uint8_t *mac_addr);
 uint32_t ixgb_get_ee_pba_number(struct ixgb_hw *hw);
 uint16_t ixgb_get_ee_device_id(struct ixgb_hw *hw);
-boolean_t ixgb_get_eeprom_data(struct ixgb_hw *hw);
+bool ixgb_get_eeprom_data(struct ixgb_hw *hw);
 __le16 ixgb_get_eeprom_word(struct ixgb_hw *hw, uint16_t index);
 
 /* Everything else */
drivers/net/ixgb/ixgb_main.c +22 -22

158 lines not on this page · raw message

drivers/net/ixgb/ixgb_osdep.h +0 -7
index 9e04a6b..4be1b27 100644
@@ -39,13 +39,6 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 
-typedef enum {
-#undef FALSE
-	FALSE = 0,
-#undef TRUE
-	TRUE = 1
-} boolean_t;
-
 #undef ASSERT
 #define ASSERT(x)	if(!(x)) BUG()
 #define MSGOUT(S, A, B)	printk(KERN_DEBUG S "\n", A, B)

-------------------------------------------------------------------------
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
#3 lore raw

PATCH 4/8 ixgb: move externs out of .c files

In reply to Auke Kok

---

 drivers/net/ixgb/ixgb.h         |   10 ++++++++++
 drivers/net/ixgb/ixgb_ethtool.c |    9 ---------
 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/net/ixgb/ixgb.h +10 -0
index fad4e99..a95ab55 100644
@@ -212,4 +212,14 @@ extern void ixgb_set_ethtool_ops(struct net_device *netdev);
 extern char ixgb_driver_name[];
 extern const char ixgb_driver_version[];
 
+extern int ixgb_up(struct ixgb_adapter *adapter);
+extern void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
+extern void ixgb_reset(struct ixgb_adapter *adapter);
+extern int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
+extern int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
+extern void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
+extern void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
+extern void ixgb_update_stats(struct ixgb_adapter *adapter);
+
+
 #endif /* _IXGB_H_ */
drivers/net/ixgb/ixgb_ethtool.c +0 -9
index 5d61c2e..45ddf80 100644
@@ -32,15 +32,6 @@
 
 #include <asm/uaccess.h>
 
-extern int ixgb_up(struct ixgb_adapter *adapter);
-extern void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
-extern void ixgb_reset(struct ixgb_adapter *adapter);
-extern int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
-extern int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
-extern void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
-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 {

-------------------------------------------------------------------------
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/8 e1000e: remove irq_sem

In reply to Auke Kok

From: Jesse Brandeburg <[email protected]>

irq_sem can safely be removed by auditing all irq.*able sites to make sure that interrupts don't get enabled unexpectedly when the interface is down.

---

 drivers/net/e1000e/e1000.h  |    3 ---
 drivers/net/e1000e/netdev.c |   37 ++++++++++++++-----------------------
 2 files changed, 14 insertions(+), 26 deletions(-)
drivers/net/e1000e/e1000.h +0 -3
index 6e0c6ed..4bf0c6c 100644
@@ -167,9 +167,6 @@ struct e1000_adapter {
 
 	spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
 
-	/* this is still needed for 82571 and above */
-	atomic_t irq_sem;
-
 	/* track device up/down/testing state */
 	unsigned long state;
 
drivers/net/e1000e/netdev.c +14 -23
index fc5c63f..f501dd5 100644
@@ -836,9 +836,7 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
 	struct e1000_hw *hw = &adapter->hw;
 	u32 icr = er32(ICR);
 
-	/* read ICR disables interrupts using IAM, so keep up with our
-	 * enable/disable accounting */
-	atomic_inc(&adapter->irq_sem);
+	/* read ICR disables interrupts using IAM */
 
 	if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
 		hw->mac.get_link_status = 1;
@@ -868,8 +866,6 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
 		adapter->total_rx_bytes = 0;
 		adapter->total_rx_packets = 0;
 		__netif_rx_schedule(netdev, &adapter->napi);
-	} else {
-		atomic_dec(&adapter->irq_sem);
 	}
 
 	return IRQ_HANDLED;
@@ -895,11 +891,8 @@ static irqreturn_t e1000_intr(int irq, void *data)
 	if (!(icr & E1000_ICR_INT_ASSERTED))
 		return IRQ_NONE;
 
-	/* Interrupt Auto-Mask...upon reading ICR,
-	 * interrupts are masked.  No need for the
-	 * IMC write, but it does mean we should
-	 * account for it ASAP. */
-	atomic_inc(&adapter->irq_sem);
+	/* Interrupt Auto-Mask...upon reading ICR, interrupts are masked.  No
+	 * need for the IMC write */
 
 	if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
 		hw->mac.get_link_status = 1;
@@ -931,8 +924,6 @@ static irqreturn_t e1000_intr(int irq, void *data)
 		adapter->total_rx_bytes = 0;
 		adapter->total_rx_packets = 0;
 		__netif_rx_schedule(netdev, &adapter->napi);
-	} else {
-		atomic_dec(&adapter->irq_sem);
 	}
 
 	return IRQ_HANDLED;
@@ -983,7 +974,6 @@ static void e1000_irq_disable(struct e1000_adapter *adapter)
 {
 	struct e1000_hw *hw = &adapter->hw;
 
-	atomic_inc(&adapter->irq_sem);
 	ew32(IMC, ~0);
 	e1e_flush();
 	synchronize_irq(adapter->pdev->irq);
@@ -996,10 +986,8 @@ static void e1000_irq_enable(struct e1000_adapter *adapter)
 {
 	struct e1000_hw *hw = &adapter->hw;
 
-	if (atomic_dec_and_test(&adapter->irq_sem)) {
-		ew32(IMS, IMS_ENABLE_MASK);
-		e1e_flush();
-	}
+	ew32(IMS, IMS_ENABLE_MASK);
+	e1e_flush();
 }
 
 /**
@@ -1427,9 +1415,12 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 	struct e1000_hw *hw = &adapter->hw;
 	u32 vfta, index;
 
-	e1000_irq_disable(adapter);
+	if (!test_bit(__E1000_DOWN, &adapter->state))
+		e1000_irq_disable(adapter);
 	vlan_group_set_device(adapter->vlgrp, vid, NULL);
-	e1000_irq_enable(adapter);
+
+	if (!test_bit(__E1000_DOWN, &adapter->state))
+		e1000_irq_enable(adapter);
 
 	if ((adapter->hw.mng_cookie.status &
 	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
@@ -1480,7 +1471,8 @@ static void e1000_vlan_rx_register(struct net_device *netdev,
 	struct e1000_hw *hw = &adapter->hw;
 	u32 ctrl, rctl;
 
-	e1000_irq_disable(adapter);
+	if (!test_bit(__E1000_DOWN, &adapter->state))
+		e1000_irq_disable(adapter);
 	adapter->vlgrp = grp;
 
 	if (grp) {
@@ -1517,7 +1509,8 @@ static void e1000_vlan_rx_register(struct net_device *netdev,
 		}
 	}
 
-	e1000_irq_enable(adapter);
+	if (!test_bit(__E1000_DOWN, &adapter->state))
+		e1000_irq_enable(adapter);
 }
 
 static void e1000_restore_vlan(struct e1000_adapter *adapter)
@@ -2167,7 +2160,6 @@ void e1000e_down(struct e1000_adapter *adapter)
 	msleep(10);
 
 	napi_disable(&adapter->napi);
-	atomic_set(&adapter->irq_sem, 0);
 	e1000_irq_disable(adapter);
 
 	del_timer_sync(&adapter->watchdog_timer);
@@ -2227,7 +2219,6 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
 	spin_lock_init(&adapter->tx_queue_lock);
 
 	/* Explicitly disable IRQ since the NIC can be in any state. */
-	atomic_set(&adapter->irq_sem, 0);
 	e1000_irq_disable(adapter);
 
 	spin_lock_init(&adapter->stats_lock);

-------------------------------------------------------------------------
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
#1 lore raw

PATCH 2/8 ixgb: add explicit state checking

In reply to Auke Kok

From: Jesse Brandeburg <[email protected]>

In order to remove the irq_sem code we need to implement strict adapter state checking to prevent accidental double up or downs or resets. This code is largely copied from e1000/e1000e.

---

 drivers/net/ixgb/ixgb.h      |    9 +++++++++
 drivers/net/ixgb/ixgb_main.c |   34 ++++++++++++++++++++++++----------
 2 files changed, 33 insertions(+), 10 deletions(-)
drivers/net/ixgb/ixgb.h +9 -0
index 3d2e721..0078136 100644
@@ -195,6 +195,15 @@ struct ixgb_adapter {
 	struct ixgb_hw_stats stats;
 	uint32_t alloc_rx_buff_failed;
 	boolean_t have_msi;
+	unsigned long flags;
+};
+
+enum ixgb_state_t {
+	/* TBD
+	__IXGB_TESTING,
+	__IXGB_RESETTING,
+	*/
+	__IXGB_DOWN
 };
 
 /* Exported from other modules */
drivers/net/ixgb/ixgb_main.c +24 -10
index 269e6f8..548c248 100644
@@ -283,13 +283,15 @@ ixgb_up(struct ixgb_adapter *adapter)
 		}
 	}
 
-	mod_timer(&adapter->watchdog_timer, jiffies);
+	clear_bit(__IXGB_DOWN, &adapter->flags);
 
 #ifdef CONFIG_IXGB_NAPI
 	napi_enable(&adapter->napi);
 #endif
 	ixgb_irq_enable(adapter);
 
+	mod_timer(&adapter->watchdog_timer, jiffies);
+
 	return 0;
 }
 
@@ -298,11 +300,14 @@ ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
 {
 	struct net_device *netdev = adapter->netdev;
 
+	/* prevent the interrupt handler from restarting watchdog */
+	set_bit(__IXGB_DOWN, &adapter->flags);
+
 #ifdef CONFIG_IXGB_NAPI
 	napi_disable(&adapter->napi);
 	atomic_set(&adapter->irq_sem, 0);
 #endif
-
+	/* waiting for NAPI to complete can re-enable interrupts */
 	ixgb_irq_disable(adapter);
 	free_irq(adapter->pdev->irq, netdev);
 
@@ -592,6 +597,7 @@ ixgb_sw_init(struct ixgb_adapter *adapter)
 	atomic_set(&adapter->irq_sem, 1);
 	spin_lock_init(&adapter->tx_lock);
 
+	set_bit(__IXGB_DOWN, &adapter->flags);
 	return 0;
 }
 
@@ -1464,14 +1470,18 @@ ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 	int vlan_id = 0;
 	int tso;
 
+	if (test_bit(__IXGB_DOWN, &adapter->flags)) {
+		dev_kfree_skb(skb);
+		return NETDEV_TX_OK;
+	}
+
 	if(skb->len <= 0) {
 		dev_kfree_skb_any(skb);
 		return 0;
 	}
 
 #ifdef NETIF_F_LLTX
-	local_irq_save(flags);
-	if (!spin_trylock(&adapter->tx_lock)) {
+	if (!spin_trylock_irqsave(&adapter->tx_lock, flags)) {
 		/* Collision - tell upper layer to requeue */
 		local_irq_restore(flags);
 		return NETDEV_TX_LOCKED;
@@ -1753,9 +1763,9 @@ ixgb_intr(int irq, void *data)
 	if(unlikely(!icr))
 		return IRQ_NONE;  /* Not our interrupt */
 
-	if(unlikely(icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC))) {
-		mod_timer(&adapter->watchdog_timer, jiffies);
-	}
+	if (unlikely(icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC)))
+		if (!test_bit(__IXGB_DOWN, &adapter->flags))
+			mod_timer(&adapter->watchdog_timer, jiffies);
 
 #ifdef CONFIG_IXGB_NAPI
 	if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
@@ -2195,7 +2205,9 @@ ixgb_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
 		IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
 	}
 
-	ixgb_irq_enable(adapter);
+	/* don't enable interrupts unless we are UP */
+	if (adapter->netdev->flags & IFF_UP)
+		ixgb_irq_enable(adapter);
 }
 
 static void
@@ -2222,9 +2234,11 @@ ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
 
 	vlan_group_set_device(adapter->vlgrp, vid, NULL);
 
-	ixgb_irq_enable(adapter);
+	/* don't enable interrupts unless we are UP */
+	if (adapter->netdev->flags & IFF_UP)
+		ixgb_irq_enable(adapter);
 
-	/* remove VID from filter table*/
+	/* remove VID from filter table */
 
 	index = (vid >> 5) & 0x7F;
 	vfta = IXGB_READ_REG_ARRAY(&adapter->hw, VFTA, index);

Auke Kok

author
#0 lore raw

PATCH 1/8 e1000: Convert boolean_t to bool

From: Joe Perches <[email protected]>

Quoted 1 line · Auke

send me a patch for e1000 and for ixgb and I'll happily apply those :)

boolean_t to bool
TRUE to true
FALSE to false
comment typo ahread to ahead

---

 drivers/net/e1000/e1000.h         |   26 ++--
 drivers/net/e1000/e1000_ethtool.c |   17 +--
 drivers/net/e1000/e1000_hw.c      |  223 ++++++++++++++++++-------------------
 drivers/net/e1000/e1000_hw.h      |   62 +++++-----
 drivers/net/e1000/e1000_main.c    |   90 +++++++--------
 drivers/net/e1000/e1000_osdep.h   |    7 -
 6 files changed, 209 insertions(+), 216 deletions(-)
drivers/net/e1000/e1000.h +13 -13
index 3b84028..d73a6c1 100644
@@ -188,7 +188,7 @@ struct e1000_tx_ring {
 	spinlock_t tx_lock;
 	uint16_t tdh;
 	uint16_t tdt;
-	boolean_t last_tx_tso;
+	bool last_tx_tso;
 };
 
 struct e1000_rx_ring {
@@ -283,17 +283,17 @@ struct e1000_adapter {
 	uint32_t tx_fifo_size;
 	uint8_t  tx_timeout_factor;
 	atomic_t tx_fifo_stall;
-	boolean_t pcix_82544;
-	boolean_t detect_tx_hung;
+	bool pcix_82544;
+	bool detect_tx_hung;
 
 	/* RX */
 #ifdef CONFIG_E1000_NAPI
-	boolean_t (*clean_rx) (struct e1000_adapter *adapter,
-			       struct e1000_rx_ring *rx_ring,
-			       int *work_done, int work_to_do);
+	bool (*clean_rx) (struct e1000_adapter *adapter,
+			  struct e1000_rx_ring *rx_ring,
+			  int *work_done, int work_to_do);
 #else
-	boolean_t (*clean_rx) (struct e1000_adapter *adapter,
-			       struct e1000_rx_ring *rx_ring);
+	bool (*clean_rx) (struct e1000_adapter *adapter,
+			  struct e1000_rx_ring *rx_ring);
 #endif
 	void (*alloc_rx_buf) (struct e1000_adapter *adapter,
 			      struct e1000_rx_ring *rx_ring,
@@ -312,7 +312,7 @@ struct e1000_adapter {
 	uint32_t alloc_rx_buff_failed;
 	uint32_t rx_int_delay;
 	uint32_t rx_abs_int_delay;
-	boolean_t rx_csum;
+	bool rx_csum;
 	unsigned int rx_ps_pages;
 	uint32_t gorcl;
 	uint64_t gorcl_old;
@@ -335,12 +335,12 @@ struct e1000_adapter {
 	struct e1000_rx_ring test_rx_ring;
 
 	int msg_enable;
-	boolean_t have_msi;
+	bool have_msi;
 
 	/* to not mess up cache alignment, always add to the bottom */
-	boolean_t tso_force;
-	boolean_t smart_power_down;	/* phy smart power down */
-	boolean_t quad_port_a;
+	bool tso_force;
+	bool smart_power_down;	/* phy smart power down */
+	bool quad_port_a;
 	unsigned long flags;
 	uint32_t eeprom_wol;
 };
drivers/net/e1000/e1000_ethtool.c +9 -8
index 85e66f4..05e1fb3 100644
@@ -353,7 +353,7 @@ e1000_set_tso(struct net_device *netdev, uint32_t data)
 		netdev->features &= ~NETIF_F_TSO6;
 
 	DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled");
-	adapter->tso_force = TRUE;
+	adapter->tso_force = true;
 	return 0;
 }
 
@@ -922,7 +922,8 @@ static int
 e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
 {
 	struct net_device *netdev = adapter->netdev;
-	uint32_t mask, i=0, shared_int = TRUE;
+	uint32_t mask, i = 0;
+	bool shared_int = true;
 	uint32_t irq = adapter->pdev->irq;
 
 	*data = 0;
@@ -931,7 +932,7 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
 	/* Hook up test interrupt handler just for this test */
 	if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
 	                 netdev))
-		shared_int = FALSE;
+		shared_int = false;
 	else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
 	         netdev->name, netdev)) {
 		*data = 1;
@@ -1295,7 +1296,7 @@ e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
 	uint32_t ctrl_reg = 0;
 	uint32_t stat_reg = 0;
 
-	adapter->hw.autoneg = FALSE;
+	adapter->hw.autoneg = false;
 
 	if (adapter->hw.phy_type == e1000_phy_m88) {
 		/* Auto-MDI/MDIX Off */
@@ -1473,7 +1474,7 @@ e1000_loopback_cleanup(struct e1000_adapter *adapter)
 	case e1000_82545_rev_3:
 	case e1000_82546_rev_3:
 	default:
-		hw->autoneg = TRUE;
+		hw->autoneg = true;
 		if (hw->phy_type == e1000_phy_gg82563)
 			e1000_write_phy_reg(hw,
 					    GG82563_PHY_KMRN_MODE_CTRL,
@@ -1607,13 +1608,13 @@ e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
 	*data = 0;
 	if (adapter->hw.media_type == e1000_media_type_internal_serdes) {
 		int i = 0;
-		adapter->hw.serdes_link_down = TRUE;
+		adapter->hw.serdes_link_down = true;
 
 		/* On some blade server designs, link establishment
 		 * could take as long as 2-3 minutes */
 		do {
 			e1000_check_for_link(&adapter->hw);
-			if (adapter->hw.serdes_link_down == FALSE)
+			if (!adapter->hw.serdes_link_down)
 				return *data;
 			msleep(20);
 		} while (i++ < 3750);
@@ -1649,7 +1650,7 @@ e1000_diag_test(struct net_device *netdev,
 		   struct ethtool_test *eth_test, uint64_t *data)
 {
 	struct e1000_adapter *adapter = netdev_priv(netdev);
-	boolean_t if_running = netif_running(netdev);
+	bool if_running = netif_running(netdev);
 
 	set_bit(__E1000_TESTING, &adapter->flags);
 	if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
drivers/net/e1000/e1000_hw.c +111 -112

709 lines not on this page · raw message

drivers/net/e1000/e1000_hw.h +31 -31

103 lines not on this page · raw message

drivers/net/e1000/e1000_main.c +45 -45

265 lines not on this page · raw message

drivers/net/e1000/e1000_osdep.h +0 -7
index 10af742..365626d 100644
@@ -41,13 +41,6 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 
-typedef enum {
-#undef FALSE
-    FALSE = 0,
-#undef TRUE
-    TRUE = 1
-} boolean_t;
-
 #ifdef DBG
 #define DEBUGOUT(S)		printk(KERN_DEBUG S "\n")
 #define DEBUGOUT1(S, A...)	printk(KERN_DEBUG S "\n", A)
author
#4 lore raw

PATCH 5/8 e1000e: remove no longer used e1000e_read_nvm_spi

This function is no longer used now that 82573 uses the eerd read method as well. Thanks to Adrian Bunk for pointing this out.

---

 drivers/net/e1000e/e1000.h |    1 -
 drivers/net/e1000e/lib.c   |   56 --------------------------------------------
 2 files changed, 0 insertions(+), 57 deletions(-)
drivers/net/e1000e/e1000.h +0 -1
index 327c062..6e0c6ed 100644
@@ -462,7 +462,6 @@ extern s32 e1000e_acquire_nvm(struct e1000_hw *hw);
 extern s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
 extern s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw);
 extern s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg);
-extern s32 e1000e_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
 extern s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
 extern s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw);
 extern void e1000e_release_nvm(struct e1000_hw *hw);
drivers/net/e1000e/lib.c +0 -56

62 lines not on this page · raw message

author
#7 lore raw

PATCH 8/8 ixgb: remove irq_sem

In reply to Auke Kok

From: Jesse Brandeburg <[email protected]>

ixgb can remove irq_sem by auditing all the call sites to make sure that each of them makes sure the adapter is in the correct state before re-enabling interrupts. after doing this to all of our other drivers it is becoming easier.

---

 drivers/net/ixgb/ixgb.h      |    1 -
 drivers/net/ixgb/ixgb_main.c |   18 ++++++------------
 2 files changed, 6 insertions(+), 13 deletions(-)
drivers/net/ixgb/ixgb.h +0 -1
index a95ab55..f2fff90 100644
@@ -158,7 +158,6 @@ struct ixgb_adapter {
 	uint16_t link_speed;
 	uint16_t link_duplex;
 	spinlock_t tx_lock;
-	atomic_t irq_sem;
 	struct work_struct tx_timeout_task;
 
 	struct timer_list blink_timer;
drivers/net/ixgb/ixgb_main.c +6 -12
index d9688bb..9c9bf31 100644
@@ -197,7 +197,6 @@ module_exit(ixgb_exit_module);
 static void
 ixgb_irq_disable(struct ixgb_adapter *adapter)
 {
-	atomic_inc(&adapter->irq_sem);
 	IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
 	IXGB_WRITE_FLUSH(&adapter->hw);
 	synchronize_irq(adapter->pdev->irq);
@@ -211,14 +210,12 @@ ixgb_irq_disable(struct ixgb_adapter *adapter)
 static void
 ixgb_irq_enable(struct ixgb_adapter *adapter)
 {
-	if(atomic_dec_and_test(&adapter->irq_sem)) {
-		u32 val = IXGB_INT_RXT0 | IXGB_INT_RXDMT0 |
-			  IXGB_INT_TXDW | IXGB_INT_LSC;
-		if (adapter->hw.subsystem_vendor_id == SUN_SUBVENDOR_ID)
-			val |= IXGB_INT_GPI0;
-		IXGB_WRITE_REG(&adapter->hw, IMS, val);
-		IXGB_WRITE_FLUSH(&adapter->hw);
-	}
+	u32 val = IXGB_INT_RXT0 | IXGB_INT_RXDMT0 |
+		  IXGB_INT_TXDW | IXGB_INT_LSC;
+	if (adapter->hw.subsystem_vendor_id == SUN_SUBVENDOR_ID)
+		val |= IXGB_INT_GPI0;
+	IXGB_WRITE_REG(&adapter->hw, IMS, val);
+	IXGB_WRITE_FLUSH(&adapter->hw);
 }
 
 int
@@ -305,7 +302,6 @@ ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog)
 
 #ifdef CONFIG_IXGB_NAPI
 	napi_disable(&adapter->napi);
-	atomic_set(&adapter->irq_sem, 0);
 #endif
 	/* waiting for NAPI to complete can re-enable interrupts */
 	ixgb_irq_disable(adapter);
@@ -594,7 +590,6 @@ ixgb_sw_init(struct ixgb_adapter *adapter)
 	/* enable flow control to be programmed */
 	hw->fc.send_xon = 1;
 
-	atomic_set(&adapter->irq_sem, 1);
 	spin_lock_init(&adapter->tx_lock);
 
 	set_bit(__IXGB_DOWN, &adapter->flags);
@@ -1774,7 +1769,6 @@ ixgb_intr(int irq, void *data)
 		  of the posted write is intentionally left out.
 		*/
 
-		atomic_inc(&adapter->irq_sem);
 		IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
 		__netif_rx_schedule(netdev, &adapter->napi);
 	}
author
#6 lore raw

PATCH 7/8 e1000: remove irq_sem

In reply to Auke Kok

From: Jesse Brandeburg <[email protected]>

irq_sem was just a hack to prevent interrupts from being enabled unexpectedly in deep call paths. Simply finding those call paths and fixing them by hand results in a driver that behaves as we expect and doesn't need the atomic at all.

---

 drivers/net/e1000/e1000.h      |    1 -
 drivers/net/e1000/e1000_main.c |   41 +++++++++++++++-------------------------
 2 files changed, 15 insertions(+), 27 deletions(-)
drivers/net/e1000/e1000.h +0 -1
index d73a6c1..a05aa51 100644
@@ -249,7 +249,6 @@ struct e1000_adapter {
 #ifdef CONFIG_E1000_NAPI
 	spinlock_t tx_queue_lock;
 #endif
-	atomic_t irq_sem;
 	unsigned int total_tx_bytes;
 	unsigned int total_tx_packets;
 	unsigned int total_rx_bytes;
drivers/net/e1000/e1000_main.c +15 -26

109 lines not on this page · raw message

author
#11 lore raw
In reply to Joe Perches
Quoted 17 lines · Joe Perches
Quoted 8 lines · Auke
Quoted 6 lines · Joe Perches
Quoted 2 lines · Auke Kok
Quoted 1 line · Auke

send me a patch for e1000 and for ixgb and I'll happily apply those :)

I gather you didn't run the little script to convert the u[_]*int\(8|16|32|64\) to u\1 uses? (u_int8_t -> u8, etc) Did you need or want actual patches to do that?

I'll take a patch for that and yes, I was too busy to do this myself just now :)

I just sent you a bunch of patches to do this conversion.

I started on doing a kind-of checkpatch/Lindent pass on e1000.

Some of the functions in e1000 are heavily indented and could be neatened with a little bit of rewrite.

Quoted 7 lines

For instance, here's a function in e1000_main.c

It's a little bit hard to understand with the indenting and breakup of the lines. I think the rewrite below it is shorter and easier to read.

Do you want these sorts of changes too?

yeah absolutely

maybe this is a bit premature since we're going to have much more fun taking out all the pci express code after 2.6.26 but we might as well start to queue this stuff up now - at least I can keep it in a branch locally and this is exactly what we need to do anyway

Quoted 60 lines

static int
e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)

{
	struct e1000_hw *hw =  &adapter->hw;
	u16 length, offset;

	if (vlan_tx_tag_present(skb)) {
		if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
			( adapter->hw.mng_cookie.status &
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
			return 0;
	}
	if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
		struct ethhdr *eth = (struct ethhdr *) skb->data;
		if ((htons(ETH_P_IP) == eth->h_proto)) {
			const struct iphdr *ip =
				(struct iphdr *)((u8 *)skb->data+14);
			if (IPPROTO_UDP == ip->protocol) {
				struct udphdr *udp =
					(struct udphdr *)((u8 *)ip +
						(ip->ihl << 2));
				if (ntohs(udp->dest) == 67) {
					offset = (u8 *)udp + 8 - skb->data;
					length = skb->len - offset;

					return e1000_mng_write_dhcp_info(hw,
							(u8 *)udp + 8,
							length);
				}
			}
		}
	}
	return 0;
}

could be:

static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
struct sk_buff *skb)

{
	struct e1000_hw *hw = &adapter->hw;
	struct ethhdr *eth;
	const struct iphdr *ip;
	struct udphdr *udp;
	u16 length, offset;

	if (vlan_tx_tag_present(skb) &&
	    (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id)
	       && (adapter->hw.mng_cookie.status
		   & E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT))))
		return 0;
	if (skb->len <= MINIMUM_DHCP_PACKET_SIZE)
		return 0;
	eth = (struct ethhdr *)skb->data;
	if (eth->h_proto != htons(ETH_P_IP))
		return 0;
	ip = (struct iphdr *)((u8 *)skb->data + 14);
	if (ip->protocol != IPPROTO_UDP)
		return 0;
	udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
Quoted 8 lines
	if (ntohs(udp->dest) != 67)
		return 0;

	offset = (u8 *)udp + 8 - skb->data;
	length = skb->len - offset;

	return e1000_mng_write_dhcp_info(hw, (u8 *)udp + 8, length);
}

yeah, much better :)

#10 lore raw
In reply to a message not in the archive
Quoted 8 lines · Auke
Quoted 6 lines · Joe Perches
Quoted 2 lines · Auke Kok
Quoted 1 line · Auke

send me a patch for e1000 and for ixgb and I'll happily apply those :)

I gather you didn't run the little script to convert the u[_]*int\(8|16|32|64\) to u\1 uses? (u_int8_t -> u8, etc) Did you need or want actual patches to do that?

I'll take a patch for that and yes, I was too busy to do this myself just now :)

I just sent you a bunch of patches to do this conversion.

I started on doing a kind-of checkpatch/Lindent pass on e1000.

Some of the functions in e1000 are heavily indented and could be neatened with a little bit of rewrite.

For instance, here's a function in e1000_main.c

It's a little bit hard to understand with the indenting and breakup of the lines. I think the rewrite below it is shorter and easier to read.

Do you want these sorts of changes too?

static int
e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)

{
	struct e1000_hw *hw =  &adapter->hw;
	u16 length, offset;

	if (vlan_tx_tag_present(skb)) {
		if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
			( adapter->hw.mng_cookie.status &
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
			return 0;
	}
	if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
		struct ethhdr *eth = (struct ethhdr *) skb->data;
		if ((htons(ETH_P_IP) == eth->h_proto)) {
			const struct iphdr *ip =
				(struct iphdr *)((u8 *)skb->data+14);
			if (IPPROTO_UDP == ip->protocol) {
				struct udphdr *udp =
					(struct udphdr *)((u8 *)ip +
						(ip->ihl << 2));
				if (ntohs(udp->dest) == 67) {
					offset = (u8 *)udp + 8 - skb->data;
					length = skb->len - offset;

					return e1000_mng_write_dhcp_info(hw,
							(u8 *)udp + 8,
							length);
				}
			}
		}
	}
	return 0;
}

could be:

static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
struct sk_buff *skb)

{
	struct e1000_hw *hw = &adapter->hw;
	struct ethhdr *eth;
	const struct iphdr *ip;
	struct udphdr *udp;
	u16 length, offset;

	if (vlan_tx_tag_present(skb) &&
	    (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id)
	       && (adapter->hw.mng_cookie.status
		   & E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT))))
		return 0;
	if (skb->len <= MINIMUM_DHCP_PACKET_SIZE)
		return 0;
	eth = (struct ethhdr *)skb->data;
	if (eth->h_proto != htons(ETH_P_IP))
		return 0;
	ip = (struct iphdr *)((u8 *)skb->data + 14);
	if (ip->protocol != IPPROTO_UDP)
		return 0;
	udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
	if (ntohs(udp->dest) != 67)
		return 0;

	offset = (u8 *)udp + 8 - skb->data;
	length = skb->len - offset;

	return e1000_mng_write_dhcp_info(hw, (u8 *)udp + 8, length);
}

cheers, Joe