svn commit: r228318 - head/lib/libc/sys

2011-12-07 Thread Ruslan Ermilov
Author: ru
Date: Wed Dec  7 11:06:18 2011
New Revision: 228318
URL: http://svn.freebsd.org/changeset/base/228318

Log:
  The NOTE_COPY should have been named NOTE_FFCOPY from the very
  beginning.
  
  Submitted by: Igor Sysoev

Modified:
  head/lib/libc/sys/kqueue.2

Modified: head/lib/libc/sys/kqueue.2
==
--- head/lib/libc/sys/kqueue.2  Wed Dec  7 07:03:14 2011(r228317)
+++ head/lib/libc/sys/kqueue.2  Wed Dec  7 11:06:18 2011(r228318)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 15, 2009
+.Dd December 7, 2011
 .Dt KQUEUE 2
 .Os
 .Sh NAME
@@ -459,7 +459,7 @@ Bitwise AND
 .It Dv NOTE_FFOR
 Bitwise OR
 .Va fflags .
-.It Dv NOTE_COPY
+.It Dv NOTE_FFCOPY
 Copy
 .Va fflags .
 .It Dv NOTE_FFCTRLMASK
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228319 - head/usr.bin/grep

2011-12-07 Thread Gabor Kovesdan
Author: gabor
Date: Wed Dec  7 12:25:28 2011
New Revision: 228319
URL: http://svn.freebsd.org/changeset/base/228319

Log:
  - Match GNU behavior of exit code
  - Rename variable that has a different meaning now
  
  PR:   bin/162930
  Submitted by: Jan Beich 
  MFC after:1 week

Modified:
  head/usr.bin/grep/grep.c
  head/usr.bin/grep/grep.h
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/grep.c
==
--- head/usr.bin/grep/grep.cWed Dec  7 11:06:18 2011(r228318)
+++ head/usr.bin/grep/grep.cWed Dec  7 12:25:28 2011(r228319)
@@ -148,7 +148,7 @@ static inline const char*init_color(con
 boolfirst = true;  /* flag whether we are processing the first match */
 boolprev;  /* flag whether or not the previous line matched */
 int tail;  /* lines left to print */
-boolnotfound;  /* file not found */
+boolfile_err;  /* file reading error */
 
 /*
  * Prints usage information and returns 2.
@@ -728,5 +728,5 @@ main(int argc, char *argv[])
 
/* Find out the correct return value according to the
   results and the command line option. */
-   exit(c ? (notfound ? (qflag ? 0 : 2) : 0) : (notfound ? 2 : 1));
+   exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1));
 }

Modified: head/usr.bin/grep/grep.h
==
--- head/usr.bin/grep/grep.hWed Dec  7 11:06:18 2011(r228318)
+++ head/usr.bin/grep/grep.hWed Dec  7 12:25:28 2011(r228319)
@@ -119,7 +119,7 @@ extern char *label;
 extern const char *color;
 extern int  binbehave, devbehave, dirbehave, filebehave, grepbehave, 
linkbehave;
 
-extern bool first, matchall, notfound, prev;
+extern bool file_err, first, matchall, prev;
 extern int  tail;
 extern unsigned int dpatterns, fpatterns, patterns;
 extern struct pat *pattern;

Modified: head/usr.bin/grep/util.c
==
--- head/usr.bin/grep/util.cWed Dec  7 11:06:18 2011(r228318)
+++ head/usr.bin/grep/util.cWed Dec  7 12:25:28 2011(r228319)
@@ -130,7 +130,7 @@ grep_tree(char **argv)
case FTS_DNR:
/* FALLTHROUGH */
case FTS_ERR:
-   notfound = true;
+   file_err = true;
if(!sflag)
warnx("%s: %s", p->fts_path, 
strerror(p->fts_errno));
break;
@@ -195,10 +195,9 @@ procfile(const char *fn)
f = grep_open(fn);
}
if (f == NULL) {
+   file_err = true;
if (!sflag)
warn("%s", fn);
-   if (errno == ENOENT)
-   notfound = true;
return (0);
}
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228321 - head/sys/netinet6

2011-12-07 Thread Gleb Smirnoff
Author: glebius
Date: Wed Dec  7 13:37:42 2011
New Revision: 228321
URL: http://svn.freebsd.org/changeset/base/228321

Log:
  Fix double free.
  
  PR:   kern/163089
  Submitted by: Herbie Robinson 

Modified:
  head/sys/netinet6/mld6.c

