From leres@ee.lbl.gov  Wed Jul 31 22:58:53 2002
Return-Path: <leres@ee.lbl.gov>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 936FD37B400
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 31 Jul 2002 22:58:53 -0700 (PDT)
Received: from fun.ee.lbl.gov (fun.ee.lbl.gov [131.243.1.81])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0637243E42
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 31 Jul 2002 22:58:53 -0700 (PDT)
	(envelope-from leres@ee.lbl.gov)
Received: from fun.ee.lbl.gov (localhost [127.0.0.1])
	by fun.ee.lbl.gov (8.12.5/8.12.5) with ESMTP id g715wqf7031654;
	Wed, 31 Jul 2002 22:58:52 -0700 (PDT)
Received: (from leres@localhost)
	by fun.ee.lbl.gov (8.12.5/8.12.5/Submit) id g715wq2C031653;
	Wed, 31 Jul 2002 22:58:52 -0700 (PDT)
Message-Id: <200208010558.g715wq2C031653@fun.ee.lbl.gov>
Date: Wed, 31 Jul 2002 22:58:52 PDT
From: Craig Leres <leres@ee.lbl.gov>
To: FreeBSD-gnats-submit@freebsd.org
Cc: leres@ee.lbl.gov (Craig Leres)
Subject: [PATCH] Minor sk driver enhancements
X-Send-Pr-Version: 3.2

>Number:         41220
>Category:       kern
>Synopsis:       [PATCH] Minor sk driver enhancements
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bz
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 31 23:00:02 PDT 2002
>Closed-Date:    Mon Apr 25 10:24:38 GMT 2005
>Last-Modified:  Mon Apr 25 10:24:38 GMT 2005
>Originator:     Craig Leres
>Release:        FreeBSD 4.4-RELEASE i386
>Organization:
Lawrence Berkeley National Laboratory
>Environment:

>Description:

	It's very useful for packet capture applications to be able
	to increase the interrupt moderation value without recompiling
	the kernel.
	
	SK_JSLOTS should be defined as a function of SK_RX_RING_CNT
	so that increasing SK_RX_RING_CNT automatically allocates
	enough jumbo buffers.

>How-To-Repeat:
>Fix:

	The appended context diffs adds a sysctl variable that
	allows the interrupt moderation value to be changed at run
	time and also changes the SK_JSLOTS define to calculate
	its value based on the number of receive descriptors.

==============================================================================
*** if_sk.c.virgin	Wed Jul 31 22:43:58 2002
--- if_sk.c	Wed Jul 31 22:55:52 2002
***************
*** 76,81 ****
--- 76,82 ----
  #include <sys/kernel.h>
  #include <sys/socket.h>
  #include <sys/queue.h>
+ #include <sys/sysctl.h>
  
  #include <net/if.h>
  #include <net/if_arp.h>
***************
*** 171,176 ****
--- 172,187 ----
  static void sk_setfilt		__P((struct sk_if_softc *, caddr_t, int));
  static void sk_setmulti		__P((struct sk_if_softc *));
  
+ #ifdef LBL
+ /*
+  * sysctl'able interrupt moderation.
+  * You must "ifconfig ... up" after changing this before it takes effect
+  */
+ static int sk_interrupt_mod = 200;
+ SYSCTL_INT(_debug, OID_AUTO, sk_interrupt_mod, CTLFLAG_RW,
+     &sk_interrupt_mod, 0, "");
+ #endif
+ 
  #ifdef SK_USEIOSPACE
  #define SK_RES		SYS_RES_IOPORT
  #define SK_RID		SK_PCI_LOIO
***************
*** 1052,1058 ****
--- 1063,1075 ----
  	 * register represents 18.825ns, so to specify a timeout in
  	 * microseconds, we have to multiply by 54.
  	 */
+ #ifdef LBL
+         printf("skc%d: sk_reset: interrupt moderation is %d us\n",
+             sc->sk_unit, sk_interrupt_mod);
+         sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(sk_interrupt_mod));
+ #else
          sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(200));
