Re: svn commit: r192595 - in head: crypto/openssh crypto/openssh/openbsd-compat secure/lib/libssh secure/usr.sbin/sshd

2009-05-24 Thread Brian Somers
On Fri, 22 May 2009 18:46:28 + (UTC) Dag-Erling Smorgrav  
wrote:
> Author: des
> Date: Fri May 22 18:46:28 2009
> New Revision: 192595
> URL: http://svn.freebsd.org/changeset/base/192595
> 
> Log:
>   Upgrade to OpenSSH 5.2p1.
>   
>   MFC after:  3 months
[.]

Should this be MFCd a little sooner?

http://news.zdnet.com/2100-9595_22-303182.html

-- 
Brian Somers  
Don't _EVER_ lose your sense of humour !   
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192677 - head/share/man/man9

2009-05-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun May 24 09:42:53 2009
New Revision: 192677
URL: http://svn.freebsd.org/changeset/base/192677

Log:
  Add new constants to the acl(9) manual page.

Modified:
  head/share/man/man9/acl.9

Modified: head/share/man/man9/acl.9
==
--- head/share/man/man9/acl.9   Sun May 24 03:49:07 2009(r192676)
+++ head/share/man/man9/acl.9   Sun May 24 09:42:53 2009(r192677)
@@ -59,7 +59,9 @@ Currently, each ACL is represented in-ke
 structure, defined as follows:
 .Bd -literal -offset indent
 struct acl {
-int acl_cnt;
+unsigned intacl_maxcnt;
+unsigned intacl_cnt;
+int acl_spare[4];
 struct acl_entryacl_entry[ACL_MAX_ENTRIES];
 };
 .Ed
@@ -67,6 +69,10 @@ struct acl {
 An ACL is constructed from a fixed size array of ACL entries,
 each of which consists of a set of permissions, principal namespace,
 and principal identifier.
+In this implementation, the
+.Vt acl_maxcnt
+field is always set to
+.Dv ACL_MAX_ENTRIES .
 .Pp
 Each individual ACL entry is of the type
 .Vt acl_entry_t ,
@@ -97,13 +103,20 @@ match the ACL entry qualifier.
 .It Dv ACL_MASK
 The maximum discretionary access rights that can be granted
 to a process in the file group class.
+This is only valid for POSIX.1e ACLs.
 .It Dv ACL_OTHER
 Discretionary access rights for processes not covered by any other ACL
 entry.
+This is only valid for POSIX.1e ACLs.
 .It Dv ACL_OTHER_OBJ
 Same as
 .Dv ACL_OTHER .
-Each ACL entry must contain exactly one
+.It Dv ACL_EVERYONE
+Discretionary access rights for all users.
+This is only valid for NFSv4 ACLs.
+.El
+.Pp
+Each POSIX.1e ACL must contain exactly one
 .Dv ACL_USER_OBJ ,
 one
 .Dv ACL_GROUP_OBJ ,
@@ -117,13 +130,19 @@ or
 are present, then exactly one
 .Dv ACL_MASK
 entry should be present.
-.El
 .It Vt uid_t Va ae_id
 The ID of user for whom this ACL describes access permissions.
+For entries other than
+.Dv ACL_USER
+and
+.Dv ACL_GROUP ,
+this field should be set to
+.Dv ACL_UNDEFINED_ID .
 .It Vt acl_perm_t Va ae_perm
 This field defines what kind of access the process matching this ACL has
 for accessing the associated file.
-.Bl -tag -width ".Dv ACL_POSIX1E_BITS"
+For POSIX.1e ACLs, the following are valid:
+.Bl -tag -width ".Dv ACL_WRITE_NAMED_ATTRS"
 .It Dv ACL_EXECUTE
 The process may execute the associated file.
 .It Dv ACL_WRITE
@@ -134,6 +153,57 @@ The process may read from the associated
 The process has no read, write or execute permissions
 to the associated file.
 .El
+.Pp
+For NFSv4 ACLs, the following are valid:
+.Bl -tag -width ".Dv ACL_WRITE_NAMED_ATTRS"
+.It Dv ACL_READ_DATA
+The process may read from the associated file.
+.It Dv ACL_LIST_DIRECTORY
+Same as
+.Dv ACL_READ_DATA .
+.It Dv ACL_WRITE_DATA
+The process may write to the associated file.
+.It Dv ACL_ADD_FILE
+Same as
+.Dv ACL_ACL_WRITE_DATA .
+.It Dv ACL_APPEND_DATA
+.It Dv ACL_ADD_SUBDIRECTORY
+Same as
+.Dv ACL_APPEND_DATA .
+.It Dv ACL_READ_NAMED_ATTRS
+Ignored.
+.It Dv ACL_WRITE_NAMED_ATTRS
+Ignored.
+.It Dv ACL_EXECUTE
+The process may execute the associated file.
+.It Dv ACL_DELETE_CHILD
+.It Dv ACL_READ_ATTRIBUTES
+.It Dv ACL_WRITE_ATTRIBUTES
+.It Dv ACL_DELETE
+.It Dv ACL_READ_ACL
+.It Dv ACL_WRITE_ACL
+.It Dv ACL_WRITE_OWNER
+.It Dv ACL_SYNCHRONIZE
+Ignored.
+.El
+.It Vt acl_entry_type_t Va ae_entry_type
+This field defines the type of NFSv4 ACL entry.
+It is not used with POSIX.1e ACLs.
+The following values are valid:
+.Bl -tag -width ".Dv ACL_WRITE_NAMED_ATTRS"
+.It Dv ACL_ENTRY_TYPE_ALLOW
+.It Dv ACL_ENTRY_TYPE_DENY
+.El
+.It Vt acl_flag_t Va ae_flags
+This field defines the inheritance flags of NFSv4 ACL entry.
+It is not used with POSIX.1e ACLs.
+The following values are valid:
+.Bl -tag -width ".Dv ACL_ENTRY_DIRECTORY_INHERIT"
+.It Dv ACL_ENTRY_FILE_INHERIT
+.It Dv ACL_ENTRY_DIRECTORY_INHERIT
+.It Dv ACL_ENRY_NO_PROPAGATE_INHERIT
+.It Dv ACL_ENTRY_INHERIT_ONLY
+.El
 .El
 .Sh SEE ALSO
 .Xr acl 3 ,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r192595 - in head: crypto/openssh crypto/openssh/openbsd-compat secure/lib/libssh secure/usr.sbin/sshd

2009-05-24 Thread Dag-Erling Smørgrav
Brian Somers  writes:
> Should this be MFCd a little sooner?
>
> http://news.zdnet.com/2100-9595_22-303182.html

Where to begin...

1) ZDNet is about six months behind - this was discovered in November of
   last year.

2) They also got the numbers wrong; it's 14 bits at 2^-14 chance of
   success.

4) They got a lot of other details wrong, including the claim that this
   is a "design flaw in OpenSSH".  It's a design flaw in the SSH
   protocol, and should affect any SSH implementation that uses CBC.

3) It is completely impractical, because every failed attempt kills the
   connection, and it takes several thousand attempts to recover
   anything at all.  In the "how worried should I be" department, it's
   about neck and neck with MD5 collisions.

4) If it *does* worry you, adding the following line at the bottom of
   /etc/ssh_config and /etc/sshd_config will take care of it:

Ciphers aes128-ctr,aes256-ctr,arcfour256,arcfour,aes128-cbc,aes256-cbc

   On systems where you don't have root access, you can add it to the
   "Host *" section in your ~/.ssh/config:

Host *
  Ciphers aes128-ctr,aes256-ctr,arcfour256,arcfour,aes128-cbc,aes256-cbc

   Your SSH client / server will then use CBC only if there is no other
   alternative.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192678 - in head/sys: kgssapi nfsserver

2009-05-24 Thread Doug Rabson
Author: dfr
Date: Sun May 24 11:10:27 2009
New Revision: 192678
URL: http://svn.freebsd.org/changeset/base/192678

Log:
  Fix build of KGSSAPI bits post-vimage.

Modified:
  head/sys/kgssapi/gsstest.c
  head/sys/nfsserver/nfs_srvkrpc.c

Modified: head/sys/kgssapi/gsstest.c
==
--- head/sys/kgssapi/gsstest.c  Sun May 24 09:42:53 2009(r192677)
+++ head/sys/kgssapi/gsstest.c  Sun May 24 11:10:27 2009(r192678)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -227,7 +228,7 @@ gsstest_1(void)
 
{
static char sbuf[512];
-   snprintf(sbuf, sizeof(sbuf), "n...@%s", hostname);
+   snprintf(sbuf, sizeof(sbuf), "n...@%s", V_hostname);
name_desc.value = sbuf;
}
 