Modified: head/sys/netinet6/mld6.c
==
--- head/sys/netinet6/mld6.cWed Dec  7 12:48:11 2011(r228320)
+++ head/sys/netinet6/mld6.cWed Dec  7 13:37:42 2011(r228321)
@@ -3090,7 +3090,6 @@ mld_dispatch_packet(struct mbuf *m)
m0 = mld_v2_encap_report(ifp, m);
if (m0 == NULL) {
CTR2(KTR_MLD, "%s: dropped %p", __func__, m);
-   m_freem(m);
IP6STAT_INC(ip6s_odropped);
goto out;
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228322 - in head: include lib/libc/stdlib sys/sys

2011-12-07 Thread David Chisnall
Author: theraven
Date: Wed Dec  7 15:25:48 2011
New Revision: 228322
URL: http://svn.freebsd.org/changeset/base/228322

Log:
  Implement quick_exit() / at_quick_exit() from C++11 / C1x.  Also add a
  __noreturn macro and modify the other exiting functions to use it.
  
  The __noreturn macro, unlike __dead2, must be used BEFORE the function.
  This is in line with the C and C++ specifications that place _Noreturn (c1x)
  and [[noreturn]] (C++11) in front of the functions.  As with __dead2, this
  macro falls back to using the GCC attribute.
  
  Unfortunately, clang currently sets the same value for the C version macro
  in C99 and C1x modes, so these functions are hidden by default.  At some
  point before 10.0, I need to go through the headers and clean up the C1x /
  C++11 visibility.
  
  Reviewed by:  brooks (mentor)

Added:
  head/lib/libc/stdlib/at_quick_exit.3   (contents, props changed)
  head/lib/libc/stdlib/quick_exit.3   (contents, props changed)
  head/lib/libc/stdlib/quick_exit.c   (contents, props changed)
Modified:
  head/include/stdlib.h
  head/lib/libc/stdlib/Makefile.inc
  head/lib/libc/stdlib/Symbol.map
  head/lib/libc/stdlib/atexit.3
  head/lib/libc/stdlib/exit.3
  head/sys/sys/cdefs.h

Modified: head/include/stdlib.h
==
--- head/include/stdlib.h   Wed Dec  7 13:37:42 2011(r228321)
+++ head/include/stdlib.h   Wed Dec  7 15:25:48 2011(r228322)
@@ -76,7 +76,7 @@ extern int __mb_cur_max;
 extern int ___mb_cur_max(void);
 #defineMB_CUR_MAX  (___mb_cur_max())
 
-voidabort(void) __dead2;
+__noreturn void abort(void);
 int abs(int) __pure2;
 int atexit(void (*)(void));
 double  atof(const char *);
@@ -86,7 +86,7 @@ void  *bsearch(const void *, const void *
size_t, int (*)(const void *, const void *));
 void   *calloc(size_t, size_t) __malloc_like;
 div_t   div(int, int) __pure2;
-voidexit(int) __dead2;
+__noreturn void exit(int);
 voidfree(void *);
 char   *getenv(const char *);
 longlabs(long) __pure2;
@@ -145,10 +145,18 @@ unsigned long long
 strtoull(const char * __restrict, char ** __restrict, int);
 #endif /* __LONG_LONG_SUPPORTED */
 
-void_Exit(int) __dead2;
+__noreturn void _Exit(int);
 #endif /* __ISO_C_VISIBLE >= 1999 */
 
 /*
+ * If we're in a mode greater than C99, expose C1x functions.
+ */
+#if __ISO_C_VISIBLE > 1999
+__noreturn void quick_exit(int)
+int
+at_quick_exit(void (*func)(void));
+#endif /* __ISO_C_VISIBLE > 1999 */
+/*
  * Extensions made by POSIX relative to C.  We don't know yet which edition
  * of POSIX made these extensions, so assume they've always been there until
  * research can be done.

Modified: head/lib/libc/stdlib/Makefile.inc
==
--- head/lib/libc/stdlib/Makefile.inc   Wed Dec  7 13:37:42 2011
(r228321)
+++ head/lib/libc/stdlib/Makefile.inc   Wed Dec  7 15:25:48 2011
(r228322)
@@ -8,8 +8,8 @@ MISRCS+=_Exit.c a64l.c abort.c abs.c ate
bsearch.c div.c exit.c getenv.c getopt.c getopt_long.c \
getsubopt.c hcreate.c heapsort.c imaxabs.c imaxdiv.c \
insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c malloc.c \
-   merge.c ptsname.c qsort.c qsort_r.c radixsort.c rand.c random.c \
-   reallocf.c realpath.c remque.c strfmon.c strtoimax.c \
+   merge.c ptsname.c qsort.c qsort_r.c quick_exit.c radixsort.c rand.c \
+   random.c reallocf.c realpath.c remque.c strfmon.c strtoimax.c \
strtol.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
 strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c
 
@@ -18,10 +18,12 @@ SYM_MAPS+= ${.CURDIR}/stdlib/Symbol.map
 # machine-dependent stdlib sources
 .sinclude "${.CURDIR}/${LIBC_ARCH}/stdlib/Makefile.inc"
 
-MAN+=  a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 bsearch.3 \
+MAN+=  a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 \
+   at_quick_exit.3 bsearch.3 \
div.3 exit.3 getenv.3 getopt.3 getopt_long.3 getsubopt.3 \
hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 llabs.3 lldiv.3 \
lsearch.3 malloc.3 memory.3 posix_memalign.3 ptsname.3 qsort.3 \
+   quick_exit.3 \
radixsort.3 rand.3 random.3 \
realpath.3 strfmon.3 strtod.3 strtol.3 strtonum.3 strtoul.3 system.3 \
tsearch.3

Modified: head/lib/libc/stdlib/Symbol.map
==
--- head/lib/libc/stdlib/Symbol.map Wed Dec  7 13:37:42 2011
(r228321)
+++ head/lib/libc/stdlib/Symbol.map Wed Dec  7 15:25:48 2011
(r228322)
@@ -97,6 +97,8 @@ FBSD_1.3 {
atoi_l;
atol_l;
atoll_l;
+   at_quick_exit;
+   quick_exit;
strtod_l;
strtol_l;
strtoll_l;

Added: head/lib/libc/stdlib/at_quick_exit.3
==

Re: svn commit: r228322 - in head: include lib/libc/stdlib sys/sys

2011-12-07 Thread Kostik Belousov
On Wed, Dec 07, 2011 at 03:25:48PM +, David Chisnall wrote:
> Author: theraven
> Date: Wed Dec  7 15:25:48 2011
> New Revision: 228322
> URL: http://svn.freebsd.org/changeset/base/228322
> 
> Log:
>   Implement quick_exit() / at_quick_exit() from C++11 / C1x.  Also add a
>   __noreturn macro and modify the other exiting functions to use it.
>   
>   The __noreturn macro, unlike __dead2, must be used BEFORE the function.
>   This is in line with the C and C++ specifications that place _Noreturn (c1x)
>   and [[noreturn]] (C++11) in front of the functions.  As with __dead2, this
>   macro falls back to using the GCC attribute.
>   
>   Unfortunately, clang currently sets the same value for the C version macro
>   in C99 and C1x modes, so these functions are hidden by default.  At some
>   point before 10.0, I need to go through the headers and clean up the C1x /
>   C++11 visibility.
>   
>   Reviewed by:brooks (mentor)
And, was it approved ?

> +#include 
> +#include 
> +
> +/**
> + * Linked list of quick exit handlers.  This is simpler than the atexit()
> + * version, because it is not required to support C++ destructors or
> + * DSO-specific cleanups.
> + */
> +struct quick_exit_handler {
> + struct quick_exit_handler *next;
> + void (*cleanup)(void);
> +};
> +
> +__attribute((weak))
> +void _ZSt9terminatev(void);
Why do you need this ?
You are not calling terminate() anyway, and added an explicit comment.

> +
> +/**
> + * Lock protecting the handlers list.
> + */
> +static pthread_mutex_t atexit_mutex = PTHREAD_MUTEX_INITIALIZER;
> +/**
> + * Stack of cleanup handlers.  These will be invoked in reverse order when 
> + */
> +static struct quick_exit_handler *handlers;
> +
> +int
> +at_quick_exit(void (*func)(void))
> +{
> + struct quick_exit_handler *h = malloc(sizeof(struct 
> quick_exit_handler));
You are making initialization at the declaration place, which is
not recommended by style.

> +
> + if (0 == h) {
Why 0 and not NULL ?  Later, you use NULL. The {} are not needed.

> + return 1;
This shall be return (1);

> + }
> + h->cleanup = func;
> + pthread_mutex_lock(&atexit_mutex);
Note that libc code is careful to only call pthread mutex functions
if __isthreaded variable is set.

Also note that libc uses mangled names to allow the application interposition
of the functions. E.g. ANSI C code is allowed to have pthread_mutex_lock()
function defined.

> + h->next = handlers;
> + handlers = h;
> + pthread_mutex_unlock(&atexit_mutex);
> + return 0;
And this shall be return (0);
> +}
> +
> +void quick_exit(int status)
The function name shall start at the column 0.
> +{
> + /*
> +  * XXX: The C++ spec requires us to call std::terminate if there is an
> +  * exception here.
> +  */
> + for (struct quick_exit_handler *h = handlers ; NULL != h ; h = h->next)
This fragment violates so many style requirements that I probably fail
to enumerate them all.

The h declaration shall go at the start of function, and not at the for
statement.

The opening '{' shall be placed on the line of 'for'. More, the {} bracing
is not needed there.

No space is needed before ';', three times.

> + {
> + h->cleanup();
> + }
> + _Exit(status);
> +}


pgp3MVIV7Qt7q.pgp
Description: PGP signature


Re: svn commit: r228322 - in head: include lib/libc/stdlib sys/sys

2011-12-07 Thread Stefan Farfeleder
On Wed, Dec 07, 2011 at 03:25:48PM +, David Chisnall wrote:
>  
>  /*
> + * If we're in a mode greater than C99, expose C1x functions.
> + */
> +#if __ISO_C_VISIBLE > 1999
> +__noreturn void quick_exit(int)
> +int
> +at_quick_exit(void (*func)(void));
> +#endif /* __ISO_C_VISIBLE > 1999 */
> +/*
>   * Extensions made by POSIX relative to C.  We don't know yet which edition

Shouldn't it be visible in the default mode too (__BSD_VISIBLE)?
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228323 - head/lib/libc/stdlib

2011-12-07 Thread David Chisnall
Author: theraven
Date: Wed Dec  7 16:12:54 2011
New Revision: 228323
URL: http://svn.freebsd.org/changeset/base/228323

Log:
  style(9) cleanups.
  
  Approved by:  brooks (mentor)

Modified:
  head/lib/libc/stdlib/quick_exit.c

Modified: head/lib/libc/stdlib/quick_exit.c
==
--- head/lib/libc/stdlib/quick_exit.c   Wed Dec  7 15:25:48 2011
(r228322)
+++ head/lib/libc/stdlib/quick_exit.c   Wed Dec  7 16:12:54 2011
(r228323)
@@ -39,9 +39,6 @@ struct quick_exit_handler {
void (*cleanup)(void);
 };
 
-__attribute((weak))
-void _ZSt9terminatev(void);
-
 /**
  * Lock protecting the handlers list.
  */
@@ -56,26 +53,26 @@ at_quick_exit(void (*func)(void))
 {
struct quick_exit_handler *h = malloc(sizeof(struct 
quick_exit_handler));
 
-   if (0 == h) {
+   if (NULL == h)
return 1;
-   }
h->cleanup = func;
pthread_mutex_lock(&atexit_mutex);
h->next = handlers;
handlers = h;
pthread_mutex_unlock(&atexit_mutex);
-   return 0;
+   return (0);
 }
 
-void quick_exit(int status)
+void
+quick_exit(int status)
 {
+   struct quick_exit_handler *h;
+
/*
 * XXX: The C++ spec requires us to call std::terminate if there is an
 * exception here.
 */
-   for (struct quick_exit_handler *h = handlers ; NULL != h ; h = h->next)
-   {
+   for (h = handlers; NULL != h; h = h->next)
h->cleanup();
-   }
_Exit(status);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228324 - head/sys/kern

2011-12-07 Thread Alan Cox
Author: alc
Date: Wed Dec  7 16:27:23 2011
New Revision: 228324
URL: http://svn.freebsd.org/changeset/base/228324

Log:
  Eliminate stale numbers from a comment.

Modified:
  head/sys/kern/kern_malloc.c

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Wed Dec  7 16:12:54 2011(r228323)
+++ head/sys/kern/kern_malloc.c Wed Dec  7 16:27:23 2011(r228324)
@@ -698,12 +698,9 @@ kmeminit(void *dummy)
 
/*
 * Try to auto-tune the kernel memory size, so that it is
-* more applicable for a wider range of machine sizes.
-* On an X86, a VM_KMEM_SIZE_SCALE value of 4 is good, while
-* a VM_KMEM_SIZE of 12MB is a fair compromise.  The
+* more applicable for a wider range of machine sizes.  The
 * VM_KMEM_SIZE_MAX is dependent on the maximum KVA space
-* available, and on an X86 with a total KVA space of 256MB,
-* try to keep VM_KMEM_SIZE_MAX at 80MB or below.
+* available.
 *
 * Note that the kmem_map is also used by the zone allocator,
 * so make sure that there is enough space.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r228322 - in head: include lib/libc/stdlib sys/sys

2011-12-07 Thread Bruce Evans

On Wed, 7 Dec 2011, Kostik Belousov wrote:


On Wed, Dec 07, 2011 at 03:25:48PM +, David Chisnall wrote:

Log:
  Implement quick_exit() / at_quick_exit() from C++11 / C1x.  Also add a
  __noreturn macro and modify the other exiting functions to use it.
...
+struct quick_exit_handler {
+   struct quick_exit_handler *next;
+   void (*cleanup)(void);
+};
+
+__attribute((weak))
+void _ZSt9terminatev(void);



...



+{
+   /*
+* XXX: The C++ spec requires us to call std::terminate if there is an
+* exception here.
+*/
+   for (struct quick_exit_handler *h = handlers ; NULL != h ; h = h->next)

This fragment violates so many style requirements that I probably fail
to enumerate them all.
...


:-).  And you didn't point the style violations in the __attribute(())
declaration above.  These include
- a hard-coded gccism
- formatting of part of the declaration on a separate line
- spelling __attribute__(()) unusually.

I'm not sure what the weak attribute does by itself.  
only defines __weak_reference() and does it less unportably without
using __attribute__().


The h declaration shall go at the start of function, and not at the for
statement.


The style rules may be different for C++.  It is hard to know what they
are since we don't have any.  This declaration wouldn't even compile in
C90, and style(9) barely supports that since it is based on K&R C.  The
declaration compiles in C99, but unnecessary use of C99 features is a
style bug (because style(9) gives no examples of it).


...


Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r228323 - head/lib/libc/stdlib

2011-12-07 Thread Bruce Evans

On Wed, 7 Dec 2011, David Chisnall wrote:


Log:
 style(9) cleanups.


Thanks, but many style bugs are still visible.


Modified: head/lib/libc/stdlib/quick_exit.c
==
--- head/lib/libc/stdlib/quick_exit.c   Wed Dec  7 15:25:48 2011
(r228322)
+++ head/lib/libc/stdlib/quick_exit.c   Wed Dec  7 16:12:54 2011
(r228323)
...
@@ -56,26 +53,26 @@ at_quick_exit(void (*func)(void))
{
struct quick_exit_handler *h = malloc(sizeof(struct 
quick_exit_handler));


This still has:
- initialization in declaration
- line too long
- sizeof(typename) instead of sizeof(var).  Maybe this is only a style bug
  for me, but for long typename's the verboseness given by sizeof(typename)
  helps implement the previous bug.



-   if (0 == h) {
+   if (NULL == h)


(h == NULL) would be normal.


return 1;


This return is still missing parentheses.


-   }
h->cleanup = func;
pthread_mutex_lock(&atexit_mutex);
h->next = handlers;
handlers = h;
pthread_mutex_unlock(&atexit_mutex);
-   return 0;
+   return (0);


The one is fixed, so now the style for returns in this file is internally
inconsistent.

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228325 - head/sys/dev/et

2011-12-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Dec  7 18:17:09 2011
New Revision: 228325
URL: http://svn.freebsd.org/changeset/base/228325

Log:
  Overhaul bus_dma(9) usage in et(4) and clean up TX/RX path.  This
  change should make et(4) work on any architectures.
   o Remove m_getl inline function and replace it with stanard mbuf
 interfaces.  Previous code tried to minimize code duplication
 but this came from incorrect use of common DMA tag.
 Driver may be still use a common RX allocation handler with
 additional structure changes but I don't see much point to do
 that it would make it hard to understand the code.
   o Remove DragonflyBSD specific constant EVL_ENCAPLEN, use
 ETHER_VLAN_ENCAP_LEN instead.
   o Add bunch of new RX status definition.  It seems controller
 supports RX checksum offloading but I was not able to make the
 feature work yet.  Currently driver checks whether recevied
 frame is good one or not.
   o Avoid a typedef ending in '_t' as style(9) says.
   o Controller has no restriction on DMA address space, so there
 is no reason to limit the DMA address to 32bit.  Descriptor
 rings,  status blocks and TX/RX buffers now use full 64bit DMA
 addressing.
   o Allocate DMA memory shared between host and controller as
 coherent.
   o Create 3 separate DMA tags to be used as TX, mini RX ring and
 stanard RX ring.  Previously it created a single DMA tag and it
 was used to all three rings.
   o et(4) does not support jumbo frame at this moment and I still
 don't quite understand how jumbo frame works on this controller
 so use two RX rings to handle small sized frame and normal sized
 frame respectively.  The mini RX ring will be used to receive
 frames that are less than or equal to 127 bytes.  The second RX
 ring is used to receive frames that are not handled by the first
 RX ring.
 If jumbo frame support is implemented, driver may have to choose
 better RX scheme by letting the second RX ring handle jumbo
 frames.  This scheme will mimic Broadcom's efficient jumbo frame
 handling feature.  However RAM buffer size(16KB) of the
 controller is too small to hold 2 jumbo frames, if 9KB
 jumbo frame is used, I'm not sure how good performance would it
 have.
   o In et_rxeof(), make sure to check whether controller received
 good frame or not.  Passing corrupted frame to upper layer is
 bad idea.
   o If driver receives a bad frame or driver fails to allocate RX
 buffer due to resource shortage condition, reuse previously
 loaded DMA map for RX buffer instead of unloading/loading RX
 buffer again.
   o et_init_tx_ring() never fails so change return type to void.
   o In watchdog handler, show TX DMA write back status of errored
 frame which could be used as a clue to debug watchdog timeout.
   o Add missing bus_dmamap_sync() in various places such that et(4)
 should work with bounce buffers(e.g. PAE).
   o TX side bus_dmamap_load_mbuf_sg(9) support.
   o RX side bus_dmamap_load_mbuf_sg(9) support.
   o Controller has no DMA alignment limit in RX buffer so use
 m_adj(9) in RX buffer allocation to make IP header align on 2
 bytes boundary.  Otherwise it would trigger unaligned access
 error in upper layer on strict alignment architectures.
 One of down side of controller is it provides limited set of RX
 buffer length like most Intel controllers.  This is not problem
 at this moment because driver does not support jumbo frame yet
 but it may require alignment fixup code to support jumbo frame
 on strict alignment architectures.
   o In et_txeof(), don't zero TX descriptors for transmitted frames.
 TX descriptors don't need write access after transmission.
 Driver sets IFF_DRV_OACTIVE when the number of available TX
 descriptors are less than or equal to ET_NSEG_SPARE.  Make sure
 to clear IFF_DRV_OACTIVE only when the number of available TX
 descriptor is greater than ET_NSEG_SPARE.

Modified:
  head/sys/dev/et/if_et.c
  head/sys/dev/et/if_etvar.h

Modified: head/sys/dev/et/if_et.c
==
--- head/sys/dev/et/if_et.c Wed Dec  7 16:27:23 2011(r228324)
+++ head/sys/dev/et/if_et.c Wed Dec  7 18:17:09 2011(r228325)
@@ -99,7 +99,7 @@ static void   et_init(void *);
 static int et_ioctl(struct ifnet *, u_long, caddr_t);
 static voidet_start_locked(struct ifnet *);
 static voidet_start(struct ifnet *);
-static voidet_watchdog(struct et_softc *);
+static int et_watchdog(struct et_softc *);
 static int et_ifmedia_upd_locked(struct ifnet *);
 static int et_ifmedia_upd(struct ifnet *);
 static voidet_ifmedia_sts(struct ifnet *, struct ifmediareq *);
@@ -114,24 +114,22 @@ static void   et_disable_intrs(struct et_s
 static voidet_rxeof(struct et_softc *);
 static voidet_txeof(struct et_softc *);
 
-static

svn commit: r228326 - head/sys/dev/et

2011-12-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Dec  7 19:08:54 2011
New Revision: 228326
URL: http://svn.freebsd.org/changeset/base/228326

Log:
  Controller does not require TX start command for every frame.  So
  send a single TX command after setting up all TX frames.  This
  removes unnecessary register accesses and bus_dmamap_sync(9) calls.
  et(4) uses TX interrupt moderation so it's possible to have TX
  buffers that were already transmitted but waiting for TX completion
  interrupt.  If the number of available TX descriptor is less then
  1/3 of total TX descriptor, try reclaiming first to get enough free
  TX descriptors before setting up TX descriptors.
  After r228325, et_txeof() no longer tries to send frames after
  reclaiming TX buffers.  That change was made to give more chance
  to transmit frames in main interrupt handler since we can still
  send frames in interrupt handler with RX interrupt.  So right
  before exiting interrupt hander, after enabling interrupt, try to
  send more frames.  This gives slightly better performance numbers.
  
  While I'm here reduce number of spare TX descriptors from 8 to 4.
  Controller does not require reserved TX descriptors, it was just to
  reduce TX overhead.  After r228325, driver has much lower TX
  overhead so it does not make sense to reserve 8 TX descriptors.

Modified:
  head/sys/dev/et/if_et.c
  head/sys/dev/et/if_etvar.h

Modified: head/sys/dev/et/if_et.c
==
--- head/sys/dev/et/if_et.c Wed Dec  7 18:17:09 2011(r228325)
+++ head/sys/dev/et/if_et.c Wed Dec  7 19:08:54 2011(r228326)
@@ -1097,7 +1097,11 @@ et_intr(void *xsc)
if (intrs & ET_INTR_TIMER)
CSR_WRITE_4(sc, ET_TIMER, sc->sc_timer);
 back:
-   et_enable_intrs(sc, ET_INTRS);
+   if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+   et_enable_intrs(sc, ET_INTRS);
+   if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+   et_start_locked(ifp);
+   }
ET_UNLOCK(sc);
 }
 
@@ -1240,7 +1244,9 @@ et_start_locked(struct ifnet *ifp)
 {
struct et_softc *sc;
struct mbuf *m_head = NULL;
+   struct et_txdesc_ring *tx_ring;
struct et_txbuf_data *tbd;
+   uint32_t tx_ready_pos;
int enq;
 
sc = ifp->if_softc;
@@ -1252,7 +1258,18 @@ et_start_locked(struct ifnet *ifp)
if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != 
IFF_DRV_RUNNING)
return;
 
+   /*
+* Driver does not request TX completion interrupt for every
+* queued frames to prevent generating excessive interrupts.
+* This means driver may wait for TX completion interrupt even
+* though some frames were sucessfully transmitted.  Reclaiming
+* transmitted frames will ensure driver see all available
+* descriptors.
+*/
tbd = &sc->sc_tx_data;
+   if (tbd->tbd_used > (ET_TX_NDESC * 2) / 3)
+   et_txeof(sc);
+
for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) {
if (tbd->tbd_used + ET_NSEG_SPARE >= ET_TX_NDESC) {
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
@@ -1277,8 +1294,17 @@ et_start_locked(struct ifnet *ifp)
ETHER_BPF_MTAP(ifp, m_head);
}
 
-   if (enq > 0)
+   if (enq > 0) {
+   tx_ring = &sc->sc_tx_ring;
+   bus_dmamap_sync(tx_ring->tr_dtag, tx_ring->tr_dmap,
+   BUS_DMASYNC_PREWRITE);
+   tx_ready_pos = tx_ring->tr_ready_index &
+   ET_TX_READY_POS_INDEX_MASK;
+   if (tx_ring->tr_ready_wrap)
+   tx_ready_pos |= ET_TX_READY_POS_WRAP;
+   CSR_WRITE_4(sc, ET_TX_READY_POS, tx_ready_pos);
sc->watchdog_timer = 5;
+   }
 }
 
 static void