+ #endif
          sk_win_write_4(sc, SK_IMMR, SK_ISR_TX1_S_EOF|SK_ISR_TX2_S_EOF|
  	    SK_ISR_RX1_EOF|SK_ISR_RX2_EOF);
          sk_win_write_1(sc, SK_IMTIMERCTL, SK_IMCTL_START);
***************
*** 2114,2119 ****
--- 2131,2143 ----
  
  	/* Configure TX LED */
  	SK_IF_WRITE_1(sc_if, 0, SK_TXLED1_CTL, SK_TXLEDCTL_COUNTER_START);
+ 
+ #ifdef LBL
+ 	/* Set interrupt moderation (in case it was changed via sysctl) */
+ 	printf("%s%d: sk_init: interrupt moderation is %d us\n",
+ 	    ifp->if_name, ifp->if_unit, sk_interrupt_mod);
+ 	sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(sk_interrupt_mod));
+ #endif
  
  	/* Configure I2C registers */
  

*** if_skreg.h.virgin	Wed Jul 31 22:43:40 2002
--- if_skreg.h	Wed Jul 31 22:44:40 2002
***************
*** 1112,1118 ****
   */
  #define SK_JUMBO_FRAMELEN	9018
  #define SK_JUMBO_MTU		(SK_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
! #define SK_JSLOTS		384
  
  #define SK_JRAWLEN (SK_JUMBO_FRAMELEN + ETHER_ALIGN + sizeof(u_int64_t))
  #define SK_JLEN (SK_JRAWLEN + (sizeof(u_int64_t) - \
--- 1112,1118 ----
   */
  #define SK_JUMBO_FRAMELEN	9018
  #define SK_JUMBO_MTU		(SK_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
! #define SK_JSLOTS		((SK_RX_RING_CNT * 3) / 2)
  
  #define SK_JRAWLEN (SK_JUMBO_FRAMELEN + ETHER_ALIGN + sizeof(u_int64_t))
  #define SK_JLEN (SK_JRAWLEN + (sizeof(u_int64_t) - \

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Tue Aug 20 13:30:59 PDT 2002 
Responsible-Changed-Why:  
Refile this under a proper category. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41220 
Responsible-Changed-From-To: freebsd-bugs->bz 
Responsible-Changed-By: ceri 
Responsible-Changed-When: Wed Nov 3 22:04:20 GMT 2004 
Responsible-Changed-Why:  
Over to bz to evaluate - he touched it last. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41220 
State-Changed-From-To: open->patched 
State-Changed-By: bz 
State-Changed-When: Sun Mar 20 12:48:43 GMT 2005 
State-Changed-Why:  
Patch comitted to HEAD with minor modifications for up-to-date HEAD. 
If you can please test. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41220 

From: Craig Leres <leres@ee.lbl.gov>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/41220: [PATCH] Minor sk driver enhancements
Date: Wed, 23 Mar 2005 18:42:40 -0800

 I built a test system using 5.3-RELEASE. The card I used (a Syskonnect
 SK-9844 -- a dual SX) had the "no PHY found!" problem until I applied
 the the dev/mii/mii.c patch found in this bug report:
 
     http://www.freebsd.org/cgi/query-pr.cgi?pr=i386/63313
 
 Once I verified the card worked in a stock configuration, I grabbed
 current versions of if_sk.c (1.102) and if_skreg.h (1.10).
 BUS_PROBE_DEFAULT is missing in 5.3-RELEASE so I changed the
 occurances to 0 and then that version compiled and worked.
 
 As far as I'm concerned you can close this PR (thanks!)
 
 		Craig
 
State-Changed-From-To: patched->closed 
State-Changed-By: bz 
State-Changed-When: Mon Apr 25 10:21:33 GMT 2005 
State-Changed-Why:  
Committed to HEAD with if_sk.c rev. 1.101, if_skreg.h rev. 1.27. 
Manpage updated. 
Thanks for testing. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41220 
>Unformatted:
