Commit graph

66026 commits

Author SHA1 Message Date
Alexander Motin 9c10d11388 Fix bundle xmit octets stats for packet-split operation mode. 2008-01-23 11:47:09 +00:00
Maxim Konovalov ff7aea9b97 o Add boot, gdb, nfsserver and opencrypto dirs to CSCOPEDIRS; sort. 2008-01-23 08:50:34 +00:00
Jeff Roberson 317da70593 - sched_prio() should only adjust tdq_lowpri if the thread is running or on
a run-queue.  If the priority is numerically raised only change lowpri
   if we're certain it will be correct.  Some slop is allowed however
   previously we could erroneously raise lowpri for an idle cpu that a
   thread had recently run on which lead to errors in load balancing
   decisions.
2008-01-23 03:10:18 +00:00
Andrey A. Chernov 0a8390f726 Bump FreeBSD_version after adding "ASCII" encoding to libc 2008-01-23 00:04:18 +00:00
Andrew Gallatin b0f7b92207 Take advantage of the new physically contiguous 9K jumbos in 8. 2008-01-22 22:04:31 +00:00
Robert Watson 9d3e5c0e2b Put "coda_rdwr: Internally Opening" printf generated by in-kernel writes
to files, such as ktrace output, under CODA_VERBOSE.  Otherwise, each
such call to VOP_WRITE() results in a kernel printf.

MFC after:	3 days
Obtained from:	NetBSD
2008-01-21 21:39:08 +00:00
Robert Watson e866951b59 Replace references to VOP_LOCK() w/o LK_RETRY to vn_lock() with LK_RETRY,
avoiding extra error handling, or in some cases, missing error handling.