@@ -2036,7 +2062,7 @@ et_encap(struct et_softc *sc, struct mbu
struct mbuf *m;
bus_dma_segment_t segs[ET_NSEG_MAX];
bus_dmamap_t map;
-   uint32_t csum_flags, last_td_ctrl2, tx_ready_pos;
+   uint32_t csum_flags, last_td_ctrl2;
int error, i, idx, first_idx, last_idx, nsegs;
 
tx_ring = &sc->sc_tx_ring;
@@ -2121,12 +2147,6 @@ et_encap(struct et_softc *sc, struct mbu
tbd->tbd_used += nsegs;
MPASS(tbd->tbd_used <= ET_TX_NDESC);
 
-   bus_dmamap_sync(tx_ring->tr_dtag, tx_ring->tr_dmap,
-   BUS_DMASYNC_PREWRITE);
-   tx_ready_pos = tx_ring->tr_ready_index & ET_TX_READY_POS_INDEX_MASK;
-   if (tx_ring->tr_ready_wrap)
-   tx_ready_pos |= ET_TX_READY_POS_WRAP;
-   CSR_WRITE_4(sc, ET_TX_READY_POS, tx_ready_pos);
return (0);
 }
 

Modified: head/sys/dev/et/if_etvar.h
==
--- head/sys/dev/et/if_etvar.h  Wed Dec  7 18:17:09 2011(r228325)
+++ head/sys/dev/et/if_etvar.h  Wed Dec  7 19:08:54 2011(r228326)
@@ -41,7 +41,7 @@
 #define

Re: svn commit: r228322 - in head: include lib/libc/stdlib sys/sys

2011-12-07 Thread David Schultz
On Wed, Dec 07, 2011, David Chisnall wrote:
> Author: theraven
> Date: Wed Dec  7 15:25:48 2011
> New Revision: 228322
> URL: http://svn.freebsd.org/changeset/base/228322
> 
> Log:
>   Implement quick_exit() / at_quick_exit() from C++11 / C1x.  Also add a
>   __noreturn macro and modify the other exiting functions to use it.
>   
>   The __noreturn macro, unlike __dead2, must be used BEFORE the function.
>   This is in line with the C and C++ specifications that place _Noreturn (c1x)
>   and [[noreturn]] (C++11) in front of the functions.  As with __dead2, this
>   macro falls back to using the GCC attribute.
>   
>   Unfortunately, clang currently sets the same value for the C version macro
>   in C99 and C1x modes, so these functions are hidden by default.  At some
>   point before 10.0, I need to go through the headers and clean up the C1x /
>   C++11 visibility.

Nice.

Why not use the standard spelling, '_Noreturn'?  In pre-C1X modes,
_Noreturn is a reserved identifier since it starts with an underscore
and capital letter, so it's not considered namespace pollution.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228327 - head/sys/dev/et

2011-12-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Dec  7 19:43:04 2011
New Revision: 228327
URL: http://svn.freebsd.org/changeset/base/228327

Log:
  Remove et_enable_intrs(), et_disable_intrs() functions and
  manipulation of interrupt register access is done through
  CSR_WRITE_4 macro.  Also add disabling interrupt into et_reset()
  because we want interrupt disabled state after controller reset.
  While I'm here slightly change interrupt handler to be more
  readable one.

Modified:
  head/sys/dev/et/if_et.c

Modified: head/sys/dev/et/if_et.c
==
--- head/sys/dev/et/if_et.c Wed Dec  7 19:08:54 2011(r228326)
+++ head/sys/dev/et/if_et.c Wed Dec  7 19:43:04 2011(r228327)
@@ -109,8 +109,6 @@ static int  et_sysctl_rx_intr_npkts(SYSCT
 static int et_sysctl_rx_intr_delay(SYSCTL_HANDLER_ARGS);
 
 static voidet_intr(void *);
-static voidet_enable_intrs(struct et_softc *, uint32_t);
-static voidet_disable_intrs(struct et_softc *);
 static voidet_rxeof(struct et_softc *);
 static voidet_txeof(struct et_softc *);
 
@@ -309,8 +307,6 @@ et_attach(device_t dev)
 
et_reset(sc);
 
-   et_disable_intrs(sc);
-
error = et_dma_alloc(sc);
if (error)
goto fail;
@@ -540,12 +536,12 @@ et_stop(struct et_softc *sc)
ET_LOCK_ASSERT(sc);
 
callout_stop(&sc->sc_tick);
+   /* Disable interrupts. */
+   CSR_WRITE_4(sc, ET_INTR_MASK, 0x);
 
et_stop_rxdma(sc);
et_stop_txdma(sc);
 
-   et_disable_intrs(sc);
-
et_free_tx_ring(sc);
et_free_rx_ring(sc);
 
@@ -670,20 +666,10 @@ et_reset(struct et_softc *sc)
ET_MAC_CFG1_RST_TXFUNC | ET_MAC_CFG1_RST_RXFUNC |
ET_MAC_CFG1_RST_TXMC | ET_MAC_CFG1_RST_RXMC);
CSR_WRITE_4(sc, ET_MAC_CFG1, 0);
-}
-
-static void
-et_disable_intrs(struct et_softc *sc)
-{
+   /* Disable interrupts. */
CSR_WRITE_4(sc, ET_INTR_MASK, 0x);
 }
 
