From owner-svn-src-stable-7@FreeBSD.ORG Mon Oct 4 19:40:01 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A935010656C3; Mon, 4 Oct 2010 19:40:01 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9761F8FC12; Mon, 4 Oct 2010 19:40:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o94Je1Dw024787; Mon, 4 Oct 2010 19:40:01 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o94Je1pr024785; Mon, 4 Oct 2010 19:40:01 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201010041940.o94Je1pr024785@svn.freebsd.org> From: Marius Strobl Date: Mon, 4 Oct 2010 19:40:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213414 - stable/7/usr.bin/tftp X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2010 19:40:01 -0000 Author: marius Date: Mon Oct 4 19:40:01 2010 New Revision: 213414 URL: http://svn.freebsd.org/changeset/base/213414 Log: MFC: r213053 Remove an explicit assignment of the CFLAGS variable intended for debugging purposes only. Modified: stable/7/usr.bin/tftp/Makefile Directory Properties: stable/7/usr.bin/tftp/ (props changed) Modified: stable/7/usr.bin/tftp/Makefile ============================================================================== --- stable/7/usr.bin/tftp/Makefile Mon Oct 4 19:39:51 2010 (r213413) +++ stable/7/usr.bin/tftp/Makefile Mon Oct 4 19:40:01 2010 (r213414) @@ -1,7 +1,6 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -CFLAGS=-g -Wall WARNS= 3 PROG= tftp SRCS= main.c tftp.c tftp-utils.c tftp-io.c tftp-file.c tftp-transfer.c tftp-options.c From owner-svn-src-stable-7@FreeBSD.ORG Mon Oct 4 19:51:16 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E96141065693; Mon, 4 Oct 2010 19:51:16 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BB01D8FC1F; Mon, 4 Oct 2010 19:51:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o94JpGsK025156; Mon, 4 Oct 2010 19:51:16 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o94JpGBH025153; Mon, 4 Oct 2010 19:51:16 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201010041951.o94JpGBH025153@svn.freebsd.org> From: Marius Strobl Date: Mon, 4 Oct 2010 19:51:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213416 - in stable/7: libexec/tftpd usr.bin/tftp X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2010 19:51:17 -0000 Author: marius Date: Mon Oct 4 19:51:16 2010 New Revision: 213416 URL: http://svn.freebsd.org/changeset/base/213416 Log: MFC: r213075 Try to adhere to style.Makefile(5). Modified: stable/7/libexec/tftpd/Makefile stable/7/usr.bin/tftp/Makefile Directory Properties: stable/7/libexec/tftpd/ (props changed) stable/7/usr.bin/tftp/ (props changed) Modified: stable/7/libexec/tftpd/Makefile ============================================================================== --- stable/7/libexec/tftpd/Makefile Mon Oct 4 19:51:15 2010 (r213415) +++ stable/7/libexec/tftpd/Makefile Mon Oct 4 19:51:16 2010 (r213416) @@ -2,13 +2,11 @@ # $FreeBSD$ PROG= tftpd -SRCS= tftpd.c tftp-io.c tftp-utils.c tftp-file.c tftp-transfer.c tftp-options.c +MAN= tftpd.8 +SRCS= tftp-file.c tftp-io.c tftp-options.c tftp-transfer.c tftp-utils.c +SRCS+= tftpd.c WARNS= 3 WFORMAT=0 -MAN= tftpd.8 -CFLAGS+=-I${.CURDIR}/../../usr.bin/tftp -I${.CURDIR}/../../libexec/tftpd -.PATH: ${.CURDIR}/../../usr.bin/tftp -COPTFLAGS = -O LDFLAGS= -lwrap .include Modified: stable/7/usr.bin/tftp/Makefile ============================================================================== --- stable/7/usr.bin/tftp/Makefile Mon Oct 4 19:51:15 2010 (r213415) +++ stable/7/usr.bin/tftp/Makefile Mon Oct 4 19:51:16 2010 (r213416) @@ -1,12 +1,14 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -WARNS= 3 +.PATH: ${.CURDIR}/../../libexec/tftpd + PROG= tftp -SRCS= main.c tftp.c tftp-utils.c tftp-io.c tftp-file.c tftp-transfer.c tftp-options.c +SRCS= main.c tftp-file.c tftp-io.c tftp-options.c tftp-transfer.c +SRCS+= tftp-utils.c tftp.c +WARNS= 3 +CFLAGS+=-I${.CURDIR}/../../libexec/tftpd DPADD= ${LIBEDIT} ${LIBTERMCAP} LDADD= -ledit -ltermcap -CFLAGS+=-I${.CURDIR}/../../libexec/tftpd -I${.CURDIR}/../../usr.bin/tftp -.PATH: ${.CURDIR}/../../libexec/tftpd .include From owner-svn-src-stable-7@FreeBSD.ORG Mon Oct 4 19:59:12 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 261F01065771; Mon, 4 Oct 2010 19:59:12 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 118718FC2B; Mon, 4 Oct 2010 19:59:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o94JxCMO025466; Mon, 4 Oct 2010 19:59:12 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o94JxBP6025457; Mon, 4 Oct 2010 19:59:11 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201010041959.o94JxBP6025457@svn.freebsd.org> From: Marius Strobl Date: Mon, 4 Oct 2010 19:59:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213418 - in stable/7: libexec/tftpd usr.bin/tftp X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2010 19:59:12 -0000 Author: marius Date: Mon Oct 4 19:59:11 2010 New Revision: 213418 URL: http://svn.freebsd.org/changeset/base/213418 Log: MFC: r213099 Make WARNS=6 clean. Modified: stable/7/libexec/tftpd/Makefile stable/7/libexec/tftpd/tftp-file.c stable/7/libexec/tftpd/tftp-options.c stable/7/libexec/tftpd/tftp-utils.c stable/7/libexec/tftpd/tftp-utils.h stable/7/libexec/tftpd/tftpd.c stable/7/usr.bin/tftp/Makefile stable/7/usr.bin/tftp/main.c Directory Properties: stable/7/libexec/tftpd/ (props changed) stable/7/usr.bin/tftp/ (props changed) Modified: stable/7/libexec/tftpd/Makefile ============================================================================== --- stable/7/libexec/tftpd/Makefile Mon Oct 4 19:59:08 2010 (r213417) +++ stable/7/libexec/tftpd/Makefile Mon Oct 4 19:59:11 2010 (r213418) @@ -5,7 +5,7 @@ PROG= tftpd MAN= tftpd.8 SRCS= tftp-file.c tftp-io.c tftp-options.c tftp-transfer.c tftp-utils.c SRCS+= tftpd.c -WARNS= 3 +WARNS= 6 WFORMAT=0 LDFLAGS= -lwrap Modified: stable/7/libexec/tftpd/tftp-file.c ============================================================================== --- stable/7/libexec/tftpd/tftp-file.c Mon Oct 4 19:59:08 2010 (r213417) +++ stable/7/libexec/tftpd/tftp-file.c Mon Oct 4 19:59:11 2010 (r213418) @@ -103,13 +103,13 @@ static size_t convert_to_net(char *buffer, size_t count, int init) { size_t i; - static size_t n = 0, read = 0; + static size_t n = 0, in = 0; static int newline = 0; if (init) { newline = 0; n = 0; - read = 0; + in = 0; return 0 ; } @@ -124,13 +124,13 @@ convert_to_net(char *buffer, size_t coun } while (i < count) { - if (n == read) { + if (n == in) { /* When done we're done */ if (feof(file)) break; /* Otherwise read another bunch */ - read = fread(convbuffer, 1, count, file); - if (read == 0) break; + in = fread(convbuffer, 1, count, file); + if (in == 0) break; n = 0; } @@ -250,7 +250,7 @@ read_close(void) int -synchnet(int peer) +synchnet(int peer __unused) { return 0; Modified: stable/7/libexec/tftpd/tftp-options.c ============================================================================== --- stable/7/libexec/tftpd/tftp-options.c Mon Oct 4 19:59:08 2010 (r213417) +++ stable/7/libexec/tftpd/tftp-options.c Mon Oct 4 19:59:11 2010 (r213418) @@ -79,7 +79,8 @@ int options_extra_enabled = 1; */ int -option_tsize(int peer, struct tftphdr *tp, int mode, struct stat *stbuf) +option_tsize(int peer __unused, struct tftphdr *tp __unused, int mode, + struct stat *stbuf) { if (options[OPT_TSIZE].o_request == NULL) @@ -159,21 +160,19 @@ option_rollover(int peer) int option_blksize(int peer) { - int *maxdgram; - char maxbuffer[100]; + u_long maxdgram; size_t len; if (options[OPT_BLKSIZE].o_request == NULL) return (0); /* maximum size of an UDP packet according to the system */ - len = sizeof(maxbuffer); + len = sizeof(maxdgram); if (sysctlbyname("net.inet.udp.maxdgram", - maxbuffer, &len, NULL, 0) < 0) { + &maxdgram, &len, NULL, 0) < 0) { tftp_log(LOG_ERR, "sysctl: net.inet.udp.maxdgram"); return (acting_as_client ? 1 : 0); } - maxdgram = (int *)maxbuffer; int size = atoi(options[OPT_BLKSIZE].o_request); if (size < BLKSIZE_MIN || size > BLKSIZE_MAX) { @@ -191,20 +190,20 @@ option_blksize(int peer) } } - if (size > *maxdgram) { + if (size > (int)maxdgram) { if (acting_as_client) { tftp_log(LOG_ERR, "Invalid blocksize (%d bytes), " "net.inet.udp.maxdgram sysctl limits it to " - "%d bytes.\n", size, *maxdgram); + "%d bytes.\n", size, maxdgram); send_error(peer, EBADOP); return (1); } else { tftp_log(LOG_WARNING, "Invalid blocksize (%d bytes), " "net.inet.udp.maxdgram sysctl limits it to " - "%d bytes.\n", size, *maxdgram); - size = *maxdgram; + "%d bytes.\n", size, maxdgram); + size = maxdgram; /* No reason to return */ } } @@ -220,10 +219,9 @@ option_blksize(int peer) } int -option_blksize2(int peer) +option_blksize2(int peer __unused) { - int *maxdgram; - char maxbuffer[100]; + u_long maxdgram; int size, i; size_t len; @@ -236,13 +234,12 @@ option_blksize2(int peer) return (0); /* maximum size of an UDP packet according to the system */ - len = sizeof(maxbuffer); + len = sizeof(maxdgram); if (sysctlbyname("net.inet.udp.maxdgram", - maxbuffer, &len, NULL, 0) < 0) { + &maxdgram, &len, NULL, 0) < 0) { tftp_log(LOG_ERR, "sysctl: net.inet.udp.maxdgram"); return (acting_as_client ? 1 : 0); } - maxdgram = (int *)maxbuffer; size = atoi(options[OPT_BLKSIZE2].o_request); for (i = 0; sizes[i] != 0; i++) { @@ -254,13 +251,13 @@ option_blksize2(int peer) return (acting_as_client ? 1 : 0); } - if (size > *maxdgram) { + if (size > (int)maxdgram) { for (i = 0; sizes[i+1] != 0; i++) { - if (*maxdgram < sizes[i+1]) break; + if ((int)maxdgram < sizes[i+1]) break; } tftp_log(LOG_INFO, "Invalid blocksize2 (%d bytes), net.inet.udp.maxdgram " - "sysctl limits it to %d bytes.\n", size, *maxdgram); + "sysctl limits it to %d bytes.\n", size, maxdgram); size = sizes[i]; /* No need to return */ } @@ -279,7 +276,7 @@ option_blksize2(int peer) * Append the available options to the header */ uint16_t -make_options(int peer, char *buffer, uint16_t size) { +make_options(int peer __unused, char *buffer, uint16_t size) { int i; char *value; const char *option; Modified: stable/7/libexec/tftpd/tftp-utils.c ============================================================================== --- stable/7/libexec/tftpd/tftp-utils.c Mon Oct 4 19:59:08 2010 (r213417) +++ stable/7/libexec/tftpd/tftp-utils.c Mon Oct 4 19:59:11 2010 (r213418) @@ -59,7 +59,7 @@ int acting_as_client; * first timeout) to 'timeoutnetwork' (i.e. the last timeout) */ int -settimeouts(int _timeoutpacket, int _timeoutnetwork, int _maxtimeouts) +settimeouts(int _timeoutpacket, int _timeoutnetwork, int _maxtimeouts __unused) { int i; @@ -91,7 +91,7 @@ unmappedaddr(struct sockaddr_in6 *sin6) !IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) return; sin4 = (struct sockaddr_in *)sin6; - addr = *(u_int32_t *)&sin6->sin6_addr.s6_addr[12]; + memcpy(&addr, &sin6->sin6_addr.s6_addr[12], sizeof(addr)); port = sin6->sin6_port; memset(sin4, 0, sizeof(struct sockaddr_in)); sin4->sin_addr.s_addr = addr; @@ -170,7 +170,7 @@ struct packettypes packettypes[] = { { 0, NULL }, }; -char * +const char * packettype(int type) { static char failed[100]; @@ -231,7 +231,7 @@ debug_finds(char *s) return (i); } -char * +const char * debug_show(int d) { static char s[100]; @@ -317,4 +317,3 @@ printstats(const char *direction, int ve printf(" [%.0f bits/sec]", (ts->amount*8.)/delta); putchar('\n'); } - Modified: stable/7/libexec/tftpd/tftp-utils.h ============================================================================== --- stable/7/libexec/tftpd/tftp-utils.h Mon Oct 4 19:59:08 2010 (r213417) +++ stable/7/libexec/tftpd/tftp-utils.h Mon Oct 4 19:59:11 2010 (r213418) @@ -64,17 +64,17 @@ ssize_t get_field(int peer, char *buffer */ struct packettypes { int value; - char *name; + const char *const name; }; extern struct packettypes packettypes[]; -char *packettype(int); +const char *packettype(int); /* * RP_ */ struct rp_errors { int error; - char *desc; + const char *const desc; }; extern struct rp_errors rp_errors[]; char *rp_strerror(int error); @@ -89,15 +89,15 @@ char *rp_strerror(int error); #define DEBUG_ACCESS 0x0008 struct debugs { int value; - char *name; - char *desc; + const char *const name; + const char *const desc; }; extern int debug; extern struct debugs debugs[]; extern int packetdroppercentage; int debug_find(char *s); int debug_finds(char *s); -char *debug_show(int d); +const char *debug_show(int d); /* * Log routines Modified: stable/7/libexec/tftpd/tftpd.c ============================================================================== --- stable/7/libexec/tftpd/tftpd.c Mon Oct 4 19:59:08 2010 (r213417) +++ stable/7/libexec/tftpd/tftpd.c Mon Oct 4 19:59:11 2010 (r213418) @@ -97,7 +97,7 @@ static int suppress_naks; static int logging; static int ipchroot; static int create_new = 0; -static char *newfile_format = "%Y%m%d"; +static const char *newfile_format = "%Y%m%d"; static int increase_name = 0; static mode_t mask = S_IWGRP | S_IWOTH; @@ -785,7 +785,6 @@ static void tftp_xmitfile(int peer, const char *mode) { uint16_t block; - uint32_t amount; time_t now; struct tftp_stats ts; @@ -799,13 +798,12 @@ tftp_xmitfile(int peer, const char *mode read_close(); if (debug&DEBUG_SIMPLE) tftp_log(LOG_INFO, "Sent %d bytes in %d seconds", - amount, time(NULL) - now); + ts.amount, time(NULL) - now); } static void tftp_recvfile(int peer, const char *mode) { - uint32_t filesize; uint16_t block; struct timeval now1, now2; struct tftp_stats ts; @@ -820,6 +818,7 @@ tftp_recvfile(int peer, const char *mode tftp_receive(peer, &block, &ts, NULL, 0); write_close(); + gettimeofday(&now2, NULL); if (debug&DEBUG_SIMPLE) { double f; @@ -832,9 +831,8 @@ tftp_recvfile(int peer, const char *mode (now2.tv_usec - now1.tv_usec) / 100000.0; tftp_log(LOG_INFO, "Download of %d bytes in %d blocks completed after %0.1f seconds\n", - filesize, block, f); + ts.amount, block, f); } return; } - Modified: stable/7/usr.bin/tftp/Makefile ============================================================================== --- stable/7/usr.bin/tftp/Makefile Mon Oct 4 19:59:08 2010 (r213417) +++ stable/7/usr.bin/tftp/Makefile Mon Oct 4 19:59:11 2010 (r213418) @@ -1,12 +1,12 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.PATH: ${.CURDIR}/../../libexec/tftpd +.PATH: ${.CURDIR}/../../libexec/tftpd PROG= tftp SRCS= main.c tftp-file.c tftp-io.c tftp-options.c tftp-transfer.c SRCS+= tftp-utils.c tftp.c -WARNS= 3 +WARNS= 6 CFLAGS+=-I${.CURDIR}/../../libexec/tftpd DPADD= ${LIBEDIT} ${LIBTERMCAP} LDADD= -ledit -ltermcap Modified: stable/7/usr.bin/tftp/main.c ============================================================================== --- stable/7/usr.bin/tftp/main.c Mon Oct 4 19:59:08 2010 (r213417) +++ stable/7/usr.bin/tftp/main.c Mon Oct 4 19:59:11 2010 (r213418) @@ -222,8 +222,8 @@ urihandling(char *URI) char uri[ARG_MAX]; char *host = NULL; char *path = NULL; - char *options = NULL; - char *mode = "octet"; + char *opts = NULL; + const char *tmode = "octet"; char *s; char line[MAXLINE]; int i; @@ -241,14 +241,14 @@ urihandling(char *URI) if ((s = strchr(path, ';')) != NULL) { *s = '\0'; - options = s + 1; + opts = s + 1; - if (strncmp(options, "mode=", 5) == 0) { - mode = options; - mode += 5; + if (strncmp(opts, "mode=", 5) == 0) { + tmode = opts; + tmode += 5; for (i = 0; modes[i].m_name != NULL; i++) { - if (strcmp(modes[i].m_name, mode) == 0) + if (strcmp(modes[i].m_name, tmode) == 0) break; } if (modes[i].m_name == NULL) { @@ -697,7 +697,7 @@ tail(char *filename) } static const char * -command_prompt() +command_prompt(void) { return ("tftp> "); @@ -964,27 +964,25 @@ setblocksize(int argc, char *argv[]) if (argc != 1) { int size = atoi(argv[1]); size_t max; - char maxbuffer[100]; - int *maxdgram; + u_long maxdgram; - max = sizeof(maxbuffer); + max = sizeof(maxdgram); if (sysctlbyname("net.inet.udp.maxdgram", - maxbuffer, &max, NULL, 0) < 0) { + &maxdgram, &max, NULL, 0) < 0) { perror("sysctl: net.inet.udp.maxdgram"); return; } - maxdgram = (int *)maxbuffer; if (size < BLKSIZE_MIN || size > BLKSIZE_MAX) { printf("Blocksize should be between %d and %d bytes.\n", BLKSIZE_MIN, BLKSIZE_MAX); return; - } else if (size > *maxdgram - 4) { - printf("Blocksize can't be bigger than %d bytes due " + } else if (size > (int)maxdgram - 4) { + printf("Blocksize can't be bigger than %ld bytes due " "to the net.inet.udp.maxdgram sysctl limitation.\n", - *maxdgram - 4); + maxdgram - 4); asprintf(&options[OPT_BLKSIZE].o_request, - "%d", *maxdgram - 4); + "%ld", maxdgram - 4); } else { asprintf(&options[OPT_BLKSIZE].o_request, "%d", size); } @@ -1005,21 +1003,19 @@ setblocksize2(int argc, char *argv[]) int size = atoi(argv[1]); int i; size_t max; - char maxbuffer[100]; - int *maxdgram; + u_long maxdgram; int sizes[] = { 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 0 }; - max = sizeof(maxbuffer); + max = sizeof(maxdgram); if (sysctlbyname("net.inet.udp.maxdgram", - maxbuffer, &max, NULL, 0) < 0) { + &maxdgram, &max, NULL, 0) < 0) { perror("sysctl: net.inet.udp.maxdgram"); return; } - maxdgram = (int *)maxbuffer; for (i = 0; sizes[i] != 0; i++) { if (sizes[i] == size) break; @@ -1034,12 +1030,12 @@ setblocksize2(int argc, char *argv[]) printf("Blocksize2 should be between " "%d and %d bytes.\n", BLKSIZE_MIN, BLKSIZE_MAX); return; - } else if (size > *maxdgram - 4) { - printf("Blocksize2 can't be bigger than %d bytes due " + } else if (size > (int)maxdgram - 4) { + printf("Blocksize2 can't be bigger than %ld bytes due " "to the net.inet.udp.maxdgram sysctl limitation.\n", - *maxdgram - 4); + maxdgram - 4); for (i = 0; sizes[i+1] != 0; i++) { - if (*maxdgram < sizes[i+1]) break; + if ((int)maxdgram < sizes[i+1]) break; } asprintf(&options[OPT_BLKSIZE2].o_request, "%d", sizes[i]); From owner-svn-src-stable-7@FreeBSD.ORG Mon Oct 4 20:02:55 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43CCC106564A; Mon, 4 Oct 2010 20:02:55 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 325018FC08; Mon, 4 Oct 2010 20:02:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o94K2tId025685; Mon, 4 Oct 2010 20:02:55 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o94K2tm3025683; Mon, 4 Oct 2010 20:02:55 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201010042002.o94K2tm3025683@svn.freebsd.org> From: Marius Strobl Date: Mon, 4 Oct 2010 20:02:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213420 - stable/7/libexec/tftpd X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2010 20:02:55 -0000 Author: marius Date: Mon Oct 4 20:02:54 2010 New Revision: 213420 URL: http://svn.freebsd.org/changeset/base/213420 Log: MFC: r213102 Remove the duplicate logging of failed read requests, whose error message also was inappropriate as it triggered for every EACCESS and ENOTFOUND, not just the case the -n option is intended to deal with and thus really spammed us with ~20 messages in the default configuration when booting a diskless FreeBSD client, introduced with r207608 commited to stable/7 in r213039) again. Modified: stable/7/libexec/tftpd/tftpd.c Directory Properties: stable/7/libexec/tftpd/ (props changed) Modified: stable/7/libexec/tftpd/tftpd.c ============================================================================== --- stable/7/libexec/tftpd/tftpd.c Mon Oct 4 20:02:48 2010 (r213419) +++ stable/7/libexec/tftpd/tftpd.c Mon Oct 4 20:02:54 2010 (r213420) @@ -604,7 +604,6 @@ tftp_rrq(int peer, char *recvbuffer, ssi */ if (suppress_naks && *filename != '/' && ecode == ENOTFOUND) exit(0); - tftp_log(LOG_ERR, "Prevent NAK storm"); send_error(peer, ecode); exit(1); } From owner-svn-src-stable-7@FreeBSD.ORG Mon Oct 4 20:13:23 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 232191065771; Mon, 4 Oct 2010 20:13:22 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C4FA8FC2A; Mon, 4 Oct 2010 20:13:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o94KDM2s026039; Mon, 4 Oct 2010 20:13:22 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o94KDLAv026036; Mon, 4 Oct 2010 20:13:21 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201010042013.o94KDLAv026036@svn.freebsd.org> From: Marius Strobl Date: Mon, 4 Oct 2010 20:13:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213422 - stable/7/sys/dev/mpt X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2010 20:13:23 -0000 Author: marius Date: Mon Oct 4 20:13:21 2010 New Revision: 213422 URL: http://svn.freebsd.org/changeset/base/213422 Log: MFC: r213105, r213147 Improve r56796; the reply handler actually may remove the request from the chain in which case it shouldn't be removed twice. Reported by: Staale Kristoffersen Modified: stable/7/sys/dev/mpt/mpt.c stable/7/sys/dev/mpt/mpt.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/mpt/mpt.c ============================================================================== --- stable/7/sys/dev/mpt/mpt.c Mon Oct 4 20:13:19 2010 (r213421) +++ stable/7/sys/dev/mpt/mpt.c Mon Oct 4 20:13:21 2010 (r213422) @@ -842,13 +842,14 @@ mpt_complete_request_chain(struct mpt_so MSG_REQUEST_HEADER *msg_hdr; u_int cb_index; - TAILQ_REMOVE(chain, req, links); msg_hdr = (MSG_REQUEST_HEADER *)req->req_vbuf; ioc_status_frame.Function = msg_hdr->Function; ioc_status_frame.MsgContext = msg_hdr->MsgContext; cb_index = MPT_CONTEXT_TO_CBI(le32toh(msg_hdr->MsgContext)); mpt_reply_handlers[cb_index](mpt, req, msg_hdr->MsgContext, &ioc_status_frame); + if (mpt_req_on_pending_list(mpt, req) != 0) + TAILQ_REMOVE(chain, req, links); } } Modified: stable/7/sys/dev/mpt/mpt.h ============================================================================== --- stable/7/sys/dev/mpt/mpt.h Mon Oct 4 20:13:19 2010 (r213421) +++ stable/7/sys/dev/mpt/mpt.h Mon Oct 4 20:13:21 2010 (r213422) @@ -1155,19 +1155,13 @@ mpt_tag_2_req(struct mpt_softc *mpt, uin KASSERT(mpt->tgt_cmd_ptrs[rtg], ("no cmd backpointer")); return (mpt->tgt_cmd_ptrs[rtg]); } - +#endif static __inline int mpt_req_on_free_list(struct mpt_softc *, request_t *); static __inline int mpt_req_on_pending_list(struct mpt_softc *, request_t *); -static __inline void -mpt_req_spcl(struct mpt_softc *, request_t *, const char *, int); -static __inline void -mpt_req_not_spcl(struct mpt_softc *, request_t *, const char *, int); - - /* * Is request on freelist? */ @@ -1200,6 +1194,12 @@ mpt_req_on_pending_list(struct mpt_softc return (0); } +#ifdef INVARIANTS +static __inline void +mpt_req_spcl(struct mpt_softc *, request_t *, const char *, int); +static __inline void +mpt_req_not_spcl(struct mpt_softc *, request_t *, const char *, int); + /* * Make sure that req *is* part of one of the special lists */ From owner-svn-src-stable-7@FreeBSD.ORG Thu Oct 7 00:30:30 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47C44106566B; Thu, 7 Oct 2010 00:30:30 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 36E728FC19; Thu, 7 Oct 2010 00:30:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o970UUfl023055; Thu, 7 Oct 2010 00:30:30 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o970UUJA023053; Thu, 7 Oct 2010 00:30:30 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201010070030.o970UUJA023053@svn.freebsd.org> From: Xin LI Date: Thu, 7 Oct 2010 00:30:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213504 - stable/7/usr.bin/gzip X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Oct 2010 00:30:30 -0000 Author: delphij Date: Thu Oct 7 00:30:29 2010 New Revision: 213504 URL: http://svn.freebsd.org/changeset/base/213504 Log: MFC r210344: In the past gunzip(1) write()'s after each inflate return. This is not optimal from a performance standpoint since the write buffer is not necessarily be filled up when the inflate rountine reached the end of input buffer and it's not the end of file. This problem gets uncovered by trying to pipe gunzip -c output to a GEOM device directly, which enforces the writes be multiple of sector size. Sponsored by: iXsystems, Inc. Reported by: jpaetzel Modified: stable/7/usr.bin/gzip/gzip.c Directory Properties: stable/7/usr.bin/gzip/ (props changed) Modified: stable/7/usr.bin/gzip/gzip.c ============================================================================== --- stable/7/usr.bin/gzip/gzip.c Thu Oct 7 00:29:07 2010 (r213503) +++ stable/7/usr.bin/gzip/gzip.c Thu Oct 7 00:30:29 2010 (r213504) @@ -920,6 +920,8 @@ gz_uncompress(int in, int out, char *pre switch (error) { /* Z_BUF_ERROR goes with Z_FINISH... */ case Z_BUF_ERROR: + if (z.avail_out > 0 && !done_reading) + continue; case Z_STREAM_END: case Z_OK: break; From owner-svn-src-stable-7@FreeBSD.ORG Thu Oct 7 00:37:40 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A30F41065698; Thu, 7 Oct 2010 00:37:40 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 782A38FC1F; Thu, 7 Oct 2010 00:37:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o970bear023348; Thu, 7 Oct 2010 00:37:40 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o970beMP023346; Thu, 7 Oct 2010 00:37:40 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201010070037.o970beMP023346@svn.freebsd.org> From: Xin LI Date: Thu, 7 Oct 2010 00:37:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213506 - stable/7/sys/netinet X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Oct 2010 00:37:40 -0000 Author: delphij Date: Thu Oct 7 00:37:40 2010 New Revision: 213506 URL: http://svn.freebsd.org/changeset/base/213506 Log: MFC r211059: Address an edge condition that we found at work, where the carp(4) interface goes to issue LINK_UP, then LINK_DOWN, then LINK_UP at cold boot. This behavior is not observed when carp(4) interface is created slightly later, when the underlying interface is fully up. Before this change what happen at boot is roughly: - ifconfig creates em0 interface; - ifconfig clones a carp device using em0; (em0's link state is DOWN at this point) - carp state: INIT -> BACKUP [*] - carp state: BACKUP -> MASTER - [Some negotiate between em0 and switch] - em0 kicks up link state change event (em0's link state is now up DOWN at this point) - do_link_state_change() -> carp_carpdev_state() - carp state: MASTER -> INIT (via carp_set_state(sc, INIT)) [+] - carp state: INIT -> BACKUP - carp state: BACKUP -> MASTER At the [*] stage, em0 did not received any broadcast message from other node, and assume our node is the master, thus carp(4) sets the link state to "UP" after becoming a master. At [+], the master status is forcely set to "INIT", then an election is casted, after which our node would actually become a master. We believe that at the [*] stage, the master status should remain as "INIT" since the underlying parent interface's link state is not up. Obtained from: iXsystems, Inc. Reported by: jpaetzel Modified: stable/7/sys/netinet/ip_carp.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/netinet/ip_carp.c ============================================================================== --- stable/7/sys/netinet/ip_carp.c Thu Oct 7 00:36:58 2010 (r213505) +++ stable/7/sys/netinet/ip_carp.c Thu Oct 7 00:37:40 2010 (r213506) @@ -1349,7 +1349,8 @@ carp_setrun(struct carp_softc *sc, sa_fa CARP_SCLOCK_ASSERT(sc); if (SC2IFP(sc)->if_flags & IFF_UP && - sc->sc_vhid > 0 && (sc->sc_naddrs || sc->sc_naddrs6)) + sc->sc_vhid > 0 && (sc->sc_naddrs || sc->sc_naddrs6) && + sc->sc_carpdev->if_link_state == LINK_STATE_UP) SC2IFP(sc)->if_drv_flags |= IFF_DRV_RUNNING; else { SC2IFP(sc)->if_drv_flags &= ~IFF_DRV_RUNNING; From owner-svn-src-stable-7@FreeBSD.ORG Thu Oct 7 12:57:16 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6460C1065693; Thu, 7 Oct 2010 12:57:16 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 52BC78FC0C; Thu, 7 Oct 2010 12:57:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o97CvG9N041740; Thu, 7 Oct 2010 12:57:16 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o97CvGeb041738; Thu, 7 Oct 2010 12:57:16 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201010071257.o97CvGeb041738@svn.freebsd.org> From: David Xu Date: Thu, 7 Oct 2010 12:57:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213513 - stable/7/lib/libthr/thread X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Oct 2010 12:57:16 -0000 Author: davidxu Date: Thu Oct 7 12:57:16 2010 New Revision: 213513 URL: http://svn.freebsd.org/changeset/base/213513 Log: MFC r211833: Decrease rdlock count only when thread unlocked a reader lock. Modified: stable/7/lib/libthr/thread/thr_rtld.c Directory Properties: stable/7/lib/libthr/ (props changed) Modified: stable/7/lib/libthr/thread/thr_rtld.c ============================================================================== --- stable/7/lib/libthr/thread/thr_rtld.c Thu Oct 7 12:34:54 2010 (r213512) +++ stable/7/lib/libthr/thread/thr_rtld.c Thu Oct 7 12:57:16 2010 (r213513) @@ -151,8 +151,8 @@ _thr_rtld_lock_release(void *lock) state = l->lock.rw_state; if (_thr_rwlock_unlock(&l->lock) == 0) { - curthread->rdlock_count--; if ((state & URWLOCK_WRITE_OWNER) == 0) { + curthread->rdlock_count--; THR_CRITICAL_LEAVE(curthread); } else { _thr_signal_unblock(curthread); From owner-svn-src-stable-7@FreeBSD.ORG Thu Oct 7 13:13:02 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DFD0106564A; Thu, 7 Oct 2010 13:13:02 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C5148FC0C; Thu, 7 Oct 2010 13:13:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o97DD27X042126; Thu, 7 Oct 2010 13:13:02 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o97DD2vD042123; Thu, 7 Oct 2010 13:13:02 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201010071313.o97DD2vD042123@svn.freebsd.org> From: David Xu Date: Thu, 7 Oct 2010 13:13:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213515 - stable/7/sys/kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Oct 2010 13:13:02 -0000 Author: davidxu Date: Thu Oct 7 13:13:02 2010 New Revision: 213515 URL: http://svn.freebsd.org/changeset/base/213515 Log: MFC r213258: - kern_sched_rr_get_interval should return interval for thread 1 in target process. - eliminate a goto. Modified: stable/7/sys/kern/p1003_1b.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/p1003_1b.c ============================================================================== --- stable/7/sys/kern/p1003_1b.c Thu Oct 7 12:58:09 2010 (r213514) +++ stable/7/sys/kern/p1003_1b.c Thu Oct 7 13:13:02 2010 (r213515) @@ -219,10 +219,8 @@ sched_getscheduler(struct thread *td, st PROC_LOCK(targetp); } else { targetp = pfind(uap->pid); - if (targetp == NULL) { - e = ESRCH; - goto done2; - } + if (targetp == NULL) + return (ESRCH); targettd = FIRST_THREAD_IN_PROC(targetp); /* XXXKSE */ } @@ -233,7 +231,6 @@ sched_getscheduler(struct thread *td, st } PROC_UNLOCK(targetp); -done2: return (e); } @@ -293,13 +290,10 @@ kern_sched_rr_get_interval(struct thread targetp = td->td_proc; PROC_LOCK(targetp); } else { - targetp = td->td_proc; - PROC_LOCK(targetp); - targettd = thread_find(targetp, pid); - if (targettd == NULL) { - PROC_UNLOCK(targetp); + targetp = pfind(pid); + if (targetp == NULL) return (ESRCH); - } + targettd = FIRST_THREAD_IN_PROC(targetp); } e = p_cansee(td, targetp); From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 07:54:55 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 82FE2106564A; Fri, 8 Oct 2010 07:54:55 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 70AD48FC13; Fri, 8 Oct 2010 07:54:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o987stG1083472; Fri, 8 Oct 2010 07:54:55 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o987stDM083470; Fri, 8 Oct 2010 07:54:55 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201010080754.o987stDM083470@svn.freebsd.org> From: Andriy Gapon Date: Fri, 8 Oct 2010 07:54:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213555 - stable/7/sys/kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 07:54:55 -0000 Author: avg Date: Fri Oct 8 07:54:55 2010 New Revision: 213555 URL: http://svn.freebsd.org/changeset/base/213555 Log: MFC r213303: kmem_size* sysctls: hint that these are also tunables Modified: stable/7/sys/kern/kern_malloc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/kern_malloc.c ============================================================================== --- stable/7/sys/kern/kern_malloc.c Fri Oct 8 07:52:00 2010 (r213554) +++ stable/7/sys/kern/kern_malloc.c Fri Oct 8 07:54:55 2010 (r213555) @@ -182,19 +182,19 @@ struct { static uma_zone_t mt_zone; u_long vm_kmem_size; -SYSCTL_ULONG(_vm, OID_AUTO, kmem_size, CTLFLAG_RD, &vm_kmem_size, 0, +SYSCTL_ULONG(_vm, OID_AUTO, kmem_size, CTLFLAG_RDTUN, &vm_kmem_size, 0, "Size of kernel memory"); static u_long vm_kmem_size_min; -SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_min, CTLFLAG_RD, &vm_kmem_size_min, 0, +SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_min, CTLFLAG_RDTUN, &vm_kmem_size_min, 0, "Minimum size of kernel memory"); static u_long vm_kmem_size_max; -SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_max, CTLFLAG_RD, &vm_kmem_size_max, 0, +SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_max, CTLFLAG_RDTUN, &vm_kmem_size_max, 0, "Maximum size of kernel memory"); static u_int vm_kmem_size_scale; -SYSCTL_UINT(_vm, OID_AUTO, kmem_size_scale, CTLFLAG_RD, &vm_kmem_size_scale, 0, +SYSCTL_UINT(_vm, OID_AUTO, kmem_size_scale, CTLFLAG_RDTUN, &vm_kmem_size_scale, 0, "Scale factor for kernel memory size"); /* From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 07:58:58 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15BB71065694; Fri, 8 Oct 2010 07:58:58 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 043738FC2D; Fri, 8 Oct 2010 07:58:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o987wvn7083667; Fri, 8 Oct 2010 07:58:57 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o987wvaL083665; Fri, 8 Oct 2010 07:58:57 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201010080758.o987wvaL083665@svn.freebsd.org> From: Andriy Gapon Date: Fri, 8 Oct 2010 07:58:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213557 - stable/7/sys/kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 07:58:58 -0000 Author: avg Date: Fri Oct 8 07:58:57 2010 New Revision: 213557 URL: http://svn.freebsd.org/changeset/base/213557 Log: MFC r213304: debug.kdb.stop_cpus sysctl: hint that this is also a tunable Modified: stable/7/sys/kern/subr_kdb.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/subr_kdb.c ============================================================================== --- stable/7/sys/kern/subr_kdb.c Fri Oct 8 07:57:19 2010 (r213556) +++ stable/7/sys/kern/subr_kdb.c Fri Oct 8 07:58:57 2010 (r213557) @@ -92,7 +92,7 @@ SYSCTL_PROC(_debug_kdb, OID_AUTO, trap_c */ #ifdef SMP static int kdb_stop_cpus = 1; -SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus, CTLTYPE_INT | CTLFLAG_RW, +SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus, CTLFLAG_RW | CTLFLAG_TUN, &kdb_stop_cpus, 0, "stop other CPUs when entering the debugger"); TUNABLE_INT("debug.kdb.stop_cpus", &kdb_stop_cpus); #endif From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 08:09:46 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 16881106564A; Fri, 8 Oct 2010 08:09:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 04C0A8FC12; Fri, 8 Oct 2010 08:09:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9889jvu084019; Fri, 8 Oct 2010 08:09:45 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9889jMH084016; Fri, 8 Oct 2010 08:09:45 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201010080809.o9889jMH084016@svn.freebsd.org> From: Andriy Gapon Date: Fri, 8 Oct 2010 08:09:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213559 - in stable/7/sys: gdb kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 08:09:46 -0000 Author: avg Date: Fri Oct 8 08:09:45 2010 New Revision: 213559 URL: http://svn.freebsd.org/changeset/base/213559 Log: MFC r213305: there must be only one SYSINIT with SI_SUB_RUN_SCHEDULER+SI_ORDER_ANY order Modified: stable/7/sys/gdb/gdb_cons.c stable/7/sys/kern/kern_ntptime.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/gdb/gdb_cons.c ============================================================================== --- stable/7/sys/gdb/gdb_cons.c Fri Oct 8 08:01:36 2010 (r213558) +++ stable/7/sys/gdb/gdb_cons.c Fri Oct 8 08:09:45 2010 (r213559) @@ -126,7 +126,7 @@ oktousecallout(void *data __unused) { calloutok = 1; } -SYSINIT(gdbhack, SI_SUB_RUN_SCHEDULER, SI_ORDER_ANY, oktousecallout, NULL); +SYSINIT(gdbhack, SI_SUB_RUN_SCHEDULER, SI_ORDER_MIDDLE, oktousecallout, NULL); static void gdb_cnputc(struct consdev *cp, int c) Modified: stable/7/sys/kern/kern_ntptime.c ============================================================================== --- stable/7/sys/kern/kern_ntptime.c Fri Oct 8 08:01:36 2010 (r213558) +++ stable/7/sys/kern/kern_ntptime.c Fri Oct 8 08:09:45 2010 (r213559) @@ -1037,5 +1037,5 @@ start_periodic_resettodr(void *arg __unu periodic_resettodr, NULL); } -SYSINIT(periodic_resettodr, SI_SUB_RUN_SCHEDULER, SI_ORDER_ANY - 1, +SYSINIT(periodic_resettodr, SI_SUB_RUN_SCHEDULER, SI_ORDER_MIDDLE, start_periodic_resettodr, NULL); From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 08:14:43 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DA1D1065672; Fri, 8 Oct 2010 08:14:43 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6BF9C8FC19; Fri, 8 Oct 2010 08:14:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o988EhPo084231; Fri, 8 Oct 2010 08:14:43 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o988EhYA084229; Fri, 8 Oct 2010 08:14:43 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201010080814.o988EhYA084229@svn.freebsd.org> From: Andriy Gapon Date: Fri, 8 Oct 2010 08:14:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213561 - stable/7/sys/kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 08:14:43 -0000 Author: avg Date: Fri Oct 8 08:14:43 2010 New Revision: 213561 URL: http://svn.freebsd.org/changeset/base/213561 Log: MFC r213322: sysctls in kern_shutdown: add twin tunables Modified: stable/7/sys/kern/kern_shutdown.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/kern_shutdown.c ============================================================================== --- stable/7/sys/kern/kern_shutdown.c Fri Oct 8 08:13:22 2010 (r213560) +++ stable/7/sys/kern/kern_shutdown.c Fri Oct 8 08:14:43 2010 (r213561) @@ -97,21 +97,24 @@ int debugger_on_panic = 0; #else int debugger_on_panic = 1; #endif -SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW, +SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW | CTLFLAG_TUN, &debugger_on_panic, 0, "Run debugger on kernel panic"); +TUNABLE_INT("debug.debugger_on_panic", &debugger_on_panic); #ifdef KDB_TRACE -int trace_on_panic = 1; +static int trace_on_panic = 1; #else -int trace_on_panic = 0; +static int trace_on_panic = 0; #endif -SYSCTL_INT(_debug, OID_AUTO, trace_on_panic, CTLFLAG_RW, +SYSCTL_INT(_debug, OID_AUTO, trace_on_panic, CTLFLAG_RW | CTLFLAG_TUN, &trace_on_panic, 0, "Print stack trace on kernel panic"); +TUNABLE_INT("debug.trace_on_panic", &trace_on_panic); #endif /* KDB */ -int sync_on_panic = 0; -SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RW, +static int sync_on_panic = 0; +SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RW | CTLFLAG_TUN, &sync_on_panic, 0, "Do a sync before rebooting from a panic"); +TUNABLE_INT("kern.sync_on_panic", &sync_on_panic); SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0, "Shutdown environment"); From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 18:06:30 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 84F921065670; Fri, 8 Oct 2010 18:06:30 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 759628FC08; Fri, 8 Oct 2010 18:06:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98I6UKd002323; Fri, 8 Oct 2010 18:06:30 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98I6Ujv002321; Fri, 8 Oct 2010 18:06:30 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201010081806.o98I6Ujv002321@svn.freebsd.org> From: Matthew D Fleming Date: Fri, 8 Oct 2010 18:06:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213589 - stable/7/sys/cam/scsi X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 18:06:30 -0000 Author: mdf Date: Fri Oct 8 18:06:30 2010 New Revision: 213589 URL: http://svn.freebsd.org/changeset/base/213589 Log: MFC r212926: Use destroy_dev_sched(9) instead of destroy_dev(9) in passcleanup() as it is indirectly a d_close method. Modified: stable/7/sys/cam/scsi/scsi_pass.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/cam/scsi/scsi_pass.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_pass.c Fri Oct 8 18:06:15 2010 (r213588) +++ stable/7/sys/cam/scsi/scsi_pass.c Fri Oct 8 18:06:30 2010 (r213589) @@ -169,7 +169,11 @@ passcleanup(struct cam_periph *periph) xpt_print(periph->path, "removing device entry\n"); devstat_remove_entry(softc->device_stats); cam_periph_unlock(periph); - destroy_dev(softc->dev); + /* + * passcleanup() is indirectly a d_close method via passclose, + * so using destroy_dev(9) directly can result in deadlock. + */ + destroy_dev_sched(softc->dev); cam_periph_lock(periph); free(softc, M_DEVBUF); } From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 18:26:15 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5F8E106564A; Fri, 8 Oct 2010 18:26:14 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D549F8FC08; Fri, 8 Oct 2010 18:26:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98IQEtf002901; Fri, 8 Oct 2010 18:26:14 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98IQEth002899; Fri, 8 Oct 2010 18:26:14 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010081826.o98IQEth002899@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 18:26:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213591 - stable/7/sys/pci X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 18:26:15 -0000 Author: yongari Date: Fri Oct 8 18:26:14 2010 New Revision: 213591 URL: http://svn.freebsd.org/changeset/base/213591 Log: MFC r213306: Rename rl_setmulti() to rl_rxfilter() as rl_rxfilter() will handle IFF_ALLMULTI/IFF_PROMISC as well as multicast filter configuration. Rewrite RX filter logic to reduce number of register accesses and make it handle promiscuous/allmulti toggling without controller reinitialization. Previously rl(4) counted on controller reinitialization to reprogram promiscuous configuration but r211767 resulted in avoiding controller reinitialization whenever promiscuous mode is toggled. To address this, keep track of driver's view of interface state and handle IFF_ALLMULTI/IFF_PROMISC changes without reinitializing controller. This should fix a regression introduced in r211267. While I'm here remove unnecessary variable reassignment in ioctl handler. PR: kern/151079 Modified: stable/7/sys/pci/if_rl.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/pci/if_rl.c ============================================================================== --- stable/7/sys/pci/if_rl.c Fri Oct 8 18:19:05 2010 (r213590) +++ stable/7/sys/pci/if_rl.c Fri Oct 8 18:26:14 2010 (r213591) @@ -203,7 +203,7 @@ static void rl_read_eeprom(struct rl_sof static void rl_reset(struct rl_softc *); static int rl_resume(device_t); static void rl_rxeof(struct rl_softc *); -static void rl_setmulti(struct rl_softc *); +static void rl_rxfilter(struct rl_softc *); static int rl_shutdown(device_t); static void rl_start(struct ifnet *); static void rl_start_locked(struct ifnet *); @@ -655,54 +655,51 @@ rl_miibus_statchg(device_t dev) * Program the 64-bit multicast hash filter. */ static void -rl_setmulti(struct rl_softc *sc) +rl_rxfilter(struct rl_softc *sc) { struct ifnet *ifp = sc->rl_ifp; int h = 0; uint32_t hashes[2] = { 0, 0 }; struct ifmultiaddr *ifma; uint32_t rxfilt; - int mcnt = 0; RL_LOCK_ASSERT(sc); rxfilt = CSR_READ_4(sc, RL_RXCFG); - + rxfilt &= ~(RL_RXCFG_RX_ALLPHYS | RL_RXCFG_RX_BROAD | + RL_RXCFG_RX_MULTI); + /* Always accept frames destined for this host. */ + rxfilt |= RL_RXCFG_RX_INDIV; + /* Set capture broadcast bit to capture broadcast frames. */ + if (ifp->if_flags & IFF_BROADCAST) + rxfilt |= RL_RXCFG_RX_BROAD; if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) { rxfilt |= RL_RXCFG_RX_MULTI; - CSR_WRITE_4(sc, RL_RXCFG, rxfilt); - CSR_WRITE_4(sc, RL_MAR0, 0xFFFFFFFF); - CSR_WRITE_4(sc, RL_MAR4, 0xFFFFFFFF); - return; - } - - /* first, zot all the existing hash bits */ - CSR_WRITE_4(sc, RL_MAR0, 0); - CSR_WRITE_4(sc, RL_MAR4, 0); - - /* now program new ones */ - IF_ADDR_LOCK(ifp); - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - h = ether_crc32_be(LLADDR((struct sockaddr_dl *) - ifma->ifma_addr), ETHER_ADDR_LEN) >> 26; - if (h < 32) - hashes[0] |= (1 << h); - else - hashes[1] |= (1 << (h - 32)); - mcnt++; + if (ifp->if_flags & IFF_PROMISC) + rxfilt |= RL_RXCFG_RX_ALLPHYS; + hashes[0] = 0xFFFFFFFF; + hashes[1] = 0xFFFFFFFF; + } else { + /* Now program new ones. */ + IF_ADDR_LOCK(ifp); + TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + h = ether_crc32_be(LLADDR((struct sockaddr_dl *) + ifma->ifma_addr), ETHER_ADDR_LEN) >> 26; + if (h < 32) + hashes[0] |= (1 << h); + else + hashes[1] |= (1 << (h - 32)); + } + IF_ADDR_UNLOCK(ifp); + if (hashes[0] != 0 || hashes[1] != 0) + rxfilt |= RL_RXCFG_RX_MULTI; } - IF_ADDR_UNLOCK(ifp); - - if (mcnt) - rxfilt |= RL_RXCFG_RX_MULTI; - else - rxfilt &= ~RL_RXCFG_RX_MULTI; - CSR_WRITE_4(sc, RL_RXCFG, rxfilt); CSR_WRITE_4(sc, RL_MAR0, hashes[0]); CSR_WRITE_4(sc, RL_MAR4, hashes[1]); + CSR_WRITE_4(sc, RL_RXCFG, rxfilt); } static void @@ -1800,7 +1797,6 @@ rl_init_locked(struct rl_softc *sc) { struct ifnet *ifp = sc->rl_ifp; struct mii_data *mii; - uint32_t rxcfg = 0; uint32_t eaddr[2]; RL_LOCK_ASSERT(sc); @@ -1857,30 +1853,8 @@ rl_init_locked(struct rl_softc *sc) CSR_WRITE_4(sc, RL_TXCFG, RL_TXCFG_CONFIG); CSR_WRITE_4(sc, RL_RXCFG, RL_RXCFG_CONFIG); - /* Set the individual bit to receive frames for this host only. */ - rxcfg = CSR_READ_4(sc, RL_RXCFG); - rxcfg |= RL_RXCFG_RX_INDIV; - - /* If we want promiscuous mode, set the allframes bit. */ - if (ifp->if_flags & IFF_PROMISC) { - rxcfg |= RL_RXCFG_RX_ALLPHYS; - CSR_WRITE_4(sc, RL_RXCFG, rxcfg); - } else { - rxcfg &= ~RL_RXCFG_RX_ALLPHYS; - CSR_WRITE_4(sc, RL_RXCFG, rxcfg); - } - - /* Set capture broadcast bit to capture broadcast frames. */ - if (ifp->if_flags & IFF_BROADCAST) { - rxcfg |= RL_RXCFG_RX_BROAD; - CSR_WRITE_4(sc, RL_RXCFG, rxcfg); - } else { - rxcfg &= ~RL_RXCFG_RX_BROAD; - CSR_WRITE_4(sc, RL_RXCFG, rxcfg); - } - - /* Program the multicast filter, if necessary. */ - rl_setmulti(sc); + /* Set RX filter. */ + rl_rxfilter(sc); #ifdef DEVICE_POLLING /* Disable interrupts if we are polling. */ @@ -1959,20 +1933,22 @@ rl_ioctl(struct ifnet *ifp, u_long comma case SIOCSIFFLAGS: RL_LOCK(sc); if (ifp->if_flags & IFF_UP) { - rl_init_locked(sc); - } else { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) - rl_stop(sc); - } + if (ifp->if_drv_flags & IFF_DRV_RUNNING && + ((ifp->if_flags ^ sc->rl_if_flags) & + (IFF_PROMISC | IFF_ALLMULTI))) + rl_rxfilter(sc); + else + rl_init_locked(sc); + } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) + rl_stop(sc); + sc->rl_if_flags = ifp->if_flags; RL_UNLOCK(sc); - error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: RL_LOCK(sc); - rl_setmulti(sc); + rl_rxfilter(sc); RL_UNLOCK(sc); - error = 0; break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 18:31:56 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D7F6106564A; Fri, 8 Oct 2010 18:31:56 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4D3AE8FC12; Fri, 8 Oct 2010 18:31:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98IVuUK003073; Fri, 8 Oct 2010 18:31:56 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98IVuAT003071; Fri, 8 Oct 2010 18:31:56 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010081831.o98IVuAT003071@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 18:31:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213592 - stable/7/sys/pci X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 18:31:56 -0000 Author: yongari Date: Fri Oct 8 18:31:56 2010 New Revision: 213592 URL: http://svn.freebsd.org/changeset/base/213592 Log: MFC r188392: Destroy TX tag outside of loop scope. Found with: Coverity Prevent(tm) CID: 3886 Modified: stable/7/sys/pci/if_rl.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/pci/if_rl.c ============================================================================== --- stable/7/sys/pci/if_rl.c Fri Oct 8 18:26:14 2010 (r213591) +++ stable/7/sys/pci/if_rl.c Fri Oct 8 18:31:56 2010 (r213592) @@ -1173,9 +1173,9 @@ rl_dma_free(struct rl_softc *sc) sc->rl_cdata.rl_tx_dmamap[i]); sc->rl_cdata.rl_tx_dmamap[i] = NULL; } + } bus_dma_tag_destroy(sc->rl_cdata.rl_tx_tag); sc->rl_cdata.rl_tx_tag = NULL; - } } if (sc->rl_parent_tag != NULL) { From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 18:46:02 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B046A106564A; Fri, 8 Oct 2010 18:46:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9DD828FC1A; Fri, 8 Oct 2010 18:46:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98Ik2qn003620; Fri, 8 Oct 2010 18:46:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98Ik2hL003617; Fri, 8 Oct 2010 18:46:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010081846.o98Ik2hL003617@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 18:46:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213594 - stable/7/sys/dev/bge X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 18:46:02 -0000 Author: yongari Date: Fri Oct 8 18:46:02 2010 New Revision: 213594 URL: http://svn.freebsd.org/changeset/base/213594 Log: MFC r212061,212065,212302: r212061: Split common parent DMA tag into ring DMA tag and TX/RX mbuf DMA tag. All controllers that are not BCM5755 or higher have 4GB boundary DMA bug. Previously bge(4) used 32bit DMA address to workaround the bug(r199670). However this caused the use of bounce buffers such that it resulted in poor performance for systems which have more than 4GB memory. Because bus_dma(9) honors boundary restriction requirement of DMA tag for dynamic buffers, having a separate TX/RX mbuf DMA tag will greatly reduce the possibility of using bounce buffers. For DMA buffers allocated with bus_dmamem_alloc(9), now bge(4) explicitly checks whether the requested memory region crossed the boundary or not. With this change, only the DMA buffer that crossed the boundary will use 32bit DMA address. Other DMA buffers are not affected as separate DMA tag is created for each DMA buffer. Even if 32bit DMA address space is used for a buffer, the chance to use bounce buffer is still very low as the size of buffer is small. This change should eliminate most usage of bounce buffers on systems that have more than 4GB memory. More correct fix would be teaching bus_dma(9) to honor boundary restriction for buffers created with bus_dmamem_alloc(9) but it seems that is not easy. While I'm here cleanup bge_dma_map_addr() and remove unnecessary member variables in bge_dmamap_arg structure. Tested by: marcel r212065: Handle PAE case correctly. You cannot effectively specify a 4GB boundary in PAE case so use a 2GB boundary for PAE as suggested by jhb. Pointed out by: jhb Reviewed by: jhb r212302: Make sure to create DMA'able memory for statistics block. This was missed in r212061 and it caused crashes for 570x controllers as controller DMAed statistics to physical address 0. Reported by: kan Modified: stable/7/sys/dev/bge/if_bge.c stable/7/sys/dev/bge/if_bgereg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/bge/if_bge.c ============================================================================== --- stable/7/sys/dev/bge/if_bge.c Fri Oct 8 18:43:06 2010 (r213593) +++ stable/7/sys/dev/bge/if_bge.c Fri Oct 8 18:46:02 2010 (r213594) @@ -355,8 +355,10 @@ static int bge_suspend(device_t); static int bge_resume(device_t); static void bge_release_resources(struct bge_softc *); static void bge_dma_map_addr(void *, bus_dma_segment_t *, int, int); -static int bge_dma_alloc(device_t); +static int bge_dma_alloc(struct bge_softc *); static void bge_dma_free(struct bge_softc *); +static int bge_dma_ring_alloc(struct bge_softc *, bus_size_t, bus_size_t, + bus_dma_tag_t *, uint8_t **, bus_dmamap_t *, bus_addr_t *, const char *); static int bge_get_eaddr_fw(struct bge_softc *sc, uint8_t ether_addr[]); static int bge_get_eaddr_mem(struct bge_softc *, uint8_t[]); @@ -614,13 +616,9 @@ bge_dma_map_addr(void *arg, bus_dma_segm if (error) return; - ctx = arg; - - if (nseg > ctx->bge_maxsegs) { - ctx->bge_maxsegs = 0; - return; - } + KASSERT(nseg == 1, ("%s: %d segments returned!", __func__, nseg)); + ctx = arg; ctx->bge_busaddr = segs->ds_addr; } @@ -2122,27 +2120,84 @@ bge_dma_free(struct bge_softc *sc) if (sc->bge_cdata.bge_stats_tag) bus_dma_tag_destroy(sc->bge_cdata.bge_stats_tag); + if (sc->bge_cdata.bge_buffer_tag) + bus_dma_tag_destroy(sc->bge_cdata.bge_buffer_tag); + /* Destroy the parent tag. */ if (sc->bge_cdata.bge_parent_tag) bus_dma_tag_destroy(sc->bge_cdata.bge_parent_tag); } static int -bge_dma_alloc(device_t dev) +bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t alignment, + bus_size_t maxsize, bus_dma_tag_t *tag, uint8_t **ring, bus_dmamap_t *map, + bus_addr_t *paddr, const char *msg) { struct bge_dmamap_arg ctx; - struct bge_softc *sc; bus_addr_t lowaddr; - bus_size_t sbsz, txsegsz, txmaxsegsz; - int i, error; + bus_size_t ring_end; + int error; - sc = device_get_softc(dev); + lowaddr = BUS_SPACE_MAXADDR; +again: + error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, + alignment, 0, lowaddr, BUS_SPACE_MAXADDR, NULL, + NULL, maxsize, 1, maxsize, 0, NULL, NULL, tag); + if (error != 0) { + device_printf(sc->bge_dev, + "could not create %s dma tag\n", msg); + return (ENOMEM); + } + /* Allocate DMA'able memory for ring. */ + error = bus_dmamem_alloc(*tag, (void **)ring, + BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, map); + if (error != 0) { + device_printf(sc->bge_dev, + "could not allocate DMA'able memory for %s\n", msg); + return (ENOMEM); + } + /* Load the address of the ring. */ + ctx.bge_busaddr = 0; + error = bus_dmamap_load(*tag, *map, *ring, maxsize, bge_dma_map_addr, + &ctx, BUS_DMA_NOWAIT); + if (error != 0) { + device_printf(sc->bge_dev, + "could not load DMA'able memory for %s\n", msg); + return (ENOMEM); + } + *paddr = ctx.bge_busaddr; + ring_end = *paddr + maxsize; + if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0 && + BGE_ADDR_HI(*paddr) != BGE_ADDR_HI(ring_end)) { + /* + * 4GB boundary crossed. Limit maximum allowable DMA + * address space to 32bit and try again. + */ + bus_dmamap_unload(*tag, *map); + bus_dmamem_free(*tag, *ring, *map); + bus_dma_tag_destroy(*tag); + if (bootverbose) + device_printf(sc->bge_dev, "4GB boundary crossed, " + "limit DMA address space to 32bit for %s\n", msg); + *ring = NULL; + *tag = NULL; + *map = NULL; + lowaddr = BUS_SPACE_MAXADDR_32BIT; + goto again; + } + return (0); +} + +static int +bge_dma_alloc(struct bge_softc *sc) +{ + bus_addr_t lowaddr; + bus_size_t boundary, sbsz, txsegsz, txmaxsegsz; + int i, error; lowaddr = BUS_SPACE_MAXADDR; if ((sc->bge_flags & BGE_FLAG_40BIT_BUG) != 0) lowaddr = BGE_DMA_MAXADDR; - if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) - lowaddr = BUS_SPACE_MAXADDR_32BIT; /* * Allocate the parent bus DMA tag appropriate for PCI. */ @@ -2150,16 +2205,93 @@ bge_dma_alloc(device_t dev) 1, 0, lowaddr, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->bge_cdata.bge_parent_tag); - if (error != 0) { device_printf(sc->bge_dev, "could not allocate parent dma tag\n"); return (ENOMEM); } + /* Create tag for standard RX ring. */ + error = bge_dma_ring_alloc(sc, PAGE_SIZE, BGE_STD_RX_RING_SZ, + &sc->bge_cdata.bge_rx_std_ring_tag, + (uint8_t **)&sc->bge_ldata.bge_rx_std_ring, + &sc->bge_cdata.bge_rx_std_ring_map, + &sc->bge_ldata.bge_rx_std_ring_paddr, "RX ring"); + if (error) + return (error); + + /* Create tag for RX return ring. */ + error = bge_dma_ring_alloc(sc, PAGE_SIZE, BGE_RX_RTN_RING_SZ(sc), + &sc->bge_cdata.bge_rx_return_ring_tag, + (uint8_t **)&sc->bge_ldata.bge_rx_return_ring, + &sc->bge_cdata.bge_rx_return_ring_map, + &sc->bge_ldata.bge_rx_return_ring_paddr, "RX return ring"); + if (error) + return (error); + + /* Create tag for TX ring. */ + error = bge_dma_ring_alloc(sc, PAGE_SIZE, BGE_TX_RING_SZ, + &sc->bge_cdata.bge_tx_ring_tag, + (uint8_t **)&sc->bge_ldata.bge_tx_ring, + &sc->bge_cdata.bge_tx_ring_map, + &sc->bge_ldata.bge_tx_ring_paddr, "TX ring"); + if (error) + return (error); + /* - * Create tag for Tx mbufs. + * Create tag for status block. + * Because we only use single Tx/Rx/Rx return ring, use + * minimum status block size except BCM5700 AX/BX which + * seems to want to see full status block size regardless + * of configured number of ring. */ + if (sc->bge_asicrev == BGE_ASICREV_BCM5700 && + sc->bge_chipid != BGE_CHIPID_BCM5700_C0) + sbsz = BGE_STATUS_BLK_SZ; + else + sbsz = 32; + error = bge_dma_ring_alloc(sc, PAGE_SIZE, sbsz, + &sc->bge_cdata.bge_status_tag, + (uint8_t **)&sc->bge_ldata.bge_status_block, + &sc->bge_cdata.bge_status_map, + &sc->bge_ldata.bge_status_block_paddr, "status block"); + if (error) + return (error); + + /* Create tag for statistics block. */ + error = bge_dma_ring_alloc(sc, PAGE_SIZE, BGE_STATS_SZ, + &sc->bge_cdata.bge_stats_tag, + (uint8_t **)&sc->bge_ldata.bge_stats, + &sc->bge_cdata.bge_stats_map, + &sc->bge_ldata.bge_stats_paddr, "statistics block"); + if (error) + return (error); + + /* Create tag for jumbo RX ring. */ + if (BGE_IS_JUMBO_CAPABLE(sc)) { + error = bge_dma_ring_alloc(sc, PAGE_SIZE, BGE_JUMBO_RX_RING_SZ, + &sc->bge_cdata.bge_rx_jumbo_ring_tag, + (uint8_t **)&sc->bge_ldata.bge_rx_jumbo_ring, + &sc->bge_cdata.bge_rx_jumbo_ring_map, + &sc->bge_ldata.bge_rx_jumbo_ring_paddr, "jumbo RX ring"); + if (error) + return (error); + } + + /* Create parent tag for buffers. */ + boundary = 0; + if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) + boundary = BGE_DMA_BNDRY; + error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), + 1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL, + NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, + 0, NULL, NULL, &sc->bge_cdata.bge_buffer_tag); + if (error != 0) { + device_printf(sc->bge_dev, + "could not allocate buffer dma tag\n"); + return (ENOMEM); + } + /* Create tag for Tx mbufs. */ if (sc->bge_flags & BGE_FLAG_TSO) { txsegsz = BGE_TSOSEG_SZ; txmaxsegsz = 65535 + sizeof(struct ether_vlan_header); @@ -2167,7 +2299,7 @@ bge_dma_alloc(device_t dev) txsegsz = MCLBYTES; txmaxsegsz = MCLBYTES * BGE_NSEG_NEW; } - error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, 1, + error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, txmaxsegsz, BGE_NSEG_NEW, txsegsz, 0, NULL, NULL, &sc->bge_cdata.bge_tx_mtag); @@ -2177,10 +2309,8 @@ bge_dma_alloc(device_t dev) return (ENOMEM); } - /* - * Create tag for Rx mbufs. - */ - error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, 1, 0, + /* Create tag for Rx mbufs. */ + error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag); @@ -2218,42 +2348,9 @@ bge_dma_alloc(device_t dev) } } - /* Create tag for standard RX ring. */ - error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, - PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, - NULL, BGE_STD_RX_RING_SZ, 1, BGE_STD_RX_RING_SZ, 0, - NULL, NULL, &sc->bge_cdata.bge_rx_std_ring_tag); - - if (error) { - device_printf(sc->bge_dev, "could not allocate dma tag\n"); - return (ENOMEM); - } - - /* Allocate DMA'able memory for standard RX ring. */ - error = bus_dmamem_alloc(sc->bge_cdata.bge_rx_std_ring_tag, - (void **)&sc->bge_ldata.bge_rx_std_ring, BUS_DMA_NOWAIT, - &sc->bge_cdata.bge_rx_std_ring_map); - if (error) - return (ENOMEM); - - bzero((char *)sc->bge_ldata.bge_rx_std_ring, BGE_STD_RX_RING_SZ); - - /* Load the address of the standard RX ring. */ - ctx.bge_maxsegs = 1; - ctx.sc = sc; - - error = bus_dmamap_load(sc->bge_cdata.bge_rx_std_ring_tag, - sc->bge_cdata.bge_rx_std_ring_map, sc->bge_ldata.bge_rx_std_ring, - BGE_STD_RX_RING_SZ, bge_dma_map_addr, &ctx, BUS_DMA_NOWAIT); - - if (error) - return (ENOMEM); - - sc->bge_ldata.bge_rx_std_ring_paddr = ctx.bge_busaddr; - - /* Create tags for jumbo mbufs. */ + /* Create tags for jumbo RX buffers. */ if (BGE_IS_JUMBO_CAPABLE(sc)) { - error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, + error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MJUM9BYTES, BGE_NSEG_JUMBO, PAGE_SIZE, 0, NULL, NULL, &sc->bge_cdata.bge_mtag_jumbo); @@ -2262,41 +2359,6 @@ bge_dma_alloc(device_t dev) "could not allocate jumbo dma tag\n"); return (ENOMEM); } - - /* Create tag for jumbo RX ring. */ - error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, - PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, - NULL, BGE_JUMBO_RX_RING_SZ, 1, BGE_JUMBO_RX_RING_SZ, 0, - NULL, NULL, &sc->bge_cdata.bge_rx_jumbo_ring_tag); - - if (error) { - device_printf(sc->bge_dev, - "could not allocate jumbo ring dma tag\n"); - return (ENOMEM); - } - - /* Allocate DMA'able memory for jumbo RX ring. */ - error = bus_dmamem_alloc(sc->bge_cdata.bge_rx_jumbo_ring_tag, - (void **)&sc->bge_ldata.bge_rx_jumbo_ring, - BUS_DMA_NOWAIT | BUS_DMA_ZERO, - &sc->bge_cdata.bge_rx_jumbo_ring_map); - if (error) - return (ENOMEM); - - /* Load the address of the jumbo RX ring. */ - ctx.bge_maxsegs = 1; - ctx.sc = sc; - - error = bus_dmamap_load(sc->bge_cdata.bge_rx_jumbo_ring_tag, - sc->bge_cdata.bge_rx_jumbo_ring_map, - sc->bge_ldata.bge_rx_jumbo_ring, BGE_JUMBO_RX_RING_SZ, - bge_dma_map_addr, &ctx, BUS_DMA_NOWAIT); - - if (error) - return (ENOMEM); - - sc->bge_ldata.bge_rx_jumbo_ring_paddr = ctx.bge_busaddr; - /* Create DMA maps for jumbo RX buffers. */ error = bus_dmamap_create(sc->bge_cdata.bge_mtag_jumbo, 0, &sc->bge_cdata.bge_rx_jumbo_sparemap); @@ -2314,154 +2376,8 @@ bge_dma_alloc(device_t dev) return (ENOMEM); } } - - } - - /* Create tag for RX return ring. */ - error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, - PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, - NULL, BGE_RX_RTN_RING_SZ(sc), 1, BGE_RX_RTN_RING_SZ(sc), 0, - NULL, NULL, &sc->bge_cdata.bge_rx_return_ring_tag); - - if (error) { - device_printf(sc->bge_dev, "could not allocate dma tag\n"); - return (ENOMEM); - } - - /* Allocate DMA'able memory for RX return ring. */ - error = bus_dmamem_alloc(sc->bge_cdata.bge_rx_return_ring_tag, - (void **)&sc->bge_ldata.bge_rx_return_ring, BUS_DMA_NOWAIT, - &sc->bge_cdata.bge_rx_return_ring_map); - if (error) - return (ENOMEM); - - bzero((char *)sc->bge_ldata.bge_rx_return_ring, - BGE_RX_RTN_RING_SZ(sc)); - - /* Load the address of the RX return ring. */ - ctx.bge_maxsegs = 1; - ctx.sc = sc; - - error = bus_dmamap_load(sc->bge_cdata.bge_rx_return_ring_tag, - sc->bge_cdata.bge_rx_return_ring_map, - sc->bge_ldata.bge_rx_return_ring, BGE_RX_RTN_RING_SZ(sc), - bge_dma_map_addr, &ctx, BUS_DMA_NOWAIT); - - if (error) - return (ENOMEM); - - sc->bge_ldata.bge_rx_return_ring_paddr = ctx.bge_busaddr; - - /* Create tag for TX ring. */ - error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, - PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, - NULL, BGE_TX_RING_SZ, 1, BGE_TX_RING_SZ, 0, NULL, NULL, - &sc->bge_cdata.bge_tx_ring_tag); - - if (error) { - device_printf(sc->bge_dev, "could not allocate dma tag\n"); - return (ENOMEM); - } - - /* Allocate DMA'able memory for TX ring. */ - error = bus_dmamem_alloc(sc->bge_cdata.bge_tx_ring_tag, - (void **)&sc->bge_ldata.bge_tx_ring, BUS_DMA_NOWAIT, - &sc->bge_cdata.bge_tx_ring_map); - if (error) - return (ENOMEM); - - bzero((char *)sc->bge_ldata.bge_tx_ring, BGE_TX_RING_SZ); - - /* Load the address of the TX ring. */ - ctx.bge_maxsegs = 1; - ctx.sc = sc; - - error = bus_dmamap_load(sc->bge_cdata.bge_tx_ring_tag, - sc->bge_cdata.bge_tx_ring_map, sc->bge_ldata.bge_tx_ring, - BGE_TX_RING_SZ, bge_dma_map_addr, &ctx, BUS_DMA_NOWAIT); - - if (error) - return (ENOMEM); - - sc->bge_ldata.bge_tx_ring_paddr = ctx.bge_busaddr; - - /* - * Create tag for status block. - * Because we only use single Tx/Rx/Rx return ring, use - * minimum status block size except BCM5700 AX/BX which - * seems to want to see full status block size regardless - * of configured number of ring. - */ - if (sc->bge_asicrev == BGE_ASICREV_BCM5700 && - sc->bge_chipid != BGE_CHIPID_BCM5700_C0) - sbsz = BGE_STATUS_BLK_SZ; - else - sbsz = 32; - error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, - PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, - NULL, sbsz, 1, sbsz, 0, NULL, NULL, &sc->bge_cdata.bge_status_tag); - - if (error) { - device_printf(sc->bge_dev, - "could not allocate status dma tag\n"); - return (ENOMEM); - } - - /* Allocate DMA'able memory for status block. */ - error = bus_dmamem_alloc(sc->bge_cdata.bge_status_tag, - (void **)&sc->bge_ldata.bge_status_block, BUS_DMA_NOWAIT, - &sc->bge_cdata.bge_status_map); - if (error) - return (ENOMEM); - - bzero((char *)sc->bge_ldata.bge_status_block, sbsz); - - /* Load the address of the status block. */ - ctx.sc = sc; - ctx.bge_maxsegs = 1; - - error = bus_dmamap_load(sc->bge_cdata.bge_status_tag, - sc->bge_cdata.bge_status_map, sc->bge_ldata.bge_status_block, - sbsz, bge_dma_map_addr, &ctx, BUS_DMA_NOWAIT); - - if (error) - return (ENOMEM); - - sc->bge_ldata.bge_status_block_paddr = ctx.bge_busaddr; - - /* Create tag for statistics block. */ - error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, - PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, - NULL, BGE_STATS_SZ, 1, BGE_STATS_SZ, 0, NULL, NULL, - &sc->bge_cdata.bge_stats_tag); - - if (error) { - device_printf(sc->bge_dev, "could not allocate dma tag\n"); - return (ENOMEM); } - /* Allocate DMA'able memory for statistics block. */ - error = bus_dmamem_alloc(sc->bge_cdata.bge_stats_tag, - (void **)&sc->bge_ldata.bge_stats, BUS_DMA_NOWAIT, - &sc->bge_cdata.bge_stats_map); - if (error) - return (ENOMEM); - - bzero((char *)sc->bge_ldata.bge_stats, BGE_STATS_SZ); - - /* Load the address of the statstics block. */ - ctx.sc = sc; - ctx.bge_maxsegs = 1; - - error = bus_dmamap_load(sc->bge_cdata.bge_stats_tag, - sc->bge_cdata.bge_stats_map, sc->bge_ldata.bge_stats, - BGE_STATS_SZ, bge_dma_map_addr, &ctx, BUS_DMA_NOWAIT); - - if (error) - return (ENOMEM); - - sc->bge_ldata.bge_stats_paddr = ctx.bge_busaddr; - return (0); } @@ -2788,7 +2704,7 @@ bge_attach(device_t dev) else sc->bge_return_ring_cnt = BGE_RETURN_RING_CNT; - if (bge_dma_alloc(dev)) { + if (bge_dma_alloc(sc)) { device_printf(sc->bge_dev, "failed to allocate DMA resources\n"); error = ENXIO; Modified: stable/7/sys/dev/bge/if_bgereg.h ============================================================================== --- stable/7/sys/dev/bge/if_bgereg.h Fri Oct 8 18:43:06 2010 (r213593) +++ stable/7/sys/dev/bge/if_bgereg.h Fri Oct 8 18:46:02 2010 (r213594) @@ -2487,6 +2487,16 @@ struct bge_gib { #define BGE_DMA_MAXADDR 0xFFFFFFFFFF #endif +#ifdef PAE +#define BGE_DMA_BNDRY 0x80000000 +#else +#if (BUS_SPACE_MAXADDR > 0xFFFFFFFF) +#define BGE_DMA_BNDRY 0x100000000 +#else +#define BGE_DMA_BNDRY 0 +#endif +#endif + /* * Ring structures. Most of these reside in host memory and we tell * the NIC where they are via the ring control blocks. The exceptions @@ -2530,6 +2540,7 @@ struct bge_ring_data { */ struct bge_chain_data { bus_dma_tag_t bge_parent_tag; + bus_dma_tag_t bge_buffer_tag; bus_dma_tag_t bge_rx_std_ring_tag; bus_dma_tag_t bge_rx_jumbo_ring_tag; bus_dma_tag_t bge_rx_return_ring_tag; @@ -2558,12 +2569,7 @@ struct bge_chain_data { }; struct bge_dmamap_arg { - struct bge_softc *sc; bus_addr_t bge_busaddr; - uint16_t bge_flags; - int bge_idx; - int bge_maxsegs; - struct bge_tx_bd *bge_ring; }; #define BGE_HWREV_TIGON 0x01 From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 18:51:29 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF27A106566C; Fri, 8 Oct 2010 18:51:28 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B3DB88FC19; Fri, 8 Oct 2010 18:51:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98IpSbk003872; Fri, 8 Oct 2010 18:51:28 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98IpSTf003870; Fri, 8 Oct 2010 18:51:28 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010081851.o98IpSTf003870@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 18:51:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213596 - stable/7/sys/dev/bge X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 18:51:29 -0000 Author: yongari Date: Fri Oct 8 18:51:28 2010 New Revision: 213596 URL: http://svn.freebsd.org/changeset/base/213596 Log: MFC r212069,212071: r212069: bge_txeof() already checks whether it has to free transmitted mbufs or not by comparing reported TX consumer index with saved index. So remove unnecessary check done after freeing transmitted mbufs. While I'm here nuke unnecessary variable initializations. r212071: Remove unnecessary atomic operation in bge_poll. bge(4) always holds a driver lock in the function entry and memory synchronization is handled by bus_dmamap_sync(9). Modified: stable/7/sys/dev/bge/if_bge.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/bge/if_bge.c ============================================================================== --- stable/7/sys/dev/bge/if_bge.c Fri Oct 8 18:49:59 2010 (r213595) +++ stable/7/sys/dev/bge/if_bge.c Fri Oct 8 18:51:28 2010 (r213596) @@ -3403,7 +3403,7 @@ bge_rxeof(struct bge_softc *sc, uint16_t static void bge_txeof(struct bge_softc *sc, uint16_t tx_cons) { - struct bge_tx_bd *cur_tx = NULL; + struct bge_tx_bd *cur_tx; struct ifnet *ifp; BGE_LOCK_ASSERT(sc); @@ -3421,7 +3421,7 @@ bge_txeof(struct bge_softc *sc, uint16_t * frames that have been sent. */ while (sc->bge_tx_saved_considx != tx_cons) { - uint32_t idx = 0; + uint32_t idx; idx = sc->bge_tx_saved_considx; cur_tx = &sc->bge_ldata.bge_tx_ring[idx]; @@ -3440,8 +3440,7 @@ bge_txeof(struct bge_softc *sc, uint16_t BGE_INC(sc->bge_tx_saved_considx, BGE_TX_RING_CNT); } - if (cur_tx != NULL) - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; if (sc->bge_txcnt == 0) sc->bge_timer = 0; } @@ -3466,8 +3465,8 @@ bge_poll(struct ifnet *ifp, enum poll_cm rx_prod = sc->bge_ldata.bge_status_block->bge_idx[0].bge_rx_prod_idx; tx_cons = sc->bge_ldata.bge_status_block->bge_idx[0].bge_tx_cons_idx; - statusword = atomic_readandclear_32( - &sc->bge_ldata.bge_status_block->bge_status); + statusword = sc->bge_ldata.bge_status_block->bge_status; + sc->bge_ldata.bge_status_block->bge_status = 0; bus_dmamap_sync(sc->bge_cdata.bge_status_tag, sc->bge_cdata.bge_status_map, From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 19:00:36 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E022106564A; Fri, 8 Oct 2010 19:00:36 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7C2888FC19; Fri, 8 Oct 2010 19:00:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98J0aSd004255; Fri, 8 Oct 2010 19:00:36 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98J0aaq004252; Fri, 8 Oct 2010 19:00:36 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010081900.o98J0aaq004252@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 19:00:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213598 - stable/7/sys/dev/mii X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 19:00:36 -0000 Author: yongari Date: Fri Oct 8 19:00:36 2010 New Revision: 213598 URL: http://svn.freebsd.org/changeset/base/213598 Log: MFC r212306-212307,212342: r212306: Remove trailing CR at EOL. r212307: Consistently use tab characters instead of tab + space characters. No functional changes. r212342: Correct definition of T2 mode bit of MRBE Message Page 5 Next Page Control Register. Modified: stable/7/sys/dev/mii/brgphy.c stable/7/sys/dev/mii/brgphyreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/mii/brgphy.c ============================================================================== --- stable/7/sys/dev/mii/brgphy.c Fri Oct 8 18:58:01 2010 (r213597) +++ stable/7/sys/dev/mii/brgphy.c Fri Oct 8 19:00:36 2010 (r213598) @@ -140,7 +140,7 @@ static const struct mii_phydesc brgphys[ MII_PHY_DESC(xxBROADCOM_ALT1, BCM5784), MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709C), MII_PHY_DESC(xxBROADCOM_ALT1, BCM5761), - MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709S), + MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709S), MII_PHY_DESC(BROADCOM2, BCM5906), MII_PHY_END }; @@ -242,11 +242,12 @@ brgphy_attach(device_t dev) bsc->serdes_flags |= BRGPHY_5708S; sc->mii_flags |= MIIF_HAVEFIBER; break; - case MII_MODEL_xxBROADCOM_ALT1_BCM5709S: - bsc->serdes_flags |= BRGPHY_5709S; - sc->mii_flags |= MIIF_HAVEFIBER; - break; - } break; + case MII_MODEL_xxBROADCOM_ALT1_BCM5709S: + bsc->serdes_flags |= BRGPHY_5709S; + sc->mii_flags |= MIIF_HAVEFIBER; + break; + } + break; default: device_printf(dev, "Unrecognized OUI for PHY!\n"); } @@ -625,7 +626,7 @@ brgphy_status(struct mii_softc *sc) PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, BRGPHY_5708S_DIG_PG0); xstat = PHY_READ(sc, BRGPHY_5708S_PG0_1000X_STAT1); - /* Check for MRBE auto-negotiated speed results. */ + /* Check for MRBE auto-negotiated speed results. */ switch (xstat & BRGPHY_5708S_PG0_1000X_STAT1_SPEED_MASK) { case BRGPHY_5708S_PG0_1000X_STAT1_SPEED_10: mii->mii_media_active |= IFM_10_FL; break; @@ -637,39 +638,39 @@ brgphy_status(struct mii_softc *sc) mii->mii_media_active |= IFM_2500_SX; break; } - /* Check for MRBE auto-negotiated duplex results. */ + /* Check for MRBE auto-negotiated duplex results. */ if (xstat & BRGPHY_5708S_PG0_1000X_STAT1_FDX) mii->mii_media_active |= IFM_FDX; else mii->mii_media_active |= IFM_HDX; - } else if (bsc->serdes_flags & BRGPHY_5709S) { + } else if (bsc->serdes_flags & BRGPHY_5709S) { - /* Select GP Status Block of the AN MMD, get autoneg results. */ - PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_GP_STATUS); + /* Select GP Status Block of the AN MMD, get autoneg results. */ + PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_GP_STATUS); xstat = PHY_READ(sc, BRGPHY_GP_STATUS_TOP_ANEG_STATUS); - /* Restore IEEE0 block (assumed in all brgphy(4) code). */ - PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_COMBO_IEEE0); + /* Restore IEEE0 block (assumed in all brgphy(4) code). */ + PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_COMBO_IEEE0); - /* Check for MRBE auto-negotiated speed results. */ - switch (xstat & BRGPHY_GP_STATUS_TOP_ANEG_SPEED_MASK) { - case BRGPHY_GP_STATUS_TOP_ANEG_SPEED_10: - mii->mii_media_active |= IFM_10_FL; break; - case BRGPHY_GP_STATUS_TOP_ANEG_SPEED_100: - mii->mii_media_active |= IFM_100_FX; break; - case BRGPHY_GP_STATUS_TOP_ANEG_SPEED_1G: - mii->mii_media_active |= IFM_1000_SX; break; - case BRGPHY_GP_STATUS_TOP_ANEG_SPEED_25G: - mii->mii_media_active |= IFM_2500_SX; break; + /* Check for MRBE auto-negotiated speed results. */ + switch (xstat & BRGPHY_GP_STATUS_TOP_ANEG_SPEED_MASK) { + case BRGPHY_GP_STATUS_TOP_ANEG_SPEED_10: + mii->mii_media_active |= IFM_10_FL; break; + case BRGPHY_GP_STATUS_TOP_ANEG_SPEED_100: + mii->mii_media_active |= IFM_100_FX; break; + case BRGPHY_GP_STATUS_TOP_ANEG_SPEED_1G: + mii->mii_media_active |= IFM_1000_SX; break; + case BRGPHY_GP_STATUS_TOP_ANEG_SPEED_25G: + mii->mii_media_active |= IFM_2500_SX; break; } - /* Check for MRBE auto-negotiated duplex results. */ + /* Check for MRBE auto-negotiated duplex results. */ if (xstat & BRGPHY_GP_STATUS_TOP_ANEG_FDX) mii->mii_media_active |= IFM_FDX; else mii->mii_media_active |= IFM_HDX; - } + } } @@ -1115,50 +1116,50 @@ brgphy_reset(struct mii_softc *sc) } else if (BCE_CHIP_NUM(bce_sc) == BCE_CHIP_NUM_5709 && (bce_sc->bce_phy_flags & BCE_PHY_SERDES_FLAG)) { - /* Select the SerDes Digital block of the AN MMD. */ - PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_SERDES_DIG); + /* Select the SerDes Digital block of the AN MMD. */ + PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_SERDES_DIG); val = PHY_READ(sc, BRGPHY_SERDES_DIG_1000X_CTL1); val &= ~BRGPHY_SD_DIG_1000X_CTL1_AUTODET; val |= BRGPHY_SD_DIG_1000X_CTL1_FIBER; PHY_WRITE(sc, BRGPHY_SERDES_DIG_1000X_CTL1, val); - /* Select the Over 1G block of the AN MMD. */ + /* Select the Over 1G block of the AN MMD. */ PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_OVER_1G); - /* Enable autoneg "Next Page" to advertise 2.5G support. */ - val = PHY_READ(sc, BRGPHY_OVER_1G_UNFORMAT_PG1); + /* Enable autoneg "Next Page" to advertise 2.5G support. */ + val = PHY_READ(sc, BRGPHY_OVER_1G_UNFORMAT_PG1); if (bce_sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) val |= BRGPHY_5708S_ANEG_NXT_PG_XMIT1_25G; else val &= ~BRGPHY_5708S_ANEG_NXT_PG_XMIT1_25G; PHY_WRITE(sc, BRGPHY_OVER_1G_UNFORMAT_PG1, val); - /* Select the Multi-Rate Backplane Ethernet block of the AN MMD. */ + /* Select the Multi-Rate Backplane Ethernet block of the AN MMD. */ PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_MRBE); - /* Enable MRBE speed autoneg. */ - val = PHY_READ(sc, BRGPHY_MRBE_MSG_PG5_NP); + /* Enable MRBE speed autoneg. */ + val = PHY_READ(sc, BRGPHY_MRBE_MSG_PG5_NP); val |= BRGPHY_MRBE_MSG_PG5_NP_MBRE | BRGPHY_MRBE_MSG_PG5_NP_T2; PHY_WRITE(sc, BRGPHY_MRBE_MSG_PG5_NP, val); - /* Select the Clause 73 User B0 block of the AN MMD. */ - PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_CL73_USER_B0); + /* Select the Clause 73 User B0 block of the AN MMD. */ + PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_CL73_USER_B0); - /* Enable MRBE speed autoneg. */ + /* Enable MRBE speed autoneg. */ PHY_WRITE(sc, BRGPHY_CL73_USER_B0_MBRE_CTL1, BRGPHY_CL73_USER_B0_MBRE_CTL1_NP_AFT_BP | BRGPHY_CL73_USER_B0_MBRE_CTL1_STA_MGR | BRGPHY_CL73_USER_B0_MBRE_CTL1_ANEG); - /* Restore IEEE0 block (assumed in all brgphy(4) code). */ - PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_COMBO_IEEE0); + /* Restore IEEE0 block (assumed in all brgphy(4) code). */ + PHY_WRITE(sc, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_COMBO_IEEE0); } else if (BCE_CHIP_NUM(bce_sc) == BCE_CHIP_NUM_5709) { if ((BCE_CHIP_REV(bce_sc) == BCE_CHIP_REV_Ax) || (BCE_CHIP_REV(bce_sc) == BCE_CHIP_REV_Bx)) brgphy_fixup_disable_early_dac(sc); - + brgphy_jumbo_settings(sc, ifp->if_mtu); brgphy_ethernet_wirespeed(sc); } else { Modified: stable/7/sys/dev/mii/brgphyreg.h ============================================================================== --- stable/7/sys/dev/mii/brgphyreg.h Fri Oct 8 18:58:01 2010 (r213597) +++ stable/7/sys/dev/mii/brgphyreg.h Fri Oct 8 19:00:36 2010 (r213598) @@ -39,21 +39,21 @@ * Broadcom BCM5400 registers */ -#define BRGPHY_MII_BMCR 0x00 -#define BRGPHY_BMCR_RESET 0x8000 -#define BRGPHY_BMCR_LOOP 0x4000 -#define BRGPHY_BMCR_SPD0 0x2000 /* Speed select, lower bit */ -#define BRGPHY_BMCR_AUTOEN 0x1000 /* Autoneg enabled */ -#define BRGPHY_BMCR_PDOWN 0x0800 /* Power down */ -#define BRGPHY_BMCR_ISO 0x0400 /* Isolate */ +#define BRGPHY_MII_BMCR 0x00 +#define BRGPHY_BMCR_RESET 0x8000 +#define BRGPHY_BMCR_LOOP 0x4000 +#define BRGPHY_BMCR_SPD0 0x2000 /* Speed select, lower bit */ +#define BRGPHY_BMCR_AUTOEN 0x1000 /* Autoneg enabled */ +#define BRGPHY_BMCR_PDOWN 0x0800 /* Power down */ +#define BRGPHY_BMCR_ISO 0x0400 /* Isolate */ #define BRGPHY_BMCR_STARTNEG 0x0200 /* Restart autoneg */ -#define BRGPHY_BMCR_FDX 0x0100 /* Duplex mode */ -#define BRGPHY_BMCR_CTEST 0x0080 /* Collision test enable */ -#define BRGPHY_BMCR_SPD1 0x0040 /* Speed select, upper bit */ - -#define BRGPHY_S1000 BRGPHY_BMCR_SPD1 /* 1000mbps */ -#define BRGPHY_S100 BRGPHY_BMCR_SPD0 /* 100mpbs */ -#define BRGPHY_S10 0 /* 10mbps */ +#define BRGPHY_BMCR_FDX 0x0100 /* Duplex mode */ +#define BRGPHY_BMCR_CTEST 0x0080 /* Collision test enable */ +#define BRGPHY_BMCR_SPD1 0x0040 /* Speed select, upper bit */ + +#define BRGPHY_S1000 BRGPHY_BMCR_SPD1 /* 1000mbps */ +#define BRGPHY_S100 BRGPHY_BMCR_SPD0 /* 100mpbs */ +#define BRGPHY_S10 0 /* 10mbps */ #define BRGPHY_MII_BMSR 0x01 #define BRGPHY_BMSR_EXTSTS 0x0100 /* Extended status present */ @@ -262,153 +262,153 @@ #define BRGPHY_IMR_LNK_CHG 0x0002 /* Link status change */ #define BRGPHY_IMR_CRCERR 0x0001 /* CRC error */ -/*******************************************************/ -/* Begin: Shared SerDes PHY register definitions */ -/*******************************************************/ - -/* SerDes autoneg is different from copper */ -#define BRGPHY_SERDES_ANAR 0x04 -#define BRGPHY_SERDES_ANAR_FDX 0x0020 -#define BRGPHY_SERDES_ANAR_HDX 0x0040 -#define BRGPHY_SERDES_ANAR_NO_PAUSE (0x0 << 7) -#define BRGPHY_SERDES_ANAR_SYM_PAUSE (0x1 << 7) -#define BRGPHY_SERDES_ANAR_ASYM_PAUSE (0x2 << 7) -#define BRGPHY_SERDES_ANAR_BOTH_PAUSE (0x3 << 7) - -#define BRGPHY_SERDES_ANLPAR 0x05 -#define BRGPHY_SERDES_ANLPAR_FDX 0x0020 -#define BRGPHY_SERDES_ANLPAR_HDX 0x0040 -#define BRGPHY_SERDES_ANLPAR_NO_PAUSE (0x0 << 7) -#define BRGPHY_SERDES_ANLPAR_SYM_PAUSE (0x1 << 7) -#define BRGPHY_SERDES_ANLPAR_ASYM_PAUSE (0x2 << 7) -#define BRGPHY_SERDES_ANLPAR_BOTH_PAUSE (0x3 << 7) - -/*******************************************************/ -/* End: Shared SerDes PHY register definitions */ -/*******************************************************/ - -/*******************************************************/ -/* Begin: PHY register values for the 5706 PHY */ -/*******************************************************/ - -/* - * Shadow register 0x1C, bit 15 is write enable, - * bits 14-10 select function (0x00 to 0x1F). - */ -#define BRGPHY_MII_SHADOW_1C 0x1C -#define BRGPHY_SHADOW_1C_WRITE_EN 0x8000 -#define BRGPHY_SHADOW_1C_SELECT_MASK 0x7C00 - +/*******************************************************/ +/* Begin: Shared SerDes PHY register definitions */ +/*******************************************************/ + +/* SerDes autoneg is different from copper */ +#define BRGPHY_SERDES_ANAR 0x04 +#define BRGPHY_SERDES_ANAR_FDX 0x0020 +#define BRGPHY_SERDES_ANAR_HDX 0x0040 +#define BRGPHY_SERDES_ANAR_NO_PAUSE (0x0 << 7) +#define BRGPHY_SERDES_ANAR_SYM_PAUSE (0x1 << 7) +#define BRGPHY_SERDES_ANAR_ASYM_PAUSE (0x2 << 7) +#define BRGPHY_SERDES_ANAR_BOTH_PAUSE (0x3 << 7) + +#define BRGPHY_SERDES_ANLPAR 0x05 +#define BRGPHY_SERDES_ANLPAR_FDX 0x0020 +#define BRGPHY_SERDES_ANLPAR_HDX 0x0040 +#define BRGPHY_SERDES_ANLPAR_NO_PAUSE (0x0 << 7) +#define BRGPHY_SERDES_ANLPAR_SYM_PAUSE (0x1 << 7) +#define BRGPHY_SERDES_ANLPAR_ASYM_PAUSE (0x2 << 7) +#define BRGPHY_SERDES_ANLPAR_BOTH_PAUSE (0x3 << 7) + +/*******************************************************/ +/* End: Shared SerDes PHY register definitions */ +/*******************************************************/ + +/*******************************************************/ +/* Begin: PHY register values for the 5706 PHY */ +/*******************************************************/ + +/* + * Shadow register 0x1C, bit 15 is write enable, + * bits 14-10 select function (0x00 to 0x1F). + */ +#define BRGPHY_MII_SHADOW_1C 0x1C +#define BRGPHY_SHADOW_1C_WRITE_EN 0x8000 +#define BRGPHY_SHADOW_1C_SELECT_MASK 0x7C00 + /* Shadow 0x1C Mode Control Register (select value 0x1F) */ -#define BRGPHY_SHADOW_1C_MODE_CTRL (0x1F << 10) +#define BRGPHY_SHADOW_1C_MODE_CTRL (0x1F << 10) /* When set, Regs 0-0x0F are 1000X, else 1000T */ -#define BRGPHY_SHADOW_1C_ENA_1000X 0x0001 +#define BRGPHY_SHADOW_1C_ENA_1000X 0x0001 + +#define BRGPHY_MII_TEST1 0x1E +#define BRGPHY_TEST1_TRIM_EN 0x0010 +#define BRGPHY_TEST1_CRC_EN 0x8000 + +#define BRGPHY_MII_TEST2 0x1F + +/*******************************************************/ +/* End: PHY register values for the 5706 PHY */ +/*******************************************************/ + +/*******************************************************/ +/* Begin: PHY register values for the 5708S SerDes PHY */ +/*******************************************************/ + +/* Autoneg Next Page Transmit 1 Regiser */ +#define BRGPHY_5708S_ANEG_NXT_PG_XMIT1 0x0B +#define BRGPHY_5708S_ANEG_NXT_PG_XMIT1_25G 0x0001 + +/* Use the BLOCK_ADDR register to select the page for registers 0x10 to 0x1E */ +#define BRGPHY_5708S_BLOCK_ADDR 0x1f +#define BRGPHY_5708S_DIG_PG0 0x0000 +#define BRGPHY_5708S_DIG3_PG2 0x0002 +#define BRGPHY_5708S_TX_MISC_PG5 0x0005 + +/* 5708S SerDes "Digital" Registers (page 0) */ +#define BRGPHY_5708S_PG0_1000X_CTL1 0x10 +#define BRGPHY_5708S_PG0_1000X_CTL1_AUTODET_EN 0x0010 +#define BRGPHY_5708S_PG0_1000X_CTL1_FIBER_MODE 0x0001 + +#define BRGPHY_5708S_PG0_1000X_STAT1 0x14 +#define BRGPHY_5708S_PG0_1000X_STAT1_LINK 0x0002 +#define BRGPHY_5708S_PG0_1000X_STAT1_FDX 0x0004 +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_MASK 0x0018 +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_10 (0x0 << 3) +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_100 (0x1 << 3) +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_1G (0x2 << 3) +#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_25G (0x3 << 3) + + +#define BRGPHY_5708S_PG0_1000X_CTL2 0x11 +#define BRGPHY_5708S_PG0_1000X_CTL2_PAR_DET_EN 0x0001 + +/* 5708S SerDes "Digital 3" Registers (page 2) */ +#define BRGPHY_5708S_PG2_DIGCTL_3_0 0x10 +#define BRGPHY_5708S_PG2_DIGCTL_3_0_USE_IEEE 0x0001 + +/* 5708S SerDes "TX Misc" Registers (page 5) */ +#define BRGPHY_5708S_PG5_2500STATUS1 0x10 +#define BRGPHY_5708S_PG5_TXACTL1 0x15 +#define BRGPHY_5708S_PG5_TXACTL3 0x17 + +/*******************************************************/ +/* End: PHY register values for the 5708S SerDes PHY */ +/*******************************************************/ -#define BRGPHY_MII_TEST1 0x1E -#define BRGPHY_TEST1_TRIM_EN 0x0010 -#define BRGPHY_TEST1_CRC_EN 0x8000 - -#define BRGPHY_MII_TEST2 0x1F - -/*******************************************************/ -/* End: PHY register values for the 5706 PHY */ -/*******************************************************/ - -/*******************************************************/ -/* Begin: PHY register values for the 5708S SerDes PHY */ -/*******************************************************/ - -/* Autoneg Next Page Transmit 1 Regiser */ -#define BRGPHY_5708S_ANEG_NXT_PG_XMIT1 0x0B -#define BRGPHY_5708S_ANEG_NXT_PG_XMIT1_25G 0x0001 - -/* Use the BLOCK_ADDR register to select the page for registers 0x10 to 0x1E */ -#define BRGPHY_5708S_BLOCK_ADDR 0x1f -#define BRGPHY_5708S_DIG_PG0 0x0000 -#define BRGPHY_5708S_DIG3_PG2 0x0002 -#define BRGPHY_5708S_TX_MISC_PG5 0x0005 - -/* 5708S SerDes "Digital" Registers (page 0) */ -#define BRGPHY_5708S_PG0_1000X_CTL1 0x10 -#define BRGPHY_5708S_PG0_1000X_CTL1_AUTODET_EN 0x0010 -#define BRGPHY_5708S_PG0_1000X_CTL1_FIBER_MODE 0x0001 - -#define BRGPHY_5708S_PG0_1000X_STAT1 0x14 -#define BRGPHY_5708S_PG0_1000X_STAT1_LINK 0x0002 -#define BRGPHY_5708S_PG0_1000X_STAT1_FDX 0x0004 -#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_MASK 0x0018 -#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_10 (0x0 << 3) -#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_100 (0x1 << 3) -#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_1G (0x2 << 3) -#define BRGPHY_5708S_PG0_1000X_STAT1_SPEED_25G (0x3 << 3) - - -#define BRGPHY_5708S_PG0_1000X_CTL2 0x11 -#define BRGPHY_5708S_PG0_1000X_CTL2_PAR_DET_EN 0x0001 - -/* 5708S SerDes "Digital 3" Registers (page 2) */ -#define BRGPHY_5708S_PG2_DIGCTL_3_0 0x10 -#define BRGPHY_5708S_PG2_DIGCTL_3_0_USE_IEEE 0x0001 - -/* 5708S SerDes "TX Misc" Registers (page 5) */ -#define BRGPHY_5708S_PG5_2500STATUS1 0x10 -#define BRGPHY_5708S_PG5_TXACTL1 0x15 -#define BRGPHY_5708S_PG5_TXACTL3 0x17 - -/*******************************************************/ -/* End: PHY register values for the 5708S SerDes PHY */ -/*******************************************************/ - /*******************************************************/ /* Begin: PHY register values for the 5709S SerDes PHY */ /*******************************************************/ /* 5709S SerDes "General Purpose Status" Registers */ -#define BRGPHY_BLOCK_ADDR_GP_STATUS 0x8120 -#define BRGPHY_GP_STATUS_TOP_ANEG_STATUS 0x1B -#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_MASK 0x3F00 -#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_10 0x0000 -#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_100 0x0100 -#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_1G 0x0200 -#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_25G 0x0300 -#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_1GKX 0x0D00 -#define BRGPHY_GP_STATUS_TOP_ANEG_FDX 0x0008 -#define BRGPHY_GP_STATUS_TOP_ANEG_LINK_UP 0x0004 -#define BRGPHY_GP_STATUS_TOP_ANEG_CL73_COMP 0x0001 +#define BRGPHY_BLOCK_ADDR_GP_STATUS 0x8120 +#define BRGPHY_GP_STATUS_TOP_ANEG_STATUS 0x1B +#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_MASK 0x3F00 +#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_10 0x0000 +#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_100 0x0100 +#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_1G 0x0200 +#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_25G 0x0300 +#define BRGPHY_GP_STATUS_TOP_ANEG_SPEED_1GKX 0x0D00 +#define BRGPHY_GP_STATUS_TOP_ANEG_FDX 0x0008 +#define BRGPHY_GP_STATUS_TOP_ANEG_LINK_UP 0x0004 +#define BRGPHY_GP_STATUS_TOP_ANEG_CL73_COMP 0x0001 /* 5709S SerDes "SerDes Digital" Registers */ -#define BRGPHY_BLOCK_ADDR_SERDES_DIG 0x8300 -#define BRGPHY_SERDES_DIG_1000X_CTL1 0x0010 -#define BRGPHY_SD_DIG_1000X_CTL1_AUTODET 0x0010 -#define BRGPHY_SD_DIG_1000X_CTL1_FIBER 0x0001 +#define BRGPHY_BLOCK_ADDR_SERDES_DIG 0x8300 +#define BRGPHY_SERDES_DIG_1000X_CTL1 0x0010 +#define BRGPHY_SD_DIG_1000X_CTL1_AUTODET 0x0010 +#define BRGPHY_SD_DIG_1000X_CTL1_FIBER 0x0001 /* 5709S SerDes "Over 1G" Registers */ -#define BRGPHY_BLOCK_ADDR_OVER_1G 0x8320 -#define BRGPHY_OVER_1G_UNFORMAT_PG1 0x19 +#define BRGPHY_BLOCK_ADDR_OVER_1G 0x8320 +#define BRGPHY_OVER_1G_UNFORMAT_PG1 0x19 /* 5709S SerDes "Multi-Rate Backplane Ethernet" Registers */ -#define BRGPHY_BLOCK_ADDR_MRBE 0x8350 -#define BRGPHY_MRBE_MSG_PG5_NP 0x10 -#define BRGPHY_MRBE_MSG_PG5_NP_MBRE 0x0001 -#define BRGPHY_MRBE_MSG_PG5_NP_T2 0x0001 +#define BRGPHY_BLOCK_ADDR_MRBE 0x8350 +#define BRGPHY_MRBE_MSG_PG5_NP 0x10 +#define BRGPHY_MRBE_MSG_PG5_NP_MBRE 0x0001 +#define BRGPHY_MRBE_MSG_PG5_NP_T2 0x0002 /* 5709S SerDes "IEEE Clause 73 User B0" Registers */ -#define BRGPHY_BLOCK_ADDR_CL73_USER_B0 0x8370 -#define BRGPHY_CL73_USER_B0_MBRE_CTL1 0x12 +#define BRGPHY_BLOCK_ADDR_CL73_USER_B0 0x8370 +#define BRGPHY_CL73_USER_B0_MBRE_CTL1 0x12 #define BRGPHY_CL73_USER_B0_MBRE_CTL1_NP_AFT_BP 0x2000 #define BRGPHY_CL73_USER_B0_MBRE_CTL1_STA_MGR 0x4000 -#define BRGPHY_CL73_USER_B0_MBRE_CTL1_ANEG 0x8000 +#define BRGPHY_CL73_USER_B0_MBRE_CTL1_ANEG 0x8000 /* 5709S SerDes "IEEE Clause 73 User B0" Registers */ -#define BRGPHY_BLOCK_ADDR_ADDR_EXT 0xFFD0 +#define BRGPHY_BLOCK_ADDR_ADDR_EXT 0xFFD0 /* 5709S SerDes "Combo IEEE 0" Registers */ -#define BRGPHY_BLOCK_ADDR_COMBO_IEEE0 0xFFE0 +#define BRGPHY_BLOCK_ADDR_COMBO_IEEE0 0xFFE0 -#define BRGPHY_ADDR_EXT 0x1E -#define BRGPHY_BLOCK_ADDR 0x1F +#define BRGPHY_ADDR_EXT 0x1E +#define BRGPHY_BLOCK_ADDR 0x1F -#define BRGPHY_ADDR_EXT_AN_MMD 0x3800 +#define BRGPHY_ADDR_EXT_AN_MMD 0x3800 /*******************************************************/ /* End: PHY register values for the 5709S SerDes PHY */ From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 19:21:16 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D240106564A; Fri, 8 Oct 2010 19:21:16 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C9888FC0A; Fri, 8 Oct 2010 19:21:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98JLGYA004803; Fri, 8 Oct 2010 19:21:16 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98JLGaD004801; Fri, 8 Oct 2010 19:21:16 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010081921.o98JLGaD004801@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 19:21:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213600 - stable/7/sys/dev/ae X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 19:21:16 -0000 Author: yongari Date: Fri Oct 8 19:21:16 2010 New Revision: 213600 URL: http://svn.freebsd.org/changeset/base/213600 Log: MFC r212968: Remove unnecessary controller reinitialization. PR: kern/87506 Modified: stable/7/sys/dev/ae/if_ae.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/ae/if_ae.c ============================================================================== --- stable/7/sys/dev/ae/if_ae.c Fri Oct 8 19:19:51 2010 (r213599) +++ stable/7/sys/dev/ae/if_ae.c Fri Oct 8 19:21:16 2010 (r213600) @@ -565,6 +565,8 @@ ae_init_locked(ae_softc_t *sc) AE_LOCK_ASSERT(sc); ifp = sc->ifp; + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return (0); mii = device_get_softc(sc->miibus); ae_stop(sc); @@ -1786,7 +1788,10 @@ ae_int_task(void *arg, int pending) if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { if ((val & (AE_ISR_DMAR_TIMEOUT | AE_ISR_DMAW_TIMEOUT | AE_ISR_PHY_LINKDOWN)) != 0) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; ae_init_locked(sc); + AE_UNLOCK(sc); + return; } if ((val & AE_ISR_TX_EVENT) != 0) ae_tx_intr(sc); @@ -1997,6 +2002,7 @@ ae_watchdog(ae_softc_t *sc) if_printf(ifp, "watchdog timeout - resetting.\n"); ifp->if_oerrors++; + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; ae_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) taskqueue_enqueue(sc->tq, &sc->tx_task); @@ -2107,8 +2113,10 @@ ae_ioctl(struct ifnet *ifp, u_long cmd, else if (ifp->if_mtu != ifr->ifr_mtu) { AE_LOCK(sc); ifp->if_mtu = ifr->ifr_mtu; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; ae_init_locked(sc); + } AE_UNLOCK(sc); } break; From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 19:25:47 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 529A4106566B; Fri, 8 Oct 2010 19:25:47 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 41EB58FC0A; Fri, 8 Oct 2010 19:25:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98JPlkg006781; Fri, 8 Oct 2010 19:25:47 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98JPlI1006779; Fri, 8 Oct 2010 19:25:47 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010081925.o98JPlI1006779@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 19:25:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213602 - stable/7/sys/dev/et X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 19:25:47 -0000 Author: yongari Date: Fri Oct 8 19:25:46 2010 New Revision: 213602 URL: http://svn.freebsd.org/changeset/base/213602 Log: MFC r212969: Make sure to clear IFF_DRV_RUNNING to reinitialize controller. While I'm here update if_oerrors counter when driver encounters watchdog timeout. Modified: stable/7/sys/dev/et/if_et.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/et/if_et.c ============================================================================== --- stable/7/sys/dev/et/if_et.c Fri Oct 8 19:24:38 2010 (r213601) +++ stable/7/sys/dev/et/if_et.c Fri Oct 8 19:25:46 2010 (r213602) @@ -1320,6 +1320,8 @@ et_watchdog(struct et_softc *sc) if_printf(sc->ifp, "watchdog timed out\n"); + sc->ifp->if_oerrors++; + sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING; et_init_locked(sc); et_start_locked(sc->ifp); } From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 19:29:17 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 927CD106567A; Fri, 8 Oct 2010 19:29:17 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6776A8FC19; Fri, 8 Oct 2010 19:29:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98JTHhJ008669; Fri, 8 Oct 2010 19:29:17 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98JTHqu008667; Fri, 8 Oct 2010 19:29:17 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010081929.o98JTHqu008667@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 19:29:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213604 - stable/7/sys/dev/sf X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 19:29:17 -0000 Author: yongari Date: Fri Oct 8 19:29:17 2010 New Revision: 213604 URL: http://svn.freebsd.org/changeset/base/213604 Log: MFC r212971: Remove unnecessary controller reinitialization. StarFire controller does not require controller reinitialization to program perfect filters. While here, make driver immediately exit from interrupt/polling handler if driver reinitialized controller. PR: kern/87506 Modified: stable/7/sys/dev/sf/if_sf.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sf/if_sf.c ============================================================================== --- stable/7/sys/dev/sf/if_sf.c Fri Oct 8 19:27:34 2010 (r213603) +++ stable/7/sys/dev/sf/if_sf.c Fri Oct 8 19:29:17 2010 (r213604) @@ -1821,7 +1821,10 @@ sf_poll(struct ifnet *ifp, enum poll_cmd else if ((status & SF_ISR_DMAERR) != 0) { device_printf(sc->sf_dev, "DMA error, resetting\n"); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sf_init_locked(sc); + SF_UNLOCK(sc); + return (rx_npkts); } else if ((status & SF_ISR_NO_TX_CSUM) != 0) { sc->sf_statistics.sf_tx_gfp_stall++; #ifdef SF_GFP_DEBUG @@ -1888,8 +1891,10 @@ sf_intr(void *arg) else if ((status & SF_ISR_DMAERR) != 0) { device_printf(sc->sf_dev, "DMA error, resetting\n"); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sf_init_locked(sc); - break; + SF_UNLOCK(sc); + return; } else if ((status & SF_ISR_NO_TX_CSUM) != 0) { sc->sf_statistics.sf_tx_gfp_stall++; #ifdef SF_GFP_DEBUG @@ -1978,6 +1983,8 @@ sf_init_locked(struct sf_softc *sc) SF_LOCK_ASSERT(sc); ifp = sc->sf_ifp; + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; mii = device_get_softc(sc->sf_miibus); sf_stop(sc); @@ -2541,6 +2548,7 @@ sf_watchdog(struct sf_softc *sc) if_printf(ifp, "watchdog timeout, %d Tx descs are active\n", sc->sf_cdata.sf_tx_cnt); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sf_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 19:34:23 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99CBE1065696; Fri, 8 Oct 2010 19:34:23 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6EDC78FC08; Fri, 8 Oct 2010 19:34:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98JYNZ7010830; Fri, 8 Oct 2010 19:34:23 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98JYNkO010828; Fri, 8 Oct 2010 19:34:23 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010081934.o98JYNkO010828@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 19:34:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213606 - stable/7/sys/dev/stge X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 19:34:23 -0000 Author: yongari Date: Fri Oct 8 19:34:23 2010 New Revision: 213606 URL: http://svn.freebsd.org/changeset/base/213606 Log: MFC r212972,21300: r212972: Remove unnecessary controller reinitialization. PR: kern/87506 r213000: Fix build breakage introduced in r212972. Modified: stable/7/sys/dev/stge/if_stge.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/stge/if_stge.c ============================================================================== --- stable/7/sys/dev/stge/if_stge.c Fri Oct 8 19:32:39 2010 (r213605) +++ stable/7/sys/dev/stge/if_stge.c Fri Oct 8 19:34:23 2010 (r213606) @@ -1386,6 +1386,7 @@ stge_watchdog(struct stge_softc *sc) ifp = sc->sc_ifp; if_printf(sc->sc_ifp, "device timeout\n"); ifp->if_oerrors++; + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; stge_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) stge_start_locked(ifp); @@ -1414,7 +1415,10 @@ stge_ioctl(struct ifnet *ifp, u_long cmd else if (ifp->if_mtu != ifr->ifr_mtu) { ifp->if_mtu = ifr->ifr_mtu; STGE_LOCK(sc); - stge_init_locked(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + stge_init_locked(sc); + } STGE_UNLOCK(sc); } break; @@ -1648,8 +1652,10 @@ stge_intr(void *arg) } force_init: - if (reinit != 0) + if (reinit != 0) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; stge_init_locked(sc); + } /* Re-enable interrupts. */ CSR_WRITE_2(sc, STGE_IntEnable, sc->sc_IntEnable); @@ -1940,11 +1946,14 @@ stge_poll(struct ifnet *ifp, enum poll_c if ((status & IS_HostError) != 0) { device_printf(sc->sc_dev, "Host interface error, resetting...\n"); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; stge_init_locked(sc); } if ((status & IS_TxComplete) != 0) { - if (stge_tx_error(sc) != 0) + if (stge_tx_error(sc) != 0) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; stge_init_locked(sc); + } } } @@ -2124,6 +2133,8 @@ stge_init_locked(struct stge_softc *sc) STGE_LOCK_ASSERT(sc); ifp = sc->sc_ifp; + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; mii = device_get_softc(sc->sc_miibus); /* From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:12:01 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15FBF106564A; Fri, 8 Oct 2010 20:12:01 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 052A48FC08; Fri, 8 Oct 2010 20:12:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KC04v011846; Fri, 8 Oct 2010 20:12:00 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KC0VT011844; Fri, 8 Oct 2010 20:12:00 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082012.o98KC0VT011844@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:12:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213608 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:12:01 -0000 Author: yongari Date: Fri Oct 8 20:12:00 2010 New Revision: 213608 URL: http://svn.freebsd.org/changeset/base/213608 Log: MFC r182065: There actually were bugs in the original handling that I missed last night. Free the children after each pci bus that is searched. Otherwise we leak them. With free in the new place, we also have to free children before going to done when we find the device we're looking for. Also, if we can't get the children of a device, just ignore that bus. Modified: stable/7/sys/dev/sis/if_sis.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 19:39:35 2010 (r213607) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:12:00 2010 (r213608) @@ -347,21 +347,22 @@ sis_find_bridge(device_t dev) devclass_get_devices(pci_devclass, &pci_devices, &pci_count); for (i = 0, busp = pci_devices; i < pci_count; i++, busp++) { - pci_childcount = 0; - device_get_children(*busp, &pci_children, &pci_childcount); + if (device_get_children(*busp, &pci_children, &pci_childcount)) + continue; for (j = 0, childp = pci_children; j < pci_childcount; j++, childp++) { if (pci_get_vendor(*childp) == SIS_VENDORID && pci_get_device(*childp) == 0x0008) { child = *childp; + free(pci_children, M_TEMP); goto done; } } + free(pci_children, M_TEMP); } done: free(pci_devices, M_TEMP); - free(pci_children, M_TEMP); return(child); } From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:13:42 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D3633106566C; Fri, 8 Oct 2010 20:13:42 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C1CA98FC1D; Fri, 8 Oct 2010 20:13:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KDgk3011992; Fri, 8 Oct 2010 20:13:42 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KDgGt011989; Fri, 8 Oct 2010 20:13:42 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082013.o98KDgGt011989@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:13:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213610 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:13:42 -0000 Author: yongari Date: Fri Oct 8 20:13:42 2010 New Revision: 213610 URL: http://svn.freebsd.org/changeset/base/213610 Log: MFC r212103-212105: r212103: Remove leading and trailing white spaces. No functional changes. r212104: style(9) - space after keywords. r212105: Nuke unnecessary return at the end of function. Modified: stable/7/sys/dev/sis/if_sis.c stable/7/sys/dev/sis/if_sisreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:13:12 2010 (r213609) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:13:42 2010 (r213610) @@ -203,7 +203,7 @@ sis_reverse(uint16_t n) n = ((n >> 4) & 0x0f0f) | ((n << 4) & 0xf0f0); n = ((n >> 8) & 0x00ff) | ((n << 8) & 0xff00); - return(n); + return (n); } static void @@ -342,7 +342,7 @@ sis_find_bridge(device_t dev) int i, j; if ((pci_devclass = devclass_find("pci")) == NULL) - return(NULL); + return (NULL); devclass_get_devices(pci_devclass, &pci_devices, &pci_count); @@ -363,7 +363,7 @@ sis_find_bridge(device_t dev) done: free(pci_devices, M_TEMP); - return(child); + return (child); } static void @@ -393,7 +393,6 @@ sis_read_cmos(struct sis_softc *sc, devi } pci_write_config(bridge, 0x48, reg & ~0x40, 1); - return; } static void @@ -406,7 +405,7 @@ sis_read_mac(struct sis_softc *sc, devic CSR_WRITE_4(sc, SIS_CSR, SIS_CSR_RELOAD | filtsave); CSR_WRITE_4(sc, SIS_CSR, 0); - + CSR_WRITE_4(sc, SIS_RXFILT_CTL, filtsave & ~SIS_RXFILTCTL_ENABLE); CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR0); @@ -418,7 +417,6 @@ sis_read_mac(struct sis_softc *sc, devic CSR_WRITE_4(sc, SIS_RXFILT_CTL, filtsave); CSR_WRITE_4(sc, SIS_CSR, csrsave); - return; } #endif @@ -429,9 +427,9 @@ static void sis_mii_sync(struct sis_softc *sc) { int i; - + SIO_SET(SIS_MII_DIR|SIS_MII_DATA); - + for (i = 0; i < 32; i++) { SIO_SET(SIS_MII_CLK); DELAY(1); @@ -439,7 +437,7 @@ sis_mii_sync(struct sis_softc *sc) DELAY(1); } } - + /* * Clock a series of bits through the MII. */ @@ -447,9 +445,9 @@ static void sis_mii_send(struct sis_softc *sc, uint32_t bits, int cnt) { int i; - + SIO_CLR(SIS_MII_CLK); - + for (i = (0x1 << (cnt - 1)); i; i >>= 1) { if (bits & i) { SIO_SET(SIS_MII_DATA); @@ -462,7 +460,7 @@ sis_mii_send(struct sis_softc *sc, uint3 SIO_SET(SIS_MII_CLK); } } - + /* * Read an PHY register through the MII. */ @@ -470,7 +468,7 @@ static int sis_mii_readreg(struct sis_softc *sc, struct sis_mii_frame *frame) { int i, ack; - + /* * Set up frame for RX. */ @@ -478,14 +476,14 @@ sis_mii_readreg(struct sis_softc *sc, st frame->mii_opcode = SIS_MII_READOP; frame->mii_turnaround = 0; frame->mii_data = 0; - + /* * Turn on data xmit. */ SIO_SET(SIS_MII_DIR); sis_mii_sync(sc); - + /* * Send command/address info. */ @@ -493,29 +491,29 @@ sis_mii_readreg(struct sis_softc *sc, st sis_mii_send(sc, frame->mii_opcode, 2); sis_mii_send(sc, frame->mii_phyaddr, 5); sis_mii_send(sc, frame->mii_regaddr, 5); - + /* Idle bit */ SIO_CLR((SIS_MII_CLK|SIS_MII_DATA)); DELAY(1); SIO_SET(SIS_MII_CLK); DELAY(1); - + /* Turn off xmit. */ SIO_CLR(SIS_MII_DIR); - + /* Check for ack */ SIO_CLR(SIS_MII_CLK); DELAY(1); ack = CSR_READ_4(sc, SIS_EECTL) & SIS_MII_DATA; SIO_SET(SIS_MII_CLK); DELAY(1); - + /* * Now try reading data bits. If the ack failed, we still * need to clock through 16 cycles to keep the PHY(s) in sync. */ if (ack) { - for(i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { SIO_CLR(SIS_MII_CLK); DELAY(1); SIO_SET(SIS_MII_CLK); @@ -523,7 +521,7 @@ sis_mii_readreg(struct sis_softc *sc, st } goto fail; } - + for (i = 0x8000; i; i >>= 1) { SIO_CLR(SIS_MII_CLK); DELAY(1); @@ -544,51 +542,51 @@ fail: DELAY(1); if (ack) - return(1); - return(0); + return (1); + return (0); } - + /* * Write to a PHY register through the MII. */ static int sis_mii_writereg(struct sis_softc *sc, struct sis_mii_frame *frame) { - + /* * Set up frame for TX. */ - + frame->mii_stdelim = SIS_MII_STARTDELIM; frame->mii_opcode = SIS_MII_WRITEOP; frame->mii_turnaround = SIS_MII_TURNAROUND; - + /* * Turn on data output. */ SIO_SET(SIS_MII_DIR); - + sis_mii_sync(sc); - + sis_mii_send(sc, frame->mii_stdelim, 2); sis_mii_send(sc, frame->mii_opcode, 2); sis_mii_send(sc, frame->mii_phyaddr, 5); sis_mii_send(sc, frame->mii_regaddr, 5); sis_mii_send(sc, frame->mii_turnaround, 2); sis_mii_send(sc, frame->mii_data, 16); - + /* Idle bit. */ SIO_SET(SIS_MII_CLK); DELAY(1); SIO_CLR(SIS_MII_CLK); DELAY(1); - + /* * Turn off xmit. */ SIO_CLR(SIS_MII_DIR); - - return(0); + + return (0); } static int @@ -601,7 +599,7 @@ sis_miibus_readreg(device_t dev, int phy if (sc->sis_type == SIS_TYPE_83815) { if (phy != 0) - return(0); + return (0); /* * The NatSemi chip can take a while after * a reset to come ready, during which the BMSR @@ -627,7 +625,7 @@ sis_miibus_readreg(device_t dev, int phy int i, val = 0; if (phy != 0) - return(0); + return (0); CSR_WRITE_4(sc, SIS_PHYCTL, (phy << 11) | (reg << 6) | SIS_PHYOP_READ); @@ -640,15 +638,15 @@ sis_miibus_readreg(device_t dev, int phy if (i == SIS_TIMEOUT) { device_printf(sc->sis_dev, "PHY failed to come ready\n"); - return(0); + return (0); } val = (CSR_READ_4(sc, SIS_PHYCTL) >> 16) & 0xFFFF; if (val == 0xFFFF) - return(0); + return (0); - return(val); + return (val); } else { bzero((char *)&frame, sizeof(frame)); @@ -656,7 +654,7 @@ sis_miibus_readreg(device_t dev, int phy frame.mii_regaddr = reg; sis_mii_readreg(sc, &frame); - return(frame.mii_data); + return (frame.mii_data); } } @@ -670,9 +668,9 @@ sis_miibus_writereg(device_t dev, int ph if (sc->sis_type == SIS_TYPE_83815) { if (phy != 0) - return(0); + return (0); CSR_WRITE_4(sc, NS_BMCR + (reg * 4), data); - return(0); + return (0); } /* @@ -685,7 +683,7 @@ sis_miibus_writereg(device_t dev, int ph int i; if (phy != 0) - return(0); + return (0); CSR_WRITE_4(sc, SIS_PHYCTL, (data << 16) | (phy << 11) | (reg << 6) | SIS_PHYOP_WRITE); @@ -706,7 +704,7 @@ sis_miibus_writereg(device_t dev, int ph frame.mii_data = data; sis_mii_writereg(sc, &frame); } - return(0); + return (0); } static void @@ -789,8 +787,6 @@ sis_setmulti_ns(struct sis_softc *sc) IF_ADDR_UNLOCK(ifp); CSR_WRITE_4(sc, SIS_RXFILT_CTL, filtsave); - - return; } static void @@ -876,8 +872,6 @@ sis_reset(struct sis_softc *sc) CSR_WRITE_4(sc, NS_CLKRUN, NS_CLKRUN_PMESTS); CSR_WRITE_4(sc, NS_CLKRUN, 0); } - - return; } /* @@ -891,7 +885,7 @@ sis_probe(device_t dev) t = sis_devs; - while(t->sis_name != NULL) { + while (t->sis_name != NULL) { if ((pci_get_vendor(dev) == t->sis_vid) && (pci_get_device(dev) == t->sis_did)) { device_set_desc(dev, t->sis_name); @@ -900,7 +894,7 @@ sis_probe(device_t dev) t++; } - return(ENXIO); + return (ENXIO); } /* @@ -947,8 +941,8 @@ sis_attach(device_t dev) sis_reset(sc); if (sc->sis_type == SIS_TYPE_900 && - (sc->sis_rev == SIS_REV_635 || - sc->sis_rev == SIS_REV_900B)) { + (sc->sis_rev == SIS_REV_635 || + sc->sis_rev == SIS_REV_900B)) { SIO_SET(SIS_CFG_RND_CNT); SIO_SET(SIS_CFG_PERR_DETECT); } @@ -1065,13 +1059,13 @@ sis_attach(device_t dev) * Allocate the parent bus DMA tag appropriate for PCI. */ #define SIS_NSEG_NEW 32 - error = bus_dma_tag_create(NULL, /* parent */ + error = bus_dma_tag_create(NULL, /* parent */ 1, 0, /* alignment, boundary */ BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ MAXBSIZE, SIS_NSEG_NEW, /* maxsize, nsegments */ - BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ + BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ NULL, NULL, /* lockfunc, lockarg */ &sc->sis_parent_tag); @@ -1213,7 +1207,7 @@ sis_attach(device_t dev) * Call MI attach routine. */ ether_ifattach(ifp, eaddr); - + /* * Tell the upper layer(s) we support long frames. */ @@ -1238,7 +1232,7 @@ fail: if (error) sis_detach(dev); - return(error); + return (error); } /* @@ -1304,7 +1298,7 @@ sis_detach(device_t dev) mtx_destroy(&sc->sis_mtx); - return(0); + return (0); } /* @@ -1342,7 +1336,7 @@ sis_ring_init(struct sis_softc *sc) for (i = 0; i < SIS_RX_LIST_CNT; i++, dp++) { error = sis_newbuf(sc, dp, NULL); if (error) - return(error); + return (error); if (i == (SIS_RX_LIST_CNT - 1)) dp->sis_nextdesc = &sc->sis_rx_list[0]; else @@ -1358,7 +1352,7 @@ sis_ring_init(struct sis_softc *sc) sc->sis_rx_pdsc = &sc->sis_rx_list[0]; - return(0); + return (0); } /* @@ -1369,12 +1363,12 @@ sis_newbuf(struct sis_softc *sc, struct { if (c == NULL) - return(EINVAL); + return (EINVAL); if (m == NULL) { m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); if (m == NULL) - return(ENOBUFS); + return (ENOBUFS); } else m->m_data = m->m_ext.ext_buf; @@ -1387,7 +1381,7 @@ sis_newbuf(struct sis_softc *sc, struct sis_dma_map_desc_ptr, c, 0); bus_dmamap_sync(sc->sis_tag, c->sis_map, BUS_DMASYNC_PREREAD); - return(0); + return (0); } /* @@ -1407,7 +1401,7 @@ sis_rxeof(struct sis_softc *sc) ifp = sc->sis_ifp; - for(cur_rx = sc->sis_rx_pdsc; SIS_OWNDESC(cur_rx); + for (cur_rx = sc->sis_rx_pdsc; SIS_OWNDESC(cur_rx); cur_rx = cur_rx->sis_nextdesc) { #ifdef DEVICE_POLLING @@ -1444,7 +1438,7 @@ sis_rxeof(struct sis_softc *sc) continue; } - /* No errors; receive the packet. */ + /* No errors; receive the packet. */ #ifdef __NO_STRICT_ALIGNMENT /* * On architectures without alignment problems we try to @@ -1536,8 +1530,6 @@ sis_txeof(struct sis_softc *sc) } sc->sis_watchdog_timer = (sc->sis_tx_cnt == 0) ? 0 : 5; - - return; } static void @@ -1651,7 +1643,7 @@ sis_intr(void *arg) if (status & (SIS_ISR_TX_DESC_OK | SIS_ISR_TX_ERR | - SIS_ISR_TX_OK | SIS_ISR_TX_IDLE) ) + SIS_ISR_TX_OK | SIS_ISR_TX_IDLE) ) sis_txeof(sc); if (status & (SIS_ISR_RX_DESC_OK | SIS_ISR_RX_OK | @@ -1713,7 +1705,7 @@ sis_encap(struct sis_softc *sc, struct m return (ENOBUFS); *m_head = m; } - + /* * Start packing the mbufs in this chain into * the fragment pointers. Stop when we run out @@ -1725,7 +1717,7 @@ sis_encap(struct sis_softc *sc, struct m if (m->m_len != 0) { if ((SIS_TX_LIST_CNT - (sc->sis_tx_cnt + cnt)) < 2) - return(ENOBUFS); + return (ENOBUFS); f = &sc->sis_tx_list[frag]; f->sis_ctl = SIS_CMDSTS_MORE | m->m_len; bus_dmamap_create(sc->sis_tag, 0, &f->sis_map); @@ -1743,7 +1735,7 @@ sis_encap(struct sis_softc *sc, struct m } if (m != NULL) - return(ENOBUFS); + return (ENOBUFS); sc->sis_tx_list[cur].sis_mbuf = *m_head; sc->sis_tx_list[cur].sis_ctl &= ~SIS_CMDSTS_MORE; @@ -1751,7 +1743,7 @@ sis_encap(struct sis_softc *sc, struct m sc->sis_tx_cnt += cnt; *txidx = frag; - return(0); + return (0); } /* @@ -1791,7 +1783,7 @@ sis_startl(struct ifnet *ifp) if (ifp->if_drv_flags & IFF_DRV_OACTIVE) return; - while(sc->sis_tx_list[idx].sis_mbuf == NULL) { + while (sc->sis_tx_list[idx].sis_mbuf == NULL) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -1999,7 +1991,7 @@ sis_initl(struct sis_softc *sc) uint32_t reg; /* - * Short Cable Receive Errors (MP21.E) + * Short Cable Receive Errors (MP21.E) */ CSR_WRITE_4(sc, NS_PHY_PAGE, 0x0001); reg = CSR_READ_4(sc, NS_PHY_DSPCFG) & 0xfff; @@ -2067,7 +2059,7 @@ sis_ifmedia_upd(struct ifnet *ifp) mii_mediachg(mii); SIS_UNLOCK(sc); - return(0); + return (0); } /* @@ -2097,7 +2089,7 @@ sis_ioctl(struct ifnet *ifp, u_long comm struct mii_data *mii; int error = 0; - switch(command) { + switch (command) { case SIOCSIFFLAGS: SIS_LOCK(sc); if (ifp->if_flags & IFF_UP) { @@ -2130,14 +2122,14 @@ sis_ioctl(struct ifnet *ifp, u_long comm !(ifp->if_capenable & IFCAP_POLLING)) { error = ether_poll_register(sis_poll, ifp); if (error) - return(error); + return (error); SIS_LOCK(sc); /* Disable interrupts */ CSR_WRITE_4(sc, SIS_IER, 0); ifp->if_capenable |= IFCAP_POLLING; SIS_UNLOCK(sc); return (error); - + } if (!(ifr->ifr_reqcap & IFCAP_POLLING) && ifp->if_capenable & IFCAP_POLLING) { @@ -2156,7 +2148,7 @@ sis_ioctl(struct ifnet *ifp, u_long comm break; } - return(error); + return (error); } static void Modified: stable/7/sys/dev/sis/if_sisreg.h ============================================================================== --- stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:13:12 2010 (r213609) +++ stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:13:42 2010 (r213610) @@ -252,7 +252,7 @@ SIS_TXCFG_FILL(64)|SIS_TXCFG_DRAIN(1536)) #define SIS_RXCFG_DRAIN_THRESH 0x0000003E /* 8-byte units */ -#define SIS_TXCFG_MPII03D 0x00040000 /* "Must be 1" */ +#define SIS_TXCFG_MPII03D 0x00040000 /* "Must be 1" */ #define SIS_RXCFG_DMABURST 0x00700000 #define SIS_RXCFG_RX_JABBER 0x08000000 #define SIS_RXCFG_RX_TXPKTS 0x10000000 From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:27:51 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC2A6106566B; Fri, 8 Oct 2010 20:27:51 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9A2C08FC0C; Fri, 8 Oct 2010 20:27:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KRpS7012590; Fri, 8 Oct 2010 20:27:51 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KRp2u012587; Fri, 8 Oct 2010 20:27:51 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082027.o98KRp2u012587@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:27:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213613 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:27:51 -0000 Author: yongari Date: Fri Oct 8 20:27:51 2010 New Revision: 213613 URL: http://svn.freebsd.org/changeset/base/213613 Log: MFC r212109,212124,212185: r212109: bus_dma(9) cleanup. o Enforce TX/RX descriptor ring alignment. NS data sheet says the controller needs 4 bytes alignment but use 16 to cover both SiS and NS controllers. I don't have SiS data sheet so I'm not sure what is alignment restriction of SiS controller but 16 would be enough because it's larger than the size of a TX/RX descriptor. Previously sis(4) ignored the alignment restriction. o Enforce RX buffer alignment, 4. Previously sis(4) ignored RX buffer alignment restriction. o Limit number of TX DMA segment to be used to 16. It seems controller has no restriction on number of DMA segments but using more than 16 looks resource waste. o Collapse long mbuf chains with m_collapse(9) instead of calling expensive m_defrag(9). o TX/RX side bus_dmamap_load_mbuf_sg(9) support and remove unnecessary callbacks. o Initial endianness support. o Prefer local alignment fixup code to m_devget(9). o Pre-allocate TX/RX mbuf DMA maps instead of creating/destroying these maps in fast TX/RX path. On non-x86 architectures, this is very expensive operation and there is no need to do that. o Add missing bus_dmamap_sync(9) in TX/RX path. o watchdog is now unarmed only when there are no pending frames on controller. Previously sis(4) blindly unarmed watchdog without checking the number of queued frames. o For efficiency, loaded DMA map is reused for error frames. o DMA map loading failure is now gracefully handled. Previously sis(4) ignored any DMA map loading errors. o Nuke unused macros which are not appropriate for endianness operation. o Stop embedding driver maintained structures into descriptor rings. Because TX/RX descriptor structures are shared between host and controller, frequent bus_dmamap_sync(9) operations are required in fast path. Embedding driver structures will increase the size of DMA map which in turn will slow down performance. r212124: Fix stupid error in r212109 which didn't swap DMA maps. This caused IOMMU panic on sparc64 under high TX load. r212185: Fix another bug introduced in r212109. We should unload DMA maps only after sending the last fragment of a frame so the mbuf pointer also should be stored in the last descriptor index. Modified: stable/7/sys/dev/sis/if_sis.c stable/7/sys/dev/sis/if_sisreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:18:44 2010 (r213612) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:27:51 2010 (r213613) @@ -64,12 +64,15 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include +#include +#include #include +#include +#include +#include #include #include +#include #include #include @@ -127,13 +130,23 @@ static struct sis_type sis_devs[] = { }; static int sis_detach(device_t); +static __inline void sis_discard_rxbuf(struct sis_rxdesc *); +static int sis_dma_alloc(struct sis_softc *); +static void sis_dma_free(struct sis_softc *); +static int sis_dma_ring_alloc(struct sis_softc *, bus_size_t, bus_size_t, + bus_dma_tag_t *, uint8_t **, bus_dmamap_t *, bus_addr_t *, const char *); +static void sis_dmamap_cb(void *, bus_dma_segment_t *, int, int); +#ifndef __NO_STRICT_ALIGNMENT +static __inline void sis_fixup_rx(struct mbuf *); +#endif static void sis_ifmedia_sts(struct ifnet *, struct ifmediareq *); static int sis_ifmedia_upd(struct ifnet *); static void sis_init(void *); static void sis_initl(struct sis_softc *); static void sis_intr(void *); static int sis_ioctl(struct ifnet *, u_long, caddr_t); -static int sis_newbuf(struct sis_softc *, struct sis_desc *, struct mbuf *); +static int sis_newbuf(struct sis_softc *, struct sis_rxdesc *); +static void sis_rxeof(struct sis_softc *); static void sis_start(struct ifnet *); static void sis_startl(struct ifnet *); static void sis_stop(struct sis_softc *); @@ -164,33 +177,6 @@ static struct resource_spec sis_res_spec #define SIO_CLR(x) \ CSR_WRITE_4(sc, SIS_EECTL, CSR_READ_4(sc, SIS_EECTL) & ~x) -static void -sis_dma_map_desc_next(void *arg, bus_dma_segment_t *segs, int nseg, int error) -{ - struct sis_desc *r; - - r = arg; - r->sis_next = segs->ds_addr; -} - -static void -sis_dma_map_desc_ptr(void *arg, bus_dma_segment_t *segs, int nseg, int error) -{ - struct sis_desc *r; - - r = arg; - r->sis_ptr = segs->ds_addr; -} - -static void -sis_dma_map_ring(void *arg, bus_dma_segment_t *segs, int nseg, int error) -{ - u_int32_t *p; - - p = arg; - *p = segs->ds_addr; -} - /* * Routine to reverse the bits in a word. Stolen almost * verbatim from /usr/games/fortune. @@ -1055,127 +1041,10 @@ sis_attach(device_t dev) break; } - /* - * Allocate the parent bus DMA tag appropriate for PCI. - */ -#define SIS_NSEG_NEW 32 - error = bus_dma_tag_create(NULL, /* parent */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MAXBSIZE, SIS_NSEG_NEW, /* maxsize, nsegments */ - BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc->sis_parent_tag); - if (error) - goto fail; - - /* - * Now allocate a tag for the DMA descriptor lists and a chunk - * of DMA-able memory based on the tag. Also obtain the physical - * addresses of the RX and TX ring, which we'll need later. - * All of our lists are allocated as a contiguous block - * of memory. - */ - error = bus_dma_tag_create(sc->sis_parent_tag, /* parent */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - SIS_RX_LIST_SZ, 1, /* maxsize,nsegments */ - BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ - 0, /* flags */ - busdma_lock_mutex, /* lockfunc */ - &Giant, /* lockarg */ - &sc->sis_rx_tag); - if (error) - goto fail; - - error = bus_dmamem_alloc(sc->sis_rx_tag, - (void **)&sc->sis_rx_list, BUS_DMA_NOWAIT | BUS_DMA_ZERO, - &sc->sis_rx_dmamap); - - if (error) { - device_printf(dev, "no memory for rx list buffers!\n"); - bus_dma_tag_destroy(sc->sis_rx_tag); - sc->sis_rx_tag = NULL; - goto fail; - } - - error = bus_dmamap_load(sc->sis_rx_tag, - sc->sis_rx_dmamap, &(sc->sis_rx_list[0]), - sizeof(struct sis_desc), sis_dma_map_ring, - &sc->sis_rx_paddr, 0); - - if (error) { - device_printf(dev, "cannot get address of the rx ring!\n"); - bus_dmamem_free(sc->sis_rx_tag, - sc->sis_rx_list, sc->sis_rx_dmamap); - bus_dma_tag_destroy(sc->sis_rx_tag); - sc->sis_rx_tag = NULL; - goto fail; - } - - error = bus_dma_tag_create(sc->sis_parent_tag, /* parent */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - SIS_TX_LIST_SZ, 1, /* maxsize,nsegments */ - BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ - 0, /* flags */ - busdma_lock_mutex, /* lockfunc */ - &Giant, /* lockarg */ - &sc->sis_tx_tag); - if (error) - goto fail; - - error = bus_dmamem_alloc(sc->sis_tx_tag, - (void **)&sc->sis_tx_list, BUS_DMA_NOWAIT | BUS_DMA_ZERO, - &sc->sis_tx_dmamap); - - if (error) { - device_printf(dev, "no memory for tx list buffers!\n"); - bus_dma_tag_destroy(sc->sis_tx_tag); - sc->sis_tx_tag = NULL; - goto fail; - } - - error = bus_dmamap_load(sc->sis_tx_tag, - sc->sis_tx_dmamap, &(sc->sis_tx_list[0]), - sizeof(struct sis_desc), sis_dma_map_ring, - &sc->sis_tx_paddr, 0); - - if (error) { - device_printf(dev, "cannot get address of the tx ring!\n"); - bus_dmamem_free(sc->sis_tx_tag, - sc->sis_tx_list, sc->sis_tx_dmamap); - bus_dma_tag_destroy(sc->sis_tx_tag); - sc->sis_tx_tag = NULL; - goto fail; - } - - error = bus_dma_tag_create(sc->sis_parent_tag, /* parent */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MCLBYTES, 1, /* maxsize,nsegments */ - BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ - 0, /* flags */ - busdma_lock_mutex, /* lockfunc */ - &Giant, /* lockarg */ - &sc->sis_tag); - if (error) + /* Allocate DMA'able memory. */ + if ((error = sis_dma_alloc(sc)) != 0) goto fail; - /* - * Obtain the physical addresses of the RX and TX - * rings which we'll need later in the init routine. - */ - ifp = sc->sis_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { device_printf(dev, "can not if_alloc()\n"); @@ -1277,30 +1146,206 @@ sis_detach(device_t dev) if (ifp) if_free(ifp); - if (sc->sis_rx_tag) { - bus_dmamap_unload(sc->sis_rx_tag, - sc->sis_rx_dmamap); - bus_dmamem_free(sc->sis_rx_tag, - sc->sis_rx_list, sc->sis_rx_dmamap); - bus_dma_tag_destroy(sc->sis_rx_tag); + sis_dma_free(sc); + + mtx_destroy(&sc->sis_mtx); + + return (0); +} + +struct sis_dmamap_arg { + bus_addr_t sis_busaddr; +}; + +static void +sis_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error) +{ + struct sis_dmamap_arg *ctx; + + if (error != 0) + return; + + KASSERT(nsegs == 1, ("%s: %d segments returned!", __func__, nsegs)); + + ctx = (struct sis_dmamap_arg *)arg; + ctx->sis_busaddr = segs[0].ds_addr; +} + +static int +sis_dma_ring_alloc(struct sis_softc *sc, bus_size_t alignment, + bus_size_t maxsize, bus_dma_tag_t *tag, uint8_t **ring, bus_dmamap_t *map, + bus_addr_t *paddr, const char *msg) +{ + struct sis_dmamap_arg ctx; + int error; + + error = bus_dma_tag_create(sc->sis_parent_tag, alignment, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, maxsize, 1, + maxsize, 0, NULL, NULL, tag); + if (error != 0) { + device_printf(sc->sis_dev, + "could not create %s dma tag\n", msg); + return (ENOMEM); } - if (sc->sis_tx_tag) { - bus_dmamap_unload(sc->sis_tx_tag, - sc->sis_tx_dmamap); - bus_dmamem_free(sc->sis_tx_tag, - sc->sis_tx_list, sc->sis_tx_dmamap); - bus_dma_tag_destroy(sc->sis_tx_tag); + /* Allocate DMA'able memory for ring. */ + error = bus_dmamem_alloc(*tag, (void **)ring, + BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, map); + if (error != 0) { + device_printf(sc->sis_dev, + "could not allocate DMA'able memory for %s\n", msg); + return (ENOMEM); } - if (sc->sis_parent_tag) - bus_dma_tag_destroy(sc->sis_parent_tag); - if (sc->sis_tag) - bus_dma_tag_destroy(sc->sis_tag); + /* Load the address of the ring. */ + ctx.sis_busaddr = 0; + error = bus_dmamap_load(*tag, *map, *ring, maxsize, sis_dmamap_cb, + &ctx, BUS_DMA_NOWAIT); + if (error != 0) { + device_printf(sc->sis_dev, + "could not load DMA'able memory for %s\n", msg); + return (ENOMEM); + } + *paddr = ctx.sis_busaddr; + return (0); +} - mtx_destroy(&sc->sis_mtx); +static int +sis_dma_alloc(struct sis_softc *sc) +{ + struct sis_rxdesc *rxd; + struct sis_txdesc *txd; + int error, i; + + /* Allocate the parent bus DMA tag appropriate for PCI. */ + error = bus_dma_tag_create(bus_get_dma_tag(sc->sis_dev), + 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, + NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, + 0, NULL, NULL, &sc->sis_parent_tag); + if (error != 0) { + device_printf(sc->sis_dev, + "could not allocate parent dma tag\n"); + return (ENOMEM); + } + + /* Create RX ring. */ + error = sis_dma_ring_alloc(sc, SIS_DESC_ALIGN, SIS_RX_LIST_SZ, + &sc->sis_rx_list_tag, (uint8_t **)&sc->sis_rx_list, + &sc->sis_rx_list_map, &sc->sis_rx_paddr, "RX ring"); + if (error) + return (error); + + /* Create TX ring. */ + error = sis_dma_ring_alloc(sc, SIS_DESC_ALIGN, SIS_TX_LIST_SZ, + &sc->sis_tx_list_tag, (uint8_t **)&sc->sis_tx_list, + &sc->sis_tx_list_map, &sc->sis_tx_paddr, "TX ring"); + if (error) + return (error); + + /* Create tag for RX mbufs. */ + error = bus_dma_tag_create(sc->sis_parent_tag, SIS_RX_BUF_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1, + MCLBYTES, 0, NULL, NULL, &sc->sis_rx_tag); + if (error) { + device_printf(sc->sis_dev, "could not allocate RX dma tag\n"); + return (error); + } + + /* Create tag for TX mbufs. */ + error = bus_dma_tag_create(sc->sis_parent_tag, 1, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES * SIS_MAXTXSEGS, SIS_MAXTXSEGS, MCLBYTES, 0, NULL, NULL, + &sc->sis_tx_tag); + if (error) { + device_printf(sc->sis_dev, "could not allocate TX dma tag\n"); + return (error); + } + + /* Create DMA maps for RX buffers. */ + error = bus_dmamap_create(sc->sis_rx_tag, 0, &sc->sis_rx_sparemap); + if (error) { + device_printf(sc->sis_dev, + "can't create spare DMA map for RX\n"); + return (error); + } + for (i = 0; i < SIS_RX_LIST_CNT; i++) { + rxd = &sc->sis_rxdesc[i]; + rxd->rx_m = NULL; + error = bus_dmamap_create(sc->sis_rx_tag, 0, &rxd->rx_dmamap); + if (error) { + device_printf(sc->sis_dev, + "can't create DMA map for RX\n"); + return (error); + } + } + + /* Create DMA maps for TX buffers. */ + for (i = 0; i < SIS_TX_LIST_CNT; i++) { + txd = &sc->sis_txdesc[i]; + txd->tx_m = NULL; + error = bus_dmamap_create(sc->sis_tx_tag, 0, &txd->tx_dmamap); + if (error) { + device_printf(sc->sis_dev, + "can't create DMA map for TX\n"); + return (error); + } + } return (0); } +static void +sis_dma_free(struct sis_softc *sc) +{ + struct sis_rxdesc *rxd; + struct sis_txdesc *txd; + int i; + + /* Destroy DMA maps for RX buffers. */ + for (i = 0; i < SIS_RX_LIST_CNT; i++) { + rxd = &sc->sis_rxdesc[i]; + if (rxd->rx_dmamap) + bus_dmamap_destroy(sc->sis_rx_tag, rxd->rx_dmamap); + } + if (sc->sis_rx_sparemap) + bus_dmamap_destroy(sc->sis_rx_tag, sc->sis_rx_sparemap); + + /* Destroy DMA maps for TX buffers. */ + for (i = 0; i < SIS_TX_LIST_CNT; i++) { + txd = &sc->sis_txdesc[i]; + if (txd->tx_dmamap) + bus_dmamap_destroy(sc->sis_tx_tag, txd->tx_dmamap); + } + + if (sc->sis_rx_tag) + bus_dma_tag_destroy(sc->sis_rx_tag); + if (sc->sis_tx_tag) + bus_dma_tag_destroy(sc->sis_tx_tag); + + /* Destroy RX ring. */ + if (sc->sis_rx_list_map) + bus_dmamap_unload(sc->sis_rx_list_tag, sc->sis_rx_list_map); + if (sc->sis_rx_list_map && sc->sis_rx_list) + bus_dmamem_free(sc->sis_rx_list_tag, sc->sis_rx_list, + sc->sis_rx_list_map); + + if (sc->sis_rx_list_tag) + bus_dma_tag_destroy(sc->sis_rx_list_tag); + + /* Destroy TX ring. */ + if (sc->sis_tx_list_map) + bus_dmamap_unload(sc->sis_tx_list_tag, sc->sis_tx_list_map); + + if (sc->sis_tx_list_map && sc->sis_tx_list) + bus_dmamem_free(sc->sis_tx_list_tag, sc->sis_tx_list, + sc->sis_tx_list_map); + + if (sc->sis_tx_list_tag) + bus_dma_tag_destroy(sc->sis_tx_list_tag); + + /* Destroy the parent tag. */ + if (sc->sis_parent_tag) + bus_dma_tag_destroy(sc->sis_parent_tag); +} + /* * Initialize the TX and RX descriptors and allocate mbufs for them. Note that * we arrange the descriptors in a closed ring, so that the last descriptor @@ -1309,48 +1354,41 @@ sis_detach(device_t dev) static int sis_ring_init(struct sis_softc *sc) { - int i, error; - struct sis_desc *dp; - - dp = &sc->sis_tx_list[0]; - for (i = 0; i < SIS_TX_LIST_CNT; i++, dp++) { - if (i == (SIS_TX_LIST_CNT - 1)) - dp->sis_nextdesc = &sc->sis_tx_list[0]; + struct sis_rxdesc *rxd; + struct sis_txdesc *txd; + bus_addr_t next; + int error, i; + + bzero(&sc->sis_tx_list[0], SIS_TX_LIST_SZ); + for (i = 0; i < SIS_TX_LIST_CNT; i++) { + txd = &sc->sis_txdesc[i]; + txd->tx_m = NULL; + if (i == SIS_TX_LIST_CNT - 1) + next = SIS_TX_RING_ADDR(sc, 0); else - dp->sis_nextdesc = dp + 1; - bus_dmamap_load(sc->sis_tx_tag, - sc->sis_tx_dmamap, - dp->sis_nextdesc, sizeof(struct sis_desc), - sis_dma_map_desc_next, dp, 0); - dp->sis_mbuf = NULL; - dp->sis_ptr = 0; - dp->sis_ctl = 0; + next = SIS_TX_RING_ADDR(sc, i + 1); + sc->sis_tx_list[i].sis_next = htole32(SIS_ADDR_LO(next)); } - sc->sis_tx_prod = sc->sis_tx_cons = sc->sis_tx_cnt = 0; + bus_dmamap_sync(sc->sis_tx_list_tag, sc->sis_tx_list_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - bus_dmamap_sync(sc->sis_tx_tag, - sc->sis_tx_dmamap, BUS_DMASYNC_PREWRITE); - - dp = &sc->sis_rx_list[0]; - for (i = 0; i < SIS_RX_LIST_CNT; i++, dp++) { - error = sis_newbuf(sc, dp, NULL); + sc->sis_rx_cons = 0; + bzero(&sc->sis_rx_list[0], SIS_RX_LIST_SZ); + for (i = 0; i < SIS_RX_LIST_CNT; i++) { + rxd = &sc->sis_rxdesc[i]; + rxd->rx_desc = &sc->sis_rx_list[i]; + if (i == SIS_RX_LIST_CNT - 1) + next = SIS_RX_RING_ADDR(sc, 0); + else + next = SIS_RX_RING_ADDR(sc, i + 1); + rxd->rx_desc->sis_next = htole32(SIS_ADDR_LO(next)); + error = sis_newbuf(sc, rxd); if (error) return (error); - if (i == (SIS_RX_LIST_CNT - 1)) - dp->sis_nextdesc = &sc->sis_rx_list[0]; - else - dp->sis_nextdesc = dp + 1; - bus_dmamap_load(sc->sis_rx_tag, - sc->sis_rx_dmamap, - dp->sis_nextdesc, sizeof(struct sis_desc), - sis_dma_map_desc_next, dp, 0); - } - - bus_dmamap_sync(sc->sis_rx_tag, - sc->sis_rx_dmamap, BUS_DMASYNC_PREWRITE); - - sc->sis_rx_pdsc = &sc->sis_rx_list[0]; + } + bus_dmamap_sync(sc->sis_rx_list_tag, sc->sis_rx_list_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); return (0); } @@ -1359,30 +1397,66 @@ sis_ring_init(struct sis_softc *sc) * Initialize an RX descriptor and attach an MBUF cluster. */ static int -sis_newbuf(struct sis_softc *sc, struct sis_desc *c, struct mbuf *m) +sis_newbuf(struct sis_softc *sc, struct sis_rxdesc *rxd) { + struct mbuf *m; + bus_dma_segment_t segs[1]; + bus_dmamap_t map; + int nsegs; - if (c == NULL) - return (EINVAL); + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m == NULL) + return (ENOBUFS); + m->m_len = m->m_pkthdr.len = SIS_RXLEN; +#ifndef __NO_STRICT_ALIGNMENT + m_adj(m, SIS_RX_BUF_ALIGN); +#endif - if (m == NULL) { - m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (m == NULL) - return (ENOBUFS); - } else - m->m_data = m->m_ext.ext_buf; + if (bus_dmamap_load_mbuf_sg(sc->sis_rx_tag, sc->sis_rx_sparemap, m, + segs, &nsegs, 0) != 0) { + m_freem(m); + return (ENOBUFS); + } + KASSERT(nsegs == 1, ("%s: %d segments returned!", __func__, nsegs)); - c->sis_mbuf = m; - c->sis_ctl = SIS_RXLEN; + if (rxd->rx_m != NULL) { + bus_dmamap_sync(sc->sis_rx_tag, rxd->rx_dmamap, + BUS_DMASYNC_POSTREAD); + bus_dmamap_unload(sc->sis_rx_tag, rxd->rx_dmamap); + } + map = rxd->rx_dmamap; + rxd->rx_dmamap = sc->sis_rx_sparemap; + sc->sis_rx_sparemap = map; + bus_dmamap_sync(sc->sis_rx_tag, rxd->rx_dmamap, BUS_DMASYNC_PREREAD); + rxd->rx_m = m; + rxd->rx_desc->sis_cmdsts = htole32(SIS_RXLEN); + rxd->rx_desc->sis_ptr = htole32(SIS_ADDR_LO(segs[0].ds_addr)); + return (0); +} - bus_dmamap_create(sc->sis_tag, 0, &c->sis_map); - bus_dmamap_load(sc->sis_tag, c->sis_map, - mtod(m, void *), MCLBYTES, - sis_dma_map_desc_ptr, c, 0); - bus_dmamap_sync(sc->sis_tag, c->sis_map, BUS_DMASYNC_PREREAD); +static __inline void +sis_discard_rxbuf(struct sis_rxdesc *rxd) +{ - return (0); + rxd->rx_desc->sis_cmdsts = htole32(SIS_RXLEN); +} + +#ifndef __NO_STRICT_ALIGNMENT +static __inline void +sis_fixup_rx(struct mbuf *m) +{ + uint16_t *src, *dst; + int i; + + src = mtod(m, uint16_t *); + dst = src - (SIS_RX_BUF_ALIGN - ETHER_ALIGN) / sizeof(*src); + + for (i = 0; i < (m->m_len / sizeof(uint16_t) + 1); i++) + *dst++ = *src++; + + m->m_data -= SIS_RX_BUF_ALIGN - ETHER_ALIGN; } +#endif /* * A frame has been uploaded: pass the resulting mbuf chain up to @@ -1391,19 +1465,23 @@ sis_newbuf(struct sis_softc *sc, struct static void sis_rxeof(struct sis_softc *sc) { - struct mbuf *m, *m0; + struct mbuf *m; struct ifnet *ifp; + struct sis_rxdesc *rxd; struct sis_desc *cur_rx; - int total_len = 0; - u_int32_t rxstat; + int prog, rx_cons, total_len; + uint32_t rxstat; SIS_LOCK_ASSERT(sc); - ifp = sc->sis_ifp; + bus_dmamap_sync(sc->sis_rx_list_tag, sc->sis_rx_list_map, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); - for (cur_rx = sc->sis_rx_pdsc; SIS_OWNDESC(cur_rx); - cur_rx = cur_rx->sis_nextdesc) { + rx_cons = sc->sis_rx_cons; + ifp = sc->sis_ifp; + for (prog = 0; (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; + SIS_INC(rx_cons, SIS_RX_LIST_CNT), prog++) { #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { if (sc->rxcycles <= 0) @@ -1411,21 +1489,13 @@ sis_rxeof(struct sis_softc *sc) sc->rxcycles--; } #endif - rxstat = cur_rx->sis_rxstat; - bus_dmamap_sync(sc->sis_tag, - cur_rx->sis_map, BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(sc->sis_tag, cur_rx->sis_map); - bus_dmamap_destroy(sc->sis_tag, cur_rx->sis_map); - m = cur_rx->sis_mbuf; - cur_rx->sis_mbuf = NULL; - total_len = SIS_RXBYTES(cur_rx); + cur_rx = &sc->sis_rx_list[rx_cons]; + rxstat = le32toh(cur_rx->sis_cmdsts); + if ((rxstat & SIS_CMDSTS_OWN) == 0) + break; + rxd = &sc->sis_rxdesc[rx_cons]; - /* - * If an error occurs, update stats, clear the - * status word and leave the mbuf cluster in place: - * it should simply get re-used next time this descriptor - * comes up in the ring. - */ + total_len = (rxstat & SIS_CMDSTS_BUFLEN) - ETHER_CRC_LEN; if ((ifp->if_capenable & IFCAP_VLAN_MTU) != 0 && total_len <= (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN - ETHER_CRC_LEN)) @@ -1434,36 +1504,29 @@ sis_rxeof(struct sis_softc *sc) ifp->if_ierrors++; if (rxstat & SIS_RXSTAT_COLL) ifp->if_collisions++; - sis_newbuf(sc, cur_rx, m); + sis_discard_rxbuf(rxd); + continue; + } + + /* Add a new receive buffer to the ring. */ + m = rxd->rx_m; + if (sis_newbuf(sc, rxd) != 0) { + ifp->if_iqdrops++; + sis_discard_rxbuf(rxd); continue; } /* No errors; receive the packet. */ -#ifdef __NO_STRICT_ALIGNMENT + m->m_pkthdr.len = m->m_len = total_len; +#ifndef __NO_STRICT_ALIGNMENT /* * On architectures without alignment problems we try to * allocate a new buffer for the receive ring, and pass up * the one where the packet is already, saving the expensive - * copy done in m_devget(). - * If we are on an architecture with alignment problems, or - * if the allocation fails, then use m_devget and leave the - * existing buffer in the receive ring. + * copy operation. */ - if (sis_newbuf(sc, cur_rx, NULL) == 0) - m->m_pkthdr.len = m->m_len = total_len; - else + sis_fixup_rx(m); #endif - { - m0 = m_devget(mtod(m, char *), total_len, - ETHER_ALIGN, ifp, NULL); - sis_newbuf(sc, cur_rx, m); - if (m0 == NULL) { - ifp->if_ierrors++; - continue; - } - m = m0; - } - ifp->if_ipackets++; m->m_pkthdr.rcvif = ifp; @@ -1472,7 +1535,12 @@ sis_rxeof(struct sis_softc *sc) SIS_LOCK(sc); } - sc->sis_rx_pdsc = cur_rx; + if (prog > 0) { + sc->sis_rx_cons = rx_cons; + bus_dmamap_sync(sc->sis_rx_list_tag, sc->sis_rx_list_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + } + } /* @@ -1484,52 +1552,54 @@ static void sis_txeof(struct sis_softc *sc) { struct ifnet *ifp; - u_int32_t idx; + struct sis_desc *cur_tx; + struct sis_txdesc *txd; + uint32_t cons, txstat; SIS_LOCK_ASSERT(sc); + + cons = sc->sis_tx_cons; + if (cons == sc->sis_tx_prod) + return; + ifp = sc->sis_ifp; + bus_dmamap_sync(sc->sis_tx_list_tag, sc->sis_tx_list_map, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); /* * Go through our tx list and free mbufs for those * frames that have been transmitted. */ - for (idx = sc->sis_tx_cons; sc->sis_tx_cnt > 0; - sc->sis_tx_cnt--, SIS_INC(idx, SIS_TX_LIST_CNT) ) { - struct sis_desc *cur_tx = &sc->sis_tx_list[idx]; - - if (SIS_OWNDESC(cur_tx)) + for (; cons != sc->sis_tx_prod; SIS_INC(cons, SIS_TX_LIST_CNT)) { + cur_tx = &sc->sis_tx_list[cons]; + txstat = le32toh(cur_tx->sis_cmdsts); + if ((txstat & SIS_CMDSTS_OWN) != 0) break; - - if (cur_tx->sis_ctl & SIS_CMDSTS_MORE) - continue; - - if (!(cur_tx->sis_ctl & SIS_CMDSTS_PKT_OK)) { - ifp->if_oerrors++; - if (cur_tx->sis_txstat & SIS_TXSTAT_EXCESSCOLLS) - ifp->if_collisions++; - if (cur_tx->sis_txstat & SIS_TXSTAT_OUTOFWINCOLL) - ifp->if_collisions++; - } - - ifp->if_collisions += - (cur_tx->sis_txstat & SIS_TXSTAT_COLLCNT) >> 16; - - ifp->if_opackets++; - if (cur_tx->sis_mbuf != NULL) { - m_freem(cur_tx->sis_mbuf); - cur_tx->sis_mbuf = NULL; - bus_dmamap_unload(sc->sis_tag, cur_tx->sis_map); - bus_dmamap_destroy(sc->sis_tag, cur_tx->sis_map); + txd = &sc->sis_txdesc[cons]; + if (txd->tx_m != NULL) { + bus_dmamap_sync(sc->sis_tx_tag, txd->tx_dmamap, + BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(sc->sis_tx_tag, txd->tx_dmamap); + m_freem(txd->tx_m); + txd->tx_m = NULL; + if ((txstat & SIS_CMDSTS_PKT_OK) != 0) { + ifp->if_opackets++; + ifp->if_collisions += + (txstat & SIS_TXSTAT_COLLCNT) >> 16; + } else { + ifp->if_oerrors++; + if (txstat & SIS_TXSTAT_EXCESSCOLLS) + ifp->if_collisions++; + if (txstat & SIS_TXSTAT_OUTOFWINCOLL) + ifp->if_collisions++; + } } - } - - if (idx != sc->sis_tx_cons) { - /* we freed up some buffers */ - sc->sis_tx_cons = idx; + sc->sis_tx_cnt--; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; } - - sc->sis_watchdog_timer = (sc->sis_tx_cnt == 0) ? 0 : 5; + sc->sis_tx_cons = cons; + if (sc->sis_tx_cnt == 0) + sc->sis_watchdog_timer = 0; } static void @@ -1676,83 +1746,80 @@ sis_intr(void *arg) * pointers to the fragment pointers. */ static int -sis_encap(struct sis_softc *sc, struct mbuf **m_head, uint32_t *txidx) +sis_encap(struct sis_softc *sc, struct mbuf **m_head) { - struct sis_desc *f = NULL; struct mbuf *m; - int frag, cur, cnt = 0, chainlen = 0; - - /* - * If there's no way we can send any packets, return now. - */ - if (SIS_TX_LIST_CNT - sc->sis_tx_cnt < 2) - return (ENOBUFS); - - /* - * Count the number of frags in this chain to see if - * we need to m_defrag. Since the descriptor list is shared - * by all packets, we'll m_defrag long chains so that they - * do not use up the entire list, even if they would fit. - */ - - for (m = *m_head; m != NULL; m = m->m_next) - chainlen++; - - if ((chainlen > SIS_TX_LIST_CNT / 4) || - ((SIS_TX_LIST_CNT - (chainlen + sc->sis_tx_cnt)) < 2)) { - m = m_defrag(*m_head, M_DONTWAIT); - if (m == NULL) + struct sis_txdesc *txd; + struct sis_desc *f; + bus_dma_segment_t segs[SIS_MAXTXSEGS]; + bus_dmamap_t map; + int error, i, frag, nsegs, prod; + + prod = sc->sis_tx_prod; + txd = &sc->sis_txdesc[prod]; + error = bus_dmamap_load_mbuf_sg(sc->sis_tx_tag, txd->tx_dmamap, + *m_head, segs, &nsegs, 0); + if (error == EFBIG) { + m = m_collapse(*m_head, M_DONTWAIT, SIS_MAXTXSEGS); + if (m == NULL) { + m_freem(*m_head); + *m_head = NULL; return (ENOBUFS); + } *m_head = m; - } - - /* - * Start packing the mbufs in this chain into - * the fragment pointers. Stop when we run out - * of fragments or hit the end of the mbuf chain. - */ - cur = frag = *txidx; - - for (m = *m_head; m != NULL; m = m->m_next) { - if (m->m_len != 0) { - if ((SIS_TX_LIST_CNT - - (sc->sis_tx_cnt + cnt)) < 2) - return (ENOBUFS); - f = &sc->sis_tx_list[frag]; - f->sis_ctl = SIS_CMDSTS_MORE | m->m_len; - bus_dmamap_create(sc->sis_tag, 0, &f->sis_map); - bus_dmamap_load(sc->sis_tag, f->sis_map, - mtod(m, void *), m->m_len, - sis_dma_map_desc_ptr, f, 0); - bus_dmamap_sync(sc->sis_tag, - f->sis_map, BUS_DMASYNC_PREREAD); - if (cnt != 0) - f->sis_ctl |= SIS_CMDSTS_OWN; - cur = frag; - SIS_INC(frag, SIS_TX_LIST_CNT); - cnt++; + error = bus_dmamap_load_mbuf_sg(sc->sis_tx_tag, txd->tx_dmamap, + *m_head, segs, &nsegs, 0); + if (error != 0) { + m_freem(*m_head); + *m_head = NULL; + return (error); } - } + } else if (error != 0) + return (error); - if (m != NULL) + /* Check for descriptor overruns. */ + if (sc->sis_tx_cnt + nsegs > SIS_TX_LIST_CNT - 1) { + bus_dmamap_unload(sc->sis_tx_tag, txd->tx_dmamap); return (ENOBUFS); + } - sc->sis_tx_list[cur].sis_mbuf = *m_head; - sc->sis_tx_list[cur].sis_ctl &= ~SIS_CMDSTS_MORE; - sc->sis_tx_list[*txidx].sis_ctl |= SIS_CMDSTS_OWN; - sc->sis_tx_cnt += cnt; - *txidx = frag; + bus_dmamap_sync(sc->sis_tx_tag, txd->tx_dmamap, BUS_DMASYNC_PREWRITE); + + frag = prod; + for (i = 0; i < nsegs; i++) { + f = &sc->sis_tx_list[prod]; + if (i == 0) + f->sis_cmdsts = htole32(segs[i].ds_len | + SIS_CMDSTS_MORE); + else + f->sis_cmdsts = htole32(segs[i].ds_len | + SIS_CMDSTS_OWN | SIS_CMDSTS_MORE); + f->sis_ptr = htole32(SIS_ADDR_LO(segs[i].ds_addr)); + SIS_INC(prod, SIS_TX_LIST_CNT); + sc->sis_tx_cnt++; + } + + /* Update producer index. */ + sc->sis_tx_prod = prod; + + /* Remove MORE flag on the last descriptor. */ + prod = (prod - 1) & (SIS_TX_LIST_CNT - 1); + f = &sc->sis_tx_list[prod]; + f->sis_cmdsts &= ~htole32(SIS_CMDSTS_MORE); + + /* Lastly transfer ownership of packet to the controller. */ + f = &sc->sis_tx_list[frag]; + f->sis_cmdsts |= htole32(SIS_CMDSTS_OWN); + + /* Swap the last and the first dmamaps. */ + map = txd->tx_dmamap; + txd->tx_dmamap = sc->sis_txdesc[prod].tx_dmamap; + sc->sis_txdesc[prod].tx_dmamap = map; + sc->sis_txdesc[prod].tx_m = *m_head; return (0); } -/* - * Main transmit routine. To avoid having to do mbuf copies, we put pointers - * to the mbuf data regions directly in the transmit lists. We also save a - * copy of the pointers since the transmit list fragment pointers are - * physical addresses. - */ - static void sis_start(struct ifnet *ifp) { @@ -1768,27 +1835,26 @@ static void sis_startl(struct ifnet *ifp) { struct sis_softc *sc; - struct mbuf *m_head = NULL; - u_int32_t idx, queued = 0; + struct mbuf *m_head; + int queued; sc = ifp->if_softc; SIS_LOCK_ASSERT(sc); - if (!sc->sis_link) + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING || sc->sis_link == 0) return; - idx = sc->sis_tx_prod; - - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) - return; - - while (sc->sis_tx_list[idx].sis_mbuf == NULL) { + for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) && + sc->sis_tx_cnt < SIS_TX_LIST_CNT - 4;) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; - if (sis_encap(sc, &m_head, &idx)) { + if (sis_encap(sc, &m_head) != 0) { + if (m_head == NULL) + break; IFQ_DRV_PREPEND(&ifp->if_snd, m_head); ifp->if_drv_flags |= IFF_DRV_OACTIVE; break; @@ -1801,12 +1867,12 @@ sis_startl(struct ifnet *ifp) * to him. */ BPF_MTAP(ifp, m_head); - } if (queued) { /* Transmit */ - sc->sis_tx_prod = idx; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:31:36 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 10DAD106564A; Fri, 8 Oct 2010 20:31:36 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F3D268FC14; Fri, 8 Oct 2010 20:31:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KVZ6m012774; Fri, 8 Oct 2010 20:31:35 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KVZ7X012771; Fri, 8 Oct 2010 20:31:35 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082031.o98KVZ7X012771@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:31:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213615 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:31:36 -0000 Author: yongari Date: Fri Oct 8 20:31:35 2010 New Revision: 213615 URL: http://svn.freebsd.org/changeset/base/213615 Log: MFC r212113: s/u_intXX_t/uintXX_t/g Modified: stable/7/sys/dev/sis/if_sis.c stable/7/sys/dev/sis/if_sisreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:30:08 2010 (r213614) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:31:35 2010 (r213615) @@ -259,7 +259,7 @@ static void sis_eeprom_getword(struct sis_softc *sc, int addr, uint16_t *dest) { int i; - u_int16_t word = 0; + uint16_t word = 0; /* Force EEPROM to idle state. */ sis_eeprom_idle(sc); @@ -302,11 +302,11 @@ static void sis_read_eeprom(struct sis_softc *sc, caddr_t dest, int off, int cnt, int swap) { int i; - u_int16_t word = 0, *ptr; + uint16_t word = 0, *ptr; for (i = 0; i < cnt; i++) { sis_eeprom_getword(sc, off + i, &word); - ptr = (u_int16_t *)(dest + (i * 2)); + ptr = (uint16_t *)(dest + (i * 2)); if (swap) *ptr = ntohs(word); else @@ -356,7 +356,7 @@ static void sis_read_cmos(struct sis_softc *sc, device_t dev, caddr_t dest, int off, int cnt) { device_t bridge; - u_int8_t reg; + uint8_t reg; int i; bus_space_tag_t btag; @@ -384,7 +384,7 @@ sis_read_cmos(struct sis_softc *sc, devi static void sis_read_mac(struct sis_softc *sc, device_t dev, caddr_t dest) { - u_int32_t filtsave, csrsave; + uint32_t filtsave, csrsave; filtsave = CSR_READ_4(sc, SIS_RXFILT_CTL); csrsave = CSR_READ_4(sc, SIS_CSR); @@ -395,11 +395,11 @@ sis_read_mac(struct sis_softc *sc, devic CSR_WRITE_4(sc, SIS_RXFILT_CTL, filtsave & ~SIS_RXFILTCTL_ENABLE); CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR0); - ((u_int16_t *)dest)[0] = CSR_READ_2(sc, SIS_RXFILT_DATA); + ((uint16_t *)dest)[0] = CSR_READ_2(sc, SIS_RXFILT_DATA); CSR_WRITE_4(sc, SIS_RXFILT_CTL,SIS_FILTADDR_PAR1); - ((u_int16_t *)dest)[1] = CSR_READ_2(sc, SIS_RXFILT_DATA); + ((uint16_t *)dest)[1] = CSR_READ_2(sc, SIS_RXFILT_DATA); CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR2); - ((u_int16_t *)dest)[2] = CSR_READ_2(sc, SIS_RXFILT_DATA); + ((uint16_t *)dest)[2] = CSR_READ_2(sc, SIS_RXFILT_DATA); CSR_WRITE_4(sc, SIS_RXFILT_CTL, filtsave); CSR_WRITE_4(sc, SIS_CSR, csrsave); @@ -731,7 +731,7 @@ sis_setmulti_ns(struct sis_softc *sc) { struct ifnet *ifp; struct ifmultiaddr *ifma; - u_int32_t h = 0, i, filtsave; + uint32_t h = 0, i, filtsave; int bit, index; ifp = sc->sis_ifp; @@ -780,8 +780,8 @@ sis_setmulti_sis(struct sis_softc *sc) { struct ifnet *ifp; struct ifmultiaddr *ifma; - u_int32_t h, i, n, ctl; - u_int16_t hashes[16]; + uint32_t h, i, n, ctl; + uint16_t hashes[16]; ifp = sc->sis_ifp; @@ -963,7 +963,7 @@ sis_attach(device_t dev) * Why? Who the hell knows. */ { - u_int16_t tmp[4]; + uint16_t tmp[4]; sis_read_eeprom(sc, (caddr_t)&tmp, NS_EE_NODEADDR, 4, 0); @@ -1658,7 +1658,7 @@ sis_poll(struct ifnet *ifp, enum poll_cm sis_startl(ifp); if (sc->rxcycles > 0 || cmd == POLL_AND_CHECK_STATUS) { - u_int32_t status; + uint32_t status; /* Reading the ISR register clears all interrupts. */ status = CSR_READ_4(sc, SIS_ISR); @@ -1684,7 +1684,7 @@ sis_intr(void *arg) { struct sis_softc *sc; struct ifnet *ifp; - u_int32_t status; + uint32_t status; sc = arg; ifp = sc->sis_ifp; @@ -1922,23 +1922,23 @@ sis_initl(struct sis_softc *sc) if (sc->sis_type == SIS_TYPE_83815) { CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR0); CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((u_int16_t *)IF_LLADDR(sc->sis_ifp))[0]); + ((uint16_t *)IF_LLADDR(sc->sis_ifp))[0]); CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR1); CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((u_int16_t *)IF_LLADDR(sc->sis_ifp))[1]); + ((uint16_t *)IF_LLADDR(sc->sis_ifp))[1]); CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR2); CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((u_int16_t *)IF_LLADDR(sc->sis_ifp))[2]); + ((uint16_t *)IF_LLADDR(sc->sis_ifp))[2]); } else { CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR0); CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((u_int16_t *)IF_LLADDR(sc->sis_ifp))[0]); + ((uint16_t *)IF_LLADDR(sc->sis_ifp))[0]); CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR1); CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((u_int16_t *)IF_LLADDR(sc->sis_ifp))[1]); + ((uint16_t *)IF_LLADDR(sc->sis_ifp))[1]); CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR2); CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((u_int16_t *)IF_LLADDR(sc->sis_ifp))[2]); + ((uint16_t *)IF_LLADDR(sc->sis_ifp))[2]); } /* Init circular TX/RX lists. */ Modified: stable/7/sys/dev/sis/if_sisreg.h ============================================================================== --- stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:30:08 2010 (r213614) +++ stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:31:35 2010 (r213615) @@ -308,9 +308,9 @@ */ struct sis_desc { /* SiS hardware descriptor section */ - u_int32_t sis_next; - u_int32_t sis_cmdsts; - u_int32_t sis_ptr; + uint32_t sis_next; + uint32_t sis_cmdsts; + uint32_t sis_ptr; }; #define SIS_CMDSTS_BUFLEN 0x00000FFF @@ -403,18 +403,18 @@ struct sis_desc { #define NS_DEVICEID_DP83815 0x0020 struct sis_type { - u_int16_t sis_vid; - u_int16_t sis_did; + uint16_t sis_vid; + uint16_t sis_did; char *sis_name; }; struct sis_mii_frame { - u_int8_t mii_stdelim; - u_int8_t mii_opcode; - u_int8_t mii_phyaddr; - u_int8_t mii_regaddr; - u_int8_t mii_turnaround; - u_int16_t mii_data; + uint8_t mii_stdelim; + uint8_t mii_opcode; + uint8_t mii_phyaddr; + uint8_t mii_regaddr; + uint8_t mii_turnaround; + uint16_t mii_data; }; /* @@ -447,10 +447,10 @@ struct sis_softc { void *sis_intrhand; device_t sis_dev; device_t sis_miibus; - u_int8_t sis_type; - u_int8_t sis_rev; - u_int8_t sis_link; - u_int sis_srr; + uint8_t sis_type; + uint8_t sis_rev; + uint8_t sis_link; + uint32_t sis_srr; struct sis_desc *sis_rx_list; struct sis_desc *sis_tx_list; bus_dma_tag_t sis_rx_list_tag; From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:37:13 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C85E7106566C; Fri, 8 Oct 2010 20:37:13 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B6FEA8FC12; Fri, 8 Oct 2010 20:37:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KbDL8013051; Fri, 8 Oct 2010 20:37:13 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KbD9P013048; Fri, 8 Oct 2010 20:37:13 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082037.o98KbD9P013048@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:37:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213618 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:37:13 -0000 Author: yongari Date: Fri Oct 8 20:37:13 2010 New Revision: 213618 URL: http://svn.freebsd.org/changeset/base/213618 Log: MFC r212116: Overhaul link state change handling. Previously sis(4) blindly configured TX/RX MACs before getting a valid link. After that, when link state change callback is called, it called device initialization again to reconfigure TX/RX MACs depending on resolved link state. This hack created several bad side effects and it required more hacks to not collide with sis_tick callback as well as disabling switching to currently selected media in device initialization. Also it seems sis(4) was used to be a template driver for long time so other drivers which was modeled after sis(4) also should be changed. TX/RX MACs are now reconfigured after getting a valid link. Fix for short cable error is also applied after getting a link because it's only valid when the resolved speed is 100Mbps. While I'm here slightly reorganize interrupt handler such that sis(4) always read SIS_ISR register to see whether the interrupt is ours or not. This change removes another hack and make it possible to nuke sis_stopped variable in softc. Modified: stable/7/sys/dev/sis/if_sis.c stable/7/sys/dev/sis/if_sisreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:34:23 2010 (r213617) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:37:13 2010 (r213618) @@ -697,10 +697,86 @@ static void sis_miibus_statchg(device_t dev) { struct sis_softc *sc; + struct mii_data *mii; + struct ifnet *ifp; + uint32_t reg; sc = device_get_softc(dev); SIS_LOCK_ASSERT(sc); - sis_initl(sc); + + mii = device_get_softc(sc->sis_miibus); + ifp = sc->sis_ifp; + if (mii == NULL || ifp == NULL || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + return; + + sc->sis_link = 0; + if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == + (IFM_ACTIVE | IFM_AVALID)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + sc->sis_link++; + CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_10); + break; + case IFM_100_TX: + sc->sis_link++; + CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_100); + break; + default: + break; + } + } + + if (sc->sis_link == 0) { + /* + * Stopping MACs seem to reset SIS_TX_LISTPTR and + * SIS_RX_LISTPTR which in turn requires resetting + * TX/RX buffers. So just don't do anything for + * lost link. + */ + return; + } + + /* Set full/half duplex mode. */ + if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) { + SIS_SETBIT(sc, SIS_TX_CFG, + (SIS_TXCFG_IGN_HBEAT | SIS_TXCFG_IGN_CARR)); + SIS_SETBIT(sc, SIS_RX_CFG, SIS_RXCFG_RX_TXPKTS); + } else { + SIS_CLRBIT(sc, SIS_TX_CFG, + (SIS_TXCFG_IGN_HBEAT | SIS_TXCFG_IGN_CARR)); + SIS_CLRBIT(sc, SIS_RX_CFG, SIS_RXCFG_RX_TXPKTS); + } + + if (sc->sis_type == SIS_TYPE_83816) { + /* + * MPII03.D: Half Duplex Excessive Collisions. + * Also page 49 in 83816 manual + */ + SIS_SETBIT(sc, SIS_TX_CFG, SIS_TXCFG_MPII03D); + } + + if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr < NS_SRR_16A && + IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) { + /* + * Short Cable Receive Errors (MP21.E) + */ + CSR_WRITE_4(sc, NS_PHY_PAGE, 0x0001); + reg = CSR_READ_4(sc, NS_PHY_DSPCFG) & 0xfff; + CSR_WRITE_4(sc, NS_PHY_DSPCFG, reg | 0x1000); + DELAY(100); + reg = CSR_READ_4(sc, NS_PHY_TDATA) & 0xff; + if ((reg & 0x0080) == 0 || (reg > 0xd8 && reg <= 0xff)) { + device_printf(sc->sis_dev, + "Applying short cable fix (reg=%x)\n", reg); + CSR_WRITE_4(sc, NS_PHY_TDATA, 0x00e8); + SIS_SETBIT(sc, NS_PHY_DSPCFG, 0x20); + } + CSR_WRITE_4(sc, NS_PHY_PAGE, 0); + } + /* Enable TX/RX MACs. */ + SIS_CLRBIT(sc, SIS_CSR, SIS_CSR_TX_DISABLE | SIS_CSR_RX_DISABLE); + SIS_SETBIT(sc, SIS_CSR, SIS_CSR_TX_ENABLE | SIS_CSR_RX_ENABLE); } static uint32_t @@ -1611,23 +1687,14 @@ sis_tick(void *xsc) sc = xsc; SIS_LOCK_ASSERT(sc); - sc->in_tick = 1; ifp = sc->sis_ifp; mii = device_get_softc(sc->sis_miibus); mii_tick(mii); - sis_watchdog(sc); - - if (!sc->sis_link && mii->mii_media_status & IFM_ACTIVE && - IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { - sc->sis_link++; - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - sis_startl(ifp); - } - + if (sc->sis_link == 0) + sis_miibus_statchg(sc->sis_dev); callout_reset(&sc->sis_stat_ch, hz, sis_tick, sc); - sc->in_tick = 0; } #ifdef DEVICE_POLLING @@ -1689,9 +1756,6 @@ sis_intr(void *arg) sc = arg; ifp = sc->sis_ifp; - if (sc->sis_stopped) /* Most likely shared interrupt */ - return; - SIS_LOCK(sc); #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { @@ -1700,17 +1764,17 @@ sis_intr(void *arg) } #endif + /* Reading the ISR register clears all interrupts. */ + status = CSR_READ_4(sc, SIS_ISR); + if ((status & SIS_INTRS) == 0) { + /* Not ours. */ + SIS_UNLOCK(sc); + } + /* Disable interrupts. */ CSR_WRITE_4(sc, SIS_IER, 0); - for (;;) { - SIS_LOCK_ASSERT(sc); - /* Reading the ISR register clears all interrupts. */ - status = CSR_READ_4(sc, SIS_ISR); - - if ((status & SIS_INTRS) == 0) - break; - + for (;(status & SIS_INTRS) != 0;) { if (status & (SIS_ISR_TX_DESC_OK | SIS_ISR_TX_ERR | SIS_ISR_TX_OK | SIS_ISR_TX_IDLE) ) @@ -1729,7 +1793,10 @@ sis_intr(void *arg) if (status & SIS_ISR_SYSERR) { sis_reset(sc); sis_initl(sc); + SIS_UNLOCK(sc); + return; } + status = CSR_READ_4(sc, SIS_ISR); } /* Re-enable interrupts. */ @@ -1904,7 +1971,6 @@ sis_initl(struct sis_softc *sc) * Cancel pending I/O and free all RX/TX buffers. */ sis_stop(sc); - sc->sis_stopped = 0; #ifdef notyet if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr >= NS_SRR_16A) { @@ -1968,7 +2034,6 @@ sis_initl(struct sis_softc *sc) CSR_WRITE_4(sc, NS_PHY_PAGE, 0); } - /* * For the NatSemi chip, we have to explicitly enable the * reception of ARP frames, as well as turn on the 'perfect @@ -2026,52 +2091,11 @@ sis_initl(struct sis_softc *sc) /* Accept Long Packets for VLAN support */ SIS_SETBIT(sc, SIS_RX_CFG, SIS_RXCFG_RX_JABBER); - /* Set TX configuration */ - if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T) { - CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_10); - } else { - CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_100); - } - - /* Set full/half duplex mode. */ - if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) { - SIS_SETBIT(sc, SIS_TX_CFG, - (SIS_TXCFG_IGN_HBEAT|SIS_TXCFG_IGN_CARR)); - SIS_SETBIT(sc, SIS_RX_CFG, SIS_RXCFG_RX_TXPKTS); - } else { - SIS_CLRBIT(sc, SIS_TX_CFG, - (SIS_TXCFG_IGN_HBEAT|SIS_TXCFG_IGN_CARR)); - SIS_CLRBIT(sc, SIS_RX_CFG, SIS_RXCFG_RX_TXPKTS); - } - - if (sc->sis_type == SIS_TYPE_83816) { - /* - * MPII03.D: Half Duplex Excessive Collisions. - * Also page 49 in 83816 manual - */ - SIS_SETBIT(sc, SIS_TX_CFG, SIS_TXCFG_MPII03D); - } - - if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr < NS_SRR_16A && - IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) { - uint32_t reg; - - /* - * Short Cable Receive Errors (MP21.E) - */ - CSR_WRITE_4(sc, NS_PHY_PAGE, 0x0001); - reg = CSR_READ_4(sc, NS_PHY_DSPCFG) & 0xfff; - CSR_WRITE_4(sc, NS_PHY_DSPCFG, reg | 0x1000); - DELAY(100); - reg = CSR_READ_4(sc, NS_PHY_TDATA) & 0xff; - if ((reg & 0x0080) == 0 || (reg > 0xd8 && reg <= 0xff)) { - device_printf(sc->sis_dev, - "Applying short cable fix (reg=%x)\n", reg); - CSR_WRITE_4(sc, NS_PHY_TDATA, 0x00e8); - SIS_SETBIT(sc, NS_PHY_DSPCFG, 0x20); - } - CSR_WRITE_4(sc, NS_PHY_PAGE, 0); - } + /* + * Assume 100Mbps link, actual MAC configuration is done + * after getting a valid link. + */ + CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_100); /* * Enable interrupts. @@ -2088,19 +2112,16 @@ sis_initl(struct sis_softc *sc) #endif CSR_WRITE_4(sc, SIS_IER, 1); - /* Enable receiver and transmitter. */ - SIS_CLRBIT(sc, SIS_CSR, SIS_CSR_TX_DISABLE|SIS_CSR_RX_DISABLE); - SIS_SETBIT(sc, SIS_CSR, SIS_CSR_RX_ENABLE); + /* Clear MAC disable. */ + SIS_CLRBIT(sc, SIS_CSR, SIS_CSR_TX_DISABLE | SIS_CSR_RX_DISABLE); -#ifdef notdef + sc->sis_link = 0; mii_mediachg(mii); -#endif ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - if (!sc->in_tick) - callout_reset(&sc->sis_stat_ch, hz, sis_tick, sc); + callout_reset(&sc->sis_stat_ch, hz, sis_tick, sc); } /* @@ -2222,10 +2243,6 @@ sis_watchdog(struct sis_softc *sc) { SIS_LOCK_ASSERT(sc); - if (sc->sis_stopped) { - SIS_UNLOCK(sc); - return; - } if (sc->sis_watchdog_timer == 0 || --sc->sis_watchdog_timer >0) return; @@ -2253,9 +2270,8 @@ sis_stop(struct sis_softc *sc) struct sis_txdesc *txd; int i; - if (sc->sis_stopped) - return; SIS_LOCK_ASSERT(sc); + ifp = sc->sis_ifp; sc->sis_watchdog_timer = 0; @@ -2299,8 +2315,6 @@ sis_stop(struct sis_softc *sc) txd->tx_m = NULL; } } - - sc->sis_stopped = 1; } /* Modified: stable/7/sys/dev/sis/if_sisreg.h ============================================================================== --- stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:34:23 2010 (r213617) +++ stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:37:13 2010 (r213618) @@ -471,11 +471,9 @@ struct sis_softc { bus_addr_t sis_tx_paddr; struct callout sis_stat_ch; int sis_watchdog_timer; - int sis_stopped; #ifdef DEVICE_POLLING int rxcycles; #endif - int in_tick; struct mtx sis_mtx; }; From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:41:15 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F794106566C; Fri, 8 Oct 2010 20:41:15 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 64FB88FC1D; Fri, 8 Oct 2010 20:41:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KfFsC013298; Fri, 8 Oct 2010 20:41:15 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KfFUN013295; Fri, 8 Oct 2010 20:41:15 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082041.o98KfFUN013295@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:41:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213621 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:41:15 -0000 Author: yongari Date: Fri Oct 8 20:41:15 2010 New Revision: 213621 URL: http://svn.freebsd.org/changeset/base/213621 Log: MFC r212117,212119: rr212117: Report result of link state change to caller. Previously it always returned success. r212119: Do not reinitialize controller whenever promiscuous mode or allmulti is toggled. Controller does not require reinitialization. This removes unnecessary controller reinitialization whenever tcpdump is used. While I'm here remove unnecessary variable reinitialization. Modified: stable/7/sys/dev/sis/if_sis.c stable/7/sys/dev/sis/if_sisreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:40:05 2010 (r213620) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:41:15 2010 (r213621) @@ -2132,6 +2132,7 @@ sis_ifmedia_upd(struct ifnet *ifp) { struct sis_softc *sc; struct mii_data *mii; + int error; sc = ifp->if_softc; @@ -2143,10 +2144,10 @@ sis_ifmedia_upd(struct ifnet *ifp) LIST_FOREACH(miisc, &mii->mii_phys, mii_list) mii_phy_reset(miisc); } - mii_mediachg(mii); + error = mii_mediachg(mii); SIS_UNLOCK(sc); - return (0); + return (error); } /* @@ -2180,10 +2181,19 @@ sis_ioctl(struct ifnet *ifp, u_long comm case SIOCSIFFLAGS: SIS_LOCK(sc); if (ifp->if_flags & IFF_UP) { - sis_initl(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0 && + ((ifp->if_flags ^ sc->sis_if_flags) & + (IFF_PROMISC | IFF_ALLMULTI)) != 0) { + if (sc->sis_type == SIS_TYPE_83815) + sis_setmulti_ns(sc); + else + sis_setmulti_sis(sc); + } else + sis_initl(sc); } else if (ifp->if_drv_flags & IFF_DRV_RUNNING) { sis_stop(sc); } + sc->sis_if_flags = ifp->if_flags; SIS_UNLOCK(sc); error = 0; break; @@ -2195,7 +2205,6 @@ sis_ioctl(struct ifnet *ifp, u_long comm else sis_setmulti_sis(sc); SIS_UNLOCK(sc); - error = 0; break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: Modified: stable/7/sys/dev/sis/if_sisreg.h ============================================================================== --- stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:40:05 2010 (r213620) +++ stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:41:15 2010 (r213621) @@ -471,6 +471,7 @@ struct sis_softc { bus_addr_t sis_tx_paddr; struct callout sis_stat_ch; int sis_watchdog_timer; + int sis_if_flags; #ifdef DEVICE_POLLING int rxcycles; #endif From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:44:35 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5852A106564A; Fri, 8 Oct 2010 20:44:35 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 481AA8FC17; Fri, 8 Oct 2010 20:44:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KiZ0o013472; Fri, 8 Oct 2010 20:44:35 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KiZhI013470; Fri, 8 Oct 2010 20:44:35 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082044.o98KiZhI013470@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:44:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213623 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:44:35 -0000 Author: yongari Date: Fri Oct 8 20:44:35 2010 New Revision: 213623 URL: http://svn.freebsd.org/changeset/base/213623 Log: MFC r212120: Avoid controller reinitialization which could be triggered by dhclient(8) or alias addresses are added. PR: kern/87506 Modified: stable/7/sys/dev/sis/if_sis.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:42:59 2010 (r213622) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:44:35 2010 (r213623) @@ -1738,6 +1738,7 @@ sis_poll(struct ifnet *ifp, enum poll_cm if (status & SIS_ISR_SYSERR) { sis_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sis_initl(sc); } } @@ -1792,6 +1793,7 @@ sis_intr(void *arg) if (status & SIS_ISR_SYSERR) { sis_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sis_initl(sc); SIS_UNLOCK(sc); return; @@ -1967,6 +1969,9 @@ sis_initl(struct sis_softc *sc) SIS_LOCK_ASSERT(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; + /* * Cancel pending I/O and free all RX/TX buffers. */ From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:49:44 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 680891065697; Fri, 8 Oct 2010 20:49:44 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 575948FC14; Fri, 8 Oct 2010 20:49:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KniUP013698; Fri, 8 Oct 2010 20:49:44 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KniYi013696; Fri, 8 Oct 2010 20:49:44 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082049.o98KniYi013696@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:49:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213625 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:49:44 -0000 Author: yongari Date: Fri Oct 8 20:49:44 2010 New Revision: 213625 URL: http://svn.freebsd.org/changeset/base/213625 Log: MFC r212121,212156: r212121: Move sis_reset() to sis_initl(). This ensures driver starts with known good state of controller. r212156: Fix the last endianness issue on handling station address which prevented driver from working on big-endian machines. Also rewrite station address programming to make it work on strict-alignment architectures. With this change, sis(4) now works on sparc64 and performance number looks good even though sis(4) have to apply fixup code to align received frames on 2 bytes boundary on sparc64. Modified: stable/7/sys/dev/sis/if_sis.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:48:09 2010 (r213624) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:49:44 2010 (r213625) @@ -1057,7 +1057,12 @@ sis_attach(device_t dev) tmp[2] = sis_reverse(tmp[2]); tmp[1] = sis_reverse(tmp[1]); - bcopy((char *)&tmp[1], eaddr, ETHER_ADDR_LEN); + eaddr[0] = (tmp[1] >> 0) & 0xFF; + eaddr[1] = (tmp[1] >> 8) & 0xFF; + eaddr[2] = (tmp[2] >> 0) & 0xFF; + eaddr[3] = (tmp[2] >> 8) & 0xFF; + eaddr[4] = (tmp[3] >> 0) & 0xFF; + eaddr[5] = (tmp[3] >> 8) & 0xFF; } break; case SIS_VENDORID: @@ -1205,7 +1210,6 @@ sis_detach(device_t dev) /* These should only be active if attach succeeded. */ if (device_is_attached(dev)) { SIS_LOCK(sc); - sis_reset(sc); sis_stop(sc); SIS_UNLOCK(sc); callout_drain(&sc->sis_stat_ch); @@ -1737,7 +1741,6 @@ sis_poll(struct ifnet *ifp, enum poll_cm SIS_SETBIT(sc, SIS_CSR, SIS_CSR_RX_ENABLE); if (status & SIS_ISR_SYSERR) { - sis_reset(sc); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sis_initl(sc); } @@ -1792,7 +1795,6 @@ sis_intr(void *arg) SIS_SETBIT(sc, SIS_CSR, SIS_CSR_RX_ENABLE); if (status & SIS_ISR_SYSERR) { - sis_reset(sc); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sis_initl(sc); SIS_UNLOCK(sc); @@ -1966,6 +1968,7 @@ sis_initl(struct sis_softc *sc) { struct ifnet *ifp = sc->sis_ifp; struct mii_data *mii; + uint8_t *eaddr; SIS_LOCK_ASSERT(sc); @@ -1976,7 +1979,10 @@ sis_initl(struct sis_softc *sc) * Cancel pending I/O and free all RX/TX buffers. */ sis_stop(sc); - + /* + * Reset the chip to a known state. + */ + sis_reset(sc); #ifdef notyet if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr >= NS_SRR_16A) { /* @@ -1990,26 +1996,21 @@ sis_initl(struct sis_softc *sc) mii = device_get_softc(sc->sis_miibus); /* Set MAC address */ + eaddr = IF_LLADDR(sc->sis_ifp); if (sc->sis_type == SIS_TYPE_83815) { CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR0); - CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((uint16_t *)IF_LLADDR(sc->sis_ifp))[0]); + CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[0] | eaddr[1] << 8); CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR1); - CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((uint16_t *)IF_LLADDR(sc->sis_ifp))[1]); + CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[2] | eaddr[3] << 8); CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_PAR2); - CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((uint16_t *)IF_LLADDR(sc->sis_ifp))[2]); + CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[4] | eaddr[5] << 8); } else { CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR0); - CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((uint16_t *)IF_LLADDR(sc->sis_ifp))[0]); + CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[0] | eaddr[1] << 8); CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR1); - CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((uint16_t *)IF_LLADDR(sc->sis_ifp))[1]); + CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[2] | eaddr[3] << 8); CSR_WRITE_4(sc, SIS_RXFILT_CTL, SIS_FILTADDR_PAR2); - CSR_WRITE_4(sc, SIS_RXFILT_DATA, - ((uint16_t *)IF_LLADDR(sc->sis_ifp))[2]); + CSR_WRITE_4(sc, SIS_RXFILT_DATA, eaddr[4] | eaddr[5] << 8); } /* Init circular TX/RX lists. */ @@ -2264,8 +2265,7 @@ sis_watchdog(struct sis_softc *sc) device_printf(sc->sis_dev, "watchdog timeout\n"); sc->sis_ifp->if_oerrors++; - sis_stop(sc); - sis_reset(sc); + sc->sis_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sis_initl(sc); if (!IFQ_DRV_IS_EMPTY(&sc->sis_ifp->if_snd)) @@ -2342,7 +2342,6 @@ sis_shutdown(device_t dev) sc = device_get_softc(dev); SIS_LOCK(sc); - sis_reset(sc); sis_stop(sc); SIS_UNLOCK(sc); } From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:52:48 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 337CA106566B; Fri, 8 Oct 2010 20:52:48 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 227078FC15; Fri, 8 Oct 2010 20:52:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KqmXi013874; Fri, 8 Oct 2010 20:52:48 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KqlSo013871; Fri, 8 Oct 2010 20:52:47 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082052.o98KqlSo013871@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:52:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213627 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:52:48 -0000 Author: yongari Date: Fri Oct 8 20:52:47 2010 New Revision: 213627 URL: http://svn.freebsd.org/changeset/base/213627 Log: MFC r212157: Unlike most other controllers, NS DP83815/DP83816 controllers seem to pad with 0xFF when it encounter short frames. According to RFC 1042 the pad bytes should be 0x00. Because manual padding consumes extra CPU cycles, introduce a new tunable which controls the padding behavior. Turning this tunable on will have driver pad manually but it's disabled by default. Users can enable software padding by setting the following tunable to non-zero value. dev.sis.%d.manual_pad="1" PR: kern/35422 (patch not used) Modified: stable/7/sys/dev/sis/if_sis.c stable/7/sys/dev/sis/if_sisreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:51:33 2010 (r213626) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 20:52:47 2010 (r213627) @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -150,6 +151,7 @@ static void sis_rxeof(struct sis_softc * static void sis_start(struct ifnet *); static void sis_startl(struct ifnet *); static void sis_stop(struct sis_softc *); +static void sis_add_sysctls(struct sis_softc *); static void sis_watchdog(struct sis_softc *); @@ -710,24 +712,24 @@ sis_miibus_statchg(device_t dev) (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) return; - sc->sis_link = 0; + sc->sis_flags &= ~SIS_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: - sc->sis_link++; CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_10); + sc->sis_flags |= SIS_FLAG_LINK; break; case IFM_100_TX: - sc->sis_link++; CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_100); + sc->sis_flags |= SIS_FLAG_LINK; break; default: break; } } - if (sc->sis_link == 0) { + if ((sc->sis_flags & SIS_FLAG_LINK) == 0) { /* * Stopping MACs seem to reset SIS_TX_LISTPTR and * SIS_RX_LISTPTR which in turn requires resetting @@ -1122,6 +1124,8 @@ sis_attach(device_t dev) break; } + sis_add_sysctls(sc); + /* Allocate DMA'able memory. */ if ((error = sis_dma_alloc(sc)) != 0) goto fail; @@ -1696,7 +1700,7 @@ sis_tick(void *xsc) mii = device_get_softc(sc->sis_miibus); mii_tick(mii); sis_watchdog(sc); - if (sc->sis_link == 0) + if ((sc->sis_flags & SIS_FLAG_LINK) == 0) sis_miibus_statchg(sc->sis_dev); callout_reset(&sc->sis_stat_ch, hz, sis_tick, sc); } @@ -1825,9 +1829,41 @@ sis_encap(struct sis_softc *sc, struct m bus_dma_segment_t segs[SIS_MAXTXSEGS]; bus_dmamap_t map; int error, i, frag, nsegs, prod; + int padlen; prod = sc->sis_tx_prod; txd = &sc->sis_txdesc[prod]; + if ((sc->sis_flags & SIS_FLAG_MANUAL_PAD) != 0 && + (*m_head)->m_pkthdr.len < SIS_MIN_FRAMELEN) { + m = *m_head; + padlen = SIS_MIN_FRAMELEN - m->m_pkthdr.len; + if (M_WRITABLE(m) == 0) { + /* Get a writable copy. */ + m = m_dup(*m_head, M_DONTWAIT); + m_freem(*m_head); + if (m == NULL) { + *m_head = NULL; + return (ENOBUFS); + } + *m_head = m; + } + if (m->m_next != NULL || M_TRAILINGSPACE(m) < padlen) { + m = m_defrag(m, M_DONTWAIT); + if (m == NULL) { + m_freem(*m_head); + *m_head = NULL; + return (ENOBUFS); + } + } + /* + * Manually pad short frames, and zero the pad space + * to avoid leaking data. + */ + bzero(mtod(m, char *) + m->m_pkthdr.len, padlen); + m->m_pkthdr.len += padlen; + m->m_len = m->m_pkthdr.len; + *m_head = m; + } error = bus_dmamap_load_mbuf_sg(sc->sis_tx_tag, txd->tx_dmamap, *m_head, segs, &nsegs, 0); if (error == EFBIG) { @@ -1914,7 +1950,7 @@ sis_startl(struct ifnet *ifp) SIS_LOCK_ASSERT(sc); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING || sc->sis_link == 0) + IFF_DRV_RUNNING || (sc->sis_flags & SIS_FLAG_LINK) == 0) return; for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) && @@ -2021,6 +2057,13 @@ sis_initl(struct sis_softc *sc) return; } + if (sc->sis_type == SIS_TYPE_83815 || sc->sis_type == SIS_TYPE_83816) { + if (sc->sis_manual_pad != 0) + sc->sis_flags |= SIS_FLAG_MANUAL_PAD; + else + sc->sis_flags &= ~SIS_FLAG_MANUAL_PAD; + } + /* * Short Cable Receive Errors (MP21.E) * also: Page 78 of the DP83815 data sheet (september 2002 version) @@ -2121,7 +2164,7 @@ sis_initl(struct sis_softc *sc) /* Clear MAC disable. */ SIS_CLRBIT(sc, SIS_CSR, SIS_CSR_TX_DISABLE | SIS_CSR_RX_DISABLE); - sc->sis_link = 0; + sc->sis_flags &= ~SIS_FLAG_LINK; mii_mediachg(mii); ifp->if_drv_flags |= IFF_DRV_RUNNING; @@ -2144,7 +2187,6 @@ sis_ifmedia_upd(struct ifnet *ifp) SIS_LOCK(sc); mii = device_get_softc(sc->sis_miibus); - sc->sis_link = 0; if (mii->mii_instance) { struct mii_softc *miisc; LIST_FOREACH(miisc, &mii->mii_phys, mii_list) @@ -2300,7 +2342,7 @@ sis_stop(struct sis_softc *sc) CSR_WRITE_4(sc, SIS_TX_LISTPTR, 0); CSR_WRITE_4(sc, SIS_RX_LISTPTR, 0); - sc->sis_link = 0; + sc->sis_flags &= ~SIS_FLAG_LINK; /* * Free data in the RX lists. @@ -2346,6 +2388,32 @@ sis_shutdown(device_t dev) SIS_UNLOCK(sc); } +static void +sis_add_sysctls(struct sis_softc *sc) +{ + struct sysctl_ctx_list *ctx; + struct sysctl_oid_list *children; + char tn[32]; + int unit; + + ctx = device_get_sysctl_ctx(sc->sis_dev); + children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sis_dev)); + + unit = device_get_unit(sc->sis_dev); + /* + * Unlike most other controllers, NS DP83815/DP83816 controllers + * seem to pad with 0xFF when it encounter short frames. According + * to RFC 1042 the pad bytes should be 0x00. Turning this tunable + * on will have driver pad manully but it's disabled by default + * because it will consume extra CPU cycles for short frames. + */ + sc->sis_manual_pad = 0; + snprintf(tn, sizeof(tn), "dev.sis.%d.manual_pad", unit); + TUNABLE_INT_FETCH(tn, &sc->sis_manual_pad); + SYSCTL_ADD_INT(ctx, children, OID_AUTO, "manual_pad", + CTLFLAG_RW, &sc->sis_manual_pad, 0, "Manually pad short frames"); +} + static device_method_t sis_methods[] = { /* Device interface */ DEVMETHOD(device_probe, sis_probe), Modified: stable/7/sys/dev/sis/if_sisreg.h ============================================================================== --- stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:51:33 2010 (r213626) +++ stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 20:52:47 2010 (r213627) @@ -449,7 +449,10 @@ struct sis_softc { device_t sis_miibus; uint8_t sis_type; uint8_t sis_rev; - uint8_t sis_link; + uint32_t sis_flags; +#define SIS_FLAG_MANUAL_PAD 0x0800 +#define SIS_FLAG_LINK 0x8000 + int sis_manual_pad; uint32_t sis_srr; struct sis_desc *sis_rx_list; struct sis_desc *sis_tx_list; From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:55:27 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E183D106566B; Fri, 8 Oct 2010 20:55:27 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D13678FC0C; Fri, 8 Oct 2010 20:55:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98KtRVZ014052; Fri, 8 Oct 2010 20:55:27 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KtRCN014050; Fri, 8 Oct 2010 20:55:27 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082055.o98KtRCN014050@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:55:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213629 - stable/7/sys/sparc64/conf X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:55:28 -0000 Author: yongari Date: Fri Oct 8 20:55:27 2010 New Revision: 213629 URL: http://svn.freebsd.org/changeset/base/213629 Log: MFC r212158: Enable sis(4). sis(4) should work on all architectures. Modified: stable/7/sys/sparc64/conf/GENERIC Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/sparc64/conf/GENERIC ============================================================================== --- stable/7/sys/sparc64/conf/GENERIC Fri Oct 8 20:54:09 2010 (r213628) +++ stable/7/sys/sparc64/conf/GENERIC Fri Oct 8 20:55:27 2010 (r213629) @@ -176,7 +176,7 @@ device nge # NatSemi DP83820 gigabit E device re # RealTek 8139C+/8169/8169S/8110S device rl # RealTek 8129/8139 device sf # Adaptec AIC-6915 (``Starfire'') -#device sis # Silicon Integrated Systems SiS 900/SiS 7016 +device sis # Silicon Integrated Systems SiS 900/SiS 7016 device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet device ste # Sundance ST201 (D-Link DFE-550TX) device stge # Sundance/Tamarack TC9021 gigabit Ethernet From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 20:58:49 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C6501065672; Fri, 8 Oct 2010 20:58:49 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 42E7A8FC0A; Fri, 8 Oct 2010 20:58:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98Kwn5B014246; Fri, 8 Oct 2010 20:58:49 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98KwnJq014244; Fri, 8 Oct 2010 20:58:49 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082058.o98KwnJq014244@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 20:58:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213631 - stable/7/share/man/man4 X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 20:58:49 -0000 Author: yongari Date: Fri Oct 8 20:58:48 2010 New Revision: 213631 URL: http://svn.freebsd.org/changeset/base/213631 Log: MFC r212159,212161: r212159: Document tunable dev.sis.%unit.manual_pad While I'm here Xref vlan(4) as sis(4) supports VLAN oversized frames. r212161: Better wording. Submitted by: jkim Modified: stable/7/share/man/man4/sis.4 Directory Properties: stable/7/share/man/man4/ (props changed) Modified: stable/7/share/man/man4/sis.4 ============================================================================== --- stable/7/share/man/man4/sis.4 Fri Oct 8 20:58:05 2010 (r213630) +++ stable/7/share/man/man4/sis.4 Fri Oct 8 20:58:48 2010 (r213631) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 28, 2006 +.Dd September 2, 2010 .Dt SIS 4 .Os .Sh NAME @@ -145,6 +145,22 @@ SiS 630, 635, and 735 motherboard chipse .It Soekris Engineering net45xx, net48xx, lan1621, and lan1641 .El +.Sh SYSCTL VARIABLES +The following variable is available as both +.Xr sysctl 8 +variable and +.Xr loader 8 +tunable: +.Bl -tag -width indent +.It Va dev.sis.%unit.manual_pad +This variable controls how to pad short frames for DP83815/DP83816 +controllers on the specified device. +DP83815/DP83816 controllers are known to pad 0xFF for short frames +which is violation of RFC 1042. +Set this variable to a non-zero value to let driver manually pad +each short frame with zeros at the cost of extra CPU cycles. +The default value is 0 to let hardware perform automatic padding. +.El .Sh DIAGNOSTICS .Bl -diag .It "sis%d: couldn't map ports/memory" @@ -190,6 +206,7 @@ the card should be configured correctly. .Xr netintro 4 , .Xr ng_ether 4 , .Xr polling 4 , +.Xr vlan 4 , .Xr ifconfig 8 .Rs .%T SiS 900 and SiS 7016 datasheets From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 23:14:21 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC57D106564A; Fri, 8 Oct 2010 23:14:21 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC2238FC0A; Fri, 8 Oct 2010 23:14:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98NELWH017305; Fri, 8 Oct 2010 23:14:21 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98NELFE017303; Fri, 8 Oct 2010 23:14:21 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082314.o98NELFE017303@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 23:14:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213636 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 23:14:21 -0000 Author: yongari Date: Fri Oct 8 23:14:21 2010 New Revision: 213636 URL: http://svn.freebsd.org/changeset/base/213636 Log: MFC r212166: Implement initial device suspend/resume method. Modified: stable/7/sys/dev/sis/if_sis.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 23:11:46 2010 (r213635) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 23:14:21 2010 (r213636) @@ -2388,6 +2388,35 @@ sis_shutdown(device_t dev) SIS_UNLOCK(sc); } +static int +sis_suspend(device_t dev) +{ + struct sis_softc *sc; + + sc = device_get_softc(dev); + SIS_LOCK(sc); + sis_stop(sc); + SIS_UNLOCK(sc); + return (0); +} + +static int +sis_resume(device_t dev) +{ + struct sis_softc *sc; + struct ifnet *ifp; + + sc = device_get_softc(dev); + SIS_LOCK(sc); + ifp = sc->sis_ifp; + if ((ifp->if_flags & IFF_UP) != 0) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + sis_initl(sc); + } + SIS_UNLOCK(sc); + return (0); +} + static void sis_add_sysctls(struct sis_softc *sc) { @@ -2420,6 +2449,8 @@ static device_method_t sis_methods[] = { DEVMETHOD(device_attach, sis_attach), DEVMETHOD(device_detach, sis_detach), DEVMETHOD(device_shutdown, sis_shutdown), + DEVMETHOD(device_suspend, sis_suspend), + DEVMETHOD(device_resume, sis_resume), /* bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 23:29:46 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51012106566B; Fri, 8 Oct 2010 23:29:46 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E311D8FC17; Fri, 8 Oct 2010 23:29:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98NTjVm017723; Fri, 8 Oct 2010 23:29:45 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98NTjTj017719; Fri, 8 Oct 2010 23:29:45 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082329.o98NTjTj017719@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 23:29:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213638 - in stable/7/sys: dev/sis dev/tx pci X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 23:29:46 -0000 Author: yongari Date: Fri Oct 8 23:29:45 2010 New Revision: 213638 URL: http://svn.freebsd.org/changeset/base/213638 Log: MFC r188463: Fix shutdown prototypes. Modified: stable/7/sys/dev/sis/if_sis.c stable/7/sys/dev/tx/if_tx.c stable/7/sys/pci/if_tl.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 23:16:02 2010 (r213637) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 23:29:45 2010 (r213638) @@ -2377,7 +2377,7 @@ sis_stop(struct sis_softc *sc) * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +static int sis_shutdown(device_t dev) { struct sis_softc *sc; @@ -2386,6 +2386,7 @@ sis_shutdown(device_t dev) SIS_LOCK(sc); sis_stop(sc); SIS_UNLOCK(sc); + return (0); } static int Modified: stable/7/sys/dev/tx/if_tx.c ============================================================================== --- stable/7/sys/dev/tx/if_tx.c Fri Oct 8 23:16:02 2010 (r213637) +++ stable/7/sys/dev/tx/if_tx.c Fri Oct 8 23:29:45 2010 (r213638) @@ -120,7 +120,7 @@ static void epic_ifmedia_sts(struct ifne static int epic_probe(device_t); static int epic_attach(device_t); -static void epic_shutdown(device_t); +static int epic_shutdown(device_t); static int epic_detach(device_t); static void epic_release(epic_softc_t *); static struct epic_type *epic_devtype(device_t); @@ -508,7 +508,7 @@ epic_detach(device_t dev) * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +static int epic_shutdown(device_t dev) { epic_softc_t *sc; @@ -516,6 +516,7 @@ epic_shutdown(device_t dev) sc = device_get_softc(dev); epic_stop(sc); + return (0); } /* Modified: stable/7/sys/pci/if_tl.c ============================================================================== --- stable/7/sys/pci/if_tl.c Fri Oct 8 23:16:02 2010 (r213637) +++ stable/7/sys/pci/if_tl.c Fri Oct 8 23:29:45 2010 (r213638) @@ -282,7 +282,7 @@ static void tl_init(void *); static void tl_init_locked(struct tl_softc *); static void tl_stop(struct tl_softc *); static void tl_watchdog(struct ifnet *); -static void tl_shutdown(device_t); +static int tl_shutdown(device_t); static int tl_ifmedia_upd(struct ifnet *); static void tl_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -2347,7 +2347,7 @@ tl_stop(sc) * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +static int tl_shutdown(dev) device_t dev; { @@ -2359,5 +2359,5 @@ tl_shutdown(dev) tl_stop(sc); TL_UNLOCK(sc); - return; + return (0); } From owner-svn-src-stable-7@FreeBSD.ORG Fri Oct 8 23:34:46 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B8F21065673; Fri, 8 Oct 2010 23:34:46 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A8C38FC13; Fri, 8 Oct 2010 23:34:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98NYjN6017874; Fri, 8 Oct 2010 23:34:45 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98NYjcV017871; Fri, 8 Oct 2010 23:34:45 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010082334.o98NYjcV017871@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 8 Oct 2010 23:34:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213639 - stable/7/sys/dev/sis X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 23:34:46 -0000 Author: yongari Date: Fri Oct 8 23:34:45 2010 New Revision: 213639 URL: http://svn.freebsd.org/changeset/base/213639 Log: MFC r212167: Initial WOL support. NS DP8315 was tested but SiS900/SiS7016 was not tested. While I'm here, clean up SIOCSIFCAP handler. Modified: stable/7/sys/dev/sis/if_sis.c stable/7/sys/dev/sis/if_sisreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Fri Oct 8 23:29:45 2010 (r213638) +++ stable/7/sys/dev/sis/if_sis.c Fri Oct 8 23:34:45 2010 (r213639) @@ -147,12 +147,15 @@ static void sis_initl(struct sis_softc * static void sis_intr(void *); static int sis_ioctl(struct ifnet *, u_long, caddr_t); static int sis_newbuf(struct sis_softc *, struct sis_rxdesc *); +static int sis_resume(device_t); static void sis_rxeof(struct sis_softc *); static void sis_start(struct ifnet *); static void sis_startl(struct ifnet *); static void sis_stop(struct sis_softc *); +static int sis_suspend(device_t); static void sis_add_sysctls(struct sis_softc *); static void sis_watchdog(struct sis_softc *); +static void sis_wol(struct sis_softc *); static struct resource_spec sis_res_spec[] = { @@ -935,6 +938,9 @@ sis_reset(struct sis_softc *sc) if (sc->sis_type == SIS_TYPE_83815) { CSR_WRITE_4(sc, NS_CLKRUN, NS_CLKRUN_PMESTS); CSR_WRITE_4(sc, NS_CLKRUN, 0); + } else { + /* Disable WOL functions. */ + CSR_WRITE_4(sc, SIS_PWRMAN_CTL, 0); } } @@ -971,7 +977,7 @@ sis_attach(device_t dev) u_char eaddr[ETHER_ADDR_LEN]; struct sis_softc *sc; struct ifnet *ifp; - int error = 0, waittime = 0; + int error = 0, pmc, waittime = 0; waittime = 0; sc = device_get_softc(dev); @@ -1147,6 +1153,14 @@ sis_attach(device_t dev) ifp->if_snd.ifq_drv_maxlen = SIS_TX_LIST_CNT - 1; IFQ_SET_READY(&ifp->if_snd); + if (pci_find_extcap(sc->sis_dev, PCIY_PMG, &pmc) == 0) { + if (sc->sis_type == SIS_TYPE_83815) + ifp->if_capabilities |= IFCAP_WOL; + else + ifp->if_capabilities |= IFCAP_WOL_MAGIC; + ifp->if_capenable = ifp->if_capabilities; + } + /* * Do MII setup. */ @@ -2223,7 +2237,7 @@ sis_ioctl(struct ifnet *ifp, u_long comm struct sis_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; struct mii_data *mii; - int error = 0; + int error = 0, mask; switch (command) { case SIOCSIFFLAGS: @@ -2260,32 +2274,37 @@ sis_ioctl(struct ifnet *ifp, u_long comm error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); break; case SIOCSIFCAP: - /* ok, disable interrupts */ + SIS_LOCK(sc); + mask = ifr->ifr_reqcap ^ ifp->if_capenable; #ifdef DEVICE_POLLING - if (ifr->ifr_reqcap & IFCAP_POLLING && - !(ifp->if_capenable & IFCAP_POLLING)) { - error = ether_poll_register(sis_poll, ifp); - if (error) - return (error); - SIS_LOCK(sc); - /* Disable interrupts */ - CSR_WRITE_4(sc, SIS_IER, 0); - ifp->if_capenable |= IFCAP_POLLING; - SIS_UNLOCK(sc); - return (error); - - } - if (!(ifr->ifr_reqcap & IFCAP_POLLING) && - ifp->if_capenable & IFCAP_POLLING) { - error = ether_poll_deregister(ifp); - /* Enable interrupts. */ - SIS_LOCK(sc); - CSR_WRITE_4(sc, SIS_IER, 1); - ifp->if_capenable &= ~IFCAP_POLLING; - SIS_UNLOCK(sc); - return (error); + if ((mask & IFCAP_POLLING) != 0 && + (IFCAP_POLLING & ifp->if_capabilities) != 0) { + ifp->if_capenable ^= IFCAP_POLLING; + if ((IFCAP_POLLING & ifp->if_capenable) != 0) { + error = ether_poll_register(sis_poll, ifp); + if (error != 0) { + SIS_UNLOCK(sc); + break; + } + /* Disable interrupts. */ + CSR_WRITE_4(sc, SIS_IER, 0); + } else { + error = ether_poll_deregister(ifp); + /* Enable interrupts. */ + CSR_WRITE_4(sc, SIS_IER, 1); + } } #endif /* DEVICE_POLLING */ + if ((mask & IFCAP_WOL) != 0 && + (ifp->if_capabilities & IFCAP_WOL) != 0) { + if ((mask & IFCAP_WOL_UCAST) != 0) + ifp->if_capenable ^= IFCAP_WOL_UCAST; + if ((mask & IFCAP_WOL_MCAST) != 0) + ifp->if_capenable ^= IFCAP_WOL_MCAST; + if ((mask & IFCAP_WOL_MAGIC) != 0) + ifp->if_capenable ^= IFCAP_WOL_MAGIC; + } + SIS_UNLOCK(sc); break; default: error = ether_ioctl(ifp, command, data); @@ -2380,13 +2399,8 @@ sis_stop(struct sis_softc *sc) static int sis_shutdown(device_t dev) { - struct sis_softc *sc; - sc = device_get_softc(dev); - SIS_LOCK(sc); - sis_stop(sc); - SIS_UNLOCK(sc); - return (0); + return (sis_suspend(dev)); } static int @@ -2397,6 +2411,7 @@ sis_suspend(device_t dev) sc = device_get_softc(dev); SIS_LOCK(sc); sis_stop(sc); + sis_wol(sc); SIS_UNLOCK(sc); return (0); } @@ -2419,6 +2434,56 @@ sis_resume(device_t dev) } static void +sis_wol(struct sis_softc *sc) +{ + struct ifnet *ifp; + uint32_t val; + uint16_t pmstat; + int pmc; + + ifp = sc->sis_ifp; + if ((ifp->if_capenable & IFCAP_WOL) == 0) + return; + + if (sc->sis_type == SIS_TYPE_83815) { + /* Reset RXDP. */ + CSR_WRITE_4(sc, SIS_RX_LISTPTR, 0); + + /* Configure WOL events. */ + CSR_READ_4(sc, NS_WCSR); + val = 0; + if ((ifp->if_capenable & IFCAP_WOL_UCAST) != 0) + val |= NS_WCSR_WAKE_UCAST; + if ((ifp->if_capenable & IFCAP_WOL_MCAST) != 0) + val |= NS_WCSR_WAKE_MCAST; + if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0) + val |= NS_WCSR_WAKE_MAGIC; + CSR_WRITE_4(sc, NS_WCSR, val); + /* Enable PME and clear PMESTS. */ + val = CSR_READ_4(sc, NS_CLKRUN); + val |= NS_CLKRUN_PMEENB | NS_CLKRUN_PMESTS; + CSR_WRITE_4(sc, NS_CLKRUN, val); + /* Enable silent RX mode. */ + SIS_SETBIT(sc, SIS_CSR, SIS_CSR_RX_ENABLE); + } else { + if (pci_find_extcap(sc->sis_dev, PCIY_PMG, &pmc) != 0) + return; + val = 0; + if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0) + val |= SIS_PWRMAN_WOL_MAGIC; + CSR_WRITE_4(sc, SIS_PWRMAN_CTL, val); + /* Request PME. */ + pmstat = pci_read_config(sc->sis_dev, + pmc + PCIR_POWER_STATUS, 2); + pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); + if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0) + pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; + pci_write_config(sc->sis_dev, + pmc + PCIR_POWER_STATUS, pmstat, 2); + } +} + +static void sis_add_sysctls(struct sis_softc *sc) { struct sysctl_ctx_list *ctx; Modified: stable/7/sys/dev/sis/if_sisreg.h ============================================================================== --- stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 23:29:45 2010 (r213638) +++ stable/7/sys/dev/sis/if_sisreg.h Fri Oct 8 23:34:45 2010 (r213639) @@ -77,6 +77,7 @@ /* NS DP83815/6 registers */ #define NS_IHR 0x1C #define NS_CLKRUN 0x3C +#define NS_WCSR 0x40 #define NS_SRR 0x58 #define NS_BMCR 0x80 #define NS_BMSR 0x84 @@ -99,6 +100,29 @@ #define NS_CLKRUN_PMEENB 0x00000100 #define NS_CLNRUN_CLKRUN_ENB 0x00000001 +#define NS_WCSR_WAKE_PHYINTR 0x00000001 +#define NS_WCSR_WAKE_UCAST 0x00000002 +#define NS_WCSR_WAKE_MCAST 0x00000004 +#define NS_WCSR_WAKE_BCAST 0x00000008 +#define NS_WCSR_WAKE_ARP 0x00000010 +#define NS_WCSR_WAKE_PATTERN0 0x00000020 +#define NS_WCSR_WAKE_PATTERN1 0x00000040 +#define NS_WCSR_WAKE_PATTERN2 0x00000080 +#define NS_WCSR_WAKE_PATTERN3 0x00000100 +#define NS_WCSR_WAKE_MAGIC 0x00000200 +#define NS_WCSR_WAKE_MAGIC_SEC 0x00000400 +#define NS_WCSR_DET_MAGIC_SECH 0x00100000 +#define NS_WCSR_DET_PHYINTR 0x00400000 +#define NS_WCSR_DET_UCAST 0x00800000 +#define NS_WCSR_DET_MCAST 0x01000000 +#define NS_WCSR_DET_BCAST 0x02000000 +#define NS_WCSR_DET_ARP 0x04000000 +#define NS_WCSR_DET_PATTERN0 0x08000000 +#define NS_WCSR_DET_PATTERN1 0x10000000 +#define NS_WCSR_DET_PATTERN2 0x20000000 +#define NS_WCSR_DET_PATTERN3 0x40000000 +#define NS_WCSR_DET_MAGIC 0x80000000 + /* NS silicon revisions */ #define NS_SRR_15C 0x302 #define NS_SRR_15D 0x403 @@ -303,6 +327,10 @@ #define NS_FILTADDR_FMEM_LO 0x00000200 #define NS_FILTADDR_FMEM_HI 0x000003FE +#define SIS_PWRMAN_WOL_LINK_OFF 0x00000001 +#define SIS_PWRMAN_WOL_LINK_ON 0x00000002 +#define SIS_PWRMAN_WOL_MAGIC 0x00000400 + /* * TX/RX DMA descriptor structures. */ From owner-svn-src-stable-7@FreeBSD.ORG Sat Oct 9 00:34:59 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 671A11065670; Sat, 9 Oct 2010 00:34:59 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5620B8FC17; Sat, 9 Oct 2010 00:34:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o990YxHp019159; Sat, 9 Oct 2010 00:34:59 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o990Yxn2019157; Sat, 9 Oct 2010 00:34:59 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201010090034.o990Yxn2019157@svn.freebsd.org> From: Xin LI Date: Sat, 9 Oct 2010 00:34:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213640 - in stable: 7/gnu/usr.bin/groff/tmac 8/gnu/usr.bin/groff/tmac X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Oct 2010 00:34:59 -0000 Author: delphij Date: Sat Oct 9 00:34:58 2010 New Revision: 213640 URL: http://svn.freebsd.org/changeset/base/213640 Log: MFC r213487: Add definition for FreeBSD 7.4, which will be used in a manual page change. Modified: stable/7/gnu/usr.bin/groff/tmac/mdoc.local (contents, props changed) Directory Properties: stable/7/gnu/usr.bin/groff/ (props changed) Changes in other areas also in this revision: Modified: stable/8/gnu/usr.bin/groff/tmac/mdoc.local Directory Properties: stable/8/gnu/usr.bin/groff/ (props changed) Modified: stable/7/gnu/usr.bin/groff/tmac/mdoc.local ============================================================================== --- stable/7/gnu/usr.bin/groff/tmac/mdoc.local Fri Oct 8 23:34:45 2010 (r213639) +++ stable/7/gnu/usr.bin/groff/tmac/mdoc.local Sat Oct 9 00:34:58 2010 (r213640) @@ -72,6 +72,7 @@ .ds doc-operating-system-FreeBSD-7.1 7.1 .ds doc-operating-system-FreeBSD-7.2 7.2 .ds doc-operating-system-FreeBSD-7.3 7.3 +.ds doc-operating-system-FreeBSD-7.4 7.4 .ds doc-operating-system-FreeBSD-8.0 8.0 .ds doc-operating-system-FreeBSD-8.1 8.1 .ds doc-operating-system-FreeBSD-9.0 9.0 From owner-svn-src-stable-7@FreeBSD.ORG Sat Oct 9 00:36:32 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 819161065670; Sat, 9 Oct 2010 00:36:32 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6F74B8FC18; Sat, 9 Oct 2010 00:36:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o990aWlf019257; Sat, 9 Oct 2010 00:36:32 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o990aWTT019255; Sat, 9 Oct 2010 00:36:32 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201010090036.o990aWTT019255@svn.freebsd.org> From: Xin LI Date: Sat, 9 Oct 2010 00:36:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213641 - in stable: 7/libexec/tftpd 8/libexec/tftpd X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Oct 2010 00:36:32 -0000 Author: delphij Date: Sat Oct 9 00:36:32 2010 New Revision: 213641 URL: http://svn.freebsd.org/changeset/base/213641 Log: MFC r213488: Use a defined FreeBSD version. Modified: stable/7/libexec/tftpd/tftpd.8 Directory Properties: stable/7/libexec/tftpd/ (props changed) Changes in other areas also in this revision: Modified: stable/8/libexec/tftpd/tftpd.8 Directory Properties: stable/8/libexec/tftpd/ (props changed) Modified: stable/7/libexec/tftpd/tftpd.8 ============================================================================== --- stable/7/libexec/tftpd/tftpd.8 Sat Oct 9 00:34:58 2010 (r213640) +++ stable/7/libexec/tftpd/tftpd.8 Sat Oct 9 00:36:32 2010 (r213641) @@ -245,14 +245,14 @@ and the and .Fl W options were introduced in -.Fx 7 . +.Fx 7.4 . .Pp Support for Timeout Interval and Transfer Size Options (RFC2349) was introduced in .Fx 5.0 , support for the TFTP Blocksize Option (RFC2348) and the blksize2 option was introduced in -.Fx 7 . +.Fx 7.4 . .Sh BUGS Files larger than 33488896 octets (65535 blocks) cannot be transferred without client and server supporting blocksize negotiation (RFC2348). From owner-svn-src-stable-7@FreeBSD.ORG Sat Oct 9 09:24:16 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C1D701065670; Sat, 9 Oct 2010 09:24:16 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 96AAD8FC0C; Sat, 9 Oct 2010 09:24:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o999OGn1033084; Sat, 9 Oct 2010 09:24:16 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o999OGYj033082; Sat, 9 Oct 2010 09:24:16 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201010090924.o999OGYj033082@svn.freebsd.org> From: Andriy Gapon Date: Sat, 9 Oct 2010 09:24:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213652 - stable/7/sys/kern X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Oct 2010 09:24:17 -0000 Author: avg Date: Sat Oct 9 09:24:16 2010 New Revision: 213652 URL: http://svn.freebsd.org/changeset/base/213652 Log: MFC r210782,210837: Update the "desiredvnodes" calculation. On behalf of: alc Modified: stable/7/sys/kern/vfs_subr.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Sat Oct 9 09:03:17 2010 (r213651) +++ stable/7/sys/kern/vfs_subr.c Sat Oct 9 09:24:16 2010 (r213652) @@ -281,23 +281,34 @@ SYSCTL_INT(_debug, OID_AUTO, vnlru_nowhe /* * Initialize the vnode management data structures. + * + * Reevaluate the following cap on the number of vnodes after the physical + * memory size exceeds 512GB. In the limit, as the physical memory size + * grows, the ratio of physical pages to vnodes approaches sixteen to one. */ #ifndef MAXVNODES_MAX -#define MAXVNODES_MAX 100000 +#define MAXVNODES_MAX (512 * (1024 * 1024 * 1024 / (int)PAGE_SIZE / 16)) #endif static void vntblinit(void *dummy __unused) { + int physvnodes, virtvnodes; /* - * Desiredvnodes is a function of the physical memory size and - * the kernel's heap size. Specifically, desiredvnodes scales - * in proportion to the physical memory size until two fifths - * of the kernel's heap size is consumed by vnodes and vm - * objects. - */ - desiredvnodes = min(maxproc + cnt.v_page_count / 4, 2 * vm_kmem_size / - (5 * (sizeof(struct vm_object) + sizeof(struct vnode)))); + * Desiredvnodes is a function of the physical memory size and the + * kernel's heap size. Generally speaking, it scales with the + * physical memory size. The ratio of desiredvnodes to physical pages + * is one to four until desiredvnodes exceeds 98,304. Thereafter, the + * marginal ratio of desiredvnodes to physical pages is one to + * sixteen. However, desiredvnodes is limited by the kernel's heap + * size. The memory required by desiredvnodes vnodes and vm objects + * may not exceed one seventh of the kernel's heap size. + */ + physvnodes = maxproc + cnt.v_page_count / 16 + 3 * min(98304 * 4, + cnt.v_page_count) / 16; + virtvnodes = vm_kmem_size / (7 * (sizeof(struct vm_object) + + sizeof(struct vnode))); + desiredvnodes = min(physvnodes, virtvnodes); if (desiredvnodes > MAXVNODES_MAX) { if (bootverbose) printf("Reducing kern.maxvnodes %d -> %d\n", From owner-svn-src-stable-7@FreeBSD.ORG Sat Oct 9 13:07:22 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24EBF106566C; Sat, 9 Oct 2010 13:07:22 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 13DF68FC13; Sat, 9 Oct 2010 13:07:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o99D7Lu0040626; Sat, 9 Oct 2010 13:07:21 GMT (envelope-from gavin@svn.freebsd.org) Received: (from gavin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o99D7L3g040624; Sat, 9 Oct 2010 13:07:21 GMT (envelope-from gavin@svn.freebsd.org) Message-Id: <201010091307.o99D7L3g040624@svn.freebsd.org> From: Gavin Atkinson Date: Sat, 9 Oct 2010 13:07:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213657 - stable/7/share/dict X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Oct 2010 13:07:22 -0000 Author: gavin Date: Sat Oct 9 13:07:21 2010 New Revision: 213657 URL: http://svn.freebsd.org/changeset/base/213657 Log: Merge r213061 from head: Various changes from various sources: - Add "children" [1] - Add "acknowledgement", "acknowledgment", "Austria" and "haunted" [2] - Add "near", "antidisestablishmentarianism" and "Persephone" [2] - "Transvaal" should be capitalized [2] - Correct spelling of "structurelessness" and "Athena" [2] - Add missing atomic elements [3] - Add various words from "word of the day" lists [3] Also, set fbsd:nokeywords on web2, to allow checkin. PR: conf/149756 [1] Submitted by: Nick Johnson [1] Obtained from: NetBSD [2], OpenBSD [3] Modified: stable/7/share/dict/web2 (contents, props changed) Directory Properties: stable/7/share/dict/ (props changed) Modified: stable/7/share/dict/web2 ============================================================================== --- stable/7/share/dict/web2 Sat Oct 9 13:03:32 2010 (r213656) +++ stable/7/share/dict/web2 Sat Oct 9 13:07:21 2010 (r213657) @@ -1545,9 +1545,11 @@ ackman acknow acknowledge acknowledgeable +acknowledgement acknowledged acknowledgedly acknowledger +acknowledgment aclastic acle acleidian @@ -3875,6 +3877,7 @@ agee Agelacrinites Agelacrinitidae Agelaius +agelast Agelaus ageless agelessness @@ -3995,6 +3998,7 @@ agist agistator agistment agistor +agita agitable agitant agitate @@ -4298,7 +4302,6 @@ Ahriman Ahrimanian ahsan Aht -Ahtena ahu ahuatle ahuehuete @@ -10059,6 +10062,7 @@ antidiphtheric antidiphtherin antidiphtheritic antidisciplinarian +antidisestablishmentarianism antidivine antidivorce antidogmatic @@ -15091,6 +15095,7 @@ atheizer athelia atheling athematic +Athena Athenaea athenaeum athenee @@ -15891,6 +15896,7 @@ australopithecine Australopithecus Australorp Austrasian +Austria Austrian Austrianize Austric @@ -21543,6 +21549,7 @@ betinge betipple betire betis +betise betitle betocsin betoil @@ -21833,6 +21840,7 @@ bibble bibbler bibbons bibcock +bibelot bibenzyl bibi Bibio @@ -24298,6 +24306,7 @@ bohereen bohireen boho bohor +bohrium bohunk boid Boidae @@ -24606,6 +24615,7 @@ boo boob boobery boobily +booboisie boobook booby boobyalla @@ -25158,6 +25168,7 @@ bouldery boule boulevard boulevardize +bouleversement boultel boulter boulterer @@ -28540,6 +28551,7 @@ caesaropopism Caesarotomy Caesarship caesious +caesium caesura caesural caesuric @@ -34554,6 +34566,7 @@ childlike childlikeness childly childness +children childrenite childridden childship @@ -41256,6 +41269,7 @@ congenitally congenitalness conger congeree +congeries congest congested congestible @@ -57000,6 +57014,7 @@ dopebook doper dopester dopey +doppelganger doppelkummel Dopper dopper @@ -58202,6 +58217,7 @@ dubitatingly dubitation dubitative dubitatively +dubnium Duboisia duboisin duboisine @@ -58916,6 +58932,7 @@ dysphagic dysphasia dysphasic dysphemia +dysphemism dysphonia dysphonic dysphoria @@ -60001,6 +60018,7 @@ eimer Eimeria einkorn Einsteinian +einsteinium Eireannach Eirene eiresione @@ -65389,6 +65407,7 @@ eudaimonia eudaimonism eudaimonist Eudemian +eudemonia Eudendrium Eudeve eudiagnostic @@ -69151,6 +69170,7 @@ fermentum fermerer fermery fermila +fermium fermorite fern fernandinite @@ -81692,6 +81712,7 @@ hagworm hah Hahnemannian Hahnemannism +hahnium Haiathalah Haida Haidan @@ -82659,6 +82680,7 @@ Hasmonaean hasp hassar hassel +hassium hassle hassock hassocky @@ -82789,6 +82811,7 @@ haunching haunchless haunchy haunt +haunted haunter hauntingly haunty @@ -87139,6 +87162,7 @@ homuncular homunculus homy Hon +honcho honda hondo Honduran @@ -100289,6 +100313,7 @@ jokish jokist jokul joky +joliotium joll jolleyman jollier @@ -101349,6 +101374,7 @@ katun katurai Katy katydid +katzenjammer Kauravas kauri kava @@ -103074,6 +103100,7 @@ kuphar kupper Kuranko kurbash +kurchatovium kurchicine kurchine Kurd @@ -104905,6 +104932,7 @@ lawny lawproof Lawrence lawrencite +lawrencium Lawrie lawrightman Lawson @@ -106402,6 +106430,7 @@ Lide lidflower lidgate lidless +lido lie liebenerite Liebfraumilch @@ -113271,6 +113300,7 @@ Meissa Meistersinger meith Meithei +meitnerium meizoseismal meizoseismic mejorana @@ -113726,6 +113756,7 @@ mendacity Mendaite Mende mendee +mendelevium Mendelian Mendelianism Mendelianist @@ -114040,6 +114071,7 @@ Mercurochrome mercurophen mercurous Mercury +mercury mercy mercyproof merdivorous @@ -122874,6 +122906,7 @@ neanthropic neap neaped Neapolitan +near nearable nearabout nearabouts @@ -124384,6 +124417,7 @@ nielled niellist niello Niels +nielsbohrium niepa Nierembergia Niersteiner @@ -124791,6 +124825,7 @@ nobble nobbler nobbut nobby +nobelium nobiliary nobilify nobilitate @@ -143300,6 +143335,7 @@ perseitol perseity persentiscency Persephassa +Persephone Persepolitan perseverance perseverant @@ -159782,6 +159818,7 @@ pukeweed Pukhtun pukish pukishness +pukka pukras puku puky @@ -171927,6 +171964,7 @@ ruther rutherford rutherfordine rutherfordite +rutherfordium ruthful ruthfully ruthfulness @@ -176364,6 +176402,7 @@ Seabee seaberry seaboard seaborderer +seaborgium seabound seacannie seacatch @@ -176891,6 +176930,7 @@ segregational segregationist segregative segregator +segue Sehyo seiche Seid @@ -182225,6 +182265,7 @@ situational situla situlae situs +sitzmark Sium Siusi Siuslaw @@ -191094,6 +191135,7 @@ structuration structure structured structureless +structurelessness structurely structurist strudel @@ -191192,7 +191234,6 @@ stuccoworker stuccoyer stuck stuckling -stucturelessness stud studbook studder @@ -206199,7 +206240,7 @@ transuranian transuranic transuranium transuterine -transvaal +Transvaal Transvaaler Transvaalian transvaluate From owner-svn-src-stable-7@FreeBSD.ORG Sat Oct 9 20:52:37 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13F741065670; Sat, 9 Oct 2010 20:52:37 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 02D808FC13; Sat, 9 Oct 2010 20:52:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o99KqaWO052273; Sat, 9 Oct 2010 20:52:36 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o99Kqalq052271; Sat, 9 Oct 2010 20:52:36 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201010092052.o99Kqalq052271@svn.freebsd.org> From: Pyun YongHyeon Date: Sat, 9 Oct 2010 20:52:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213663 - stable/7/sys/dev/sf X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Oct 2010 20:52:37 -0000 Author: yongari Date: Sat Oct 9 20:52:36 2010 New Revision: 213663 URL: http://svn.freebsd.org/changeset/base/213663 Log: Fix build breakage introducted in r213604. Modified: stable/7/sys/dev/sf/if_sf.c Modified: stable/7/sys/dev/sf/if_sf.c ============================================================================== --- stable/7/sys/dev/sf/if_sf.c Sat Oct 9 20:20:27 2010 (r213662) +++ stable/7/sys/dev/sf/if_sf.c Sat Oct 9 20:52:36 2010 (r213663) @@ -1824,7 +1824,7 @@ sf_poll(struct ifnet *ifp, enum poll_cmd ifp->if_drv_flags &= ~IFF_DRV_RUNNING; sf_init_locked(sc); SF_UNLOCK(sc); - return (rx_npkts); + return; } else if ((status & SF_ISR_NO_TX_CSUM) != 0) { sc->sf_statistics.sf_tx_gfp_stall++; #ifdef SF_GFP_DEBUG