MFC after:	3 days
Discussed with:	kib
2008-01-21 21:19:07 +00:00
Ruslan Ermilov 7716c3a1f9 Add copyrights.
PR:	119136
2008-01-21 13:26:33 +00:00
Pyun YongHyeon 9a508b89dc Fix build. 2008-01-21 09:51:28 +00:00
Pyun YongHyeon 23f7072d31 Uncomment sf(4), sf(4) should work on all architectures. 2008-01-21 06:51:25 +00:00
Pyun YongHyeon f2ff94851b Overhaul sf(4) to make it run on all architectures and implement
checksum offoload by downloading AIC-6915 firmware. Changes are
 o Header file cleanup.
 o Simplified probe logic.
 o s/u_int{8,16,32}_t/uint{8,16,32}_t/g
 o K&R -> ANSI C.
 o In register access function, added support both memory mapped and
   IO space register acccess. The function will dynamically detect
   which method would be choosed.
 o sf_setperf() was modified to support strict-alignment
   architectures.
 o Use SF_MII_DATAPORT instead of hardcoded value 0xffff.
 o Added link state/speed, duplex changes handling task q. The task q
   is also responsible for flow control settings.
 o Always hornor link up/down state reported by mii layers. The link
   state information is used in sf_start() to determine whether we
   got a valid link.
 o Added experimental flow-control setup. It was commented out but
   will be activated once we have flow-cotrol infrastructure in mii
   layer.
 o Simplify IFF_UP/IFCAP_POLLING and IFF_PROMISC handling logic. Rx
   filter always honors promiscuous mode.
 o Implemented suspend/resume methods.
 o Reorganized Rx filter routine so promiscuous mode changes doesn't
   require interface re-initialization.
 o Reimplemnted driver probe routine such that it looks for matching
   device from supported hardware list table. This change will help to
   add newer hardware revision to the driver.
 o Use ETHER_ADDR_LEN instead of hardcoded value.
 o Prefer memory space register mapping over I/O space as the hardware
   requires lots of register access to get various consumer/producer
   index. Failing to get memory space mapping, sf(4) falls back to I/O
   space mapping. Use of memory space register mapping requires
   somewhat large memory space(512K), though.
 o Switch to simpler bus_{read,write}_{1,2,4}.
 o Use PCIR_BAR macro to get BARs.
 o Program PCI cache line size if the cache line size was set to 0
   and enable PCI MWI.
 o Add a new sysctl node 'dev.sf.N.stats' that shows various MAC
   counters for Rx/Tx statistics.
 o Add a sysctl node to configure interrupt moderation timer. The
   timer defers interrupts generation until time specified in timer
   control register is expired. The value in the timer register is in
   units of 102.4us. The allowable range for the timer is 0 - 31
   (0 ~ 3.276ms).
   The default value is 1(102.4us). Users can change the timer value
   with dev.sf.N.int_mod sysctl(8) variable/loader(8) tunable.
 o bus_dma(9) conversion
    - Enable 64bit DMA addressing.
    - Enable 64bit descriptor format support.
    - Apply descriptor ring alignment requirements(256 bytes alignment).
    - Apply Rx buffer address alignment requirements(4 bytes alignment).
    - Apply 4GB boundary restrictions(Tx/Rx ring and its completion ring
      should live in the same 4GB address space.)
    - Set number of allowable number of DMA segments to 16. In fact,
      AIC-6915 doesn't have a limit for number of DMA segments but it
      would be waste of Tx descriptor resource if we allow more than 16.
    - Rx/Tx side bus_dmamap_load_mbuf_sg(9) support.
    - Added alignment fixup code for strict-alignment architectures.
    - Added endianness support code in Tx/Rx descriptor access.
    With these changes sf(4) should work on all platforms.
 o Don't set if_mtu in device attach, it's handled in ether_ifattach.
 o Use our own callout to drive watchdog timer.
 o Enable VLAN oversized frames and announce sf(4)'s VLAN capability
   to upper layer.
 o In sf_detach(), remove mtx_initialized KASSERT as it's not possible
   to get there without initialzing the mutex. Also mark that we're
   about to detaching so active bpf listeners do not panic the system.
 o To reduce PCI register access cycles, Rx completion ring is
   directly scanned instead of reading consumer/producer index
   registers. In theory, Tx completion ring also can be directly
   scanned. However the completion ring is composed of two types
   completion(1 for Tx done and 1 and DMA done). So reading producer
   index via register access would be more safer way to detect the
   ring wrap-around.
 o In sf_rxeof(), don't use m_devget(9) to align recevied frames. The
   alignment is required only for strict-alignment architectures and
   now the alignment is handled by sf_fixup_rx() if required. The
   removal of the copy operation in fast path should increase Rx
   performance a lot on non-strict-alignemnt architectures such as
   i386 and amd64.
 o In sf_newbuf(), don't set descriptor valid bit as sf(4) is
   programmed to run with normal mode. In normal mode, the valid bit
   have no meaning. The valid bit should be used only when the
   hardware uses polling(prefetch) mode. The end of descriptor queue
   bit could be used if needed, but sf(4) relys on auto-wrapping of
   hardware on 256 descriptor queue entries so both valid and
   descriptor end bit are not used anymore.
 o Don't disable generation of Tx DMA completion as said in datasheet
   and use the Tx DMA completion entry instead of relying on Tx done
   completion entry. Also added additional Tx completion entry type
   check in Tx completion handler.
 o Don't blindly reset watchdog timer in sf_txeof(). sf(4) now unarm
   the the watchdog only if there are no active Tx descriptors in Tx
   queue.
 o Don't manually update various counters in driver, instead, use
   built-in MAC statistic registers to update them. The statistic
   registers are updated in every second.
 o Modified Tx underrun handlers to increase the threshold value
   in units of 256 bytes. Previously it used to increase 16 bytes
   at a time which seems to take too long to stabalize whenever Tx
   underrun occurrs.
 o In interrupt handler, additional check for the interrupt is
   performed such that interrupts only for this device is allowed to
   process descriptor rings. Because reading SF_ISR register clears
   all interrtups, nuke writing to a SF_ISR register.
 o Tx underrun is abonormal condition and SF_ISR_ABNORMALINTR includes
   the interrupt. So there is no need to inspect the Tx underrun again
   in main interrupt loop.
 o Don't blindly reinitialize hardware for abnormal interrupt
   condition. sf(4) reintializes the hardware only when it encounters
   DMA error which requires an explicit hardware reinitialization.
 o Fix a long standing bug that incorrectly clears MAC statistic
   registers in sf_init_locked.
 o Added strict-alignment safe way of ethernet address reprogramming
   as IF_LLADDR may return unaligned address.
 o Move sf_reset() to sf_init_locked in order to always reset the
   hardware to a known state prior to configuring hardware.
 o Set default Rx DMA, Tx DMA paramters as shown in datasheet.
 o Enable PCI busmaster logic and autopadding for VLAN frames.
 o Rework sf_encap.
     - Previously sf(4) used to type 0 of Tx descriptor with padding
       enabled to store driver private data. Emebedding private data
       structures into descriptors is bad idea as the structure size
       would be different between 64bit and 32bit architectures. The
       type 0 descriptor allows fixed number of DMA segments in
       a descriptor format and provides relatively simple interface to
       manage multi-fragmented frames.
       However, it wastes lots of Tx descriptors as not all frames are
       fragmented as the number of allowable segments in a descriptor.
     - To overcome the limitation of type 0 descriptor, switch to type
       2 descriptor which allows 64bit DMA addressing and can handle
       unliumited number of fragmented DMA segments. The drawback of
       type 2 descriptor is in its complexity in managing descriptors
       as driver should handle the end of Tx ring manually.
    -  Manually set Tx desciptor queue end mark and record number of
       used descriptors to reclaim used descriptors in sf_txeof().
 o Rework sf_start.
     - Honor link up/down state before attempting transmission.
     - Because sf(4) uses only one of two Tx queues, use low priority
       queue instead of high one. This will remove one shift operation
       in each Tx kick command.
     - Cache last produder index into softc such that subsequenet Tx
       operation doesn't need to access producer index register.
 o Rewrote sf_stats_update to include all available MAC statistic
   counters.
 o Employ AIC-6915 firmware from Adaptec and implement firmware
   download routine and TCP/UDP checksum offload.
   Partial checksum offload support was commented out due to the
   possibility of firmware bug in RxGFP.
   The firmware can strip VLAN tag in Rx path but the lack of firmware
   assistance of VLAN tag insertion in transmit side made it useless
   on FreeBSD. Unlike checksum offload, FreeBSD requires both Tx/Rx
   hardware VLAN assistance capability. The firmware may also detect
   wakeup frame and can wake system up from states other than D0.
   However, the lack of wakeup support form D3cold state keep me from
   adding WOL capability. Also detecting WOL frame requires firmware
   support but it's not yet known to me whether the firmware can
   process the WOL frame.
 o Changed *_ADDR_HIADDR to *_ADDR_HI to match other definitions of
   registers.
 o Added definitioan to interrupt moderation related constants.
 o Redefined SF_INTRS to include Tx DMA done and DMA errors. Removed
   Tx done as it's not needed anymore.
 o Added definition for Rx/Tx DMA high priority threshold.
 o Nuked unused marco SF_IDX_LO, SF_IDX_HI.
 o Added complete MAC statistic register definition.
 o Modified sf_stats structure to hold all MAC statistic regiters.
 o Nuke various driver private padding data in Tx/Rx descriptor
   definition. sf(4) no longer requires private padding. Also remove
   unused padding related definitions. This greatly simplifies
   descriptor manipulation on 64bit architectures.
 o Becase we no longer pad driver private data into descriptor,
   remove deprecated/not-applicable comments for padding.
 o Redefine Rx/Tx desciptor status. sf(4) doesn't use bit fileds
   anymore to support endianness.