-static void
-et_enable_intrs(struct et_softc *sc, uint32_t intrs)
-{
-   CSR_WRITE_4(sc, ET_INTR_MASK, ~intrs);
-}
-
 struct et_dmamap_arg {
bus_addr_t  et_busaddr;
 };
@@ -1083,12 +1069,12 @@ et_intr(void *xsc)
return;
}
 
-   et_disable_intrs(sc);
+   /* Disable further interrupts. */
+   CSR_WRITE_4(sc, ET_INTR_MASK, 0x);
 
intrs = CSR_READ_4(sc, ET_INTR_STATUS);
-   intrs &= ET_INTRS;
-   if (intrs == 0) /* Not interested */
-   goto back;
+   if ((intrs & ET_INTRS) == 0)
+   goto done;
 
if (intrs & ET_INTR_RXEOF)
et_rxeof(sc);
@@ -1096,9 +1082,9 @@ et_intr(void *xsc)
et_txeof(sc);
if (intrs & ET_INTR_TIMER)
CSR_WRITE_4(sc, ET_TIMER, sc->sc_timer);
-back:
+done:
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-   et_enable_intrs(sc, ET_INTRS);
+   CSR_WRITE_4(sc, ET_INTR_MASK, ~ET_INTRS);
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
et_start_locked(ifp);
}
@@ -1132,7 +1118,8 @@ et_init_locked(struct et_softc *sc)
if (error)
goto back;
 
-   et_enable_intrs(sc, ET_INTRS);
+   /* Enable interrupts. */
+   CSR_WRITE_4(sc, ET_INTR_MASK, ~ET_INTRS);
 
callout_reset(&sc->sc_tick, hz, et_tick, sc);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228328 - head/contrib/libstdc++/include/debug

2011-12-07 Thread Dimitry Andric
Author: dim
Date: Wed Dec  7 21:00:33 2011
New Revision: 228328
URL: http://svn.freebsd.org/changeset/base/228328

Log:
  Make it possible to use the debug versions of std::map and std::multimap
  with clang, by removing two unneeded using declarations.  Otherwise, you
  would get errors similar to:
  
  /usr/include/c++/4.2/debug/map.h:77:20: error: dependent using declaration 
resolved to type without 'typename'
using _Base::value_compare;
 ^
  
  N.B.: Take care when you actually use the debug versions of any
  libstdc++ header.  They are more likely to contain problems, because
  they are exercised far less often, and since the standard library
  complexity guarantees don't always apply anymore, compile times can
  drastically increase.
  
  MFC after:2 weeks

Modified:
  head/contrib/libstdc++/include/debug/map.h
  head/contrib/libstdc++/include/debug/multimap.h

Modified: head/contrib/libstdc++/include/debug/map.h
==
--- head/contrib/libstdc++/include/debug/map.h  Wed Dec  7 19:43:04 2011
(r228327)
+++ head/contrib/libstdc++/include/debug/map.h  Wed Dec  7 21:00:33 2011
(r228328)
@@ -74,8 +74,6 @@ namespace __debug
   typedef std::reverse_iterator   reverse_iterator;
   typedef std::reverse_iterator const_reverse_iterator;
 
-  using _Base::value_compare;
-
   // 23.3.1.1 construct/copy/destroy:
   explicit map(const _Compare& __comp = _Compare(),
   const _Allocator& __a = _Allocator())

Modified: head/contrib/libstdc++/include/debug/multimap.h
==
--- head/contrib/libstdc++/include/debug/multimap.h Wed Dec  7 19:43:04 
2011(r228327)
+++ head/contrib/libstdc++/include/debug/multimap.h Wed Dec  7 21:00:33 
2011(r228328)
@@ -74,8 +74,6 @@ namespace __debug
   typedef std::reverse_iteratorreverse_iterator;
   typedef std::reverse_iterator  const_reverse_iterator;
 