@@ -430,7 +431,7 @@ gsstest_2(int step, const gss_buffer_t i
case 1:
if (server_context == GSS_C_NO_CONTEXT) {
static char sbuf[512];
-   snprintf(sbuf, sizeof(sbuf), "n...@%s", hostname);
+   snprintf(sbuf, sizeof(sbuf), "n...@%s", V_hostname);
name_desc.value = sbuf;
name_desc.length = strlen((const char *)
name_desc.value);
@@ -811,7 +812,7 @@ gsstest_3(void)
return(1);
}
 
-   snprintf(service, sizeof(service), "h...@%s", hostname);
+   snprintf(service, sizeof(service), "h...@%s", V_hostname);
 
auth = rpc_gss_seccreate(client, curthread->td_ucred,
service, "kerberosv5", rpc_gss_svc_privacy,
@@ -881,7 +882,7 @@ gsstest_4(void)
const char **mechs;
static rpc_gss_callback_t cb;
 
-   snprintf(principal, sizeof(principal), "h...@%s", hostname);
+   snprintf(principal, sizeof(principal), "h...@%s", V_hostname);
 
mechs = rpc_gss_get_mechanisms();
while (*mechs) {

Modified: head/sys/nfsserver/nfs_srvkrpc.c
==
--- head/sys/nfsserver/nfs_srvkrpc.cSun May 24 09:42:53 2009
(r192677)
+++ head/sys/nfsserver/nfs_srvkrpc.cSun May 24 11:10:27 2009
(r192678)
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -488,7 +489,7 @@ nfssvc_nfsd(struct thread *td, struct nf
if (error)
return (error);
} else {
-   snprintf(principal, sizeof(principal), "n...@%s", hostname);
+   snprintf(principal, sizeof(principal), "n...@%s", V_hostname);
}
 #endif
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192679 - head/lib/libstand

2009-05-24 Thread Doug Rabson
Author: dfr
Date: Sun May 24 11:37:10 2009
New Revision: 192679
URL: http://svn.freebsd.org/changeset/base/192679

Log:
  Increase the number of available file descriptors to 64. This fixes the
  reported zfsboot problems for systems where more than seven drives are part
  of ZFS pools.

Modified:
  head/lib/libstand/stand.h

Modified: head/lib/libstand/stand.h
==
--- head/lib/libstand/stand.h   Sun May 24 11:10:27 2009(r192678)
+++ head/lib/libstand/stand.h   Sun May 24 11:37:10 2009(r192679)
@@ -167,7 +167,7 @@ struct open_file {
 #define SOPEN_RASIZE   512
 };
 
-#defineSOPEN_MAX   8
+#defineSOPEN_MAX   64
 extern struct open_file files[];
 
 /* f_flags values */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r192194 - in head/sys: boot/i386/zfsboot boot/zfs cddl/boot/zfs

2009-05-24 Thread Doug Rabson


On 23 May 2009, at 00:27, Xin LI wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi, Doug,

Doug Rabson wrote:

Author: dfr
Date: Sat May 16 10:48:20 2009
New Revision: 192194
URL: http://svn.freebsd.org/changeset/base/192194

Log:
 Add support for booting from raidz1 and raidz2 pools.

Modified:
 head/sys/boot/i386/zfsboot/zfsboot.c
 head/sys/boot/zfs/zfsimpl.c
 head/sys/cddl/boot/zfs/README
 head/sys/cddl/boot/zfs/zfsimpl.h
 head/sys/cddl/boot/zfs/zfssubr.c


I think this commit has broken booting from mirrored zpool when raidz2
pool is exist.  In my setup it was 4 disks:


This should be fixed in r192679.

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


svn commit: r192681 - head/sys/kern

2009-05-24 Thread Konstantin Belousov
Author: kib
Date: Sun May 24 12:28:38 2009
New Revision: 192681
URL: http://svn.freebsd.org/changeset/base/192681

Log:
  Replace the while statement with the if for clarity. The loop body
  cannot be executed more then once.
  
  Reviewed by:  dfr
  Tested by:pho
  MFC after:1 month

Modified:
  head/sys/kern/kern_lockf.c

Modified: head/sys/kern/kern_lockf.c
==
--- head/sys/kern/kern_lockf.c  Sun May 24 11:52:08 2009(r192680)
+++ head/sys/kern/kern_lockf.c  Sun May 24 12:28:38 2009(r192681)
@@ -1361,7 +1361,7 @@ lf_setlock(struct lockf *state, struct l
/*
 * Scan lock list for this file looking for locks that would block us.
 */
-   while (lf_getblock(state, lock)) {
+   if (lf_getblock(state, lock)) {
/*
 * Free the structure and return if nonblocking.
 */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192682 - head/sys/kern

2009-05-24 Thread Ed Schouten
Author: ed
Date: Sun May 24 12:32:03 2009
New Revision: 192682
URL: http://svn.freebsd.org/changeset/base/192682

Log:
  Block when initially opening a TTY multiple times.
  
  In the original MPSAFE TTY code, I changed the behaviour by returning
  EBUSY. I thought this made more sense, because it's basically a race to
  see who gets the TTY first.
  
  It turns out this is not a good change, because it also causes EBUSY to
  be returned when another process is closing the TTY. This can happen
  during startup, when /etc/rc (or one of its children) is still busy
  draining its data and /sbin/init is attempting to open the TTY to spawn
  a getty.
  
  Reported by:  bz
  Tested by:bz

Modified:
  head/sys/kern/tty.c

Modified: head/sys/kern/tty.c
==
--- head/sys/kern/tty.c Sun May 24 12:28:38 2009(r192681)
+++ head/sys/kern/tty.c Sun May 24 12:32:03 2009(r192682)
@@ -206,6 +206,7 @@ ttydev_leave(struct tty *tp)
ttydevsw_close(tp);
 
tp->t_flags &= ~TF_OPENCLOSE;
+   cv_broadcast(&tp->t_dcdwait);
tty_rel_free(tp);
 }
 
@@ -231,13 +232,17 @@ ttydev_open(struct cdev *dev, int oflags
tty_unlock(tp);
return (ENXIO);
}
+
/*
-* Prevent the TTY from being opened when being torn down or
-* built up by unrelated processes.
+* Block when other processes are currently opening or closing
+* the TTY.
 */
-   if (tp->t_flags & TF_OPENCLOSE) {
-   tty_unlock(tp);
-   return (EBUSY);
+   while (tp->t_flags & TF_OPENCLOSE) {
+   error = tty_wait(tp, &tp->t_dcdwait);
+   if (error != 0) {
+   tty_unlock(tp);
+   return (error);
+   }
}
tp->t_flags |= TF_OPENCLOSE;
 
@@ -299,6 +304,7 @@ ttydev_open(struct cdev *dev, int oflags
tp->t_flags |= TF_OPENED_IN;
 
 done:  tp->t_flags &= ~TF_OPENCLOSE;
+   cv_broadcast(&tp->t_dcdwait);
ttydev_leave(tp);
 
return (error);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192683 - head/sys/kern

2009-05-24 Thread Konstantin Belousov
Author: kib
Date: Sun May 24 12:33:16 2009
New Revision: 192683
URL: http://svn.freebsd.org/changeset/base/192683

Log:
  In lf_advlockasync(), recheck for doomed vnode after the state->ls_lock
  is acquired. In the lf_purgelocks(), assert that vnode is doomed and set
  *statep to NULL before clearing ls_pending list. Otherwise, we allow for
  the thread executing lf_advlockasync() to put new pending entry after
  state->ls_lock is dropped in lf_purgelocks().
  
  Reviewed by:  dfr
  Tested by:pho
  MFC after:1 month

Modified:
  head/sys/kern/kern_lockf.c

Modified: head/sys/kern/kern_lockf.c
==
--- head/sys/kern/kern_lockf.c  Sun May 24 12:32:03 2009(r192682)
+++ head/sys/kern/kern_lockf.c  Sun May 24 12:33:16 2009(r192683)
@@ -633,7 +633,20 @@ lf_advlockasync(struct vop_advlockasync_
}
 
sx_xlock(&state->ls_lock);
-   switch(ap->a_op) {
+   /*
+* Recheck the doomed vnode after state->ls_lock is
+* locked. lf_purgelocks() requires that no new threads add
+* pending locks when vnode is marked by VI_DOOMED flag.
+*/
+   VI_LOCK(vp);
+   if (vp->v_iflag & VI_DOOMED) {
+   VI_UNLOCK(vp);
+   lf_free_lock(lock);
+   return (ENOENT);
+   }
+   VI_UNLOCK(vp);
+
+   switch (ap->a_op) {
case F_SETLK:
error = lf_setlock(state, lock, vp, ap->a_cookiep);
break;
@@ -755,8 +768,11 @@ lf_purgelocks(struct vnode *vp, struct l
 * the remaining locks.
 */
VI_LOCK(vp);
+   KASSERT(vp->v_iflag & VI_DOOMED,
+   ("lf_purgelocks: vp %p has not vgone yet", vp));
state = *statep;
if (state) {
+   *statep = NULL;
state->ls_threads++;
VI_UNLOCK(vp);
 
@@ -789,7 +805,6 @@ lf_purgelocks(struct vnode *vp, struct l
VI_LOCK(vp);
while (state->ls_threads > 1)
msleep(state, VI_MTX(vp), 0, "purgelocks", 0);
-   *statep = 0;
VI_UNLOCK(vp);
 
/*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192684 - head/sys/kern

2009-05-24 Thread Konstantin Belousov
Author: kib
Date: Sun May 24 12:37:55 2009
New Revision: 192684
URL: http://svn.freebsd.org/changeset/base/192684

Log:
  In lf_purgelocks(), assert that state->ls_pending is empty after we
  weeded out threads, and clean ls_active instead of ls_pending.
  
  Reviewed by:  dfr
  Tested by:pho
  MFC after:1 month

Modified:
  head/sys/kern/kern_lockf.c

Modified: head/sys/kern/kern_lockf.c
==
--- head/sys/kern/kern_lockf.c  Sun May 24 12:33:16 2009(r192683)
+++ head/sys/kern/kern_lockf.c  Sun May 24 12:37:55 2009(r192684)
@@ -813,7 +813,9 @@ lf_purgelocks(struct vnode *vp, struct l
 * above). We don't need to bother locking since we
 * are the last thread using this state structure.
 */
-   LIST_FOREACH_SAFE(lock, &state->ls_pending, lf_link, nlock) {
+   KASSERT(LIST_EMPTY(&state->ls_pending),
+   ("lock pending for %p", state));
+   LIST_FOREACH_SAFE(lock, &state->ls_active, lf_link, nlock) {
LIST_REMOVE(lock, lf_link);
lf_free_lock(lock);
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192685 - in head/sys: kern sys

2009-05-24 Thread Konstantin Belousov
Author: kib
Date: Sun May 24 12:39:38 2009
New Revision: 192685
URL: http://svn.freebsd.org/changeset/base/192685

Log:
  The advisory lock may be activated or activated and removed during the
  sleep waiting for conditions when the lock may be granted.
  To prevent lf_setlock() from accessing possibly freed memory, add reference
  counting to the struct lockf_entry. Bump refcount around the sleep.
  
  Make lf_free_lock() return non-zero when structure was freed, and use
  this after the sleep to return EINTR to the caller. The error code might
  need a clarification, but we cannot return success to usermode, since
  the lock is not owned anymore.
  
  Reviewed by:  dfr
  Tested by:pho
  MFC after:1 month

Modified:
  head/sys/kern/kern_lockf.c
  head/sys/sys/lockf.h

Modified: head/sys/kern/kern_lockf.c
==
--- head/sys/kern/kern_lockf.c  Sun May 24 12:37:55 2009(r192684)
+++ head/sys/kern/kern_lockf.c  Sun May 24 12:39:38 2009(r192685)
@@ -106,7 +106,7 @@ static int   lf_owner_matches(struct lock
 int);
 static struct lockf_entry *
 lf_alloc_lock(struct lock_owner *);
-static void lf_free_lock(struct lockf_entry *);
+static int  lf_free_lock(struct lockf_entry *);
 static int  lf_clearlock(struct lockf *, struct lockf_entry *);
 static int  lf_overlaps(struct lockf_entry *, struct lockf_entry *);
 static int  lf_blocks(struct lockf_entry *, struct lockf_entry *);
@@ -347,9 +347,13 @@ lf_alloc_lock(struct lock_owner *lo)
return (lf);
 }
 
-static void
+static int
 lf_free_lock(struct lockf_entry *lock)
 {
+
+   KASSERT(lock->lf_refs > 0, ("lockf_entry negative ref count %p", lock));
+   if (--lock->lf_refs > 0)
+   return (0);
/*
 * Adjust the lock_owner reference count and
 * reclaim the entry if this is the last lock
@@ -394,6 +398,7 @@ lf_free_lock(struct lockf_entry *lock)
printf("Freed lock %p\n", lock);
 #endif
free(lock, M_LOCKF);
+   return (1);
 }
 
 /*
@@ -540,6 +545,7 @@ lf_advlockasync(struct vop_advlockasync_
 * the lf_lock_owners_lock tax twice.
 */
lock = lf_alloc_lock(NULL);
+   lock->lf_refs = 1;
lock->lf_start = start;
lock->lf_end = end;
lock->lf_owner = lo;
@@ -1447,7 +1453,13 @@ lf_setlock(struct lockf *state, struct l
goto out;
}
 
+   lock->lf_refs++;
error = sx_sleep(lock, &state->ls_lock, priority, lockstr, 0);
+   if (lf_free_lock(lock)) {
+   error = EINTR;
+   goto out;
+   }
+
/*
 * We may have been awakened by a signal and/or by a
 * debugger continuing us (in which cases we must
@@ -1809,6 +1821,7 @@ lf_split(struct lockf *state, struct loc
 */
splitlock = lf_alloc_lock(lock1->lf_owner);
memcpy(splitlock, lock1, sizeof *splitlock);
+   splitlock->lf_refs = 1;
if (splitlock->lf_flags & F_REMOTE)
vref(splitlock->lf_vnode);
 

Modified: head/sys/sys/lockf.h
==
--- head/sys/sys/lockf.hSun May 24 12:37:55 2009(r192684)
+++ head/sys/sys/lockf.hSun May 24 12:39:38 2009(r192685)
@@ -80,6 +80,7 @@ struct lockf_entry {
LIST_ENTRY(lockf_entry) lf_link;  /* (s) Linkage for lock lists */
struct lockf_edge_list lf_outedges; /* (s) list of out-edges */
struct lockf_edge_list lf_inedges; /* (s) list of out-edges */
+   int lf_refs;/* (s) ref count */
 };
 LIST_HEAD(lockf_entry_list, lockf_entry);
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192686 - head/sys/nfsclient

2009-05-24 Thread Doug Rabson
Author: dfr
Date: Sun May 24 13:22:00 2009
New Revision: 192686
URL: http://svn.freebsd.org/changeset/base/192686

Log:
  Make sure we feed 32bit align memory to nfsm_dissect otherwise we will fault
  on platforms with strict alignment requirements. In particular, this fixes the
  problems with the new RPC transport on the arm platform.
  
  Note: this adds yet another copy of nfs_realign(). I will attempt to refactor
  after NFS_LEGACYRPC is removed.
  
  Submitted by: sam

Modified:
  head/sys/nfsclient/nfs_krpc.c

Modified: head/sys/nfsclient/nfs_krpc.c
==
--- head/sys/nfsclient/nfs_krpc.c   Sun May 24 12:39:38 2009
(r192685)
+++ head/sys/nfsclient/nfs_krpc.c   Sun May 24 13:22:00 2009
(r192686)
@@ -407,6 +407,65 @@ nfs_feedback(int type, int proc, void *a
 }
 
 /*
+ * nfs_realign:
+ *
+ * Check for badly aligned mbuf data and realign by copying the unaligned
+ * portion of the data into a new mbuf chain and freeing the portions
+ * of the old chain that were replaced.
+ *
+ * We cannot simply realign the data within the existing mbuf chain
+ * because the underlying buffers may contain other rpc commands and
+ * we cannot afford to overwrite them.
+ *
+ * We would prefer to avoid this situation entirely.  The situation does
+ * not occur with NFS/UDP and is supposed to only occassionally occur
+ * with TCP.  Use vfs.nfs.realign_count and realign_test to check this.
+ *
+ */
+static int
+nfs_realign(struct mbuf **pm, int hsiz)
+{
+   struct mbuf *m, *n;
+   int off, space;
+
+   ++nfs_realign_test;
+   while ((m = *pm) != NULL) {
+   if ((m->m_len & 0x3) || (mtod(m, intptr_t) & 0x3)) {
+   /*
+* NB: we can't depend on m_pkthdr.len to help us
+* decide what to do here.  May not be worth doing
+* the m_length calculation as m_copyback will
+* expand the mbuf chain below as needed.
+*/
+   space = m_length(m, NULL);
+   if (space >= MINCLSIZE) {
+   /* NB: m_copyback handles space > MCLBYTES */
+   n = m_getcl(M_DONTWAIT, MT_DATA, 0);
+   } else
+   n = m_get(M_DONTWAIT, MT_DATA);
+   if (n == NULL)
+   return (ENOMEM);
+   /*
+* Align the remainder of the mbuf chain.
+*/
+   n->m_len = 0;
+   off = 0;
+   while (m != NULL) {
+   m_copyback(n, off, m->m_len, mtod(m, caddr_t));
+   off += m->m_len;
+   m = m->m_next;
+   }
+   m_freem(*pm);
+   *pm = n;
+   ++nfs_realign_count;
+   break;
+   }
+   pm = &m->m_next;
+   }
+   return (0);
+}
+
+/*
  * nfs_request - goes something like this
  * - fill in request struct
  * - links it into list
@@ -525,12 +584,25 @@ tryagain:
} else {
error = EACCES;
}
-   md = mrep;
if (error)
goto nfsmout;
 
KASSERT(mrep != NULL, ("mrep shouldn't be NULL if no error\n"));
 
+   /*
+* Search for any mbufs that are not a multiple of 4 bytes long
+* or with m_data not longword aligned.
+* These could cause pointer alignment problems, so copy them to
+* well aligned mbufs.
+*/
+   error = nfs_realign(&mrep, 2 * NFSX_UNSIGNED);
+   if (error == ENOMEM) {
+   m_freem(mrep);
+   AUTH_DESTROY(auth);
+   return (error);
+   }
+
+   md = mrep;
dpos = mtod(mrep, caddr_t);
tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED);
if (*tl != 0) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r192686 - head/sys/nfsclient

2009-05-24 Thread Doug Rabson
Also, this problem appears to be there in the new experimental NFS  
client code as well. I haven't tried to fix that.



On 24 May 2009, at 14:22, Doug Rabson wrote:


Author: dfr
Date: Sun May 24 13:22:00 2009
New Revision: 192686
URL: http://svn.freebsd.org/changeset/base/192686

Log:
 Make sure we feed 32bit align memory to nfsm_dissect otherwise we  
will fault
 on platforms with strict alignment requirements. In particular,  
this fixes the

 problems with the new RPC transport on the arm platform.

 Note: this adds yet another copy of nfs_realign(). I will attempt  
to refactor

 after NFS_LEGACYRPC is removed.

 Submitted by:  sam

Modified:
 head/sys/nfsclient/nfs_krpc.c

Modified: head/sys/nfsclient/nfs_krpc.c
= 
= 
= 
= 
= 
= 
= 
= 
==

--- head/sys/nfsclient/nfs_krpc.c   Sun May 24 12:39:38 2009
(r192685)
+++ head/sys/nfsclient/nfs_krpc.c   Sun May 24 13:22:00 2009
(r192686)
@@ -407,6 +407,65 @@ nfs_feedback(int type, int proc, void *a
}

/*
+ * nfs_realign:
+ *
+ *	Check for badly aligned mbuf data and realign by copying the  
unaligned

+ * portion of the data into a new mbuf chain and freeing the portions
+ * of the old chain that were replaced.
+ *
+ * We cannot simply realign the data within the existing mbuf chain
+ * because the underlying buffers may contain other rpc commands and
+ * we cannot afford to overwrite them.
+ *
+ *	We would prefer to avoid this situation entirely.  The situation  
does

+ * not occur with NFS/UDP and is supposed to only occassionally occur
+ *	with TCP.  Use vfs.nfs.realign_count and realign_test to check  
this.

+ *
+ */
+static int
+nfs_realign(struct mbuf **pm, int hsiz)
+{
+   struct mbuf *m, *n;
+   int off, space;
+
+   ++nfs_realign_test;
+   while ((m = *pm) != NULL) {
+   if ((m->m_len & 0x3) || (mtod(m, intptr_t) & 0x3)) {
+   /*
+* NB: we can't depend on m_pkthdr.len to help us
+* decide what to do here.  May not be worth doing
+* the m_length calculation as m_copyback will
+* expand the mbuf chain below as needed.
+*/
+   space = m_length(m, NULL);
+   if (space >= MINCLSIZE) {
+   /* NB: m_copyback handles space > MCLBYTES */
+   n = m_getcl(M_DONTWAIT, MT_DATA, 0);
+   } else
+   n = m_get(M_DONTWAIT, MT_DATA);
+   if (n == NULL)
+   return (ENOMEM);
+   /*
+* Align the remainder of the mbuf chain.
+*/
+   n->m_len = 0;
+   off = 0;
+   while (m != NULL) {
+   m_copyback(n, off, m->m_len, mtod(m, caddr_t));
+   off += m->m_len;
+   m = m->m_next;
+   }
+   m_freem(*pm);
+   *pm = n;
+   ++nfs_realign_count;
+   break;
+   }
+   pm = &m->m_next;
+   }
+   return (0);
+}
+
+/*
 * nfs_request - goes something like this
 *  - fill in request struct
 *  - links it into list
@@ -525,12 +584,25 @@ tryagain:
} else {
error = EACCES;
}
-   md = mrep;
if (error)
goto nfsmout;

KASSERT(mrep != NULL, ("mrep shouldn't be NULL if no error\n"));

+   /*
+* Search for any mbufs that are not a multiple of 4 bytes long
+* or with m_data not longword aligned.
+* These could cause pointer alignment problems, so copy them to
+* well aligned mbufs.
+*/
+   error = nfs_realign(&mrep, 2 * NFSX_UNSIGNED);
+   if (error == ENOMEM) {
+   m_freem(mrep);
+   AUTH_DESTROY(auth);
+   return (error);
+   }
+
+   md = mrep;
dpos = mtod(mrep, caddr_t);
tl = nfsm_dissect(u_int32_t *, NFSX_UNSIGNED);
if (*tl != 0) {


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


svn commit: r192687 - head/bin/chflags

2009-05-24 Thread Jilles Tjoelker
Author: jilles
Date: Sun May 24 15:27:25 2009
New Revision: 192687
URL: http://svn.freebsd.org/changeset/base/192687

Log:
  Fix chflags -h in various cases: do not use link target's flags as original.
  
  Patch slightly changed to align more with chmod.c.
  
  PR:   bin/131999
  Submitted by: bde
  Approved by:  ed (mentor)
  MFC after:3 weeks

Modified:
  head/bin/chflags/chflags.c

Modified: head/bin/chflags/chflags.c
==
--- head/bin/chflags/chflags.c  Sun May 24 13:22:00 2009(r192686)
+++ head/bin/chflags/chflags.c  Sun May 24 15:27:25 2009(r192687)
@@ -115,7 +115,7 @@ main(int argc, char *argv[])
fts_options |= FTS_LOGICAL;
}
} else
-   fts_options = FTS_LOGICAL;
+   fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
 
/* XXX: Why don't chflags and lchflags have compatible prototypes? */
if (hflag)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192688 - head/bin/ps

2009-05-24 Thread Jilles Tjoelker
Author: jilles
Date: Sun May 24 15:32:34 2009
New Revision: 192688
URL: http://svn.freebsd.org/changeset/base/192688

Log:
  Fix elapsed (etime) field for swapped out processes in ps:
  show '-' instead of time since the Epoch.
  
  PR:   bin/123069
  Submitted by: Vladimir Kozbin
  Approved by:  ed (mentor)
  MFC after:3 weeks

Modified:
  head/bin/ps/print.c

Modified: head/bin/ps/print.c
==
--- head/bin/ps/print.c Sun May 24 15:27:25 2009(r192687)
+++ head/bin/ps/print.c Sun May 24 15:32:34 2009(r192688)
@@ -596,6 +596,10 @@ elapsed(KINFO *k, VARENT *ve)
char obuff[128];
 
v = ve->var;
+   if (!k->ki_valid) {
+   (void)printf("%-*s", v->width, "-");
+   return;
+   }
val = now - k->ki_p->ki_start.tv_sec;
days = val / (24 * 60 * 60);
val %= 24 * 60 * 60;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192689 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2009-05-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun May 24 15:48:48 2009
New Revision: 192689
URL: http://svn.freebsd.org/changeset/base/192689

Log:
  Fix comment.

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sun May 
24 15:32:34 2009(r192688)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sun May 
24 15:48:48 2009(r192689)
@@ -3963,7 +3963,7 @@ static int
 zfs_freebsd_access(ap)
struct vop_access_args /* {
struct vnode *a_vp;
-   int  a_accmode;
+   accmode_t a_accmode;
struct ucred *a_cred;
struct thread *a_td;
} */ *ap;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192690 - head/share/man/man9

2009-05-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun May 24 17:08:00 2009
New Revision: 192690
URL: http://svn.freebsd.org/changeset/base/192690

Log:
  Fix typo in the manual page.

Modified:
  head/share/man/man9/acl.9

Modified: head/share/man/man9/acl.9
==
--- head/share/man/man9/acl.9   Sun May 24 15:48:48 2009(r192689)
+++ head/share/man/man9/acl.9   Sun May 24 17:08:00 2009(r192690)
@@ -201,7 +201,7 @@ The following values are valid:
 .Bl -tag -width ".Dv ACL_ENTRY_DIRECTORY_INHERIT"
 .It Dv ACL_ENTRY_FILE_INHERIT
 .It Dv ACL_ENTRY_DIRECTORY_INHERIT
-.It Dv ACL_ENRY_NO_PROPAGATE_INHERIT
+.It Dv ACL_ENRTY_NO_PROPAGATE_INHERIT
 .It Dv ACL_ENTRY_INHERIT_ONLY
 .El
 .El
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192691 - head/share/man/man9

2009-05-24 Thread Tom McLaughlin
Author: tmclaugh (ports committer)
Date: Sun May 24 18:34:54 2009
New Revision: 192691
URL: http://svn.freebsd.org/changeset/base/192691

Log:
  Update man pages after VFS_* changes in r191990.
  
  Approved by:  brueffer, attilio

Modified:
  head/share/man/man9/VFS_MOUNT.9
  head/share/man/man9/VFS_QUOTACTL.9
  head/share/man/man9/VFS_ROOT.9
  head/share/man/man9/VFS_STATFS.9
  head/share/man/man9/VFS_SYNC.9
  head/share/man/man9/VFS_UNMOUNT.9

Modified: head/share/man/man9/VFS_MOUNT.9
==
--- head/share/man/man9/VFS_MOUNT.9 Sun May 24 17:08:00 2009
(r192690)
+++ head/share/man/man9/VFS_MOUNT.9 Sun May 24 18:34:54 2009
(r192691)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 7, 2005
+.Dd May 23, 2009
 .Os
 .Dt VFS_MOUNT 9
 .Sh NAME
@@ -39,7 +39,7 @@
 .In sys/mount.h
 .In sys/vnode.h
 .Ft int
-.Fn VFS_MOUNT "struct mount *mp" "struct thread *td"
+.Fn VFS_MOUNT "struct mount *mp"
 .Sh DESCRIPTION
 The
 .Fn VFS_MOUNT
@@ -50,8 +50,6 @@ The arguments it expects are:
 .Bl -tag -width data
 .It Fa mp
 Structure representing the file system.
-.It Fa td
-Thread which is mounting the file system.
 .El
 .Pp
 The

Modified: head/share/man/man9/VFS_QUOTACTL.9
==
--- head/share/man/man9/VFS_QUOTACTL.9  Sun May 24 17:08:00 2009
(r192690)
+++ head/share/man/man9/VFS_QUOTACTL.9  Sun May 24 18:34:54 2009
(r192691)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 24, 1996
+.Dd May 23, 2009
 .Os
 .Dt VFS_QUOTACTL 9
 .Sh NAME
@@ -39,7 +39,7 @@
 .In sys/mount.h
 .In sys/vnode.h
 .Ft int
-.Fn VFS_QUOTACTL "struct mount *mp" "int cmds" "uid_t uid" "caddr_t arg" 
"struct thread *td"
+.Fn VFS_QUOTACTL "struct mount *mp" "int cmds" "uid_t uid" "caddr_t arg"
 .Sh DESCRIPTION
 Implement file system quotas.
 See

Modified: head/share/man/man9/VFS_ROOT.9
==
--- head/share/man/man9/VFS_ROOT.9  Sun May 24 17:08:00 2009
(r192690)
+++ head/share/man/man9/VFS_ROOT.9  Sun May 24 18:34:54 2009
(r192691)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 26, 2006
+.Dd May 23, 2009
 .Os
 .Dt VFS_ROOT 9
 .Sh NAME
@@ -39,7 +39,7 @@
 .In sys/mount.h
 .In sys/vnode.h
 .Ft int
-.Fn VFS_ROOT "struct mount *mp" "int flags" "struct vnode **vpp" "struct 
thread *td"
+.Fn VFS_ROOT "struct mount *mp" "int flags" "struct vnode **vpp"
 .Sh DESCRIPTION
 Return a locked vnode for the root directory of the file system.
 .Pp
@@ -58,8 +58,6 @@ File system is free to ignore the
 argument and instead acquire an exclusive lock.
 .It Fa vpp
 Return parameter for the root vnode.
-.It Fa td
-The calling thread.
 .El
 .Sh SEE ALSO
 .Xr VFS 9 ,

Modified: head/share/man/man9/VFS_STATFS.9
==
--- head/share/man/man9/VFS_STATFS.9Sun May 24 17:08:00 2009
(r192690)
+++ head/share/man/man9/VFS_STATFS.9Sun May 24 18:34:54 2009
(r192691)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 7, 2005
+.Dd May 23, 2009
 .Os
 .Dt VFS_STATFS 9
 .Sh NAME
@@ -39,7 +39,7 @@
 .In sys/mount.h
 .In sys/vnode.h
 .Ft int
-.Fn VFS_STATFS "struct mount *mp" "struct statfs *sbp" "struct thread *td"
+.Fn VFS_STATFS "struct mount *mp" "struct statfs *sbp"
 .Sh DESCRIPTION
 The
 .Fn VFS_STATFS
@@ -56,8 +56,6 @@ A
 structure, as defined by
 .In sys/mount.h ,
 into which information is placed about the file system.
-.It Fa td
-The thread which is querying the file system.
 .El
 .Pp
 The fields of

Modified: head/share/man/man9/VFS_SYNC.9
==
--- head/share/man/man9/VFS_SYNC.9  Sun May 24 17:08:00 2009
(r192690)
+++ head/share/man/man9/VFS_SYNC.9  Sun May 24 18:34:54 2009
(r192691)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 7, 2005
+.Dd May 23, 2009
 .Os
 .Dt VFS_SYNC 9
 .Sh NAME
@@ -39,7 +39,7 @@
 .In sys/mount.h
 .In sys/vnode.h
 .Ft int
-.Fn VFS_SYNC "struct mount *mp" "int waitfor" "struct thread *td"
+.Fn VFS_SYNC "struct mount *mp" "int waitfor"
 .Sh DESCRIPTION
 The
 .Fn VFS_SYNC
@@ -61,8 +61,6 @@ start all I/O, but do not wait for it
 .It Dv MNT_LAZY
 push data not written by file system syncer
 .El
-.It Fa td
-The calling thread.
 .El
 .Pp
 The

Modified: head/share/man/man9/VFS_UNMOUNT.9
==
--- head/share/man/man9/VFS_UNMOUNT.9   Sun May 24 17:08:00 2009
(r192690)
+++ head/share/man/man9/VFS_UNMOUNT.9   Sun May 24 18:34:54 2009
(r192691)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 7, 2005
+.Dd May 23, 2009
 .Os
 .Dt VFS_UNMOUNT 9
 .Sh NAME
@@ -39,7 +39,7 @@
 .In sys/mount.h
 .In sys/vnode.h
 .Ft int
-.Fn VFS_UNMOUNT "struct mount *mp" "int mntflags" "struct thread *td"
+.Fn 

svn commit: r192692 - head/sys/compat/ndis

2009-05-24 Thread Antoine Brodin
Author: antoine
Date: Sun May 24 18:35:53 2009
New Revision: 192692
URL: http://svn.freebsd.org/changeset/base/192692

Log:
  Remove an unused variable.

Modified:
  head/sys/compat/ndis/kern_ndis.c

Modified: head/sys/compat/ndis/kern_ndis.c
==
--- head/sys/compat/ndis/kern_ndis.cSun May 24 18:34:54 2009
(r192691)
+++ head/sys/compat/ndis/kern_ndis.cSun May 24 18:35:53 2009
(r192692)
@@ -543,7 +543,7 @@ ndis_free_bufs(b0)
 
return;
 }
-int in_reset = 0;
+
 void
 ndis_free_packet(p)
ndis_packet *p;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192693 - head/sys/fs/nfsserver

2009-05-24 Thread Rick Macklem
Author: rmacklem
Date: Sun May 24 18:49:53 2009
New Revision: 192693
URL: http://svn.freebsd.org/changeset/base/192693

Log:
  Fix the experimental NFSv4 server so that it handles the case
  where a client is not allowed NFSv4 access correctly. This
  restriction is specified in the "V4: ..." line(s) in
  /etc/exports.
  
  Approved by:  kib (mentor)

Modified:
  head/sys/fs/nfsserver/nfs_nfsdkrpc.c

Modified: head/sys/fs/nfsserver/nfs_nfsdkrpc.c
==
--- head/sys/fs/nfsserver/nfs_nfsdkrpc.cSun May 24 18:35:53 2009
(r192692)
+++ head/sys/fs/nfsserver/nfs_nfsdkrpc.cSun May 24 18:49:53 2009
(r192693)
@@ -286,6 +286,8 @@ nfs_proc(struct nfsrv_descript *nd, u_in
cacherep = RC_DROPIT;
} else if (nd->nd_repstat) {
cacherep = RC_REPLY;
+   if ((nd->nd_flag & ND_NFSV4) == 0)
+   panic("nfs_repstat for nfsv2,3");
} else {
/*
 * For NFSv3, play it safe and assume that the client is
@@ -313,6 +315,9 @@ nfs_proc(struct nfsrv_descript *nd, u_in
else
cacherep = RC_REPLY;
*rpp = nfsrvd_updatecache(nd, so);
+   } else if (cacherep == RC_REPLY) {
+   /* Generate the error reply message for NFSv4 */
+   nfsrvd_dorpc(nd, isdgram, td);
}
return (cacherep);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192694 - head/sys/cddl/compat/opensolaris/kern

2009-05-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun May 24 19:21:49 2009
New Revision: 192694
URL: http://svn.freebsd.org/changeset/base/192694

Log:
  Don't allow non-owner to set SUID bit on a file.  It doesn't make
  any difference now, but in NFSv4 ACLs, there is write_acl permission,
  which also affects mode changes.
  
  Reviewed by:  pjd

Modified:
  head/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c

Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c
==
--- head/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c  Sun May 24 
18:49:53 2009(r192693)
+++ head/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c  Sun May 24 
19:21:49 2009(r192694)
@@ -302,6 +302,14 @@ secpolicy_setid_setsticky_clear(struct v
if (error)
return (error);
}
+   /*
+* Deny setting setuid if we are not the file owner.
+*/
+   if ((vap->va_mode & S_ISUID) && ovap->va_uid != cred->cr_uid) {
+   error = priv_check_cred(cred, PRIV_VFS_ADMIN, 0);
+   if (error)
+   return (error);
+   }
return (0);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192695 - head/sys/fs/nfs

2009-05-24 Thread Rick Macklem
Author: rmacklem
Date: Sun May 24 19:46:12 2009
New Revision: 192695
URL: http://svn.freebsd.org/changeset/base/192695

Log:
  Crib the realign function out of nfs_krpc.c and add a call
  to it for the client side reply. Hopefully this fixes the
  problem with using the new krpc for arm for the experimental
  nfs client.
  
  Approved by:  kib (mentor)

Modified:
  head/sys/fs/nfs/nfs_commonkrpc.c
  head/sys/fs/nfs/nfs_commonport.c

Modified: head/sys/fs/nfs/nfs_commonkrpc.c
==
--- head/sys/fs/nfs/nfs_commonkrpc.cSun May 24 19:21:49 2009
(r192694)
+++ head/sys/fs/nfs/nfs_commonkrpc.cSun May 24 19:46:12 2009
(r192695)
@@ -603,6 +603,13 @@ tryagain:
 
KASSERT(nd->nd_mrep != NULL, ("mrep shouldn't be NULL if no error\n"));
 
+   /*
+* Search for any mbufs that are not a multiple of 4 bytes long
+* or with m_data not longword aligned.
+* These could cause pointer alignment problems, so copy them to
+* well aligned mbufs.
+*/
+   newnfs_realign(&nd->nd_mrep);
nd->nd_md = nd->nd_mrep;
nd->nd_dpos = NFSMTOD(nd->nd_md, caddr_t);
nd->nd_repstat = 0;

Modified: head/sys/fs/nfs/nfs_commonport.c
==
--- head/sys/fs/nfs/nfs_commonport.cSun May 24 19:21:49 2009
(r192694)
+++ head/sys/fs/nfs/nfs_commonport.cSun May 24 19:46:12 2009
(r192695)
@@ -70,8 +70,8 @@ static int nfs_realign_test;
 static int nfs_realign_count;
 
 SYSCTL_NODE(_vfs, OID_AUTO, newnfs, CTLFLAG_RW, 0, "New NFS filesystem");
-SYSCTL_INT(_vfs_newnfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, 
0, "");
-SYSCTL_INT(_vfs_newnfs, OID_AUTO, realign_count, CTLFLAG_RW, 
&nfs_realign_count, 0, "");
+SYSCTL_INT(_vfs_newnfs, OID_AUTO, newnfs_realign_test, CTLFLAG_RW, 
&nfs_realign_test, 0, "");
+SYSCTL_INT(_vfs_newnfs, OID_AUTO, newnfs_realign_count, CTLFLAG_RW, 
&nfs_realign_count, 0, "");
 SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs4acl_enable, CTLFLAG_RW, &nfsrv_useacl, 
0, "");
 SYSCTL_STRING(_vfs_newnfs, OID_AUTO, callback_addr, CTLFLAG_RW,
 nfsv4_callbackaddr, sizeof(nfsv4_callbackaddr), "");
@@ -129,7 +129,7 @@ newnfs_realign(struct mbuf **pm)
 }
 #else
 /*
- * nfs_realign:
+ * newnfs_realign:
  *
  * Check for badly aligned mbuf data and realign by copying the unaligned
  * portion of the data into a new mbuf chain and freeing the portions
@@ -142,43 +142,50 @@ newnfs_realign(struct mbuf **pm)
  * We would prefer to avoid this situation entirely.  The situation does
  * not occur with NFS/UDP and is supposed to only occassionally occur
  * with TCP.  Use vfs.nfs.realign_count and realign_test to check this.
+ *
  */
 void
 newnfs_realign(struct mbuf **pm)
 {
-   struct mbuf *m;
-   struct mbuf *n = NULL;
-   int off = 0;
+   struct mbuf *m, *n;
+   int off, space;
 
++nfs_realign_test;
while ((m = *pm) != NULL) {
if ((m->m_len & 0x3) || (mtod(m, intptr_t) & 0x3)) {
-   MGET(n, M_WAIT, MT_DATA);
-   if (m->m_len >= MINCLSIZE) {
-   MCLGET(n, M_WAIT);
-   }
+   /*
+* NB: we can't depend on m_pkthdr.len to help us
+* decide what to do here.  May not be worth doing
+* the m_length calculation as m_copyback will
+* expand the mbuf chain below as needed.
+*/
+   space = m_length(m, NULL);
+   if (space >= MINCLSIZE) {
+   /* NB: m_copyback handles space > MCLBYTES */
+   n = m_getcl(M_WAITOK, MT_DATA, 0);
+   } else
+   n = m_get(M_WAITOK, MT_DATA);
+   if (n == NULL)
+   return;
+   /*
+* Align the remainder of the mbuf chain.
+*/
n->m_len = 0;
+   off = 0;
+   while (m != NULL) {
+   m_copyback(n, off, m->m_len, mtod(m, caddr_t));
+   off += m->m_len;
+   m = m->m_next;
+   }
+   m_freem(*pm);
+   *pm = n;
+   ++nfs_realign_count;
break;
}
pm = &m->m_next;
}
-
-   /*
-* If n is non-NULL, loop on m copying data, then replace the
-* portion of the chain that had to be realigned.
-*/
-   if (n != NULL) {
-   ++nfs_realign_count;
-   while (m) {
-   m_copyback(n

svn commit: r192696 - head/share/man/man9

2009-05-24 Thread Edward Tomasz Napierala
Author: trasz
Date: Sun May 24 20:34:29 2009
New Revision: 192696
URL: http://svn.freebsd.org/changeset/base/192696

Log:
  There are things too complex to be fixed in one commit.
  Fix a typo in acl(9) manual page.
  
  Submitted by: avg

Modified:
  head/share/man/man9/acl.9

Modified: head/share/man/man9/acl.9
==
--- head/share/man/man9/acl.9   Sun May 24 19:46:12 2009(r192695)
+++ head/share/man/man9/acl.9   Sun May 24 20:34:29 2009(r192696)
@@ -201,7 +201,7 @@ The following values are valid:
 .Bl -tag -width ".Dv ACL_ENTRY_DIRECTORY_INHERIT"
 .It Dv ACL_ENTRY_FILE_INHERIT
 .It Dv ACL_ENTRY_DIRECTORY_INHERIT
-.It Dv ACL_ENRTY_NO_PROPAGATE_INHERIT
+.It Dv ACL_ENTRY_NO_PROPAGATE_INHERIT
 .It Dv ACL_ENTRY_INHERIT_ONLY
 .El
 .El
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192697 - stable/7/usr.sbin/btxld

2009-05-24 Thread Kip Macy
Author: kmacy
Date: Sun May 24 20:49:22 2009
New Revision: 192697
URL: http://svn.freebsd.org/changeset/base/192697

Log:
  merge 177933
  
  Allow for a zero length 'loader'.

Modified:
  stable/7/usr.sbin/btxld/btxld.c

Modified: stable/7/usr.sbin/btxld/btxld.c
==
--- stable/7/usr.sbin/btxld/btxld.c Sun May 24 20:34:29 2009
(r192696)
+++ stable/7/usr.sbin/btxld/btxld.c Sun May 24 20:49:22 2009
(r192697)
@@ -336,6 +336,8 @@ gethdr(int fd, struct hdr *hdr)
 if (sb.st_size > MAXU32)
errx(1, "%s: Too big", fname);
 hdr->size = sb.st_size;
+if (!hdr->size)
+   return;
 if ((p = mmap(NULL, hdr->size, PROT_READ, MAP_SHARED, fd,
  0)) == MAP_FAILED)
err(2, "%s", fname);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192705 - head/sys/fs/nfs

2009-05-24 Thread Rick Macklem
Author: rmacklem
Date: Sun May 24 23:47:22 2009
New Revision: 192705
URL: http://svn.freebsd.org/changeset/base/192705

Log:
  Temporarily #undef NFS4_ACL_EXTATTR_NAME, so that the
  experimental nfs subsystem will build while the NFSv4 ACL
  support is going into the kernel.
  
  Approved by:  kib (mentor)

Modified:
  head/sys/fs/nfs/nfsport.h

Modified: head/sys/fs/nfs/nfsport.h
==
--- head/sys/fs/nfs/nfsport.h   Sun May 24 23:24:49 2009(r192704)
+++ head/sys/fs/nfs/nfsport.h   Sun May 24 23:47:22 2009(r192705)
@@ -71,6 +71,8 @@
 #include 
 #include 
 #include 
+/* until the nfsv4 acl stuff is all committed, undef NFS4_ACL_EXTATTR_NAME */
+#undef NFS4_ACL_EXTATTR_NAME
 #include 
 #include 
 #include 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192706 - head/sys/dev/nfe

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 00:56:01 2009
New Revision: 192706
URL: http://svn.freebsd.org/changeset/base/192706

Log:
  NVIDIA MCP controllers have no Rx buffer alignment restrictions.
  Remove PAGE_SIZE alignment used in Rx buffer DMA tag creation. The
  alignment restriction was used in old local jumbo allocator and
  nfe(4) switched to UMA backed page allocator for jumbo frame.
  
  This change should fix jumbo buffer allocation failure.
  
  Reported by:  Pascal Braun ( pascal.braun <> continum dot net )

Modified:
  head/sys/dev/nfe/if_nfe.c

Modified: head/sys/dev/nfe/if_nfe.c
==
--- head/sys/dev/nfe/if_nfe.c   Sun May 24 23:47:22 2009(r192705)
+++ head/sys/dev/nfe/if_nfe.c   Mon May 25 00:56:01 2009(r192706)
@@ -1153,7 +1153,7 @@ nfe_alloc_jrx_ring(struct nfe_softc *sc,
 
/* Create DMA tag for jumbo Rx buffers. */
error = bus_dma_tag_create(sc->nfe_parent_tag,
-   PAGE_SIZE, 0,   /* alignment, boundary */
+   1, 0,   /* alignment, boundary */
BUS_SPACE_MAXADDR,  /* lowaddr */
BUS_SPACE_MAXADDR,  /* highaddr */
NULL, NULL, /* filter, filterarg */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192707 - head/sys/fs/nfsserver

2009-05-24 Thread Rick Macklem
Author: rmacklem
Date: Mon May 25 01:00:09 2009
New Revision: 192707
URL: http://svn.freebsd.org/changeset/base/192707

Log:
  Add NFSv4 root export checks to the DelegPurge, Renew and
  ReleaseLockOwner operations analagous to what is already
  in place for SetClientID and SetClientIDConfirm. These are
  the five NFSv4 operations that do not use file handle(s),
  so the checks are done using the NFSv4 root export entries
  in /etc/exports.
  
  Approved by:  kib (mentor)

Modified:
  head/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==
--- head/sys/fs/nfsserver/nfs_nfsdserv.cMon May 25 00:56:01 2009
(r192706)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.cMon May 25 01:00:09 2009
(r192707)
@@ -2830,6 +2830,11 @@ nfsrvd_delegpurge(struct nfsrv_descript 
int error = 0;
nfsquad_t clientid;
 
+   if ((!nfs_rootfhset && !nfsv4root_set) ||
+   nfsd_checkrootexp(nd)) {
+   nd->nd_repstat = NFSERR_WRONGSEC;
+   return (0);
+   }
NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
clientid.lval[0] = *tl++;
clientid.lval[1] = *tl;
@@ -3024,6 +3029,11 @@ nfsrvd_renew(struct nfsrv_descript *nd, 
int error = 0;
nfsquad_t clientid;
 
+   if ((!nfs_rootfhset && !nfsv4root_set) ||
+   nfsd_checkrootexp(nd)) {
+   nd->nd_repstat = NFSERR_WRONGSEC;
+   return (0);
+   }
NFSM_DISSECT(tl, u_int32_t *, NFSX_HYPER);
clientid.lval[0] = *tl++;
clientid.lval[1] = *tl;
@@ -3355,6 +3365,11 @@ nfsrvd_releaselckown(struct nfsrv_descri
int error = 0, len;
nfsquad_t clientid;
 
+   if ((!nfs_rootfhset && !nfsv4root_set) ||
+   nfsd_checkrootexp(nd)) {
+   nd->nd_repstat = NFSERR_WRONGSEC;
+   return (0);
+   }
NFSM_DISSECT(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
len = fxdr_unsigned(int, *(tl + 2));
MALLOC(stp, struct nfsstate *, sizeof (struct nfsstate) + len,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192708 - head/sys/dev/mii

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 01:41:05 2009
New Revision: 192708
URL: http://svn.freebsd.org/changeset/base/192708

Log:
  Use mii_phy_add_media() and remove usage of local macro ADD. Also
  checks extended status register to see whether the PHY is fast
  ethernet or not. This removes a lot of checks for specific PHY
  models and it makes easy to add more PHYs to e1000phy(4).
  
  While I'm here remove setting mii_anegticks as it is set with
  mii_phy_add_media().

Modified:
  head/sys/dev/mii/e1000phy.c

Modified: head/sys/dev/mii/e1000phy.c
==
--- head/sys/dev/mii/e1000phy.c Mon May 25 01:00:09 2009(r192707)
+++ head/sys/dev/mii/e1000phy.c Mon May 25 01:41:05 2009(r192708)
@@ -129,7 +129,6 @@ e1000phy_attach(device_t dev)
struct mii_softc *sc;
struct mii_attach_args *ma;
struct mii_data *mii;
-   int fast_ether;
 
esc = device_get_softc(dev);
sc = &esc->mii_sc;
@@ -142,10 +141,8 @@ e1000phy_attach(device_t dev)
sc->mii_phy = ma->mii_phyno;
sc->mii_service = e1000phy_service;
sc->mii_pdata = mii;
-   sc->mii_anegticks = MII_ANEGTICKS_GIGE;
mii->mii_instance++;
 
-   fast_ether = 0;
esc->mii_model = MII_MODEL(ma->mii_id2);
switch (esc->mii_model) {
case MII_MODEL_MARVELL_E1011:
@@ -167,54 +164,16 @@ e1000phy_attach(device_t dev)
 */
PHY_WRITE(sc, E1000_EADR, 0);
break;
-   case MII_MODEL_MARVELL_E3082:
-   /* 88E3082 10/100 Fast Ethernet PHY. */
-   sc->mii_anegticks = MII_ANEGTICKS;
-   fast_ether = 1;
-   break;
}
 
e1000phy_reset(sc);
 
+   sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+   if (sc->mii_capabilities & BMSR_EXTSTAT)
+   sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
device_printf(dev, " ");
-
-#defineADD(m, c)   ifmedia_add(&mii->mii_media, (m), (c), NULL)
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
-   E1000_CR_ISOLATE);
-   if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst),
-   E1000_CR_SPEED_10);
-   printf("10baseT, ");
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, sc->mii_inst),
-   E1000_CR_SPEED_10 | E1000_CR_FULL_DUPLEX);
-   printf("10baseT-FDX, ");
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst),
-   E1000_CR_SPEED_100);
-   printf("100baseTX, ");
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, sc->mii_inst),
-   E1000_CR_SPEED_100 | E1000_CR_FULL_DUPLEX);
-   printf("100baseTX-FDX, ");
-   if (fast_ether == 0) {
-   /*
-* 1000BT-simplex not supported; driver must ignore
-* this entry, but it must be present in order to
-* manually set full-duplex.
-*/
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, 0,
-   sc->mii_inst), E1000_CR_SPEED_1000);
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, IFM_FDX,
-   sc->mii_inst),
-   E1000_CR_SPEED_1000 | E1000_CR_FULL_DUPLEX);
-   printf("1000baseTX-FDX, ");
-   }
-   } else {
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, IFM_FDX, sc->mii_inst),
-   E1000_CR_SPEED_1000 | E1000_CR_FULL_DUPLEX);
-   printf("1000baseSX-FDX, ");
-   }
-   ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst), 0);
-   printf("auto\n");
-#undef ADD
+   mii_phy_add_media(sc);
+   printf("\n");
 
MIIBUS_MEDIAINIT(sc->mii_dev);
return (0);
@@ -339,12 +298,14 @@ e1000phy_service(struct mii_softc *sc, s
speed = 0;
switch (IFM_SUBTYPE(ife->ifm_media)) {
case IFM_1000_T:
-   if (esc->mii_model == MII_MODEL_MARVELL_E3082)
+   if ((sc->mii_extcapabilities &
+   (EXTSR_1000TFDX | EXTSR_1000THDX)) == 0)
return (EINVAL);
speed = E1000_CR_SPEED_1000;
break;
case IFM_1000_SX:
-   if (esc->mii_model == MII_MODEL_MARVELL_E3082)
+   if ((sc->mii_extcapabilities &
+   (EXTSR_1000XFDX | EXTSR_1000XHDX)) == 0)
return (EINVAL);
speed = E1000_CR_SPEED_1000;
break;
@@ -390,7 +351,8 @@ e1000phy_service(struct mii_softc *sc, s
PHY_WRITE

svn commit: r192709 - head/sys/dev/mii

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 01:45:28 2009
New Revision: 192709
URL: http://svn.freebsd.org/changeset/base/192709

Log:
  Report current link state while auto-negotiation is in progress.

Modified:
  head/sys/dev/mii/e1000phy.c

Modified: head/sys/dev/mii/e1000phy.c
==
--- head/sys/dev/mii/e1000phy.c Mon May 25 01:41:05 2009(r192708)
+++ head/sys/dev/mii/e1000phy.c Mon May 25 01:45:28 2009(r192709)
@@ -394,7 +394,7 @@ done:
if (sc->mii_ticks++ == 0)
break;
if (sc->mii_ticks <= sc->mii_anegticks)
-   return (0);
+   break;
 
sc->mii_ticks = 0;
e1000phy_reset(sc);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192710 - head/sys/dev/mii

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 01:56:19 2009
New Revision: 192710
URL: http://svn.freebsd.org/changeset/base/192710

Log:
  Don't read unnecessary PHY registers. Speed/duplex resolution bit
  is valid only for auto-negotiation case so check the bit if we know
  auto-negotiation is active. While I'm here explicitly checks
  current speed with speed mask and set IFM_NONE if resolved speed
  is unknown.

Modified:
  head/sys/dev/mii/e1000phy.c

Modified: head/sys/dev/mii/e1000phy.c
==
--- head/sys/dev/mii/e1000phy.c Mon May 25 01:45:28 2009(r192709)
+++ head/sys/dev/mii/e1000phy.c Mon May 25 01:56:19 2009(r192710)
@@ -414,18 +414,14 @@ static void
 e1000phy_status(struct mii_softc *sc)
 {
struct mii_data *mii = sc->mii_pdata;
-   int bmsr, bmcr, esr, gsr, ssr, isr, ar, lpar;
+   int bmcr, bmsr, gsr, ssr, ar, lpar;
 
mii->mii_media_status = IFM_AVALID;
mii->mii_media_active = IFM_ETHER;
 
bmsr = PHY_READ(sc, E1000_SR) | PHY_READ(sc, E1000_SR);
-   esr = PHY_READ(sc, E1000_ESR);
bmcr = PHY_READ(sc, E1000_CR);
ssr = PHY_READ(sc, E1000_SSR);
-   isr = PHY_READ(sc, E1000_ISR);
-   ar = PHY_READ(sc, E1000_AR);
-   lpar = PHY_READ(sc, E1000_LPAR);
 
if (bmsr & E1000_SR_LINK_STATUS)
mii->mii_media_status |= IFM_ACTIVE;
@@ -433,22 +429,28 @@ e1000phy_status(struct mii_softc *sc)
if (bmcr & E1000_CR_LOOPBACK)
mii->mii_media_active |= IFM_LOOP;
 
-   if bmcr & E1000_CR_AUTO_NEG_ENABLE) != 0) &&
-   ((bmsr & E1000_SR_AUTO_NEG_COMPLETE) == 0)) ||
-   ((ssr & E1000_SSR_LINK) == 0) ||
-   ((ssr & E1000_SSR_SPD_DPLX_RESOLVED) == 0)) {
+   if ((bmcr & E1000_CR_AUTO_NEG_ENABLE) != 0 &&
+   (ssr & E1000_SSR_SPD_DPLX_RESOLVED) == 0) {
/* Erg, still trying, I guess... */
mii->mii_media_active |= IFM_NONE;
return;
}
 
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
-   if (ssr & E1000_SSR_1000MBS)
+   switch (ssr & E1000_SSR_SPEED) {
+   case E1000_SSR_1000MBS:
mii->mii_media_active |= IFM_1000_T;
-   else if (ssr & E1000_SSR_100MBS)
+   break;
+   case E1000_SSR_100MBS:
mii->mii_media_active |= IFM_100_TX;
-   else
+   break;
+   case E1000_SSR_10MBS:
mii->mii_media_active |= IFM_10_T;
+   break;
+   default:
+   mii->mii_media_active |= IFM_NONE;
+   return;
+   }
} else {
if (ssr & E1000_SSR_1000MBS)
mii->mii_media_active |= IFM_1000_SX;
@@ -460,6 +462,8 @@ e1000phy_status(struct mii_softc *sc)
mii->mii_media_active |= IFM_HDX;
 
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
+   ar = PHY_READ(sc, E1000_AR);
+   lpar = PHY_READ(sc, E1000_LPAR);
/* FLAG0==rx-flow-control FLAG1==tx-flow-control */
if ((ar & E1000_AR_PAUSE) && (lpar & E1000_LPAR_PAUSE)) {
mii->mii_media_active |= IFM_FLAG0 | IFM_FLAG1;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192711 - head/sys/dev/mii

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 02:05:00 2009
New Revision: 192711
URL: http://svn.freebsd.org/changeset/base/192711

Log:
  Do not ignore NEXT Page capability of auto-negotiation
  advertisement register. Some PHYs such as 88E3016 requires NEXT
  Page capability to establish valid link. Also set protocol selector
  field which is read only but it makes the intention clearer.

Modified:
  head/sys/dev/mii/e1000phy.c

Modified: head/sys/dev/mii/e1000phy.c
==
--- head/sys/dev/mii/e1000phy.c Mon May 25 01:56:19 2009(r192710)
+++ head/sys/dev/mii/e1000phy.c Mon May 25 02:05:00 2009(r192711)
@@ -490,13 +490,16 @@ static int
 e1000phy_mii_phy_auto(struct e1000phy_softc *esc)
 {
struct mii_softc *sc;
+   uint16_t reg;
 
sc = &esc->mii_sc;
-   if ((sc->mii_flags & MIIF_HAVEFIBER) == 0)
-   PHY_WRITE(sc, E1000_AR, E1000_AR_10T | E1000_AR_10T_FD |
+   if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
+   reg = PHY_READ(sc, E1000_AR);
+   reg |= E1000_AR_10T | E1000_AR_10T_FD |
E1000_AR_100TX | E1000_AR_100TX_FD |
-   E1000_AR_PAUSE | E1000_AR_ASM_DIR);
-   else
+   E1000_AR_PAUSE | E1000_AR_ASM_DIR;
+   PHY_WRITE(sc, E1000_AR, reg | E1000_AR_SELECTOR_FIELD);
+   } else
PHY_WRITE(sc, E1000_AR, E1000_FA_1000X_FD | E1000_FA_1000X |
E1000_FA_SYM_PAUSE | E1000_FA_ASYM_PAUSE);
if ((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192713 - head/sys/dev/mii

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 02:36:29 2009
New Revision: 192713
URL: http://svn.freebsd.org/changeset/base/192713

Log:
  Add driver support for 88E3016 PHY which is found on Marvell Yukon
  FE+ controller. Due to the severe silicon bugs for Yukon FE+,
  88E3016 seems to require more workarounds. However I'm not sure
  whether the workaround is PHY specific or only applicable to Yukon
  FE+. The datasheet for the PHY is publicly available but it lacks
  several details for the workaround used in this change. The
  workaround information was obtained from Linux. Many thanks to
  Yukon FE+ users who helped me add 88E3016 support.
  
  Tested by:bz, Tanguy Bouzeloc ( the.zauron <> gmail dot com )
Bruce Cran ( bruce <> cran dot org dot uk )
Michael Reifenberger ( mike <> reifenberger dot com )
Stephen Montgomery-Smith ( stephen <> missouri dot edu )

Modified:
  head/sys/dev/mii/e1000phy.c
  head/sys/dev/mii/e1000phyreg.h
  head/sys/dev/mii/miidevs

Modified: head/sys/dev/mii/e1000phy.c
==
--- head/sys/dev/mii/e1000phy.c Mon May 25 02:09:09 2009(r192712)
+++ head/sys/dev/mii/e1000phy.c Mon May 25 02:36:29 2009(r192713)
@@ -107,6 +107,7 @@ static const struct mii_phydesc e1000phy
MII_PHY_DESC(MARVELL, E1116),
MII_PHY_DESC(MARVELL, E1116R),
MII_PHY_DESC(MARVELL, E1118),
+   MII_PHY_DESC(MARVELL, E3016),
MII_PHY_DESC(xxMARVELL, E1000),
MII_PHY_DESC(xxMARVELL, E1011),
MII_PHY_DESC(xxMARVELL, E1000_3),
@@ -212,18 +213,29 @@ e1000phy_reset(struct mii_softc *sc)
reg |= E1000_SCR_AUTO_X_MODE;
if (esc->mii_model == MII_MODEL_MARVELL_E1116)
reg &= ~E1000_SCR_POWER_DOWN;
+   reg |= E1000_SCR_ASSERT_CRS_ON_TX;
break;
case MII_MODEL_MARVELL_E3082:
reg |= (E1000_SCR_AUTO_X_MODE >> 1);
+   reg |= E1000_SCR_ASSERT_CRS_ON_TX;
+   break;
+   case MII_MODEL_MARVELL_E3016:
+   reg |= E1000_SCR_AUTO_MDIX;
+   reg &= ~(E1000_SCR_EN_DETECT |
+   E1000_SCR_SCRAMBLER_DISABLE);
+   reg |= E1000_SCR_LPNP;
+   /* XXX Enable class A driver for Yukon FE+ A0. */
+   PHY_WRITE(sc, 0x1C, PHY_READ(sc, 0x1C) | 0x0001);
break;
default:
reg &= ~E1000_SCR_AUTO_X_MODE;
+   reg |= E1000_SCR_ASSERT_CRS_ON_TX;
break;
}
-   /* Enable CRS on TX. */
-   reg |= E1000_SCR_ASSERT_CRS_ON_TX;
-   /* Auto correction for reversed cable polarity. */
-   reg &= ~E1000_SCR_POLARITY_REVERSAL;
+   if (esc->mii_model != MII_MODEL_MARVELL_E3016) {
+   /* Auto correction for reversed cable polarity. */
+   reg &= ~E1000_SCR_POLARITY_REVERSAL;
+   }
PHY_WRITE(sc, E1000_SCR, reg);
 
if (esc->mii_model == MII_MODEL_MARVELL_E1116) {
@@ -242,6 +254,13 @@ e1000phy_reset(struct mii_softc *sc)
case MII_MODEL_MARVELL_E1118:
case MII_MODEL_MARVELL_E1149:
break;
+   case MII_MODEL_MARVELL_E3016:
+   /* LED2 -> ACT, LED1 -> LINK, LED0 -> SPEED. */
+   PHY_WRITE(sc, 0x16, 0x0B << 8 | 0x05 << 4 | 0x04);
+   /* Integrated register calibration workaround. */
+   PHY_WRITE(sc, 0x1D, 17);
+   PHY_WRITE(sc, 0x1E, 0x3F60);
+   break;
default:
/* Force TX_CLK to 25MHz clock. */
reg = PHY_READ(sc, E1000_ESCR);

Modified: head/sys/dev/mii/e1000phyreg.h
==
--- head/sys/dev/mii/e1000phyreg.h  Mon May 25 02:09:09 2009
(r192712)
+++ head/sys/dev/mii/e1000phyreg.h  Mon May 25 02:36:29 2009
(r192713)
@@ -236,6 +236,16 @@
 #define E1000_SCR_TX_FIFO_DEPTH_10 0x8000
 #define E1000_SCR_TX_FIFO_DEPTH_12 0xC000
 
+/* 88E3016 only */
+#defineE1000_SCR_AUTO_MDIX 0x0030
+#defineE1000_SCR_SIGDET_POLARITY   0x0040
+#defineE1000_SCR_EXT_DISTANCE  0x0080
+#defineE1000_SCR_FEFI_DISABLE  0x0100
+#defineE1000_SCR_NLP_GEN_DISABLE   0x0800
+#defineE1000_SCR_LPNP  0x1000
+#defineE1000_SCR_NLP_CHK_DISABLE   0x2000
+#defineE1000_SCR_EN_DETECT 0x4000
+
 #define E1000_SCR_EN_DETECT_MASK   0x0300
 
 /* 88E1112 page 2 */

Modified: head/sys/dev/mii/miidevs
==
--- head/sy

svn commit: r192714 - in stable/7/sys/boot/i386: . gptzfsboot

2009-05-24 Thread Kip Macy
Author: kmacy
Date: Mon May 25 02:59:54 2009
New Revision: 192714
URL: http://svn.freebsd.org/changeset/base/192714

Log:
  import gptzfsboot

Added:
  stable/7/sys/boot/i386/gptzfsboot/
  stable/7/sys/boot/i386/gptzfsboot/Makefile   (contents, props changed)
Modified:
  stable/7/sys/boot/i386/Makefile

Modified: stable/7/sys/boot/i386/Makefile
==
--- stable/7/sys/boot/i386/Makefile Mon May 25 02:36:29 2009
(r192713)
+++ stable/7/sys/boot/i386/Makefile Mon May 25 02:59:54 2009
(r192714)
@@ -1,7 +1,7 @@
 # $FreeBSD$
 
 SUBDIR=mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot 
zfsboot \
-   kgzldr libi386 libfirewire loader
+   gptzfsboot kgzldr libi386 libfirewire loader
 
 # special boot programs, 'self-extracting boot2+loader'
 SUBDIR+=   pxeldr

Added: stable/7/sys/boot/i386/gptzfsboot/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/7/sys/boot/i386/gptzfsboot/Makefile  Mon May 25 02:59:54 2009
(r192714)
@@ -0,0 +1,74 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../gptboot ${.CURDIR}/../zfsboot
+
+FILES= gptzfsboot
+
+NM?=   nm
+
+BOOT_COMCONSOLE_PORT?= 0x3f8
+BOOT_COMCONSOLE_SPEED?= 9600
+B2SIOFMT?= 0x3
+
+REL1=  0x700
+ORG1=  0x7c00
+ORG2=  0x0
+
+CFLAGS=-Os \
+   -fno-guess-branch-probability \
+   -fomit-frame-pointer \
+   -fno-unit-at-a-time \
+   -mno-align-long-strings \
+   -mrtd \
+   -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \
+   -DGPT -DBOOT2 \
+   -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
+   -DSIOFMT=${B2SIOFMT} \
+   -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
+   -I${.CURDIR}/../../common \
+   -I${.CURDIR}/../../zfs \
+   -I${.CURDIR}/../../../cddl/boot/zfs \
+   -I${.CURDIR}/../btx/lib -I. \
+   -I${.CURDIR}/../boot2 \
+   -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
+   -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
+   -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
+   -Winline --param max-inline-insns-single=100
+
+LDFLAGS=-static -N --gc-sections
+
+# Pick up ../Makefile.inc early.
+.include 
+
+CLEANFILES=gptzfsboot
+
+gptzfsboot: gptldr.bin gptzfsboot.bin ${BTXKERN}
+   btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \
+   -o ${.TARGET} gptzfsboot.bin
+
+CLEANFILES+=   gptldr.bin gptldr.out gptldr.o
+
+gptldr.bin: gptldr.out
+   objcopy -S -O binary gptldr.out ${.TARGET}
+
+gptldr.out: gptldr.o
+   ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
+
+CLEANFILES+=   gptzfsboot.bin gptzfsboot.out zfsboot.o sio.o
+
+gptzfsboot.bin: gptzfsboot.out
+   objcopy -S -O binary gptzfsboot.out ${.TARGET}
+
+gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o
+   ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
+
+zfsboot.o: ${.CURDIR}/../../zfs/zfsimpl.c
+
+.if ${MACHINE_ARCH} == "amd64"
+beforedepend zfsboot.o: machine
+CLEANFILES+=   machine
+machine:
+   ln -sf ${.CURDIR}/../../../i386/include machine
+.endif
+
+.include 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192715 - stable/7/sys/boot/i386

2009-05-24 Thread Kip Macy
Author: kmacy
Date: Mon May 25 03:06:26 2009
New Revision: 192715
URL: http://svn.freebsd.org/changeset/base/192715

Log:
  don't try building zfsboot and gptzfsboot if zfs loader is not enabled

Modified:
  stable/7/sys/boot/i386/Makefile

Modified: stable/7/sys/boot/i386/Makefile
==
--- stable/7/sys/boot/i386/Makefile Mon May 25 02:59:54 2009
(r192714)
+++ stable/7/sys/boot/i386/Makefile Mon May 25 03:06:26 2009
(r192715)
@@ -1,7 +1,11 @@
 # $FreeBSD$
 
-SUBDIR=mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot 
zfsboot \
-   gptzfsboot kgzldr libi386 libfirewire loader
+SUBDIR=mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot \
+   kgzldr libi386 libfirewire loader
+
+.if defined(LOADER_ZFS_SUPPORT)
+SUBDIR+=   zfsboot gptzfsboot
+.endif
 
 # special boot programs, 'self-extracting boot2+loader'
 SUBDIR+=   pxeldr
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192716 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 03:24:47 2009
New Revision: 192716
URL: http://svn.freebsd.org/changeset/base/192716

Log:
  Remove link handling taskqueue and use mii callback directly. While
  I'm here also checks driver running state.

Modified:
  head/sys/dev/msk/if_msk.c
  head/sys/dev/msk/if_mskreg.h

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 03:06:26 2009(r192715)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 03:24:47 2009(r192716)
@@ -285,7 +285,6 @@ static int msk_phy_writereg(struct msk_i
 static int msk_miibus_readreg(device_t, int, int);
 static int msk_miibus_writereg(device_t, int, int, int);
 static void msk_miibus_statchg(device_t);
-static void msk_link_task(void *, int);
 
 static void msk_rxfilter(struct msk_if_softc *);
 static void msk_setvlan(struct msk_if_softc *, struct ifnet *);
@@ -459,32 +458,22 @@ msk_phy_writereg(struct msk_if_softc *sc
 static void
 msk_miibus_statchg(device_t dev)
 {
-   struct msk_if_softc *sc_if;
-
-   sc_if = device_get_softc(dev);
-   taskqueue_enqueue(taskqueue_swi, &sc_if->msk_link_task);
-}
-
-static void
-msk_link_task(void *arg, int pending)
-{
struct msk_softc *sc;
struct msk_if_softc *sc_if;
struct mii_data *mii;
struct ifnet *ifp;
uint32_t gmac;
 
-   sc_if = (struct msk_if_softc *)arg;
+   sc_if = device_get_softc(dev);
sc = sc_if->msk_softc;
 
MSK_IF_LOCK(sc_if);
 
mii = device_get_softc(sc_if->msk_miibus);
ifp = sc_if->msk_ifp;
-   if (mii == NULL || ifp == NULL) {
-   MSK_IF_UNLOCK(sc_if);
+   if (mii == NULL || ifp == NULL ||
+   (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
return;
-   }
 
if (mii->mii_media_status & IFM_ACTIVE) {
if (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE)
@@ -554,8 +543,6 @@ msk_link_task(void *arg, int pending)
/* Read again to ensure writing. */
GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL);
}
-
-   MSK_IF_UNLOCK(sc_if);
 }
 
 static void
@@ -1416,7 +1403,6 @@ msk_attach(device_t dev)
}
 
callout_init_mtx(&sc_if->msk_tick_ch, &sc_if->msk_softc->msk_mtx, 0);
-   TASK_INIT(&sc_if->msk_link_task, 0, msk_link_task, sc_if);
msk_sysctl_node(sc_if);
 
/* Disable jumbo frame for Yukon FE. */
@@ -1791,7 +1777,6 @@ msk_detach(device_t dev)
MSK_IF_UNLOCK(sc_if);
callout_drain(&sc_if->msk_tick_ch);
taskqueue_drain(taskqueue_fast, &sc_if->msk_tx_task);
-   taskqueue_drain(taskqueue_swi, &sc_if->msk_link_task);
ether_ifdetach(ifp);
MSK_IF_LOCK(sc_if);
}

Modified: head/sys/dev/msk/if_mskreg.h
==
--- head/sys/dev/msk/if_mskreg.hMon May 25 03:06:26 2009
(r192715)
+++ head/sys/dev/msk/if_mskreg.hMon May 25 03:24:47 2009
(r192716)
@@ -2395,7 +2395,6 @@ struct msk_if_softc {
struct msk_ring_datamsk_rdata;
struct msk_softc*msk_softc; /* parent controller */
struct msk_hw_stats msk_stats;
-   struct task msk_link_task;
struct task msk_tx_task;
int msk_if_flags;
int msk_detach;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192718 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 03:42:33 2009
New Revision: 192718
URL: http://svn.freebsd.org/changeset/base/192718

Log:
  Use bit definition to represent link state, device suspend instead
  of using separate variables in softc.

Modified:
  head/sys/dev/msk/if_msk.c
  head/sys/dev/msk/if_mskreg.h

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 03:41:40 2009(r192717)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 03:42:33 2009(r192718)
@@ -477,11 +477,11 @@ msk_miibus_statchg(device_t dev)
 
if (mii->mii_media_status & IFM_ACTIVE) {
if (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE)
-   sc_if->msk_link = 1;
+   sc_if->msk_flags |= MSK_FLAG_LINK;
} else
-   sc_if->msk_link = 0;
+   sc_if->msk_flags &= ~MSK_FLAG_LINK;
 
-   if (sc_if->msk_link != 0) {
+   if ((sc_if->msk_flags & MSK_FLAG_LINK) != 0) {
/* Enable Tx FIFO Underrun. */
CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_MSK),
GM_IS_TX_FF_UR | GM_IS_RX_FF_OR);
@@ -2626,7 +2626,7 @@ msk_start(struct ifnet *ifp)
MSK_IF_LOCK(sc_if);
 
if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
-   IFF_DRV_RUNNING || sc_if->msk_link == 0) {
+   IFF_DRV_RUNNING || (sc_if->msk_flags & MSK_FLAG_LINK) == 0) {
MSK_IF_UNLOCK(sc_if);
return;
}
@@ -2683,7 +2683,7 @@ msk_watchdog(struct msk_if_softc *sc_if)
if (sc_if->msk_watchdog_timer == 0 || --sc_if->msk_watchdog_timer)
return;
ifp = sc_if->msk_ifp;
-   if (sc_if->msk_link == 0) {
+   if ((sc_if->msk_flags & MSK_FLAG_LINK) == 0) {
if (bootverbose)
if_printf(sc_if->msk_ifp, "watchdog timeout "
   "(missed link)\n");
@@ -2770,7 +2770,7 @@ mskc_suspend(device_t dev)
 
/* Put hardware reset. */
CSR_WRITE_2(sc, B0_CTST, CS_RST_SET);
-   sc->msk_suspended = 1;
+   sc->msk_pflags |= MSK_FLAG_SUSPEND;
 
MSK_UNLOCK(sc);
 
@@ -2793,7 +2793,7 @@ mskc_resume(device_t dev)
((sc->msk_if[i]->msk_ifp->if_flags & IFF_UP) != 0))
msk_init_locked(sc->msk_if[i]);
}
-   sc->msk_suspended = 0;
+   sc->msk_pflags &= MSK_FLAG_SUSPEND;
 
MSK_UNLOCK(sc);
 
@@ -3306,7 +3306,8 @@ msk_legacy_intr(void *xsc)
 
/* Reading B0_Y2_SP_ISRC2 masks further interrupts. */
status = CSR_READ_4(sc, B0_Y2_SP_ISRC2);
-   if (status == 0 || status == 0x || sc->msk_suspended != 0 ||
+   if (status == 0 || status == 0x ||
+   (sc->msk_pflags & MSK_FLAG_SUSPEND) != 0 ||
(status & sc->msk_intrmask) == 0) {
CSR_WRITE_4(sc, B0_Y2_SP_ICR, 2);
return;
@@ -3393,7 +3394,8 @@ msk_int_task(void *arg, int pending)
 
/* Get interrupt source. */
status = CSR_READ_4(sc, B0_ISRC);
-   if (status == 0 || status == 0x || sc->msk_suspended != 0 ||
+   if (status == 0 || status == 0x ||
+   (sc->msk_pflags & MSK_FLAG_SUSPEND) != 0 ||
(status & sc->msk_intrmask) == 0)
goto done;
 
@@ -3675,7 +3677,7 @@ msk_init_locked(struct msk_if_softc *sc_
CSR_WRITE_4(sc, B0_IMSK, sc->msk_intrmask);
CSR_READ_4(sc, B0_IMSK);
 
-   sc_if->msk_link = 0;
+   sc_if->msk_flags &= ~MSK_FLAG_LINK;
mii_mediachg(mii);
 
ifp->if_drv_flags |= IFF_DRV_RUNNING;
@@ -3910,7 +3912,7 @@ msk_stop(struct msk_if_softc *sc_if)
 * Mark the interface down.
 */
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
-   sc_if->msk_link = 0;
+   sc_if->msk_flags &= ~MSK_FLAG_LINK;
 }
 
 /*

Modified: head/sys/dev/msk/if_mskreg.h
==
--- head/sys/dev/msk/if_mskreg.hMon May 25 03:41:40 2009
(r192717)
+++ head/sys/dev/msk/if_mskreg.hMon May 25 03:42:33 2009
(r192718)
@@ -2342,7 +2342,6 @@ struct msk_softc {
uint32_tmsk_intrmask;
uint32_tmsk_intrhwemask;
uint32_tmsk_pflags;
-   int msk_suspended;
int msk_clock;
int msk_msi;
struct msk_if_softc *msk_if[2];
@@ -2382,10 +2381,11 @@ struct msk_if_softc {
int msk_framesize;
int msk_phytype;
int msk_phyaddr;
-   int msk_link;
uint32_tmsk_flags;
 #defineMSK_FLAG_RAMBUF 0x0010
 #defineMSK_FLAG_NOJUMBO0x0020
+#defineMSK_FLAG_SUSPEND0x2000
+#

svn commit: r192719 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 03:49:43 2009
New Revision: 192719
URL: http://svn.freebsd.org/changeset/base/192719

Log:
  Use bit definition to represent MSI and detach state instead of
  using separate variables in softc.

Modified:
  head/sys/dev/msk/if_msk.c
  head/sys/dev/msk/if_mskreg.h

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 03:42:33 2009(r192718)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 03:49:43 2009(r192719)
@@ -923,7 +923,7 @@ msk_ioctl(struct ifnet *ifp, u_long comm
& (IFF_PROMISC | IFF_ALLMULTI)) != 0)
msk_rxfilter(sc_if);
} else {
-   if (sc_if->msk_detach == 0)
+   if ((sc_if->msk_flags & MSK_FLAG_DETACH) == 0)
msk_init_locked(sc_if);
}
} else {
@@ -1645,7 +1645,7 @@ mskc_attach(device_t dev)
if (sc->msk_num_port == 1 &&
pci_alloc_msi(dev, &msir) == 0) {
if (msic == msir) {
-   sc->msk_msi = 1;
+   sc->msk_pflags |= MSK_FLAG_MSI;
sc->msk_irq_spec = msic == 2 ?
msk_irq_spec_msi2 :
msk_irq_spec_msi;
@@ -1771,7 +1771,7 @@ msk_detach(device_t dev)
ifp = sc_if->msk_ifp;
if (device_is_attached(dev)) {
/* XXX */
-   sc_if->msk_detach = 1;
+   sc_if->msk_flags |= MSK_FLAG_DETACH;
msk_stop(sc_if);
/* Can't hold locks while calling detach. */
MSK_IF_UNLOCK(sc_if);
@@ -1855,7 +1855,7 @@ mskc_detach(device_t dev)
sc->msk_intrhand[1] = NULL;
}
bus_release_resources(dev, sc->msk_irq_spec, sc->msk_irq);
-   if (sc->msk_msi)
+   if ((sc->msk_pflags & MSK_FLAG_MSI) != 0)
pci_release_msi(dev);
bus_release_resources(dev, sc->msk_res_spec, sc->msk_res);
mtx_destroy(&sc->msk_mtx);

Modified: head/sys/dev/msk/if_mskreg.h
==
--- head/sys/dev/msk/if_mskreg.hMon May 25 03:42:33 2009
(r192718)
+++ head/sys/dev/msk/if_mskreg.hMon May 25 03:49:43 2009
(r192719)
@@ -2343,7 +2343,6 @@ struct msk_softc {
uint32_tmsk_intrhwemask;
uint32_tmsk_pflags;
int msk_clock;
-   int msk_msi;
struct msk_if_softc *msk_if[2];
device_tmsk_devs[2];
int msk_txqsize;
@@ -2382,9 +2381,11 @@ struct msk_if_softc {
int msk_phytype;
int msk_phyaddr;
uint32_tmsk_flags;
+#defineMSK_FLAG_MSI0x0001
 #defineMSK_FLAG_RAMBUF 0x0010
 #defineMSK_FLAG_NOJUMBO0x0020
 #defineMSK_FLAG_SUSPEND0x2000
+#defineMSK_FLAG_DETACH 0x4000
 #defineMSK_FLAG_LINK   0x8000
struct callout  msk_tick_ch;
int msk_watchdog_timer;
@@ -2397,7 +2398,6 @@ struct msk_if_softc {
struct msk_hw_stats msk_stats;
struct task msk_tx_task;
int msk_if_flags;
-   int msk_detach;
uint16_tmsk_vtag;   /* VLAN tag id. */
 };
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192720 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 03:53:12 2009
New Revision: 192720
URL: http://svn.freebsd.org/changeset/base/192720

Log:
  Correctly return the result of mii_mediachg(). Previously it always
  used to return success.

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 03:49:43 2009(r192719)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 03:53:12 2009(r192720)
@@ -856,15 +856,16 @@ msk_mediachange(struct ifnet *ifp)
 {
struct msk_if_softc *sc_if;
struct mii_data *mii;
+   int error;
 
sc_if = ifp->if_softc;
 
MSK_IF_LOCK(sc_if);
mii = device_get_softc(sc_if->msk_miibus);
-   mii_mediachg(mii);
+   error = mii_mediachg(mii);
MSK_IF_UNLOCK(sc_if);
 
-   return (0);
+   return (error);
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192721 - stable/7/usr.sbin/mergemaster

2009-05-24 Thread Doug Barton
Author: dougb
Date: Mon May 25 04:11:30 2009
New Revision: 192721
URL: http://svn.freebsd.org/changeset/base/192721

Log:
  MFC 192219:
  Add -L to the mtree invocation to chase symbolic links that are present
  in "Service jails."
  
  MFC 192230:
  Enhance the safety and efficiency of the -U option,
  fix indentation on one line.

Modified:
  stable/7/usr.sbin/mergemaster/mergemaster.sh

Modified: stable/7/usr.sbin/mergemaster/mergemaster.sh
==
--- stable/7/usr.sbin/mergemaster/mergemaster.shMon May 25 03:53:12 
2009(r192720)
+++ stable/7/usr.sbin/mergemaster/mergemaster.shMon May 25 04:11:30 
2009(r192721)
@@ -115,8 +115,10 @@ diff_loop () {
   while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o \
 "${HANDLE_COMPFILE}" = "NOT V" ]; do
 if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then
-  if [ -n "${AUTO_UPGRADE}" ]; then
-if echo "${CHANGED}" | grep -qsv ${DESTDIR}${COMPFILE#.}; then
+  if [ -n "${AUTO_UPGRADE}" -a -n "${CHANGED}" ]; then
+case "${CHANGED}" in
+*:${DESTDIR}${COMPFILE#.}:*) ;;# File has been modified
+*)
   echo ''
   echo "  *** ${COMPFILE} has not been user modified."
   echo ''
@@ -128,10 +130,11 @@ diff_loop () {
 AUTO_UPGRADED_FILES="${AUTO_UPGRADED_FILES}  
${DESTDIR}${COMPFILE#.}
 "
   else
-  echo "   *** Problem upgrading ${COMPFILE}, it will remain to merge 
by hand"
+echo "   *** Problem upgrading ${COMPFILE}, it will remain to 
merge by hand"
   fi
   return
-fi
+  ;;
+esac
   fi
   if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then
echo ''
@@ -348,7 +351,7 @@ fi
 case "${AUTO_UPGRADE}" in
 '') ;; # If the option is not set no need to run the test or warn the user
 *)
-  if [ ! -f "${DESTDIR}${MTREEFILE}" ]; then
+  if [ ! -s "${DESTDIR}${MTREEFILE}" ]; then
 echo ''
 echo "*** Unable to find mtree database. Skipping auto-upgrade."
 echo ''
@@ -459,14 +462,15 @@ MM_MAKE="make ${ARCHSTRING} -m ${SOURCED
 # Check DESTDIR against the mergemaster mtree database to see what
 # files the user changed from the reference files.
 #
-CHANGED=
-if [ -n "${AUTO_UPGRADE}" -a -f "${DESTDIR}${MTREEFILE}" ]; then
-   for file in `mtree -eq -f ${DESTDIR}${MTREEFILE} -p ${DESTDIR}/ \
+if [ -n "${AUTO_UPGRADE}" -a -s "${DESTDIR}${MTREEFILE}" ]; then
+   CHANGED=:
+   for file in `mtree -eqL -f ${DESTDIR}${MTREEFILE} -p ${DESTDIR}/ \
2>/dev/null | awk '($2 == "changed") {print $1}'`; do
if [ -f "${DESTDIR}/$file" ]; then
-   CHANGED="${CHANGED} ${DESTDIR}/$file"
+   CHANGED="${CHANGED}${DESTDIR}/${file}:"
fi
done
+   [ "$CHANGED" = ':' ] && unset CHANGED
 fi
 
 # Check the width of the user's terminal
@@ -1055,7 +1059,7 @@ done # This is for the for way up there 
 echo ''
 echo "*** Comparison complete"
 
-if [ -f "${MTREENEW}" ]; then
+if [ -s "${MTREENEW}" ]; then
   echo "*** Saving mtree database for future upgrades"
   test -e "${DESTDIR}${MTREEFILE}" && unlink ${DESTDIR}${MTREEFILE}
   mv ${MTREENEW} ${DESTDIR}${MTREEFILE}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192722 - stable/6/usr.sbin/mergemaster

2009-05-24 Thread Doug Barton
Author: dougb
Date: Mon May 25 04:13:06 2009
New Revision: 192722
URL: http://svn.freebsd.org/changeset/base/192722

Log:
  MFC 192219:
  Add -L to the mtree invocation to chase symbolic links that are present
  in "Service jails."
  
  MFC 192230:
  Enhance the safety and efficiency of the -U option,
  fix indentation on one line.

Modified:
  stable/6/usr.sbin/mergemaster/   (props changed)
  stable/6/usr.sbin/mergemaster/mergemaster.sh

Modified: stable/6/usr.sbin/mergemaster/mergemaster.sh
==
--- stable/6/usr.sbin/mergemaster/mergemaster.shMon May 25 04:11:30 
2009(r192721)
+++ stable/6/usr.sbin/mergemaster/mergemaster.shMon May 25 04:13:06 
2009(r192722)
@@ -115,8 +115,10 @@ diff_loop () {
   while [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" -o \
 "${HANDLE_COMPFILE}" = "NOT V" ]; do
 if [ -f "${DESTDIR}${COMPFILE#.}" -a -f "${COMPFILE}" ]; then
-  if [ -n "${AUTO_UPGRADE}" ]; then
-if echo "${CHANGED}" | grep -qsv ${DESTDIR}${COMPFILE#.}; then
+  if [ -n "${AUTO_UPGRADE}" -a -n "${CHANGED}" ]; then
+case "${CHANGED}" in
+*:${DESTDIR}${COMPFILE#.}:*) ;;# File has been modified
+*)
   echo ''
   echo "  *** ${COMPFILE} has not been user modified."
   echo ''
@@ -128,10 +130,11 @@ diff_loop () {
 AUTO_UPGRADED_FILES="${AUTO_UPGRADED_FILES}  
${DESTDIR}${COMPFILE#.}
 "
   else
-  echo "   *** Problem upgrading ${COMPFILE}, it will remain to merge 
by hand"
+echo "   *** Problem upgrading ${COMPFILE}, it will remain to 
merge by hand"
   fi
   return
-fi
+  ;;
+esac
   fi
   if [ "${HANDLE_COMPFILE}" = "v" -o "${HANDLE_COMPFILE}" = "V" ]; then
echo ''
@@ -348,7 +351,7 @@ fi
 case "${AUTO_UPGRADE}" in
 '') ;; # If the option is not set no need to run the test or warn the user
 *)
-  if [ ! -f "${DESTDIR}${MTREEFILE}" ]; then
+  if [ ! -s "${DESTDIR}${MTREEFILE}" ]; then
 echo ''
 echo "*** Unable to find mtree database. Skipping auto-upgrade."
 echo ''
@@ -459,14 +462,15 @@ MM_MAKE="make ${ARCHSTRING} -m ${SOURCED
 # Check DESTDIR against the mergemaster mtree database to see what
 # files the user changed from the reference files.
 #
-CHANGED=
-if [ -n "${AUTO_UPGRADE}" -a -f "${DESTDIR}${MTREEFILE}" ]; then
-   for file in `mtree -eq -f ${DESTDIR}${MTREEFILE} -p ${DESTDIR}/ \
+if [ -n "${AUTO_UPGRADE}" -a -s "${DESTDIR}${MTREEFILE}" ]; then
+   CHANGED=:
+   for file in `mtree -eqL -f ${DESTDIR}${MTREEFILE} -p ${DESTDIR}/ \
2>/dev/null | awk '($2 == "changed") {print $1}'`; do
if [ -f "${DESTDIR}/$file" ]; then
-   CHANGED="${CHANGED} ${DESTDIR}/$file"
+   CHANGED="${CHANGED}${DESTDIR}/${file}:"
fi
done
+   [ "$CHANGED" = ':' ] && unset CHANGED
 fi
 
 # Check the width of the user's terminal
@@ -1049,7 +1053,7 @@ done # This is for the for way up there 
 echo ''
 echo "*** Comparison complete"
 
-if [ -f "${MTREENEW}" ]; then
+if [ -s "${MTREENEW}" ]; then
   echo "*** Saving mtree database for future upgrades"
   test -e "${DESTDIR}${MTREEFILE}" && unlink ${DESTDIR}${MTREEFILE}
   mv ${MTREENEW} ${DESTDIR}${MTREEFILE}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192723 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 04:22:27 2009
New Revision: 192723
URL: http://svn.freebsd.org/changeset/base/192723

Log:
  Rather than checking every chip revision, introduce more flags to
  mark controller's capability. Controllers that have jumbo frame
  support sets MSK_FLAG_JUMBO, and controllers that does not support
  checksum offloading for jumbo frames will set MSK_FLAG_JUMBO_NOCSUM.
  For Fast Ethernet controllers it will set MSK_FLAG_FASTETHER and it
  would be used in link state handling.
  
  While here, disable Tx checksum offloading if jumbo frame is used
  on controllers that does not have Tx checksum offloading capability
  for jumbo frame(e.g. Yukon EC Ultra).

Modified:
  head/sys/dev/msk/if_msk.c
  head/sys/dev/msk/if_mskreg.h

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 04:13:06 2009(r192722)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 04:22:27 2009(r192723)
@@ -901,20 +901,29 @@ msk_ioctl(struct ifnet *ifp, u_long comm
 
switch(command) {
case SIOCSIFMTU:
+   MSK_IF_LOCK(sc_if);
if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN)
error = EINVAL;
else if (ifp->if_mtu != ifr->ifr_mtu) {
-   if ((sc_if->msk_flags & MSK_FLAG_NOJUMBO) != 0 &&
-   ifr->ifr_mtu > ETHERMTU)
-   error = EINVAL;
-   else {
-   MSK_IF_LOCK(sc_if);
-   ifp->if_mtu = ifr->ifr_mtu;
-   if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
-   msk_init_locked(sc_if);
-   MSK_IF_UNLOCK(sc_if);
+   if (ifr->ifr_mtu > ETHERMTU) {
+   if ((sc_if->msk_flags & MSK_FLAG_JUMBO) == 0) {
+   error = EINVAL;
+   MSK_IF_UNLOCK(sc_if);
+   break;
+   }
+   if ((sc_if->msk_flags &
+   MSK_FLAG_JUMBO_NOCSUM) != 0) {
+   ifp->if_hwassist &=
+   ~(MSK_CSUM_FEATURES | CSUM_TSO);
+   ifp->if_capenable &=
+   ~(IFCAP_TSO4 | IFCAP_TXCSUM);
+   VLAN_CAPABILITIES(ifp);
+   }
}
+   ifp->if_mtu = ifr->ifr_mtu;
+   msk_init_locked(sc_if);
}
+   MSK_IF_UNLOCK(sc_if);
break;
case SIOCSIFFLAGS:
MSK_IF_LOCK(sc_if);
@@ -971,11 +980,7 @@ msk_ioctl(struct ifnet *ifp, u_long comm
ifp->if_hwassist &= ~CSUM_TSO;
}
if (ifp->if_mtu > ETHERMTU &&
-   sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U) {
-   /*
-* In Yukon EC Ultra, TSO & checksum offload is not
-* supported for jumbo frame.
-*/
+   (sc_if->msk_flags & MSK_FLAG_JUMBO_NOCSUM) != 0) {
ifp->if_hwassist &= ~(MSK_CSUM_FEATURES | CSUM_TSO);
ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_TXCSUM);
}
@@ -1406,10 +1411,6 @@ msk_attach(device_t dev)
callout_init_mtx(&sc_if->msk_tick_ch, &sc_if->msk_softc->msk_mtx, 0);
msk_sysctl_node(sc_if);
 
-   /* Disable jumbo frame for Yukon FE. */
-   if (sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_FE)
-   sc_if->msk_flags |= MSK_FLAG_NOJUMBO;
-
if ((error = msk_txrx_dma_alloc(sc_if) != 0))
goto fail;
msk_rx_dma_jalloc(sc_if);
@@ -1609,14 +1610,20 @@ mskc_attach(device_t dev)
 
switch (sc->msk_hw_id) {
case CHIP_ID_YUKON_EC:
+   sc->msk_clock = 125;/* 125 Mhz */
+   sc->msk_pflags |= MSK_FLAG_JUMBO;
+   break;
case CHIP_ID_YUKON_EC_U:
sc->msk_clock = 125;/* 125 Mhz */
+   sc->msk_pflags |= MSK_FLAG_JUMBO | MSK_FLAG_JUMBO_NOCSUM;
break;
case CHIP_ID_YUKON_FE:
sc->msk_clock = 100;/* 100 Mhz */
+   sc->msk_pflags |= MSK_FLAG_FASTETHER;
break;
case CHIP_ID_YUKON_XL:
sc->msk_clock = 156;/* 156 Mhz */
+   sc->msk_pflags |= MSK_FLAG_JUMBO;
break;
default:
sc->msk_clock = 156;/* 156 Mhz */
@@ -2158,11 +2165,10 @@ msk_rx_dma_jalloc(struct msk_if_softc *s
bus_size_t rxalign;
 

svn commit: r192724 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 04:25:08 2009
New Revision: 192724
URL: http://svn.freebsd.org/changeset/base/192724

Log:
  Caller already hold a driver lock in mii callback, assert it.

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 04:22:27 2009(r192723)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 04:25:08 2009(r192724)
@@ -467,7 +467,7 @@ msk_miibus_statchg(device_t dev)
sc_if = device_get_softc(dev);
sc = sc_if->msk_softc;
 
-   MSK_IF_LOCK(sc_if);
+   MSK_IF_LOCK_ASSERT(sc_if);
 
mii = device_get_softc(sc_if->msk_miibus);
ifp = sc_if->msk_ifp;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192725 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 04:27:12 2009
New Revision: 192725
URL: http://svn.freebsd.org/changeset/base/192725

Log:
  Oops, add missing ~ operator.

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 04:25:08 2009(r192724)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 04:27:12 2009(r192725)
@@ -2800,7 +2800,7 @@ mskc_resume(device_t dev)
((sc->msk_if[i]->msk_ifp->if_flags & IFF_UP) != 0))
msk_init_locked(sc->msk_if[i]);
}
-   sc->msk_pflags &= MSK_FLAG_SUSPEND;
+   sc->msk_pflags &= ~MSK_FLAG_SUSPEND;
 
MSK_UNLOCK(sc);
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192726 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 06:09:18 2009
New Revision: 192726
URL: http://svn.freebsd.org/changeset/base/192726

Log:
  Add support for newer descriptor format. This format is used on
  Yukon FE+, Yukon Extreme and Yukon Supreme.

Modified:
  head/sys/dev/msk/if_msk.c
  head/sys/dev/msk/if_mskreg.h

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 04:27:12 2009(r192725)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 06:09:18 2009(r192726)
@@ -2399,7 +2399,8 @@ msk_encap(struct msk_if_softc *sc_if, st
 
tcp_offset = offset = 0;
m = *m_head;
-   if ((m->m_pkthdr.csum_flags & (MSK_CSUM_FEATURES | CSUM_TSO)) != 0) {
+   if ((sc_if->msk_flags & MSK_FLAG_DESCV2) == 0 &&
+   (m->m_pkthdr.csum_flags & (MSK_CSUM_FEATURES | CSUM_TSO)) != 0) {
/*
 * Since mbuf has no protocol specific structure information
 * in it we have to inspect protocol information here to
@@ -2526,11 +2527,18 @@ msk_encap(struct msk_if_softc *sc_if, st
 
/* Check TSO support. */
if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) {
-   tso_mtu = offset + m->m_pkthdr.tso_segsz;
+   if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0)
+   tso_mtu = m->m_pkthdr.tso_segsz;
+   else
+   tso_mtu = offset + m->m_pkthdr.tso_segsz;
if (tso_mtu != sc_if->msk_cdata.msk_tso_mtu) {
tx_le = &sc_if->msk_rdata.msk_tx_ring[prod];
tx_le->msk_addr = htole32(tso_mtu);
-   tx_le->msk_control = htole32(OP_LRGLEN | HW_OWNER);
+   if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0)
+   tx_le->msk_control = htole32(OP_MSS | HW_OWNER);
+   else
+   tx_le->msk_control =
+   htole32(OP_LRGLEN | HW_OWNER);
sc_if->msk_cdata.msk_tx_cnt++;
MSK_INC(prod, MSK_TX_RING_CNT);
sc_if->msk_cdata.msk_tso_mtu = tso_mtu;
@@ -2554,15 +2562,21 @@ msk_encap(struct msk_if_softc *sc_if, st
}
/* Check if we have to handle checksum offload. */
if (tso == 0 && (m->m_pkthdr.csum_flags & MSK_CSUM_FEATURES) != 0) {
-   tx_le = &sc_if->msk_rdata.msk_tx_ring[prod];
-   tx_le->msk_addr = htole32(((tcp_offset + m->m_pkthdr.csum_data)
-   & 0x) | ((uint32_t)tcp_offset << 16));
-   tx_le->msk_control = htole32(1 << 16 | (OP_TCPLISW | HW_OWNER));
-   control = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
-   if ((m->m_pkthdr.csum_flags & CSUM_UDP) != 0)
-   control |= UDPTCP;
-   sc_if->msk_cdata.msk_tx_cnt++;
-   MSK_INC(prod, MSK_TX_RING_CNT);
+   if ((sc_if->msk_flags & MSK_FLAG_DESCV2) != 0)
+   control |= CALSUM;
+   else {
+   tx_le = &sc_if->msk_rdata.msk_tx_ring[prod];
+   tx_le->msk_addr = htole32(((tcp_offset +
+   m->m_pkthdr.csum_data) & 0x) |
+   ((uint32_t)tcp_offset << 16));
+   tx_le->msk_control = htole32(1 << 16 |
+   (OP_TCPLISW | HW_OWNER));
+   control = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
+   if ((m->m_pkthdr.csum_flags & CSUM_UDP) != 0)
+   control |= UDPTCP;
+   sc_if->msk_cdata.msk_tx_cnt++;
+   MSK_INC(prod, MSK_TX_RING_CNT);
+   }
}
 
si = prod;

Modified: head/sys/dev/msk/if_mskreg.h
==
--- head/sys/dev/msk/if_mskreg.hMon May 25 04:27:12 2009
(r192725)
+++ head/sys/dev/msk/if_mskreg.hMon May 25 06:09:18 2009
(r192726)
@@ -2122,6 +2122,8 @@ struct msk_stat_desc {
 #define OP_ADDR64VLAN  (OP_ADDR64 | OP_VLAN)
 #define OP_LRGLEN  0x2400
 #define OP_LRGLENVLAN  (OP_LRGLEN | OP_VLAN)
+#define OP_MSS 0x2800
+#define OP_MSSVLAN (OP_MSS | OP_VLAN)
 #define OP_BUFFER  0x4000
 #define OP_PACKET  0x4100
 #define OP_LARGESEND   0x4300
@@ -2386,6 +2388,7 @@ struct msk_if_softc {
 #defineMSK_FLAG_JUMBO  0x0008
 #defineMSK_FLAG_JUMBO_NOCSUM   0x0010
 #defineMSK_FLAG_RAMBUF 0x0020
+#defineMSK_FLAG_DESCV2 0x0040
 #defineMSK_FLAG_SUSPEND0x2000
 #defineMSK_FLAG_DETACH 0x4000
 #defineMSK_FLAG_LINK   0x8000
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-sr

svn commit: r192727 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 06:19:36 2009
New Revision: 192727
URL: http://svn.freebsd.org/changeset/base/192727

Log:
  Explicitly check resolved speed/duplex. Just checking IFM_ACTIVE
  does not guarantee established link. Also 1000baseT link report for
  fast ethernet controller is not valid one so make sure gigabit link
  is allowed for this controller.
  Whenever we lost link, check whether Rx/Tx MACs were enabled. If both
  MAC are not active, do not try to disable it again.

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 06:09:18 2009(r192726)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 06:19:36 2009(r192727)
@@ -475,11 +475,25 @@ msk_miibus_statchg(device_t dev)
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
return;
 
-   if (mii->mii_media_status & IFM_ACTIVE) {
-   if (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE)
+   sc_if->msk_flags &= ~MSK_FLAG_LINK;
+   if ((mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) ==
+   (IFM_AVALID | IFM_ACTIVE)) {
+   switch (IFM_SUBTYPE(mii->mii_media_active)) {
+   case IFM_10_T:
+   case IFM_100_TX:
sc_if->msk_flags |= MSK_FLAG_LINK;
-   } else
-   sc_if->msk_flags &= ~MSK_FLAG_LINK;
+   break;
+   case IFM_1000_T:
+   case IFM_1000_SX:
+   case IFM_1000_LX:
+   case IFM_1000_CX:
+   if ((sc_if->msk_flags & MSK_FLAG_FASTETHER) == 0)
+   sc_if->msk_flags |= MSK_FLAG_LINK;
+   break;
+   default:
+   break;
+   }
+   }
 
if ((sc_if->msk_flags & MSK_FLAG_LINK) != 0) {
/* Enable Tx FIFO Underrun. */
@@ -538,10 +552,12 @@ msk_miibus_statchg(device_t dev)
msk_phy_writereg(sc_if, PHY_ADDR_MARV, PHY_MARV_INT_MASK, 0);
/* Disable Rx/Tx MAC. */
gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL);
-   gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
-   GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac);
-   /* Read again to ensure writing. */
-   GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL);
+   if ((GM_GPCR_RX_ENA | GM_GPCR_TX_ENA) != 0) {
+   gmac &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
+   GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac);
+   /* Read again to ensure writing. */
+   GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL);
+   }
}
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192728 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 06:29:02 2009
New Revision: 192728
URL: http://svn.freebsd.org/changeset/base/192728

Log:
  Disable HW WOL for Yukon EC Ultra. While I'm here use switch
  statement over if-else statement. This change will make it easy to
  add newer Yukon controllers.

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 06:19:36 2009(r192727)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 06:29:02 2009(r192728)
@@ -1080,7 +1080,7 @@ mskc_setup_rambuffer(struct msk_softc *s
 static void
 msk_phy_power(struct msk_softc *sc, int mode)
 {
-   uint32_t val;
+   uint32_t our, val;
int i;
 
switch (mode) {
@@ -1106,16 +1106,17 @@ msk_phy_power(struct msk_softc *sc, int 
 
val = pci_read_config(sc->msk_dev, PCI_OUR_REG_1, 4);
val &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
-   if (sc->msk_hw_id == CHIP_ID_YUKON_XL &&
-   sc->msk_hw_rev > CHIP_REV_YU_XL_A1) {
-   /* Deassert Low Power for 1st PHY. */
-   val |= PCI_Y2_PHY1_COMA;
-   if (sc->msk_num_port > 1)
-   val |= PCI_Y2_PHY2_COMA;
-   } else if (sc->msk_hw_id == CHIP_ID_YUKON_EC_U) {
-   uint32_t our;
-
-   CSR_WRITE_2(sc, B0_CTST, Y2_HW_WOL_ON);
+   switch (sc->msk_hw_id) {
+   case CHIP_ID_YUKON_XL:
+   if (sc->msk_hw_rev > CHIP_REV_YU_XL_A1) {
+   /* Deassert Low Power for 1st PHY. */
+   val |= PCI_Y2_PHY1_COMA;
+   if (sc->msk_num_port > 1)
+   val |= PCI_Y2_PHY2_COMA;
+   }
+   break;
+   case CHIP_ID_YUKON_EC_U:
+   CSR_WRITE_2(sc, B0_CTST, Y2_HW_WOL_OFF);
 
/* Enable all clocks. */
pci_write_config(sc->msk_dev, PCI_OUR_REG_3, 0, 4);
@@ -1126,6 +1127,9 @@ msk_phy_power(struct msk_softc *sc, int 
pci_write_config(sc->msk_dev, PCI_OUR_REG_4, our, 4);
/* Set to default value. */
pci_write_config(sc->msk_dev, PCI_OUR_REG_5, 0, 4);
+   break;
+   default:
+   break;
}
/* Release PHY from PowerDown/COMA mode. */
pci_write_config(sc->msk_dev, PCI_OUR_REG_1, val, 4);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192731 - head/sys/dev/msk

2009-05-24 Thread Pyun YongHyeon
Author: yongari
Date: Mon May 25 06:39:48 2009
New Revision: 192731
URL: http://svn.freebsd.org/changeset/base/192731

Log:
  Explicitly reset GMAC Controls and initialize GM_GP_CTRL register.
  The GM_GP_CTRL register may have stale content from previous link
  information so clearing it will make hardware update the register
  correctly when it established a valid link.
  While I'm here remove stale comment.

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon May 25 06:36:02 2009(r192730)
+++ head/sys/dev/msk/if_msk.c   Mon May 25 06:39:48 2009(r192731)
@@ -3535,18 +3535,16 @@ msk_init_locked(struct msk_if_softc *sc_
ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_TXCSUM);
}
 
+   /* GMAC Control reset. */
+   CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_RST_SET);
+   CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_RST_CLR);
+   CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_F_LOOPB_OFF);
+ 
/*
-* Initialize GMAC first.
-* Without this initialization, Rx MAC did not work as expected
-* and Rx MAC garbled status LEs and it resulted in out-of-order
-* or duplicated frame delivery which in turn showed very poor
-* Rx performance.(I had to write a packet analysis code that
-* could be embeded in driver to diagnose this issue.)
-* I've spent almost 2 months to fix this issue. If I have had
-* datasheet for Yukon II I wouldn't have encountered this. :-(
+* Initialize GMAC first such that speed/duplex/flow-control
+* parameters are renegotiated when interface is brought up.
 */
-   gmac = GM_GPCR_SPEED_100 | GM_GPCR_SPEED_1000 | GM_GPCR_DUP_FULL;
-   GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, gmac);
+   GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, 0);
 
/* Dummy read the Interrupt Source Register. */
CSR_READ_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_SRC));
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r192732 - head/usr.bin/sed

2009-05-24 Thread Brian Somers
Author: brian
Date: Mon May 25 06:45:33 2009
New Revision: 192732
URL: http://svn.freebsd.org/changeset/base/192732

Log:
  Implement "addr1,+N" ranges - not dissimilar to grep's -A switch.
  
  PR:   134856
  Submitted by: Jeremie Le Hen - jeremie at le-hen dot org

Modified:
  head/usr.bin/sed/compile.c
  head/usr.bin/sed/defs.h
  head/usr.bin/sed/process.c
  head/usr.bin/sed/sed.1

Modified: head/usr.bin/sed/compile.c
==
--- head/usr.bin/sed/compile.c  Mon May 25 06:39:48 2009(r192731)
+++ head/usr.bin/sed/compile.c  Mon May 25 06:45:33 2009(r192732)
@@ -181,7 +181,7 @@ semicolon:  EATSPACE();
if ((*link = cmd = malloc(sizeof(struct s_command))) == NULL)
err(1, "malloc");
link = &cmd->next;
-   cmd->nonsel = cmd->inrange = 0;
+   cmd->startline = cmd->nonsel = 0;
/* First parse the addresses */
naddr = 0;
 
@@ -775,6 +775,7 @@ compile_addr(char *p, struct s_addr *a)
 
icase = 0;
 
+   a->type = 0;
switch (*p) {
case '\\':  /* Context address */
++p;
@@ -798,10 +799,16 @@ compile_addr(char *p, struct s_addr *a)
case '$':   /* Last line */
a->type = AT_LAST;
return (p + 1);
+
+   case '+':   /* Relative line number */
+   a->type = AT_RELLINE;
+   p++;
+   /* FALLTHROUGH */
/* Line number */
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
-   a->type = AT_LINE;
+   if (a->type == 0)
+   a->type = AT_LINE;
a->u.l = strtol(p, &end, 10);
return (end);
default:

Modified: head/usr.bin/sed/defs.h
==
--- head/usr.bin/sed/defs.h Mon May 25 06:39:48 2009(r192731)
+++ head/usr.bin/sed/defs.h Mon May 25 06:45:33 2009(r192732)
@@ -38,8 +38,9 @@
  * Types of address specifications
  */
 enum e_atype {
-   AT_RE,  /* Line that match RE */
+   AT_RE   = 1,/* Line that match RE */
AT_LINE,/* Specific line */
+   AT_RELLINE, /* Relative line */
AT_LAST,/* Last line */
 };
 
@@ -91,6 +92,7 @@ struct s_tr {
 struct s_command {
struct s_command *next; /* Pointer to next command */
struct s_addr *a1, *a2; /* Start and end address */
+   u_long startline;   /* Start line number or zero */
char *t;/* Text for : a c i r w */
union {
struct s_command *c;/* Command(s) for b t { */
@@ -100,7 +102,6 @@ struct s_command {
} u;
char code;  /* Command code */
u_int nonsel:1; /* True if ! */
-   u_int inrange:1;/* True if in range */
 };
 
 /*

Modified: head/usr.bin/sed/process.c
==
--- head/usr.bin/sed/process.c  Mon May 25 06:39:48 2009(r192731)
+++ head/usr.bin/sed/process.c  Mon May 25 06:45:33 2009(r192732)
@@ -275,8 +275,8 @@ new:if (!nflag && !pd)
(a)->type == AT_LINE ? linenum == (a)->u.l : lastline())
 
 /*
- * Return TRUE if the command applies to the current line.  Sets the inrange
- * flag to process ranges.  Interprets the non-select (``!'') flag.
+ * Return TRUE if the command applies to the current line.  Sets the start
+ * line for process ranges.  Interprets the non-select (``!'') flag.
  */
 static __inline int
 applies(struct s_command *cp)
@@ -287,18 +287,22 @@ applies(struct s_command *cp)
if (cp->a1 == NULL && cp->a2 == NULL)
r = 1;
else if (cp->a2)
-   if (cp->inrange) {
+   if (cp->startline > 0) {
if (MATCH(cp->a2)) {
-   cp->inrange = 0;
+   cp->startline = 0;
lastaddr = 1;
r = 1;
-   } else if (cp->a2->type == AT_LINE &&
-  linenum > cp->a2->u.l) {
+   } else if (linenum - cp->startline <= cp->a2->u.l)
+   r = 1;
+   else if ((cp->a2->type == AT_LINE &&
+  linenum > cp->a2->u.l) ||
+