Tested by:	bruffer (initial version)
2008-01-21 06:38:23 +00:00
Pyun YongHyeon 0e24813a2e It seems that the firmware for TxGFP does not work at all. I could
be wrong but I couldn't find a way to make it work. In addition, the
number of TxGFP instruction does not match the firmware image size,
so I guess something was wrong when Adaptec generated the TxGFP
firmware from their DDK.

According to datasheet, normally, the first GFP instruction would be
opcode C, WaitForStartOfFrame, to synchronize checksumming with
incoming frame. But the first instruction in TxGFP firmware was
opcode 1, BrToImmIfTrue, so it could not process checksum correctly,
I guess. Checking for RxGFP firmware also indicates the first
instruction should be opcode C. Since the number of instructions in
TxGFP firmware lacks exactly one instruction, I prepended the opcode
C to TxGFP firmware image. With this change, the resulting image size
perfectly matches with the nummber of instructions and Tx checksum
offload seems to work without problems.
2008-01-21 05:09:07 +00:00
Pyun YongHyeon c5d7502930 Import AIC-6915 firmware for GFP from Adaptec.
Special thanks to bruffer to send the firmware image to me.

Submitted by:	gibbs via bruffer
2008-01-21 05:02:44 +00:00
Pyun YongHyeon 1171c67d01 sf(4) was repocopied to src/sys/dev/sf. 2008-01-21 04:45:58 +00:00
Pyun YongHyeon 6bf42daa74 Update file list and Makefile after repocopying sf(4) from
src/sys/pci to src/sys/dev.
2008-01-21 04:27:32 +00:00
Pyun YongHyeon 1dede5975a Forced commit to note that sf(4) was repocopied from sys/pci
and modified for its new location.
2008-01-21 04:23:47 +00:00
Robert Watson 20c6fe828a Regenerate. 2008-01-20 23:44:24 +00:00
Robert Watson 6c902059f2 Use audit events AUE_SHMOPEN and AUE_SHMUNLINK with new system calls
shm_open() and shm_unlink().  More auditing will need to be done for
these calls to capture arguments properly.
2008-01-20 23:43:06 +00:00
Robert Watson 07dd4a31b5 Export a type for POSIX SHM file descriptors via kern.proc.filedesc as
used by procstat, or SHM descriptors will show up as type unknown in
userspace.
2008-01-20 19:55:52 +00:00
Bjoern A. Zeeb ab569b9c05 Correct the commented out debugging printf()s in REPLACE and NEXT macros.
ip6_sprintf() needs a buffer as first argument these days.