-  using _Base::value_compare;
-
   // 23.3.1.1 construct/copy/destroy:
   explicit multimap(const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228329 - head/lib/libc/stdlib

2011-12-07 Thread David Chisnall
Author: theraven
Date: Wed Dec  7 21:02:35 2011
New Revision: 228329
URL: http://svn.freebsd.org/changeset/base/228329

Log:
  Some fixes to the man pages for [at_]quick_exit(3)
  
  Reviewed by:pluknet
  Approved by:dim (mentor)

Modified:
  head/lib/libc/stdlib/at_quick_exit.3
  head/lib/libc/stdlib/quick_exit.3

Modified: head/lib/libc/stdlib/at_quick_exit.3
==
--- head/lib/libc/stdlib/at_quick_exit.3Wed Dec  7 21:00:33 2011
(r228328)
+++ head/lib/libc/stdlib/at_quick_exit.3Wed Dec  7 21:02:35 2011
(r228329)
@@ -23,13 +23,13 @@
 .\"  SUCH DAMAGE.
 .\" 
 .\"  $FreeBSD$
-.\" /
-.Dd December 7, 2011o.Dt ATEXIT 3
+.\"
+.Dd December 7, 2011
 .Dt AT_QUICK_EXIT 3
 .Os
 .Sh NAME
 .Nm at_quick_exit
-.Nd Registers a cleanup function to run on quick exit.
+.Nd registers a cleanup function to run on quick exit
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
@@ -48,10 +48,13 @@ the program exits by calling 
 .Xr _Exit 3 ,
 or
 .Xr abort 3 .
-.El
+.Sh RETURN VALUES
+The 
+.Fn at_quick_exit
+function returns the value 0 if successful and a non-zero value on failure.
 .Sh SEE ALSO
 .Xr exit 3 ,
-.Xr at_quick_exit 3
+.Xr quick_exit 3
 .Sh STANDARDS
 The
 .Fn at_quick_exit

Modified: head/lib/libc/stdlib/quick_exit.3
==
--- head/lib/libc/stdlib/quick_exit.3   Wed Dec  7 21:00:33 2011
(r228328)
+++ head/lib/libc/stdlib/quick_exit.3   Wed Dec  7 21:02:35 2011
(r228329)
@@ -23,13 +23,13 @@
 .\"  SUCH DAMAGE.
 .\" 
 .\"  $FreeBSD$
-.\" /
-.Dd December 7, 2011o.Dt ATEXIT 3
+.\"
+.Dd December 7, 2011
 .Dt QUICK_EXIT 3
 .Os
 .Sh NAME
 .Nm quick_exit
-.Nd Exits a program quickly, running minimal cleanup
+.Nd exits a program quickly, running minimal cleanup
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
@@ -44,12 +44,14 @@ with
 .Xr at_quick_exit 3
 but not any C++ destructors or cleanup code registered with
 .Xr atexit 3 .
-.El
+.Sh RETURN VALUES
+The
+.Fn quick_exit
+function does not return.
 .Sh SEE ALSO
-.Xr exit 3 ,
-.Xr at_quick_exit 3
+.Xr at_quick_exit 3 ,
+.Xr exit 3
 .Sh STANDARDS
 The
 .Fn quick_exit
 function conforms to the C1x draft specification.
-
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r228322 - in head: include lib/libc/stdlib sys/sys

2011-12-07 Thread David Chisnall
On 7 Dec 2011, at 19:11, David Schultz wrote:

> Why not use the standard spelling, '_Noreturn'?  In pre-C1X modes,
> _Noreturn is a reserved identifier since it starts with an underscore
> and capital letter, so it's not considered namespace pollution.

Because that would be too obvious...

David
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228330 - in head: include sys/sys

2011-12-07 Thread David Chisnall
Author: theraven
Date: Wed Dec  7 21:17:50 2011
New Revision: 228330
URL: http://svn.freebsd.org/changeset/base/228330

Log:
  As per das@'s suggestion, s/__noreturn/_Noreturn/, since the latter is an
  identifier reserved for the implementation in C99 and earlier so there is
  no sensible reason for introducing yet another reserved identifier when we
  could just use the one C1x uses.
  
  Approved by:  brooks (mentor)

Modified:
  head/include/stdlib.h
  head/sys/sys/cdefs.h

Modified: head/include/stdlib.h
==
--- head/include/stdlib.h   Wed Dec  7 21:02:35 2011(r228329)
+++ head/include/stdlib.h   Wed Dec  7 21:17:50 2011(r228330)
@@ -76,7 +76,7 @@ extern int __mb_cur_max;
 extern int ___mb_cur_max(void);
 #defineMB_CUR_MAX  (___mb_cur_max())
 
-__noreturn void abort(void);
+_Noreturn void  abort(void);
 int abs(int) __pure2;
 int atexit(void (*)(void));
 double  atof(const char *);
@@ -86,7 +86,7 @@ void  *bsearch(const void *, const void *
size_t, int (*)(const void *, const void *));
 void   *calloc(size_t, size_t) __malloc_like;
 div_t   div(int, int) __pure2;
-__noreturn void exit(int);
+_Noreturn void  exit(int);
 voidfree(void *);
 char   *getenv(const char *);
 longlabs(long) __pure2;
@@ -145,14 +145,14 @@ unsigned long long
 strtoull(const char * __restrict, char ** __restrict, int);
 #endif /* __LONG_LONG_SUPPORTED */
 
-__noreturn void _Exit(int);
+_Noreturn void  _Exit(int);
 #endif /* __ISO_C_VISIBLE >= 1999 */
 
 /*
  * If we're in a mode greater than C99, expose C1x functions.
  */
 #if __ISO_C_VISIBLE > 1999
-__noreturn void quick_exit(int)
+_Noreturn void quick_exit(int)
 int
 at_quick_exit(void (*func)(void));
 #endif /* __ISO_C_VISIBLE > 1999 */

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hWed Dec  7 21:02:35 2011(r228329)
+++ head/sys/sys/cdefs.hWed Dec  7 21:17:50 2011(r228330)
@@ -220,13 +220,13 @@
 
 
 #if defined(__cplusplus) && __cplusplus >= 201103L
-#define__noreturn  [[noreturn]]
+#define_Noreturn   [[noreturn]]
 #elif defined(__STDC_VERSION__) && __STDC_VERSION__ > 201000L
-#define__noreturn  _Noreturn
+/* Do nothing - _Noreturn is a keyword */
 #elif defined(__GNUC__)
-#define__noreturn  __attribute__((__noreturn__))
+#define_Noreturn   __attribute__((__noreturn__))
 #else
-#define__noreturn
+#define_Noreturn
 #endif
 
 #if __GNUC_PREREQ__(2, 96)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r228322 - in head: include lib/libc/stdlib sys/sys

2011-12-07 Thread Bruce Evans

On Wed, 7 Dec 2011, David Schultz wrote:


On Wed, Dec 07, 2011, David Chisnall wrote:

Log:
  Implement quick_exit() / at_quick_exit() from C++11 / C1x.  Also add a
  __noreturn macro and modify the other exiting functions to use it.

  The __noreturn macro, unlike __dead2, must be used BEFORE the function.
  This is in line with the C and C++ specifications that place _Noreturn (c1x)
  and [[noreturn]] (C++11) in front of the functions.  As with __dead2, this
  macro falls back to using the GCC attribute.

  Unfortunately, clang currently sets the same value for the C version macro
  in C99 and C1x modes, so these functions are hidden by default.  At some
  point before 10.0, I need to go through the headers and clean up the C1x /
  C++11 visibility.


Nice.

Why not use the standard spelling, '_Noreturn'?  In pre-C1X modes,
_Noreturn is a reserved identifier since it starts with an underscore
and capital letter, so it's not considered namespace pollution.


There is also the __dead attribute for gcc-1 and some versions of
gcc-2.  It has the same syntax as __noreturn, since it was implemented
as `volatile' in gcc-1, and `volatile' must be in the declarator BEFORE
the function name.  This was changed in gcc-2 because it was determined
that `volatile' for a function has some defined meaning that of course
can't be the gcc-1 one.  FreeBSD introduced __dead2 for newer versions
of gcc-2 and kept __dead for a while.  __dead remains dead (reserved for
gcc-1, or perhaps anything that uses the same syntax).  Not quite
similarly for __pure.  Someone broke its reservedness by using it for
gcc-2.96+'s new __pure__ attribute, which is subtly different from
the old __pure and the current __pure2 FreeBSD macros.

NetBSD still had the old __dead and __pure, and no __dead2 or __pure2, as
late as 2005.  It still use[d] (as well as defining) __dead in a few
places, and uses a hard __attribute__((__noreturn__)) instead of
__dead2.  Sometimes both.

This change seems to break compatibility cruft related to this in the
critical header , since __Noreturn is actually used there
and replaces __dead2 and has a different syntax that might not work
with old compilers (sys/cdefs.h still has mounds of compatibility cruft
for old compilers, although this doesn't include __dead for gcc-1, and
probably mostly doesn't actually work).  Here is the change in cdefs.h:

% Index: cdefs.h
% ===
% RCS file: /home/ncvs/src/sys/sys/cdefs.h,v
% retrieving revision 1.117
% retrieving revision 1.118
% diff -u -2 -r1.117 -r1.118
% --- cdefs.h   12 Nov 2011 23:17:54 -  1.117
% +++ cdefs.h   7 Dec 2011 15:25:48 -   1.118
% @@ -219,4 +219,15 @@
%  #endif
% 
% +


Style bug (extra blank line).

% +#if defined(__cplusplus) && __cplusplus >= 201103L
% +#define  __noreturn  [[noreturn]]
% +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ > 201000L
% +#define  __noreturn  _Noreturn
% +#elif defined(__GNUC__)
% +#define  __noreturn  __attribute__((__noreturn__))

This assumes that all versions of gcc support the __noreturn__
attribute, and the new uses of this attribute assumes that
__attribute__(()) works BEFORE the function name when it is used
there, as it now is in .

The first assumption bogotifies the fussy ifdefs used later in cdefs.h.
__attribute__((__noreturn__)) is already used later, to define __dead2,
and this is under several ifdefs with ugly duplication:
- one for gcc-2.5 and 2.6 vs older gcc's
- one for gcc >= 2.7
- one for __INTEL_COMPILER (twisted by interaction with the ones for
  very old gcc's)
I don't trust most of the version numbers in the GNC_PREREQ()s, but
these have more chance than most of being correct since they are old
and detailed.  If they are correct, then we see that the above is
incorrect mainly for gcc-2.0 through 2.4.  gcc-1 is already fully
unsupported (except as a generic compiler).  gcc-2.0 through gcc-2.4
are old enough to unsupport, so this is mainly a style bug.

The second assumption is probably not satisfied by middle versions of
gcc-2.  IIRC, the reason for switching the syntax from __dead (placed
before the function name) to __dead2 (placed after) was that early
implementations of __attribute__() only worked if they were placed
after.  Otherwise, we would have just ifdefed another case for __dead.
I don't know when gcc fixed this.

% +#else
% +#define  __noreturn

Defaulting to nothing for a generic/unknown compiler is good, but this
combined with actually using __noreturn seems to break some previously
supported cases, in particular __INTEL_COMPILER sees a null __noreturn
for declarations in  where it used to see a non-null __dead2.
Apparently it doesn't pretend to be gcc, but it supports most gcc
features so it mostly works, but it needs messy ifdefs to use these
features.  Perhaps __INTEL_COMPILER should be unsupported together
with gcc-2.  It is painful to maintain all these 

svn commit: r228331 - head/sys/dev/et

2011-12-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Dec  7 21:29:51 2011
New Revision: 228331
URL: http://svn.freebsd.org/changeset/base/228331

Log:
  Rework link state tracking and TX/RX MAC configuration.
   o Do not report link status if driver is not running.
   o TX/RX MAC configuration should be done with resolved speed,
 duplex and flow control after establishing a link so it can't
 be done in driver initialization routine.
 Move the configuration to miibus_statchg callback which will be
 called whenever any link state change is detected.
 At this moment, flow-control is not enabled yet mainly because
 I was not able to set correct flow control parameters to
 generate TX pause frames.
   o Now TX/RX MAC is enabled only when a valid link is detected.
 Rearragnge hardware initialization routine a bit to leave
 enabling MAC to miibus_statchg callback.  In order to that,
 TX/RX DMA engine is enabled in et_init_locked().
   o Introduce ET_FLAG_LINK flag to track current link state.
   o Introduce ET_FLAG_FASTETHER flag to mark whether controller is
 fast ethernet.  This flag is checked in miibus_statchg callback
 to know whether PHY established a valid link.
   o In et_stop(), TX/RX MAC is explicitly disabled instead of
 relying on et_reset().  And move et_reset() from et_stop() to
 controller initialization.  Controler reset is not required here
 and it would also clear critial registers(i.e station address,
 RX filter configuration, WOL etc) that are required to make WOL
 work.
   o Switching to current media is done in et_init_locked() after
 setting IFF_DRV_RUNNING flag.  This should ensure reliable
 auto-negotiation/manual link establishment.
   o In et_start_locked(), check whether driver got a valid link
 before trying to send frames.
   o Remove checking a link in et_tick() as this is done by
 miibus_statchg callback.

Modified:
  head/sys/dev/et/if_et.c
  head/sys/dev/et/if_etvar.h

Modified: head/sys/dev/et/if_et.c
==
--- head/sys/dev/et/if_et.c Wed Dec  7 21:17:50 2011(r228330)
+++ head/sys/dev/et/if_et.c Wed Dec  7 21:29:51 2011(r228331)
@@ -141,13 +141,11 @@ static intet_start_rxdma(struct et_soft
 static int et_start_txdma(struct et_softc *);
 static int et_stop_rxdma(struct et_softc *);
 static int et_stop_txdma(struct et_softc *);
-static int et_enable_txrx(struct et_softc *, int);
 static voidet_reset(struct et_softc *);
 static int et_bus_config(struct et_softc *);
 static voidet_get_eaddr(device_t, uint8_t[]);
 static voidet_setmulti(struct et_softc *);
 static voidet_tick(void *);
-static voidet_setmedia(struct et_softc *);
 
 static const struct et_dev {
uint16_tvid;
@@ -296,6 +294,9 @@ et_attach(device_t dev)
goto fail;
}
 
+   if (pci_get_device(dev) == PCI_PRODUCT_LUCENT_ET1310_FAST)
+   sc->sc_flags |= ET_FLAG_FASTETHER;
+
error = et_bus_config(sc);
if (error)
goto fail;
@@ -487,7 +488,89 @@ et_miibus_writereg(device_t dev, int phy
 static void
 et_miibus_statchg(device_t dev)
 {
-   et_setmedia(device_get_softc(dev));
+   struct et_softc *sc;
+   struct mii_data *mii;
+   struct ifnet *ifp;
+   uint32_t cfg1, cfg2, ctrl;
+   int i;
+
+   sc = device_get_softc(dev);
+
+   mii = device_get_softc(sc->sc_miibus);
+   ifp = sc->ifp;
+   if (mii == NULL || ifp == NULL ||
+   (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+   return;
+
+   sc->sc_flags &= ~ET_FLAG_LINK;
+   if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
+   (IFM_ACTIVE | IFM_AVALID)) {
+   switch (IFM_SUBTYPE(mii->mii_media_active)) {
+   case IFM_10_T:
+   case IFM_100_TX:
+   sc->sc_flags |= ET_FLAG_LINK;
+   break;
+   case IFM_1000_T:
+   if ((sc->sc_flags & ET_FLAG_FASTETHER) == 0)
+   sc->sc_flags |= ET_FLAG_LINK;
+   break;
+   }
+   }
+
+   /* XXX Stop TX/RX MAC? */
+   if ((sc->sc_flags & ET_FLAG_LINK) == 0)
+   return;
+
+   /* Program MACs with resolved speed/duplex/flow-control. */
+   ctrl = CSR_READ_4(sc, ET_MAC_CTRL);
+   ctrl &= ~(ET_MAC_CTRL_GHDX | ET_MAC_CTRL_MODE_MII);
+   cfg1 = CSR_READ_4(sc, ET_MAC_CFG1);
+   cfg1 &= ~(ET_MAC_CFG1_TXFLOW | ET_MAC_CFG1_RXFLOW |
+   ET_MAC_CFG1_LOOPBACK);
+   cfg2 = CSR_READ_4(sc, ET_MAC_CFG2);
+   cfg2 &= ~(ET_MAC_CFG2_MODE_MII | ET_MAC_CFG2_MODE_GMII |
+   ET_MAC_CFG2_FDX | ET_MAC_CFG2_BIGFRM);
+   cfg2 |= ET_MAC_CFG2_LENCHK | ET_MAC_CFG2_CRC | ET_MAC_CFG2_PADCRC |
+   ((7 << ET_MAC_CFG2_PREAMBLE_LEN_SHIFT) &
+   ET_MAC_CFG2_PREAMBLE_LEN_MA

svn commit: r228332 - head/sys/dev/et

2011-12-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Dec  7 21:46:09 2011
New Revision: 228332
URL: http://svn.freebsd.org/changeset/base/228332

Log:
  Implement hardware MAC statistics counter.  Counters could be
  queried with dev.et.%d.stats sysctl node where %d is an instance of
  device.

Modified:
  head/sys/dev/et/if_et.c
  head/sys/dev/et/if_etreg.h
  head/sys/dev/et/if_etvar.h

Modified: head/sys/dev/et/if_et.c
==
--- head/sys/dev/et/if_et.c Wed Dec  7 21:29:51 2011(r228331)
+++ head/sys/dev/et/if_et.c Wed Dec  7 21:46:09 2011(r228332)
@@ -146,6 +146,7 @@ static int  et_bus_config(struct et_softc
 static voidet_get_eaddr(device_t, uint8_t[]);
 static voidet_setmulti(struct et_softc *);
 static voidet_tick(void *);
+static voidet_stats_update(struct et_softc *);
 
 static const struct et_dev {
uint16_tvid;
@@ -635,6 +636,7 @@ et_stop(struct et_softc *sc)
 
et_stop_rxdma(sc);
et_stop_txdma(sc);
+   et_stats_update(sc);
 
et_free_tx_ring(sc);
et_free_rx_ring(sc);
@@ -2049,7 +2051,6 @@ et_rxeof(struct et_softc *sc)
m = rbd->rbd_buf[buf_idx].rb_mbuf;
if ((rxst_info1 & ET_RXST_INFO1_OK) == 0){
/* Discard errored frame. */
-   ifp->if_ierrors++;
rbd->rbd_discard(rbd, buf_idx);
} else if (rbd->rbd_newbuf(rbd, buf_idx) != 0) {
/* No available mbufs, discard it. */
@@ -2063,7 +2064,6 @@ et_rxeof(struct et_softc *sc)
} else {
m->m_pkthdr.len = m->m_len = buflen;
m->m_pkthdr.rcvif = ifp;
-   ifp->if_ipackets++;
ET_UNLOCK(sc);
ifp->if_input(ifp, m);
ET_LOCK(sc);
@@ -2229,7 +2229,6 @@ et_txeof(struct et_softc *sc)
bus_dmamap_unload(sc->sc_tx_tag, tb->tb_dmap);
m_freem(tb->tb_mbuf);
tb->tb_mbuf = NULL;
-   ifp->if_opackets++;
}
 
if (++tbd->tbd_start_index == ET_TX_NDESC) {
@@ -2259,6 +2258,7 @@ et_tick(void *xsc)
mii = device_get_softc(sc->sc_miibus);
 
mii_tick(mii);
+   et_stats_update(sc);
if (et_watchdog(sc) == EJUSTRETURN)
return;
callout_reset(&sc->sc_tick, hz, et_tick, sc);
@@ -2371,6 +2371,11 @@ et_newbuf_hdr(struct et_rxbuf_data *rbd,
return (0);
 }
 
+#defineET_SYSCTL_STAT_ADD32(c, h, n, p, d) \
+   SYSCTL_ADD_UINT(c, h, OID_AUTO, n, CTLFLAG_RD, p, 0, d)
+#defineET_SYSCTL_STAT_ADD64(c, h, n, p, d) \
+   SYSCTL_ADD_UQUAD(c, h, OID_AUTO, n, CTLFLAG_RD, p, d)
+
 /*
  * Create sysctl tree
  */
@@ -2378,7 +2383,9 @@ static void
 et_add_sysctls(struct et_softc * sc)
 {
struct sysctl_ctx_list *ctx;
-   struct sysctl_oid_list *children;
+   struct sysctl_oid_list *children, *parent;
+   struct sysctl_oid *tree;
+   struct et_hw_stats *stats;
 
ctx = device_get_sysctl_ctx(sc->dev);
children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev));
@@ -2394,8 +2401,116 @@ et_add_sysctls(struct et_softc * sc)
"TX IM, # segments per TX interrupt");
SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "timer",
CTLFLAG_RW, &sc->sc_timer, 0, "TX timer");
+
+   tree = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "stats", CTLFLAG_RD,
+   NULL, "ET statistics");
+parent = SYSCTL_CHILDREN(tree);
+
+   /* TX/RX statistics. */
+   stats = &sc->sc_stats;
+   ET_SYSCTL_STAT_ADD64(ctx, parent, "frames_64", &stats->pkts_64,
+   "0 to 64 bytes frames");
+   ET_SYSCTL_STAT_ADD64(ctx, parent, "frames_65_127", &stats->pkts_65,
+   "65 to 127 bytes frames");
+   ET_SYSCTL_STAT_ADD64(ctx, parent, "frames_128_255", &stats->pkts_128,
+   "128 to 255 bytes frames");
+   ET_SYSCTL_STAT_ADD64(ctx, parent, "frames_256_511", &stats->pkts_256,
+   "256 to 511 bytes frames");
+   ET_SYSCTL_STAT_ADD64(ctx, parent, "frames_512_1023", &stats->pkts_512,
+   "512 to 1023 bytes frames");
+   ET_SYSCTL_STAT_ADD64(ctx, parent, "frames_1024_1518", &stats->pkts_1024,
+   "1024 to 1518 bytes frames");
+   ET_SYSCTL_STAT_ADD64(ctx, parent, "frames_1519_1522", &stats->pkts_1519,
+   "1519 to 1522 bytes frames");
+
+   /* RX statistics. */
+   tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx", CTLFLAG_RD,
+   NULL, "RX MAC statistics");
+   children = SYSCTL_CHILDREN(tree);
+   ET_SYSCTL_STAT_ADD64(ctx, children, "bytes",
+   &stats->rx_bytes, "Good bytes");
+   ET_SYSCTL_STAT_ADD64(ctx, children, "frames",
+   &stats->rx_frames, "Good frames");
+

svn commit: r228333 - head/sys/dev/et

2011-12-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Dec  7 21:54:44 2011
New Revision: 228333
URL: http://svn.freebsd.org/changeset/base/228333

Log:
  Protect SIOCSIFMTU ioctl handler with driver lock.
  Don't blindly re-initialize controller whenever MTU is changed.
  Now, reinitializing is done only when driver is running.
  
  While here, remove unnecessary assignment of error value since it
  was already initialized to 0.

Modified:
  head/sys/dev/et/if_et.c

Modified: head/sys/dev/et/if_et.c
==
--- head/sys/dev/et/if_et.c Wed Dec  7 21:46:09 2011(r228332)
+++ head/sys/dev/et/if_et.c Wed Dec  7 21:54:44 2011(r228333)
@@ -1287,11 +1287,11 @@ et_ioctl(struct ifnet *ifp, u_long cmd, 
ET_LOCK(sc);
et_setmulti(sc);
ET_UNLOCK(sc);
-   error = 0;
}
break;
 
case SIOCSIFMTU:
+   ET_LOCK(sc);
 #if 0
if (sc->sc_flags & ET_FLAG_JUMBO)
max_framelen = ET_JUMBO_FRAMELEN;
@@ -1301,14 +1301,18 @@ et_ioctl(struct ifnet *ifp, u_long cmd, 
 
if (ET_FRAMELEN(ifr->ifr_mtu) > max_framelen) {
error = EOPNOTSUPP;
+   ET_UNLOCK(sc);
break;
}
 
if (ifp->if_mtu != ifr->ifr_mtu) {
ifp->if_mtu = ifr->ifr_mtu;
-   ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
-   et_init(sc);
+   if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+   ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+   et_init_locked(sc);
+   }
}
+   ET_UNLOCK(sc);
break;
 
case SIOCSIFCAP:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228335 - head/sys/dev/et

2011-12-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Dec  7 22:04:57 2011
New Revision: 228335
URL: http://svn.freebsd.org/changeset/base/228335

Log:
  Consistently use a tab character instead of using either a space or
  tab after #define.
  While I'm here consistently use capital letters when it uses
  hexadecimal notation.
  
  No functional changes.

Modified:
  head/sys/dev/et/if_etreg.h
  head/sys/dev/et/if_etvar.h

Modified: head/sys/dev/et/if_etreg.h
==
--- head/sys/dev/et/if_etreg.h  Wed Dec  7 21:55:11 2011(r228334)
+++ head/sys/dev/et/if_etreg.h  Wed Dec  7 22:04:57 2011(r228335)
@@ -38,11 +38,11 @@
 #ifndef _IF_ETREG_H
 #define _IF_ETREG_H
 
-#define ET_MEM_TXSIZE_EX   182
-#define ET_MEM_RXSIZE_MIN  608
-#define ET_MEM_RXSIZE_DEFAULT  11216
-#define ET_MEM_SIZE16384
-#define ET_MEM_UNIT16
+#defineET_MEM_TXSIZE_EX182
+#defineET_MEM_RXSIZE_MIN   608
+#defineET_MEM_RXSIZE_DEFAULT   11216
+#defineET_MEM_SIZE 16384
+#defineET_MEM_UNIT 16
 
 /*
  * PCI registers
@@ -53,270 +53,270 @@
  * ET_PCIV_REPLAY_TIMER_{128,256} are from
  * PCI EXPRESS BASE SPECIFICATION, REV. 1.0a, Table 3-4
  */
-#define ET_PCIR_BARPCIR_BAR(0)
+#defineET_PCIR_BAR PCIR_BAR(0)
 
-#define ET_PCIR_DEVICE_CAPS0x4c
-#define ET_PCIM_DEVICE_CAPS_MAX_PLSZ   0x7 /* Max playload size */
-#define ET_PCIV_DEVICE_CAPS_PLSZ_128   0x0
-#define ET_PCIV_DEVICE_CAPS_PLSZ_256   0x1
+#defineET_PCIR_DEVICE_CAPS 0x4C
+#defineET_PCIM_DEVICE_CAPS_MAX_PLSZ0x7 /* Max playload size */
+#defineET_PCIV_DEVICE_CAPS_PLSZ_1280x0
+#defineET_PCIV_DEVICE_CAPS_PLSZ_2560x1
 
-#define ET_PCIR_DEVICE_CTRL0x50
-#define ET_PCIM_DEVICE_CTRL_MAX_RRSZ   0x7000  /* Max read request size */
-#define ET_PCIV_DEVICE_CTRL_RRSZ_2K0x4000
+#defineET_PCIR_DEVICE_CTRL 0x50
+#defineET_PCIM_DEVICE_CTRL_MAX_RRSZ0x7000  /* Max read request 
size */
+#defineET_PCIV_DEVICE_CTRL_RRSZ_2K 0x4000
 
-#define ET_PCIR_MAC_ADDR0  0xa4
-#define ET_PCIR_MAC_ADDR1  0xa8
+#defineET_PCIR_MAC_ADDR0   0xA4
+#defineET_PCIR_MAC_ADDR1   0xA8
 
-#define ET_PCIR_EEPROM_STATUS  0xb2/* XXX undocumented */
-#define ET_PCIM_EEPROM_STATUS_ERROR0x4c
+#defineET_PCIR_EEPROM_STATUS   0xB2/* XXX undocumented */
+#defineET_PCIM_EEPROM_STATUS_ERROR 0x4C
 
-#define ET_PCIR_ACK_LATENCY0xc0
-#define ET_PCIV_ACK_LATENCY_128237
-#define ET_PCIV_ACK_LATENCY_256416
+#defineET_PCIR_ACK_LATENCY 0xC0
+#defineET_PCIV_ACK_LATENCY_128 237
+#defineET_PCIV_ACK_LATENCY_256 416
 
-#define ET_PCIR_REPLAY_TIMER   0xc2
-#define ET_REPLAY_TIMER_RX_L0S_ADJ 250 /* XXX infered from default */
-#define ET_PCIV_REPLAY_TIMER_128   (711 + ET_REPLAY_TIMER_RX_L0S_ADJ)
-#define ET_PCIV_REPLAY_TIMER_256   (1248 + ET_REPLAY_TIMER_RX_L0S_ADJ)
+#defineET_PCIR_REPLAY_TIMER0xC2
+#defineET_REPLAY_TIMER_RX_L0S_ADJ  250 /* XXX infered from 
default */
+#defineET_PCIV_REPLAY_TIMER_128(711 + 
ET_REPLAY_TIMER_RX_L0S_ADJ)
+#defineET_PCIV_REPLAY_TIMER_256(1248 + 
ET_REPLAY_TIMER_RX_L0S_ADJ)
 
-#define ET_PCIR_L0S_L1_LATENCY 0xcf
+#defineET_PCIR_L0S_L1_LATENCY  0xCF
 
 /*
  * CSR
  */
-#define ET_TXQUEUE_START   0x
-#define ET_TXQUEUE_END 0x0004
-#define ET_RXQUEUE_START   0x0008
-#define ET_RXQUEUE_END 0x000c
-#define ET_QUEUE_ADDR(addr)(((addr) / ET_MEM_UNIT) - 1)
-#define ET_QUEUE_ADDR_START0
-#define ET_QUEUE_ADDR_END  ET_QUEUE_ADDR(ET_MEM_SIZE)
-
-#define ET_PM  0x0010
-#define ET_PM_SYSCLK_GATE  0x0008
-#define ET_PM_TXCLK_GATE   0x0010
-#define ET_PM_RXCLK_GATE   0x0020
-
-#define ET_INTR_STATUS 0x0018
-#define ET_INTR_MASK   0x001c
-
-#define ET_SWRST   0x0028
-#define ET_SWRST_TXDMA 0x0001
-#define ET_SWRST_RXDMA 0x0002
-#define ET_SWRST_TXMAC 0x0004
-#define ET_SWRST_RXMAC 0x0008
-#define ET_SWRST_MAC   0x0010
-#define ET_SWRST_MAC_STAT  0x0020
-#define ET_SWRST_MMC   0x0040
-#define ET_SWRST_SELFCLR_DISABLE   0x8000
-
-#define ET_MSI_CFG 0x0030
-
-#define ET_LOOPBACK0x0034
-
-#define ET_TIMER  

svn commit: r228336 - head/sys/dev/et

2011-12-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Dec  7 23:20:14 2011
New Revision: 228336
URL: http://svn.freebsd.org/changeset/base/228336

Log:
  Disable all clocks and put PHY into COMA before entering into
  suspend state.  This will save more power.
  On resume, make sure to enable all clocks.  While I'm here, if
  controller is not fast ethernet, enable gigabit PHY.

Modified:
  head/sys/dev/et/if_et.c
  head/sys/dev/et/if_etreg.h

Modified: head/sys/dev/et/if_et.c
==
--- head/sys/dev/et/if_et.c Wed Dec  7 22:04:57 2011(r228335)
+++ head/sys/dev/et/if_et.c Wed Dec  7 23:20:14 2011(r228336)
@@ -220,6 +220,7 @@ et_attach(device_t dev)
struct et_softc *sc;
struct ifnet *ifp;
uint8_t eaddr[ETHER_ADDR_LEN];
+   uint32_t pmcfg;
int cap, error, msic;
 
sc = device_get_softc(dev);
@@ -304,8 +305,11 @@ et_attach(device_t dev)
 
et_get_eaddr(dev, eaddr);
 
-   CSR_WRITE_4(sc, ET_PM,
-   ET_PM_SYSCLK_GATE | ET_PM_TXCLK_GATE | ET_PM_RXCLK_GATE);
+   /* Take PHY out of COMA and enable clocks. */
+   pmcfg = ET_PM_SYSCLK_GATE | ET_PM_TXCLK_GATE | ET_PM_RXCLK_GATE;
+   if ((sc->sc_flags & ET_FLAG_FASTETHER) == 0)
+   pmcfg |= EM_PM_GIGEPHY_ENB;
+   CSR_WRITE_4(sc, ET_PM, pmcfg);
 
et_reset(sc);
 
@@ -2636,11 +2640,18 @@ static int
 et_suspend(device_t dev)
 {
struct et_softc *sc;
+   uint32_t pmcfg;
 
sc = device_get_softc(dev);
ET_LOCK(sc);
if ((sc->ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
et_stop(sc);
+   /* Diable all clocks and put PHY into COMA. */
+   pmcfg = CSR_READ_4(sc, ET_PM);
+   pmcfg &= ~(EM_PM_GIGEPHY_ENB | ET_PM_SYSCLK_GATE | ET_PM_TXCLK_GATE |
+   ET_PM_RXCLK_GATE);
+   pmcfg |= ET_PM_PHY_SW_COMA;
+   CSR_WRITE_4(sc, ET_PM, pmcfg);
ET_UNLOCK(sc);
return (0);
 }
@@ -2649,9 +2660,15 @@ static int
 et_resume(device_t dev)
 {
struct et_softc *sc;
+   uint32_t pmcfg;
 
sc = device_get_softc(dev);
ET_LOCK(sc);
+   /* Take PHY out of COMA and enable clocks. */
+   pmcfg = ET_PM_SYSCLK_GATE | ET_PM_TXCLK_GATE | ET_PM_RXCLK_GATE;
+   if ((sc->sc_flags & ET_FLAG_FASTETHER) == 0)
+   pmcfg |= EM_PM_GIGEPHY_ENB;
+   CSR_WRITE_4(sc, ET_PM, pmcfg);
if ((sc->ifp->if_flags & IFF_UP) != 0)
et_init_locked(sc);
ET_UNLOCK(sc);

Modified: head/sys/dev/et/if_etreg.h
==
--- head/sys/dev/et/if_etreg.h  Wed Dec  7 22:04:57 2011(r228335)
+++ head/sys/dev/et/if_etreg.h  Wed Dec  7 23:20:14 2011(r228336)
@@ -93,9 +93,11 @@
 #defineET_QUEUE_ADDR_END   ET_QUEUE_ADDR(ET_MEM_SIZE)
 
 #defineET_PM   0x0010
+#defineEM_PM_GIGEPHY_ENB   0x0001
 #defineET_PM_SYSCLK_GATE   0x0008
 #defineET_PM_TXCLK_GATE0x0010
 #defineET_PM_RXCLK_GATE0x0020
+#defineET_PM_PHY_SW_COMA   0x0040
 
 #defineET_INTR_STATUS  0x0018
 #defineET_INTR_MASK0x001C
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228342 - head/contrib/tzcode/zic

2011-12-07 Thread Eitan Adler
Author: eadler (ports committer)
Date: Thu Dec  8 02:40:46 2011
New Revision: 228342
URL: http://svn.freebsd.org/changeset/base/228342

Log:
  - set progname for use in usage()
  
  PR:   bin/162908
  Submitted by: Oleg Ginzburg 
  Approved by:  sbruno@
  MFC after:3 days

Modified:
  head/contrib/tzcode/zic/zdump.c

Modified: head/contrib/tzcode/zic/zdump.c
==
--- head/contrib/tzcode/zic/zdump.c Thu Dec  8 00:56:23 2011
(r228341)
+++ head/contrib/tzcode/zic/zdump.c Thu Dec  8 02:40:46 2011
(r228342)
@@ -260,6 +260,7 @@ char *  argv[];
register struct tm *tmp;
register struct tm *newtmp;
 
+   progname=argv[0];
INITIALIZE(cutlotime);
INITIALIZE(cuthitime);
 #if HAVE_GETTEXT
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228343 - head/sys/kern

2011-12-07 Thread Eitan Adler
Author: eadler (ports committer)
Date: Thu Dec  8 03:20:38 2011
New Revision: 228343
URL: http://svn.freebsd.org/changeset/base/228343

Log:
  - Fix ktrace leakage if error is set
  
  PR:   kern/163098
  Submitted by: Loganaden Velvindron 
  Approved by:  sbruno@
  MFC after:1 month

Modified:
  head/sys/kern/kern_ktrace.c

Modified: head/sys/kern/kern_ktrace.c
==
--- head/sys/kern/kern_ktrace.c Thu Dec  8 02:40:46 2011(r228342)
+++ head/sys/kern/kern_ktrace.c Thu Dec  8 03:20:38 2011(r228343)
@@ -478,7 +478,7 @@ ktrsysret(code, error, retval)
ktp = &req->ktr_data.ktr_sysret;
ktp->ktr_code = code;
ktp->ktr_error = error;
-   ktp->ktr_retval = retval;   /* what about val2 ? */
+   ktp->ktr_retval = ((error == 0) ? retval: 0);   /* what about 
val2 ? */
ktr_submitrequest(curthread, req);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r228344 - head/sys/cam/scsi

2011-12-07 Thread Eitan Adler
Author: eadler (ports committer)
Date: Thu Dec  8 03:20:48 2011
New Revision: 228344
URL: http://svn.freebsd.org/changeset/base/228344

Log:
  - Add support for Support SEAGATE DAT Scopion 130
  
  PR:   kern/141934
  Submitted by: HASHI Hiroaki 
  Approved by:  sbruno@
  MFC after:1 week

Modified:
  head/sys/cam/scsi/scsi_sa.c

Modified: head/sys/cam/scsi/scsi_sa.c
==
--- head/sys/cam/scsi/scsi_sa.c Thu Dec  8 03:20:38 2011(r228343)
+++ head/sys/cam/scsi/scsi_sa.c Thu Dec  8 03:20:48 2011(r228344)
@@ -334,6 +334,10 @@ static struct sa_quirk_entry sa_quirk_ta
"STT2*", "*"}, SA_QUIRK_1FM, 0
},
{
+   { T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "SEAGATE",
+   "DAT06241-XXX", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
+   },
+   {
{ T_SEQUENTIAL, SIP_MEDIA_REMOVABLE, "TANDBERG",
  " TDC 3600", "U07:"}, SA_QUIRK_NOCOMP|SA_QUIRK_1FM, 512
},
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r228342 - head/contrib/tzcode/zic

2011-12-07 Thread Pawel Jakub Dawidek
On Thu, Dec 08, 2011 at 02:40:46AM +, Eitan Adler wrote:
> Author: eadler (ports committer)
> Date: Thu Dec  8 02:40:46 2011
> New Revision: 228342
> URL: http://svn.freebsd.org/changeset/base/228342
> 
> Log:
>   - set progname for use in usage()
>   
>   PR: bin/162908
>   Submitted by:   Oleg Ginzburg 
>   Approved by:sbruno@
>   MFC after:  3 days
> 
> Modified:
>   head/contrib/tzcode/zic/zdump.c
> 
> Modified: head/contrib/tzcode/zic/zdump.c
> ==
> --- head/contrib/tzcode/zic/zdump.c   Thu Dec  8 00:56:23 2011
> (r228341)
> +++ head/contrib/tzcode/zic/zdump.c   Thu Dec  8 02:40:46 2011
> (r228342)
> @@ -260,6 +260,7 @@ char *argv[];
>   register struct tm *tmp;
>   register struct tm *newtmp;
>  
> + progname=argv[0];
>   INITIALIZE(cutlotime);
>   INITIALIZE(cuthitime);
>  #if HAVE_GETTEXT

It will good to to try to upstream it as this is contributed code.
This change doesn't seem to be consistent with the style of this file.
They use spaces around =.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://yomoli.com


pgpgCB7H5AR7J.pgp
Description: PGP signature