Date: Fri, 10 Dec 2004 12:00:21 +0900 From: Shunsuke SHINOMIYA <shino@fornext.org> To: Jeremie Le Hen <jeremie@le-hen.org> Cc: freebsd-stable@freebsd.org Subject: if_em int_throttle_ceil patch Message-ID: <20041210113318.BBF3.SHINO@fornext.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi, Jeremie and Lists.
The previous patch to change if_em's int_throttle_ceil into
sysctl-able cause a kernel panic. If you set em's int_throttle_ceil=0
and then reconfigure the em, it cause a diveded by zero panic.
This patch for original if_em.[ch] which is attached to this mail is
corrected this problem.
--
Shunsuke SHINOMIYA <shino@fornext.org>
[-- Attachment #2 --]
--- 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 <dev/em/if_em.h>
@@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041210113318.BBF3.SHINO>
