From 61871f77781057bd99cf509b946fe7d352e74309 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 27 Feb 2014 08:02:40 +0100 Subject: [PATCH 01/16] kernel: Remove {msg,sem,shm}sys() syscalls. They have become obsolete with the recent sysvipc userland work and are not implemented in userspace either. Thanks to marino for helping to verify that no packages were affected by this commit. Pointed-out-by: Mihai Carabas --- lib/libc/gen/Symbol.map | 1 - lib/libc/gen/semconfig.c | 11 ++-- lib/libc/gen/sysvipc_semctl.c | 7 ++- lib/libc/i386/sys/Makefile.inc | 2 +- lib/libc/sys/Symbol.map | 8 --- sys/kern/init_sysent.c | 6 +- sys/kern/syscalls.c | 6 +- sys/kern/syscalls.master | 11 +--- sys/kern/sysv_ipc.c | 6 -- sys/kern/sysv_msg.c | 33 ----------- sys/kern/sysv_sem.c | 31 ---------- sys/kern/sysv_shm.c | 105 --------------------------------- sys/sys/msg.h | 2 - sys/sys/sem.h | 2 - sys/sys/shm.h | 1 - sys/sys/syscall.h | 6 +- sys/sys/syscall.mk | 3 - sys/sys/sysproto.h | 33 ----------- sys/sys/sysunion.h | 3 - 19 files changed, 22 insertions(+), 255 deletions(-) diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 61a76a7226..7699258ca0 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -346,7 +346,6 @@ DF306.0 { semctl; semget; semop; - semsys; set_mcontext; setcontext; setdomainname; diff --git a/lib/libc/gen/semconfig.c b/lib/libc/gen/semconfig.c index 6f5a3077b5..921262103f 100644 --- a/lib/libc/gen/semconfig.c +++ b/lib/libc/gen/semconfig.c @@ -1,12 +1,11 @@ -/* - * $DragonFly: src/lib/libc/gen/semconfig.c,v 1.2 2005/11/13 00:07:42 swildner Exp $ - */ - #include #include #include -int semconfig(int cmd, int p1, int p2, int p3) +#include + +int +semconfig(int cmd, int p1, int p2, int p3) { - return (semsys(3, cmd, p1, p2, p3)); + return EINVAL; } diff --git a/lib/libc/gen/sysvipc_semctl.c b/lib/libc/gen/sysvipc_semctl.c index 032fda6a8a..74c2816cb9 100644 --- a/lib/libc/gen/sysvipc_semctl.c +++ b/lib/libc/gen/sysvipc_semctl.c @@ -2,18 +2,19 @@ #include #include #include -#include #include "sysvipc_sem.h" extern char sysvipc_userland; +extern int __sys___semctl(int, int, int, union semun *); int semctl(int semid, int semnum, int cmd, ...) { va_list ap; - union semun semun = {0}; + union semun semun = { 0 }; union semun *semun_ptr = NULL; + va_start(ap, cmd); if (cmd == IPC_SET || cmd == IPC_STAT || cmd == GETALL || cmd == SETVAL || cmd == SETALL) { @@ -24,5 +25,5 @@ semctl(int semid, int semnum, int cmd, ...) if (sysvipc_userland) return (sysvipc___semctl(semid, semnum, cmd, semun_ptr)); - return (semsys(0, semid, semnum, cmd, semun_ptr)); + return (__sys___semctl(semid, semnum, cmd, semun_ptr)); } diff --git a/lib/libc/i386/sys/Makefile.inc b/lib/libc/i386/sys/Makefile.inc index 85bf3cd719..558d35c225 100644 --- a/lib/libc/i386/sys/Makefile.inc +++ b/lib/libc/i386/sys/Makefile.inc @@ -8,7 +8,7 @@ MDASM= Ovfork.S brk.S cerror.S exect.S fork.S getcontext.S pipe.S ptrace.S \ reboot.S rfork.S sbrk.S setlogin.S sigreturn.S syscall.S # Don't generate default code for these syscalls: -NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \ +NOASM= break.o exit.o ftruncate.o getdomainname.o getlogin.o \ lseek.o mmap.o openbsd_poll.o semconfig.o setdomainname.o sstk.o \ truncate.o uname.o vfork.o yield.o fork.o diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index c6cc4951af..940e6f407a 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -153,7 +153,6 @@ DF306.0 { mq_unlink; msgctl; msync; - msgsys; munlock; munlockall; munmap; @@ -225,7 +224,6 @@ DF306.0 { shmctl; shmdt; shmget; - shmsys; shutdown; sigaction; sigaltstack; @@ -450,7 +448,6 @@ DFprivate_1.0 { __sys_mq_timedreceive; __sys_mq_timedsend; __sys_mq_unlink; - __sys_msgsys; __sys_msync; __sys_munlock; __sys_munlockall; @@ -491,7 +488,6 @@ DFprivate_1.0 { __sys_sched_setscheduler; __sys_sched_yield; __sys_select; - __sys_semsys; __sys_sendfile; __sys_sendmsg; __sys_sendto; @@ -517,7 +513,6 @@ DFprivate_1.0 { __sys_shmctl; __sys_shmdt; __sys_shmget; - __sys_shmsys; __sys_shutdown; __sys_sigaction; __sys_sigaltstack; @@ -735,7 +730,6 @@ DFprivate_1.0 { _mq_timedreceive; _mq_timedsend; _mq_unlink; - _msgsys; _msync; _munlock; _munlockall; @@ -786,7 +780,6 @@ DFprivate_1.0 { _sem_trywait; _sem_unlink; _sem_wait; - _semsys; _sendfile; _sendmsg; _sendto; @@ -812,7 +805,6 @@ DFprivate_1.0 { _shmctl; _shmdt; _shmget; - _shmsys; _shutdown; _sigaction; _sigaltstack; diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c index 6de4d6acf5..0951244014 100644 --- a/sys/kern/init_sysent.c +++ b/sys/kern/init_sysent.c @@ -205,9 +205,9 @@ struct sysent sysent[] = { { AS(rtprio_args), (sy_call_t *)sys_rtprio }, /* 166 = rtprio */ { 0, (sy_call_t *)sys_nosys }, /* 167 = nosys */ { 0, (sy_call_t *)sys_nosys }, /* 168 = nosys */ - { AS(semsys_args), (sy_call_t *)sys_semsys }, /* 169 = semsys */ - { AS(msgsys_args), (sy_call_t *)sys_msgsys }, /* 170 = msgsys */ - { AS(shmsys_args), (sy_call_t *)sys_shmsys }, /* 171 = shmsys */ + { 0, (sy_call_t *)sys_nosys }, /* 169 = obsolete semsys */ + { 0, (sy_call_t *)sys_nosys }, /* 170 = obsolete msgsys */ + { 0, (sy_call_t *)sys_nosys }, /* 171 = obsolete shmsys */ { 0, (sy_call_t *)sys_nosys }, /* 172 = nosys */ { AS(extpread_args), (sy_call_t *)sys_extpread }, /* 173 = extpread */ { AS(extpwrite_args), (sy_call_t *)sys_extpwrite }, /* 174 = extpwrite */ diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c index 021bd267ca..62ad164be2 100644 --- a/sys/kern/syscalls.c +++ b/sys/kern/syscalls.c @@ -177,9 +177,9 @@ const char *syscallnames[] = { "rtprio", /* 166 = rtprio */ "#167", /* 167 = nosys */ "#168", /* 168 = nosys */ - "semsys", /* 169 = semsys */ - "msgsys", /* 170 = msgsys */ - "shmsys", /* 171 = shmsys */ + "obs_semsys", /* 169 = obsolete semsys */ + "obs_msgsys", /* 170 = obsolete msgsys */ + "obs_shmsys", /* 171 = obsolete shmsys */ "#172", /* 172 = nosys */ "extpread", /* 173 = extpread */ "extpwrite", /* 174 = extpwrite */ diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index e3b91492fc..141056e4a6 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -265,14 +265,9 @@ struct rtprio *rtp); } 167 UNIMPL nosys 168 UNIMPL nosys -169 STD { int semsys(int which, int a2, int a3, int a4, \ - int a5); } -; XXX should be { int semsys(int which, ...); } -170 STD { int msgsys(int which, int a2, int a3, int a4, \ - int a5, int a6); } -; XXX should be { int msgsys(int which, ...); } -171 STD { int shmsys(int which, int a2, int a3, int a4); } -; XXX should be { int shmsys(int which, ...); } +169 OBSOL semsys +170 OBSOL msgsys +171 OBSOL shmsys 172 UNIMPL nosys 173 STD { ssize_t extpread(int fd, void *buf, \ size_t nbyte, int flags, off_t offset); } diff --git a/sys/kern/sysv_ipc.c b/sys/kern/sysv_ipc.c index 203d0823dd..fd1044741d 100644 --- a/sys/kern/sysv_ipc.c +++ b/sys/kern/sysv_ipc.c @@ -1,5 +1,4 @@ /* $FreeBSD: src/sys/kern/sysv_ipc.c,v 1.13.2.2 2000/07/01 14:33:49 bsd Exp $ */ -/* $DragonFly: src/sys/kern/sysv_ipc.c,v 1.8 2005/10/08 14:31:26 corecode Exp $ */ /* $NetBSD: sysv_ipc.c,v 1.7 1994/06/29 06:33:11 cgd Exp $ */ /* @@ -107,7 +106,6 @@ sysv_nosys(char *s) * SYSVSEM stubs */ -SYSCALL_NOT_PRESENT_GEN(semsys, "SYSVSEM"); SYSCALL_NOT_PRESENT_GEN(__semctl, "SYSVSEM"); SYSCALL_NOT_PRESENT_GEN(semget, "SYSVSEM"); SYSCALL_NOT_PRESENT_GEN(semop, "SYSVSEM"); @@ -126,11 +124,8 @@ semexit(struct proc *p) /* * SYSVMSG stubs - * - * note: msgsys args actually var-args? YYYY */ -SYSCALL_NOT_PRESENT_GEN(msgsys, "SYSVMSG"); SYSCALL_NOT_PRESENT_GEN(msgctl, "SYSVMSG"); SYSCALL_NOT_PRESENT_GEN(msgget, "SYSVMSG"); SYSCALL_NOT_PRESENT_GEN(msgsnd, "SYSVMSG"); @@ -149,7 +144,6 @@ SYSCALL_NOT_PRESENT_GEN(shmdt, "SYSVSHM"); SYSCALL_NOT_PRESENT_GEN(shmat, "SYSVSHM"); SYSCALL_NOT_PRESENT_GEN(shmctl, "SYSVSHM"); SYSCALL_NOT_PRESENT_GEN(shmget, "SYSVSHM"); -SYSCALL_NOT_PRESENT_GEN(shmsys, "SYSVSHM"); /* called from kern_fork.c */ void diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index e0003a9f76..cd9709fbc5 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -44,12 +44,6 @@ static void msginit (void *); static void msg_freehdr (struct msg *msghdr); -/* XXX casting to (sy_call_t *) is bogus, as usual. */ -static sy_call_t *msgcalls[] = { - (sy_call_t *)sys_msgctl, (sy_call_t *)sys_msgget, - (sy_call_t *)sys_msgsnd, (sy_call_t *)sys_msgrcv -}; - struct msg { struct msg *msg_next; /* next msg in the chain */ long msg_type; /* type of this message */ @@ -180,33 +174,6 @@ msginit(void *dummy) } SYSINIT(sysv_msg, SI_SUB_SYSV_MSG, SI_ORDER_FIRST, msginit, NULL) -/* - * Entry point for all MSG calls - * - * msgsys_args(int which, int a2, ...) (VARARGS) - * - * MPALMOSTSAFE - */ -int -sys_msgsys(struct msgsys_args *uap) -{ - struct thread *td = curthread; - unsigned int which = (unsigned int)uap->which; - int error; - - if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL) - return (ENOSYS); - - if (which >= NELEM(msgcalls)) - return (EINVAL); - bcopy(&uap->a2, &uap->which, - sizeof(struct msgsys_args) - offsetof(struct msgsys_args, a2)); - get_mplock(); - error = (*msgcalls[which])(uap); - rel_mplock(); - return (error); -} - static void msg_freehdr(struct msg *msghdr) { diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index addc6edeb6..c8c1d1f52b 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -32,12 +32,6 @@ static struct sem_undo *semu_alloc (struct proc *p); static int semundo_adjust (struct proc *p, int semid, int semnum, int adjval); static void semundo_clear (int semid, int semnum); -/* XXX casting to (sy_call_t *) is bogus, as usual. */ -static sy_call_t *semcalls[] = { - (sy_call_t *)sys___semctl, (sy_call_t *)sys_semget, - (sy_call_t *)sys_semop -}; - static struct lwkt_token semu_token = LWKT_TOKEN_INITIALIZER(semu_token); static int semtot = 0; static struct semid_pool *sema; /* semaphore id pool */ @@ -188,31 +182,6 @@ seminit(void *dummy) } SYSINIT(sysv_sem, SI_SUB_SYSV_SEM, SI_ORDER_FIRST, seminit, NULL) -/* - * Entry point for all SEM calls - * - * semsys_args(int which, a2, a3, ...) (VARARGS) - * - * MPALMOSTSAFE - */ -int -sys_semsys(struct semsys_args *uap) -{ - struct thread *td = curthread; - unsigned int which = (unsigned int)uap->which; - int error; - - if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL) - return (ENOSYS); - - if (which >= NELEM(semcalls)) - return (EINVAL); - bcopy(&uap->a2, &uap->which, - sizeof(struct semsys_args) - offsetof(struct semsys_args, a2)); - error = (*semcalls[which])(uap); - return (error); -} - /* * Allocate a new sem_undo structure for a process * (returns ptr to structure or NULL if no more room) diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index a399271056..8edd773614 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -57,19 +57,9 @@ static MALLOC_DEFINE(M_SHM, "shm", "SVID compatible shared memory segments"); -struct oshmctl_args; -static int sys_oshmctl (struct proc *p, struct oshmctl_args *uap); - static int shmget_allocate_segment (struct proc *p, struct shmget_args *uap, int mode); static int shmget_existing (struct proc *p, struct shmget_args *uap, int mode, int segnum); -/* XXX casting to (sy_call_t *) is bogus, as usual. */ -static sy_call_t *shmcalls[] = { - (sy_call_t *)sys_shmat, (sy_call_t *)sys_oshmctl, - (sy_call_t *)sys_shmdt, (sy_call_t *)sys_shmget, - (sy_call_t *)sys_shmctl -}; - #define SHMSEG_FREE 0x0200 #define SHMSEG_REMOVED 0x0400 #define SHMSEG_ALLOCATED 0x0800 @@ -368,75 +358,6 @@ done: return error; } -struct oshmid_ds { - struct ipc_perm shm_perm; /* operation perms */ - int shm_segsz; /* size of segment (bytes) */ - ushort shm_cpid; /* pid, creator */ - ushort shm_lpid; /* pid, last operation */ - short shm_nattch; /* no. of current attaches */ - time_t shm_atime; /* last attach time */ - time_t shm_dtime; /* last detach time */ - time_t shm_ctime; /* last change time */ - void *shm_handle; /* internal handle for shm segment */ -}; - -struct oshmctl_args { - struct sysmsg sysmsg; - int shmid; - int cmd; - struct oshmid_ds *ubuf; -}; - -/* - * MPALMOSTSAFE - */ -static int -sys_oshmctl(struct proc *p, struct oshmctl_args *uap) -{ -#ifdef COMPAT_43 - struct thread *td = curthread; - struct shmid_ds *shmseg; - struct oshmid_ds outbuf; - int error; - - if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL) - return (ENOSYS); - - get_mplock(); - shmseg = shm_find_segment_by_shmid(uap->shmid); - if (shmseg == NULL) { - error = EINVAL; - goto done; - } - - switch (uap->cmd) { - case IPC_STAT: - error = ipcperm(p, &shmseg->shm_perm, IPC_R); - if (error) - break; - outbuf.shm_perm = shmseg->shm_perm; - outbuf.shm_segsz = shmseg->shm_segsz; - outbuf.shm_cpid = shmseg->shm_cpid; - outbuf.shm_lpid = shmseg->shm_lpid; - outbuf.shm_nattch = shmseg->shm_nattch; - outbuf.shm_atime = shmseg->shm_atime; - outbuf.shm_dtime = shmseg->shm_dtime; - outbuf.shm_ctime = shmseg->shm_ctime; - outbuf.shm_handle = shmseg->shm_internal; - error = copyout((caddr_t)&outbuf, uap->ubuf, sizeof(outbuf)); - break; - default: - /* XXX casting to (sy_call_t *) is bogus, as usual. */ - error = sys_shmctl((struct shmctl_args *)uap); - } -done: - rel_mplock(); - return error; -#else - return EINVAL; -#endif -} - /* * MPALMOSTSAFE */ @@ -679,32 +600,6 @@ done: return (error); } -/* - * shmsys_args(int which, int a2, ...) (VARARGS) - * - * MPALMOSTSAFE - */ -int -sys_shmsys(struct shmsys_args *uap) -{ - struct thread *td = curthread; - unsigned int which = (unsigned int)uap->which; - int error; - - if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL) - return (ENOSYS); - - if (which >= NELEM(shmcalls)) - return EINVAL; - get_mplock(); - bcopy(&uap->a2, &uap->which, - sizeof(struct shmsys_args) - offsetof(struct shmsys_args, a2)); - error = ((*shmcalls[which])(uap)); - rel_mplock(); - - return(error); -} - void shmfork(struct proc *p1, struct proc *p2) { diff --git a/sys/sys/msg.h b/sys/sys/msg.h index 7542dc43f5..1fa89af1fb 100644 --- a/sys/sys/msg.h +++ b/sys/sys/msg.h @@ -1,5 +1,4 @@ /* $FreeBSD: src/sys/sys/msg.h,v 1.10.2.1 2000/08/04 22:31:10 peter Exp $ */ -/* $DragonFly: src/sys/sys/msg.h,v 1.4 2003/08/27 02:03:22 dillon Exp $ */ /* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */ /* @@ -105,7 +104,6 @@ extern struct msginfo msginfo; #include __BEGIN_DECLS -int msgsys (int, ...); int msgctl (int, int, struct msqid_ds *); int msgget (key_t, int); int msgsnd (int, void *, size_t, int); diff --git a/sys/sys/sem.h b/sys/sys/sem.h index 6dca474c33..0549f5ae2c 100644 --- a/sys/sys/sem.h +++ b/sys/sys/sem.h @@ -1,5 +1,4 @@ /* $FreeBSD: src/sys/sys/sem.h,v 1.20.2.2 2000/08/04 22:31:10 peter Exp $ */ -/* $DragonFly: src/sys/sys/sem.h,v 1.4 2003/08/27 02:03:22 dillon Exp $ */ /* $NetBSD: sem.h,v 1.5 1994/06/29 06:45:15 cgd Exp $ */ /* @@ -117,7 +116,6 @@ extern struct seminfo seminfo; #include __BEGIN_DECLS -int semsys (int, ...); int semctl (int, int, int, ...); int semget (key_t, int, int); int semop (int, struct sembuf *,unsigned); diff --git a/sys/sys/shm.h b/sys/sys/shm.h index 1c9ccbb3d6..8bfc58ab20 100644 --- a/sys/sys/shm.h +++ b/sys/sys/shm.h @@ -95,7 +95,6 @@ void shmfork (struct proc *, struct proc *); #include __BEGIN_DECLS -int shmsys (int, ...); int shmget (key_t, size_t, int); int shmctl (int, int, struct shmid_ds *); void *shmat (int, const void *, int); diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index c04cce2de2..0cf2913bca 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -163,9 +163,9 @@ #define SYS_uname 164 #define SYS_sysarch 165 #define SYS_rtprio 166 -#define SYS_semsys 169 -#define SYS_msgsys 170 -#define SYS_shmsys 171 + /* 169 is obsolete semsys */ + /* 170 is obsolete msgsys */ + /* 171 is obsolete shmsys */ #define SYS_extpread 173 #define SYS_extpwrite 174 #define SYS_ntp_adjtime 176 diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk index 4f48f174ee..16e6f926f3 100644 --- a/sys/sys/syscall.mk +++ b/sys/sys/syscall.mk @@ -114,9 +114,6 @@ MIASM = \ uname.o \ sysarch.o \ rtprio.o \ - semsys.o \ - msgsys.o \ - shmsys.o \ extpread.o \ extpwrite.o \ ntp_adjtime.o \ diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h index a696e4ea0a..61acfd0372 100644 --- a/sys/sys/sysproto.h +++ b/sys/sys/sysproto.h @@ -858,36 +858,6 @@ struct rtprio_args { pid_t pid; char pid_[PAD_(pid_t)]; struct rtprio * rtp; char rtp_[PAD_(struct rtprio *)]; }; -struct semsys_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - int which; char which_[PAD_(int)]; - int a2; char a2_[PAD_(int)]; - int a3; char a3_[PAD_(int)]; - int a4; char a4_[PAD_(int)]; - int a5; char a5_[PAD_(int)]; -}; -struct msgsys_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - int which; char which_[PAD_(int)]; - int a2; char a2_[PAD_(int)]; - int a3; char a3_[PAD_(int)]; - int a4; char a4_[PAD_(int)]; - int a5; char a5_[PAD_(int)]; - int a6; char a6_[PAD_(int)]; -}; -struct shmsys_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - int which; char which_[PAD_(int)]; - int a2; char a2_[PAD_(int)]; - int a3; char a3_[PAD_(int)]; - int a4; char a4_[PAD_(int)]; -}; struct extpread_args { #ifdef _KERNEL struct sysmsg sysmsg; @@ -2717,9 +2687,6 @@ int sys_setdomainname (struct setdomainname_args *); int sys_uname (struct uname_args *); int sys_sysarch (struct sysarch_args *); int sys_rtprio (struct rtprio_args *); -int sys_semsys (struct semsys_args *); -int sys_msgsys (struct msgsys_args *); -int sys_shmsys (struct shmsys_args *); int sys_extpread (struct extpread_args *); int sys_extpwrite (struct extpwrite_args *); int sys_ntp_adjtime (struct ntp_adjtime_args *); diff --git a/sys/sys/sysunion.h b/sys/sys/sysunion.h index f9acb9fa0f..4cef34a024 100644 --- a/sys/sys/sysunion.h +++ b/sys/sys/sysunion.h @@ -206,9 +206,6 @@ union sysunion { struct uname_args uname; struct sysarch_args sysarch; struct rtprio_args rtprio; - struct semsys_args semsys; - struct msgsys_args msgsys; - struct shmsys_args shmsys; struct extpread_args extpread; struct extpwrite_args extpwrite; struct ntp_adjtime_args ntp_adjtime; -- 2.41.0 From 173c3351fa2e30d86778607158eeba185c411788 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Thu, 27 Feb 2014 01:08:26 +0100 Subject: [PATCH 02/16] kernel/ntfs - Fix a possible problem in bufcache. - Avoid different block size bread() calls for the same blkno. - Fix a bug in the code handling holes which could cause infinite loops. Taken-from: FreeBSD's r116620 --- sys/vfs/ntfs/ntfs_subr.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/vfs/ntfs/ntfs_subr.c b/sys/vfs/ntfs/ntfs_subr.c index 9d74fc128e..87836e8886 100644 --- a/sys/vfs/ntfs/ntfs_subr.c +++ b/sys/vfs/ntfs/ntfs_subr.c @@ -1509,6 +1509,19 @@ ntfs_readntvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, min(ntfs_cntob(ccl) - off, MAXBSIZE - off)); cl = ntfs_btocl(tocopy + off); + + /* If 'off' pushes us to next + * block, don't attempt to read whole + * 'tocopy' at once. This is to avoid + * bread() with varying 'size' for + * same 'blkno', which is not good. + */ + if (cl > ntfs_btocl(tocopy)) { + tocopy -= + ntfs_btocnoff(tocopy + off); + cl--; + } + ddprintf(("ntfs_readntvattr_plain: " \ "read: cn: 0x%x cl: %d, " \ "off: %d len: %d, left: %d\n", @@ -1552,7 +1565,7 @@ ntfs_readntvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, off = 0; if (uio) { size_t remains = tocopy; - for(; remains; remains++) + for(; remains; remains--) uiomove("", 1, uio); } else bzero(data, tocopy); -- 2.41.0 From b07e7f2d79769cda3f2b3b080cafdf14df7e4a8b Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Thu, 27 Feb 2014 21:26:49 +0100 Subject: [PATCH 03/16] kernel/ntfs - Fix buffer overlapping problems. - Read only one cluster at a time. - Do not cache boot block. Taken-from: FreeBSD's r118035 Dragonfly-bug: (Commit refs #2388 and fixes #1853) --- sys/vfs/ntfs/ntfs_subr.c | 33 +++++++++++++++++++++------------ sys/vfs/ntfs/ntfs_vfsops.c | 10 +++++++++- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/sys/vfs/ntfs/ntfs_subr.c b/sys/vfs/ntfs/ntfs_subr.c index 87836e8886..82af7be345 100644 --- a/sys/vfs/ntfs/ntfs_subr.c +++ b/sys/vfs/ntfs/ntfs_subr.c @@ -1412,9 +1412,16 @@ ntfs_writentvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, off = ntfs_btocnoff(off); while (left && ccl) { - tocopy = min(left, - min(ntfs_cntob(ccl) - off, MAXBSIZE - off)); + /* + * Always read and write single clusters at a time - + * we need to avoid requesting differently-sized + * blocks at the same disk offsets to avoid + * confusing the buffer cache. + */ + tocopy = min(left, ntfs_cntob(1) - off); cl = ntfs_btocl(tocopy + off); + KASSERT(cl == 1 && tocopy <= ntfs_cntob(1), + ("single cluster limit mistake")); ddprintf(("ntfs_writentvattr_plain: write: " \ "cn: 0x%x cl: %d, off: %d len: %d, left: %d\n", (u_int32_t) cn, (u_int32_t) cl, @@ -1510,17 +1517,19 @@ ntfs_readntvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, MAXBSIZE - off)); cl = ntfs_btocl(tocopy + off); - /* If 'off' pushes us to next - * block, don't attempt to read whole - * 'tocopy' at once. This is to avoid - * bread() with varying 'size' for - * same 'blkno', which is not good. + /* + * Always read single clusters at a + * time - we need to avoid reading + * differently-sized blocks at the + * same disk offsets to avoid + * confusing the buffer cache. */ - if (cl > ntfs_btocl(tocopy)) { - tocopy -= - ntfs_btocnoff(tocopy + off); - cl--; - } + tocopy = min(left, + ntfs_cntob(1) - off); + cl = ntfs_btocl(tocopy + off); + KASSERT(cl == 1 && + tocopy <= ntfs_cntob(1), + ("single cluster limit mistake")); ddprintf(("ntfs_readntvattr_plain: " \ "read: cn: 0x%x cl: %d, " \ diff --git a/sys/vfs/ntfs/ntfs_vfsops.c b/sys/vfs/ntfs/ntfs_vfsops.c index d693e028b7..2e37daf1de 100644 --- a/sys/vfs/ntfs/ntfs_vfsops.c +++ b/sys/vfs/ntfs/ntfs_vfsops.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/ntfs/ntfs_vfsops.c,v 1.20.2.5 2001/12/25 01:44:45 dillon Exp $ + * $FreeBSD: src/sys/ntfs/ntfs_subr.c,v 1.7.2.4 2001/10/12 22:08:49 semenu Exp $ */ @@ -329,6 +329,14 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp, goto out; ntmp = kmalloc(sizeof *ntmp, M_NTFSMNT, M_WAITOK | M_ZERO); bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) ); + /* + * We must not cache the boot block if its size is not exactly + * one cluster in order to avoid confusing the buffer cache when + * the boot file is read later by ntfs_readntvattr_plain(), which + * reads a cluster at a time. + */ + if (ntfs_cntob(1) != BBSIZE) + bp->b_flags |= B_NOCACHE; brelse( bp ); bp = NULL; -- 2.41.0 From e669f13b93440ec932aba858ed83a187c35b4cc9 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Thu, 27 Feb 2014 21:45:56 +0100 Subject: [PATCH 04/16] kernel/ntfs - Remove a forgotten #if defined --- sys/vfs/ntfs/ntfs_vnops.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/vfs/ntfs/ntfs_vnops.c b/sys/vfs/ntfs/ntfs_vnops.c index e8fb78a631..36706f17b4 100644 --- a/sys/vfs/ntfs/ntfs_vnops.c +++ b/sys/vfs/ntfs/ntfs_vnops.c @@ -725,7 +725,6 @@ ntfs_lookup(struct vop_old_lookup_args *ap) return (error); } -#if defined(__DragonFly__) /* * Flush the blocks of a file to disk. * @@ -739,7 +738,6 @@ ntfs_fsync(struct vop_fsync_args *ap) { return (0); } -#endif /* * Return POSIX pathconf information applicable to NTFS filesystem -- 2.41.0 From 9581b82e394de41d36d060987c67d4de7999ab80 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Fri, 28 Feb 2014 09:35:56 +0100 Subject: [PATCH 05/16] libsmb: Bump WARNS to 2 and fix a warning. --- contrib/smbfs/lib/smb/rcfile.c | 2 +- lib/libsmb/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/smbfs/lib/smb/rcfile.c b/contrib/smbfs/lib/smb/rcfile.c index 79f6bd75a0..3a03e5c526 100644 --- a/contrib/smbfs/lib/smb/rcfile.c +++ b/contrib/smbfs/lib/smb/rcfile.c @@ -344,7 +344,7 @@ rc_getstring(struct rcfile *rcp, const char *section, const char *key, if (error) return error; if (strlen(value) >= maxlen) { - warnx("line too long for key '%s' in section '%s', max = %d\n", key, section, maxlen); + warnx("line too long for key '%s' in section '%s', max = %zu\n", key, section, maxlen); return EINVAL; } strcpy(dest, value); diff --git a/lib/libsmb/Makefile b/lib/libsmb/Makefile index 9566998b97..ca7bc77fb1 100644 --- a/lib/libsmb/Makefile +++ b/lib/libsmb/Makefile @@ -2,7 +2,7 @@ LIB= smb -WARNS?= 1 +WARNS?= 2 SHLIB_MAJOR= 2 -- 2.41.0 From 0612e99a9b0f809b4fba82962748b4783901bc31 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Fri, 28 Feb 2014 09:39:35 +0100 Subject: [PATCH 06/16] rtadvt(8): Bump WARNS to 2. --- usr.sbin/rtadvd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/rtadvd/Makefile b/usr.sbin/rtadvd/Makefile index 513e87096d..54eb3aeb2e 100644 --- a/usr.sbin/rtadvd/Makefile +++ b/usr.sbin/rtadvd/Makefile @@ -15,7 +15,7 @@ PROG= rtadvd SRCS= rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c -WARNS?= 1 +WARNS?= 2 CFLAGS+=-DINET6 -- 2.41.0 From 189a0ff3761b47cd5d8fa4e38e0c61209c3a91ac Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Wed, 19 Feb 2014 20:01:35 +0800 Subject: [PATCH 07/16] ix: Implement MSI-X support and enable multiple TX rings Two modes are supported, if there are enough MSI-X vector: - TX ring and RX ring processing uses independent MSI-X vector. It could be useful for some most TX applocation. It could be enabled by setting hw.ix.msix.agg_rxtx or hw.ixY.msix.agg_rxtx to 0. - TX ring and RX ring processing uses same MSI-X vector. This is the default. TX ring is processed when the header write back pointer is moved; this avoids unecessary TX ring serialization if there is no TX descriptor to recollect at all. For 82598, MSI-X is not enabled by default, due to hardware errata. It could be enabled by setting per-device tunable hw.ixY.msix.enable. Multiple TX rings are enable as of this commit. Under MSI-X mode, 32 TX rings could be used for 82599 and X540; 16 TX rings could be used for 82598. Once polling(4) is implemented, more TX rings could be used. Multiple RX rings have already been enabled, however, under MSI-X mode, 16 RX rings could be used for all devices supported by this driver. Unlike the original Intel's ixgbe, number of RX rings and number of TX rings could be configured independently. Remove the original Intel's ixgbe MSI-X related code, which is not used at all. --- sys/dev/netif/ix/if_ix.c | 1266 ++++++++++++++++++++++---------------- sys/dev/netif/ix/if_ix.h | 44 +- 2 files changed, 773 insertions(+), 537 deletions(-) diff --git a/sys/dev/netif/ix/if_ix.c b/sys/dev/netif/ix/if_ix.c index e0878fdf87..aca12df834 100644 --- a/sys/dev/netif/ix/if_ix.c +++ b/sys/dev/netif/ix/if_ix.c @@ -141,12 +141,18 @@ static int ix_media_change(struct ifnet *); static void ix_timer(void *); static void ix_add_sysctl(struct ix_softc *); +static void ix_add_intr_rate_sysctl(struct ix_softc *, int, + const char *, int (*)(SYSCTL_HANDLER_ARGS), const char *); static int ix_sysctl_tx_wreg_nsegs(SYSCTL_HANDLER_ARGS); static int ix_sysctl_rx_wreg_nsegs(SYSCTL_HANDLER_ARGS); static int ix_sysctl_txd(SYSCTL_HANDLER_ARGS); static int ix_sysctl_rxd(SYSCTL_HANDLER_ARGS); static int ix_sysctl_tx_intr_nsegs(SYSCTL_HANDLER_ARGS); -static int ix_sysctl_intr_rate(SYSCTL_HANDLER_ARGS); +static int ix_sysctl_intr_rate(SYSCTL_HANDLER_ARGS, int); +static int ix_sysctl_rxtx_intr_rate(SYSCTL_HANDLER_ARGS); +static int ix_sysctl_rx_intr_rate(SYSCTL_HANDLER_ARGS); +static int ix_sysctl_tx_intr_rate(SYSCTL_HANDLER_ARGS); +static int ix_sysctl_sts_intr_rate(SYSCTL_HANDLER_ARGS); static int ix_sysctl_flowctrl(SYSCTL_HANDLER_ARGS); #ifdef foo static int ix_sysctl_advspeed(SYSCTL_HANDLER_ARGS); @@ -181,7 +187,7 @@ static int ix_tx_ctx_setup(struct ix_tx_ring *, const struct mbuf *, uint32_t *, uint32_t *); static int ix_tso_ctx_setup(struct ix_tx_ring *, const struct mbuf *, uint32_t *, uint32_t *); -static void ix_txeof(struct ix_tx_ring *); +static void ix_txeof(struct ix_tx_ring *, int); static int ix_get_rxring_inuse(const struct ix_softc *, boolean_t); static int ix_init_rx_ring(struct ix_rx_ring *); @@ -198,6 +204,12 @@ static void ix_rx_discard(struct ix_rx_ring *, int, boolean_t); static void ix_enable_rx_drop(struct ix_softc *); static void ix_disable_rx_drop(struct ix_softc *); +static void ix_alloc_msix(struct ix_softc *); +static void ix_free_msix(struct ix_softc *, boolean_t); +static void ix_conf_rx_msix(struct ix_softc *, int, int *, int); +static void ix_conf_tx_msix(struct ix_softc *, int, int *, int); +static void ix_setup_msix_eims(const struct ix_softc *, int, + uint32_t *, uint32_t *); static int ix_alloc_intr(struct ix_softc *); static void ix_free_intr(struct ix_softc *); static int ix_setup_intr(struct ix_softc *); @@ -205,11 +217,13 @@ static void ix_teardown_intr(struct ix_softc *, int); static void ix_enable_intr(struct ix_softc *); static void ix_disable_intr(struct ix_softc *); static void ix_set_ivar(struct ix_softc *, uint8_t, uint8_t, int8_t); -#if 0 -static void ix_configure_ivars(struct ix_softc *); -#endif static void ix_set_eitr(struct ix_softc *, int, int); +static void ix_intr_status(struct ix_softc *, uint32_t); static void ix_intr(void *); +static void ix_msix_rxtx(void *); +static void ix_msix_rx(void *); +static void ix_msix_tx(void *); +static void ix_msix_status(void *); static void ix_config_link(struct ix_softc *); static boolean_t ix_sfp_probe(struct ix_softc *); @@ -220,14 +234,6 @@ static void ix_handle_link(struct ix_softc *); static void ix_handle_mod(struct ix_softc *); static void ix_handle_msf(struct ix_softc *); -#if 0 -static void ix_msix_que(void *); -static void ix_msix_link(void *); -static int ix_allocate_msix(struct ix_softc *); -static int ix_setup_msix(struct ix_softc *); -static void ix_handle_que(void *, int); -#endif - /* XXX Shared code structure requires this for the moment */ extern void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *); @@ -252,13 +258,19 @@ DECLARE_DUMMY_MODULE(if_ix); DRIVER_MODULE(if_ix, pci, ix_driver, ix_devclass, NULL, NULL); static int ix_msi_enable = 1; +static int ix_msix_enable = 1; +static int ix_msix_agg_rxtx = 1; static int ix_rxr = 0; +static int ix_txr = 0; static int ix_txd = IX_PERF_TXD; static int ix_rxd = IX_PERF_RXD; static int ix_unsupported_sfp = 0; TUNABLE_INT("hw.ix.msi.enable", &ix_msi_enable); +TUNABLE_INT("hw.ix.msix.enable", &ix_msix_enable); +TUNABLE_INT("hw.ix.msix.agg_rxtx", &ix_msix_agg_rxtx); TUNABLE_INT("hw.ix.rxr", &ix_rxr); +TUNABLE_INT("hw.ix.txr", &ix_txr); TUNABLE_INT("hw.ix.txd", &ix_txd); TUNABLE_INT("hw.ix.rxd", &ix_rxd); TUNABLE_INT("hw.ix.unsupported_sfp", &ix_unsupported_sfp); @@ -294,7 +306,7 @@ ix_attach(device_t dev) { struct ix_softc *sc = device_get_softc(dev); struct ixgbe_hw *hw; - int error; + int error, ring_cnt_max; uint16_t csum; uint32_t ctrl_ext; @@ -355,7 +367,25 @@ ix_attach(device_t dev) sc->rx_ring_cnt = if_ring_count2(sc->rx_ring_cnt, IX_MAX_RXRING); sc->rx_ring_inuse = sc->rx_ring_cnt; - sc->tx_ring_cnt = 1; + switch (hw->mac.type) { + case ixgbe_mac_82598EB: + ring_cnt_max = IX_MAX_TXRING_82598; + break; + + case ixgbe_mac_82599EB: + ring_cnt_max = IX_MAX_TXRING_82599; + break; + + case ixgbe_mac_X540: + ring_cnt_max = IX_MAX_TXRING_X540; + break; + + default: + ring_cnt_max = 1; + break; + } + sc->tx_ring_cnt = device_getenv_int(dev, "txr", ix_txr); + sc->tx_ring_cnt = if_ring_count2(sc->tx_ring_cnt, ring_cnt_max); sc->tx_ring_inuse = sc->tx_ring_cnt; /* Allocate TX/RX rings */ @@ -483,6 +513,10 @@ ix_detach(device_t dev) ix_free_intr(sc); + if (sc->msix_mem_res != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, sc->msix_mem_rid, + sc->msix_mem_res); + } if (sc->mem_res != NULL) { bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res); @@ -811,25 +845,64 @@ ix_init(void *xsc) rxctrl |= IXGBE_RXCTRL_RXEN; ixgbe_enable_rx_dma(hw, rxctrl); + for (i = 0; i < sc->tx_ring_inuse; ++i) { + const struct ix_tx_ring *txr = &sc->tx_rings[i]; + + if (txr->tx_intr_vec >= 0) { + ix_set_ivar(sc, i, txr->tx_intr_vec, 1); + } else { + /* + * Unconfigured TX interrupt vector could only + * happen for MSI-X. + */ + KASSERT(sc->intr_type == PCI_INTR_TYPE_MSIX, + ("TX intr vector is not set")); + KASSERT(i < sc->rx_ring_inuse, + ("invalid TX ring %d, no piggyback RX ring", i)); + KASSERT(sc->rx_rings[i].rx_txr == txr, + ("RX ring %d piggybacked TX ring mismatch", i)); + if (bootverbose) + if_printf(ifp, "IVAR skips TX ring %d\n", i); + } + } + for (i = 0; i < sc->rx_ring_inuse; ++i) { + const struct ix_rx_ring *rxr = &sc->rx_rings[i]; + + KKASSERT(rxr->rx_intr_vec >= 0); + ix_set_ivar(sc, i, rxr->rx_intr_vec, 0); + if (rxr->rx_txr != NULL) { + /* + * Piggyback the TX ring interrupt onto the RX + * ring interrupt vector. + */ + KASSERT(rxr->rx_txr->tx_intr_vec < 0, + ("piggybacked TX ring configured intr vector")); + KASSERT(rxr->rx_txr->tx_idx == i, + ("RX ring %d piggybacked TX ring %u", + i, rxr->rx_txr->tx_idx)); + ix_set_ivar(sc, i, rxr->rx_intr_vec, 1); + if (bootverbose) { + if_printf(ifp, "IVAR RX ring %d piggybacks " + "TX ring %u\n", i, rxr->rx_txr->tx_idx); + } + } + } if (sc->intr_type == PCI_INTR_TYPE_MSIX) { -#if 0 - ix_configure_ivars(sc); -#endif - /* Set up auto-mask */ - if (hw->mac.type == ixgbe_mac_82598EB) - IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE); - else { + /* Set up status MSI-X vector; it is using fixed entry 1 */ + ix_set_ivar(sc, 1, sc->sts_msix_vec, -1); + + /* Set up auto-mask for TX and RX rings */ + if (hw->mac.type == ixgbe_mac_82598EB) { + IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EIMS_RTX_QUEUE); + } else { IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF); IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF); } } else { - for (i = 0; i < sc->tx_ring_inuse; ++i) - ix_set_ivar(sc, i, sc->tx_rings[i].tx_intr_vec, 1); - for (i = 0; i < sc->rx_ring_inuse; ++i) - ix_set_ivar(sc, i, sc->rx_rings[i].rx_intr_vec, 0); - IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE); - ix_set_eitr(sc, 0, sc->intr_data[0].intr_rate); + IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EIMS_RTX_QUEUE); } + for (i = 0; i < sc->intr_cnt; ++i) + ix_set_eitr(sc, i, sc->intr_data[i].intr_rate); /* * Check on any SFP devices that need to be kick-started @@ -844,11 +917,6 @@ ix_init(void *xsc) } } -#if 0 - /* Set moderation on the Link interrupt */ - IXGBE_WRITE_REG(hw, IXGBE_EITR(sc->linkvec), IXGBE_LINK_ITR); -#endif - /* Config/Enable Link */ ix_config_link(sc); @@ -893,93 +961,6 @@ ix_init(void *xsc) callout_reset_bycpu(&sc->timer, hz, ix_timer, sc, sc->timer_cpuid); } -#if 0 -/* -** -** MSIX Interrupt Handlers and Tasklets -** -*/ - -static __inline void -ix_enable_queue(struct ix_softc *sc, uint32_t vector) -{ - struct ixgbe_hw *hw = &sc->hw; - uint64_t queue = (uint64_t)(1 << vector); - uint32_t mask; - - if (hw->mac.type == ixgbe_mac_82598EB) { - mask = (IXGBE_EIMS_RTX_QUEUE & queue); - IXGBE_WRITE_REG(hw, IXGBE_EIMS, mask); - } else { - mask = (queue & 0xFFFFFFFF); - if (mask) - IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask); - mask = (queue >> 32); - if (mask) - IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask); - } -} - -static __inline void -ix_disable_queue(struct ix_softc *sc, uint32_t vector) -{ - struct ixgbe_hw *hw = &sc->hw; - uint64_t queue = (uint64_t)(1 << vector); - uint32_t mask; - - if (hw->mac.type == ixgbe_mac_82598EB) { - mask = (IXGBE_EIMS_RTX_QUEUE & queue); - IXGBE_WRITE_REG(hw, IXGBE_EIMC, mask); - } else { - mask = (queue & 0xFFFFFFFF); - if (mask) - IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), mask); - mask = (queue >> 32); - if (mask) - IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), mask); - } -} - -static __inline void -ix_rearm_queues(struct ix_softc *sc, uint64_t queues) -{ - uint32_t mask; - - if (sc->hw.mac.type == ixgbe_mac_82598EB) { - mask = (IXGBE_EIMS_RTX_QUEUE & queues); - IXGBE_WRITE_REG(&sc->hw, IXGBE_EICS, mask); - } else { - mask = (queues & 0xFFFFFFFF); - IXGBE_WRITE_REG(&sc->hw, IXGBE_EICS_EX(0), mask); - mask = (queues >> 32); - IXGBE_WRITE_REG(&sc->hw, IXGBE_EICS_EX(1), mask); - } -} - -static void -ix_handle_que(void *context, int pending) -{ - struct ix_queue *que = context; - struct ix_softc *sc = que->sc; - struct ix_tx_ring *txr = que->txr; - struct ifnet *ifp = &sc->arpcom.ac_if; - - if (ifp->if_flags & IFF_RUNNING) { - more = ix_rxeof(que); - ix_txeof(txr); - if (!ifq_is_empty(&ifp->if_snd)) - ixgbe_start_locked(txr, ifp); - } - - /* Reenable this interrupt */ - if (que->res != NULL) - ixgbe_enable_queue(sc, que->msix); - else - ix_enable_intr(sc); - return; -} -#endif - static void ix_intr(void *xsc) { @@ -1017,177 +998,18 @@ ix_intr(void *xsc) struct ix_tx_ring *txr = &sc->tx_rings[0]; lwkt_serialize_enter(&txr->tx_serialize); - ix_txeof(txr); + ix_txeof(txr, *(txr->tx_hdr)); if (!ifsq_is_empty(txr->tx_ifsq)) ifsq_devstart(txr->tx_ifsq); lwkt_serialize_exit(&txr->tx_serialize); } - /* Check for fan failure */ - if (__predict_false((eicr & IXGBE_EICR_GPI_SDP1) && - hw->phy.media_type == ixgbe_media_type_copper)) { - if_printf(&sc->arpcom.ac_if, "CRITICAL: FAN FAILURE!! " - "REPLACE IMMEDIATELY!!\n"); - } - - /* Link status change */ - if (__predict_false(eicr & IXGBE_EICR_LSC)) - ix_handle_link(sc); + if (__predict_false(eicr & IX_EICR_STATUS)) + ix_intr_status(sc, eicr); IXGBE_WRITE_REG(hw, IXGBE_EIMS, sc->intr_mask); } -#if 0 -/********************************************************************* - * - * MSIX Queue Interrupt Service routine - * - **********************************************************************/ -void -ix_msix_que(void *arg) -{ - struct ix_queue *que = arg; - struct ix_softc *sc = que->sc; - struct ifnet *ifp = &sc->arpcom.ac_if; - struct ix_tx_ring *txr = que->txr; - struct ix_rx_ring *rxr = que->rxr; - uint32_t newitr = 0; - - ixgbe_disable_queue(sc, que->msix); - ++que->irqs; - - more = ix_rxeof(que); - - ix_txeof(txr); - if (!ifq_is_empty(&ifp->if_snd)) - ixgbe_start_locked(txr, ifp); - - /* Do AIM now? */ - - if (ixgbe_enable_aim == FALSE) - goto no_calc; - /* - ** Do Adaptive Interrupt Moderation: - ** - Write out last calculated setting - ** - Calculate based on average size over - ** the last interval. - */ - if (que->eitr_setting) - IXGBE_WRITE_REG(&sc->hw, - IXGBE_EITR(que->msix), que->eitr_setting); - - que->eitr_setting = 0; - - /* Idle, do nothing */ - if ((txr->bytes == 0) && (rxr->bytes == 0)) - goto no_calc; - - if ((txr->bytes) && (txr->packets)) - newitr = txr->bytes/txr->packets; - if ((rxr->bytes) && (rxr->packets)) - newitr = max(newitr, - (rxr->bytes / rxr->packets)); - newitr += 24; /* account for hardware frame, crc */ - - /* set an upper boundary */ - newitr = min(newitr, 3000); - - /* Be nice to the mid range */ - if ((newitr > 300) && (newitr < 1200)) - newitr = (newitr / 3); - else - newitr = (newitr / 2); - - if (sc->hw.mac.type == ixgbe_mac_82598EB) - newitr |= newitr << 16; - else - newitr |= IXGBE_EITR_CNT_WDIS; - - /* save for next interrupt */ - que->eitr_setting = newitr; - - /* Reset state */ - txr->bytes = 0; - txr->packets = 0; - rxr->bytes = 0; - rxr->packets = 0; - -no_calc: -#if 0 - if (more) - taskqueue_enqueue(que->tq, &que->que_task); - else -#endif - ixgbe_enable_queue(sc, que->msix); - return; -} - - -static void -ix_msix_link(void *arg) -{ - struct ix_softc *sc = arg; - struct ixgbe_hw *hw = &sc->hw; - uint32_t reg_eicr; - - ++sc->link_irq; - - /* First get the cause */ - reg_eicr = IXGBE_READ_REG(hw, IXGBE_EICS); - /* Clear interrupt with write */ - IXGBE_WRITE_REG(hw, IXGBE_EICR, reg_eicr); - -#if 0 - /* Link status change */ - if (reg_eicr & IXGBE_EICR_LSC) - taskqueue_enqueue(sc->tq, &sc->link_task); -#endif - - if (sc->hw.mac.type != ixgbe_mac_82598EB) { - if (reg_eicr & IXGBE_EICR_ECC) { - device_printf(sc->dev, "\nCRITICAL: ECC ERROR!! " - "Please Reboot!!\n"); - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC); - } else - - if (reg_eicr & IXGBE_EICR_GPI_SDP1) { - /* Clear the interrupt */ - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1); -#if 0 - taskqueue_enqueue(sc->tq, &sc->msf_task); -#endif - } else if (reg_eicr & IXGBE_EICR_GPI_SDP2) { - /* Clear the interrupt */ - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP2); -#if 0 - taskqueue_enqueue(sc->tq, &sc->mod_task); -#endif - } - } - - /* Check for fan failure */ - if ((hw->device_id == IXGBE_DEV_ID_82598AT) && - (reg_eicr & IXGBE_EICR_GPI_SDP1)) { - device_printf(sc->dev, "\nCRITICAL: FAN FAILURE!! " - "REPLACE IMMEDIATELY!!\n"); - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1); - } - - /* Check for over temp condition */ - if ((hw->mac.type == ixgbe_mac_X540) && - (reg_eicr & IXGBE_EICR_TS)) { - device_printf(sc->dev, "\nCRITICAL: OVER TEMP!! " - "PHY IS SHUT DOWN!!\n"); - device_printf(sc->dev, "System shutdown required\n"); - IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_TS); - } - - IXGBE_WRITE_REG(&sc->hw, IXGBE_EIMS, IXGBE_EIMS_OTHER); - return; -} - -#endif - static void ix_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) { @@ -1616,164 +1438,6 @@ ix_setup_optics(struct ix_softc *sc) sc->optics = IFM_ETHER | IFM_AUTO; } -#if 0 -/********************************************************************* - * - * Setup MSIX Interrupt resources and handlers - * - **********************************************************************/ -static int -ix_allocate_msix(struct ix_softc *sc) -{ - device_t dev = sc->dev; - struct ix_queue *que = sc->queues; - struct ix_tx_ring *txr = sc->tx_rings; - int error, rid, vector = 0; - - for (int i = 0; i < sc->num_queues; i++, vector++, que++, txr++) { - rid = vector + 1; - que->res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); - if (que->res == NULL) { - device_printf(dev,"Unable to allocate" - " bus resource: que interrupt [%d]\n", vector); - return (ENXIO); - } - /* Set the handler function */ - error = bus_setup_intr(dev, que->res, - INTR_TYPE_NET | INTR_MPSAFE, NULL, - ix_msix_que, que, &que->tag); - if (error) { - que->res = NULL; - device_printf(dev, "Failed to register QUE handler"); - return (error); - } -#if __FreeBSD_version >= 800504 - bus_describe_intr(dev, que->res, que->tag, "que %d", i); -#endif - que->msix = vector; - sc->que_mask |= (uint64_t)(1 << que->msix); - /* - ** Bind the msix vector, and thus the - ** ring to the corresponding cpu. - */ - if (sc->num_queues > 1) - bus_bind_intr(dev, que->res, i); - - TASK_INIT(&que->que_task, 0, ix_handle_que, que); - que->tq = taskqueue_create_fast("ixgbe_que", M_NOWAIT, - taskqueue_thread_enqueue, &que->tq); - taskqueue_start_threads(&que->tq, 1, PI_NET, "%s que", - device_get_nameunit(sc->dev)); - } - - /* and Link */ - rid = vector + 1; - sc->res = bus_alloc_resource_any(dev, - SYS_RES_IRQ, &rid, RF_SHAREABLE | RF_ACTIVE); - if (!sc->res) { - device_printf(dev,"Unable to allocate" - " bus resource: Link interrupt [%d]\n", rid); - return (ENXIO); - } - /* Set the link handler function */ - error = bus_setup_intr(dev, sc->res, - INTR_TYPE_NET | INTR_MPSAFE, NULL, - ix_msix_link, sc, &sc->tag); - if (error) { - sc->res = NULL; - device_printf(dev, "Failed to register LINK handler"); - return (error); - } -#if __FreeBSD_version >= 800504 - bus_describe_intr(dev, sc->res, sc->tag, "link"); -#endif - sc->linkvec = vector; - /* Tasklets for Link, SFP and Multispeed Fiber */ - TASK_INIT(&sc->link_task, 0, ix_handle_link, sc); - TASK_INIT(&sc->mod_task, 0, ix_handle_mod, sc); - TASK_INIT(&sc->msf_task, 0, ix_handle_msf, sc); - sc->tq = taskqueue_create_fast("ixgbe_link", M_NOWAIT, - taskqueue_thread_enqueue, &sc->tq); - taskqueue_start_threads(&sc->tq, 1, PI_NET, "%s linkq", - device_get_nameunit(sc->dev)); - - return (0); -} - -static int -ix_setup_msix(struct ix_softc *sc) -{ - device_t dev = sc->dev; - int rid, want, queues, msgs; - - /* Override by tuneable */ - if (ixgbe_enable_msix == 0) - goto msi; - - /* First try MSI/X */ - rid = PCIR_BAR(MSIX_82598_BAR); - sc->msix_mem = bus_alloc_resource_any(dev, - SYS_RES_MEMORY, &rid, RF_ACTIVE); - if (!sc->msix_mem) { - rid += 4; /* 82599 maps in higher BAR */ - sc->msix_mem = bus_alloc_resource_any(dev, - SYS_RES_MEMORY, &rid, RF_ACTIVE); - } - if (!sc->msix_mem) { - /* May not be enabled */ - device_printf(sc->dev, - "Unable to map MSIX table \n"); - goto msi; - } - - msgs = pci_msix_count(dev); - if (msgs == 0) { /* system has msix disabled */ - bus_release_resource(dev, SYS_RES_MEMORY, - rid, sc->msix_mem); - sc->msix_mem = NULL; - goto msi; - } - - /* Figure out a reasonable auto config value */ - queues = (mp_ncpus > (msgs-1)) ? (msgs-1) : mp_ncpus; - - if (ixgbe_num_queues != 0) - queues = ixgbe_num_queues; - /* Set max queues to 8 when autoconfiguring */ - else if ((ixgbe_num_queues == 0) && (queues > 8)) - queues = 8; - - /* - ** Want one vector (RX/TX pair) per queue - ** plus an additional for Link. - */ - want = queues + 1; - if (msgs >= want) - msgs = want; - else { - device_printf(sc->dev, - "MSIX Configuration Problem, " - "%d vectors but %d queues wanted!\n", - msgs, want); - return (0); /* Will go to Legacy setup */ - } - if ((msgs) && pci_alloc_msix(dev, &msgs) == 0) { - device_printf(sc->dev, - "Using MSIX interrupts with %d vectors\n", msgs); - sc->num_queues = queues; - return (msgs); - } -msi: - msgs = pci_msi_count(dev); - if (msgs == 1 && pci_alloc_msi(dev, &msgs) == 0) - device_printf(sc->dev,"Using an MSI interrupt\n"); - else - device_printf(sc->dev,"Using a Legacy interrupt\n"); - return (msgs); -} -#endif - static void ix_setup_ifp(struct ix_softc *sc) { @@ -1795,6 +1459,9 @@ ix_setup_ifp(struct ix_softc *sc) ifp->if_serialize_assert = ix_serialize_assert; #endif + /* Increase TSO burst length */ + ifp->if_tsolen = (8 * ETHERMTU); + ifq_set_maxlen(&ifp->if_snd, sc->tx_rings[0].tx_ndesc - 2); ifq_set_ready(&ifp->if_snd); ifq_set_subq_cnt(&ifp->if_snd, sc->tx_ring_cnt); @@ -1932,6 +1599,7 @@ ix_alloc_rings(struct ix_softc *sc) txr->tx_sc = sc; txr->tx_idx = i; + txr->tx_intr_vec = -1; lwkt_serialize_init(&txr->tx_serialize); error = ix_create_tx_ring(txr); @@ -1950,6 +1618,7 @@ ix_alloc_rings(struct ix_softc *sc) rxr->rx_sc = sc; rxr->rx_idx = i; + rxr->rx_intr_vec = -1; lwkt_serialize_init(&rxr->rx_serialize); error = ix_create_rx_ring(rxr); @@ -2322,17 +1991,15 @@ ix_tso_ctx_setup(struct ix_tx_ring *txr, const struct mbuf *mp, } static void -ix_txeof(struct ix_tx_ring *txr) +ix_txeof(struct ix_tx_ring *txr, int hdr) { struct ifnet *ifp = &txr->tx_sc->arpcom.ac_if; - int first, hdr, avail; + int first, avail; if (txr->tx_avail == txr->tx_ndesc) return; first = txr->tx_next_clean; - hdr = *(txr->tx_hdr); - if (first == hdr) return; @@ -3038,64 +2705,76 @@ static void ix_enable_intr(struct ix_softc *sc) { struct ixgbe_hw *hw = &sc->hw; - uint32_t mask, fwsm; + uint32_t fwsm; int i; for (i = 0; i < sc->intr_cnt; ++i) lwkt_serialize_handler_enable(sc->intr_data[i].intr_serialize); - mask = (IXGBE_EIMS_ENABLE_MASK & ~IXGBE_EIMS_RTX_QUEUE); + sc->intr_mask = (IXGBE_EIMS_ENABLE_MASK & ~IXGBE_EIMS_RTX_QUEUE); /* Enable Fan Failure detection */ if (hw->device_id == IXGBE_DEV_ID_82598AT) - mask |= IXGBE_EIMS_GPI_SDP1; + sc->intr_mask |= IXGBE_EIMS_GPI_SDP1; switch (sc->hw.mac.type) { case ixgbe_mac_82599EB: - mask |= IXGBE_EIMS_ECC; - mask |= IXGBE_EIMS_GPI_SDP0; - mask |= IXGBE_EIMS_GPI_SDP1; - mask |= IXGBE_EIMS_GPI_SDP2; + sc->intr_mask |= IXGBE_EIMS_ECC; + sc->intr_mask |= IXGBE_EIMS_GPI_SDP0; + sc->intr_mask |= IXGBE_EIMS_GPI_SDP1; + sc->intr_mask |= IXGBE_EIMS_GPI_SDP2; break; + case ixgbe_mac_X540: - mask |= IXGBE_EIMS_ECC; + sc->intr_mask |= IXGBE_EIMS_ECC; /* Detect if Thermal Sensor is enabled */ fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM); if (fwsm & IXGBE_FWSM_TS_ENABLED) - mask |= IXGBE_EIMS_TS; + sc->intr_mask |= IXGBE_EIMS_TS; /* FALL THROUGH */ default: break; } - sc->intr_mask = mask; - /* With MSI-X we use auto clear */ + /* With MSI-X we use auto clear for RX and TX rings */ if (sc->intr_type == PCI_INTR_TYPE_MSIX) { - mask = IXGBE_EIMS_ENABLE_MASK; - /* Don't autoclear Link */ - mask &= ~IXGBE_EIMS_OTHER; - mask &= ~IXGBE_EIMS_LSC; - IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask); + /* + * There are no EIAC1/EIAC2 for newer chips; the related + * bits for TX and RX rings > 16 are always auto clear. + * + * XXX which bits? There are _no_ documented EICR1 and + * EICR2 at all; only EICR. + */ + IXGBE_WRITE_REG(hw, IXGBE_EIAC, IXGBE_EIMS_RTX_QUEUE); } else { - sc->intr_mask |= IX_TX_INTR_MASK | - IX_RX0_INTR_MASK; + sc->intr_mask |= IX_TX_INTR_MASK | IX_RX0_INTR_MASK; KKASSERT(sc->rx_ring_inuse <= IX_MIN_RXRING_RSS); if (sc->rx_ring_inuse == IX_MIN_RXRING_RSS) sc->intr_mask |= IX_RX1_INTR_MASK; } -#if 0 - /* - ** Now enable all queues, this is done separately to - ** allow for handling the extended (beyond 32) MSIX - ** vectors that can be used by 82599 - */ - for (int i = 0; i < sc->num_queues; i++, que++) - ixgbe_enable_queue(sc, que->msix); -#else IXGBE_WRITE_REG(hw, IXGBE_EIMS, sc->intr_mask); -#endif + + /* + * Enable RX and TX rings for MSI-X + */ + if (sc->intr_type == PCI_INTR_TYPE_MSIX) { + for (i = 0; i < sc->tx_ring_inuse; ++i) { + const struct ix_tx_ring *txr = &sc->tx_rings[i]; + + if (txr->tx_intr_vec >= 0) { + IXGBE_WRITE_REG(hw, txr->tx_eims, + txr->tx_eims_val); + } + } + for (i = 0; i < sc->rx_ring_inuse; ++i) { + const struct ix_rx_ring *rxr = &sc->rx_rings[i]; + + KKASSERT(rxr->rx_intr_vec >= 0); + IXGBE_WRITE_REG(hw, rxr->rx_eims, rxr->rx_eims_val); + } + } IXGBE_WRITE_FLUSH(hw); } @@ -3105,10 +2784,9 @@ ix_disable_intr(struct ix_softc *sc) { int i; -#if 0 - if (sc->msix_mem) + if (sc->intr_type == PCI_INTR_TYPE_MSIX) IXGBE_WRITE_REG(&sc->hw, IXGBE_EIAC, 0); -#endif + if (sc->hw.mac.type == ixgbe_mac_82598EB) { IXGBE_WRITE_REG(&sc->hw, IXGBE_EIMC, ~0); } else { @@ -3278,33 +2956,6 @@ ix_set_ivar(struct ix_softc *sc, uint8_t entry, uint8_t vector, } } -#if 0 -static void -ix_configure_ivars(struct ix_softc *sc) -{ - struct ix_queue *que = sc->queues; - uint32_t newitr; - - if (ixgbe_max_interrupt_rate > 0) - newitr = (4000000 / ixgbe_max_interrupt_rate) & 0x0FF8; - else - newitr = 0; - - for (int i = 0; i < sc->num_queues; i++, que++) { - /* First the RX queue entry */ - ix_set_ivar(sc, i, que->msix, 0); - /* ... and the TX */ - ix_set_ivar(sc, i, que->msix, 1); - /* Set an Initial EITR value */ - IXGBE_WRITE_REG(&sc->hw, - IXGBE_EITR(que->msix), newitr); - } - - /* For the Link interrupt */ - ix_set_ivar(sc, 1, sc->linkvec, -1); -} -#endif - static boolean_t ix_sfp_probe(struct ix_softc *sc) { @@ -3911,7 +3562,12 @@ ix_alloc_intr(struct ix_softc *sc) { struct ix_intr_data *intr; u_int intr_flags; - int i; + + ix_alloc_msix(sc); + if (sc->intr_type == PCI_INTR_TYPE_MSIX) { + ix_set_ring_inuse(sc, FALSE); + return 0; + } if (sc->intr_data != NULL) kfree(sc->intr_data, M_DEVBUF); @@ -3942,13 +3598,10 @@ ix_alloc_intr(struct ix_softc *sc) intr->intr_rate = IX_INTR_RATE; intr->intr_use = IX_INTR_USE_RXTX; - for (i = 0; i < sc->tx_ring_cnt; ++i) { - sc->tx_rings[i].tx_intr_cpuid = intr->intr_cpuid; - sc->tx_rings[i].tx_intr_vec = IX_TX_INTR_VEC; - } + sc->tx_rings[0].tx_intr_cpuid = intr->intr_cpuid; + sc->tx_rings[0].tx_intr_vec = IX_TX_INTR_VEC; - for (i = 0; i < sc->rx_ring_cnt; ++i) - sc->rx_rings[i].rx_intr_vec = IX_RX0_INTR_VEC; + sc->rx_rings[0].rx_intr_vec = IX_RX0_INTR_VEC; ix_set_ring_inuse(sc, FALSE); @@ -3975,10 +3628,11 @@ ix_free_intr(struct ix_softc *sc) } if (sc->intr_type == PCI_INTR_TYPE_MSI) pci_release_msi(sc->dev); + + kfree(sc->intr_data, M_DEVBUF); } else { - /* TODO */ + ix_free_msix(sc, TRUE); } - kfree(sc->intr_data, M_DEVBUF); } static void @@ -4005,7 +3659,7 @@ ix_get_rxring_inuse(const struct ix_softc *sc, boolean_t polling) else if (sc->intr_type != PCI_INTR_TYPE_MSIX) return IX_MIN_RXRING_RSS; else - return 1; /* TODO */ + return sc->rx_ring_msix; } static int @@ -4019,7 +3673,7 @@ ix_get_txring_inuse(const struct ix_softc *sc, boolean_t polling) else if (sc->intr_type != PCI_INTR_TYPE_MSIX) return 1; else - return 1; /* TODO */ + return sc->tx_ring_msix; } static int @@ -4248,7 +3902,6 @@ ix_add_sysctl(struct ix_softc *sc) #ifdef IX_RSS_DEBUG char node[32]; #endif - int i, add; sysctl_ctx_init(&sc->sysctl_ctx); sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx, @@ -4290,20 +3943,18 @@ ix_add_sysctl(struct ix_softc *sc) sc, 0, ix_sysctl_tx_intr_nsegs, "I", "# of segments per TX interrupt"); - add = 0; - for (i = 0; i < sc->intr_cnt; ++i) { - if (sc->intr_data[i].intr_use == IX_INTR_USE_RXTX) { - add = 1; - break; - } - } - if (add) { - SYSCTL_ADD_PROC(&sc->sysctl_ctx, - SYSCTL_CHILDREN(sc->sysctl_tree), - OID_AUTO, "intr_rate", CTLTYPE_INT | CTLFLAG_RW, - sc, 0, ix_sysctl_intr_rate, "I", - "interrupt rate"); - } +#define IX_ADD_INTR_RATE_SYSCTL(sc, use, name) \ +do { \ + ix_add_intr_rate_sysctl(sc, IX_INTR_USE_##use, #name, \ + ix_sysctl_##name, #use " interrupt rate"); \ +} while (0) + + IX_ADD_INTR_RATE_SYSCTL(sc, RXTX, rxtx_intr_rate); + IX_ADD_INTR_RATE_SYSCTL(sc, RX, rx_intr_rate); + IX_ADD_INTR_RATE_SYSCTL(sc, TX, tx_intr_rate); + IX_ADD_INTR_RATE_SYSCTL(sc, STATUS, sts_intr_rate); + +#undef IX_ADD_INTR_RATE_SYSCTL #ifdef IX_RSS_DEBUG SYSCTL_ADD_INT(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), @@ -4466,7 +4117,31 @@ ix_set_eitr(struct ix_softc *sc, int idx, int rate) } static int -ix_sysctl_intr_rate(SYSCTL_HANDLER_ARGS) +ix_sysctl_rxtx_intr_rate(SYSCTL_HANDLER_ARGS) +{ + return ix_sysctl_intr_rate(oidp, arg1, arg2, req, IX_INTR_USE_RXTX); +} + +static int +ix_sysctl_rx_intr_rate(SYSCTL_HANDLER_ARGS) +{ + return ix_sysctl_intr_rate(oidp, arg1, arg2, req, IX_INTR_USE_RX); +} + +static int +ix_sysctl_tx_intr_rate(SYSCTL_HANDLER_ARGS) +{ + return ix_sysctl_intr_rate(oidp, arg1, arg2, req, IX_INTR_USE_TX); +} + +static int +ix_sysctl_sts_intr_rate(SYSCTL_HANDLER_ARGS) +{ + return ix_sysctl_intr_rate(oidp, arg1, arg2, req, IX_INTR_USE_STATUS); +} + +static int +ix_sysctl_intr_rate(SYSCTL_HANDLER_ARGS, int use) { struct ix_softc *sc = (void *)arg1; struct ifnet *ifp = &sc->arpcom.ac_if; @@ -4474,7 +4149,7 @@ ix_sysctl_intr_rate(SYSCTL_HANDLER_ARGS) rate = 0; for (i = 0; i < sc->intr_cnt; ++i) { - if (sc->intr_data[i].intr_use == IX_INTR_USE_RXTX) { + if (sc->intr_data[i].intr_use == use) { rate = sc->intr_data[i].intr_rate; break; } @@ -4489,7 +4164,7 @@ ix_sysctl_intr_rate(SYSCTL_HANDLER_ARGS) ifnet_serialize_all(ifp); for (i = 0; i < sc->intr_cnt; ++i) { - if (sc->intr_data[i].intr_use == IX_INTR_USE_RXTX) { + if (sc->intr_data[i].intr_use == use) { sc->intr_data[i].intr_rate = rate; if (ifp->if_flags & IFF_RUNNING) ix_set_eitr(sc, i, rate); @@ -4501,6 +4176,23 @@ ix_sysctl_intr_rate(SYSCTL_HANDLER_ARGS) return error; } +static void +ix_add_intr_rate_sysctl(struct ix_softc *sc, int use, + const char *name, int (*handler)(SYSCTL_HANDLER_ARGS), const char *desc) +{ + int i; + + for (i = 0; i < sc->intr_cnt; ++i) { + if (sc->intr_data[i].intr_use == use) { + SYSCTL_ADD_PROC(&sc->sysctl_ctx, + SYSCTL_CHILDREN(sc->sysctl_tree), + OID_AUTO, name, CTLTYPE_INT | CTLFLAG_RW, + sc, 0, handler, "I", desc); + break; + } + } +} + static void ix_set_timer_cpuid(struct ix_softc *sc, boolean_t polling) { @@ -4509,3 +4201,515 @@ ix_set_timer_cpuid(struct ix_softc *sc, boolean_t polling) else sc->timer_cpuid = rman_get_cpuid(sc->intr_data[0].intr_res); } + +static void +ix_alloc_msix(struct ix_softc *sc) +{ + int msix_enable, msix_cnt, msix_cnt2, alloc_cnt; + struct ix_intr_data *intr; + int i, x, error; + int offset, offset_def, agg_rxtx, ring_max; + boolean_t aggregate, setup = FALSE; + + msix_enable = ix_msix_enable; + /* + * Don't enable MSI-X on 82598 by default, see: + * 82598 specification update errata #38 + */ + if (sc->hw.mac.type == ixgbe_mac_82598EB) + msix_enable = 0; + msix_enable = device_getenv_int(sc->dev, "msix.enable", msix_enable); + if (!msix_enable) + return; + + msix_cnt = pci_msix_count(sc->dev); +#ifdef IX_MSIX_DEBUG + msix_cnt = device_getenv_int(sc->dev, "msix.count", msix_cnt); +#endif + if (msix_cnt <= 1) { + /* One MSI-X model does not make sense */ + return; + } + + i = 0; + while ((1 << (i + 1)) <= msix_cnt) + ++i; + msix_cnt2 = 1 << i; + + if (bootverbose) { + device_printf(sc->dev, "MSI-X count %d/%d\n", + msix_cnt2, msix_cnt); + } + + KKASSERT(msix_cnt >= msix_cnt2); + if (msix_cnt == msix_cnt2) { + /* We need at least one MSI-X for link status */ + msix_cnt2 >>= 1; + if (msix_cnt2 <= 1) { + /* One MSI-X for RX/TX does not make sense */ + device_printf(sc->dev, "not enough MSI-X for TX/RX, " + "MSI-X count %d/%d\n", msix_cnt2, msix_cnt); + return; + } + KKASSERT(msix_cnt > msix_cnt2); + + if (bootverbose) { + device_printf(sc->dev, "MSI-X count eq fixup %d/%d\n", + msix_cnt2, msix_cnt); + } + } + + /* + * Make sure that we don't break interrupt related registers + * (EIMS, etc) limitation. + * + * NOTE: msix_cnt > msix_cnt2, when we reach here + */ + if (sc->hw.mac.type == ixgbe_mac_82598EB) { + if (msix_cnt2 > IX_MAX_MSIX_82598) + msix_cnt2 = IX_MAX_MSIX_82598; + } else { + if (msix_cnt2 > IX_MAX_MSIX) + msix_cnt2 = IX_MAX_MSIX; + } + msix_cnt = msix_cnt2 + 1; /* +1 for status */ + + if (bootverbose) { + device_printf(sc->dev, "MSI-X count max fixup %d/%d\n", + msix_cnt2, msix_cnt); + } + + sc->rx_ring_msix = sc->rx_ring_cnt; + if (sc->rx_ring_msix > msix_cnt2) + sc->rx_ring_msix = msix_cnt2; + + sc->tx_ring_msix = sc->tx_ring_cnt; + if (sc->tx_ring_msix > msix_cnt2) + sc->tx_ring_msix = msix_cnt2; + + ring_max = sc->rx_ring_msix; + if (ring_max < sc->tx_ring_msix) + ring_max = sc->tx_ring_msix; + + /* Allow user to force independent RX/TX MSI-X handling */ + agg_rxtx = device_getenv_int(sc->dev, "msix.agg_rxtx", + ix_msix_agg_rxtx); + + if (!agg_rxtx && msix_cnt >= sc->tx_ring_msix + sc->rx_ring_msix + 1) { + /* + * Independent TX/RX MSI-X + */ + aggregate = FALSE; + if (bootverbose) + device_printf(sc->dev, "independent TX/RX MSI-X\n"); + alloc_cnt = sc->tx_ring_msix + sc->rx_ring_msix; + } else { + /* + * Aggregate TX/RX MSI-X + */ + aggregate = TRUE; + if (bootverbose) + device_printf(sc->dev, "aggregate TX/RX MSI-X\n"); + alloc_cnt = msix_cnt2; + if (alloc_cnt > ring_max) + alloc_cnt = ring_max; + KKASSERT(alloc_cnt >= sc->rx_ring_msix && + alloc_cnt >= sc->tx_ring_msix); + } + ++alloc_cnt; /* For status */ + + if (bootverbose) { + device_printf(sc->dev, "MSI-X alloc %d, " + "RX ring %d, TX ring %d\n", alloc_cnt, + sc->rx_ring_msix, sc->tx_ring_msix); + } + + sc->msix_mem_rid = PCIR_BAR(IX_MSIX_BAR_82598); + sc->msix_mem_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, + &sc->msix_mem_rid, RF_ACTIVE); + if (sc->msix_mem_res == NULL) { + sc->msix_mem_rid = PCIR_BAR(IX_MSIX_BAR_82599); + sc->msix_mem_res = bus_alloc_resource_any(sc->dev, + SYS_RES_MEMORY, &sc->msix_mem_rid, RF_ACTIVE); + if (sc->msix_mem_res == NULL) { + device_printf(sc->dev, "Unable to map MSI-X table\n"); + return; + } + } + + sc->intr_cnt = alloc_cnt; + sc->intr_data = kmalloc(sizeof(struct ix_intr_data) * sc->intr_cnt, + M_DEVBUF, M_WAITOK | M_ZERO); + for (x = 0; x < sc->intr_cnt; ++x) { + intr = &sc->intr_data[x]; + intr->intr_rid = -1; + intr->intr_rate = IX_INTR_RATE; + } + + x = 0; + if (!aggregate) { + /* + * RX rings + */ + if (sc->rx_ring_msix == ncpus2) { + offset = 0; + } else { + offset_def = (sc->rx_ring_msix * + device_get_unit(sc->dev)) % ncpus2; + + offset = device_getenv_int(sc->dev, + "msix.rxoff", offset_def); + if (offset >= ncpus2 || + offset % sc->rx_ring_msix != 0) { + device_printf(sc->dev, + "invalid msix.rxoff %d, use %d\n", + offset, offset_def); + offset = offset_def; + } + } + ix_conf_rx_msix(sc, 0, &x, offset); + + /* + * TX rings + */ + if (sc->tx_ring_msix == ncpus2) { + offset = 0; + } else { + offset_def = (sc->tx_ring_msix * + device_get_unit(sc->dev)) % ncpus2; + + offset = device_getenv_int(sc->dev, + "msix.txoff", offset_def); + if (offset >= ncpus2 || + offset % sc->tx_ring_msix != 0) { + device_printf(sc->dev, + "invalid msix.txoff %d, use %d\n", + offset, offset_def); + offset = offset_def; + } + } + ix_conf_tx_msix(sc, 0, &x, offset); + } else { + int ring_agg; + + ring_agg = sc->rx_ring_msix; + if (ring_agg > sc->tx_ring_msix) + ring_agg = sc->tx_ring_msix; + + if (ring_max == ncpus2) { + offset = 0; + } else { + offset_def = (ring_max * device_get_unit(sc->dev)) % + ncpus2; + + offset = device_getenv_int(sc->dev, "msix.off", + offset_def); + if (offset >= ncpus2 || offset % ring_max != 0) { + device_printf(sc->dev, + "invalid msix.off %d, use %d\n", + offset, offset_def); + offset = offset_def; + } + } + + for (i = 0; i < ring_agg; ++i) { + struct ix_tx_ring *txr = &sc->tx_rings[i]; + struct ix_rx_ring *rxr = &sc->rx_rings[i]; + + KKASSERT(x < sc->intr_cnt); + rxr->rx_intr_vec = x; + ix_setup_msix_eims(sc, x, + &rxr->rx_eims, &rxr->rx_eims_val); + rxr->rx_txr = txr; + /* NOTE: Leave TX ring's intr_vec negative */ + + intr = &sc->intr_data[x++]; + + intr->intr_serialize = &rxr->rx_serialize; + intr->intr_func = ix_msix_rxtx; + intr->intr_funcarg = rxr; + intr->intr_use = IX_INTR_USE_RXTX; + + intr->intr_cpuid = i + offset; + KKASSERT(intr->intr_cpuid < ncpus2); + txr->tx_intr_cpuid = intr->intr_cpuid; + + ksnprintf(intr->intr_desc0, sizeof(intr->intr_desc0), + "%s rxtx%d", device_get_nameunit(sc->dev), i); + intr->intr_desc = intr->intr_desc0; + } + + if (ring_agg != ring_max) { + if (ring_max == sc->tx_ring_msix) + ix_conf_tx_msix(sc, i, &x, offset); + else + ix_conf_rx_msix(sc, i, &x, offset); + } + } + + /* + * Status MSI-X + */ + KKASSERT(x < sc->intr_cnt); + sc->sts_msix_vec = x; + + intr = &sc->intr_data[x++]; + + intr->intr_serialize = &sc->main_serialize; + intr->intr_func = ix_msix_status; + intr->intr_funcarg = sc; + intr->intr_cpuid = 0; + intr->intr_use = IX_INTR_USE_STATUS; + + ksnprintf(intr->intr_desc0, sizeof(intr->intr_desc0), "%s sts", + device_get_nameunit(sc->dev)); + intr->intr_desc = intr->intr_desc0; + + KKASSERT(x == sc->intr_cnt); + + error = pci_setup_msix(sc->dev); + if (error) { + device_printf(sc->dev, "Setup MSI-X failed\n"); + goto back; + } + setup = TRUE; + + for (i = 0; i < sc->intr_cnt; ++i) { + intr = &sc->intr_data[i]; + + error = pci_alloc_msix_vector(sc->dev, i, &intr->intr_rid, + intr->intr_cpuid); + if (error) { + device_printf(sc->dev, + "Unable to allocate MSI-X %d on cpu%d\n", i, + intr->intr_cpuid); + goto back; + } + + intr->intr_res = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, + &intr->intr_rid, RF_ACTIVE); + if (intr->intr_res == NULL) { + device_printf(sc->dev, + "Unable to allocate MSI-X %d resource\n", i); + error = ENOMEM; + goto back; + } + } + + pci_enable_msix(sc->dev); + sc->intr_type = PCI_INTR_TYPE_MSIX; +back: + if (error) + ix_free_msix(sc, setup); +} + +static void +ix_free_msix(struct ix_softc *sc, boolean_t setup) +{ + int i; + + KKASSERT(sc->intr_cnt > 1); + + for (i = 0; i < sc->intr_cnt; ++i) { + struct ix_intr_data *intr = &sc->intr_data[i]; + + if (intr->intr_res != NULL) { + bus_release_resource(sc->dev, SYS_RES_IRQ, + intr->intr_rid, intr->intr_res); + } + if (intr->intr_rid >= 0) + pci_release_msix_vector(sc->dev, intr->intr_rid); + } + if (setup) + pci_teardown_msix(sc->dev); + + sc->intr_cnt = 0; + kfree(sc->intr_data, M_DEVBUF); + sc->intr_data = NULL; +} + +static void +ix_conf_rx_msix(struct ix_softc *sc, int i, int *x0, int offset) +{ + int x = *x0; + + for (; i < sc->rx_ring_msix; ++i) { + struct ix_rx_ring *rxr = &sc->rx_rings[i]; + struct ix_intr_data *intr; + + KKASSERT(x < sc->intr_cnt); + rxr->rx_intr_vec = x; + ix_setup_msix_eims(sc, x, &rxr->rx_eims, &rxr->rx_eims_val); + + intr = &sc->intr_data[x++]; + + intr->intr_serialize = &rxr->rx_serialize; + intr->intr_func = ix_msix_rx; + intr->intr_funcarg = rxr; + intr->intr_rate = IX_MSIX_RX_RATE; + intr->intr_use = IX_INTR_USE_RX; + + intr->intr_cpuid = i + offset; + KKASSERT(intr->intr_cpuid < ncpus2); + + ksnprintf(intr->intr_desc0, sizeof(intr->intr_desc0), "%s rx%d", + device_get_nameunit(sc->dev), i); + intr->intr_desc = intr->intr_desc0; + } + *x0 = x; +} + +static void +ix_conf_tx_msix(struct ix_softc *sc, int i, int *x0, int offset) +{ + int x = *x0; + + for (; i < sc->tx_ring_msix; ++i) { + struct ix_tx_ring *txr = &sc->tx_rings[i]; + struct ix_intr_data *intr; + + KKASSERT(x < sc->intr_cnt); + txr->tx_intr_vec = x; + ix_setup_msix_eims(sc, x, &txr->tx_eims, &txr->tx_eims_val); + + intr = &sc->intr_data[x++]; + + intr->intr_serialize = &txr->tx_serialize; + intr->intr_func = ix_msix_tx; + intr->intr_funcarg = txr; + intr->intr_rate = IX_MSIX_TX_RATE; + intr->intr_use = IX_INTR_USE_TX; + + intr->intr_cpuid = i + offset; + KKASSERT(intr->intr_cpuid < ncpus2); + txr->tx_intr_cpuid = intr->intr_cpuid; + + ksnprintf(intr->intr_desc0, sizeof(intr->intr_desc0), "%s tx%d", + device_get_nameunit(sc->dev), i); + intr->intr_desc = intr->intr_desc0; + } + *x0 = x; +} + +static void +ix_msix_rx(void *xrxr) +{ + struct ix_rx_ring *rxr = xrxr; + + ASSERT_SERIALIZED(&rxr->rx_serialize); + + ix_rxeof(rxr); + IXGBE_WRITE_REG(&rxr->rx_sc->hw, rxr->rx_eims, rxr->rx_eims_val); +} + +static void +ix_msix_tx(void *xtxr) +{ + struct ix_tx_ring *txr = xtxr; + + ASSERT_SERIALIZED(&txr->tx_serialize); + + ix_txeof(txr, *(txr->tx_hdr)); + if (!ifsq_is_empty(txr->tx_ifsq)) + ifsq_devstart(txr->tx_ifsq); + IXGBE_WRITE_REG(&txr->tx_sc->hw, txr->tx_eims, txr->tx_eims_val); +} + +static void +ix_msix_rxtx(void *xrxr) +{ + struct ix_rx_ring *rxr = xrxr; + struct ix_tx_ring *txr; + int hdr; + + ASSERT_SERIALIZED(&rxr->rx_serialize); + + ix_rxeof(rxr); + + /* + * NOTE: + * Since tx_next_clean is only changed by ix_txeof(), + * which is called only in interrupt handler, the + * check w/o holding tx serializer is MPSAFE. + */ + txr = rxr->rx_txr; + hdr = *(txr->tx_hdr); + if (hdr != txr->tx_next_clean) { + lwkt_serialize_enter(&txr->tx_serialize); + ix_txeof(txr, hdr); + if (!ifsq_is_empty(txr->tx_ifsq)) + ifsq_devstart(txr->tx_ifsq); + lwkt_serialize_exit(&txr->tx_serialize); + } + + IXGBE_WRITE_REG(&rxr->rx_sc->hw, rxr->rx_eims, rxr->rx_eims_val); +} + +static void +ix_intr_status(struct ix_softc *sc, uint32_t eicr) +{ + struct ixgbe_hw *hw = &sc->hw; + + /* Link status change */ + if (eicr & IXGBE_EICR_LSC) + ix_handle_link(sc); + + if (hw->mac.type != ixgbe_mac_82598EB) { + if (eicr & IXGBE_EICR_ECC) + if_printf(&sc->arpcom.ac_if, "ECC ERROR!! Reboot!!\n"); + else if (eicr & IXGBE_EICR_GPI_SDP1) + ix_handle_msf(sc); + else if (eicr & IXGBE_EICR_GPI_SDP2) + ix_handle_mod(sc); + } + + /* Check for fan failure */ + if (hw->device_id == IXGBE_DEV_ID_82598AT && + (eicr & IXGBE_EICR_GPI_SDP1)) + if_printf(&sc->arpcom.ac_if, "FAN FAILURE!! Replace!!\n"); + + /* Check for over temp condition */ + if (hw->mac.type == ixgbe_mac_X540 && (eicr & IXGBE_EICR_TS)) { + if_printf(&sc->arpcom.ac_if, "OVER TEMP!! " + "PHY IS SHUT DOWN!! Reboot\n"); + } +} + +static void +ix_msix_status(void *xsc) +{ + struct ix_softc *sc = xsc; + uint32_t eicr; + + ASSERT_SERIALIZED(&sc->main_serialize); + + eicr = IXGBE_READ_REG(&sc->hw, IXGBE_EICR); + ix_intr_status(sc, eicr); + + IXGBE_WRITE_REG(&sc->hw, IXGBE_EIMS, sc->intr_mask); +} + +static void +ix_setup_msix_eims(const struct ix_softc *sc, int x, + uint32_t *eims, uint32_t *eims_val) +{ + if (x < 32) { + if (sc->hw.mac.type == ixgbe_mac_82598EB) { + KASSERT(x < IX_MAX_MSIX_82598, + ("%s: invalid vector %d for 82598", + device_get_nameunit(sc->dev), x)); + *eims = IXGBE_EIMS; + } else { + *eims = IXGBE_EIMS_EX(0); + } + *eims_val = 1 << x; + } else { + KASSERT(x < IX_MAX_MSIX, ("%s: invalid vector %d", + device_get_nameunit(sc->dev), x)); + KASSERT(sc->hw.mac.type != ixgbe_mac_82598EB, + ("%s: invalid vector %d for 82598", + device_get_nameunit(sc->dev), x)); + *eims = IXGBE_EIMS_EX(1); + *eims_val = 1 << (x - 32); + } +} diff --git a/sys/dev/netif/ix/if_ix.h b/sys/dev/netif/ix/if_ix.h index c12fda9123..1127bb6f65 100644 --- a/sys/dev/netif/ix/if_ix.h +++ b/sys/dev/netif/ix/if_ix.h @@ -34,12 +34,25 @@ /* Tunables */ +/* + * MSI-X count + */ +#define IX_MAX_MSIX 64 +#define IX_MAX_MSIX_82598 16 + /* * RX ring count */ #define IX_MAX_RXRING 16 #define IX_MIN_RXRING_RSS 2 +/* + * TX ring count + */ +#define IX_MAX_TXRING_82598 32 +#define IX_MAX_TXRING_82599 64 +#define IX_MAX_TXRING_X540 64 + /* * Default number of segments received before writing to RX related registers */ @@ -123,8 +136,8 @@ #define IX_MAX_MCASTADDR 128 -#define MSIX_82598_BAR 3 -#define MSIX_82599_BAR 4 +#define IX_MSIX_BAR_82598 3 +#define IX_MSIX_BAR_82599 4 #define IX_TSO_SIZE (IP_MAXPACKET + \ sizeof(struct ether_vlan_header)) @@ -150,6 +163,8 @@ #define IX_RX1_INTR_MASK (1 << IX_RX1_INTR_VEC) #define IX_INTR_RATE 8000 +#define IX_MSIX_RX_RATE 8000 +#define IX_MSIX_TX_RATE 6000 /* IOCTL define to gather SFP+ Diagnostic data */ #define SIOCGI2C SIOCGIFGENERIC @@ -157,6 +172,10 @@ /* TX checksum offload */ #define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP) +#define IX_EICR_STATUS (IXGBE_EICR_LSC | IXGBE_EICR_ECC | \ + IXGBE_EICR_GPI_SDP1 | IXGBE_EICR_GPI_SDP2 | \ + IXGBE_EICR_TS) + /* This is used to get SFP+ module data */ struct ix_i2c_req { uint8_t dev_addr; @@ -200,6 +219,8 @@ struct ix_tx_ring { uint16_t tx_nsegs; int16_t tx_intr_vec; int tx_intr_cpuid; + uint32_t tx_eims; + uint32_t tx_eims_val; struct ifsubq_watchdog tx_watchdog; bus_dma_tag_t tx_base_dtag; @@ -227,6 +248,9 @@ struct ix_rx_ring { uint16_t rx_mbuf_sz; uint16_t rx_wreg_nsegs; int16_t rx_intr_vec; + uint32_t rx_eims; + uint32_t rx_eims_val; + struct ix_tx_ring *rx_txr; /* piggybacked TX ring */ #ifdef IX_RSS_DEBUG u_long rx_pkts; @@ -266,13 +290,11 @@ struct ix_softc { boolean_t link_active; - int tx_ring_cnt; + int rx_ring_inuse; int tx_ring_inuse; - struct ix_tx_ring *tx_rings; - int rx_ring_cnt; - int rx_ring_inuse; struct ix_rx_ring *rx_rings; + struct ix_tx_ring *tx_rings; struct callout timer; int timer_cpuid; @@ -285,6 +307,12 @@ struct ix_softc { struct ixgbe_hw_stats stats; + int rx_ring_cnt; + int rx_ring_msix; + + int tx_ring_cnt; + int tx_ring_msix; + int intr_type; int intr_cnt; struct ix_intr_data *intr_data; @@ -300,6 +328,9 @@ struct ix_softc { struct resource *mem_res; int mem_rid; + struct resource *msix_mem_res; + int msix_mem_rid; + int nserialize; struct lwkt_serialize **serializes; @@ -308,6 +339,7 @@ struct ix_softc { int if_flags; int advspeed; /* advertised link speeds */ uint16_t max_frame_size; + int16_t sts_msix_vec; /* status MSI-X vector */ #ifdef IX_RSS_DEBUG int rss_debug; -- 2.41.0 From 5658c3a22b90168a987c50dc40667ce902853abe Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Fri, 28 Feb 2014 19:40:11 +0800 Subject: [PATCH 08/16] x86_64/mwait: Fix sysctl node OID settings --- sys/platform/pc64/x86_64/machdep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/platform/pc64/x86_64/machdep.c b/sys/platform/pc64/x86_64/machdep.c index 50a1ebed60..a8626f99d4 100644 --- a/sys/platform/pc64/x86_64/machdep.c +++ b/sys/platform/pc64/x86_64/machdep.c @@ -190,8 +190,8 @@ SYSCTL_INT(_hw, OID_AUTO, cpu_mwait_spin, CTLFLAG_RD, &cpu_mwait_spin, 0, #define CPU_MWAIT_HINT_AUTO -1 /* C1 and C2 */ #define CPU_MWAIT_HINT_AUTODEEP -2 /* C3+ */ -SYSCTL_NODE(_machdep, 0, mwait, CTLFLAG_RW, 0, "MWAIT features"); -SYSCTL_NODE(_machdep_mwait, 0, CX, CTLFLAG_RW, 0, "MWAIT Cx settings"); +SYSCTL_NODE(_machdep, OID_AUTO, mwait, CTLFLAG_RW, 0, "MWAIT features"); +SYSCTL_NODE(_machdep_mwait, OID_AUTO, CX, CTLFLAG_RW, 0, "MWAIT Cx settings"); struct cpu_mwait_cx { int subcnt; -- 2.41.0 From 1a7bbca142a2a1d10c61db0e4b5d3230e8fc10a2 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Fri, 28 Feb 2014 14:04:50 +0100 Subject: [PATCH 09/16] kernel/nata - Fix a memory leak in ata-dma. --- sys/dev/disk/nata/ata-dma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/dev/disk/nata/ata-dma.c b/sys/dev/disk/nata/ata-dma.c index 1e1fe650b5..222c91e0d3 100644 --- a/sys/dev/disk/nata/ata-dma.c +++ b/sys/dev/disk/nata/ata-dma.c @@ -194,6 +194,8 @@ ata_dmafree(device_t dev) bus_dma_tag_destroy(ch->dma->dmatag); ch->dma->dmatag = NULL; } + if (ch->dma) + kfree(ch->dma, M_ATADMA); } static void -- 2.41.0 From 40fa28485e51267b667cffb3cc801ee93a20bc48 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Fri, 28 Feb 2014 14:16:02 +0100 Subject: [PATCH 10/16] kernel/natapci - Fix a NULL pointer dereference. - ata_devclass is NULL when no unit 0/1 is available or no legacy support has been detected. - device_add_child() populates ata_devclass via make_device() so do not try to get information out of it when NULL. Submitted-by: @dillon --- sys/dev/disk/nata/ata-pci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/dev/disk/nata/ata-pci.c b/sys/dev/disk/nata/ata-pci.c index ec4be4fced..6726d79d41 100644 --- a/sys/dev/disk/nata/ata-pci.c +++ b/sys/dev/disk/nata/ata-pci.c @@ -246,9 +246,11 @@ ata_pci_attach(device_t dev) continue; } /* XXX TGEN devclass_find_free_unit() implementation */ - while (freeunit < devclass_get_maxunit(ata_devclass) && - devclass_get_device(ata_devclass, freeunit) != NULL) - freeunit++; + if (ata_devclass) { + while (freeunit < devclass_get_maxunit(ata_devclass) && + devclass_get_device(ata_devclass, freeunit) != NULL) + freeunit++; + } device_add_child(dev, "ata", freeunit); } bus_generic_attach(dev); -- 2.41.0 From dd411e9531d7ed412fe8a5942cbb2991c29b9df4 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Sat, 1 Mar 2014 00:25:10 +0100 Subject: [PATCH 11/16] test - Testing 1 2 3 --- test/test/WRITEME | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test/WRITEME b/test/test/WRITEME index 24287baf5d..a41b7dcb8f 100644 --- a/test/test/WRITEME +++ b/test/test/WRITEME @@ -18,3 +18,5 @@ Noooooo. Yessss. Im here again. hmm... Meeew ! There is a black cat. + +Adun Toridas -- 2.41.0 From 7c979d69af6df55ea9e8179591d1220ba800e1c9 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sat, 1 Mar 2014 00:45:28 +0100 Subject: [PATCH 12/16] test --- test/test/README | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test/README b/test/test/README index 143d6e0840..4eac61025f 100644 --- a/test/test/README +++ b/test/test/README @@ -81,3 +81,4 @@ Dank dafuer. from xanadu1 from xanadu2 from orb +test -- 2.41.0 From 09a1276cb9d413937ce87b0b7986241e8d345964 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Sat, 1 Mar 2014 01:03:12 +0100 Subject: [PATCH 13/16] test again --- test/test/README | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test/README b/test/test/README index 4eac61025f..dd4af897a8 100644 --- a/test/test/README +++ b/test/test/README @@ -82,3 +82,4 @@ from xanadu1 from xanadu2 from orb test +again -- 2.41.0 From 020afcaab7558566ea81669b86d02f42e15cd3d7 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sat, 1 Mar 2014 12:10:33 +0100 Subject: [PATCH 14/16] kernel/ixgbe: Fix building kernels with IX_RSS_DEBUG in the config. --- sys/dev/netif/ix/if_ix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/netif/ix/if_ix.c b/sys/dev/netif/ix/if_ix.c index aca12df834..a65967ac69 100644 --- a/sys/dev/netif/ix/if_ix.c +++ b/sys/dev/netif/ix/if_ix.c @@ -3901,6 +3901,7 @@ ix_add_sysctl(struct ix_softc *sc) { #ifdef IX_RSS_DEBUG char node[32]; + int i; #endif sysctl_ctx_init(&sc->sysctl_ctx); -- 2.41.0 From 14075a68e0c6d2f7d920fec06751e277318c6d3c Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Sat, 1 Mar 2014 03:46:16 -0800 Subject: [PATCH 15/16] virtual/vcd - Adapt for DEVFS. - disk_setdiskinfo() call to completely configure the device. - This allows vcd(4) to work properly on vkernels. --- sys/dev/virtual/vkernel/cdrom/vcd.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sys/dev/virtual/vkernel/cdrom/vcd.c b/sys/dev/virtual/vkernel/cdrom/vcd.c index 261649b3bc..cecefa4485 100644 --- a/sys/dev/virtual/vkernel/cdrom/vcd.c +++ b/sys/dev/virtual/vkernel/cdrom/vcd.c @@ -77,6 +77,7 @@ vcdinit(void *dummy __unused) { struct vkdisk_info *dsk; struct vcd_softc *sc; + struct disk_info info; struct stat st; int i; @@ -100,6 +101,18 @@ vcdinit(void *dummy __unused) sc->dev = disk_create(sc->unit, &sc->disk, &vcd_ops); sc->dev->si_drv1 = sc; sc->dev->si_iosize_max = 256 * 1024; + + bzero(&info, sizeof(info)); + info.d_media_blksize = 2048; + info.d_media_blocks = st.st_size / info.d_media_blksize; + info.d_dsflags = DSO_ONESLICE | DSO_COMPATLABEL | DSO_COMPATPARTA | + DSO_RAWEXTENSIONS; + info.d_nheads = 1; + info.d_ncylinders = 1; + info.d_secpertrack = info.d_media_blocks; + info.d_secpercyl = info.d_secpertrack * info.d_nheads; + + disk_setdiskinfo(&sc->disk, &info); } } @@ -109,7 +122,6 @@ static int vcdopen(struct dev_open_args *ap) { struct vcd_softc *sc; - struct disk_info info; struct stat st; cdev_t dev; @@ -118,17 +130,6 @@ vcdopen(struct dev_open_args *ap) if (fstat(sc->fd, &st) < 0 || st.st_size == 0) return(ENXIO); - bzero(&info, sizeof(info)); - info.d_media_blksize = 2048; - info.d_media_blocks = st.st_size / info.d_media_blksize; - info.d_dsflags = DSO_ONESLICE | DSO_COMPATLABEL | DSO_COMPATPARTA | - DSO_RAWEXTENSIONS; - info.d_nheads = 1; - info.d_ncylinders = 1; - info.d_secpertrack = info.d_media_blocks; - info.d_secpercyl = info.d_secpertrack * info.d_nheads; - - disk_setdiskinfo(&sc->disk, &info); return(0); } -- 2.41.0 From 060fb3f5f68e87e8f51aeed5d4d5cfa7f59599ae Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Sat, 1 Mar 2014 03:54:54 -0800 Subject: [PATCH 16/16] vkernel - Use 'vcd0' by default. - This allow booting our ISO images directly. --- sys/platform/vkernel/platform/init.c | 2 +- sys/platform/vkernel64/platform/init.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/platform/vkernel/platform/init.c b/sys/platform/vkernel/platform/init.c index fc773ba3ce..bbb1643f61 100644 --- a/sys/platform/vkernel/platform/init.c +++ b/sys/platform/vkernel/platform/init.c @@ -848,7 +848,7 @@ init_disk(char *diskExp[], int diskFileNum, enum vkdisk_type type) if (DiskNum == 0) { if (type == VKD_CD) { - rootdevnames[0] = "cd9660:vcd0a"; + rootdevnames[0] = "cd9660:vcd0"; } else if (type == VKD_DISK) { rootdevnames[0] = "ufs:vkd0s0a"; rootdevnames[1] = "ufs:vkd0s1a"; diff --git a/sys/platform/vkernel64/platform/init.c b/sys/platform/vkernel64/platform/init.c index 29fd11433b..d27d2a487e 100644 --- a/sys/platform/vkernel64/platform/init.c +++ b/sys/platform/vkernel64/platform/init.c @@ -974,7 +974,7 @@ init_disk(char *diskExp[], int diskFileNum, enum vkdisk_type type) if (DiskNum == 0) { if (type == VKD_CD) { - rootdevnames[0] = "cd9660:vcd0a"; + rootdevnames[0] = "cd9660:vcd0"; } else if (type == VKD_DISK) { rootdevnames[0] = "ufs:vkd0s0a"; rootdevnames[1] = "ufs:vkd0s1a"; -- 2.41.0