[ewg] [PATCH 4/10] nes: interrupt moderation fix

Glenn Grundstrom NetEffect glenn at lists.openfabrics.org
Thu Dec 20 12:28:01 PST 2007


Hardware interrupt moderation timer gave average performance
on slower systems.  These fixes increase performance.

Signed-off-by: Glenn Grundstrom <ggrundstrom at neteffect.com>

---

diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 674ce32..1048db2 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -155,26 +155,41 @@ static void nes_nic_tune_timer(struct nes_device *nesdev)
 
 	spin_lock_irqsave(&nesadapter->periodic_timer_lock, flags);
 
+	if (shared_timer->cq_count_old < shared_timer->cq_count) {
+		if (shared_timer->cq_count > shared_timer->threshold_low ) {
+			shared_timer->cq_direction_downward=0;
+		}
+	}
+	if (shared_timer->cq_count_old >= shared_timer->cq_count) {
+		shared_timer->cq_direction_downward++;
+	}
+	shared_timer->cq_count_old = shared_timer->cq_count;
+	if (shared_timer->cq_direction_downward > NES_NIC_CQ_DOWNWARD_TREND) {
+		if (shared_timer->cq_count <= shared_timer->threshold_low ) {
+			shared_timer->threshold_low = shared_timer->threshold_low/2;
+			shared_timer->cq_direction_downward=0;
+			shared_timer->cq_count = 0;
+			spin_unlock_irqrestore(&nesadapter->periodic_timer_lock, flags);
+			return;
+		}
+	}
+
 	if (shared_timer->cq_count>1) {
 		nesdev->deepcq_count += shared_timer->cq_count;
 		if (shared_timer->cq_count <= shared_timer->threshold_low ) {       /* increase timer gently */
 			shared_timer->timer_direction_upward++;
 			shared_timer->timer_direction_downward = 0;
-		}
-		else if (shared_timer->cq_count <= shared_timer->threshold_target ) { /* balanced */
+		} else if (shared_timer->cq_count <= shared_timer->threshold_target ) { /* balanced */
 			shared_timer->timer_direction_upward = 0;
 			shared_timer->timer_direction_downward = 0;
-		}
-		else if (shared_timer->cq_count <= shared_timer->threshold_high ) {  /* decrease timer gently */
+		} else if (shared_timer->cq_count <= shared_timer->threshold_high ) {  /* decrease timer gently */
 			shared_timer->timer_direction_downward++;
 			shared_timer->timer_direction_upward = 0;
-		}
-		else if (shared_timer->cq_count <= (shared_timer->threshold_high)*2) {
+		} else if (shared_timer->cq_count <= (shared_timer->threshold_high)*2) {
 			shared_timer->timer_in_use -= 2;
 			shared_timer->timer_direction_upward = 0;
 			shared_timer->timer_direction_downward++;
-		}
-		else {
+		} else {
 			shared_timer->timer_in_use -= 4;
 			shared_timer->timer_direction_upward = 0;
 			shared_timer->timer_direction_downward++;
@@ -2241,7 +2256,7 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
 				if (atomic_read(&nesvnic->rx_skbs_needed) > (nesvnic->nic.rq_size>>1)) {
 					nes_write32(nesdev->regs+NES_CQE_ALLOC,
 							cq->cq_number | (cqe_count << 16));
-                    nesadapter->tune_timer.cq_count += cqe_count;
+					nesadapter->tune_timer.cq_count += cqe_count;
 					cqe_count = 0;
 					nes_replenish_nic_rq(nesvnic);
 				}
diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
index 25cfda2..ca0b006 100644
--- a/drivers/infiniband/hw/nes/nes_hw.h
+++ b/drivers/infiniband/hw/nes/nes_hw.h
@@ -957,6 +957,7 @@ struct nes_arp_entry {
 #define DEFAULT_JUMBO_NES_QL_LOW    12
 #define DEFAULT_JUMBO_NES_QL_TARGET 40
 #define DEFAULT_JUMBO_NES_QL_HIGH   128
+#define NES_NIC_CQ_DOWNWARD_TREND   8
 
 struct nes_hw_tune_timer {
     u16 cq_count;
@@ -969,6 +970,8 @@ struct nes_hw_tune_timer {
     u16 timer_in_use_max;
     u8  timer_direction_upward;
     u8  timer_direction_downward;
+    u16 cq_count_old;
+    u8  cq_direction_downward;
 };
 
 #define NES_TIMER_INT_LIMIT         2
@@ -1051,17 +1054,17 @@ struct nes_adapter {
 
 	u32 nic_rx_eth_route_err;
 
-	u32	et_rx_coalesce_usecs;
+	u32 et_rx_coalesce_usecs;
 	u32	et_rx_max_coalesced_frames;
 	u32 et_rx_coalesce_usecs_irq;
-	u32	et_rx_max_coalesced_frames_irq;
-	u32	et_pkt_rate_low;
-	u32	et_rx_coalesce_usecs_low;
-	u32	et_rx_max_coalesced_frames_low;
-	u32	et_pkt_rate_high;
-	u32	et_rx_coalesce_usecs_high;
-	u32	et_rx_max_coalesced_frames_high;
-	u32	et_rate_sample_interval;
+	u32 et_rx_max_coalesced_frames_irq;
+	u32 et_pkt_rate_low;
+	u32 et_rx_coalesce_usecs_low;
+	u32 et_rx_max_coalesced_frames_low;
+	u32 et_pkt_rate_high;
+	u32 et_rx_coalesce_usecs_high;
+	u32 et_rx_max_coalesced_frames_high;
+	u32 et_rate_sample_interval;
 	u32 timer_int_limit;
 
 	/* Adapter base MAC address */
@@ -1077,7 +1080,7 @@ struct nes_adapter {
 	u16 pd_config_size[4];
 	u16 pd_config_base[4];
 
-	u16  link_interrupt_count[4];
+	u16 link_interrupt_count[4];
 
 	/* the phy index for each port */
 	u8  phy_index[4];



More information about the ewg mailing list