MFC after:	2 weeks
2008-01-20 10:08:15 +00:00
Kip Macy 9619451708 Re-enable pcpu caching by default make sysctl R/W 2008-01-19 22:47:43 +00:00
David Schultz 2d6d5e1604 Correct the visibility macro surrounding SIGSYS.
Submitted by:	Andriy Gapon <avg@icyb.net.ua>
2008-01-19 21:41:31 +00:00
Robert Watson 9440b9f7ea Remove unused oldhash definition from Coda namecache.
MFC after:	3 days
2008-01-19 19:21:07 +00:00
Attilio Rao 6e8f9331d7 Bump FreeBSD_version in order to reflect introduction of
lockmgr_recursed(), BUF_RECURSED(), BUF_ISLOCKED() and trimming out of
BUF_REFCNT().
2008-01-19 17:39:25 +00:00
Attilio Rao d638e093d6 - Introduce the function lockmgr_recursed() which returns true if the
lockmgr lkp, when held in exclusive mode, is recursed
- Introduce the function BUF_RECURSED() which does the same for bufobj
  locks based on the top of lockmgr_recursed()
- Introduce the function BUF_ISLOCKED() which works like the counterpart
  VOP_ISLOCKED(9), showing the state of lockmgr linked with the bufobj

BUF_RECURSED() and BUF_ISLOCKED() entirely replace the usage of bogus
BUF_REFCNT() in a more explicative and SMP-compliant way.
This allows us to axe out BUF_REFCNT() and leaving the function
lockcount() totally unused in our stock kernel. Further commits will
axe lockcount() as well as part of lockmgr() cleanup.

KPI results, obviously, broken so further commits will update manpages
and freebsd version.

Tested by: kris (on UFS and NFS)
2008-01-19 17:36:23 +00:00
Robert Watson de5910460a Improve default vnode operation handling for Coda:
- Don't specify vnode operations for mknod, lease, and advlock--let them
  fall through to vop_default.

