aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/efx.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-10-23 04:32:13 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-24 07:27:15 -0400
commit0d86ebd815416efb4e95ca70c3b8e65b476c5f9f (patch)
treed6ed53cfda8b1968119ea3ddf2a0b24e18211cfb /drivers/net/sfc/efx.c
parent0484e0db7c4293d6202cff730ee359d8a7a6b085 (diff)
sfc: Maintain interrupt moderation values in ticks, not microseconds
This simplifies the implementation a lot. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc/efx.c')
-rw-r--r--drivers/net/sfc/efx.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 862e4832f614..30951fb3d20f 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -228,26 +228,20 @@ static int efx_poll(struct napi_struct *napi, int budget)
228 if (channel->used_flags & EFX_USED_BY_RX && 228 if (channel->used_flags & EFX_USED_BY_RX &&
229 efx->irq_rx_adaptive && 229 efx->irq_rx_adaptive &&
230 unlikely(++channel->irq_count == 1000)) { 230 unlikely(++channel->irq_count == 1000)) {
231 unsigned old_irq_moderation = channel->irq_moderation;
232
233 if (unlikely(channel->irq_mod_score < 231 if (unlikely(channel->irq_mod_score <
234 irq_adapt_low_thresh)) { 232 irq_adapt_low_thresh)) {
235 channel->irq_moderation = 233 if (channel->irq_moderation > 1) {
236 max_t(int, 234 channel->irq_moderation -= 1;
237 channel->irq_moderation - 235 falcon_set_int_moderation(channel);
238 FALCON_IRQ_MOD_RESOLUTION, 236 }
239 FALCON_IRQ_MOD_RESOLUTION);
240 } else if (unlikely(channel->irq_mod_score > 237 } else if (unlikely(channel->irq_mod_score >
241 irq_adapt_high_thresh)) { 238 irq_adapt_high_thresh)) {
242 channel->irq_moderation = 239 if (channel->irq_moderation <
243 min(channel->irq_moderation + 240 efx->irq_rx_moderation) {
244 FALCON_IRQ_MOD_RESOLUTION, 241 channel->irq_moderation += 1;
245 efx->irq_rx_moderation); 242 falcon_set_int_moderation(channel);
243 }
246 } 244 }
247
248 if (channel->irq_moderation != old_irq_moderation)
249 falcon_set_int_moderation(channel);
250
251 channel->irq_count = 0; 245 channel->irq_count = 0;
252 channel->irq_mod_score = 0; 246 channel->irq_mod_score = 0;
253 } 247 }
@@ -1220,22 +1214,33 @@ void efx_flush_queues(struct efx_nic *efx)
1220 * 1214 *
1221 **************************************************************************/ 1215 **************************************************************************/
1222 1216
1217static unsigned irq_mod_ticks(int usecs, int resolution)
1218{
1219 if (usecs <= 0)
1220 return 0; /* cannot receive interrupts ahead of time :-) */
1221 if (usecs < resolution)
1222 return 1; /* never round down to 0 */
1223 return usecs / resolution;
1224}
1225
1223/* Set interrupt moderation parameters */ 1226/* Set interrupt moderation parameters */
1224void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs, 1227void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs,
1225 bool rx_adaptive) 1228 bool rx_adaptive)
1226{ 1229{
1227 struct efx_tx_queue *tx_queue; 1230 struct efx_tx_queue *tx_queue;
1228 struct efx_rx_queue *rx_queue; 1231 struct efx_rx_queue *rx_queue;
1232 unsigned tx_ticks = irq_mod_ticks(tx_usecs, FALCON_IRQ_MOD_RESOLUTION);
1233 unsigned rx_ticks = irq_mod_ticks(rx_usecs, FALCON_IRQ_MOD_RESOLUTION);
1229 1234
1230 EFX_ASSERT_RESET_SERIALISED(efx); 1235 EFX_ASSERT_RESET_SERIALISED(efx);
1231 1236
1232 efx_for_each_tx_queue(tx_queue, efx) 1237 efx_for_each_tx_queue(tx_queue, efx)
1233 tx_queue->channel->irq_moderation = tx_usecs; 1238 tx_queue->channel->irq_moderation = tx_ticks;
1234 1239
1235 efx->irq_rx_adaptive = rx_adaptive; 1240 efx->irq_rx_adaptive = rx_adaptive;
1236 efx->irq_rx_moderation = rx_usecs; 1241 efx->irq_rx_moderation = rx_ticks;
1237 efx_for_each_rx_queue(rx_queue, efx) 1242 efx_for_each_rx_queue(rx_queue, efx)
1238 rx_queue->channel->irq_moderation = rx_usecs; 1243 rx_queue->channel->irq_moderation = rx_ticks;
1239} 1244}
1240 1245
1241/************************************************************************** 1246/**************************************************************************