--- if_em.c-1.44.2.3.orig Tue Nov 9 05:06:14 2004 +++ if_em.c Fri Dec 10 11:22:05 2004 @@ -32,6 +32,7 @@ ***************************************************************************/ /*$FreeBSD: src/sys/dev/em/if_em.c,v 1.44.2.3 2004/11/08 20:06:14 scottl Exp $*/ #include @@ -182,6 +183,9 @@ static void em_add_int_delay_sysctl(struct adapter *, const char *, const char *, struct em_int_delay_info *, int, int); +#ifdef 1 +static int em_sysctl_throttle_ceil(SYSCTL_HANDLER_ARGS); +#endif /********************************************************************* * FreeBSD Device Interface Entry Points @@ -205,6 +209,13 @@ MODULE_DEPEND(em, pci, 1, 1, 1); MODULE_DEPEND(em, ether, 1, 1, 1); +#ifdef 1 +/* Set the interrupt throttling rate. Value is calculated + * as ITR = 1/(INTS_PER_SEC * 256ns) */ +#define ITR_VALUE(ips) ((ips) > 0 ? 1000000000 / ((ips) * 256) : 0) +#define MAX_INTS_PER_SEC 8000 +#endif + /********************************************************************* * Tunable default values. *********************************************************************/ @@ -358,6 +369,13 @@ &adapter->tx_abs_int_delay, E1000_REG_OFFSET(&adapter->hw, TADV), em_tx_abs_int_delay_dflt); +#ifdef 1 + SYSCTL_ADD_PROC(&adapter->sysctl_ctx, + SYSCTL_CHILDREN(adapter->sysctl_tree), OID_AUTO, + "int_throttle_ceil", CTLTYPE_INT|CTLFLAG_RW, + adapter, 0, em_sysctl_throttle_ceil, "IU", + "interrupt throttling rate"); +#endif } /* Parameters (to be read from user) */ @@ -403,6 +421,9 @@ */ adapter->hw.report_tx_early = 1; +#ifdef 1 + adapter->throttle_ceil = MAX_INTS_PER_SEC; +#endif if (em_allocate_pci_resources(adapter)) { printf("em%d: Allocation of PCI resources failed\n", @@ -2609,11 +2630,16 @@ E1000_WRITE_REG(&adapter->hw, RADV, adapter->rx_abs_int_delay.value); +#ifdef 1 + E1000_WRITE_REG(&adapter->hw, ITR, + ITR_VALUE(adapter->throttle_ceil)); +#else /* Set the interrupt throttling rate. Value is calculated * as DEFAULT_ITR = 1/(MAX_INTS_PER_SEC * 256ns) */ #define MAX_INTS_PER_SEC 8000 #define DEFAULT_ITR 1000000000/(MAX_INTS_PER_SEC * 256) E1000_WRITE_REG(&adapter->hw, ITR, DEFAULT_ITR); +#endif } /* Setup the Base and Length of the Rx Descriptor Ring */ @@ -3383,4 +3409,28 @@ SYSCTL_CHILDREN(adapter->sysctl_tree), OID_AUTO, name, CTLTYPE_INT|CTLFLAG_RW, info, 0, em_sysctl_int_delay, "I", description); +} + +static int +em_sysctl_throttle_ceil(SYSCTL_HANDLER_ARGS) +{ + struct adapter *adapter; + int error; + u_int32_t ceil; + int s; + + adapter = (struct adapter *)arg1; + ceil = adapter->throttle_ceil; + error = sysctl_handle_int(oidp, &ceil, 0, req); + if (error != 0 || req->newptr == NULL) + return error; + adapter->throttle_ceil = ceil; + + s = splimp(); + + E1000_WRITE_REG(&adapter->hw, ITR, ITR_VALUE(ceil)); + + splx(s); + + return 0; } --- if_em.h-1.25.2.1.orig Fri Nov 19 19:00:03 2004 +++ if_em.h Mon Nov 22 13:29:58 2004 @@ -353,6 +353,9 @@ u_int16_t link_speed; u_int16_t link_duplex; u_int32_t smartspeed; +#ifdef 1 + u_int32_t throttle_ceil; +#endif struct em_int_delay_info tx_int_delay; struct em_int_delay_info tx_abs_int_delay; struct em_int_delay_info rx_int_delay;