- Implement vop_default with &default_vnodeops, rather than with VOP_PANIC,
  so that unimplemented vnode operations are handled in more sensible ways
  than panicking, such as EOPNOTSUPP on ACL queries generated by bsdtar,
  or mknod.

MFC after:	3 days
2008-01-19 17:12:44 +00:00
Robert Watson aeab4f72a0 Rework coda_statfs(): no longer need to zero the statfs structure or
fill out all fields, just fill out the ones the file system knows
about.  Among other things, this causes the outpuf of "mount" and
"df" to make quite a bit more sense as /dev/cfs0 is specified as the
mountfrom name.

MFC after:	3 days
2008-01-19 16:39:14 +00:00
Robert Watson 82bf4517ef Zero mi_rotovp and coda_ctlvp immediately after calling vrele() on the
vnodes during coda_unmount() in order to detect errant use of them
after the vnode references may no longer be valid.

No need to clear the VV_ROOT flag on mi_rootvp flag (especially after
the vnode reference is no longer valid) as this isn't done on other
file systems.

MFC after:	3 days
2008-01-19 15:40:46 +00:00
Robert Watson 96b1e9b015 Don't acquire an additional vnode reference to a vnode when it is opened
and then release it when it is closed: we rely on the caller to keep the
vnode around with a valid reference.  This avoids vrele() destroying the
vnode vop_close() is being called from during a call to vop_close(), and
a crash due to lockmgr recursing the vnode lock when a Coda unmount
occurs.

MFC after:	3 days
2008-01-19 15:39:10 +00:00
Robert Watson 76898521e8 Don't declare functions as extern.
Move all extern variable definitions to associated .h files, move some
extern variable definitions between include files to place them more
appropriately.

MFC after:	3 days
2008-01-19 14:32:44 +00:00
Robert Watson 11cc4ab95a Use VOP_NULL rather than VOP_PANIC for Coda's vop_print routine, so as
to avoid panicking in DDB show lockedvnods.

MFC after:	3 days
2008-01-19 13:41:56 +00:00
Robert Watson d883e8e720 Lock the new directory vnode returned by coda_mkdir(), as this is required
by FreeBSD's vnode locking protocol.

MFC after:	3 days
2008-01-19 13:29:14 +00:00
Robert Watson 6885d70dfe Borrow the VM object associated with an underlying cache vnode with the
Coda vnode derived from it, in the style of nullfs.  This allows files
in the Coda file system to be memory-mapped, such as with execve(2) or
mmap(2).

MFC after:	3 days
Reported by:	Rune <u+openafsdev-sr55 at chalmers dot se>
2008-01-19 13:27:14 +00:00
Jung-uk Kim 86543395c1 Add a flag for Ethernet@WireSpeed capability and correct chip revisions.
The idea was taken from OpenBSD and cross-referenced with Linux driver.
2008-01-18 22:09:50 +00:00
Jung-uk Kim e4be3198af Fix mbuf pool watermark configuration (mismerged from OpenBSD in 1.132).
Submitted by:	sephe
MFC after:	3 days
2008-01-18 20:33:21 +00:00
Christian S.J. Peron 0f7e334a95 Fix gratuitous whitespace bug
MFC after:	1 week
Obtained from:	TrustedBSD Project
2008-01-18 19:57:21 +00:00
Christian S.J. Peron cd109a68ae Add a case for AUE_LISTEN. This removes the following console error message:
"BSM conversion requested for unknown event 43140"

It should be noted that we need to audit the fd argument for this system
call.

Obtained from:	TrustedBSD Project
MFC after:	1 week
2008-01-18 19:50:34 +00:00
Robert Watson 8c96f9c193 Move unlock of global UNIX domain socket lock slightly lower in
unp_connect(): it is expected to return with the lock held, and two
possible error paths otherwise returned with it unlocked.

The fix committed here is slightly different from the patch in the
PR, but along an alternative line suggested in the PR.

PR:		119778
MFC after:	3 days
Submitted by:	James Juran <james dot juran at baesystems dot com>
2008-01-18 19:16:03 +00:00
Konstantin Belousov 81aa963bc7 In the rev. 1.153, the one place for converting minor number to unit
was missed. As result, pty_create_slave() may index out of the names[]
bounds, creating wrong slave tty names.

Tested by:	kensmith
Reviewed by:	jhb
MFC after:	3 days
2008-01-18 18:07:04 +00:00
Remko Lodder af3e1b9f22 Use nfsrv_destroycache() only once, else it crashes the server.
PR:		kern/118152
Submitted by:	Bjoern Groenvall <bg at sics dot se>
Approved by:	imp (mentor, a while ago already), jhb
MFC After:	3 days
2008-01-18 17:03:36 +00:00
Julian Elischer ce3b9e3aea refactor code so it can run in a chroot without having to have /dev/mounted
MFC After: 1 week
2008-01-18 17:02:14 +00:00
Doug Ambrisko ecefd670f5 Style changes from avatar.
Submitted by:	avatar
2008-01-18 16:34:18 +00:00
Doug Ambrisko f0e1e8d9fb First real attempt at proper locking. The locking is a little complicated
since the the command and data that is being built to be sent to or read
from the HW lives in the softc.  Commands are later run via an_setdef etc.
In the ioctl path various references are kept to the data stored in
the softc so it needs to be protected.  Almost think of the command
in the softc a global variable since it essentially is.  Since locking
wasn't done in this type of context the commands would get corrupted.

Thanks to avatar@ for catching some lock issues and dhw@ for testing.

Things are a lot more stable except for the MPI-350 cards.  My an(4)
remote laptop stays on the network now.

The driver should be changed so that it uses private memory that is passed
to the functions that talk to the card.  Then only those functions would
really need to grab locks.

Reviewed by:	avatar@
2008-01-18 16:31:24 +00:00
David Xu 0e17ccbe36 Make sure reading td_runtime in critical section since thread may be
preempted and td_runtime will be modified.
2008-01-18 13:00:28 +00:00
Robert Watson 1e8f5ffa35 In tcp_ctloutput(), don't hold the inpcb lock over sooptcopyin(), rather,
drop the lock and then re-acquire it, revalidating TCP connection state
assumptions when we do so.  This avoids a potential lock order reversal
(and potential deadlock, although none have been reported) due to the
inpcb lock being held over a page fault.

MFC after:	1 week
PR:		102752
Reviewed by:	bz
Reported by:	Václav Haisman <v dot haisman at sh dot cvut dot cz>
2008-01-18 12:19:50 +00:00
Konstantin Belousov 61af195933 udf_vget() shall vgone() the vnode when the file_entry cannot be allocated
or read from the volume. Otherwise, half-constructed vnode could be found
later and cause panic when accessed.

PR:	118322
MFC after:	1 week
2008-01-18 12:09:54 +00:00
Andrew Thompson fdf229b124 Remove a chunk of duplicated code, test the destination address against the
bridge the same way we check member interfaces.
2008-01-18 09:34:09 +00:00
Pyun YongHyeon 7eb12306d6 Use m_collapse(9) to collapse mbuf chains instead of relying on
shortest possible chain of mbufs of m_defrag(9). What we want is
chains of mbufs that can be safely stored to a Tx descriptor which
can have up to STGE_MAXTXSEGS mbufs. The ethernet controller does
not need to align Tx buffers on 32bit boundary. So the use of
m_defrag(9) was waste of time.
2008-01-18 08:32:08 +00:00
David Xu 00d6ac63cd Add POSIX clock id CLOCK_THREAD_CPUTIME_ID, this can be used to measure
per-thread runtime in user code.
2008-01-18 07:04:42 +00:00
Andrew Thompson 905925d349 IEEE 802.1D-2004 states, frames containing any of the group MAC Addresses
specified in Table 7-10 in their destination address field shall not be relayed
by the Bridge. Add a check in bridge_forward() to adhere to this.

PR:		kern/119744
2008-01-18 00:19:10 +00:00